31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
45$langs->loadLangs(array(
'banks',
'categories',
'withdrawals'));
47$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
48$massaction =
GETPOST(
'massaction',
'alpha');
49$confirm =
GETPOST(
'confirm',
'alpha');
50$cancel =
GETPOST(
'cancel',
'alpha');
51$toselect =
GETPOST(
'toselect',
'array');
52$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'directdebitcredittransferlist';
53$backtopage =
GETPOST(
'backtopage',
'alpha');
54$optioncss =
GETPOST(
'optioncss',
'alpha');
55$mode =
GETPOST(
'mode',
'alpha');
61$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
62$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
64if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
68$offset = $limit * $page;
75 $sortfield =
"p.datec";
80$search_ref =
GETPOST(
'search_ref',
'alpha');
81$search_amount =
GETPOST(
'search_amount',
'alpha');
84$hookmanager->initHooks(array(
'withdrawalsreceiptslist'));
86$usercancreate = $user->hasRight(
'prelevement',
'bons',
'creer');
87$permissiontodelete = $user->hasRight(
'prelevement',
'creer');
88if ($type ==
'bank-transfer') {
89 $usercancreate = $user->hasRight(
'paymentbybanktransfer',
'create');
90 $permissiontodelete = $user->hasRight(
'paymentbybanktransfer',
'create');
96 $socid = $user->socid;
98if ($type ==
'bank-transfer') {
99 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
110if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
118if (($massaction ==
"delete" || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
124 foreach ($toselect as $toselectid) {
125 $result = $objecttmp->fetch($toselectid);
127 if ($objecttmp->status != $objecttmp::STATUS_DRAFT || $objecttmp->credite > 0 || $objecttmp->date_creation !=
null) {
128 $langs->load(
"errors");
130 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
133 $result = $objecttmp->delete($user);
151 } elseif ($nbok > 0) {
169$objectclass =
'BonPrelevement';
170$objectlabel =
'BonPrelevement';
171if ($type ==
'bank-transfer') {
172 $uploaddir =
$conf->paymentbybanktransfer->dir_output;
174 $uploaddir =
$conf->prelevement->dir_output;
176include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
183$form =
new Form($db);
186$titlekey =
"WithdrawalsReceipts";
187$title = $langs->trans(
"WithdrawalsReceipts");
188if ($type ==
'bank-transfer') {
189 $titlekey =
"BankTransferReceipts";
190 $title = $langs->trans(
"BankTransferReceipts");
195$sql =
"SELECT p.rowid, p.ref, p.amount, p.statut, p.datec";
199$sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
200$sql .=
" WHERE p.entity IN (".getEntity(
'invoice').
")";
201if ($type ==
'bank-transfer') {
202 $sql .=
" AND p.type = 'bank-transfer'";
204 $sql .=
" AND p.type = 'debit-order'";
214$nbtotalofrecords =
'';
217 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
218 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
219 $resql = $db->query($sqlforcount);
221 $objforcount = $db->fetch_object($resql);
222 $nbtotalofrecords = $objforcount->nbtotalofrecords;
227 if (($page * $limit) > $nbtotalofrecords) {
235$sql .= $db->order($sortfield, $sortorder);
237 $sql .= $db->plimit($limit + 1, $offset);
240$resql = $db->query($sql);
246$num = $db->num_rows($resql);
251llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
253$arrayofselected = is_array($toselect) ? $toselect : array();
255$param .=
"&statut=".urlencode((
string) ($statut));
256if ($type ==
'bank-transfer') {
257 $param .=
'&type=bank-transfer';
260 $param .=
'&mode='.urlencode($mode);
262if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
263 $param .=
'&contextpage='.urlencode($contextpage);
265if ($limit > 0 && $limit !=
$conf->liste_limit) {
266 $param .=
'&limit='.((int) $limit);
268if ($optioncss !=
'') {
269 $param .=
'&optioncss='.urlencode($optioncss);
272$arrayofmassactions = array(
276if (!empty($permissiontodelete)) {
277 $arrayofmassactions[
'predeletedraft'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
279$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
281print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
282print
'<input type="hidden" name="token" value="'.newToken().
'">';
283if ($optioncss !=
'') {
284 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
286print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
287print
'<input type="hidden" name="action" value="list">';
288print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
289print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
290print
'<input type="hidden" name="page" value="'.$page.
'">';
291print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
292print
'<input type="hidden" name="page_y" value="">';
293print
'<input type="hidden" name="mode" value="'.$mode.
'">';
296 print
'<input type="hidden" name="type" value="'.$type.
'">';
300$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'));
301$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'));
304 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewStandingOrder'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php?type='.urlencode($type));
307print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit, 0, 0, 1);
309include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
317$parameters = array();
318$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters,
$object, $action);
319if (empty($reshook)) {
320 $moreforfilter .= $hookmanager->resPrint;
322 $moreforfilter = $hookmanager->resPrint;
325if (!empty($moreforfilter)) {
326 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
327 print $moreforfilter;
331$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
332$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
333$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
334$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
336print
'<div class="div-table-responsive">';
337print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
341print
'<tr class="liste_titre_filter">';
344 print
'<td class="liste_titre center maxwidthsearch">';
345 $searchpicto = $form->showFilterButtons(
'left');
349print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
350print
'<td class="liste_titre"> </td>';
351print
'<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
352print
'<td class="liste_titre"> </td>';
355 print
'<td class="liste_titre center maxwidthsearch">';
356 $searchpicto = $form->showFilterButtons();
362$totalarray = array();
363$totalarray[
'nbfield'] = 0;
367print
'<tr class="liste_titre">';
370 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
371 $totalarray[
'nbfield']++;
374$totalarray[
'nbfield']++;
375print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
376$totalarray[
'nbfield']++;
377print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"p.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
378$totalarray[
'nbfield']++;
380$totalarray[
'nbfield']++;
383 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
384 $totalarray[
'nbfield']++;
392$savnbfield = $totalarray[
'nbfield'];
393$totalarray = array();
394$totalarray[
'nbfield'] = 0;
396$imaxinloop = ($limit ? min($num, $limit) : $num);
397while ($i < $imaxinloop) {
398 $obj = $db->fetch_object($resql);
400 $directdebitorder->id = $obj->rowid;
401 $directdebitorder->ref = $obj->ref;
402 $directdebitorder->date_echeance = $obj->datec;
403 $directdebitorder->total = $obj->amount;
404 $directdebitorder->statut = $obj->statut;
408 if ($mode ==
'kanban') {
410 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
411 print
'<div class="box-flex-container kanban">';
414 if ($massactionbutton || $massaction) {
416 if (in_array(
$object->id, $arrayofselected)) {
420 print $directdebitorder->getKanbanView(
'', array(
'selected' => in_array($obj->id, $arrayofselected)));
421 if ($i == ($imaxinloop - 1)) {
428 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
432 print
'<td class="nowrap center">';
433 if ($massactionbutton || $massaction) {
435 if (in_array(
$object->id, $arrayofselected)) {
438 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
442 $totalarray[
'nbfield']++;
447 print $directdebitorder->getNomUrl(1);
450 print
'<td class="center">'.dol_print_date($db->jdate($obj->datec),
'day').
"</td>\n";
452 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>\n";
454 print
'<td class="right">';
455 print $bon->LibStatut($obj->statut, 5);
460 print
'<td class="nowrap center">';
461 if ($massactionbutton || $massaction) {
463 if (in_array(
$object->id, $arrayofselected)) {
466 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
470 $totalarray[
'nbfield']++;
480 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
485$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
486$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters,
$object, $action);
487print $hookmanager->resPrint;
489print
'</table>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage withdrawal receipts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.