mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #6830 from turbo124/v5-develop
Triggered actions for recurring objects
This commit is contained in:
commit
2106c9fe8e
@ -53,6 +53,9 @@ class InvoiceSum
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
|
||||
// if(!$this->invoice->relationLoaded('client'))
|
||||
// $this->invoice->load('client');
|
||||
|
||||
$this->tax_map = new Collection;
|
||||
}
|
||||
|
||||
|
@ -210,6 +210,10 @@ class RecurringInvoiceController extends BaseController
|
||||
$recurring_invoice->next_send_date = Carbon::parse($recurring_invoice->next_send_date)->startOfDay()->addSeconds($offset);
|
||||
$recurring_invoice->save();
|
||||
|
||||
$recurring_invoice->service()
|
||||
->triggeredActions($request)
|
||||
->save();
|
||||
|
||||
return $this->itemResponse($recurring_invoice);
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,9 @@ class QueryLogging
|
||||
{
|
||||
|
||||
// Enable query logging for development
|
||||
if (!Ninja::isHosted() || !config('beacon.enabled')) {
|
||||
return $next($request);
|
||||
}
|
||||
// if (!Ninja::isHosted() || !config('beacon.enabled')) {
|
||||
// return $next($request);
|
||||
// }
|
||||
|
||||
$timeStart = microtime(true);
|
||||
DB::enableQueryLog();
|
||||
@ -52,7 +52,7 @@ class QueryLogging
|
||||
$timeEnd = microtime(true);
|
||||
$time = $timeEnd - $timeStart;
|
||||
|
||||
// info("Query count = {$count}");
|
||||
info("Query count = {$count}");
|
||||
|
||||
if($count > 175){
|
||||
nlog("Query count = {$count}");
|
||||
|
@ -105,7 +105,7 @@ class StoreRecurringInvoiceRequest extends Request
|
||||
if (isset($input['auto_bill'])) {
|
||||
$input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']);
|
||||
} else {
|
||||
if ($client = Client::find($input['client_id'])) {
|
||||
if (array_key_exists('client_id', $input) && $client = Client::find($input['client_id'])) {
|
||||
$input['auto_bill'] = $client->getSetting('auto_bill');
|
||||
$input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']);
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ class CreateEntityPdf implements ShouldQueue
|
||||
$this->contact = $invitation->contact;
|
||||
|
||||
$this->client = $invitation->contact->client;
|
||||
$this->client->load('company');
|
||||
|
||||
$this->disk = Ninja::isHosted() ? config('filesystems.default') : $disk;
|
||||
|
||||
@ -107,7 +108,7 @@ class CreateEntityPdf implements ShouldQueue
|
||||
/* Init a new copy of the translator*/
|
||||
$t = app('translator');
|
||||
/* Set the locale*/
|
||||
App::setLocale($this->contact->preferredLocale());
|
||||
App::setLocale($this->client->locale());
|
||||
|
||||
/* Set customized translations _NOW_ */
|
||||
$t->replace(Ninja::transformTranslations($this->client->getMergedSettings()));
|
||||
|
@ -49,6 +49,7 @@ class EntityCreatedObject
|
||||
/* Set customized translations _NOW_ */
|
||||
$t->replace(Ninja::transformTranslations($this->entity->company->settings));
|
||||
|
||||
$this->entity->load('client.country', 'client.company');
|
||||
$this->client = $this->entity->client;
|
||||
$this->company = $this->entity->company;
|
||||
|
||||
|
@ -87,7 +87,7 @@ class TemplateEmail extends Mailable
|
||||
$this->from(config('mail.from.address'), $email_from_name);
|
||||
|
||||
if (strlen($settings->bcc_email) > 1)
|
||||
$this->bcc(explode(",",$settings->bcc_email));
|
||||
$this->bcc(explode(",",str_replace(" ", "", $settings->bcc_email)));//remove whitespace if any has been inserted.
|
||||
|
||||
$this->subject($this->build_email->getSubject())
|
||||
->text('email.template.plain', [
|
||||
|
@ -81,7 +81,8 @@ class ActivityRepository extends BaseRepository
|
||||
|| get_class($entity) == Credit::class
|
||||
|| get_class($entity) == RecurringInvoice::class
|
||||
) {
|
||||
$entity->load('company', 'client');
|
||||
|
||||
$entity->load('client');
|
||||
$contact = $entity->client->primary_contact()->first();
|
||||
$backup->html_backup = $this->generateHtml($entity);
|
||||
$backup->amount = $entity->amount;
|
||||
@ -95,7 +96,7 @@ class ActivityRepository extends BaseRepository
|
||||
public function getTokenId(array $event_vars)
|
||||
{
|
||||
if ($event_vars['token']) {
|
||||
$company_token = CompanyToken::whereRaw('BINARY `token`= ?', [$event_vars['token']])->first();
|
||||
$company_token = CompanyToken::where('token', $event_vars['token'])->first();
|
||||
|
||||
if ($company_token) {
|
||||
return $company_token->id;
|
||||
@ -117,7 +118,7 @@ class ActivityRepository extends BaseRepository
|
||||
$entity_design_id = 'credit_design_id';
|
||||
}
|
||||
|
||||
$entity->load('client','client.company');
|
||||
// $entity->load('client.company');
|
||||
|
||||
$entity_design_id = $entity->design_id ? $entity->design_id : $this->decodePrimaryKey($entity->client->getSetting($entity_design_id));
|
||||
|
||||
@ -128,6 +129,8 @@ class ActivityRepository extends BaseRepository
|
||||
return;
|
||||
}
|
||||
|
||||
$entity->load('client.company', 'invitations');
|
||||
|
||||
$html = new HtmlEngine($entity->invitations->first());
|
||||
|
||||
if ($design->is_custom) {
|
||||
|
@ -64,7 +64,6 @@ class TriggeredActions extends AbstractService
|
||||
{
|
||||
|
||||
$reminder_template = $this->invoice->calculateTemplate('invoice');
|
||||
//$reminder_template = 'payment';
|
||||
|
||||
$this->invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) use ($reminder_template) {
|
||||
EmailEntity::dispatch($invitation, $this->invoice->company, $reminder_template);
|
||||
|
@ -97,6 +97,20 @@ class RecurringService
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function triggeredActions($request)
|
||||
{
|
||||
|
||||
if ($request->has('start') && $request->input('start') == 'true') {
|
||||
$this->start();
|
||||
}
|
||||
|
||||
if ($request->has('stop') && $request->input('stop') == 'true') {
|
||||
$this->stop();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fillDefaults()
|
||||
{
|
||||
|
||||
|
@ -49,7 +49,6 @@ class HtmlEngine
|
||||
public function __construct($invitation)
|
||||
{
|
||||
$this->invitation = $invitation;
|
||||
// $invitation->load('contact.client.company', 'company');
|
||||
|
||||
$this->entity_string = $this->resolveEntityString();
|
||||
|
||||
@ -59,8 +58,8 @@ class HtmlEngine
|
||||
|
||||
$this->contact = $invitation->contact;
|
||||
|
||||
$this->client = $invitation->contact->client;
|
||||
$this->client->load('country','company');
|
||||
$this->client = $this->contact->client->load('company','country');
|
||||
|
||||
$this->entity->load('client');
|
||||
|
||||
$this->settings = $this->client->getMergedSettings();
|
||||
|
@ -2479,6 +2479,8 @@ $LANG = array(
|
||||
'currency_cambodian_riel' => 'Cambodian Riel',
|
||||
'currency_vanuatu_vatu' => 'Vanuatu Vatu',
|
||||
|
||||
'currency_cuban_peso' => 'Cuban Peso',
|
||||
|
||||
'review_app_help' => 'We hope you\'re enjoying using the app.<br/>If you\'d consider :link we\'d greatly appreciate it!',
|
||||
'writing_a_review' => 'writing a review',
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user