33 require
'../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/bankcateg.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/paymentsocialcontribution.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
57 $langs->loadLangs(array(
"banks",
"bills",
"categories",
"companies",
"margins",
"salaries",
"loan",
"donations",
"trips",
"members",
"compta",
"accountancy"));
61 $action =
GETPOST(
'action',
'aZ09');
62 $cancel =
GETPOST(
'cancel',
'alpha');
63 $confirm =
GETPOST(
'confirm',
'alpha');
64 $contextpage =
'banktransactionlist'.(empty($object->ref) ?
'' :
'-'.$object->id);
67 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
68 $fieldtype = (!empty($ref) ?
'ref' :
'rowid');
71 if ($user->socid) $socid = $user->socid;
72 $result =
restrictedArea($user,
'banque', $fieldvalue,
'bank_account&bank_account',
'',
'', $fieldtype);
74 if ($user->socid) $socid = $user->socid;
79 $search_debit =
GETPOST(
"search_debit",
'alpha');
80 $search_credit =
GETPOST(
"search_credit",
'alpha');
81 $search_type =
GETPOST(
"search_type",
'alpha');
82 $search_account =
GETPOST(
"search_account",
'int') ?
GETPOST(
"search_account",
'int') :
GETPOST(
"account",
'int');
83 $search_accountancy_code =
GETPOST(
'search_accountancy_code',
'alpha') ?
GETPOST(
'search_accountancy_code',
'alpha') :
GETPOST(
'accountancy_code',
'alpha');
85 $search_ref =
GETPOST(
'search_ref',
'alpha');
86 $search_description =
GETPOST(
"search_description",
'alpha');
87 $search_dt_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_start_dtmonth',
'int'),
GETPOST(
'search_start_dtday',
'int'),
GETPOST(
'search_start_dtyear',
'int'));
89 $search_dv_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_start_dvmonth',
'int'),
GETPOST(
'search_start_dvday',
'int'),
GETPOST(
'search_start_dvyear',
'int'));
91 $search_thirdparty =
GETPOST(
"search_thirdparty",
'alpha') ?
GETPOST(
"search_thirdparty",
'alpha') :
GETPOST(
"thirdparty",
'alpha');
92 $search_req_nb =
GETPOST(
"req_nb",
'alpha');
93 $search_num_releve =
GETPOST(
"search_num_releve",
'alpha');
94 $search_conciliated =
GETPOST(
"search_conciliated",
'int');
95 $num_releve =
GETPOST(
"num_releve",
"alpha");
96 if (empty($dateop)) $dateop = -1;
98 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
99 $sortfield =
GETPOST(
"sortfield",
'alpha');
100 $sortorder =
GETPOST(
"sortorder",
'alpha');
102 $pageplusone =
GETPOST(
"pageplusone",
'int');
103 if ($pageplusone) $page = $pageplusone - 1;
104 if (empty($page) || $page == -1) { $page = 0; }
105 $offset = $limit * $page;
106 $pageprev = $page - 1;
107 $pagenext = $page + 1;
108 if (!$sortorder) $sortorder =
'desc,desc,desc';
109 if (!$sortfield) $sortfield =
'b.datev,b.dateo,b.rowid';
112 if ($id > 0 || !empty($ref))
114 $result = $object->fetch($id, $ref);
115 $search_account = $object->id;
117 if (!($object->id > 0))
119 $langs->load(
"errors");
120 print($langs->trans(
'ErrorRecordNotFound'));
125 $mode_balance_ok =
false;
127 if (($sortfield ==
'b.datev' || $sortfield ==
'b.datev,b.dateo,b.rowid'))
129 $sortfield =
'b.datev,b.dateo,b.rowid';
130 if ($id > 0 || !empty($ref) || $search_account > 0) $mode_balance_ok =
true;
134 $hookmanager->initHooks(array(
'banktransactionlist', $contextpage));
138 $extrafields->fetch_name_optionals_label(
'banktransaction');
139 $search_array_options = $extrafields->getOptionalsFromPost(
'banktransaction',
'',
'search_');
141 $arrayfields = array(
142 'b.rowid'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
143 'b.label'=>array(
'label'=>$langs->trans(
"Description"),
'checked'=>1),
144 'b.dateo'=>array(
'label'=>$langs->trans(
"DateOperationShort"),
'checked'=>1),
145 'b.datev'=>array(
'label'=>$langs->trans(
"DateValueShort"),
'checked'=>1),
146 'type'=>array(
'label'=>$langs->trans(
"Type"),
'checked'=>1),
147 'b.num_chq'=>array(
'label'=>$langs->trans(
"Numero"),
'checked'=>1),
148 'bu.label'=>array(
'label'=>$langs->trans(
"ThirdParty"),
'checked'=>1,
'position'=>500),
149 'ba.ref'=>array(
'label'=>$langs->trans(
"BankAccount"),
'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1),
'position'=>1000),
150 'b.debit'=>array(
'label'=>$langs->trans(
"Debit"),
'checked'=>1,
'position'=>600),
151 'b.credit'=>array(
'label'=>$langs->trans(
"Credit"),
'checked'=>1,
'position'=>605),
152 'balancebefore'=>array(
'label'=>$langs->trans(
"BalanceBefore"),
'checked'=>0,
'position'=>1000),
153 'balance'=>array(
'label'=>$langs->trans(
"Balance"),
'checked'=>1,
'position'=>1001),
154 'b.num_releve'=>array(
'label'=>$langs->trans(
"AccountStatement"),
'checked'=>1,
'position'=>1010),
155 'b.conciliated'=>array(
'label'=>$langs->trans(
"Conciliated"),
'enabled'=> $object->rappro,
'checked'=>($action ==
'reconcile' ? 1 : 0),
'position'=>1020),
158 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
169 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
170 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
172 $parameters = array();
173 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
174 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
176 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
178 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
180 $search_dt_start =
'';
182 $search_dv_start =
'';
190 $search_description =
'';
191 $search_thirdparty =
'';
192 $search_num_releve =
'';
193 $search_conciliated =
'';
196 $search_account =
"";
197 if ($id > 0 || !empty($ref)) $search_account = $object->id;
202 $objectclass =
'Account';
203 $objectlabel =
'BankTransaction';
204 $permissiontoread = $user->rights->banque->lire;
205 $permissiontodelete = $user->rights->banque->supprimer;
206 $uploaddir = $conf->bank->dir_output;
207 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
211 if ((
GETPOST(
'confirm_savestatement',
'alpha') ||
GETPOST(
'confirm_reconcile',
'alpha')) && $user->rights->banque->consolidate
217 $num_releve =
GETPOST(
"num_releve",
"alpha");
223 $rowids =
GETPOST(
'rowid',
'array');
225 if (!empty($rowids) && is_array($rowids)) {
226 foreach ($rowids as $row) {
228 $result = $bankline->fetch($row);
229 $bankline->num_releve = $num_releve;
230 $result = $bankline->update_conciliation($user,
GETPOST(
"cat"),
GETPOST(
'confirm_reconcile',
'alpha') ? 1 : 0);
240 $langs->load(
"errors");
245 $langs->load(
"errors");
246 setEventMessages($langs->trans(
"ErrorPleaseTypeBankTransactionReportName"), null,
'errors');
251 $param =
'action=reconcile&contextpage=banktransactionlist&id='.$id.
'&search_account='.$id;
252 $param .=
'&search_conciliated='.urlencode($search_conciliated);
253 if ($page) $param .=
'&page='.urlencode($page);
254 if ($offset) $param .=
'&offset='.urlencode($offset);
255 if ($search_thirdparty) $param .=
'&search_thirdparty='.urlencode($search_thirdparty);
256 if ($search_num_releve) $param .=
'&search_num_releve='.urlencode($search_num_releve);
257 if ($search_description) $param .=
'&search_description='.urlencode($search_description);
258 if ($search_start_dt) $param .=
'&search_start_dt='.urlencode($search_start_dt);
259 if ($search_end_dt) $param .=
'&search_end_dt='.urlencode($search_end_dt);
260 if ($search_start_dv) $param .=
'&search_start_dv='.urlencode($search_start_dv);
261 if ($search_end_dv) $param .=
'&search_end_dv='.urlencode($search_end_dv);
262 if ($search_type) $param .=
'&search_type='.urlencode($search_type);
263 if ($search_debit) $param .=
'&search_debit='.urlencode($search_debit);
264 if ($search_credit) $param .=
'&search_credit='.urlencode($search_credit);
265 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
266 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?'.$param);
272 if (
GETPOST(
'save') && !$cancel && $user->rights->banque->modifier)
283 $operation =
GETPOST(
"operation",
'alpha');
284 $num_chq =
GETPOST(
"num_chq",
'alpha');
285 $label =
GETPOST(
"label",
'alpha');
286 $cat1 =
GETPOST(
"cat1",
'alpha');
288 $bankaccountid = $id;
289 if (
GETPOST(
'add_account',
'int') > 0) $bankaccountid =
GETPOST(
'add_account',
'int');
293 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")), null,
'errors');
297 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), null,
'errors');
301 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")), null,
'errors');
305 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")), null,
'errors');
307 if (!$bankaccountid > 0)
310 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount")), null,
'errors');
318 if (!$error && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT))
321 $objecttmp->fetch($bankaccountid);
322 $insertid = $objecttmp->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user,
'',
'', $search_accountancy_code);
326 header(
"Location: ".
$_SERVER[
'PHP_SELF'].($id ?
"?id=".$id :
''));
336 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->banque->modifier)
339 $result = $accline->fetch(
GETPOST(
"rowid",
"int"));
340 $result = $accline->delete($user);
354 $form =
new Form($db);
358 $companystatic =
new Societe($db);
359 $bankaccountstatic =
new Account($db);
362 $societestatic =
new Societe($db);
363 $userstatic =
new User($db);
365 $loanstatic =
new Loan($db);
367 $donstatic =
new Don($db);
371 $paymentvatstatic =
new TVA($db);
376 $bankstatic =
new Account($db);
384 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
385 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
386 if ($id > 0) $param .=
'&id='.urlencode($id);
387 if (!empty($ref)) $param .=
'&ref='.urlencode($ref);
388 if (!empty($search_ref)) $param .=
'&search_ref='.urlencode($search_ref);
389 if (!empty($search_description)) $param .=
'&search_description='.urlencode($search_description);
390 if (!empty($search_type)) $param .=
'&type='.urlencode($search_type);
391 if (!empty($search_thirdparty)) $param .=
'&search_thirdparty='.urlencode($search_thirdparty);
392 if (!empty($search_debit)) $param .=
'&search_debit='.urlencode($search_debit);
393 if (!empty($search_credit)) $param .=
'&search_credit='.urlencode($search_credit);
394 if (!empty($search_account)) $param .=
'&search_account='.urlencode($search_account);
395 if (!empty($search_num_releve)) $param .=
'&search_num_releve='.urlencode($search_num_releve);
396 if ($search_conciliated !=
'' && $search_conciliated !=
'-1') $param .=
'&search_conciliated='.urlencode($search_conciliated);
397 if ($search_bid > 0) $param .=
'&search_bid='.urlencode($search_bid);
398 if (
dol_strlen($search_dt_start) > 0) $param .=
'&search_start_dtmonth='.GETPOST(
'search_start_dtmonth',
'int').
'&search_start_dtday='.
GETPOST(
'search_start_dtday',
'int').
'&search_start_dtyear='.
GETPOST(
'search_start_dtyear',
'int');
399 if (
dol_strlen($search_dt_end) > 0) $param .=
'&search_end_dtmonth='.GETPOST(
'search_end_dtmonth',
'int').
'&search_end_dtday='.
GETPOST(
'search_end_dtday',
'int').
'&search_end_dtyear='.
GETPOST(
'search_end_dtyear',
'int');
400 if (
dol_strlen($search_dv_start) > 0) $param .=
'&search_start_dvmonth='.GETPOST(
'search_start_dvmonth',
'int').
'&search_start_dvday='.
GETPOST(
'search_start_dvday',
'int').
'&search_start_dvyear='.
GETPOST(
'search_start_dvyear',
'int');
401 if (
dol_strlen($search_dv_end) > 0) $param .=
'&search_end_dvmonth='.GETPOST(
'search_end_dvmonth',
'int').
'&search_end_dvday='.
GETPOST(
'search_end_dvday',
'int').
'&search_end_dvyear='.
GETPOST(
'search_end_dvyear',
'int');
402 if ($search_req_nb) $param .=
'&req_nb='.urlencode($search_req_nb);
403 if (
GETPOST(
"search_thirdparty",
'int')) $param .=
'&thirdparty='.urlencode(
GETPOST(
"search_thirdparty",
'int'));
404 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
405 if ($action ==
'reconcile') $param .=
'&action=reconcile';
407 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
411 $buttonreconcile =
'';
414 if ($id > 0 || !empty($ref))
416 $title = $langs->trans(
"FinancialAccount").
' - '.$langs->trans(
"Transactions");
421 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/bankcateg.class.php';
424 foreach ($bankcateg->fetchAll() as $bankcategory) {
425 $options[$bankcategory->id] = $bankcategory->label;
432 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
434 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'', 1);
443 if ($action !=
'reconcile')
445 if ($object->canBeConciliated() > 0)
448 if ($user->rights->banque->consolidate) {
450 $newparam = preg_replace(
'/search_conciliated=\d+/i',
'', $newparam);
451 $buttonreconcile =
'<a class="butAction" style="margin-bottom: 5px !important; margin-top: 5px !important" href="'.DOL_URL_ROOT.
'/compta/bank/bankentries_list.php?action=reconcile&sortfield=b.datev,b.dateo,b.rowid&sortorder=asc,asc,asc&search_conciliated=0'.$newparam.
'">'.$langs->trans(
"Conciliate").
'</a>';
453 $buttonreconcile =
'<a class="butActionRefused" style="margin-bottom: 5px !important; margin-top: 5px !important" title="'.$langs->trans(
"NotEnoughPermissions").
'" href="#">'.$langs->trans(
"Conciliate").
'</a>';
458 llxHeader(
'', $langs->trans(
"BankTransactions"),
'',
'', 0, 0, array(), array(), $param);
461 $sql =
"SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,";
462 $sql .=
" b.fk_account, b.fk_type,";
463 $sql .=
" ba.rowid as bankid, ba.ref as bankref,";
464 $sql .=
" bu.url_id,";
465 $sql .=
" s.nom, s.name_alias, s.client, s.fournisseur, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
467 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
468 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
' as options_'.$key :
'');
471 $parameters = array();
472 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
473 $sql .= $hookmanager->resPrint;
475 if ($search_bid > 0) $sql .= MAIN_DB_PREFIX.
"bank_class as l,";
476 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba,";
477 $sql .=
" ".MAIN_DB_PREFIX.
"bank as b";
478 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (b.rowid = ef.fk_object)";
479 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'";
480 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON bu.url_id = s.rowid";
481 $sql .=
" WHERE b.fk_account = ba.rowid";
482 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
483 if ($search_account > 0) $sql .=
" AND b.fk_account = ".$search_account;
485 if (
dol_strlen($search_dt_start) > 0) $sql .=
" AND b.dateo >= '".$db->idate($search_dt_start).
"'";
486 if (
dol_strlen($search_dt_end) > 0) $sql .=
" AND b.dateo <= '".$db->idate($search_dt_end).
"'";
488 if (
dol_strlen($search_dv_start) > 0) $sql .=
" AND b.datev >= '".$db->idate($search_dv_start).
"'";
489 if (
dol_strlen($search_dv_end) > 0) $sql .=
" AND b.datev <= '".$db->idate($search_dv_end).
"'";
490 if ($search_ref) $sql .=
natural_search(
"b.rowid", $search_ref, 1);
491 if ($search_req_nb) $sql .=
natural_search(
"b.num_chq", $search_req_nb);
492 if ($search_num_releve) $sql .=
natural_search(
"b.num_releve", $search_num_releve);
493 if ($search_conciliated !=
'' && $search_conciliated !=
'-1') $sql .=
" AND b.rappro = ".urlencode($search_conciliated);
494 if ($search_thirdparty) $sql .=
natural_search(
"s.nom", $search_thirdparty);
495 if ($search_description)
497 $search_description_to_use = $search_description;
498 $arrayoffixedlabels = array(
500 'CustomerInvoicePayment',
'CustomerInvoicePaymentBack',
501 'SupplierInvoicePayment',
'SupplierInvoicePaymentBack',
503 'ExpenseReportPayment',
504 'SocialContributionPayment',
505 'SubscriptionPayment',
508 foreach ($arrayoffixedlabels as $keyforlabel)
510 $translatedlabel = $langs->transnoentitiesnoconv($keyforlabel);
511 if (preg_match(
'/'.$search_description.
'/i', $translatedlabel))
513 $search_description_to_use .=
"|".$keyforlabel;
518 if ($search_bid > 0) $sql .=
" AND b.rowid=l.lineid AND l.fk_categ=".$search_bid;
519 if (!empty($search_type)) $sql .=
" AND b.fk_type = '".$db->escape($search_type).
"' ";
521 $search_debit =
price2num(str_replace(
'-',
'', $search_debit));
522 $search_credit =
price2num(str_replace(
'-',
'', $search_credit));
523 if ($search_debit) $sql .=
natural_search(
'- b.amount', $search_debit, 1);
524 if ($search_credit) $sql .=
natural_search(
'b.amount', $search_credit, 1);
526 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
529 $parameters = array();
530 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
531 $sql .= $hookmanager->resPrint;
533 $sql .= $db->order($sortfield, $sortorder);
535 $nbtotalofrecords =
'';
537 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
539 $result = $db->query($sql);
540 $nbtotalofrecords = $db->num_rows($result);
541 $nbtotalofpages = ceil($nbtotalofrecords / $limit);
544 if (($id > 0 || !empty($ref)) && ((
string) $page ==
''))
548 $page = ($nbtotalofpages - 1);
549 $offset = $limit * $page;
550 if ($page < 0) $page = 0;
552 if ($page >= $nbtotalofpages)
555 $page = ($nbtotalofpages - 1);
556 $offset = $limit * $page;
557 if ($page < 0) $page = 0;
562 if (empty($search_account)) $mode_balance_ok =
false;
564 if (!empty($search_ref)) $mode_balance_ok =
false;
565 if (!empty($search_description)) $mode_balance_ok =
false;
566 if (!empty($search_type)) $mode_balance_ok =
false;
567 if (!empty($search_debit)) $mode_balance_ok =
false;
568 if (!empty($search_credit)) $mode_balance_ok =
false;
569 if (!empty($search_thirdparty)) $mode_balance_ok =
false;
570 if ($search_conciliated !=
'' && $search_conciliated !=
'-1') $mode_balance_ok =
false;
571 if (!empty($search_num_releve)) $mode_balance_ok =
false;
573 $sql .= $db->plimit($limit + 1, $offset);
575 dol_syslog(
'compta/bank/bankentries_list.php', LOG_DEBUG);
576 $resql = $db->query($sql);
579 $num = $db->num_rows(
$resql);
581 $arrayofselected = is_array($toselect) ? $toselect : array();
584 $arrayofmassactions = array(
589 if (in_array($massaction, array(
'presend',
'predelete'))) $arrayofmassactions = array();
590 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
593 if ($action ==
'delete')
595 $text = $langs->trans(
'ConfirmDeleteTransaction');
596 print $form->formconfirm(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&rowid='.
GETPOST(
"rowid"), $langs->trans(
'DeleteTransaction'), $text,
'confirm_delete', null,
'', 1);
600 print '<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="search_form">'.
"\n";
601 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
602 print '<input type="hidden" name="token" value="'.newToken().
'">';
603 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
604 print '<input type="hidden" name="action" value="'.($action ? $action :
'search').
'">';
605 print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).
'">';
606 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
607 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
608 print '<input type="hidden" name="page" value="'.$page.
'">';
609 print '<input type="hidden" name="id" value="'.$id.
'">';
610 print '<input type="hidden" name="ref" value="'.$ref.
'">';
611 if (
GETPOST(
'bid'))
print '<input type="hidden" name="bid" value="'.GETPOST(
"bid").
'">';
614 if ($user->rights->banque->consolidate && $action ==
'reconcile')
616 print '<div class="valignmiddle inline-block" style="padding-right: 20px;">';
617 print '<strong>'.$langs->trans(
"InputReceiptNumber").
'</strong>: ';
618 print '<input class="flat" id="num_releve" name="num_releve" type="text" value="'.(GETPOST(
'num_releve') ?
GETPOST(
'num_releve') :
'').
'" size="10">';
620 if (is_array($options) && count($options))
622 print $langs->trans(
"EventualyAddCategory").
': ';
625 print '<br><div style="margin-top: 5px;"><span class="opacitymedium">'.$langs->trans(
"ThenCheckLinesAndConciliate").
'</span> ';
626 print '<input class="button" name="confirm_savestatement" type="submit" value="'.$langs->trans(
"SaveStatementOnly").
'">';
627 print ' '.$langs->trans(
"or").
' ';
628 print '<input class="button" name="confirm_reconcile" type="submit" value="'.$langs->trans(
"Conciliate").
'">';
629 print ' '.$langs->trans(
"or").
' ';
630 print '<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
636 $sql =
"SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX.
"bank";
637 $sql .=
" WHERE fk_account=".$object->id.
" AND num_releve IS NOT NULL";
638 $sql .= $db->order(
"num_releve",
"DESC");
639 $sql .= $db->plimit($nbmax + 1);
641 print $langs->trans(
"LastAccountStatements").
' : ';
642 $resqlr = $db->query($sql);
645 $numr = $db->num_rows($resqlr);
648 while (($i < $numr) && ($i < $nbmax))
650 $objr = $db->fetch_object($resqlr);
652 $last_releve = $objr->num_releve;
656 $liste =
'<a href="'.DOL_URL_ROOT.
'/compta/bank/releve.php?account='.$id.
'&num='.$objr->num_releve.
'">'.$objr->num_releve.
'</a> '.$liste;
658 if ($numr >= $nbmax) $liste =
"... ".$liste;
660 if ($numr <= 0)
print '<b>'.$langs->trans(
"None").
'</b>';
666 if (!empty($conf->global->BANK_REPORT_LAST_NUM_RELEVE))
669 <script type="text/javascript">
670 $("#num_releve").val("' . $last_releve.
'");
678 if ($user->rights->banque->modifier && $action ==
'addline' && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT))
682 print '<table class="noborder centpercent">';
684 print
'<tr class="liste_titre">';
685 print
'<td>'.$langs->trans(
"Description").
'</td>';
686 print
'<td>'.$langs->trans(
"Date").
'</td>';
687 print
'<td> </td>';
688 print
'<td>'.$langs->trans(
"Type").
'</td>';
689 print
'<td>'.$langs->trans(
"Numero").
'</td>';
690 print
'<td class=right>'.$langs->trans(
"BankAccount").
'</td>';
691 print
'<td class=right>'.$langs->trans(
"Debit").
'</td>';
692 print
'<td class=right>'.$langs->trans(
"Credit").
'</td>';
699 print
'<td align="center"> </td>';
704 print
'<input name="label" class="flat minwidth200" type="text" value="'.GETPOST(
"label",
"alpha").
'">';
705 if (is_array($options) && count($options))
707 print
'<br>'.$langs->trans(
"Rubrique").
': ';
711 print
'<td class="nowrap">';
712 print $form->selectDate(empty($dateop) ?-1 : $dateop,
'op', 0, 0, 0,
'transaction');
714 print
'<td> </td>';
715 print
'<td class="nowrap">';
716 $form->select_types_paiements((
GETPOST(
'operation') ?
GETPOST(
'operation') : ($object->courant ==
Account::TYPE_CASH ?
'LIQ' :
'')),
'operation',
'1,2', 2, 1);
719 print
'<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST(
"num_chq",
"alpha").
'">';
723 print
'<td class=right>';
724 $form->select_comptes(
GETPOST(
'add_account',
'int') ?
GETPOST(
'add_account',
'int') : $search_account,
'add_account', 0,
'', 1, ($id > 0 || !empty($ref) ?
' disabled="disabled"' :
''));
727 print
'<td class="right"><input name="adddebit" class="flat" type="text" size="4" value="'.GETPOST(
"adddebit",
"alpha").
'"></td>';
728 print
'<td class="right"><input name="addcredit" class="flat" type="text" size="4" value="'.GETPOST(
"addcredit",
"alpha").
'"></td>';
735 print
'<td class="center">';
736 print
'<input type="submit" name="save" class="button buttongen marginbottomonly" value="'.$langs->trans(
"Add").
'"><br>';
737 print
'<input type="submit" name="cancel" class="button buttongen marginbottomonly button-cancel" value="'.$langs->trans(
"Cancel").
'">';
746 <script type="text/javascript">
748 $("a.ajax").each(function(){
749 var current = $(this);
750 current.click(function()
752 $.get("'.DOL_URL_ROOT.
'/core/ajax/bankconciliate.php?"+current.attr("href").split("?")[1], function(data)
755 current.parent().prev().replaceWith(data);
770 if ($action !=
'addline' && $action !=
'reconcile')
772 if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT))
774 if (empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT))
776 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddBankRecord'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?action=create&accountid='.$search_account.
'&backtopage='.urlencode(
$_SERVER[
'PHP_SELF'].
'?id='.urlencode($search_account)),
'', $user->rights->banque->modifier);
779 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddBankRecord'),
'',
'fa fa-plus-circle',
$_SERVER[
"PHP_SELF"].
'?action=addline&page='.$page.$param,
'', $user->rights->banque->modifier);
782 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddBankRecord'),
'',
'fa fa-plus-circle',
$_SERVER[
"PHP_SELF"].
'?action=addline&page='.$page.$param,
'', -1);
793 if ($action !=
'addline' && $action !=
'reconcile')
795 $morehtml .= $buttonreconcile;
798 $morehtml .=
'<!-- Add New button -->'.$newcardbutton;
800 $picto =
'bank_account';
801 if ($id > 0 || !empty($ref)) $picto =
'';
803 print_barre_liste($langs->trans(
"BankTransactions"), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml,
'', $limit, 0, 0, 1);
806 if ($page !=
'') $param .=
'&page='.urlencode($page);
810 $moreforfilter .=
'<div class="divsearchfield">';
811 $moreforfilter .= $langs->trans(
'DateOperationShort').
' :';
812 $moreforfilter .= ($conf->browser->layout ==
'phone' ?
'<br>' :
' ');
813 $moreforfilter .=
'<div class="nowrap inline-block">';
814 $moreforfilter .= $form->selectDate($search_dt_start,
'search_start_dt', 0, 0, 1,
"search_form", 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From')).
'</div>';
816 $moreforfilter .=
'<div class="nowrap inline-block">'.$form->selectDate($search_dt_end,
'search_end_dt', 0, 0, 1,
"search_form", 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to')).
'</div>';
817 $moreforfilter .=
'</div>';
819 $moreforfilter .=
'<div class="divsearchfield">';
820 $moreforfilter .= $langs->trans(
'DateValueShort').
' : ';
821 $moreforfilter .= ($conf->browser->layout ==
'phone' ?
'<br>' :
' ');
822 $moreforfilter .=
'<div class="nowrap inline-block">';
823 $moreforfilter .= $form->selectDate($search_dv_start,
'search_start_dv', 0, 0, 1,
"search_form", 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From')).
'</div>';
825 $moreforfilter .=
'<div class="nowrap inline-block">'.$form->selectDate($search_dv_end,
'search_end_dv', 0, 0, 1,
"search_form", 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to')).
'</div>';
826 $moreforfilter .=
'</div>';
828 if (!empty($conf->categorie->enabled))
831 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
833 $langs->load(
'categories');
836 $moreforfilter .=
'<div class="divsearchfield">';
837 $moreforfilter .= $langs->trans(
'RubriquesTransactions').
' : ';
838 $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid,
'parent', null, null, 1);
839 $moreforfilter .= $form->selectarray(
'search_bid', $cate_arbo, $search_bid, 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
840 $moreforfilter .=
'</div>';
844 $parameters = array();
845 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
846 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
847 else $moreforfilter = $hookmanager->resPrint;
851 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
852 print $moreforfilter;
856 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
857 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
859 if ($action ==
'reconcile') {
860 $arrayfields[
'b.num_releve'][
'checked'] = 1;
863 print
'<div class="div-table-responsive">';
864 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
867 print
'<tr class="liste_titre_filter">';
868 if (!empty($arrayfields[
'b.rowid'][
'checked']))
870 print
'<td class="liste_titre">';
871 print
'<input type="text" class="flat" name="search_ref" size="2" value="'.dol_escape_htmltag($search_ref).
'">';
874 if (!empty($arrayfields[
'b.label'][
'checked']))
876 print
'<td class="liste_titre">';
877 print
'<input type="text" class="flat maxwidth100" name="search_description" value="'.dol_escape_htmltag($search_description).
'">';
880 if (!empty($arrayfields[
'b.dateo'][
'checked']))
882 print
'<td class="liste_titre"> </td>';
884 if (!empty($arrayfields[
'b.datev'][
'checked']))
886 print
'<td class="liste_titre"> </td>';
888 if (!empty($arrayfields[
'type'][
'checked']))
890 print
'<td class="liste_titre" align="center">';
891 $form->select_types_paiements(empty($search_type) ?
'' : $search_type,
'search_type',
'', 2, 1, 1, 0, 1,
'maxwidth100');
894 if (!empty($arrayfields[
'b.num_chq'][
'checked']))
897 print
'<td class="liste_titre" align="center"><input type="text" class="flat" name="req_nb" value="'.dol_escape_htmltag($search_req_nb).
'" size="2"></td>';
899 if (!empty($arrayfields[
'bu.label'][
'checked']))
901 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).
'"></td>';
903 if (!empty($arrayfields[
'ba.ref'][
'checked']))
905 print
'<td class="liste_titre">';
906 $form->select_comptes($search_account,
'search_account', 0,
'', 1, ($id > 0 || !empty($ref) ?
' disabled="disabled"' :
''), 0,
'maxwidth100');
909 if (!empty($arrayfields[
'b.debit'][
'checked']))
911 print
'<td class="liste_titre right">';
912 print
'<input type="text" class="flat width50" name="search_debit" value="'.dol_escape_htmltag($search_debit).
'">';
915 if (!empty($arrayfields[
'b.credit'][
'checked']))
917 print
'<td class="liste_titre right">';
918 print
'<input type="text" class="flat width50" name="search_credit" value="'.dol_escape_htmltag($search_credit).
'">';
921 if (!empty($arrayfields[
'balancebefore'][
'checked']))
923 print
'<td class="liste_titre right">';
924 $htmltext = $langs->trans(
"BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv(
"DateValue"));
925 print $form->textwithpicto(
'', $htmltext, 1);
928 if (!empty($arrayfields[
'balance'][
'checked']))
930 print
'<td class="liste_titre right">';
931 $htmltext = $langs->trans(
"BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv(
"DateValue"));
932 print $form->textwithpicto(
'', $htmltext, 1);
936 if (!empty($arrayfields[
'b.num_releve'][
'checked']))
938 print
'<td class="liste_titre" align="center"><input type="text" class="flat" name="search_num_releve" value="'.dol_escape_htmltag($search_num_releve).
'" size="3"></td>';
941 if (!empty($arrayfields[
'b.conciliated'][
'checked']))
943 print
'<td class="liste_titre" align="center">';
944 print $form->selectyesno(
'search_conciliated', $search_conciliated, 1,
false, 1, 1);
947 print
'<td class="liste_titre" align="middle">';
949 print
'<td class="liste_titre" align="middle">';
950 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
956 print
'<tr class="liste_titre">';
957 if (!empty($arrayfields[
'b.rowid'][
'checked']))
print_liste_field_titre($arrayfields[
'b.rowid'][
'label'], $_SERVER[
'PHP_SELF'],
'b.rowid',
'', $param,
'', $sortfield, $sortorder);
958 if (!empty($arrayfields[
'b.label'][
'checked']))
print_liste_field_titre($arrayfields[
'b.label'][
'label'], $_SERVER[
'PHP_SELF'],
'b.label',
'', $param,
'', $sortfield, $sortorder);
959 if (!empty($arrayfields[
'b.dateo'][
'checked']))
print_liste_field_titre($arrayfields[
'b.dateo'][
'label'], $_SERVER[
'PHP_SELF'],
'b.dateo',
'', $param,
'', $sortfield, $sortorder,
"center ");
960 if (!empty($arrayfields[
'b.datev'][
'checked']))
print_liste_field_titre($arrayfields[
'b.datev'][
'label'], $_SERVER[
'PHP_SELF'],
'b.datev,b.dateo,b.rowid',
'', $param,
'align="center"', $sortfield, $sortorder);
961 if (!empty($arrayfields[
'type'][
'checked']))
print_liste_field_titre($arrayfields[
'type'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'align="center"', $sortfield, $sortorder);
962 if (!empty($arrayfields[
'b.num_chq'][
'checked']))
print_liste_field_titre($arrayfields[
'b.num_chq'][
'label'], $_SERVER[
'PHP_SELF'],
'b.num_chq',
'', $param,
'', $sortfield, $sortorder,
"center ");
963 if (!empty($arrayfields[
'bu.label'][
'checked']))
print_liste_field_titre($arrayfields[
'bu.label'][
'label'], $_SERVER[
'PHP_SELF'],
'bu.label',
'', $param,
'', $sortfield, $sortorder);
964 if (!empty($arrayfields[
'ba.ref'][
'checked']))
print_liste_field_titre($arrayfields[
'ba.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'ba.ref',
'', $param,
'', $sortfield, $sortorder);
965 if (!empty($arrayfields[
'b.debit'][
'checked']))
print_liste_field_titre($arrayfields[
'b.debit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
"right ");
966 if (!empty($arrayfields[
'b.credit'][
'checked']))
print_liste_field_titre($arrayfields[
'b.credit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
"right ");
967 if (!empty($arrayfields[
'balancebefore'][
'checked']))
print_liste_field_titre($arrayfields[
'balancebefore'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
"right ");
968 if (!empty($arrayfields[
'balance'][
'checked']))
print_liste_field_titre($arrayfields[
'balance'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
"right ");
969 if (!empty($arrayfields[
'b.num_releve'][
'checked']))
print_liste_field_titre($arrayfields[
'b.num_releve'][
'label'], $_SERVER[
'PHP_SELF'],
'b.num_releve',
'', $param,
'', $sortfield, $sortorder,
"center ");
970 if (!empty($arrayfields[
'b.conciliated'][
'checked']))
print_liste_field_titre($arrayfields[
'b.conciliated'][
'label'], $_SERVER[
'PHP_SELF'],
'b.rappro',
'', $param,
'', $sortfield, $sortorder,
"center ");
972 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
974 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
975 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
976 print $hookmanager->resPrint;
977 print_liste_field_titre(
'', $_SERVER[
"PHP_SELF"],
"",
'',
'',
'class="right"', $sortfield, $sortorder,
'maxwidthsearch ');
978 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
983 $balancecalculated =
false;
984 $posconciliatecol = 0;
985 $cachebankaccount = array();
990 $totalarray = array();
991 while ($i < min($num, $limit))
993 $objp = $db->fetch_object(
$resql);
995 if (!$balancecalculated && (!empty($arrayfields[
'balancebefore'][
'checked']) || !empty($arrayfields[
'balance'][
'checked'])) && ($mode_balance_ok || $search_conciliated ===
'0'))
997 if (!$search_account)
999 dol_print_error(
'',
'account is not defined but $mode_balance_ok is true');
1006 $sqlforbalance =
'SELECT SUM(b.amount) as previoustotal';
1007 $sqlforbalance .=
" FROM ";
1008 $sqlforbalance .=
" ".MAIN_DB_PREFIX.
"bank_account as ba,";
1009 $sqlforbalance .=
" ".MAIN_DB_PREFIX.
"bank as b";
1010 $sqlforbalance .=
" WHERE b.fk_account = ba.rowid";
1011 $sqlforbalance .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1012 $sqlforbalance .=
" AND b.fk_account = ".$search_account;
1013 $sqlforbalance .=
" AND (b.datev < '".$db->idate($db->jdate($objp->dv)).
"' OR (b.datev = '".$db->idate($db->jdate($objp->dv)).
"' AND (b.dateo < '".$db->idate($db->jdate($objp->do)).
"' OR (b.dateo = '".$db->idate($db->jdate($objp->do)).
"' AND b.rowid < ".$objp->rowid.
"))))";
1014 $resqlforbalance = $db->query($sqlforbalance);
1016 if ($resqlforbalance) {
1017 $objforbalance = $db->fetch_object($resqlforbalance);
1018 if ($objforbalance) {
1020 if ($sortfield ==
'b.datev,b.dateo,b.rowid' && $sortorder ==
'desc,desc,desc')
1022 $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount);
1025 $balance = $objforbalance->previoustotal;
1030 $balancecalculated =
true;
1033 if ($user->rights->banque->consolidate && $action ==
'reconcile')
1035 $tmpnbfieldbeforebalance = 0;
1036 $tmpnbfieldafterbalance = 0;
1037 $balancefieldfound = 0;
1038 foreach ($arrayfields as $key => $val)
1040 if ($key ==
'balancebefore' || $key ==
'balance')
1042 $balancefieldfound++;
1045 if (!empty($arrayfields[$key][
'checked']))
1047 if (!$balancefieldfound) $tmpnbfieldbeforebalance++;
1048 else $tmpnbfieldafterbalance++;
1052 $element =
'banktransaction';
1053 if (is_array($extrafields->attributes[$element][
'label']) && count($extrafields->attributes[$element][
'label']))
1055 foreach ($extrafields->attributes[$element][
'label'] as $key => $val)
1057 if (!empty($arrayfields[
"ef.".$key][
'checked']))
1059 if (!empty($arrayfields[$key][
'checked']))
1061 if (!$balancefieldfound) $tmpnbfieldbeforebalance++;
1062 else $tmpnbfieldafterbalance++;
1068 print
'<tr class="oddeven trforbreak">';
1069 if ($tmpnbfieldbeforebalance)
1071 print
'<td colspan="'.$tmpnbfieldbeforebalance.
'">';
1076 if (!empty($arrayfields[
'balancebefore'][
'checked']))
1078 print
'<td class="right">';
1079 if ($search_conciliated !==
'0') {
1084 if (!empty($arrayfields[
'balance'][
'checked']))
1086 print
'<td class="right">';
1087 if ($search_conciliated !==
'0') {
1092 if (!empty($arrayfields[
'b.num_releve'][
'checked']))
1094 print
'<td class="center">';
1095 print
'<input type="checkbox" id="selectAll" title="'.dol_escape_htmltag($langs->trans(
"SelectAll")).
'" />';
1096 print
' <script type="text/javascript">
1097 $("input#selectAll").change(function() {
1098 $("input[type=checkbox][name^=rowid]").prop("checked", $(this).is(":checked"));
1103 print
'<td colspan="'.($tmpnbfieldafterbalance + 2).
'">';
1111 if ($sortfield ==
'b.datev,b.dateo,b.rowid' && $sortorder ==
'desc,desc,desc')
1113 $balance =
price2num($balancebefore,
'MT');
1114 $balancebefore =
price2num($balancebefore - ($sign * $objp->amount),
'MT');
1116 $balancebefore =
price2num($balance,
'MT');
1117 $balance =
price2num($balance + ($sign * $objp->amount),
'MT');
1120 if (empty($cachebankaccount[$objp->bankid]))
1122 $bankaccounttmp =
new Account($db);
1123 $bankaccounttmp->fetch($objp->bankid);
1124 $cachebankaccount[$objp->bankid] = $bankaccounttmp;
1125 $bankaccount = $bankaccounttmp;
1127 $bankaccount = $cachebankaccount[$objp->bankid];
1130 if (empty($conf->global->BANK_COLORIZE_MOVEMENT)) {
1131 $backgroundcolor =
"class='oddeven'";
1133 if ($objp->amount < 0)
1135 if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR1)) {
1138 $color =
'#'.$conf->global->BANK_COLORIZE_MOVEMENT_COLOR1;
1140 $backgroundcolor =
'style="background: '.$color.
';"';
1142 if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR2)) {
1145 $color =
'#'.$conf->global->BANK_COLORIZE_MOVEMENT_COLOR2;
1147 $backgroundcolor =
'style="background: '.$color.
';"';
1151 $banklinestatic->id = $objp->rowid;
1152 $banklinestatic->ref = $objp->rowid;
1154 print
'<tr class="oddeven" '.$backgroundcolor.
'>';
1157 if (!empty($arrayfields[
'b.rowid'][
'checked']))
1159 print
'<td class="nowrap left">';
1160 print $banklinestatic->getNomUrl(1);
1162 if (!$i) $totalarray[
'nbfield']++;
1166 if (!empty($arrayfields[
'b.label'][
'checked']))
1172 preg_match(
'/\((.+)\)/i', $objp->label, $reg);
1173 if ($reg[1] && $langs->trans($reg[1]) != $reg[1]) print $langs->trans($reg[1]);
1175 if ($objp->label ==
'(payment_salary)') {
1176 print
dol_trunc($langs->trans(
"SalaryPayment", 40));
1184 $links = $bankaccountstatic->get_url($objp->rowid);
1185 $cachebankaccount = array();
1186 foreach ($links as $key=>$val)
1188 print
'<!-- '.$links[$key][
'type'].
' -->';
1189 if ($links[$key][
'type'] ==
'withdraw')
1191 $banktransferstatic->id = $links[$key][
'url_id'];
1192 $banktransferstatic->ref = $links[$key][
'label'];
1193 print
' '.$banktransferstatic->getNomUrl(0);
1194 } elseif ($links[$key][
'type'] ==
'payment')
1196 $paymentstatic->id = $links[$key][
'url_id'];
1197 $paymentstatic->ref = $links[$key][
'url_id'];
1198 print
' '.$paymentstatic->getNomUrl(2);
1199 } elseif ($links[$key][
'type'] ==
'payment_supplier')
1201 $paymentsupplierstatic->id = $links[$key][
'url_id'];
1202 $paymentsupplierstatic->ref = $links[$key][
'url_id'];
1203 print
' '.$paymentsupplierstatic->getNomUrl(2);
1204 } elseif ($links[$key][
'type'] ==
'payment_sc')
1206 $paymentscstatic->id = $links[$key][
'url_id'];
1207 $paymentscstatic->ref = $links[$key][
'url_id'];
1208 $paymentscstatic->label = $links[$key][
'label'];
1209 print
' '.$paymentscstatic->getNomUrl(2);
1210 } elseif ($links[$key][
'type'] ==
'payment_vat')
1212 $paymentvatstatic->id = $links[$key][
'url_id'];
1213 $paymentvatstatic->ref = $links[$key][
'url_id'];
1214 print
' '.$paymentvatstatic->getNomUrl(2);
1215 } elseif ($links[$key][
'type'] ==
'payment_salary')
1217 $paymentsalstatic->id = $links[$key][
'url_id'];
1218 $paymentsalstatic->ref = $links[$key][
'url_id'];
1219 $paymentsalstatic->label = $links[$key][
'label'];
1220 print
' '.$paymentsalstatic->getNomUrl(2);
1221 } elseif ($links[$key][
'type'] ==
'payment_loan')
1223 print
'<a href="'.DOL_URL_ROOT.
'/loan/payment/card.php?id='.$links[$key][
'url_id'].
'">';
1224 print
' '.img_object($langs->trans(
'ShowPayment'),
'payment').
' ';
1226 } elseif ($links[$key][
'type'] ==
'payment_donation')
1228 $paymentdonationstatic->id = $links[$key][
'url_id'];
1229 $paymentdonationstatic->ref = $links[$key][
'url_id'];
1230 print
' '.$paymentdonationstatic->getNomUrl(2);
1231 } elseif ($links[$key][
'type'] ==
'payment_expensereport')
1233 $paymentexpensereportstatic->id = $links[$key][
'url_id'];
1234 $paymentexpensereportstatic->ref = $links[$key][
'url_id'];
1235 print
' '.$paymentexpensereportstatic->getNomUrl(2);
1236 } elseif ($links[$key][
'type'] ==
'payment_various')
1238 $paymentvariousstatic->id = $links[$key][
'url_id'];
1239 $paymentvariousstatic->ref = $links[$key][
'url_id'];
1240 print
' '.$paymentvariousstatic->getNomUrl(2);
1241 } elseif ($links[$key][
'type'] ==
'banktransfert')
1244 if ($objp->amount > 0)
1246 $banklinestatic->fetch($links[$key][
'url_id']);
1247 $bankstatic->id = $banklinestatic->fk_account;
1248 $bankstatic->label = $banklinestatic->bank_account_ref;
1249 print
' ('.$langs->trans(
"TransferFrom").
' ';
1250 print $bankstatic->getNomUrl(1,
'transactions');
1251 print
' '.$langs->trans(
"toward").
' ';
1252 $bankstatic->id = $objp->bankid;
1253 $bankstatic->label = $objp->bankref;
1254 print $bankstatic->getNomUrl(1,
'');
1257 $bankstatic->id = $objp->bankid;
1258 $bankstatic->label = $objp->bankref;
1259 print
' ('.$langs->trans(
"TransferFrom").
' ';
1260 print $bankstatic->getNomUrl(1,
'');
1261 print
' '.$langs->trans(
"toward").
' ';
1262 $banklinestatic->fetch($links[$key][
'url_id']);
1263 $bankstatic->id = $banklinestatic->fk_account;
1264 $bankstatic->label = $banklinestatic->bank_account_ref;
1265 print $bankstatic->getNomUrl(1,
'transactions');
1269 } elseif ($links[$key][
'type'] ==
'company')
1271 } elseif ($links[$key][
'type'] ==
'user')
1273 } elseif ($links[$key][
'type'] ==
'member')
1275 } elseif ($links[$key][
'type'] ==
'sc')
1279 if (!empty($objp->label) && !empty($links[$key][
'label'])) print
' - ';
1280 print
'<a href="'.$links[$key][
'url'].$links[$key][
'url_id'].
'">';
1281 if (preg_match(
'/^\((.*)\)$/i', $links[$key][
'label'], $reg))
1284 if ($reg[1] ==
'paiement') $reg[1] =
'Payment';
1285 print
' '.$langs->trans($reg[1]);
1287 print
' '.$links[$key][
'label'];
1293 if (!$i) $totalarray[
'nbfield']++;
1297 if (!empty($arrayfields[
'b.dateo'][
'checked']))
1299 print
'<td align="center" class="nowrap">';
1300 print
'<span id="dateoperation_'.$objp->rowid.
'">'.
dol_print_date($db->jdate($objp->do),
"day").
"</span>";
1302 print
'<span class="inline-block">';
1303 print
'<a class="ajax" href="'.$_SERVER[
'PHP_SELF'].
'?action=doprev&account='.$objp->bankid.
'&rowid='.$objp->rowid.
'">';
1305 print
'<a class="ajax" href="'.$_SERVER[
'PHP_SELF'].
'?action=donext&account='.$objp->bankid.
'&rowid='.$objp->rowid.
'">';
1309 if (!$i) $totalarray[
'nbfield']++;
1313 if (!empty($arrayfields[
'b.datev'][
'checked']))
1315 print
'<td align="center" class="nowrap">';
1316 print
'<span id="datevalue_'.$objp->rowid.
'">'.
dol_print_date($db->jdate($objp->dv),
"day").
"</span>";
1318 print
'<span class="inline-block">';
1319 print
'<a class="ajax" href="'.$_SERVER[
'PHP_SELF'].
'?action=dvprev&account='.$objp->bankid.
'&rowid='.$objp->rowid.
'">';
1321 print
'<a class="ajax" href="'.$_SERVER[
'PHP_SELF'].
'?action=dvnext&account='.$objp->bankid.
'&rowid='.$objp->rowid.
'">';
1325 if (!$i) $totalarray[
'nbfield']++;
1329 if (!empty($arrayfields[
'type'][
'checked']))
1331 print
'<td align="center" class="nowrap">';
1332 $labeltype = ($langs->trans(
"PaymentTypeShort".$objp->fk_type) !=
"PaymentTypeShort".$objp->fk_type) ? $langs->trans(
"PaymentTypeShort".$objp->fk_type) : $langs->getLabelFromKey($db, $objp->fk_type,
'c_paiement',
'code',
'libelle',
'', 1);
1333 if ($labeltype ==
'SOLD') print
' ';
1334 else print $labeltype;
1336 if (!$i) $totalarray[
'nbfield']++;
1340 if (!empty($arrayfields[
'b.num_chq'][
'checked']))
1342 print
'<td class="nowrap" align="center">'.($objp->num_chq ? $objp->num_chq :
"").
"</td>\n";
1343 if (!$i) $totalarray[
'nbfield']++;
1347 if (!empty($arrayfields[
'bu.label'][
'checked']))
1349 print
'<td class="tdoverflowmax150">';
1352 $companystatic->id = $objp->url_id;
1353 $companystatic->name = $objp->nom;
1354 $companystatic->name_alias = $objp->name_alias;
1355 $companystatic->client = $objp->client;
1356 $companystatic->email = $objp->email;
1357 $companystatic->fournisseur = $objp->fournisseur;
1358 $companystatic->code_client = $objp->code_client;
1359 $companystatic->code_fournisseur = $objp->code_fournisseur;
1360 $companystatic->code_compta = $objp->code_compta;
1361 $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
1362 print $companystatic->getNomUrl(1);
1367 if (!$i) $totalarray[
'nbfield']++;
1371 if (!empty($arrayfields[
'ba.ref'][
'checked']))
1373 print
'<td class="nowrap">';
1374 print $bankaccount->getNomUrl(1);
1376 if (!$i) $totalarray[
'nbfield']++;
1380 if (!empty($arrayfields[
'b.debit'][
'checked']))
1382 print
'<td class="nowrap right">';
1383 if ($objp->amount < 0)
1385 print
price($objp->amount * -1);
1386 $totalarray[
'totaldeb'] += $objp->amount;
1389 if (!$i) $totalarray[
'nbfield']++;
1390 if (!$i) $totalarray[
'totaldebfield'] = $totalarray[
'nbfield'];
1394 if (!empty($arrayfields[
'b.credit'][
'checked']))
1396 print
'<td class="nowrap right">';
1397 if ($objp->amount > 0)
1399 print
price($objp->amount);
1400 $totalarray[
'totalcred'] += $objp->amount;
1403 if (!$i) $totalarray[
'nbfield']++;
1404 if (!$i) $totalarray[
'totalcredfield'] = $totalarray[
'nbfield'];
1408 if (!empty($arrayfields[
'balancebefore'][
'checked']))
1410 if ($mode_balance_ok)
1412 if ($balancebefore >= 0)
1414 print
'<td class="nowrap right"> '.price($balancebefore).
'</td>';
1416 print
'<td class="error nowrap right"> '.price($balancebefore).
'</td>';
1419 print
'<td class="right">-</td>';
1421 if (!$i) $totalarray[
'nbfield']++;
1424 if (!empty($arrayfields[
'balance'][
'checked']))
1426 if ($mode_balance_ok)
1430 print
'<td class="nowrap right"> '.price($balance).
'</td>';
1432 print
'<td class="error nowrap right"> '.price($balance).
'</td>';
1435 print
'<td class="right">-</td>';
1437 if (!$i) $totalarray[
'nbfield']++;
1440 if (!empty($arrayfields[
'b.num_releve'][
'checked']))
1442 print
'<td class="nowraponall" align="center">';
1444 if ($bankaccount->canBeConciliated() > 0)
1446 if ($objp->num_releve)
1448 print
'<a href="releve.php?num='.$objp->num_releve.
'&account='.$objp->bankid.
'&save_lastsearch_values=1">'.$objp->num_releve.
'</a>';
1450 if (!$objp->conciliated && $action ==
'reconcile')
1452 if ($objp->num_releve) print
' ';
1453 print
'<input class="flat" name="rowid['.$objp->rowid.
']" type="checkbox" value="'.$objp->rowid.
'" size="1"'.(!empty($_POST[
'rowid'][$objp->rowid]) ?
' checked' :
'').
'>';
1459 $totalarray[
'nbfield']++;
1460 $posconciliatecol = $totalarray[
'nbfield'];
1464 if (!empty($arrayfields[
'b.conciliated'][
'checked']))
1466 print
'<td class="nowraponall" align="center">';
1467 print $objp->conciliated ? $langs->trans(
"Yes") : $langs->trans(
"No");
1469 if (!$i) $totalarray[
'nbfield']++;
1473 print
'<td class="nowraponall" align="center">';
1475 if ($objp->conciliated && $bankaccount->canBeConciliated() > 0)
1477 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/compta/bank/line.php?save_lastsearch_values=1&rowid='.$objp->rowid.
'&account='.$objp->bankid.
'&page='.$page.
'">';
1481 if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
1483 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/compta/bank/line.php?save_lastsearch_values=1&rowid='.$objp->rowid.
'&account='.$objp->bankid.
'&page='.$page.
'">';
1487 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/compta/bank/line.php?save_lastsearch_values=1&rowid='.$objp->rowid.
'&account='.$objp->bankid.
'&page='.$page.
'">';
1491 if ($bankaccount->canBeConciliated() > 0 && empty($objp->conciliated))
1493 if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay))
1495 print
' '.img_warning($langs->trans(
"ReconciliationLate"));
1498 if ($user->rights->banque->modifier)
1500 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&rowid='.$objp->rowid.
'&id='.$objp->bankid.
'&page='.$page.
'">';
1501 print
img_delete(
'',
'class="marginleftonly"');
1506 if (!$i) $totalarray[
'nbfield']++;
1509 print
'<td class="nowrap" align="center">';
1510 if ($massactionbutton || $massaction)
1513 if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
1514 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1517 if (!$i) $totalarray[
'nbfield']++;
1525 if (isset($totalarray[
'totaldebfield']) || isset($totalarray[
'totalcredfield']))
1527 print
'<tr class="liste_total">';
1529 while ($i < $totalarray[
'nbfield'])
1534 if ($num < $limit && empty($offset)) print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
1535 else print
'<td class="left tdoverflowmax50" title="'.$langs->trans(
"Totalforthispage").
'">'.$langs->trans(
"Totalforthispage").
'</td>';
1536 } elseif ($totalarray[
'totaldebfield'] == $i) print '<td class="right">'.
price(-1 * $totalarray['totaldeb']).'</td>';
1537 elseif ($totalarray['totalcredfield'] == $i) print '<td class="right">'.
price($totalarray['totalcred']).'</td>';
1538 elseif ($i == $posconciliatecol)
1540 print
'<td class="center">';
1541 if ($user->rights->banque->consolidate && $action ==
'reconcile') print
'<input class="button" name="confirm_reconcile" type="submit" value="'.$langs->trans(
"Conciliate").
'">';
1543 }
else print
'<td></td>';
1552 foreach ($arrayfields as $key => $val) {
if (!empty($val[
'checked'])) $colspan++; }
1553 print
'<tr><td colspan="'.($colspan + 1).
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
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...
Class to manage various payments.
Class to manage salary payments.
bank_prepare_head(Account $object)
Prepare array with list of tabs.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Class to manage payments of social contributions.
Class to manage bank transaction lines.
Class to manage bank accounts.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class to manage withdrawal receipts.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage payments of customer invoices.
Class to manage bank categories.
Class to manage members of a foundation.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
const TYPE_CASH
Cash account.
Class to manage payments of donations.
print $_SERVER["PHP_SELF"]
Edit parameters.
img_edit_add($titlealt= 'default', $other= '')
Show logo +.
img_edit_remove($titlealt= 'default', $other= '')
Show logo -.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Class to manage donations.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Class to manage payments of expense report.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_view($titlealt= 'default', $float=0, $other= '')
Show logo view card.
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
Class to manage payments for supplier invoices.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...