dolibarr  19.0.0-dev
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  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 // Load Dolibarr environment
28 require '../../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
31 
32 // Load translation files required by the page
33 $langs->loadLangs(array('banks', 'categories', 'compta', 'bills'));
34 
35 $checkdepositstatic = new RemiseCheque($db);
36 $accountstatic = new Account($db);
37 
38 // Security check
39 if ($user->socid) {
40  $socid = $user->socid;
41 }
42 $result = restrictedArea($user, 'banque', '', '');
43 
44 $usercancreate = $user->hasRight('banque', 'cheque');
45 
46 // List of payment mode to support
47 // Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA'
48 $arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ'));
49 
50 
51 /*
52  * Actions
53  */
54 
55 // None
56 
57 
58 /*
59  * View
60  */
61 
62 if (getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ') == 'CHQ') {
63  $title = $langs->trans("ChequesArea");
64 } else {
65  $title = $langs->trans("DocumentsDepositArea");
66 }
67 
68 llxHeader('', $title);
69 
70 $newcardbutton = '';
71 if ($usercancreate) {
72  $newcardbutton .= dolGetButtonTitle($langs->trans('NewDeposit'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new');
73 }
74 
75 print load_fiche_titre($title, $newcardbutton, $checkdepositstatic->picto);
76 
77 print '<div class="fichecenter"><div class="fichethirdleft">';
78 
79 print '<div class="div-table-responsive-no-min">';
80 print '<table class="noborder centpercent">';
81 print '<tr class="liste_titre">';
82 print '<th colspan="2">'.$langs->trans("DocumentsForDeposit")."</th>\n";
83 print "</tr>\n";
84 
85 foreach ($arrayofpaymentmodetomanage as $val) {
86  $sql = "SELECT count(b.rowid) as nb";
87  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
88  $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
89  $sql .= " WHERE ba.rowid = b.fk_account";
90  $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
91  $sql .= " AND b.fk_type = '".$db->escape($val)."'";
92  $sql .= " AND b.fk_bordereau = 0";
93  $sql .= " AND b.amount > 0";
94 
95  $resql = $db->query($sql);
96  if ($resql) {
97  $num = '';
98  if ($obj = $db->fetch_object($resql)) {
99  $num = $obj->nb;
100  }
101  print '<tr class="oddeven">';
102  print '<td>';
103  if ($val == 'CHQ') {
104  print $langs->trans("BankChecks");
105  } else {
106  print ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $langs->trans("PaymentMode").' '.$val);
107  }
108  print '</td>';
109  print '<td class="right">';
110  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>';
111  print '</td></tr>';
112  } else {
113  dol_print_error($db);
114  }
115 }
116 
117 print "</table></div>\n";
118 
119 
120 print '</div><div class="fichetwothirdright">';
121 
122 $max = 10;
123 
124 foreach ($arrayofpaymentmodetomanage as $val) {
125  $sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref,";
126  $sql .= " bc.statut as status, bc.nbcheque, bc.type,";
127  $sql .= " ba.ref as bref, ba.label, ba.rowid as bid, ba.number, ba.currency_code, ba.account_number, ba.fk_accountancy_journal,";
128  $sql .= " aj.code";
129  $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc, ".MAIN_DB_PREFIX."bank_account as ba";
130  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal";
131  $sql .= " WHERE ba.rowid = bc.fk_bank_account";
132  $sql .= " AND bc.entity = ".((int) $conf->entity);
133  $sql .= " AND bc.type = '".$db->escape($val)."'";
134  $sql .= " ORDER BY bc.date_bordereau DESC, rowid DESC";
135  $sql .= $db->plimit($max);
136 
137  $resql = $db->query($sql);
138  if ($resql) {
139  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
140  print '<table class="noborder centpercent">';
141  print '<tr class="liste_titre">';
142  print '<th>';
143  if ($val == 'CHQ') {
144  print $langs->trans("LastCheckReceiptShort", $max);
145  } else {
146  $labelpaymentmode = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val);
147  print $langs->trans("LastPaymentForDepositShort", $max, $labelpaymentmode);
148  }
149  print '</th>';
150  print '<th>'.$langs->trans("Date")."</th>";
151  print '<th>'.$langs->trans("Account").'</th>';
152  print '<th class="right">'.$langs->trans("NbOfCheques").'</th>';
153  print '<th class="right">'.$langs->trans("Amount").'</th>';
154  print '<th class="right">'.$langs->trans("Status").'</th>';
155  print "</tr>\n";
156 
157  $i = 0;
158  while ($objp = $db->fetch_object($resql)) {
159  $i++;
160 
161  $checkdepositstatic->id = $objp->rowid;
162  $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
163  $checkdepositstatic->statut = $objp->status;
164  $checkdepositstatic->status = $objp->status;
165 
166  $accountstatic->id = $objp->bid;
167  $accountstatic->ref = $objp->bref;
168  $accountstatic->label = $objp->label;
169  $accountstatic->number = $objp->number;
170  $accountstatic->currency_code = $objp->currency_code;
171  $accountstatic->account_number = $objp->account_number;
172  $accountstatic->accountancy_journal = $objp->code;
173  $accountstatic->fk_accountancy_journal = $objp->fk_accountancy_journal;
174 
175  print '<tr class="oddeven">'."\n";
176 
177  print '<td class="nowraponall">'.$checkdepositstatic->getNomUrl(1).'</td>';
178  print '<td>'.dol_print_date($db->jdate($objp->db), 'day').'</td>';
179  print '<td class="nowraponall">'.$accountstatic->getNomUrl(1).'</td>';
180  print '<td class="right">'.$objp->nbcheque.'</td>';
181  print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
182  print '<td class="right">'.$checkdepositstatic->LibStatut($objp->status, 3).'</td>';
183 
184  print '</tr>';
185  }
186  if ($i == 0) {
187  print '<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
188  }
189 
190  print "</table>";
191  print '</div>';
192 
193  $db->free($resql);
194  } else {
195  dol_print_error($db);
196  }
197 }
198 
199 print '</div></div>';
200 
201 // End of page
202 llxFooter();
203 $db->close();
Class to manage bank accounts.
Class to manage cheque delivery receipts.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
getDolGlobalString($key, $default='')
Return 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...
llxFooter()
Footer empty.
Definition: index.php:71
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
Definition: index.php:63
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.