diff --git a/.github/workflows/stale-issues-safe.yml b/.github/workflows/stale-issues-safe.yml new file mode 100644 index 00000000000..c8139b37caf --- /dev/null +++ b/.github/workflows/stale-issues-safe.yml @@ -0,0 +1,24 @@ +# See syntax file on https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions +name: "Close stale issues (bugs and feature requests)" + +on: + schedule: + - cron: "0 21 * * *" + issue_comment: + types: [created] + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: DeMoorJasper/stale@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. This issue may be closed automatically by stale bot in 15 days (you should still be able to re-open it if required).' + stale-label: 'Issue Stale (automatic label)' + exempt-label: 'Priority High / Blocking' + days-before-stale: 365 + days-before-close: 15 + operations-per-run: 100 + dry-run: false + \ No newline at end of file diff --git a/.github/workflows/stale-issues.yml b/.github/workflows/stale-issues.yml index 633cc53437b..6e7dad5dc9b 100644 --- a/.github/workflows/stale-issues.yml +++ b/.github/workflows/stale-issues.yml @@ -12,12 +12,12 @@ jobs: - uses: Dolibarr/stale@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. Without comment, this issue will be closed automatically by stale bot in 15 days.' + stale-issue-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. This issue may be closed automatically by stale bot in 15 days (you should still be able to re-open it if required).' stale-issue-label: 'Issue Stale (automatic label)' exempt-issue-label: 'Priority High / Blocking' days-before-stale: 365 - days-before-close: 15 - operations-per-run: 50 + days-before-close: -1 + operations-per-run: 100 #stale-pr-message: 'This PR is stale because it has been open 1 year with no activity. If this PR is still mergeable (no conflict, nor Continuous Integration errors), please comment to confirm this merge is still expected. Without comment, this issue will be closed automatically by stale bot in 15 days.' stale-pr-label: 'PR Stale (automatic label)' stale-pr-message: diff --git a/.gitignore b/.gitignore index ffacba65feb..30151359365 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ htdocs/includes/sebastian/ htdocs/includes/squizlabs/ htdocs/includes/symfony/ htdocs/includes/webmozart/ +htdocs/.well-known/apple-developer-merchantid-domain-association diff --git a/COPYRIGHT b/COPYRIGHT index fe707c1d63d..09557f6520e 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -37,10 +37,11 @@ TCPDF 6.3.2 LGPL-3+ Yes TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement JS libraries: -Ace 1.4.6 BSD Yes JS library to get code syntaxique coloration in a textarea. +Ace 1.4.8 BSD Yes JS library to get code syntaxique coloration in a textarea. +Chart 2.9.3 MIT License Yes JS library for graph jQuery 3.4.1 MIT License Yes JS library jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI -jQuery select2 4.0.5 GPL and Apache License Yes JS library plugin for sexier multiselect +jQuery select2 4.0.13 GPL and Apache License Yes JS library plugin for sexier multiselect jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups) jQuery Colorpicker 1.1 MIT License Yes JS library for color picker for a defined list of colors jQuery Flot 0.8.3 MIT License Yes JS library to build graph diff --git a/ChangeLog b/ChangeLog index f7631b8dc5f..279fc01cfa8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,69 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 11.0.2 compared to 11.0.1 ***** +FIX: #10309 +FIX: #13110 +FIX: #13118 +FIX: #13124 +FIX: #13131 +FIX: #13135 +FIX: #13146 #13198 +FIX: #13175 +FIX: #13182 +FIX: #13183 +FIX: #13184 +FIX: #13263 +FIX: #13267 +FIX: an external user can not approve +FIX: API Get list of documents for supplier_invoice +FIX: API to push an expense report +FIX: API upload/download doc for expensereport +FIX: Avoid to download the export if we just press enter to refresh form +FIX: Bad link to template invoices +FIX: Bad sort link in accounting report +FIX: Bad translation for productlot EatBy and SellBy +FIX: better method to check user rights AND usergroup rights ! +FIX: CA by product list filter +FIX: CSS +FIX: Disable js if no javascript +FIX: duplicate class name into some log lines +FIX: etrafield with visibilty=5 were not in read only. +FIX: excess paid from situation invoices not counted when calculating remain to pay. +FIX: Force FEC export to txt format. +FIX: Free input for email no more visible. +FIX: Keep assigned users in session when loading projects and tasks +FIX: List of viewed projects too large in task widget. +FIX: Menu truncated. Add tooltip to have all content. +FIX: Missing field "billed" in export. +FIX: missing "statut" for getNomUrl() function +FIX: modFournisseur is required by modSupplierProposal +FIX: Multicompany compatibility +FIX: must be == and not = +FIX: option for topbar search and bookmarks +FIX: option MAIN_OPTIMIZEFORTEXTBROWSER +FIX: some responsive troubles +FIX: round MT in accountancy books +FIX: search with '0' +FIX: sort link +FIX: SQL Overload in default contact trigger. +FIX: SQl syntax error. +FIX: Submit of documents for supplier invoices. +FIX: timezone must be tzserver and not tzuser as on contract card +FIX: token in barcode tools page missing +FIX: Bad name of trigger PROPAL_SUPPLIER_TRIGGER, should be PROPOSAL_SUPPLIER_TRIGGER +FIX: Type of contact for event does not exists and not supported +FIX: Type of contact not saved when creating a contact +FIX: typo on ckeck method +FIX: undefined function measuringUnitString in product list +FIX: Usage of project not available in export. +FIX: wrong test +FIX: z-index for moretabsList with constant MAIN_MAXTABS_IN_CARD +FIX: Use GETPOST instead of POST +FIX: HTML Injection +FIX: Visualization rights correction on last modified contacts box. +FIX: Vulnerability in module from modulebuilder. +FIX: Vulnerability reported by code16 ***** ChangeLog for 12.0.0 compared to 11.0.0 ***** For Users: @@ -19,7 +82,8 @@ Following changes may create regressions for some external modules, but were nec with HTML content that you make a GETPOST('myparam', 'restricthtml') or GETPOST('myparam', 'none') if you really need posted content without sanitizing the HTML into content (in such a case, sanitize data later) * Removed hidden constant MAIN_EXTRAFIELDS_IN_ONE_TD that was useless. - +* Reference of object including a "/" are no more allowed. It is never used by default but to support setup that introduced it, the "/" will be replaced + by a "_" automatically when a reference is generated. ***** ChangeLog for 11.0.1 compared to 11.0.0 ***** FIX: advanced target emailing sql and ergonomy. diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index c0c3f835481..43dc3ccea67 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2019 Alexandre Spangaro + * Copyright (C) 2013-2020 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -54,19 +54,27 @@ $list_account_main = array ( $list_account = array (); $list_account[] = '---Product---'; -$list_account[] = 'ACCOUNTING_PRODUCT_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT'; if ($mysoc->isInEEC()) { $list_account[] = 'ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT'; } $list_account[] = 'ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT'; +$list_account[] = 'ACCOUNTING_PRODUCT_BUY_ACCOUNT'; +if ($mysoc->isInEEC()) { + $list_account[] = 'ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT'; +} +$list_account[] = 'ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT'; $list_account[] = '---Service---'; -$list_account[] = 'ACCOUNTING_SERVICE_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_SERVICE_SOLD_ACCOUNT'; if ($mysoc->isInEEC()) { $list_account[] = 'ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT'; } $list_account[] = 'ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT'; +$list_account[] = 'ACCOUNTING_SERVICE_BUY_ACCOUNT'; +if ($mysoc->isInEEC()) { + $list_account[] = 'ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT'; +} +$list_account[] = 'ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT'; $list_account[] = '---Other---'; $list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT'; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 60c9c88f0c8..6946f8df831 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2019 Alexandre Spangaro + * Copyright (C) 2013-2020 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) @@ -117,7 +117,9 @@ if ($action == 'update') { 'ACCOUNTANCY_SELL', 'ACCOUNTANCY_SELL_INTRA', 'ACCOUNTANCY_SELL_EXPORT', - 'ACCOUNTANCY_BUY' + 'ACCOUNTANCY_BUY', + 'ACCOUNTANCY_BUY_INTRA', + 'ACCOUNTANCY_BUY_EXPORT' ); if (in_array($accounting_product_mode, $accounting_product_modes)) { @@ -159,6 +161,12 @@ if ($action == 'update') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { $sql .= " SET accountancy_code_buy = ".$accounting->account_number; } + if ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + $sql .= " SET accountancy_code_buy_intra = ".$accounting->account_number; + } + if ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + $sql .= " SET accountancy_code_buy_export = ".$accounting->account_number; + } if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { $sql .= " SET accountancy_code_sell = ".$accounting->account_number; } @@ -204,7 +212,11 @@ $form = new FormAccounting($db); $accounting = new AccountingAccount($db); // TODO: we should need to check if result is already exists accountaccount rowid..... $aarowid_servbuy = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1); +$aarowid_servbuy_intra = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT, 1); +$aarowid_servbuy_export = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT, 1); $aarowid_prodbuy = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1); +$aarowid_prodbuy_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT, 1); +$aarowid_prodbuy_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT, 1); $aarowid_servsell = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1); $aarowid_servsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT, 1); $aarowid_servsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT, 1); @@ -213,7 +225,11 @@ $aarowid_prodsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_P $aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT, 1); $aacompta_servbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy_intra = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy_export = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodbuy_intra = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodbuy_export = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_servsell_intra = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_servsell_export = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); @@ -228,7 +244,8 @@ $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'p if (empty($pcgvercode)) $pcgvercode=$pcgverid; $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy,"; -$sql.= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,"; +$sql.= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; +$sql.= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; $sql.= " p.tms, p.fk_product_type as product_type,"; $sql.= " aa.rowid as aaid"; $sql.= " FROM " . MAIN_DB_PREFIX . "product as p"; @@ -236,6 +253,14 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { $sql.=" p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; } +elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') +{ + $sql.=" p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; +} +elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') +{ + $sql.=" p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; +} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { $sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; @@ -253,6 +278,14 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_buy", $search_current_account); } +} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_buy_intra", $search_current_account); + } +} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_buy_export", $search_current_account); + } } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_sell", $search_current_account); @@ -356,6 +389,13 @@ if ($result) print "\n"; print ' ' . $langs->trans('OptionModeProductBuy') . ''; print ''.$langs->trans('OptionModeProductBuyDesc')."\n"; + if ($mysoc->isInEEC()) + { + print ' ' . $langs->trans('OptionModeProductBuyIntra') . ''; + print '' . $langs->trans('OptionModeProductBuyDesc') . "\n"; + } + print ' ' . $langs->trans('OptionModeProductBuyExport') . ''; + print ''.$langs->trans('OptionModeProductBuyDesc')."\n"; print "\n"; print '
'; @@ -386,7 +426,7 @@ if ($result) print ''.$form->selectyesno('search_onsell', $search_onsell, 1, false, 1).''; } // On buy - elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { print ''.$form->selectyesno('search_onpurchase', $search_onpurchase, 1, false, 1).''; } // Current account @@ -416,10 +456,16 @@ if ($result) } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); $fieldtosortaccount="p.accountancy_code_sell_export"; - } else { - if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); $fieldtosortaccount="p.accountancy_code_buy"; - } + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount="p.accountancy_code_buy_intra"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount="p.accountancy_code_buy_export"; + } print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AssignDedicatedAccountingAccount"); $clickpitco=$form->showCheckAddButtons('checkforselect', 1); @@ -457,22 +503,22 @@ if ($result) $compta_prodsell_id = $aarowid_prodsell_export; } else { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_servsell; + $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_prodsell; } } else { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell; + $compta_prodsell_id = $aarowid_servsell; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell_intra; + $compta_prodsell_id = $aarowid_servsell_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell_export; + $compta_prodsell_id = $aarowid_servsell_export; } else { $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); @@ -482,11 +528,40 @@ if ($result) // Purchases if ($obj->product_type == 0) { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_prodbuy; - } else { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_servbuy; + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy; + } + elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy_intra; + } + elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy_export; + } + else { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy; + } + } + else { + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_servbuy; + } + elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_servbuy_intra; + } + elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_servbuy_export; + } + else { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_servbuy; + } } print ''; @@ -509,7 +584,7 @@ if ($result) if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') print ''.$product_static->getLibStatut(3, 0).''; - if ($accounting_product_mode == 'ACCOUNTANCY_BUY') + if ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') print ''.$product_static->getLibStatut(3, 1).''; // Current accounting account @@ -517,7 +592,13 @@ if ($result) if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { print length_accountg($obj->accountancy_code_buy); if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + print length_accountg($obj->accountancy_code_buy_intra); + if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + print length_accountg($obj->accountancy_code_buy_export); + if ($obj->accountancy_code_buy_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { print length_accountg($obj->accountancy_code_sell); if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { @@ -540,6 +621,26 @@ if ($result) if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); print ''; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + // Accounting account buy intra (In EEC) + print ''; + //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code + if (empty($defaultvalue)) $defaultvalue=$compta_prodbuy_intra; + $codesell=length_accountg($obj->accountancy_code_buy_intra); + //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); + if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + print ''; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + // Accounting account buy export (Out of EEC) + print ''; + //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code + if (empty($defaultvalue)) $defaultvalue=$compta_prodbuy_export; + $codesell=length_accountg($obj->accountancy_code_buy_export); + //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); + if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { // Accounting account sell print ''; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 58dbf20e7bf..bbc16fa08f9 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -271,7 +271,7 @@ if ($action != 'export_csv') $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."' GROUP BY t.numero_compte"; $resql = $db->query($sql); $nrows = $resql->num_rows; - $opening_balances = Array(); + $opening_balances = array(); for ($i = 0; $i < $nrows; $i++) { $arr = $resql->fetch_array(); $opening_balances["'".$arr['numero_compte']."'"] = $arr['opening_balance']; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index bd5b780a0b6..9b6ad2fbbb0 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -538,6 +539,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { */ $formother = new FormOther($db); +$formfile = new FormFile($db); $title_page = $langs->trans("Bookkeeping"); @@ -914,7 +916,69 @@ while ($i < min($num, $limit)) // Document ref if (!empty($arrayfields['t.doc_ref']['checked'])) { - print ''.$line->doc_ref.''; + if ($line->doc_type == 'customer_invoice') + { + $langs->loadLangs(array('bills')); + + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $objectstatic = new Facture($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'facture'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } + elseif ($line->doc_type == 'supplier_invoice') + { + $langs->loadLangs(array('bills')); + + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $objectstatic = new FactureFournisseur($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'invoice_supplier'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); + } + elseif ($line->doc_type == 'expense_report') + { + $langs->loadLangs(array('trips')); + + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $objectstatic = new ExpenseReport($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'expensereport'; + + $filename=dol_sanitizeFileName($line->doc_ref); + $filedir=$conf->expensereport->dir_output . '/' . dol_sanitizeFileName($line->doc_ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } + else + { + // Other type + } + + print ''; + + print ''; + // Picto + Ref + print '
'; + + if($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') + { + print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + print $documentlink; + } else { + print $line->doc_ref; + } + print '
'; + + print "\n"; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 71fce0be43a..ec193b2922a 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -66,7 +66,7 @@ if ($conf->accounting->enabled) $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) - $helpisexpanded = empty($resultboxes['boxactivated']); // If there is no widget, the tooltip help is expanded by default. + $helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default. $showtutorial = ''; if (!$helpisexpanded) @@ -222,10 +222,6 @@ if ($conf->accounting->enabled) $boxlist .= '
'; $boxlist .= '
'; - if (!empty($nbworkboardcount)) - { - $boxlist .= $boxwork; - } $boxlist .= $resultboxes['boxlista']; @@ -233,7 +229,6 @@ if ($conf->accounting->enabled) $boxlist .= '
'; - $boxlist .= $boxstat; $boxlist .= $resultboxes['boxlistb']; $boxlist .= '
'; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 3bc44698029..07877378ce1 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2020 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -119,8 +119,9 @@ if ($action == 'validatehistory') { // Supplier Invoice Lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; - $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; - $sql .= " aa.rowid as aarowid,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type,"; + $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export, p.tva_tx as tva_tx_prod,"; + $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.tva_intra"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; @@ -128,7 +129,9 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; @@ -157,16 +160,12 @@ if ($action == 'validatehistory') { $suggestedaccountingaccountfor = ''; } else { if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - //$objp->code_buy_p = $objp->code_buy_intra; - $objp->code_buy_p = $objp->code_buy; - //$objp->aarowid_suggest = $objp->aarowid_intra; - $objp->aarowid_suggest = $objp->aarowid; + $objp->code_buy_p = $objp->code_buy_intra; + $objp->aarowid_suggest = $objp->aarowid_intra; $suggestedaccountingaccountfor = 'eec'; } else { // Foreign sale - //$objp->code_buy_p = $objp->code_buy_export; - $objp->code_buy_p = $objp->code_buy; - //$objp->aarowid_suggest = $objp->aarowid_export; - $objp->aarowid_suggest = $objp->aarowid; + $objp->code_buy_p = $objp->code_buy_export; + $objp->aarowid_suggest = $objp->aarowid_export; $suggestedaccountingaccountfor = 'export'; } } diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index ecd41f2f9da..2c8ad2432a3 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2020 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent s @@ -211,7 +211,8 @@ if (empty($chartaccountcode)) $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; -$sql .= " aa.rowid as aarowid,"; +$sql .= " p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,"; +$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.tva_intra"; $parameters = array(); @@ -222,7 +223,9 @@ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; // Add search filter like @@ -414,7 +417,6 @@ if ($result) { // issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB ! $objp->code_buy_l = ''; $objp->code_buy_p = ''; - $objp->aarowid_suggest = ''; $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; @@ -426,28 +428,67 @@ if ($result) { $facturefourn_static->type = $objp->type; $code_buy_p_notset = ''; - $objp->aarowid_suggest = $objp->aarowid; + $objp->aarowid_suggest = ''; // Will be set later + $isBuyerInEEC = isInEEC($objp); + + $suggestedaccountingaccountbydefaultfor = ''; if ($objp->type_l == 1) { - $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : ''); - if ($objp->aarowid == '') - $objp->aarowid_suggest = $aarowid_s; + if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'eec'; + } else { // Foreign sale + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'export'; + } + } } elseif ($objp->type_l == 0) { - $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : ''); - if ($objp->aarowid == '') - $objp->aarowid_suggest = $aarowid_p; + if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'eec'; + } else { + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'export'; + } + } } - if ($objp->code_buy_l == -1) $objp->code_buy_l = ''; + if ($objp->code_sell_l == -1) $objp->code_sell_l = ''; - if (!empty($objp->code_buy)) { - $objp->code_buy_p = $objp->code_buy; // Code on product + // Search suggested account for product/service + $suggestedaccountingaccountfor = ''; + if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_buy_p = $objp->code_buy; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $objp->code_buy_p = $objp->code_buy_intra; + $objp->aarowid_suggest = $objp->aarowid_intra; + $suggestedaccountingaccountfor = 'eec'; + } else { // Foreign sale + $objp->code_buy_p = $objp->code_buy_export; + $objp->aarowid_suggest = $objp->aarowid_export; + $suggestedaccountingaccountfor = 'export'; + } + } + + if (! empty($objp->code_buy_p)) { + // Value was defined previously } else { $code_buy_p_notset = 'color:orange'; } if (empty($objp->code_buy_l) && empty($objp->code_buy_p)) $code_buy_p_notset = 'color:red'; - // $objp->code_buy_p is now code of product/service // $objp->code_buy_l is now default code of product/service + // $objp->code_buy_p is now code of product/service print ''; @@ -520,6 +561,21 @@ if ($result) { // Suggested accounting account print ''; $suggestedid = $objp->aarowid_suggest; + if (empty($suggestedid) && empty($objp->code_buy_p) && ! empty($objp->code_buy_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) + { + if (empty($accountingaccount_codetotid_cache[$objp->code_buy_l])) + { + $tmpaccount = new AccountingAccount($db); + $tmpaccount->fetch(0, $objp->code_buy_l, 1); + if ($tmpaccount->id > 0) { + $suggestedid = $tmpaccount->id; + } + $accountingaccount_codetotid_cache[$objp->code_buy_l] = $tmpaccount->id; + } + else { + $suggestedid = $accountingaccount_codetotid_cache[$objp->code_buy_l]; + } + } print $formaccounting->select_account($suggestedid, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); print ''; @@ -540,6 +596,9 @@ if ($result) { } else { print $db->error(); } +if ($db->type == 'mysqli') { + $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation +} // Add code to auto check the box when we select an account print ''."\n"; } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Build a graph using Chart library. Input when calling this method should be: + * $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB)); + * $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // or when there is n series to show for each x + * $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // Syntax deprecated + * $this->legend= array("Val1",...,"Valn"); // list of n series name + * $this->type = array('bars',...'lines', 'linesnopoint'); or array('pie') or array('polar') or array('piesemicircle'); + * $this->mode = 'depth' ??? + * $this->bgcolorgrid + * $this->datacolor + * $this->shownodatagraph + * + * @param string $file Image file name to use to save onto disk (also used as javascript unique id) + * @param string $fileurl Url path to show image if saved onto disk. Never used here. + * @return void + */ + private function draw_chart($file, $fileurl) + { + // phpcs:enable + global $conf, $langs; + + dol_syslog(get_class($this)."::draw_chart this->type=".join(',', $this->type)." this->MaxValue=".$this->MaxValue); + + if (empty($this->width) && empty($this->height)) + { + print 'Error width or height not set'; + return; + } + + $showlegend = $this->showlegend; + + $legends = array(); + $nblot = 0; + if (is_array($this->data)) { + foreach ($this->data as $valarray) // Loop on each x + { + $nblot = max($nblot, count($valarray) - 1); // -1 to remove legend + } + } + //var_dump($nblot); + if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING); + $firstlot = 0; + // Works with line but not with bars + //if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x + + $serie = array(); $arrayofgroupslegend = array(); + //var_dump($this->data); + + $i = $firstlot; + while ($i < $nblot) // Loop on each serie + { + $values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x (with x=0,1,2,...) + $serie[$i] = ""; + + // Fill array $values + $x = 0; + foreach ($this->data as $valarray) // Loop on each x + { + $legends[$x] = (array_key_exists('label', $valarray) ? $valarray['label'] : $valarray[0]); + $array_of_ykeys = array_keys($valarray); + $alabelexists = 1; + $tmpykey = explode('_', ($array_of_ykeys[$i+($alabelexists ? 1 : 0)]), 3); + if (! empty($tmpykey[2]) || $tmpykey[2] == '0') { // This is a 'Group by' array + $tmpvalue = (array_key_exists('y_'.$tmpykey[1].'_'.$tmpykey[2], $valarray) ? $valarray['y_'.$tmpykey[1].'_'.$tmpykey[2]] : $valarray[$i + 1]); + $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue : null); + $arrayofgroupslegend[$i] = array( + 'stacknum'=> $tmpykey[1], + 'legend' => $this->Legend[$tmpykey[1]], + 'legendwithgroup' => $this->Legend[$tmpykey[1]].' - '.$tmpykey[2] + ); + } else { + $tmpvalue = (array_key_exists('y_'.$i, $valarray) ? $valarray['y_'.$i] : $valarray[$i + 1]); + //var_dump($i.'_'.$x.'_'.$tmpvalue); + $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue : null); + } + $x++; + } + //var_dump($values); + $j = 0; + foreach ($values as $x => $y) { + if (isset($y)) { + $serie[$i] .= ($j > 0 ? ", " : "").$y; + } else { + $serie[$i] .= ($j > 0 ? ", " : "").'null'; + } + $j++; + } + + $values = null; // Free mem + $i++; + } + //var_dump($serie); + //var_dump($arrayofgroupslegend); + + $tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.')))); + + $this->stringtoshow = ''."\n"; + if (!empty($this->title)) $this->stringtoshow .= '
'.$this->title.'
'; + if (!empty($this->shownographyet)) + { + $this->stringtoshow .= '
'; + $this->stringtoshow .= '
'.$langs->trans("NotEnoughDataYet").'
'; + return; + } + + // Start the div that will contains all the graph + $dolxaxisvertical=''; + if (count($this->data) > 20) $dolxaxisvertical='dol-xaxis-vertical'; + // No height for the pie grah + $cssfordiv = 'dolgraphchart'; + if (isset($this->type[$firstlot])) $cssfordiv .= ' dolgraphchar'.$this->type[$firstlot]; + $this->stringtoshow .= '
'."\n"; + + $this->stringtoshow .= ''."\n"; + } + + /** * Output HTML string to total value * diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b31607c1d60..0db01a84656 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -202,7 +202,7 @@ class Form $ret .= ''; if (empty($notabletag)) $ret .= ''; if (empty($notabletag)) $ret .= ''; + + // Accountancy_code_buy_intra + if ($mysoc->isInEEC()) + { + print ''; + print ''; + } + + // Accountancy_code_buy_export + print ''; + print ''; } else // For external software { @@ -1299,6 +1333,19 @@ else print ''; print ''; + + // Accountancy_code_buy_intra + if ($mysoc->isInEEC()) + { + print ''; + print ''; + } + + // Accountancy_code_buy_export + print ''; + print ''; } print '
'; - if (preg_match('/^(string|email)/', $typeofdata)) + if (preg_match('/^(string|safehtmlstring|email)/', $typeofdata)) { $tmp = explode(':', $typeofdata); $ret .= ''; @@ -276,6 +276,7 @@ class Form if (preg_match('/^(email)/', $typeofdata)) $ret .= dol_print_email($value, 0, 0, 0, 0, 1); elseif (preg_match('/^(amount|numeric)/', $typeofdata)) $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : ''); elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) $ret .= dol_htmlentitiesbr($value); + elseif (preg_match('/^safehtmlstring/', $typeofdata)) $ret .= dol_string_onlythesehtmltags($value); elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret .= dol_print_date($value, 'day'); elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') $ret .= dol_print_date($value, 'dayhour'); elseif (preg_match('/^select;/', $typeofdata)) @@ -2906,7 +2907,7 @@ class Form $objp->fprice = $price_result; if ($objp->quantity >= 1) { - $objp->unitprice = $objp->fprice / $objp->quantity; + $objp->unitprice = $objp->fprice / $objp->quantity; // Replace dynamically unitprice } } } @@ -2973,7 +2974,7 @@ class Form if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt .= ' disabled'; if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) { - $opt .= ' pbq="'.$objp->idprodfournprice.'" data-pbq="'.$objp->idprodfournprice.'" data-pbqqty="'.$objp->quantity.'" data-pbqpercent="'.$objp->remise_percent.'"'; + $opt .= ' pbq="'.$objp->idprodfournprice.'" data-pbq="'.$objp->idprodfournprice.'" data-pbqqty="'.$objp->quantity.'" data-pbqup="'.$objp->unitprice.'" data-pbqpercent="'.$objp->remise_percent.'"'; } $opt .= ' data-html="'.dol_escape_htmltag($optlabel).'"'; $opt .= '>'; @@ -2988,7 +2989,7 @@ class Form // "key" value of json key array is used by jQuery automatically as selected value // "label" value of json key array is used by jQuery automatically as text for combo box $out .= $opt; - array_push($outarray, array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'qty'=>$outqty, 'discount'=>$outdiscount, 'type'=>$outtype, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'disabled'=>(empty($objp->idprodfournprice) ?true:false))); + array_push($outarray, array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'qty'=>$outqty, 'up'=>$objp->unitprice, 'discount'=>$outdiscount, 'type'=>$outtype, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'disabled'=>(empty($objp->idprodfournprice) ?true:false))); // Exemple of var_dump $outarray // array(1) {[0]=>array(6) {[key"]=>string(1) "2" ["value"]=>string(3) "ppp" // ["label"]=>string(76) "ppp (fff2) - ppp - 20,00 Euros/1unité (20,00 Euros/unité)" @@ -3507,7 +3508,7 @@ class Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of payment methods - * Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value but scope is all application, probably not what you want. + * Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value but scope is all application, probably not what you want. * * @param string $selected Id du mode de paiement pre-selectionne * @param string $htmlname Nom de la zone select @@ -5268,8 +5269,9 @@ class Form $disabled = false; $title = ''; if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj == "0") { - // Override/enable VAT for expense report regardless of global setting - needed if expense report used for business expenses - if (empty($conf->global->OVERRIDE_VAT_FOR_EXPENSE_REPORT)) + // Override/enable VAT for expense report regardless of global setting - needed if expense report used for business expenses instead + // of using supplier invoices (this is a very bad idea !) + if (empty($conf->global->EXPENSEREPORT_OVERRIDE_VAT)) { $title = ' title="'.$langs->trans('VATIsNotUsed').'"'; $disabled = true; diff --git a/htdocs/core/class/html.formcategory.class.php b/htdocs/core/class/html.formcategory.class.php new file mode 100644 index 00000000000..4dd8bed247b --- /dev/null +++ b/htdocs/core/class/html.formcategory.class.php @@ -0,0 +1,58 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/class/html.formcategory.class.php + * \ingroup core + * \brief File of class to build HTML component for category filtering + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + +class FormCategory extends Form +{ + /** + * Return a HTML filter box for a list filter view + * + * @param string $type The categorie type (e.g Categorie::TYPE_WAREHOUSE) + * @param Array $preSelected A list with the elements that should pre-selected + * @return string A HTML filter box (Note: selected results can get with GETPOST("search_category_".$type."_list")) + */ + public function getFilterBox($type, $preSelected) + { + // phpcs:enable + global $langs; + + if (empty($preSelected) || !is_array($preSelected)) + { + $preSelected = array(); + } + + $htmlName = "search_category_".$type."_list"; + + $categoryArray = $this->select_all_categories($type, "", "", 64, 0, 1); + $categoryArray[-2] = "- ".$langs->trans('NotCategorized')." -"; + + $filter = ''; + $filter .= '
'; + $filter .= $langs->trans('Categories').": "; + $filter .= Form::multiselectarray($htmlName, $categoryArray, $preSelected, 0, 0, "minwidth300"); + $filter .= "
"; + + return $filter; + } +} diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 0d0c0d74661..e084028b430 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -249,8 +249,7 @@ class FormCompany extends Form } } - if ((!empty($selected) && $selected == $obj->rowid) - || (empty($selected) && !empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) + if (!empty($selected) && $selected == $obj->rowid) { $out .= ''; } $out .= ''; - $out .= ''; + $out .= ''; } elseif ($typeinput == 'admin') { if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { $out .= ''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 238c3cad60a..d961cd20536 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1027,6 +1027,7 @@ class FormMail extends Form $out .= ' $(document).on("keypress", \'#mailform\', function (e) { /* Note this is called at every key pressed ! */ var code = e.keyCode || e.which; if (code == 13) { + console.log("Enter was intercepted and blocked"); e.preventDefault(); return false; } diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 3b5dbd664d6..829a3f9c72f 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1338,4 +1338,122 @@ class FormOther $resultautomanual .= ''."\n"; return $resultautomanual; } + + + /** + * Return HTML select list to select a group by field + * + * @param mixed $object Object analyzed + * @param array $search_groupby Array of preselected fields + * @param array $arrayofgroupby Array of groupby to fill + * @return string HTML string component + */ + public function selectGroupByField($object, $search_groupby, &$arrayofgroupby) + { + global $langs, $extrafields, $form; + + $YYYY=substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1); + $MM=substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1); + $DD=substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1); + $HH=substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1); + $MI=substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1); + $SS=substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1); + + foreach ($object->fields as $key => $val) { + if (!$val['measure']) { + if (in_array($key, array( + 'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams', + 'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) continue; + if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) continue; + if (isset($val['visible']) && !dol_eval($val['visible'], 1)) continue; + if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) continue; + if (preg_match('/^pass/', $key)) continue; + if (in_array($val['type'], array('html', 'text'))) continue; + if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { + $arrayofgroupby['t.'.$key.'-year'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.')', 'position' => $val['position'].'-y'); + $arrayofgroupby['t.'.$key.'-month'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => $val['position'].'-m'); + $arrayofgroupby['t.'.$key.'-day'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => $val['position'].'-d'); + } else { + $arrayofgroupby['t.'.$key] = array('label' => $langs->trans($val['label']), 'position' => (int) $val['position']); + } + } + } + // Add extrafields to Group by + if ($object->isextrafieldmanaged) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') continue; + if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) continue; + $arrayofgroupby['te.'.$key] = array('label' => $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key]); + } + } + + $arrayofgroupby = dol_sort_array($arrayofgroupby, 'position', 'asc', 0, 0, 1); + $arrayofgroupbylabel = array(); + foreach ($arrayofgroupby as $key => $val) { + $arrayofgroupbylabel[$key] = $val['label']; + } + $result = $form->selectarray('search_groupby', $arrayofgroupbylabel, $search_groupby, 1, 0, 0, '', 0, 0, 0, '', 'minwidth250', 1); + + return $result; + } + + /** + * Return HTML select list to select a group by field + * + * @param mixed $object Object analyzed + * @param array $search_xaxis Array of preselected fields + * @param array $arrayofxaxis Array of groupby to fill + * @return string HTML string component + */ + public function selectXAxisField($object, $search_xaxis, &$arrayofxaxis) + { + global $langs, $extrafields, $form; + + $YYYY=substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1); + $MM=substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1); + $DD=substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1); + $HH=substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1); + $MI=substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1); + $SS=substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1); + + + foreach ($object->fields as $key => $val) { + if (!$val['measure']) { + if (in_array($key, array( + 'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams', + 'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) continue; + if (isset($val['enabled']) && !dol_eval($val['enabled'], 1)) continue; + if (isset($val['visible']) && !dol_eval($val['visible'], 1)) continue; + if (preg_match('/^fk_/', $key) && !preg_match('/^fk_statu/', $key)) continue; + if (preg_match('/^pass/', $key)) continue; + if (in_array($val['type'], array('html', 'text'))) continue; + if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { + $arrayofxaxis['t.'.$key.'-year'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.')', 'position' => $val['position'].'-y'); + $arrayofxaxis['t.'.$key.'-month'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => $val['position'].'-m'); + $arrayofxaxis['t.'.$key.'-day'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => $val['position'].'-d'); + } else { + $arrayofxaxis['t.'.$key] = array('label' => $langs->trans($val['label']), 'position' => (int) $val['position']); + } + } + } + + // Add extrafields to X-Axis + if ($object->isextrafieldmanaged) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') continue; + if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) continue; + $arrayofxaxis['te.'.$key] = array('label' => $langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key]); + } + } + + $arrayofxaxis = dol_sort_array($arrayofxaxis, 'position', 'asc', 0, 0, 1); + + $arrayofxaxislabel = array(); + foreach ($arrayofxaxis as $key => $val) { + $arrayofxaxislabel[$key] = $val['label']; + } + $result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, 1, 0, 0, '', 0, 0, 0, '', 'minwidth250', 1); + + return $result; + } } diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index c4f10c69469..e0c19e300a3 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -269,13 +269,14 @@ abstract class Stats * * @param int $year Year * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) + * @param int $limit Limit * @return array Array of values */ - public function getAllByProductEntry($year, $cachedelay = 0) + public function getAllByProductEntry($year, $cachedelay = 0, $limit = 10) { global $conf,$user,$langs; - $datay=array(); + $data=array(); // Search into cache if (! empty($cachedelay)) @@ -313,7 +314,7 @@ abstract class Stats } else { - $data=$this->getAllByProduct($year); + $data = $this->getAllByProduct($year, $limit); // $data[$i][]=$datay[$year][$i][1]; // set yval for x=i } @@ -604,7 +605,6 @@ abstract class Stats global $langs; $result=array(); - $res=array(); dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 8307d010e52..2f2b44d6d79 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -282,7 +282,7 @@ class Translate * and split the rest until a line feed. * This is more efficient than fgets + explode + trim by a factor of ~2. */ - while ($line = fscanf($fp, "%[^= ]%*[ =]%[^\n]")) + while ($line = fscanf($fp, "%[^= ]%*[ =]%[^\n\r]")) { if (isset($line[1])) { diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 766e063e80c..b5379ef911b 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -28,10 +28,6 @@ if (!defined('USE_CUSTOME_REPORT_AS_INCLUDE')) { require '../main.inc.php'; - require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; - require_once DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"; - require_once DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php"; - require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"; // Get parameters $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... @@ -45,7 +41,14 @@ if (!defined('USE_CUSTOME_REPORT_AS_INCLUDE')) $search_filters = GETPOST('search_filters', 'array'); $search_measures = GETPOST('search_measures', 'array'); - $search_xaxis = GETPOST('search_xaxis', 'array'); + + //$search_xaxis = GETPOST('search_xaxis', 'array'); + if (GETPOST('search_xaxis', 'alpha') && GETPOST('search_xaxis', 'alpha') != '-1') $search_xaxis = array(GETPOST('search_xaxis', 'alpha')); + else $search_xaxis = array(); + //$search_groupby = GETPOST('search_groupby', 'array'); + if (GETPOST('search_groupby', 'alpha') && GETPOST('search_groupby', 'alpha') != '-1') $search_groupby = array(GETPOST('search_groupby', 'alpha')); + else $search_groupby = array(); + $search_yaxis = GETPOST('search_yaxis', 'array'); $search_graph = GETPOST('search_graph', 'none'); @@ -62,8 +65,14 @@ if (!defined('USE_CUSTOME_REPORT_AS_INCLUDE')) $diroutputmassaction = $conf->user->dir_temp.'/'.$user->id.'/customreport'; } +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"; + // Load traductions files requiredby by page -$langs->loadLangs(array("companies", "other", "exports")); +$langs->loadLangs(array("companies", "other", "exports", "sendings")); $extrafields = new ExtraFields($db); @@ -76,16 +85,18 @@ $object = null; $ObjectClassName = ''; // Objects available by default $arrayoftype = array( - 'thirdparty' => array('label' => 'ThirdParties', 'ObjectClassName' => 'Societe', 'enabled' => $conf->societe->enabled, 'ClassPath' => DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"), - 'contact' => array('label' => 'Contacts', 'ObjectClassName' => 'Contact', 'enabled' => $conf->societe->enabled, 'ClassPath' => DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"), - 'contract' => array('label' => 'Contracts', 'ObjectClassName' => 'Contrat', 'enabled' => $conf->contrat->enabled, 'ClassPath' => DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php", 'langs'=>'contract'), - 'invoice' => array('label' => 'Invoices', 'ObjectClassName' => 'Facture', 'enabled' => $conf->facture->enabled, 'ClassPath' => DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"), - 'invoice_template'=>array('label' => 'PredefinedInvoices', 'ObjectClassName' => 'FactureRec', 'enabled' => $conf->facture->enabled, 'ClassPath' => DOL_DOCUMENT_ROOT."/compta/class/facturerec.class.php", 'langs'=>'bills'), + 'thirdparty' => array('label' => 'ThirdParties', 'ObjectClassName' => 'Societe', 'enabled' => $conf->societe->enabled, 'ClassPath' => "/societe/class/societe.class.php"), + 'contact' => array('label' => 'Contacts', 'ObjectClassName' => 'Contact', 'enabled' => $conf->societe->enabled, 'ClassPath' => "/contact/class/contact.class.php"), + 'proposal' => array('label' => 'Proposals', 'ObjectClassName' => 'Propal', 'enabled' => $conf->propal->enabled, 'ClassPath' => "/comm/propal/class/propal.class.php"), + 'order' => array('label' => 'Orders', 'ObjectClassName' => 'Commande', 'enabled' => $conf->commande->enabled, 'ClassPath' => "/commande/class/commande.class.php"), + 'invoice' => array('label' => 'Invoices', 'ObjectClassName' => 'Facture', 'enabled' => $conf->facture->enabled, 'ClassPath' => "/compta/facture/class/facture.class.php"), + 'invoice_template'=>array('label' => 'PredefinedInvoices', 'ObjectClassName' => 'FactureRec', 'enabled' => $conf->facture->enabled, 'ClassPath' => "/compta/class/facturerec.class.php", 'langs'=>'bills'), + 'contract' => array('label' => 'Contracts', 'ObjectClassName' => 'Contrat', 'enabled' => $conf->contrat->enabled, 'ClassPath' => "/contrat/class/contrat.class.php", 'langs'=>'contract'), 'bom' => array('label' => 'BOM', 'ObjectClassName' => 'Bom', 'enabled' => $conf->bom->enabled), - 'mo' => array('label' => 'MO', 'ObjectClassName' => 'Mo', 'enabled' => $conf->mrp->enabled, 'ClassPath' => DOL_DOCUMENT_ROOT."/mrp/class/mo.class.php"), + 'mo' => array('label' => 'MO', 'ObjectClassName' => 'Mo', 'enabled' => $conf->mrp->enabled, 'ClassPath' => "/mrp/class/mo.class.php"), 'ticket' => array('label' => 'Ticket', 'ObjectClassName' => 'Ticket', 'enabled' => $conf->ticket->enabled), - 'member' => array('label' => 'Adherent', 'ObjectClassName' => 'Adherent', 'enabled' => $conf->adherent->enabled, 'ClassPath' => DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php", 'langs'=>'members'), - 'cotisation' => array('label' => 'Subscriptions', 'ObjectClassName' => 'Subscription', 'enabled' => $conf->adherent->enabled, 'ClassPath' => DOL_DOCUMENT_ROOT."/adherents/class/subscription.class.php", 'langs'=>'members'), + 'member' => array('label' => 'Adherent', 'ObjectClassName' => 'Adherent', 'enabled' => $conf->adherent->enabled, 'ClassPath' => "/adherents/class/adherent.class.php", 'langs'=>'members'), + 'cotisation' => array('label' => 'Subscriptions', 'ObjectClassName' => 'Subscription', 'enabled' => $conf->adherent->enabled, 'ClassPath' => "/adherents/class/subscription.class.php", 'langs'=>'members'), ); // Complete $arrayoftype by external modules @@ -107,17 +118,14 @@ elseif (is_array($hookmanager->resArray)) { $arrayoftype[$key] = $val; } } - if (!empty($hookmanager->resArray['modenotusedforlist'])) { // Show objecttype selection even if objecttype is set - $modenotusedforlist = $hookmanager->resArray['modenotusedforlist']; - } } if ($objecttype) { try { - if ($arrayoftype[$objecttype]['ClassPath']) { - include_once $arrayoftype[$objecttype]['ClassPath']; + if (! empty($arrayoftype[$objecttype]['ClassPath'])) { + dol_include_once($arrayoftype[$objecttype]['ClassPath']); } else { - include_once DOL_DOCUMENT_ROOT."/".$objecttype."/class/".$objecttype.".class.php"; + dol_include_once("/".$objecttype."/class/".$objecttype.".class.php"); } $ObjectClassName = $arrayoftype[$objecttype]['ObjectClassName']; $object = new $ObjectClassName($db); @@ -134,6 +142,7 @@ if ($user->socid > 0) // Protection if external user //$socid = $user->socid; accessforbidden(); } + $result = restrictedArea($user, $object->element, 0, ''); // Fetch optionals attributes and labels @@ -144,6 +153,23 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen $search_component_params = array(''); +$MAXUNIQUEVALFORGROUP = 20; +$MAXMEASURESINBARGRAPH = 20; + +$YYYY=substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1).substr($langs->trans("Year"), 0, 1); +$MM=substr($langs->trans("Month"), 0, 1).substr($langs->trans("Month"), 0, 1); +$DD=substr($langs->trans("Day"), 0, 1).substr($langs->trans("Day"), 0, 1); +$HH=substr($langs->trans("Hour"), 0, 1).substr($langs->trans("Hour"), 0, 1); +$MI=substr($langs->trans("Minute"), 0, 1).substr($langs->trans("Minute"), 0, 1); +$SS=substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1); + +$arrayofmesures = array('t.count'=>'Count'); +$arrayofxaxis = array(); +$arrayofgroupby = array(); +$arrayofyaxis = array(); +$arrayofvaluesforgroupby = array(); + + /* * Actions @@ -158,6 +184,7 @@ $search_component_params = array(''); */ $form = new Form($db); +$formother = new FormOther($db); if (!defined('USE_CUSTOME_REPORT_AS_INCLUDE')) { llxHeader('', $langs->transnoentitiesnoconv('CustomReports'), ''); @@ -173,14 +200,89 @@ if ($action == 'viewgraph') { setEventMessages($langs->trans("OnlyOneFieldForXAxisIsPossible"), null, 'warnings'); $search_xaxis = array(0 => $search_xaxis[0]); } + if (count($search_groupby) >= 2) { + setEventMessages($langs->trans("ErrorOnlyOneFieldForGroupByIsPossible"), null, 'warnings'); + $search_groupby = array(0 => $search_groupby[0]); + } if (!count($search_xaxis)) { setEventMessages($langs->trans("AtLeastOneXAxisIsRequired"), null, 'warnings'); - } elseif ($mode == 'graph' && $search_graph == 'bars' && count($search_measures) > 3) { - setEventMessages($langs->trans("GraphInBarsAreLimitedTo3Measures"), null, 'warnings'); + } elseif ($mode == 'graph' && $search_graph == 'bars' && count($search_measures) > $MAXMEASURESINBARGRAPH) { + $langs->load("errors"); + setEventMessages($langs->trans("GraphInBarsAreLimitedToNMeasures", $MAXMEASURESINBARGRAPH), null, 'warnings'); $search_graph = 'lines'; } } +// Get all possible values of fields when a 'group by' is set and save this into $arrayofvaluesforgroupby +if (is_array($search_groupby) && count($search_groupby)) { + foreach($search_groupby as $gkey => $gval) { + $gvalwithoutprefix = preg_replace('/^[a-z]+\./', '', $gval); + + if (preg_match('/\-year$/', $search_groupby[$gkey])) { + $tmpval = preg_replace('/\-year$/', '', $search_groupby[$gkey]); + $fieldtocount .= 'DATE_FORMAT('.$tmpval.", '%Y')"; + } elseif (preg_match('/\-month$/', $search_groupby[$gkey])) { + $tmpval = preg_replace('/\-month$/', '', $search_groupby[$gkey]); + $fieldtocount .= 'DATE_FORMAT('.$tmpval.", '%Y-%m')"; + } elseif (preg_match('/\-day$/', $search_groupby[$gkey])) { + $tmpval = preg_replace('/\-day$/', '', $search_groupby[$gkey]); + $fieldtocount .= 'DATE_FORMAT('.$tmpval.", '%Y-%m-%d')"; + } else { + $fieldtocount = $search_groupby[$gkey]; + } + + $sql = 'SELECT DISTINCT '.$fieldtocount.' as val'; + if (strpos($fieldtocount, 'te.') === 0) { + $sql.= ' FROM '.MAIN_DB_PREFIX.$object->table_element.'_extrafields as te'; + } else { + $sql.= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t'; + } + // TODO Add the where here + + $sql.= ' LIMIT '.($MAXUNIQUEVALFORGROUP + 1); + + //print $sql; + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + } + + while ($obj = $db->fetch_object($resql)) { + if (is_null($obj->val)) { + $keytouse = '__NULL__'; + $valuetranslated = $langs->transnoentitiesnoconv("NotDefined"); + } + elseif ($obj->val === '') { + $keytouse = ''; + $valuetranslated = $langs->transnoentitiesnoconv("Empty"); + } + else { + $keytouse = (string) $obj->val; + $valuetranslated = $obj->val; + } + if (!empty($object->fields[$gvalwithoutprefix]['arrayofkeyval'])) { + $valuetranslated = $object->fields[$gvalwithoutprefix]['arrayofkeyval'][$obj->val]; + } + + $arrayofvaluesforgroupby['g_'.$gkey][$keytouse] = $valuetranslated; + } + asort($arrayofvaluesforgroupby['g_'.$gkey]); + + if (count($arrayofvaluesforgroupby['g_'.$gkey]) > $MAXUNIQUEVALFORGROUP) { + $langs->load("errors"); + //var_dump($gkey.' '.$gval.' '.$gvalwithoutprefix); + $gvalwithoutprefix = preg_replace('/\-(year|month|day)/', '', $gvalwithoutprefix); + $labeloffield = $langs->transnoentitiesnoconv($object->fields[$gvalwithoutprefix]['label']); + setEventMessages($langs->trans("ErrorTooManyDifferentValueForSelectedGroupBy", $MAXUNIQUEVALFORGROUP, $labeloffield), null, 'warnings'); + $search_groupby = array(); + } + + $db->free($resql); + } +} +//var_dump($arrayofvaluesforgroupby);exit; + + $tmparray = dol_getdate(dol_now()); $endyear = $tmparray['year']; $endmonth = $tmparray['mon']; @@ -189,10 +291,6 @@ $startyear = $endyear - 2; $param = ''; -$arrayofmesures = array('t.count'=>'Count'); -$arrayofxaxis = array(); -$arrayofyaxis = array(); - print '
'; print ''; print ''; @@ -212,7 +310,7 @@ foreach ($arrayoftype as $key => $val) { $langs->load($val['langs']); } } -print $form->selectarray('objecttype', $newarrayoftype, $objecttype, 0, 0, 0, '', 1, 0, 0, '', '', 1); +print $form->selectarray('objecttype', $newarrayoftype, $objecttype, 0, 0, 0, '', 1, 0, 0, '', 'minwidth200', 1); if (empty($conf->use_javascript_ajax)) print ''; else { print ''."\n"; } // Flot - if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT) && !defined('DISABLE_JQUERY_FLOT')) + if (empty($conf->global->MAIN_JS_GRAPH) || $conf->global->MAIN_JS_GRAPH == 'jflot') { - if (constant('JS_JQUERY_FLOT')) + if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT) && !defined('DISABLE_JQUERY_FLOT')) { - print ''."\n"; - print ''."\n"; - print ''."\n"; - } - else - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - /* Test for jflot 4.2 -> not better than current - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - */ + if (constant('JS_JQUERY_FLOT')) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + /* Test for jflot 4.2 -> not better than current + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + */ + } } } + // Chart + if ($conf->global->MAIN_JS_GRAPH == 'chart') + { + print ''."\n"; + } + // jQuery jeditable if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !defined('DISABLE_JQUERY_JEDITABLE')) { @@ -1915,17 +1924,22 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $("#topmenu-login-dropdown").removeClass("open"); } }); + '; - $("#topmenu-login-dropdown .dropdown-toggle").on("click", function(event) { - console.log("toggle login dropdown"); - event.preventDefault(); - $("#topmenu-login-dropdown").toggleClass("open"); - }); + if ($conf->theme != 'md') { + $btnUser .= ' + $("#topmenu-login-dropdown .dropdown-toggle").on("click", function(event) { + console.log("toggle login dropdown"); + event.preventDefault(); + $("#topmenu-login-dropdown").toggleClass("open"); + }); - $("#topmenuloginmoreinfo-btn").on("click", function() { - $("#topmenuloginmoreinfo").slideToggle(); - }); + $("#topmenuloginmoreinfo-btn").on("click", function() { + $("#topmenuloginmoreinfo").slideToggle(); + });'; + } + $btnUser .= ' }); '; diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index 45548c28312..9a7798d0091 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -279,5 +279,33 @@ class ActionsMyModule } + + /** + * Overloading the restrictedArea function : check permission on an object + * + * @param array $parameters Hook metadatas (context, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. + */ + public function restrictedArea($parameters, &$action, $hookmanager) + { + global $user; + + if ($parameters['features'] == 'myobject') { + if ($user->rights->mymodule->myobject->read) { + $this->results['result'] = 1; + return 1; + } else { + $this->results['result'] = 0; + return 1; + } + } + + return 0; + } + /* Add here any other hooked methods... */ } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index fe4cc0931fd..29fd1d99980 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -755,8 +755,8 @@ class MyObject extends CommonObject $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); @@ -765,8 +765,38 @@ class MyObject extends CommonObject $linkend = ''; $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + + if (empty($this->showphoto_on_popup)) { + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } else { + if ($withpicto) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity] . "/$class/" . dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if(!empty($filename)){ + $pospoint = strpos($filearray[0]['name'], '.'); + + $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint); + if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + $result .= '
No photo
'; + } + else { + $result .= '
No photo
'; + } + + $result .= ''; + } + else { + $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + } + } + } + if ($withpicto != 2) $result .= $this->ref; + $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index c4024a89c57..c83a0ff1aca 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1091,7 +1091,7 @@ class Mo extends CommonObject $statusType = 'status'.$status; if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; - if ($status == self::STATUS_INPROGRESS) $statusType = 'status3'; + if ($status == self::STATUS_INPROGRESS) $statusType = 'status4'; if ($status == self::STATUS_PRODUCED) $statusType = 'status6'; if ($status == self::STATUS_CANCELED) $statusType = 'status5'; diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index 26524b2df6d..c95eca30770 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -66,6 +66,7 @@ if ($conf->use_javascript_ajax) $sql= "SELECT COUNT(t.rowid) as nb, status"; $sql.=" FROM ".MAIN_DB_PREFIX."mrp_mo as t"; $sql.=" GROUP BY t.status"; + $sql.=" ORDER BY t.status ASC"; $resql = $db->query($sql); if ($resql) @@ -74,18 +75,24 @@ if ($conf->use_javascript_ajax) $i = 0; $totalnb=0; - $dataseries=array(); - // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) + $dataseries = array(); + $colorseries = array(); + + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) { - //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) - { - $dataseries[$obj->status]=array(0=>$staticmo->LibStatut($obj->status), $obj->nb); - $totalnb+=$obj->nb; - } + $dataseries[$obj->status]=array(0=>$staticmo->LibStatut($obj->status), $obj->nb); + if ($obj->status == Mo::STATUS_DRAFT) $coloseries[$obj->status] = '-'.$badgeStatus0; + if ($obj->status == Mo::STATUS_VALIDATED) $coloseries[$obj->status] = $badgeStatus1; + if ($obj->status == Mo::STATUS_INPROGRESS) $coloseries[$obj->status] = $badgeStatus4; + if ($obj->status == Mo::STATUS_PRODUCED) $coloseries[$obj->status] = $badgeStatus6; + if ($obj->status == Mo::STATUS_CANCELED) $coloseries[$obj->status] = '-'.$badgeStatus5; + + $totalnb+=$obj->nb; } $i++; } @@ -101,11 +108,11 @@ if ($conf->use_javascript_ajax) include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->SetDataColor(array_values($coloseries)); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); - $dolgraph->SetHeight(180); + $dolgraph->SetHeight('200'); $dolgraph->draw('idgraphstatus'); print $dolgraph->show($totalnb?0:1); diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 6cf45bf238b..a065cc922fe 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -621,7 +621,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (in_array($action, array('consumeorproduce', 'consumeandproduceall', 'addconsumeline'))) { - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f2c1b62f757..9c315591903 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2013-2016 Marcos García * Copyright (C) 2012-2013 Cédric Salvador - * Copyright (C) 2011-2017 Alexandre Spangaro + * Copyright (C) 2011-2020 Alexandre Spangaro * Copyright (C) 2014 Cédric Gross * Copyright (C) 2014-2015 Ferran Marcet * Copyright (C) 2015 Jean-François Ferry @@ -320,11 +320,15 @@ if (empty($reshook)) $accountancy_code_sell_intra = GETPOST('accountancy_code_sell_intra', 'alpha'); $accountancy_code_sell_export = GETPOST('accountancy_code_sell_export', 'alpha'); $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + $accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha'); + $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha'); if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } if ($accountancy_code_sell_intra <= 0) { $object->accountancy_code_sell_intra = ''; } else { $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; } if ($accountancy_code_sell_export <= 0) { $object->accountancy_code_sell_export = ''; } else { $object->accountancy_code_sell_export = $accountancy_code_sell_export; } if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } + if ($accountancy_code_buy_intra <= 0) { $object->accountancy_code_buy_intra = ''; } else { $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; } + if ($accountancy_code_buy_export <= 0) { $object->accountancy_code_buy_export = ''; } else { $object->accountancy_code_buy_export = $accountancy_code_buy_export; } // MultiPrix if (!empty($conf->global->PRODUIT_MULTIPRICES)) @@ -461,11 +465,15 @@ if (empty($reshook)) $accountancy_code_sell_intra = GETPOST('accountancy_code_sell_intra', 'alpha'); $accountancy_code_sell_export = GETPOST('accountancy_code_sell_export', 'alpha'); $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + $accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha'); + $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha'); if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } if ($accountancy_code_sell_intra <= 0) { $object->accountancy_code_sell_intra = ''; } else { $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; } if ($accountancy_code_sell_export <= 0) { $object->accountancy_code_sell_export = ''; } else { $object->accountancy_code_sell_export = $accountancy_code_sell_export; } if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } + if ($accountancy_code_buy_intra <= 0) { $object->accountancy_code_buy_intra = ''; } else { $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; } + if ($accountancy_code_buy_export <= 0) { $object->accountancy_code_buy_export = ''; } else { $object->accountancy_code_buy_export = $accountancy_code_buy_export; } // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -1274,6 +1282,32 @@ else print '
'; print $formaccounting->select_account(GETPOST('accountancy_code_buy', 'alpha'), 'accountancy_code_buy', 1, null, 1, 1, ''); print '
'.$langs->trans("ProductAccountancyBuyIntraCode").''; + if ($type == 0) { + $accountancy_code_buy_intra = (GETPOSTISSET('accountancy_code_buy_intra') ? GETPOST('accountancy_code_buy_intra', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT); + } else { + $accountancy_code_buy_intra = (GETPOSTISSET('accountancy_code_buy_intra') ? GETPOST('accountancy_code_buy_intra', 'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT); + } + print $formaccounting->select_account($accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, null, 1, 1, ''); + print '
'.$langs->trans("ProductAccountancyBuyExportCode").''; + if ($type == 0) + { + $accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT); + } else { + $accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT); + } + print $formaccounting->select_account($accountancy_code_buy_export, 'accountancy_code_buy_export', 1, null, 1, 1, ''); + print '
'.$langs->trans("ProductAccountancyBuyCode").''; print '
'.$langs->trans("ProductAccountancyBuyIntraCode").''; + print '
'.$langs->trans("ProductAccountancyBuyExportCode").''; + print '
'; @@ -1606,6 +1653,21 @@ else print ''; print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1); print ''; + + // Accountancy_code_buy_intra + if ($mysoc->isInEEC()) + { + print ''.$langs->trans("ProductAccountancyBuyIntraCode").''; + print ''; + print $formaccounting->select_account($object->accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, '', 1, 1); + print ''; + } + + // Accountancy_code_buy_export + print ''.$langs->trans("ProductAccountancyBuyExportCode").''; + print ''; + print $formaccounting->select_account($object->accountancy_code_buy_export, 'accountancy_code_buy_export', 1, '', 1, 1); + print ''; } else // For external software { @@ -1631,6 +1693,19 @@ else print ''.$langs->trans("ProductAccountancyBuyCode").''; print ''; print ''; + + // Accountancy_code_buy_intra + if ($mysoc->isInEEC()) + { + print ''.$langs->trans("ProductAccountancyBuyIntraCode").''; + print ''; + print ''; + } + + // Accountancy_code_buy_export + print ''.$langs->trans("ProductAccountancyBuyExportCode").''; + print ''; + print ''; } print ''; @@ -1812,6 +1887,45 @@ else } print ''; + // Accountancy buy code intra-community + if ($mysoc->isInEEC()) + { + print ''; + print $langs->trans("ProductAccountancyBuyIntraCode"); + print ''; + if (!empty($conf->accounting->enabled)) + { + if (!empty($object->accountancy_code_buy_intra)) + { + $accountingaccount5 = new AccountingAccount($db); + $accountingaccount5->fetch('', $object->accountancy_code_buy_intra, 1); + + print $accountingaccount5->getNomUrl(0, 1, 1, '', 1); + } + } else { + print $object->accountancy_code_buy_intra; + } + print ''; + } + + // Accountancy buy code export + print ''; + print $langs->trans("ProductAccountancyBuyExportCode"); + print ''; + if (!empty($conf->accounting->enabled)) + { + if (!empty($object->accountancy_code_buy_export)) + { + $accountingaccount6 = new AccountingAccount($db); + $accountingaccount6->fetch('', $object->accountancy_code_buy_export, 1); + + print $accountingaccount6->getNomUrl(0, 1, 1, '', 1); + } + } else { + print $object->accountancy_code_buy_export; + } + print ''; + // Batch number management (to batch) if (!empty($conf->productbatch->enabled)) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 6542190fbd2..30e1d48cd18 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013-2014 Cedric GROSS * Copyright (C) 2013-2016 Marcos García - * Copyright (C) 2011-2017 Alexandre Spangaro + * Copyright (C) 2011-2020 Alexandre Spangaro * Copyright (C) 2014 Henry Florian * Copyright (C) 2014-2016 Philippe Grand * Copyright (C) 2014 Ion agorria @@ -284,6 +284,8 @@ class Product extends CommonObject public $accountancy_code_sell_intra; public $accountancy_code_sell_export; public $accountancy_code_buy; + public $accountancy_code_buy_intra; + public $accountancy_code_buy_export; /** * Main Barcode value @@ -544,7 +546,9 @@ class Product extends CommonObject $price_min_ttc = price2num($this->price_min * (1 + ($this->tva_tx / 100)), 'MU'); } - $this->accountancy_code_buy = trim($this->accountancy_code_buy); + $this->accountancy_code_buy = trim($this->accountancy_code_buy); + $this->accountancy_code_buy_intra = trim($this->accountancy_code_buy_intra); + $this->accountancy_code_buy_export = trim($this->accountancy_code_buy_export); $this->accountancy_code_sell = trim($this->accountancy_code_sell); $this->accountancy_code_sell_intra = trim($this->accountancy_code_sell_intra); $this->accountancy_code_sell_export = trim($this->accountancy_code_sell_export); @@ -622,6 +626,8 @@ class Product extends CommonObject $sql .= ", tobuy"; $sql .= ", tosell"; $sql .= ", accountancy_code_buy"; + $sql .= ", accountancy_code_buy_intra"; + $sql .= ", accountancy_code_buy_export"; $sql .= ", accountancy_code_sell"; $sql .= ", accountancy_code_sell_intra"; $sql .= ", accountancy_code_sell_export"; @@ -645,6 +651,8 @@ class Product extends CommonObject $sql .= ", ".$this->status; $sql .= ", ".$this->status_buy; $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code_buy_intra)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code_buy_export)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code_sell_intra)."'"; $sql .= ", '".$this->db->escape($this->accountancy_code_sell_export)."'"; @@ -896,6 +904,8 @@ class Product extends CommonObject $this->barcode = trim($this->barcode); $this->accountancy_code_buy = trim($this->accountancy_code_buy); + $this->accountancy_code_buy_intra = trim($this->accountancy_code_buy_intra); + $this->accountancy_code_buy_export = trim($this->accountancy_code_buy_export); $this->accountancy_code_sell = trim($this->accountancy_code_sell); $this->accountancy_code_sell_intra = trim($this->accountancy_code_sell_intra); $this->accountancy_code_sell_export = trim($this->accountancy_code_sell_export); @@ -1010,6 +1020,8 @@ class Product extends CommonObject $sql .= ", note = ".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : 'null'); $sql .= ", duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."'"; $sql .= ", accountancy_code_buy = '".$this->db->escape($this->accountancy_code_buy)."'"; + $sql .= ", accountancy_code_buy_intra = '".$this->db->escape($this->accountancy_code_buy_intra)."'"; + $sql .= ", accountancy_code_buy_export = '".$this->db->escape($this->accountancy_code_buy_export)."'"; $sql .= ", accountancy_code_sell= '".$this->db->escape($this->accountancy_code_sell)."'"; $sql .= ", accountancy_code_sell_intra= '".$this->db->escape($this->accountancy_code_sell_intra)."'"; $sql .= ", accountancy_code_sell_export= '".$this->db->escape($this->accountancy_code_sell_export)."'"; @@ -1431,7 +1443,7 @@ class Product extends CommonObject * Sets an accountancy code for a product. * Also calls PRODUCT_MODIFY trigger when modified * - * @param string $type It can be 'buy', 'sell', 'sell_intra' or 'sell_export' + * @param string $type It can be 'buy', 'buy_intra', 'buy_export', 'sell', 'sell_intra' or 'sell_export' * @param string $value Accountancy code * @return int <0 KO >0 OK */ @@ -1443,7 +1455,11 @@ class Product extends CommonObject if ($type == 'buy') { $field = 'accountancy_code_buy'; - } elseif ($type == 'sell') { + } elseif ($type == 'buy_intra') { + $field = 'accountancy_code_buy_intra'; + } elseif ($type == 'buy_export') { + $field = 'accountancy_code_buy_export'; + } elseif ($type == 'sell') { $field = 'accountancy_code_sell'; } elseif ($type == 'sell_intra') { $field = 'accountancy_code_sell_intra'; @@ -2082,7 +2098,8 @@ class Product extends CommonObject $sql .= " tobuy, fk_product_type, duration, fk_default_warehouse, seuil_stock_alerte, canvas, net_measure, net_measure_units, weight, weight_units,"; $sql .= " length, length_units, width, width_units, height, height_units,"; $sql .= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; - $sql .= " accountancy_code_buy, accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,"; + $sql .= " accountancy_code_buy, accountancy_code_buy_intra, accountancy_code_buy_export,"; + $sql .= " accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,"; $sql .= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; $sql .= " fk_price_expression, price_autogen"; $sql .= " FROM ".MAIN_DB_PREFIX."product"; @@ -2163,10 +2180,12 @@ class Product extends CommonObject $this->barcode = $obj->barcode; $this->barcode_type = $obj->fk_barcode_type; - $this->accountancy_code_buy = $obj->accountancy_code_buy; - $this->accountancy_code_sell = $obj->accountancy_code_sell; - $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; - $this->accountancy_code_sell_export = $obj->accountancy_code_sell_export; + $this->accountancy_code_buy = $obj->accountancy_code_buy; + $this->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; + $this->accountancy_code_buy_export = $obj->accountancy_code_buy_export; + $this->accountancy_code_sell = $obj->accountancy_code_sell; + $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; + $this->accountancy_code_sell_export = $obj->accountancy_code_sell_export; $this->fk_default_warehouse = $obj->fk_default_warehouse; $this->seuil_stock_alerte = $obj->seuil_stock_alerte; @@ -4398,15 +4417,15 @@ class Product extends CommonObject if (!empty($conf->accounting->enabled) && $this->status) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { - $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_export); - $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_intra); - } + $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); + $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); } if (!empty($conf->accounting->enabled) && $this->status_buy) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); - } + $label .= '
'.$langs->trans('ProductAccountancyBuyIntraCode').': '.length_accountg($this->accountancy_code_buy_intra); + $label .= '
'.$langs->trans('ProductAccountancyBuyExportCode').': '.length_accountg($this->accountancy_code_buy_export); + } if (isset($this->status) && isset($this->status_buy)) { $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5, 0); $label .= ' '.$this->getLibStatut(5, 1); diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 49df2b36cc9..1c54d002be2 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -148,8 +148,8 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us { print '
'; print ''; - print ''; - print ''; + print ''; if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) print ''; // Accountancy code buy - if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) print ''; + if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) print ''; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook @@ -886,6 +901,12 @@ if ($resql) if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy", "", $param, '', $sortfield, $sortorder); } + if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) { + print_liste_field_titre($arrayfields['p.accountancy_code_buy_intra']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy_intra", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) { + print_liste_field_titre($arrayfields['p.accountancy_code_buy_export']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy_export", "", $param, '', $sortfield, $sortorder); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -950,6 +971,8 @@ if ($resql) $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; $product_static->accountancy_code_buy = $obj->accountancy_code_buy; + $product_static->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; + $product_static->accountancy_code_buy_export = $obj->accountancy_code_buy_export; $product_static->length = $obj->length; $product_static->length_units = $obj->length_units; $product_static->width = $obj->width; @@ -1306,6 +1329,16 @@ if ($resql) print ''; if (!$i) $totalarray['nbfield']++; } + if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index be244e32783..e2a30b51a87 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -355,6 +355,7 @@ if ($result || empty($id)) $px->SetYLabel($graphfiles[$key]['label']); $px->SetMaxValue($px->GetCeilMaxValue() < 0 ? 0 : $px->GetCeilMaxValue()); $px->SetMinValue($px->GetFloorMinValue() > 0 ? 0 : $px->GetFloorMinValue()); + $px->setShowLegend(0); $px->SetWidth($WIDTH); $px->SetHeight($HEIGHT); $px->SetHorizTickIncrement(1); diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 4299a1db53b..260929cd546 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -59,7 +59,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="c.date_commande"; -$search_month = GETPOST('search_month', 'aplha'); +$search_month = GETPOST('search_month', 'alpha'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index df6abec3d22..c854f8280ce 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -63,7 +63,7 @@ if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "c.date_commande"; -$search_month = GETPOST('search_month', 'aplha'); +$search_month = GETPOST('search_month', 'alpha'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 7bb784f5031..5ef97845338 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -61,7 +61,7 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="f.datef"; -$search_month = GETPOST('search_month', 'aplha'); +$search_month = GETPOST('search_month', 'alpha'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 34247393106..c8b085e8178 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -60,7 +60,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "f.datef"; -$search_month = GETPOST('search_month', 'aplha'); +$search_month = GETPOST('search_month', 'alpha'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 17e9c37158c..2355ecaed59 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -60,7 +60,7 @@ $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "p.datep"; -$search_month = GETPOST('search_month', 'aplha'); +$search_month = GETPOST('search_month', 'alpha'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index c344170e674..ad425249200 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -60,7 +60,7 @@ $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "p.date_valid"; -$search_month = GETPOST('search_month', 'aplha'); +$search_month = GETPOST('search_month', 'alpha'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 491f0979409..8f8ca7ad283 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -26,6 +27,12 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; + +if (!empty($conf->categorie->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} // Load translation files required by the page $langs->loadLangs(array("stocks", "other")); @@ -45,6 +52,11 @@ $search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("sear $search_label = GETPOST("snom", "alpha") ?GETPOST("snom", "alpha") : GETPOST("search_label", "alpha"); $search_status = GETPOST("search_status", "int"); +if (!empty($conf->categorie->enabled)) +{ + $search_category_list = GETPOST("search_category_".Categorie::TYPE_WAREHOUSE."_list", "array"); +} + // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); @@ -137,6 +149,7 @@ if (empty($reshook)) $search_status = ""; $toselect = ''; $search_array_options = array(); + $search_category_list = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) @@ -158,7 +171,7 @@ if (empty($reshook)) * View */ -$form = new Form($db); +$form = new FormCategory($db); $warehouse = new Entrepot($db); $now = dol_now(); @@ -183,10 +196,22 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as e"; + +if (!empty($conf->categorie->enabled)) +{ + $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_WAREHOUSE, "e.rowid"); +} + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; $sql .= " WHERE e.entity IN (".getEntity('stock').")"; + +if (!empty($conf->categorie->enabled)) +{ + $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_WAREHOUSE, "e.rowid", $search_category_list); +} + if ($search_ref) $sql .= natural_search("e.ref", $search_ref); // ref if ($search_label) $sql .= natural_search("e.lieu", $search_label); // label if ($search_status != '' && $search_status >= 0) $sql .= " AND e.statut = ".$search_status; @@ -313,6 +338,12 @@ if ($search_all) } $moreforfilter = ''; + +if (!empty($conf->categorie->enabled)) +{ + $moreforfilter .= $form->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list); +} + /*$moreforfilter.='
'; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '
';*/ diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index d80c7220866..a16b77b6667 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -546,7 +546,7 @@ if ($action == 'create' && $user->rights->projet->creer) print '
'; // Label - print ''; + print ''; // Usage (opp, task, bill time, ...) print ''; } - // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit', $parameters); - } + // Other attributes + $parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_create.tpl.php'; // Assign a sale representative print ''; @@ -2218,14 +2213,9 @@ else print ''; } - // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit', $parameters); - } + // Other attributes + $parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; // Webservices url/key if (!empty($conf->syncsupplierwebservices->enabled)) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a664fe21db2..5f7f297d55d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -134,7 +134,7 @@ class Societe extends CommonObject 'name_alias' =>array('type'=>'varchar(128)', 'label'=>'Name alias', 'enabled'=>1, 'visible'=>-1, 'position'=>36, 'showoncombobox'=>1), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>40, 'index'=>1), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>45), - 'ref_int' =>array('type'=>'varchar(60)', 'label'=>'Ref int', 'enabled'=>1, 'visible'=>-1, 'position'=>50), + 'ref_int' =>array('type'=>'varchar(60)', 'label'=>'Ref int', 'enabled'=>1, 'visible'=>0, 'position'=>50), // deprecated 'code_client' =>array('type'=>'varchar(24)', 'label'=>'Code client', 'enabled'=>1, 'visible'=>-1, 'position'=>55), 'code_fournisseur' =>array('type'=>'varchar(24)', 'label'=>'Code fournisseur', 'enabled'=>1, 'visible'=>-1, 'position'=>60), 'code_compta' =>array('type'=>'varchar(24)', 'label'=>'Code compta', 'enabled'=>1, 'visible'=>-1, 'position'=>65), @@ -625,13 +625,13 @@ class Societe extends CommonObject /** * @var string Internal ref + * @deprecated */ public $ref_int; /** * External user reference. - * This is to allow external systems to store their id and make self-developed synchronizing functions easier to - * build. + * This is to allow external systems to store their id and make self-developed synchronizing functions easier to build. * @var string */ public $ref_ext; @@ -1454,7 +1454,7 @@ class Societe extends CommonObject * @param int $rowid Id of third party to load * @param string $ref Reference of third party, name (Warning, this can return several records) * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr) - * @param string $ref_int Internal reference of third party (not used by dolibarr) + * @param string $notused Not used * @param string $idprof1 Prof id 1 of third party (Warning, this can return several records) * @param string $idprof2 Prof id 2 of third party (Warning, this can return several records) * @param string $idprof3 Prof id 3 of third party (Warning, this can return several records) @@ -1465,12 +1465,12 @@ class Societe extends CommonObject * @param string $ref_alias Name_alias of third party (Warning, this can return several records) * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. */ - public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') + public function fetch($rowid, $ref = '', $ref_ext = '', $notused = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') { global $langs; global $conf; - if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6) && empty($email)) return -1; + if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6) && empty($email)) return -1; $sql = 'SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm'; $sql .= ', s.status'; @@ -1515,7 +1515,7 @@ class Societe extends CommonObject if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; if ($ref_alias) $sql .= " AND s.name_alias = '".$this->db->escape($ref_alias)."'"; if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; + if ($notused) $sql .= " AND s.ref_int = '".$this->db->escape($notused)."'"; if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; if ($idprof2) $sql .= " AND s.siret = '".$this->db->escape($idprof2)."'"; if ($idprof3) $sql .= " AND s.ape = '".$this->db->escape($idprof3)."'"; diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 6ae3f0cac28..5b89c086c1f 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -112,10 +112,10 @@ if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); + $dolgraph->setHeight('200'); $dolgraph->draw('idgraphthirdparties'); print $dolgraph->show(); print ''."\n"; @@ -200,10 +200,10 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); + $dolgraph->setHeight('200'); $dolgraph->draw('idgraphcateg'); print $dolgraph->show(); } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 9402627e44a..a7860012740 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -542,7 +542,6 @@ $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($search_all != '') $param = "&sall=".urlencode($search_all); -if ($sall != '') $param .= "&sall=".urlencode($sall); if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); if ($search_categ_sup > 0) $param .= '&search_categ_sup='.urlencode($search_categ_sup); if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index afa8fcf4d77..0570b78bcdd 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1462,7 +1462,7 @@ class SupplierProposal extends CommonObject { $num = $this->ref; } - $this->newref = $num; + $this->newref = dol_sanitizeFileName($num); $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; $sql .= " SET ref = '".$this->db->escape($num)."',"; diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php index a6c95083410..57db269cc2e 100644 --- a/htdocs/supplier_proposal/index.php +++ b/htdocs/supplier_proposal/index.php @@ -144,10 +144,10 @@ if ($resql) include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); + $dolgraph->setHeight('200'); $dolgraph->draw('idgraphstatus'); print $dolgraph->show($total ? 0 : 1); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 02652da5875..fdd8609fd06 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -68,6 +68,11 @@ $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $search_montant_ht = GETPOST('search_montant_ht', 'alpha'); $search_montant_vat = GETPOST('search_montant_vat', 'alpha'); $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); +$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha'); +$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha'); +$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha'); +$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha'); +$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha'); $search_status = GETPOST('viewstatut', 'alpha') ?GETPOST('viewstatut', 'alpha') : GETPOST('search_status', 'int'); $object_statut = $db->escape(GETPOST('supplier_proposal_statut')); $search_btn = GETPOST('button_search', 'alpha'); @@ -148,6 +153,11 @@ $arrayfields = array( 'sp.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), 'sp.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), 'sp.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), + 'sp.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'sp.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'sp.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'sp.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'sp.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'u.login'=>array('label'=>$langs->trans("Author"), 'checked'=>1, 'position'=>10), 'sp.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'sp.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), @@ -191,6 +201,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_montant_ht = ''; $search_montant_vat = ''; $search_montant_ttc = ''; + $search_multicurrency_code = ''; + $search_multicurrency_tx = ''; + $search_multicurrency_montant_ht = ''; + $search_multicurrency_montant_vat = ''; + $search_multicurrency_montant_ttc = ''; $search_login = ''; $search_product_category = ''; $search_town = ''; @@ -245,6 +260,7 @@ $sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= ' sp.rowid, sp.note_private, sp.total_ht, sp.tva as total_vat, sp.total as total_ttc, sp.localtax1, sp.localtax2, sp.ref, sp.fk_statut, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,'; +$sql .= ' sp.fk_multicurrency, sp.multicurrency_code, sp.multicurrency_tx, sp.multicurrency_total_ht, sp.multicurrency_total_tva as multicurrency_total_vat, sp.multicurrency_total_ttc,'; $sql .= ' sp.datec as date_creation, sp.tms as date_update,'; $sql .= " p.rowid as project_id, p.ref as project_ref,"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,"; @@ -291,6 +307,11 @@ if ($search_author) $sql .= natural_search('u.login', $search_author); if ($search_montant_ht) $sql .= natural_search('sp.total_ht=', $search_montant_ht, 1); if ($search_montant_vat != '') $sql .= natural_search("sp.tva", $search_montant_vat, 1); if ($search_montant_ttc != '') $sql .= natural_search("sp.total", $search_montant_ttc, 1); +if ($search_multicurrency_code != '') $sql .= ' AND sp.multicurrency_code = "' . $db->escape($search_multicurrency_code) . '"'; +if ($search_multicurrency_tx != '') $sql .= natural_search('sp.multicurrency_tx', $search_multicurrency_tx, 1); +if ($search_multicurrency_montant_ht != '') $sql .= natural_search('sp.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); +if ($search_multicurrency_montant_vat != '') $sql .= natural_search('sp.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); +if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('sp.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($socid) $sql .= ' AND s.rowid = '.$socid; if ($search_status >= 0 && $search_status != '') $sql .= ' AND sp.fk_statut IN ('.$db->escape($search_status).')'; @@ -371,6 +392,11 @@ if ($resql) if ($search_user > 0) $param .= '&search_user='.$search_user; if ($search_sale > 0) $param .= '&search_sale='.$search_sale; if ($search_montant_ht) $param .= '&search_montant_ht='.$search_montant_ht; + if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); + if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); + if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); + if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); + if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); if ($search_author) $param .= '&search_author='.$search_author; if ($search_town) $param .= '&search_town='.$search_town; if ($search_zip) $param .= '&search_zip='.$search_zip; @@ -550,6 +576,41 @@ if ($resql) print ''; print ''; } + if (!empty($arrayfields['sp.multicurrency_code']['checked'])) + { + // Currency + print ''; + } + if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) + { + // Currency rate + print ''; + } + if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) + { + // Amount + print ''; + } if (!empty($arrayfields['u.login']['checked'])) { // Author @@ -604,6 +665,11 @@ if ($resql) if (!empty($arrayfields['sp.total_ht']['checked'])) print_liste_field_titre($arrayfields['sp.total_ht']['label'], $_SERVER["PHP_SELF"], 'sp.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['sp.total_vat']['checked'])) print_liste_field_titre($arrayfields['sp.total_vat']['label'], $_SERVER["PHP_SELF"], 'sp.total_vat', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['sp.total_ttc']['checked'])) print_liste_field_titre($arrayfields['sp.total_ttc']['label'], $_SERVER["PHP_SELF"], 'sp.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['sp.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_code', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_tx', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['sp.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'sp.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -764,6 +830,40 @@ if ($resql) $totalarray['val']['sp.total_ttc'] += $obj->total_ttc; } + // Currency + if (!empty($arrayfields['sp.multicurrency_code']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Currency rate + if (!empty($arrayfields['sp.multicurrency_tx']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount HT + if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount VAT + if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount TTC + if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + $userstatic->id=$obj->fk_user_author; $userstatic->login=$obj->login; diff --git a/htdocs/takepos/admin/other.php b/htdocs/takepos/admin/other.php index 383a710a47a..564b637d8e1 100644 --- a/htdocs/takepos/admin/other.php +++ b/htdocs/takepos/admin/other.php @@ -77,7 +77,6 @@ if (GETPOST('action', 'alpha') == 'set') { $res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_CUSTOM_RECEIPT", GETPOST('TAKEPOS_CUSTOM_RECEIPT', 'int'), 'int', 0, '', $conf->entity); //$res = dolibarr_set_const($db, "TAKEPOS_HEAD_BAR", GETPOST('TAKEPOS_HEAD_BAR', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); if (!empty($conf->global->TAKEPOS_ENABLE_SUMUP)) { diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 5b6fe25af44..fce4d6d324f 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php"; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // If socid provided by ajax company selector if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) @@ -78,8 +79,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_CUSTOM_RECEIPT", GETPOST('TAKEPOS_CUSTOM_RECEIPT', 'int'), 'int', 0, '', $conf->entity); - //$res = dolibarr_set_const($db, "TAKEPOS_HEAD_BAR", GETPOST('TAKEPOS_HEAD_BAR', 'int'), 'int', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_ADDON", GETPOST('TAKEPOS_ADDON', 'alpha'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); if (!empty($conf->global->TAKEPOS_ENABLE_SUMUP)) { $res = dolibarr_set_const($db, "TAKEPOS_SUMUP_AFFILIATE", GETPOST('TAKEPOS_SUMUP_AFFILIATE', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -175,7 +175,7 @@ print '\n"; @@ -201,6 +201,13 @@ $array = array(0=>$langs->trans("Numberspad"), 1=>$langs->trans("BillsCoinsPad") print $form->selectarray('TAKEPOS_NUMPAD', $array, (empty($conf->global->TAKEPOS_NUMPAD) ? '0' : $conf->global->TAKEPOS_NUMPAD), 0); print "\n"; +// Numpad use payment icons +print '\n"; + // Direct Payment print '\n"; +// Numbering module +print '\n"; + print '
'.$langs->trans("Statistics").'
'; + print '
'.$langs->trans("Statistics").'
'; $SommeA = $prodser[0]['sell']; $SommeB = $prodser[0]['buy']; @@ -174,16 +174,16 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us { $dataseries[] = array($langs->trans("ServicesOnSale"), round($SommeD)); $dataseries[] = array($langs->trans("ServicesOnPurchase"), round($SommeE)); - $dataseries[] = array($langs->trans("ServicesNotOnSell"), round($SommeF)); + $dataseries[] = array(dol_trunc($langs->trans("ServicesNotOnSell"), 24), round($SommeF)); } include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(0); $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); + $dolgraph->setHeight('200'); $dolgraph->draw('idgraphstatus'); print $dolgraph->show($total ? 0 : 1); @@ -241,10 +241,10 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); + $dolgraph->setHeight('200'); $dolgraph->draw('idstatscategproduct'); print $dolgraph->show($total ? 0 : 1); } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 252c3e214fa..ae89e4c558c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -11,6 +11,7 @@ * Copyright (C) 2013 Adolfo segura * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2020 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -69,6 +70,8 @@ $search_accountancy_code_sell = GETPOST("search_accountancy_code_sell", 'alpha') $search_accountancy_code_sell_intra = GETPOST("search_accountancy_code_sell_intra", 'alpha'); $search_accountancy_code_sell_export = GETPOST("search_accountancy_code_sell_export", 'alpha'); $search_accountancy_code_buy = GETPOST("search_accountancy_code_buy", 'alpha'); +$search_accountancy_code_buy_intra = GETPOST("search_accountancy_code_buy_intra", 'alpha'); +$search_accountancy_code_buy_export = GETPOST("search_accountancy_code_buy_export", 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $type = GETPOST("type", "int"); @@ -201,6 +204,8 @@ $arrayfields = array( 'p.accountancy_code_sell_intra'=>array('label'=>$langs->trans("ProductAccountancySellIntraCode"), 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401), 'p.accountancy_code_sell_export'=>array('label'=>$langs->trans("ProductAccountancySellExportCode"), 'checked'=>0, 'position'=>402), 'p.accountancy_code_buy'=>array('label'=>$langs->trans("ProductAccountancyBuyCode"), 'checked'=>0, 'position'=>403), + 'p.accountancy_code_buy_intra'=>array('label'=>$langs->trans("ProductAccountancyBuyIntraCode"), 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>404), + 'p.accountancy_code_buy_export'=>array('label'=>$langs->trans("ProductAccountancyBuyExportCode"), 'checked'=>0, 'position'=>405), 'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'p.tosell'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Sell").')', 'checked'=>1, 'position'=>1000), @@ -256,6 +261,8 @@ if (empty($reshook)) $search_accountancy_code_sell_intra = ''; $search_accountancy_code_sell_export = ''; $search_accountancy_code_buy = ''; + $search_accountancy_code_buy_intra = ''; + $search_accountancy_code_buy_export = ''; $search_array_options = array(); } @@ -297,7 +304,8 @@ else $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type, p.entity,'; $sql .= ' p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; -$sql .= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,'; +$sql .= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,'; +$sql .= ' p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,'; $sql .= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock,'; $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units,'; if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ' p.fk_unit, cu.label as cu_label,'; @@ -378,6 +386,8 @@ if ($search_accountancy_code_sell) $sql .= natural_search('p.accountancy_ if ($search_accountancy_code_sell_intra) $sql .= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); if ($search_accountancy_code_sell_export) $sql .= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export); if ($search_accountancy_code_buy) $sql .= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); +if ($search_accountancy_code_buy_intra) $sql .= natural_search('p.accountancy_code_buy_intra', $search_accountancy_code_buy_intra); +if ($search_accountancy_code_buy_export) $sql .= natural_search('p.accountancy_code_buy_export', $search_accountancy_code_buy_export); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -387,7 +397,8 @@ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // No $sql .= $hookmanager->resPrint; $sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type,"; $sql .= " p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; -$sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.pmp, p.stock,'; +$sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,'; +$sql .= ' p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.pmp, p.stock,'; $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units'; if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ', p.fk_unit, cu.label'; @@ -481,6 +492,8 @@ if ($resql) if ($search_accountancy_code_sell_intra) $param = "&search_accountancy_code_sell_intra=".urlencode($search_accountancy_code_sell_intra); if ($search_accountancy_code_sell_export) $param = "&search_accountancy_code_sell_export=".urlencode($search_accountancy_code_sell_export); if ($search_accountancy_code_buy) $param = "&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); + if ($search_accountancy_code_buy_intra) $param = "&search_accountancy_code_buy_intra=".urlencode($search_accountancy_code_buy_intra); + if ($search_accountancy_code_buy_export) $param = "&search_accountancy_code_buy_export=".urlencode($search_accountancy_code_buy_export); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -770,7 +783,9 @@ if ($resql) if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) print ''.$obj->accountancy_code_buy.''.$obj->accountancy_code_buy_intra.''.$obj->accountancy_code_buy_export.'
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'; @@ -786,7 +786,7 @@ elseif ($object->id > 0) array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false) ); - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300, 590); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300, 590); } diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index 42226f93208..6e4f19b2818 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -19,7 +19,7 @@ /** * \file htdocs/projet/contact.php * \ingroup project - * \brief Onglet de gestion des contacts du projet + * \brief List of all contacts of a project */ require '../main.inc.php'; @@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +if ($conf->categorie->enabled) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } // Load translation files required by the page $langs->loadLangs(array('projects', 'companies')); diff --git a/htdocs/projet/graph_opportunities.inc.php b/htdocs/projet/graph_opportunities.inc.php index 72394c348fc..e535756ce0c 100644 --- a/htdocs/projet/graph_opportunities.inc.php +++ b/htdocs/projet/graph_opportunities.inc.php @@ -75,16 +75,16 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) } if ($conf->use_javascript_ajax) { - print '
'; + print '
'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); - $dolgraph->SetHeight(180); + //$dolgraph->setWidth('100%'); + $dolgraph->SetHeight('200'); $dolgraph->draw('idgraphstatus'); print $dolgraph->show($totaloppnb ? 0 : 1); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index f7f7cce75e1..ca4f918c7d3 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -771,9 +771,7 @@ while ($i < min($num, $limit)) $nbofsalesrepresentative = count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number { - print ''; print $nbofsalesrepresentative; - print ''; } elseif ($nbofsalesrepresentative > 0) { diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 3810f18dea3..1f1c1ed40d4 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -665,9 +665,9 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) if ($paymentintent->status != 'succeeded') { $error++; - $errormessage = "StatusOfRetreivedIntent is not succeeded: ".$e->getMessage(); + $errormessage = "StatusOfRetreivedIntent is not succeeded: ".$paymentintent->status; dol_syslog($errormessage, LOG_WARNING, 0, '_stripe'); - setEventMessages($e->getMessage(), null, 'errors'); + setEventMessages($paymentintent->status, null, 'errors'); $action = ''; } else diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 181973912e5..16978e06ee2 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -68,11 +68,12 @@ if (GETPOST('addfile', 'alpha') && !GETPOST('add', 'alpha')) { // Set tmp directory TODO Use a dedicated directory for temp mails files $vardir = $conf->ticket->dir_output; - $upload_dir_tmp = $vardir.'/temp'; + $upload_dir_tmp = $vardir.'/temp/'.session_id(); if (!dol_is_dir($upload_dir_tmp)) { dol_mkdir($upload_dir_tmp); } - dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile'); + + dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, '', 0); $action = 'create_ticket'; ////} } @@ -83,7 +84,7 @@ if (GETPOST('removedfile', 'alpha') && !GETPOST('add', 'alpha')) { // Set tmp directory $vardir = $conf->ticket->dir_output.'/'; - $upload_dir_tmp = $vardir.'/temp'; + $upload_dir_tmp = $vardir.'/temp/'.session_id(); // TODO Delete only files that was uploaded from email form dol_remove_file_process($_POST['removedfile'], 0, 0); @@ -170,7 +171,7 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) { if (!$error && $id > 0) { if ($usertoassign > 0) { - $object->add_contact($usertoassign, "SUPPORTCLI", 'external', $notrigger = 0); + $object->add_contact($usertoassign, "SUPPORTCLI", 'external', 0); } } @@ -304,7 +305,7 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) { } // Copy files into ticket directory - $destdir = $conf->ticket->dir_output.'/'.$object->track_id; + $destdir = $conf->ticket->dir_output.'/'.$object->ref; if (!dol_is_dir($destdir)) { dol_mkdir($destdir); } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 260a3744e2e..595100b771c 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -56,7 +56,13 @@ class Reception extends CommonObject public $socid; public $ref_supplier; + + /** + * @var int Ref int + * @deprecated + */ public $ref_int; + public $brouillon; public $entrepot_id; public $lines = array(); @@ -372,15 +378,15 @@ class Reception extends CommonObject * @param int $id Id of object to load * @param string $ref Ref of object * @param string $ref_ext External reference of object - * @param string $ref_int Internal reference of other object + * @param string $notused Internal reference of other object * @return int >0 if OK, 0 if not found, <0 if KO */ - public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') + public function fetch($id, $ref = '', $ref_ext = '', $notused = '') { global $conf; // Check parameters - if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; + if (empty($id) && empty($ref) && empty($ref_ext)) return -1; $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_supplier, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut"; $sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; @@ -397,7 +403,7 @@ class Reception extends CommonObject if ($id) $sql .= " AND e.rowid=".$id; if ($ref) $sql .= " AND e.ref='".$this->db->escape($ref)."'"; if ($ref_ext) $sql .= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql .= " AND e.ref_int='".$this->db->escape($ref_int)."'"; + if ($notused) $sql .= " AND e.ref_int='".$this->db->escape($notused)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -546,7 +552,7 @@ class Reception extends CommonObject $numref = $this->ref; } - $this->newref = $numref; + $this->newref = dol_sanitizeFileName($numref); $now = dol_now(); diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index a76e9aa34cb..10cc427afcf 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -306,9 +306,7 @@ abstract class ActionsCardCommon $nbofsalesrepresentative=count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number { - $this->tpl['sales_representatives'].= ''; $this->tpl['sales_representatives'].= $nbofsalesrepresentative; - $this->tpl['sales_representatives'].= ''; } elseif ($nbofsalesrepresentative > 0) { diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b7bdda5d6ba..d297678a2d2 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1557,14 +1557,9 @@ else print '
'; + print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''.$obj->multicurrency_code . ' - ' . $langs->trans('Currency' . $obj->multicurrency_code)."'; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."
'; print $langs->trans("SortProductField"); print ''; $prod = new Product($db); -$array = array('rowid' => 'ID', 'ref' => 'Ref', 'datec' => 'DateCreation', 'tms' => 'DateModification'); +$array = array('rowid' => 'ID', 'ref' => 'Ref', 'label' => 'Label', 'datec' => 'DateCreation', 'tms' => 'DateModification'); print $form->selectarray('TAKEPOS_SORTPRODUCTFIELD', $array, (empty($conf->global->TAKEPOS_SORTPRODUCTFIELD) ? 'rowid' : $conf->global->TAKEPOS_SORTPRODUCTFIELD), 0, 0, 0, '', 1); print "
'; +print $langs->trans('TakeposNumpadUsePaymentIcon'); +print ''; +print ajax_constantonoff("TAKEPOS_NUMPAD_USE_PAYMENT_ICON", array(), $conf->entity, 0, 0, 1, 0); +print "
'; print $langs->trans('DirectPaymentButton'); @@ -241,6 +248,63 @@ if (is_array($formmail->lines_model)) { print $form->selectarray('TAKEPOS_EMAIL_TEMPLATE_INVOICE', $arrayofmessagename, $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE, 'None', 1, 0, '', 0, 0, 0, '', '', 1); print "
'; +print $langs->trans("BillsNumberingModule"); +print ''; +$array = array(0=>$langs->trans("Default"), "terminal"=>$langs->trans("ByTerminal")); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); +foreach ($dirmodels as $reldir) +{ + $dir = dol_buildpath($reldir."core/modules/facture/"); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/', '', $file); + // For compatibility + if (!is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_facture_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/', $classname, $reg); + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + + $classname = preg_replace('/\-.*$/', '', $classname); + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; + + $module = new $classname($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) + { + $array[preg_replace('/\-.*$/', '', preg_replace('/\.php$/', '', $file))]=preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); + } + } + } + } + closedir($handle); + } + } +} + +print $form->selectarray('TAKEPOS_ADDON', $array, (empty($conf->global->TAKEPOS_ADDON) ? '0' : $conf->global->TAKEPOS_ADDON), 0); +print "
'; print '
'; diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 1107f9101c7..08ca05bb109 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -90,6 +90,8 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, 'CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, (GETPOST('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, 'int') > 0 ? GETPOST('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, 'int') : ''), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_ADDON".$terminaltouse, GETPOST('TAKEPOS_ADDON'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); + dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); if (!$res > 0) $error++; @@ -251,6 +253,66 @@ print ''; print ''; print ''; +// Numbering module +if ($conf->global->TAKEPOS_ADDON=="terminal"){ + print ''; + print $langs->trans("BillsNumberingModule"); + print ''; + $array = array(0=>$langs->trans("Default")); + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $dir = dol_buildpath($reldir."core/modules/facture/"); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/', '', $file); + // For compatibility + if (!is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_facture_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/', $classname, $reg); + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + + $classname = preg_replace('/\-.*$/', '', $classname); + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; + + $module = new $classname($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) + { + $array[preg_replace('/\-.*$/', '', preg_replace('/\.php$/', '', $file))]=preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); + } + } + } + } + closedir($handle); + } + } + } + print $form->selectarray('TAKEPOS_ADDON'.$terminaltouse, $array, (empty($conf->global->{'TAKEPOS_ADDON'.$terminaltouse}) ? '0' : $conf->global->{'TAKEPOS_ADDON'.$terminaltouse}), 0); + print "\n"; + print ''; + print '
'; +} + print ''; print '
'; diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 6ce0dfcf88e..07de9e50a51 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -38,6 +38,10 @@ $action = GETPOST('action', 'alpha'); $term = GETPOST('term', 'alpha'); $id = GETPOST('id', 'int'); +if (empty($user->rights->takepos->run)) { + access_forbidden(); +} + /* * View @@ -103,14 +107,14 @@ elseif ($action == 'search' && $term != '') { } elseif ($action == "opendrawer" && $term != '') { require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; $printer = new dolReceiptPrinter($db); - // chek printer for terminal + // check printer for terminal if ($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$term} > 0) { $printer->initPrinter($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$term}); // open cashdrawer $printer->pulse(); $printer->close(); } -} elseif ($action == "printinvoiceticket" && $term != '' && $id > 0) { +} elseif ($action == "printinvoiceticket" && $term != '' && $id > 0 && ! empty($user->rights->facture->lire)) { require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $printer = new dolReceiptPrinter($db); @@ -120,4 +124,13 @@ elseif ($action == 'search' && $term != '') { $object->fetch($id); $ret = $printer->sendToPrinter($object, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$term}, $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$term}); } +} elseif ($action == 'getInvoice') { + require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + + $object = new Facture($db); + if ($id > 0) { + $object->fetch($id); + } + + echo json_encode($object); } diff --git a/htdocs/takepos/css/colorful.css b/htdocs/takepos/css/colorful.css index 3cfd18e72f1..298a29ce4cf 100644 --- a/htdocs/takepos/css/colorful.css +++ b/htdocs/takepos/css/colorful.css @@ -22,4 +22,12 @@ button.actionbutton { tr.selected, tr.selected td { background-color: #0000FF !important; color: #FFFFFF !important; -} \ No newline at end of file +} + +.header{ + background: rgb(0,0,0) !important; +} + +.topnav{ + background: rgb(0,0,0) !important; +} diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index 8a75549ce0c..c228b948c3b 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -101,6 +101,7 @@ button.calcbutton { /* border-color: unset; */ border-width: 0; margin: 1px; + font-size: 14pt; } button.calcbutton2 { @@ -118,6 +119,8 @@ button.calcbutton2 { width: calc(25% - 2px); height: calc(25% - 2px); font-weight: bold; + font-size: 8pt; + margin: 1px; } button.calcbutton3 { @@ -128,10 +131,11 @@ button.calcbutton3 { cursor: pointer; vertical-align: middle; text-align: center; - font-size:120%; overflow: visible; /* removes extra width in IE */ width: calc(25% - 2px); height: calc(25% - 2px); + font-size: 14pt; + margin: 1px; } button.actionbutton { @@ -153,6 +157,16 @@ button.actionbutton { height: calc(25% - 2px); } +div[aria-describedby="dialog-info"] button:before { + content: "\f788"; + font-family: "Font Awesome 5 Free"; + font-weight: 900; + padding-right: 5px; +} +div[aria-describedby="dialog-info"].ui-dialog .ui-dialog-buttonpane { + border-width: 0; +} + .takepospay { font-size: 1.5em; } @@ -468,12 +482,6 @@ div.description_content { } @media screen and (min-width: 892px) { - .calcbutton{ - font-size: 18px; - } - .calcbutton2{ - font-size: 14px; - } .actionbutton{ font-size: 13px; } @@ -486,12 +494,6 @@ div.description_content { } @media (max-width: 891px) and (min-width: 386px) { - .calcbutton{ - font-size: 12px; - } - .calcbutton2{ - font-size: 9px; - } .actionbutton{ font-size: 12px; } @@ -504,12 +506,6 @@ div.description_content { } @media screen and (max-width: 385px){ - .calcbutton{ - font-size: 8px; - } - .calcbutton2{ - font-size: 7px; - } .actionbutton{ font-size: 10px; } diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index fc4ae6ee23e..60854bf2407 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -171,7 +171,8 @@ if ($action == 'valid' && $user->rights->facture->creer) $sav_FACTURE_ADDON=''; if (! empty($conf->global->TAKEPOS_ADDON)) { $sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON; - $conf->global->FACTURE_ADDON = $conf->global->TAKEPOS_ADDON; + if ($conf->global->TAKEPOS_ADDON=="terminal") $conf->global->FACTURE_ADDON = $conf->global->{'TAKEPOS_ADDON'.$_SESSION["takeposterminal"]}; + else $conf->global->FACTURE_ADDON = $conf->global->TAKEPOS_ADDON; } $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; @@ -225,7 +226,8 @@ if ($action == 'valid' && $user->rights->facture->creer) $payment->amounts[$invoice->id] = $amountofpayment; // If user has not used change control, add total invoice payment - if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $remaintopay; + // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay + if ($amountofpayment == 0 || $amountofpayment>$remaintopay) $payment->amounts[$invoice->id] = $remaintopay; $payment->paiementid = $paiementid; $payment->num_payment = $invoice->ref; @@ -238,6 +240,8 @@ if ($action == 'valid' && $user->rights->facture->creer) dol_syslog("Invoice is paid, so we set it to status Paid"); $result = $invoice->set_paid($user); if ($result > 0) $invoice->paye = 1; + // set payment method + $invoice->setPaymentMethods($paiementid); } else { dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay); } @@ -451,6 +455,12 @@ if ($action == "updatereduction") else $result = $invoice->updateline($line->id, $line->desc, $line->multicurrency_subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } } + $invoice->fetch($placeid); +} elseif ($action == 'update_reduction_global') { + foreach ($invoice->lines as $line) { + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } + $invoice->fetch($placeid); } @@ -548,7 +558,7 @@ if ($action == "valid" || $action == "history") $sectionwithinvoicelink .= ' '; } - if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink .= ''; + if ($remaintopay <= 0 && $conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink .= ''; } /* @@ -662,6 +672,14 @@ function DolibarrTakeposPrinting(id) { url: "" + id, }); } + +$( document ).ready(function() { + $("a#customer").text("socid != $conf->global->$constforcompanyid) print $soc->name; + else print $langs->trans("Customer"); + ?>"); +}); + 0) if (empty($line->product_type)) $htmlforlines .= img_object('', 'product').' '; else $htmlforlines .= img_object('', 'service').' '; } - if ($line->product_label) $htmlforlines .= $line->product_label; - if ($line->product_label && $line->desc) $htmlforlines .= '
'; - if ($line->product_label != $line->desc) - { - $firstline = dolGetFirstLineOfText($line->desc); - if ($firstline != $line->desc) - { - $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); - } - else - { - $htmlforlines .= $line->desc; - } + if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) { + $tooltiptext = ''.$langs->trans("Ref").' : '.$line->product_ref.'
'; + $tooltiptext .= ''.$langs->trans("Label").' : '.$line->product_label.'
'; + $tooltiptext .= '
'; + $tooltiptext .= $line->desc; + $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : $line->product_ref, $tooltiptext); + } else { + if ($line->product_label) $htmlforlines .= $line->product_label; + if ($line->product_label && $line->desc) $htmlforlines .= '
'; + if ($line->product_label != $line->desc) + { + $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES); + if ($firstline != $line->desc) + { + $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); + } + else + { + $htmlforlines .= $line->desc; + } + } } if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "
(".$line->array_options['options_order_notes'].")"; if ($_SESSION["basiclayout"] != 1) @@ -879,9 +905,7 @@ print ''; if ($invoice->socid != $conf->global->$constforcompanyid) { - print ''; print '

