mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for templates
This commit is contained in:
parent
1e845c46fe
commit
747975998f
@ -557,7 +557,7 @@ class CreditController extends BaseController
|
||||
$hash_or_response = $request->boolean('send_email') ? 'email sent' : \Illuminate\Support\Str::uuid();
|
||||
|
||||
TemplateAction::dispatch(
|
||||
$credits->pluck('id')->toArray(),
|
||||
$credits->pluck('hashed_id')->toArray(),
|
||||
$request->template_id,
|
||||
Credit::class,
|
||||
$user->id,
|
||||
@ -570,8 +570,6 @@ class CreditController extends BaseController
|
||||
return response()->json(['message' => $hash_or_response], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$credits->each(function ($credit, $key) use ($action, $user) {
|
||||
if ($user->can('edit', $credit)) {
|
||||
$this->performAction($credit, $action, true);
|
||||
|
@ -519,9 +519,9 @@ class PaymentController extends BaseController
|
||||
if($action == 'template' && $user->can('view', $payments->first())) {
|
||||
|
||||
$hash_or_response = request()->boolean('send_email') ? 'email sent' : \Illuminate\Support\Str::uuid();
|
||||
|
||||
nlog($payments->pluck('hashed_id')->toArray());
|
||||
TemplateAction::dispatch(
|
||||
$payments->pluck('id')->toArray(),
|
||||
$payments->pluck('hashed_id')->toArray(),
|
||||
$request->template_id,
|
||||
Payment::class,
|
||||
$user->id,
|
||||
|
@ -29,7 +29,7 @@ use App\Http\Requests\Project\CreateProjectRequest;
|
||||
use App\Http\Requests\Project\UpdateProjectRequest;
|
||||
use App\Http\Requests\Project\UploadProjectRequest;
|
||||
use App\Http\Requests\Project\DestroyProjectRequest;
|
||||
use App\Http\Requests\PrTaskoject\BulkProjectRequest;
|
||||
use App\Http\Requests\Project\BulkProjectRequest;
|
||||
|
||||
/**
|
||||
* Class ProjectController.
|
||||
@ -508,7 +508,7 @@ class ProjectController extends BaseController
|
||||
$hash_or_response = $request->boolean('send_email') ? 'email sent' : \Illuminate\Support\Str::uuid();
|
||||
|
||||
TemplateAction::dispatch(
|
||||
$projects->pluck('id')->toArray(),
|
||||
$projects->pluck('hashed_id')->toArray(),
|
||||
$request->template_id,
|
||||
Project::class,
|
||||
$user->id,
|
||||
|
@ -525,15 +525,12 @@ class PurchaseOrderController extends BaseController
|
||||
}, 'print.pdf', ['Content-Type' => 'application/pdf']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if($action == 'template' && $user->can('view', $purchase_orders->first())) {
|
||||
|
||||
$hash_or_response = $request->boolean('send_email') ? 'email sent' : \Illuminate\Support\Str::uuid();
|
||||
|
||||
TemplateAction::dispatch(
|
||||
$purchase_orders->pluck('id')->toArray(),
|
||||
$purchase_orders->pluck('hashed_id')->toArray(),
|
||||
$request->template_id,
|
||||
PurchaseOrder::class,
|
||||
$user->id,
|
||||
@ -546,7 +543,6 @@ class PurchaseOrderController extends BaseController
|
||||
return response()->json(['message' => $hash_or_response], 200);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Send the other actions to the switch
|
||||
*/
|
||||
|
@ -518,9 +518,9 @@ class QuoteController extends BaseController
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$action = request()->input('action');
|
||||
$action = $request->input('action');
|
||||
|
||||
$ids = request()->input('ids');
|
||||
$ids = $request->input('ids');
|
||||
|
||||
if (Ninja::isHosted() && (stripos($action, 'email') !== false) && !$user->account->account_sms_verified) {
|
||||
return response(['message' => 'Please verify your account to send emails.'], 400);
|
||||
|
@ -35,9 +35,15 @@ class BulkCreditRequest extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return [
|
||||
'ids' => ['required','bail','array',Rule::exists('credits', 'id')->where('company_id', auth()->user()->company()->id)],
|
||||
'action' => 'required|bail|in:archive,restore,delete,email,bulk_download,bulk_print,mark_paid,clone_to_credit,history,mark_sent,download,send_email'
|
||||
'ids' => ['required','bail','array',Rule::exists('credits', 'id')->where('company_id', $user->company()->id)],
|
||||
'action' => 'required|bail|in:archive,restore,delete,email,bulk_download,bulk_print,mark_paid,clone_to_credit,history,mark_sent,download,send_email,template',
|
||||
'template' => 'sometimes|string',
|
||||
'template_id' => 'sometimes|string',
|
||||
'send_email' => 'sometimes|bool'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests\PrTaskoject;
|
||||
namespace App\Http\Requests\Project;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
|
@ -30,7 +30,10 @@ class BulkPurchaseOrderRequest extends Request
|
||||
{
|
||||
return [
|
||||
'ids' => 'required|bail|array|min:1',
|
||||
'action' => 'in:archive,restore,delete,email,bulk_download,bulk_print,mark_sent,download,send_email,add_to_inventory,expense,cancel'
|
||||
'action' => 'in:template,archive,restore,delete,email,bulk_download,bulk_print,mark_sent,download,send_email,add_to_inventory,expense,cancel',
|
||||
'template' => 'sometimes|string',
|
||||
'template_id' => 'sometimes|string',
|
||||
'send_email' => 'sometimes|bool'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,11 @@ class BulkActionQuoteRequest extends Request
|
||||
$input = $this->all();
|
||||
|
||||
$rules = [
|
||||
'action' => 'sometimes|in:convert_to_invoice,convert_to_project,email,bulk_download,bulk_print,clone_to_invoice,approve,download,restore,archive,delete,send_email,mark_sent',
|
||||
'action' => 'sometimes|in:template,convert_to_invoice,convert_to_project,email,bulk_download,bulk_print,clone_to_invoice,approve,download,restore,archive,delete,send_email,mark_sent',
|
||||
'ids' => 'required|array',
|
||||
'template' => 'sometimes|string',
|
||||
'template_id' => 'sometimes|string',
|
||||
'send_email' => 'sometimes|bool'
|
||||
];
|
||||
|
||||
if (in_array($input['action'], ['convert,convert_to_invoice'])) {
|
||||
|
@ -103,6 +103,8 @@ class TemplateAction implements ShouldQueue
|
||||
->where('company_id', $this->company->id)
|
||||
->get();
|
||||
|
||||
nlog($result->toArray());
|
||||
|
||||
if($result->count() <= 1) {
|
||||
$data[$key] = collect($result);
|
||||
} else {
|
||||
|
@ -120,7 +120,7 @@ class TemplateService
|
||||
* @return self
|
||||
*/
|
||||
public function build(array $data): self
|
||||
{
|
||||
{nlog($data);
|
||||
$this->compose()
|
||||
->processData($data)
|
||||
->parseNinjaBlocks()
|
||||
|
Loading…
x
Reference in New Issue
Block a user