From 27f803cab0e73b2fb2bf69a7fe67be604b8acc54 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Jun 2021 03:35:22 +0200 Subject: [PATCH] Fix receipt of cash fence must contains more legal information --- .../cashcontrol/class/cashcontrol.class.php | 19 +-- htdocs/compta/cashcontrol/report.php | 108 ++++++++++-------- 2 files changed, 71 insertions(+), 56 deletions(-) diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index a59816eebd7..59580cb7c46 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -93,10 +93,12 @@ class CashControl extends CommonObject 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>50, 'css'=>'center'), 'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'css'=>'center'), 'day_close' =>array('type'=>'integer', 'label'=>'Day close', 'enabled'=>1, 'visible'=>1, 'position'=>60, 'css'=>'center'), - 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>490), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), + 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>502), 'tms' =>array('type'=>'timestamp', 'label'=>'Tms', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>505), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'Import key', 'enabled'=>1, 'visible'=>0, 'position'=>510), + 'fk_user_creat' =>array('type'=>'integer:User', 'label'=>'userCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>600), + 'fk_user_valid' =>array('type'=>'integer:User', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>602), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'Import key', 'enabled'=>1, 'visible'=>0, 'position'=>700), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated')), ); @@ -115,21 +117,24 @@ class CashControl extends CommonObject public $cheque; public $card; - /** - * @var integer|string $date_valid - */ - public $date_valid; - /** * @var integer|string date_creation */ public $date_creation; + public $fk_user_creat; /** * @var integer|string $date_modification */ public $date_modification; + /** + * @var integer|string $date_valid + */ + public $date_valid; + public $fk_user_valid; + + const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; const STATUS_CLOSED = 1; // For the moment CLOSED = VALIDATED diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 653161ca3bc..12dff9d460a 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -26,7 +26,7 @@ /** * \file htdocs/compta/cashcontrol/report.php * \ingroup cashdesk|takepos - * \brief List of bank transactions + * \brief List of sales from POS */ if (!defined('NOREQUIREMENU')) { @@ -36,6 +36,8 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); // Disable browser notification } +$_GET['optioncss'] = "print"; + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -48,10 +50,8 @@ $langs->loadLangs(array("bills", "banks")); $id = GETPOST('id', 'int'); -$_GET['optioncss'] = "print"; - -$cashcontrol = new CashControl($db); -$cashcontrol->fetch($id); +$object = new CashControl($db); +$object->fetch($id); //$limit = GETPOST('limit')?GETPOST('limit', 'int'):$conf->liste_limit; $sortorder = 'ASC'; @@ -67,19 +67,19 @@ $arrayfields = array( 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), ); -$syear = $cashcontrol->year_close; -$smonth = $cashcontrol->month_close; -$sday = $cashcontrol->day_close; +$syear = $object->year_close; +$smonth = $object->month_close; +$sday = $object->day_close; -$posmodule = $cashcontrol->posmodule; -$terminalid = $cashcontrol->posnumber; +$posmodule = $object->posmodule; +$terminalid = $object->posnumber; // Security check if ($user->socid > 0) { // Protection if external user //$socid = $user->socid; accessforbidden(); } -if (!$user->rights->cashdesk->run && !$user->rights->takepos->run) { +if (empty($user->rights->cashdesk->run) && empty($user->rights->takepos->run)) { accessforbidden(); } @@ -106,8 +106,8 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON bu.url_id = f.rowid"; $sql.= " WHERE b.fk_account = ba.rowid"; // Define filter on invoice -$sql.= " AND f.module_source = '".$db->escape($cashcontrol->posmodule)."'"; -$sql.= " AND f.pos_source = '".$db->escape($cashcontrol->posnumber)."'"; +$sql.= " AND f.module_source = '".$db->escape($object->posmodule)."'"; +$sql.= " AND f.pos_source = '".$db->escape($object->posnumber)."'"; $sql.= " AND f.entity IN (".getEntity('facture').")"; // Define filter on data if ($syear && ! $smonth) $sql.= " AND dateo BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; @@ -151,19 +151,33 @@ if ($resql) { $i = 0; print "\n"; - print "

"; - if ($cashcontrol->status != $cashcontrol::STATUS_DRAFT) { - print $langs->trans("CashControl")." ".$cashcontrol->id; + print '
'; + print '

