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)";
600 $sql .=
" WHERE b.fk_account = ba.rowid";
601 $sql .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
602 if ($search_account > 0) {
603 $sql .=
" AND b.fk_account = ".((int) $search_account);
607 $sql .=
" AND b.dateo >= '".$db->idate($search_dt_start).
"'";
610 $sql .=
" AND b.dateo <= '".$db->idate($search_dt_end).
"'";
614 $sql .=
" AND b.datev >= '".$db->idate($search_dv_start).
"'";
617 $sql .=
" AND b.datev <= '".$db->idate($search_dv_end).
"'";
622 if ($search_req_nb) {
625 if ($search_num_releve) {
628 if ($search_conciliated !=
'' && $search_conciliated !=
'-1') {
629 $sql .=
" AND b.rappro = ".((int) $search_conciliated);
631 if ($search_fk_bordereau > 0) {
632 $sql .=
" AND b.fk_bordereau = " . ((int) $search_fk_bordereau);
634 if ($search_thirdparty_user) {
635 $sql.=
" AND (b.rowid IN ";
636 $sql.=
" ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX.
"bank_url AS bu";
637 $sql.=
" JOIN ".MAIN_DB_PREFIX.
"bank AS b2 ON b2.rowid = bu.fk_bank";
638 $sql.=
" JOIN ".MAIN_DB_PREFIX.
"user AS subUser ON (bu.type = 'user' AND bu.url_id = subUser.rowid)";
639 $sql.=
" WHERE ".
natural_search(array(
"subUser.firstname",
"subUser.lastname"), $search_thirdparty_user,
'', 1).
")";
641 $sql.=
" OR 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.
"societe AS subSoc ON (bu.type = 'company' AND bu.url_id = subSoc.rowid)";
645 $sql.=
" WHERE ".
natural_search(array(
"subSoc.nom"), $search_thirdparty_user,
'', 1);
648 if ($search_description) {
649 $search_description_to_use = $search_description;
650 $arrayoffixedlabels = array(
652 'CustomerInvoicePayment',
'CustomerInvoicePaymentBack',
653 'SupplierInvoicePayment',
'SupplierInvoicePaymentBack',
655 'ExpenseReportPayment',
656 'SocialContributionPayment',
657 'SubscriptionPayment',
660 foreach ($arrayoffixedlabels as $keyforlabel) {
661 $translatedlabel = $langs->transnoentitiesnoconv($keyforlabel);
662 if (preg_match(
'/'.$search_description.
'/i', $translatedlabel)) {
663 $search_description_to_use .=
"|".$keyforlabel;
669 if ($search_bid > 0) {
670 $sql .=
" AND b.rowid = l.lineid AND l.fk_categ = ".((int) $search_bid);
672 if (!empty($search_type)) {
673 $sql .=
" AND b.fk_type = '".$db->escape($search_type).
"'";
678 $sql .=
' AND b.amount <= 0';
680 if ($search_credit) {
682 $sql .=
' AND b.amount >= 0';
685 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
688 $parameters = array();
689 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
690 $sql .= $hookmanager->resPrint;
692 $sql .= $db->order($sortfield, $sortorder);
694 $nbtotalofrecords =
'';
696 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
697 $result = $db->query($sql);
698 $nbtotalofrecords = $db->num_rows($result);
699 $nbtotalofpages = ceil($nbtotalofrecords / $limit);
702 if (($id > 0 || !empty($ref)) && ((
string) $page ==
'')) {
705 $page = ($nbtotalofpages - 1);
706 $offset = $limit * $page;
711 if ($page >= $nbtotalofpages) {
713 $page = ($nbtotalofpages - 1);
714 $offset = $limit * $page;
722 if (empty($search_account)) {
723 $mode_balance_ok =
false;
726 if (!empty($search_ref)) {
727 $mode_balance_ok =
false;
729 if (!empty($search_description)) {
730 $mode_balance_ok =
false;
732 if (!empty($search_type)) {
733 $mode_balance_ok =
false;
735 if (!empty($search_debit)) {
736 $mode_balance_ok =
false;
738 if (!empty($search_credit)) {
739 $mode_balance_ok =
false;
741 if (!empty($search_thirdparty_user)) {
742 $mode_balance_ok =
false;
744 if ($search_conciliated !=
'' && $search_conciliated !=
'-1') {
745 $mode_balance_ok =
false;
747 if (!empty($search_num_releve)) {
748 $mode_balance_ok =
false;
750 if (!empty($search_fk_bordereau)) {
751 $mode_balance_ok =
false;
754 $sql .= $db->plimit($limit + 1, $offset);
756 dol_syslog(
'compta/bank/bankentries_list.php', LOG_DEBUG);
757 $resql = $db->query($sql);
759 $num = $db->num_rows(
$resql);
761 $arrayofselected = (!empty($toselect) && is_array($toselect)) ? $toselect : array();
764 $arrayofmassactions = array(
769 if (in_array($massaction, array(
'presend',
'predelete'))) {
770 $arrayofmassactions = array();
772 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
775 if ($action ==
'delete') {
776 $text = $langs->trans(
'ConfirmDeleteTransaction');
777 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&rowid='.
GETPOST(
"rowid",
'int'), $langs->trans(
'DeleteTransaction'), $text,
'confirm_delete',
null,
'', 1);
781 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'" name="search_form">'.
"\n";
782 if ($optioncss !=
'') {
783 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
785 print
'<input type="hidden" name="token" value="'.newToken().
'">';
786 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
787 print
'<input type="hidden" name="action" value="'.($action !=
'delete' ? $action :
'search').
'">';
789 print
'<input type="hidden" name="view" value="'.dol_escape_htmltag($view).
'">';
791 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
792 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
793 print
'<input type="hidden" name="page" value="'.$page.
'">';
794 print
'<input type="hidden" name="id" value="'.$id.
'">';
795 print
'<input type="hidden" name="ref" value="'.$ref.
'">';
797 print
'<input type="hidden" name="bid" value="'.GETPOST(
"bid",
'int').
'">';
801 if ($user->rights->banque->consolidate && $action ==
'reconcile') {
802 print
'<div class="valignmiddle inline-block" style="padding-right: 20px;">';
803 print
'<strong>'.$langs->trans(
"InputReceiptNumber").
'</strong>: ';
804 print
'<input class="flat" id="num_releve" name="num_releve" type="text" value="'.(GETPOST(
'num_releve') ?
GETPOST(
'num_releve') :
'').
'" size="10">';
806 if (is_array($options) && count($options)) {
807 print $langs->trans(
"EventualyAddCategory").
': ';
810 print
'<br><div style="margin-top: 5px;"><span class="opacitymedium">'.$langs->trans(
"ThenCheckLinesAndConciliate").
'</span> ';
811 print
'<input class="button" name="confirm_savestatement" type="submit" value="'.$langs->trans(
"SaveStatementOnly").
'">';
812 print
' '.$langs->trans(
"or").
' ';
813 print
'<input class="button" name="confirm_reconcile" type="submit" value="'.$langs->trans(
"Conciliate").
'">';
814 print
' '.$langs->trans(
"or").
' ';
815 print
'<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
821 $sql =
"SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX.
"bank";
822 $sql .=
" WHERE fk_account = ".((int) $object->id).
" AND num_releve IS NOT NULL";
823 $sql .= $db->order(
"num_releve",
"DESC");
824 $sql .= $db->plimit($nbmax + 1);
826 print $langs->trans(
"LastAccountStatements").
' : ';
827 $resqlr = $db->query($sql);
829 $numr = $db->num_rows($resqlr);
832 while (($i < $numr) && ($i < $nbmax)) {
833 $objr = $db->fetch_object($resqlr);
835 $last_releve = $objr->num_releve;
839 $liste =
'<a href="'.DOL_URL_ROOT.
'/compta/bank/releve.php?account='.$id.
'&num='.$objr->num_releve.
'">'.$objr->num_releve.
'</a> '.$liste;
841 if ($numr >= $nbmax) {
842 $liste =
"... ".$liste;
846 print
'<b>'.$langs->trans(
"None").
'</b>';
853 if (!empty($conf->global->BANK_REPORT_LAST_NUM_RELEVE)) {
855 <script type="text/javascript">
856 $("#num_releve").val("' . $last_releve.
'");
864 if (!empty($user->rights->banque->modifier) && $action ==
'addline' && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) {
867 print
'<table class="noborder centpercent">';
869 print
'<tr class="liste_titre">';
870 print
'<td>'.$langs->trans(
"Description").
'</td>';
871 print
'<td>'.$langs->trans(
"Date").
'</td>';
872 print
'<td> </td>';
873 print
'<td>'.$langs->trans(
"Type").
'</td>';
874 print
'<td>'.$langs->trans(
"Numero").
'</td>';
875 print
'<td class=right>'.$langs->trans(
"BankAccount").
'</td>';
876 print
'<td class=right>'.$langs->trans(
"Debit").
'</td>';
877 print
'<td class=right>'.$langs->trans(
"Credit").
'</td>';
884 print
'<td align="center"> </td>';
889 print
'<input name="label" class="flat minwidth200" type="text" value="'.GETPOST(
"label",
"alpha").
'">';
890 if (is_array($options) && count($options)) {
891 print
'<br>'.$langs->trans(
"Rubrique").
': ';
895 print
'<td class="nowrap">';
896 print
$form->selectDate(empty($dateop) ?-1 : $dateop,
'op', 0, 0, 0,
'transaction');
898 print
'<td> </td>';
899 print
'<td class="nowrap">';
903 print
'<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST(
"num_chq",
"alpha").
'">';
907 print
'<td class=right>';
908 $form->select_comptes(
GETPOST(
'add_account',
'int') ?
GETPOST(
'add_account',
'int') : $search_account,
'add_account', 0,
'', 1, ($id > 0 || !empty($ref) ?
' disabled="disabled"' :
''));
911 print
'<td class="right"><input name="adddebit" class="flat" type="text" size="4" value="'.GETPOST(
"adddebit",
"alpha").
'"></td>';
912 print
'<td class="right"><input name="addcredit" class="flat" type="text" size="4" value="'.GETPOST(
"addcredit",
"alpha").
'"></td>';
919 print
'<td class="center">';
920 print
'<input type="submit" name="save" class="button buttongen marginbottomonly button-add" value="'.$langs->trans(
"Add").
'"><br>';
921 print
'<input type="submit" name="cancel" class="button buttongen marginbottomonly button-cancel" value="'.$langs->trans(
"Cancel").
'">';
929 $urlajax = DOL_URL_ROOT.
'/core/ajax/bankconciliate.php?token='.
currentToken();
931 <script type="text/javascript">
933 $("a.ajaxforbankoperationchange").each(function(){
934 var current = $(this);
935 current.click(function()
937 var url = "'.$urlajax.
'&"+current.attr("href").split("?")[1];
938 $.get(url, function(data)
942 current.parent().parent().find(".spanforajaxedit").replaceWith(data);
957 if ($action !=
'addline' && $action !=
'reconcile') {
958 if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
959 if (empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) {
960 $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);
963 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddBankRecord'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?action=addline&token='.
newToken().
'&page='.$page.$param,
'', $user->rights->banque->modifier);
966 $newcardbutton =
dolGetButtonTitle($langs->trans(
'AddBankRecord'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?action=addline&token='.
newToken().
'&page='.$page.$param,
'', -1);
978 if ($action !=
'addline' && $action !=
'reconcile') {
979 $morehtml .= $buttonreconcile;
982 $morehtml .=
'<!-- Add New button -->'.$newcardbutton;
984 $picto =
'bank_account';
985 if ($id > 0 || !empty($ref)) {
989 print_barre_liste($langs->trans(
"BankTransactions"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml,
'', $limit, 0, 0, 1);
993 $param .=
'&page='.urlencode($page);
998 $moreforfilter .=
'<div class="divsearchfield">';
999 $moreforfilter .= $langs->trans(
'DateOperationShort');
1000 $moreforfilter .= ($conf->browser->layout ==
'phone' ?
'<br>' :
' ');
1001 $moreforfilter .=
'<div class="nowrap inline-block">';
1002 $moreforfilter .=
$form->selectDate($search_dt_start,
'search_start_dt', 0, 0, 1,
"search_form", 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1003 $moreforfilter .=
'</div>';
1004 $moreforfilter .= ($conf->browser->layout ==
'phone' ?
'' :
' ');
1005 $moreforfilter .=
'<div class="nowrap inline-block">';
1006 $moreforfilter .=
$form->selectDate($search_dt_end,
'search_end_dt', 0, 0, 1,
"search_form", 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1007 $moreforfilter .=
'</div>';
1008 $moreforfilter .=
'</div>';
1010 $moreforfilter .=
'<div class="divsearchfield">';
1011 $moreforfilter .= $langs->trans(
'DateValueShort');
1012 $moreforfilter .= ($conf->browser->layout ==
'phone' ?
'<br>' :
' ');
1013 $moreforfilter .=
'<div class="nowrap inline-block">';
1014 $moreforfilter .=
$form->selectDate($search_dv_start,
'search_start_dv', 0, 0, 1,
"search_form", 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1015 $moreforfilter .=
'</div>';
1016 $moreforfilter .= ($conf->browser->layout ==
'phone' ?
'' :
' ');
1017 $moreforfilter .=
'<div class="nowrap inline-block">';
1018 $moreforfilter .=
$form->selectDate($search_dv_end,
'search_end_dv', 0, 0, 1,
"search_form", 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1019 $moreforfilter .=
'</div>';
1020 $moreforfilter .=
'</div>';
1024 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
1025 $langs->load(
'categories');
1028 $moreforfilter .=
'<div class="divsearchfield">';
1029 $tmptitle = $langs->trans(
'RubriquesTransactions');
1030 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid,
'parent',
null,
null, 1);
1031 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_bid', $cate_arbo, $search_bid, $tmptitle, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1032 $moreforfilter .=
'</div>';
1036 $parameters = array();
1037 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
1038 if (empty($reshook)) {
1039 $moreforfilter .= $hookmanager->resPrint;
1041 $moreforfilter = $hookmanager->resPrint;
1044 if ($moreforfilter) {
1045 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1046 print $moreforfilter;
1047 print
'</div>'.
"\n";
1050 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1051 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
1053 if ($action ==
'reconcile') {
1054 $arrayfields[
'b.num_releve'][
'checked'] = 1;
1057 print
'<div class="div-table-responsive">';
1058 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1061 print
'<tr class="liste_titre_filter">';
1062 if (!empty($arrayfields[
'b.rowid'][
'checked'])) {
1063 print
'<td class="liste_titre">';
1064 print
'<input type="text" class="flat" name="search_ref" size="2" value="'.dol_escape_htmltag($search_ref).
'">';
1067 if (!empty($arrayfields[
'b.label'][
'checked'])) {
1068 print
'<td class="liste_titre">';
1069 print
'<input type="text" class="flat maxwidth100" name="search_description" value="'.dol_escape_htmltag($search_description).
'">';
1072 if (!empty($arrayfields[
'b.dateo'][
'checked'])) {
1073 print
'<td class="liste_titre"> </td>';
1075 if (!empty($arrayfields[
'b.datev'][
'checked'])) {
1076 print
'<td class="liste_titre"> </td>';
1078 if (!empty($arrayfields[
'type'][
'checked'])) {
1079 print
'<td class="liste_titre" align="center">';
1080 $form->select_types_paiements(empty($search_type) ?
'' : $search_type,
'search_type',
'', 2, 1, 1, 0, 1,
'maxwidth100');
1084 if (!empty($arrayfields[
'b.num_chq'][
'checked'])) {
1085 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>';
1088 if (!empty($arrayfields[
'bu.label'][
'checked'])) {
1089 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty_user).
'"></td>';
1092 if (!empty($arrayfields[
'ba.ref'][
'checked'])) {
1093 print
'<td class="liste_titre">';
1094 $form->select_comptes($search_account,
'search_account', 0,
'', 1, ($id > 0 || !empty($ref) ?
' disabled="disabled"' :
''), 0,
'maxwidth100');
1098 if (!empty($arrayfields[
'b.debit'][
'checked'])) {
1099 print
'<td class="liste_titre right">';
1100 print
'<input type="text" class="flat width50" name="search_debit" value="'.dol_escape_htmltag($search_debit).
'">';
1104 if (!empty($arrayfields[
'b.credit'][
'checked'])) {
1105 print
'<td class="liste_titre right">';
1106 print
'<input type="text" class="flat width50" name="search_credit" value="'.dol_escape_htmltag($search_credit).
'">';
1110 if (!empty($arrayfields[
'balancebefore'][
'checked'])) {
1111 print
'<td class="liste_titre right">';
1112 $htmltext = $langs->trans(
"BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv(
"DateValue"));
1113 print
$form->textwithpicto(
'', $htmltext, 1);
1117 if (!empty($arrayfields[
'balance'][
'checked'])) {
1118 print
'<td class="liste_titre right">';
1119 $htmltext = $langs->trans(
"BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv(
"DateValue"));
1120 print
$form->textwithpicto(
'', $htmltext, 1);
1124 if (!empty($arrayfields[
'b.num_releve'][
'checked'])) {
1125 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>';
1128 if (!empty($arrayfields[
'b.conciliated'][
'checked'])) {
1129 print
'<td class="liste_titre" align="center">';
1130 print
$form->selectyesno(
'search_conciliated', $search_conciliated, 1,
false, 1, 1);
1134 if (!empty($arrayfields[
'b.fk_bordereau'][
'checked'])) {
1135 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>';
1139 print
'<td class="liste_titre" align="middle">';
1140 $searchpicto =
$form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
1146 print
'<tr class="liste_titre">';
1147 if (!empty($arrayfields[
'b.rowid'][
'checked'])) {
1148 print_liste_field_titre($arrayfields[
'b.rowid'][
'label'], $_SERVER[
'PHP_SELF'],
'b.rowid',
'', $param,
'', $sortfield, $sortorder);
1150 if (!empty($arrayfields[
'b.label'][
'checked'])) {
1151 print_liste_field_titre($arrayfields[
'b.label'][
'label'], $_SERVER[
'PHP_SELF'],
'b.label',
'', $param,
'', $sortfield, $sortorder);
1153 if (!empty($arrayfields[
'b.dateo'][
'checked'])) {
1154 print_liste_field_titre($arrayfields[
'b.dateo'][
'label'], $_SERVER[
'PHP_SELF'],
'b.dateo',
'', $param,
'', $sortfield, $sortorder,
"center ");
1156 if (!empty($arrayfields[
'b.datev'][
'checked'])) {
1157 print_liste_field_titre($arrayfields[
'b.datev'][
'label'], $_SERVER[
'PHP_SELF'],
'b.datev,b.dateo,b.rowid',
'', $param,
'align="center"', $sortfield, $sortorder);
1159 if (!empty($arrayfields[
'type'][
'checked'])) {
1160 print_liste_field_titre($arrayfields[
'type'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'align="center"', $sortfield, $sortorder);
1162 if (!empty($arrayfields[
'b.num_chq'][
'checked'])) {
1163 print_liste_field_titre($arrayfields[
'b.num_chq'][
'label'], $_SERVER[
'PHP_SELF'],
'b.num_chq',
'', $param,
'', $sortfield, $sortorder,
"center ");
1165 if (!empty($arrayfields[
'bu.label'][
'checked'])) {
1166 print_liste_field_titre($arrayfields[
'bu.label'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
1168 if (!empty($arrayfields[
'ba.ref'][
'checked'])) {
1169 print_liste_field_titre($arrayfields[
'ba.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'ba.ref',
'', $param,
'', $sortfield, $sortorder);
1171 if (!empty($arrayfields[
'b.debit'][
'checked'])) {
1172 print_liste_field_titre($arrayfields[
'b.debit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
"right ");
1174 if (!empty($arrayfields[
'b.credit'][
'checked'])) {
1175 print_liste_field_titre($arrayfields[
'b.credit'][
'label'], $_SERVER[
'PHP_SELF'],
'b.amount',
'', $param,
'', $sortfield, $sortorder,
"right ");
1177 if (!empty($arrayfields[
'balancebefore'][
'checked'])) {
1178 print_liste_field_titre($arrayfields[
'balancebefore'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
"right ");
1180 if (!empty($arrayfields[
'balance'][
'checked'])) {
1181 print_liste_field_titre($arrayfields[
'balance'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
"right ");
1183 if (!empty($arrayfields[
'b.num_releve'][
'checked'])) {
1184 print_liste_field_titre($arrayfields[
'b.num_releve'][
'label'], $_SERVER[
'PHP_SELF'],
'b.num_releve',
'', $param,
'', $sortfield, $sortorder,
"center ");
1186 if (!empty($arrayfields[
'b.conciliated'][
'checked'])) {
1187 print_liste_field_titre($arrayfields[
'b.conciliated'][
'label'], $_SERVER[
'PHP_SELF'],
'b.rappro',
'', $param,
'', $sortfield, $sortorder,
"center ");
1189 if (!empty($arrayfields[
'b.fk_bordereau'][
'checked'])) {
1190 print_liste_field_titre($arrayfields[
'b.fk_bordereau'][
'label'], $_SERVER[
'PHP_SELF'],
'b.fk_bordereau',
'', $param,
'', $sortfield, $sortorder,
"center ");
1194 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1196 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1197 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
1198 print $hookmanager->resPrint;
1200 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
1205 $balancecalculated =
false;
1206 $posconciliatecol = 0;
1207 $cachebankaccount = array();
1212 while ($i < min($num, $limit)) {
1213 $objp = $db->fetch_object(
$resql);
1214 $links = $bankaccountstatic->get_url($objp->rowid);
1217 if (!$balancecalculated && (!empty($arrayfields[
'balancebefore'][
'checked']) || !empty($arrayfields[
'balance'][
'checked'])) && ($mode_balance_ok || $search_conciliated ===
'0')) {
1218 if (!$search_account) {
1219 dol_print_error(
'',
'account is not defined but $mode_balance_ok is true');
1226 $sqlforbalance =
'SELECT SUM(b.amount) as previoustotal';
1227 $sqlforbalance .=
" FROM ";
1228 $sqlforbalance .=
" ".MAIN_DB_PREFIX.
"bank_account as ba,";
1229 $sqlforbalance .=
" ".MAIN_DB_PREFIX.
"bank as b";
1230 $sqlforbalance .=
" WHERE b.fk_account = ba.rowid";
1231 $sqlforbalance .=
" AND ba.entity IN (".getEntity(
'bank_account').
")";
1232 $sqlforbalance .=
" AND b.fk_account = ".((int) $search_account);
1233 $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.
"))))";
1234 $resqlforbalance = $db->query($sqlforbalance);
1236 if ($resqlforbalance) {
1237 $objforbalance = $db->fetch_object($resqlforbalance);
1238 if ($objforbalance) {
1240 if ($sortfield ==
'b.datev,b.dateo,b.rowid' && ($sortorder ==
'desc' || $sortorder ==
'desc,desc' || $sortorder ==
'desc,desc,desc')) {
1241 $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount);
1244 $balance = $objforbalance->previoustotal;
1251 $balancecalculated =
true;
1254 if ($user->rights->banque->consolidate && $action ==
'reconcile') {
1255 $tmpnbfieldbeforebalance = 0;
1256 $tmpnbfieldafterbalance = 0;
1257 $balancefieldfound = 0;
1258 foreach ($arrayfields as $key => $val) {
1259 if ($key ==
'balancebefore' || $key ==
'balance') {
1260 $balancefieldfound++;
1263 if (!empty($arrayfields[$key][
'checked'])) {
1264 if (!$balancefieldfound) {
1265 $tmpnbfieldbeforebalance++;
1267 $tmpnbfieldafterbalance++;
1272 $element =
'banktransaction';
1273 if (is_array($extrafields->attributes[$element][
'label']) && count($extrafields->attributes[$element][
'label'])) {
1274 foreach ($extrafields->attributes[$element][
'label'] as $key => $val) {
1275 if (!empty($arrayfields[
"ef.".$key][
'checked'])) {
1276 if (!empty($arrayfields[$key][
'checked'])) {
1277 if (!$balancefieldfound) {
1278 $tmpnbfieldbeforebalance++;
1280 $tmpnbfieldafterbalance++;
1287 print
'<tr class="oddeven trforbreak">';
1288 if ($tmpnbfieldbeforebalance) {
1289 print
'<td colspan="'.$tmpnbfieldbeforebalance.
'">';
1294 if (!empty($arrayfields[
'balancebefore'][
'checked'])) {
1295 print
'<td class="right">';
1296 if ($search_conciliated !==
'0') {
1301 if (!empty($arrayfields[
'balance'][
'checked'])) {
1302 print
'<td class="right">';
1303 if ($search_conciliated !==
'0') {
1308 if (!empty($arrayfields[
'b.num_releve'][
'checked'])) {
1309 print
'<td class="center">';
1310 print
'<input type="checkbox" id="selectAll" title="'.dol_escape_htmltag($langs->trans(
"SelectAll")).
'" />';
1311 print
' <script type="text/javascript">
1312 $("input#selectAll").change(function() {
1313 $("input[type=checkbox][name^=rowid]").prop("checked", $(this).is(":checked"));
1318 print
'<td colspan="'.($tmpnbfieldafterbalance + 1).
'">';
1325 if ($sortfield ==
'b.datev,b.dateo,b.rowid' && ($sortorder ==
'desc' || $sortorder ==
'desc,desc' || $sortorder ==
'desc,desc,desc')) {
1326 $balance =
price2num($balancebefore,
'MT');
1327 $balancebefore =
price2num($balancebefore - ($sign * $objp->amount),
'MT');
1329 $balancebefore =
price2num($balance,
'MT');
1330 $balance =
price2num($balance + ($sign * $objp->amount),
'MT');
1333 if (empty($cachebankaccount[$objp->bankid])) {
1334 $bankaccounttmp =
new Account($db);
1335 $bankaccounttmp->fetch($objp->bankid);
1336 $cachebankaccount[$objp->bankid] = $bankaccounttmp;
1337 $bankaccount = $bankaccounttmp;
1339 $bankaccount = $cachebankaccount[$objp->bankid];
1342 if (empty($conf->global->BANK_COLORIZE_MOVEMENT)) {
1343 $backgroundcolor =
"class='oddeven'";
1345 if ($objp->amount < 0) {
1347 $backgroundcolor =
'style="background: '.$color.
';"';
1350 $backgroundcolor =
'style="background: '.$color.
';"';
1354 $banklinestatic->id = $objp->rowid;
1355 $banklinestatic->ref = $objp->rowid;
1357 print
'<tr class="oddeven" '.$backgroundcolor.
'>';
1360 if (!empty($arrayfields[
'b.rowid'][
'checked'])) {
1361 print
'<td class="nowrap left">';
1362 print $banklinestatic->getNomUrl(1);
1365 $totalarray[
'nbfield']++;
1370 if (!empty($arrayfields[
'b.label'][
'checked'])) {
1374 preg_match(
'/\((.+)\)/i', $objp->label, $reg);
1375 if (!empty($reg[1]) && $langs->trans($reg[1]) != $reg[1]) {
1376 $labeltoshow = $langs->trans($reg[1]);
1378 if ($objp->label ==
'(payment_salary)') {
1379 $labeltoshow = $langs->trans(
"SalaryPayment");
1382 $titletoshow = $objp->label;
1387 print
'<td class="tdoverflowmax250"'.($titletoshow ?
' title="'.dol_escape_htmltag($titletoshow).
'"' :
'').
'>';
1390 $cachebankaccount = array();
1391 foreach ($links as $key => $val) {
1392 print
'<!-- '.$links[$key][
'type'].
' -->';
1393 if ($links[$key][
'type'] ==
'withdraw') {
1394 $banktransferstatic->id = $links[$key][
'url_id'];
1395 $banktransferstatic->ref = $links[$key][
'label'];
1396 print $banktransferstatic->getNomUrl(0).
' ';
1397 } elseif ($links[$key][
'type'] ==
'payment') {
1398 $paymentstatic->id = $links[$key][
'url_id'];
1399 $paymentstatic->ref = $links[$key][
'url_id'];
1400 $paymentstatic->date = $db->jdate($objp->do);
1401 print $paymentstatic->getNomUrl(2).
' ';
1402 } elseif ($links[$key][
'type'] ==
'payment_supplier') {
1403 $paymentsupplierstatic->id = $links[$key][
'url_id'];
1404 $paymentsupplierstatic->ref = $links[$key][
'url_id'];
1405 print $paymentsupplierstatic->getNomUrl(2).
' ';
1406 } elseif ($links[$key][
'type'] ==
'payment_sc') {
1407 $paymentscstatic->id = $links[$key][
'url_id'];
1408 $paymentscstatic->ref = $links[$key][
'url_id'];
1409 $paymentscstatic->label = $links[$key][
'label'];
1410 print $paymentscstatic->getNomUrl(2).
' ';
1411 } elseif ($links[$key][
'type'] ==
'payment_vat') {
1412 $paymentvatstatic->id = $links[$key][
'url_id'];
1413 $paymentvatstatic->ref = $links[$key][
'url_id'];
1414 print $paymentvatstatic->getNomUrl(2).
' ';
1415 } elseif ($links[$key][
'type'] ==
'payment_salary') {
1416 $paymentsalstatic->id = $links[$key][
'url_id'];
1417 $paymentsalstatic->ref = $links[$key][
'url_id'];
1418 $paymentsalstatic->label = $links[$key][
'label'];
1419 print $paymentsalstatic->getNomUrl(2).
' ';
1420 } elseif ($links[$key][
'type'] ==
'payment_loan') {
1421 print
'<a href="'.DOL_URL_ROOT.
'/loan/payment/card.php?id='.$links[$key][
'url_id'].
'">';
1422 print
' '.img_object($langs->trans(
'ShowPayment'),
'payment').
' ';
1424 } elseif ($links[$key][
'type'] ==
'payment_donation') {
1425 $paymentdonationstatic->id = $links[$key][
'url_id'];
1426 $paymentdonationstatic->ref = $links[$key][
'url_id'];
1427 print $paymentdonationstatic->getNomUrl(2).
' ';
1428 } elseif ($links[$key][
'type'] ==
'payment_expensereport') {
1429 $paymentexpensereportstatic->id = $links[$key][
'url_id'];
1430 $paymentexpensereportstatic->ref = $links[$key][
'url_id'];
1431 print $paymentexpensereportstatic->getNomUrl(2).
' ';
1432 } elseif ($links[$key][
'type'] ==
'payment_various') {
1433 $paymentvariousstatic->id = $links[$key][
'url_id'];
1434 $paymentvariousstatic->ref = $links[$key][
'url_id'];
1435 print $paymentvariousstatic->getNomUrl(2).
' ';
1436 } elseif ($links[$key][
'type'] ==
'banktransfert') {
1438 if ($objp->amount > 0) {
1439 $banklinestatic->fetch($links[$key][
'url_id']);
1440 $bankstatic->id = $banklinestatic->fk_account;
1441 $bankstatic->label = $banklinestatic->bank_account_ref;
1442 print $langs->trans(
"TransferFrom").
' ';
1443 print $bankstatic->getNomUrl(1,
'transactions');
1444 print
' '.$langs->trans(
"toward").
' ';
1445 $bankstatic->id = $objp->bankid;
1446 $bankstatic->label = $objp->bankref;
1447 print $bankstatic->getNomUrl(1,
'');
1450 $bankstatic->id = $objp->bankid;
1451 $bankstatic->label = $objp->bankref;
1452 print $langs->trans(
"TransferFrom").
' ';
1453 print $bankstatic->getNomUrl(1,
'');
1454 print
' '.$langs->trans(
"toward").
' ';
1455 $banklinestatic->fetch($links[$key][
'url_id']);
1456 $bankstatic->id = $banklinestatic->fk_account;
1457 $bankstatic->label = $banklinestatic->bank_account_ref;
1458 print $bankstatic->getNomUrl(1,
'transactions');
1462 } elseif ($links[$key][
'type'] ==
'company') {
1463 } elseif ($links[$key][
'type'] ==
'user') {
1464 } elseif ($links[$key][
'type'] ==
'member') {
1465 } elseif ($links[$key][
'type'] ==
'sc') {
1466 } elseif ($links[$key][
'type'] ==
'vat') {
1467 } elseif ($links[$key][
'type'] ==
'salary') {
1471 print
'<a href="'.$links[$key][
'url'].$links[$key][
'url_id'].
'">';
1472 if (preg_match(
'/^\((.*)\)$/i', $links[$key][
'label'], $reg)) {
1474 if ($reg[1] ==
'paiement') {
1475 $reg[1] =
'Payment';
1477 print $langs->trans($reg[1]);
1479 print $links[$key][
'label'];
1481 print
'</a>'.($labeltoshow ?
' - ' :
'');
1489 $totalarray[
'nbfield']++;
1494 if (!empty($arrayfields[
'b.dateo'][
'checked'])) {
1495 print
'<td align="center" class="nowrap">';
1496 print
'<span class="spanforajaxedit" id="dateoperation_'.$objp->rowid.
'">'.
dol_print_date($db->jdate($objp->do),
"day").
"</span>";
1498 print
'<span class="inline-block">';
1499 print
'<a class="ajaxforbankoperationchange" href="'.$_SERVER[
'PHP_SELF'].
'?action=doprev&account='.$objp->bankid.
'&rowid='.$objp->rowid.
'">';
1501 print
'<a class="ajaxforbankoperationchange" href="'.$_SERVER[
'PHP_SELF'].
'?action=donext&account='.$objp->bankid.
'&rowid='.$objp->rowid.
'">';
1506 $totalarray[
'nbfield']++;
1511 if (!empty($arrayfields[
'b.datev'][
'checked'])) {
1512 print
'<td align="center" class="nowrap">';
1513 print
'<span class="spanforajaxedit" id="datevalue_'.$objp->rowid.
'">'.
dol_print_date($db->jdate($objp->dv),
"day").
"</span>";
1515 print
'<span class="inline-block">';
1516 print
'<a class="ajaxforbankoperationchange" href="'.$_SERVER[
'PHP_SELF'].
'?action=dvprev&account='.$objp->bankid.
'&rowid='.$objp->rowid.
'">';
1518 print
'<a class="ajaxforbankoperationchange" href="'.$_SERVER[
'PHP_SELF'].
'?action=dvnext&account='.$objp->bankid.
'&rowid='.$objp->rowid.
'">';
1523 $totalarray[
'nbfield']++;
1528 if (!empty($arrayfields[
'type'][
'checked'])) {
1529 print
'<td class="tdoverflowmax100 center">';
1530 $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);
1531 if ($labeltype ==
'SOLD') {
1538 $totalarray[
'nbfield']++;
1543 if (!empty($arrayfields[
'b.num_chq'][
'checked'])) {
1544 print
'<td class="nowrap" align="center">'.($objp->num_chq ?
dol_escape_htmltag($objp->num_chq) :
"").
"</td>\n";
1546 $totalarray[
'nbfield']++;
1551 if (!empty($arrayfields[
'bu.label'][
'checked'])) {
1552 print
'<td class="tdoverflowmax150">';
1554 $companylinked_id = 0;
1558 foreach ($links as $key => $value) {
1559 if ($links[$key][
'type'] ==
'payment_sc') {
1560 $type_link =
'payment_sc';
1562 if ($links[$key][
'type'] ==
'payment_salary') {
1563 $type_link =
'payment_salary';
1566 if ($links[$key][
'type'] ==
'company') {
1567 $companylinked_id = $links[$key][
'url_id'];
1569 if ($links[$key][
'type'] ==
'user') {
1570 $userlinked_id = $links[$key][
'url_id'];
1574 if ($companylinked_id) {
1576 $companystatic->fetch($companylinked_id);
1577 print $companystatic->getNomUrl(1);
1578 } elseif ($userlinked_id &&
1579 (($type_link ==
'payment_salary' && !empty($user->rights->salaries->read))
1580 || ($type_link ==
'payment_sc' && !empty($user->rights->tax->charges->lire)))) {
1582 if (!empty($conf->cache[
'user'][$userlinked_id])) {
1583 $tmpuser = $conf->cache[
'user'][$userlinked_id];
1585 $tmpuser =
new User($db);
1586 $tmpuser->fetch($userlinked_id);
1587 $conf->cache[
'user'][$userlinked_id] = $tmpuser;
1589 print $tmpuser->getNomUrl(1);
1596 $totalarray[
'nbfield']++;
1601 if (!empty($arrayfields[
'ba.ref'][
'checked'])) {
1602 print
'<td class="nowrap">';
1603 print $bankaccount->getNomUrl(1);
1606 $totalarray[
'nbfield']++;
1611 if (!empty($arrayfields[
'b.debit'][
'checked'])) {
1612 print
'<td class="nowrap right"><span class="amount">';
1613 if ($objp->amount < 0) {
1614 print
price($objp->amount * -1);
1615 $totalarray[
'totaldeb'] += $objp->amount;
1617 print
"</span></td>\n";
1619 $totalarray[
'nbfield']++;
1622 $totalarray[
'totaldebfield'] = $totalarray[
'nbfield'];
1627 if (!empty($arrayfields[
'b.credit'][
'checked'])) {
1628 print
'<td class="nowrap right"><span class="amount">';
1629 if ($objp->amount > 0) {
1630 print
price($objp->amount);
1631 $totalarray[
'totalcred'] += $objp->amount;
1633 print
"</span></td>\n";
1635 $totalarray[
'nbfield']++;
1638 $totalarray[
'totalcredfield'] = $totalarray[
'nbfield'];
1643 if (!empty($arrayfields[
'balancebefore'][
'checked'])) {
1644 if ($mode_balance_ok) {
1645 if ($balancebefore >= 0) {
1646 print
'<td class="nowrap right"> '.price($balancebefore).
'</td>';
1648 print
'<td class="error nowrap right"> '.price($balancebefore).
'</td>';
1651 print
'<td class="right">-</td>';
1654 $totalarray[
'nbfield']++;
1659 if (!empty($arrayfields[
'balance'][
'checked'])) {
1660 if ($mode_balance_ok) {
1661 if ($balance >= 0) {
1662 print
'<td class="nowrap right"> '.price($balance).
'</td>';
1664 print
'<td class="error nowrap right"> '.price($balance).
'</td>';
1667 print
'<td class="right">-</td>';
1670 $totalarray[
'nbfield']++;
1674 if (!empty($arrayfields[
'b.num_releve'][
'checked'])) {
1675 print
'<td class="nowraponall" align="center">';
1677 if ($bankaccount->canBeConciliated() > 0) {
1678 if ($objp->num_releve) {
1679 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>';
1681 if (!$objp->conciliated && $action ==
'reconcile') {
1682 if ($objp->num_releve) {
1685 print
'<input class="flat" name="rowid['.$objp->rowid.
']" type="checkbox" value="'.$objp->rowid.
'" size="1"'.(!empty($_POST[
'rowid'][$objp->rowid]) ?
' checked' :
'').
'>';
1690 $totalarray[
'nbfield']++;
1691 $posconciliatecol = $totalarray[
'nbfield'];
1695 if (!empty($arrayfields[
'b.conciliated'][
'checked'])) {
1696 print
'<td class="nowraponall" align="center">';
1697 print
yn($objp->conciliated);
1700 $totalarray[
'nbfield']++;
1704 if (!empty($arrayfields[
'b.fk_bordereau'][
'checked'])) {
1705 $bordereaustatic->fetch($objp->fk_bordereau);
1706 print
'<td class="nowraponall" align="center">';
1707 print $bordereaustatic->getNomUrl();
1710 $totalarray[
'nbfield']++;
1715 print
'<td class="nowraponall" align="center">';
1717 if ($objp->conciliated && $bankaccount->canBeConciliated() > 0) {
1718 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.
'">';
1722 if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
1723 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.
'">';
1727 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.
'">';
1731 if ($bankaccount->canBeConciliated() > 0 && empty($objp->conciliated)) {
1732 if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) {
1733 print
' '.img_warning($langs->trans(
"ReconciliationLate"));
1736 if ($user->rights->banque->modifier) {
1737 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&rowid='.$objp->rowid.
'&page='.$page.$param.($sortfield ?
'&sortfield='.$sortfield :
'').($sortorder ?
'&sortorder='.$sortorder :
'').
'">';
1738 print
img_delete(
'',
'class="marginleftonly"');
1744 if ($massactionbutton || $massaction) {
1746 if (in_array($obj->rowid, $arrayofselected)) {
1749 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1753 $totalarray[
'nbfield']++;
1762 if (isset($totalarray[
'totaldebfield']) || isset($totalarray[
'totalcredfield'])) {
1763 print
'<tr class="liste_total">';
1765 while ($i < $totalarray[
'nbfield']) {
1768 if ($num < $limit && empty($offset)) {
1769 print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
1771 print
'<td class="left tdoverflowmax50" title="'.$langs->trans(
"Totalforthispage").
'">'.$langs->trans(
"Totalforthispage").
'</td>';
1773 } elseif ($totalarray[
'totaldebfield'] == $i) {
1774 print
'<td class="right"><span class="amount">'.price(-1 * $totalarray[
'totaldeb']).
'</span></td>';
1775 } elseif ($totalarray[
'totalcredfield'] == $i) {
1776 print
'<td class="right"><span class="amount">'.price($totalarray[
'totalcred']).
'</span></td>';
1777 } elseif ($i == $posconciliatecol) {
1778 print
'<td class="center">';
1779 if ($user->rights->banque->consolidate && $action ==
'reconcile') {
1780 print
'<input class="button" name="confirm_reconcile" type="submit" value="'.$langs->trans(
"Conciliate").
'">';
1793 foreach ($arrayfields as $key => $val) {
1794 if (!empty($val[
'checked'])) {
1798 print
'<tr><td colspan="'.($colspan + 1).
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';