Go to the documentation of this file.
29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/ligneprelevement.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/rejetprelevement.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
37 $langs->loadlangs(array(
'banks',
'categories',
'bills',
'withdrawals'));
40 $action =
GETPOST(
'action',
'aZ09');
42 $socid =
GETPOST(
'socid',
'int');
44 $type =
GETPOST(
'type',
'aZ09');
46 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
47 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
48 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
54 $offset = $limit * $page;
55 $pageprev = $page - 1;
56 $pagenext = $page + 1;
58 if ($sortorder ==
"") {
61 if ($sortfield ==
"") {
62 $sortfield =
"pl.fk_soc";
66 if ($type ==
'bank-transfer') {
67 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
77 if ($action ==
'confirm_rejet') {
78 if (
GETPOST(
"confirm") ==
'yes') {
79 if (
GETPOST(
'remonth',
'int')) {
80 $daterej = mktime(2, 0, 0,
GETPOST(
'remonth',
'int'),
GETPOST(
'reday',
'int'),
GETPOST(
'reyear',
'int'));
83 if (empty($daterej)) {
85 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
86 } elseif ($daterej >
dol_now()) {
88 $langs->load(
"error");
89 setEventMessages($langs->transnoentities(
"ErrorDateMustBeBeforeToday"),
null,
'errors');
92 if (
GETPOST(
'motif',
'alpha') == 0) {
94 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"RefusedReason")),
null,
'errors');
100 if ($lipre->fetch($id) == 0) {
103 $rej->create($user, $id,
GETPOST(
'motif',
'alpha'), $daterej, $lipre->bon_rowid,
GETPOST(
'facturer',
'int'));
105 header(
"Location: line.php?id=".urlencode($id).
'&type='.urlencode($type));
112 header(
"Location: line.php?id=".urlencode($id).
'&type='.urlencode($type));
122 if ($type ==
'bank-transfer') {
123 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
126 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
127 $invoicestatic =
new Facture($db);
130 $title = $langs->trans(
"WithdrawalsLine");
131 if ($type ==
'bank-transfer') {
132 $title = $langs->trans(
"CreditTransferLine");
140 $head[$h][0] = DOL_URL_ROOT.
'/compta/prelevement/line.php?id='.$id.
'&type='.$type;
141 $head[$h][1] = $title;
148 if ($lipre->fetch($id) >= 0) {
150 $bon->fetch($lipre->bon_rowid);
154 print
'<table class="border centpercent tableforfield">';
156 print
'<tr><td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
157 print $id.
'</td></tr>';
159 print
'<tr><td class="titlefield">'.$langs->trans(
"WithdrawalsReceipts").
'</td><td>';
160 print $bon->getNomUrl(1).
'</td></tr>';
162 print
'<tr><td>'.$langs->trans(
"Date").
'</td><td>'.
dol_print_date($bon->datec,
'day').
'</td></tr>';
164 print
'<tr><td>'.$langs->trans(
"Amount").
'</td><td><span class="amount">'.
price($lipre->amount).
'</span></td></tr>';
166 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>'.$lipre->LibStatut($lipre->statut, 1).
'</td></tr>';
168 if ($lipre->statut == 3) {
170 $resf = $rej->fetch($lipre->id);
172 print
'<tr><td>'.$langs->trans(
"RefusedReason").
'</td><td>'.$rej->motif.
'</td></tr>';
174 print
'<tr><td>'.$langs->trans(
"RefusedData").
'</td><td>';
175 if ($rej->date_rejet == 0) {
177 print $langs->trans(
"Unknown");
183 print
'<tr><td>'.$langs->trans(
"RefusedInvoicing").
'</td><td>'.$rej->invoicing.
'</td></tr>';
185 print
'<tr><td>'.$resf.
'</td></tr>';
195 if ($action ==
'rejet' && $user->rights->prelevement->bons->credit) {
199 $soc->fetch($lipre->socid);
203 print
'<form name="confirm_rejet" method="post" action="line.php?id='.$id.
'">';
204 print
'<input type="hidden" name="token" value="'.newToken().
'">';
205 print
'<input type="hidden" name="action" value="confirm_rejet">';
206 print
'<input type="hidden" name="type" value="'.$type.
'">';
207 print
'<table class="noborder centpercent">';
209 print
'<tr class="liste_titre">';
210 print
'<td colspan="3">'.$langs->trans(
"WithdrawalRefused").
'</td></tr>';
213 print
'<tr><td class="valid">'.$langs->trans(
"WithdrawalRefusedConfirm").
' '.$soc->name.
' ?</td>';
214 print
'<td colspan="2" class="valid">';
215 print
$form->selectyesno(
"confirm", 1, 0);
219 print
'<tr><td class="fieldrequired valid">'.$langs->trans(
"RefusedData").
'</td>';
220 print
'<td colspan="2" class="valid">';
221 print
$form->selectDate(
'',
'',
'',
'',
'',
"confirm_rejet");
225 print
'<tr><td class="fieldrequired valid">'.$langs->trans(
"RefusedReason").
'</td>';
226 print
'<td class="valid">';
231 print
'<tr><td class="valid">'.$langs->trans(
"RefusedInvoicing").
'</td>';
232 print
'<td class="valid" colspan="2">';
235 print
'</table><br>';
238 print
'<div class="center"><input type="submit" class="button button-save" value='.$langs->trans(
"Confirm").
'></div>';
245 print
'<div class="tabsAction">';
248 if ($bon->statut == BonPrelevement::STATUS_CREDITED) {
249 if ($lipre->statut == 2) {
250 if ($user->rights->prelevement->bons->credit) {
251 print
'<a class="butActionDelete" href="line.php?action=rejet&type='.$type.
'&id='.$lipre->id.
'">'.$langs->trans(
"StandingOrderReject").
'</a>';
253 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"StandingOrderReject").
'</a>';
257 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotPossibleForThisStatusOfWithdrawReceiptORLine").
'">'.$langs->trans(
"StandingOrderReject").
'</a>';
266 $sql =
"SELECT pf.rowid";
267 $sql .=
" ,f.rowid as facid, f.ref as ref, f.total_ttc, f.paye, f.fk_statut";
268 $sql .=
" , s.rowid as socid, s.nom as name";
269 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
270 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement_lignes as pl";
271 $sql .=
" , ".MAIN_DB_PREFIX.
"prelevement as pf";
272 if ($type ==
'bank-transfer') {
273 $sql .=
" , ".MAIN_DB_PREFIX.
"facture_fourn as f";
275 $sql .=
" , ".MAIN_DB_PREFIX.
"facture as f";
277 $sql .=
" , ".MAIN_DB_PREFIX.
"societe as s";
278 $sql .=
" WHERE pf.fk_prelevement_lignes = pl.rowid";
279 $sql .=
" AND pl.fk_prelevement_bons = p.rowid";
280 $sql .=
" AND f.fk_soc = s.rowid";
281 if ($type ==
'bank-transfer') {
282 $sql .=
" AND pf.fk_facture_fourn = f.rowid";
284 $sql .=
" AND pf.fk_facture = f.rowid";
286 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
287 $sql .=
" AND pl.rowid = ".((int) $id);
289 $sql .=
" AND s.rowid = ".((int) $socid);
291 $sql .= $db->order($sortfield, $sortorder);
292 $sql .= $db->plimit($conf->liste_limit + 1, $offset);
294 $result = $db->query(
$sql);
297 $num = $db->num_rows($result);
300 $urladd =
"&id=".urlencode($id);
302 print_barre_liste($langs->trans(
"Bills"), $page,
"factures.php", $urladd, $sortfield, $sortorder,
'', $num, 0,
'');
304 print
"\n<!-- debut table -->\n";
305 print
'<table class="noborder" width="100%" cellpadding="4">';
306 print
'<tr class="liste_titre">';
307 print
'<td>'.$langs->trans(
"Invoice").
'</td><td>'.$langs->trans(
"ThirdParty").
'</td><td class="right">'.$langs->trans(
"Amount").
'</td><td class="right">'.$langs->trans(
"Status").
'</td>';
312 while ($i < min($num, $conf->liste_limit)) {
313 $obj = $db->fetch_object($result);
315 print
'<tr class="oddeven"><td>';
317 print
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$obj->facid.
'">';
318 print
img_object($langs->trans(
"ShowBill"),
"bill");
321 if ($type ==
'bank-transfer') {
322 print
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$obj->facid.
'">'.$obj->ref.
"</a></td>\n";
324 print
'<a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$obj->facid.
'">'.$obj->ref.
"</a></td>\n";
327 if ($type ==
'bank-transfer') {
328 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid.
'">';
330 print
'<td><a href="'.DOL_URL_ROOT.
'/comm/card.php?socid='.$obj->socid.
'">';
332 print
img_object($langs->trans(
"ShowCompany"),
"company").
' '.$obj->name.
"</a></td>\n";
334 print
'<td class="right"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
336 print
'<td class="right">';
337 $invoicestatic->fetch($obj->facid);
338 print $invoicestatic->getLibStatut(5);
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage withdrawals.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage suppliers invoices.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Class to manage invoices.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage withdrawal receipts.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Class to manage standing orders rejects.
dol_now($mode='auto')
Return date for now.
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.