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',
'',
'',
'');
103$form =
new Form($db);
105$thirdpartytmp =
new Societe($db);
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)) {
134 $muser =
new User($db);
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>';
195 if (isModEnabled(
'multicompany')) {
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, pl.statut as status, pl.amount as amount_requested";
227 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
228 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"prelevement_lignes as pl ON pl.fk_prelevement_bons = p.rowid";
229 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"prelevement as pf ON pf.fk_prelevement_lignes = pl.rowid";
230 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"salary as f ON f.rowid = pf.fk_salary AND f.entity IN (".
getEntity(
'salary').
")";
231 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"user as u ON f.fk_user = u.rowid";
232 $sql .=
" WHERE 1 = 1";
234 $sql .=
" AND p.rowid = ".((int)
$object->id);
237 $sql .=
" AND u.rowid = ".((int) $userid);
240 $sql =
"SELECT pf.rowid, p.type,";
241 $sql .=
" f.rowid as facid, f.ref as ref, f.total_ttc,";
242 if (
$object->type ==
'bank-transfer') {
243 $sql .=
" f.ref_supplier,";
245 $sql .=
" s.rowid as socid, s.nom as name, pl.statut as status, pl.amount as amount_requested";
246 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p,";
247 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_lignes as pl,";
248 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement as pf";
249 if (
$object->type !=
'bank-transfer') {
250 $sql .=
", ".MAIN_DB_PREFIX.
"facture as f";
252 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as f";
254 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
255 $sql .=
" WHERE pf.fk_prelevement_lignes = pl.rowid";
256 $sql .=
" AND pl.fk_prelevement_bons = p.rowid";
257 $sql .=
" AND f.fk_soc = s.rowid";
258 if (
$object->type !=
'bank-transfer') {
259 $sql .=
" AND pf.fk_facture = f.rowid";
261 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
263 if (
$object->type !=
'bank-transfer') {
264 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
266 $sql .=
" AND f.entity IN (".getEntity(
'supplier_invoice').
")";
269 $sql .=
" AND p.rowid = ".((int)
$object->id);
272 $sql .=
" AND s.rowid = ".((int) $socid);
274 $sql .= $db->order($sortfield, $sortorder);
277$nbtotalofrecords =
'';
279 $resql = $db->query($sql);
280 $nbtotalofrecords = $db->num_rows($resql);
281 if (($page * $limit) > $nbtotalofrecords) {
287$sql .= $db->plimit($limit + 1, $offset);
288$resql = $db->query($sql);
290 $num = $db->num_rows($resql);
293 $param =
"&id=".((int) $id);
294 if ($limit > 0 && $limit !=
$conf->liste_limit) {
295 $param .=
'&limit='.((int) $limit);
299 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
300 if ($optioncss !=
'') {
301 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
303 print
'<input type="hidden" name="token" value="'.newToken().
'">';
304 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
305 print
'<input type="hidden" name="action" value="list">';
306 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
307 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
308 print
'<input type="hidden" name="page" value="'.$page.
'">';
309 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
310 print
'<input type="hidden" name="id" value="'.$id.
'">';
312 $massactionbutton =
'';
313 $title = ($salaryBonPl ? $langs->trans(
"Salaries") : (
$object->type ==
'bank-transfer' ? $langs->trans(
"SupplierInvoices") : $langs->trans(
"Invoices")));
315 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
317 print
"\n<!-- debut table -->\n";
318 print
'<div class="div-table-responsive-no-min">';
319 print
'<table class="liste centpercent">';
320 print
'<tr class="liste_titre">';
321 print_liste_field_titre(($salaryBonPl ?
"Salary" :
"Bill"), $_SERVER[
"PHP_SELF"],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
322 if (
$object->type ==
'bank-transfer' && !$salaryBonPl) {
323 print_liste_field_titre(
"RefSupplierShort", $_SERVER[
"PHP_SELF"],
"f.ref_supplier",
'', $param,
'', $sortfield, $sortorder);
325 print_liste_field_titre(($salaryBonPl ?
"Employee" :
"ThirdParty"), $_SERVER[
"PHP_SELF"],
"s.nom",
'', $param,
'', $sortfield, $sortorder);
326 print_liste_field_titre(($salaryBonPl ?
"AmountSalary" :
"AmountInvoice"), $_SERVER[
"PHP_SELF"],
"f.total_ttc",
"", $param,
'', $sortfield, $sortorder,
'right ');
327 print_liste_field_titre(
"AmountRequested", $_SERVER[
"PHP_SELF"],
"pl.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
328 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"",
"", $param,
'"', $sortfield, $sortorder,
'center ');
332 $totalamount_requested = 0;
335 $invoicetmpcustomer =
null;
336 $invoicetmpsupplier =
null;
339 $salarytmp =
new Salary($db);
340 $usertmp =
new User($db);
342 $invoicetmpcustomer =
new Facture($db);
346 $imaxinloop = ($limit ? min($num, $limit) : $num);
347 while ($i < $imaxinloop) {
348 $obj = $db->fetch_object($resql);
352 if ($salaryBonPl && ($salarytmp instanceof
Salary) && ($usertmp instanceof
User)) {
353 $salarytmp->fetch($obj->salaryid);
354 $usertmp->fetch($obj->userid);
355 $itemurl = $salarytmp->getNomUrl(1);
356 $partyurl = $usertmp->getNomUrl(-1);
358 if ($obj->type ==
'bank-transfer') {
359 $invoicetmp = $invoicetmpsupplier;
361 $invoicetmp = $invoicetmpcustomer;
363 $invoicetmp->fetch($obj->facid);
365 $thirdpartytmp->fetch($obj->socid);
366 $itemurl = $invoicetmp->getNomUrl(1);
367 $partyurl = $thirdpartytmp->getNomUrl(1);
370 print
'<tr class="oddeven">';
372 print
'<td class="nowraponall">';
376 if (
$object->type ==
'bank-transfer' && !$salaryBonPl) {
378 if ($invoicetmp instanceof
Facture) {
379 $labeltoshow = $invoicetmp->ref_supplier;
381 print
'<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($labeltoshow).
'">';
382 if ($invoicetmp instanceof
Facture) {
388 print
'<td class="tdoverflowmax125">';
393 print
'<td class="right"><span class="amount">'.price(($salaryBonPl ? $obj->amount : $obj->total_ttc)).
"</span></td>\n";
396 print
'<td class="right"><span class="amount">'.price($obj->amount_requested).
"</span></td>\n";
399 print
'<td class="center">';
400 if ($obj->status == 0) {
401 print $langs->trans(
"StatusWaiting");
402 } elseif ($obj->status == 2) {
403 if ($obj->type ==
'bank-transfer') {
404 print $langs->trans(
"StatusDebited");
406 print $langs->trans(
"StatusCredited");
408 } elseif ($obj->status == 3) {
409 print
'<span class="error">'.$langs->trans(
"StatusRefused").
'</span>';
415 $totalinvoices += $obj->total_ttc;
416 $totalamount_requested += $obj->amount_requested;
422 print
'<tr class="liste_total">';
423 print
'<td>'.$langs->trans(
"Total").
'</td>';
424 if (
$object->type ==
'bank-transfer' && !$salaryBonPl) {
425 print
'<td> </td>';
427 print
'<td> </td>';
428 print
'<td class="right">';
430 print
'<td class="right">';
432 if (($nbtotalofrecords <= $num) && $totalamount_requested != (
float)
$object->amount) {
433 $langs->load(
"errors");
435 print
img_warning($langs->trans(
"WarningAmountOfFileDiffersFromSumOfLines",
price((
float)
$object->amount),
price($totalamount_requested)));
437 print
price($totalamount_requested);
439 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($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_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_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.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.