diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php
index 56eb95cc578..ed26ed94541 100644
--- a/htdocs/stripe/payment.php
+++ b/htdocs/stripe/payment.php
@@ -24,8 +24,8 @@
*/
/**
- * \file htdocs/compta/paiement.php
- * \ingroup facture
+ * \file htdocs/stripe/payment.php
+ * \ingroup stripe
* \brief Payment page for customers invoices
*/
@@ -72,7 +72,7 @@ if (! empty($conf->stripe->enabled))
{
$service = 'StripeLive';
$servicestatus = 0;
- }
+ }
$stripe = new Stripe($db);
$stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here)
@@ -119,7 +119,7 @@ if (empty($reshook))
$atleastonepaymentnotnull = 0;
// Generate payment array and check if there is payment higher than invoice and payment date before invoice date
- $tmpinvoice=new Facture($db);
+ $tmpinvoice=new Facture($db);
foreach ($_POST as $key => $value)
{
if (substr($key,0,7) == 'amount_')
@@ -208,7 +208,7 @@ if (empty($reshook))
// setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors');
// $error++;
// }
-
+
// Check if payments in both currency
if ($totalpayment > 0 && $multicurrency_totalpayment > 0)
{
@@ -223,10 +223,10 @@ if (empty($reshook))
if ($action == 'add_paiement')
{
if ($error)
- {
+ {
$action = 'create';
if (!$source)
- {
+ {
setEventMessages($langs->transnoentities('NoSource'), null, 'errors');
}
$error++;
@@ -254,7 +254,7 @@ if (empty($reshook))
$newvalue = price2num($value,'MT');
$amounts[$key] = -$newvalue;
}
-
+
foreach ($multicurrency_amounts as $key => $value) // How payment is dispatch
{
$newvalue = price2num($value,'MT');
@@ -273,12 +273,13 @@ if (empty($reshook))
}
$facture = new Facture($db);
$facture->fetch($facid);
-
+$facture->fetch_thirdparty();
+
$error = 0;
if (is_object($stripe) && $stripeacc)
{
- $customerstripe=$stripe->customerStripe($object->socid, $stripeacc, $servicestatus);
+ $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus);
if ($customerstripe->id) {
$listofsources=$customerstripe->sources->data;
@@ -287,7 +288,7 @@ $facture->fetch($facid);
$stripeamount=0;
foreach ($amounts as $key => $value) // How payment is dispatch
- {
+ {
$stripeamount+=price2num($value,'MT');
}
@@ -312,7 +313,7 @@ $societe->fetch($facture->socid);
dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe');
$charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$source,$customer->id,$stripe->getStripeAccount($conf->entity));
-
+
if (!$error)
{
// Creation of payment line
@@ -327,7 +328,7 @@ $charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$sourc
if (! $error)
{
-
+
$paiement_id = $paiement->create($user, 0);
if ($paiement_id < 0)
{
@@ -349,8 +350,8 @@ $charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$sourc
$facture->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
- }
-
+ }
+
}
if (! $error)
@@ -364,14 +365,14 @@ $charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$sourc
$error++;
}
elseif (GETPOST('closepaidinvoices')=='on') {
- $facture->set_paid($user);
+ $facture->set_paid($user);
}
}
if (! $error)
{
$db->commit();
-
+
// If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card
$invoiceid=0;
foreach ($paiement->amounts as $key => $amount)
@@ -394,7 +395,7 @@ $charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$sourc
$db->rollback();
header('Location: '.$loc);
}
-
+
}
}
@@ -403,21 +404,23 @@ $charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$sourc
* View
*/
+$form=new Form($db);
+
llxHeader();
- if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha'))
- {
- $service = 'StripeLive';
- $servicestatus = 0;
- }
- else {
-dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning');
- }
-
-$form=new Form($db);
-if (GETPOST('error')){
-setEventMessages(GETPOST('error'), NULL, 'errors');
+if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha'))
+{
+ $service = 'StripeLive';
+ $servicestatus = 0;
}
+else {
+ dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning');
+}
+
+if (GETPOST('error')){
+ setEventMessages(GETPOST('error'), NULL, 'errors');
+}
+
if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement')
{
$facture = new Facture($db);
@@ -484,7 +487,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
{
subJson[n["name"]] = n["value"];
});
-
+
return subJson;
}
function callForResult(imgId)
@@ -557,7 +560,13 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '
';
- // Third party
+ // Invoice
+ /*if ($facture->id > 0)
+ {
+ print '| '.$langs->trans('Invoice').' | '.$facture->getNomUrl(4)." |
\n";
+ }*/
+
+ // Third party
print '| '.$langs->trans('Company').' | '.$facture->thirdparty->getNomUrl(4)." |
\n";
// Bank account
@@ -592,27 +601,28 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
// Comments
print '| '.$langs->trans('Comments').' | ';
print '';
- print ' |
';
-
+ print '';
+
print '
';
dol_fiche_end();
-$customerstripe=$stripe->customerStripe($facture->socid, $stripeacc, $servicestatus);
- print '
';
- print_barre_liste($langs->trans('StripeSourceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', '');
+ $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus);
- print ''."\n";
- // Titles with sort buttons
- print '';
- print ' | ';
- print ''.$langs->trans('Type').' | ';
- print ''.$langs->trans('Informations').' | ';
- print ' | ';
- print " |
\n";
- foreach ($customerstripe->sources->data as $src) {
-print '';
+ print '
';
+ print_barre_liste($langs->trans('StripeSourceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', '');
+
+ print '";
-print '';
- // Default
- print 'id!=$source) { print'class="opacitymedium"';}
-print'>';
-// if (($customer->default_source!=$src->id)) {
-// print img_picto($langs->trans("Disabled"),'off');
-// } else {
-// print img_picto($langs->trans("Default"),'on');
-// }
- print ' | ';
-print '
';
-}
-if (empty($input)&&!$stripe->getStripeCustomerAccount($facture->socid))
-{
-print '| '.$langs->trans("NoSource").' |
';
-}
- print "
";
/*
* List of unpaid invoices
*/
-
+
$sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type, ';
$sql.= ' f.datef as df, f.fk_soc as socid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
-
+
if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) {
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)';
}
-
+
$sql.= ' WHERE f.entity = '.$conf->entity;
$sql.= ' AND (f.fk_soc = '.$facture->socid;
-
+
if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) {
$sql.= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')';
}
-
+
$sql.= ') AND f.paye = 0';
$sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled
if ($facture->type != 2)
@@ -838,9 +850,9 @@ print '| '.$langs->trans("NoSource").'
$deposits=$invoice->getSumDepositsUsed();
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
-
+
// Multicurrency Price
- if (!empty($conf->multicurrency->enabled))
+ if (!empty($conf->multicurrency->enabled))
{
$multicurrency_payment = $invoice->getSommePaiement(1);
$multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1);
@@ -848,7 +860,7 @@ print ' |
| '.$langs->trans("NoSource").'
$multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,'MT');
$multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,'MT');
}
-
+
print ' |
';
print '| ';
@@ -858,36 +870,36 @@ print ' |
| '.$langs->trans("NoSource").'
// Date
print ' | '.dol_print_date($db->jdate($objp->df),'day')." | \n";
-
+
// Currency
if (!empty($conf->multicurrency->enabled)) print ''.$objp->multicurrency_code." | \n";
-
+
// Multicurrency Price
- if (!empty($conf->multicurrency->enabled))
+ if (!empty($conf->multicurrency->enabled))
{
print '';
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $objp->multicurrency_total_ttc);
print ' | ';
-
+
// Multicurrency Price
print '';
- if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
+ if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
{
print price($sign * $multicurrency_payment);
if ($multicurrency_creditnotes) print '+'.price($multicurrency_creditnotes);
if ($multicurrency_deposits) print '+'.price($multicurrency_deposits);
}
print ' | ';
-
+
// Multicurrency Price
print '';
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay);
print ' | ';
}
-
+
// Price
print ''.price($sign * $objp->total_ttc).' | ';
-
+
// Received or paid back
print ''.price($sign * $paiement);
if ($creditnotes) print '+'.price($creditnotes);
@@ -920,14 +932,14 @@ print ' |
| '.$langs->trans("NoSource").'
print " | ";
// Multicurrency Price
- if (! empty($conf->multicurrency->enabled))
+ if (! empty($conf->multicurrency->enabled))
{
print '';
-
+
// Add remind multicurrency amount
$namef = 'multicurrency_amount_'.$objp->facid;
$nameRemain = 'multicurrency_remain_'.$objp->facid;
-
+
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
{
if ($action != 'add_paiement')
@@ -947,7 +959,7 @@ print ' |
| '.$langs->trans("NoSource").'
}
// Warning
- print ' | ';
+ print ' | ';
//print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]." ";
if ($amounts[$invoice->id] && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id]))
|| $multicurrency_amounts[$invoice->id] && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id])))
@@ -1024,7 +1036,7 @@ print ' |
'.$langs->trans("NoSource").'
print ' ';
if (!empty($totalpayment)) $text=$langs->trans('ConfirmCustomerPayment',$totalpayment,$langs->trans("Currency".$conf->currency));
- if (!empty($multicurrency_totalpayment))
+ if (!empty($multicurrency_totalpayment))
{
$text.=' '.$langs->trans('ConfirmCustomerPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency"));
}
|