27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/prelevement.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/ligneprelevement.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
34 $langs->loadLangs(array(
'banks',
'categories',
'bills',
'companies',
'withdrawals'));
40 $action =
GETPOST(
'action',
'aZ09');
43 $socid =
GETPOST(
'socid',
'int');
44 $type =
GETPOST(
'type',
'aZ09');
47 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
48 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
49 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
51 if (empty($page) || $page == -1) { $page = 0; }
52 $offset = $limit * $page;
53 $pageprev = $page - 1;
54 $pagenext = $page + 1;
56 if (!$sortfield) $sortfield =
'pl.fk_soc';
57 if (!$sortorder) $sortorder =
'DESC';
62 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
64 $hookmanager->initHooks(array(
'directdebitprevcard',
'globalcard',
'directdebitprevlist'));
66 if (!$user->rights->prelevement->bons->lire && $object->type !=
'bank-transfer') {
69 if (!$user->rights->paymentbybanktransfer->read && $object->type ==
'bank-transfer') {
78 $parameters = array(
'socid' => $socid);
79 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
80 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
84 if ($action ==
'confirm_delete')
86 $res = $object->delete($user);
89 if ($object->type ==
'bank-transfer') {
90 header(
"Location: ".DOL_URL_ROOT.
'/compta/paymentbybanktransfer/index.php');
92 header(
"Location: ".DOL_URL_ROOT.
'/compta/prelevement/index.php');
99 if ($action ==
'confirm_credite' &&
GETPOST(
'confirm',
'alpha') ==
'yes')
101 if ($object->statut == 2) {
105 $res = $object->set_credite();
110 header(
"Location: card.php?id=".$id);
115 if ($action ==
'infotrans' && $user->rights->prelevement->bons->send)
117 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
140 $error = $object->set_infotrans($user, $dt,
GETPOST(
'methode',
'alpha'));
144 header(
"Location: card.php?id=".$id.
"&error=$error");
150 if ($action ==
'infocredit' && $user->rights->prelevement->bons->credit)
154 if ($object->statut == 2) {
158 $error = $object->set_infocredit($user, $dt);
174 $form =
new Form($db);
176 llxHeader(
'', $langs->trans(
"WithdrawalsReceipts"));
183 if (
GETPOST(
'error',
'alpha') !=
'')
185 print '<div class="error">'.$object->getErrorString(
GETPOST(
'error',
'alpha')).
'</div>';
194 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/prelevement/orders_list.php?restore_lastsearch_values=1'.($object->type !=
'bank-transfer' ?
'' :
'&type=bank-transfer').
'">'.$langs->trans(
"BackToList").
'</a>';
198 print '<div class="fichecenter">';
199 print '<div class="underbanner clearboth"></div>';
200 print '<table class="border centpercent tableforfield">';
203 print '<tr><td class="titlefield">'.$langs->trans(
"Date").
'</td><td>'.
dol_print_date($object->datec,
'day').
'</td></tr>';
204 print '<tr><td>'.$langs->trans(
"Amount").
'</td><td>'.
price($object->amount).
'</td></tr>';
213 if ($object->date_trans <> 0)
215 $muser =
new User($db);
216 $muser->fetch($object->user_trans);
218 print '<tr><td>'.$langs->trans(
"TransData").
'</td><td>';
220 print ' <span class="opacitymedium">'.$langs->trans(
"By").
'</span> '.$muser->getFullName($langs).
'</td></tr>';
221 print '<tr><td>'.$langs->trans(
"TransMetod").
'</td><td>';
222 print $object->methodes_trans[$object->method_trans];
225 if ($object->date_credit <> 0)
227 print '<tr><td>'.$langs->trans(
'CreditDate').
'</td><td>';
236 print '<div class="underbanner clearboth"></div>';
237 print '<table class="border centpercent tableforfield">';
240 $result = $acc->fetch(($object->type ==
'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT));
242 print '<tr><td class="titlefield">';
243 $labelofbankfield =
"BankToReceiveWithdraw";
244 if ($object->type ==
'bank-transfer') $labelofbankfield =
'BankToPayCreditTransfer';
245 print $langs->trans($labelofbankfield);
249 print $acc->getNomUrl(1);
253 print '<tr><td class="titlefield">';
254 $labelfororderfield =
'WithdrawalFile';
255 if ($object->type ==
'bank-transfer') $labelfororderfield =
'CreditTransferFile';
256 print $langs->trans($labelfororderfield).
'</td><td>';
257 $relativepath =
'receipts/'.$object->ref.
'.xml';
258 $modulepart =
'prelevement';
259 if ($object->type ==
'bank-transfer') $modulepart =
'paymentbybanktransfer';
260 print '<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?type=text/plain&modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'">'.$relativepath.
'</a>';
261 print '</td></tr></table>';
271 if ($action ==
'delete')
273 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'Delete'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
286 if (empty($object->date_trans) && $user->rights->prelevement->bons->send && $action ==
'settransmitted')
288 print '<form method="post" name="userfile" action="card.php?id='.$object->id.
'" enctype="multipart/form-data">';
289 print '<input type="hidden" name="token" value="'.newToken().
'">';
290 print '<input type="hidden" name="action" value="infotrans">';
291 print '<table class="noborder centpercent">';
292 print '<tr class="liste_titre">';
293 print '<td colspan="3">'.$langs->trans(
"NotifyTransmision").
'</td></tr>';
294 print '<tr class="oddeven"><td>'.$langs->trans(
"TransData").
'</td><td>';
295 print $form->selectDate(
'',
'',
'',
'',
'',
"userfile", 1, 1);
297 print '<tr class="oddeven"><td>'.$langs->trans(
"TransMetod").
'</td><td>';
298 print $form->selectarray(
"methode", $object->methodes_trans);
300 print '</table><br>';
301 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"SetToStatusSent")).
'"></div>';
306 if (!empty($object->date_trans) && $object->date_credit == 0 && $user->rights->prelevement->bons->credit && $action ==
'setcredited')
308 print '<form name="infocredit" method="post" action="card.php?id='.$object->id.
'">';
309 print '<input type="hidden" name="token" value="'.newToken().
'">';
310 print '<input type="hidden" name="action" value="infocredit">';
311 print '<table class="noborder centpercent">';
312 print '<tr class="liste_titre">';
313 print '<td colspan="3">'.$langs->trans(
"NotifyCredit").
'</td></tr>';
314 print '<tr class="oddeven"><td>'.$langs->trans(
'CreditDate').
'</td><td>';
315 print $form->selectDate(
'',
'',
'',
'',
'',
"infocredit", 1, 1);
318 print '<br><div class="center"><span class="opacitymedium">'.$langs->trans(
"ThisWillAlsoAddPaymentOnInvoice").
'</span></div>';
319 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"ClassCredited")).
'"></div>';
326 if ($action !=
'settransmitted' && $action !=
'setcredited')
328 print "\n<div class=\"tabsAction\">\n";
330 if (empty($object->date_trans) && $user->rights->prelevement->bons->send)
332 print "<a class=\"butAction\" href=\"card.php?action=settransmitted&token='.newToken().'&id=".$object->id.
"\">".$langs->trans(
"SetToStatusSent").
"</a>";
335 if (!empty($object->date_trans) && $object->date_credit == 0)
337 print "<a class=\"butAction\" href=\"card.php?action=setcredited&token='.newToken().'&id=".$object->id.
"\">".$langs->trans(
"ClassCredited").
"</a>";
340 print "<a class=\"butActionDelete\" href=\"card.php?action=delete&token='.newToken().'&id=".$object->id.
"\">".$langs->trans(
"Delete").
"</a>";
351 $sql =
"SELECT pl.rowid, pl.statut, pl.amount,";
352 $sql .=
" s.rowid as socid, s.nom as name";
353 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
354 $sql .=
", ".MAIN_DB_PREFIX.
"prelevement_bons as pb";
355 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
356 $sql .=
" WHERE pl.fk_prelevement_bons = ".$id;
357 $sql .=
" AND pl.fk_prelevement_bons = pb.rowid";
358 $sql .=
" AND pb.entity = ".$conf->entity;
359 $sql .=
" AND pl.fk_soc = s.rowid";
360 if ($socid) $sql .=
" AND s.rowid = ".$socid;
361 $sql .= $db->order($sortfield, $sortorder);
364 $nbtotalofrecords =
'';
365 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
367 $result = $db->query($sql);
368 $nbtotalofrecords = $db->num_rows($result);
369 if (($page * $limit) > $nbtotalofrecords)
376 $sql .= $db->plimit($limit + 1, $offset);
378 $result = $db->query($sql);
382 $num = $db->num_rows($result);
385 $urladd =
"&id=".$id;
387 print '<form method="get" action="'.$_SERVER [
'PHP_SELF'].
'" name="search_form">'.
"\n";
388 print '<input type="hidden" name="id" value="'.$id.
'"/>';
389 print '<input type="hidden" name="socid" value="'.$socid.
'"/>';
391 print '<input type="hidden" name="page" value="'.$page.
'"/>';
393 if (!empty($limit)) {
394 print '<input type="hidden" name="limit" value="'.$limit.
'"/>';
396 print_barre_liste($langs->trans(
"Lines"), $page,
$_SERVER[
"PHP_SELF"], $urladd, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
398 print '<div class="div-table-responsive-no-min">';
399 print
'<table class="noborder liste" width="100%" cellspacing="0" cellpadding="4">';
400 print
'<tr class="liste_titre">';
409 while ($i < min($num, $limit))
411 $obj = $db->fetch_object($result);
413 print
'<tr class="oddeven">';
417 print $ligne->LibStatut($obj->statut, 2);
419 print
'<a href="'.DOL_URL_ROOT.
'/compta/prelevement/line.php?id='.$obj->rowid.
'&type='.$object->type.
'">';
420 print sprintf(
"%06s", $obj->rowid);
423 $thirdparty =
new Societe($db);
424 $thirdparty->fetch($obj->socid);
426 print $thirdparty->getNomUrl(1);
429 print
'<td class="right">'.price($obj->amount).
"</td>\n";
431 print
'<td class="right">';
433 if ($obj->statut == 3)
435 print
'<b>'.$langs->trans(
"StatusRefused").
'</b>';
437 if ($object->statut == BonPrelevement::STATUS_CREDITED)
439 if ($obj->statut == 2) {
440 if ($user->rights->prelevement->bons->credit)
443 print
'<a href="line.php?action=rejet&type='.$object->type.
'&id='.$obj->rowid.
'">'.$langs->trans(
"StandingOrderReject").
'</a>';
455 $total += $obj->amount;
462 print
'<tr class="liste_total">';
463 print
'<td>'.$langs->trans(
"Total").
'</td>';
464 print
'<td> </td>';
465 print
'<td class="right">';
466 if (empty($offset) && $num <= $limit)
468 if ($total != $object->amount) print
img_warning(
"TotalAmountOfdirectDebitOrderDiffersFromSumOfLines");
472 print
'<td> </td>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage Dolibarr users.
Class to manage bank accounts.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage withdrawal receipts.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
prelevement_prepare_head(BonPrelevement $object)
Prepare array with list of tabs.
print $_SERVER["PHP_SELF"]
Edit parameters.
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).
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.
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.
Class to manage withdrawals.