mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 07:38:16 -04:00 
			
		
		
		
	
						commit
						d2d62adf55
					
				| @ -398,7 +398,6 @@ class CompanySettings extends BaseSettings | |||||||
|         'email_template_reminder2'           => 'string', |         'email_template_reminder2'           => 'string', | ||||||
|         'email_template_reminder3'           => 'string', |         'email_template_reminder3'           => 'string', | ||||||
|         'email_template_reminder_endless'    => 'string', |         'email_template_reminder_endless'    => 'string', | ||||||
|         'enable_client_portal_password'      => 'bool', |  | ||||||
|         'inclusive_taxes'                    => 'bool', |         'inclusive_taxes'                    => 'bool', | ||||||
|         'invoice_number_pattern'             => 'string', |         'invoice_number_pattern'             => 'string', | ||||||
|         'invoice_number_counter'             => 'integer', |         'invoice_number_counter'             => 'integer', | ||||||
|  | |||||||
| @ -46,8 +46,6 @@ class GmailTransport extends Transport | |||||||
|         $this->gmail = null; |         $this->gmail = null; | ||||||
|         $this->gmail = new Mail; |         $this->gmail = new Mail; | ||||||
| 
 | 
 | ||||||
|         nlog(array_keys($message->getBcc())); |  | ||||||
| 
 |  | ||||||
