33if (!defined(
'NOREQUIREMENU')) {
34 define(
'NOREQUIREMENU',
'1');
36if (!defined(
'NOBROWSERNOTIF')) {
37 define(
'NOBROWSERNOTIF',
'1');
43require
'../../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
51$langs->loadLangs(array(
"bills",
"banks"));
61$sortfield =
'b.datev,b.dateo,b.rowid';
64 'b.rowid' => array(
'label' => $langs->trans(
"Ref"),
'checked' => 1),
65 'b.dateo' => array(
'label' => $langs->trans(
"DateOperationShort"),
'checked' => 1),
66 'b.num_chq' => array(
'label' => $langs->trans(
"Number"),
'checked' => 1),
67 'ba.ref' => array(
'label' => $langs->trans(
"BankAccount"),
'checked' => 1),
68 'cp.code' => array(
'label' => $langs->trans(
"PaymentMode"),
'checked' => 1),
69 'b.debit' => array(
'label' => $langs->trans(
"Debit"),
'checked' => 1,
'position' => 600),
70 'b.credit' => array(
'label' => $langs->trans(
"Credit"),
'checked' => 1,
'position' => 605),
78$terminalid =
$object->posnumber;
81if ($user->socid > 0) {
85if (!$user->hasRight(
'cashdesk',
'run') && !$user->hasRight(
'takepos',
'run')) {
94$title = $langs->trans(
"CashControl");
97$conf->dol_hide_topmenu = 1;
98$conf->dol_hide_leftmenu = 1;
100llxHeader(
'', $title,
'',
'', 0, 0, array(), array(), $param);
102print
'<!-- Begin div id-container --><div id="id-container" class="id-container center">';
131$sql =
"SELECT f.rowid as facid, f.ref, f.datef as do, pf.amount as amount, b.fk_account as bankid, cp.code";
132$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";
133$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";
134$sql .=
" AND f.module_source = '".$db->escape($posmodule).
"'";
135$sql .=
" AND f.pos_source = '".$db->escape($terminalid).
"'";
136$sql .=
" AND f.paye = 1";
137$sql .=
" AND p.entity = ".$conf->entity;
146if ($syear && !$smonth) {
148} elseif ($syear && $smonth && !$sday) {
150} elseif ($syear && $smonth && $sday) {
151 $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)).
"'";
156$resql = $db->query($sql);
158 $num = $db->num_rows($resql);
161 print
"<!-- title of cash fence -->\n";
166 print $langs->trans(
"CashControl").
" #".
$object->id.(($nameterminal !=
"TAKEPOS_TERMINAL_NAME_".$object->posnumber) ?
'<br>'.$nameterminal :
'');
167 if (
$object->status == $object::STATUS_DRAFT) {
168 print
'<br><span class="opacitymedium small">('.$langs->trans(
"Draft").
")</span>";
172 print
'<br>'.$langs->trans(
"DateCreationShort").
": ".
dol_print_date(
$object->date_creation,
'dayhour');
173 $userauthor =
$object->fk_user_valid;
174 if (empty($userauthor)) {
175 $userauthor =
$object->fk_user_creat;
178 $uservalid =
new User($db);
179 if ($userauthor > 0) {
180 $uservalid->fetch($userauthor);
181 print
'<br>'.$langs->trans(
"Author").
': '.$uservalid->getFullName($langs);
183 print
'<br>'.$langs->trans(
"Period").
': '.
$object->year_close.($object->month_close ?
'-'.$object->month_close :
'').(
$object->day_close ?
'-'.$object->day_close :
'');
186 $invoicetmp =
new Facture($db);
189 print
"<div style='text-align: right'><h2>";
190 print $langs->trans(
"InitialBankBalance").
' - '.$langs->trans(
"Cash").
' : <div class="inline-block amount width100">'.
price(
$object->opening).
'</div>';
199 print
'<div class="div-table-responsive">';
200 print
'<table class="tagtable liste">'.
"\n";
203 print
'<tr class="liste_titre">';
204 print_liste_field_titre($arrayfields[
'b.rowid'][
'label'], $_SERVER[
'PHP_SELF'],
'b.rowid',
'', $param,
'', $sortfield, $sortorder);
205 print_liste_field_titre($arrayfields[
'b.dateo'][
'label'], $_SERVER[
'PHP_SELF'],
'b.dateo',
'', $param,
'"', $sortfield, $sortorder,
'center ');
206 print_liste_field_titre($arrayfields[
'ba.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'ba.ref',
'', $param,
'', $sortfield, $sortorder,
'right ');
207 print_liste_field_titre($arrayfields[
'cp.code'][
'label'], $_SERVER[
'PHP_SELF'],
'cp.code',
'', $param,
'', $sortfield, $sortorder,
'right ');
208 print_liste_field_titre($arrayfields[
'b.debit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
'right ');
209 print_liste_field_titre($arrayfields[
'b.credit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
'right ');
214 $cash = $bank = $cheque = $other = 0;
218 $totalvatperrate = array();
221 $cachebankaccount = array();
222 $cacheinvoiceid = array();
223 $transactionspertype = array();
224 $amountpertype = array();
226 $totalarray = array(
'nbfield' => 0,
'pos' => array());
228 $objp = $db->fetch_object($resql);
231 if (empty($cachebankaccount[$objp->bankid])) {
232 $bankaccounttmp =
new Account($db);
233 $bankaccounttmp->fetch($objp->bankid);
234 $cachebankaccount[$objp->bankid] = $bankaccounttmp;
235 $bankaccount = $bankaccounttmp;
237 $bankaccount = $cachebankaccount[$objp->bankid];
240 $invoicetmp->fetch($objp->facid);
242 if (empty($cacheinvoiceid[$objp->facid])) {
243 $cacheinvoiceid[$objp->facid] = $objp->facid;
244 foreach ($invoicetmp->lines as $line) {
245 $totalqty += $line->qty;
246 $totalvat += $line->total_tva;
248 if (empty($totalvatperrate[$line->tva_tx])) {
249 $totalvatperrate[$line->tva_tx] = 0;
251 $totalvatperrate[$line->tva_tx] += $line->total_tva;
253 $totallocaltax1 += $line->total_localtax1;
254 $totallocaltax2 += $line->total_localtax2;
258 if (
$object->posmodule ==
"takepos") {
259 $var1 =
'CASHDESK_ID_BANKACCOUNT_CASH'.$object->posnumber;
261 $var1 =
'CASHDESK_ID_BANKACCOUNT_CASH';
264 if ($objp->code ==
'CHQ') {
265 $cheque += $objp->amount;
266 if (empty($transactionspertype[$objp->code])) {
267 $transactionspertype[$objp->code] = 0;
269 $transactionspertype[$objp->code] += 1;
270 } elseif ($objp->code ==
'CB') {
271 $bank += $objp->amount;
272 if (empty($transactionspertype[$objp->code])) {
273 $transactionspertype[$objp->code] = 0;
275 $transactionspertype[$objp->code] += 1;
278 $cash += $objp->amount;
281 if (empty($transactionspertype[
'CASH'])) {
282 $transactionspertype[
'CASH'] = 0;
284 $transactionspertype[
'CASH'] += 1;
286 $other += $objp->amount;
287 if (empty($transactionspertype[
'OTHER'])) {
288 $transactionspertype[
'OTHER'] = 0;
290 $transactionspertype[
'OTHER'] += 1;
294 if (empty($amountpertype[$objp->code])) {
295 $amountpertype[$objp->code] = 0;
298 if ($objp->amount < 0) {
299 $amountpertype[$objp->code] += $objp->amount;
301 if ($objp->amount > 0) {
302 $amountpertype[$objp->code] -= $objp->amount;
306 print
'<tr class="oddeven">';
309 print
'<td class="nowrap left">';
310 print $invoicetmp->getNomUrl(1);
313 $totalarray[
'nbfield']++;
317 print
'<td class="nowrap left">';
318 print
'<span id="dateoperation_'.$objp->rowid.
'">'.
dol_print_date($db->jdate($objp->do),
"day").
"</span>";
321 $totalarray[
'nbfield']++;
325 print
'<td class="nowrap right">';
326 print $bankaccount->getNomUrl(1);
329 $totalarray[
'nbfield']++;
333 print
'<td class="right">';
337 $totalarray[
'nbfield']++;
341 print
'<td class="right">';
342 if ($objp->amount < 0) {
343 print
'<span class="amount">'.price($objp->amount * -1).
'</span>';
344 $totalarray[
'val'][
'totaldebfield'] += $objp->amount;
348 $totalarray[
'nbfield']++;
351 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totaldebfield';
355 print
'<td class="right">';
356 if ($objp->amount > 0) {
357 print
'<span class="amount">'.price($objp->amount).
'</span>';
358 $totalarray[
'val'][
'totalcredfield'] += $objp->amount;
362 $totalarray[
'nbfield']++;
365 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalcredfield';
376 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
385 print
'<div style="text-align: right">';
388 print $langs->trans(
"Cash").(!empty($transactionspertype[
'CASH']) ?
' ('.$transactionspertype[
'CASH'].
' '.$langs->trans(
"Articles").
')' :
'').
' : ';
390 print
'<div class="inline-block amount width100">'.($cash >= 0 ?
'+' :
'').
price($cash).
'</div>';
391 print
'<div class="inline-block amount width100">'.price($newcash).
'</div>';
393 print
'<div class="inline-block amount width100"></div>';
394 print
'<div class="inline-block amount width100">'.price($cash).
'</div>';
396 if (!$summaryonly &&
$object->status == $object::STATUS_VALIDATED && $newcash !=
$object->cash) {
397 print
' <div class="inline-block amountremaintopay fontsizeunset small"><> '.$langs->trans(
"Declared").
': '.
price(
$object->cash).
'</div>';
402 print $langs->trans(
"PaymentTypeCHQ").(!empty($transactionspertype[
'CHQ']) ?
' ('.$transactionspertype[
'CHQ'].
' '.$langs->trans(
"Articles").
')' :
'').
' : ';
403 print
'<div class="inline-block amount width100"></div>';
404 print
'<div class="inline-block amount width100">'.price($cheque).
'</div>';
405 if (!$summaryonly &&
$object->status == $object::STATUS_VALIDATED && $cheque !=
$object->cheque) {
406 print
' <div class="inline-block amountremaintopay fontsizeunset small"><> '.$langs->trans(
"Declared").
' : '.
price(
$object->cheque).
'</div>';
411 print $langs->trans(
"PaymentTypeCB").(!empty($transactionspertype[
'CB']) ?
' ('.$transactionspertype[
'CB'].
' '.$langs->trans(
"Articles").
')' :
'').
' : ';
412 print
'<div class="inline-block amount width100"></div>';
413 print
'<div class="inline-block amount width100">'.price($bank).
'</div>';
414 if (!$summaryonly &&
$object->status == $object::STATUS_VALIDATED && $bank !=
$object->card) {
415 print
' <div class="inline-block amountremaintopay fontsizeunset small"><> '.$langs->trans(
"Declared").
': '.
price(
$object->card).
'</div>';
421 print
''.$langs->trans(
"Other").(!empty($transactionspertype[
'OTHER']) ?
' ('.$transactionspertype[
'OTHER'].
' '.$langs->trans(
"Articles").
')' :
'').
' : ';
422 print
'<div class="inline-block amount width100"></div>';
423 print
'<div class="inline-block amount width100">'.price($other).
"</div>";
429 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>';
431 print
'<br>'.$langs->trans(
"TotalVAT").
' : <div class="inline-block amount width100"></div><div class="inline-block amount width100">'.
price($totalvat).
'</div>';
433 if ($mysoc->useLocalTax(1)) {
434 print
'<br>'.$langs->trans(
"TotalLT1").
' : <div class="inline-block amount width100"></div><div class="inline-block amount width100">'.
price($totallocaltax1).
'</div>';
436 if ($mysoc->useLocalTax(1)) {
437 print
'<br>'.$langs->trans(
"TotalLT2").
' : <div class="inline-block amount width100"></div><div class="inline-block amount width100">'.
price($totallocaltax2).
'</div>';
440 if (!empty($totalvatperrate) && is_array($totalvatperrate)) {
441 print
'<br><br><div class="small inline-block">'.$langs->trans(
"VATRate").
'</div>';
442 foreach ($totalvatperrate as $keyrate => $valuerate) {
443 print
'<br><div class="small">'.$langs->trans(
"VATRate").
' '.
vatrate($keyrate, 1).
' : <div class="inline-block amount width100"></div><div class="inline-block amount width100">'.
price($valuerate).
'</div></div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
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.
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.
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).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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 dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.