Fix set default

This commit is contained in:
ptibogxiv 2018-03-08 02:08:14 +01:00 committed by GitHub
parent a0b587acc0
commit 197ce2fc3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -272,13 +272,13 @@ if (empty($reshook))
} }
} }
if ($action == 'setasdefault') if ($action == 'setasbankdefault')
{ {
$account = new CompanyBankAccount($db); $account = new CompanyBankAccount($db);
$res = $account->setAsDefault(GETPOST('ribid','int')); $res = $account->setAsDefault(GETPOST('ribid','int'));
if ($res) if ($res)
{ {
$url=DOL_URL_ROOT.'/societe/gateway.php?socid='.$object->id; $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
header('Location: '.$url); header('Location: '.$url);
exit; exit;
} }
@ -337,19 +337,20 @@ if (class_exists('Stripe'))
$stripe=new Stripe($db); $stripe=new Stripe($db);
$customerstripe=$stripe->CustomerStripe($socid,$stripe->GetStripeAccount($conf->entity)); $customerstripe=$stripe->CustomerStripe($socid,$stripe->GetStripeAccount($conf->entity));
if ($customerstripe->id) { if ($customerstripe->id) {
$cu = \Stripe\Customer::retrieve("".$customerstripe->id."",array("stripe_account" => $stripe->GetStripeAccount($conf->entity)));} $cu = \Stripe\Customer::retrieve("".$customerstripe->id."");}
$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
if ($action == 'setasdefault') if ($action == 'setassourcedefault')
{ {
$cu->default_source = "$source"; // obtained with Stripe.js $cu->default_source = "$source"; // obtained with Stripe.js
$cu->save(); $cu->save();
header('Location: '.$url); //header('Location: '.$url);
exit; //exit;
} }
elseif ($action == 'delete') elseif ($action == 'delete')
{ {
$cu->sources->retrieve("$source")->delete(); $cu->sources->retrieve("$source")->detach();
header('Location: '.$url); header('Location: '.$url);
exit; exit;
@ -367,6 +368,7 @@ $formfile = new FormFile($db);
llxHeader(); llxHeader();
$head=societe_prepare_head($object); $head=societe_prepare_head($object);
if (! $id) if (! $id)
{ {
$account->fetch(0,$object->id); $account->fetch(0,$object->id);
@ -505,7 +507,7 @@ if ($socid && $action != 'edit' && $action != "create")
print '<td align="center" width="50">'; print '<td align="center" width="50">';
if (($cu->default_source!=$src->id)) if (($cu->default_source!=$src->id))
{ {
print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=setasdefault">'; print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=setassourcedefault">';
print "<SPAN class='fa fa-circle fa-2x'></SPAN>"; print "<SPAN class='fa fa-circle fa-2x'></SPAN>";
print '</a>'; print '</a>';
} else { } else {
@ -515,7 +517,7 @@ if ($socid && $action != 'edit' && $action != "create")
print '<td align="center">'; print '<td align="center">';
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
// print '<a href="' . DOL_URL_ROOT.'/societe/gateway.php?socid='.$object->id.'&id='.$src->id.'&action=edit">'; // print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$src->id.'&action=edit">';
// print img_picto($langs->trans("Modify"),'edit'); // print img_picto($langs->trans("Modify"),'edit');
// print '</a>'; // print '</a>';
// print '&nbsp;'; // print '&nbsp;';
@ -634,7 +636,7 @@ if ($socid && $action != 'edit' && $action != "create")
// Default // Default
print '<td align="center" width="70">'; print '<td align="center" width="70">';
if (!$rib->default_rib) { if (!$rib->default_rib) {
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&ribid='.$rib->id.'&action=setasdefault">'; print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&ribid='.$rib->id.'&action=setasbankdefault">';
print img_picto($langs->trans("Disabled"),'off'); print img_picto($langs->trans("Disabled"),'off');
print '</a>'; print '</a>';
} else { } else {