dolibarr  17.0.4
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 
47 /*
48  * Actions
49  */
50 
51 // None
52 
53 
54 /*
55  * View
56  */
57 
58 llxHeader('', $langs->trans("ChequesArea"));
59 
60 $newcardbutton = '';
61 if ($usercancreate) {
62  $newcardbutton .= dolGetButtonTitle($langs->trans('NewDeposit'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new');
63 }
64 
65 print load_fiche_titre($langs->trans("ChequesArea"), $newcardbutton, $checkdepositstatic->picto);
66 
67 print '<div class="fichecenter"><div class="fichethirdleft">';
68 
69 $sql = "SELECT count(b.rowid) as nb";
70 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
71 $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
72 $sql .= " WHERE ba.rowid = b.fk_account";
73 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
74 $sql .= " AND b.fk_type = 'CHQ'";
75 $sql .= " AND b.fk_bordereau = 0";
76 $sql .= " AND b.amount > 0";
77 
78 $resql = $db->query($sql);
79 
80 print '<div class="div-table-responsive-no-min">';
81 print '<table class="noborder centpercent">';
82 print '<tr class="liste_titre">';
83 print '<th colspan="2">'.$langs->trans("BankChecks")."</th>\n";
84 print "</tr>\n";
85 
86 if ($resql) {
87  $num = '';
88  if ($obj = $db->fetch_object($resql)) {
89  $num = $obj->nb;
90  }
91  print '<tr class="oddeven">';
92  print '<td>'.$langs->trans("BankChecksToReceipt").'</td>';
93  print '<td class="right">';
94  print '<a class="badge badge-info" href="'.DOL_URL_ROOT.'/compta/paiement/cheque/card.php?leftmenu=customers_bills_checks&action=new">'.$num.'</a>';
95  print '</td></tr>';
96 } else {
97  dol_print_error($db);
98 }
99 print "</table></div>\n";
100 
101 
102 print '</div><div class="fichetwothirdright">';
103 
104 $max = 10;
105 
106 $sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref,";
107 $sql .= " bc.statut, bc.nbcheque,";
108 $sql .= " ba.ref as bref, ba.label, ba.rowid as bid, ba.number, ba.currency_code, ba.account_number, ba.fk_accountancy_journal,";
109 $sql .= " aj.code";
110 $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc, ".MAIN_DB_PREFIX."bank_account as ba";
111 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal";
112 $sql .= " WHERE ba.rowid = bc.fk_bank_account";
113 $sql .= " AND bc.entity = ".$conf->entity;
114 $sql .= " ORDER BY bc.date_bordereau DESC, rowid DESC";
115 $sql .= $db->plimit($max);
116 
117 $resql = $db->query($sql);
118 if ($resql) {
119  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
120  print '<table class="noborder centpercent">';
121  print '<tr class="liste_titre">';
122  print '<th>'.$langs->trans("LastCheckReceiptShort", $max).'</th>';
123  print '<th>'.$langs->trans("Date")."</th>";
124  print '<th>'.$langs->trans("Account").'</th>';
125  print '<th class="right">'.$langs->trans("NbOfCheques").'</th>';
126  print '<th class="right">'.$langs->trans("Amount").'</th>';
127  print '<th class="right">'.$langs->trans("Status").'</th>';
128  print "</tr>\n";
129 
130  $num = $db->num_rows($resql);
131 
132  while ($objp = $db->fetch_object($resql)) {
133  $checkdepositstatic->id = $objp->rowid;
134  $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
135  $checkdepositstatic->statut = $objp->statut;
136 
137  $accountstatic->id = $objp->bid;
138  $accountstatic->ref = $objp->bref;
139  $accountstatic->label = $objp->label;
140  $accountstatic->number = $objp->number;
141  $accountstatic->currency_code = $objp->currency_code;
142  $accountstatic->account_number = $objp->account_number;
143  $accountstatic->accountancy_journal = $objp->code;
144  $accountstatic->fk_accountancy_journal = $objp->fk_accountancy_journal;
145 
146  print '<tr class="oddeven">'."\n";
147 
148  print '<td class="nowraponall">'.$checkdepositstatic->getNomUrl(1).'</td>';
149  print '<td>'.dol_print_date($db->jdate($objp->db), 'day').'</td>';
150  print '<td class="nowraponall">'.$accountstatic->getNomUrl(1).'</td>';
151  print '<td class="right">'.$objp->nbcheque.'</td>';
152  print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
153  print '<td class="right">'.$checkdepositstatic->LibStatut($objp->statut, 3).'</td>';
154 
155  print '</tr>';
156  }
157  if (empty($num)) {
158  print '<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
159  }
160 
161  print "</table>";
162  print '</div>';
163 
164  $db->free($resql);
165 } else {
166  dol_print_error($db);
167 }
168 
169 
170 print '</div></div>';
171 
172 // End of page
173 llxFooter();
174 $db->close();
Class to manage bank accounts.
Class to manage cheque delivery receipts.
if(isModEnabled('facture') &&!empty($user->rights->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') &&!empty($user->rights->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)) $resql
Social contributions to pay.
Definition: index.php:745
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.
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.