31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
40 require_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');
49 $type =
GETPOST(
'type',
'aZ09');
51 $fieldid = (!empty($ref) ?
'ref' :
'rowid');
53 $socid = $user->socid;
57 if ($type ==
'bank-transfer') {
59 $moreparam =
'&type='.$type;
65 if ($id > 0 || !empty($ref)) {
66 $ret = $object->fetch($id, $ref);
69 $object->fetch_thirdparty();
73 $hookmanager->initHooks(array(
'directdebitcard',
'globalcard'));
75 if ($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->rights->facture->lire) {
87 if ($type ==
'bank-transfer') {
88 $usercancreate = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
90 $usercancreate = $user->rights->facture->creer;
98 $parameters = array(
'socid' => $socid);
99 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
104 if (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 ==
'sepastripepayment' && $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 ==
'setconditions' && $usercancreate) {
159 $object->cond_reglement_code = 0;
160 $object->cond_reglement_id = 0;
167 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id',
'int'));
175 $old_date_echeance = $object->date_echeance;
176 $new_date_echeance = $object->calculate_date_lim_reglement();
177 if ($new_date_echeance > $old_date_echeance) {
178 $object->date_echeance = $new_date_echeance;
180 if ($object->date_echeance < $object->date) {
181 $object->date_echeance = $object->date;
183 $result = $object->update($user);
195 } elseif ($action ==
'setmode' && $usercancreate) {
197 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
198 } elseif ($action ==
'setdatef' && $usercancreate) {
200 if ($newdate > (
dol_now(
'tzuserrel') + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
201 if (empty($conf->global->INVOICE_MAX_FUTURE_DELAY)) {
202 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
204 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
208 $object->date = $newdate;
209 $date_echence_calc = $object->calculate_date_lim_reglement();
210 if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) {
211 $object->date_echeance = $date_echence_calc;
213 if ($object->date_echeance && $object->date_echeance < $object->date) {
214 $object->date_echeance = $object->date;
217 $result = $object->update($user);
221 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
222 $object->date_echeance =
dol_mktime(12, 0, 0,
GETPOST(
'date_lim_reglementmonth',
'int'),
GETPOST(
'date_lim_reglementday',
'int'),
GETPOST(
'date_lim_reglementyear',
'int'));
223 if (!empty($object->date_echeance) && $object->date_echeance < $object->date) {
224 $object->date_echeance = $object->date;
225 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
227 $result = $object->update($user);
243 if ($type ==
'bank-transfer') {
244 $title = $langs->trans(
'SupplierInvoice').
" - ".$langs->trans(
'CreditTransfer');
247 $title = $langs->trans(
'InvoiceCustomer').
" - ".$langs->trans(
'StandingOrders');
248 $helpurl =
"EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
254 if ($object->id > 0) {
255 $selleruserevenustamp = $mysoc->useRevenueStamp();
257 $totalpaid = $object->getSommePaiement();
258 $totalcreditnotes = $object->getSumCreditNotesUsed();
259 $totaldeposits = $object->getSumDepositsUsed();
266 $resteapayer =
price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
271 $resteapayeraffiche = $resteapayer;
273 if ($type ==
'bank-transfer') {
274 if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
275 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
276 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
278 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
279 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
282 $absolute_discount = $object->thirdparty->getAvailableDiscounts(
'', $filterabsolutediscount, 0, 1);
283 $absolute_creditnote = $object->thirdparty->getAvailableDiscounts(
'', $filtercreditnote, 0, 1);
284 $absolute_discount =
price2num($absolute_discount,
'MT');
285 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
287 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
288 $filterabsolutediscount =
"fk_facture_source IS NULL";
289 $filtercreditnote =
"fk_facture_source IS NOT NULL";
291 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
292 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
295 $absolute_discount = $object->thirdparty->getAvailableDiscounts(
'', $filterabsolutediscount);
296 $absolute_creditnote = $object->thirdparty->getAvailableDiscounts(
'', $filtercreditnote);
297 $absolute_discount =
price2num($absolute_discount,
'MT');
298 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
301 $author =
new User($db);
302 if ($object->fk_user_author) {
303 $author->fetch($object->fk_user_author);
306 if ($type ==
'bank-transfer') {
318 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
319 $sql .=
" , pfd.date_traite as date_traite";
320 $sql .=
" , pfd.amount";
321 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
322 if ($type ==
'bank-transfer') {
323 $sql .=
" WHERE fk_facture_fourn = ".((int) $object->id);
325 $sql .=
" WHERE fk_facture = ".((int) $object->id);
327 $sql .=
" AND pfd.traite = 0";
328 $sql .=
" AND pfd.ext_payment_id IS NULL";
329 $sql .=
" ORDER BY pfd.date_demande DESC";
331 $resql = $db->query($sql);
333 $num = $db->num_rows(
$resql);
340 print
dol_get_fiche_head($head,
'standingorders', $title, -1, ($type ==
'bank-transfer' ?
'supplier_invoice' :
'bill'));
343 if ($type ==
'bank-transfer') {
344 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
346 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
349 $morehtmlref =
'<div class="refidno">';
351 if ($type ==
'bank-transfer') {
352 $morehtmlref .=
$form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', 0, 1);
353 $morehtmlref .=
$form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'',
null,
null,
'', 1);
355 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'', 0, 1);
356 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'',
null,
null,
'', 1);
359 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
360 if ($type ==
'bank-transfer') {
361 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
362 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->thirdparty->id.
'&search_company='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
365 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
366 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?socid='.$object->thirdparty->id.
'&search_company='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
371 $langs->load(
"projects");
372 $morehtmlref .=
'<br>';
374 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
375 if ($action !=
'classify') {
376 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
378 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, ($action ==
'classify' ? 1 : 0), 0, 1,
'');
380 if (!empty($object->fk_project)) {
382 $proj->fetch($object->fk_project);
383 $morehtmlref .= $proj->getNomUrl(1);
385 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
390 $morehtmlref .=
'</div>';
392 $object->totalpaid = $totalpaid;
394 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $moreparam, 0,
'',
'');
396 print
'<div class="fichecenter">';
397 print
'<div class="fichehalfleft">';
398 print
'<div class="underbanner clearboth"></div>';
400 print
'<table class="border centpercent tableforfield">';
403 print
'<tr><td class="titlefield fieldname_type">'.$langs->trans(
'Type').
'</td><td colspan="3">';
404 print
'<span class="badgeneutral">';
405 print $object->getLibType();
407 if ($object->module_source) {
408 print
' <span class="opacitymediumbycolor paddingleft">('.$langs->trans(
"POS").
' '.$object->module_source.
' - '.$langs->trans(
"Terminal").
' '.$object->pos_source.
')</span>';
410 if ($object->type == $object::TYPE_REPLACEMENT) {
411 if ($type ==
'bank-transfer') {
414 $facreplaced =
new Facture($db);
416 $facreplaced->fetch($object->fk_facture_source);
417 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
419 if ($object->type == $object::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) {
420 if ($type ==
'bank-transfer') {
425 $facusing->fetch($object->fk_facture_source);
426 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
429 $facidavoir = $object->getListIdAvoirFromInvoice();
430 if (count($facidavoir) > 0) {
431 $invoicecredits = array();
432 foreach ($facidavoir as $facid) {
433 if ($type ==
'bank-transfer') {
438 $facavoir->fetch($facid);
439 $invoicecredits[] = $facavoir->getNomUrl(1);
441 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir");
442 print
' '. (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
455 print
'<!-- Discounts -->'.
"\n";
456 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining').
'</td><td colspan="3">';
458 if ($type ==
'bank-transfer') {
461 $thirdparty = $object->thirdparty;
464 $thirdparty = $object->thirdparty;
467 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?facid='.$object->id);
468 $cannotApplyDiscount = 1;
469 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
474 if ($type ==
'bank-transfer') {
476 print
'<td>'.$form->editfieldkey(
"Label",
'label', $object->label, $object, 0).
'</td>';
477 print
'<td>'.$form->editfieldval(
"Label",
'label', $object->label, $object, 0).
'</td>';
483 print
'<table class="nobordernopadding centpercent"><tr><td>';
484 print $langs->trans(
'DateInvoice');
486 if ($object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editinvoicedate' && !empty($object->brouillon) && $user->rights->facture->creer) {
487 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>';
489 print
'</tr></table>';
490 print
'</td><td colspan="3">';
492 if ($object->type != $object::TYPE_CREDIT_NOTE) {
493 if ($action ==
'editinvoicedate') {
494 print
$form->form_date($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->date,
'invoicedate', 0, 0, 1, $type);
506 print
'<table class="nobordernopadding centpercent"><tr><td>';
507 print $langs->trans(
'PaymentConditionsShort');
509 if ($object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editconditions' && !empty($object->brouillon) && $user->rights->facture->creer) {
510 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>';
512 print
'</tr></table>';
513 print
'</td><td colspan="3">';
514 if ($object->type != $object::TYPE_CREDIT_NOTE) {
515 if ($action ==
'editconditions') {
516 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id', 0, $type);
518 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none');
527 print
'<table class="nobordernopadding centpercent"><tr><td>';
528 print $langs->trans(
'DateMaxPayment');
530 if ($object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editpaymentterm' && !empty($object->brouillon) && $user->rights->facture->creer) {
531 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>';
533 print
'</tr></table>';
534 print
'</td><td colspan="3">';
535 if ($object->type != $object::TYPE_CREDIT_NOTE) {
536 $duedate = $object->date_lim_reglement;
537 if ($type ==
'bank-transfer') {
538 $duedate = $object->date_echeance;
541 if ($action ==
'editpaymentterm') {
542 print
$form->form_date($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $duedate,
'paymentterm', 0, 0, 1, $type);
545 if ($object->hasDelay()) {
556 print
'<table class="nobordernopadding centpercent"><tr><td>';
557 print $langs->trans(
'PaymentMode');
559 if ($action !=
'editmode' && !empty($object->brouillon) && $user->rights->facture->creer) {
560 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>';
562 print
'</tr></table>';
563 print
'</td><td colspan="3">';
564 $filtertype =
'CRDT';
565 if ($type ==
'bank-transfer') {
566 $filtertype =
'DBIT';
568 if ($action ==
'editmode') {
569 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id', $filtertype, 1, 0, $type);
571 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
576 print
'<tr><td class="nowrap">';
577 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
578 print $langs->trans(
'BankAccount');
580 if (($action !=
'editbankaccount') && $user->rights->commande->creer && !empty($object->brouillon)) {
581 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>';
583 print
'</tr></table>';
584 print
'</td><td colspan="3">';
585 if ($action ==
'editbankaccount') {
586 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
588 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
594 $title =
'CustomerIBAN';
595 if ($type ==
'bank-transfer') {
596 $title =
'SupplierIBAN';
598 print
'<tr><td>'.$langs->trans($title).
'</td><td colspan="3">';
601 $bac->fetch(0, $object->thirdparty->id);
603 print $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
604 if (!empty($bac->iban)) {
605 if ($bac->verif() <= 0) {
606 print
img_warning(
'Error on default bank number for IBAN : '.$bac->error_message);
609 if ($numopen || ($type !=
'bank-transfer' && $object->mode_reglement_code ==
'PRE') || ($type ==
'bank-transfer' && $object->mode_reglement_code ==
'VIR')) {
610 print
img_warning($langs->trans(
"NoDefaultIBANFound"));
619 print
'<div class="fichehalfright">';
620 print
'<div class="underbanner clearboth"></div>';
622 print
'<table class="border centpercent tableforfield">';
624 if (
isModEnabled(
'multicurrency') && ($object->multicurrency_code != $conf->currency)) {
626 print
'<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
'MulticurrencyAmountHT',
'multicurrency_total_ht',
'', $object, 0).
'</td>';
627 print
'<td class="nowrap">'.price($object->multicurrency_total_ht,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
631 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountVAT',
'multicurrency_total_tva',
'', $object, 0).
'</td>';
632 print
'<td class="nowrap">'.price($object->multicurrency_total_tva,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
636 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountTTC',
'multicurrency_total_ttc',
'', $object, 0).
'</td>';
637 print
'<td class="nowrap">'.price($object->multicurrency_total_ttc,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
642 print
'<tr><td class="titlefield">'.$langs->trans(
'AmountHT').
'</td>';
643 print
'<td class="nowrap">'.price($object->total_ht, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
646 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="3" class="nowrap">'.
price($object->total_tva, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
650 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) {
651 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
652 print
'<td class="nowrap">'.price($object->total_localtax1, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
654 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) {
655 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
656 print
'<td class=nowrap">'.price($object->total_localtax2, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
660 if ($selleruserevenustamp) {
662 print
'<table class="nobordernopadding" width="100%"><tr><td>';
663 print $langs->trans(
'RevenueStamp');
665 if ($action !=
'editrevenuestamp' && !empty($object->brouillon) && $user->rights->facture->creer) {
666 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>';
668 print
'</tr></table>';
670 print
price($object->revenuestamp, 1,
'', 1, - 1, - 1, $conf->currency);
675 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td class="nowrap">'.
price($object->total_ttc, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
677 $resteapayer =
price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
680 print
'<tr><td>'.$langs->trans(
'RemainderToPay').
'</td><td class="nowrap">'.
price($resteapayer, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
687 print
'<div class="clearboth"></div>';
695 $sql =
"SELECT SUM(pfd.amount) as amount";
696 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
697 if ($type ==
'bank-transfer') {
698 $sql .=
" WHERE fk_facture_fourn = ".((int) $object->id);
700 $sql .=
" WHERE fk_facture = ".((int) $object->id);
702 $sql .=
" AND pfd.traite = 0";
703 $sql .=
" AND pfd.ext_payment_id IS NULL";
705 $resql = $db->query($sql);
707 $obj = $db->fetch_object(
$resql);
709 $pending = $obj->amount;
720 print
"\n".
'<div class="tabsAction">'.
"\n";
722 $buttonlabel = $langs->trans(
"MakeWithdrawRequest");
723 $user_perms = $user->rights->prelevement->bons->creer;
724 if ($type ==
'bank-transfer') {
725 $buttonlabel = $langs->trans(
"MakeBankTransferOrder");
726 $user_perms = $user->rights->paymentbybanktransfer->create;
730 if ($object->statut > $object::STATUS_DRAFT && $object->paye == 0 && $num == 0) {
731 if ($resteapayer > 0) {
733 $remaintopaylesspendingdebit = $resteapayer - $pending;
735 print
'<form method="POST" action="">';
736 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
737 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
738 print
'<input type="hidden" name="type" value="'.$type.
'" />';
739 print
'<input type="hidden" name="action" value="new" />';
740 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
741 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
742 print
'<input type="submit" class="butAction" value="'.$buttonlabel.
'" />';
745 if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT_SHOW_BUTTON)) {
749 $buttonlabel = $langs->trans(
"MakeWithdrawRequestStripe");
750 print
'<form method="POST" action="">';
751 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
752 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
753 print
'<input type="hidden" name="type" value="'.$type.
'" />';
754 print
'<input type="hidden" name="action" value="new" />';
755 print
'<input type="hidden" name="paymenservice" value="stripesepa" />';
756 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
757 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
758 print
'<input type="submit" class="butAction" value="'.$buttonlabel.
'" />';
762 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$buttonlabel.
'</a>';
765 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AmountMustBePositive")).
'">'.$buttonlabel.
'</a>';
769 if ($object->statut > $object::STATUS_DRAFT) {
770 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AlreadyPaid")).
'">'.$buttonlabel.
'</a>';
772 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"Draft")).
'">'.$buttonlabel.
'</a>';
775 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"RequestAlreadyDone")).
'">'.$buttonlabel.
'</a>';
782 if ($type ==
'bank-transfer') {
783 print
'<div class="opacitymedium">'.$langs->trans(
"DoCreditTransferBeforePayments");
785 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
787 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
790 print
'<div class="opacitymedium">'.$langs->trans(
"DoStandingOrdersBeforePayments");
792 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
794 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
802 print
'<div class="div-table-responsive-no-min">';
803 print
'<table class="noborder centpercent">';
805 print
'<tr class="liste_titre">';
806 print
'<td class="left">'.$langs->trans(
"DateRequest").
'</td>';
807 print
'<td class="center">'.$langs->trans(
"User").
'</td>';
808 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
809 print
'<td class="center">'.$langs->trans(
"DateProcess").
'</td>';
810 print
'<td> </td>';
811 if ($type ==
'bank-transfer') {
812 print
'<td class="center">'.$langs->trans(
"BankTransferReceipt").
'</td>';
814 print
'<td class="center">'.$langs->trans(
"WithdrawalReceipt").
'</td>';
816 print
'<td> </td>';
819 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
820 $sql .=
" pfd.date_traite as date_traite, pfd.amount,";
821 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
822 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
823 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on pfd.fk_user_demande = u.rowid";
824 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
825 if ($type ==
'bank-transfer') {
826 $sql .=
" WHERE fk_facture_fourn = ".((int) $object->id);
828 $sql .=
" WHERE fk_facture = ".((int) $object->id);
830 $sql .=
" AND pfd.traite = 0";
831 $sql .=
" AND pfd.ext_payment_id IS NULL";
832 $sql .=
" ORDER BY pfd.date_demande DESC";
834 $resql = $db->query($sql);
840 $tmpuser =
new User($db);
842 $num = $db->num_rows($result);
844 $obj = $db->fetch_object(
$resql);
846 $tmpuser->id = $obj->user_id;
847 $tmpuser->login = $obj->login;
848 $tmpuser->ref = $obj->login;
849 $tmpuser->email = $obj->email;
850 $tmpuser->lastname = $obj->lastname;
851 $tmpuser->firstname = $obj->firstname;
852 $tmpuser->statut = $obj->user_status;
854 print
'<tr class="oddeven">';
857 print
'<td class="left">'.dol_print_date($db->jdate($obj->date_demande),
'dayhour').
"</td>\n";
860 print
'<td align="center">';
861 print $tmpuser->getNomUrl(1,
'', 0, 0, 0, 0,
'login');
865 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
868 print
'<td class="center"><span class="opacitymedium">'.$langs->trans(
"OrderWaiting").
'</span></td>';
871 if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) {
872 $langs->load(
"stripe");
873 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=sepastripepayment&paymentservice=stripesepa&token='.
newToken().
'&did='.$obj->rowid.
'&id='.$object->id.
'&type='.urlencode($type).
'">'.
img_picto(
'',
'stripe',
'class="pictofixedwidth"').$langs->trans(
"RequestDirectDebitWithStripe").
'</a>';
877 print
'<td align="center">-</td>';
879 print
'<td class="right">';
880 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.$type.
'">';
896 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,";
898 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
899 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
900 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on pfd.fk_user_demande = u.rowid";
901 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
902 if ($type ==
'bank-transfer') {
903 $sql .=
" WHERE fk_facture_fourn = ".((int) $object->id);
905 $sql .=
" WHERE fk_facture = ".((int) $object->id);
907 $sql .=
" AND pfd.traite = 1";
908 $sql .=
" AND pfd.ext_payment_id IS NULL";
909 $sql .=
" ORDER BY pfd.date_demande DESC";
911 $result = $db->query($sql);
913 $num = $db->num_rows($result);
917 $tmpuser =
new User($db);
920 $obj = $db->fetch_object($result);
922 $tmpuser->id = $obj->user_id;
923 $tmpuser->login = $obj->login;
924 $tmpuser->ref = $obj->login;
925 $tmpuser->email = $obj->email;
926 $tmpuser->lastname = $obj->lastname;
927 $tmpuser->firstname = $obj->firstname;
928 $tmpuser->statut = $obj->user_status;
930 print
'<tr class="oddeven">';
932 print
'<td class="left">'.dol_print_date($db->jdate($obj->date_demande),
'day').
"</td>\n";
934 print
'<td align="center">';
935 print $tmpuser->getNomUrl(1,
'', 0, 0, 0, 0,
'login');
938 print
'<td class="center">'.price($obj->amount).
'</td>';
940 print
'<td class="center">';
941 if ($obj->fk_prelevement_bons > 0) {
943 $withdrawreceipt->id = $obj->fk_prelevement_bons;
944 $withdrawreceipt->ref = $obj->ref;
945 print $withdrawreceipt->getNomUrl(1);
949 print
'<td> </td>';
951 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_traite),
'day').
"</td>\n";
953 print
'<td> </td>';
959 if (!$numopen && !$numclosed) {
960 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 withdrawal receipts.
Class to manage bank accounts description of third parties.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage projects.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->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') &&!empty($user->rights->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)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
facturefourn_prepare_head($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...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
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.