30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/prelevement.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
38$langs->loadLangs(array(
'banks',
'categories',
'withdrawals'));
41$socid =
GETPOST(
'socid',
'int');
43 $socid = $user->socid;
47$usercancreate = $user->rights->prelevement->bons->creer;
61llxHeader(
'', $langs->trans(
"CustomersStandingOrdersArea"));
64 $langs->load(
"errors");
65 setEventMessages($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"PaymentByDirectDebit")),
null,
'errors');
70 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewStandingOrder'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php?type=');
73print
load_fiche_titre($langs->trans(
"CustomersStandingOrdersArea"), $newcardbutton);
76print
'<div class="fichecenter"><div class="fichethirdleft">';
79$thirdpartystatic =
new Societe($db);
80$invoicestatic =
new Facture($db);
83print
'<div class="div-table-responsive-no-min">';
84print
'<table class="noborder centpercent">';
85print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
'</th></tr>';
87print
'<tr class="oddeven"><td>'.$langs->trans(
"NbOfInvoiceToWithdraw").
'</td>';
88print
'<td class="right">';
89print
'<a class="badge badge-info" href="'.DOL_URL_ROOT.
'/compta/prelevement/demandes.php?status=0">';
90print $bprev->nbOfInvoiceToPay(
'direct-debit');
94print
'<tr class="oddeven"><td>'.$langs->trans(
"AmountToWithdraw").
'</td>';
95print
'<td class="right"><span class="amount">';
96print
price($bprev->SommeAPrelever(
'direct-debit'),
'',
'', 1, -1, -1,
'auto');
97print
'</span></td></tr></table></div><br>';
104$sql =
"SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut as status, f.paye, f.type,";
105$sql .=
" pfd.date_demande, pfd.amount,";
106$sql .=
" s.nom as name, s.email, s.rowid as socid, s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6";
107$sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
108$sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
109if (empty($user->rights->societe->client->voir) && !$socid) {
110 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
112$sql .=
" , ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
113$sql .=
" WHERE s.rowid = f.fk_soc";
114$sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
115$sql .=
" AND f.total_ttc > 0";
116if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
117 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
119$sql .=
" AND pfd.traite = 0";
120$sql .=
" AND pfd.ext_payment_id IS NULL";
121$sql .=
" AND pfd.fk_facture = f.rowid";
122if (empty($user->rights->societe->client->voir) && !$socid) {
123 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
126 $sql .=
" AND f.fk_soc = ".((int) $socid);
129$resql = $db->query($sql);
131 $num = $db->num_rows($resql);
134 print
'<div class="div-table-responsive-no-min">';
135 print
'<table class="noborder centpercent">';
136 print
'<tr class="liste_titre">';
137 print
'<th colspan="5">'.$langs->trans(
"InvoiceWaitingWithdraw").
' ('.$num.
')</th></tr>';
139 while ($i < $num && $i < 20) {
140 $obj = $db->fetch_object($resql);
142 $invoicestatic->id = $obj->rowid;
143 $invoicestatic->ref = $obj->ref;
144 $invoicestatic->statut = $obj->status;
145 $invoicestatic->status = $obj->status;
146 $invoicestatic->paye = $obj->paye;
147 $invoicestatic->type = $obj->type;
148 $totalallpayments = $invoicestatic->getSommePaiement(0);
149 $totalallpayments += $invoicestatic->getSumCreditNotesUsed(0);
150 $totalallpayments += $invoicestatic->getSumDepositsUsed(0);
152 $thirdpartystatic->id = $obj->socid;
153 $thirdpartystatic->name = $obj->name;
154 $thirdpartystatic->email = $obj->email;
155 $thirdpartystatic->tva_intra = $obj->tva_intra;
156 $thirdpartystatic->siren = $obj->idprof1;
157 $thirdpartystatic->siret = $obj->idprof2;
158 $thirdpartystatic->ape = $obj->idprof3;
159 $thirdpartystatic->idprof1 = $obj->idprof1;
160 $thirdpartystatic->idprof2 = $obj->idprof2;
161 $thirdpartystatic->idprof3 = $obj->idprof3;
162 $thirdpartystatic->idprof4 = $obj->idprof4;
163 $thirdpartystatic->idprof5 = $obj->idprof5;
164 $thirdpartystatic->idprof6 = $obj->idprof6;
166 print
'<tr class="oddeven"><td class="nowraponall">';
167 print $invoicestatic->getNomUrl(1,
'withdraw');
170 print
'<td class="tdoverflowmax150">';
171 print $thirdpartystatic->getNomUrl(1,
'customer');
174 print
'<td class="right">';
175 print
'<span class="amount">'.price($obj->amount).
'</span>';
178 print
'<td class="right">';
182 print
'<td class="right">';
183 print $invoicestatic->getLibStatut(3, $totalallpayments);
189 $titlefortab = $langs->transnoentitiesnoconv(
"StandingOrders");
190 print
'<tr class="oddeven"><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"NoInvoiceToWithdraw", $titlefortab, $titlefortab).
'</span></td></tr>';
192 print
"</table></div><br>";
198print
'</div><div class="fichetwothirdright">';
206$sql =
"SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
207$sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
208$sql .=
" WHERE p.type = 'debit-order'";
209$sql .=
" AND entity IN (".getEntity(
'prelevement').
")";
210$sql .=
" ORDER BY datec DESC";
211$sql .= $db->plimit($limit);
213$result = $db->query($sql);
215 $num = $db->num_rows($result);
218 print
"\n<!-- debut table -->\n";
219 print
'<div class="div-table-responsive-no-min">';
220 print
'<table class="noborder centpercent">';
221 print
'<tr class="liste_titre">';
222 print
'<th>'.$langs->trans(
"LastWithdrawalReceipt", $limit).
'</th>';
223 print
'<th>'.$langs->trans(
"Date").
'</th>';
224 print
'<th class="right">'.$langs->trans(
"Amount").
'</th>';
225 print
'<th class="right">'.$langs->trans(
"Status").
'</th>';
229 while ($i < min($num, $limit)) {
230 $obj = $db->fetch_object($result);
232 $bprev->id = $obj->rowid;
233 $bprev->ref = $obj->ref;
234 $bprev->statut = $obj->statut;
236 print
'<tr class="oddeven">';
238 print
'<td class="nowraponall">';
239 print $bprev->getNomUrl(1);
241 print
'<td>'.dol_print_date($db->jdate($obj->datec),
"dayhour").
"</td>\n";
242 print
'<td class="right nowraponall"><span class="amount">'.price($obj->amount).
"</span></td>\n";
243 print
'<td class="right">'.$bprev->getLibStatut(3).
"</td>\n";
249 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
252 print
"</table></div><br>";
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage withdrawal receipts.
Class to manage invoices.
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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
prelevement_check_config($type='direct-debit')
Check need data to create standigns orders receipt file.
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.