34if (!defined(
'NOREQUIREMENU')) {
35 define(
'NOREQUIREMENU',
'1');
37if (!defined(
'NOBROWSERNOTIF')) {
38 define(
'NOBROWSERNOTIF',
'1');
44require
'../../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
61$langs->loadLangs(array(
"bills",
"banks"));
71$sortfield =
'b.datev,b.dateo,b.rowid';
74 'b.rowid' => array(
'label' => $langs->trans(
"Ref"),
'checked' => 1),
75 'b.dateo' => array(
'label' => $langs->trans(
"DateOperationShort"),
'checked' => 1),
76 'b.num_chq' => array(
'label' => $langs->trans(
"Number"),
'checked' => 1),
77 'ba.ref' => array(
'label' => $langs->trans(
"BankAccount"),
'checked' => 1),
78 'cp.code' => array(
'label' => $langs->trans(
"PaymentMode"),
'checked' => 1),
79 'b.debit' => array(
'label' => $langs->trans(
"Debit"),
'checked' => 1,
'position' => 600),
80 'b.credit' => array(
'label' => $langs->trans(
"Credit"),
'checked' => 1,
'position' => 605),
88$terminalid =
$object->posnumber;
91if ($user->socid > 0) {
95if (!$user->hasRight(
'cashdesk',
'run') && !$user->hasRight(
'takepos',
'run')) {
104$title = $langs->trans(
"CashControl");
107$conf->dol_hide_topmenu = 1;
108$conf->dol_hide_leftmenu = 1;
110llxHeader(
'', $title,
'',
'', 0, 0, array(), array(), $param);
112print
'<!-- Begin div id-container --><div id="id-container" class="id-container center">';
141$sql =
"SELECT f.rowid as facid, f.ref, f.datef as do, pf.amount as amount, b.fk_account as bankid, cp.code";
142$sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"facture as f, ".MAIN_DB_PREFIX.
"paiement as p, ".MAIN_DB_PREFIX.
"c_paiement as cp, ".MAIN_DB_PREFIX.
"bank as b";
143$sql .=
" WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement AND p.fk_bank = b.rowid";
144$sql .=
" AND f.module_source = '".$db->escape($posmodule).
"'";
145$sql .=
" AND f.pos_source = '".$db->escape($terminalid).
"'";
147$sql .=
" AND p.entity = ".$conf->entity;
156if ($syear && !$smonth) {
158} elseif ($syear && $smonth && !$sday) {
160} elseif ($syear && $smonth && $sday) {
161 $sql .=
" AND datef BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $smonth, $sday, $syear)).
"' AND '".$db->idate(
dol_mktime(23, 59, 59, $smonth, $sday, $syear)).
"'";
166$resql = $db->query($sql);
168 $num = $db->num_rows($resql);
171 print
"<!-- title of cash fence -->\n";
176 print $langs->trans(
"CashControl").
" #".
$object->id.(($nameterminal !=
"TAKEPOS_TERMINAL_NAME_".$object->posnumber) ?
'<br>'.$nameterminal :
'');
177 if (
$object->status == $object::STATUS_DRAFT) {
178 print
'<br><span class="opacitymedium small">('.$langs->trans(
"Draft").
")</span>";
182 print
'<br>'.$langs->trans(
"DateCreationShort").
": ".
dol_print_date(
$object->date_creation,
'dayhour');
183 $userauthor =
$object->fk_user_valid;
184 if (empty($userauthor)) {
185 $userauthor =
$object->fk_user_creat;
188 $uservalid =
new User($db);
189 if ($userauthor > 0) {
190 $uservalid->fetch($userauthor);
191 print
'<br>'.$langs->trans(
"Author").
': '.$uservalid->getFullName($langs);
193 print
'<br>'.$langs->trans(
"Period").
': '.
$object->year_close.($object->month_close ?
'-'.$object->month_close :
'').(
$object->day_close ?
'-'.$object->day_close :
'');
196 $invoicetmp =
new Facture($db);
199 print
"<div style='text-align: right'><h2>";
200 print $langs->trans(
"InitialBankBalance").
' - '.$langs->trans(
"Cash").
' : <div class="inline-block amount width100">'.
price(
$object->opening).
'</div>';
209 print
'<div class="div-table-responsive">';
210 print
'<table class="tagtable liste">'.
"\n";
213 print
'<tr class="liste_titre">';
214 print_liste_field_titre($arrayfields[
'b.rowid'][
'label'], $_SERVER[
'PHP_SELF'],
'b.rowid',
'', $param,
'', $sortfield, $sortorder);
215 print_liste_field_titre($arrayfields[
'b.dateo'][
'label'], $_SERVER[
'PHP_SELF'],
'b.dateo',
'', $param,
'"', $sortfield, $sortorder,
'center ');
216 print_liste_field_titre($arrayfields[
'ba.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'ba.ref',
'', $param,
'', $sortfield, $sortorder,
'right ');
217 print_liste_field_titre($arrayfields[
'cp.code'][
'label'], $_SERVER[
'PHP_SELF'],
'cp.code',
'', $param,
'', $sortfield, $sortorder,
'right ');
218 print_liste_field_titre($arrayfields[
'b.debit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
'right ');
219 print_liste_field_titre($arrayfields[
'b.credit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
'right ');
224 $cash = $bank = $cheque = $other = 0;
228 $totalvatperrate = array();
229 $totalhtperrate = array();
232 $cachebankaccount = array();
233 $cacheinvoiceid = array();
234 $transactionspertype = array();
235 $amountpertype = array();
237 $totalarray = array(
'nbfield' => 0,
'pos' => array(),
'val' => array(
'totaldebfield' => 0,
'totalcredfield' => 0));
239 $objp = $db->fetch_object($resql);
242 if (empty($cachebankaccount[$objp->bankid])) {
243 $bankaccounttmp =
new Account($db);
244 $bankaccounttmp->fetch($objp->bankid);
245 $cachebankaccount[$objp->bankid] = $bankaccounttmp;
246 $bankaccount = $bankaccounttmp;
248 $bankaccount = $cachebankaccount[$objp->bankid];
251 $invoicetmp->fetch($objp->facid);
253 if (empty($cacheinvoiceid[$objp->facid])) {
254 $cacheinvoiceid[$objp->facid] = $objp->facid;
255 foreach ($invoicetmp->lines as $line) {
256 $totalqty += $line->qty;
257 $totalvat += $line->total_tva;
259 if (empty($totalvatperrate[$line->tva_tx])) {
260 $totalvatperrate[$line->tva_tx] = 0;
261 $totalhtperrate[$line->tva_tx] = 0;
263 $totalvatperrate[$line->tva_tx] += $line->total_tva;
264 $totalhtperrate[$line->tva_tx] += $line->total_ht;
266 $totallocaltax1 += $line->total_localtax1;
267 $totallocaltax2 += $line->total_localtax2;
271 if (
$object->posmodule ==
"takepos") {
272 $var1 =
'CASHDESK_ID_BANKACCOUNT_CASH'.$object->posnumber;
274 $var1 =
'CASHDESK_ID_BANKACCOUNT_CASH';
277 if ($objp->code ==
'CHQ') {
278 $cheque += $objp->amount;
279 if (empty($transactionspertype[$objp->code])) {
280 $transactionspertype[$objp->code] = 0;
282 $transactionspertype[$objp->code] += 1;
283 } elseif ($objp->code ==
'CB') {
284 $bank += $objp->amount;
285 if (empty($transactionspertype[$objp->code])) {
286 $transactionspertype[$objp->code] = 0;
288 $transactionspertype[$objp->code] += 1;
291 $cash += $objp->amount;
294 if (empty($transactionspertype[
'CASH'])) {
295 $transactionspertype[
'CASH'] = 0;
297 $transactionspertype[
'CASH'] += 1;
299 $other += $objp->amount;
300 if (empty($transactionspertype[
'OTHER'])) {
301 $transactionspertype[
'OTHER'] = 0;
303 $transactionspertype[
'OTHER'] += 1;
307 if (empty($amountpertype[$objp->code])) {
308 $amountpertype[$objp->code] = 0;
311 if ($objp->amount < 0) {
312 $amountpertype[$objp->code] += $objp->amount;
314 if ($objp->amount > 0) {
315 $amountpertype[$objp->code] -= $objp->amount;
319 print
'<tr class="oddeven">';
322 print
'<td class="nowrap left">';
323 print $invoicetmp->getNomUrl(1);
330 print
'<td class="nowrap left">';
331 print
'<span id="dateoperation_'.$objp->facid.
'">'.
dol_print_date($db->jdate($objp->do),
"day").
"</span>";
338 print
'<td class="nowrap right">';
339 print $bankaccount->getNomUrl(1);
346 print
'<td class="right">';
354 print
'<td class="right">';
355 if ($objp->amount < 0) {
356 print
'<span class="amount">'.price($objp->amount * -1).
'</span>';
357 $totalarray[
'val'][
'totaldebfield'] += $objp->amount;
368 print
'<td class="right">';
369 if ($objp->amount > 0) {
370 print
'<span class="amount">'.price($objp->amount).
'</span>';
371 $totalarray[
'val'][
'totalcredfield'] += $objp->amount;
389 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
398 print
'<div style="text-align: right">';
401 print $langs->trans(
"Cash").(!empty($transactionspertype[
'CASH']) ?
' ('.$transactionspertype[
'CASH'].
' '.$langs->trans(
"Articles").
')' :
'').
' : ';
403 print
'<div class="inline-block amount width100">'.($cash >= 0 ?
'+' :
'').
price($cash).
'</div>';
404 print
'<div class="inline-block amount width100">'.price($newcash).
'</div>';
406 print
'<div class="inline-block amount width100"></div>';
407 print
'<div class="inline-block amount width100">'.price($cash).
'</div>';
409 if (!$summaryonly &&
$object->status == $object::STATUS_VALIDATED && $newcash !=
$object->cash) {
410 print
' <div class="inline-block amountremaintopay fontsizeunset small"><> '.$langs->trans(
"Declared").
': '.
price(
$object->cash).
'</div>';
415 print $langs->trans(
"PaymentTypeCHQ").(!empty($transactionspertype[
'CHQ']) ?
' ('.$transactionspertype[
'CHQ'].
' '.$langs->trans(
"Articles").
')' :
'').
' : ';
416 print
'<div class="inline-block amount width100"></div>';
417 print
'<div class="inline-block amount width100">'.price($cheque).
'</div>';
418 if (!$summaryonly &&
$object->status == $object::STATUS_VALIDATED && $cheque !=
$object->cheque) {
419 print
' <div class="inline-block amountremaintopay fontsizeunset small"><> '.$langs->trans(
"Declared").
' : '.
price(
$object->cheque).
'</div>';
424 print $langs->trans(
"PaymentTypeCB").(!empty($transactionspertype[
'CB']) ?
' ('.$transactionspertype[
'CB'].
' '.$langs->trans(
"Articles").
')' :
'').
' : ';
425 print
'<div class="inline-block amount width100"></div>';
426 print
'<div class="inline-block amount width100">'.price($bank).
'</div>';
427 if (!$summaryonly &&
$object->status == $object::STATUS_VALIDATED && $bank !=
$object->card) {
428 print
' <div class="inline-block amountremaintopay fontsizeunset small"><> '.$langs->trans(
"Declared").
': '.
price(
$object->card).
'</div>';
434 print
''.$langs->trans(
"Other").(!empty($transactionspertype[
'OTHER']) ?
' ('.$transactionspertype[
'OTHER'].
' '.$langs->trans(
"Articles").
')' :
'').
' : ';
435 print
'<div class="inline-block amount width100"></div>';
436 print
'<div class="inline-block amount width100">'.price($other).
"</div>";
442 print $langs->trans(
"Total").
' ('.$totalqty.
' '.$langs->trans(
"Articles").
') : <div class="inline-block amount width100"></div><div class="inline-block amount width100">'.
price((
float) $cash + (
float) $cheque + (
float) $bank + (
float) $other).
'</div>';
444 print
'<br>'.$langs->trans(
"TotalVAT").
' : <div class="inline-block amount width100"></div><div class="inline-block amount width100">'.
price($totalvat).
'</div>';
446 if ($mysoc->useLocalTax(1)) {
447 print
'<br>'.$langs->trans(
"TotalLT1").
' : <div class="inline-block amount width100"></div><div class="inline-block amount width100">'.
price($totallocaltax1).
'</div>';
449 if ($mysoc->useLocalTax(1)) {
450 print
'<br>'.$langs->trans(
"TotalLT2").
' : <div class="inline-block amount width100"></div><div class="inline-block amount width100">'.
price($totallocaltax2).
'</div>';
453 if (!empty($totalvatperrate) && is_array($totalvatperrate)) {
454 print
'<br><br><div class="small inline-block width100">'.$langs->trans(
"TotalHT").
'</div><div class="small inline-block width100">'.$langs->trans(
"TotalVAT").
'</div>';
455 if (
getDolGlobalInt(
'TAKEPOS_CASHCONTROL_REPORT_SHOW_TOTAL_INCLUDING_TAXES_COLUMN', 0) != 0) {
456 print
'<div class="small inline-block width100">'.$langs->trans(
"TotalTTC").
'</div>';
458 foreach ($totalvatperrate as $keyrate => $valuerate) {
459 print
'<br><div class="small">'.$langs->trans(
"VATRate").
' '.
vatrate($keyrate,
true).
' : <div class="inline-block amount width100">'.
price($totalhtperrate[$keyrate] ?? 0).
'</div><div class="inline-block amount width100">'.
price($valuerate).
'</div>';
460 if (
getDolGlobalInt(
'TAKEPOS_CASHCONTROL_REPORT_SHOW_TOTAL_INCLUDING_TAXES_COLUMN', 0) != 0) {
461 print
'<div class="inline-block amount width100">'.price(($totalhtperrate[$keyrate] ?? 0) + $valuerate).
'</div>';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
Class to manage bank accounts.
Class to manage cash fence.
Class to manage invoices.
Class to manage Dolibarr users.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.