28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
33$langs->loadLangs(array(
'banks',
'categories',
'withdrawals'));
35$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
36$massaction =
GETPOST(
'massaction',
'alpha');
37$confirm =
GETPOST(
'confirm',
'alpha');
38$cancel =
GETPOST(
'cancel',
'alpha');
39$toselect =
GETPOST(
'toselect',
'array');
40$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'directdebitcredittransferlist';
41$backtopage =
GETPOST(
'backtopage',
'alpha');
42$optioncss =
GETPOST(
'optioncss',
'alpha');
43$mode =
GETPOST(
'mode',
'alpha');
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 < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
56$offset = $limit * $page;
63 $sortfield =
"p.datec";
67$statut =
GETPOST(
'statut',
'int');
68$search_ref =
GETPOST(
'search_ref',
'alpha');
69$search_amount =
GETPOST(
'search_amount',
'alpha');
72$hookmanager->initHooks(array(
'withdrawalsreceiptslist'));
74$usercancreate = $user->rights->prelevement->bons->creer;
75$permissiontodelete = $user->hasRight(
'prelevement',
'creer');
76if ($type ==
'bank-transfer') {
77 $usercancreate = $user->rights->paymentbybanktransfer->create;
78 $permissiontodelete = $user->hasRight(
'paymentbybanktransfer',
'create');
82$socid =
GETPOST(
'socid',
'int');
84 $socid = $user->socid;
86if ($type ==
'bank-transfer') {
87 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
97if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
105if (($massaction ==
"delete" || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
108 foreach ($toselect as $toselectid) {
109 $result = $objecttmp->fetch($toselectid);
111 if ($objecttmp->status != $objecttmp::STATUS_DRAFT || $objecttmp->credite > 0 || $objecttmp->date_creation !=
null) {
112 $langs->load(
"errors");
114 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
117 $result = $objecttmp->delete($user);
135 } elseif ($nbok > 0) {
153$objectclass =
'BonPrelevement';
154$objectlabel =
'BonPrelevement';
155$uploaddir = $conf->prelevement->dir_output;
156include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
164$titlekey =
"WithdrawalsReceipts";
165$title = $langs->trans(
"WithdrawalsReceipts");
166if ($type ==
'bank-transfer') {
167 $titlekey =
"BankTransferReceipts";
168 $title = $langs->trans(
"BankTransferReceipts");
173$sql =
"SELECT p.rowid, p.ref, p.amount, p.statut, p.datec";
177$sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
178$sql .=
" WHERE p.entity IN (".getEntity(
'invoice').
")";
179if ($type ==
'bank-transfer') {
180 $sql .=
" AND p.type = 'bank-transfer'";
182 $sql .=
" AND p.type = 'debit-order'";
192$nbtotalofrecords =
'';
195 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
196 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
197 $resql = $db->query($sqlforcount);
199 $objforcount = $db->fetch_object($resql);
200 $nbtotalofrecords = $objforcount->nbtotalofrecords;
205 if (($page * $limit) > $nbtotalofrecords) {
213$sql .= $db->order($sortfield, $sortorder);
215 $sql .= $db->plimit($limit + 1, $offset);
218$resql = $db->query($sql);
224$num = $db->num_rows($resql);
231$arrayofselected = is_array($toselect) ? $toselect : array();
233$param .=
"&statut=".urlencode($statut);
234if ($type ==
'bank-transfer') {
235 $param .=
'&type=bank-transfer';
238 $param .=
'&mode='.urlencode($mode);
240if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
241 $param .=
'&contextpage='.urlencode($contextpage);
243if ($limit > 0 && $limit != $conf->liste_limit) {
244 $param .=
'&limit='.((int) $limit);
246if ($optioncss !=
'') {
247 $param .=
'&optioncss='.urlencode($optioncss);
250$arrayofmassactions = array(
254if (!empty($permissiontodelete)) {
255 $arrayofmassactions[
'predeletedraft'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
257$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
259print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
260print
'<input type="hidden" name="token" value="'.newToken().
'">';
261if ($optioncss !=
'') {
262 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
264print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
265print
'<input type="hidden" name="action" value="list">';
266print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
267print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
268print
'<input type="hidden" name="page" value="'.$page.
'">';
269print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
270print
'<input type="hidden" name="page_y" value="">';
271print
'<input type="hidden" name="mode" value="'.$mode.
'">';
274 print
'<input type="hidden" name="type" value="'.$type.
'">';
278$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss'=>
'reposition'));
279$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss'=>
'reposition'));
282 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewStandingOrder'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php?type='.urlencode($type));
285print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit, 0, 0, 1);
287include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
295$parameters = array();
296$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
297if (empty($reshook)) {
298 $moreforfilter .= $hookmanager->resPrint;
300 $moreforfilter = $hookmanager->resPrint;
303if (!empty($moreforfilter)) {
304 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
305 print $moreforfilter;
306 $parameters = array();
307 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
308 print $hookmanager->resPrint;
312$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
313$selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
314$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
316print
'<div class="div-table-responsive">';
317print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
321print
'<tr class="liste_titre_filter">';
324 print
'<td class="liste_titre center maxwidthsearch">';
325 $searchpicto = $form->showFilterButtons(
'left');
329print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
330print
'<td class="liste_titre"> </td>';
331print
'<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
332print
'<td class="liste_titre"> </td>';
335 print
'<td class="liste_titre center maxwidthsearch">';
336 $searchpicto = $form->showFilterButtons();
342$totalarray = array();
343$totalarray[
'nbfield'] = 0;
347print
'<tr class="liste_titre">';
350 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
351 $totalarray[
'nbfield']++;
354$totalarray[
'nbfield']++;
355print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
356$totalarray[
'nbfield']++;
357print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"p.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
358$totalarray[
'nbfield']++;
360$totalarray[
'nbfield']++;
363 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
364 $totalarray[
'nbfield']++;
372$savnbfield = $totalarray[
'nbfield'];
373$totalarray = array();
374$totalarray[
'nbfield'] = 0;
376$imaxinloop = ($limit ? min($num, $limit) : $num);
377while ($i < $imaxinloop) {
378 $obj = $db->fetch_object($resql);
380 $directdebitorder->id = $obj->rowid;
381 $directdebitorder->ref = $obj->ref;
382 $directdebitorder->date_echeance = $obj->datec;
383 $directdebitorder->total = $obj->amount;
384 $directdebitorder->statut = $obj->statut;
386 $object = $directdebitorder;
388 if ($mode ==
'kanban') {
390 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
391 print
'<div class="box-flex-container kanban">';
394 if ($massactionbutton || $massaction) {
396 if (in_array($object->id, $arrayofselected)) {
400 print $directdebitorder->getKanbanView(
'', array(
'selected' => in_array($obj->id, $arrayofselected)));
401 if ($i == ($imaxinloop - 1)) {
408 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
412 print
'<td class="nowrap center">';
413 if ($massactionbutton || $massaction) {
415 if (in_array($object->id, $arrayofselected)) {
418 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
422 $totalarray[
'nbfield']++;
427 print $directdebitorder->getNomUrl(1);
430 print
'<td class="center">'.dol_print_date($db->jdate($obj->datec),
'day').
"</td>\n";
432 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>\n";
434 print
'<td class="right">';
435 print $bon->LibStatut($obj->statut, 5);
440 print
'<td class="nowrap center">';
441 if ($massactionbutton || $massaction) {
443 if (in_array($object->id, $arrayofselected)) {
446 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
450 $totalarray[
'nbfield']++;
460 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
465$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
466$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
467print $hookmanager->resPrint;
469print
'</table>'.
"\n";
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.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a 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)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.