Work on cash fence
This commit is contained in:
parent
e366d7d57c
commit
e5e4ef7b8c
@ -22,9 +22,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/compta/bank/categ.php
|
* \file htdocs/compta/cashcontrol/cashcontrol_card.php
|
||||||
* \ingroup pos
|
* \ingroup cashdesk|takepos
|
||||||
* \brief Page ajout de categories bancaires
|
* \brief Page to show a cash fence
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
@ -55,6 +55,15 @@ if (! $user->rights->cashdesk->use && ! $user->rights->takepos->use)
|
|||||||
accessforbidden();
|
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';
|
$action='create';
|
||||||
$error++;
|
$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';
|
$action='create';
|
||||||
$error++;
|
$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)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$cashcontrol= new CashControl($db);
|
$cashcontrol->day_close = GETPOST('closeday', 'int');
|
||||||
$cashcontrol->opening=GETPOST('opening');
|
$cashcontrol->month_close = GETPOST('closemonth', 'int');
|
||||||
if (GETPOST('posmodule')=='cashdesk') $cashcontrol->posmodule="cashdesk";
|
$cashcontrol->year_close = GETPOST('closeyear', 'int');
|
||||||
else if (GETPOST('posmodule')=='takepos') $cashcontrol->posmodule="takepos";
|
|
||||||
$cashcontrol->posnumber=GETPOST('posnumber');
|
$cashcontrol->opening=price2num(GETPOST('opening','alpha'));
|
||||||
|
$cashcontrol->posmodule=GETPOST('posmodule','alpha');
|
||||||
|
$cashcontrol->posnumber=GETPOST('posnumber','alpha');
|
||||||
|
|
||||||
$id=$cashcontrol->create($user);
|
$id=$cashcontrol->create($user);
|
||||||
$action="view";
|
|
||||||
|
$action="view";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,18 +139,32 @@ if ($action=="close")
|
|||||||
$action="view";
|
$action="view";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action=="create")
|
if ($action=="create" || $action=="start")
|
||||||
{
|
{
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$arrayofposavailable=array();
|
$initialbalanceforterminal=array();
|
||||||
if (! empty($conf->cashdesk->enabled)) $arrayofposavailable['cashdesk']=$langs->trans('CashDesk').' (cashdesk)';
|
$theoricalamountforterminal=array();
|
||||||
if (! empty($conf->takepos->enabled)) $arrayofposavailable['takepos']=$langs->trans('TakePOS').' (takepos)';
|
|
||||||
// TODO Add hook here to allow other POS to add themself
|
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 load_fiche_titre($langs->trans("CashControl")." - ".$langs->trans("New"), '', 'title_bank.png');
|
||||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
|
||||||
print '<input type="hidden" name="action" value="start">';
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
|
if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1')
|
||||||
|
{
|
||||||
|
print '<input type="hidden" name="action" value="add">';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<input type="hidden" name="action" value="start">';
|
||||||
|
}
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>'.$langs->trans("Module").'</td>';
|
print '<td>'.$langs->trans("Module").'</td>';
|
||||||
@ -115,22 +172,22 @@ if ($action=="create")
|
|||||||
print '<td>'.$langs->trans("Year").'</td>';
|
print '<td>'.$langs->trans("Year").'</td>';
|
||||||
print '<td>'.$langs->trans("Month").'</td>';
|
print '<td>'.$langs->trans("Month").'</td>';
|
||||||
print '<td>'.$langs->trans("Day").'</td>';
|
print '<td>'.$langs->trans("Day").'</td>';
|
||||||
print '<td>'.$langs->trans("InitialBankBalance").'</td>';
|
|
||||||
print '<td></td>';
|
print '<td></td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
$syear = dol_print_date($now, "%Y");
|
$syear = (GETPOSTISSET('closeyear')?GETPOST('closeyear', 'int'):dol_print_date($now, "%Y"));
|
||||||
$smonth = dol_print_date($now, "%m");
|
$smonth = (GETPOSTISSET('closemonth')?GETPOST('closemonth', 'int'):dol_print_date($now, "%m"));
|
||||||
$sday = dol_print_date($now, "%d");
|
$sday = (GETPOSTISSET('closeday')?GETPOST('closeday', 'int'):dol_print_date($now, "%d"));
|
||||||
|
$disabled=0;
|
||||||
|
$prefix='close';
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td>'.$form->selectarray('posmodule', $arrayofposavailable, 1, (count($arrayofposavailable)>1?1:0)).'</td>';
|
print '<td>'.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule','alpha'), (count($arrayofposavailable)>1?1:0)).'</td>';
|
||||||
print '<td><input name="posnumber" type="text" class="maxwidth50" value="0"></td>';
|
print '<td><input name="posnumber" type="text" class="maxwidth50" value="'.(GETPOSTISSET('posnumber')?GETPOST('posnumber','alpha'):'0').'"></td>';
|
||||||
// Year
|
// Year
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$retstring='<select'.($disabled?' disabled':'').' class="flat valignmiddle maxwidth75imp" id="'.$prefix.'year" name="'.$prefix.'year">';
|
$retstring='<select'.($disabled?' disabled':'').' class="flat valignmiddle maxwidth75imp" id="'.$prefix.'year" name="'.$prefix.'year">';
|
||||||
|
|
||||||
for ($year = $syear - 10; $year < $syear + 10 ; $year++)
|
for ($year = $syear - 10; $year < $syear + 10 ; $year++)
|
||||||
{
|
{
|
||||||
$retstring.='<option value="'.$year.'"'.($year == $syear ? ' selected':'').'>'.$year.'</option>';
|
$retstring.='<option value="'.$year.'"'.($year == $syear ? ' selected':'').'>'.$year.'</option>';
|
||||||
@ -141,6 +198,7 @@ if ($action=="create")
|
|||||||
// Month
|
// Month
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$retstring='<select'.($disabled?' disabled':'').' class="flat valignmiddle maxwidth75imp" id="'.$prefix.'month" name="'.$prefix.'month">';
|
$retstring='<select'.($disabled?' disabled':'').' class="flat valignmiddle maxwidth75imp" id="'.$prefix.'month" name="'.$prefix.'month">';
|
||||||
|
$retstring.='<option value="0"></option>';
|
||||||
for ($month = 1 ; $month <= 12 ; $month++)
|
for ($month = 1 ; $month <= 12 ; $month++)
|
||||||
{
|
{
|
||||||
$retstring.='<option value="'.$month.'"'.($month == $smonth?' selected':'').'>';
|
$retstring.='<option value="'.$month.'"'.($month == $smonth?' selected':'').'>';
|
||||||
@ -153,10 +211,7 @@ if ($action=="create")
|
|||||||
// Day
|
// Day
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$retstring='<select'.($disabled?' disabled':'').' class="flat valignmiddle maxwidth50imp" id="'.$prefix.'day" name="'.$prefix.'day">';
|
$retstring='<select'.($disabled?' disabled':'').' class="flat valignmiddle maxwidth50imp" id="'.$prefix.'day" name="'.$prefix.'day">';
|
||||||
if ($emptydate || $set_time == -1)
|
$retstring.='<option value="0" selected> </option>';
|
||||||
{
|
|
||||||
$retstring.='<option value="0" selected> </option>';
|
|
||||||
}
|
|
||||||
for ($day = 1 ; $day <= 31; $day++)
|
for ($day = 1 ; $day <= 31; $day++)
|
||||||
{
|
{
|
||||||
$retstring.='<option value="'.$day.'"'.($day == $sday ? ' selected':'').'>'.$day.'</option>';
|
$retstring.='<option value="'.$day.'"'.($day == $sday ? ' selected':'').'>'.$day.'</option>';
|
||||||
@ -164,10 +219,45 @@ if ($action=="create")
|
|||||||
$retstring.="</select>";
|
$retstring.="</select>";
|
||||||
print $retstring;
|
print $retstring;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td><input name="opening" type="text" class="maxwidth100" value=""></td>';
|
print '<td>';
|
||||||
print '<td align="center"><input type="submit" name="add" class="button" value="'.$langs->trans("Start").'"></td>';
|
if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1')
|
||||||
print '</tr>';
|
{
|
||||||
print '</table></form>';
|
print '';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<input type="submit" name="add" class="button" value="'.$langs->trans("Start").'">';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1')
|
||||||
|
{
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td align="center">'.$langs->trans("InitialBankBalance").'</td>';
|
||||||
|
foreach($arrayofpaymentmode as $key => $val)
|
||||||
|
{
|
||||||
|
print '<td align="center">'.$langs->trans($val).'<br>'.$langs->trans("TheoricalAmount").'<br>'.$langs->trans("RealAmount").'</td>';
|
||||||
|
}
|
||||||
|
print '<td></td>';
|
||||||
|
print '</tr>';
|
||||||
|
print '<tr>';
|
||||||
|
// Initial amount
|
||||||
|
print '<td align="center"><input name="opening" type="text" class="maxwidth100" value="'.price($initialbalanceforterminal[0]).'"></td>';
|
||||||
|
foreach($arrayofpaymentmode as $key => $val)
|
||||||
|
{
|
||||||
|
print '<td align="center">';
|
||||||
|
print price($theoricalamountforterminal[0][$key]).'<br>';
|
||||||
|
print '<input name="'.$key.'" type="text" class="maxwidth100" value="'.GETPOST($key,'alpha').'">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<td align="center"><input type="submit" name="add" class="button" value="'.$langs->trans("Save").'"></td>';
|
||||||
|
print '</tr>';
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($action) || $action=="view")
|
if (empty($action) || $action=="view")
|
||||||
|
|||||||
@ -83,7 +83,9 @@ class CashControl extends CommonObject
|
|||||||
public $day_close;
|
public $day_close;
|
||||||
public $posmodule;
|
public $posmodule;
|
||||||
public $posnumber;
|
public $posnumber;
|
||||||
|
public $cash;
|
||||||
|
public $cheque;
|
||||||
|
public $card;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,6 +112,11 @@ class CashControl extends CommonObject
|
|||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
|
// Clean data
|
||||||
|
if (empty($this->cash)) $this->cash=0;
|
||||||
|
if (empty($this->cheque)) $this->cheque=0;
|
||||||
|
if (empty($this->card)) $this->card=0;
|
||||||
|
|
||||||
// Insert request
|
// Insert request
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."pos_cash_fence (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."pos_cash_fence (";
|
||||||
$sql .= "entity";
|
$sql .= "entity";
|
||||||
@ -119,14 +126,26 @@ class CashControl extends CommonObject
|
|||||||
$sql .= ", date_creation";
|
$sql .= ", date_creation";
|
||||||
$sql .= ", posmodule";
|
$sql .= ", posmodule";
|
||||||
$sql .= ", posnumber";
|
$sql .= ", posnumber";
|
||||||
|
$sql .= ", day_close";
|
||||||
|
$sql .= ", month_close";
|
||||||
|
$sql .= ", year_close";
|
||||||
|
$sql .= ", cash";
|
||||||
|
$sql .= ", cheque";
|
||||||
|
$sql .= ", card";
|
||||||
$sql .= ") VALUES (";
|
$sql .= ") VALUES (";
|
||||||
//$sql .= "'(PROV)', ";
|
//$sql .= "'(PROV)', ";
|
||||||
$sql .= $conf->entity;
|
$sql .= $conf->entity;
|
||||||
$sql .= ", ".$this->opening;
|
$sql .= ", ".($this->opening > 0 ? $this->opening : 0);
|
||||||
$sql .= ", 0"; // Draft by default
|
$sql .= ", 0"; // Draft by default
|
||||||
$sql .= ", '".$this->db->idate(dol_now())."'";
|
$sql .= ", '".$this->db->idate(dol_now())."'";
|
||||||
$sql .= ", '".$this->db->escape($this->posmodule)."'";
|
$sql .= ", '".$this->db->escape($this->posmodule)."'";
|
||||||
$sql .= ", '".$this->db->escape($this->posnumber)."'";
|
$sql .= ", '".$this->db->escape($this->posnumber)."'";
|
||||||
|
$sql .= ", ".($this->day_close > 0 ? $this->day_close : "null");
|
||||||
|
$sql .= ", ".($this->month_close > 0 ? $this->month_close : "null");
|
||||||
|
$sql .= ", ".$this->year_close;
|
||||||
|
$sql .= ", ".$this->cash;
|
||||||
|
$sql .= ", ".$this->cheque;
|
||||||
|
$sql .= ", ".$this->card;
|
||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|||||||
@ -1248,9 +1248,10 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
|||||||
// Cash Control
|
// Cash Control
|
||||||
if (! empty($conf->takepos->enabled) || ! empty($conf->cashdesk->enabled))
|
if (! empty($conf->takepos->enabled) || ! empty($conf->cashdesk->enabled))
|
||||||
{
|
{
|
||||||
$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list",$langs->trans("POS"),0,1, '', $mainmenu, 'cashcontrol');
|
$permtomakecashfence = ($user->rights->cashdesk->use ||$user->rights->takepos->use);
|
||||||
$newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create",$langs->trans("NewCashFence"),1,1);
|
$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list",$langs->trans("POS"),0,$permtomakecashfence, '', $mainmenu, 'cashcontrol');
|
||||||
$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list",$langs->trans("List"),1,1);
|
$newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create",$langs->trans("NewCashFence"),1,$permtomakecashfence);
|
||||||
|
$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list",$langs->trans("List"),1,$permtomakecashfence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user