33require
'../../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/blockedlog/lib/blockedlog.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
48$langs->loadLangs(array(
"install",
"cashdesk",
"admin",
"banks",
"blockedlog"));
50$action =
GETPOST(
'action',
'aZ09');
51$backtopage =
GETPOST(
'backtopage',
'aZ09');
60$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
61$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
63if (empty($page) || $page == -1) {
66$offset = $limit * $page;
75$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'thirdpartylist';
77if ($contextpage ==
'takepos') {
81$arrayofpaymentmode = array(
'cash' =>
'Cash',
'cheque' =>
'Cheque',
'card' =>
'CreditCard');
83$arrayofposavailable = array();
85 $arrayofposavailable[
'cashdesk'] = $langs->trans(
'CashDesk').
' (cashdesk)';
88 $arrayofposavailable[
'takepos'] = $langs->trans(
'TakePOS').
' (takepos)';
96$extrafields->fetch_name_optionals_label(
$object->table_element);
99$hookmanager->initHooks(array(
'cashcontrolcard',
'globalcard'));
102include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
105if ($user->socid > 0) {
109if (!$user->hasRight(
"cashdesk",
"run") && !$user->hasRight(
"takepos",
"run")) {
113$permissiontoadd = ($user->hasRight(
"cashdesk",
"run") || $user->hasRight(
"takepos",
"run"));
114$permissiontodelete = ($user->hasRight(
"cashdesk",
"run") || $user->hasRight(
"takepos",
"run")) || ($permissiontoadd &&
$object->status == 0);
116$sqlfilteronopdate =
'';
134 } elseif (empty(
$object->day_close) && empty(
$object->month_close)) {
144 if ($syear && !$smonth) {
147 } elseif ($syear && $smonth && !$sday) {
150 } elseif ($syear && $smonth && $sday) {
151 $datestart =
dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear,
'tzuserrel');
152 $dateend =
dol_mktime(23, 59, 59, $smonth, $sday, $syear,
'tzuserrel');
157$sqlfilteronopdate .=
" AND dateo < '".$db->idate((
int) $datestart).
"'";
165if ($action ==
"create" || $action ==
"start" || $action ==
'valid' || $action ==
'close') {
166 if ($action ==
'valid' || $action ==
'close') {
167 $posmodule =
$object->posmodule;
168 $terminalid =
$object->posnumber;
169 $terminaltouse = $terminalid;
172 $smonth =
$object->month_close;
174 } elseif (
GETPOST(
'posnumber',
'alpha') !=
'' &&
GETPOST(
'posnumber',
'alpha') !=
'-1') {
175 $posmodule =
GETPOST(
'posmodule',
'alpha');
176 $terminalid =
GETPOST(
'posnumber',
'alpha');
177 $terminaltouse = $terminalid;
179 if ($terminaltouse ==
'1' && $posmodule ==
'cashdesk') {
192if (empty($backtopage)) {
193 $backtopage = DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_card.php?id='.(!empty($id) &&
$id > 0 ?
$id :
'__ID__');
195$backurlforlist = DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_list.php';
196$triggermodname =
'CACHCONTROL_MODIFY';
199 setEventMessages($langs->trans(
"CashDesk").
" - ".$langs->trans(
"NotConfigured"),
null,
'errors');
203if (
GETPOST(
'cancel',
'alpha')) {
204 if ($action ==
'valid') {
222if ($action ==
"start" && $permissiontoadd) {
223 if (!
GETPOST(
'posmodule',
'alpha') ||
GETPOST(
'posmodule',
'alpha') ==
'-1') {
224 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Module")),
null,
'errors');
228 if (
GETPOST(
'posnumber',
'alpha') ==
'') {
229 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CashDesk")),
null,
'errors');
233 if (!
GETPOST(
'closeyear',
'alpha') ||
GETPOST(
'closeyear',
'alpha') ==
'-1') {
234 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Year")),
null,
'errors');
238} elseif ($action ==
"add" && $permissiontoadd) {
239 if (
GETPOST(
'opening',
'alpha') ==
'') {
240 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InitialBankBalance")),
null,
'errors');
244 foreach ($arrayofpaymentmode as $key => $val) {
256 $tmparray =
dol_getdate($dateclosegmt,
false,
'gmt');
260 $object->year_close = $tmparray[
'year'];
262 $object->hour_close = $tmparray[
'hours'];
263 $object->min_close = $tmparray[
'minutes'];
264 $object->sec_close = $tmparray[
'seconds'];
282 if ($contextpage ==
'takepos') {
285 parent.location.href='../../takepos/index.php?place='+parent.place;
291if ($action ==
"valid" && $permissiontoadd) {
308 $cash_lifetime = $card_lifetime = $cheque_lifetime = 0;
312 $datefilter =
'p.datep';
313 $modulesourcefilter =
'f.module_source';
314 $amountfield =
'pf.amount';
317 $datefilter =
'bl.date_creation';
318 $modulesourcefilter =
'bl.module_source';
319 $amountfield =
'bl.amounts';
323 $lifetimeamount = array();
324 $lifetimenb = array();
328 foreach ($arrayofpaymentmode as $key => $val) {
335 $sql =
"SELECT SUM(".$db->sanitize($amountfield).
") as total, COUNT(*) as nb";
336 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"facture as f,";
337 $sql .=
" ".MAIN_DB_PREFIX.
"paiement as p";
339 $sql .=
" ".$db->sanitize($joinleft).
" JOIN ".MAIN_DB_PREFIX.
"blockedlog as bl ON bl.action = 'PAYMENT_CUSTOMER_CREATE'";
340 $sql .=
" AND bl.element = 'payment' AND bl.fk_object = p.rowid AND bl.entity = ".((int) $conf->entity).
",";
342 $sql .=
" ".MAIN_DB_PREFIX.
"c_paiement as cp";
343 $sql .=
" WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement";
344 $sql .=
" AND ".$db->sanitize($modulesourcefilter).
" = '".$db->escape($posmodule).
"'";
345 $sql .=
" AND f.pos_source = '".$db->escape($terminalid).
"'";
346 $sql .=
" AND p.entity = ".((int) $conf->entity);
347 $sql .=
" AND ".$db->sanitize($datefilter).
" <= '".$db->idate((
int) $datee).
"'";
348 if ($key ==
'cash') {
349 $sql .=
" AND cp.code = 'LIQ'";
350 } elseif ($key ==
'cheque') {
351 $sql .=
" AND cp.code = 'CHQ'";
352 } elseif ($key ==
'card') {
353 $sql .=
" AND cp.code = 'CB'";
360 $resql = $db->query($sql);
362 $lifetimeamount[$terminalid][$key] = 0;
363 $lifetimenb[$terminalid][$key] = 0;
365 $obj = $db->fetch_object($resql);
367 $lifetimeamount[$terminalid][$key] =
price2num($lifetimeamount[$terminalid][$key] + $obj->total);
368 $lifetimenb[$terminalid][$key] = $obj->nb;
375 $cash_lifetime = $lifetimeamount[$terminalid][
'cash'];
376 $card_lifetime = $lifetimeamount[$terminalid][
'card'];
377 $cheque_lifetime = $lifetimeamount[$terminalid][
'cheque'];
379 $object->cash_lifetime = $cash_lifetime;
380 $object->card_lifetime = $card_lifetime;
381 $object->cheque_lifetime = $cheque_lifetime;
385 $sql =
"SELECT action, module_source, object_format, date_creation";
386 $sql .=
" FROM ".MAIN_DB_PREFIX.
"blockedlog";
387 $sql .=
" WHERE entity = ".((int) $conf->entity);
388 $sql .=
" AND action IN ('PAYMENT_CUSTOMER_CREATE')";
389 $sql .=
" AND module_source = '".$db->escape($posmodule).
"'";
391 $sql .= $db->order(
"date_creation",
"ASC");
392 $sql .= $db->plimit(1);
394 $firstrecorddate = 0;
395 $resql = $db->query($sql);
397 $obj = $db->fetch_object($resql);
399 $firstrecorddate = $db->jdate($obj->date_creation);
402 if ($firstrecorddate) {
403 $object->lifetime_start = $firstrecorddate;
406 $result =
$object->update($user);
408 $result2 =
$object->close($user);
415 if ($result <= 0 || $result2 <= 0) {
423 if ($contextpage ==
'takepos') {
426 location.href='cashcontrol_card.php?id=".$id.
"&contextpage=takepos';
434if ($action ==
'confirm_delete' && !empty($permissiontodelete)) {
438 dol_print_error(
null,
'Error, object must be fetched before being deleted');
442 $result =
$object->delete($user);
446 header(
"Location: ".$backurlforlist);
462$form =
new Form($db);
464$initialbalanceforterminal = array();
465$theoricalamountforterminal = array();
466$theoricalnbofinvoiceforterminal = array();
469llxHeader(
'', $langs->trans(
"CashControl"));
473if ($action ==
"create" || $action ==
"start" || $action ==
'close') {
474 if ($action ==
'close') {
475 $posmodule =
$object->posmodule;
476 $terminalid =
$object->posnumber;
477 $terminaltouse = $terminalid;
480 $smonth =
$object->month_close;
482 } elseif (
GETPOST(
'posnumber',
'alpha') !=
'' &&
GETPOST(
'posnumber',
'alpha') !=
'-1') {
483 $posmodule =
GETPOST(
'posmodule',
'alpha');
484 $terminalid =
GETPOST(
'posnumber',
'alpha');
485 $terminaltouse = $terminalid;
487 if ($terminaltouse ==
'1' && $posmodule ==
'cashdesk') {
491 if ($posmodule ==
'cashdesk' && $terminaltouse !=
'' && $terminaltouse !=
'1') {
493 setEventMessages($langs->trans(
"OnlyTerminal1IsAvailableForCashDeskModule"),
null,
'errors');
498 if (isset($terminalid) && $terminalid !=
'' && isset($posmodule)) {
500 foreach ($arrayofpaymentmode as $key => $val) {
501 if ($key !=
'cash') {
502 $initialbalanceforterminal[$terminalid][$key] = 0;
507 $vartouse =
'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse;
513 $sql =
"SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX.
"bank";
514 $sql .=
" WHERE fk_account = ".((int) $bankid);
515 $sql .= $sqlfilteronopdate;
517 $resql = $db->query($sql);
519 $obj = $db->fetch_object($resql);
521 $initialbalanceforterminal[$terminalid][$key] = $obj->total;
527 setEventMessages($langs->trans(
"SetupOfTerminalNotComplete", $terminaltouse),
null,
'errors');
534 $datefilter =
'p.datep';
535 $modulesourcefilter =
'f.module_source';
536 $amountfield =
'pf.amount';
539 $datefilter =
'bl.date_creation';
540 $modulesourcefilter =
'bl.module_source';
541 $amountfield =
'bl.amounts';
547 foreach ($arrayofpaymentmode as $key => $val) {
554 $sql =
"SELECT SUM(".$db->sanitize($amountfield).
") as total, COUNT(*) as nb";
555 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"facture as f,";
556 $sql .=
" ".MAIN_DB_PREFIX.
"paiement as p";
558 $sql .=
" ".$db->sanitize($joinleft).
" JOIN ".MAIN_DB_PREFIX.
"blockedlog as bl ON bl.action = 'PAYMENT_CUSTOMER_CREATE'";
559 $sql .=
" AND bl.element = 'payment' AND bl.fk_object = p.rowid AND bl.entity = ".((int) $conf->entity).
",";
561 $sql .=
" ".MAIN_DB_PREFIX.
"c_paiement as cp";
562 $sql .=
" WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement";
563 $sql .=
" AND ".$db->sanitize($modulesourcefilter).
" = '".$db->escape($posmodule).
"'";
564 $sql .=
" AND f.pos_source = '".$db->escape($terminalid).
"'";
565 $sql .=
" AND p.entity = ".((int) $conf->entity);
566 $sql .=
" AND ".$db->sanitize($datefilter).
" BETWEEN '".$db->idate((
int) $dates).
"' AND '".$db->idate((
int) $datee).
"'";
567 if ($key ==
'cash') {
568 $sql .=
" AND cp.code = 'LIQ'";
569 } elseif ($key ==
'cheque') {
570 $sql .=
" AND cp.code = 'CHQ'";
571 } elseif ($key ==
'card') {
572 $sql .=
" AND cp.code = 'CB'";
578 $resql = $db->query($sql);
580 $obj = $db->fetch_object($resql);
582 $theoricalamountforterminal[$terminalid][$key] = $obj->total;
583 $theoricalnbofinvoiceforterminal[$terminalid][$key] = $obj->nb;
592if ($action ==
"create" || $action ==
"start") {
593 print
load_fiche_titre($langs->trans(
"CashControl").
" - ".$langs->trans(
"New"),
'',
'cash-register');
595 if ($action ==
'start') {
599 setEventMessages($langs->trans(
"CashControlEndDateMustBeBeforeNow"),
null,
'errors');
604 if ($endperiod >=
dol_now() &&
$mysoc->country_code ==
'FR') {
605 setEventMessages($langs->trans(
"CashControlEndDayMustNotBeInPast"),
null,
'errors');
611 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
612 print
'<input type="hidden" name="token" value="'.newToken().
'">';
613 if ($contextpage ==
'takepos') {
614 print
'<input type="hidden" name="contextpage" value="takepos">';
617 print
'<input type="hidden" name="action" value="add">';
618 } elseif ($action ==
'close') {
619 print
'<input type="hidden" name="action" value="valid">';
620 print
'<input type="hidden" name="id" value="'.$id.
'">';
622 print
'<input type="hidden" name="action" value="start">';
625 print
'<!-- Table to start cash control -->'.
"\n";
626 print
'<div class="div-table-responsive-no-min">'.
"\n";
627 print
'<table class="noborder centpercent">'.
"\n";
628 print
'<tr class="liste_titre">';
629 print
'<td>'.$langs->trans(
"Module").
'</td>';
630 print
'<td>'.$langs->trans(
"Terminal").
'</td>';
631 print
'<td>'.$langs->trans(
"Year").
'</td>';
632 print
'<td>'.$langs->trans(
"Month").
'</td>';
633 print
'<td>'.$langs->trans(
"Day").
'</td>';
640 print
'<tr class="oddeven nohover">';
641 print
'<td>'.$form->selectarray(
'posmodule', $arrayofposavailable,
GETPOST(
'posmodule',
'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).
'</td>';
644 $arrayofpos = array();
646 for ($i = 1; $i <= $numterminals; $i++) {
648 $arrayofpos[$i] = array(
'id' => $i,
'label' => (($nameofterminal !=
"TAKEPOS_TERMINAL_NAME_".$i) ?
'#'.$i.
' '.$nameofterminal : $i),
'data-html' => (($nameofterminal !=
"TAKEPOS_TERMINAL_NAME_".$i) ?
'#'.$i.
' - '.$nameofterminal : $i));
650 $selectedposnumber = 0;
653 $selectedposnumber = 1;
656 print $form->selectarray(
'posnumber', $arrayofpos, GETPOSTISSET(
'posnumber') ?
GETPOSTINT(
'posnumber') : $selectedposnumber, $showempty);
661 $retstring =
'<select'.($disabled ?
' disabled' :
'').
' class="flat valignmiddle maxwidth75imp" id="'.$prefix.
'year" name="'.$prefix.
'year">';
662 for ($year = $syear - 10; $year < $syear + 10; $year++) {
663 $retstring .=
'<option value="'.$year.
'"'.($year == $syear ?
' selected' :
'').
'>'.$year.
'</option>';
665 $retstring .=
"</select>\n";
670 $retstring =
'<select'.($disabled ?
' disabled' :
'').
' class="flat valignmiddle maxwidth75imp" id="'.$prefix.
'month" name="'.$prefix.
'month">';
671 $retstring .=
'<option value="0"></option>';
672 for ($month = 1; $month <= 12; $month++) {
673 $retstring .=
'<option value="'.$month.
'"'.($month == $smonth ?
' selected' :
'').
'>';
674 $retstring .=
dol_print_date(mktime(12, 0, 0, $month, 1, 2000),
"%b");
675 $retstring .=
"</option>";
677 $retstring .=
"</select>";
682 $retstring =
'<select'.($disabled ?
' disabled' :
'').
' class="flat valignmiddle maxwidth50imp" id="'.$prefix.
'day" name="'.$prefix.
'day">';
683 $retstring .=
'<option value="0" selected> </option>';
684 for ($day = 1; $day <= 31; $day++) {
685 $retstring .=
'<option value="'.$day.
'"'.($day == $sday ?
' selected' :
'').
'>'.$day.
'</option>';
687 $retstring .=
"</select>";
692 if ($action ==
'start' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'-1') {
695 print
'<input type="submit" name="add" class="button" value="'.$langs->trans(
"Start").
'">';
703 if ($action ==
'start' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'-1') {
704 $posmodule =
GETPOST(
'posmodule',
'alpha');
705 $terminalid =
GETPOST(
'posnumber',
'alpha');
709 print
'<div class="div-table-responsive-no-min">';
710 print
'<table class="noborder centpercent">';
712 print
'<tr class="liste_titre">';
714 print
'<td class="center">'.$langs->trans(
"InitialBankBalance");
716 print
'<span class="small opacitymedium">'.$langs->trans(
"at").
' '.
dol_print_date($datestart,
'standard',
'gmt').
' UTC</span>';
728 print
'<tr class="liste_titre">';
730 print
'<td class="center">'.$langs->trans(
"Cash");
766 print
'<td>'.$langs->trans(
"TheoricalAmount").
'</td>';
767 print
'<td class="center">';
768 print
price($initialbalanceforterminal[$terminalid][
'cash']).
'<br>';
784 print
'<td>'.$langs->trans(
"RealAmount").
'</td>';
786 print
'<td class="center">';
788 if ($action ==
'close') {
791 print
'name="opening" type="text" class="maxwidth100 center" value="';
792 if ($action ==
'close') {
796 print (GETPOSTISSET(
'opening') ?
price2num(
GETPOST(
'opening',
'alpha')) :
price($initialbalanceforterminal[$terminalid][
'cash']));
812 print
'<td class="center">';
813 print
'<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
814 if ($action ==
'start') {
815 print
'<input type="submit" name="add" class="button button-save" value="'.$langs->trans(
"Start").
'">';
816 } elseif ($action ==
'close') {
817 print
'<input type="submit" name="valid" class="button" value="'.$langs->trans(
"Validate").
'">';
830if (empty($action) || $action ==
"view" || $action ==
"close") {
834 print $langs->trans(
"ErrorRecordNotFound");
837 $head[0][0] = DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_card.php?id='.
$object->id;
838 $head[0][1] = $langs->trans(
"CashControl");
839 $head[0][2] =
'cashcontrol';
841 print
dol_get_fiche_head($head,
'cashcontrol', $langs->trans(
"CashControl"), -1,
'account');
843 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
845 $morehtmlref =
'<div class="refidno">';
846 $morehtmlref .=
'</div>';
849 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'rowid', $morehtmlref);
851 print
'<div class="fichecenter">';
852 print
'<div class="fichehalfleft">';
853 print
'<div class="underbanner clearboth"></div>';
854 print
'<table class="border tableforfield centpercent">';
856 print
'<tr><td class="titlefield nowrap">';
857 print $langs->trans(
"Ref");
862 print
'<tr><td valign="middle">'.$langs->trans(
"Module").
'</td><td>';
866 print
'<tr><td valign="middle">'.$langs->trans(
"Terminal").
'</td><td>';
870 print
'<tr><td class="titlefield nowrap">';
871 print $langs->trans(
"DateCreationShort");
872 print
'</td><td colspan="3">';
876 print
'<tr><td class="nowrap">';
877 print $langs->trans(
"Period");
880 print(
$object->month_close ?
"-".sprintf(
"%02d",
$object->month_close) :
"");
881 print(
$object->day_close ?
"-".sprintf(
"%02d",
$object->day_close) :
"");
885 $htmltooltip .=
dol_print_date($datestart,
'standard',
'tzuserrel').
' - ';
886 $htmltooltip .=
dol_print_date($dateend,
'standard',
'tzuserrel');
887 $htmltooltip .=
'<br><span class="small opacitymedium">UTC : ';
888 $htmltooltip .=
dol_print_date($datestart,
'standard',
'gmt').
' - ';
890 $htmltooltip .=
'</span>';
891 print $form->textwithpicto(
'', $htmltooltip);
895 print
'<tr><td class="titlefield nowrap">';
896 print $langs->trans(
"LifetimeAmount");
897 print
'</td><td colspan="3">';
898 print
'<span class="amount">'.price(
$object->card_lifetime +
$object->cheque_lifetime +
$object->cash_lifetime, 0, $langs, 1, -1, -1, $conf->currency).
'</span>';
899 print
' <span class="opacitymedium">'.$langs->trans(
"since").
' '.
dol_print_date(
$object->lifetime_start,
'dayhour').
' ('.$langs->trans(
"AllTerminals").
')</span>';
906 print
'<div class="fichehalfright">';
907 print
'<div class="underbanner clearboth"></div>';
909 print
'<table class="noborder paymenttable centpercent">';
911 if (
$object->status == $object::STATUS_CLOSED) {
912 print
'<tr class="liste_titre"><td class="liste_titre">'.$langs->trans(
"Summary").
'</td>';
913 print
'<td class="liste_titre right">'.$langs->trans(
"InitialBankBalance").
'</td>';
914 print
'<td class="liste_titre right">'.$langs->trans(
"Sales").
'</td>';
915 print
'<td class="liste_titre right">'.$langs->trans(
"EndBankBalance").
'</td>';
918 foreach ($arrayofpaymentmode as $key => $val) {
919 $newkey = $key.
'_declared';
920 if (!property_exists($object, $key)) {
924 $realamountforpaymentmode =
$object->$key;
925 $declaredamountforpaymentmode =
$object->$newkey;
928 print
'<td class="">'.$langs->trans($val).
'</td>';
929 print
'<td class="right">';
930 if ($key ==
'cash') {
931 print
'<span class="amount">'.price(
$object->opening, 0, $langs, 1, -1, -1, $conf->currency).
'</span>';
934 print
'<td class="right">';
935 if ($realamountforpaymentmode) {
936 print
'<span class="amount">'.($realamountforpaymentmode >= 0 ?
'+' :
'').
price($realamountforpaymentmode, 0, $langs, 1, -1, -1, $conf->currency).
'</span>';
939 print
'<td class="right">';
940 print
'<span class="amount';
941 if ((($key ==
'cash' ?
$object->opening : 0) + $realamountforpaymentmode) != $declaredamountforpaymentmode) {
945 print
price($declaredamountforpaymentmode, 0, $langs, 1, -1, -1, $conf->currency).
'</span>';
953 print
'</div></div>';
954 print
'<div class="clearboth"></div>';
958 if ($action !=
'close') {
959 print
'<div class="tabsAction">';
962 print
'<div class="inline-block divButAction"><a target="_blank" rel="noopener noreferrer" class="butAction" href="report.php?id='.((int) $id).
'">'.$langs->trans(
'PrintReport').
'</a></div>';
965 print
'<div class="inline-block divButAction"><a target="_blank" rel="noopener noreferrer" class="butAction" href="report.php?id='.((int) $id).
'&summaryonly=1">'.$langs->trans(
'PrintReportNoDetail').
'</a></div>';
968 if (
$object->status == CashControl::STATUS_DRAFT) {
969 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.((int) $id).
'&action=close&token='.
newToken().
'&contextpage='.$contextpage.
'">'.$langs->trans(
'Close').
'</a></div>';
971 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.((int) $id).
'&action=confirm_delete&token='.
newToken().
'">'.$langs->trans(
'Delete').
'</a></div>';
978 if ($contextpage !=
'takepos') {
979 print
'<center><iframe src="report.php?id='.$id.
'" width="60%" height="800"></iframe></center>';
982 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'" name="formclose">';
983 print
'<input type="hidden" name="token" value="'.newToken().
'">';
984 if ($contextpage ==
'takepos') {
985 print
'<input type="hidden" name="contextpage" value="takepos">';
988 print
'<input type="hidden" name="action" value="add">';
989 } elseif ($action ==
'close') {
990 print
'<input type="hidden" name="action" value="valid">';
991 print
'<input type="hidden" name="id" value="'.$id.
'">';
993 print
'<input type="hidden" name="action" value="start">';
997 if (($action ==
'start' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'-1') || $action ==
'close') {
998 $posmodule =
$object->posmodule;
999 $terminalid =
$object->posnumber;
1003 print
'<!-- section to enter declareda mount -->';
1004 print
'<div class="div-table-responsive-no-min">';
1005 print
'<table class="noborder centpercent">';
1007 print
'<tr class="liste_titre">';
1009 print
'<td class="center">'.$langs->trans(
"InitialBankBalance");
1011 print
'<span class="small opacitymedium">'.$langs->trans(
"at").
' '.
dol_print_date($datestart,
'standard',
'gmt').
' UTC</span>';
1014 print
'<td align="center" class="hide0" colspan="'.count($arrayofpaymentmode).
'">';
1015 print $langs->trans(
"AmountAtEndOfPeriod");
1017 print
'<span class="small opacitymedium">'.$langs->trans(
"at").
' '.
dol_print_date($dateend,
'standard',
'gmt').
' UTC</span>';
1022 print
'<tr class="liste_titre">';
1024 print
'<td class="center">'.$langs->trans(
"Cash");
1028 foreach ($arrayofpaymentmode as $key => $val) {
1029 print
'<td align="center"'.($i == 0 ?
' class="hide0"' :
'').
'>'.$langs->trans($val);
1039 print
'<td>'.$langs->trans(
"NbOfPayments").
'</td>';
1040 print
'<td class="center">';
1044 foreach ($arrayofpaymentmode as $key => $val) {
1045 print
'<td align="center"'.($i == 0 ?
' class="hide0"' :
'').
'>';
1046 print $theoricalnbofinvoiceforterminal[$terminalid][$key];
1051 print
'<td align="center"></td>';
1056 print
'<td>'.$langs->trans(
"TheoricalAmount").
'</td>';
1057 print
'<td class="center">';
1058 print
price($initialbalanceforterminal[$terminalid][
'cash']).
'<br>';
1063 foreach ($arrayofpaymentmode as $key => $val) {
1064 print
'<td class="smallheight center'.($i == 0 ?
' hide0' :
'').
'">';
1065 if ($key ==
'cash') {
1066 print
price(
$object->opening + $theoricalamountforterminal[$terminalid][$key]).
'<br>';
1067 print
'<span class="opacitymedium small">('.price(
$object->opening).
' + '.
price($theoricalamountforterminal[$terminalid][$key]).
')</span>';
1069 print
price($theoricalamountforterminal[$terminalid][$key]).
'<br>';
1071 print
'<input type="hidden" name="'.$key.
'_calculated" value="'.$theoricalamountforterminal[$terminalid][$key].
'">';
1077 print
'<td align="center"></td>';
1082 print
'<td>'.$langs->trans(
"RealAmount").
'</td>';
1085 print
'<td class="center">';
1087 if ($action ==
'close') {
1090 print
'name="opening" type="text" class="maxwidth100 center" value="';
1091 if ($action ==
'close') {
1095 print(GETPOSTISSET(
'opening') ?
price2num(
GETPOST(
'opening',
'alpha')) :
price($initialbalanceforterminal[$terminalid][
'cash']));
1102 foreach ($arrayofpaymentmode as $key => $val) {
1103 print
'<td class="center '.($i == 0 ?
' hide0' :
'').
'">';
1105 if ($action ==
'start') {
1108 print
'name="'.$key.
'_amount" type="text"'.($key ==
'cash' ?
' autofocus' :
'').
' class="maxwidth100 center" value="'.
GETPOST($key.
'_amount',
'alpha').
'">';
1114 print
'<td class="center">';
1115 print
'<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1116 if ($action ==
'start') {
1117 print
'<input type="submit" name="add" class="button button-save" value="'.$langs->trans(
"Save").
'">';
1118 } elseif ($action ==
'close') {
1119 print
'<input type="submit" name="valid" class="button" value="'.$langs->trans(
"Close").
'">';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
isALNERunningVersion($blockedlogtestalreadydone=0)
Return if the application is executed with the LNE requirements on.
Class to manage cash fence.
dol_get_first_hour($date, $gm='tzserver')
Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.