mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Purchase Order Download emails
This commit is contained in:
parent
b1c3878da2
commit
6e357d8c7b
@ -33,6 +33,7 @@ use App\Transformers\PurchaseOrderTransformer;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PurchaseOrderController extends BaseController
|
||||
{
|
||||
@ -488,7 +489,7 @@ class PurchaseOrderController extends BaseController
|
||||
* Download Purchase Order/s
|
||||
*/
|
||||
|
||||
if ($action == 'bulk_download' && $purchase_orders->count() > 1) {
|
||||
if ($action == 'bulk_download' && $purchase_orders->count() >= 1) {
|
||||
$purchase_orders->each(function ($purchase_order) {
|
||||
if (auth()->user()->cannot('view', $purchase_order)) {
|
||||
nlog("access denied");
|
||||
@ -582,7 +583,7 @@ class PurchaseOrderController extends BaseController
|
||||
*/
|
||||
public function action(ActionPurchaseOrderRequest $request, PurchaseOrder $purchase_order, $action)
|
||||
{
|
||||
return $this->performAction($invoice, $action);
|
||||
return $this->performAction($purchase_order, $action);
|
||||
}
|
||||
|
||||
private function performAction(PurchaseOrder $purchase_order, $action, $bulk = false)
|
||||
|
@ -18,6 +18,7 @@ use App\Jobs\Util\UnlinkFile;
|
||||
use App\Jobs\Vendor\CreatePurchaseOrderPdf;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Mail\DownloadInvoices;
|
||||
use App\Mail\DownloadPurchaseOrders;
|
||||
use App\Models\Company;
|
||||
use App\Models\User;
|
||||
use App\Utils\TempFile;
|
||||
@ -101,7 +102,7 @@ class ZipPurchaseOrders implements ShouldQueue
|
||||
Storage::put($path.$file_name, $zipFile->outputAsString());
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new DownloadInvoices(Storage::url($path.$file_name), $this->company);
|
||||
$nmo->mailable = new DownloadPurchaseOrders(Storage::url($path.$file_name), $this->company);
|
||||
$nmo->to_user = $this->user;
|
||||
$nmo->settings = $this->settings;
|
||||
$nmo->company = $this->company;
|
||||
|
56
app/Mail/DownloadPurchaseOrders.php
Normal file
56
app/Mail/DownloadPurchaseOrders.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Company;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class DownloadPurchaseOrders extends Mailable
|
||||
{
|
||||
// use Queueable, SerializesModels;
|
||||
|
||||
public $file_path;
|
||||
|
||||
public $company;
|
||||
|
||||
public function __construct($file_path, Company $company)
|
||||
{
|
||||
$this->file_path = $file_path;
|
||||
|
||||
$this->company = $company;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
|
||||
App::setLocale($this->company->getLocale());
|
||||
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
->subject(ctrans('texts.download_files'))
|
||||
->text('email.admin.download_invoices_text', [
|
||||
'url' => $this->file_path,
|
||||
])
|
||||
->view('email.admin.download_purchase_orders', [
|
||||
'url' => $this->file_path,
|
||||
'logo' => $this->company->present()->logo,
|
||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||
'settings' => $this->company->settings,
|
||||
'greeting' => $this->company->present()->name(),
|
||||
]);
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ class GetPurchaseOrderPdf extends AbstractService
|
||||
{
|
||||
|
||||
if (! $this->contact) {
|
||||
$this->contact = $this->purchase_order->vendor->contacts()->where('send_email', true)->first();
|
||||
$this->contact = $this->purchase_order->vendor->contacts()->orderBy('send_email', 'DESC')->first();
|
||||
}
|
||||
|
||||
$invitation = $this->purchase_order->invitations()->where('vendor_contact_id', $this->contact->id)->first();
|
||||
|
@ -4622,6 +4622,7 @@ $LANG = array(
|
||||
'purchase_order_subject' => 'New Purchase Order :number from :account',
|
||||
'purchase_order_message' => 'To view your purchase order for :amount, click the link below.',
|
||||
'view_purchase_order' => 'View Purchase Order',
|
||||
'purchase_orders_backup_subject' => 'Your purchase orders are ready for download',
|
||||
|
||||
);
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
@component('email.template.admin', ['logo' => $logo, 'settings' => $settings])
|
||||
<div class="center">
|
||||
<h1>{{ ctrans('texts.purchase_orders_backup_subject') }}</h1>
|
||||
<p>{{ ctrans('texts.download_timeframe') }}</p>
|
||||
|
||||
<a target="_blank" class="button" href="{{ $url }}">
|
||||
{{ ctrans('texts.download') }}
|
||||
</a>
|
||||
</div>
|
||||
@endcomponent
|
Loading…
x
Reference in New Issue
Block a user