34 require
'../../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/bankcateg.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/paymentvat.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/paymentsocialcontribution.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
55 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
56 require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
58 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/cheque/class/remisecheque.class.php';
61 $langs->loadLangs(array(
"banks",
"bills",
"categories",
"companies",
"margins",
"salaries",
"loan",
"donations",
"trips",
"members",
"compta",
"accountancy"));
65 $action =
GETPOST(
'action',
'aZ09');
66 $cancel =
GETPOST(
'cancel',
'alpha');
67 $confirm =
GETPOST(
'confirm',
'alpha');
68 $contextpage =
'banktransactionlist'.(empty($object->ref) ?
'' :
'-'.$object->id);
69 $massaction =
GETPOST(
'massaction',
'alpha');
70 $optioncss =
GETPOST(
'optioncss',
'aZ09');
73 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
74 $fieldtype = (!empty($ref) ?
'ref' :
'rowid');
77 $socid = $user->socid;
79 $result =
restrictedArea($user,
'banque', $fieldvalue,
'bank_account&bank_account',
'',
'', $fieldtype);
82 $socid = $user->socid;
88 $search_debit =
GETPOST(
"search_debit",
'alpha');
89 $search_credit =
GETPOST(
"search_credit",
'alpha');
90 $search_type =
GETPOST(
"search_type",
'alpha');
91 $search_account =
GETPOST(
"search_account",
'int') ?
GETPOST(
"search_account",
'int') :
GETPOST(
"account",
'int');
92 $search_accountancy_code =
GETPOST(
'search_accountancy_code',
'alpha') ?
GETPOST(
'search_accountancy_code',
'alpha') :
GETPOST(
'accountancy_code',
'alpha');
94 $search_ref =
GETPOST(
'search_ref',
'alpha');
95 $search_description =
GETPOST(
"search_description",
'alpha');
96 $search_dt_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_start_dtmonth',
'int'),
GETPOST(
'search_start_dtday',
'int'),
GETPOST(
'search_start_dtyear',
'int'));
98 $search_dv_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_start_dvmonth',
'int'),
GETPOST(
'search_start_dvday',
'int'),
GETPOST(
'search_start_dvyear',
'int'));
100 $search_thirdparty_user =
GETPOST(
"search_thirdparty",
'alpha') ?
GETPOST(
"search_thirdparty",
'alpha') :
GETPOST(
"thirdparty",
'alpha');
101 $search_req_nb =
GETPOST(
"req_nb",
'alpha');
102 $search_num_releve =
GETPOST(
"search_num_releve",
'alpha');
103 $search_conciliated =
GETPOST(
"search_conciliated",
'int');
104 $search_fk_bordereau =
GETPOST(
"search_fk_bordereau",
'int');
105 $optioncss =
GETPOST(
'optioncss',
'alpha');
106 $toselect =
GETPOST(
'toselect',
'array');
107 $num_releve =
GETPOST(
"num_releve",
"alpha");
108 if (empty($dateop)) {
112 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
113 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
114 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
116 $pageplusone =
GETPOST(
"pageplusone",
'int');
118 $page = $pageplusone - 1;
120 if (empty($page) || $page == -1) {
123 $offset = $limit * $page;
124 $pageprev = $page - 1;
125 $pagenext = $page + 1;
127 $sortorder =
'desc,desc,desc';
130 $sortfield =
'b.datev,b.dateo,b.rowid';
134 if ($id > 0 || !empty($ref)) {
135 $result = $object->fetch($id, $ref);
136 $search_account = $object->id;
138 if (!($object->id > 0)) {
139 $langs->load(
"errors");
140 print($langs->trans(
'ErrorRecordNotFound'));
145 $mode_balance_ok =
false;
147 if (($sortfield ==
'b.datev' || $sortfield ==
'b.datev,b.dateo,b.rowid')) {
148 $sortfield =
'b.datev,b.dateo,b.rowid';
149 if ($id > 0 || !empty($ref) || $search_account > 0) {
150 $mode_balance_ok =
true;
155 $hookmanager->initHooks(array(
'banktransactionlist', $contextpage));
159 $extrafields->fetch_name_optionals_label(
'banktransaction');
160 $search_array_options = $extrafields->getOptionalsFromPost(
'banktransaction',
'',
'search_');
162 $arrayfields = array(
163 'b.rowid'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1,
'position'=>10),
164 'b.label'=>array(
'label'=>$langs->trans(
"Description"),
'checked'=>1,
'position'=>20),
165 'b.dateo'=>array(
'label'=>$langs->trans(
"DateOperationShort"),
'checked'=>1,
'position'=>30),
166 'b.datev'=>array(
'label'=>$langs->trans(
"DateValueShort"),
'checked'=>1,
'position'=>40),
167 'type'=>array(
'label'=>$langs->trans(
"Type"),
'checked'=>1,
'position'=>50),
168 'b.num_chq'=>array(
'label'=>$langs->trans(
"Numero"),
'checked'=>1,
'position'=>60),
169 'bu.label'=>array(
'label'=>$langs->trans(
"ThirdParty").
'/'.$langs->trans(
"User"),
'checked'=>1,
'position'=>70),
170 'ba.ref'=>array(
'label'=>$langs->trans(
"BankAccount"),
'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1),
'position'=>80),
171 'b.debit'=>array(
'label'=>$langs->trans(
"Debit"),
'checked'=>1,
'position'=>90),
172 'b.credit'=>array(
'label'=>$langs->trans(
"Credit"),
'checked'=>1,
'position'=>100),
173 'balancebefore'=>array(
'label'=>$langs->trans(
"BalanceBefore"),
'checked'=>0,
'position'=>110),
174 'balance'=>array(
'label'=>$langs->trans(
"Balance"),
'checked'=>1,
'position'=>120),
175 'b.num_releve'=>array(
'label'=>$langs->trans(
"AccountStatement"),
'checked'=>1,
'position'=>130),
176 'b.conciliated'=>array(
'label'=>$langs->trans(
"BankLineReconciled"),
'enabled'=> $object->rappro,
'checked'=>($action ==
'reconcile' ? 1 : 0),
'position'=>140),
177 'b.fk_bordereau'=>array(
'label'=>$langs->trans(
"ChequeReceipt"),
'checked'=>0,
'position'=>150),
180 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
189 if (
GETPOST(
'cancel',
'alpha')) {
193 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
197 $parameters = array();
198 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
203 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
205 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
206 $search_dt_start =
'';
208 $search_dv_start =
'';
216 $search_description =
'';
217 $search_thirdparty_user =
'';
218 $search_num_releve =
'';
219 $search_conciliated =
'';
220 $search_fk_bordereau =
'';
223 $search_account =
"";
224 if ($id > 0 || !empty($ref)) {
225 $search_account = $object->id;
229 if (empty($reshook)) {
230 $objectclass =
'Account';
231 $objectlabel =
'BankTransaction';
232 $permissiontoread = !empty($user->rights->banque->lire);
233 $permissiontodelete = !empty($user->rights->banque->modifier);
234 $uploaddir = $conf->bank->dir_output;
235 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
239 if ((
GETPOST(
'confirm_savestatement',
'alpha') ||
GETPOST(
'confirm_reconcile',
'alpha')) && !empty($user->rights->banque->consolidate)
244 $num_releve =
GETPOST(
"num_releve",
"alpha");
249 $rowids =
GETPOST(
'rowid',
'array');
251 if (!empty($rowids) && is_array($rowids)) {
252 foreach ($rowids as $row) {
254 $result = $bankline->fetch($row);
255 $bankline->num_releve = $num_releve;
256 $result = $bankline->update_conciliation($user,
GETPOST(
"cat"),
GETPOST(
'confirm_reconcile',
'alpha') ? 1 : 0);
266 $langs->load(
"errors");
271 $langs->load(
"errors");
272 setEventMessages($langs->trans(
"ErrorPleaseTypeBankTransactionReportName"),
null,
'errors');
276 $param =
'action=reconcile&contextpage=banktransactionlist&id='.((int) $id).
'&search_account='.((int) $id);
278 $param .=
'&page='.urlencode($page);
281 $param .=
'&offset='.urlencode($offset);
284 $param .=
'&limit='.urlencode($limit);
286 if ($search_conciliated !=
'' && $search_conciliated !=
'-1') {
287 $param .=
'&search_conciliated='.urlencode($search_conciliated);
289 if ($search_thirdparty_user) {
290 $param .=
'&search_thirdparty='.urlencode($search_thirdparty_user);
292 if ($search_num_releve) {
293 $param .=
'&search_num_releve='.urlencode($search_num_releve);
295 if ($search_description) {
296 $param .=
'&search_description='.urlencode($search_description);
299 $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');
302 $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');
305 $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');
308 $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');
311 $param .=
'&search_type='.urlencode($search_type);
314 $param .=
'&search_debit='.urlencode($search_debit);
316 if ($search_credit) {
317 $param .=
'&search_credit='.urlencode($search_credit);
319 $param .=
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder);
320 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?'.$param);
326 if (
GETPOST(
'save') && !$cancel && !empty($user->rights->banque->modifier)) {
335 $operation =
GETPOST(
"operation",
'alpha');
336 $num_chq =
GETPOST(
"num_chq",
'alpha');
337 $label =
GETPOST(
"label",
'alpha');
338 $cat1 =
GETPOST(
"cat1",
'alpha');
340 $bankaccountid = $id;
341 if (
GETPOST(
'add_account',
'int') > 0) {
342 $bankaccountid =
GETPOST(
'add_account',
'int');
346 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
350 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
354 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
358 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
360 if (!($bankaccountid > 0)) {
362 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount")),
null,
'errors');
370 if (!$error && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) {
372 $objecttmp->fetch($bankaccountid);
373 $insertid = $objecttmp->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user,
'',
'', $search_accountancy_code);
376 header(
"Location: ".$_SERVER[
'PHP_SELF'].($id ?
"?id=".$id :
''));
386 if ($action ==
'confirm_delete' && $confirm ==
'yes' && !empty($user->rights->banque->modifier)) {
388 $result = $accline->fetch(
GETPOST(
"rowid",
"int"));
389 $result = $accline->delete($user);
405 $companystatic =
new Societe($db);
406 $bankaccountstatic =
new Account($db);
407 $userstatic=
new User($db);
410 $societestatic =
new Societe($db);
411 $userstatic =
new User($db);
413 $loanstatic =
new Loan($db);
415 $donstatic =
new Don($db);
424 $bankstatic =
new Account($db);
432 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
433 $param .=
'&contextpage='.urlencode($contextpage);
435 if ($limit > 0 && $limit != $conf->liste_limit) {
436 $param .=
'&limit='.urlencode($limit);
439 $param .=
'&id='.urlencode($id);
442 $param .=
'&ref='.urlencode($ref);
444 if (!empty($search_ref)) {
445 $param .=
'&search_ref='.urlencode($search_ref);
447 if (!empty($search_description)) {
448 $param .=
'&search_description='.urlencode($search_description);
450 if (!empty($search_type)) {
451 $param .=
'&type='.urlencode($search_type);
453 if (!empty($search_thirdparty_user)) {
454 $param .=
'&search_thirdparty='.urlencode($search_thirdparty_user);
456 if (!empty($search_debit)) {
457 $param .=
'&search_debit='.urlencode($search_debit);
459 if (!empty($search_credit)) {
460 $param .=
'&search_credit='.urlencode($search_credit);
462 if ($search_account > 0) {
463 $param .=
'&search_account='.urlencode($search_account);
465 if (!empty($search_num_releve)) {
466 $param .=
'&search_num_releve='.urlencode($search_num_releve);
468 if ($search_conciliated !=
'' && $search_conciliated !=
'-1') {
469 $param .=
'&search_conciliated='.urlencode($search_conciliated);
471 if ($search_fk_bordereau > 0) {
472 $param .=
'$&search_fk_bordereau='.urlencode($search_fk_bordereau);
474 if ($search_bid > 0) {
475 $param .=
'&search_bid='.urlencode($search_bid);
478 $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');
481 $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');
484 $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');
487 $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');
489 if ($search_req_nb) {
490 $param .=
'&req_nb='.urlencode($search_req_nb);
492 if (
GETPOST(
"search_thirdparty",
'int')) {
493 $param .=
'&thirdparty='.urlencode(
GETPOST(
"search_thirdparty",
'int'));
495 if ($optioncss !=
'') {
496 $param .=
'&optioncss='.urlencode($optioncss);
498 if ($action ==
'reconcile') {
499 $param .=
'&action=reconcile';
507 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
511 $buttonreconcile =
'';
514 if ($id > 0 || !empty($ref)) {
515 $title = $langs->trans(
"FinancialAccount").
' - '.$langs->trans(
"Transactions");
520 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/bankcateg.class.php';
523 foreach ($bankcateg->fetchAll() as $bankcategory) {
524 $options[$bankcategory->id] = $bankcategory->label;
529 print
dol_get_fiche_head($head,
'journal', $langs->trans(
"FinancialAccount"), 0,
'account');
531 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
533 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'', 1);
542 if ($action !=
'reconcile') {
543 if ($object->canBeConciliated() > 0) {
544 $allowautomaticconciliation =
false;
545 $titletoconciliatemanual = $langs->trans(
"Conciliate");
546 $titletoconciliateauto = $langs->trans(
"Conciliate");
547 if ($allowautomaticconciliation) {
548 $titletoconciliatemanual .=
' ('.$langs->trans(
"Manual").
')';
549 $titletoconciliateauto .=
' ('.$langs->trans(
"Auto").
')';
553 if ($user->rights->banque->consolidate) {
555 $newparam = preg_replace(
'/search_conciliated=\d+/i',
'', $newparam);
556 $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.
'">'.$titletoconciliatemanual.
'</a>';
558 $buttonreconcile =
'<a class="butActionRefused" style="margin-bottom: 5px !important; margin-top: 5px !important" title="'.$langs->trans(
"NotEnoughPermissions").
'" href="#">'.$titletoconciliatemanual.
'</a>';
561 if ($allowautomaticconciliation) {
563 if ($user->rights->banque->consolidate) {
565 $newparam = preg_replace(
'/search_conciliated=\d+/i',
'', $newparam);
566 $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.
'">'.$titletoconciliateauto.
'</a>';
568 $buttonreconcile .=
' <a class="butActionRefused" style="margin-bottom: 5px !important; margin-top: 5px !important" title="'.$langs->trans(
"NotEnoughPermissions").
'" href="#">'.$titletoconciliateauto.
'</a>';
574 llxHeader(
'', $langs->trans(
"BankTransactions"),
'',
'', 0, 0, array(), array(), $param);
578 $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,";
579 $sql .=
" b.fk_account, b.fk_type, b.fk_bordereau,";
580 $sql .=
" ba.rowid as bankid, ba.ref as bankref";
582 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
583 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
584 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
588 $parameters = array();
589 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
590 $sql .= $hookmanager->resPrint;
592 if ($search_bid > 0) {
593 $sql .= MAIN_DB_PREFIX.
"bank_class as l,";
595 $sql .=
" ".MAIN_DB_PREFIX.
"bank_account as ba,";
596 $sql .=
" ".MAIN_DB_PREFIX.
"bank as b";
597 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
598 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (b.rowid = ef.fk_object)";
602 $parameters = array();
603 $reshook = $hookmanager->executeHooks(
'printFieldListJoin', $parameters);
604 $sql .= $hookmanager->resPrint;
606 $sql .=
" WHERE b.fk_account = ba.rowid";
607 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
608 if ($search_account > 0) {
609 $sql .=
" AND b.fk_account = ".((int) $search_account);
613 $sql .=
" AND b.dateo >= '".$db->idate($search_dt_start).
"'";
616 $sql .=
" AND b.dateo <= '".$db->idate($search_dt_end).
"'";
620 $sql .=
" AND b.datev >= '".$db->idate($search_dv_start).
"'";
623 $sql .=
" AND b.datev <= '".$db->idate($search_dv_end).
"'";
628 if ($search_req_nb) {
631 if ($search_num_releve) {
634 if ($search_conciliated !=
'' && $search_conciliated !=
'-1') {
635 $sql .=
" AND b.rappro = ".((int) $search_conciliated);
637 if ($search_fk_bordereau > 0) {
638 $sql .=
" AND b.fk_bordereau = " . ((int) $search_fk_bordereau);
640 if ($search_thirdparty_user) {
641 $sql.=
" AND (b.rowid IN ";
642 $sql.=
" ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX.
"bank_url AS bu";
643 $sql.=
" JOIN ".MAIN_DB_PREFIX.
"bank AS b2 ON b2.rowid = bu.fk_bank";
644 $sql.=
" JOIN ".MAIN_DB_PREFIX.
"user AS subUser ON (bu.type = 'user' AND bu.url_id = subUser.rowid)";
645 $sql.=
" WHERE ".
natural_search(array(
"subUser.firstname",
"subUser.lastname"), $search_thirdparty_user,
'', 1).
")";
647 $sql.=
" OR b.rowid IN ";
648 $sql.=
" ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX.
"bank_url AS bu";
649 $sql.=
" JOIN ".MAIN_DB_PREFIX.
"bank AS b2 ON b2.rowid = bu.fk_bank";
650 $sql.=
" JOIN ".MAIN_DB_PREFIX.
"societe AS subSoc ON (bu.type = 'company' AND bu.url_id = subSoc.rowid)";
651 $sql.=
" WHERE ".
natural_search(array(
"subSoc.nom"), $search_thirdparty_user,
'', 1);
654 if ($search_description) {
655 $search_description_to_use = $search_description;
656 $arrayoffixedlabels = array(
658 'CustomerInvoicePayment',
'CustomerInvoicePaymentBack',
659 'SupplierInvoicePayment',
'SupplierInvoicePaymentBack',
661 'ExpenseReportPayment',
662 'SocialContributionPayment',
663 'SubscriptionPayment',
666 foreach ($arrayoffixedlabels as $keyforlabel) {
667 $translatedlabel = $langs->transnoentitiesnoconv($keyforlabel);
668 if (preg_match(
'/'.$search_description.
'/i', $translatedlabel)) {
669 $search_description_to_use .=
"|".$keyforlabel;
675 if ($search_bid > 0) {
676 $sql .=
" AND b.rowid = l.lineid AND l.fk_categ = ".((int) $search_bid);
678 if (!empty($search_type)) {
679 $sql .=
" AND b.fk_type = '".$db->escape($search_type).
"'";
684 $sql .=
' AND b.amount <= 0';
686 if ($search_credit) {
688 $sql .=
' AND b.amount >= 0';
691 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
694 $parameters = array();
695 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
696 $sql .= $hookmanager->resPrint;
698 $sql .= $db->order($sortfield, $sortorder);
700 $nbtotalofrecords =
'';
702 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
703 $result = $db->query($sql);
704 $nbtotalofrecords = $db->num_rows($result);
705 $nbtotalofpages = ceil($nbtotalofrecords / $limit);
708 if (($id > 0 || !empty($ref)) && ((
string) $page ==
'')) {
711 $page = ($nbtotalofpages - 1);
712 $offset = $limit * $page;
717 if ($page >= $nbtotalofpages) {
719 $page = ($nbtotalofpages - 1);
720 $offset = $limit * $page;
728 if (empty($search_account)) {
729 $mode_balance_ok =
false;
732 if (!empty($search_ref)) {
733 $mode_balance_ok =
false;
735 if (!empty($search_description)) {
736 $mode_balance_ok =
false;
738 if (!empty($search_type)) {
739 $mode_balance_ok =
false;
741 if (!empty($search_debit)) {
742 $mode_balance_ok =
false;
744 if (!empty($search_credit)) {
745 $mode_balance_ok =
false;
747 if (!empty($search_thirdparty_user)) {
748 $mode_balance_ok =
false;
750 if ($search_conciliated !=
'' && $search_conciliated !=
'-1') {
751 $mode_balance_ok =
false;
753 if (!empty($search_num_releve)) {
754 $mode_balance_ok =
false;
756 if (!empty($search_fk_bordereau)) {
757 $mode_balance_ok =
false;
760 $sql .= $db->plimit($limit + 1, $offset);
762 dol_syslog(
'compta/bank/bankentries_list.php', LOG_DEBUG);
763 $resql = $db->query($sql);
765 $num = $db->num_rows(
$resql);
767 $arrayofselected = (!empty($toselect) && is_array($toselect)) ? $toselect : array();
770 $arrayofmassactions = array(
775 if (in_array($massaction, array(
'presend',
'predelete'))) {
776 $arrayofmassactions = array();
778 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
781 if ($action ==
'delete') {
782 $text = $langs->trans(
'ConfirmDeleteTransaction');
783 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&rowid='.
GETPOST(
"rowid",
'int'), $langs->trans(
'DeleteTransaction'), $text,
'confirm_delete',
null,
'', 1);
787 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="search_form">'.
"\n";
788 if ($optioncss !=
'') {
789 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
791 print
'<input type="hidden" name="token" value="'.newToken().
'">';
792 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
793 print
'<input type="hidden" name="action" value="'.($action !=
'delete' ? $action :
'search').
'">';
795 print
'<input type="hidden" name="view" value="'.dol_escape_htmltag($view).
'">';
797 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
798 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
799 print
'<input type="hidden" name="page" value="'.$page.
'">';
800 print
'<input type="hidden" name="id" value="'.$id.
'">';
801 print
'<input type="hidden" name="ref" value="'.$ref.
'">';
803 print
'<input type="hidden" name="bid" value="'.GETPOST(
"bid",
'int').
'">';
807 if ($user->rights->banque->consolidate && $action ==
'reconcile') {
808 print
'<div class="valignmiddle inline-block" style="padding-right: 20px;">';
809 print
'<strong>'.$langs->trans(
"InputReceiptNumber").
'</strong>: ';
810 print
'<input class="flat" id="num_releve" name="num_releve" type="text" value="'.(GETPOST(
'num_releve') ?
GETPOST(
'num_releve') :
'').
'" size="10">';
812 if (is_array($options) && count($options)) {
813 print $langs->trans(
"EventualyAddCategory").
': ';
816 print
'<br><div style="margin-top: 5px;"><span class="opacitymedium">'.$langs->trans(
"ThenCheckLinesAndConciliate").
'</span> ';
817 print
'<input class="button" name="confirm_savestatement" type="submit" value="'.$langs->trans(
"SaveStatementOnly").
'">';
818 print
' '.$langs->trans(
"or").
' ';
819 print
'<input class="button" name="confirm_reconcile" type="submit" value="'.$langs->trans(
"Conciliate").
'">';
820 print
' '.$langs->trans(
"or").
' ';
821 print
'<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
827 $sql =
"SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX.
"bank";
828 $sql .=
" WHERE fk_account = ".((int) $object->id).
" AND num_releve IS NOT NULL";
829 $sql .= $db->order(
"num_releve",
"DESC");
830 $sql .= $db->plimit($nbmax + 1);
832 print $langs->trans(
"LastAccountStatements").
' : ';
833 $resqlr = $db->query($sql);
835 $numr = $db->num_rows($resqlr);
838 while (($i < $numr) && ($i < $nbmax)) {
839 $objr = $db->fetch_object($resqlr);
841 $last_releve = $objr->num_releve;
845 $liste =
'<a href="'.DOL_URL_ROOT.
'/compta/bank/releve.php?account='.$id.
'&num='.$objr->num_releve.
'">'.$objr->num_releve.
'</a> '.$liste;
847 if ($numr >= $nbmax) {
848 $liste =
"... ".$liste;
852 print
'<b>'.$langs->trans(
"None").
'</b>';
859 if (!empty($conf->global->BANK_REPORT_LAST_NUM_RELEVE)) {
861 <script type="text/javascript">
862 $("#num_releve").val("' . $last_releve.
'");
870 if (!empty($user->rights->banque->modifier) && $action ==
'addline' && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) {
873 print
'<table class="noborder centpercent">';
875 print
'<tr class="liste_titre">';
876 print
'<td>'.$langs->trans(
"Description").
'</td>';
877 print
'<td>'.$langs->trans(
"Date").
'</td>';
878 print
'<td> </td>';
879 print
'<td>'.$langs->trans(
"Type").
'</td>';
880 print
'<td>'.$langs->trans(
"Numero").
'</td>';
881 print
'<td class=right>'.$langs->trans(
"BankAccount").
'</td>';
882 print
'<td class=right>'.$langs->trans(
"Debit").
'</td>';
883 print
'<td class=right>'.$langs->trans(
"Credit").
'</td>';
890 print
'<td align="center"> </td>';
895 print
'<input name="label" class="flat minwidth200" type="text" value="'.GETPOST(
"label",
"alpha").
'">';
896 if (is_array($options) && count($options)) {
897 print
'<br>'.$langs->trans(
"Rubrique").
': ';
901 print
'<td class="nowrap">';
902 print
$form->selectDate(empty($dateop) ?-1 : $dateop,
'op', 0, 0, 0,
'transaction');
904 print
'<td> </td>';
905 print
'<td class="nowrap">';
909 print
'<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST(
"num_chq",
"alpha").
'">';
913 print
'<td class=right>';
914 $form->select_comptes(
GETPOST(
'add_account',
'int') ?
GETPOST(
'add_account',
'int') : $search_account,
'add_account', 0,
'', 1, ($id > 0 || !empty($ref) ?
' disabled="disabled"' :
''));
917 print
'<td class="right"><input name="adddebit" class="flat" type="text" size="4" value="'.GETPOST(
"adddebit",
"alpha").
'"></td>';
918 print
'<td class="right"><input name="addcredit" class="flat" type="text" size="4" value="'.GETPOST(
"addcredit",
"alpha").
'"></td>';
925 print
'<td class="center">';
926 print
'<input type="submit" name="save" class="button buttongen marginbottomonly button-add" value="'.$langs->trans(
"Add").
'"><br>';
927 print
'<input type="submit" name="cancel" class="button buttongen marginbottomonly button-cancel" value="'.$langs->trans(
"Cancel").
'">';
935 $urlajax = DOL_URL_ROOT.
'/core/ajax/bankconciliate.php?token='.
currentToken();
937 <script type="text/javascript">
939 $("a.ajaxforbankoperationchange").each(function(){
940 var current = $(this);
941 current.click(function()
943 var url = "'.$urlajax.
'&"+current.attr("href").split("?")[1];
944 $.get(url, function(data)
948 current.parent().parent().find(".spanforajaxedit").replaceWith(data);
963 if ($action !=
'addline' && $action !=
'reconcile') {
964 if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
965 if (empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) {
966 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddBankRecord'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?action=create&accountid='.urlencode($search_account).
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.urlencode($search_account)),
'', $user->rights->banque->modifier);
969 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddBankRecord'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?action=addline&token='.
newToken().
'&page='.$page.$param,
'', $user->rights->banque->modifier);
972 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddBankRecord'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?action=addline&token='.
newToken().
'&page='.$page.$param,
'', -1);
984 if ($action !=
'addline' && $action !=
'reconcile') {
985 $morehtml .= $buttonreconcile;
988 $morehtml .=
'<!-- Add New button -->'.$newcardbutton;
990 $picto =
'bank_account';
991 if ($id > 0 || !empty($ref)) {
995 print_barre_liste($langs->trans(
"BankTransactions"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml,
'', $limit, 0, 0, 1);
999 $param .=
'&page='.urlencode($page);
1002 $moreforfilter =
'';
1004 $moreforfilter .=
'<div class="divsearchfield">';
1005 $moreforfilter .= $langs->trans(
'DateOperationShort');
1006 $moreforfilter .= ($conf->browser->layout ==
'phone' ?
'<br>' :
' ');
1007 $moreforfilter .=
'<div class="nowrap inline-block">';
1008 $moreforfilter .=
$form->selectDate($search_dt_start,
'search_start_dt', 0, 0, 1,
"search_form", 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1009 $moreforfilter .=
'</div>';
1010 $moreforfilter .= ($conf->browser->layout ==
'phone' ?
'' :
' ');
1011 $moreforfilter .=
'<div class="nowrap inline-block">';
1012 $moreforfilter .=
$form->selectDate($search_dt_end,
'search_end_dt', 0, 0, 1,
"search_form", 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1013 $moreforfilter .=
'</div>';
1014 $moreforfilter .=
'</div>';
1016 $moreforfilter .=
'<div class="divsearchfield">';
1017 $moreforfilter .= $langs->trans(
'DateValueShort');
1018 $moreforfilter .= ($conf->browser->layout ==
'phone' ?
'<br>' :
' ');
1019 $moreforfilter .=
'<div class="nowrap inline-block">';
1020 $moreforfilter .=
$form->selectDate($search_dv_start,
'search_start_dv', 0, 0, 1,
"search_form", 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1021 $moreforfilter .=
'</div>';
1022 $moreforfilter .= ($conf->browser->layout ==
'phone' ?
'' :
' ');
1023 $moreforfilter .=
'<div class="nowrap inline-block">';
1024 $moreforfilter .=
$form->selectDate($search_dv_end,
'search_end_dv', 0, 0, 1,
"search_form", 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1025 $moreforfilter .=
'</div>';
1026 $moreforfilter .=
'</div>';
1030 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
1031 $langs->load(
'categories');
1034 $moreforfilter .=
'<div class="divsearchfield">';
1035 $tmptitle = $langs->trans(
'RubriquesTransactions');
1036 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid,
'parent',
null,
null, 1);
1037 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_bid', $cate_arbo, $search_bid, $tmptitle, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1038 $moreforfilter .=
'</div>';
1042 $parameters = array();
1043 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1044 if (empty($reshook)) {
1045 $moreforfilter .= $hookmanager->resPrint;
1047 $moreforfilter = $hookmanager->resPrint;
1050 if ($moreforfilter) {
1051 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1052 print $moreforfilter;
1053 print
'</div>'.
"\n";
1056 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1057 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
1059 if ($action ==
'reconcile') {
1060 $arrayfields[
'b.num_releve'][
'checked'] = 1;
1063 print
'<div class="div-table-responsive">';
1064 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1067 print
'<tr class="liste_titre_filter">';
1068 if (!empty($arrayfields[
'b.rowid'][
'checked'])) {
1069 print
'<td class="liste_titre">';
1070 print
'<input type="text" class="flat" name="search_ref" size="2" value="'.dol_escape_htmltag($search_ref).
'">';
1073 if (!empty($arrayfields[
'b.label'][
'checked'])) {
1074 print
'<td class="liste_titre">';
1075 print
'<input type="text" class="flat maxwidth100" name="search_description" value="'.dol_escape_htmltag($search_description).
'">';
1078 if (!empty($arrayfields[
'b.dateo'][
'checked'])) {
1079 print
'<td class="liste_titre"> </td>';
1081 if (!empty($arrayfields[
'b.datev'][
'checked'])) {
1082 print
'<td class="liste_titre"> </td>';
1084 if (!empty($arrayfields[
'type'][
'checked'])) {
1085 print
'<td class="liste_titre" align="center">';
1086 $form->select_types_paiements(empty($search_type) ?
'' : $search_type,
'search_type',
'', 2, 1, 1, 0, 1,
'maxwidth100');
1090 if (!empty($arrayfields[
'b.num_chq'][
'checked'])) {
1091 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>';
1094 if (!empty($arrayfields[
'bu.label'][
'checked'])) {
1095 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty_user).
'"></td>';
1098 if (!empty($arrayfields[
'ba.ref'][
'checked'])) {
1099 print
'<td class="liste_titre">';
1100 $form->select_comptes($search_account,
'search_account', 0,
'', 1, ($id > 0 || !empty($ref) ?
' disabled="disabled"' :
''), 0,
'maxwidth100');
1104 if (!empty($arrayfields[
'b.debit'][
'checked'])) {
1105 print
'<td class="liste_titre right">';
1106 print
'<input type="text" class="flat width50" name="search_debit" value="'.dol_escape_htmltag($search_debit).
'">';
1110 if (!empty($arrayfields[
'b.credit'][
'checked'])) {
1111 print
'<td class="liste_titre right">';
1112 print
'<input type="text" class="flat width50" name="search_credit" value="'.dol_escape_htmltag($search_credit).
'">';
1116 if (!empty($arrayfields[
'balancebefore'][
'checked'])) {
1117 print
'<td class="liste_titre right">';
1118 $htmltext = $langs->trans(
"BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv(
"DateValue"));
1119 print
$form->textwithpicto(
'', $htmltext, 1);
1123 if (!empty($arrayfields[
'balance'][
'checked'])) {
1124 print
'<td class="liste_titre right">';
1125 $htmltext = $langs->trans(
"BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv(
"DateValue"));
1126 print
$form->textwithpicto(
'', $htmltext, 1);
1130 if (!empty($arrayfields[
'b.num_releve'][
'checked'])) {
1131 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>';
1134 if (!empty($arrayfields[
'b.conciliated'][
'checked'])) {
1135 print
'<td class="liste_titre" align="center">';
1136 print
$form->selectyesno(
'search_conciliated', $search_conciliated, 1,
false, 1, 1);
1140 if (!empty($arrayfields[
'b.fk_bordereau'][
'checked'])) {
1141 print
'<td class="liste_titre" align="center"><input type="text" class="flat" name="search_fk_bordereau" value="'.dol_escape_htmltag($search_fk_bordereau).
'" size="3"></td>';
1145 print
'<td class="liste_titre" align="middle">';
1146 $searchpicto =
$form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
1152 print
'<tr class="liste_titre">';
1153 if (!empty($arrayfields[
'b.rowid'][
'checked'])) {
1154 print_liste_field_titre($arrayfields[
'b.rowid'][
'label'], $_SERVER[
'PHP_SELF'],
'b.rowid',
'', $param,
'', $sortfield, $sortorder);
1156 if (!empty($arrayfields[
'b.label'][
'checked'])) {
1157 print_liste_field_titre($arrayfields[
'b.label'][
'label'], $_SERVER[
'PHP_SELF'],
'b.label',
'', $param,
'', $sortfield, $sortorder);
1159 if (!empty($arrayfields[
'b.dateo'][
'checked'])) {
1160 print_liste_field_titre($arrayfields[
'b.dateo'][
'label'], $_SERVER[
'PHP_SELF'],
'b.dateo',
'', $param,
'', $sortfield, $sortorder,
"center ");
1162 if (!empty($arrayfields[
'b.datev'][
'checked'])) {
1163 print_liste_field_titre($arrayfields[
'b.datev'][
'label'], $_SERVER[
'PHP_SELF'],
'b.datev,b.dateo,b.rowid',
'', $param,
'align="center"', $sortfield, $sortorder);
1165 if (!empty($arrayfields[
'type'][
'checked'])) {
1166 print_liste_field_titre($arrayfields[
'type'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'align="center"', $sortfield, $sortorder);
1168 if (!empty($arrayfields[
'b.num_chq'][
'checked'])) {
1169 print_liste_field_titre($arrayfields[
'b.num_chq'][
'label'], $_SERVER[
'PHP_SELF'],
'b.num_chq',
'', $param,
'', $sortfield, $sortorder,
"center ");
1171 if (!empty($arrayfields[
'bu.label'][
'checked'])) {
1172 print_liste_field_titre($arrayfields[
'bu.label'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
1174 if (!empty($arrayfields[
'ba.ref'][
'checked'])) {
1175 print_liste_field_titre($arrayfields[
'ba.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'ba.ref',
'', $param,
'', $sortfield, $sortorder);
1177 if (!empty($arrayfields[
'b.debit'][
'checked'])) {
1178 print_liste_field_titre($arrayfields[
'b.debit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
"right ");
1180 if (!empty($arrayfields[
'b.credit'][
'checked'])) {
1181 print_liste_field_titre($arrayfields[
'b.credit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
"right ");
1183 if (!empty($arrayfields[
'balancebefore'][
'checked'])) {
1184 print_liste_field_titre($arrayfields[
'balancebefore'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
"right ");
1186 if (!empty($arrayfields[
'balance'][
'checked'])) {
1187 print_liste_field_titre($arrayfields[
'balance'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
"right ");
1189 if (!empty($arrayfields[
'b.num_releve'][
'checked'])) {
1190 print_liste_field_titre($arrayfields[
'b.num_releve'][
'label'], $_SERVER[
'PHP_SELF'],
'b.num_releve',
'', $param,
'', $sortfield, $sortorder,
"center ");
1192 if (!empty($arrayfields[
'b.conciliated'][
'checked'])) {
1193 print_liste_field_titre($arrayfields[
'b.conciliated'][
'label'], $_SERVER[
'PHP_SELF'],
'b.rappro',
'', $param,
'', $sortfield, $sortorder,
"center ");
1195 if (!empty($arrayfields[
'b.fk_bordereau'][
'checked'])) {
1196 print_liste_field_titre($arrayfields[
'b.fk_bordereau'][
'label'], $_SERVER[
'PHP_SELF'],
'b.fk_bordereau',
'', $param,
'', $sortfield, $sortorder,
"center ");
1200 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1202 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1203 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1204 print $hookmanager->resPrint;
1206 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
1211 $balancecalculated =
false;
1212 $posconciliatecol = 0;
1213 $cachebankaccount = array();
1218 while ($i < min($num, $limit)) {
1219 $objp = $db->fetch_object(
$resql);
1220 $links = $bankaccountstatic->get_url($objp->rowid);
1223 if (!$balancecalculated && (!empty($arrayfields[
'balancebefore'][
'checked']) || !empty($arrayfields[
'balance'][
'checked'])) && ($mode_balance_ok || $search_conciliated ===
'0')) {
1224 if (!$search_account) {
1225 dol_print_error(
'',
'account is not defined but $mode_balance_ok is true');
1232 $sqlforbalance =
'SELECT SUM(b.amount) as previoustotal';
1233 $sqlforbalance .=
" FROM ";
1234 $sqlforbalance .=
" ".MAIN_DB_PREFIX.
"bank_account as ba,";
1235 $sqlforbalance .=
" ".MAIN_DB_PREFIX.
"bank as b";
1236 $sqlforbalance .=
" WHERE b.fk_account = ba.rowid";
1237 $sqlforbalance .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1238 $sqlforbalance .=
" AND b.fk_account = ".((int) $search_account);
1239 $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.
"))))";
1240 $resqlforbalance = $db->query($sqlforbalance);
1242 if ($resqlforbalance) {
1243 $objforbalance = $db->fetch_object($resqlforbalance);
1244 if ($objforbalance) {
1246 if ($sortfield ==
'b.datev,b.dateo,b.rowid' && ($sortorder ==
'desc' || $sortorder ==
'desc,desc' || $sortorder ==
'desc,desc,desc')) {
1247 $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount);
1250 $balance = $objforbalance->previoustotal;
1257 $balancecalculated =
true;
1260 if ($user->rights->banque->consolidate && $action ==
'reconcile') {
1261 $tmpnbfieldbeforebalance = 0;
1262 $tmpnbfieldafterbalance = 0;
1263 $balancefieldfound = 0;
1264 foreach ($arrayfields as $key => $val) {
1265 if ($key ==
'balancebefore' || $key ==
'balance') {
1266 $balancefieldfound++;
1269 if (!empty($arrayfields[$key][
'checked'])) {
1270 if (!$balancefieldfound) {
1271 $tmpnbfieldbeforebalance++;
1273 $tmpnbfieldafterbalance++;
1278 $element =
'banktransaction';
1279 if (is_array($extrafields->attributes[$element][
'label']) && count($extrafields->attributes[$element][
'label'])) {
1280 foreach ($extrafields->attributes[$element][
'label'] as $key => $val) {
1281 if (!empty($arrayfields[
"ef.".$key][
'checked'])) {
1282 if (!empty($arrayfields[$key][
'checked'])) {
1283 if (!$balancefieldfound) {
1284 $tmpnbfieldbeforebalance++;
1286 $tmpnbfieldafterbalance++;
1293 print
'<tr class="oddeven trforbreak">';
1294 if ($tmpnbfieldbeforebalance) {
1295 print
'<td colspan="'.$tmpnbfieldbeforebalance.
'">';
1300 if (!empty($arrayfields[
'balancebefore'][
'checked'])) {
1301 print
'<td class="right">';
1302 if ($search_conciliated !==
'0') {
1307 if (!empty($arrayfields[
'balance'][
'checked'])) {
1308 print
'<td class="right">';
1309 if ($search_conciliated !==
'0') {
1314 if (!empty($arrayfields[
'b.num_releve'][
'checked'])) {
1315 print
'<td class="center">';
1316 print
'<input type="checkbox" id="selectAll" title="'.dol_escape_htmltag($langs->trans(
"SelectAll")).
'" />';
1317 print
' <script type="text/javascript">
1318 $("input#selectAll").change(function() {
1319 $("input[type=checkbox][name^=rowid]").prop("checked", $(this).is(":checked"));
1324 print
'<td colspan="'.($tmpnbfieldafterbalance + 1).
'">';
1331 if ($sortfield ==
'b.datev,b.dateo,b.rowid' && ($sortorder ==
'desc' || $sortorder ==
'desc,desc' || $sortorder ==
'desc,desc,desc')) {
1332 $balance =
price2num($balancebefore,
'MT');
1333 $balancebefore =
price2num($balancebefore - ($sign * $objp->amount),
'MT');
1335 $balancebefore =
price2num($balance,
'MT');
1336 $balance =
price2num($balance + ($sign * $objp->amount),
'MT');
1339 if (empty($cachebankaccount[$objp->bankid])) {
1340 $bankaccounttmp =
new Account($db);
1341 $bankaccounttmp->fetch($objp->bankid);
1342 $cachebankaccount[$objp->bankid] = $bankaccounttmp;
1343 $bankaccount = $bankaccounttmp;
1345 $bankaccount = $cachebankaccount[$objp->bankid];
1348 if (empty($conf->global->BANK_COLORIZE_MOVEMENT)) {
1349 $backgroundcolor =
"class='oddeven'";
1351 if ($objp->amount < 0) {
1353 $backgroundcolor =
'style="background: '.$color.
';"';
1356 $backgroundcolor =
'style="background: '.$color.
';"';
1360 $banklinestatic->id = $objp->rowid;
1361 $banklinestatic->ref = $objp->rowid;
1363 print
'<tr class="oddeven" '.$backgroundcolor.
'>';
1366 if (!empty($arrayfields[
'b.rowid'][
'checked'])) {
1367 print
'<td class="nowrap left">';
1368 print $banklinestatic->getNomUrl(1);
1371 $totalarray[
'nbfield']++;
1376 if (!empty($arrayfields[
'b.label'][
'checked'])) {
1380 preg_match(
'/\((.+)\)/i', $objp->label, $reg);
1381 if (!empty($reg[1]) && $langs->trans($reg[1]) != $reg[1]) {
1382 $labeltoshow = $langs->trans($reg[1]);
1384 if ($objp->label ==
'(payment_salary)') {
1385 $labeltoshow = $langs->trans(
"SalaryPayment");
1388 $titletoshow = $objp->label;
1393 print
'<td class="tdoverflowmax250"'.($titletoshow ?
' title="'.dol_escape_htmltag($titletoshow).
'"' :
'').
'>';
1396 $cachebankaccount = array();
1397 foreach ($links as $key => $val) {
1398 print
'<!-- '.$links[$key][
'type'].
' -->';
1399 if ($links[$key][
'type'] ==
'withdraw') {
1400 $banktransferstatic->id = $links[$key][
'url_id'];
1401 $banktransferstatic->ref = $links[$key][
'label'];
1402 print $banktransferstatic->getNomUrl(0).
' ';
1403 } elseif ($links[$key][
'type'] ==
'payment') {
1404 $paymentstatic->id = $links[$key][
'url_id'];
1405 $paymentstatic->ref = $links[$key][
'url_id'];
1406 $paymentstatic->date = $db->jdate($objp->do);
1407 print $paymentstatic->getNomUrl(2).
' ';
1408 } elseif ($links[$key][
'type'] ==
'payment_supplier') {
1409 $paymentsupplierstatic->id = $links[$key][
'url_id'];
1410 $paymentsupplierstatic->ref = $links[$key][
'url_id'];
1411 print $paymentsupplierstatic->getNomUrl(2).
' ';
1412 } elseif ($links[$key][
'type'] ==
'payment_sc') {
1413 $paymentscstatic->id = $links[$key][
'url_id'];
1414 $paymentscstatic->ref = $links[$key][
'url_id'];
1415 $paymentscstatic->label = $links[$key][
'label'];
1416 print $paymentscstatic->getNomUrl(2).
' ';
1417 } elseif ($links[$key][
'type'] ==
'payment_vat') {
1418 $paymentvatstatic->id = $links[$key][
'url_id'];
1419 $paymentvatstatic->ref = $links[$key][
'url_id'];
1420 print $paymentvatstatic->getNomUrl(2).
' ';
1421 } elseif ($links[$key][
'type'] ==
'payment_salary') {
1422 $paymentsalstatic->id = $links[$key][
'url_id'];
1423 $paymentsalstatic->ref = $links[$key][
'url_id'];
1424 $paymentsalstatic->label = $links[$key][
'label'];
1425 print $paymentsalstatic->getNomUrl(2).
' ';
1426 } elseif ($links[$key][
'type'] ==
'payment_loan') {
1427 print
'<a href="'.DOL_URL_ROOT.
'/loan/payment/card.php?id='.$links[$key][
'url_id'].
'">';
1428 print
' '.img_object($langs->trans(
'ShowPayment'),
'payment').
' ';
1430 } elseif ($links[$key][
'type'] ==
'payment_donation') {
1431 $paymentdonationstatic->id = $links[$key][
'url_id'];
1432 $paymentdonationstatic->ref = $links[$key][
'url_id'];
1433 print $paymentdonationstatic->getNomUrl(2).
' ';
1434 } elseif ($links[$key][
'type'] ==
'payment_expensereport') {
1435 $paymentexpensereportstatic->id = $links[$key][
'url_id'];
1436 $paymentexpensereportstatic->ref = $links[$key][
'url_id'];
1437 print $paymentexpensereportstatic->getNomUrl(2).
' ';
1438 } elseif ($links[$key][
'type'] ==
'payment_various') {
1439 $paymentvariousstatic->id = $links[$key][
'url_id'];
1440 $paymentvariousstatic->ref = $links[$key][
'url_id'];
1441 print $paymentvariousstatic->getNomUrl(2).
' ';
1442 } elseif ($links[$key][
'type'] ==
'banktransfert') {
1444 if ($objp->amount > 0) {
1445 $banklinestatic->fetch($links[$key][
'url_id']);
1446 $bankstatic->id = $banklinestatic->fk_account;
1447 $bankstatic->label = $banklinestatic->bank_account_ref;
1448 print $langs->trans(
"TransferFrom").
' ';
1449 print $bankstatic->getNomUrl(1,
'transactions');
1450 print
' '.$langs->trans(
"toward").
' ';
1451 $bankstatic->id = $objp->bankid;
1452 $bankstatic->label = $objp->bankref;
1453 print $bankstatic->getNomUrl(1,
'');
1456 $bankstatic->id = $objp->bankid;
1457 $bankstatic->label = $objp->bankref;
1458 print $langs->trans(
"TransferFrom").
' ';
1459 print $bankstatic->getNomUrl(1,
'');
1460 print
' '.$langs->trans(
"toward").
' ';
1461 $banklinestatic->fetch($links[$key][
'url_id']);
1462 $bankstatic->id = $banklinestatic->fk_account;
1463 $bankstatic->label = $banklinestatic->bank_account_ref;
1464 print $bankstatic->getNomUrl(1,
'transactions');
1468 } elseif ($links[$key][
'type'] ==
'company') {
1469 } elseif ($links[$key][
'type'] ==
'user') {
1470 } elseif ($links[$key][
'type'] ==
'member') {
1471 } elseif ($links[$key][
'type'] ==
'sc') {
1472 } elseif ($links[$key][
'type'] ==
'vat') {
1473 } elseif ($links[$key][
'type'] ==
'salary') {
1477 print
'<a href="'.$links[$key][
'url'].$links[$key][
'url_id'].
'">';
1478 if (preg_match(
'/^\((.*)\)$/i', $links[$key][
'label'], $reg)) {
1480 if ($reg[1] ==
'paiement') {
1481 $reg[1] =
'Payment';
1483 print $langs->trans($reg[1]);
1485 print $links[$key][
'label'];
1487 print
'</a>'.($labeltoshow ?
' - ' :
'');
1495 $totalarray[
'nbfield']++;
1500 if (!empty($arrayfields[
'b.dateo'][
'checked'])) {
1501 print
'<td align="center" class="nowrap">';
1502 print
'<span class="spanforajaxedit" id="dateoperation_'.$objp->rowid.
'">'.
dol_print_date($db->jdate($objp->do),
"day").
"</span>";
1504 print
'<span class="inline-block">';
1505 print
'<a class="ajaxforbankoperationchange" href="'.$_SERVER[
'PHP_SELF'].
'?action=doprev&account='.$objp->bankid.
'&rowid='.$objp->rowid.
'">';
1507 print
'<a class="ajaxforbankoperationchange" href="'.$_SERVER[
'PHP_SELF'].
'?action=donext&account='.$objp->bankid.
'&rowid='.$objp->rowid.
'">';
1512 $totalarray[
'nbfield']++;
1517 if (!empty($arrayfields[
'b.datev'][
'checked'])) {
1518 print
'<td align="center" class="nowrap">';
1519 print
'<span class="spanforajaxedit" id="datevalue_'.$objp->rowid.
'">'.
dol_print_date($db->jdate($objp->dv),
"day").
"</span>";
1521 print
'<span class="inline-block">';
1522 print
'<a class="ajaxforbankoperationchange" href="'.$_SERVER[
'PHP_SELF'].
'?action=dvprev&account='.$objp->bankid.
'&rowid='.$objp->rowid.
'">';
1524 print
'<a class="ajaxforbankoperationchange" href="'.$_SERVER[
'PHP_SELF'].
'?action=dvnext&account='.$objp->bankid.
'&rowid='.$objp->rowid.
'">';
1529 $totalarray[
'nbfield']++;
1534 if (!empty($arrayfields[
'type'][
'checked'])) {
1535 print
'<td class="tdoverflowmax100 center">';
1536 $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);
1537 if ($labeltype ==
'SOLD') {
1544 $totalarray[
'nbfield']++;
1549 if (!empty($arrayfields[
'b.num_chq'][
'checked'])) {
1550 print
'<td class="nowrap" align="center">'.($objp->num_chq ?
dol_escape_htmltag($objp->num_chq) :
"").
"</td>\n";
1552 $totalarray[
'nbfield']++;
1557 if (!empty($arrayfields[
'bu.label'][
'checked'])) {
1558 print
'<td class="tdoverflowmax150">';
1560 $companylinked_id = 0;
1564 foreach ($links as $key => $value) {
1565 if ($links[$key][
'type'] ==
'payment_sc') {
1566 $type_link =
'payment_sc';
1568 if ($links[$key][
'type'] ==
'payment_salary') {
1569 $type_link =
'payment_salary';
1572 if ($links[$key][
'type'] ==
'company') {
1573 $companylinked_id = $links[$key][
'url_id'];
1575 if ($links[$key][
'type'] ==
'user') {
1576 $userlinked_id = $links[$key][
'url_id'];
1580 if ($companylinked_id) {
1582 $companystatic->fetch($companylinked_id);
1583 print $companystatic->getNomUrl(1);
1584 } elseif ($userlinked_id &&
1585 (($type_link ==
'payment_salary' && !empty($user->rights->salaries->read))
1586 || ($type_link ==
'payment_sc' && !empty($user->rights->tax->charges->lire)))) {
1588 if (!empty($conf->cache[
'user'][$userlinked_id])) {
1589 $tmpuser = $conf->cache[
'user'][$userlinked_id];
1591 $tmpuser =
new User($db);
1592 $tmpuser->fetch($userlinked_id);
1593 $conf->cache[
'user'][$userlinked_id] = $tmpuser;
1595 print $tmpuser->getNomUrl(1);
1602 $totalarray[
'nbfield']++;
1607 if (!empty($arrayfields[
'ba.ref'][
'checked'])) {
1608 print
'<td class="nowrap">';
1609 print $bankaccount->getNomUrl(1);
1612 $totalarray[
'nbfield']++;
1617 if (!empty($arrayfields[
'b.debit'][
'checked'])) {
1618 print
'<td class="nowrap right"><span class="amount">';
1619 if ($objp->amount < 0) {
1620 print
price($objp->amount * -1);
1621 $totalarray[
'totaldeb'] += $objp->amount;
1623 print
"</span></td>\n";
1625 $totalarray[
'nbfield']++;
1628 $totalarray[
'totaldebfield'] = $totalarray[
'nbfield'];
1633 if (!empty($arrayfields[
'b.credit'][
'checked'])) {
1634 print
'<td class="nowrap right"><span class="amount">';
1635 if ($objp->amount > 0) {
1636 print
price($objp->amount);
1637 $totalarray[
'totalcred'] += $objp->amount;
1639 print
"</span></td>\n";
1641 $totalarray[
'nbfield']++;
1644 $totalarray[
'totalcredfield'] = $totalarray[
'nbfield'];
1649 if (!empty($arrayfields[
'balancebefore'][
'checked'])) {
1650 if ($mode_balance_ok) {
1651 if ($balancebefore >= 0) {
1652 print
'<td class="nowrap right"> '.price($balancebefore).
'</td>';
1654 print
'<td class="error nowrap right"> '.price($balancebefore).
'</td>';
1657 print
'<td class="right">-</td>';
1660 $totalarray[
'nbfield']++;
1665 if (!empty($arrayfields[
'balance'][
'checked'])) {
1666 if ($mode_balance_ok) {
1667 if ($balance >= 0) {
1668 print
'<td class="nowrap right"> '.price($balance).
'</td>';
1670 print
'<td class="error nowrap right"> '.price($balance).
'</td>';
1673 print
'<td class="right">-</td>';
1676 $totalarray[
'nbfield']++;
1680 if (!empty($arrayfields[
'b.num_releve'][
'checked'])) {
1681 print
'<td class="nowraponall" align="center">';
1683 if ($bankaccount->canBeConciliated() > 0) {
1684 if ($objp->num_releve) {
1685 print
'<a href="releve.php?num='.urlencode($objp->num_releve).
'&account='.urlencode($objp->bankid).
'&save_lastsearch_values=1">'.
dol_escape_htmltag($objp->num_releve).
'</a>';
1687 if (!$objp->conciliated && $action ==
'reconcile') {
1688 if ($objp->num_releve) {
1691 print
'<input class="flat" name="rowid['.$objp->rowid.
']" type="checkbox" value="'.$objp->rowid.
'" size="1"'.(!empty($_POST[
'rowid'][$objp->rowid]) ?
' checked' :
'').
'>';
1696 $totalarray[
'nbfield']++;
1697 $posconciliatecol = $totalarray[
'nbfield'];
1701 if (!empty($arrayfields[
'b.conciliated'][
'checked'])) {
1702 print
'<td class="nowraponall" align="center">';
1703 print
yn($objp->conciliated);
1706 $totalarray[
'nbfield']++;
1710 if (!empty($arrayfields[
'b.fk_bordereau'][
'checked'])) {
1711 $bordereaustatic->fetch($objp->fk_bordereau);
1712 print
'<td class="nowraponall" align="center">';
1713 print $bordereaustatic->getNomUrl();
1716 $totalarray[
'nbfield']++;
1721 $parameters=array(
'arrayfields'=>$arrayfields,
'obj'=>$objp,
'i'=>$i,
'totalarray'=>&$totalarray);
1722 $reshook=$hookmanager->executeHooks(
'printFieldListValue', $parameters, $objecttmp);
1723 print $hookmanager->resPrint;
1726 print
'<td class="nowraponall" align="center">';
1728 if ($objp->conciliated && $bankaccount->canBeConciliated() > 0) {
1729 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/compta/bank/line.php?save_lastsearch_values=1&rowid='.$objp->rowid.($object->id > 0 ?
'&account='.$object->id :
'').
'&page='.$page.
'">';
1733 if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
1734 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/compta/bank/line.php?save_lastsearch_values=1&rowid='.$objp->rowid.($object->id > 0 ?
'&account='.$object->id :
'').
'&page='.$page.
'">';
1738 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/compta/bank/line.php?save_lastsearch_values=1&rowid='.$objp->rowid.($object->id > 0 ?
'&account='.$object->id :
'').
'&page='.$page.
'">';
1742 if ($bankaccount->canBeConciliated() > 0 && empty($objp->conciliated)) {
1743 if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) {
1744 print
' '.img_warning($langs->trans(
"ReconciliationLate"));
1747 if ($user->rights->banque->modifier) {
1748 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&rowid='.$objp->rowid.
'&page='.$page.$param.($sortfield ?
'&sortfield='.$sortfield :
'').($sortorder ?
'&sortorder='.$sortorder :
'').
'">';
1749 print
img_delete(
'',
'class="marginleftonly"');
1755 if ($massactionbutton || $massaction) {
1757 if (in_array($obj->rowid, $arrayofselected)) {
1760 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1764 $totalarray[
'nbfield']++;
1773 if (isset($totalarray[
'totaldebfield']) || isset($totalarray[
'totalcredfield'])) {
1774 print
'<tr class="liste_total">';
1776 while ($i < $totalarray[
'nbfield']) {
1779 if ($num < $limit && empty($offset)) {
1780 print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
1782 print
'<td class="left tdoverflowmax50" title="'.$langs->trans(
"Totalforthispage").
'">'.$langs->trans(
"Totalforthispage").
'</td>';
1784 } elseif ($totalarray[
'totaldebfield'] == $i) {
1785 print
'<td class="right"><span class="amount">'.price(-1 * $totalarray[
'totaldeb']).
'</span></td>';
1786 } elseif ($totalarray[
'totalcredfield'] == $i) {
1787 print
'<td class="right"><span class="amount">'.price($totalarray[
'totalcred']).
'</span></td>';
1788 } elseif ($i == $posconciliatecol) {
1789 print
'<td class="center">';
1790 if ($user->rights->banque->consolidate && $action ==
'reconcile') {
1791 print
'<input class="button" name="confirm_reconcile" type="submit" value="'.$langs->trans(
"Conciliate").
'">';
1804 foreach ($arrayfields as $key => $val) {
1805 if (!empty($val[
'checked'])) {
1809 print
'<tr><td colspan="'.($colspan + 1).
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';