28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/prelevement.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/ligneprelevement.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
36 $langs->loadLangs(array(
'banks',
'categories',
'bills',
'companies',
'withdrawals'));
39 $action =
GETPOST(
'action',
'aZ09');
42 $socid =
GETPOST(
'socid',
'int');
43 $type =
GETPOST(
'type',
'aZ09');
46 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
47 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
48 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
50 if (empty($page) || $page == -1) {
53 $offset = $limit * $page;
54 $pageprev = $page - 1;
55 $pagenext = $page + 1;
58 $sortfield =
'pl.rowid';
67 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
69 $hookmanager->initHooks(array(
'directdebitprevcard',
'globalcard',
'directdebitprevlist'));
71 $type = $object->type;
73 if ($type ==
'bank-transfer') {
74 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
76 $permissiontoadd = $user->hasRight(
'paymentbybanktransfer',
'read');
77 $permissiontosend = $user->hasRight(
'paymentbybanktransfer',
'send');
78 $permissiontocreditdebit = $user->hasRight(
'paymentbybanktransfer',
'debit');
79 $permissiontodelete = $user->hasRight(
'paymentbybanktransfer',
'read');
83 $permissiontoadd = $user->hasRight(
'prelevement',
'bons',
'read');
84 $permissiontosend = $user->hasRight(
'prelevement',
'bons',
'send');
85 $permissiontocreditdebit = $user->hasRight(
'prelevement',
'bons',
'credit');
86 $permissiontodelete = $user->hasRight(
'prelevement',
'bons',
'read');
96 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
101 if (empty($reshook)) {
102 if ($action ==
'setbankaccount' && $permissiontoadd) {
104 $object->fk_bank_account =
GETPOST(
'fk_bank_account',
'int');
105 $object->update($user);
108 if ($action ==
'infotrans' && $permissiontosend) {
109 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
132 $error = $object->set_infotrans($user, $dt,
GETPOST(
'methode',
'alpha'));
135 header(
"Location: card.php?id=".$id.
"&error=$error");
141 if ($action ==
'infocredit' && $permissiontocreditdebit) {
144 if (($object->type !=
'bank-transfer' && $object->statut == BonPrelevement::STATUS_CREDITED) || ($object->type ==
'bank-transfer' && $object->statut == BonPrelevement::STATUS_DEBITED)) {
148 $error = $object->set_infocredit($user, $dt);
156 if ($action ==
'confirm_delete' && $permissiontodelete) {
157 $savtype = $object->type;
158 $res = $object->delete($user);
160 if ($savtype ==
'bank-transfer') {
161 header(
"Location: ".DOL_URL_ROOT.
'/compta/paymentbybanktransfer/index.php');
163 header(
"Location: ".DOL_URL_ROOT.
'/compta/prelevement/index.php');
178 llxHeader(
'', $langs->trans(
"WithdrawalsReceipts"));
180 if ($id > 0 || $ref) {
182 print
dol_get_fiche_head($head,
'prelevement', $langs->trans(
"WithdrawalsReceipts"), -1,
'payment');
184 if (
GETPOST(
'error',
'alpha') !=
'') {
185 print
'<div class="error">'.$object->getErrorString(
GETPOST(
'error',
'alpha')).
'</div>';
188 $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>';
192 print
'<div class="fichecenter">';
193 print
'<div class="underbanner clearboth"></div>';
194 print
'<table class="border centpercent tableforfield">';
196 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Date").
'</td><td>'.
dol_print_date($object->datec,
'day').
'</td></tr>';
198 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td><span class="amount">'.
price($object->amount).
'</span></td></tr>';
200 if (!empty($object->date_trans)) {
201 $muser =
new User($db);
202 $muser->fetch($object->user_trans);
204 print
'<tr><td>'.$langs->trans(
"TransData").
'</td><td>';
206 print
' <span class="opacitymedium">'.$langs->trans(
"By").
'</span> '.$muser->getNomUrl(-1).
'</td></tr>';
207 print
'<tr><td>'.$langs->trans(
"TransMetod").
'</td><td>';
208 print $object->methodes_trans[$object->method_trans];
211 if (!empty($object->date_credit)) {
212 print
'<tr><td>'.$langs->trans(
'CreditDate').
'</td><td>';
221 print
'<div class="underbanner clearboth"></div>';
222 print
'<table class="border centpercent tableforfield">';
226 $fk_bank_account = $object->fk_bank_account;
227 if (empty($fk_bank_account)) {
228 $fk_bank_account = ($object->type ==
'bank-transfer' ?
getDolGlobalInt(
'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') :
getDolGlobalInt(
'PRELEVEMENT_ID_BANKACCOUNT'));
230 if ($fk_bank_account > 0) {
231 $result = $acc->fetch($fk_bank_account);
235 $labelofbankfield =
"BankToReceiveWithdraw";
236 if ($object->type ==
'bank-transfer') {
237 $labelofbankfield =
'BankToPayCreditTransfer';
240 $caneditbank = $permissiontoadd;
241 if ($object->status != $object::STATUS_DRAFT) {
253 print
'<tr><td class="titlefieldcreate">';
254 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
255 print
$form->textwithpicto($langs->trans(
"BankAccount"), $langs->trans($labelofbankfield));
257 if (($action !=
'editbankaccount') && $caneditbank) {
258 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>';
260 print
'</tr></table>';
262 if ($action ==
'editfkbankaccount') {
263 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $fk_bank_account,
'fk_bank_account', 0);
265 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $fk_bank_account,
'none');
271 print
'<tr><td class="titlefieldcreate">';
272 $labelfororderfield =
'WithdrawalFile';
273 if ($object->type ==
'bank-transfer') {
274 $labelfororderfield =
'CreditTransferFile';
276 print $langs->trans($labelfororderfield).
'</td><td>';
278 $modulepart =
'prelevement';
279 if ($object->type ==
'bank-transfer') {
280 $modulepart =
'paymentbybanktransfer';
284 $labelentity = $conf->entity;
285 $relativepath =
'receipts/'.$object->ref.
'-'.$labelentity.
'.xml';
287 if ($type !=
'bank-transfer') {
288 $dir = $conf->prelevement->dir_output;
290 $dir = $conf->paymentbybanktransfer->dir_output;
293 $relativepath =
'receipts/'.$object->ref.
'.xml';
296 $relativepath =
'receipts/'.$object->ref.
'.xml';
299 print
'<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?type=text/plain&modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'">'.$relativepath;
300 print
img_picto(
'',
'download',
'class="paddingleft"');
306 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
307 print $hookmanager->resPrint;
319 if ($action ==
'delete') {
320 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'Delete'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
333 if (empty($object->date_trans) && (($user->rights->prelevement->bons->send && $object->type !=
'bank-transfer') || ($user->rights->paymentbybanktransfer->send && $object->type ==
'bank-transfer')) && $action ==
'settransmitted') {
334 print
'<form method="post" name="userfile" action="card.php?id='.$object->id.
'" enctype="multipart/form-data">';
335 print
'<input type="hidden" name="token" value="'.newToken().
'">';
336 print
'<input type="hidden" name="action" value="infotrans">';
337 print
'<table class="noborder centpercent">';
338 print
'<tr class="liste_titre">';
339 print
'<td colspan="3">'.$langs->trans(
"NotifyTransmision").
'</td></tr>';
340 print
'<tr class="oddeven"><td>'.$langs->trans(
"TransData").
'</td><td>';
341 print
$form->selectDate(
'',
'',
'',
'',
'',
"userfile", 1, 1);
343 print
'<tr class="oddeven"><td>'.$langs->trans(
"TransMetod").
'</td><td>';
344 print
$form->selectarray(
"methode", $object->methodes_trans);
347 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"SetToStatusSent")).
'"></div>';
352 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') {
353 $btnLabel = ($object->type ==
'bank-transfer') ? $langs->trans(
"ClassDebited") : $langs->trans(
"ClassCredited");
354 print
'<form name="infocredit" method="post" action="card.php?id='.$object->id.
'">';
355 print
'<input type="hidden" name="token" value="'.newToken().
'">';
356 print
'<input type="hidden" name="action" value="infocredit">';
357 print
'<table class="noborder centpercent">';
358 print
'<tr class="liste_titre">';
359 print
'<td colspan="3">'.$langs->trans(
"NotifyCredit").
'</td></tr>';
360 print
'<tr class="oddeven"><td>'.$langs->trans(
'CreditDate').
'</td><td>';
361 print
$form->selectDate(-1,
'',
'',
'',
'',
"infocredit", 1, 1);
364 print
'<br><div class="center"><span class="opacitymedium">'.$langs->trans(
"ThisWillAlsoAddPaymentOnInvoice").
'</span></div>';
365 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($btnLabel).
'"></div>';
371 if ($action !=
'settransmitted' && $action !=
'setcredited') {
372 print
"\n".
'<div class="tabsAction">'.
"\n";
374 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
375 if (empty($reshook)) {
376 if (empty($object->date_trans)) {
377 if ($object->type ==
'bank-transfer') print
dolGetButtonAction($langs->trans(
"SetToStatusSent"),
'',
'default',
'card.php?action=settransmitted&token='.newToken().
'&id='.$object->id,
'', $user->rights->paymentbybanktransfer->send);
378 else print
dolGetButtonAction($langs->trans(
"SetToStatusSent"),
'',
'default',
'card.php?action=settransmitted&token='.newToken().
'&id='.$object->id,
'', $user->rights->prelevement->bons->send);
380 if (!empty($object->date_trans) && empty($object->date_credit)) {
381 if ($object->type ==
'bank-transfer') print
dolGetButtonAction($langs->trans(
"ClassDebited"),
'',
'default',
'card.php?action=setcredited&token='.newToken().
'&id='.$object->id,
'', $user->rights->paymentbybanktransfer->debit);
382 else print
dolGetButtonAction($langs->trans(
"ClassCredited"),
'',
'default',
'card.php?action=setcredited&token='.newToken().
'&id='.$object->id,
'', $user->rights->prelevement->bons->credit);
385 if ($object->type ==
'bank-transfer') print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete',
'card.php?action=delete&token='.newToken().
'&id='.$object->id,
'', $user->rights->paymentbybanktransfer->create);
386 else print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete',
'card.php?action=delete&token='.newToken().
'&id='.$object->id,
'', $user->rights->prelevement->bons->creer);
397 $sql =
"SELECT pl.rowid, pl.statut, pl.amount,";
398 $sql .=
" s.rowid as socid, s.nom as name";
399 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
400 $sql .=
", ".MAIN_DB_PREFIX.
"prelevement_bons as pb";
401 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
402 $sql .=
" WHERE pl.fk_prelevement_bons = ".((int) $id);
403 $sql .=
" AND pl.fk_prelevement_bons = pb.rowid";
404 $sql .=
" AND pb.entity = ".((int) $conf->entity);
405 $sql .=
" AND pl.fk_soc = s.rowid";
407 $sql .=
" AND s.rowid = ".((int) $socid);
409 $sql .= $db->order($sortfield, $sortorder);
412 $nbtotalofrecords =
'';
414 $result = $db->query(
$sql);
415 $nbtotalofrecords = $db->num_rows($result);
416 if (($page * $limit) > $nbtotalofrecords) {
423 $sql .= $db->plimit($limit + 1, $offset);
425 $result = $db->query(
$sql);
428 $num = $db->num_rows($result);
431 $urladd =
"&id=".urlencode($id);
432 if ($limit > 0 && $limit != $conf->liste_limit) {
433 $urladd .=
'&limit='.((int) $limit);
436 print
'<form method="POST" action="'.$_SERVER [
'PHP_SELF'].
'" name="search_form">'.
"\n";
437 print
'<input type="hidden" name="token" value="'.newToken().
'"/>';
438 print
'<input type="hidden" name="id" value="'.$id.
'"/>';
439 print
'<input type="hidden" name="socid" value="'.$socid.
'"/>';
441 print
'<input type="hidden" name="page" value="'.$page.
'"/>';
443 if (!empty($limit)) {
444 print
'<input type="hidden" name="limit" value="'.$limit.
'"/>';
446 if (!empty($sortfield)) {
447 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
449 if (!empty($sortorder)) {
450 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
452 print_barre_liste($langs->trans(
"Lines"), $page, $_SERVER[
"PHP_SELF"], $urladd, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
454 print
'<div class="div-table-responsive-no-min">';
455 print
'<table class="noborder liste centpercent">';
456 print
'<tr class="liste_titre">';
459 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"pl.amount",
"", $urladd,
'class="right"', $sortfield, $sortorder);
465 while ($i < min($num, $limit)) {
466 $obj = $db->fetch_object($result);
468 print
'<tr class="oddeven">';
472 print
'<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/compta/prelevement/line.php?id='.$obj->rowid.
'&type='.$object->type.
'&token='.
newToken().
'">';
473 print $ligne->LibStatut($obj->statut, 2);
474 print
'<span class="paddingleft">'.$obj->rowid.
'</span>';
477 $thirdparty =
new Societe($db);
478 $thirdparty->fetch($obj->socid);
480 print $thirdparty->getNomUrl(1);
483 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>\n";
485 print
'<td class="right">';
487 if ($obj->statut == 3) {
488 print
'<b>'.$langs->trans(
"StatusRefused").
'</b>';
490 if ($object->statut == BonPrelevement::STATUS_CREDITED) {
491 if ($obj->statut == 2) {
492 if ($user->rights->prelevement->bons->credit) {
494 print
'<a href="line.php?action=rejet&type='.$object->type.
'&id='.$obj->rowid.
'&token='.
newToken().
'">'.$langs->trans(
"StandingOrderReject").
'</a>';
506 $total += $obj->amount;
514 print
'<tr class="liste_total">';
515 print
'<td>'.$langs->trans(
"Total").
'</td>';
516 print
'<td> </td>';
517 print
'<td class="right">';
518 if (empty($offset) && $num <= $limit) {
520 if ($total != $object->amount) {
521 print
img_warning($langs->trans(
"TotalAmountOfdirectDebitOrderDiffersFromSumOfLines"));
526 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(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
$formconfirm
if ($action == 'delbookkeepingyear') {
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.