31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
51$langs->loadLangs(array(
'banks',
'bills',
'categories',
'companies',
'salaries'));
54if (GETPOSTISSET(
"account") || GETPOSTISSET(
"ref")) {
55 $id = GETPOSTISSET(
"account") ?
GETPOST(
"account") : (GETPOSTISSET(
"ref") ?
GETPOST(
"ref") :
'');
57$fieldid = GETPOSTISSET(
"ref") ?
'ref' :
'rowid';
59 $socid = $user->socid;
63$hookmanager->initHooks(array(
'banktreso',
'globalcard'));
65$result =
restrictedArea($user,
'banque',
$id,
'bank_account&bank_account',
'',
'', $fieldid);
68$page = GETPOSTISSET(
"page") ?
GETPOST(
"page") : 0;
73$societestatic =
new Societe($db);
74$userstatic =
new User($db);
75$facturestatic =
new Facture($db);
78$salarystatic =
new Salary($db);
79$vatstatic =
new Tva($db);
99 $title =
$object->ref.
' - '.$langs->trans(
"PlannedTransactions");
105 print
dol_get_fiche_head($head,
'cash', $langs->trans(
"FinancialAccount"), 0,
'account');
107 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
111 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'', 1);
120 $sql =
"SELECT 'invoice' as family, f.rowid as objid, f.ref as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,";
121 $sql .=
" s.rowid as socid, s.nom as name, s.fournisseur";
122 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
123 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON f.fk_soc = s.rowid";
124 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
")";
125 $sql .=
" AND f.paye = 0 AND f.fk_statut = 1";
126 $sql .=
" AND (f.fk_account IN (0, ".$object->id.
") OR f.fk_account IS NULL)";
127 $sql .=
" ORDER BY dlr ASC";
131 $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,";
132 $sql .=
" s.rowid as socid, s.nom as name, s.fournisseur";
133 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as ff";
134 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON ff.fk_soc = s.rowid";
135 $sql .=
" WHERE ff.entity = ".$conf->entity;
136 $sql .=
" AND ff.paye = 0 AND fk_statut = 1";
137 $sql .=
" AND (ff.fk_account IN (0, ".$object->id.
") OR ff.fk_account IS NULL)";
138 $sql .=
" ORDER BY dlr ASC";
142 $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,";
143 $sql .=
" 0 as socid, 'noname' as name, 0 as fournisseur";
144 $sql .=
" FROM ".MAIN_DB_PREFIX.
"chargesociales as cs";
145 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_chargesociales as ccs ON cs.fk_type = ccs.id";
146 $sql .=
" WHERE cs.entity = ".$conf->entity;
147 $sql .=
" AND cs.paye = 0";
148 $sql .=
" AND (cs.fk_account IN (0, ".$object->id.
") OR cs.fk_account IS NULL)";
149 $sql .=
" ORDER BY dlr ASC";
153 $sql =
" SELECT 'salary' as family, sa.rowid as objid, sa.label as ref, (-1*sa.amount) as total_ttc, sa.dateep as dlr,";
154 $sql .=
" s.rowid as socid, CONCAT(s.firstname, ' ', s.lastname) as name, 0 as fournisseur";
155 $sql .=
" FROM ".MAIN_DB_PREFIX.
"salary as sa";
156 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as s ON sa.fk_user = s.rowid";
157 $sql .=
" WHERE sa.entity = ".$conf->entity;
158 $sql .=
" AND sa.paye = 0";
159 $sql .=
" AND (sa.fk_account IN (0, ".$object->id.
") OR sa.fk_account IS NULL)";
160 $sql .=
" ORDER BY dlr ASC";
164 $sql =
" SELECT 'vat' as family, t.rowid as objid, t.label as ref, (-1*t.amount) as total_ttc, t.datev as dlr,";
165 $sql .=
" 0 as socid, 'noname' as name, 0 as fournisseur";
166 $sql .=
" FROM ".MAIN_DB_PREFIX.
"tva as t";
167 $sql .=
" WHERE t.entity = ".$conf->entity;
168 $sql .=
" AND t.paye = 0";
169 $sql .=
" AND (t.fk_account IN (-1, 0, ".$object->id.
") OR t.fk_account IS NULL)";
170 $sql .=
" ORDER BY dlr ASC";
174 $parameters = array();
175 $reshook = $hookmanager->executeHooks(
'addMoreSQL', $parameters,
$object, $action);
176 if (empty($reshook) and isset($hookmanager->resArray[
'sql'])) {
177 $sqls[] = $hookmanager->resArray[
'sql'];
181 $tab_sqlobjOrder = array();
182 $tab_sqlobj = array();
183 $nbtotalofrecords = 0;
185 foreach ($sqls as $sql) {
186 $resql = $db->query($sql);
188 $nbtotalofrecords += $db->num_rows($resql);
189 while ($sqlobj = $db->fetch_object($resql)) {
191 $tmpobj->family = $sqlobj->family;
192 $tmpobj->objid = $sqlobj->objid;
193 $tmpobj->ref = $sqlobj->ref;
194 $tmpobj->total_ttc = $sqlobj->total_ttc;
195 $tmpobj->type = $sqlobj->type;
196 $tmpobj->dlr = $db->jdate($sqlobj->dlr);
197 $tmpobj->socid = $sqlobj->socid;
198 $tmpobj->name = $sqlobj->name;
199 $tmpobj->fournisseur = $sqlobj->fournisseur;
201 $tab_sqlobj[] = $tmpobj;
202 $tab_sqlobjOrder[] = $db->jdate($sqlobj->dlr);
213 $massactionbutton =
'';
219 print_barre_liste($langs->trans(
"PlannedTransactions"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml,
'', $limit, 0, 0, 1);
230 print
'<div class="div-table-responsive">';
231 print
'<table class="noborder centpercent">';
234 print
'<tr class="liste_titre">';
235 print
'<td>'.$langs->trans(
"DateDue").
'</td>';
236 print
'<td>'.$langs->trans(
"Description").
'</td>';
238 print
'<td>'.$langs->trans(
"Entity").
'</td>';
240 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
241 print
'<td class="right">'.$langs->trans(
"Debit").
'</td>';
242 print
'<td class="right">'.$langs->trans(
"Credit").
'</td>';
243 print
'<td class="right" width="80">'.$langs->trans(
"BankBalance").
'</td>';
247 print
'<tr class="liste_total">';
248 print
'<td class="left" colspan="5">'.$langs->trans(
"CurrentBalance").
'</td>';
249 print
'<td class="nowrap right">'.price($solde).
'</td>';
254 array_multisort($tab_sqlobjOrder, $tab_sqlobj);
256 $num = count($tab_sqlobj);
264 $tmpobj = array_shift($tab_sqlobj);
266 if ($tmpobj->family ==
'invoice_supplier') {
272 $facturefournstatic->ref = $ref;
273 $facturefournstatic->id = $tmpobj->objid;
274 $facturefournstatic->type = $tmpobj->type;
275 $ref = $facturefournstatic->getNomUrl(1,
'');
277 $societestatic->id = $tmpobj->socid;
278 $societestatic->name = $tmpobj->name;
279 $refcomp = $societestatic->getNomUrl(1,
'', 24);
281 $totalpayment = -1 * $facturefournstatic->getSommePaiement();
284 if ($tmpobj->family ==
'invoice') {
285 $facturestatic->ref = $tmpobj->ref;
286 $facturestatic->id = $tmpobj->objid;
287 $facturestatic->type = (int) $tmpobj->type;
288 $ref = $facturestatic->getNomUrl(1,
'');
290 $societestatic->id = $tmpobj->socid;
291 $societestatic->name = $tmpobj->name;
292 $refcomp = $societestatic->getNomUrl(1,
'', 24);
294 $totalpayment = $facturestatic->getSommePaiement();
295 $totalpayment += $facturestatic->getSumDepositsUsed();
296 $totalpayment += $facturestatic->getSumCreditNotesUsed();
298 if ($tmpobj->family ==
'social_contribution') {
299 $socialcontribstatic->ref = $tmpobj->ref;
300 $socialcontribstatic->id = $tmpobj->objid;
301 $socialcontribstatic->label = $tmpobj->type;
302 $ref = $socialcontribstatic->getNomUrl(1, 24);
304 $totalpayment = -1 * $socialcontribstatic->getSommePaiement();
306 if ($tmpobj->family ==
'salary') {
307 $salarystatic->ref = $tmpobj->ref;
308 $salarystatic->id = $tmpobj->objid;
309 $salarystatic->label = $langs->trans(
"SalaryPayment");
310 $ref = $salarystatic->getNomUrl(1,
'');
312 $userstatic->id = $tmpobj->socid;
313 $userstatic->name = $tmpobj->name;
314 $refcomp = $userstatic->getNomUrl(1);
316 $totalpayment = -1 * $salarystatic->getSommePaiement();
318 if ($tmpobj->family ==
'vat') {
319 $vatstatic->ref = $tmpobj->ref;
320 $vatstatic->id = $tmpobj->objid;
321 $vatstatic->type = $tmpobj->type;
322 $ref = $vatstatic->getNomUrl(1,
'');
324 $totalpayment = -1 * $vatstatic->getSommePaiement();
327 $parameters = array(
'obj' => $tmpobj,
'ref' => $ref,
'refcomp' => $refcomp,
'totalpayment' => $totalpayment);
328 $reshook = $hookmanager->executeHooks(
'moreFamily', $parameters, $tmpobject, $action);
329 if (empty($reshook)) {
330 $ref = isset($hookmanager->resArray[
'ref']) ? $hookmanager->resArray[
'ref'] : $ref;
331 $refcomp = isset($hookmanager->resArray[
'refcomp']) ? $hookmanager->resArray[
'refcomp'] : $refcomp;
332 $totalpayment = isset($hookmanager->resArray[
'totalpayment']) ? $hookmanager->resArray[
'totalpayment'] : $totalpayment;
335 $total_ttc = $tmpobj->total_ttc;
337 $total_ttc = $tmpobj->total_ttc - $totalpayment;
339 $solde += $total_ttc;
344 print
'<tr class="oddeven">';
349 print $langs->trans(
"NotDefined");
352 print
"<td>".$ref.
"</td>";
354 if ($tmpobj->family ==
'invoice') {
355 $mc->getInfo($tmpobj->entity);
356 print
"<td>".$mc->label.
"</td>";
361 print
"<td>".$refcomp.
"</td>";
362 if ($tmpobj->total_ttc < 0) {
363 print
'<td class="nowrap right">'.price(abs($total_ttc)).
"</td><td> </td>";
365 if ($tmpobj->total_ttc >= 0) {
366 print
'<td> </td><td class="nowrap right">'.price($total_ttc).
"</td>";
368 print
'<td class="nowrap right">'.price($solde).
'</td>';
379 $parameters = array(
'solde' => $solde);
380 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters,
$object, $action);
381 if (empty($reshook)) {
382 print $hookmanager->resPrint;
383 $solde = isset($hookmanager->resArray[
'solde']) ? $hookmanager->resArray[
'solde'] : $solde;
387 print
'<tr class="liste_total">';
388 print
'<td class="left" colspan="'.$colspan.
'">'.$langs->trans(
"FutureBalance").
' ('.
$object->currency_code.
')</td>';
389 print
'<td class="nowrap right">'.price($solde, 0, $langs, 0, 0, -1,
$object->currency_code).
'</td>';
395 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.