29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
34$langs->loadLangs(array(
'banks',
'categories',
'withdrawals'));
36$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
37$massaction =
GETPOST(
'massaction',
'alpha');
38$confirm =
GETPOST(
'confirm',
'alpha');
39$cancel =
GETPOST(
'cancel',
'alpha');
40$toselect =
GETPOST(
'toselect',
'array');
41$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'directdebitcredittransferlist';
42$backtopage =
GETPOST(
'backtopage',
'alpha');
43$optioncss =
GETPOST(
'optioncss',
'alpha');
44$mode =
GETPOST(
'mode',
'alpha');
50$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
57$offset = $limit * $page;
64 $sortfield =
"p.datec";
69$search_ref =
GETPOST(
'search_ref',
'alpha');
70$search_amount =
GETPOST(
'search_amount',
'alpha');
73$hookmanager->initHooks(array(
'withdrawalsreceiptslist'));
75$usercancreate = $user->hasRight(
'prelevement',
'bons',
'creer');
76$permissiontodelete = $user->hasRight(
'prelevement',
'creer');
77if ($type ==
'bank-transfer') {
78 $usercancreate = $user->hasRight(
'paymentbybanktransfer',
'create');
79 $permissiontodelete = $user->hasRight(
'paymentbybanktransfer',
'create');
85 $socid = $user->socid;
87if ($type ==
'bank-transfer') {
88 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
98if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
106if (($massaction ==
"delete" || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
110 foreach ($toselect as $toselectid) {
111 $result = $objecttmp->fetch($toselectid);
113 if ($objecttmp->status != $objecttmp::STATUS_DRAFT || $objecttmp->credite > 0 || $objecttmp->date_creation !=
null) {
114 $langs->load(
"errors");
116 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
119 $result = $objecttmp->delete($user);
137 } elseif ($nbok > 0) {
155$objectclass =
'BonPrelevement';
156$objectlabel =
'BonPrelevement';
157if ($type ==
'bank-transfer') {
158 $uploaddir = $conf->paymentbybanktransfer->dir_output;
160 $uploaddir = $conf->prelevement->dir_output;
162include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
170$titlekey =
"WithdrawalsReceipts";
171$title = $langs->trans(
"WithdrawalsReceipts");
172if ($type ==
'bank-transfer') {
173 $titlekey =
"BankTransferReceipts";
174 $title = $langs->trans(
"BankTransferReceipts");
179$sql =
"SELECT p.rowid, p.ref, p.amount, p.statut, p.datec";
183$sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
184$sql .=
" WHERE p.entity IN (".getEntity(
'invoice').
")";
185if ($type ==
'bank-transfer') {
186 $sql .=
" AND p.type = 'bank-transfer'";
188 $sql .=
" AND p.type = 'debit-order'";
198$nbtotalofrecords =
'';
201 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
202 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
203 $resql = $db->query($sqlforcount);
205 $objforcount = $db->fetch_object($resql);
206 $nbtotalofrecords = $objforcount->nbtotalofrecords;
211 if (($page * $limit) > $nbtotalofrecords) {
219$sql .= $db->order($sortfield, $sortorder);
221 $sql .= $db->plimit($limit + 1, $offset);
224$resql = $db->query($sql);
230$num = $db->num_rows($resql);
235llxHeader(
'', $title, $help_url, 0, 0,
'',
'',
'',
'bodyforlist');
237$arrayofselected = is_array($toselect) ? $toselect : array();
239$param .=
"&statut=".urlencode((
string) ($statut));
240if ($type ==
'bank-transfer') {
241 $param .=
'&type=bank-transfer';
244 $param .=
'&mode='.urlencode($mode);
246if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
247 $param .=
'&contextpage='.urlencode($contextpage);
249if ($limit > 0 && $limit != $conf->liste_limit) {
250 $param .=
'&limit='.((int) $limit);
252if ($optioncss !=
'') {
253 $param .=
'&optioncss='.urlencode($optioncss);
256$arrayofmassactions = array(
260if (!empty($permissiontodelete)) {
261 $arrayofmassactions[
'predeletedraft'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
263$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
265print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
266print
'<input type="hidden" name="token" value="'.newToken().
'">';
267if ($optioncss !=
'') {
268 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
270print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
271print
'<input type="hidden" name="action" value="list">';
272print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
273print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
274print
'<input type="hidden" name="page" value="'.$page.
'">';
275print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
276print
'<input type="hidden" name="page_y" value="">';
277print
'<input type="hidden" name="mode" value="'.$mode.
'">';
280 print
'<input type="hidden" name="type" value="'.$type.
'">';
284$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'));
285$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'));
288 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewStandingOrder'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php?type='.urlencode($type));
291print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit, 0, 0, 1);
293include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
301$parameters = array();
302$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters,
$object, $action);
303if (empty($reshook)) {
304 $moreforfilter .= $hookmanager->resPrint;
306 $moreforfilter = $hookmanager->resPrint;
309if (!empty($moreforfilter)) {
310 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
311 print $moreforfilter;
315$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
316$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
317$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
318$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
320print
'<div class="div-table-responsive">';
321print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
325print
'<tr class="liste_titre_filter">';
328 print
'<td class="liste_titre center maxwidthsearch">';
329 $searchpicto = $form->showFilterButtons(
'left');
333print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
334print
'<td class="liste_titre"> </td>';
335print
'<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
336print
'<td class="liste_titre"> </td>';
339 print
'<td class="liste_titre center maxwidthsearch">';
340 $searchpicto = $form->showFilterButtons();
346$totalarray = array();
347$totalarray[
'nbfield'] = 0;
351print
'<tr class="liste_titre">';
354 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
355 $totalarray[
'nbfield']++;
358$totalarray[
'nbfield']++;
359print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
360$totalarray[
'nbfield']++;
361print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"p.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
362$totalarray[
'nbfield']++;
364$totalarray[
'nbfield']++;
367 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
368 $totalarray[
'nbfield']++;
376$savnbfield = $totalarray[
'nbfield'];
377$totalarray = array();
378$totalarray[
'nbfield'] = 0;
380$imaxinloop = ($limit ? min($num, $limit) : $num);
381while ($i < $imaxinloop) {
382 $obj = $db->fetch_object($resql);
384 $directdebitorder->id = $obj->rowid;
385 $directdebitorder->ref = $obj->ref;
386 $directdebitorder->date_echeance = $obj->datec;
387 $directdebitorder->total = $obj->amount;
388 $directdebitorder->statut = $obj->statut;
392 if ($mode ==
'kanban') {
394 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
395 print
'<div class="box-flex-container kanban">';
398 if ($massactionbutton || $massaction) {
400 if (in_array(
$object->id, $arrayofselected)) {
404 print $directdebitorder->getKanbanView(
'', array(
'selected' => in_array($obj->id, $arrayofselected)));
405 if ($i == ($imaxinloop - 1)) {
412 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
416 print
'<td class="nowrap center">';
417 if ($massactionbutton || $massaction) {
419 if (in_array(
$object->id, $arrayofselected)) {
422 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
426 $totalarray[
'nbfield']++;
431 print $directdebitorder->getNomUrl(1);
434 print
'<td class="center">'.dol_print_date($db->jdate($obj->datec),
'day').
"</td>\n";
436 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>\n";
438 print
'<td class="right">';
439 print $bon->LibStatut($obj->statut, 5);
444 print
'<td class="nowrap center">';
445 if ($massactionbutton || $massaction) {
447 if (in_array(
$object->id, $arrayofselected)) {
450 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
454 $totalarray[
'nbfield']++;
464 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
469$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
470$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters,
$object, $action);
471print $hookmanager->resPrint;
473print
'</table>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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.
print_barre_liste($title, $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.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.