30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/prelevement.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/rejetprelevement.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
48$langs->loadLangs(array(
'banks',
'categories',
'bills',
'companies',
'withdrawals',
'salaries',
'suppliers'));
50$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
51$optioncss =
GETPOST(
'optioncss',
'aZ');
62$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
63$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
65if (empty($page) || $page == -1) {
68$offset = $limit * $page;
81include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
83$hookmanager->initHooks(array(
'directdebitprevcard',
'globalcard',
'directdebitprevlist'));
86if ($user->socid > 0) {
91$salaryBonPl =
$object->checkIfSalaryBonPrelevement();
92if ($type ==
'bank-transfer') {
93 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
107llxHeader(
'', $langs->trans(
"WithdrawalsReceipts"));
109if ($id > 0 || $ref) {
111 $langs->load(
'errors');
112 echo
'<div class="error">'.$langs->trans(
"ErrorRecordNotFound").
'</div>';
119 print
dol_get_fiche_head($head,
'invoices', $langs->trans(
"WithdrawalsReceipts"), -1,
'payment');
121 $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>';
123 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref');
125 print
'<div class="fichecenter">';
126 print
'<div class="underbanner clearboth"></div>';
127 print
'<table class="border centpercent tableforfield">'.
"\n";
130 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Date").
'</td><td>'.
dol_print_date(
$object->datec,
'day').
'</td></tr>';
131 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td><span class="amount">'.
price(
$object->amount).
'</span></td></tr>';
133 if (!empty(
$object->date_trans)) {
135 $muser->fetch(
$object->user_trans);
137 print
'<tr><td>'.$langs->trans(
"TransData").
'</td><td>';
139 print
' <span class="opacitymedium">'.$langs->trans(
"By").
'</span> '.$muser->getNomUrl(-1).
'</td></tr>';
140 print
'<tr><td>'.$langs->trans(
"TransMetod").
'</td><td>';
144 if (!empty(
$object->date_credit)) {
145 print
'<tr><td>'.$langs->trans(
'CreditDate').
'</td><td>';
154 print
'<div class="underbanner clearboth"></div>';
155 print
'<table class="border centpercent tableforfield">';
159 $fk_bank_account =
$object->fk_bank_account;
160 if (empty($fk_bank_account)) {
163 if ($fk_bank_account > 0) {
164 $result = $acc->fetch($fk_bank_account);
167 $labelofbankfield =
"BankToReceiveWithdraw";
168 if (
$object->type ==
'bank-transfer') {
169 $labelofbankfield =
'BankToPayCreditTransfer';
172 print
'<tr><td class="titlefieldcreate">';
173 print $form->textwithpicto($langs->trans(
"BankAccount"), $langs->trans($labelofbankfield));
178 print $acc->getNomUrl(1);
183 $modulepart =
'prelevement';
184 if (
$object->type ==
'bank-transfer') {
185 $modulepart =
'paymentbybanktransfer';
188 print
'<tr><td class="titlefieldcreate">';
189 $labelfororderfield =
'WithdrawalFile';
190 if (
$object->type ==
'bank-transfer') {
191 $labelfororderfield =
'CreditTransferFile';
193 print $langs->trans($labelfororderfield).
'</td><td>';
196 $labelentity =
$conf->entity;
197 $relativepath =
'receipts/'.$object->ref.
'-'.$labelentity.
'.xml';
199 if ($type !=
'bank-transfer') {
200 $dir =
$conf->prelevement->dir_output;
202 $dir =
$conf->paymentbybanktransfer->dir_output;
205 $relativepath =
'receipts/'.$object->ref.
'.xml';
208 $relativepath =
'receipts/'.$object->ref.
'.xml';
211 print
'<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?type=text/plain&modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'">'.$relativepath;
212 print
img_picto(
'',
'download',
'class="paddingleft"');
214 print
'</td></tr></table>';
224 $sql =
"SELECT pf.rowid, p.type,";
225 $sql .=
" f.rowid as salaryid, f.ref as ref, f.amount,";
226 $sql .=
" u.rowid as userid, u.firstname, u.lastname,";
227 $sql .=
" pl.statut as status, pl.amount as amount_requested";
228 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
229 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"prelevement_lignes as pl ON pl.fk_prelevement_bons = p.rowid";
230 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"prelevement as pf ON pf.fk_prelevement_lignes = pl.rowid";
231 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"salary as f ON f.rowid = pf.fk_salary AND f.entity IN (".
getEntity(
'salary').
")";
232 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON f.fk_user = u.rowid";
233 $sql .=
" WHERE 1 = 1";
235 $sql .=
" AND p.rowid = ".((int)
$object->id);
238 $sql .=
" AND u.rowid = ".((int) $userid);
241 $sql =
"SELECT pf.rowid, p.type,";
242 $sql .=
" f.rowid as facid, f.ref as ref, f.total_ttc,";
243 if (
$object->type ==
'bank-transfer') {
244 $sql .=
" f.ref_supplier,";
246 $sql .=
" s.rowid as socid, s.nom as name,";
247 $sql .=
" pl.statut as status, pl.amount as amount_requested";
248 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p,";
249 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
250 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement as pf";
251 if (
$object->type !=
'bank-transfer') {
252 $sql .=
", ".MAIN_DB_PREFIX.
"facture as f";
254 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as f";
256 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
257 $sql .=
" WHERE pf.fk_prelevement_lignes = pl.rowid";
258 $sql .=
" AND pl.fk_prelevement_bons = p.rowid";
259 $sql .=
" AND f.fk_soc = s.rowid";
260 if (
$object->type !=
'bank-transfer') {
261 $sql .=
" AND pf.fk_facture = f.rowid";
263 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
265 if (
$object->type !=
'bank-transfer') {
266 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
268 $sql .=
" AND f.entity IN (".getEntity(
'supplier_invoice').
")";
271 $sql .=
" AND p.rowid = ".((int)
$object->id);
274 $sql .=
" AND s.rowid = ".((int) $socid);
276 $sql .=
$db->order($sortfield, $sortorder);
279$nbtotalofrecords =
'';
281 $resql =
$db->query($sql);
282 $nbtotalofrecords =
$db->num_rows($resql);
283 if (($page * $limit) > (int) $nbtotalofrecords) {
289$sql .=
$db->plimit($limit + 1, $offset);
290$resql =
$db->query($sql);
292 $num =
$db->num_rows($resql);
295 $param =
"&id=".((int) $id);
296 if ($limit > 0 && $limit !=
$conf->liste_limit) {
297 $param .=
'&limit='.((int) $limit);
301 print
'<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
302 if ($optioncss !=
'') {
303 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
305 print
'<input type="hidden" name="token" value="'.newToken().
'">';
306 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
307 print
'<input type="hidden" name="action" value="list">';
308 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
309 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
310 print
'<input type="hidden" name="page" value="'.$page.
'">';
311 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
312 print
'<input type="hidden" name="id" value="'.$id.
'">';
314 $massactionbutton =
'';
315 $title = ($salaryBonPl ? $langs->trans(
"Salaries") : (
$object->type ==
'bank-transfer' ? $langs->trans(
"SupplierInvoices") : $langs->trans(
"Invoices")));
317 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
319 print
"\n<!-- debut table -->\n";
320 print
'<div class="div-table-responsive-no-min">';
321 print
'<table class="liste centpercent">';
322 print
'<tr class="liste_titre">';
323 print_liste_field_titre(($salaryBonPl ?
"Salary" :
"Bill"), $_SERVER[
"PHP_SELF"],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
324 if (
$object->type ==
'bank-transfer' && !$salaryBonPl) {
325 print_liste_field_titre(
"RefSupplierShort", $_SERVER[
"PHP_SELF"],
"f.ref_supplier",
'', $param,
'', $sortfield, $sortorder);
327 print_liste_field_titre(($salaryBonPl ?
"Employee" :
"ThirdParty"), $_SERVER[
"PHP_SELF"],
"s.nom",
'', $param,
'', $sortfield, $sortorder);
328 print_liste_field_titre(($salaryBonPl ?
"AmountSalary" :
"AmountInvoice"), $_SERVER[
"PHP_SELF"],
"f.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
329 print_liste_field_titre(
"AmountRequested", $_SERVER[
"PHP_SELF"],
"pl.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
330 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"",
"", $param,
'"', $sortfield, $sortorder,
'center ');
334 $totalamount_requested = 0;
337 $invoicetmpcustomer =
null;
338 $invoicetmpsupplier =
null;
348 $imaxinloop = ($limit ? min($num, $limit) : $num);
349 while ($i < $imaxinloop) {
350 $obj =
$db->fetch_object($resql);
354 if ($salaryBonPl && ($salarytmp instanceof
Salary) && ($usertmp instanceof
User)) {
355 $salarytmp->fetch($obj->salaryid);
356 $usertmp->fetch($obj->userid);
357 $itemurl = $salarytmp->getNomUrl(1);
358 $partyurl = $usertmp->getNomUrl(-1);
360 if ($obj->type ==
'bank-transfer') {
361 $invoicetmp = $invoicetmpsupplier;
363 $invoicetmp = $invoicetmpcustomer;
365 $invoicetmp->fetch($obj->facid);
367 $thirdpartytmp->fetch($obj->socid);
368 $itemurl = $invoicetmp->getNomUrl(1);
369 $partyurl = $thirdpartytmp->getNomUrl(1);
372 print
'<tr class="oddeven">';
374 print
'<td class="nowraponall">';
378 if (
$object->type ==
'bank-transfer' && !$salaryBonPl) {
380 if ($invoicetmp instanceof
Facture) {
381 $labeltoshow = $invoicetmp->ref_supplier;
383 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($labeltoshow).
'">';
384 if ($invoicetmp instanceof
Facture) {
390 print
'<td class="tdoverflowmax125">';
395 print
'<td class="right"><span class="amount">'.price(($salaryBonPl ? $obj->amount : $obj->total_ttc)).
"</span></td>\n";
398 print
'<td class="right"><span class="amount">'.price($obj->amount_requested).
"</span></td>\n";
401 print
'<td class="center">';
402 if ($obj->status == 0) {
403 print $langs->trans(
"StatusWaiting");
404 } elseif ($obj->status == 2) {
405 if ($obj->type ==
'bank-transfer') {
406 print $langs->trans(
"StatusDebited");
408 print $langs->trans(
"StatusCredited");
410 } elseif ($obj->status == 3) {
411 print
'<span class="error">'.$langs->trans(
"StatusRefused").
'</span>';
417 $totalinvoices += $obj->total_ttc;
418 $totalamount_requested += $obj->amount_requested;
424 print
'<tr class="liste_total">';
425 print
'<td>'.$langs->trans(
"Total").
'</td>';
426 if (
$object->type ==
'bank-transfer' && !$salaryBonPl) {
427 print
'<td> </td>';
429 print
'<td> </td>';
430 print
'<td class="right">';
432 print
'<td class="right">';
434 if (($nbtotalofrecords <= $num) && $totalamount_requested != (
float)
$object->amount) {
435 $langs->load(
"errors");
437 print
img_warning($langs->trans(
"WarningAmountOfFileDiffersFromSumOfLines",
price((
float)
$object->amount),
price($totalamount_requested)));
439 print
price($totalamount_requested);
441 print
'<td> </td>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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 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.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $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, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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, $morecssdiv='')
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isModEnabled($module)
Is Dolibarr module enabled.
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.