28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/prelevement.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/ligneprelevement.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
35 $langs->loadLangs(array(
'banks',
'categories',
'bills',
'companies',
'withdrawals'));
38 $action =
GETPOST(
'action',
'aZ09');
41 $socid =
GETPOST(
'socid',
'int');
42 $type =
GETPOST(
'type',
'aZ09');
45 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
46 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
47 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
49 if (empty($page) || $page == -1) {
52 $offset = $limit * $page;
53 $pageprev = $page - 1;
54 $pagenext = $page + 1;
57 $sortfield =
'pl.rowid';
66 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
68 $hookmanager->initHooks(array(
'directdebitprevcard',
'globalcard',
'directdebitprevlist'));
70 $type = $object->type;
72 if ($type ==
'bank-transfer') {
73 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
84 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
89 if (empty($reshook)) {
90 if ($action ==
'confirm_delete') {
91 $savtype = $object->type;
92 $res = $object->delete($user);
94 if ($savtype ==
'bank-transfer') {
95 header(
"Location: ".DOL_URL_ROOT.
'/compta/paymentbybanktransfer/index.php');
97 header(
"Location: ".DOL_URL_ROOT.
'/compta/prelevement/index.php');
103 if ($action ==
'infotrans' && (($user->rights->prelevement->bons->send && $object->type !=
'bank-transfer') || ($user->rights->paymentbybanktransfer->send && $object->type ==
'bank-transfer'))) {
104 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
127 $error = $object->set_infotrans($user, $dt,
GETPOST(
'methode',
'alpha'));
130 header(
"Location: card.php?id=".$id.
"&error=$error");
136 if ($action ==
'infocredit' && (($user->rights->prelevement->bons->credit && $object->type !=
'bank-transfer') || ($user->rights->paymentbybanktransfer->debit && $object->type ==
'bank-transfer'))) {
139 if (($object->type !=
'bank-transfer' && $object->statut == BonPrelevement::STATUS_CREDITED) || ($object->type ==
'bank-transfer' && $object->statut == BonPrelevement::STATUS_DEBITED)) {
143 $error = $object->set_infocredit($user, $dt);
160 llxHeader(
'', $langs->trans(
"WithdrawalsReceipts"));
162 if ($id > 0 || $ref) {
164 print
dol_get_fiche_head($head,
'prelevement', $langs->trans(
"WithdrawalsReceipts"), -1,
'payment');
166 if (
GETPOST(
'error',
'alpha') !=
'') {
167 print
'<div class="error">'.$object->getErrorString(
GETPOST(
'error',
'alpha')).
'</div>';
170 $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>';
174 print
'<div class="fichecenter">';
175 print
'<div class="underbanner clearboth"></div>';
176 print
'<table class="border centpercent tableforfield">';
178 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Date").
'</td><td>'.
dol_print_date($object->datec,
'day').
'</td></tr>';
180 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td><span class="amount">'.
price($object->amount).
'</span></td></tr>';
189 if (!empty($object->date_trans)) {
190 $muser =
new User($db);
191 $muser->fetch($object->user_trans);
193 print
'<tr><td>'.$langs->trans(
"TransData").
'</td><td>';
195 print
' <span class="opacitymedium">'.$langs->trans(
"By").
'</span> '.$muser->getNomUrl(-1).
'</td></tr>';
196 print
'<tr><td>'.$langs->trans(
"TransMetod").
'</td><td>';
197 print $object->methodes_trans[$object->method_trans];
200 if (!empty($object->date_credit)) {
201 print
'<tr><td>'.$langs->trans(
'CreditDate').
'</td><td>';
210 print
'<div class="underbanner clearboth"></div>';
211 print
'<table class="border centpercent tableforfield">';
214 $result = $acc->fetch(($object->type ==
'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT));
216 print
'<tr><td class="titlefieldcreate">';
217 $labelofbankfield =
"BankToReceiveWithdraw";
218 if ($object->type ==
'bank-transfer') {
219 $labelofbankfield =
'BankToPayCreditTransfer';
221 print $langs->trans($labelofbankfield);
225 print $acc->getNomUrl(1);
230 print
'<tr><td class="titlefieldcreate">';
231 $labelfororderfield =
'WithdrawalFile';
232 if ($object->type ==
'bank-transfer') {
233 $labelfororderfield =
'CreditTransferFile';
235 print $langs->trans($labelfororderfield).
'</td><td>';
236 $relativepath =
'receipts/'.$object->ref.
'.xml';
237 $modulepart =
'prelevement';
238 if ($object->type ==
'bank-transfer') {
239 $modulepart =
'paymentbybanktransfer';
241 print
'<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?type=text/plain&modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'">'.$relativepath;
242 print
img_picto(
'',
'download',
'class="paddingleft"');
248 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
249 print $hookmanager->resPrint;
261 if ($action ==
'delete') {
262 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'Delete'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
275 if (empty($object->date_trans) && $user->rights->prelevement->bons->send && $action ==
'settransmitted') {
276 print
'<form method="post" name="userfile" action="card.php?id='.$object->id.
'" enctype="multipart/form-data">';
277 print
'<input type="hidden" name="token" value="'.newToken().
'">';
278 print
'<input type="hidden" name="action" value="infotrans">';
279 print
'<table class="noborder centpercent">';
280 print
'<tr class="liste_titre">';
281 print
'<td colspan="3">'.$langs->trans(
"NotifyTransmision").
'</td></tr>';
282 print
'<tr class="oddeven"><td>'.$langs->trans(
"TransData").
'</td><td>';
283 print
$form->selectDate(
'',
'',
'',
'',
'',
"userfile", 1, 1);
285 print
'<tr class="oddeven"><td>'.$langs->trans(
"TransMetod").
'</td><td>';
286 print
$form->selectarray(
"methode", $object->methodes_trans);
289 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"SetToStatusSent")).
'"></div>';
294 if (!empty($object->date_trans) && empty($object->date_credit) && $user->rights->prelevement->bons->credit && $action ==
'setcredited') {
295 $btnLabel = ($object->type ==
'bank-transfer') ? $langs->trans(
"ClassDebited") : $langs->trans(
"ClassCredited");
296 print
'<form name="infocredit" method="post" action="card.php?id='.$object->id.
'">';
297 print
'<input type="hidden" name="token" value="'.newToken().
'">';
298 print
'<input type="hidden" name="action" value="infocredit">';
299 print
'<table class="noborder centpercent">';
300 print
'<tr class="liste_titre">';
301 print
'<td colspan="3">'.$langs->trans(
"NotifyCredit").
'</td></tr>';
302 print
'<tr class="oddeven"><td>'.$langs->trans(
'CreditDate').
'</td><td>';
303 print
$form->selectDate(-1,
'',
'',
'',
'',
"infocredit", 1, 1);
306 print
'<br><div class="center"><span class="opacitymedium">'.$langs->trans(
"ThisWillAlsoAddPaymentOnInvoice").
'</span></div>';
307 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($btnLabel).
'"></div>';
313 if ($action !=
'settransmitted' && $action !=
'setcredited') {
314 print
"\n".
'<div class="tabsAction">'.
"\n";
316 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
317 if (empty($reshook)) {
318 if (empty($object->date_trans)) {
319 if ($object->type ==
'bank-transfer') print
dolGetButtonAction($langs->trans(
"SetToStatusSent"),
'',
'default',
'card.php?action=settransmitted&token='.newToken().
'&id='.$object->id,
'', $user->rights->paymentbybanktransfer->send);
320 else print
dolGetButtonAction($langs->trans(
"SetToStatusSent"),
'',
'default',
'card.php?action=settransmitted&token='.newToken().
'&id='.$object->id,
'', $user->rights->prelevement->bons->send);
322 if (!empty($object->date_trans) && empty($object->date_credit)) {
323 if ($object->type ==
'bank-transfer') print
dolGetButtonAction($langs->trans(
"ClassDebited"),
'',
'default',
'card.php?action=setcredited&token='.newToken().
'&id='.$object->id,
'', $user->rights->paymentbybanktransfer->debit);
324 else print
dolGetButtonAction($langs->trans(
"ClassCredited"),
'',
'default',
'card.php?action=setcredited&token='.newToken().
'&id='.$object->id,
'', $user->rights->prelevement->bons->credit);
327 if ($object->type ==
'bank-transfer') print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete',
'card.php?action=delete&token='.newToken().
'&id='.$object->id,
'', $user->rights->paymentbybanktransfer->create);
328 else print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete',
'card.php?action=delete&token='.newToken().
'&id='.$object->id,
'', $user->rights->prelevement->bons->creer);
339 $sql =
"SELECT pl.rowid, pl.statut, pl.amount,";
340 $sql .=
" s.rowid as socid, s.nom as name";
341 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
342 $sql .=
", ".MAIN_DB_PREFIX.
"prelevement_bons as pb";
343 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
344 $sql .=
" WHERE pl.fk_prelevement_bons = ".((int) $id);
345 $sql .=
" AND pl.fk_prelevement_bons = pb.rowid";
346 $sql .=
" AND pb.entity = ".((int) $conf->entity);
347 $sql .=
" AND pl.fk_soc = s.rowid";
349 $sql .=
" AND s.rowid = ".((int) $socid);
351 $sql .= $db->order($sortfield, $sortorder);
355 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
356 $result = $db->query($sql);
365 $sql .= $db->plimit($limit + 1, $offset);
367 $result = $db->query($sql);
370 $num = $db->num_rows($result);
373 $urladd =
"&id=".urlencode($id);
374 if ($limit > 0 && $limit != $conf->liste_limit) {
375 $urladd .=
'&limit='.urlencode($limit);
378 print
'<form method="POST" action="'.$_SERVER [
'PHP_SELF'].
'" name="search_form">'.
"\n";
379 print
'<input type="hidden" name="token" value="'.newToken().
'"/>';
380 print
'<input type="hidden" name="id" value="'.$id.
'"/>';
381 print
'<input type="hidden" name="socid" value="'.$socid.
'"/>';
383 print
'<input type="hidden" name="page" value="'.$page.
'"/>';
385 if (!empty($limit)) {
386 print
'<input type="hidden" name="limit" value="'.$limit.
'"/>';
388 if (!empty($sortfield)) {
389 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
391 if (!empty($sortorder)) {
392 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
394 print_barre_liste($langs->trans(
"Lines"), $page, $_SERVER[
"PHP_SELF"], $urladd, $sortfield, $sortorder,
'', $num,
$nbtotalofrecords,
'', 0,
'',
'', $limit);
396 print
'<div class="div-table-responsive-no-min">';
397 print
'<table class="noborder liste" width="100%" cellpadding="4">';
398 print
'<tr class="liste_titre">';
401 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"pl.amount",
"", $urladd,
'class="right"', $sortfield, $sortorder);
407 while ($i < min($num, $limit)) {
408 $obj = $db->fetch_object($result);
410 print
'<tr class="oddeven">';
414 print
'<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/compta/prelevement/line.php?id='.$obj->rowid.
'&type='.$object->type.
'&token='.
newToken().
'">';
415 print $ligne->LibStatut($obj->statut, 2);
416 print
'<span class="paddingleft">'.$obj->rowid.
'</span>';
419 $thirdparty =
new Societe($db);
420 $thirdparty->fetch($obj->socid);
422 print $thirdparty->getNomUrl(1);
425 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>\n";
427 print
'<td class="right">';
429 if ($obj->statut == 3) {
430 print
'<b>'.$langs->trans(
"StatusRefused").
'</b>';
432 if ($object->statut == BonPrelevement::STATUS_CREDITED) {
433 if ($obj->statut == 2) {
434 if ($user->rights->prelevement->bons->credit) {
436 print
'<a href="line.php?action=rejet&type='.$object->type.
'&id='.$obj->rowid.
'&token='.
newToken().
'">'.$langs->trans(
"StandingOrderReject").
'</a>';
448 $total += $obj->amount;
456 print
'<tr class="liste_total">';
457 print
'<td>'.$langs->trans(
"Total").
'</td>';
458 print
'<td> </td>';
459 print
'<td class="right">';
460 if (empty($offset) && $num <= $limit) {
462 if ($total != $object->amount) {
463 print
img_warning($langs->trans(
"TotalAmountOfdirectDebitOrderDiffersFromSumOfLines"));
468 print
'<td> </td>';
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
Class to manage withdrawal receipts.
Class to manage withdrawals.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
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...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 from a POST of a form.
$formconfirm
if ($action == 'delbookkeepingyear') {
prelevement_prepare_head(BonPrelevement $object)
Prepare array with list of tabs.
$nbtotalofrecords
Count total nb of records.
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.