'; - print $langs->trans("Customer").': '.$soc->name; $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index ec619015496..215a42e119b 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -214,7 +214,7 @@ else print "var received=0;"; } -

+
trans('TotalTTC'); ?>: total_ttc, 1, '', 1, -1, -1) ?>
@@ -233,7 +233,7 @@ else print "var received=0;";
-
+
"parent.$.colorbox.close();", - "span" => "id='printtext'", - "text" => $langs->trans("Cancel"), + "span" => "id='printtext' style='font-weight: bold; font-size: 18pt;'", + "text" => "X", "class" => "poscolordelete" ), ); $numpad = $conf->global->TAKEPOS_NUMPAD; + +print ''; +print ''; +print ''; ?> - - - 0) { $paycode = $paiements[0]->code; - if ($paycode == 'LIQ') $paycode = 'cash'; - if ($paycode == 'CB') $paycode = 'card'; - if ($paycode == 'CHQ') $paycode = 'cheque'; - ?> - - - - - - - + $payIcon = ''; + if ($paycode == 'LIQ') { + $paycode = 'cash'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins'; + } elseif ($paycode == 'CB') { + $paycode = 'card'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card'; + } elseif ($paycode == 'CHQ') { + $paycode = 'cheque'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check'; + } + + print ''; +} else { + print ''; +} + +print ''; +print ''; +print ''; +?> 1) { $paycode = $paiements[1]->code; - if ($paycode == 'LIQ') $paycode = 'cash'; - if ($paycode == 'CB') $paycode = 'card'; - if ($paycode == 'CHQ') $paycode = 'cheque'; - ?> - - - - - - - + $payIcon = ''; + if ($paycode == 'LIQ') { + $paycode = 'cash'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins'; + } elseif ($paycode == 'CB') { + $paycode = 'card'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card'; + } elseif ($paycode == 'CHQ') { + $paycode = 'cheque'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check'; + } + + print ''; +} else { + $button = array_pop($action_buttons); + print ''; +} + +print ''; +print ''; +print ''; +?> 2) { $paycode = $paiements[2]->code; - if ($paycode == 'LIQ') $paycode = 'cash'; - if ($paycode == 'CB') $paycode = 'card'; - if ($paycode == 'CHQ') $paycode = 'cheque'; - ?> - -global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'coins'; + } elseif ($paycode == 'CB') { + $paycode = 'card'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'credit-card'; + } elseif ($paycode == 'CHQ') { + $paycode = 'cheque'; + if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) $payIcon = 'money-check'; + } + + print ''; +} else { $button = array_pop($action_buttons); - ?> - - - - - -' . $button["text"] . ''; +} + +print ''; +print ''; +print ''; + $i = 3; while ($i < count($paiements)) { - ?> - - trans($paiements[$i]->code).'\');">' . $langs->trans("PaymentTypeShort".$paiements[$i]->code) . ''; $i = $i + 1; } @@ -320,9 +346,7 @@ if ($conf->global->TAKEPOS_ENABLE_SUMUP) { $class = ($i == 3) ? "calcbutton3" : "calcbutton2"; foreach ($action_buttons as $button) { $newclass = $class.($button["class"] ? " ".$button["class"] : ""); - ?> - - '.$button["text"].''; } ?>
diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 1df223716fb..66043f7139c 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -85,31 +85,27 @@ if (!empty($hookmanager->resPrint)) {

global->TAKEPOS_CUSTOM_RECEIPT) +if (!empty($conf->global->TAKEPOS_HEADER)) { $substitutionarray = getCommonSubstitutionArray($langs); if (!empty($conf->global->TAKEPOS_HEADER)) - { - $newfreetext = make_substitutions($conf->global->TAKEPOS_HEADER, $substitutionarray); - echo $newfreetext; - } + $newfreetext = make_substitutions($conf->global->TAKEPOS_HEADER, $substitutionarray); + echo $newfreetext; } ?>

trans('Date')." ".dol_print_date($object->date, 'day').'
'; -if ($conf->global->TAKEPOS_CUSTOM_RECEIPT) print $conf->global->TAKEPOS_RECEIPT_NAME." "; +if (!empty($conf->global->TAKEPOS_RECEIPT_NAME)) print $conf->global->TAKEPOS_RECEIPT_NAME." "; if ($object->statut == Facture::STATUS_DRAFT) print str_replace(")", "", str_replace("-", " ".$langs->trans('Place')." ", str_replace("(PROV-POS", $langs->trans("Terminal")." ", $object->ref))); else print $object->ref; -if ($conf->global->TAKEPOS_CUSTOM_RECEIPT && $conf->global->TAKEPOS_SHOW_CUSTOMER) +if ($conf->global->TAKEPOS_SHOW_CUSTOMER) { - $soc = new Societe($db); - $soc->fetch($invoice->socid); - if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}) + if ($object->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}) { $soc = new Societe($db); - if ($invoice->socid > 0) $soc->fetch($invoice->socid); + if ($object->socid > 0) $soc->fetch($object->socid); else $soc->fetch($conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}); print "
".$langs->trans("Customer").': '.$soc->name; } @@ -183,13 +179,11 @@ if ($conf->global->TAKEPOS_CUSTOM_RECEIPT && $conf->global->TAKEPOS_SHOW_CUSTOME

global->TAKEPOS_CUSTOM_RECEIPT) +if (!empty($conf->global->TAKEPOS_FOOTER)) { $substitutionarray = getCommonSubstitutionArray($langs); - if (!empty($conf->global->TAKEPOS_FOOTER)) { - $newfreetext = make_substitutions($conf->global->TAKEPOS_FOOTER, $substitutionarray); - echo $newfreetext; - } + $newfreetext = make_substitutions($conf->global->TAKEPOS_FOOTER, $substitutionarray); + echo $newfreetext; } ?> diff --git a/htdocs/takepos/reduction.php b/htdocs/takepos/reduction.php new file mode 100644 index 00000000000..34929fd54ff --- /dev/null +++ b/htdocs/takepos/reduction.php @@ -0,0 +1,219 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/takepos/reduction.php + * \ingroup takepos + * \brief Page with the content of the popup to enter reductions + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); + +require '../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant + +$invoiceid = GETPOST('invoiceid', 'int'); + + +/* + * View + */ + +$invoice = new Facture($db); +if ($invoiceid > 0) +{ + $invoice->fetch($invoiceid); +} +else +{ + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $resql = $db->query($sql); + $obj = $db->fetch_object($resql); + if ($obj) + { + $invoiceid = $obj->rowid; + } + if (!$invoiceid) + { + $invoiceid = 0; // Invoice does not exist yet + } + else + { + $invoice->fetch($invoiceid); + } +} + +$arrayofcss = array('/takepos/css/pos.css.php'); +$arrayofjs = array(); + +top_htmlhead($head, '', 0, 0, $arrayofjs, $arrayofcss); + +$langs->loadLangs(array('main', 'bills', 'cashdesk')); +?> + + + + + + +

