mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improve functionality of Purchase Order Signatures
This commit is contained in:
parent
db5b9adcc5
commit
552532f1ef
@ -146,25 +146,32 @@ class PurchaseOrderController extends Controller
|
||||
$purchase_orders = PurchaseOrder::query()
|
||||
->whereIn('id', $this->transformKeys($data['purchase_orders']))
|
||||
->where('company_id', auth()->guard('vendor')->user()->vendor->company_id)
|
||||
->whereIn('status_id', [PurchaseOrder::STATUS_DRAFT, PurchaseOrder::STATUS_SENT])
|
||||
->where('is_deleted', 0)
|
||||
->withTrashed()
|
||||
->cursor()->each(function ($purchase_order) {
|
||||
$purchase_order->service()
|
||||
->markSent()
|
||||
->applyNumber()
|
||||
->setStatus(PurchaseOrder::STATUS_ACCEPTED)
|
||||
->save();
|
||||
->withTrashed();
|
||||
|
||||
if (request()->has('signature') && ! is_null(request()->signature) && ! empty(request()->signature)) {
|
||||
InjectSignature::dispatch($purchase_order, request()->signature);
|
||||
}
|
||||
$purchase_count_query = clone $purchase_orders;
|
||||
|
||||
event(new PurchaseOrderWasAccepted($purchase_order, auth()->guard('vendor')->user(), $purchase_order->company, Ninja::eventVars()));
|
||||
});
|
||||
$purchase_orders->whereIn('status_id', [PurchaseOrder::STATUS_DRAFT, PurchaseOrder::STATUS_SENT])
|
||||
->cursor()->each(function ($purchase_order) {
|
||||
|
||||
$purchase_order->service()
|
||||
->markSent()
|
||||
->applyNumber()
|
||||
->setStatus(PurchaseOrder::STATUS_ACCEPTED)
|
||||
->save();
|
||||
|
||||
if (count($data['purchase_orders']) == 1) {
|
||||
$purchase_order = PurchaseOrder::withTrashed()->where('is_deleted', 0)->whereIn('id', $this->transformKeys($data['purchase_orders']))->first();
|
||||
if (request()->has('signature') && ! is_null(request()->signature) && ! empty(request()->signature)) {
|
||||
(new InjectSignature($purchase_order, request()->signature))->handle();
|
||||
// InjectSignature::dispatch($purchase_order, request()->signature);
|
||||
}
|
||||
|
||||
event(new PurchaseOrderWasAccepted($purchase_order, auth()->guard('vendor')->user(), $purchase_order->company, Ninja::eventVars()));
|
||||
});
|
||||
|
||||
nlog($purchase_count_query->count());
|
||||
|
||||
if ($purchase_count_query->count() == 1) {
|
||||
$purchase_order = $purchase_count_query->first();
|
||||
|
||||
return redirect()->route('vendor.purchase_order.show', ['purchase_order' => $purchase_order->hashed_id]);
|
||||
} else {
|
||||
|
@ -54,9 +54,11 @@ class InjectSignature implements ShouldQueue
|
||||
$invitation->signature_base64 = $this->signature;
|
||||
$invitation->save();
|
||||
|
||||
if($this->entity instanceof PurchaseOrder)
|
||||
CreatePurchaseOrderPdf::dispatch($invitation);
|
||||
else
|
||||
CreateEntityPdf::dispatch($invitation);
|
||||
$this->entity->refresh()->service()->touchPdf(true);
|
||||
|
||||
// if($this->entity instanceof PurchaseOrder)
|
||||
// (new CreatePurchaseOrderPdf($invitation))->handle();
|
||||
// else
|
||||
// (new CreateEntityPdf($invitation))->handle();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user