From 745438419f897d64610ca168260976ddf0cb0ec5 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 11 Dec 2023 01:09:57 +0100 Subject: [PATCH 1/3] Allow to set a default project for POS sales --- htdocs/langs/en_US/admin.lang | 1 + htdocs/takepos/admin/terminal.php | 13 ++++++++++++- htdocs/takepos/invoice.php | 10 ++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index ec0d628d8cfe2..cebde43392878 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1885,6 +1885,7 @@ CashDeskYouDidNotDisableStockDecease=You did not disable stock decrease when mak CashDeskForceDecreaseStockLabel=Stock decrease for batch products was forced. CashDeskForceDecreaseStockDesc=Decrease first by the oldest eatby and sellby dates. CashDeskReaderKeyCodeForEnter=Key ASCII code for "Enter" defined in barcode reader (Example: 13) +CashDeskDefaultProject=Assign all future sales to this project ##### Bookmark ##### BookmarkSetup=Bookmark module setup BookmarkDesc=This module allows you to manage bookmarks. You can also add shortcuts to any Dolibarr pages or external web sites on your left menu. diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 1934c0358a062..1a02e6ac6eab4 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -75,7 +75,7 @@ $res = dolibarr_set_const($db, "TAKEPOS_TERMINAL_NAME_".$terminaltouse, (!empty(GETPOST('terminalname'.$terminaltouse, 'restricthtml')) ? GETPOST('terminalname'.$terminaltouse, 'restricthtml') : $langs->trans("TerminalName", $terminaltouse)), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY".$terminaltouse, (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity); - + $res = dolibarr_set_const($db, "CASHDESK_ID_PROJECT".$terminaltouse, (GETPOST('projectid', 'int') > 0 ? GETPOST('projectid', 'int') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); @@ -157,6 +157,17 @@ print 'trans("TerminalName", $terminal)).'" >'; print ''; +if (isModEnabled('project')) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + $formproject = new FormProjets($db); + print ''.$langs->trans("CashDeskDefaultProject").''; + print img_picto('', 'project', 'class="pictofixedwidth"'); + // select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '', $morefilter = '') + $projectid = getDolGlobalInt('CASHDESK_ID_PROJECT'.$terminaltouse); + print $formproject->select_projects(-1, $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 1, 'maxwidth500 widthcentpercentminusxx'); + print ''; +} + print ''.$langs->trans("CashDeskThirdPartyForSell").''; print ''; print img_picto('', 'company', 'class="pictofixedwidth"'); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 7f9ab131f0af2..87fe884f78e39 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -80,6 +80,7 @@ } } +$takeposterminal = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''; /** * Abort invoice creationg with a given error message @@ -134,13 +135,13 @@ function fail($message) if ($invoiceid > 0) { $ret = $invoice->fetch($invoiceid); } else { - $ret = $invoice->fetch('', '(PROV-POS'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '') .'-'.$place.')'); + $ret = $invoice->fetch('', '(PROV-POS'.$takeposterminal.'-'.$place.')'); } if ($ret > 0) { $placeid = $invoice->id; } -$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : ''); +$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$takeposterminal; $soc = new Societe($db); if ($invoice->socid > 0) { @@ -149,6 +150,11 @@ function fail($message) $soc->fetch(getDolGlobalString($constforcompanyid)); } +// Assign a default project, if relevant +if (isModEnabled('project') && !empty(getDolGlobalString("CASHDESK_ID_PROJECT".$takeposterminal))) { + $invoice->fk_project = (int)getDolGlobalString("CASHDESK_ID_PROJECT".$takeposterminal); +} + // Change the currency of invoice if it was modified if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"])) { if ($invoice->multicurrency_code != $_SESSION["takeposcustomercurrency"]) { From 0463aa613431d3a620116123e784b745932bb537 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 11 Dec 2023 01:16:22 +0100 Subject: [PATCH 2/3] Fixed: Expected 1 space(s) after cast statement --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 87fe884f78e39..48b481770ac65 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -152,7 +152,7 @@ function fail($message) // Assign a default project, if relevant if (isModEnabled('project') && !empty(getDolGlobalString("CASHDESK_ID_PROJECT".$takeposterminal))) { - $invoice->fk_project = (int)getDolGlobalString("CASHDESK_ID_PROJECT".$takeposterminal); + $invoice->fk_project = (int) getDolGlobalString("CASHDESK_ID_PROJECT".$takeposterminal); } // Change the currency of invoice if it was modified From 8b9a675f9649f5f9702cf9645cee1a5dd5d2a0b1 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 24 Dec 2023 11:40:16 +0100 Subject: [PATCH 3/3] (int) getDolGlobalString() -> getDolGlobalInt() --- htdocs/takepos/invoice.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 48b481770ac65..74774a41617ad 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -151,8 +151,8 @@ function fail($message) } // Assign a default project, if relevant -if (isModEnabled('project') && !empty(getDolGlobalString("CASHDESK_ID_PROJECT".$takeposterminal))) { - $invoice->fk_project = (int) getDolGlobalString("CASHDESK_ID_PROJECT".$takeposterminal); +if (isModEnabled('project') && getDolGlobalInt("CASHDESK_ID_PROJECT".$takeposterminal)) { + $invoice->fk_project = getDolGlobalInt("CASHDESK_ID_PROJECT".$takeposterminal); } // Change the currency of invoice if it was modified