28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
30 require_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');
45 $type =
GETPOST(
'type',
'aZ09');
48 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
49 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
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');
76 if ($type ==
'bank-transfer') {
77 $usercancreate = $user->rights->paymentbybanktransfer->create;
78 $permissiontodelete = $user->hasRight(
'paymentbybanktransfer',
'create');
82 $socid =
GETPOST(
'socid',
'int');
84 $socid = $user->socid;
86 if ($type ==
'bank-transfer') {
87 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
97 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
105 if (($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;
156 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
164 $titlekey =
"WithdrawalsReceipts";
165 $title = $langs->trans(
"WithdrawalsReceipts");
166 if ($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').
")";
179 if ($type ==
'bank-transfer') {
180 $sql .=
" AND p.type = 'bank-transfer'";
182 $sql .=
" AND p.type = 'debit-order'";
187 if ($search_amount) {
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);
234 if ($type ==
'bank-transfer') {
235 $param .=
'&type=bank-transfer';
238 $param .=
'&mode='.urlencode($mode);
240 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
241 $param .=
'&contextpage='.urlencode($contextpage);
243 if ($limit > 0 && $limit != $conf->liste_limit) {
244 $param .=
'&limit='.((int) $limit);
246 if ($optioncss !=
'') {
247 $param .=
'&optioncss='.urlencode($optioncss);
250 $arrayofmassactions = array(
254 if (!empty($permissiontodelete)) {
255 $arrayofmassactions[
'predeletedraft'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
257 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
259 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
260 print
'<input type="hidden" name="token" value="'.newToken().
'">';
261 if ($optioncss !=
'') {
262 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
264 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
265 print
'<input type="hidden" name="action" value="list">';
266 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
267 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
268 print
'<input type="hidden" name="page" value="'.$page.
'">';
269 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
270 print
'<input type="hidden" name="page_y" value="">';
271 print
'<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'));
280 if ($usercancreate) {
281 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewStandingOrder'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php?type='.urlencode($type));
284 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit, 0, 0, 1);
286 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
294 $parameters = array();
295 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
296 if (empty($reshook)) {
297 $moreforfilter .= $hookmanager->resPrint;
299 $moreforfilter = $hookmanager->resPrint;
302 if (!empty($moreforfilter)) {
303 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
304 print $moreforfilter;
305 $parameters = array();
306 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
307 print $hookmanager->resPrint;
311 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
312 $selectedfields = ($mode !=
'kanban' ?
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
313 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
315 print
'<div class="div-table-responsive">';
316 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
320 print
'<tr class="liste_titre_filter">';
323 print
'<td class="liste_titre center maxwidthsearch">';
324 $searchpicto =
$form->showFilterButtons(
'left');
328 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
329 print
'<td class="liste_titre"> </td>';
330 print
'<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
331 print
'<td class="liste_titre"> </td>';
334 print
'<td class="liste_titre center maxwidthsearch">';
335 $searchpicto =
$form->showFilterButtons();
341 $totalarray = array();
342 $totalarray[
'nbfield'] = 0;
346 print
'<tr class="liste_titre">';
349 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
350 $totalarray[
'nbfield']++;
353 $totalarray[
'nbfield']++;
354 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
355 $totalarray[
'nbfield']++;
356 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"p.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
357 $totalarray[
'nbfield']++;
359 $totalarray[
'nbfield']++;
362 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
363 $totalarray[
'nbfield']++;
371 $savnbfield = $totalarray[
'nbfield'];
372 $totalarray = array();
373 $totalarray[
'nbfield'] = 0;
375 $imaxinloop = ($limit ? min($num, $limit) : $num);
376 while ($i < $imaxinloop) {
377 $obj = $db->fetch_object($resql);
379 $directdebitorder->id = $obj->rowid;
380 $directdebitorder->ref = $obj->ref;
381 $directdebitorder->date_echeance = $obj->datec;
382 $directdebitorder->total = $obj->amount;
383 $directdebitorder->statut = $obj->statut;
385 $object = $directdebitorder;
387 if ($mode ==
'kanban') {
389 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
390 print
'<div class="box-flex-container kanban">';
393 if ($massactionbutton || $massaction) {
395 if (in_array($object->id, $arrayofselected)) {
399 print $directdebitorder->getKanbanView(
'', array(
'selected' => in_array($obj->id, $arrayofselected)));
400 if ($i == ($imaxinloop - 1)) {
407 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
411 print
'<td class="nowrap center">';
412 if ($massactionbutton || $massaction) {
414 if (in_array($object->id, $arrayofselected)) {
417 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
421 $totalarray[
'nbfield']++;
426 print $directdebitorder->getNomUrl(1);
429 print
'<td class="center">'.dol_print_date($db->jdate($obj->datec),
'day').
"</td>\n";
431 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>\n";
433 print
'<td class="right">';
434 print $bon->LibStatut($obj->statut, 5);
439 print
'<td class="nowrap center">';
440 if ($massactionbutton || $massaction) {
442 if (in_array($object->id, $arrayofselected)) {
445 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
449 $totalarray[
'nbfield']++;
459 print
'<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
464 $parameters = array(
'arrayfields' => $arrayfields,
'sql' =>
$sql);
465 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
466 print $hookmanager->resPrint;
468 print
'</table>'.
"\n";
471 print
'</form>'.
"\n";
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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 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.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.