diff --git a/app/Http/Controllers/PurchaseOrderController.php b/app/Http/Controllers/PurchaseOrderController.php index 75f0fb465774..77027d0789db 100644 --- a/app/Http/Controllers/PurchaseOrderController.php +++ b/app/Http/Controllers/PurchaseOrderController.php @@ -633,11 +633,23 @@ class PurchaseOrderController extends BaseController //check query parameter for email_type and set the template else use calculateTemplate PurchaseOrderEmail::dispatch($purchase_order, $purchase_order->company); - if (! $bulk) { return response()->json(['message' => 'email sent'], 200); } + case 'cancel': + + if($purchase_order->status_id <= PurchaseOrder::STATUS_SENT) + { + $purchase_order->status_id = PurchaseOrder::STATUS_CANCELLED; + $purchase_order->save(); + } + + if (! $bulk) { + return $this->listResponse($purchase_order); + } + break; + default: return response()->json(['message' => ctrans('texts.action_unavailable', ['action' => $action])], 400); break; diff --git a/app/Services/PurchaseOrder/PurchaseOrderService.php b/app/Services/PurchaseOrder/PurchaseOrderService.php index 89d2b64a8b31..e2990b372b42 100644 --- a/app/Services/PurchaseOrder/PurchaseOrderService.php +++ b/app/Services/PurchaseOrder/PurchaseOrderService.php @@ -51,7 +51,6 @@ class PurchaseOrderService // //TODO implement design, footer, terms - // /* If client currency differs from the company default currency, then insert the client exchange rate on the model.*/ // if (!isset($this->purchase_order->exchange_rate) && $this->purchase_order->client->currency()->id != (int)$this->purchase_order->company->settings->currency_id) // $this->purchase_order->exchange_rate = $this->purchase_order->client->currency()->exchange_rate; @@ -89,7 +88,6 @@ class PurchaseOrderService return $this; } - public function touchPdf($force = false) { try {