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;
54$hookmanager->initHooks(array(
'banktreso',
'globalcard'));
56$result =
restrictedArea($user,
'banque',
$id,
'bank_account&bank_account',
'',
'', $fieldid);
59$page = GETPOSTISSET(
"page") ?
GETPOST(
"page") : 0;
64$societestatic =
new Societe($db);
65$userstatic =
new User($db);
66$facturestatic =
new Facture($db);
69$salarystatic =
new Salary($db);
70$vatstatic =
new Tva($db);
90 $title =
$object->ref.
' - '.$langs->trans(
"PlannedTransactions");
96 print
dol_get_fiche_head($head,
'cash', $langs->trans(
"FinancialAccount"), 0,
'account');
98 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
102 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'', 1);
111 $sql =
"SELECT 'invoice' as family, f.rowid as objid, f.ref as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,";
112 $sql .=
" s.rowid as socid, s.nom as name, s.fournisseur";
113 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
114 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON f.fk_soc = s.rowid";
115 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
")";
116 $sql .=
" AND f.paye = 0 AND f.fk_statut = 1";
117 $sql .=
" AND (f.fk_account IN (0, ".$object->id.
") OR f.fk_account IS NULL)";
118 $sql .=
" ORDER BY dlr ASC";
122 $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,";
123 $sql .=
" s.rowid as socid, s.nom as name, s.fournisseur";
124 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as ff";
125 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON ff.fk_soc = s.rowid";
126 $sql .=
" WHERE ff.entity = ".$conf->entity;
127 $sql .=
" AND ff.paye = 0 AND fk_statut = 1";
128 $sql .=
" AND (ff.fk_account IN (0, ".$object->id.
") OR ff.fk_account IS NULL)";
129 $sql .=
" ORDER BY dlr ASC";
133 $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,";
134 $sql .=
" 0 as socid, 'noname' as name, 0 as fournisseur";
135 $sql .=
" FROM ".MAIN_DB_PREFIX.
"chargesociales as cs";
136 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_chargesociales as ccs ON cs.fk_type = ccs.id";
137 $sql .=
" WHERE cs.entity = ".$conf->entity;
138 $sql .=
" AND cs.paye = 0";
139 $sql .=
" AND (cs.fk_account IN (0, ".$object->id.
") OR cs.fk_account IS NULL)";
140 $sql .=
" ORDER BY dlr ASC";
144 $sql =
" SELECT 'salary' as family, sa.rowid as objid, sa.label as ref, (-1*sa.amount) as total_ttc, sa.dateep as dlr,";
145 $sql .=
" s.rowid as socid, CONCAT(s.firstname, ' ', s.lastname) as name, 0 as fournisseur";
146 $sql .=
" FROM ".MAIN_DB_PREFIX.
"salary as sa";
147 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as s ON sa.fk_user = s.rowid";
148 $sql .=
" WHERE sa.entity = ".$conf->entity;
149 $sql .=
" AND sa.paye = 0";
150 $sql .=
" AND (sa.fk_account IN (0, ".$object->id.
") OR sa.fk_account IS NULL)";
151 $sql .=
" ORDER BY dlr ASC";
155 $sql =
" SELECT 'vat' as family, t.rowid as objid, t.label as ref, (-1*t.amount) as total_ttc, t.datev as dlr,";
156 $sql .=
" 0 as socid, 'noname' as name, 0 as fournisseur";
157 $sql .=
" FROM ".MAIN_DB_PREFIX.
"tva as t";
158 $sql .=
" WHERE t.entity = ".$conf->entity;
159 $sql .=
" AND t.paye = 0";
160 $sql .=
" AND (t.fk_account IN (-1, 0, ".$object->id.
") OR t.fk_account IS NULL)";
161 $sql .=
" ORDER BY dlr ASC";
165 $parameters = array();
166 $reshook = $hookmanager->executeHooks(
'addMoreSQL', $parameters,
$object, $action);
167 if (empty($reshook) and isset($hookmanager->resArray[
'sql'])) {
168 $sqls[] = $hookmanager->resArray[
'sql'];
172 $tab_sqlobjOrder = array();
173 $tab_sqlobj = array();
174 $nbtotalofrecords = 0;
176 foreach ($sqls as $sql) {
177 $resql = $db->query($sql);
179 $nbtotalofrecords += $db->num_rows($resql);
180 while ($sqlobj = $db->fetch_object($resql)) {
182 $tmpobj->family = $sqlobj->family;
183 $tmpobj->objid = $sqlobj->objid;
184 $tmpobj->ref = $sqlobj->ref;
185 $tmpobj->total_ttc = $sqlobj->total_ttc;
186 $tmpobj->type = $sqlobj->type;
187 $tmpobj->dlr = $db->jdate($sqlobj->dlr);
188 $tmpobj->socid = $sqlobj->socid;
189 $tmpobj->name = $sqlobj->name;
190 $tmpobj->fournisseur = $sqlobj->fournisseur;
192 $tab_sqlobj[] = $tmpobj;
193 $tab_sqlobjOrder[] = $db->jdate($sqlobj->dlr);
204 $massactionbutton =
'';
210 print_barre_liste($langs->trans(
"RemainderToPay"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml,
'', $limit, 0, 0, 1);
221 print
'<div class="div-table-responsive">';
222 print
'<table class="noborder centpercent">';
225 print
'<tr class="liste_titre">';
226 print
'<td>'.$langs->trans(
"DateDue").
'</td>';
227 print
'<td>'.$langs->trans(
"Description").
'</td>';
229 print
'<td>'.$langs->trans(
"Entity").
'</td>';
231 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
232 print
'<td class="right">'.$langs->trans(
"Debit").
'</td>';
233 print
'<td class="right">'.$langs->trans(
"Credit").
'</td>';
234 print
'<td class="right" width="80">'.$langs->trans(
"BankBalance").
'</td>';
238 print
'<tr class="liste_total">';
239 print
'<td class="left" colspan="5">'.$langs->trans(
"CurrentBalance").
'</td>';
240 print
'<td class="nowrap right">'.price($solde).
'</td>';
245 array_multisort($tab_sqlobjOrder, $tab_sqlobj);
247 $num = count($tab_sqlobj);
255 $tmpobj = array_shift($tab_sqlobj);
257 if ($tmpobj->family ==
'invoice_supplier') {
263 $facturefournstatic->ref = $ref;
264 $facturefournstatic->id = $tmpobj->objid;
265 $facturefournstatic->type = $tmpobj->type;
266 $ref = $facturefournstatic->getNomUrl(1,
'');
268 $societestatic->id = $tmpobj->socid;
269 $societestatic->name = $tmpobj->name;
270 $refcomp = $societestatic->getNomUrl(1,
'', 24);
272 $totalpayment = -1 * $facturefournstatic->getSommePaiement();
275 if ($tmpobj->family ==
'invoice') {
276 $facturestatic->ref = $tmpobj->ref;
277 $facturestatic->id = $tmpobj->objid;
278 $facturestatic->type = $tmpobj->type;
279 $ref = $facturestatic->getNomUrl(1,
'');
281 $societestatic->id = $tmpobj->socid;
282 $societestatic->name = $tmpobj->name;
283 $refcomp = $societestatic->getNomUrl(1,
'', 24);
285 $totalpayment = $facturestatic->getSommePaiement();
286 $totalpayment += $facturestatic->getSumDepositsUsed();
287 $totalpayment += $facturestatic->getSumCreditNotesUsed();
289 if ($tmpobj->family ==
'social_contribution') {
290 $socialcontribstatic->ref = $tmpobj->ref;
291 $socialcontribstatic->id = $tmpobj->objid;
292 $socialcontribstatic->label = $tmpobj->type;
293 $ref = $socialcontribstatic->getNomUrl(1, 24);
295 $totalpayment = -1 * $socialcontribstatic->getSommePaiement();
297 if ($tmpobj->family ==
'salary') {
298 $salarystatic->ref = $tmpobj->ref;
299 $salarystatic->id = $tmpobj->objid;
300 $salarystatic->label = $langs->trans(
"SalaryPayment");
301 $ref = $salarystatic->getNomUrl(1,
'');
303 $userstatic->id = $tmpobj->socid;
304 $userstatic->name = $tmpobj->name;
305 $refcomp = $userstatic->getNomUrl(1);
307 $totalpayment = -1 * $salarystatic->getSommePaiement();
309 if ($tmpobj->family ==
'vat') {
310 $vatstatic->ref = $tmpobj->ref;
311 $vatstatic->id = $tmpobj->objid;
312 $vatstatic->type = $tmpobj->type;
313 $ref = $vatstatic->getNomUrl(1,
'');
315 $totalpayment = -1 * $vatstatic->getSommePaiement();
318 $parameters = array(
'obj' => $tmpobj,
'ref' => $ref,
'refcomp' => $refcomp,
'totalpayment' => $totalpayment);
319 $reshook = $hookmanager->executeHooks(
'moreFamily', $parameters, $tmpobject, $action);
320 if (empty($reshook)) {
321 $ref = isset($hookmanager->resArray[
'ref']) ? $hookmanager->resArray[
'ref'] : $ref;
322 $refcomp = isset($hookmanager->resArray[
'refcomp']) ? $hookmanager->resArray[
'refcomp'] : $refcomp;
323 $totalpayment = isset($hookmanager->resArray[
'totalpayment']) ? $hookmanager->resArray[
'totalpayment'] : $totalpayment;
326 $total_ttc = $tmpobj->total_ttc;
328 $total_ttc = $tmpobj->total_ttc - $totalpayment;
330 $solde += $total_ttc;
335 print
'<tr class="oddeven">';
340 print $langs->trans(
"NotDefined");
343 print
"<td>".$ref.
"</td>";
345 if ($tmpobj->family ==
'invoice') {
346 $mc->getInfo($tmpobj->entity);
347 print
"<td>".$mc->label.
"</td>";
352 print
"<td>".$refcomp.
"</td>";
353 if ($tmpobj->total_ttc < 0) {
354 print
'<td class="nowrap right">'.price(abs($total_ttc)).
"</td><td> </td>";
356 if ($tmpobj->total_ttc >= 0) {
357 print
'<td> </td><td class="nowrap right">'.price($total_ttc).
"</td>";
359 print
'<td class="nowrap right">'.price($solde).
'</td>';
370 $parameters = array(
'solde' => $solde);
371 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters,
$object, $action);
372 if (empty($reshook)) {
373 print $hookmanager->resPrint;
374 $solde = isset($hookmanager->resArray[
'solde']) ? $hookmanager->resArray[
'solde'] : $solde;
378 print
'<tr class="liste_total">';
379 print
'<td class="left" colspan="'.$colspan.
'">'.$langs->trans(
"FutureBalance").
' ('.
$object->currency_code.
')</td>';
380 print
'<td class="nowrap right">'.price($solde, 0, $langs, 0, 0, -1,
$object->currency_code).
'</td>';
386 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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...)
Class to manage VAT - Value-added tax (also known in French as TVA - Taxe sur la valeur ajoutée)
Class to manage Dolibarr users.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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).
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 a 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.