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';
184$titlekey =
"WithdrawalsReceipts";
185$title = $langs->trans(
"WithdrawalsReceipts");
186if ($type ==
'bank-transfer') {
187 $titlekey =
"BankTransferReceipts";
188 $title = $langs->trans(
"BankTransferReceipts");
193$sql =
"SELECT p.rowid, p.ref, p.amount, p.statut, p.datec";
197$sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
198$sql .=
" WHERE p.entity IN (".getEntity(
'invoice').
")";
199if ($type ==
'bank-transfer') {
200 $sql .=
" AND p.type = 'bank-transfer'";
202 $sql .=
" AND p.type = 'debit-order'";
212$nbtotalofrecords =
'';
215 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
216 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
217 $resql = $db->query($sqlforcount);
219 $objforcount = $db->fetch_object($resql);
220 $nbtotalofrecords = $objforcount->nbtotalofrecords;
225 if (($page * $limit) > $nbtotalofrecords) {
233$sql .= $db->order($sortfield, $sortorder);
235 $sql .= $db->plimit($limit + 1, $offset);
238$resql = $db->query($sql);
244$num = $db->num_rows($resql);
249llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
251$arrayofselected = is_array($toselect) ? $toselect : array();
253$param .=
"&statut=".urlencode((
string) ($statut));
254if ($type ==
'bank-transfer') {
255 $param .=
'&type=bank-transfer';
258 $param .=
'&mode='.urlencode($mode);
260if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
261 $param .=
'&contextpage='.urlencode($contextpage);
263if ($limit > 0 && $limit !=
$conf->liste_limit) {
264 $param .=
'&limit='.((int) $limit);
266if ($optioncss !=
'') {
267 $param .=
'&optioncss='.urlencode($optioncss);
270$arrayofmassactions = array(
274if (!empty($permissiontodelete)) {
275 $arrayofmassactions[
'predeletedraft'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
277$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
279print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
280print
'<input type="hidden" name="token" value="'.newToken().
'">';
281if ($optioncss !=
'') {
282 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
284print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
285print
'<input type="hidden" name="action" value="list">';
286print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
287print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
288print
'<input type="hidden" name="page" value="'.$page.
'">';
289print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
290print
'<input type="hidden" name="page_y" value="">';
291print
'<input type="hidden" name="mode" value="'.$mode.
'">';
294 print
'<input type="hidden" name="type" value="'.$type.
'">';
298$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'));
299$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'));
302 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewStandingOrder'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php?type='.urlencode($type));
305print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit, 0, 0, 1);
307include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
315$parameters = array();
316$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters,
$object, $action);
317if (empty($reshook)) {
318 $moreforfilter .= $hookmanager->resPrint;
320 $moreforfilter = $hookmanager->resPrint;
323if (!empty($moreforfilter)) {
324 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
325 print $moreforfilter;
329$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
330$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
331$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
332$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
334print
'<div class="div-table-responsive">';
335print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
339print
'<tr class="liste_titre_filter">';
342 print
'<td class="liste_titre center maxwidthsearch">';
343 $searchpicto = $form->showFilterButtons(
'left');
347print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
348print
'<td class="liste_titre"> </td>';
349print
'<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
350print
'<td class="liste_titre"> </td>';
353 print
'<td class="liste_titre center maxwidthsearch">';
354 $searchpicto = $form->showFilterButtons();
360$totalarray = array();
361$totalarray[
'nbfield'] = 0;
365print
'<tr class="liste_titre">';
368 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
369 $totalarray[
'nbfield']++;
372$totalarray[
'nbfield']++;
373print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
374$totalarray[
'nbfield']++;
375print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"p.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
376$totalarray[
'nbfield']++;
378$totalarray[
'nbfield']++;
381 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
382 $totalarray[
'nbfield']++;
390$savnbfield = $totalarray[
'nbfield'];
391$totalarray = array();
392$totalarray[
'nbfield'] = 0;
394$imaxinloop = ($limit ? min($num, $limit) : $num);
395while ($i < $imaxinloop) {
396 $obj = $db->fetch_object($resql);
398 $directdebitorder->id = $obj->rowid;
399 $directdebitorder->ref = $obj->ref;
400 $directdebitorder->date_echeance = $obj->datec;
401 $directdebitorder->total = $obj->amount;
402 $directdebitorder->statut = $obj->statut;
406 if ($mode ==
'kanban') {
408 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
409 print
'<div class="box-flex-container kanban">';
412 if ($massactionbutton || $massaction) {
414 if (in_array(
$object->id, $arrayofselected)) {
418 print $directdebitorder->getKanbanView(
'', array(
'selected' => in_array($obj->id, $arrayofselected)));
419 if ($i == ($imaxinloop - 1)) {
426 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
430 print
'<td class="nowrap center">';
431 if ($massactionbutton || $massaction) {
433 if (in_array(
$object->id, $arrayofselected)) {
436 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
440 $totalarray[
'nbfield']++;
445 print $directdebitorder->getNomUrl(1);
448 print
'<td class="center">'.dol_print_date($db->jdate($obj->datec),
'day').
"</td>\n";
450 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>\n";
452 print
'<td class="right">';
453 print $bon->LibStatut($obj->statut, 5);
458 print
'<td class="nowrap center">';
459 if ($massactionbutton || $massaction) {
461 if (in_array(
$object->id, $arrayofselected)) {
464 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
468 $totalarray[
'nbfield']++;
478 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
483$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
484$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters,
$object, $action);
485print $hookmanager->resPrint;
487print
'</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($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)
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.