33require
'../../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/blockedlog/lib/blockedlog.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
49$langs->loadLangs(array(
"install",
"cashdesk",
"admin",
"banks",
"blockedlog"));
51$action =
GETPOST(
'action',
'aZ09');
52$backtopage =
GETPOST(
'backtopage',
'aZ09');
61$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
62$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
64if (empty($page) || $page == -1) {
67$offset = $limit * $page;
76$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'thirdpartylist';
78if ($contextpage ==
'takepos') {
82$arrayofpaymentmode = array(
'cash' =>
'Cash',
'cheque' =>
'Cheque',
'card' =>
'CreditCard');
84$arrayofposavailable = array();
86 $arrayofposavailable[
'cashdesk'] = $langs->trans(
'CashDesk').
' (cashdesk)';
89 $arrayofposavailable[
'takepos'] = $langs->trans(
'TakePOS').
' (takepos)';
97$extrafields->fetch_name_optionals_label(
$object->table_element);
100$hookmanager->initHooks(array(
'cashcontrolcard',
'globalcard'));
103include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
106if ($user->socid > 0) {
110if (!$user->hasRight(
"cashdesk",
"run") && !$user->hasRight(
"takepos",
"run")) {
114$permissiontoadd = $user->hasRight(
"takepos",
"run");
115$permissiontodelete = $user->hasRight(
"takepos",
"run") || ($permissiontoadd &&
$object->status == 0);
116$permissiontoeditextra = $permissiontoadd;
117if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
119 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
121$permissiontoreopen = $user->hasRight(
"takepos",
"run");
124$sqlfilteronopdate =
'';
145 } elseif (empty(
$object->day_close) && empty(
$object->month_close)) {
154 if ($syear && !$smonth) {
157 } elseif ($syear && $smonth && !$sday) {
160 } elseif ($syear && $smonth && $sday) {
161 $datestart =
dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear,
'tzuserrel');
162 $dateend =
dol_mktime(23, 59, 59, $smonth, $sday, $syear,
'tzuserrel');
164 setEventMessages($langs->trans(
'YearNotDefined'),
null,
'errors');
167$sqlfilteronopdate .=
" AND dateo < '".$db->idate((
int) $datestart).
"'";
175if ($action ==
"create" || $action ==
"start" || $action ==
'valid' || $action ==
'close') {
176 if ($action ==
'valid' || $action ==
'close') {
177 $posmodule =
$object->posmodule;
178 $terminalid =
$object->posnumber;
179 $terminaltouse = $terminalid;
182 $smonth =
$object->month_close;
184 } elseif (
GETPOST(
'posnumber',
'alpha') !=
'' &&
GETPOST(
'posnumber',
'alpha') !=
'-1') {
185 $posmodule =
GETPOST(
'posmodule',
'alpha');
186 $terminalid =
GETPOST(
'posnumber',
'alpha');
187 $terminaltouse = $terminalid;
189 if ($terminaltouse ==
'1' && $posmodule ==
'cashdesk') {
202if (empty($backtopage)) {
203 $backtopage = DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_card.php?id='.(!empty($id) &&
$id > 0 ?
$id :
'__ID__');
205$backurlforlist = DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_list.php';
206$triggermodname =
'CACHCONTROL_MODIFY';
209 setEventMessages($langs->trans(
"CashDesk").
" - ".$langs->trans(
"NotConfigured"),
null,
'errors');
213if (
GETPOST(
'cancel',
'alpha')) {
214 if ($action ==
'valid') {
221if ($action ==
"reopen" && $permissiontoreopen) {
222 $result =
$object->setStatut($object::STATUS_DRAFT,
null,
'',
'CASHFENCE_MODIFY');
230if ($action ==
"start" && $permissiontoadd) {
231 if (!
GETPOST(
'posmodule',
'alpha') ||
GETPOST(
'posmodule',
'alpha') ==
'-1') {
232 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Module")),
null,
'errors');
236 if (
GETPOST(
'posnumber',
'alpha') ==
'') {
237 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CashDesk")),
null,
'errors');
241 if (!
GETPOST(
'closeyear',
'alpha') ||
GETPOST(
'closeyear',
'alpha') ==
'-1') {
242 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Year")),
null,
'errors');
246} elseif ($action ==
"add" && $permissiontoadd) {
247 if (
GETPOST(
'opening',
'alpha') ==
'') {
248 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InitialBankBalance")),
null,
'errors');
252 foreach ($arrayofpaymentmode as $key => $val) {
264 $tmparray =
dol_getdate($dateclosegmt,
false,
'gmt');
268 $object->year_close = $tmparray[
'year'];
270 $object->hour_close = $tmparray[
'hours'];
271 $object->min_close = $tmparray[
'minutes'];
272 $object->sec_close = $tmparray[
'seconds'];
290 if ($contextpage ==
'takepos') {
293 parent.location.href='../../takepos/index.php?place='+parent.place;
299if ($action ==
"valid" && $permissiontoadd) {
316 $cash_lifetime = $card_lifetime = $cheque_lifetime = 0;
320 $datefilter =
'p.datep';
321 $modulesourcefilter =
'f.module_source';
322 $amountfield =
'pf.amount';
323 $possource =
'f.pos_source';
324 $fieldentity =
'p.entity';
327 $datefilter =
'bl.date_creation';
328 $modulesourcefilter =
'bl.module_source';
329 $amountfield =
'bl.amounts';
330 $possource =
'bl.pos_source';
331 $fieldentity =
'bl.entity';
335 $lifetimeamount = array();
336 $lifetimenb = array();
340 foreach ($arrayofpaymentmode as $key => $val) {
347 $sql =
"SELECT SUM(".$db->sanitize($amountfield).
") as total, COUNT(*) as nb";
348 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"facture as f,";
349 $sql .=
" ".MAIN_DB_PREFIX.
"paiement as p";
350 $sql .=
" ".$db->sanitize($joinleft).
" JOIN ".MAIN_DB_PREFIX.
"blockedlog as bl ON bl.action = 'PAYMENT_CUSTOMER_CREATE'";
351 $sql .=
" AND bl.element = 'payment' AND bl.fk_object = p.rowid AND bl.entity = ".((int)
$conf->entity).
",";
352 $sql .=
" ".MAIN_DB_PREFIX.
"c_paiement as cp";
353 $sql .=
" WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement";
354 $sql .=
" AND ".$db->sanitize($modulesourcefilter).
" = '".$db->escape($posmodule).
"'";
355 $sql .=
" AND ".$db->sanitize($possource).
" = '".$db->escape($terminalid).
"'";
356 $sql .=
" AND ".$db->sanitize($fieldentity).
" = ".((int)
$conf->entity);
357 $sql .=
" AND ".$db->sanitize($datefilter).
" <= '".$db->idate((
int) $datee).
"'";
358 if ($key ==
'cash') {
359 $sql .=
" AND cp.code = 'LIQ'";
360 } elseif ($key ==
'cheque') {
361 $sql .=
" AND cp.code = 'CHQ'";
362 } elseif ($key ==
'card') {
363 $sql .=
" AND cp.code = 'CB'";
365 dol_print_error(
null,
'Value for key = '.$key.
' not supported');
370 $resql = $db->query($sql);
372 $lifetimeamount[$terminalid][$key] = 0;
373 $lifetimenb[$terminalid][$key] = 0;
375 $obj = $db->fetch_object($resql);
377 $lifetimeamount[$terminalid][$key] =
price2num($lifetimeamount[$terminalid][$key] + $obj->total);
378 $lifetimenb[$terminalid][$key] = $obj->nb;
381 dol_print_error($db);
385 $cash_lifetime = $lifetimeamount[$terminalid][
'cash'];
386 $card_lifetime = $lifetimeamount[$terminalid][
'card'];
387 $cheque_lifetime = $lifetimeamount[$terminalid][
'cheque'];
389 $object->cash_lifetime = $cash_lifetime;
390 $object->card_lifetime = $card_lifetime;
391 $object->cheque_lifetime = $cheque_lifetime;
395 $sql =
"SELECT action, module_source, object_format, date_creation";
396 $sql .=
" FROM ".MAIN_DB_PREFIX.
"blockedlog";
397 $sql .=
" WHERE entity = ".((int)
$conf->entity);
398 $sql .=
" AND action IN ('PAYMENT_CUSTOMER_CREATE')";
399 $sql .=
" AND module_source = '".$db->escape($posmodule).
"'";
401 $sql .= $db->order(
"date_creation",
"ASC");
402 $sql .= $db->plimit(1);
404 $firstrecorddate = 0;
405 $resql = $db->query($sql);
407 $obj = $db->fetch_object($resql);
409 $firstrecorddate = $db->jdate($obj->date_creation);
412 if ($firstrecorddate) {
413 $object->lifetime_start = $firstrecorddate;
416 $result =
$object->update($user);
418 $result2 =
$object->close($user);
425 if ($result <= 0 || $result2 <= 0) {
429 setEventMessages($langs->trans(
"CashFenceDone"),
null);
433 if ($contextpage ==
'takepos') {
436 location.href='cashcontrol_card.php?id=".$id.
"&contextpage=takepos';
444if ($action ==
'confirm_delete' && !empty($permissiontodelete)) {
448 dol_print_error(
null,
'Error, object must be fetched before being deleted');
453 $result =
$object->delete($user);
456 setEventMessages(
"RecordDeleted",
null,
'mesgs');
457 header(
"Location: ".$backurlforlist);
461 setEventMessages(
null,
$object->errors,
'errors');
463 setEventMessages(
$object->error,
null,
'errors');
468if ($action ==
'update_extras' && $permissiontoeditextra) {
471 $attribute_name =
GETPOST(
'attribute',
'aZ09');
474 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
481 $result =
$object->updateExtraField($attribute_name,
'CASHCONTROL_MODIFY');
489 $action =
'edit_extras';
498$form =
new Form($db);
500$initialbalanceforterminal = array();
501$theoricalamountforterminal = array();
502$theoricalnbofinvoiceforterminal = array();
505llxHeader(
'', $langs->trans(
"CashControl"));
509if ($action ==
"create" || $action ==
"start" || $action ==
'close') {
510 if ($action ==
'close') {
511 $posmodule =
$object->posmodule;
512 $terminalid =
$object->posnumber;
513 $terminaltouse = $terminalid;
516 $smonth =
$object->month_close;
518 } elseif (
GETPOST(
'posnumber',
'alpha') !=
'' &&
GETPOST(
'posnumber',
'alpha') !=
'-1') {
519 $posmodule =
GETPOST(
'posmodule',
'alpha');
520 $terminalid =
GETPOST(
'posnumber',
'alpha');
521 $terminaltouse = $terminalid;
523 if ($terminaltouse ==
'1' && $posmodule ==
'cashdesk') {
527 if ($posmodule ==
'cashdesk' && $terminaltouse !=
'' && $terminaltouse !=
'1') {
529 setEventMessages($langs->trans(
"OnlyTerminal1IsAvailableForCashDeskModule"),
null,
'errors');
534 if (isset($terminalid) && $terminalid !=
'' && isset($posmodule)) {
536 foreach ($arrayofpaymentmode as $key => $val) {
537 if ($key !=
'cash') {
538 $initialbalanceforterminal[$terminalid][$key] = 0;
543 $vartouse =
'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse;
549 $sql =
"SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX.
"bank";
550 $sql .=
" WHERE fk_account = ".((int) $bankid);
551 $sql .= $sqlfilteronopdate;
553 $resql = $db->query($sql);
555 $obj = $db->fetch_object($resql);
557 $initialbalanceforterminal[$terminalid][$key] = $obj->total;
560 dol_print_error($db);
563 setEventMessages($langs->trans(
"SetupOfTerminalNotComplete", $terminaltouse),
null,
'errors');
570 $datefilter =
'p.datep';
571 $modulesourcefilter =
'f.module_source';
572 $amountfield =
'pf.amount';
575 $datefilter =
'bl.date_creation';
576 $modulesourcefilter =
'bl.module_source';
577 $amountfield =
'bl.amounts';
583 foreach ($arrayofpaymentmode as $key => $val) {
591 $sql =
"SELECT SUM(".$db->sanitize($amountfield).
") as total, COUNT(*) as nb";
592 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"facture as f,";
593 $sql .=
" ".MAIN_DB_PREFIX.
"paiement as p";
595 $sql .=
" ".$db->sanitize($joinleft).
" JOIN ".MAIN_DB_PREFIX.
"blockedlog as bl ON bl.action = 'PAYMENT_CUSTOMER_CREATE'";
596 $sql .=
" AND bl.element = 'payment' AND bl.fk_object = p.rowid AND bl.entity = ".((int)
$conf->entity).
",";
598 $sql .=
" ".MAIN_DB_PREFIX.
"c_paiement as cp";
599 $sql .=
" WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement";
600 $sql .=
" AND ".$db->sanitize($modulesourcefilter).
" = '".$db->escape($posmodule).
"'";
601 $sql .=
" AND f.pos_source = '".$db->escape($terminalid).
"'";
602 $sql .=
" AND p.entity = ".((int)
$conf->entity);
603 $sql .=
" AND ".$db->sanitize($datefilter).
" BETWEEN '".$db->idate((
int) $dates).
"' AND '".$db->idate((
int) $datee).
"'";
604 if ($key ==
'cash') {
605 $sql .=
" AND cp.code = 'LIQ'";
606 } elseif ($key ==
'cheque') {
607 $sql .=
" AND cp.code = 'CHQ'";
608 } elseif ($key ==
'card') {
609 $sql .=
" AND cp.code = 'CB'";
611 dol_print_error(
null,
'Value for key = '.$key.
' not supported');
615 $resql = $db->query($sql);
617 $obj = $db->fetch_object($resql);
620 $theoricalamountforterminal[$terminalid][$key] = $obj->total;
621 $theoricalnbofinvoiceforterminal[$terminalid][$key] = $obj->nb;
624 dol_print_error($db);
630if ($action ==
"create" || $action ==
"start") {
631 print
load_fiche_titre($langs->trans(
"CashControl").
" - ".$langs->trans(
"New"),
'',
'cash-register');
633 if ($action ==
'start') {
637 setEventMessages($langs->trans(
"CashControlEndDateMustBeBeforeNow"),
null,
'errors');
642 if ($endperiod >=
dol_now() &&
$mysoc->country_code ==
'FR') {
643 setEventMessages($langs->trans(
"CashControlEndDayMustNotBeInPast"),
null,
'errors');
649 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
650 print
'<input type="hidden" name="token" value="'.newToken().
'">';
651 if ($contextpage ==
'takepos') {
652 print
'<input type="hidden" name="contextpage" value="takepos">';
655 print
'<input type="hidden" name="action" value="add">';
656 } elseif ($action ==
'close') {
657 print
'<input type="hidden" name="action" value="valid">';
658 print
'<input type="hidden" name="id" value="'.$id.
'">';
660 print
'<input type="hidden" name="action" value="start">';
663 print
'<!-- Table to start cash control -->'.
"\n";
664 print
'<div class="div-table-responsive-no-min">'.
"\n";
665 print
'<table class="noborder centpercent">'.
"\n";
666 print
'<tr class="liste_titre">';
667 print
'<td>'.$langs->trans(
"Module").
'</td>';
668 print
'<td>'.$langs->trans(
"Terminal").
'</td>';
669 print
'<td>'.$langs->trans(
"Year").
'</td>';
670 print
'<td>'.$langs->trans(
"Month").
'</td>';
671 print
'<td>'.$langs->trans(
"Day").
'</td>';
678 print
'<tr class="oddeven nohover">';
679 print
'<td>'.$form->selectarray(
'posmodule', $arrayofposavailable,
GETPOST(
'posmodule',
'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).
'</td>';
682 $arrayofpos = array();
684 for ($i = 1; $i <= $numterminals; $i++) {
686 $arrayofpos[$i] = array(
'id' => $i,
'label' => (($nameofterminal !=
"TAKEPOS_TERMINAL_NAME_".$i) ?
'#'.$i.
' '.$nameofterminal : $i),
'data-html' => (($nameofterminal !=
"TAKEPOS_TERMINAL_NAME_".$i) ?
'#'.$i.
' - '.$nameofterminal : $i));
688 $selectedposnumber = 0;
691 $selectedposnumber = 1;
694 print $form->selectarray(
'posnumber', $arrayofpos,
GETPOSTISSET(
'posnumber') ?
GETPOSTINT(
'posnumber') : $selectedposnumber, $showempty);
700 $retstring =
'<select'.($disabled ?
' disabled' :
'').
' class="flat valignmiddle maxwidth75imp" id="'.$prefix.
'year" name="'.$prefix.
'year">';
701 for ($year = $syear - 10; $year < $syear + 10; $year++) {
702 $retstring .=
'<option value="'.$year.
'"'.($year == $syear ?
' selected' :
'').
'>'.$year.
'</option>';
704 $retstring .=
"</select>\n";
710 $retstring =
'<select'.($disabled ?
' disabled' :
'').
' class="flat valignmiddle maxwidth75imp" id="'.$prefix.
'month" name="'.$prefix.
'month">';
711 $retstring .=
'<option value="0"></option>';
712 for ($month = 1; $month <= 12; $month++) {
713 $retstring .=
'<option value="'.$month.
'"'.($month == $smonth ?
' selected' :
'').
'>';
714 $retstring .=
dol_print_date(mktime(12, 0, 0, $month, 1, 2000),
"%b");
715 $retstring .=
"</option>";
717 $retstring .=
"</select>";
719 print
' '.$form->textwithpicto(
'', $langs->trans(
"KeepEmptyForAYearlyControl"));
724 $retstring =
'<select'.($disabled ?
' disabled' :
'').
' class="flat valignmiddle maxwidth50imp" id="'.$prefix.
'day" name="'.$prefix.
'day">';
725 $retstring .=
'<option value="0" selected> </option>';
726 for ($day = 1; $day <= 31; $day++) {
727 $retstring .=
'<option value="'.$day.
'"'.($day == $sday ?
' selected' :
'').
'>'.$day.
'</option>';
729 $retstring .=
"</select>";
731 print
' '.$form->textwithpicto(
'', $langs->trans(
"KeepEmptyForAMonthlyControl"));
739 print
'<input type="submit" name="add" class="button" value="'.$langs->trans(
"Start").
'">';
748 $posmodule =
GETPOST(
'posmodule',
'alpha');
749 $terminalid =
GETPOST(
'posnumber',
'alpha');
753 print
'<div class="div-table-responsive-no-min">';
754 print
'<table class="noborder centpercent">';
756 print
'<tr class="liste_titre">';
758 print
'<td class="center">'.$langs->trans(
"InitialBankBalance");
760 print
'<span class="small opacitymedium">'.$langs->trans(
"at").
' '.
dol_print_date($datestart,
'standard',
'gmt').
' UTC</span>';
772 print
'<tr class="liste_titre">';
774 print
'<td class="center">'.$langs->trans(
"Cash");
811 print $form->textwithpicto($langs->trans(
"TheoricalAmount"), $langs->trans(
"TheoricalAmountAtOpening"));
813 print
'<td class="center">';
814 print
price($initialbalanceforterminal[$terminalid][
'cash']).
'<br>';
830 print
'<td>'.$langs->trans(
"RealAmount").
'</td>';
832 print
'<td class="center">';
834 if ($action ==
'close') {
837 print
'name="opening" type="text" class="maxwidth100 center" value="';
838 if ($action ==
'close') {
858 print
'<td class="center">';
859 print
'<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
860 if ($action ==
'start') {
861 print
'<input type="submit" name="add" class="button button-save" value="'.$langs->trans(
"Start").
'">';
862 } elseif ($action ==
'close') {
863 print
'<input type="submit" name="valid" class="button" value="'.$langs->trans(
"Validate").
'">';
876if (empty($action) || $action ==
"view" || $action ==
"close") {
880 print $langs->trans(
"ErrorRecordNotFound");
883 $head[0][0] = DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_card.php?id='.
$object->id;
884 $head[0][1] = $langs->trans(
"CashControl");
885 $head[0][2] =
'cashcontrol';
887 print
dol_get_fiche_head($head,
'cashcontrol', $langs->trans(
"CashControl"), -1,
'account');
889 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
891 $morehtmlref =
'<div class="refidno">';
892 $morehtmlref .=
'</div>';
895 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'rowid', $morehtmlref);
897 print
'<div class="fichecenter">';
898 print
'<div class="fichehalfleft">';
899 print
'<div class="underbanner clearboth"></div>';
900 print
'<table class="border tableforfield centpercent">';
902 print
'<tr><td class="titlefield nowrap">';
903 print $langs->trans(
"Ref");
908 print
'<tr><td valign="middle">'.$langs->trans(
"Module").
'</td><td>';
912 print
'<tr><td valign="middle">'.$langs->trans(
"Terminal").
'</td><td>';
916 print
'<tr><td class="titlefield nowrap">';
917 print $langs->trans(
"DateCreationShort");
918 print
'</td><td colspan="3">';
922 print
'<tr><td class="nowrap">';
923 print $langs->trans(
"Period");
926 $period .= (
$object->month_close ?
"-".sprintf(
"%02d",
$object->month_close) :
"");
927 $period .= (
$object->day_close ?
"-".sprintf(
"%02d",
$object->day_close) :
"");
932 $htmltooltip .=
dol_print_date($datestart,
'standard',
'tzuserrel').
' - ';
933 $htmltooltip .=
dol_print_date($dateend,
'standard',
'tzuserrel');
934 $htmltooltip .=
'<br><span class="small opacitymedium">UTC : ';
935 $htmltooltip .=
dol_print_date($datestart,
'standard',
'gmt').
' - ';
937 $htmltooltip .=
'</span>';
938 $htmltooltip .=
'<br><br>';
940 $htmltooltip .= $langs->trans(
"UsedToSeletRecordOn", $langs->transnoentitiesnoconv(
"BlockedLog"), MAIN_DB_PREFIX.
"blockedlog", $langs->transnoentitiesnoconv(
"DateCreation"),
"date_creation");
942 $htmltooltip .= $langs->trans(
"UsedToSeletRecordOn", $langs->transnoentitiesnoconv(
"Payment"), MAIN_DB_PREFIX.
"paiement", $langs->transnoentitiesnoconv(
"DatePayment"),
"datep");
945 print $form->textwithpicto(
'', $htmltooltip);
949 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' =>
'2');
950 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
951 print $hookmanager->resPrint;
952 if (empty($reshook)) {
953 print
$object->showOptionals($extrafields,
'create', $parameters);
957 print
'<tr><td class="titlefield nowrap">';
958 print $langs->trans(
"LifetimeAmount", $langs->transnoentities(
"AllPaymentModes"));
959 print
'</td><td colspan="3">';
960 print
'<span class="amount">'.price(
$object->card_lifetime +
$object->cheque_lifetime +
$object->cash_lifetime, 0, $langs, 1, -1, -1,
$conf->currency).
'</span>';
961 print
' <span class="opacitymedium">'.$langs->trans(
"since").
' '.
dol_print_date(
$object->lifetime_start,
'dayhour').
' ('.$langs->trans(
"AllTerminals").
')</span>';
968 print
'<div class="fichehalfright">';
969 print
'<div class="underbanner clearboth"></div>';
971 print
'<table class="noborder paymenttable centpercent">';
973 if (
$object->status == $object::STATUS_CLOSED) {
974 print
'<tr class="liste_titre"><td class="liste_titre">'.$langs->trans(
"Summary").
'</td>';
975 print
'<td class="liste_titre right">'.$langs->trans(
"InitialBankBalance").
'</td>';
976 print
'<td class="liste_titre right">'.$langs->trans(
"Sales").
'</td>';
977 print
'<td class="liste_titre right">'.$langs->trans(
"EndBankBalance").
'</td>';
980 foreach ($arrayofpaymentmode as $key => $val) {
981 $newkey = $key.
'_declared';
982 if (!property_exists($object, $key)) {
986 $realamountforpaymentmode =
$object->$key;
987 $declaredamountforpaymentmode =
$object->$newkey;
990 print
'<td class="">'.$langs->trans($val).
'</td>';
991 print
'<td class="right">';
992 if ($key ==
'cash') {
993 print
'<span class="amount">'.price(
$object->opening, 0, $langs, 1, -1, -1,
$conf->currency).
'</span>';
996 print
'<td class="right">';
997 if ($realamountforpaymentmode) {
998 print
'<span class="amount">'.($realamountforpaymentmode >= 0 ?
'+' :
'').
price($realamountforpaymentmode, 0, $langs, 1, -1, -1,
$conf->currency).
'</span>';
1001 print
'<td class="right">';
1002 $calcamount = (($key ==
'cash' ?
$object->opening : 0) + $realamountforpaymentmode);
1003 print
'<span class="amount">'.price($calcamount, 0, $langs, 1, -1, -1,
$conf->currency).
'</span>';
1006 if ($calcamount != $declaredamountforpaymentmode) {
1008 print img_picto($langs->trans(
"Declared").
': '.$declaredamountforpaymentmode,
'warning');
1020 print
'</div></div>';
1021 print
'<div class="clearboth"></div>';
1025 if ($action !=
'close') {
1026 print
'<div class="tabsAction">';
1029 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>';
1032 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>';
1035 if (
$object->status == CashControl::STATUS_DRAFT) {
1036 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>';
1038 print
'<div class="inline-block divButAction">'.dolGetButtonAction($langs->trans(
'Delete'), $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.((
int) $id).
'&action=confirm_delete&token='.
newToken(),
'',
true, array(
'attr' => array(
'class' =>
'reposition'))).
'</div>'.
"\n";
1041 if ($permissiontoreopen) {
1042 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.((int) $id).
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
'ReOpen').
'</a></div>';
1044 print
'<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dolPrintHTMLForAttribute($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'ReOpen').
'</a></div>';
1051 if ($contextpage !=
'takepos') {
1053 print
'<center><iframe src="'.DOL_URL_ROOT.
'/compta/cashcontrol/report.php?id='.
$id.
'" width="60%" height="800"></iframe></center>';
1056 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'" name="formclose">';
1057 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1058 if ($contextpage ==
'takepos') {
1059 print
'<input type="hidden" name="contextpage" value="takepos">';
1062 print
'<input type="hidden" name="action" value="add">';
1063 } elseif ($action ==
'close') {
1064 print
'<input type="hidden" name="action" value="valid">';
1065 print
'<input type="hidden" name="id" value="'.$id.
'">';
1067 print
'<input type="hidden" name="action" value="start">';
1071 if (($action ==
'start' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'-1') || $action ==
'close') {
1072 $posmodule =
$object->posmodule;
1073 $terminalid =
$object->posnumber;
1077 print
'<!-- section to enter declared mount -->';
1078 print
'<div class="div-table-responsive-no-min">';
1079 print
'<table class="noborder centpercent">';
1081 print
'<tr class="liste_titre">';
1083 print
'<td class="center">'.$langs->trans(
"InitialBankBalance");
1085 print
'<span class="small opacitymedium">'.$langs->trans(
"at").
' '.
dol_print_date($datestart,
'standard',
'gmt').
' UTC</span>';
1088 print
'<td align="center" class="hide0" colspan="'.count($arrayofpaymentmode).
'">';
1089 print $langs->trans(
"AmountAtEndOfPeriod");
1091 print
'<span class="small opacitymedium">'.$langs->trans(
"at").
' '.
dol_print_date($dateend,
'standard',
'gmt').
' UTC</span>';
1096 print
'<tr class="liste_titre">';
1098 print
'<td class="center">'.$langs->trans(
"Cash");
1102 foreach ($arrayofpaymentmode as $key => $val) {
1103 print
'<td class="center'.($i == 0 ?
' hide0' :
'').
'">'.$langs->trans($val);
1113 print
'<td>'.$langs->trans(
"NbOfPayments").
'</td>';
1114 print
'<td class="center">';
1118 foreach ($arrayofpaymentmode as $key => $val) {
1119 print
'<td class="center'.($i == 0 ?
' hide0' :
'').
'">';
1120 print $theoricalnbofinvoiceforterminal[$terminalid][$key];
1125 print
'<td align="center"></td>';
1130 print
'<td>'.$langs->trans(
"TheoricalAmount").
'</td>';
1131 print
'<td class="center">';
1132 print
price($initialbalanceforterminal[$terminalid][
'cash']).
'<br>';
1137 foreach ($arrayofpaymentmode as $key => $val) {
1138 print
'<td class="smallheight center'.($i == 0 ?
' hide0' :
'').
'">';
1139 if ($key ==
'cash') {
1140 print
price(
$object->opening + $theoricalamountforterminal[$terminalid][$key]).
'<br>';
1141 print
'<span class="opacitymedium small">('.price(
$object->opening).
' + '.
price($theoricalamountforterminal[$terminalid][$key]).
')</span>';
1143 print
price($theoricalamountforterminal[$terminalid][$key]).
'<br>';
1145 print
'<input type="hidden" name="'.$key.
'_calculated" value="'.$theoricalamountforterminal[$terminalid][$key].
'">';
1151 print
'<td align="center"></td>';
1156 print
'<td>'.$langs->trans(
"RealAmount").
'</td>';
1159 print
'<td class="center">';
1161 if ($action ==
'close') {
1164 print
'name="opening" type="text" class="maxwidth100 center" value="';
1165 if ($action ==
'close') {
1176 foreach ($arrayofpaymentmode as $key => $val) {
1177 print
'<td class="center '.($i == 0 ?
' hide0' :
'').
'">';
1179 if ($action ==
'start') {
1182 print
'name="'.$key.
'_amount" type="text"'.($key ==
'cash' ?
' autofocus' :
'').
' class="maxwidth100 center" value="';
1183 $suggestedvalue =
'';
1184 if ($key ==
'cash') {
1185 $suggestedvalue =
price(
$object->opening + $theoricalamountforterminal[$terminalid][$key]);
1187 $suggestedvalue =
price($theoricalamountforterminal[$terminalid][$key]);
1196 print
'<td class="center">';
1197 print
'<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1198 if ($action ==
'start') {
1199 print
'<input type="submit" name="add" class="button button-save" value="'.$langs->trans(
"Save").
'">';
1200 } elseif ($action ==
'close') {
1201 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($blockedlogusagealreadychecked=0, $blockedlogmoduleonalreadychecked=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...
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.