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'));
40$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
41$optioncss =
GETPOST(
'optioncss',
'aZ');
52$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
53$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
55if (empty($page) || $page == -1) {
58$offset = $limit * $page;
71include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
73$hookmanager->initHooks(array(
'directdebitprevcard',
'globalcard',
'directdebitprevlist'));
76if ($user->socid > 0) {
81$salaryBonPl =
$object->checkIfSalaryBonPrelevement();
82if ($type ==
'bank-transfer') {
83 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
95$thirdpartytmp =
new Societe($db);
97llxHeader(
'', $langs->trans(
"WithdrawalsReceipts"));
101 $langs->load(
'errors');
102 echo
'<div class="error">'.$langs->trans(
"ErrorRecordNotFound").
'</div>';
109 print
dol_get_fiche_head($head,
'invoices', $langs->trans(
"WithdrawalsReceipts"), -1,
'payment');
111 $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>';
113 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref');
115 print
'<div class="fichecenter">';
116 print
'<div class="underbanner clearboth"></div>';
117 print
'<table class="border centpercent tableforfield">'.
"\n";
120 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Date").
'</td><td>'.
dol_print_date(
$object->datec,
'day').
'</td></tr>';
121 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td><span class="amount">'.
price(
$object->amount).
'</span></td></tr>';
123 if (!empty(
$object->date_trans)) {
124 $muser =
new User($db);
125 $muser->fetch(
$object->user_trans);
127 print
'<tr><td>'.$langs->trans(
"TransData").
'</td><td>';
129 print
' <span class="opacitymedium">'.$langs->trans(
"By").
'</span> '.$muser->getNomUrl(-1).
'</td></tr>';
130 print
'<tr><td>'.$langs->trans(
"TransMetod").
'</td><td>';
134 if (!empty(
$object->date_credit)) {
135 print
'<tr><td>'.$langs->trans(
'CreditDate').
'</td><td>';
144 print
'<div class="underbanner clearboth"></div>';
145 print
'<table class="border centpercent tableforfield">';
149 $fk_bank_account =
$object->fk_bank_account;
150 if (empty($fk_bank_account)) {
153 if ($fk_bank_account > 0) {
154 $result = $acc->fetch($fk_bank_account);
157 $labelofbankfield =
"BankToReceiveWithdraw";
158 if (
$object->type ==
'bank-transfer') {
159 $labelofbankfield =
'BankToPayCreditTransfer';
162 print
'<tr><td class="titlefieldcreate">';
163 print $form->textwithpicto($langs->trans(
"BankAccount"), $langs->trans($labelofbankfield));
168 print $acc->getNomUrl(1);
173 $modulepart =
'prelevement';
174 if (
$object->type ==
'bank-transfer') {
175 $modulepart =
'paymentbybanktransfer';
178 print
'<tr><td class="titlefieldcreate">';
179 $labelfororderfield =
'WithdrawalFile';
180 if (
$object->type ==
'bank-transfer') {
181 $labelfororderfield =
'CreditTransferFile';
183 print $langs->trans($labelfororderfield).
'</td><td>';
185 if (isModEnabled(
'multicompany')) {
186 $labelentity = $conf->entity;
187 $relativepath =
'receipts/'.$object->ref.
'-'.$labelentity.
'.xml';
189 if ($type !=
'bank-transfer') {
190 $dir = $conf->prelevement->dir_output;
192 $dir = $conf->paymentbybanktransfer->dir_output;
195 $relativepath =
'receipts/'.$object->ref.
'.xml';
198 $relativepath =
'receipts/'.$object->ref.
'.xml';
201 print
'<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?type=text/plain&modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'">'.$relativepath;
202 print
img_picto(
'',
'download',
'class="paddingleft"');
204 print
'</td></tr></table>';
214 $sql =
"SELECT pf.rowid, p.type,";
215 $sql .=
" f.rowid as salaryid, f.ref as ref, f.amount,";
216 $sql .=
" u.rowid as userid, u.firstname, u.lastname, pl.statut as status, pl.amount as amount_requested";
217 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
218 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"prelevement_lignes as pl ON pl.fk_prelevement_bons = p.rowid";
219 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"prelevement as pf ON pf.fk_prelevement_lignes = pl.rowid";
220 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"salary as f ON f.rowid = pf.fk_salary AND f.entity IN (".
getEntity(
'salary').
")";
221 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON f.fk_user = u.rowid";
222 $sql .=
" WHERE 1 = 1";
224 $sql .=
" AND p.rowid = ".((int)
$object->id);
227 $sql .=
" AND u.rowid = ".((int) $userid);
230 $sql =
"SELECT pf.rowid, p.type,";
231 $sql .=
" f.rowid as facid, f.ref as ref, f.total_ttc,";
232 if (
$object->type ==
'bank-transfer') {
233 $sql .=
" f.ref_supplier,";
235 $sql .=
" s.rowid as socid, s.nom as name, pl.statut as status, pl.amount as amount_requested";
236 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p,";
237 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
238 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement as pf";
239 if (
$object->type !=
'bank-transfer') {
240 $sql .=
", ".MAIN_DB_PREFIX.
"facture as f";
242 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as f";
244 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
245 $sql .=
" WHERE pf.fk_prelevement_lignes = pl.rowid";
246 $sql .=
" AND pl.fk_prelevement_bons = p.rowid";
247 $sql .=
" AND f.fk_soc = s.rowid";
248 if (
$object->type !=
'bank-transfer') {
249 $sql .=
" AND pf.fk_facture = f.rowid";
251 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
253 if (
$object->type !=
'bank-transfer') {
254 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
256 $sql .=
" AND f.entity IN (".getEntity(
'supplier_invoice').
")";
259 $sql .=
" AND p.rowid = ".((int)
$object->id);
262 $sql .=
" AND s.rowid = ".((int) $socid);
264 $sql .= $db->order($sortfield, $sortorder);
267$nbtotalofrecords =
'';
269 $resql = $db->query($sql);
270 $nbtotalofrecords = $db->num_rows($resql);
271 if (($page * $limit) > $nbtotalofrecords) {
277$sql .= $db->plimit($limit + 1, $offset);
278$resql = $db->query($sql);
280 $num = $db->num_rows($resql);
283 $param =
"&id=".((int) $id);
284 if ($limit > 0 && $limit != $conf->liste_limit) {
285 $param .=
'&limit='.((int) $limit);
289 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
290 if ($optioncss !=
'') {
291 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
293 print
'<input type="hidden" name="token" value="'.newToken().
'">';
294 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
295 print
'<input type="hidden" name="action" value="list">';
296 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
297 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
298 print
'<input type="hidden" name="page" value="'.$page.
'">';
299 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
300 print
'<input type="hidden" name="id" value="'.$id.
'">';
302 $massactionbutton =
'';
303 $title = ($salaryBonPl ? $langs->trans(
"Salaries") : (
$object->type ==
'bank-transfer' ? $langs->trans(
"SupplierInvoices") : $langs->trans(
"Invoices")));
305 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
307 print
"\n<!-- debut table -->\n";
308 print
'<div class="div-table-responsive-no-min">';
309 print
'<table class="liste centpercent">';
310 print
'<tr class="liste_titre">';
311 print_liste_field_titre(($salaryBonPl ?
"Salary" :
"Bill"), $_SERVER[
"PHP_SELF"],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
312 if (
$object->type ==
'bank-transfer' && !$salaryBonPl) {
313 print_liste_field_titre(
"RefSupplierShort", $_SERVER[
"PHP_SELF"],
"f.ref_supplier",
'', $param,
'', $sortfield, $sortorder);
315 print_liste_field_titre(($salaryBonPl ?
"Employee" :
"ThirdParty"), $_SERVER[
"PHP_SELF"],
"s.nom",
'', $param,
'', $sortfield, $sortorder);
316 print_liste_field_titre(($salaryBonPl ?
"AmountSalary" :
"AmountInvoice"), $_SERVER[
"PHP_SELF"],
"f.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
317 print_liste_field_titre(
"AmountRequested", $_SERVER[
"PHP_SELF"],
"pl.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
318 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"",
"", $param,
'"', $sortfield, $sortorder,
'center ');
322 $totalamount_requested = 0;
325 $salarytmp =
new Salary($db);
326 $usertmp =
new User($db);
328 $invoicetmpcustomer =
new Facture($db);
332 $imaxinloop = ($limit ? min($num, $limit) : $num);
333 while ($i < $imaxinloop) {
334 $obj = $db->fetch_object($resql);
338 if ($salaryBonPl && ($salarytmp instanceof
Salary) && ($usertmp instanceof
User)) {
339 $salarytmp->fetch($obj->salaryid);
340 $usertmp->fetch($obj->userid);
341 $itemurl = $salarytmp->getNomUrl(1);
342 $partyurl = $usertmp->getNomUrl(-1);
344 if ($obj->type ==
'bank-transfer') {
345 $invoicetmp = $invoicetmpsupplier;
347 $invoicetmp = $invoicetmpcustomer;
349 $invoicetmp->fetch($obj->facid);
351 $thirdpartytmp->fetch($obj->socid);
352 $itemurl = $invoicetmp->getNomUrl(1);
353 $partyurl = $thirdpartytmp->getNomUrl(1);
356 print
'<tr class="oddeven">';
358 print
'<td class="nowraponall">';
362 if (
$object->type ==
'bank-transfer' && !$salaryBonPl) {
364 if ($invoicetmp instanceof
Facture) {
365 $labeltoshow = $invoicetmp->ref_supplier;
367 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($labeltoshow).
'">';
368 if ($invoicetmp instanceof
Facture) {
374 print
'<td class="tdoverflowmax125">';
379 print
'<td class="right"><span class="amount">'.price(($salaryBonPl ? $obj->amount : $obj->total_ttc)).
"</span></td>\n";
382 print
'<td class="right"><span class="amount">'.price($obj->amount_requested).
"</span></td>\n";
385 print
'<td class="center">';
386 if ($obj->status == 0) {
387 print $langs->trans(
"StatusWaiting");
388 } elseif ($obj->status == 2) {
389 if ($obj->type ==
'bank-transfer') {
390 print $langs->trans(
"StatusDebited");
392 print $langs->trans(
"StatusCredited");
394 } elseif ($obj->status == 3) {
395 print
'<span class="error">'.$langs->trans(
"StatusRefused").
'</span>';
401 $totalinvoices += $obj->total_ttc;
402 $totalamount_requested += $obj->amount_requested;
408 print
'<tr class="liste_total">';
409 print
'<td>'.$langs->trans(
"Total").
'</td>';
410 if (
$object->type ==
'bank-transfer' && !$salaryBonPl) {
411 print
'<td> </td>';
413 print
'<td> </td>';
414 print
'<td class="right">';
416 print
'<td class="right">';
418 if (($nbtotalofrecords <= $num) && $totalamount_requested != (
float)
$object->amount) {
419 $langs->load(
"errors");
422 print
price($totalamount_requested);
424 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.