30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
42$langs->loadLangs(array(
'banks',
'bills',
'categories',
'companies',
'salaries'));
45if (GETPOSTISSET(
"account") || GETPOSTISSET(
"ref")) {
46 $id = GETPOSTISSET(
"account") ?
GETPOST(
"account") : (GETPOSTISSET(
"ref") ?
GETPOST(
"ref") :
'');
48$fieldid = GETPOSTISSET(
"ref") ?
'ref' :
'rowid';
50 $socid = $user->socid;
52$result =
restrictedArea($user,
'banque', $id,
'bank_account&bank_account',
'',
'', $fieldid);
56$page = GETPOSTISSET(
"page") ?
GETPOST(
"page") : 0;
59$hookmanager->initHooks(array(
'banktreso',
'globalcard'));
65$societestatic =
new Societe($db);
66$userstatic =
new User($db);
67$facturestatic =
new Facture($db);
70$salarystatic =
new Salary($db);
71$vatstatic =
new Tva($db);
91 $title =
$object->ref.
' - '.$langs->trans(
"PlannedTransactions");
97 print
dol_get_fiche_head($head,
'cash', $langs->trans(
"FinancialAccount"), 0,
'account');
99 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
103 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'', 1);
112 $sql =
"SELECT 'invoice' as family, f.rowid as objid, f.ref as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,";
113 $sql .=
" s.rowid as socid, s.nom as name, s.fournisseur";
114 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
115 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON f.fk_soc = s.rowid";
116 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
")";
117 $sql .=
" AND f.paye = 0 AND f.fk_statut = 1";
118 $sql .=
" AND (f.fk_account IN (0, ".$object->id.
") OR f.fk_account IS NULL)";
119 $sql .=
" ORDER BY dlr ASC";
123 $sql =
" SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,";
124 $sql .=
" s.rowid as socid, s.nom as name, s.fournisseur";
125 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as ff";
126 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON ff.fk_soc = s.rowid";
127 $sql .=
" WHERE ff.entity = ".$conf->entity;
128 $sql .=
" AND ff.paye = 0 AND fk_statut = 1";
129 $sql .=
" AND (ff.fk_account IN (0, ".$object->id.
") OR ff.fk_account IS NULL)";
130 $sql .=
" ORDER BY dlr ASC";
134 $sql =
" SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr,";
135 $sql .=
" 0 as socid, 'noname' as name, 0 as fournisseur";
136 $sql .=
" FROM ".MAIN_DB_PREFIX.
"chargesociales as cs";
137 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_chargesociales as ccs ON cs.fk_type = ccs.id";
138 $sql .=
" WHERE cs.entity = ".$conf->entity;
139 $sql .=
" AND cs.paye = 0";
140 $sql .=
" AND (cs.fk_account IN (0, ".$object->id.
") OR cs.fk_account IS NULL)";
141 $sql .=
" ORDER BY dlr ASC";
145 $sql =
" SELECT 'salary' as family, sa.rowid as objid, sa.label as ref, (-1*sa.amount) as total_ttc, sa.dateep as dlr,";
146 $sql .=
" s.rowid as socid, CONCAT(s.firstname, ' ', s.lastname) as name, 0 as fournisseur";
147 $sql .=
" FROM ".MAIN_DB_PREFIX.
"salary as sa";
148 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as s ON sa.fk_user = s.rowid";
149 $sql .=
" WHERE sa.entity = ".$conf->entity;
150 $sql .=
" AND sa.paye = 0";
151 $sql .=
" AND (sa.fk_account IN (0, ".$object->id.
") OR sa.fk_account IS NULL)";
152 $sql .=
" ORDER BY dlr ASC";
156 $sql =
" SELECT 'vat' as family, t.rowid as objid, t.label as ref, (-1*t.amount) as total_ttc, t.datev as dlr,";
157 $sql .=
" 0 as socid, 'noname' as name, 0 as fournisseur";
158 $sql .=
" FROM ".MAIN_DB_PREFIX.
"tva as t";
159 $sql .=
" WHERE t.entity = ".$conf->entity;
160 $sql .=
" AND t.paye = 0";
161 $sql .=
" AND (t.fk_account IN (-1, 0, ".$object->id.
") OR t.fk_account IS NULL)";
162 $sql .=
" ORDER BY dlr ASC";
166 $parameters = array();
167 $reshook = $hookmanager->executeHooks(
'addMoreSQL', $parameters,
$object, $action);
168 if (empty($reshook) and isset($hookmanager->resArray[
'sql'])) {
169 $sqls[] = $hookmanager->resArray[
'sql'];
173 $tab_sqlobjOrder = array();
174 $tab_sqlobj = array();
175 $nbtotalofrecords = 0;
177 foreach ($sqls as $sql) {
178 $resql = $db->query($sql);
180 $nbtotalofrecords += $db->num_rows($resql);
181 while ($sqlobj = $db->fetch_object($resql)) {
183 $tmpobj->family = $sqlobj->family;
184 $tmpobj->objid = $sqlobj->objid;
185 $tmpobj->ref = $sqlobj->ref;
186 $tmpobj->total_ttc = $sqlobj->total_ttc;
187 $tmpobj->type = $sqlobj->type;
188 $tmpobj->dlr = $db->jdate($sqlobj->dlr);
189 $tmpobj->socid = $sqlobj->socid;
190 $tmpobj->name = $sqlobj->name;
191 $tmpobj->fournisseur = $sqlobj->fournisseur;
193 $tab_sqlobj[] = $tmpobj;
194 $tab_sqlobjOrder[] = $db->jdate($sqlobj->dlr);
205 $massactionbutton =
'';
211 print_barre_liste($langs->trans(
"RemainderToPay"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml,
'', $limit, 0, 0, 1);
222 print
'<div class="div-table-responsive">';
223 print
'<table class="noborder centpercent">';
226 print
'<tr class="liste_titre">';
227 print
'<td>'.$langs->trans(
"DateDue").
'</td>';
228 print
'<td>'.$langs->trans(
"Description").
'</td>';
230 print
'<td>'.$langs->trans(
"Entity").
'</td>';
232 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
233 print
'<td class="right">'.$langs->trans(
"Debit").
'</td>';
234 print
'<td class="right">'.$langs->trans(
"Credit").
'</td>';
235 print
'<td class="right" width="80">'.$langs->trans(
"BankBalance").
'</td>';
239 print
'<tr class="liste_total">';
240 print
'<td class="left" colspan="5">'.$langs->trans(
"CurrentBalance").
'</td>';
241 print
'<td class="nowrap right">'.price($solde).
'</td>';
246 array_multisort($tab_sqlobjOrder, $tab_sqlobj);
248 $num = count($tab_sqlobj);
256 $tmpobj = array_shift($tab_sqlobj);
258 if ($tmpobj->family ==
'invoice_supplier') {
264 $facturefournstatic->ref = $ref;
265 $facturefournstatic->id = $tmpobj->objid;
266 $facturefournstatic->type = $tmpobj->type;
267 $ref = $facturefournstatic->getNomUrl(1,
'');
269 $societestatic->id = $tmpobj->socid;
270 $societestatic->name = $tmpobj->name;
271 $refcomp = $societestatic->getNomUrl(1,
'', 24);
273 $totalpayment = -1 * $facturefournstatic->getSommePaiement();
276 if ($tmpobj->family ==
'invoice') {
277 $facturestatic->ref = $tmpobj->ref;
278 $facturestatic->id = $tmpobj->objid;
279 $facturestatic->type = $tmpobj->type;
280 $ref = $facturestatic->getNomUrl(1,
'');
282 $societestatic->id = $tmpobj->socid;
283 $societestatic->name = $tmpobj->name;
284 $refcomp = $societestatic->getNomUrl(1,
'', 24);
286 $totalpayment = $facturestatic->getSommePaiement();
287 $totalpayment += $facturestatic->getSumDepositsUsed();
288 $totalpayment += $facturestatic->getSumCreditNotesUsed();
290 if ($tmpobj->family ==
'social_contribution') {
291 $socialcontribstatic->ref = $tmpobj->ref;
292 $socialcontribstatic->id = $tmpobj->objid;
293 $socialcontribstatic->label = $tmpobj->type;
294 $ref = $socialcontribstatic->getNomUrl(1, 24);
296 $totalpayment = -1 * $socialcontribstatic->getSommePaiement();
298 if ($tmpobj->family ==
'salary') {
299 $salarystatic->ref = $tmpobj->ref;
300 $salarystatic->id = $tmpobj->objid;
301 $salarystatic->label = $langs->trans(
"SalaryPayment");
302 $ref = $salarystatic->getNomUrl(1,
'');
304 $userstatic->id = $tmpobj->socid;
305 $userstatic->name = $tmpobj->name;
306 $refcomp = $userstatic->getNomUrl(1);
308 $totalpayment = -1 * $salarystatic->getSommePaiement();
310 if ($tmpobj->family ==
'vat') {
311 $vatstatic->ref = $tmpobj->ref;
312 $vatstatic->id = $tmpobj->objid;
313 $vatstatic->type = $tmpobj->type;
314 $ref = $vatstatic->getNomUrl(1,
'');
316 $totalpayment = -1 * $vatstatic->getSommePaiement();
319 $parameters = array(
'obj' => $tmpobj,
'ref' => $ref,
'refcomp' => $refcomp,
'totalpayment' => $totalpayment);
320 $reshook = $hookmanager->executeHooks(
'moreFamily', $parameters, $tmpobject, $action);
321 if (empty($reshook)) {
322 $ref = isset($hookmanager->resArray[
'ref']) ? $hookmanager->resArray[
'ref'] : $ref;
323 $refcomp = isset($hookmanager->resArray[
'refcomp']) ? $hookmanager->resArray[
'refcomp'] : $refcomp;
324 $totalpayment = isset($hookmanager->resArray[
'totalpayment']) ? $hookmanager->resArray[
'totalpayment'] : $totalpayment;
327 $total_ttc = $tmpobj->total_ttc;
329 $total_ttc = $tmpobj->total_ttc - $totalpayment;
331 $solde += $total_ttc;
336 print
'<tr class="oddeven">';
341 print $langs->trans(
"NotDefined");
344 print
"<td>".$ref.
"</td>";
346 if ($tmpobj->family ==
'invoice') {
347 $mc->getInfo($tmpobj->entity);
348 print
"<td>".$mc->label.
"</td>";
353 print
"<td>".$refcomp.
"</td>";
354 if ($tmpobj->total_ttc < 0) {
355 print
'<td class="nowrap right">'.price(abs($total_ttc)).
"</td><td> </td>";
357 if ($tmpobj->total_ttc >= 0) {
358 print
'<td> </td><td class="nowrap right">'.price($total_ttc).
"</td>";
360 print
'<td class="nowrap right">'.price($solde).
'</td>';
371 $parameters = array(
'solde' => $solde);
372 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters,
$object, $action);
373 if (empty($reshook)) {
374 print $hookmanager->resPrint;
375 $solde = isset($hookmanager->resArray[
'solde']) ? $hookmanager->resArray[
'solde'] : $solde;
379 print
'<tr class="liste_total">';
380 print
'<td class="left" colspan="'.$colspan.
'">'.$langs->trans(
"FutureBalance").
' ('.
$object->currency_code.
')</td>';
381 print
'<td class="nowrap right">'.price($solde, 0, $langs, 0, 0, -1,
$object->currency_code).
'</td>';
387 print $langs->trans(
"ErrorBankAccountNotFound");
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
bank_prepare_head(Account $object)
Prepare array with list of tabs.
Class to manage bank accounts.
Class for managing the social charges.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage salary payments.
Class to manage third parties objects (customers, suppliers, prospects...)
Put here description of your class.
Class to manage Dolibarr users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 dolibarr global constant string value.
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.