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'));
43$socid =
GETPOST(
'socid',
'int');
44$userid =
GETPOST(
'userid',
'int');
48$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
49$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
51$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
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"));
97 if ($object->fetch($id, $ref) >= 0) {
100 print
dol_get_fiche_head($head,
'invoices', $langs->trans(
"WithdrawalsReceipts"), -1,
'payment');
102 $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>';
106 print
'<div class="fichecenter">';
107 print
'<div class="underbanner clearboth"></div>';
108 print
'<table class="border centpercent tableforfield">'.
"\n";
111 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Date").
'</td><td>'.
dol_print_date($object->datec,
'day').
'</td></tr>';
112 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td><span class="amount">'.
price($object->amount).
'</span></td></tr>';
114 if (!empty($object->date_trans)) {
115 $muser =
new User($db);
116 $muser->fetch($object->user_trans);
118 print
'<tr><td>'.$langs->trans(
"TransData").
'</td><td>';
120 print
' <span class="opacitymedium">'.$langs->trans(
"By").
'</span> '.$muser->getNomUrl(-1).
'</td></tr>';
121 print
'<tr><td>'.$langs->trans(
"TransMetod").
'</td><td>';
122 print $object->methodes_trans[$object->method_trans];
125 if (!empty($object->date_credit)) {
126 print
'<tr><td>'.$langs->trans(
'CreditDate').
'</td><td>';
135 print
'<div class="underbanner clearboth"></div>';
136 print
'<table class="border centpercent tableforfield">';
140 $fk_bank_account = $object->fk_bank_account;
141 if (empty($fk_bank_account)) {
142 $fk_bank_account = ($object->type ==
'bank-transfer' ?
getDolGlobalInt(
'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') :
getDolGlobalInt(
'PRELEVEMENT_ID_BANKACCOUNT'));
144 if ($fk_bank_account > 0) {
145 $result = $acc->fetch($fk_bank_account);
148 $labelofbankfield =
"BankToReceiveWithdraw";
149 if ($object->type ==
'bank-transfer') {
150 $labelofbankfield =
'BankToPayCreditTransfer';
153 print
'<tr><td class="titlefieldcreate">';
154 print $form->textwithpicto($langs->trans(
"BankAccount"), $langs->trans($labelofbankfield));
159 print $acc->getNomUrl(1);
164 $modulepart =
'prelevement';
165 if ($object->type ==
'bank-transfer') {
166 $modulepart =
'paymentbybanktransfer';
169 print
'<tr><td class="titlefieldcreate">';
170 $labelfororderfield =
'WithdrawalFile';
171 if ($object->type ==
'bank-transfer') {
172 $labelfororderfield =
'CreditTransferFile';
174 print $langs->trans($labelfororderfield).
'</td><td>';
176 if (isModEnabled(
'multicompany')) {
177 $labelentity = $conf->entity;
178 $relativepath =
'receipts/'.$object->ref.
'-'.$labelentity.
'.xml';
180 if ($type !=
'bank-transfer') {
181 $dir = $conf->prelevement->dir_output;
183 $dir = $conf->paymentbybanktransfer->dir_output;
186 $relativepath =
'receipts/'.$object->ref.
'.xml';
189 $relativepath =
'receipts/'.$object->ref.
'.xml';
192 print
'<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?type=text/plain&modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'">'.$relativepath;
193 print
img_picto(
'',
'download',
'class="paddingleft"');
195 print
'</td></tr></table>';
208 $sql =
"SELECT pf.rowid, p.type,";
209 $sql .=
" f.rowid as salaryid, f.ref as ref, f.amount,";
210 $sql .=
" u.rowid as userid, u.firstname, u.lastname, pl.statut as status, pl.amount as amount_requested";
211 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
212 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"prelevement_lignes as pl ON pl.fk_prelevement_bons = p.rowid";
213 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"prelevement as pf ON pf.fk_prelevement_lignes = pl.rowid";
214 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"salary as f ON f.rowid = pf.fk_salary AND f.entity IN (".
getEntity(
'salary').
")";
215 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON f.fk_user = u.rowid";
216 $sql .=
" WHERE 1 = 1";
217 if ($object->id > 0) {
218 $sql .=
" AND p.rowid = ".((int) $object->id);
221 $sql .=
" AND u.rowid = ".((int) $userid);
224 $sql =
"SELECT pf.rowid, p.type,";
225 $sql .=
" f.rowid as facid, f.ref as ref, f.total_ttc,";
226 if ($object->type ==
'bank-transfer') {
227 $sql .=
" f.ref_supplier,";
229 $sql .=
" s.rowid as socid, s.nom as name, pl.statut as status, pl.amount as amount_requested";
230 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p,";
231 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
232 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement as pf";
233 if ($object->type !=
'bank-transfer') {
234 $sql .=
", ".MAIN_DB_PREFIX.
"facture as f";
236 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as f";
238 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
239 $sql .=
" WHERE pf.fk_prelevement_lignes = pl.rowid";
240 $sql .=
" AND pl.fk_prelevement_bons = p.rowid";
241 $sql .=
" AND f.fk_soc = s.rowid";
242 if ($object->type !=
'bank-transfer') {
243 $sql .=
" AND pf.fk_facture = f.rowid";
245 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
247 if ($object->type !=
'bank-transfer') {
248 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
250 $sql .=
" AND f.entity IN (".getEntity(
'supplier_invoice').
")";
252 if ($object->id > 0) {
253 $sql .=
" AND p.rowid = ".((int) $object->id);
256 $sql .=
" AND s.rowid = ".((int) $socid);
258 $sql .= $db->order($sortfield, $sortorder);
261$nbtotalofrecords =
'';
263 $resql = $db->query($sql);
264 $nbtotalofrecords = $db->num_rows($resql);
265 if (($page * $limit) > $nbtotalofrecords) {
271$sql .= $db->plimit($limit + 1, $offset);
272$resql = $db->query($sql);
274 $num = $db->num_rows($resql);
277 if ($limit > 0 && $limit != $conf->liste_limit) {
278 $param.=
'&limit='.((int) $limit);
280 $param =
"&id=".urlencode($id);
283 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
284 if ($optioncss !=
'') {
285 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
287 print
'<input type="hidden" name="token" value="'.newToken().
'">';
288 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
289 print
'<input type="hidden" name="action" value="list">';
290 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
291 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
292 print
'<input type="hidden" name="page" value="'.$page.
'">';
293 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
294 print
'<input type="hidden" name="id" value="'.$id.
'">';
296 $massactionbutton =
'';
297 $title = ($salaryBonPl ? $langs->trans(
"Salaries") : ($object->type ==
'bank-transfer' ? $langs->trans(
"SupplierInvoices") : $langs->trans(
"Invoices")));
299 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
301 print
"\n<!-- debut table -->\n";
302 print
'<div class="div-table-responsive-no-min">';
303 print
'<table class="liste centpercent">';
304 print
'<tr class="liste_titre">';
305 print_liste_field_titre(($salaryBonPl ?
"Salary" :
"Bill"), $_SERVER[
"PHP_SELF"],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
306 if ($object->type ==
'bank-transfer' && !$salaryBonPl) {
307 print_liste_field_titre(
"RefSupplierShort", $_SERVER[
"PHP_SELF"],
"f.ref_supplier",
'', $param,
'', $sortfield, $sortorder);
309 print_liste_field_titre(($salaryBonPl ?
"Employee" :
"ThirdParty"), $_SERVER[
"PHP_SELF"],
"s.nom",
'', $param,
'', $sortfield, $sortorder);
310 print_liste_field_titre(($salaryBonPl ?
"AmountSalary" :
"AmountInvoice"), $_SERVER[
"PHP_SELF"],
"f.total_ttc",
"", $param,
'class="right"', $sortfield, $sortorder);
311 print_liste_field_titre(
"AmountRequested", $_SERVER[
"PHP_SELF"],
"pl.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
312 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"",
"", $param,
'align="center"', $sortfield, $sortorder);
316 $totalamount_requested = 0;
319 $salarytmp =
new Salary($db);
320 $usertmp =
new User($db);
322 $invoicetmpcustomer =
new Facture($db);
326 while ($i < min($num, $limit)) {
327 $obj = $db->fetch_object($resql);
329 $salarytmp->fetch($obj->salaryid);
330 $usertmp->fetch($obj->userid);
332 if ($obj->type ==
'bank-transfer') {
333 $invoicetmp = $invoicetmpsupplier;
335 $invoicetmp = $invoicetmpcustomer;
337 $invoicetmp->fetch($obj->facid);
339 $thirdpartytmp->fetch($obj->socid);
342 print
'<tr class="oddeven">';
344 print
'<td class="nowraponall">';
345 print ($salaryBonPl ? $salarytmp->getNomUrl(1) : $invoicetmp->getNomUrl(1));
348 if ($object->type ==
'bank-transfer' && !$salaryBonPl) {
349 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($invoicetmp->ref_supplier).
'">';
354 print
'<td class="tdoverflowmax125">';
355 print($salaryBonPl ? $usertmp->getNomUrl(-1) : $thirdpartytmp->getNomUrl(1));
359 print
'<td class="right"><span class="amount">'.price(($salaryBonPl ? $obj->amount : $obj->total_ttc)).
"</span></td>\n";
362 print
'<td class="right"><span class="amount">'.price($obj->amount_requested).
"</span></td>\n";
365 print
'<td class="center">';
366 if ($obj->status == 0) {
367 print $langs->trans(
"StatusWaiting");
368 } elseif ($obj->status == 2) {
369 if ($obj->type ==
'bank-transfer') {
370 print $langs->trans(
"StatusDebited");
372 print $langs->trans(
"StatusCredited");
374 } elseif ($obj->status == 3) {
375 print
'<span class="error">'.$langs->trans(
"StatusRefused").
'</span>';
381 $totalinvoices += $obj->total_ttc;
382 $totalamount_requested += $obj->amount_requested;
388 print
'<tr class="liste_total">';
389 print
'<td>'.$langs->trans(
"Total").
'</td>';
390 if ($object->type ==
'bank-transfer' && !$salaryBonPl) {
391 print
'<td> </td>';
393 print
'<td> </td>';
394 print
'<td class="right">';
396 print
'<td class="right">';
398 if (($nbtotalofrecords <= $num) && $totalamount_requested != $object->amount) {
399 print
img_warning(
"AmountOfFileDiffersFromSumOfInvoices");
401 print
price($totalamount_requested);
403 print
'<td> </td>';
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.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show 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.
print_barre_liste($titre, $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.
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.