32if (!defined(
'NOREQUIREMENU')) {
33 define(
'NOREQUIREMENU',
'1');
35if (!defined(
'NOBROWSERNOTIF')) {
36 define(
'NOBROWSERNOTIF',
'1');
39$_GET[
'optioncss'] =
"print";
42require
'../../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
50$langs->loadLangs(array(
"bills",
"banks"));
59$sortfield =
'b.datev,b.dateo,b.rowid';
62 'b.rowid'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
63 'b.dateo'=>array(
'label'=>$langs->trans(
"DateOperationShort"),
'checked'=>1),
64 'b.num_chq'=>array(
'label'=>$langs->trans(
"Number"),
'checked'=>1),
65 'ba.ref'=>array(
'label'=>$langs->trans(
"BankAccount"),
'checked'=>1),
66 'cp.code'=>array(
'label'=>$langs->trans(
"PaymentMode"),
'checked'=>1),
67 'b.debit'=>array(
'label'=>$langs->trans(
"Debit"),
'checked'=>1,
'position'=>600),
68 'b.credit'=>array(
'label'=>$langs->trans(
"Credit"),
'checked'=>1,
'position'=>605),
71$syear = $object->year_close;
72$smonth = $object->month_close;
73$sday = $object->day_close;
75$posmodule = $object->posmodule;
76$terminalid = $object->posnumber;
79if ($user->socid > 0) {
83if (empty($user->rights->cashdesk->run) && empty($user->rights->takepos->run)) {
92$title = $langs->trans(
"CashControl");
95llxHeader(
'', $title,
'',
'', 0, 0, array(), array(), $param);
124$sql =
"SELECT f.rowid as facid, f.ref, f.datef as do, pf.amount as amount, b.fk_account as bankid, cp.code";
125$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";
126$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";
127$sql .=
" AND f.module_source = '".$db->escape($posmodule).
"'";
128$sql .=
" AND f.pos_source = '".$db->escape($terminalid).
"'";
129$sql .=
" AND f.paye = 1";
130$sql .=
" AND p.entity = ".$conf->entity;
139if ($syear && !$smonth) {
141} elseif ($syear && $smonth && !$sday) {
143} elseif ($syear && $smonth && $sday) {
144 $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)).
"'";
149$resql = $db->query($sql);
151 $num = $db->num_rows($resql);
154 print
"<!-- title of cash fence -->\n";
157 if ($object->status != $object::STATUS_DRAFT) {
158 print $langs->trans(
"CashControl").
" ".$object->id;
160 print $langs->trans(
"CashControl").
" - ".$langs->trans(
"Draft");
164 print
'<br>'.$langs->trans(
"DateCreationShort").
": ".
dol_print_date($object->date_creation,
'dayhour');
165 $userauthor = $object->fk_user_valid;
166 if (empty($userauthor)) {
167 $userauthor = $object->fk_user_creat;
170 $uservalid =
new User($db);
171 if ($userauthor > 0) {
172 $uservalid->fetch($userauthor);
173 print
'<br>'.$langs->trans(
"Author").
': '.$uservalid->getFullName($langs);
175 print
'<br>'.$langs->trans(
"Period").
': '.$object->year_close.($object->month_close ?
'-'.$object->month_close :
'').($object->day_close ?
'-'.$object->day_close :
'');
178 $invoicetmp =
new Facture($db);
180 print
"<div style='text-align: right'><h2>";
181 print $langs->trans(
"InitialBankBalance").
' - '.$langs->trans(
"Cash").
' : <div class="inline-block amount width100">'.
price($object->opening).
'</div>';
184 print
'<div class="div-table-responsive">';
185 print
'<table class="tagtable liste">'.
"\n";
190 print
'<tr class="liste_titre">';
191 print_liste_field_titre($arrayfields[
'b.rowid'][
'label'], $_SERVER[
'PHP_SELF'],
'b.rowid',
'', $param,
'', $sortfield, $sortorder);
192 print_liste_field_titre($arrayfields[
'b.dateo'][
'label'], $_SERVER[
'PHP_SELF'],
'b.dateo',
'', $param,
'"', $sortfield, $sortorder,
'center ');
193 print_liste_field_titre($arrayfields[
'ba.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'ba.ref',
'', $param,
'', $sortfield, $sortorder,
'right ');
194 print_liste_field_titre($arrayfields[
'cp.code'][
'label'], $_SERVER[
'PHP_SELF'],
'cp.code',
'', $param,
'', $sortfield, $sortorder,
'right ');
195 print_liste_field_titre($arrayfields[
'b.debit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
'right ');
196 print_liste_field_titre($arrayfields[
'b.credit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
'right ');
200 $cash = $bank = $cheque = $other = 0;
204 $totalvatperrate = array();
207 $cachebankaccount = array();
208 $cacheinvoiceid = array();
209 $transactionspertype = array();
210 $amountpertype = array();
212 $totalarray = array();
214 $objp = $db->fetch_object($resql);
217 if (empty($cachebankaccount[$objp->bankid])) {
218 $bankaccounttmp =
new Account($db);
219 $bankaccounttmp->fetch($objp->bankid);
220 $cachebankaccount[$objp->bankid] = $bankaccounttmp;
221 $bankaccount = $bankaccounttmp;
223 $bankaccount = $cachebankaccount[$objp->bankid];
226 $invoicetmp->fetch($objp->facid);
228 if (empty($cacheinvoiceid[$objp->facid])) {
229 $cacheinvoiceid[$objp->facid] = $objp->facid;
230 foreach ($invoicetmp->lines as $line) {
231 $totalqty += $line->qty;
232 $totalvat += $line->total_tva;
234 if (empty($totalvatperrate[$line->tva_tx])) {
235 $totalvatperrate[$line->tva_tx] = 0;
237 $totalvatperrate[$line->tva_tx] += $line->total_tva;
239 $totallocaltax1 += $line->total_localtax1;
240 $totallocaltax2 += $line->total_localtax2;
244 print
'<tr class="oddeven">';
247 print
'<td class="nowrap left">';
248 print $invoicetmp->getNomUrl(1);
251 $totalarray[
'nbfield']++;
255 print
'<td class="nowrap left">';
256 print
'<span id="dateoperation_'.$objp->rowid.
'">'.
dol_print_date($db->jdate($objp->do),
"day").
"</span>";
259 $totalarray[
'nbfield']++;
262 if ($object->posmodule ==
"takepos") {
263 $var1 =
'CASHDESK_ID_BANKACCOUNT_CASH'.$object->posnumber;
265 $var1 =
'CASHDESK_ID_BANKACCOUNT_CASH';
269 print
'<td class="nowrap right">';
270 print $bankaccount->getNomUrl(1);
271 if ($objp->code ==
'CHQ') {
272 $cheque += $objp->amount;
273 if (empty($transactionspertype[$objp->code])) {
274 $transactionspertype[$objp->code] = 0;
276 $transactionspertype[$objp->code] += 1;
277 } elseif ($objp->code ==
'CB') {
278 $bank += $objp->amount;
279 if (empty($transactionspertype[$objp->code])) {
280 $transactionspertype[$objp->code] = 0;
282 $transactionspertype[$objp->code] += 1;
284 if ($conf->global->$var1 == $bankaccount->id) {
285 $cash += $objp->amount;
288 if (empty($transactionspertype[
'CASH'])) {
289 $transactionspertype[
'CASH'] = 0;
291 $transactionspertype[
'CASH'] += 1;
293 $other += $objp->amount;
294 if (empty($transactionspertype[
'OTHER'])) {
295 $transactionspertype[
'OTHER'] = 0;
297 $transactionspertype[
'OTHER'] += 1;
302 $totalarray[
'nbfield']++;
306 print
'<td class="right">';
308 if (empty($amountpertype[$objp->code])) {
309 $amountpertype[$objp->code] = 0;
313 $totalarray[
'nbfield']++;
317 print
'<td class="right">';
318 if ($objp->amount < 0) {
319 print
'<span class="amount">'.price($objp->amount * -1).
'</span>';
320 $totalarray[
'val'][
'totaldebfield'] += $objp->amount;
321 $amountpertype[$objp->code] += $objp->amount;
325 $totalarray[
'nbfield']++;
328 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totaldebfield';
332 print
'<td class="right">';
333 if ($objp->amount > 0) {
334 print
'<span class="amount">'.price($objp->amount).
'</span>';
335 $totalarray[
'val'][
'totalcredfield'] += $objp->amount;
336 $amountpertype[$objp->code] -= $objp->amount;
340 $totalarray[
'nbfield']++;
343 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalcredfield';
352 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
358 $cash =
price2num($cash + $object->opening,
'MT');
360 print
'<div style="text-align: right">';
363 print $langs->trans(
"Cash").(!empty($transactionspertype[
'CASH']) ?
' ('.$transactionspertype[
'CASH'].
')' :
'').
' : <div class="inline-block amount width100">'.
price($cash).
'</div>';
364 if ($object->status == $object::STATUS_VALIDATED && $cash != $object->cash) {
365 print
' <> <div class="inline-block amountremaintopay fontsizeunset">'.$langs->trans(
"Declared").
': '.
price($object->cash).
'</div>';
370 print $langs->trans(
"PaymentTypeCHQ").(!empty($transactionspertype[
'CHQ']) ?
' ('.$transactionspertype[
'CHQ'].
')' :
'').
' : <div class="inline-block amount width100">'.
price($cheque).
'</div>';
371 if ($object->status == $object::STATUS_VALIDATED && $cheque != $object->cheque) {
372 print
' <> <div class="inline-block amountremaintopay fontsizeunset">'.$langs->trans(
"Declared").
' : '.
price($object->cheque).
'</div>';
377 print $langs->trans(
"PaymentTypeCB").(!empty($transactionspertype[
'CB']) ?
' ('.$transactionspertype[
'CB'].
')' :
'').
' : <div class="inline-block amount width100">'.
price($bank).
'</div>';
378 if ($object->status == $object::STATUS_VALIDATED && $bank != $object->card) {
379 print
' <> <div class="inline-block amountremaintopay fontsizeunset">'.$langs->trans(
"Declared").
': '.
price($object->card).
'</div>';
385 print
''.$langs->trans(
"Other").($transactionspertype[
'OTHER'] ?
' ('.$transactionspertype[
'OTHER'].
')' :
'').
' : <div class="inline-block amount width100">'.
price($other).
"</div>";
389 print $langs->trans(
"Total").
' ('.$totalqty.
' '.$langs->trans(
"Articles").
') : <div class="inline-block amount width100">'.
price($cash + $cheque + $bank + $other).
'</div>';
391 print
'<br>'.$langs->trans(
"TotalVAT").
' : <div class="inline-block amount width100">'.
price($totalvat).
'</div>';
393 if ($mysoc->useLocalTax(1)) {
394 print
'<br>'.$langs->trans(
"TotalLT1").
' : <div class="inline-block amount width100">'.
price($totallocaltax1).
'</div>';
396 if ($mysoc->useLocalTax(1)) {
397 print
'<br>'.$langs->trans(
"TotalLT2").
' : <div class="inline-block amount width100">'.
price($totallocaltax2).
'</div>';
400 if (!empty($totalvatperrate) && is_array($totalvatperrate)) {
401 print
'<br><br><div class="small inline-block">'.$langs->trans(
"VATRate").
'</div>';
402 foreach ($totalvatperrate as $keyrate => $valuerate) {
403 print
'<br><div class="small">'.$langs->trans(
"VATRate").
' '.
vatrate($keyrate, 1).
' : <div class="inline-block amount width100">'.
price($valuerate).
'</div></div>';
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 informations (by default a local PHP server timestamp) Re...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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='', $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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.