28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/prelevement.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/ligneprelevement.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
36$langs->loadLangs(array(
'banks',
'categories',
'bills',
'companies',
'withdrawals'));
39$action =
GETPOST(
'action',
'aZ09');
43$socid =
GETPOST(
'socid',
'int');
45$date_trans =
dol_mktime(
GETPOST(
'date_transhour',
'int'),
GETPOST(
'date_transmin',
'int'),
GETPOST(
'date_transsec',
'int'),
GETPOST(
'date_transmonth',
'int'),
GETPOST(
'date_transday',
'int'),
GETPOST(
'date_transyear',
'int'));
48$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
49$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
51$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
52if (empty($page) || $page == -1) {
55$offset = $limit * $page;
60 $sortfield =
'pl.rowid';
69include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
71$hookmanager->initHooks(array(
'directdebitprevcard',
'globalcard',
'directdebitprevlist'));
75if ($type ==
'bank-transfer') {
76 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
78 $permissiontoadd = $user->hasRight(
'paymentbybanktransfer',
'read');
79 $permissiontosend = $user->hasRight(
'paymentbybanktransfer',
'send');
80 $permissiontocreditdebit = $user->hasRight(
'paymentbybanktransfer',
'debit');
81 $permissiontodelete = $user->hasRight(
'paymentbybanktransfer',
'read');
85 $permissiontoadd = $user->hasRight(
'prelevement',
'bons',
'read');
86 $permissiontosend = $user->hasRight(
'prelevement',
'bons',
'send');
87 $permissiontocreditdebit = $user->hasRight(
'prelevement',
'bons',
'credit');
88 $permissiontodelete = $user->hasRight(
'prelevement',
'bons',
'read');
97$parameters = array(
'socid' => $socid);
98$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
103if (empty($reshook)) {
104 if ($action ==
'setbankaccount' && $permissiontoadd) {
106 $object->fk_bank_account =
GETPOST(
'fk_bank_account',
'int');
107 $object->update($user);
111 if ($action ==
'setdate_trans' && $permissiontoadd) {
112 $result = $object->setValueFrom(
'date_trans', $date_trans,
'',
null,
'date');
118 if ($action ==
'infotrans' && $permissiontosend) {
119 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
142 $error = $object->set_infotrans($user, $dt,
GETPOST(
'methode',
'alpha'));
145 header(
"Location: card.php?id=".$id.
"&error=$error");
151 if ($action ==
'infocredit' && $permissiontocreditdebit) {
154 if (($object->type !=
'bank-transfer' && $object->statut == BonPrelevement::STATUS_CREDITED) || ($object->type ==
'bank-transfer' && $object->statut == BonPrelevement::STATUS_DEBITED)) {
158 $error = $object->set_infocredit($user, $dt);
166 if ($action ==
'confirm_delete' && $permissiontodelete) {
167 $savtype = $object->type;
168 $res = $object->delete($user);
170 if ($savtype ==
'bank-transfer') {
171 header(
"Location: ".DOL_URL_ROOT.
'/compta/paymentbybanktransfer/index.php');
173 header(
"Location: ".DOL_URL_ROOT.
'/compta/prelevement/index.php');
186$form =
new Form($db);
188llxHeader(
'', $langs->trans(
"WithdrawalsReceipts"));
190if ($id > 0 || $ref) {
192 print
dol_get_fiche_head($head,
'prelevement', $langs->trans(
"WithdrawalsReceipts"), -1,
'payment');
194 if (
GETPOST(
'error',
'alpha') !=
'') {
195 print
'<div class="error">'.$object->getErrorString(
GETPOST(
'error',
'alpha')).
'</div>';
198 $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>';
202 print
'<div class="fichecenter">';
203 print
'<div class="underbanner clearboth"></div>';
204 print
'<table class="border centpercent tableforfield">';
207 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Date").
'</td><td>'.
dol_print_date($object->datec,
'day').
'</td></tr>';
209 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td><span class="amount">'.
price($object->amount).
'</span></td></tr>';
212 if (!empty($object->date_trans)) {
213 $muser =
new User($db);
214 $muser->fetch($object->user_trans);
218 print
'<table class="nobordernopadding centpercent"><tr><td>';
219 print $langs->trans(
'TransData');
221 if ($action !=
'editdate_trans') {
222 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editdate_trans&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetTransDate'), 1).
'</a></td>';
224 print
'</tr></table>';
226 if ($action ==
'editdate_trans') {
227 print
'<form name="setdate_trans" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
228 print
'<input type="hidden" name="token" value="'.newToken().
'">';
229 print
'<input type="hidden" name="action" value="setdate_trans">';
230 print $form->selectDate($object->date_trans ? $object->date_trans : -1,
'date_trans', 0,
'',
"setdate_trans");
231 print
'<input type="submit" class="button button-edit smallpaddingimp valign middle" value="'.$langs->trans(
'Modify').
'">';
234 print $object->date_trans ?
dol_print_date($object->date_trans,
'day') :
'';
235 print
' <span class="opacitymedium">'.$langs->trans(
"By").
'</span> '.$muser->getNomUrl(-1).
'</td>';
241 print
'<tr><td>'.$langs->trans(
"TransMetod").
'</td><td>';
242 print $object->methodes_trans[$object->method_trans];
247 if (!empty($object->date_credit)) {
248 print
'<tr><td>'.$langs->trans(
'CreditDate').
'</td><td>';
257 print
'<div class="underbanner clearboth"></div>';
258 print
'<table class="border centpercent tableforfield">';
262 $fk_bank_account = $object->fk_bank_account;
263 if (empty($fk_bank_account)) {
264 $fk_bank_account = ($object->type ==
'bank-transfer' ?
getDolGlobalInt(
'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') :
getDolGlobalInt(
'PRELEVEMENT_ID_BANKACCOUNT'));
266 if ($fk_bank_account > 0) {
267 $result = $acc->fetch($fk_bank_account);
271 $labelofbankfield =
"BankToReceiveWithdraw";
272 if ($object->type ==
'bank-transfer') {
273 $labelofbankfield =
'BankToPayCreditTransfer';
276 $caneditbank = $permissiontoadd;
277 if ($object->status != $object::STATUS_DRAFT) {
289 print
'<tr><td class="titlefieldcreate">';
290 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
291 print $form->textwithpicto($langs->trans(
"BankAccount"), $langs->trans($labelofbankfield));
293 if (($action !=
'editbankaccount') && $caneditbank) {
294 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editfkbankaccount&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
296 print
'</tr></table>';
298 if ($action ==
'editfkbankaccount') {
299 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $fk_bank_account,
'fk_bank_account', 0);
301 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $fk_bank_account,
'none');
307 print
'<tr><td class="titlefieldcreate">';
308 $labelfororderfield =
'WithdrawalFile';
309 if ($object->type ==
'bank-transfer') {
310 $labelfororderfield =
'CreditTransferFile';
312 print $langs->trans($labelfororderfield).
'</td><td>';
314 $modulepart =
'prelevement';
315 if ($object->type ==
'bank-transfer') {
316 $modulepart =
'paymentbybanktransfer';
319 if (isModEnabled(
'multicompany')) {
320 $labelentity = $conf->entity;
321 $relativepath =
'receipts/'.$object->ref.
'-'.$labelentity.
'.xml';
323 if ($type !=
'bank-transfer') {
324 $dir = $conf->prelevement->dir_output;
326 $dir = $conf->paymentbybanktransfer->dir_output;
329 $relativepath =
'receipts/'.$object->ref.
'.xml';
332 $relativepath =
'receipts/'.$object->ref.
'.xml';
335 print
'<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?type=text/plain&modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'">'.$relativepath;
336 print
img_picto(
'',
'download',
'class="paddingleft"');
341 $parameters = array();
342 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
343 print $hookmanager->resPrint;
355 if ($action ==
'delete') {
356 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'Delete'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
369 if (empty($object->date_trans) && (($user->rights->prelevement->bons->send && $object->type !=
'bank-transfer') || ($user->rights->paymentbybanktransfer->send && $object->type ==
'bank-transfer')) && $action ==
'settransmitted') {
370 print
'<form method="post" name="userfile" action="card.php?id='.$object->id.
'" enctype="multipart/form-data">';
371 print
'<input type="hidden" name="token" value="'.newToken().
'">';
372 print
'<input type="hidden" name="action" value="infotrans">';
373 print
'<table class="noborder centpercent">';
374 print
'<tr class="liste_titre">';
375 print
'<td colspan="3">'.$langs->trans(
"NotifyTransmision").
'</td></tr>';
376 print
'<tr class="oddeven"><td>'.$langs->trans(
"TransData").
'</td><td>';
377 print $form->selectDate(
'',
'',
'',
'',
'',
"userfile", 1, 1);
379 print
'<tr class="oddeven"><td>'.$langs->trans(
"TransMetod").
'</td><td>';
380 print $form->selectarray(
"methode", $object->methodes_trans);
383 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"SetToStatusSent")).
'"></div>';
388 if (!empty($object->date_trans) && empty($object->date_credit) && (($user->rights->prelevement->bons->credit && $object->type !=
'bank-transfer') || ($user->rights->paymentbybanktransfer->debit && $object->type ==
'bank-transfer')) && $action ==
'setcredited') {
389 $btnLabel = ($object->type ==
'bank-transfer') ? $langs->trans(
"ClassDebited") : $langs->trans(
"ClassCredited");
390 print
'<form name="infocredit" method="post" action="card.php?id='.$object->id.
'">';
391 print
'<input type="hidden" name="token" value="'.newToken().
'">';
392 print
'<input type="hidden" name="action" value="infocredit">';
393 print
'<table class="noborder centpercent">';
394 print
'<tr class="liste_titre">';
395 print
'<td colspan="3">'.$langs->trans(
"NotifyCredit").
'</td></tr>';
396 print
'<tr class="oddeven"><td>'.$langs->trans(
'CreditDate').
'</td><td>';
397 print $form->selectDate(-1,
'',
'',
'',
'',
"infocredit", 1, 1);
400 print
'<br><div class="center"><span class="opacitymedium">'.$langs->trans(
"ThisWillAlsoAddPaymentOnInvoice").
'</span></div>';
401 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($btnLabel).
'"></div>';
407 if ($action !=
'settransmitted' && $action !=
'setcredited') {
408 print
"\n".
'<div class="tabsAction">'.
"\n";
409 $parameters = array();
410 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
411 if (empty($reshook)) {
412 if (empty($object->date_trans)) {
413 if ($object->type ==
'bank-transfer') print
dolGetButtonAction($langs->trans(
"SetToStatusSent"),
'',
'default',
'card.php?action=settransmitted&token='.newToken().
'&id='.$object->id,
'', $user->rights->paymentbybanktransfer->send);
414 else print
dolGetButtonAction($langs->trans(
"SetToStatusSent"),
'',
'default',
'card.php?action=settransmitted&token='.newToken().
'&id='.$object->id,
'', $user->rights->prelevement->bons->send);
416 if (!empty($object->date_trans) && empty($object->date_credit)) {
417 if ($object->type ==
'bank-transfer') print
dolGetButtonAction($langs->trans(
"ClassDebited"),
'',
'default',
'card.php?action=setcredited&token='.newToken().
'&id='.$object->id,
'', $user->rights->paymentbybanktransfer->debit);
418 else print
dolGetButtonAction($langs->trans(
"ClassCredited"),
'',
'default',
'card.php?action=setcredited&token='.newToken().
'&id='.$object->id,
'', $user->rights->prelevement->bons->credit);
421 if ($object->type ==
'bank-transfer') print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete',
'card.php?action=delete&token='.newToken().
'&id='.$object->id,
'', $user->rights->paymentbybanktransfer->create);
422 else print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete',
'card.php?action=delete&token='.newToken().
'&id='.$object->id,
'', $user->rights->prelevement->bons->creer);
433 $sql =
"SELECT pl.rowid, pl.statut, pl.amount,";
434 $sql .=
" s.rowid as socid, s.nom as name";
435 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
436 $sql .=
", ".MAIN_DB_PREFIX.
"prelevement_bons as pb";
437 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
438 $sql .=
" WHERE pl.fk_prelevement_bons = ".((int) $id);
439 $sql .=
" AND pl.fk_prelevement_bons = pb.rowid";
440 $sql .=
" AND pb.entity = ".((int) $conf->entity);
441 $sql .=
" AND pl.fk_soc = s.rowid";
443 $sql .=
" AND s.rowid = ".((int) $socid);
445 $sql .= $db->order($sortfield, $sortorder);
448 $nbtotalofrecords =
'';
450 $result = $db->query($sql);
451 $nbtotalofrecords = $db->num_rows($result);
452 if (($page * $limit) > $nbtotalofrecords) {
459 $sql .= $db->plimit($limit + 1, $offset);
461 $result = $db->query($sql);
464 $num = $db->num_rows($result);
467 $urladd =
"&id=".urlencode($id);
468 if ($limit > 0 && $limit != $conf->liste_limit) {
469 $urladd .=
'&limit='.((int) $limit);
472 print
'<form method="POST" action="'.$_SERVER [
'PHP_SELF'].
'" name="search_form">'.
"\n";
473 print
'<input type="hidden" name="token" value="'.newToken().
'"/>';
474 print
'<input type="hidden" name="id" value="'.$id.
'"/>';
475 print
'<input type="hidden" name="socid" value="'.$socid.
'"/>';
477 print
'<input type="hidden" name="page" value="'.$page.
'"/>';
479 if (!empty($limit)) {
480 print
'<input type="hidden" name="limit" value="'.$limit.
'"/>';
482 if (!empty($sortfield)) {
483 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
485 if (!empty($sortorder)) {
486 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
488 print_barre_liste($langs->trans(
"Lines"), $page, $_SERVER[
"PHP_SELF"], $urladd, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
490 print
'<div class="div-table-responsive-no-min">';
491 print
'<table class="noborder liste centpercent">';
492 print
'<tr class="liste_titre">';
495 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"pl.amount",
"", $urladd,
'class="right"', $sortfield, $sortorder);
501 while ($i < min($num, $limit)) {
502 $obj = $db->fetch_object($result);
504 print
'<tr class="oddeven">';
508 print
'<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/compta/prelevement/line.php?id='.$obj->rowid.
'&type='.$object->type.
'&token='.newToken().
'">';
509 print $ligne->LibStatut($obj->statut, 2);
510 print
'<span class="paddingleft">'.$obj->rowid.
'</span>';
513 $thirdparty =
new Societe($db);
514 $thirdparty->fetch($obj->socid);
516 print $thirdparty->getNomUrl(1);
519 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>\n";
521 print
'<td class="right">';
523 if ($obj->statut == 3) {
524 print
'<span class="error">'.$langs->trans(
"StatusRefused").
'</span>';
526 if ($object->statut == BonPrelevement::STATUS_CREDITED) {
527 if ($obj->statut == LignePrelevement::STATUS_CREDITED) {
528 if ($user->hasRight(
'prelevement',
'bons',
'credit')) {
530 print
'<a href="line.php?action=rejet&type='.$object->type.
'&id='.$obj->rowid.
'&token='.newToken().
'">'.$langs->trans(
"StandingOrderReject").
'</a>';
542 $total += $obj->amount;
550 print
'<tr class="liste_total">';
551 print
'<td>'.$langs->trans(
"Total").
'</td>';
552 print
'<td> </td>';
553 print
'<td class="right">';
554 if (empty($offset) && $num <= $limit) {
556 if ($total != $object->amount) {
557 print
img_warning($langs->trans(
"TotalAmountOfdirectDebitOrderDiffersFromSumOfLines"));
562 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.
dol_is_file($pathoffile)
Return if path is a file.
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...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
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.
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).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
prelevement_prepare_head(BonPrelevement $object)
Prepare array with list of tabs.
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.