33 if (!defined(
'NOREQUIREMENU')) {
34 define(
'NOREQUIREMENU',
'1');
36 if (!defined(
'NOBROWSERNOTIF')) {
37 define(
'NOBROWSERNOTIF',
'1');
43 require
'../../main.inc.php';
44 require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
51 $langs->loadLangs(array(
"bills",
"banks"));
60 $sortfield =
'b.datev,b.dateo,b.rowid';
63 'b.rowid' => array(
'label' => $langs->trans(
"Ref"),
'checked' => 1),
64 'b.dateo' => array(
'label' => $langs->trans(
"DateOperationShort"),
'checked' => 1),
65 'b.num_chq' => array(
'label' => $langs->trans(
"Number"),
'checked' => 1),
66 'ba.ref' => array(
'label' => $langs->trans(
"BankAccount"),
'checked' => 1),
67 'cp.code' => array(
'label' => $langs->trans(
"PaymentMode"),
'checked' => 1),
68 'b.debit' => array(
'label' => $langs->trans(
"Debit"),
'checked' => 1,
'position' => 600),
69 'b.credit' => array(
'label' => $langs->trans(
"Credit"),
'checked' => 1,
'position' => 605),
76 $posmodule =
$object->posmodule;
77 $terminalid =
$object->posnumber;
80 if ($user->socid > 0) {
84 if (!$user->hasRight(
'cashdesk',
'run') && !$user->hasRight(
'takepos',
'run')) {
93 $title = $langs->trans(
"CashControl");
96 llxHeader(
'', $title,
'',
'', 0, 0, array(), array(), $param);
125 $sql =
"SELECT f.rowid as facid, f.ref, f.datef as do, pf.amount as amount, b.fk_account as bankid, cp.code";
126 $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";
127 $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";
128 $sql .=
" AND f.module_source = '".$db->escape($posmodule).
"'";
129 $sql .=
" AND f.pos_source = '".$db->escape($terminalid).
"'";
130 $sql .=
" AND f.paye = 1";
131 $sql .=
" AND p.entity = ".$conf->entity;
140 if ($syear && !$smonth) {
142 } elseif ($syear && $smonth && !$sday) {
144 } elseif ($syear && $smonth && $sday) {
145 $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)).
"'";
150 $resql = $db->query(
$sql);
152 $num = $db->num_rows($resql);
155 print
"<!-- title of cash fence -->\n";
158 if (
$object->status != $object::STATUS_DRAFT) {
159 print $langs->trans(
"CashControl").
" ".
$object->id;
161 print $langs->trans(
"CashControl").
" - ".$langs->trans(
"Draft");
165 print
'<br>'.$langs->trans(
"DateCreationShort").
": ".
dol_print_date(
$object->date_creation,
'dayhour');
166 $userauthor =
$object->fk_user_valid;
167 if (empty($userauthor)) {
168 $userauthor =
$object->fk_user_creat;
171 $uservalid =
new User($db);
172 if ($userauthor > 0) {
173 $uservalid->fetch($userauthor);
174 print
'<br>'.$langs->trans(
"Author").
': '.$uservalid->getFullName($langs);
176 print
'<br>'.$langs->trans(
"Period").
': '.
$object->year_close.($object->month_close ?
'-'.$object->month_close :
'').(
$object->day_close ?
'-'.$object->day_close :
'');
179 $invoicetmp =
new Facture($db);
181 print
"<div style='text-align: right'><h2>";
182 print $langs->trans(
"InitialBankBalance").
' - '.$langs->trans(
"Cash").
' : <div class="inline-block amount width100">'.
price(
$object->opening).
'</div>';
185 print
'<div class="div-table-responsive">';
186 print
'<table class="tagtable liste">'.
"\n";
191 print
'<tr class="liste_titre">';
192 print_liste_field_titre($arrayfields[
'b.rowid'][
'label'], $_SERVER[
'PHP_SELF'],
'b.rowid',
'', $param,
'', $sortfield, $sortorder);
193 print_liste_field_titre($arrayfields[
'b.dateo'][
'label'], $_SERVER[
'PHP_SELF'],
'b.dateo',
'', $param,
'"', $sortfield, $sortorder,
'center ');
194 print_liste_field_titre($arrayfields[
'ba.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'ba.ref',
'', $param,
'', $sortfield, $sortorder,
'right ');
195 print_liste_field_titre($arrayfields[
'cp.code'][
'label'], $_SERVER[
'PHP_SELF'],
'cp.code',
'', $param,
'', $sortfield, $sortorder,
'right ');
196 print_liste_field_titre($arrayfields[
'b.debit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
'right ');
197 print_liste_field_titre($arrayfields[
'b.credit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
'right ');
201 $cash = $bank = $cheque = $other = 0;
205 $totalvatperrate = array();
208 $cachebankaccount = array();
209 $cacheinvoiceid = array();
210 $transactionspertype = array();
211 $amountpertype = array();
213 $totalarray = array(
'nbfield' => 0,
'pos' => array());
215 $objp = $db->fetch_object($resql);
218 if (empty($cachebankaccount[$objp->bankid])) {
219 $bankaccounttmp =
new Account($db);
220 $bankaccounttmp->fetch($objp->bankid);
221 $cachebankaccount[$objp->bankid] = $bankaccounttmp;
222 $bankaccount = $bankaccounttmp;
224 $bankaccount = $cachebankaccount[$objp->bankid];
227 $invoicetmp->fetch($objp->facid);
229 if (empty($cacheinvoiceid[$objp->facid])) {
230 $cacheinvoiceid[$objp->facid] = $objp->facid;
231 foreach ($invoicetmp->lines as $line) {
232 $totalqty += $line->qty;
233 $totalvat += $line->total_tva;
235 if (empty($totalvatperrate[$line->tva_tx])) {
236 $totalvatperrate[$line->tva_tx] = 0;
238 $totalvatperrate[$line->tva_tx] += $line->total_tva;
240 $totallocaltax1 += $line->total_localtax1;
241 $totallocaltax2 += $line->total_localtax2;
245 print
'<tr class="oddeven">';
248 print
'<td class="nowrap left">';
249 print $invoicetmp->getNomUrl(1);
252 $totalarray[
'nbfield']++;
256 print
'<td class="nowrap left">';
257 print
'<span id="dateoperation_'.$objp->rowid.
'">'.
dol_print_date($db->jdate($objp->do),
"day").
"</span>";
260 $totalarray[
'nbfield']++;
263 if (
$object->posmodule ==
"takepos") {
264 $var1 =
'CASHDESK_ID_BANKACCOUNT_CASH'.$object->posnumber;
266 $var1 =
'CASHDESK_ID_BANKACCOUNT_CASH';
270 print
'<td class="nowrap right">';
271 print $bankaccount->getNomUrl(1);
272 if ($objp->code ==
'CHQ') {
273 $cheque += $objp->amount;
274 if (empty($transactionspertype[$objp->code])) {
275 $transactionspertype[$objp->code] = 0;
277 $transactionspertype[$objp->code] += 1;
278 } elseif ($objp->code ==
'CB') {
279 $bank += $objp->amount;
280 if (empty($transactionspertype[$objp->code])) {
281 $transactionspertype[$objp->code] = 0;
283 $transactionspertype[$objp->code] += 1;
286 $cash += $objp->amount;
289 if (empty($transactionspertype[
'CASH'])) {
290 $transactionspertype[
'CASH'] = 0;
292 $transactionspertype[
'CASH'] += 1;
294 $other += $objp->amount;
295 if (empty($transactionspertype[
'OTHER'])) {
296 $transactionspertype[
'OTHER'] = 0;
298 $transactionspertype[
'OTHER'] += 1;
303 $totalarray[
'nbfield']++;
307 print
'<td class="right">';
309 if (empty($amountpertype[$objp->code])) {
310 $amountpertype[$objp->code] = 0;
314 $totalarray[
'nbfield']++;
318 print
'<td class="right">';
319 if ($objp->amount < 0) {
320 print
'<span class="amount">'.price($objp->amount * -1).
'</span>';
321 $totalarray[
'val'][
'totaldebfield'] += $objp->amount;
322 $amountpertype[$objp->code] += $objp->amount;
326 $totalarray[
'nbfield']++;
329 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totaldebfield';
333 print
'<td class="right">';
334 if ($objp->amount > 0) {
335 print
'<span class="amount">'.price($objp->amount).
'</span>';
336 $totalarray[
'val'][
'totalcredfield'] += $objp->amount;
337 $amountpertype[$objp->code] -= $objp->amount;
341 $totalarray[
'nbfield']++;
344 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalcredfield';
353 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
361 print
'<div style="text-align: right">';
364 print $langs->trans(
"Cash").(!empty($transactionspertype[
'CASH']) ?
' ('.$transactionspertype[
'CASH'].
')' :
'').
' : <div class="inline-block amount width100">'.
price($cash).
'</div>';
365 if (
$object->status == $object::STATUS_VALIDATED && $cash !=
$object->cash) {
366 print
' <> <div class="inline-block amountremaintopay fontsizeunset">'.$langs->trans(
"Declared").
': '.
price(
$object->cash).
'</div>';
371 print $langs->trans(
"PaymentTypeCHQ").(!empty($transactionspertype[
'CHQ']) ?
' ('.$transactionspertype[
'CHQ'].
')' :
'').
' : <div class="inline-block amount width100">'.
price($cheque).
'</div>';
372 if (
$object->status == $object::STATUS_VALIDATED && $cheque !=
$object->cheque) {
373 print
' <> <div class="inline-block amountremaintopay fontsizeunset">'.$langs->trans(
"Declared").
' : '.
price(
$object->cheque).
'</div>';
378 print $langs->trans(
"PaymentTypeCB").(!empty($transactionspertype[
'CB']) ?
' ('.$transactionspertype[
'CB'].
')' :
'').
' : <div class="inline-block amount width100">'.
price($bank).
'</div>';
379 if (
$object->status == $object::STATUS_VALIDATED && $bank !=
$object->card) {
380 print
' <> <div class="inline-block amountremaintopay fontsizeunset">'.$langs->trans(
"Declared").
': '.
price(
$object->card).
'</div>';
386 print
''.$langs->trans(
"Other").($transactionspertype[
'OTHER'] ?
' ('.$transactionspertype[
'OTHER'].
')' :
'').
' : <div class="inline-block amount width100">'.
price($other).
"</div>";
390 print $langs->trans(
"Total").
' ('.$totalqty.
' '.$langs->trans(
"Articles").
') : <div class="inline-block amount width100">'.
price((
float) $cash + (
float) $cheque + (
float) $bank + (
float) $other).
'</div>';
392 print
'<br>'.$langs->trans(
"TotalVAT").
' : <div class="inline-block amount width100">'.
price($totalvat).
'</div>';
394 if ($mysoc->useLocalTax(1)) {
395 print
'<br>'.$langs->trans(
"TotalLT1").
' : <div class="inline-block amount width100">'.
price($totallocaltax1).
'</div>';
397 if ($mysoc->useLocalTax(1)) {
398 print
'<br>'.$langs->trans(
"TotalLT2").
' : <div class="inline-block amount width100">'.
price($totallocaltax2).
'</div>';
401 if (!empty($totalvatperrate) && is_array($totalvatperrate)) {
402 print
'<br><br><div class="small inline-block">'.$langs->trans(
"VATRate").
'</div>';
403 foreach ($totalvatperrate as $keyrate => $valuerate) {
404 print
'<br><div class="small">'.$langs->trans(
"VATRate").
' '.
vatrate($keyrate, 1).
' : <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.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
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.