31require
'../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
44$langs->loadLangs(array(
'banks',
'categories',
'withdrawals'));
46$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
47$massaction =
GETPOST(
'massaction',
'alpha');
48$confirm =
GETPOST(
'confirm',
'alpha');
49$cancel =
GETPOST(
'cancel',
'alpha');
50$toselect =
GETPOST(
'toselect',
'array:int');
51$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'directdebitcredittransferlist';
52$backtopage =
GETPOST(
'backtopage',
'alpha');
53$optioncss =
GETPOST(
'optioncss',
'alpha');
54$mode =
GETPOST(
'mode',
'alpha');
57$search_ref =
GETPOST(
'search_ref',
'alpha');
58$search_amount =
GETPOST(
'search_amount',
'alpha');
64$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
65$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
67if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
71$offset = $limit * $page;
78 $sortfield =
"p.datec";
82$hookmanager->initHooks(array(
'withdrawalsreceiptslist'));
84$usercancreate = $user->hasRight(
'prelevement',
'bons',
'creer');
85$permissiontodelete = $user->hasRight(
'prelevement',
'bons',
'creer');
86$permissiontocreditdebit = $user->hasRight(
'prelevement',
'bons',
'credit');
87if ($type ==
'bank-transfer') {
88 $usercancreate = $user->hasRight(
'paymentbybanktransfer',
'create');
89 $permissiontodelete = $user->hasRight(
'paymentbybanktransfer',
'create');
90 $permissiontocreditdebit = $user->hasRight(
'paymentbybanktransfer',
'debit');
96 $socid = $user->socid;
98if ($type ==
'bank-transfer') {
99 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
106$arrayfields = array();
107foreach (
$object->fields as $key => $val) {
109 if (!empty($val[
'visible'])) {
110 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
111 $arrayfields[$tableprefix.
'.'.$key] = array(
112 'label' => $val[
'label'],
113 'checked' => (($visible < 0) ?
'0' :
'1'),
114 'enabled' => (string) (int) (abs($visible) != 3 && (bool)
dol_eval((string) $val[
'enabled'], 1)),
115 'position' => $val[
'position'],
116 'help' => isset($val[
'help']) ? $val[
'help'] :
''
122include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
124$parameters = array(
'arrayfields' => &$arrayfields);
125$reshook = $hookmanager->executeHooks(
'completeArrayFields', $parameters, $object, $action);
133if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
136 $search_status = array();
142if (($massaction ==
"delete" || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
148 foreach ($toselect as $toselectid) {
149 $result = $objecttmp->fetch($toselectid);
151 if ($objecttmp->status != $objecttmp::STATUS_DRAFT || $objecttmp->credite > 0 || $objecttmp->date_creation !=
null) {
152 $langs->load(
"errors");
154 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).
'</div><br>';
157 $result = $objecttmp->delete($user);
159 setEventMessages($objecttmp->error, $objecttmp->errors,
'errors');
166 setEventMessages($objecttmp->error, $objecttmp->errors,
'errors');
174 setEventMessages($langs->trans(
"RecordsDeleted", $nbok),
null,
'mesgs');
175 } elseif ($nbok > 0) {
176 setEventMessages($langs->trans(
"RecordDeleted", $nbok),
null,
'mesgs');
178 setEventMessages($langs->trans(
"NoRecordDeleted"),
null,
'mesgs');
184 setEventMessages(
'', array_unique($TMsg),
'warnings');
196if ($massaction ==
'classdebited' && $type ==
'bank-transfer' && $permissiontocreditdebit) {
202 $arrayofobjectids = array();
203 foreach ($toselect as $toselectid) {
204 $result = $objecttmp->fetch($toselectid);
206 if ($objecttmp->type !=
'bank-transfer' || $objecttmp->status != BonPrelevement::STATUS_TRANSFERED || empty($objecttmp->date_trans)) {
207 $langs->load(
"errors");
209 $TMsg[] =
'<div class="error">'.$langs->trans(
'ErrorOnlyTransferredStatusCanBeDebitedInMassAction', $objecttmp->ref).
'</div><br>';
212 $arrayofobjectids[] = $objecttmp->id;
214 setEventMessages($objecttmp->error, $objecttmp->errors,
'errors');
225 foreach ($arrayofobjectids as $toselectid) {
226 $result = $objecttmp->fetch($toselectid);
228 $result = $objecttmp->set_infocredit($user, $objecttmp->date_trans, ($objecttmp->checkIfSalaryBonPrelevement() ?
'salary' :
''));
230 setEventMessages($objecttmp->error, $objecttmp->errors,
'errors');
237 setEventMessages($objecttmp->error, $objecttmp->errors,
'errors');
252 setEventMessages($langs->trans(
"RecordsModified", $nbok),
null,
'mesgs');
258 setEventMessages(
'', array_unique($TMsg),
'warnings');
260 } elseif (!empty($TMsg)) {
263 setEventMessages(
'', array_unique($TMsg),
'errors');
267$objectclass =
'BonPrelevement';
268$objectlabel =
'BonPrelevement';
269if ($type ==
'bank-transfer') {
270 $uploaddir =
$conf->paymentbybanktransfer->dir_output;
272 $uploaddir =
$conf->prelevement->dir_output;
274include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
281$form =
new Form($db);
284$titlekey =
"WithdrawalsReceipts";
285$title = $langs->trans(
"WithdrawalsReceipts");
286if ($type ==
'bank-transfer') {
287 $titlekey =
"BankTransferReceipts";
288 $title = $langs->trans(
"BankTransferReceipts");
293$sql =
"SELECT p.rowid, p.ref, p.amount, p.statut as status, p.type, p.date_trans, p.method_trans, p.date_credit, p.fk_bank_account, p.datec, p.tms as datem";
297$sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
298$sql .=
" WHERE p.entity IN (".getEntity(
'invoice').
")";
299if ($type ==
'bank-transfer') {
300 $sql .=
" AND p.type = 'bank-transfer'";
302 $sql .=
" AND p.type = 'debit-order'";
310if (is_array($search_status)) {
311 if (!empty($search_status)) {
312 $sql .=
natural_search(
"p.statut", implode(
',', $search_status), 2);
314} elseif ((
string) $search_status !=
'' && (
string) $search_status !=
'-1') {
319$nbtotalofrecords =
'';
322 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
323 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
324 $resql = $db->query($sqlforcount);
326 $objforcount = $db->fetch_object($resql);
327 $nbtotalofrecords = $objforcount->nbtotalofrecords;
329 dol_print_error($db);
332 if (($page * $limit) > (
int) $nbtotalofrecords) {
340$sql .= $db->order($sortfield, $sortorder);
342 $sql .= $db->plimit($limit + 1, $offset);
345$resql = $db->query($sql);
347 dol_print_error($db);
351$num = $db->num_rows($resql);
356llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
358$arrayofselected = is_array($toselect) ? $toselect : array();
360if ($type ==
'bank-transfer') {
361 $query += [
'type' =>
'bank-transfer'];
364 $query += [
'mode' => $mode];
366if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
367 $query += [
'contextpage' => $contextpage];
369if ($limit > 0 && $limit !=
$conf->liste_limit) {
370 $query += [
'limit' => (int) $limit];
372if ($optioncss !=
'') {
373 $query += [
'optioncss' => $optioncss];
376 $query += [
'search_amount' => $search_amount];
378if (is_array($search_status)) {
379 if (!empty($search_status)) {
380 $query += [
'search_status' => implode(
',', $search_status)];
382} elseif ((
string) $search_status !=
'' && (
string) $search_status !=
'-1') {
383 $query += [
'search_status' => (int) $search_status];
386$arrayofmassactions = array(
390if ($type ==
'bank-transfer' && !empty($permissiontocreditdebit)) {
391 $arrayofmassactions[
'classdebited'] = img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"ClassifyDebitedAtDateOfTransfer");
393if (!empty($permissiontodelete)) {
394 $arrayofmassactions[
'predeletedraft'] = img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
396$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
398print
'<form method="POST" id="searchFormList" spellcheck="false" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
399print
'<input type="hidden" name="token" value="'.newToken().
'">';
400if ($optioncss !=
'') {
401 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
403print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
404print
'<input type="hidden" name="action" value="list">';
405print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
406print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
407print
'<input type="hidden" name="page" value="'.$page.
'">';
408print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
409print
'<input type="hidden" name="page_y" value="">';
410print
'<input type="hidden" name="mode" value="'.$mode.
'">';
413 print
'<input type="hidden" name="type" value="'.$type.
'">';
415$param = http_build_query($query);
418$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'));
419$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'));
420$newcardbutton .=
dolGetButtonTitle($langs->trans(
'Statistics'),
'',
'fa fa-chart-bar imgforviewmode',
dolBuildUrl(DOL_URL_ROOT.
'/compta/prelevement/stats.php', $query),
'', ($mode ==
'statistics' ? 2 : 1), array(
'morecss' =>
'reposition'));
423 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewStandingOrder'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php?type='.urlencode($type));
426print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit, 0, 0, 1);
428include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
436$parameters = array();
437$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
438if (empty($reshook)) {
439 $moreforfilter .= $hookmanager->resPrint;
441 $moreforfilter = $hookmanager->resPrint;
444if (!empty($moreforfilter)) {
445 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
446 print $moreforfilter;
450$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
451$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
452$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
453$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
455print
'<div class="div-table-responsive">';
456print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
460print
'<tr class="liste_titre_filter">';
462if (
$conf->main_checkbox_left_column) {
463 print
'<td class="liste_titre center maxwidthsearch">';
464 $searchpicto = $form->showFilterButtons(
'left');
468print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
469print
'<td class="liste_titre"> </td>';
470print
'<td class="liste_titre"> </td>';
471print
'<td class="liste_titre"> </td>';
472print
'<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
473print
'<td class="liste_titre"> </td>';
474print
'<td class="liste_titre center minwidth75imp parentonrightofpage">';
475$arrayofstatus = array(
476 BonPrelevement::STATUS_DRAFT => $langs->trans(
'StatusWaiting'),
477 BonPrelevement::STATUS_TRANSFERED => $langs->trans(
'StatusTrans'),
478 BonPrelevement::STATUS_CREDITED => $langs->trans(
'Closed'),
479 BonPrelevement::STATUS_CANCELED => $langs->trans(
'Canceled')
481print $form->multiselectarray(
'search_status', $arrayofstatus, $search_status, 0, 0,
'search_status width200 right onrightofpage', 0, 0,
'');
484if (!
$conf->main_checkbox_left_column) {
485 print
'<td class="liste_titre center maxwidthsearch">';
486 $searchpicto = $form->showFilterButtons();
492$totalarray = array();
493$totalarray[
'nbfield'] = 0;
497print
'<tr class="liste_titre">';
499if (
$conf->main_checkbox_left_column) {
500 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
501 $totalarray[
'nbfield']++;
504$totalarray[
'nbfield']++;
505print_liste_field_titre(
"DateCreation", $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
506$totalarray[
'nbfield']++;
507print_liste_field_titre(
"TransData", $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
508$totalarray[
'nbfield']++;
509print_liste_field_titre(
"CreditDate", $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
510$totalarray[
'nbfield']++;
511print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"p.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
512$totalarray[
'nbfield']++;
513print_liste_field_titre(
"BankAccount", $_SERVER[
"PHP_SELF"],
"p.fk_bank_account",
"", $param,
'', $sortfield, $sortorder);
514$totalarray[
'nbfield']++;
516$totalarray[
'nbfield']++;
518if (!
$conf->main_checkbox_left_column) {
519 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
520 $totalarray[
'nbfield']++;
528$savnbfield = $totalarray[
'nbfield'];
529$totalarray = array();
530$totalarray[
'nbfield'] = 0;
532$imaxinloop = ($limit ? min($num, $limit) : $num);
533while ($i < $imaxinloop) {
534 $obj = $db->fetch_object($resql);
536 $directdebitorder->id = $obj->rowid;
537 $directdebitorder->ref = $obj->ref;
538 $directdebitorder->date_creation = $db->jdate($obj->datec);
539 $directdebitorder->date_trans = $db->jdate($obj->date_trans);
540 $directdebitorder->date_credit = $db->jdate($obj->date_credit);
541 $directdebitorder->amount = $obj->amount;
542 $directdebitorder->status = $obj->status;
543 $directdebitorder->type = $obj->type;
547 if ($mode ==
'kanban') {
549 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
550 print
'<div class="box-flex-container kanban">';
553 if ($massactionbutton || $massaction) {
555 if (in_array(
$object->id, $arrayofselected)) {
559 print $directdebitorder->getKanbanView(
'', array(
'selected' => in_array($obj->id, $arrayofselected)));
560 if ($i == ($imaxinloop - 1)) {
566 print
'<tr data-rowid="'.$object->id.
'" class="oddeven row-with-select">';
569 if (
$conf->main_checkbox_left_column) {
570 print
'<td class="nowrap center">';
571 if ($massactionbutton || $massaction) {
573 if (in_array(
$object->id, $arrayofselected)) {
576 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
580 $totalarray[
'nbfield']++;
585 print $directdebitorder->getNomUrl(1);
588 $totalarray[
'nbfield']++;
591 print
'<td class="center">'.dol_print_date($db->jdate($obj->datec),
'day').
"</td>\n";
593 $totalarray[
'nbfield']++;
596 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_trans),
'day').
"</td>\n";
598 $totalarray[
'nbfield']++;
601 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_credit),
'day').
"</td>\n";
603 $totalarray[
'nbfield']++;
606 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>\n";
608 $totalarray[
'nbfield']++;
612 if ($obj->fk_bank_account > 0) {
614 $bankaccount =
new Account($db);
615 $bankaccount->fetch($obj->fk_bank_account);
616 print $bankaccount->getNomUrl(1);
620 $totalarray[
'nbfield']++;
623 print
'<td class="center">';
624 print
$object->LibStatut($obj->status, 5);
627 $totalarray[
'nbfield']++;
631 if (!
$conf->main_checkbox_left_column) {
632 print
'<td class="nowrap center">';
633 if ($massactionbutton || $massaction) {
635 if (in_array(
$object->id, $arrayofselected)) {
638 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
642 $totalarray[
'nbfield']++;
652 print
'<tr><td colspan="'.$savnbfield.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
657$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
658$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
659print $hookmanager->resPrint;
661print
'</table>'.
"\n";
if(! $sortfield) if(! $sortorder) $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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage bank accounts.
Class to manage withdrawal receipts.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
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.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.