diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 9e288d4b9a6..cfb9d3de8bc 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -22,9 +22,9 @@ */ /** - * \file htdocs/compta/bank/categ.php - * \ingroup pos - * \brief Page ajout de categories bancaires + * \file htdocs/compta/cashcontrol/cashcontrol_card.php + * \ingroup cashdesk|takepos + * \brief Page to show a cash fence */ require '../../main.inc.php'; @@ -55,6 +55,15 @@ if (! $user->rights->cashdesk->use && ! $user->rights->takepos->use) accessforbidden(); } +$arrayofpaymentmode=array('cash'=>'Cash', 'cheque'=>'Cheque', 'card'=>'CreditCard'); + +$arrayofposavailable=array(); +if (! empty($conf->cashdesk->enabled)) $arrayofposavailable['cashdesk']=$langs->trans('CashDesk').' (cashdesk)'; +if (! empty($conf->takepos->enabled)) $arrayofposavailable['takepos']=$langs->trans('TakePOS').' (takepos)'; +// TODO Add hook here to allow other POS to add themself + +$cashcontrol= new CashControl($db); + /* @@ -70,21 +79,55 @@ if ($action=="start") $action='create'; $error++; } - if (GETPOST('opening','alpha') == '') + if (GETPOST('posnumber','alpha') == '') { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InitialBankBalance")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CashDesk")), null, 'errors'); $action='create'; $error++; } + if (! GETPOST('closeyear','alpha') || GETPOST('closeyear','alpha') == '-1') + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Year")), null, 'errors'); + $action='create'; + $error++; + } +} +elseif ($action=="add") +{ + $error=0; + if (GETPOST('opening','alpha') == '') + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InitialBankBalance")), null, 'errors'); + $action='start'; + $error++; + } + foreach($arrayofpaymentmode as $key=>$val) + { + if (GETPOST($key,'alpha') == '') + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors'); + $action='start'; + $error++; + } + else + { + $cashcontrol->$key = price2num(GETPOST($key,'alpha')); + } + } + if (! $error) { - $cashcontrol= new CashControl($db); - $cashcontrol->opening=GETPOST('opening'); - if (GETPOST('posmodule')=='cashdesk') $cashcontrol->posmodule="cashdesk"; - else if (GETPOST('posmodule')=='takepos') $cashcontrol->posmodule="takepos"; - $cashcontrol->posnumber=GETPOST('posnumber'); + $cashcontrol->day_close = GETPOST('closeday', 'int'); + $cashcontrol->month_close = GETPOST('closemonth', 'int'); + $cashcontrol->year_close = GETPOST('closeyear', 'int'); + + $cashcontrol->opening=price2num(GETPOST('opening','alpha')); + $cashcontrol->posmodule=GETPOST('posmodule','alpha'); + $cashcontrol->posnumber=GETPOST('posnumber','alpha'); + $id=$cashcontrol->create($user); - $action="view"; + + $action="view"; } } @@ -96,18 +139,32 @@ if ($action=="close") $action="view"; } -if ($action=="create") +if ($action=="create" || $action=="start") { llxHeader(); - $arrayofposavailable=array(); - if (! empty($conf->cashdesk->enabled)) $arrayofposavailable['cashdesk']=$langs->trans('CashDesk').' (cashdesk)'; - if (! empty($conf->takepos->enabled)) $arrayofposavailable['takepos']=$langs->trans('TakePOS').' (takepos)'; - // TODO Add hook here to allow other POS to add themself + $initialbalanceforterminal=array(); + $theoricalamountforterminal=array(); + + if (GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') + { + // Calculate $initialbalanceforterminal and $theoricalamountforterminal for terminal 0 + // TODO + + + } print load_fiche_titre($langs->trans("CashControl")." - ".$langs->trans("New"), '', 'title_bank.png'); - print '
'; + print '| '.$langs->trans("InitialBankBalance").' | '; + foreach($arrayofpaymentmode as $key => $val) + { + print ''.$langs->trans($val).' '.$langs->trans("TheoricalAmount").' '.$langs->trans("RealAmount").' | ';
+ }
+ print ''; + print ' |
| '; + foreach($arrayofpaymentmode as $key => $val) + { + print ' | ';
+ print price($theoricalamountforterminal[0][$key]).' '; + print ''; + print ' | ';
+ }
+
+ print ''; + print ' |