mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
commit
950a057496
@ -125,7 +125,7 @@ class PreviewController extends BaseController
|
||||
->design($design)
|
||||
->build();
|
||||
|
||||
if (request()->has('html') && request()->input('html') == true) {
|
||||
if (request()->query('html') == true) {
|
||||
return $maker->getCompiledHTML;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,9 @@ use App\Import\Transformers\ClientTransformer;
|
||||
use App\Import\Transformers\InvoiceItemTransformer;
|
||||
use App\Import\Transformers\InvoiceTransformer;
|
||||
use App\Import\Transformers\ProductTransformer;
|
||||
use App\Jobs\Mail\MailRouter;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Mail\Import\ImportCompleted;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\Currency;
|
||||
@ -98,11 +100,19 @@ class CSVImport implements ShouldQueue
|
||||
|
||||
info("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");
|
||||
|
||||
info(print_r($this->error_array,1));
|
||||
MailRouter::dispatch(new ImportCompleted($data), $this->company, auth()->user());
|
||||
|
||||
}
|
||||
|
||||
@ -180,7 +190,7 @@ class CSVImport implements ShouldQueue
|
||||
$validator = Validator::make($invoice, (new StoreInvoiceRequest())->rules());
|
||||
|
||||
if ($validator->fails()) {
|
||||
$this->error_array[] = ['invoice' => $invoice, 'error' => json_encode($validator->errors())];
|
||||
$this->error_array['invoices'] = ['invoice' => $invoice, 'error' => json_encode($validator->errors())];
|
||||
} else {
|
||||
|
||||
$invoice = $invoice_repository->save($invoice, InvoiceFactory::create($this->company->id, $this->setUser($record)));
|
||||
@ -248,7 +258,7 @@ class CSVImport implements ShouldQueue
|
||||
$validator = Validator::make($client, (new StoreClientRequest())->rules());
|
||||
|
||||
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 {
|
||||
$client = $client_repository->save($client, ClientFactory::create($this->company->id, $this->setUser($record)));
|
||||
|
||||
@ -291,7 +301,7 @@ class CSVImport implements ShouldQueue
|
||||
$validator = Validator::make($product, (new StoreProductRequest())->rules());
|
||||
|
||||
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 {
|
||||
$product = $product_repository->save($product, ProductFactory::create($this->company->id, $this->setUser($record)));
|
||||
|
||||
@ -310,6 +320,7 @@ class CSVImport implements ShouldQueue
|
||||
$this->maps['company'] = $this->company;
|
||||
$this->maps['clients'] = [];
|
||||
$this->maps['products'] = [];
|
||||
$this->maps['invoices'] = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -97,8 +97,9 @@ class BaseMailerJob implements ShouldQueue
|
||||
public function failed($exception = null)
|
||||
{
|
||||
|
||||
// info('the job failed');
|
||||
|
||||
info('the job failed');
|
||||
info($exception->getMessage());
|
||||
|
||||
$job_failure = new EmailFailure();
|
||||
$job_failure->string_metric5 = get_parent_class($this);
|
||||
$job_failure->string_metric6 = $exception->getMessage();
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Jobs\Mail;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Company;
|
||||
use App\Models\User;
|
||||
@ -74,7 +75,9 @@ class MailRouter extends BaseMailerJob implements ShouldQueue
|
||||
->send($this->mailable);
|
||||
} catch (\Exception $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->user_id = $event->quote->user_id;
|
||||
$fields->company_id = $event->quote->company_id;
|
||||
$fields->user_id = $event->invitation->quote->user_id;
|
||||
$fields->company_id = $event->invitation->company_id;
|
||||
$fields->activity_type_id = Activity::VIEW_QUOTE;
|
||||
$fields->client_id = $event->invitation->client_id;
|
||||
$fields->client_contact_id = $event->invitation->client_contact_id;
|
||||
$fields->invitation_id = $event->invitation->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)
|
||||
->waitUntilNetworkIdle(true)
|
||||
->noSandbox()
|
||||
->ignoreHttpsErrors()
|
||||
->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