30 require
'../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
42 $langs->loadLangs(array(
'bills',
'banks',
'withdrawals',
'companies'));
46 $socid =
GETPOST(
'socid',
'int');
47 $action =
GETPOST(
'action',
'aZ09');
48 $type =
GETPOST(
'type',
'aZ09');
50 $fieldid = (!empty($ref) ?
'ref' :
'rowid');
51 if ($user->socid) $socid = $user->socid;
53 if ($type ==
'bank-transfer') {
60 if ($id > 0 || !empty($ref))
62 $ret = $object->fetch($id, $ref);
66 $object->fetch_thirdparty();
70 $hookmanager->initHooks(array(
'directdebitcard',
'globalcard'));
72 if ($type ==
'bank-transfer') {
73 $result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture',
'fk_soc', $fieldid, $isdraft);
76 $result =
restrictedArea($user,
'facture', $id,
'',
'',
'fk_soc', $fieldid, $isdraft);
85 $parameters = array(
'socid' => $socid);
86 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
87 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
98 $sourcetype =
'facture';
99 if ($type ==
'bank-transfer') {
100 $sourcetype =
'supplier_invoice';
101 $newtype =
'bank-transfer';
104 $result = $object->demande_prelevement($user,
price2num(
GETPOST(
'withdraw_request_amount',
'alpha')), $newtype, $sourcetype);
118 if ($action ==
"delete")
122 $result = $object->demande_prelevement_delete($user,
GETPOST(
'did',
'int'));
125 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id.
'&type='.$type);
137 $form =
new Form($db);
141 if ($type ==
'bank-transfer') {
142 $title = $langs->trans(
'InvoiceSupplier').
" - ".$langs->trans(
'CreditTransfer');
145 $title = $langs->trans(
'InvoiceCustomer').
" - ".$langs->trans(
'StandingOrders');
146 $helpurl =
"EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
160 $selleruserevenustamp = $mysoc->useRevenueStamp();
162 $totalpaye = $object->getSommePaiement();
163 $totalcreditnotes = $object->getSumCreditNotesUsed();
164 $totaldeposits = $object->getSumDepositsUsed();
171 $resteapayer =
price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,
'MT');
173 if ($object->paye) $resteapayer = 0;
174 $resteapayeraffiche = $resteapayer;
176 if ($type ==
'bank-transfer') {
177 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
178 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
179 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
181 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
182 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
185 $absolute_discount = $object->thirdparty->getAvailableDiscounts(
'', $filterabsolutediscount, 0, 1);
186 $absolute_creditnote = $object->thirdparty->getAvailableDiscounts(
'', $filtercreditnote, 0, 1);
187 $absolute_discount =
price2num($absolute_discount,
'MT');
188 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
190 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
191 $filterabsolutediscount =
"fk_facture_source IS NULL";
192 $filtercreditnote =
"fk_facture_source IS NOT NULL";
194 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
195 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
198 $absolute_discount = $object->thirdparty->getAvailableDiscounts(
'', $filterabsolutediscount);
199 $absolute_creditnote = $object->thirdparty->getAvailableDiscounts(
'', $filtercreditnote);
200 $absolute_discount =
price2num($absolute_discount,
'MT');
201 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
204 $author =
new User($db);
205 if ($object->user_author)
207 $author->fetch($object->user_author);
210 if ($type ==
'bank-transfer') {
216 print dol_get_fiche_head($head,
'standingorders', $title, -1, ($type ==
'bank-transfer' ?
'supplier_invoice' :
'bill'));
219 if ($type ==
'bank-transfer') {
220 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
222 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
225 $morehtmlref =
'<div class="refidno">';
227 if ($type ==
'bank-transfer') {
228 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', 0, 1);
229 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', null, null,
'', 1);
231 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'', 0, 1);
232 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'', null, null,
'', 1);
235 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
236 if ($type ==
'bank-transfer') {
237 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->thirdparty->id.
'&search_company='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
239 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?socid='.$object->thirdparty->id.
'&search_company='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
242 if (!empty($conf->projet->enabled))
244 $langs->load(
"projects");
245 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
246 if ($user->rights->facture->creer)
248 if ($action !=
'classify') {
250 $morehtmlref .=
' : ';
252 if ($action ==
'classify') {
254 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
255 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
256 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
257 $morehtmlref .=
'<input type="hidden" name="type" value="'.$type.
'">';
258 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
259 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
260 $morehtmlref .=
'</form>';
262 $morehtmlref .= $form->form_project(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
265 if (!empty($object->fk_project)) {
267 $proj->fetch($object->fk_project);
268 $morehtmlref .=
'<a href="'.DOL_URL_ROOT.
'/projet/card.php?id='.$object->fk_project.
'" title="'.$langs->trans(
'ShowProject').
'">';
269 $morehtmlref .= $proj->ref;
270 $morehtmlref .=
'</a>';
276 $morehtmlref .=
'</div>';
278 $object->totalpaye = $totalpaye;
280 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'');
282 print '<div class="fichecenter">';
283 print '<div class="fichehalfleft">';
284 print '<div class="underbanner clearboth"></div>';
286 print '<table class="border centpercent tableforfield">';
289 print '<tr><td class="titlefield">'.$langs->trans(
'Type').
'</td><td colspan="3">';
290 print $object->getLibType();
291 if ($object->module_source) {
292 print ' <span class="opacitymediumbycolor">('.$langs->trans(
"POS").
' '.$object->module_source.
' - '.$langs->trans(
"Terminal").
' '.$object->pos_source.
')</span>';
294 if ($object->type == $object::TYPE_REPLACEMENT)
296 if ($type ==
'bank-transfer') {
299 $facreplaced =
new Facture($db);
301 $facreplaced->fetch($object->fk_facture_source);
302 print ' ('.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
')';
304 if ($object->type == $object::TYPE_CREDIT_NOTE)
306 if ($type ==
'bank-transfer') {
311 $facusing->fetch($object->fk_facture_source);
312 print ' ('.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
')';
315 $facidavoir = $object->getListIdAvoirFromInvoice();
316 if (count($facidavoir) > 0)
318 print ' ('.$langs->transnoentities(
"InvoiceHasAvoir");
320 foreach ($facidavoir as $id)
322 if ($i == 0)
print ' ';
324 if ($type ==
'bank-transfer') {
329 $facavoir->fetch($id);
330 print $facavoir->getNomUrl(1);
345 print '<tr><td>'.$langs->trans(
'Discounts').
'</td><td colspan="3">';
347 if ($type ==
'bank-transfer') {
350 $thirdparty = $object->thirdparty;
353 $thirdparty = $object->thirdparty;
356 $backtopage = urlencode(
$_SERVER[
"PHP_SELF"].
'?facid='.$object->id);
357 $cannotApplyDiscount = 1;
358 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
363 if ($type ==
'bank-transfer') {
365 print '<td>'.$form->editfieldkey(
"Label",
'label', $object->label, $object, 0).
'</td>';
366 print '<td>'.$form->editfieldval(
"Label",
'label', $object->label, $object, 0).
'</td>';
372 print '<table class="nobordernopadding centpercent"><tr><td>';
373 print $langs->trans(
'DateInvoice');
375 if ($object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editinvoicedate' && !empty($object->brouillon) && $user->rights->facture->creer)
print '<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editinvoicedate&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetDate'), 1).
'</a></td>';
376 print '</tr></table>';
377 print
'</td><td colspan="3">';
379 if ($object->type != $object::TYPE_CREDIT_NOTE)
381 if ($action ==
'editinvoicedate')
383 $form->form_date(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->date,
'invoicedate');
395 print
'<table class="nobordernopadding centpercent"><tr><td>';
396 print $langs->trans(
'PaymentConditionsShort');
398 if ($object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editconditions' && !empty($object->brouillon) && $user->rights->facture->creer) print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editconditions&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetConditions'), 1).
'</a></td>';
399 print
'</tr></table>';
400 print
'</td><td colspan="3">';
401 if ($object->type != $object::TYPE_CREDIT_NOTE)
403 if ($action ==
'editconditions')
405 $form->form_conditions_reglement(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id');
407 $form->form_conditions_reglement(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none');
416 print
'<table class="nobordernopadding centpercent"><tr><td>';
417 print $langs->trans(
'DateMaxPayment');
419 if ($object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editpaymentterm' && !empty($object->brouillon) && $user->rights->facture->creer) print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editpaymentterm&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetDate'), 1).
'</a></td>';
420 print
'</tr></table>';
421 print
'</td><td colspan="3">';
422 if ($object->type != $object::TYPE_CREDIT_NOTE)
424 $duedate = $object->date_lim_reglement;
425 if ($type ==
'bank-transfer') {
426 $duedate = $object->date_echeance;
429 if ($action ==
'editpaymentterm')
431 $form->form_date(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $duedate,
'paymentterm');
434 if ($object->hasDelay()) {
445 print
'<table class="nobordernopadding centpercent"><tr><td>';
446 print $langs->trans(
'PaymentMode');
448 if ($action !=
'editmode' && !empty($object->brouillon) && $user->rights->facture->creer) print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
449 print
'</tr></table>';
450 print
'</td><td colspan="3">';
451 if ($action ==
'editmode')
453 $form->form_modes_reglement(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id');
455 $form->form_modes_reglement(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
460 print
'<tr><td class="nowrap">';
461 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
462 print $langs->trans(
'BankAccount');
464 if (($action !=
'editbankaccount') && $user->rights->commande->creer && !empty($object->brouillon))
465 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbankaccount&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
466 print
'</tr></table>';
467 print
'</td><td colspan="3">';
468 if ($action ==
'editbankaccount')
470 $form->formSelectAccount(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
472 $form->formSelectAccount(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
477 $title =
'CustomerIBAN';
478 if ($type ==
'bank-transfer') {
479 $title =
'SupplierIBAN';
481 print
'<tr><td>'.$langs->trans($title).
'</td><td colspan="3">';
484 $bac->fetch(0, $object->thirdparty->id);
486 print $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
487 if (!empty($bac->iban)) {
488 if ($bac->verif() <= 0) print
img_warning(
'Error on default bank number for IBAN : '.$bac->error_message);
490 print
img_warning($langs->trans(
"NoDefaultIBANFound"));
498 print
'<div class="fichehalfright">';
499 print
'<div class="ficheaddleft">';
500 print
'<div class="underbanner clearboth"></div>';
502 print
'<table class="border centpercent tableforfield">';
504 if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
507 print
'<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
'MulticurrencyAmountHT',
'multicurrency_total_ht',
'', $object, 0).
'</td>';
508 print
'<td class="nowrap">'.price($object->multicurrency_total_ht,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
512 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountVAT',
'multicurrency_total_tva',
'', $object, 0).
'</td>';
513 print
'<td class="nowrap">'.price($object->multicurrency_total_tva,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
517 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountTTC',
'multicurrency_total_ttc',
'', $object, 0).
'</td>';
518 print
'<td class="nowrap">'.price($object->multicurrency_total_ttc,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
523 print
'<tr><td class="titlefield">'.$langs->trans(
'AmountHT').
'</td>';
524 print
'<td class="nowrap">'.price($object->total_ht, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
527 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="3" class="nowrap">'.
price($object->total_tva, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
531 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0)
533 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
534 print
'<td class="nowrap">'.price($object->total_localtax1, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
536 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0)
538 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
539 print
'<td class=nowrap">'.price($object->total_localtax2, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
543 if ($selleruserevenustamp)
546 print
'<table class="nobordernopadding" width="100%"><tr><td>';
547 print $langs->trans(
'RevenueStamp');
549 if ($action !=
'editrevenuestamp' && !empty($object->brouillon) && $user->rights->facture->creer)
551 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editrevenuestamp&facid='.$object->id.
'">'.
img_edit($langs->trans(
'SetRevenuStamp'), 1).
'</a></td>';
553 print
'</tr></table>';
555 print
price($object->revenuestamp, 1,
'', 1, - 1, - 1, $conf->currency);
560 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td class="nowrap">'.
price($object->total_ttc, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
562 $resteapayer =
price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,
'MT');
565 print
'<tr><td>'.$langs->trans(
'RemainderToPay').
'</td><td class="nowrap">'.
price($resteapayer, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
573 print
'<div class="clearboth"></div>';
579 $numopen = 0; $pending = 0; $numclosed = 0;
584 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
585 $sql .=
" , pfd.date_traite as date_traite";
586 $sql .=
" , pfd.amount";
587 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
588 if ($type ==
'bank-transfer') {
589 $sql .=
" WHERE fk_facture_fourn = ".$object->id;
591 $sql .=
" WHERE fk_facture = ".$object->id;
593 $sql .=
" AND pfd.traite = 0";
594 $sql .=
" AND pfd.ext_payment_id IS NULL";
595 $sql .=
" ORDER BY pfd.date_demande DESC";
597 $result_sql = $db->query($sql);
600 $num = $db->num_rows($result_sql);
608 $sql =
"SELECT SUM(pfd.amount) as amount";
609 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
610 if ($type ==
'bank-transfer') {
611 $sql .=
" WHERE fk_facture_fourn = ".$object->id;
613 $sql .=
" WHERE fk_facture = ".$object->id;
615 $sql .=
" AND pfd.traite = 0";
616 $sql .=
" AND pfd.ext_payment_id IS NULL";
618 $result_sql = $db->query($sql);
621 $obj = $db->fetch_object($result_sql);
622 if ($obj) $pending = $obj->amount;
632 print
"\n<div class=\"tabsAction\">\n";
634 $buttonlabel = $langs->trans(
"MakeWithdrawRequest");
635 $user_perms = $user->rights->prelevement->bons->creer;
636 if ($type ==
'bank-transfer') {
637 $buttonlabel = $langs->trans(
"MakeBankTransferOrder");
638 $user_perms = $user->rights->paymentbybanktransfer->create;
642 if ($object->statut > $object::STATUS_DRAFT && $object->paye == 0 && $num == 0)
644 if ($resteapayer > 0)
648 $remaintopaylesspendingdebit = $resteapayer - $pending;
650 print
'<form method="POST" action="">';
651 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
652 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
653 print
'<input type="hidden" name="type" value="'.$type.
'" />';
654 print
'<input type="hidden" name="action" value="new" />';
655 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
656 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
657 print
'<input type="submit" class="butAction" value="'.$buttonlabel.
'" />';
660 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$buttonlabel.
'</a>';
663 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AmountMustBePositive")).
'">'.$buttonlabel.
'</a>';
668 if ($object->statut > $object::STATUS_DRAFT) print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AlreadyPaid")).
'">'.$buttonlabel.
'</a>';
669 else print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"Draft")).
'">'.$buttonlabel.
'</a>';
671 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"RequestAlreadyDone")).
'">'.$buttonlabel.
'</a>';
675 print
"</div><br>\n";
678 if ($type ==
'bank-transfer') {
679 print
'<div class="opacitymedium">'.$langs->trans(
"DoCreditTransferBeforePayments").
'</div><br>';
681 print
'<div class="opacitymedium">'.$langs->trans(
"DoStandingOrdersBeforePayments").
'</div><br>';
688 print
'<div class="div-table-responsive-no-min">';
689 print
'<table class="noborder centpercent">';
691 print
'<tr class="liste_titre">';
692 print
'<td class="left">'.$langs->trans(
"DateRequest").
'</td>';
693 print
'<td class="center">'.$langs->trans(
"User").
'</td>';
694 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
695 if ($type ==
'bank-transfer') {
696 print
'<td class="center">'.$langs->trans(
"BankTransferReceipt").
'</td>';
698 print
'<td class="center">'.$langs->trans(
"WithdrawalReceipt").
'</td>';
700 print
'<td> </td>';
701 print
'<td class="center">'.$langs->trans(
"DateProcess").
'</td>';
702 print
'<td> </td>';
705 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
706 $sql .=
" pfd.date_traite as date_traite, pfd.amount,";
707 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
708 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
709 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on pfd.fk_user_demande = u.rowid";
710 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
711 if ($type ==
'bank-transfer') {
712 $sql .=
" WHERE fk_facture_fourn = ".$object->id;
714 $sql .=
" WHERE fk_facture = ".$object->id;
716 $sql .=
" AND pfd.traite = 0";
717 $sql .=
" AND pfd.ext_payment_id IS NULL";
718 $sql .=
" ORDER BY pfd.date_demande DESC";
720 $result_sql = $db->query($sql);
727 $tmpuser =
new User($db);
729 $num = $db->num_rows($result);
732 $obj = $db->fetch_object($result_sql);
734 $tmpuser->id = $obj->user_id;
735 $tmpuser->login = $obj->login;
736 $tmpuser->ref = $obj->login;
737 $tmpuser->email = $obj->email;
738 $tmpuser->lastname = $obj->lastname;
739 $tmpuser->firstname = $obj->firstname;
740 $tmpuser->statut = $obj->user_status;
742 print
'<tr class="oddeven">';
744 print
'<td class="left">'.dol_print_date($db->jdate($obj->date_demande),
'dayhour').
"</td>\n";
746 print
'<td align="center">';
747 print $tmpuser->getNomUrl(1,
'', 0, 0, 0, 0,
'login');
750 print
'<td class="center">'.price($obj->amount).
'</td>';
751 print
'<td align="center">-</td>';
752 print
'<td> </td>';
754 print
'<td class="center">'.$langs->trans(
"OrderWaiting").
'</td>';
756 print
'<td class="right">';
757 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.$type.
'">';
765 $db->free($result_sql);
773 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,";
775 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
776 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
777 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on pfd.fk_user_demande = u.rowid";
778 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
779 if ($type ==
'bank-transfer') {
780 $sql .=
" WHERE fk_facture_fourn = ".$object->id;
782 $sql .=
" WHERE fk_facture = ".$object->id;
784 $sql .=
" AND pfd.traite = 1";
785 $sql .=
" AND pfd.ext_payment_id IS NULL";
786 $sql .=
" ORDER BY pfd.date_demande DESC";
788 $result = $db->query($sql);
791 $num = $db->num_rows($result);
795 $tmpuser =
new User($db);
799 $obj = $db->fetch_object($result);
801 $tmpuser->id = $obj->user_id;
802 $tmpuser->login = $obj->login;
803 $tmpuser->ref = $obj->login;
804 $tmpuser->email = $obj->email;
805 $tmpuser->lastname = $obj->lastname;
806 $tmpuser->firstname = $obj->firstname;
807 $tmpuser->statut = $obj->user_status;
809 print
'<tr class="oddeven">';
811 print
'<td class="left">'.dol_print_date($db->jdate($obj->date_demande),
'day').
"</td>\n";
813 print
'<td align="center">';
814 print $tmpuser->getNomUrl(1,
'', 0, 0, 0, 0,
'login');
817 print
'<td class="center">'.price($obj->amount).
'</td>';
819 print
'<td class="center">';
820 if ($obj->fk_prelevement_bons > 0)
823 $withdrawreceipt->id = $obj->fk_prelevement_bons;
824 $withdrawreceipt->ref = $obj->ref;
825 print $withdrawreceipt->getNomUrl(1);
829 print
'<td> </td>';
831 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_traite),
'day').
"</td>\n";
833 print
'<td> </td>';
839 if (!$numopen && !$numclosed)
840 print
'<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Class to manage bank accounts description of third parties.
Class to manage suppliers invoices.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage projects.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class to manage withdrawal receipts.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=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 Calling this function terminate execution ...
facturefourn_prepare_head($object)
Prepare array with list of tabs.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers 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).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage invoices.
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_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
facture_prepare_head($object)
Initialize the array of tabs for customer invoice.