30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/ligneprelevement.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/rejetprelevement.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
46$langs->loadlangs(array(
'banks',
'categories',
'bills',
'companies',
'withdrawals'));
49$action =
GETPOST(
'action',
'aZ09');
56$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
57$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
63$offset = $limit * $page;
67if ($sortorder ==
"") {
70if ($sortfield ==
"") {
71 $sortfield =
"pl.fk_soc";
75if ($type ==
'bank-transfer') {
76 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
81if ($type ==
'bank-transfer') {
82 $permissiontoadd = $user->hasRight(
'paymentbybanktransfer',
'create');
84 $permissiontoadd = $user->hasRight(
'prelevement',
'bons',
'creer');
94if ($action ==
'confirm_rejet' && $permissiontoadd) {
95 if (
GETPOST(
"confirm") ==
'yes') {
101 if (empty($daterej)) {
103 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
104 } elseif ($daterej >
dol_now()) {
106 $langs->load(
"error");
107 setEventMessages($langs->transnoentities(
"ErrorDateMustBeBeforeToday"),
null,
'errors');
110 if (
GETPOST(
'motif',
'alpha') == 0) {
112 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"RefusedReason")),
null,
'errors');
118 if ($lipre->fetch($id) == 0) {
121 $result = $rej->create($user, $id,
GETPOSTINT(
'motif'), $daterej, $lipre->bon_rowid,
GETPOSTINT(
'facturer'));
124 header(
"Location: line.php?id=".urlencode((
string) ($id)).
'&type='.urlencode((
string) ($type)));
132 header(
"Location: line.php?id=".urlencode((
string) ($id)).
'&type='.urlencode((
string) ($type)));
142$form =
new Form($db);
144if ($type ==
'bank-transfer') {
145 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
148 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
149 $invoicestatic =
new Facture($db);
152$title = $langs->trans(
"WithdrawalsLine");
153if ($type ==
'bank-transfer') {
154 $title = $langs->trans(
"CreditTransferLine");
162$head[$h][0] = DOL_URL_ROOT.
'/compta/prelevement/line.php?id='.((int) $id).
'&type='.urlencode($type);
163$head[$h][1] = $title;
164$hselected = (string) $h;
171 if ($lipre->fetch($id) >= 0) {
173 $bon->fetch($lipre->bon_rowid);
177 print
'<table class="border centpercent tableforfield">';
179 print
'<tr><td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
180 print
$id.
'</td></tr>';
182 print
'<tr><td class="titlefield">'.$langs->trans(
"WithdrawalsReceipts").
'</td><td>';
183 print $bon->getNomUrl(1).
'</td></tr>';
185 print
'<tr><td>'.$langs->trans(
"Date").
'</td><td>'.
dol_print_date($bon->datec,
'day').
'</td></tr>';
187 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td><span class="amount">'.
price($lipre->amount).
'</span></td></tr>';
189 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>'.$lipre->LibStatut($lipre->statut, 1).
'</td></tr>';
191 if ($lipre->statut == 3) {
193 $resf = $rej->fetch($lipre->id);
195 print
'<tr><td>'.$langs->trans(
"RefusedReason").
'</td><td>'.$rej->motif.
'</td></tr>';
197 print
'<tr><td>'.$langs->trans(
"RefusedData").
'</td><td>';
198 if ($rej->date_rejet == 0) {
200 print $langs->trans(
"Unknown");
206 print
'<tr><td>'.$langs->trans(
"RefusedInvoicing").
'</td><td>'.$rej->invoicing.
'</td></tr>';
208 print
'<tr><td>'.$resf.
'</td></tr>';
219 if ($action ==
'rejet' && $user->hasRight(
'prelevement',
'bons',
'credit')) {
221 $soc->fetch($lipre->socid);
225 print
'<form name="confirm_rejet" method="post" action="'.DOL_URL_ROOT.
'/compta/prelevement/line.php?id='.
$id.
'">';
226 print
'<input type="hidden" name="token" value="'.newToken().
'">';
227 print
'<input type="hidden" name="action" value="confirm_rejet">';
228 print
'<input type="hidden" name="type" value="'.$type.
'">';
230 print
'<div class="div-table-responsive-no-min">';
231 print
'<table class="noborder centpercent">';
233 print
'<tr class="liste_titre">';
234 print
'<td>'.$langs->trans(
"WithdrawalRefused").
'</td>';
239 print
'<tr><td class="valid">'.$langs->trans(
"WithdrawalRefusedConfirm").
' '.$soc->name.
' ?</td>';
240 print
'<td class="valid">';
241 print $form->selectyesno(
"confirm", 1, 0);
245 print
'<tr><td class="fieldrequired valid">'.$langs->trans(
"RefusedData").
'</td>';
246 print
'<td class="valid">';
247 print $form->selectDate(
'',
'', 0, 0, 0,
"confirm_rejet");
251 print
'<tr><td class="fieldrequired valid">'.$langs->trans(
"RefusedReason").
'</td>';
252 print
'<td class="valid">';
253 print $form->selectarray(
"motif", $rej->motifs, GETPOSTISSET(
'motif') ?
GETPOSTINT(
'motif') :
'');
257 print
'<tr><td class="fieldrequired valid">';
258 print $form->textwithpicto($langs->trans(
"RefusedInvoicing"), $langs->trans(
"DirectDebitRefusedInvoicingDesc"));
260 print
'<td class="valid">';
261 print $form->selectarray(
"facturer", $rej->labelsofinvoicing, GETPOSTISSET(
'facturer') ?
GETPOSTINT(
'facturer') :
'', 0);
268 print
'<div class="center"><input type="submit" class="button button-save" value='.$langs->trans(
"Confirm").
'></div>';
275 print
'<div class="tabsAction">';
278 if (is_object($bon) && $bon->statut == BonPrelevement::STATUS_CREDITED) {
279 if ($lipre->statut == 2) {
280 if ($user->hasRight(
'prelevement',
'bons',
'credit')) {
281 print
'<a class="butActionDelete" href="line.php?action=rejet&type='.$type.
'&id='.$lipre->id.
'">'.$langs->trans(
"StandingOrderReject").
'</a>';
283 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"StandingOrderReject").
'</a>';
287 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotPossibleForThisStatusOfWithdrawReceiptORLine").
'">'.$langs->trans(
"StandingOrderReject").
'</a>';
296 $sql =
"SELECT pf.rowid";
297 $sql .=
" ,f.rowid as facid, f.ref as ref, f.total_ttc, f.paye, f.fk_statut";
298 $sql .=
" , s.rowid as socid, s.nom as name";
302 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
303 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
304 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement as pf";
305 if ($type ==
'bank-transfer') {
306 $sql .=
" , ".MAIN_DB_PREFIX.
"facture_fourn as f";
308 $sql .=
" , ".MAIN_DB_PREFIX.
"facture as f";
310 $sql .=
" , ".MAIN_DB_PREFIX.
"societe as s";
311 $sql .=
" WHERE pf.fk_prelevement_lignes = pl.rowid";
312 $sql .=
" AND pl.fk_prelevement_bons = p.rowid";
313 $sql .=
" AND f.fk_soc = s.rowid";
314 if ($type ==
'bank-transfer') {
315 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
317 $sql .=
" AND pf.fk_facture = f.rowid";
319 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
320 $sql .=
" AND pl.rowid = ".((int) $id);
322 $sql .=
" AND s.rowid = ".((int) $socid);
326 $nbtotalofrecords =
'';
329 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
330 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
331 $resql = $db->query($sqlforcount);
333 $objforcount = $db->fetch_object($resql);
334 $nbtotalofrecords = $objforcount->nbtotalofrecords;
339 if (($page * $limit) > $nbtotalofrecords) {
346 $result = $db->query($sql);
348 $sql .= $db->order($sortfield, $sortorder);
349 $sql .= $db->plimit(
$conf->liste_limit + 1, $offset);
351 $result = $db->query($sql);
354 $num = $db->num_rows($result);
357 $urladd =
"&id=".urlencode((
string) ($id));
358 $title = $langs->trans(
"Bills");
359 if ($type ==
'bank-transfer') {
360 $title = $langs->trans(
"SupplierInvoices");
363 print_barre_liste($title, $page,
"factures.php", $urladd, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'');
365 print
"\n<!-- debut table -->\n";
366 print
'<table class="noborder" width="100%" cellpadding="4">';
367 print
'<tr class="liste_titre">';
368 print
'<td>'.$langs->trans(
"Invoice").
'</td>';
369 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
370 print
'<td class="right">'.$langs->trans(
"Amount").
'</td><td class="right">'.$langs->trans(
"Status").
'</td>';
375 while ($i < min($num,
$conf->liste_limit)) {
376 $obj = $db->fetch_object($result);
378 print
'<tr class="oddeven"><td>';
380 print
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$obj->facid.
'">';
381 print
img_object($langs->trans(
"ShowBill"),
"bill");
384 if ($type ==
'bank-transfer') {
385 print
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$obj->facid.
'">'.$obj->ref.
"</a></td>\n";
387 print
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$obj->facid.
'">'.$obj->ref.
"</a></td>\n";
390 if ($type ==
'bank-transfer') {
391 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid.
'">';
393 print
'<td><a href="'.DOL_URL_ROOT.
'/comm/card.php?socid='.$obj->socid.
'">';
395 print
img_object($langs->trans(
"ShowCompany"),
"company").
' '.$obj->name.
"</a></td>\n";
397 print
'<td class="right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
399 print
'<td class="right">';
400 $invoicestatic->fetch($obj->facid);
401 print $invoicestatic->getLibStatut(5);
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 withdrawal receipts.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage withdrawals.
Class to manage standing orders rejects.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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.
dol_now($mode='auto')
Return date for now.
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).
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.