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';
37$langs->loadLangs(array(
'banks',
'categories',
'bills',
'companies',
'withdrawals',
'suppliers'));
42$socid =
GETPOST(
'socid',
'int');
46$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
47$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
48$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
49$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
50if (empty($page) || $page == -1) {
53$offset = $limit * $page;
66include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
68$hookmanager->initHooks(array(
'directdebitprevcard',
'globalcard',
'directdebitprevlist'));
71if ($user->socid > 0) {
76if ($type ==
'bank-transfer') {
77 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
89$thirdpartytmp =
new Societe($db);
91llxHeader(
'', $langs->trans(
"WithdrawalsReceipts"));
94 if ($object->fetch($id, $ref) >= 0) {
96 print
dol_get_fiche_head($head,
'invoices', $langs->trans(
"WithdrawalsReceipts"), -1,
'payment');
98 $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>';
102 print
'<div class="fichecenter">';
103 print
'<div class="underbanner clearboth"></div>';
104 print
'<table class="border centpercent tableforfield">'.
"\n";
107 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Date").
'</td><td>'.
dol_print_date($object->datec,
'day').
'</td></tr>';
108 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td><span class="amount">'.
price($object->amount).
'</span></td></tr>';
110 if (!empty($object->date_trans)) {
111 $muser =
new User($db);
112 $muser->fetch($object->user_trans);
114 print
'<tr><td>'.$langs->trans(
"TransData").
'</td><td>';
116 print
' <span class="opacitymedium">'.$langs->trans(
"By").
'</span> '.$muser->getNomUrl(-1).
'</td></tr>';
117 print
'<tr><td>'.$langs->trans(
"TransMetod").
'</td><td>';
118 print $object->methodes_trans[$object->method_trans];
121 if (!empty($object->date_credit)) {
122 print
'<tr><td>'.$langs->trans(
'CreditDate').
'</td><td>';
131 print
'<div class="underbanner clearboth"></div>';
132 print
'<table class="border centpercent tableforfield">';
136 $fk_bank_account = $object->fk_bank_account;
137 if (empty($fk_bank_account)) {
138 $fk_bank_account = ($object->type ==
'bank-transfer' ?
getDolGlobalInt(
'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') :
getDolGlobalInt(
'PRELEVEMENT_ID_BANKACCOUNT'));
140 if ($fk_bank_account > 0) {
141 $result = $acc->fetch($fk_bank_account);
144 $labelofbankfield =
"BankToReceiveWithdraw";
145 if ($object->type ==
'bank-transfer') {
146 $labelofbankfield =
'BankToPayCreditTransfer';
149 print
'<tr><td class="titlefieldcreate">';
150 print $form->textwithpicto($langs->trans(
"BankAccount"), $langs->trans($labelofbankfield));
155 print $acc->getNomUrl(1);
160 $modulepart =
'prelevement';
161 if ($object->type ==
'bank-transfer') {
162 $modulepart =
'paymentbybanktransfer';
165 print
'<tr><td class="titlefieldcreate">';
166 $labelfororderfield =
'WithdrawalFile';
167 if ($object->type ==
'bank-transfer') {
168 $labelfororderfield =
'CreditTransferFile';
170 print $langs->trans($labelfororderfield).
'</td><td>';
172 if (isModEnabled(
'multicompany')) {
173 $labelentity = $conf->entity;
174 $relativepath =
'receipts/'.$object->ref.
'-'.$labelentity.
'.xml';
176 if ($type !=
'bank-transfer') {
177 $dir = $conf->prelevement->dir_output;
179 $dir = $conf->paymentbybanktransfer->dir_output;
182 $relativepath =
'receipts/'.$object->ref.
'.xml';
185 $relativepath =
'receipts/'.$object->ref.
'.xml';
188 print
'<a data-ajax="false" href="'.DOL_URL_ROOT.
'/document.php?type=text/plain&modulepart='.$modulepart.
'&file='.urlencode($relativepath).
'">'.$relativepath;
189 print
img_picto(
'',
'download',
'class="paddingleft"');
191 print
'</td></tr></table>';
203$sql =
"SELECT pf.rowid, p.type,";
204$sql .=
" f.rowid as facid, f.ref as ref, f.total_ttc,";
205if ($object->type ==
'bank-transfer') {
206 $sql .=
" f.ref_supplier,";
208$sql .=
" s.rowid as socid, s.nom as name, pl.statut, pl.amount as amount_requested";
209$sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
210$sql .=
", ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
211$sql .=
", ".MAIN_DB_PREFIX.
"prelevement as pf";
212if ($object->type !=
'bank-transfer') {
213 $sql .=
", ".MAIN_DB_PREFIX.
"facture as f";
215 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as f";
217$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
218$sql .=
" WHERE pf.fk_prelevement_lignes = pl.rowid";
219$sql .=
" AND pl.fk_prelevement_bons = p.rowid";
220$sql .=
" AND f.fk_soc = s.rowid";
221if ($object->type !=
'bank-transfer') {
222 $sql .=
" AND pf.fk_facture = f.rowid";
224 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
226if ($object->type !=
'bank-transfer') {
227 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
229 $sql .=
" AND f.entity IN (".getEntity(
'supplier_invoice').
")";
231if ($object->id > 0) {
232 $sql .=
" AND p.rowid = ".((int) $object->id);
235 $sql .=
" AND s.rowid = ".((int) $socid);
237$sql .= $db->order($sortfield, $sortorder);
240$nbtotalofrecords =
'';
242 $resql = $db->query($sql);
243 $nbtotalofrecords = $db->num_rows($resql);
244 if (($page * $limit) > $nbtotalofrecords) {
250$sql .= $db->plimit($limit + 1, $offset);
252$resql = $db->query($sql);
254 $num = $db->num_rows($resql);
257 if ($limit > 0 && $limit != $conf->liste_limit) {
258 $param.=
'&limit='.((int) $limit);
260 $param =
"&id=".urlencode($id);
263 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
264 if ($optioncss !=
'') {
265 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
267 print
'<input type="hidden" name="token" value="'.newToken().
'">';
268 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
269 print
'<input type="hidden" name="action" value="list">';
270 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
271 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
272 print
'<input type="hidden" name="page" value="'.$page.
'">';
273 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
274 print
'<input type="hidden" name="id" value="'.$id.
'">';
276 $massactionbutton =
'';
278 print_barre_liste($langs->trans(
"Invoices"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0,
'',
'', $limit);
280 print
"\n<!-- debut table -->\n";
281 print
'<div class="div-table-responsive-no-min">';
282 print
'<table class="liste centpercent">';
283 print
'<tr class="liste_titre">';
285 if ($object->type ==
'bank-transfer') {
286 print_liste_field_titre(
"RefSupplierShort", $_SERVER[
"PHP_SELF"],
"f.ref_supplier",
'', $param,
'', $sortfield, $sortorder);
289 print_liste_field_titre(
"AmountInvoice", $_SERVER[
"PHP_SELF"],
"f.total_ttc",
"", $param,
'class="right"', $sortfield, $sortorder);
290 print_liste_field_titre(
"AmountRequested", $_SERVER[
"PHP_SELF"],
"pl.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
291 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"",
"", $param,
'align="center"', $sortfield, $sortorder);
296 $totalamount_requested = 0;
298 $invoicetmpcustomer =
new Facture($db);
301 while ($i < min($num, $limit)) {
302 $obj = $db->fetch_object($resql);
304 if ($obj->type ==
'bank-transfer') {
305 $invoicetmp = $invoicetmpsupplier;
307 $invoicetmp = $invoicetmpcustomer;
309 $invoicetmp->fetch($obj->facid);
311 $thirdpartytmp->fetch($obj->socid);
313 print
'<tr class="oddeven">';
315 print
'<td class="nowraponall">';
316 print $invoicetmp->getNomUrl(1);
319 if ($object->type ==
'bank-transfer') {
320 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($invoicetmp->ref_supplier).
'">';
325 print
'<td class="tdoverflowmax125">';
326 print $thirdpartytmp->getNomUrl(1);
330 print
'<td class="right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
333 print
'<td class="right"><span class="amount">'.price($obj->amount_requested).
"</span></td>\n";
336 print
'<td class="center">';
338 if ($obj->statut == 0) {
340 } elseif ($obj->statut == 2) {
341 if ($obj->type ==
'bank-transfer') {
342 print $langs->trans(
"StatusDebited");
344 print $langs->trans(
"StatusCredited");
346 } elseif ($obj->statut == 3) {
347 print
'<span class="error">'.$langs->trans(
"StatusRefused").
'</span>';
356 $totalinvoices += $obj->total_ttc;
357 $totalamount_requested += $obj->amount_requested;
363 print
'<tr class="liste_total">';
364 print
'<td>'.$langs->trans(
"Total").
'</td>';
365 if ($object->type ==
'bank-transfer') {
366 print
'<td> </td>';
368 print
'<td> </td>';
369 print
'<td class="right">';
371 print
'<td class="right">';
373 if (($nbtotalofrecords <= $num) && $totalamount_requested != $object->amount) {
374 print
img_warning(
"AmountOfFileDiffersFromSumOfInvoices");
376 print
price($totalamount_requested);
378 print
'<td> </td>';
379 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 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 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.
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.