29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/ligneprelevement.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
35$langs->loadLangs(array(
'banks',
'withdrawals',
'companies',
'categories'));
37$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
38$massaction =
GETPOST(
'massaction',
'alpha');
39$show_files =
GETPOST(
'show_files',
'int');
40$confirm =
GETPOST(
'confirm',
'alpha');
41$cancel =
GETPOST(
'cancel',
'alpha');
42$toselect =
GETPOST(
'toselect',
'array');
43$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'directdebitcredittransferlinelist';
44$backtopage =
GETPOST(
'backtopage',
'alpha');
45$optioncss =
GETPOST(
'optioncss',
'aZ');
51$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
52$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
53$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
55if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
59$offset = $limit * $page;
66 $sortfield =
"p.datec";
69$search_line =
GETPOST(
'search_line',
'alpha');
70$search_bon =
GETPOST(
'search_bon',
'alpha');
71$search_code =
GETPOST(
'search_code',
'alpha');
72$search_company =
GETPOST(
'search_company',
'alpha');
73$statut =
GETPOST(
'statut',
'int');
79$hookmanager->initHooks(array(
'withdrawalsreceiptslineslist'));
82$socid =
GETPOST(
'socid',
'int');
84 $socid = $user->socid;
86if ($type ==
'bank-transfer') {
87 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
97if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
101 $search_company =
"";
110$form =
new Form($db);
112$title = $langs->trans(
"WithdrawalsLines");
113if ($type ==
'bank-transfer') {
114 $title = $langs->trans(
"CreditTransferLines");
118$sql =
"SELECT p.rowid, p.ref, p.statut as status, p.datec";
119$sql .=
" , f.rowid as facid, f.ref as invoiceref, f.total_ttc";
120$sql .=
" , s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.email";
121$sql .=
" , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne";
125$sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
126$sql .=
" , ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
127$sql .=
" , ".MAIN_DB_PREFIX.
"prelevement as pf";
128if ($type ==
'bank-transfer') {
129 $sql .=
" , ".MAIN_DB_PREFIX.
"facture_fourn as f";
131 $sql .=
" , ".MAIN_DB_PREFIX.
"facture as f";
133$sql .=
" , ".MAIN_DB_PREFIX.
"societe as s";
134$sql .=
" WHERE pl.fk_prelevement_bons = p.rowid";
135$sql .=
" AND pf.fk_prelevement_lignes = pl.rowid";
136if ($type ==
'bank-transfer') {
137 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
139 $sql .=
" AND pf.fk_facture = f.rowid";
141$sql .=
" AND f.fk_soc = s.rowid";
142$sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
144 $sql .=
" AND s.rowid = ".((int) $socid);
147 $sql .=
" AND pl.rowid = '".$db->escape($search_line).
"'";
152if ($type ==
'bank-transfer') {
161if ($search_company) {
166$nbtotalofrecords =
'';
169 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
170 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
171 $resql = $db->query($sqlforcount);
173 $objforcount = $db->fetch_object($resql);
174 $nbtotalofrecords = $objforcount->nbtotalofrecords;
179 if (($page * $limit) > $nbtotalofrecords) {
187$sql .= $db->order($sortfield, $sortorder);
189 $sql .= $db->plimit($limit + 1, $offset);
192$resql = $db->query($sql);
198$num = $db->num_rows($resql);
205$arrayofselected = is_array($toselect) ? $toselect : array();
208$param .=
"&statut=".urlencode($statut);
209$param .=
"&search_bon=".urlencode($search_bon);
210if ($type ==
'bank-transfer') {
211 $param .=
'&type=bank-transfer';
214 $param .=
'&mode='.urlencode($mode);
216if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
217 $param .=
'&contextpage='.urlencode($contextpage);
219if ($limit > 0 && $limit != $conf->liste_limit) {
220 $param .=
'&limit='.((int) $limit);
222if ($optioncss !=
'') {
223 $param .=
'&optioncss='.urlencode($optioncss);
226$arrayofmassactions = array(
230$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
232print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
233print
'<input type="hidden" name="token" value="'.newToken().
'">';
234if ($optioncss !=
'') {
235 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
237print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
238print
'<input type="hidden" name="action" value="list">';
239print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
240print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
241print
'<input type="hidden" name="page" value="'.$page.
'">';
242print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
243print
'<input type="hidden" name="page_y" value="">';
244print
'<input type="hidden" name="mode" value="'.$mode.
'">';
247 print
'<input type="hidden" name="type" value="'.$type.
'">';
251$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'));
252$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'));
254print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit, 0, 0, 1);
261$parameters = array();
262$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
263if (empty($reshook)) {
264 $moreforfilter .= $hookmanager->resPrint;
266 $moreforfilter = $hookmanager->resPrint;
269if (!empty($moreforfilter)) {
270 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
271 print $moreforfilter;
272 $parameters = array();
273 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
274 print $hookmanager->resPrint;
278$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
279$selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
280$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
282print
'<div class="div-table-responsive">';
283print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
287print
'<tr class="liste_titre_filter">';
290 print
'<td class="liste_titre center maxwidthsearch">';
291 $searchpicto = $form->showFilterButtons(
'left');
295print
'<td class="liste_titre"><input type="text" class="flat" name="search_line" value="'.dol_escape_htmltag($search_line).
'" size="6"></td>';
296print
'<td class="liste_titre"><input type="text" class="flat" name="search_bon" value="'.dol_escape_htmltag($search_bon).
'" size="6"></td>';
297print
'<td class="liste_titre"> </td>';
298print
'<td class="liste_titre"><input type="text" class="flat" name="search_company" value="'.dol_escape_htmltag($search_company).
'" size="6"></td>';
299print
'<td class="liste_titre center"><input type="text" class="flat" name="search_code" value="'.dol_escape_htmltag($search_code).
'" size="6"></td>';
300print
'<td class="liste_titre"> </td>';
301print
'<td class="liste_titre"> </td>';
304 print
'<td class="liste_titre center maxwidthsearch">';
305 $searchpicto = $form->showFilterButtons();
311$totalarray = array();
312$totalarray[
'nbfield'] = 0;
314$columntitle =
"WithdrawalsReceipts";
315$columntitlethirdparty =
"CustomerCode";
316$columncodethirdparty =
"s.code_client";
317if ($type ==
'bank-transfer') {
318 $columntitle =
"BankTransferReceipts";
319 $columntitlethirdparty =
"SupplierCode";
320 $columncodethirdparty =
"s.code_fournisseur";
325print
'<tr class="liste_titre">';
328 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
329 $totalarray[
'nbfield']++;
332$totalarray[
'nbfield']++;
334$totalarray[
'nbfield']++;
336$totalarray[
'nbfield']++;
338$totalarray[
'nbfield']++;
339print_liste_field_titre($columntitlethirdparty, $_SERVER[
"PHP_SELF"], $columncodethirdparty,
'', $param,
'', $sortfield, $sortorder,
'center ');
340$totalarray[
'nbfield']++;
341print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
342$totalarray[
'nbfield']++;
343print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"pl.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
344$totalarray[
'nbfield']++;
347 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
348 $totalarray[
'nbfield']++;
355$savnbfield = $totalarray[
'nbfield'];
356$totalarray = array();
357$totalarray[
'nbfield'] = 0;
359$imaxinloop = ($limit ? min($num, $limit) : $num);
360while ($i < $imaxinloop) {
361 $obj = $db->fetch_object($resql);
363 $bon->id = $obj->rowid;
364 $bon->ref = $obj->ref;
365 $bon->statut = $obj->status;
366 $bon->date_echeance = $obj->datec;
367 $bon->total = $obj->amount;
371 $company->id = $obj->socid;
372 $company->name = $obj->name;
373 $company->email = $obj->email;
374 $company->code_client = $obj->code_client;
376 if ($mode ==
'kanban') {
378 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
379 print
'<div class="box-flex-container kanban">';
382 if ($massactionbutton || $massaction) {
384 if (in_array($object->id, $arrayofselected)) {
388 print $object->getKanbanView(
'', array(
'selected' => in_array($bon->id, $arrayofselected)));
389 if ($i == ($imaxinloop - 1)) {
396 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
400 print
'<td class="nowrap center">';
401 if ($massactionbutton || $massaction) {
403 if (in_array($object->id, $arrayofselected)) {
406 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
410 $totalarray[
'nbfield']++;
414 print $bon->getNomUrl(1);
418 print $line->LibStatut($obj->statut_ligne, 2);
420 print
'<a href="'.DOL_URL_ROOT.
'/compta/prelevement/line.php?id='.$obj->rowid_ligne.
'">';
421 print substr(
'000000'.$obj->rowid_ligne, -6);
425 $link_to_bill =
'/compta/facture/card.php?facid=';
426 $link_title =
'Invoice';
427 $link_picto =
'bill';
428 if ($type ==
'bank-transfer') {
429 $link_to_bill =
'/fourn/facture/card.php?facid=';
430 $link_title =
'SupplierInvoice';
431 $link_picto =
'supplier_invoice';
433 print
'<a href="'.DOL_URL_ROOT.$link_to_bill.$obj->facid.
'">';
434 print
img_object($langs->trans($link_title), $link_picto);
435 print
' '.$obj->invoiceref.
"</td>\n";
440 print $company->getNomUrl(1);
444 print
'<td class="center">';
445 $link_to_tab =
'/comm/card.php?socid=';
446 $link_code = $obj->code_client;
447 if ($type ==
'bank-transfer') {
448 $link_to_tab =
'/fourn/card.php?socid=';
449 $link_code = $obj->code_fournisseur;
451 print
'<a href="'.DOL_URL_ROOT.$link_to_tab.$company->id.
'">'.$link_code.
"</a></td>\n";
453 print
'<td class="center">'.dol_print_date($db->jdate($obj->datec),
'day').
"</td>\n";
455 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>\n";
459 print
'<td class="nowrap center">';
460 if ($massactionbutton || $massaction) {
462 if (in_array($object->id, $arrayofselected)) {
465 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
469 $totalarray[
'nbfield']++;
479 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
484$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
485$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
486print $hookmanager->resPrint;
488print
'</table>'.
"\n";
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.
Class to manage withdrawals.
Class to manage third parties objects (customers, suppliers, prospects...)
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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.
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.
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.
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.