2 use Stripe\BankAccount;
33 require
'../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
45 $langs->loadLangs(array(
'bills',
'banks',
'withdrawals',
'companies'));
49 $socid =
GETPOST(
'socid',
'int');
50 $action =
GETPOST(
'action',
'aZ09');
51 $type =
GETPOST(
'type',
'aZ09');
53 $fieldid = (!empty($ref) ?
'ref' :
'rowid');
55 $socid = $user->socid;
59 if ($type ==
'bank-transfer') {
61 $moreparam =
'&type='.$type;
67 if ($id > 0 || !empty($ref)) {
68 $ret = $object->fetch($id, $ref);
71 $object->fetch_thirdparty();
75 $hookmanager->initHooks(array(
'directdebitcard',
'globalcard'));
77 if ($type ==
'bank-transfer') {
78 $result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture',
'fk_soc', $fieldid, $isdraft);
79 if (empty($user->rights->fournisseur->facture->lire)) {
83 $result =
restrictedArea($user,
'facture', $id,
'',
'',
'fk_soc', $fieldid, $isdraft);
84 if (!$user->hasRight(
'facture',
'lire')) {
89 if ($type ==
'bank-transfer') {
90 $usercancreate = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
92 $usercancreate = $user->hasRight(
'facture',
'creer');
100 $parameters = array(
'socid' => $socid);
101 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
106 if (empty($reshook)) {
107 if ($action ==
"new" && $usercancreate) {
108 if ($object->id > 0) {
112 $sourcetype =
'facture';
113 if ($type ==
'bank-transfer') {
114 $sourcetype =
'supplier_invoice';
115 $newtype =
'bank-transfer';
117 $paymentservice =
GETPOST(
'paymentservice');
119 $result = $object->demande_prelevement($user,
price2num(
GETPOST(
'withdraw_request_amount',
'alpha')), $newtype, $sourcetype);
133 if ($action ==
"delete" && $usercancreate) {
134 if ($object->id > 0) {
135 $result = $object->demande_prelevement_delete($user,
GETPOST(
'did',
'int'));
137 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id.
'&type='.$type);
144 if ($action ==
'sepastripedirectdebit' && $usercancreate) {
145 $result = $object->makeStripeSepaRequest($user,
GETPOST(
'did',
'int'),
'direct-debit',
'facture');
150 $ret = $object->fetch($id, $ref);
153 $object->fetch_thirdparty();
159 if ($action ==
'sepastripecredittransfer' && $usercancreate) {
160 $result = $object->makeStripeSepaRequest($user,
GETPOST(
'did',
'int'),
'bank-transfer',
'supplier_invoice');
165 $ret = $object->fetch($id, $ref);
168 $object->fetch_thirdparty();
174 if ($action ==
'setconditions' && $usercancreate) {
176 $object->cond_reglement_code = 0;
177 $object->cond_reglement_id = 0;
184 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id',
'int'));
192 $old_date_echeance = $object->date_echeance;
193 $new_date_echeance = $object->calculate_date_lim_reglement();
194 if ($new_date_echeance > $old_date_echeance) {
195 $object->date_echeance = $new_date_echeance;
197 if ($object->date_echeance < $object->date) {
198 $object->date_echeance = $object->date;
200 $result = $object->update($user);
212 } elseif ($action ==
'setmode' && $usercancreate) {
214 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
215 } elseif ($action ==
'setdatef' && $usercancreate) {
217 if ($newdate > (
dol_now(
'tzuserrel') + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
218 if (empty($conf->global->INVOICE_MAX_FUTURE_DELAY)) {
219 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
221 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
225 $object->date = $newdate;
226 $date_echence_calc = $object->calculate_date_lim_reglement();
227 if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) {
228 $object->date_echeance = $date_echence_calc;
230 if ($object->date_echeance && $object->date_echeance < $object->date) {
231 $object->date_echeance = $object->date;
234 $result = $object->update($user);
238 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
239 $object->date_echeance =
dol_mktime(12, 0, 0,
GETPOST(
'date_lim_reglementmonth',
'int'),
GETPOST(
'date_lim_reglementday',
'int'),
GETPOST(
'date_lim_reglementyear',
'int'));
240 if (!empty($object->date_echeance) && $object->date_echeance < $object->date) {
241 $object->date_echeance = $object->date;
242 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
244 $result = $object->update($user);
260 if ($type ==
'bank-transfer') {
261 $title = $langs->trans(
'SupplierInvoice').
" - ".$langs->trans(
'CreditTransfer');
264 $title = $langs->trans(
'InvoiceCustomer').
" - ".$langs->trans(
'StandingOrders');
265 $helpurl =
"EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
271 if ($object->id > 0) {
272 $selleruserevenustamp = $mysoc->useRevenueStamp();
274 $totalpaid = $object->getSommePaiement();
275 $totalcreditnotes = $object->getSumCreditNotesUsed();
276 $totaldeposits = $object->getSumDepositsUsed();
283 $resteapayer =
price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
288 $resteapayeraffiche = $resteapayer;
290 if ($type ==
'bank-transfer') {
291 if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
292 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
293 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
295 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
296 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
299 $absolute_discount = $object->thirdparty->getAvailableDiscounts(
'', $filterabsolutediscount, 0, 1);
300 $absolute_creditnote = $object->thirdparty->getAvailableDiscounts(
'', $filtercreditnote, 0, 1);
301 $absolute_discount =
price2num($absolute_discount,
'MT');
302 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
304 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
305 $filterabsolutediscount =
"fk_facture_source IS NULL";
306 $filtercreditnote =
"fk_facture_source IS NOT NULL";
308 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
309 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
312 $absolute_discount = $object->thirdparty->getAvailableDiscounts(
'', $filterabsolutediscount);
313 $absolute_creditnote = $object->thirdparty->getAvailableDiscounts(
'', $filtercreditnote);
314 $absolute_discount =
price2num($absolute_discount,
'MT');
315 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
318 $author =
new User($db);
319 if ($object->fk_user_author) {
320 $author->fetch($object->fk_user_author);
323 if ($type ==
'bank-transfer') {
335 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
336 $sql .=
" , pfd.date_traite as date_traite";
337 $sql .=
" , pfd.amount";
338 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
339 if ($type ==
'bank-transfer') {
340 $sql .=
" WHERE fk_facture_fourn = ".((int) $object->id);
342 $sql .=
" WHERE fk_facture = ".((int) $object->id);
344 $sql .=
" AND pfd.traite = 0";
345 $sql .=
" AND pfd.type = 'ban'";
346 $sql .=
" ORDER BY pfd.date_demande DESC";
348 $resql = $db->query(
$sql);
350 $num = $db->num_rows($resql);
357 print
dol_get_fiche_head($head,
'standingorders', $title, -1, ($type ==
'bank-transfer' ?
'supplier_invoice' :
'bill'));
360 if ($type ==
'bank-transfer') {
361 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
363 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
366 $morehtmlref =
'<div class="refidno">';
368 if ($type ==
'bank-transfer') {
369 $morehtmlref .=
$form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', 0, 1);
370 $morehtmlref .=
$form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'',
null,
null,
'', 1);
372 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'', 0, 1);
373 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'',
null,
null,
'', 1);
376 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
377 if ($type ==
'bank-transfer') {
378 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
379 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->thirdparty->id.
'&search_company='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
382 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
383 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?socid='.$object->thirdparty->id.
'&search_company='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
388 $langs->load(
"projects");
389 $morehtmlref .=
'<br>';
391 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
392 if ($action !=
'classify') {
393 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
395 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
397 if (!empty($object->fk_project)) {
399 $proj->fetch($object->fk_project);
400 $morehtmlref .= $proj->getNomUrl(1);
402 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
407 $morehtmlref .=
'</div>';
409 $object->totalpaid = $totalpaid;
411 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $moreparam, 0,
'',
'');
413 print
'<div class="fichecenter">';
414 print
'<div class="fichehalfleft">';
415 print
'<div class="underbanner clearboth"></div>';
417 print
'<table class="border centpercent tableforfield">';
420 print
'<tr><td class="titlefield fieldname_type">'.$langs->trans(
'Type').
'</td><td colspan="3">';
421 print
'<span class="badgeneutral">';
422 print $object->getLibType();
424 if (!empty($object->module_source)) {
425 print
' <span class="opacitymediumbycolor paddingleft">('.$langs->trans(
"POS").
' '.$object->module_source.
' - '.$langs->trans(
"Terminal").
' '.$object->pos_source.
')</span>';
427 if ($object->type == $object::TYPE_REPLACEMENT) {
428 if ($type ==
'bank-transfer') {
431 $facreplaced =
new Facture($db);
433 $facreplaced->fetch($object->fk_facture_source);
434 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
436 if ($object->type == $object::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) {
437 if ($type ==
'bank-transfer') {
442 $facusing->fetch($object->fk_facture_source);
443 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
446 $facidavoir = $object->getListIdAvoirFromInvoice();
447 if (count($facidavoir) > 0) {
448 $invoicecredits = array();
449 foreach ($facidavoir as $facid) {
450 if ($type ==
'bank-transfer') {
455 $facavoir->fetch($facid);
456 $invoicecredits[] = $facavoir->getNomUrl(1);
458 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir");
459 print
' '. (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
472 print
'<!-- Discounts -->'.
"\n";
473 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining').
'</td><td colspan="3">';
475 if ($type ==
'bank-transfer') {
478 $thirdparty = $object->thirdparty;
481 $thirdparty = $object->thirdparty;
484 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?facid='.$object->id);
485 $cannotApplyDiscount = 1;
486 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
491 if ($type ==
'bank-transfer') {
493 print
'<td>'.$form->editfieldkey(
"Label",
'label', $object->label, $object, 0).
'</td>';
494 print
'<td>'.$form->editfieldval(
"Label",
'label', $object->label, $object, 0).
'</td>';
500 print
'<table class="nobordernopadding centpercent"><tr><td>';
501 print $langs->trans(
'DateInvoice');
503 if ($object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editinvoicedate' && !empty($object->brouillon) && $user->hasRight(
'facture',
'creer')) {
504 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>';
506 print
'</tr></table>';
507 print
'</td><td colspan="3">';
509 if ($object->type != $object::TYPE_CREDIT_NOTE) {
510 if ($action ==
'editinvoicedate') {
511 print
$form->form_date($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->date,
'invoicedate', 0, 0, 1, $type);
523 print
'<table class="nobordernopadding centpercent"><tr><td>';
524 print $langs->trans(
'PaymentConditionsShort');
526 if ($object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editconditions' && !empty($object->brouillon) && $user->hasRight(
'facture',
'creer')) {
527 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>';
529 print
'</tr></table>';
530 print
'</td><td colspan="3">';
531 if ($object->type != $object::TYPE_CREDIT_NOTE) {
532 if ($action ==
'editconditions') {
533 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id', 0, $type);
535 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none');
544 print
'<table class="nobordernopadding centpercent"><tr><td>';
545 print $langs->trans(
'DateMaxPayment');
547 if ($object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editpaymentterm' && !empty($object->brouillon) && $user->hasRight(
'facture',
'creer')) {
548 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>';
550 print
'</tr></table>';
551 print
'</td><td colspan="3">';
552 if ($object->type != $object::TYPE_CREDIT_NOTE) {
553 $duedate = $object->date_lim_reglement;
554 if ($type ==
'bank-transfer') {
555 $duedate = $object->date_echeance;
558 if ($action ==
'editpaymentterm') {
559 print
$form->form_date($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $duedate,
'paymentterm', 0, 0, 1, $type);
562 if ($object->hasDelay()) {
573 print
'<table class="nobordernopadding centpercent"><tr><td>';
574 print $langs->trans(
'PaymentMode');
576 if ($action !=
'editmode' && !empty($object->brouillon) && $user->hasRight(
'facture',
'creer')) {
577 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>';
579 print
'</tr></table>';
580 print
'</td><td colspan="3">';
581 $filtertype =
'CRDT';
582 if ($type ==
'bank-transfer') {
583 $filtertype =
'DBIT';
585 if ($action ==
'editmode') {
586 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id', $filtertype, 1, 0, $type);
588 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
593 print
'<tr><td class="nowrap">';
594 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
595 print $langs->trans(
'BankAccount');
597 if (($action !=
'editbankaccount') && $user->hasRight(
'commande',
'creer') && !empty($object->brouillon)) {
598 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>';
600 print
'</tr></table>';
601 print
'</td><td colspan="3">';
602 if ($action ==
'editbankaccount') {
603 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
605 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
611 $title =
'CustomerIBAN';
612 if ($type ==
'bank-transfer') {
613 $title =
'SupplierIBAN';
615 print
'<tr><td>'.$langs->trans($title).
'</td><td colspan="3">';
618 $bac->fetch(0, $object->thirdparty->id);
620 print $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
621 if (!empty($bac->iban)) {
622 if ($bac->verif() <= 0) {
623 print
img_warning(
'Error on default bank number for IBAN : '.$bac->error_message);
626 if ($numopen || ($type !=
'bank-transfer' && $object->mode_reglement_code ==
'PRE') || ($type ==
'bank-transfer' && $object->mode_reglement_code ==
'VIR')) {
627 print
img_warning($langs->trans(
"NoDefaultIBANFound"));
636 print
'<div class="fichehalfright">';
637 print
'<div class="underbanner clearboth"></div>';
639 print
'<table class="border centpercent tableforfield">';
641 if (
isModEnabled(
'multicurrency') && ($object->multicurrency_code != $conf->currency)) {
643 print
'<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
'MulticurrencyAmountHT',
'multicurrency_total_ht',
'', $object, 0).
'</td>';
644 print
'<td class="nowrap">'.price($object->multicurrency_total_ht,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
648 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountVAT',
'multicurrency_total_tva',
'', $object, 0).
'</td>';
649 print
'<td class="nowrap">'.price($object->multicurrency_total_tva,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
653 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountTTC',
'multicurrency_total_ttc',
'', $object, 0).
'</td>';
654 print
'<td class="nowrap">'.price($object->multicurrency_total_ttc,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
659 print
'<tr><td class="titlefield">'.$langs->trans(
'AmountHT').
'</td>';
660 print
'<td class="nowrap">'.price($object->total_ht, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
663 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="3" class="nowrap">'.
price($object->total_tva, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
667 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) {
668 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
669 print
'<td class="nowrap">'.price($object->total_localtax1, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
671 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) {
672 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
673 print
'<td class=nowrap">'.price($object->total_localtax2, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
677 if ($selleruserevenustamp) {
679 print
'<table class="nobordernopadding" width="100%"><tr><td>';
680 print $langs->trans(
'RevenueStamp');
682 if ($action !=
'editrevenuestamp' && !empty($object->brouillon) && $user->hasRight(
'facture',
'creer')) {
683 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>';
685 print
'</tr></table>';
687 print
price($object->revenuestamp, 1,
'', 1, - 1, - 1, $conf->currency);
692 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td class="nowrap">'.
price($object->total_ttc, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
694 $resteapayer =
price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
697 $parameters = array(
'remaintopay' => $resteapayer);
698 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfSupplierInvoice', $parameters, $object, $action);
700 print $hookmanager->resPrint;
701 if (!empty($remaintopay = $hookmanager->resArray[
'remaintopay'])) {
702 $resteapayer = $remaintopay;
707 print
'<tr><td>'.$langs->trans(
'RemainderToPay').
'</td><td class="nowrap">'.
price($resteapayer, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
714 print
'<div class="clearboth"></div>';
722 $sql =
"SELECT SUM(pfd.amount) as amount";
723 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
724 if ($type ==
'bank-transfer') {
725 $sql .=
" WHERE fk_facture_fourn = ".((int) $object->id);
727 $sql .=
" WHERE fk_facture = ".((int) $object->id);
729 $sql .=
" AND pfd.traite = 0";
730 $sql .=
" AND pfd.type = 'ban'";
732 $resql = $db->query(
$sql);
734 $obj = $db->fetch_object($resql);
736 $pending = $obj->amount;
747 print
"\n".
'<div class="tabsAction">'.
"\n";
749 $buttonlabel = $langs->trans(
"MakeWithdrawRequest");
750 $user_perms = $user->hasRight(
'prelevement',
'bons',
'creer');
751 if ($type ==
'bank-transfer') {
752 $buttonlabel = $langs->trans(
"MakeBankTransferOrder");
753 $user_perms = $user->hasRight(
'paymentbybanktransfer',
'create');
757 if ($object->statut > $object::STATUS_DRAFT && $object->paye == 0 && $num == 0) {
758 if ($resteapayer > 0) {
760 $remaintopaylesspendingdebit = $resteapayer - $pending;
762 print
'<form method="POST" action="">';
763 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
764 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
765 print
'<input type="hidden" name="type" value="'.$type.
'" />';
766 print
'<input type="hidden" name="action" value="new" />';
767 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
768 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
769 print
'<input type="submit" class="butAction" value="'.$buttonlabel.
'" />';
776 $buttonlabel = $langs->trans(
"MakeWithdrawRequestStripe");
777 print
'<form method="POST" action="">';
778 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
779 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
780 print
'<input type="hidden" name="type" value="'.$type.
'" />';
781 print
'<input type="hidden" name="action" value="new" />';
782 print
'<input type="hidden" name="paymenservice" value="stripesepa" />';
783 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
784 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
785 print
'<input type="submit" class="butAction" value="'.$buttonlabel.
'" />';
789 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$buttonlabel.
'</a>';
792 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AmountMustBePositive")).
'">'.$buttonlabel.
'</a>';
796 if ($object->statut > $object::STATUS_DRAFT) {
797 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AlreadyPaid")).
'">'.$buttonlabel.
'</a>';
799 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"Draft")).
'">'.$buttonlabel.
'</a>';
802 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"RequestAlreadyDone")).
'">'.$buttonlabel.
'</a>';
809 if ($type ==
'bank-transfer') {
810 print
'<div class="opacitymedium">'.$langs->trans(
"DoCreditTransferBeforePayments");
812 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
814 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
817 print
'<div class="opacitymedium">'.$langs->trans(
"DoStandingOrdersBeforePayments");
819 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
821 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
829 print
'<div class="div-table-responsive-no-min">';
830 print
'<table class="noborder centpercent">';
832 print
'<tr class="liste_titre">';
833 print
'<td class="left">'.$langs->trans(
"DateRequest").
'</td>';
834 print
'<td class="center">'.$langs->trans(
"User").
'</td>';
835 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
836 print
'<td class="center">'.$langs->trans(
"DateProcess").
'</td>';
837 if ($type ==
'bank-transfer') {
838 print
'<td class="center">'.$langs->trans(
"BankTransferReceipt").
'</td>';
840 print
'<td class="center">'.$langs->trans(
"WithdrawalReceipt").
'</td>';
842 print
'<td> </td>';
843 print
'<td> </td>';
846 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
847 $sql .=
" pfd.date_traite as date_traite, pfd.amount, pfd.fk_prelevement_bons,";
848 $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,";
849 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
850 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
851 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on pfd.fk_user_demande = u.rowid";
852 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
853 if ($type ==
'bank-transfer') {
854 $sql .=
" WHERE fk_facture_fourn = ".((int) $object->id);
856 $sql .=
" WHERE fk_facture = ".((int) $object->id);
858 $sql .=
" AND pfd.traite = 0";
859 $sql .=
" AND pfd.type = 'ban'";
860 $sql .=
" ORDER BY pfd.date_demande DESC";
862 $resql = $db->query(
$sql);
868 $tmpuser =
new User($db);
870 $num = $db->num_rows($result);
872 $obj = $db->fetch_object($resql);
874 $tmpuser->id = $obj->user_id;
875 $tmpuser->login = $obj->login;
876 $tmpuser->ref = $obj->login;
877 $tmpuser->email = $obj->email;
878 $tmpuser->lastname = $obj->lastname;
879 $tmpuser->firstname = $obj->firstname;
880 $tmpuser->statut = $obj->user_status;
882 print
'<tr class="oddeven">';
885 print
'<td class="left">'.dol_print_date($db->jdate($obj->date_demande),
'dayhour').
"</td>\n";
888 print
'<td align="center">';
889 print $tmpuser->getNomUrl(1,
'', 0, 0, 0, 0,
'login');
893 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
896 print
'<td class="center"><span class="opacitymedium">'.$langs->trans(
"OrderWaiting").
'</span></td>';
899 print
'<td class="center">';
900 if ($obj->fk_prelevement_bons > 0) {
902 $withdrawreceipt->id = $obj->fk_prelevement_bons;
903 $withdrawreceipt->ref = $obj->ref;
904 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
905 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
906 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
907 $withdrawreceipt->statut = $obj->status;
908 $withdrawreceipt->status = $obj->status;
909 $withdrawreceipt->amount = $obj->pb_amount;
912 print $withdrawreceipt->getNomUrl(1);
915 if ($type !=
'bank-transfer') {
916 if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) {
917 $langs->load(
"stripe");
918 if ($obj->fk_prelevement_bons > 0) {
921 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>';
924 if (!empty($conf->global->STRIPE_SEPA_CREDIT_TRANSFER)) {
925 $langs->load(
"stripe");
926 if ($obj->fk_prelevement_bons > 0) {
929 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>';
935 print
'<td class="center">-</td>';
938 print
'<td class="right">';
939 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
955 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,";
956 $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,";
957 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
958 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
959 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on pfd.fk_user_demande = u.rowid";
960 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
961 if ($type ==
'bank-transfer') {
962 $sql .=
" WHERE fk_facture_fourn = ".((int) $object->id);
964 $sql .=
" WHERE fk_facture = ".((int) $object->id);
966 $sql .=
" AND pfd.traite = 1";
967 $sql .=
" AND pfd.type = 'ban'";
968 $sql .=
" ORDER BY pfd.date_demande DESC";
970 $resql = $db->query(
$sql);
972 $num = $db->num_rows($resql);
976 $tmpuser =
new User($db);
979 $obj = $db->fetch_object($resql);
981 $tmpuser->id = $obj->user_id;
982 $tmpuser->login = $obj->login;
983 $tmpuser->ref = $obj->login;
984 $tmpuser->email = $obj->email;
985 $tmpuser->lastname = $obj->lastname;
986 $tmpuser->firstname = $obj->firstname;
987 $tmpuser->statut = $obj->user_status;
989 print
'<tr class="oddeven">';
992 print
'<td class="left">'.dol_print_date($db->jdate($obj->date_demande),
'day').
"</td>\n";
995 print
'<td align="center">';
996 print $tmpuser->getNomUrl(1,
'', 0, 0, 0, 0,
'login');
1000 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
1003 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_traite),
'dayhour',
'tzuserrel').
"</td>\n";
1006 print
'<td class="center">';
1007 if ($obj->fk_prelevement_bons > 0) {
1009 $withdrawreceipt->id = $obj->fk_prelevement_bons;
1010 $withdrawreceipt->ref = $obj->ref;
1011 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
1012 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
1013 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
1014 $withdrawreceipt->statut = $obj->status;
1015 $withdrawreceipt->status = $obj->status;
1016 $withdrawreceipt->fk_bank_account = $obj->fk_bank_account;
1017 $withdrawreceipt->amount = $obj->pb_amount;
1020 print $withdrawreceipt->getNomUrl(1);
1022 print $withdrawreceipt->getLibStatut(2);
1025 $fk_bank_account = $withdrawreceipt->fk_bank_account;
1026 if (empty($fk_bank_account)) {
1027 $fk_bank_account = ($object->type ==
'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
1029 if ($fk_bank_account > 0) {
1030 $bankaccount =
new Account($db);
1031 $result = $bankaccount->fetch($fk_bank_account);
1034 print $bankaccount->getNomUrl(1);
1041 print
'<td> </td>';
1044 print
'<td> </td>';
1050 if (!$numopen && !$numclosed) {
1051 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.
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.