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');
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');
52$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
53$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
55if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
59$offset = $limit * $page;
66 $sortfield = ($type ==
'bank-transfer' ?
"datec" :
"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');
78$userstatic =
new User($db);
80$hookmanager->initHooks(array(
'withdrawalsreceiptslineslist'));
85 $socid = $user->socid;
87if ($type ==
'bank-transfer') {
88 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
98if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
102 $search_company =
"";
111$form =
new Form($db);
113$title = $langs->trans(
"WithdrawalsLines");
114if ($type ==
'bank-transfer') {
115 $title = $langs->trans(
"CreditTransferLines");
119$sql =
"SELECT p.rowid, p.ref, p.statut as status, p.datec";
120$sql .=
" , f.rowid as facid, f.ref as invoiceref, f.total_ttc";
121$sql .=
" , s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.email";
122$sql .=
" , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne";
126$sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
127$sql .=
" , ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
128$sql .=
" , ".MAIN_DB_PREFIX.
"prelevement as pf";
129if ($type ==
'bank-transfer') {
130 $sql .=
" , ".MAIN_DB_PREFIX.
"facture_fourn as f";
132 $sql .=
" , ".MAIN_DB_PREFIX.
"facture as f";
134$sql .=
" , ".MAIN_DB_PREFIX.
"societe as s";
135$sql .=
" WHERE pl.fk_prelevement_bons = p.rowid";
136$sql .=
" AND pf.fk_prelevement_lignes = pl.rowid";
137if ($type ==
'bank-transfer') {
138 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
140 $sql .=
" AND pf.fk_facture = f.rowid";
142$sql .=
" AND f.fk_soc = s.rowid";
143$sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
145 $sql .=
" AND s.rowid = ".((int) $socid);
148 $sql .=
" AND pl.rowid = '".$db->escape($search_bon).
"'";
153if ($type ==
'bank-transfer') {
162if ($search_company) {
166if ($type ==
'bank-transfer') {
169 $sql .=
" SELECT p.rowid, p.ref, p.statut as status, p.datec";
170 $sql .=
", sl.rowid as facid, sl.ref as invoiceref, sl.amount";
171 $sql .=
", u.rowid as socid, CONCAT(u.firstname, ' ', u.lastname) as name, u.ref_employee as code_client, NULL as code_fournisseur, u.email";
172 $sql .=
", pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne";
174 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
175 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
176 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement as pf";
177 $sql .=
" , ".MAIN_DB_PREFIX.
"salary as sl";
178 $sql .=
" , ".MAIN_DB_PREFIX.
"user as u";
180 $sql .=
" WHERE pl.fk_prelevement_bons = p.rowid";
181 $sql .=
" AND pf.fk_prelevement_lignes = pl.rowid";
182 $sql .=
" AND pf.fk_salary = sl.rowid";
183 $sql .=
" AND sl.fk_user = u.rowid";
184 $sql .=
" AND sl.entity IN (".getEntity(
'invoice').
")";
186 $sql .=
" AND s.rowid = ".((int) $socid);
189 $sql .=
" AND pl.rowid = '".$db->escape($search_bon).
"'";
194 if ($type ==
'bank-transfer') {
203 if ($search_company) {
204 $sql .=
natural_search(array(
"u.firstname",
"u.lastname"), $search_company);
208$nbtotalofrecords =
'';
211 if ($type ==
'bank-transfer') {
212 $sqlforcount =
"SELECT COUNT(*) as nbtotalofrecords FROM (" . $sql .
") AS combined_results";
214 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
215 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
218 $resql = $db->query($sqlforcount);
220 $objforcount = $db->fetch_object($resql);
221 $nbtotalofrecords = $objforcount->nbtotalofrecords;
226 if (($page * $limit) > $nbtotalofrecords) {
234$sql .= $db->order($sortfield, $sortorder);
236 $sql .= $db->plimit($limit + 1, $offset);
239$resql = $db->query($sql);
245$num = $db->num_rows($resql);
250llxHeader(
'', $title, $help_url, 0, 0,
'',
'',
'',
'bodyforlist');
252$arrayofselected = is_array($toselect) ? $toselect : array();
255$param .=
"&statut=".urlencode($statut);
256$param .=
"&search_bon=".urlencode($search_bon);
257if ($type ==
'bank-transfer') {
258 $param .=
'&type=bank-transfer';
261 $param .=
'&mode='.urlencode($mode);
263if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
264 $param .=
'&contextpage='.urlencode($contextpage);
266if ($limit > 0 && $limit != $conf->liste_limit) {
267 $param .=
'&limit='.((int) $limit);
269if ($optioncss !=
'') {
270 $param .=
'&optioncss='.urlencode($optioncss);
273$arrayofmassactions = array(
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'));
301print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit, 0, 0, 1);
308$parameters = array();
309$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
310if (empty($reshook)) {
311 $moreforfilter .= $hookmanager->resPrint;
313 $moreforfilter = $hookmanager->resPrint;
316if (!empty($moreforfilter)) {
317 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
318 print $moreforfilter;
319 $parameters = array();
320 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
321 print $hookmanager->resPrint;
325$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
326$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
327$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
328$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
330print
'<div class="div-table-responsive">';
331print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
335print
'<tr class="liste_titre_filter">';
338 print
'<td class="liste_titre center maxwidthsearch">';
339 $searchpicto = $form->showFilterButtons(
'left');
343print
'<td class="liste_titre"><input type="text" class="flat" name="search_line" value="'.dol_escape_htmltag($search_line).
'" size="6"></td>';
344print
'<td class="liste_titre"><input type="text" class="flat" name="search_bon" value="'.dol_escape_htmltag($search_bon).
'" size="6"></td>';
345print
'<td class="liste_titre"> </td>';
346print
'<td class="liste_titre"><input type="text" class="flat" name="search_company" value="'.dol_escape_htmltag($search_company).
'" size="6"></td>';
347print
'<td class="liste_titre center"><input type="text" class="flat" name="search_code" value="'.dol_escape_htmltag($search_code).
'" size="6"></td>';
348print
'<td class="liste_titre"> </td>';
349print
'<td class="liste_titre"> </td>';
352 print
'<td class="liste_titre center maxwidthsearch">';
353 $searchpicto = $form->showFilterButtons();
359$totalarray = array();
360$totalarray[
'nbfield'] = 0;
362$columntitle =
"WithdrawalsReceipts";
363$columntitlethirdparty =
"CustomerCode";
364$columncodethirdparty =
"s.code_client";
365if ($type ==
'bank-transfer') {
366 $columntitle =
"BankTransferReceipts";
367 $columntitlethirdparty =
"SupplierCode";
368 $columncodethirdparty =
"s.code_fournisseur";
373print
'<tr class="liste_titre">';
376 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
377 $totalarray[
'nbfield']++;
380$totalarray[
'nbfield']++;
382$totalarray[
'nbfield']++;
383print_liste_field_titre(($type ==
'bank-transfer' ?
"BillsAndSalaries" :
"Bills"), $_SERVER[
"PHP_SELF"],
"f.ref",
'', $param,
'', $sortfield, $sortorder);
384$totalarray[
'nbfield']++;
386$totalarray[
'nbfield']++;
387print_liste_field_titre($columntitlethirdparty, $_SERVER[
"PHP_SELF"], $columncodethirdparty,
'', $param,
'', $sortfield, $sortorder,
'center ');
388$totalarray[
'nbfield']++;
389print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
390$totalarray[
'nbfield']++;
391print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"pl.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
392$totalarray[
'nbfield']++;
395 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
396 $totalarray[
'nbfield']++;
403$savnbfield = $totalarray[
'nbfield'];
404$totalarray = array();
405$totalarray[
'nbfield'] = 0;
407$imaxinloop = ($limit ? min($num, $limit) : $num);
408while ($i < $imaxinloop) {
409 $obj = $db->fetch_object($resql);
411 $bon->id = $obj->rowid;
412 $bon->ref = $obj->ref;
413 $bon->statut = $obj->status;
414 $bon->date_echeance = $obj->datec;
415 $bon->total = $obj->amount;
418 if (
$object->checkIfSalaryBonPrelevement()) {
419 $fullname = explode(
' ', $obj->name);
421 $userstatic->id = $obj->socid;
422 $userstatic->email = $obj->email;
423 $userstatic->firstname = $fullname[0];
424 $userstatic->lastname = isset($fullname[1]) ? $fullname[1] :
'';
427 $company->id = $obj->socid;
428 $company->name = $obj->name;
429 $company->email = $obj->email;
430 $company->code_client = $obj->code_client;
432 if ($mode ==
'kanban') {
434 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
435 print
'<div class="box-flex-container kanban">';
439 if ($massactionbutton || $massaction) {
441 if (in_array(
$object->id, $arrayofselected)) {
445 print
$object->getKanbanView(
'', array(
'selected' => $selected));
446 if ($i == ($imaxinloop - 1)) {
453 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
457 print
'<td class="nowrap center">';
458 if ($massactionbutton || $massaction) {
460 if (in_array(
$object->id, $arrayofselected)) {
463 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
467 $totalarray[
'nbfield']++;
471 print $bon->getNomUrl(1);
475 print $line->LibStatut($obj->statut_ligne, 2);
477 print
'<a href="'.DOL_URL_ROOT.
'/compta/prelevement/line.php?id='.$obj->rowid_ligne.
'">';
478 print substr(
'000000'.$obj->rowid_ligne, -6);
482 print
'<td class="nowraponall">';
483 $link_to_bill =
'/compta/facture/card.php?facid=';
484 $link_title =
'Invoice';
485 $link_picto =
'bill';
486 if ($type ==
'bank-transfer') {
487 if ($bon->checkIfSalaryBonPrelevement()) {
488 $link_to_bill =
'/salaries/card.php?id=';
489 $link_title =
'SalaryInvoice';
490 $link_picto =
'salary';
492 $link_to_bill =
'/fourn/facture/card.php?facid=';
493 $link_title =
'SupplierInvoice';
494 $link_picto =
'supplier_invoice';
497 print
'<a href="'.DOL_URL_ROOT.$link_to_bill.$obj->facid.
'">';
498 print
img_object($langs->trans($link_title), $link_picto);
499 if (!$bon->checkIfSalaryBonPrelevement()) {
500 print
' '.$obj->invoiceref.
"</td>\n";
502 print
' '.(!empty($obj->invoiceref) ? $obj->invoiceref : $obj->facid).
"</td>\n";
508 print
'<td class="tdoverflowmax150">';
509 print(!$bon->checkIfSalaryBonPrelevement() ? $company->getNomUrl(1) : $userstatic->getNomUrl(-1));
512 print
'<td class="center">';
513 $link_to_tab =
'/comm/card.php?socid=';
514 $link_code = $obj->code_client;
515 if ($type ==
'bank-transfer') {
516 $link_to_tab =
'/fourn/card.php?socid=';
517 $link_code = $obj->code_fournisseur;
519 print
'<a href="'.DOL_URL_ROOT.$link_to_tab.$company->id.
'">'.$link_code.
"</a>";
522 print
'<td class="center">'.dol_print_date($db->jdate($obj->datec),
'day').
"</td>\n";
524 print
'<td class="nowraponall right"><span class="amount">'.price($obj->amount).
"</span></td>\n";
528 print
'<td class="nowrap center">';
529 if ($massactionbutton || $massaction) {
531 if (in_array(
$object->id, $arrayofselected)) {
534 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
538 $totalarray[
'nbfield']++;
548 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
553$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
554$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
555print $hookmanager->resPrint;
557print
'</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()
Empty header.
Class to manage withdrawal receipts.
Class to manage withdrawals.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (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.
print_barre_liste($title, $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.
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 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.