dolibarr 21.0.0-beta
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2009 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
31require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
32
41// Load translation files required by the page
42$langs->loadLangs(array('banks', 'categories', 'compta', 'bills'));
43
44$checkdepositstatic = new RemiseCheque($db);
45$accountstatic = new Account($db);
46
47// Security check
48if ($user->socid) {
49 $socid = $user->socid;
50}
51$result = restrictedArea($user, 'banque', '', '');
52
53$usercancreate = $user->hasRight('banque', 'cheque');
54
55// List of payment mode to support
56// Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA'
57$arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ'));
58
59
60/*
61 * Actions
62 */
63
64// None
65
66
67/*
68 * View
69 */
70
71if (getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ') == 'CHQ') {
72 $title = $langs->trans("ChequesArea");
73} else {
74 $title = $langs->trans("DocumentsDepositArea");
75}
76
77llxHeader('', $title);
78
79$newcardbutton = '';
80if ($usercancreate) {
81 $newcardbutton .= dolGetButtonTitle($langs->trans('NewDeposit'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new');
82}
83
84print load_fiche_titre($title, $newcardbutton, $checkdepositstatic->picto);
85
86print '<div class="fichecenter"><div class="fichethirdleft">';
87
88print '<div class="div-table-responsive-no-min">';
89print '<table class="noborder centpercent">';
90print '<tr class="liste_titre">';
91print '<th colspan="2">'.$langs->trans("DocumentsForDeposit")."</th>\n";
92print "</tr>\n";
93
94foreach ($arrayofpaymentmodetomanage as $val) {
95 $sql = "SELECT count(b.rowid) as nb";
96 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
97 $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
98 $sql .= " WHERE ba.rowid = b.fk_account";
99 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
100 $sql .= " AND b.fk_type = '".$db->escape($val)."'";
101 $sql .= " AND b.fk_bordereau = 0";
102 $sql .= " AND b.amount > 0";
103
104 $resql = $db->query($sql);
105 if ($resql) {
106 $num = '';
107 if ($obj = $db->fetch_object($resql)) {
108 $num = $obj->nb;
109 }
110 print '<tr class="oddeven">';
111 print '<td>';
112 if ($val == 'CHQ') {
113 print $langs->trans("BankChecks");
114 } else {
115 print($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $langs->trans("PaymentMode").' '.$val);
116 }
117 print '</td>';
118 print '<td class="right">';
119 print '<a class="badge badge-info" href="'.DOL_URL_ROOT.'/compta/paiement/cheque/card.php?leftmenu=customers_bills_checks&action=new&type='.urlencode($val).'">'.dol_escape_htmltag($num).'</a>';
120 print '</td></tr>';
121 } else {
122 dol_print_error($db);
123 }
124}
125
126print "</table></div>\n";
127
128
129print '</div><div class="fichetwothirdright">';
130
131$max = 10;
132
133foreach ($arrayofpaymentmodetomanage as $val) {
134 $sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref,";
135 $sql .= " bc.statut as status, bc.nbcheque, bc.type,";
136 $sql .= " ba.ref as bref, ba.label, ba.rowid as bid, ba.number, ba.currency_code, ba.account_number, ba.fk_accountancy_journal,";
137 $sql .= " aj.code";
138 $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc, ".MAIN_DB_PREFIX."bank_account as ba";
139 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal";
140 $sql .= " WHERE ba.rowid = bc.fk_bank_account";
141 $sql .= " AND bc.entity = ".((int) $conf->entity);
142 $sql .= " AND bc.type = '".$db->escape($val)."'";
143 $sql .= " ORDER BY bc.date_bordereau DESC, rowid DESC";
144 $sql .= $db->plimit($max);
145
146 $resql = $db->query($sql);
147 if ($resql) {
148 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
149 print '<table class="noborder centpercent">';
150 print '<tr class="liste_titre">';
151 print '<th>';
152 if ($val == 'CHQ') {
153 print $langs->trans("LastCheckReceiptShort", $max);
154 } else {
155 $labelpaymentmode = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val);
156 print $langs->trans("LastPaymentForDepositShort", $max, $labelpaymentmode);
157 }
158 print '</th>';
159 print '<th>'.$langs->trans("Date")."</th>";
160 print '<th>'.$langs->trans("BankAccount").'</th>';
161 print '<th class="right">'.$langs->trans("NbOfCheques").'</th>';
162 print '<th class="right">'.$langs->trans("Amount").'</th>';
163 print '<th class="right">'.$langs->trans("Status").'</th>';
164 print "</tr>\n";
165
166 $i = 0;
167 while ($objp = $db->fetch_object($resql)) {
168 $i++;
169
170 $checkdepositstatic->id = $objp->rowid;
171 $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
172 $checkdepositstatic->statut = $objp->status;
173 $checkdepositstatic->status = $objp->status;
174
175 $accountstatic->id = $objp->bid;
176 $accountstatic->ref = $objp->bref;
177 $accountstatic->label = $objp->label;
178 $accountstatic->number = $objp->number;
179 $accountstatic->currency_code = $objp->currency_code;
180 $accountstatic->account_number = $objp->account_number;
181 $accountstatic->accountancy_journal = $objp->code;
182 $accountstatic->fk_accountancy_journal = $objp->fk_accountancy_journal;
183
184 print '<tr class="oddeven">'."\n";
185
186 print '<td class="nowraponall">'.$checkdepositstatic->getNomUrl(1).'</td>';
187 print '<td>'.dol_print_date($db->jdate($objp->db), 'day').'</td>';
188 print '<td class="nowraponall">'.$accountstatic->getNomUrl(1).'</td>';
189 print '<td class="right">'.dol_escape_htmltag($objp->nbcheque).'</td>';
190 print '<td class="right"><span class="amount nowraponall">'.price($objp->amount).'</span></td>';
191 print '<td class="right">'.$checkdepositstatic->LibStatut($objp->status, 3).'</td>';
192
193 print '</tr>';
194 }
195 if ($i == 0) {
196 print '<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
197 }
198
199 print "</table>";
200 print '</div>';
201
202 $db->free($resql);
203 } else {
204 dol_print_error($db);
205 }
206}
207
208print '</div></div>';
209
210// End of page
211llxFooter();
212$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage bank accounts.
Class to manage cheque delivery receipts.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.