Fix deletion of stripe card
Solve validation of recurring invoice
This commit is contained in:
parent
ef395fc36b
commit
ac97ba9e36
@ -973,9 +973,11 @@ class FactureRec extends CommonInvoice
|
|||||||
*
|
*
|
||||||
* WARNING: This method change temporarly context $conf->entity to be in correct context for each recurring invoice found.
|
* WARNING: This method change temporarly context $conf->entity to be in correct context for each recurring invoice found.
|
||||||
*
|
*
|
||||||
* @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK)
|
* @param int $restictoninvoiceid 0=All qualified template invoices found. > 0 = restrict action on invoice ID
|
||||||
|
* @param int $forcevalidation 1=Force validation of invoice whatever is template auto_validate flag.
|
||||||
|
* @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK)
|
||||||
*/
|
*/
|
||||||
function createRecurringInvoices()
|
function createRecurringInvoices($restictoninvoiceid=0, $forcevalidation=0)
|
||||||
{
|
{
|
||||||
global $conf, $langs, $db, $user;
|
global $conf, $langs, $db, $user;
|
||||||
|
|
||||||
@ -989,13 +991,15 @@ class FactureRec extends CommonInvoice
|
|||||||
$tmparray=dol_getdate($now);
|
$tmparray=dol_getdate($now);
|
||||||
$today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day
|
$today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day
|
||||||
|
|
||||||
dol_syslog("createRecurringInvoices");
|
dol_syslog("createRecurringInvoices restictoninvoiceid=".$restictoninvoiceid." forcevalidation=".$forcevalidation);
|
||||||
|
|
||||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_rec';
|
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_rec';
|
||||||
$sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency
|
$sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency
|
||||||
$sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')";
|
$sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')";
|
||||||
$sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)';
|
$sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)';
|
||||||
$sql.= ' AND suspended = 0';
|
$sql.= ' AND suspended = 0';
|
||||||
$sql.= ' AND entity = '.$conf->entity; // MUST STAY = $conf->entity here
|
$sql.= ' AND entity = '.$conf->entity; // MUST STAY = $conf->entity here
|
||||||
|
if ($restictoninvoiceid > 0) $sql.=' AND rowid = '.$restictoninvoiceid;
|
||||||
$sql.= $db->order('entity', 'ASC');
|
$sql.= $db->order('entity', 'ASC');
|
||||||
//print $sql;exit;
|
//print $sql;exit;
|
||||||
|
|
||||||
@ -1044,7 +1048,7 @@ class FactureRec extends CommonInvoice
|
|||||||
$this->error = $facture->error;
|
$this->error = $facture->error;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
if (! $error && $facturerec->auto_validate)
|
if (! $error && ($facturerec->auto_validate || $forcevalidation))
|
||||||
{
|
{
|
||||||
$result = $facture->validate($user);
|
$result = $facture->validate($user);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
|
|||||||
@ -614,7 +614,7 @@ if (empty($reshook))
|
|||||||
setEventMessages($e->getMessage(), null, 'errors');
|
setEventMessages($e->getMessage(), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($action == 'deletecard')
|
elseif ($action == 'deletecard' && $source)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
|
$cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
|
||||||
@ -918,7 +918,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
|
|||||||
print img_picto($langs->trans("Modify"),'edit');
|
print img_picto($langs->trans("Modify"),'edit');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
print ' ';
|
print ' ';
|
||||||
print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=deletecard">';
|
print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=deletecard">'; // source='.$companypaymentmodetemp->stripe_card_ref.'&
|
||||||
print img_picto($langs->trans("Delete"), 'delete');
|
print img_picto($langs->trans("Delete"), 'delete');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user