31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
43$langs->loadLangs(array(
'bills',
'banks',
'withdrawals',
'companies'));
47$socid =
GETPOST(
'socid',
'int');
48$action =
GETPOST(
'action',
'aZ09');
51$fieldid = (!empty($ref) ?
'ref' :
'rowid');
53 $socid = $user->socid;
57if ($type ==
'bank-transfer') {
59 $moreparam =
'&type='.$type;
65if ($id > 0 || !empty($ref)) {
66 $ret = $object->fetch($id, $ref);
69 $object->fetch_thirdparty();
73$hookmanager->initHooks(array(
'directdebitcard',
'globalcard'));
75if ($type ==
'bank-transfer') {
76 $result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture',
'fk_soc', $fieldid, $isdraft);
77 if (empty($user->rights->fournisseur->facture->lire)) {
81 $result =
restrictedArea($user,
'facture', $id,
'',
'',
'fk_soc', $fieldid, $isdraft);
82 if (!$user->hasRight(
'facture',
'lire')) {
87if ($type ==
'bank-transfer') {
88 $usercancreate = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
90 $usercancreate = $user->hasRight(
'facture',
'creer');
98$parameters = array(
'socid' => $socid);
99$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
104if (empty($reshook)) {
105 if ($action ==
"new" && $usercancreate) {
106 if ($object->id > 0) {
110 $sourcetype =
'facture';
111 if ($type ==
'bank-transfer') {
112 $sourcetype =
'supplier_invoice';
113 $newtype =
'bank-transfer';
115 $paymentservice =
GETPOST(
'paymentservice');
117 $result = $object->demande_prelevement($user,
price2num(
GETPOST(
'withdraw_request_amount',
'alpha')), $newtype, $sourcetype);
131 if ($action ==
"delete" && $usercancreate) {
132 if ($object->id > 0) {
133 $result = $object->demande_prelevement_delete($user,
GETPOST(
'did',
'int'));
135 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id.
'&type='.$type);
142 if ($action ==
'sepastripedirectdebit' && $usercancreate) {
143 $result = $object->makeStripeSepaRequest($user,
GETPOST(
'did',
'int'),
'direct-debit',
'facture');
148 $ret = $object->fetch($id, $ref);
151 $object->fetch_thirdparty();
157 if ($action ==
'sepastripecredittransfer' && $usercancreate) {
158 $result = $object->makeStripeSepaRequest($user,
GETPOST(
'did',
'int'),
'bank-transfer',
'supplier_invoice');
163 $ret = $object->fetch($id, $ref);
166 $object->fetch_thirdparty();
172 if ($action ==
'setconditions' && $usercancreate) {
174 $object->cond_reglement_code = 0;
175 $object->cond_reglement_id = 0;
182 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id',
'int'));
190 $old_date_echeance = $object->date_echeance;
191 $new_date_echeance = $object->calculate_date_lim_reglement();
192 if ($new_date_echeance > $old_date_echeance) {
193 $object->date_echeance = $new_date_echeance;
195 if ($object->date_echeance < $object->date) {
196 $object->date_echeance = $object->date;
198 $result = $object->update($user);
210 } elseif ($action ==
'setmode' && $usercancreate) {
212 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
213 } elseif ($action ==
'setdatef' && $usercancreate) {
215 if ($newdate > (
dol_now(
'tzuserrel') + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
216 if (empty($conf->global->INVOICE_MAX_FUTURE_DELAY)) {
217 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
219 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
223 $object->date = $newdate;
224 $date_echence_calc = $object->calculate_date_lim_reglement();
225 if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) {
226 $object->date_echeance = $date_echence_calc;
228 if ($object->date_echeance && $object->date_echeance < $object->date) {
229 $object->date_echeance = $object->date;
232 $result = $object->update($user);
236 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
237 $object->date_echeance =
dol_mktime(12, 0, 0,
GETPOST(
'date_lim_reglementmonth',
'int'),
GETPOST(
'date_lim_reglementday',
'int'),
GETPOST(
'date_lim_reglementyear',
'int'));
238 if (!empty($object->date_echeance) && $object->date_echeance < $object->date) {
239 $object->date_echeance = $object->date;
240 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
242 $result = $object->update($user);
254$form =
new Form($db);
258if ($type ==
'bank-transfer') {
259 $title = $langs->trans(
'SupplierInvoice').
" - ".$langs->trans(
'CreditTransfer');
262 $title = $langs->trans(
'InvoiceCustomer').
" - ".$langs->trans(
'StandingOrders');
263 $helpurl =
"EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
269if ($object->id > 0) {
270 $selleruserevenustamp = $mysoc->useRevenueStamp();
272 $totalpaid = $object->getSommePaiement();
273 $totalcreditnotes = $object->getSumCreditNotesUsed();
274 $totaldeposits = $object->getSumDepositsUsed();
281 $resteapayer =
price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
286 $resteapayeraffiche = $resteapayer;
288 if ($type ==
'bank-transfer') {
289 if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
290 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
291 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
293 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
294 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
297 $absolute_discount = $object->thirdparty->getAvailableDiscounts(
'', $filterabsolutediscount, 0, 1);
298 $absolute_creditnote = $object->thirdparty->getAvailableDiscounts(
'', $filtercreditnote, 0, 1);
299 $absolute_discount =
price2num($absolute_discount,
'MT');
300 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
302 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
303 $filterabsolutediscount =
"fk_facture_source IS NULL";
304 $filtercreditnote =
"fk_facture_source IS NOT NULL";
306 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
307 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
310 $absolute_discount = $object->thirdparty->getAvailableDiscounts(
'', $filterabsolutediscount);
311 $absolute_creditnote = $object->thirdparty->getAvailableDiscounts(
'', $filtercreditnote);
312 $absolute_discount =
price2num($absolute_discount,
'MT');
313 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
316 $author =
new User($db);
317 if ($object->fk_user_author) {
318 $author->fetch($object->fk_user_author);
321 if ($type ==
'bank-transfer') {
333 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
334 $sql .=
" , pfd.date_traite as date_traite";
335 $sql .=
" , pfd.amount";
336 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
337 if ($type ==
'bank-transfer') {
338 $sql .=
" WHERE fk_facture_fourn = ".((int) $object->id);
340 $sql .=
" WHERE fk_facture = ".((int) $object->id);
342 $sql .=
" AND pfd.traite = 0";
343 $sql .=
" AND pfd.type = 'ban'";
344 $sql .=
" ORDER BY pfd.date_demande DESC";
346 $resql = $db->query($sql);
348 $num = $db->num_rows($resql);
355 print
dol_get_fiche_head($head,
'standingorders', $title, -1, ($type ==
'bank-transfer' ?
'supplier_invoice' :
'bill'));
358 if ($type ==
'bank-transfer') {
359 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
361 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
364 $morehtmlref =
'<div class="refidno">';
366 if ($type ==
'bank-transfer') {
367 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', 0, 1);
368 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'',
null,
null,
'', 1);
370 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'', 0, 1);
371 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'',
null,
null,
'', 1);
374 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
375 if ($type ==
'bank-transfer') {
376 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
377 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->thirdparty->id.
'&search_company='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
380 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
381 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?socid='.$object->thirdparty->id.
'&search_company='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
385 if (isModEnabled(
'project')) {
386 $langs->load(
"projects");
387 $morehtmlref .=
'<br>';
389 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
390 if ($action !=
'classify') {
391 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
393 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
395 if (!empty($object->fk_project)) {
397 $proj->fetch($object->fk_project);
398 $morehtmlref .= $proj->getNomUrl(1);
400 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
405 $morehtmlref .=
'</div>';
407 $object->totalpaid = $totalpaid;
409 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $moreparam, 0,
'',
'');
411 print
'<div class="fichecenter">';
412 print
'<div class="fichehalfleft">';
413 print
'<div class="underbanner clearboth"></div>';
415 print
'<table class="border centpercent tableforfield">';
418 print
'<tr><td class="titlefield fieldname_type">'.$langs->trans(
'Type').
'</td><td colspan="3">';
419 print
'<span class="badgeneutral">';
420 print $object->getLibType();
422 if (!empty($object->module_source)) {
423 print
' <span class="opacitymediumbycolor paddingleft">('.$langs->trans(
"POS").
' '.$object->module_source.
' - '.$langs->trans(
"Terminal").
' '.$object->pos_source.
')</span>';
425 if ($object->type == $object::TYPE_REPLACEMENT) {
426 if ($type ==
'bank-transfer') {
429 $facreplaced =
new Facture($db);
431 $facreplaced->fetch($object->fk_facture_source);
432 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
434 if ($object->type == $object::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) {
435 if ($type ==
'bank-transfer') {
440 $facusing->fetch($object->fk_facture_source);
441 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
444 $facidavoir = $object->getListIdAvoirFromInvoice();
445 if (count($facidavoir) > 0) {
446 $invoicecredits = array();
447 foreach ($facidavoir as $facid) {
448 if ($type ==
'bank-transfer') {
453 $facavoir->fetch($facid);
454 $invoicecredits[] = $facavoir->getNomUrl(1);
456 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir");
457 print
' '. (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
470 print
'<!-- Discounts -->'.
"\n";
471 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining').
'</td><td colspan="3">';
473 if ($type ==
'bank-transfer') {
476 $thirdparty = $object->thirdparty;
479 $thirdparty = $object->thirdparty;
482 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?facid='.$object->id);
483 $cannotApplyDiscount = 1;
484 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
489 if ($type ==
'bank-transfer') {
491 print
'<td>'.$form->editfieldkey(
"Label",
'label', $object->label, $object, 0).
'</td>';
492 print
'<td>'.$form->editfieldval(
"Label",
'label', $object->label, $object, 0).
'</td>';
498 print
'<table class="nobordernopadding centpercent"><tr><td>';
499 print $langs->trans(
'DateInvoice');
501 if ($object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editinvoicedate' && !empty($object->brouillon) && $user->hasRight(
'facture',
'creer')) {
502 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editinvoicedate&token='.newToken().
'&id='.$object->id.
'&type='.urlencode($type).
'">'.
img_edit($langs->trans(
'SetDate'), 1).
'</a></td>';
504 print
'</tr></table>';
505 print
'</td><td colspan="3">';
507 if ($object->type != $object::TYPE_CREDIT_NOTE) {
508 if ($action ==
'editinvoicedate') {
509 print $form->form_date($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->date,
'invoicedate', 0, 0, 1, $type);
521 print
'<table class="nobordernopadding centpercent"><tr><td>';
522 print $langs->trans(
'PaymentConditionsShort');
524 if ($object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editconditions' && !empty($object->brouillon) && $user->hasRight(
'facture',
'creer')) {
525 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editconditions&token='.newToken().
'&id='.$object->id.
'&type='.urlencode($type).
'">'.
img_edit($langs->trans(
'SetConditions'), 1).
'</a></td>';
527 print
'</tr></table>';
528 print
'</td><td colspan="3">';
529 if ($object->type != $object::TYPE_CREDIT_NOTE) {
530 if ($action ==
'editconditions') {
531 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id', 0, $type);
533 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none');
542 print
'<table class="nobordernopadding centpercent"><tr><td>';
543 print $langs->trans(
'DateMaxPayment');
545 if ($object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editpaymentterm' && !empty($object->brouillon) && $user->hasRight(
'facture',
'creer')) {
546 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editpaymentterm&token='.newToken().
'&id='.$object->id.
'&type='.urlencode($type).
'">'.
img_edit($langs->trans(
'SetDate'), 1).
'</a></td>';
548 print
'</tr></table>';
549 print
'</td><td colspan="3">';
550 if ($object->type != $object::TYPE_CREDIT_NOTE) {
551 $duedate = $object->date_lim_reglement;
552 if ($type ==
'bank-transfer') {
553 $duedate = $object->date_echeance;
556 if ($action ==
'editpaymentterm') {
557 print $form->form_date($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $duedate,
'paymentterm', 0, 0, 1, $type);
560 if ($object->hasDelay()) {
571 print
'<table class="nobordernopadding centpercent"><tr><td>';
572 print $langs->trans(
'PaymentMode');
574 if ($action !=
'editmode' && !empty($object->brouillon) && $user->hasRight(
'facture',
'creer')) {
575 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&token='.newToken().
'&id='.$object->id.
'&type='.urlencode($type).
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
577 print
'</tr></table>';
578 print
'</td><td colspan="3">';
579 $filtertype =
'CRDT';
580 if ($type ==
'bank-transfer') {
581 $filtertype =
'DBIT';
583 if ($action ==
'editmode') {
584 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id', $filtertype, 1, 0, $type);
586 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
591 print
'<tr><td class="nowrap">';
592 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
593 print $langs->trans(
'BankAccount');
595 if (($action !=
'editbankaccount') && $user->hasRight(
'commande',
'creer') && !empty($object->brouillon)) {
596 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbankaccount&token='.newToken().
'&id='.$object->id.
'&type='.urlencode($type).
'">'.
img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
598 print
'</tr></table>';
599 print
'</td><td colspan="3">';
600 if ($action ==
'editbankaccount') {
601 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
603 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
609 $title =
'CustomerIBAN';
610 if ($type ==
'bank-transfer') {
611 $title =
'SupplierIBAN';
613 print
'<tr><td>'.$langs->trans($title).
'</td><td colspan="3">';
616 $bac->fetch(0, $object->thirdparty->id);
618 print $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
619 if (!empty($bac->iban)) {
620 if ($bac->verif() <= 0) {
621 print
img_warning(
'Error on default bank number for IBAN : '.$bac->error_message);
624 if ($numopen || ($type !=
'bank-transfer' && $object->mode_reglement_code ==
'PRE') || ($type ==
'bank-transfer' && $object->mode_reglement_code ==
'VIR')) {
625 print
img_warning($langs->trans(
"NoDefaultIBANFound"));
634 print
'<div class="fichehalfright">';
635 print
'<div class="underbanner clearboth"></div>';
637 print
'<table class="border centpercent tableforfield">';
639 if (isModEnabled(
'multicurrency') && ($object->multicurrency_code != $conf->currency)) {
641 print
'<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
'MulticurrencyAmountHT',
'multicurrency_total_ht',
'', $object, 0).
'</td>';
642 print
'<td class="nowrap">'.price($object->multicurrency_total_ht,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
646 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountVAT',
'multicurrency_total_tva',
'', $object, 0).
'</td>';
647 print
'<td class="nowrap">'.price($object->multicurrency_total_tva,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
651 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountTTC',
'multicurrency_total_ttc',
'', $object, 0).
'</td>';
652 print
'<td class="nowrap">'.price($object->multicurrency_total_ttc,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
657 print
'<tr><td class="titlefield">'.$langs->trans(
'AmountHT').
'</td>';
658 print
'<td class="nowrap">'.price($object->total_ht, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
661 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="3" class="nowrap">'.
price($object->total_tva, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
665 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) {
666 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
667 print
'<td class="nowrap">'.price($object->total_localtax1, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
669 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) {
670 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
671 print
'<td class=nowrap">'.price($object->total_localtax2, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
675 if ($selleruserevenustamp) {
677 print
'<table class="nobordernopadding" width="100%"><tr><td>';
678 print $langs->trans(
'RevenueStamp');
680 if ($action !=
'editrevenuestamp' && !empty($object->brouillon) && $user->hasRight(
'facture',
'creer')) {
681 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editrevenuestamp&token='.newToken().
'&facid='.$object->id.
'">'.
img_edit($langs->trans(
'SetRevenuStamp'), 1).
'</a></td>';
683 print
'</tr></table>';
685 print
price($object->revenuestamp, 1,
'', 1, - 1, - 1, $conf->currency);
690 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td class="nowrap">'.
price($object->total_ttc, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
692 $resteapayer =
price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
695 $parameters = array(
'remaintopay' => $resteapayer);
696 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfSupplierInvoice', $parameters, $object, $action);
698 print $hookmanager->resPrint;
699 if (!empty($remaintopay = $hookmanager->resArray[
'remaintopay'])) {
700 $resteapayer = $remaintopay;
705 print
'<tr><td>'.$langs->trans(
'RemainderToPay').
'</td><td class="nowrap">'.
price($resteapayer, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
712 print
'<div class="clearboth"></div>';
720 $sql =
"SELECT SUM(pfd.amount) as amount";
721 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
722 if ($type ==
'bank-transfer') {
723 $sql .=
" WHERE fk_facture_fourn = ".((int) $object->id);
725 $sql .=
" WHERE fk_facture = ".((int) $object->id);
727 $sql .=
" AND pfd.traite = 0";
728 $sql .=
" AND pfd.type = 'ban'";
730 $resql = $db->query($sql);
732 $obj = $db->fetch_object($resql);
734 $pending = $obj->amount;
745 print
"\n".
'<div class="tabsAction">'.
"\n";
747 $buttonlabel = $langs->trans(
"MakeWithdrawRequest");
748 $user_perms = $user->hasRight(
'prelevement',
'bons',
'creer');
749 if ($type ==
'bank-transfer') {
750 $buttonlabel = $langs->trans(
"MakeBankTransferOrder");
751 $user_perms = $user->hasRight(
'paymentbybanktransfer',
'create');
755 if ($object->statut > $object::STATUS_DRAFT && $object->paye == 0 && $num == 0) {
756 if ($resteapayer > 0) {
758 $remaintopaylesspendingdebit = $resteapayer - $pending;
760 print
'<form method="POST" action="">';
761 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
762 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
763 print
'<input type="hidden" name="type" value="'.$type.
'" />';
764 print
'<input type="hidden" name="action" value="new" />';
765 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
766 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
767 print
'<input type="submit" class="butAction" value="'.$buttonlabel.
'" />';
774 $buttonlabel = $langs->trans(
"MakeWithdrawRequestStripe");
775 print
'<form method="POST" action="">';
776 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
777 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
778 print
'<input type="hidden" name="type" value="'.$type.
'" />';
779 print
'<input type="hidden" name="action" value="new" />';
780 print
'<input type="hidden" name="paymenservice" value="stripesepa" />';
781 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
782 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
783 print
'<input type="submit" class="butAction" value="'.$buttonlabel.
'" />';
787 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$buttonlabel.
'</a>';
790 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AmountMustBePositive")).
'">'.$buttonlabel.
'</a>';
794 if ($object->statut > $object::STATUS_DRAFT) {
795 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AlreadyPaid")).
'">'.$buttonlabel.
'</a>';
797 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"Draft")).
'">'.$buttonlabel.
'</a>';
800 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"RequestAlreadyDone")).
'">'.$buttonlabel.
'</a>';
807 if ($type ==
'bank-transfer') {
808 print
'<div class="opacitymedium">'.$langs->trans(
"DoCreditTransferBeforePayments");
810 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
812 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
815 print
'<div class="opacitymedium">'.$langs->trans(
"DoStandingOrdersBeforePayments");
817 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
819 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
827 print
'<div class="div-table-responsive-no-min">';
828 print
'<table class="noborder centpercent">';
830 print
'<tr class="liste_titre">';
833 print
'<td> </td>';
835 print
'<td class="left">'.$langs->trans(
"DateRequest").
'</td>';
836 print
'<td>'.$langs->trans(
"User").
'</td>';
837 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
838 print
'<td class="center">'.$langs->trans(
"DateProcess").
'</td>';
839 if ($type ==
'bank-transfer') {
840 print
'<td class="center">'.$langs->trans(
"BankTransferReceipt").
'</td>';
842 print
'<td class="center">'.$langs->trans(
"WithdrawalReceipt").
'</td>';
844 print
'<td> </td>';
847 print
'<td> </td>';
851 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
852 $sql .=
" pfd.date_traite as date_traite, pfd.amount, pfd.fk_prelevement_bons,";
853 $sql .=
" pb.ref, pb.date_trans, pb.method_trans, pb.credite, pb.date_credit, pb.datec, pb.statut as status, pb.amount as pb_amount,";
854 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
855 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
856 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on pfd.fk_user_demande = u.rowid";
857 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
858 if ($type ==
'bank-transfer') {
859 $sql .=
" WHERE fk_facture_fourn = ".((int) $object->id);
861 $sql .=
" WHERE fk_facture = ".((int) $object->id);
863 $sql .=
" AND pfd.traite = 0";
864 $sql .=
" AND pfd.type = 'ban'";
865 $sql .=
" ORDER BY pfd.date_demande DESC";
867 $resql = $db->query($sql);
873 $tmpuser =
new User($db);
875 $num = $db->num_rows($result);
877 $obj = $db->fetch_object($resql);
879 $tmpuser->id = $obj->user_id;
880 $tmpuser->login = $obj->login;
881 $tmpuser->ref = $obj->login;
882 $tmpuser->email = $obj->email;
883 $tmpuser->lastname = $obj->lastname;
884 $tmpuser->firstname = $obj->firstname;
885 $tmpuser->statut = $obj->user_status;
886 $tmpuser->status = $obj->user_status;
888 print
'<tr class="oddeven">';
892 print
'<td class="right">';
893 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
899 print
'<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande),
'dayhour').
"</td>\n";
902 print
'<td class="tdoverflowmax125">';
903 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
907 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
910 print
'<td class="center"><span class="opacitymedium">'.$langs->trans(
"OrderWaiting").
'</span></td>';
913 print
'<td class="minwidth75">';
914 if ($obj->fk_prelevement_bons > 0) {
916 $withdrawreceipt->id = $obj->fk_prelevement_bons;
917 $withdrawreceipt->ref = $obj->ref;
918 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
919 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
920 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
921 $withdrawreceipt->statut = $obj->status;
922 $withdrawreceipt->status = $obj->status;
923 $withdrawreceipt->amount = $obj->pb_amount;
926 print $withdrawreceipt->getNomUrl(1);
929 if ($type !=
'bank-transfer') {
930 if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) {
931 $langs->load(
"stripe");
932 if ($obj->fk_prelevement_bons > 0) {
935 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=sepastripedirectdebit&paymentservice=stripesepa&token='.newToken().
'&did='.$obj->rowid.
'&id='.$object->id.
'&type='.urlencode($type).
'">'.
img_picto(
'',
'stripe',
'class="pictofixedwidth"').$langs->trans(
"RequestDirectDebitWithStripe").
'</a>';
938 if (!empty($conf->global->STRIPE_SEPA_CREDIT_TRANSFER)) {
939 $langs->load(
"stripe");
940 if ($obj->fk_prelevement_bons > 0) {
943 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=sepastripecredittransfer&paymentservice=stripesepa&token='.newToken().
'&did='.$obj->rowid.
'&id='.$object->id.
'&type='.urlencode($type).
'">'.
img_picto(
'',
'stripe',
'class="pictofixedwidth"').$langs->trans(
"RequestDirectDebitWithStripe").
'</a>';
949 print
'<td class="center">-</td>';
953 print
'<td class="right">';
954 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
971 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,";
972 $sql .=
" pb.ref, pb.date_trans, pb.method_trans, pb.credite, pb.date_credit, pb.datec, pb.statut as status, pb.fk_bank_account, pb.amount as pb_amount,";
973 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status, u.photo as user_photo";
974 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
975 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on pfd.fk_user_demande = u.rowid";
976 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
977 if ($type ==
'bank-transfer') {
978 $sql .=
" WHERE fk_facture_fourn = ".((int) $object->id);
980 $sql .=
" WHERE fk_facture = ".((int) $object->id);
982 $sql .=
" AND pfd.traite = 1";
983 $sql .=
" AND pfd.type = 'ban'";
984 $sql .=
" ORDER BY pfd.date_demande DESC";
986 $resql = $db->query($sql);
988 $num = $db->num_rows($resql);
992 $tmpuser =
new User($db);
995 $obj = $db->fetch_object($resql);
997 $tmpuser->id = $obj->user_id;
998 $tmpuser->login = $obj->login;
999 $tmpuser->ref = $obj->login;
1000 $tmpuser->email = $obj->email;
1001 $tmpuser->lastname = $obj->lastname;
1002 $tmpuser->firstname = $obj->firstname;
1003 $tmpuser->statut = $obj->user_status;
1004 $tmpuser->status = $obj->user_status;
1005 $tmpuser->photo = $obj->user_photo;
1007 print
'<tr class="oddeven">';
1011 print
'<td> </td>';
1015 print
'<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande),
'day').
"</td>\n";
1018 print
'<td class="tdoverflowmax125">';
1019 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
1023 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
1026 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_traite),
'dayhour',
'tzuserrel').
"</td>\n";
1029 print
'<td class="center minwidth75">';
1030 if ($obj->fk_prelevement_bons > 0) {
1032 $withdrawreceipt->id = $obj->fk_prelevement_bons;
1033 $withdrawreceipt->ref = $obj->ref;
1034 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
1035 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
1036 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
1037 $withdrawreceipt->statut = $obj->status;
1038 $withdrawreceipt->status = $obj->status;
1039 $withdrawreceipt->fk_bank_account = $obj->fk_bank_account;
1040 $withdrawreceipt->amount = $obj->pb_amount;
1043 print $withdrawreceipt->getNomUrl(1);
1045 print $withdrawreceipt->getLibStatut(2);
1048 $fk_bank_account = $withdrawreceipt->fk_bank_account;
1049 if (empty($fk_bank_account)) {
1050 $fk_bank_account = ($object->type ==
'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
1052 if ($fk_bank_account > 0) {
1053 $bankaccount =
new Account($db);
1054 $result = $bankaccount->fetch($fk_bank_account);
1057 print $bankaccount->getNomUrl(1);
1064 print
'<td> </td>';
1068 print
'<td> </td>';
1075 if (!$numopen && !$numclosed) {
1076 print
'<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
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 bank accounts description of third parties.
Class to manage suppliers invoices.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
Class to manage projects.
Class to manage Dolibarr users.
facturefourn_prepare_head(FactureFournisseur $object)
Prepare array with list of tabs.
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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete 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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
facture_prepare_head($object)
Initialize the array of tabs for customer invoice.
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.