|         /*We should nest the token in the message and then discard it as needed*/ |         /*We should nest the token in the message and then discard it as needed*/ | ||||||
|         $token = $message->getHeaders()->get('GmailToken')->getValue(); |         $token = $message->getHeaders()->get('GmailToken')->getValue(); | ||||||
|          |          | ||||||
| @ -67,8 +65,6 @@ class GmailTransport extends Transport | |||||||
|         foreach ($message->getChildren() as $child)  |         foreach ($message->getChildren() as $child)  | ||||||
|         { |         { | ||||||
| 
 | 
 | ||||||
|             nlog("trying to attach"); |  | ||||||
| 
 |  | ||||||
|             if($child->getContentType() != 'text/plain') |             if($child->getContentType() != 'text/plain') | ||||||
|             { |             { | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -11,11 +11,16 @@ | |||||||
| 
 | 
 | ||||||
| namespace App\Http\Controllers; | namespace App\Http\Controllers; | ||||||
| 
 | 
 | ||||||
| use PragmaRX\Google2FA\Google2FA; | use App\Models\User; | ||||||
| use Crypt; | use Crypt; | ||||||
|  | use PragmaRX\Google2FA\Google2FA; | ||||||
| 
 | 
 | ||||||
| class TwoFactorController extends BaseController | class TwoFactorController extends BaseController | ||||||
| { | { | ||||||
|  |     protected $entity_type = User::class; | ||||||
|  | 
 | ||||||
|  |     protected $entity_transformer = UserTransformer::class; | ||||||
|  |      | ||||||
|     public function setupTwoFactor() |     public function setupTwoFactor() | ||||||
|     { |     { | ||||||
|         $user = auth()->user(); |         $user = auth()->user(); | ||||||
|  | |||||||
| @ -377,23 +377,28 @@ class InvoiceService | |||||||
|     { |     { | ||||||
|         switch ($reminder_template) { |         switch ($reminder_template) { | ||||||
|             case 'reminder1': |             case 'reminder1': | ||||||
|                 $this->invoice->reminder1_sent = now()->format('Y-m-d'); |                 $this->invoice->reminder1_sent = now(); | ||||||
|                 $this->invoice->reminder_last_sent = now()->format('Y-m-d'); |                 $this->invoice->reminder_last_sent = now(); | ||||||
|  |                 $this->invoice->last_sent_date = now(); | ||||||
|                 break; |                 break; | ||||||
|             case 'reminder2': |             case 'reminder2': | ||||||
|                 $this->invoice->reminder2_sent = now()->format('Y-m-d'); |                 $this->invoice->reminder2_sent = now(); | ||||||
|                 $this->invoice->reminder_last_sent = now()->format('Y-m-d'); |                 $this->invoice->reminder_last_sent = now(); | ||||||
|  |                 $this->invoice->last_sent_date = now(); | ||||||
|                 break; |                 break; | ||||||
|             case 'reminder3': |             case 'reminder3': | ||||||
|                 $this->invoice->reminder3_sent = now()->format('Y-m-d'); |                 $this->invoice->reminder3_sent = now(); | ||||||
|                 $this->invoice->reminder_last_sent = now()->format('Y-m-d'); |                 $this->invoice->reminder_last_sent = now(); | ||||||
|  |                 $this->invoice->last_sent_date = now(); | ||||||
|                 break; |                 break; | ||||||
|             case 'endless_reminder': |             case 'endless_reminder': | ||||||
|                 $this->invoice->reminder_last_sent = now()->format('Y-m-d'); |                 $this->invoice->reminder_last_sent = now(); | ||||||
|  |                 $this->invoice->last_sent_date = now(); | ||||||
|                 break; |                 break; | ||||||
|             default: |             default: | ||||||
|                 $this->invoice->reminder1_sent = now()->format('Y-m-d'); |                 $this->invoice->reminder1_sent = now(); | ||||||
|                 $this->invoice->reminder_last_sent = now()->format('Y-m-d'); |                 $this->invoice->reminder_last_sent = now(); | ||||||
|  |                 $this->invoice->last_sent_date = now(); | ||||||
|                 break; |                 break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -12,6 +12,7 @@ | |||||||
| namespace App\Services\Invoice; | namespace App\Services\Invoice; | ||||||
| 
 | 
 | ||||||
| use App\Models\Invoice; | use App\Models\Invoice; | ||||||
|  | use App\Models\RecurringInvoice; | ||||||
| use App\Services\AbstractService; | use App\Services\AbstractService; | ||||||
| use Carbon\Carbon; | use Carbon\Carbon; | ||||||
| 
 | 
 | ||||||
| @ -126,6 +127,14 @@ class UpdateReminder extends AbstractService | |||||||
|                 $date_collection->push($reminder_date);  |                 $date_collection->push($reminder_date);  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         if ($this->invoice->last_sent_date && | ||||||
|  |             (int)$this->settings->endless_reminder_frequency_id > 0) { | ||||||
|  |             $reminder_date = $this->addTimeInterval($this->invoice->last_sent_date, (int)$this->settings->num_days_reminder3)->addSeconds($offset); | ||||||
|  | 
 | ||||||
|  |             if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date))); | ||||||
|  |                 $date_collection->push($reminder_date);  | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         if($date_collection->count() >=1 && $date_collection->sort()->first()->gte(now())) |         if($date_collection->count() >=1 && $date_collection->sort()->first()->gte(now())) | ||||||
|             $this->invoice->next_send_date = $date_collection->sort()->first(); |             $this->invoice->next_send_date = $date_collection->sort()->first(); | ||||||
|         else |         else | ||||||
| @ -133,4 +142,41 @@ class UpdateReminder extends AbstractService | |||||||
|          |          | ||||||
|         return $this->invoice; |         return $this->invoice; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     private function addTimeInterval($date, $endless_reminder_frequency_id) :?Carbon | ||||||
|  |     {    | ||||||
|  | 
 | ||||||
|  |         if (!$date)  | ||||||
|  |             return null; | ||||||
|  |          | ||||||
|  |         switch ($endless_reminder_frequency_id) { | ||||||
|  |             case RecurringInvoice::FREQUENCY_DAILY: | ||||||
|  |                 return Carbon::parse($date)->addDay()->startOfDay();  | ||||||
|  |            case RecurringInvoice::FREQUENCY_WEEKLY: | ||||||
|  |                 return Carbon::parse($date)->addWeek()->startOfDay(); | ||||||
|  |             case RecurringInvoice::FREQUENCY_TWO_WEEKS: | ||||||
|  |                 return Carbon::parse($date)->addWeeks(2)->startOfDay(); | ||||||
|  |             case RecurringInvoice::FREQUENCY_FOUR_WEEKS: | ||||||
|  |                 return Carbon::parse($date)->addWeeks(4)->startOfDay(); | ||||||
|  |             case RecurringInvoice::FREQUENCY_MONTHLY: | ||||||
|  |                 return Carbon::parse($date)->addMonthNoOverflow()->startOfDay(); | ||||||
|  |             case RecurringInvoice::FREQUENCY_TWO_MONTHS: | ||||||
|  |                 return Carbon::parse($date)->addMonthsNoOverflow(2)->startOfDay(); | ||||||
|  |             case RecurringInvoice::FREQUENCY_THREE_MONTHS: | ||||||
|  |                 return Carbon::parse($date)->addMonthsNoOverflow(3)->startOfDay(); | ||||||
|  |             case RecurringInvoice::FREQUENCY_FOUR_MONTHS: | ||||||
|  |                 return Carbon::parse($date)->addMonthsNoOverflow(4)->startOfDay(); | ||||||
|  |             case RecurringInvoice::FREQUENCY_SIX_MONTHS: | ||||||
|  |                 return Carbon::parse($date)->addMonthsNoOverflow(6)->startOfDay(); | ||||||
|  |             case RecurringInvoice::FREQUENCY_ANNUALLY: | ||||||
|  |                 return Carbon::parse($date)->addYear()->startOfDay(); | ||||||
|  |             case RecurringInvoice::FREQUENCY_TWO_YEARS: | ||||||
|  |                 return Carbon::parse($date)->addYears(2)->startOfDay(); | ||||||
|  |             case RecurringInvoice::FREQUENCY_THREE_YEARS: | ||||||
|  |                 return Carbon::parse($date)->addYears(3)->startOfDay(); | ||||||
|  |             default: | ||||||
|  |                 return null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user