28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
37 $langs->loadLangs(array(
'banks',
'categories',
'bills',
'companies'));
40 if (isset($_GET[
"account"]) || isset($_GET[
"ref"]))
42 $id = isset($_GET[
"account"]) ? $_GET[
"account"] : (isset($_GET[
"ref"]) ? $_GET[
"ref"] :
'');
44 $fieldid = isset($_GET[
"ref"]) ?
'ref' :
'rowid';
45 if ($user->socid) $socid = $user->socid;
46 $result =
restrictedArea($user,
'banque', $id,
'bank_account&bank_account',
'',
'', $fieldid);
49 $vline = isset($_GET[
"vline"]) ? $_GET[
"vline"] : $_POST[
"vline"];
50 $page = isset($_GET[
"page"]) ? $_GET[
"page"] : 0;
53 $hookmanager->initHooks(array(
'banktreso',
'globalcard'));
59 $title = $langs->trans(
"FinancialAccount").
' - '.$langs->trans(
"PlannedTransactions");
63 $societestatic =
new Societe($db);
64 $facturestatic =
new Facture($db);
68 $form =
new Form($db);
70 if ($_REQUEST[
"account"] || $_REQUEST[
"ref"])
82 $result = $object->fetch($_GET[
"account"]);
86 $result = $object->fetch(0, $_GET[
"ref"]);
87 $_GET[
"account"] = $object->id;
95 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
97 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'', 1);
103 $solde = $object->solde(0);
104 if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)$colspan = 6;
108 print '<div class="div-table-responsive">';
109 print '<table class="noborder centpercent">';
112 print '<tr class="liste_titre">';
113 print '<td>'.$langs->trans(
"DateDue").
'</td>';
114 print '<td>'.$langs->trans(
"Description").
'</td>';
115 if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)
print '<td>'.$langs->trans(
"Entity").
'</td>';
116 print '<td>'.$langs->trans(
"ThirdParty").
'</td>';
117 print '<td class="right">'.$langs->trans(
"Debit").
'</td>';
118 print '<td class="right">'.$langs->trans(
"Credit").
'</td>';
119 print '<td class="right" width="80">'.$langs->trans(
"BankBalance").
'</td>';
123 print '<tr class="liste_total">';
124 print '<td class="left" colspan="5">'.$langs->trans(
"CurrentBalance").
'</td>';
125 print '<td class="nowrap right">'.price($solde).
'</td>';
129 print '<tr class="liste_titre">';
130 print '<td class="left" colspan="'.$colspan.
'">'.$langs->trans(
"RemainderToPay").
'</td>';
131 print '<td class="nowrap right"> </td>';
139 $sql =
"SELECT 'invoice' as family, f.rowid as objid, f.ref as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,";
140 $sql .=
" s.rowid as socid, s.nom as name, s.fournisseur";
141 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
142 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON f.fk_soc = s.rowid";
143 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
")";
144 $sql .=
" AND f.paye = 0 AND f.fk_statut = 1";
145 $sql .=
" AND (f.fk_account IN (0, ".$object->id.
") OR f.fk_account IS NULL)";
146 $sql .=
" ORDER BY dlr ASC";
150 $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,";
151 $sql .=
" s.rowid as socid, s.nom as name, s.fournisseur";
152 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as ff";
153 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON ff.fk_soc = s.rowid";
154 $sql .=
" WHERE ff.entity = ".$conf->entity;
155 $sql .=
" AND ff.paye = 0 AND fk_statut = 1";
156 $sql .=
" AND (ff.fk_account IN (0, ".$object->id.
") OR ff.fk_account IS NULL)";
157 $sql .=
" ORDER BY dlr ASC";
161 $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";
162 $sql .=
", cs.fk_account";
163 $sql .=
" FROM ".MAIN_DB_PREFIX.
"chargesociales as cs";
164 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_chargesociales as ccs ON cs.fk_type = ccs.id";
165 $sql .=
" WHERE cs.entity = ".$conf->entity;
166 $sql .=
" AND cs.paye = 0";
167 $sql .=
" AND (cs.fk_account IN (0, ".$object->id.
") OR cs.fk_account IS NULL)";
168 $sql .=
" ORDER BY dlr ASC";
172 $parameters = array();
173 $reshook = $hookmanager->executeHooks(
'addMoreSQL', $parameters, $object, $action);
174 if (empty($reshook) and isset($hookmanager->resArray[
'sql'])) {
175 $sqls[] = $hookmanager->resArray[
'sql'];
179 $tab_sqlobjOrder = array();
180 $tab_sqlobj = array();
182 foreach ($sqls as $sql) {
183 $resql = $db->query($sql);
185 while ($sqlobj = $db->fetch_object(
$resql)) {
186 $tab_sqlobj[] = $sqlobj;
187 $tab_sqlobjOrder[] = $db->jdate($sqlobj->dlr);
198 array_multisort($tab_sqlobjOrder, $tab_sqlobj);
201 foreach ($tab_sqlobj as $key=>$value) {
202 $tab_sqlobj[$key] =
"'".serialize($value).
"'";
204 $tab_sqlobj = array_unique($tab_sqlobj);
205 foreach ($tab_sqlobj as $key=>$value) {
206 $tab_sqlobj[$key] = unserialize(trim($value,
"'"));
209 $num = count($tab_sqlobj);
218 $obj = array_shift($tab_sqlobj);
220 if ($obj->family ==
'invoice_supplier')
228 $facturefournstatic->ref = $ref;
229 $facturefournstatic->id = $obj->objid;
230 $facturefournstatic->type = $obj->type;
231 $ref = $facturefournstatic->getNomUrl(1,
'');
233 $societestatic->id = $obj->socid;
234 $societestatic->name = $obj->name;
235 $refcomp = $societestatic->getNomUrl(1,
'', 24);
237 $totalpayment = -1 * $facturefournstatic->getSommePaiement();
240 if ($obj->family ==
'invoice')
242 $facturestatic->ref = $obj->ref;
243 $facturestatic->id = $obj->objid;
244 $facturestatic->type = $obj->type;
245 $ref = $facturestatic->getNomUrl(1,
'');
247 $societestatic->id = $obj->socid;
248 $societestatic->name = $obj->name;
249 $refcomp = $societestatic->getNomUrl(1,
'', 24);
251 $totalpayment = $facturestatic->getSommePaiement();
252 $totalpayment += $facturestatic->getSumDepositsUsed();
253 $totalpayment += $facturestatic->getSumCreditNotesUsed();
255 if ($obj->family ==
'social_contribution')
257 $socialcontribstatic->ref = $obj->ref;
258 $socialcontribstatic->id = $obj->objid;
259 $socialcontribstatic->label = $obj->type;
260 $ref = $socialcontribstatic->getNomUrl(1, 24);
262 $totalpayment = -1 * $socialcontribstatic->getSommePaiement();
265 $parameters = array(
'obj' => $obj,
'ref' => $ref,
'refcomp' => $refcomp,
'totalpayment' => $totalpayment);
266 $reshook = $hookmanager->executeHooks(
'moreFamily', $parameters, $object, $action);
267 if (empty($reshook)) {
268 $ref = isset($hookmanager->resArray[
'ref']) ? $hookmanager->resArray[
'ref'] : $ref;
269 $refcomp = isset($hookmanager->resArray[
'refcomp']) ? $hookmanager->resArray[
'refcomp'] : $refcomp;
270 $totalpayment = isset($hookmanager->resArray[
'totalpayment']) ? $hookmanager->resArray[
'totalpayment'] : $totalpayment;
273 $total_ttc = $obj->total_ttc;
274 if ($totalpayment) $total_ttc = $obj->total_ttc - $totalpayment;
275 $solde += $total_ttc;
281 print '<tr class="oddeven">';
284 else print $langs->trans(
"NotDefined");
286 print "<td>".$ref.
"</td>";
287 if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) {
288 if ($obj->family ==
'invoice') {
289 $mc->getInfo($obj->entity);
290 print "<td>".$mc->label.
"</td>";
295 print "<td>".$refcomp.
"</td>";
296 if ($obj->total_ttc < 0) {
print '<td class="nowrap right">'.price(abs($total_ttc)).
"</td><td> </td>"; };
297 if ($obj->total_ttc >= 0) {
print '<td> </td><td class="nowrap right">'.price($total_ttc).
"</td>"; };
298 print '<td class="nowrap right">'.price($solde).
'</td>';
309 $parameters = array(
'solde' => $solde);
310 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $object, $action);
311 if (empty($reshook)) {
312 print $hookmanager->resPrint;
313 $solde = isset($hookmanager->resArray[
'solde']) ? $hookmanager->resArray[
'solde'] : $solde;
317 print '<tr class="liste_total">';
318 print '<td class="left" colspan="'.$colspan.
'">'.$langs->trans(
"FutureBalance").
' ('.$object->currency_code.
')</td>';
319 print '<td class="nowrap right">'.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).
'</td>';
325 print $langs->trans(
"ErrorBankAccountNotFound");
bank_prepare_head(Account $object)
Prepare array with list of tabs.
Class to manage suppliers invoices.
Class to manage bank accounts.
Class to manage third parties objects (customers, suppliers, prospects...)
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage invoices.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...