Progress on order progress
This commit is contained in:
@@ -17,55 +17,6 @@ class AdminHomeController extends Controller
|
||||
return View('a.service',['o'=>$o]);
|
||||
}
|
||||
|
||||
public function service_update(Request $request, Service $o)
|
||||
{
|
||||
if (! $o->validStatus(strtolower($request->input('action'))))
|
||||
return $this->service($o);
|
||||
|
||||
$action = strtolower($request->input('action'));
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
case 'approve':
|
||||
// Send an email to the supplier.
|
||||
// @todo Change to address to suppliers email address.
|
||||
Mail::to('help@graytech.net.au')
|
||||
->queue((new OrderRequestApprove($o,$request->input('order_notes') ?: 'NONE'))->onQueue('high'));
|
||||
|
||||
// Send an email to the client.
|
||||
// @todo Your order has been submitted to supplier.
|
||||
|
||||
// Update the service to "ORDER-SENT"
|
||||
$o->nextStatus($action);
|
||||
|
||||
break;
|
||||
|
||||
case 'reject':
|
||||
$o->order_info = array_merge($o->order_info ? $o->order_info : [],['reason'=>$request->input('notes')]);
|
||||
|
||||
// Send mail to user
|
||||
Mail::to($o->orderby->email)->queue((new OrderRequestReject($o,$request->input('notes')))->onQueue('email'));
|
||||
|
||||
$o->nextStatus($action);
|
||||
break;
|
||||
|
||||
case 'hold':
|
||||
case 'release':
|
||||
$o->nextStatus($action);
|
||||
break;
|
||||
|
||||
case 'update_reference':
|
||||
$o->order_info = array_merge($o->order_info ? $o->order_info : [],['order_reference'=>$request->input('notes')]);
|
||||
$o->save();
|
||||
|
||||
// No action specified.
|
||||
default:
|
||||
return $this->service($o);
|
||||
}
|
||||
|
||||
return redirect(url('/a/service',[$o->id]));
|
||||
}
|
||||
|
||||
public function setup()
|
||||
{
|
||||
return view('a.setup');
|
||||
|
50
app/Http/Controllers/ServiceController.php
Normal file
50
app/Http/Controllers/ServiceController.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
use App\Models\Service;
|
||||
|
||||
class ServiceController extends Controller
|
||||
{
|
||||
/**
|
||||
* Update a service
|
||||
*
|
||||
* @note: Route Middleware protects this path
|
||||
* @param Service $o
|
||||
* @return View|void
|
||||
*/
|
||||
public function update(Request $request,Service $o)
|
||||
{
|
||||
switch ($o->order_status) {
|
||||
case 'ORDER-SENT':
|
||||
if ($request->post()) {
|
||||
foreach (['reference','notes'] as $key) {
|
||||
$o->setOrderInfo($key,$request->post($key));
|
||||
}
|
||||
|
||||
$o->save();
|
||||
|
||||
foreach ($request->post($o->stype) as $k=>$v) {
|
||||
$o->type->{$k} = $v;
|
||||
}
|
||||
|
||||
$o->type->save();
|
||||
|
||||
return redirect()->to(url('u/service',$o->id))->with('updated','Order sent notes updated.');
|
||||
}
|
||||
|
||||
return $this->update_order_status($o);
|
||||
|
||||
default:
|
||||
abort(499,'Not yet implemented');
|
||||
}
|
||||
}
|
||||
|
||||
private function update_order_status(Service $o)
|
||||
{
|
||||
return View('r.service.order.sent',['o'=>$o]);
|
||||
}
|
||||
}
|
@@ -87,6 +87,19 @@ class UserHomeController extends Controller
|
||||
*/
|
||||
public function service(Service $o): View
|
||||
{
|
||||
return View('u.service',['o'=>$o]);
|
||||
return View('u.service.home',['o'=>$o]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Progress the order to the next stage
|
||||
*
|
||||
* @note: Route Middleware protects this path
|
||||
* @param Service $o
|
||||
* @param string $status
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function service_progress(Service $o,string $status)
|
||||
{
|
||||
return redirect()->to($o->action($status) ?: url('u/service',$o->id));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user