From 053b4dd63c8e231d0c36f71755bface5647710ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Oct 2012 21:47:59 +0200 Subject: [PATCH] New: [ task #210 ] Can choose cash account during POS login --- ChangeLog | 1 + htdocs/cashdesk/index.php | 28 ++++++++++++++++++++++++ htdocs/cashdesk/index_verif.php | 11 ++++++++-- htdocs/cashdesk/tpl/facturation1.tpl.php | 6 ++--- htdocs/cashdesk/tpl/menu.tpl.php | 12 +++++----- htdocs/cashdesk/tpl/validation1.tpl.php | 12 +++++----- 6 files changed, 53 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1de53b75a0..a18f63dd704 100644 --- a/ChangeLog +++ b/ChangeLog @@ -52,6 +52,7 @@ For users: - New: Can make one invoice for several orders. - New: POS module can works with only one payment method (cach, chq, credit card). - New: Add possibility to defined position/job of a user +- New: [ task #210 ] Can choose cash account during POS login New experimental modules: - New: Add margin and commissions management module. diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index 3dac2d0f57d..9aa8622d1ac 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -111,6 +111,34 @@ if (! empty($conf->stock->enabled)) print ''; print "\n"; } + +print ""; +print ''.$langs->trans("CashDeskBankAccountForSell").''; +print ''; +$defaultknown=0; +if (! empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && $conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0) $defaultknown=1; // If a particular stock is defined, we disable choice +print $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH,'CASHDESK_ID_BANKACCOUNT_CASH',0,"courant=2",($defaultknown?0:2)); +print ''; +print "\n"; + +print ""; +print ''.$langs->trans("CashDeskBankAccountForCheque").''; +print ''; +$defaultknown=0; +if (! empty($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE) && $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE > 0) $defaultknown=1; // If a particular stock is defined, we disable choice +print $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE,'CASHDESK_ID_BANKACCOUNT_CHEQUE',0,"courant=1",($defaultknown?0:2)); +print ''; +print "\n"; + +print ""; +print ''.$langs->trans("CashDeskBankAccountForCB").''; +print ''; +$defaultknown=0; +if (! empty($conf->global->CASHDESK_ID_BANKACCOUNT_CB) && $conf->global->CASHDESK_ID_BANKACCOUNT_CB > 0) $defaultknown=1; // If a particular stock is defined, we disable choice +print $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CB,'CASHDESK_ID_BANKACCOUNT_CB',0,"courant=1",($defaultknown?0:2)); +print ''; +print "\n"; + ?> diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php index 81576a92630..98d6aa00561 100644 --- a/htdocs/cashdesk/index_verif.php +++ b/htdocs/cashdesk/index_verif.php @@ -32,6 +32,9 @@ $username = GETPOST("txtUsername"); $password = GETPOST("pwdPassword"); $thirdpartyid = (GETPOST('socid','int')!='')?GETPOST('socid','int'):$conf->global->CASHDESK_ID_THIRDPARTY; $warehouseid = (GETPOST("warehouseid")!='')?GETPOST("warehouseid"):$conf->global->CASHDESK_ID_WAREHOUSE; +$bankid_cash = (GETPOST("CASHDESK_ID_BANKACCOUNT_CASH")!='')?GETPOST("CASHDESK_ID_BANKACCOUNT_CASH"):$conf->global->CASHDESK_ID_BANKACCOUNT_CASH; +$bankid_cheque = (GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE")!='')?GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE"):$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; +$bankid_cb = (GETPOST("CASHDESK_ID_BANKACCOUNT_CB")!='')?GETPOST("CASHDESK_ID_BANKACCOUNT_CB"):$conf->global->CASHDESK_ID_BANKACCOUNT_CB; // Check username if (empty($username)) @@ -56,6 +59,7 @@ if (! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_BILL && exit; } +/* if (! empty($_POST['txtUsername']) && ! empty($conf->banque->enabled) && (empty($conf_fkaccount_cash) && empty($conf_fkaccount_cheque) && empty($conf_fkaccount_cb))) { $langs->load("errors"); @@ -63,7 +67,7 @@ if (! empty($_POST['txtUsername']) && ! empty($conf->banque->enabled) && (empty( header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid); exit; } - +*/ // Check password $auth = new Auth($db); @@ -94,7 +98,10 @@ if ( $retour >= 0 ) $_SESSION['prenom'] = $tab['firstname']; $_SESSION['CASHDESK_ID_THIRDPARTY'] = $thirdpartyid; $_SESSION['CASHDESK_ID_WAREHOUSE'] = $warehouseid; - //var_dump($_SESSION);exit; + $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash : ''); + $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque : ''); + $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : ''); + //var_dump($_SESSION);exit; header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&id=NOUV'); exit; diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index 51242c37015..ade62360036 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -184,7 +184,7 @@ $langs->load("cashdesk"); '; - if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) || $conf->global->CASHDESK_ID_BANKACCOUNT_CASH < 0) + if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0) { $langs->load("errors"); print ''; @@ -192,7 +192,7 @@ $langs->load("cashdesk"); else print ''; print ''; print ''; - if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE) || $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE < 0) + if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) { $langs->load("errors"); print ''; @@ -200,7 +200,7 @@ $langs->load("cashdesk"); else print ''; print ''; print ''; - if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CB) || $conf->global->CASHDESK_ID_BANKACCOUNT_CB < 0) + if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) { $langs->load("errors"); print ''; diff --git a/htdocs/cashdesk/tpl/menu.tpl.php b/htdocs/cashdesk/tpl/menu.tpl.php index b1cdf424f89..a199240a758 100644 --- a/htdocs/cashdesk/tpl/menu.tpl.php +++ b/htdocs/cashdesk/tpl/menu.tpl.php @@ -29,23 +29,23 @@ if (!empty($_SESSION["CASHDESK_ID_THIRDPARTY"])) $company->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); $companyLink = $company->getNomUrl(1); } -if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH)) +if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) { $bankcash=new Account($db); - $bankcash->fetch($conf->global->CASHDESK_ID_BANKACCOUNT_CASH); + $bankcash->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]); $bankcash->label=$bankcash->ref; $bankcashLink = $bankcash->getNomUrl(1); } -if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CB)) +if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) { $bankcb=new Account($db); - $bankcb->fetch($conf->global->CASHDESK_ID_BANKACCOUNT_CB); + $bankcb->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]); $bankcbLink = $bankcb->getNomUrl(1); } -if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE)) +if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) { $bankcheque=new Account($db); - $bankcheque->fetch($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE); + $bankcheque->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]); $bankchequeLink = $bankcheque->getNomUrl(1); } if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && ! empty($conf->stock->enabled)) diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php index 5cca10af8eb..6372afeb27a 100644 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ b/htdocs/cashdesk/tpl/validation1.tpl.php @@ -49,20 +49,20 @@ $langs->load("main"); case 'ESP': echo $langs->trans("Cash"); $filtre='courant=2'; - if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH)) - $selected = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH; + if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) + $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]; break; case 'CB': echo $langs->trans("CreditCard"); $filtre='courant=1'; - if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CB)) - $selected = $conf->global->CASHDESK_ID_BANKACCOUNT_CB; + if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) + $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]; break; case 'CHQ': echo $langs->trans("Cheque"); $filtre='courant=1'; - if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE)) - $selected = $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; + if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) + $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]; break; case 'DIF': echo $langs->trans("Reported");