+
+trans('Reduction') . '">'; +?> +
+
+ +
+7'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +?> +
+ + + diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index a5ce4980468..b693a41c366 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -137,8 +137,8 @@ foreach ($categories as $key => $categorycursor) } } -sort($maincategories); -sort($subcategories); +$maincategories = dol_sort_array($maincategories, 'label'); +$subcategories = dol_sort_array($subcategories, 'label'); ?> var categories = ; @@ -398,6 +398,12 @@ function History() $.colorbox({href:"../compta/facture/list.php?contextpage=poslist", width:"90%", height:"80%", transition:"none", iframe:"true", title:"trans("History"); ?>"}); } +function Reduction() { + invoiceid = $("#invoiceid").val(); + console.log("Open popup to enter reduction on invoiceid="+invoiceid); + $.colorbox({href:"reduction.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""}); +} + function CloseBill() { invoiceid = $("#invoiceid").val(); console.log("Open popup to enter payment on invoiceid="+invoiceid); @@ -429,13 +435,24 @@ function Refresh() { function New() { // If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined console.log("New with place = , js place="+place); - var r = confirm(' 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>'); - if (r == true) { - $("#poslines").load("invoice.php?action=delete&place="+place, function() { - //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); - }); - ClearSearch(); - } + + invoiceid = $("#invoiceid").val(); + $.getJSON('/takepos/ajax/ajax.php?action=getInvoice&id='+invoiceid, function(data) { + var r; + + if (parseInt(data['paye']) === 1) { + r = true; + } else { + r = confirm(' 0 ? $langs->transnoentitiesnoconv("ConfirmDeletionOfThisPOSSale") : $langs->transnoentitiesnoconv("ConfirmDiscardOfThisPOSSale")); ?>'); + } + + if (r == true) { + $("#poslines").load("invoice.php?action=delete&place=" + place, function () { + //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); + }); + ClearSearch(); + } + }); } /** @@ -446,28 +463,36 @@ function New() { */ function Search2(keyCodeForEnter) { console.log("Search2 Call ajax search to replace products"); - if(window.event.keyCode == keyCodeForEnter) var key=13; - pageproducts=0; - jQuery(".wrapper2 .catwatermark").hide(); - $.getJSON('/takepos/ajax/ajax.php?action=search&term='+$('#search').val(), function(data) { - for (i = 0; i < ; i++) { - if (typeof (data[i]) == "undefined"){ - $("#prodesc"+i).text(""); - $("#proimg"+i).attr("src","genimg/empty.png"); - $("#prodiv"+i).data("rowid",""); - continue; + + var search = false; + var eventKeyCode = window.event.keyCode; + if (typeof keyCodeForEnter === 'undefined' || eventKeyCode == keyCodeForEnter) { + search = true; + } + + if (search === true) { + pageproducts = 0; + jQuery(".wrapper2 .catwatermark").hide(); + $.getJSON('/takepos/ajax/ajax.php?action=search&term=' + $('#search').val(), function (data) { + for (i = 0; i < ; i++) { + if (typeof (data[i]) == "undefined") { + $("#prodesc" + i).text(""); + $("#proimg" + i).attr("src", "genimg/empty.png"); + $("#prodiv" + i).data("rowid", ""); + continue; + } + var titlestring = 'transnoentities('Ref') . ': '); ?>' + data[i]['ref']; + $("#prodesc" + i).text(data[i]['label']); + $("#prodivdesc" + i).show(); + $("#proimg" + i).attr("title", titlestring); + $("#proimg" + i).attr("src", "genimg/index.php?query=pro&id=" + data[i]['rowid']); + $("#prodiv" + i).data("rowid", data[i]['rowid']); + $("#prodiv" + i).data("iscat", 0); } - var titlestring = 'transnoentities('Ref').': '); ?>'+data[i]['ref']; - $("#prodesc"+i).text(data[i]['label']); - $("#prodivdesc"+i).show(); - $("#proimg"+i).attr("title", titlestring); - $("#proimg"+i).attr("src", "genimg/index.php?query=pro&id="+data[i]['rowid']); - $("#prodiv"+i).data("rowid", data[i]['rowid']); - $("#prodiv"+i).data("iscat", 0); - } - }).always(function(data) { - if(key==13 && data.length==1) ClickProduct(0); - }); + }).always(function (data) { + if ($('#search').val().length > 0 && data.length == 1) ClickProduct(0); + }); + } } function Edit(number) { @@ -654,8 +679,8 @@ $( document ).ready(function() { global->TAKEPOS_NUM_TERMINALS != "1" && $_SESSION["takeposterminal"] == "") print '
'.$langs->trans('TerminalSelect').'
'; -$keyCodeForEnter = $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} > 0 ? $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} : 13; +print ''; +$keyCodeForEnter = $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} > 0 ? $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} : ''; ?>
@@ -669,10 +694,10 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { trans("Terminal")." "; if ($_SESSION["takeposterminal"] == "") echo "1"; else echo $_SESSION["takeposterminal"]; - echo ' - '.dol_print_date(dol_now(), "dayhour").''; + echo ' - '.dol_print_date(dol_now(), "day").''; ?> - trans("Customer"); ?> +