28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/prelevement.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/rejetprelevement.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
38$langs->loadLangs(array(
'banks',
'categories',
'bills',
'companies',
'withdrawals',
'salaries',
'suppliers'));
49$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52if (empty($page) || $page == -1) {
55$offset = $limit * $page;
68include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
70$hookmanager->initHooks(array(
'directdebitprevcard',
'globalcard',
'directdebitprevlist'));
73if ($user->socid > 0) {
78$salaryBonPl =
$object->checkIfSalaryBonPrelevement();
79if ($type ==
'bank-transfer') {
80 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
92$thirdpartytmp =
new Societe($db);
94llxHeader(
'', $langs->trans(
"WithdrawalsReceipts"));
99 $langs->load(
'errors');
100 echo
'<div class="error">'.$langs->trans(
"ErrorRecordNotFound").
'</div>';
107 print
dol_get_fiche_head($head,
'invoices', $langs->trans(
"WithdrawalsReceipts"), -1,
'payment');
109 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/prelevement/orders_list.php?restore_lastsearch_values=1'.(
$object->type !=
'bank-transfer' ?
'' :
'&type=bank-transfer').
'">'.$langs->trans(
"BackToList").
'</a>';
111 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref');
113 print
'<div class="fichecenter">';
114 print
'<div class="underbanner clearboth"></div>';
115 print
'<table class="border centpercent tableforfield">'.
"\n";
118 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Date").
'</td><td>'.
dol_print_date(
$object->datec,
'day').
'</td></tr>';
119 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td><span class="amount">'.
price(
$object->amount).
'</span></td></tr>';
121 if (!empty(
$object->date_trans)) {
122 $muser =
new User($db);
123 $muser->fetch(
$object->user_trans);
125 print
'<tr><td>'.$langs->trans(
"TransData").
'</td><td>';
127 print
' <span class="opacitymedium">'.$langs->trans(
"By").
'</span> '.$muser->getNomUrl(-1).
'</td></tr>';
128 print
'<tr><td>'.$langs->trans(
"TransMetod").
'</td><td>';
132 if (!empty(
$object->date_credit)) {
133 print
'<tr><td>'.$langs->trans(
'CreditDate').
'</td><td>';
142 print
'<div class="underbanner clearboth"></div>';
143 print
'<table class="border centpercent tableforfield">';
147 $fk_bank_account =
$object->fk_bank_account;
148 if (empty($fk_bank_account)) {
151 if ($fk_bank_account > 0) {
152 $result = $acc->fetch($fk_bank_account);
155 $labelofbankfield =
"BankToReceiveWithdraw";
156 if (
$object->type ==
'bank-transfer') {
157 $labelofbankfield =
'BankToPayCreditTransfer';
160 print
'<tr><td class="titlefieldcreate">';
161 print $form->textwithpicto($langs->trans(
"BankAccount"), $langs->trans($labelofbankfield));
166 print $acc->getNomUrl(1);
171 $modulepart =
'prelevement';
172 if (
$object->type ==
'bank-transfer') {
173 $modulepart =
'paymentbybanktransfer';
176 print
'<tr><td class="titlefieldcreate">';
177 $labelfororderfield =
'WithdrawalFile';
178 if (
$object->type ==
'bank-transfer') {
179 $labelfororderfield =
'CreditTransferFile';
181 print $langs->trans($labelfororderfield).
'</td><td>';
183 if (isModEnabled(
'multicompany')) {
184 $labelentity = $conf->entity;
185 $relativepath =
'receipts/'.$object->ref.
'-'.$labelentity.
'.xml';
187 if ($type !=
'bank-transfer') {
188 $dir = $conf->prelevement->dir_output;
190 $dir = $conf->paymentbybanktransfer->dir_output;
193 $relativepath =
'receipts/'.$object->ref.
'.xml';
196 $relativepath =
'receipts/'.$object->ref.
'.xml';
199 print
'<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?type=text/plain&modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'">'.$relativepath;
200 print
img_picto(
'',
'download',
'class="paddingleft"');
202 print
'</td></tr></table>';
212 $sql =
"SELECT pf.rowid, p.type,";
213 $sql .=
" f.rowid as salaryid, f.ref as ref, f.amount,";
214 $sql .=
" u.rowid as userid, u.firstname, u.lastname, pl.statut as status, pl.amount as amount_requested";
215 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
216 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"prelevement_lignes as pl ON pl.fk_prelevement_bons = p.rowid";
217 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"prelevement as pf ON pf.fk_prelevement_lignes = pl.rowid";
218 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"salary as f ON f.rowid = pf.fk_salary AND f.entity IN (".
getEntity(
'salary').
")";
219 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON f.fk_user = u.rowid";
220 $sql .=
" WHERE 1 = 1";
222 $sql .=
" AND p.rowid = ".((int)
$object->id);
225 $sql .=
" AND u.rowid = ".((int) $userid);
228 $sql =
"SELECT pf.rowid, p.type,";
229 $sql .=
" f.rowid as facid, f.ref as ref, f.total_ttc,";
230 if (
$object->type ==
'bank-transfer') {
231 $sql .=
" f.ref_supplier,";
233 $sql .=
" s.rowid as socid, s.nom as name, pl.statut as status, pl.amount as amount_requested";
234 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p,";
235 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
236 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement as pf";
237 if (
$object->type !=
'bank-transfer') {
238 $sql .=
", ".MAIN_DB_PREFIX.
"facture as f";
240 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as f";
242 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
243 $sql .=
" WHERE pf.fk_prelevement_lignes = pl.rowid";
244 $sql .=
" AND pl.fk_prelevement_bons = p.rowid";
245 $sql .=
" AND f.fk_soc = s.rowid";
246 if (
$object->type !=
'bank-transfer') {
247 $sql .=
" AND pf.fk_facture = f.rowid";
249 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
251 if (
$object->type !=
'bank-transfer') {
252 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
254 $sql .=
" AND f.entity IN (".getEntity(
'supplier_invoice').
")";
257 $sql .=
" AND p.rowid = ".((int)
$object->id);
260 $sql .=
" AND s.rowid = ".((int) $socid);
262 $sql .= $db->order($sortfield, $sortorder);
265$nbtotalofrecords =
'';
267 $resql = $db->query($sql);
268 $nbtotalofrecords = $db->num_rows($resql);
269 if (($page * $limit) > $nbtotalofrecords) {
275$sql .= $db->plimit($limit + 1, $offset);
276$resql = $db->query($sql);
278 $num = $db->num_rows($resql);
281 $param =
"&id=".((int) $id);
282 if ($limit > 0 && $limit != $conf->liste_limit) {
283 $param .=
'&limit='.((int) $limit);
287 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
288 if ($optioncss !=
'') {
289 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
291 print
'<input type="hidden" name="token" value="'.newToken().
'">';
292 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
293 print
'<input type="hidden" name="action" value="list">';
294 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
295 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
296 print
'<input type="hidden" name="page" value="'.$page.
'">';
297 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
298 print
'<input type="hidden" name="id" value="'.$id.
'">';
300 $massactionbutton =
'';
301 $title = ($salaryBonPl ? $langs->trans(
"Salaries") : (
$object->type ==
'bank-transfer' ? $langs->trans(
"SupplierInvoices") : $langs->trans(
"Invoices")));
303 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
305 print
"\n<!-- debut table -->\n";
306 print
'<div class="div-table-responsive-no-min">';
307 print
'<table class="liste centpercent">';
308 print
'<tr class="liste_titre">';
309 print_liste_field_titre(($salaryBonPl ?
"Salary" :
"Bill"), $_SERVER[
"PHP_SELF"],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
310 if (
$object->type ==
'bank-transfer' && !$salaryBonPl) {
311 print_liste_field_titre(
"RefSupplierShort", $_SERVER[
"PHP_SELF"],
"f.ref_supplier",
'', $param,
'', $sortfield, $sortorder);
313 print_liste_field_titre(($salaryBonPl ?
"Employee" :
"ThirdParty"), $_SERVER[
"PHP_SELF"],
"s.nom",
'', $param,
'', $sortfield, $sortorder);
314 print_liste_field_titre(($salaryBonPl ?
"AmountSalary" :
"AmountInvoice"), $_SERVER[
"PHP_SELF"],
"f.total_ttc",
"", $param,
'class="right"', $sortfield, $sortorder);
315 print_liste_field_titre(
"AmountRequested", $_SERVER[
"PHP_SELF"],
"pl.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
316 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"",
"", $param,
'align="center"', $sortfield, $sortorder);
320 $totalamount_requested = 0;
323 $salarytmp =
new Salary($db);
324 $usertmp =
new User($db);
326 $invoicetmpcustomer =
new Facture($db);
330 $imaxinloop = ($limit ? min($num, $limit) : $num);
331 while ($i < $imaxinloop) {
332 $obj = $db->fetch_object($resql);
336 if ($salaryBonPl && ($salarytmp instanceof
Salary) && ($usertmp instanceof
User)) {
337 $salarytmp->fetch($obj->salaryid);
338 $usertmp->fetch($obj->userid);
339 $itemurl = $salarytmp->getNomUrl(1);
340 $partyurl = $usertmp->getNomUrl(1);
342 if ($obj->type ==
'bank-transfer') {
343 $invoicetmp = $invoicetmpsupplier;
345 $invoicetmp = $invoicetmpcustomer;
347 $invoicetmp->fetch($obj->facid);
349 $thirdpartytmp->fetch($obj->socid);
350 $itemurl = $invoicetmp->getNomUrl(1);
351 $partyurl = $thirdpartytmp->getNomUrl(1);
354 print
'<tr class="oddeven">';
356 print
'<td class="nowraponall">';
360 if (
$object->type ==
'bank-transfer' && !$salaryBonPl) {
362 if ($invoicetmp instanceof
Facture) {
363 $labeltoshow = $invoicetmp->ref_supplier;
365 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($labeltoshow).
'">';
366 if ($invoicetmp instanceof
Facture) {
372 print
'<td class="tdoverflowmax125">';
377 print
'<td class="right"><span class="amount">'.price(($salaryBonPl ? $obj->amount : $obj->total_ttc)).
"</span></td>\n";
380 print
'<td class="right"><span class="amount">'.price($obj->amount_requested).
"</span></td>\n";
383 print
'<td class="center">';
384 if ($obj->status == 0) {
385 print $langs->trans(
"StatusWaiting");
386 } elseif ($obj->status == 2) {
387 if ($obj->type ==
'bank-transfer') {
388 print $langs->trans(
"StatusDebited");
390 print $langs->trans(
"StatusCredited");
392 } elseif ($obj->status == 3) {
393 print
'<span class="error">'.$langs->trans(
"StatusRefused").
'</span>';
399 $totalinvoices += $obj->total_ttc;
400 $totalamount_requested += $obj->amount_requested;
406 print
'<tr class="liste_total">';
407 print
'<td>'.$langs->trans(
"Total").
'</td>';
408 if (
$object->type ==
'bank-transfer' && !$salaryBonPl) {
409 print
'<td> </td>';
411 print
'<td> </td>';
412 print
'<td class="right">';
414 print
'<td class="right">';
416 if (($nbtotalofrecords <= $num) && $totalamount_requested !=
$object->amount) {
417 print
img_warning(
"AmountOfFileDiffersFromSumOfInvoices");
419 print
price($totalamount_requested);
421 print
'<td> </td>';
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 bank accounts.
Class to manage withdrawal receipts.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage salary payments.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dol_is_file($pathoffile)
Return if path is a file.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show 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...
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
prelevement_prepare_head(BonPrelevement $object)
Prepare array with list of tabs.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.