mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 22:27:31 -05:00 
			
		
		
		
	Company Import mailer
This commit is contained in:
		
							parent
							
								
									1baadd96b4
								
							
						
					
					
						commit
						b29c9f25e3
					
				@ -19,6 +19,7 @@ use App\Jobs\Util\UnlinkFile;
 | 
				
			|||||||
use App\Libraries\MultiDB;
 | 
					use App\Libraries\MultiDB;
 | 
				
			||||||
use App\Mail\DownloadBackup;
 | 
					use App\Mail\DownloadBackup;
 | 
				
			||||||
use App\Mail\DownloadInvoices;
 | 
					use App\Mail\DownloadInvoices;
 | 
				
			||||||
 | 
					use App\Mail\Import\CompanyImportFailure;
 | 
				
			||||||
use App\Models\Activity;
 | 
					use App\Models\Activity;
 | 
				
			||||||
use App\Models\Backup;
 | 
					use App\Models\Backup;
 | 
				
			||||||
use App\Models\Client;
 | 
					use App\Models\Client;
 | 
				
			||||||
@ -165,11 +166,20 @@ class CompanyImport implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if(array_key_exists('import_data', $this->request_array) && $this->request_array['import_data'] == 'true') {
 | 
					        if(array_key_exists('import_data', $this->request_array) && $this->request_array['import_data'] == 'true') {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            try{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $this->preFlightChecks()
 | 
					                $this->preFlightChecks()
 | 
				
			||||||
                     ->purgeCompanyData()
 | 
					                     ->purgeCompanyData()
 | 
				
			||||||
                     ->importData();
 | 
					                     ->importData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
             }
 | 
					             }
 | 
				
			||||||
 | 
					             catch(\Exception $e){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                info($e->getMessage());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					             }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -263,6 +273,18 @@ class CompanyImport implements ShouldQueue
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!$this->checkUserCount())
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            $nmo = new NinjaMailerObject;
 | 
				
			||||||
 | 
					            $nmo->mailable = new CompanyImportFailure($this->company, $this->message);
 | 
				
			||||||
 | 
					            $nmo->company = $this->company;
 | 
				
			||||||
 | 
					            $nmo->settings = $this->company->settings;
 | 
				
			||||||
 | 
					            $nmo->to_user = $this->company->owner();
 | 
				
			||||||
 | 
					            NinjaMailerJob::dispatchNow($nmo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            throw new \Exception('Company import check failed');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    	return $this;
 | 
					    	return $this;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										64
									
								
								app/Mail/Import/CompanyImportFailure.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								app/Mail/Import/CompanyImportFailure.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,64 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Invoice Ninja (https://invoiceninja.com).
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @link https://github.com/invoiceninja/invoiceninja source repository
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @license https://opensource.org/licenses/AAL
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace App\Mail\Import;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Illuminate\Bus\Queueable;
 | 
				
			||||||
 | 
					use Illuminate\Mail\Mailable;
 | 
				
			||||||
 | 
					use Illuminate\Queue\SerializesModels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class CompanyImportFailure extends Mailable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // use Queueable, SerializesModels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public $company;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public $settings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public $logo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public $title;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public $message;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public $whitelabel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public $user_message;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Create a new message instance.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return void
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function __construct($company, $user_message)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->company = $company;
 | 
				
			||||||
 | 
					        $this->user_message = $user_message;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Build the message.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return $this
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function build()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->settings = $this->company->settings;
 | 
				
			||||||
 | 
					        $this->logo = $this->company->present()->logo();
 | 
				
			||||||
 | 
					        $this->title = ctrans('texts.max_companies');
 | 
				
			||||||
 | 
					        $this->message = ctrans('texts.max_companies_desc');
 | 
				
			||||||
 | 
					        $this->whitelabel = $this->company->account->isPaid();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->from(config('mail.from.address'), config('mail.from.name'))
 | 
				
			||||||
 | 
					                    ->subject(ctrans('texts.company_import_failure_subject'))
 | 
				
			||||||
 | 
					                    ->view('email.migration.max_companies');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -4254,6 +4254,8 @@ $LANG = array(
 | 
				
			|||||||
    'account_passwordless_login' => 'Account passwordless login',
 | 
					    'account_passwordless_login' => 'Account passwordless login',
 | 
				
			||||||
    'user_duplicate_error' => 'Cannot add the same user to the same company',
 | 
					    'user_duplicate_error' => 'Cannot add the same user to the same company',
 | 
				
			||||||
    'user_cross_linked_error' => 'User exists but cannot be crossed linked to multiple accounts',
 | 
					    'user_cross_linked_error' => 'User exists but cannot be crossed linked to multiple accounts',
 | 
				
			||||||
 | 
					    'company_import_failure_subject' => 'Error importing :company',
 | 
				
			||||||
 | 
					    'company_import_failure_body' => 'There was an error importing the company data, the error message was:',
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return $LANG;
 | 
					return $LANG;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										22
									
								
								resources/views/email/import/import_failure.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								resources/views/email/import/import_failure.blade.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					@component('email.template.master', ['design' => 'light', 'settings' => $settings])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @slot('header')
 | 
				
			||||||
 | 
					        @include('email.components.header', ['logo' => $logo])
 | 
				
			||||||
 | 
					    @endslot
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <h2>{{ctrans('texts.company_import_failure_subject')}}</h2>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <p>{{ctrans('texts.company_import_failure_body')}}</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @if($user_message)
 | 
				
			||||||
 | 
					    <p>{{ $user_message }}</p>
 | 
				
			||||||
 | 
					    @endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @if(isset($whitelabel) && !$whitelabel)
 | 
				
			||||||
 | 
					        @slot('footer')
 | 
				
			||||||
 | 
					            @component('email.components.footer', ['url' => 'https://invoiceninja.com', 'url_text' => '© InvoiceNinja'])
 | 
				
			||||||
 | 
					                For any info, please visit InvoiceNinja.
 | 
				
			||||||
 | 
					            @endcomponent
 | 
				
			||||||
 | 
					        @endslot
 | 
				
			||||||
 | 
					    @endif
 | 
				
			||||||
 | 
					@endcomponent
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user