29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/prelevement.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
37 $langs->loadLangs(array(
'banks',
'categories',
'withdrawals'));
40 $socid =
GETPOST(
'socid',
'int');
41 if ($user->socid) $socid = $user->socid;
56 llxHeader(
'', $langs->trans(
"CustomersStandingOrdersArea"));
60 $langs->load(
"errors");
61 setEventMessages($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Withdraw")), null,
'errors');
67 print '<div class="fichecenter"><div class="fichethirdleft">';
70 $thirdpartystatic =
new Societe($db);
71 $invoicestatic =
new Facture($db);
74 print
'<div class="div-table-responsive-no-min">';
75 print
'<table class="noborder centpercent">';
76 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
'</th></tr>';
78 print
'<tr class="oddeven"><td>'.$langs->trans(
"NbOfInvoiceToWithdraw").
'</td>';
79 print
'<td class="right">';
80 print
'<a href="'.DOL_URL_ROOT.
'/compta/prelevement/demandes.php?status=0">';
81 print $bprev->nbOfInvoiceToPay(
'direct-debit');
85 print
'<tr class="oddeven"><td>'.$langs->trans(
"AmountToWithdraw").
'</td>';
86 print
'<td class="right">';
87 print
price($bprev->SommeAPrelever(
'direct-debit'),
'',
'', 1, -1, -1,
'auto');
88 print
'</td></tr></table></div><br>';
95 $sql =
"SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
96 $sql .=
" pfd.date_demande, pfd.amount,";
97 $sql .=
" s.nom as name, s.email, s.rowid as socid";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
99 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
100 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
101 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
102 $sql .=
" WHERE s.rowid = f.fk_soc";
103 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
104 $sql .=
" AND f.total_ttc > 0";
105 if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
107 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
109 $sql .=
" AND pfd.traite = 0";
110 $sql .=
" AND pfd.ext_payment_id IS NULL";
111 $sql .=
" AND pfd.fk_facture = f.rowid";
112 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
113 if ($socid) $sql .=
" AND f.fk_soc = ".$socid;
115 $resql = $db->query($sql);
118 $num = $db->num_rows(
$resql);
121 print
'<div class="div-table-responsive-no-min">';
122 print
'<table class="noborder centpercent">';
123 print
'<tr class="liste_titre">';
124 print
'<th colspan="5">'.$langs->trans(
"InvoiceWaitingWithdraw").
' ('.$num.
')</th></tr>';
127 while ($i < $num && $i < 20)
129 $obj = $db->fetch_object(
$resql);
131 $invoicestatic->id = $obj->rowid;
132 $invoicestatic->ref = $obj->ref;
133 $invoicestatic->statut = $obj->fk_statut;
134 $invoicestatic->paye = $obj->paye;
135 $invoicestatic->type = $obj->type;
136 $alreadypayed = $invoicestatic->getSommePaiement();
138 $thirdpartystatic->id = $obj->socid;
139 $thirdpartystatic->name = $obj->name;
140 $thirdpartystatic->email = $obj->email;
142 print
'<tr class="oddeven"><td>';
143 print $invoicestatic->getNomUrl(1,
'withdraw');
147 print $thirdpartystatic->getNomUrl(1,
'customer');
150 print
'<td class="right">';
151 print
price($obj->amount);
154 print
'<td class="right">';
158 print
'<td class="right">';
159 print $invoicestatic->getLibStatut(3, $alreadypayed);
165 print
'<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans(
"NoInvoiceToWithdraw", $langs->transnoentitiesnoconv(
"StandingOrders")).
'</td></tr>';
167 print
"</table></div><br>";
173 print
'</div><div class="fichetwothirdright"><div class="ficheaddleft">';
181 $sql =
"SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
182 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
183 $sql .=
" WHERE p.type = 'debit-order'";
184 $sql .=
" AND entity IN (".getEntity(
'prelevement').
")";
185 $sql .=
" ORDER BY datec DESC";
186 $sql .= $db->plimit($limit);
188 $result = $db->query($sql);
191 $num = $db->num_rows($result);
194 print
"\n<!-- debut table -->\n";
195 print
'<div class="div-table-responsive-no-min">';
196 print
'<table class="noborder centpercent">';
197 print
'<tr class="liste_titre">';
198 print
'<th>'.$langs->trans(
"LastWithdrawalReceipt", $limit).
'</th>';
199 print
'<th>'.$langs->trans(
"Date").
'</th>';
200 print
'<th class="right">'.$langs->trans(
"Amount").
'</th>';
201 print
'<th class="right">'.$langs->trans(
"Status").
'</th>';
205 while ($i < min($num, $limit))
207 $obj = $db->fetch_object($result);
210 print
'<tr class="oddeven">';
213 $bprev->id = $obj->rowid;
214 $bprev->ref = $obj->ref;
215 $bprev->statut = $obj->statut;
216 print $bprev->getNomUrl(1);
218 print
'<td>'.dol_print_date($db->jdate($obj->datec),
"dayhour").
"</td>\n";
219 print
'<td class="right">'.price($obj->amount).
"</td>\n";
220 print
'<td class="right">'.$bprev->getLibStatut(3).
"</td>\n";
226 print
'<tr><td class="opacitymedium" colspan="4">'.$langs->trans(
"None").
'</td></tr>';
229 print
"</table></div><br>";
236 print
'</div></div></div>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
prelevement_check_config()
Check need data to create standigns orders receipt file.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage withdrawal receipts.
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.
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...
Class to manage invoices.