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');
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'";
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;
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) {
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');
452 $result =
$object->delete($user);
456 header(
"Location: ".$backurlforlist);
467if ($action ==
'update_extras' && $permissiontoeditextra) {
470 $attribute_name =
GETPOST(
'attribute',
'aZ09');
473 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
480 $result =
$object->updateExtraField($attribute_name,
'CASHCONTROL_MODIFY');
488 $action =
'edit_extras';
499$initialbalanceforterminal = array();
500$theoricalamountforterminal = array();
501$theoricalnbofinvoiceforterminal = array();
504llxHeader(
'', $langs->trans(
"CashControl"));
508if ($action ==
"create" || $action ==
"start" || $action ==
'close') {
509 if ($action ==
'close') {
510 $posmodule =
$object->posmodule;
511 $terminalid =
$object->posnumber;
512 $terminaltouse = $terminalid;
515 $smonth =
$object->month_close;
517 } elseif (
GETPOST(
'posnumber',
'alpha') !=
'' &&
GETPOST(
'posnumber',
'alpha') !=
'-1') {
518 $posmodule =
GETPOST(
'posmodule',
'alpha');
519 $terminalid =
GETPOST(
'posnumber',
'alpha');
520 $terminaltouse = $terminalid;
522 if ($terminaltouse ==
'1' && $posmodule ==
'cashdesk') {
526 if ($posmodule ==
'cashdesk' && $terminaltouse !=
'' && $terminaltouse !=
'1') {
528 setEventMessages($langs->trans(
"OnlyTerminal1IsAvailableForCashDeskModule"),
null,
'errors');
533 if (isset($terminalid) && $terminalid !=
'' && isset($posmodule)) {
535 foreach ($arrayofpaymentmode as $key => $val) {
536 if ($key !=
'cash') {
537 $initialbalanceforterminal[$terminalid][$key] = 0;
542 $vartouse =
'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse;
548 $sql =
"SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX.
"bank";
549 $sql .=
" WHERE fk_account = ".((int) $bankid);
550 $sql .= $sqlfilteronopdate;
552 $resql =
$db->query($sql);
554 $obj =
$db->fetch_object($resql);
556 $initialbalanceforterminal[$terminalid][$key] = $obj->total;
562 setEventMessages($langs->trans(
"SetupOfTerminalNotComplete", $terminaltouse),
null,
'errors');
569 $datefilter =
'p.datep';
570 $modulesourcefilter =
'f.module_source';
571 $amountfield =
'pf.amount';
574 $datefilter =
'bl.date_creation';
575 $modulesourcefilter =
'bl.module_source';
576 $amountfield =
'bl.amounts';
582 foreach ($arrayofpaymentmode as $key => $val) {
590 $sql =
"SELECT SUM(".$db->sanitize($amountfield).
") as total, COUNT(*) as nb";
591 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"facture as f,";
592 $sql .=
" ".MAIN_DB_PREFIX.
"paiement as p";
594 $sql .=
" ".$db->sanitize($joinleft).
" JOIN ".MAIN_DB_PREFIX.
"blockedlog as bl ON bl.action = 'PAYMENT_CUSTOMER_CREATE'";
595 $sql .=
" AND bl.element = 'payment' AND bl.fk_object = p.rowid AND bl.entity = ".((int)
$conf->entity).
",";
597 $sql .=
" ".MAIN_DB_PREFIX.
"c_paiement as cp";
598 $sql .=
" WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement";
599 $sql .=
" AND ".$db->sanitize($modulesourcefilter).
" = '".
$db->escape($posmodule).
"'";
600 $sql .=
" AND f.pos_source = '".$db->escape($terminalid).
"'";
601 $sql .=
" AND p.entity = ".((int)
$conf->entity);
602 $sql .=
" AND ".$db->sanitize($datefilter).
" BETWEEN '".
$db->idate((
int) $dates).
"' AND '".
$db->idate((
int) $datee).
"'";
603 if ($key ==
'cash') {
604 $sql .=
" AND cp.code = 'LIQ'";
605 } elseif ($key ==
'cheque') {
606 $sql .=
" AND cp.code = 'CHQ'";
607 } elseif ($key ==
'card') {
608 $sql .=
" AND cp.code = 'CB'";
614 $resql =
$db->query($sql);
616 $obj =
$db->fetch_object($resql);
619 $theoricalamountforterminal[$terminalid][$key] = $obj->total;
620 $theoricalnbofinvoiceforterminal[$terminalid][$key] = $obj->nb;
629if ($action ==
"create" || $action ==
"start") {
630 print
load_fiche_titre($langs->trans(
"CashControl").
" - ".$langs->trans(
"New"),
'',
'cash-register');
632 if ($action ==
'start') {
636 setEventMessages($langs->trans(
"CashControlEndDateMustBeBeforeNow"),
null,
'errors');
641 if ($endperiod >=
dol_now() &&
$mysoc->country_code ==
'FR') {
642 setEventMessages($langs->trans(
"CashControlEndDayMustNotBeInPast"),
null,
'errors');
648 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
649 print
'<input type="hidden" name="token" value="'.newToken().
'">';
650 if ($contextpage ==
'takepos') {
651 print
'<input type="hidden" name="contextpage" value="takepos">';
654 print
'<input type="hidden" name="action" value="add">';
655 } elseif ($action ==
'close') {
656 print
'<input type="hidden" name="action" value="valid">';
657 print
'<input type="hidden" name="id" value="'.$id.
'">';
659 print
'<input type="hidden" name="action" value="start">';
662 print
'<!-- Table to start cash control -->'.
"\n";
663 print
'<div class="div-table-responsive-no-min">'.
"\n";
664 print
'<table class="noborder centpercent">'.
"\n";
665 print
'<tr class="liste_titre">';
666 print
'<td>'.$langs->trans(
"Module").
'</td>';
667 print
'<td>'.$langs->trans(
"Terminal").
'</td>';
668 print
'<td>'.$langs->trans(
"Year").
'</td>';
669 print
'<td>'.$langs->trans(
"Month").
'</td>';
670 print
'<td>'.$langs->trans(
"Day").
'</td>';
677 print
'<tr class="oddeven nohover">';
678 print
'<td>'.$form->selectarray(
'posmodule', $arrayofposavailable,
GETPOST(
'posmodule',
'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).
'</td>';
681 $arrayofpos = array();
683 for ($i = 1; $i <= $numterminals; $i++) {
685 $arrayofpos[$i] = array(
'id' => $i,
'label' => (($nameofterminal !=
"TAKEPOS_TERMINAL_NAME_".$i) ?
'#'.$i.
' '.$nameofterminal : $i),
'data-html' => (($nameofterminal !=
"TAKEPOS_TERMINAL_NAME_".$i) ?
'#'.$i.
' - '.$nameofterminal : $i));
687 $selectedposnumber = 0;
690 $selectedposnumber = 1;
693 print $form->selectarray(
'posnumber', $arrayofpos, GETPOSTISSET(
'posnumber') ?
GETPOSTINT(
'posnumber') : $selectedposnumber, $showempty);
699 $retstring =
'<select'.($disabled ?
' disabled' :
'').
' class="flat valignmiddle maxwidth75imp" id="'.$prefix.
'year" name="'.$prefix.
'year">';
700 for ($year = $syear - 10; $year < $syear + 10; $year++) {
701 $retstring .=
'<option value="'.$year.
'"'.($year == $syear ?
' selected' :
'').
'>'.$year.
'</option>';
703 $retstring .=
"</select>\n";
709 $retstring =
'<select'.($disabled ?
' disabled' :
'').
' class="flat valignmiddle maxwidth75imp" id="'.$prefix.
'month" name="'.$prefix.
'month">';
710 $retstring .=
'<option value="0"></option>';
711 for ($month = 1; $month <= 12; $month++) {
712 $retstring .=
'<option value="'.$month.
'"'.($month == $smonth ?
' selected' :
'').
'>';
713 $retstring .=
dol_print_date(mktime(12, 0, 0, $month, 1, 2000),
"%b");
714 $retstring .=
"</option>";
716 $retstring .=
"</select>";
718 print
' '.$form->textwithpicto(
'', $langs->trans(
"KeepEmptyForAYearlyControl"));
723 $retstring =
'<select'.($disabled ?
' disabled' :
'').
' class="flat valignmiddle maxwidth50imp" id="'.$prefix.
'day" name="'.$prefix.
'day">';
724 $retstring .=
'<option value="0" selected> </option>';
725 for ($day = 1; $day <= 31; $day++) {
726 $retstring .=
'<option value="'.$day.
'"'.($day == $sday ?
' selected' :
'').
'>'.$day.
'</option>';
728 $retstring .=
"</select>";
730 print
' '.$form->textwithpicto(
'', $langs->trans(
"KeepEmptyForAMonthlyControl"));
735 if ($action ==
'start' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'-1') {
738 print
'<input type="submit" name="add" class="button" value="'.$langs->trans(
"Start").
'">';
746 if ($action ==
'start' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'-1') {
747 $posmodule =
GETPOST(
'posmodule',
'alpha');
748 $terminalid =
GETPOST(
'posnumber',
'alpha');
752 print
'<div class="div-table-responsive-no-min">';
753 print
'<table class="noborder centpercent">';
755 print
'<tr class="liste_titre">';
757 print
'<td class="center">'.$langs->trans(
"InitialBankBalance");
759 print
'<span class="small opacitymedium">'.$langs->trans(
"at").
' '.
dol_print_date($datestart,
'standard',
'gmt').
' UTC</span>';
771 print
'<tr class="liste_titre">';
773 print
'<td class="center">'.$langs->trans(
"Cash");
810 print $form->textwithpicto($langs->trans(
"TheoricalAmount"), $langs->trans(
"TheoricalAmountAtOpening"));
812 print
'<td class="center">';
813 print
price($initialbalanceforterminal[$terminalid][
'cash']).
'<br>';
829 print
'<td>'.$langs->trans(
"RealAmount").
'</td>';
831 print
'<td class="center">';
833 if ($action ==
'close') {
836 print
'name="opening" type="text" class="maxwidth100 center" value="';
837 if ($action ==
'close') {
841 print(GETPOSTISSET(
'opening') ?
price2num(
GETPOST(
'opening',
'alpha')) :
price($initialbalanceforterminal[$terminalid][
'cash']));
857 print
'<td class="center">';
858 print
'<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
859 if ($action ==
'start') {
860 print
'<input type="submit" name="add" class="button button-save" value="'.$langs->trans(
"Start").
'">';
861 } elseif ($action ==
'close') {
862 print
'<input type="submit" name="valid" class="button" value="'.$langs->trans(
"Validate").
'">';
875if (empty($action) || $action ==
"view" || $action ==
"close") {
879 print $langs->trans(
"ErrorRecordNotFound");
882 $head[0][0] = DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_card.php?id='.
$object->id;
883 $head[0][1] = $langs->trans(
"CashControl");
884 $head[0][2] =
'cashcontrol';
886 print
dol_get_fiche_head($head,
'cashcontrol', $langs->trans(
"CashControl"), -1,
'account');
888 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
890 $morehtmlref =
'<div class="refidno">';
891 $morehtmlref .=
'</div>';
894 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'rowid', $morehtmlref);
896 print
'<div class="fichecenter">';
897 print
'<div class="fichehalfleft">';
898 print
'<div class="underbanner clearboth"></div>';
899 print
'<table class="border tableforfield centpercent">';
901 print
'<tr><td class="titlefield nowrap">';
902 print $langs->trans(
"Ref");
907 print
'<tr><td valign="middle">'.$langs->trans(
"Module").
'</td><td>';
911 print
'<tr><td valign="middle">'.$langs->trans(
"Terminal").
'</td><td>';
915 print
'<tr><td class="titlefield nowrap">';
916 print $langs->trans(
"DateCreationShort");
917 print
'</td><td colspan="3">';
921 print
'<tr><td class="nowrap">';
922 print $langs->trans(
"Period");
925 $period .= (
$object->month_close ?
"-".sprintf(
"%02d",
$object->month_close) :
"");
926 $period .= (
$object->day_close ?
"-".sprintf(
"%02d",
$object->day_close) :
"");
931 $htmltooltip .=
dol_print_date($datestart,
'standard',
'tzuserrel').
' - ';
932 $htmltooltip .=
dol_print_date($dateend,
'standard',
'tzuserrel');
933 $htmltooltip .=
'<br><span class="small opacitymedium">UTC : ';
934 $htmltooltip .=
dol_print_date($datestart,
'standard',
'gmt').
' - ';
936 $htmltooltip .=
'</span>';
937 print $form->textwithpicto(
'', $htmltooltip);
941 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' =>
'2');
942 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
943 print $hookmanager->resPrint;
944 if (empty($reshook)) {
945 print
$object->showOptionals($extrafields,
'create', $parameters);
949 print
'<tr><td class="titlefield nowrap">';
950 print $langs->trans(
"LifetimeAmount", $langs->transnoentities(
"AllPaymentModes"));
951 print
'</td><td colspan="3">';
952 print
'<span class="amount">'.price(
$object->card_lifetime +
$object->cheque_lifetime +
$object->cash_lifetime, 0, $langs, 1, -1, -1,
$conf->currency).
'</span>';
953 print
' <span class="opacitymedium">'.$langs->trans(
"since").
' '.
dol_print_date(
$object->lifetime_start,
'dayhour').
' ('.$langs->trans(
"AllTerminals").
')</span>';
960 print
'<div class="fichehalfright">';
961 print
'<div class="underbanner clearboth"></div>';
963 print
'<table class="noborder paymenttable centpercent">';
965 if (
$object->status == $object::STATUS_CLOSED) {
966 print
'<tr class="liste_titre"><td class="liste_titre">'.$langs->trans(
"Summary").
'</td>';
967 print
'<td class="liste_titre right">'.$langs->trans(
"InitialBankBalance").
'</td>';
968 print
'<td class="liste_titre right">'.$langs->trans(
"Sales").
'</td>';
969 print
'<td class="liste_titre right">'.$langs->trans(
"EndBankBalance").
'</td>';
972 foreach ($arrayofpaymentmode as $key => $val) {
973 $newkey = $key.
'_declared';
974 if (!property_exists($object, $key)) {
978 $realamountforpaymentmode =
$object->$key;
979 $declaredamountforpaymentmode =
$object->$newkey;
982 print
'<td class="">'.$langs->trans($val).
'</td>';
983 print
'<td class="right">';
984 if ($key ==
'cash') {
985 print
'<span class="amount">'.price(
$object->opening, 0, $langs, 1, -1, -1,
$conf->currency).
'</span>';
988 print
'<td class="right">';
989 if ($realamountforpaymentmode) {
990 print
'<span class="amount">'.($realamountforpaymentmode >= 0 ?
'+' :
'').
price($realamountforpaymentmode, 0, $langs, 1, -1, -1,
$conf->currency).
'</span>';
993 print
'<td class="right">';
994 $calcamount = (($key ==
'cash' ?
$object->opening : 0) + $realamountforpaymentmode);
995 print
'<span class="amount">'.price($calcamount, 0, $langs, 1, -1, -1,
$conf->currency).
'</span>';
998 if ($calcamount != $declaredamountforpaymentmode) {
1000 print
img_picto($langs->trans(
"Declared").
': '.$declaredamountforpaymentmode,
'warning');
1012 print
'</div></div>';
1013 print
'<div class="clearboth"></div>';
1017 if ($action !=
'close') {
1018 print
'<div class="tabsAction">';
1021 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>';
1024 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>';
1027 if (
$object->status == CashControl::STATUS_DRAFT) {
1028 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>';
1030 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>';
1033 if ($permissiontoreopen) {
1034 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>';
1036 print
'<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dolPrintHTMLForAttribute($langs->trans(
"NotEnoughPermissions")).
'">'.$langs->trans(
'ReOpen').
'</a></div>';
1043 if ($contextpage !=
'takepos') {
1045 print
'<center><iframe src="'.DOL_URL_ROOT.
'/compta/cashcontrol/report.php?id='.
$id.
'" width="60%" height="800"></iframe></center>';
1048 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'" name="formclose">';
1049 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1050 if ($contextpage ==
'takepos') {
1051 print
'<input type="hidden" name="contextpage" value="takepos">';
1054 print
'<input type="hidden" name="action" value="add">';
1055 } elseif ($action ==
'close') {
1056 print
'<input type="hidden" name="action" value="valid">';
1057 print
'<input type="hidden" name="id" value="'.$id.
'">';
1059 print
'<input type="hidden" name="action" value="start">';
1063 if (($action ==
'start' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'' &&
GETPOST(
'posnumber') !=
'-1') || $action ==
'close') {
1064 $posmodule =
$object->posmodule;
1065 $terminalid =
$object->posnumber;
1069 print
'<!-- section to enter declareda mount -->';
1070 print
'<div class="div-table-responsive-no-min">';
1071 print
'<table class="noborder centpercent">';
1073 print
'<tr class="liste_titre">';
1075 print
'<td class="center">'.$langs->trans(
"InitialBankBalance");
1077 print
'<span class="small opacitymedium">'.$langs->trans(
"at").
' '.
dol_print_date($datestart,
'standard',
'gmt').
' UTC</span>';
1080 print
'<td align="center" class="hide0" colspan="'.count($arrayofpaymentmode).
'">';
1081 print $langs->trans(
"AmountAtEndOfPeriod");
1083 print
'<span class="small opacitymedium">'.$langs->trans(
"at").
' '.
dol_print_date($dateend,
'standard',
'gmt').
' UTC</span>';
1088 print
'<tr class="liste_titre">';
1090 print
'<td class="center">'.$langs->trans(
"Cash");
1094 foreach ($arrayofpaymentmode as $key => $val) {
1095 print
'<td class="center'.($i == 0 ?
' hide0' :
'').
'">'.$langs->trans($val);
1105 print
'<td>'.$langs->trans(
"NbOfPayments").
'</td>';
1106 print
'<td class="center">';
1110 foreach ($arrayofpaymentmode as $key => $val) {
1111 print
'<td class="center'.($i == 0 ?
' hide0' :
'').
'">';
1112 print $theoricalnbofinvoiceforterminal[$terminalid][$key];
1117 print
'<td align="center"></td>';
1122 print
'<td>'.$langs->trans(
"TheoricalAmount").
'</td>';
1123 print
'<td class="center">';
1124 print
price($initialbalanceforterminal[$terminalid][
'cash']).
'<br>';
1129 foreach ($arrayofpaymentmode as $key => $val) {
1130 print
'<td class="smallheight center'.($i == 0 ?
' hide0' :
'').
'">';
1131 if ($key ==
'cash') {
1132 print
price(
$object->opening + $theoricalamountforterminal[$terminalid][$key]).
'<br>';
1133 print
'<span class="opacitymedium small">('.price(
$object->opening).
' + '.
price($theoricalamountforterminal[$terminalid][$key]).
')</span>';
1135 print
price($theoricalamountforterminal[$terminalid][$key]).
'<br>';
1137 print
'<input type="hidden" name="'.$key.
'_calculated" value="'.$theoricalamountforterminal[$terminalid][$key].
'">';
1143 print
'<td align="center"></td>';
1148 print
'<td>'.$langs->trans(
"RealAmount").
'</td>';
1151 print
'<td class="center">';
1153 if ($action ==
'close') {
1156 print
'name="opening" type="text" class="maxwidth100 center" value="';
1157 if ($action ==
'close') {
1161 print(GETPOSTISSET(
'opening') ?
price2num(
GETPOST(
'opening',
'alpha')) :
price($initialbalanceforterminal[$terminalid][
'cash']));
1168 foreach ($arrayofpaymentmode as $key => $val) {
1169 print
'<td class="center '.($i == 0 ?
' hide0' :
'').
'">';
1171 if ($action ==
'start') {
1174 print
'name="'.$key.
'_amount" type="text"'.($key ==
'cash' ?
' autofocus' :
'').
' class="maxwidth100 center" value="'.
GETPOST($key.
'_amount',
'alpha').
'">';
1180 print
'<td class="center">';
1181 print
'<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
1182 if ($action ==
'start') {
1183 print
'<input type="submit" name="add" class="button button-save" value="'.$langs->trans(
"Save").
'">';
1184 } elseif ($action ==
'close') {
1185 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, $blockedlogmodulealreadydone=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,...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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).
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.