mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 17:37:31 -04:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/v5-develop' into v5-amount-with-fee
This commit is contained in:
		
						commit
						09a5ab4fad
					
				| @ -125,7 +125,7 @@ class PreviewController extends BaseController | |||||||
|                 ->design($design) |                 ->design($design) | ||||||
|                 ->build(); |                 ->build(); | ||||||
| 
 | 
 | ||||||
|             if (request()->has('html') && request()->input('html') == true) { |             if (request()->query('html') == true) { | ||||||
|                 return $maker->getCompiledHTML; |                 return $maker->getCompiledHTML; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -21,7 +21,9 @@ use App\Import\Transformers\ClientTransformer; | |||||||
| use App\Import\Transformers\InvoiceItemTransformer; | use App\Import\Transformers\InvoiceItemTransformer; | ||||||
| use App\Import\Transformers\InvoiceTransformer; | use App\Import\Transformers\InvoiceTransformer; | ||||||
| use App\Import\Transformers\ProductTransformer; | use App\Import\Transformers\ProductTransformer; | ||||||
|  | use App\Jobs\Mail\MailRouter; | ||||||
| use App\Libraries\MultiDB; | use App\Libraries\MultiDB; | ||||||
|  | use App\Mail\Import\ImportCompleted; | ||||||
| use App\Models\Client; | use App\Models\Client; | ||||||
| use App\Models\Company; | use App\Models\Company; | ||||||
| use App\Models\Currency; | use App\Models\Currency; | ||||||
| @ -98,11 +100,20 @@ class CSVImport implements ShouldQueue | |||||||
| 
 | 
 | ||||||
|         info("import".ucfirst($this->entity_type)); |         info("import".ucfirst($this->entity_type)); | ||||||
|         $this->{"import".ucfirst($this->entity_type)}(); |         $this->{"import".ucfirst($this->entity_type)}(); | ||||||
|  |          | ||||||
|  |         $data = [ | ||||||
|  |             'entity' => ucfirst($this->entity_type), | ||||||
|  |             'errors' => $this->error_array, | ||||||
|  |             'clients' => $this->maps['clients'], | ||||||
|  |             'products' => $this->maps['products'], | ||||||
|  |             'invoices' => $this->maps['invoices'], | ||||||
|  |             'settings' => $this->company->settings | ||||||
|  |         ]; | ||||||
| 
 | 
 | ||||||
|  | info(print_r($data,1)); | ||||||
| 
 | 
 | ||||||
|         info("errors"); |         MailRouter::dispatch(new ImportCompleted($data), $this->company, auth()->user()); | ||||||
| 
 | 
 | ||||||
|         info(print_r($this->error_array, 1)); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function failed($exception) |     public function failed($exception) | ||||||
| @ -168,7 +179,11 @@ class CSVImport implements ShouldQueue | |||||||
| 
 | 
 | ||||||
|         $invoice['line_items'] = $this->cleanItems($items); |         $invoice['line_items'] = $this->cleanItems($items); | ||||||
| 
 | 
 | ||||||
|         $validator = Validator::make($invoice, (new StoreInvoiceRequest())->rules()); |             $validator = Validator::make($invoice, (new StoreInvoiceRequest())->rules()); | ||||||
|  | 
 | ||||||
|  |             if ($validator->fails()) { | ||||||
|  |                 $this->error_array['invoices'] = ['invoice' => $invoice, 'error' => json_encode($validator->errors())]; | ||||||
|  |             } else { | ||||||
| 
 | 
 | ||||||
|         if ($validator->fails()) { |         if ($validator->fails()) { | ||||||
|             $this->error_array[] = ['invoice' => $invoice, 'error' => json_encode($validator->errors())]; |             $this->error_array[] = ['invoice' => $invoice, 'error' => json_encode($validator->errors())]; | ||||||
| @ -237,7 +252,7 @@ class CSVImport implements ShouldQueue | |||||||
|             $validator = Validator::make($client, (new StoreClientRequest())->rules()); |             $validator = Validator::make($client, (new StoreClientRequest())->rules()); | ||||||
| 
 | 
 | ||||||
|             if ($validator->fails()) { |             if ($validator->fails()) { | ||||||
|                 $this->error_array[] = ['client' => $client, 'error' => json_encode($validator->errors())]; |                 $this->error_array['clients'] = ['client' => $client, 'error' => json_encode($validator->errors())]; | ||||||
|             } else { |             } else { | ||||||
|                 $client = $client_repository->save($client, ClientFactory::create($this->company->id, $this->setUser($record))); |                 $client = $client_repository->save($client, ClientFactory::create($this->company->id, $this->setUser($record))); | ||||||
| 
 | 
 | ||||||
| @ -279,7 +294,7 @@ class CSVImport implements ShouldQueue | |||||||
|             $validator = Validator::make($product, (new StoreProductRequest())->rules()); |             $validator = Validator::make($product, (new StoreProductRequest())->rules()); | ||||||
| 
 | 
 | ||||||
|             if ($validator->fails()) { |             if ($validator->fails()) { | ||||||
|                 $this->error_array[] = ['product' => $product, 'error' => json_encode($validator->errors())]; |                 $this->error_array['products'] = ['product' => $product, 'error' => json_encode($validator->errors())]; | ||||||
|             } else { |             } else { | ||||||
|                 $product = $product_repository->save($product, ProductFactory::create($this->company->id, $this->setUser($record))); |                 $product = $product_repository->save($product, ProductFactory::create($this->company->id, $this->setUser($record))); | ||||||
| 
 | 
 | ||||||
| @ -298,6 +313,7 @@ class CSVImport implements ShouldQueue | |||||||
|         $this->maps['company'] = $this->company; |         $this->maps['company'] = $this->company; | ||||||
|         $this->maps['clients'] = []; |         $this->maps['clients'] = []; | ||||||
|         $this->maps['products'] = []; |         $this->maps['products'] = []; | ||||||
|  |         $this->maps['invoices'] = []; | ||||||
| 
 | 
 | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -97,8 +97,9 @@ class BaseMailerJob implements ShouldQueue | |||||||
|     public function failed($exception = null) |     public function failed($exception = null) | ||||||
|     { |     { | ||||||
| 
 | 
 | ||||||
|        // info('the job failed');
 |         info('the job failed'); | ||||||
| 
 |         info($exception->getMessage()); | ||||||
|  |          | ||||||
|         $job_failure = new EmailFailure(); |         $job_failure = new EmailFailure(); | ||||||
|         $job_failure->string_metric5 = get_parent_class($this); |         $job_failure->string_metric5 = get_parent_class($this); | ||||||
|         $job_failure->string_metric6 = $exception->getMessage(); |         $job_failure->string_metric6 = $exception->getMessage(); | ||||||
|  | |||||||
| @ -12,6 +12,7 @@ | |||||||
| namespace App\Jobs\Mail; | namespace App\Jobs\Mail; | ||||||
| 
 | 
 | ||||||
| use App\Libraries\MultiDB; | use App\Libraries\MultiDB; | ||||||
|  | use App\Models\Client; | ||||||
| use App\Models\ClientContact; | use App\Models\ClientContact; | ||||||
| use App\Models\Company; | use App\Models\Company; | ||||||
| use App\Models\User; | use App\Models\User; | ||||||
| @ -74,7 +75,9 @@ class MailRouter extends BaseMailerJob implements ShouldQueue | |||||||
|                 ->send($this->mailable); |                 ->send($this->mailable); | ||||||
|         } catch (\Exception $e) { |         } catch (\Exception $e) { | ||||||
|             $this->failed($e); |             $this->failed($e); | ||||||
|             $this->logMailError($e->getMessage(), $this->to_user); |              | ||||||
|  |             if($this->to_user instanceof ClientContact) | ||||||
|  |                 $this->logMailError($e->getMessage(), $this->to_user->client); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -43,14 +43,14 @@ class QuoteViewedActivity implements ShouldQueue | |||||||
| 
 | 
 | ||||||
|         $fields = new stdClass; |         $fields = new stdClass; | ||||||
| 
 | 
 | ||||||
|         $fields->user_id = $event->quote->user_id; |         $fields->user_id = $event->invitation->quote->user_id; | ||||||
|         $fields->company_id = $event->quote->company_id; |         $fields->company_id = $event->invitation->company_id; | ||||||
|         $fields->activity_type_id = Activity::VIEW_QUOTE; |         $fields->activity_type_id = Activity::VIEW_QUOTE; | ||||||
|         $fields->client_id = $event->invitation->client_id; |         $fields->client_id = $event->invitation->client_id; | ||||||
|         $fields->client_contact_id = $event->invitation->client_contact_id; |         $fields->client_contact_id = $event->invitation->client_contact_id; | ||||||
|         $fields->invitation_id = $event->invitation->id; |         $fields->invitation_id = $event->invitation->id; | ||||||
|         $fields->quote_id = $event->invitation->quote_id; |         $fields->quote_id = $event->invitation->quote_id; | ||||||
| 
 | 
 | ||||||
|         $this->activity_repo->save($fields, $event->quote, $event->event_vars); |         $this->activity_repo->save($fields, $event->invitation->quote, $event->event_vars); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										35
									
								
								app/Mail/Import/ImportCompleted.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								app/Mail/Import/ImportCompleted.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | |||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | namespace App\Mail\Import; | ||||||
|  | 
 | ||||||
|  | use Illuminate\Bus\Queueable; | ||||||
|  | use Illuminate\Mail\Mailable; | ||||||
|  | use Illuminate\Queue\SerializesModels; | ||||||
|  | 
 | ||||||
|  | class ImportCompleted extends Mailable | ||||||
|  | { | ||||||
|  |     use Queueable, SerializesModels; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Create a new message instance. | ||||||
|  |      * | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public $data; | ||||||
|  | 
 | ||||||
|  |     public function __construct($data) | ||||||
|  |     { | ||||||
|  |         $this->data = $data; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Build the message. | ||||||
|  |      * | ||||||
|  |      * @return $this | ||||||
|  |      */ | ||||||
|  |     public function build() | ||||||
|  |     { | ||||||
|  |         return $this->from(config('mail.from.address'), config('mail.from.name')) | ||||||
|  |                     ->view('email.import.completed', $this->data); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -51,6 +51,7 @@ trait PdfMaker | |||||||
|                 ->deviceScaleFactor(1) |                 ->deviceScaleFactor(1) | ||||||
|                 ->waitUntilNetworkIdle(true) |                 ->waitUntilNetworkIdle(true) | ||||||
|                 ->noSandbox() |                 ->noSandbox() | ||||||
|  |                 ->ignoreHttpsErrors() | ||||||
|                 ->pdf(); |                 ->pdf(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										82
									
								
								resources/views/email/import/completed.blade.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								resources/views/email/import/completed.blade.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,82 @@ | |||||||
|  | @component('email.template.master', ['design' => 'light', 'settings' =>$settings]) | ||||||
|  | 
 | ||||||
|  | @slot('header') | ||||||
|  |     @component('email.components.header') | ||||||
|  |         Import completed | ||||||
|  |     @endcomponent | ||||||
|  | @endslot | ||||||
|  | 
 | ||||||
|  | @slot('greeting') | ||||||
|  | 	Hello, | ||||||
|  | @endslot | ||||||
|  | 
 | ||||||
|  | Here is the output of your recent import job. <br><br> | ||||||
|  | 
 | ||||||
|  | @if(isset($clients) && count($clients) >=1) | ||||||
|  | 
 | ||||||
|  | <h3>Clients Imported: {{ count($clients) }} </h3> | ||||||
|  | 
 | ||||||
|  | @endif | ||||||
|  | 
 | ||||||
|  | @if(isset($errors['clients']) && count($errors['clients']) >=1) | ||||||
|  | 
 | ||||||
|  |     <h3>Client Errors</h3> | ||||||
|  | 
 | ||||||
|  |     <ul> | ||||||
|  |     @foreach($errors['clients'] as $error) | ||||||
|  |         <li>{{ $error['client'] }} - {{ $error['error'] }}</li> | ||||||
|  |     @endforeach | ||||||
|  |     </ul> | ||||||
|  | @endif | ||||||
|  | 
 | ||||||
|  | @if(isset($invoices) && count($invoices) >=1) | ||||||
|  | 
 | ||||||
|  | <h3>Invoices Imported: {{ count($invoices) }} </h3> | ||||||
|  | 
 | ||||||
|  | @endif | ||||||
|  | 
 | ||||||
|  | @if(isset($errors['invoices']) && count($errors['invoices']) >=1) | ||||||
|  | 
 | ||||||
|  |     <h3>Invoices Errors</h3> | ||||||
|  | 
 | ||||||
|  |     <ul> | ||||||
|  |     @foreach($errors['invoices'] as $error) | ||||||
|  |         <li>{{ $error['invoice'] }} - {{ $error['error'] }}</li> | ||||||
|  |     @endforeach | ||||||
|  |     </ul> | ||||||
|  | @endif | ||||||
|  | 
 | ||||||
|  | @if(isset($products) && count($products) >=1) | ||||||
|  | 
 | ||||||
|  | <h3>Products Imported: {{ count($products) }} </h3> | ||||||
|  | 
 | ||||||
|  | @endif | ||||||
|  | 
 | ||||||
|  | @if(isset($errors['products']) && count($errors['products']) >=1) | ||||||
|  | 
 | ||||||
|  |     <h3>Client Errors</h3> | ||||||
|  | 
 | ||||||
|  |     <ul> | ||||||
|  |     @foreach($errors['products'] as $error) | ||||||
|  |         <li>{{ $error['product'] }} - {{ $error['error'] }}</li> | ||||||
|  |     @endforeach | ||||||
|  |     </ul> | ||||||
|  | @endif | ||||||
|  | 
 | ||||||
|  | @component('email.components.button', ['url' => url('/')]) | ||||||
|  |     Visit portal | ||||||
|  | @endcomponent | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @slot('signature') | ||||||
|  | Thank you, <br> | ||||||
|  | Invoice Ninja     | ||||||
|  | @endslot | ||||||
|  | 
 | ||||||
|  | @slot('footer') | ||||||
|  |     @component('email.components.footer', ['url' => 'https://invoiceninja.com', 'url_text' => '© InvoiceNinja']) | ||||||
|  |         For any info, please visit InvoiceNinja. | ||||||
|  |     @endcomponent | ||||||
|  | @endslot | ||||||
|  | 
 | ||||||
|  | @endcomponent | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user