30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/ligneprelevement.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
44$langs->loadLangs(array(
'banks',
'withdrawals',
'companies',
'categories'));
46$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
47$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') :
'directdebitcredittransferlinelist';
53$backtopage =
GETPOST(
'backtopage',
'alpha');
54$optioncss =
GETPOST(
'optioncss',
'aZ');
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 = ($type ==
'bank-transfer' ?
"datec" :
"p.datec");
78$search_line =
GETPOST(
'search_line',
'alpha');
79$search_bon =
GETPOST(
'search_bon',
'alpha');
80$search_code =
GETPOST(
'search_code',
'alpha');
81$search_company =
GETPOST(
'search_company',
'alpha');
87$userstatic =
new User($db);
89$hookmanager->initHooks(array(
'withdrawalsreceiptslineslist'));
94 $socid = $user->socid;
96if ($type ==
'bank-transfer') {
97 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
107if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
111 $search_company =
"";
120$form =
new Form($db);
122$title = $langs->trans(
"WithdrawalsLines");
123if ($type ==
'bank-transfer') {
124 $title = $langs->trans(
"CreditTransferLines");
128$sql =
"SELECT p.rowid, p.ref, p.statut as status, p.datec";
129$sql .=
" , f.rowid as facid, f.ref as invoiceref, f.total_ttc";
130$sql .=
" , s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.email";
131$sql .=
" , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne";
135$sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
136$sql .=
" , ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
137$sql .=
" , ".MAIN_DB_PREFIX.
"prelevement as pf";
138if ($type ==
'bank-transfer') {
139 $sql .=
" , ".MAIN_DB_PREFIX.
"facture_fourn as f";
141 $sql .=
" , ".MAIN_DB_PREFIX.
"facture as f";
143$sql .=
" , ".MAIN_DB_PREFIX.
"societe as s";
144$sql .=
" WHERE pl.fk_prelevement_bons = p.rowid";
145$sql .=
" AND pf.fk_prelevement_lignes = pl.rowid";
146if ($type ==
'bank-transfer') {
147 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
149 $sql .=
" AND pf.fk_facture = f.rowid";
151$sql .=
" AND f.fk_soc = s.rowid";
152$sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
154 $sql .=
" AND s.rowid = ".((int) $socid);
157 $sql .=
" AND pl.rowid = '".$db->escape($search_bon).
"'";
162if ($type ==
'bank-transfer') {
171if ($search_company) {
175if ($type ==
'bank-transfer') {
178 $sql .=
" SELECT p.rowid, p.ref, p.statut as status, p.datec";
179 $sql .=
", sl.rowid as facid, sl.ref as invoiceref, sl.amount";
180 $sql .=
", u.rowid as socid, CONCAT(u.firstname, ' ', u.lastname) as name, u.ref_employee as code_client, NULL as code_fournisseur, u.email";
181 $sql .=
", pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne";
183 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
184 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
185 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement as pf";
186 $sql .=
" , ".MAIN_DB_PREFIX.
"salary as sl";
187 $sql .=
" , ".MAIN_DB_PREFIX.
"user as u";
189 $sql .=
" WHERE pl.fk_prelevement_bons = p.rowid";
190 $sql .=
" AND pf.fk_prelevement_lignes = pl.rowid";
191 $sql .=
" AND pf.fk_salary = sl.rowid";
192 $sql .=
" AND sl.fk_user = u.rowid";
193 $sql .=
" AND sl.entity IN (".getEntity(
'invoice').
")";
195 $sql .=
" AND s.rowid = ".((int) $socid);
198 $sql .=
" AND pl.rowid = '".$db->escape($search_bon).
"'";
203 if ($type ==
'bank-transfer') {
212 if ($search_company) {
213 $sql .=
natural_search(array(
"u.firstname",
"u.lastname"), $search_company);
217$nbtotalofrecords =
'';
220 if ($type ==
'bank-transfer') {
221 $sqlforcount =
"SELECT COUNT(*) as nbtotalofrecords FROM (" . $sql .
") AS combined_results";
223 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
224 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
227 $resql = $db->query($sqlforcount);
229 $objforcount = $db->fetch_object($resql);
230 $nbtotalofrecords = $objforcount->nbtotalofrecords;
235 if (($page * $limit) > $nbtotalofrecords) {
243$sql .= $db->order($sortfield, $sortorder);
245 $sql .= $db->plimit($limit + 1, $offset);
248$resql = $db->query($sql);
254$num = $db->num_rows($resql);
259llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
261$arrayofselected = is_array($toselect) ? $toselect : array();
264$param .=
"&statut=".urlencode($statut);
265$param .=
"&search_bon=".urlencode($search_bon);
266if ($type ==
'bank-transfer') {
267 $param .=
'&type=bank-transfer';
270 $param .=
'&mode='.urlencode($mode);
272if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
273 $param .=
'&contextpage='.urlencode($contextpage);
275if ($limit > 0 && $limit !=
$conf->liste_limit) {
276 $param .=
'&limit='.((int) $limit);
278if ($optioncss !=
'') {
279 $param .=
'&optioncss='.urlencode($optioncss);
282$arrayofmassactions = array(
286$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
288print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
289print
'<input type="hidden" name="token" value="'.newToken().
'">';
290if ($optioncss !=
'') {
291 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
293print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
294print
'<input type="hidden" name="action" value="list">';
295print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
296print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
297print
'<input type="hidden" name="page" value="'.$page.
'">';
298print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
299print
'<input type="hidden" name="page_y" value="">';
300print
'<input type="hidden" name="mode" value="'.$mode.
'">';
303 print
'<input type="hidden" name="type" value="'.$type.
'">';
307$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'));
308$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'));
310print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0, $newcardbutton,
'', $limit, 0, 0, 1);
317$parameters = array();
318$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
319if (empty($reshook)) {
320 $moreforfilter .= $hookmanager->resPrint;
322 $moreforfilter = $hookmanager->resPrint;
325if (!empty($moreforfilter)) {
326 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
327 print $moreforfilter;
331$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
332$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
333$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
334$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
336print
'<div class="div-table-responsive">';
337print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
341print
'<tr class="liste_titre_filter">';
344 print
'<td class="liste_titre center maxwidthsearch">';
345 $searchpicto = $form->showFilterButtons(
'left');
349print
'<td class="liste_titre"><input type="text" class="flat" name="search_line" value="'.dol_escape_htmltag($search_line).
'" size="6"></td>';
350print
'<td class="liste_titre"><input type="text" class="flat" name="search_bon" value="'.dol_escape_htmltag($search_bon).
'" size="6"></td>';
351print
'<td class="liste_titre"> </td>';
352print
'<td class="liste_titre"><input type="text" class="flat" name="search_company" value="'.dol_escape_htmltag($search_company).
'" size="6"></td>';
353print
'<td class="liste_titre center"><input type="text" class="flat" name="search_code" value="'.dol_escape_htmltag($search_code).
'" size="6"></td>';
354print
'<td class="liste_titre"> </td>';
355print
'<td class="liste_titre"> </td>';
358 print
'<td class="liste_titre center maxwidthsearch">';
359 $searchpicto = $form->showFilterButtons();
365$totalarray = array();
366$totalarray[
'nbfield'] = 0;
368$columntitle =
"WithdrawalsReceipts";
369$columntitlethirdparty =
"CustomerCode";
370$columncodethirdparty =
"s.code_client";
371if ($type ==
'bank-transfer') {
372 $columntitle =
"BankTransferReceipts";
373 $columntitlethirdparty =
"SupplierCode";
374 $columncodethirdparty =
"s.code_fournisseur";
379print
'<tr class="liste_titre">';
382 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
383 $totalarray[
'nbfield']++;
386$totalarray[
'nbfield']++;
388$totalarray[
'nbfield']++;
389print_liste_field_titre(($type ==
'bank-transfer' ?
"BillsAndSalaries" :
"Bills"), $_SERVER[
"PHP_SELF"],
"f.ref",
'', $param,
'', $sortfield, $sortorder);
390$totalarray[
'nbfield']++;
392$totalarray[
'nbfield']++;
393print_liste_field_titre($columntitlethirdparty, $_SERVER[
"PHP_SELF"], $columncodethirdparty,
'', $param,
'', $sortfield, $sortorder,
'center ');
394$totalarray[
'nbfield']++;
395print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"p.datec",
"", $param,
'', $sortfield, $sortorder,
'center ');
396$totalarray[
'nbfield']++;
397print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"pl.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
398$totalarray[
'nbfield']++;
401 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
402 $totalarray[
'nbfield']++;
409$savnbfield = $totalarray[
'nbfield'];
410$totalarray = array();
411$totalarray[
'nbfield'] = 0;
413$imaxinloop = ($limit ? min($num, $limit) : $num);
414while ($i < $imaxinloop) {
415 $obj = $db->fetch_object($resql);
417 $bon->id = $obj->rowid;
418 $bon->ref = $obj->ref;
419 $bon->statut = $obj->status;
420 $bon->date_echeance = $obj->datec;
421 $bon->total = $obj->amount;
424 if (
$object->checkIfSalaryBonPrelevement()) {
425 $fullname = explode(
' ', $obj->name);
427 $userstatic->id = $obj->socid;
428 $userstatic->email = $obj->email;
429 $userstatic->firstname = $fullname[0];
430 $userstatic->lastname = isset($fullname[1]) ? $fullname[1] :
'';
433 $company->id = $obj->socid;
434 $company->name = $obj->name;
435 $company->email = $obj->email;
436 $company->code_client = $obj->code_client;
438 if ($mode ==
'kanban') {
440 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
441 print
'<div class="box-flex-container kanban">';
445 if ($massactionbutton || $massaction) {
447 if (in_array(
$object->id, $arrayofselected)) {
451 print
$object->getKanbanView(
'', array(
'selected' => $selected));
452 if ($i == ($imaxinloop - 1)) {
459 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
463 print
'<td class="nowrap center">';
464 if ($massactionbutton || $massaction) {
466 if (in_array(
$object->id, $arrayofselected)) {
469 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
473 $totalarray[
'nbfield']++;
477 print $bon->getNomUrl(1);
481 print $line->LibStatut($obj->statut_ligne, 2);
483 print
'<a href="'.DOL_URL_ROOT.
'/compta/prelevement/line.php?id='.$obj->rowid_ligne.
'">';
484 print substr(
'000000'.$obj->rowid_ligne, -6);
488 print
'<td class="nowraponall">';
489 $link_to_bill =
'/compta/facture/card.php?facid=';
490 $link_title =
'Invoice';
491 $link_picto =
'bill';
492 if ($type ==
'bank-transfer') {
493 if ($bon->checkIfSalaryBonPrelevement()) {
494 $link_to_bill =
'/salaries/card.php?id=';
495 $link_title =
'SalaryInvoice';
496 $link_picto =
'salary';
498 $link_to_bill =
'/fourn/facture/card.php?facid=';
499 $link_title =
'SupplierInvoice';
500 $link_picto =
'supplier_invoice';
503 print
'<a href="'.DOL_URL_ROOT.$link_to_bill.$obj->facid.
'">';
504 print
img_object($langs->trans($link_title), $link_picto);
505 if (!$bon->checkIfSalaryBonPrelevement()) {
506 print
' '.$obj->invoiceref.
"</td>\n";
508 print
' '.(!empty($obj->invoiceref) ? $obj->invoiceref : $obj->facid).
"</td>\n";
514 print
'<td class="tdoverflowmax150">';
515 print(!$bon->checkIfSalaryBonPrelevement() ? $company->getNomUrl(1) : $userstatic->getNomUrl(-1));
518 print
'<td class="center">';
519 $link_to_tab =
'/comm/card.php?socid=';
520 $link_code = $obj->code_client;
521 if ($type ==
'bank-transfer') {
522 $link_to_tab =
'/fourn/card.php?socid=';
523 $link_code = $obj->code_fournisseur;
525 print
'<a href="'.DOL_URL_ROOT.$link_to_tab.$company->id.
'">'.$link_code.
"</a>";
528 print
'<td class="center">'.dol_print_date($db->jdate($obj->datec),
'day').
"</td>\n";
530 print
'<td class="nowraponall right"><span class="amount">'.price($obj->amount).
"</span></td>\n";
534 print
'<td class="nowrap center">';
535 if ($massactionbutton || $massaction) {
537 if (in_array(
$object->id, $arrayofselected)) {
540 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
544 $totalarray[
'nbfield']++;
554 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
559$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
560$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
561print $hookmanager->resPrint;
563print
'</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.
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)
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.
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.
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.