'; + if ($object->status != $object::STATUS_DRAFT) { + print $langs->trans("CashControl")." ".$object->id; } else { print $langs->trans("CashControl")." - ".$langs->trans("Draft"); } - print "
".$langs->trans("DateCreationShort").": ".dol_print_date($cashcontrol->date_creation, 'dayhour'); - print "

"; + print "

"; + print $langs->trans("DateCreationShort").": ".dol_print_date($object->date_creation, 'dayhour'); + print '
'.$mysoc->name; + $userauthor = $object->fk_user_valid; + if (empty($userauthor)) { + $userauthor = $object->fk_user_creat; + } + + $uservalid = new User($db); + if ($userauthor > 0) { + $uservalid->fetch($userauthor); + print '
'.$langs->trans("Author").': '.$uservalid->getFullName($langs); + } + print '
'.$langs->trans("Period").': '.$object->year_close.($object->month_close ? '-'.$object->month_close : '').($object->day_close ? '-'.$object->day_close : ''); + print '
'; $invoicetmp = new Facture($db); print "

"; - print $langs->trans("InitialBankBalance").' - '.$langs->trans("Cash")." : ".price($cashcontrol->opening); + print $langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").' : '.price($object->opening).''; print "

"; print '
'; @@ -206,7 +220,7 @@ if ($resql) { { print ''; print ''.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; - print ''.price($cashcontrol->opening).''; + print ''.price($object->opening).''; print ''; $first = "no"; }*/ @@ -232,8 +246,8 @@ if ($resql) { // Bank account print ''; print $bankaccount->getNomUrl(1); - if ($cashcontrol->posmodule == "takepos") { - $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'.$cashcontrol->posnumber; + if ($object->posmodule == "takepos") { + $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'.$object->posnumber; } else { $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'; } @@ -305,48 +319,44 @@ if ($resql) { include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; print ""; + print "
"; - //$cash = $amountpertype['LIQ'] + $cashcontrol->opening; - $cash = price2num($cash + $cashcontrol->opening, 'MT'); + //$cash = $amountpertype['LIQ'] + $object->opening; + $cash = price2num($cash + $object->opening, 'MT'); - print '

'; - print $langs->trans("Cash").": ".price($cash); - if ($cashcontrol->status == $cashcontrol::STATUS_VALIDATED && $cash != $cashcontrol->cash) { - print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->cash).''; + print '
'; + print '

'; + + print $langs->trans("Cash").': '.price($cash).''; + if ($object->status == $object::STATUS_VALIDATED && $cash != $object->cash) { + print ' <> '.$langs->trans("Declared").': '.price($object->cash).''; } - print "

"; + print "
"; //print '
'; - print $langs->trans("PaymentTypeCHQ").": ".price($cheque); - if ($cashcontrol->status == $cashcontrol::STATUS_VALIDATED && $cheque != $cashcontrol->cheque) { - print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->cheque).''; + print $langs->trans("PaymentTypeCHQ").': '.price($cheque).''; + if ($object->status == $object::STATUS_VALIDATED && $cheque != $object->cheque) { + print ' <> '.$langs->trans("Declared").': '.price($object->cheque).''; } - print "

"; + print "
"; //print '
'; - print $langs->trans("PaymentTypeCB").": ".price($bank); - if ($cashcontrol->status == $cashcontrol::STATUS_VALIDATED && $bank != $cashcontrol->card) { - print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->card).''; + print $langs->trans("PaymentTypeCB").': '.price($bank).''; + if ($object->status == $object::STATUS_VALIDATED && $bank != $object->card) { + print ' <> '.$langs->trans("Declared").': '.price($object->card).''; } - print "

"; + print "
"; // print '
'; if ($other) { - print '
'.$langs->trans("Other").": ".price($other)."

"; + print ''.$langs->trans("Other").': '.price($other).""; + print '
'; } - print "

"; - //save totals to DB - /* - $sql = "UPDATE ".MAIN_DB_PREFIX."pos_cash_fence "; - $sql .= "SET"; - $sql .= " cash='".$db->escape($cash)."'"; - $sql .= ", card='".$db->escape($bank)."'"; - $sql .= " where rowid = ".((int) $id); - $db->query($sql); - */ + print $langs->trans("Total").': '.price($cash + $cheque + $bank + $other).''; - print "

"; + print ''; + print ''; print '';