Some order processing
This commit is contained in:
parent
90bcb7f5f1
commit
27fdb334d0
@ -5,11 +5,43 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
use App\Models\SiteDetails;
|
||||
use App\Mail\OrderRequestApprove;
|
||||
use App\Models\{Service,SiteDetails};
|
||||
|
||||
class AdminHomeController extends Controller
|
||||
{
|
||||
public function service(Service $o)
|
||||
{
|
||||
return View('a.service',['o'=>$o]);
|
||||
}
|
||||
|
||||
public function service_update(Request $request, Service $o)
|
||||
{
|
||||
switch (strtolower($request->input('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();
|
||||
break;
|
||||
|
||||
// No action specified.
|
||||
default:
|
||||
return $this->service($o);
|
||||
}
|
||||
|
||||
return redirect(url('/a/service/',[$o->id]));
|
||||
}
|
||||
|
||||
public function setup()
|
||||
{
|
||||
return view('a.setup');
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\{Invoice,Service};
|
||||
use App\User;
|
||||
use PDF;
|
||||
|
||||
@ -14,16 +14,6 @@ class UserHomeController extends Controller
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function invoice(Invoice $o)
|
||||
{
|
||||
return View('u.invoice',['o'=>$o]);
|
||||
}
|
||||
|
||||
public function invoice_pdf(Invoice $o)
|
||||
{
|
||||
return PDF::loadView('u.invoice', ['o'=>$o])->stream(sprintf('%s.pdf',$o->invoice_account_id));
|
||||
}
|
||||
|
||||
public function home()
|
||||
{
|
||||
switch (Auth::user()->role()) {
|
||||
@ -41,6 +31,16 @@ class UserHomeController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function invoice(Invoice $o)
|
||||
{
|
||||
return View('u.invoice',['o'=>$o]);
|
||||
}
|
||||
|
||||
public function invoice_pdf(Invoice $o)
|
||||
{
|
||||
return PDF::loadView('u.invoice', ['o'=>$o])->stream(sprintf('%s.pdf',$o->invoice_account_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to redirect to the old site, when functions are not available in this one.
|
||||
*
|
||||
@ -55,6 +55,11 @@ class UserHomeController extends Controller
|
||||
abort(307,sprintf('http://www.graytech.net.au/u/%s/%s/%s',$type,$action,$id));
|
||||
}
|
||||
|
||||
public function service(Service $o)
|
||||
{
|
||||
return View('u.service',['o'=>$o]);
|
||||
}
|
||||
|
||||
public function User(User $o)
|
||||
{
|
||||
// @todo Check authorised to see this account.
|
||||
|
42
app/Mail/OrderRequestApprove.php
Normal file
42
app/Mail/OrderRequestApprove.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
use App\Models\Service;
|
||||
|
||||
class OrderRequestApprove extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $service;
|
||||
public $notes;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param Service $o
|
||||
* @param string $notes
|
||||
*/
|
||||
public function __construct(Service $o,$notes='')
|
||||
{
|
||||
$this->service = $o;
|
||||
$this->notes = $notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this
|
||||
->markdown('email.admin.order.approve')
|
||||
->with(['site'=>config('SITE_SETUP')]);
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ class Service extends Model
|
||||
|
||||
protected $appends = [
|
||||
'account_name',
|
||||
'admin_service_id_url',
|
||||
'category',
|
||||
'name',
|
||||
'next_invoice',
|
||||
@ -33,6 +34,7 @@ class Service extends Model
|
||||
|
||||
protected $visible = [
|
||||
'account_name',
|
||||
'admin_service_id_url',
|
||||
'active',
|
||||
'category',
|
||||
'data_orig',
|
||||
@ -99,6 +101,11 @@ class Service extends Model
|
||||
return $this->account->company;
|
||||
}
|
||||
|
||||
public function getAdminServiceIdUrlAttribute()
|
||||
{
|
||||
return sprintf('<a href="/a/service/%s">%s</a>',$this->id,$this->service_id);
|
||||
}
|
||||
|
||||
public function getCategoryAttribute()
|
||||
{
|
||||
return $this->product->category;
|
||||
@ -162,6 +169,19 @@ class Service extends Model
|
||||
return $this->active OR ($this->order_status AND ! in_array($this->order_status,$this->inactive_status));
|
||||
}
|
||||
|
||||
public function nextStatus() {
|
||||
switch ($this->order_status)
|
||||
{
|
||||
case 'ORDER-REQUEST':
|
||||
$this->order_status = 'ORDER-SENT';
|
||||
$this->save();
|
||||
return $this;
|
||||
|
||||
default:
|
||||
abort(500,'Next Status not set up for:'.$this->order_status);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will return the associated service model for the product type
|
||||
*/
|
||||
|
@ -226,6 +226,7 @@ class User extends Authenticatable
|
||||
|
||||
return $result->flatten();
|
||||
}
|
||||
|
||||
public function all_clients($level=0)
|
||||
{
|
||||
$result = collect();
|
||||
@ -286,6 +287,11 @@ class User extends Authenticatable
|
||||
return in_array($this->role(),['wholesaler','reseller']);
|
||||
}
|
||||
|
||||
public function isWholesaler()
|
||||
{
|
||||
return in_array($this->role(),['wholesaler']);
|
||||
}
|
||||
|
||||
public function role()
|
||||
{
|
||||
// If I have agents and no parent, I am the wholesaler
|
||||
|
38
resources/theme/backend/adminlte/a/service.blade.php
Normal file
38
resources/theme/backend/adminlte/a/service.blade.php
Normal file
@ -0,0 +1,38 @@
|
||||
@extends('adminlte::layouts.app')
|
||||
|
||||
@section('htmlheader_title')
|
||||
Service #{{ $o->id }}
|
||||
@endsection
|
||||
|
||||
@section('contentheader_title')
|
||||
Service #
|
||||
@endsection
|
||||
@section('contentheader_description')
|
||||
{{ $o->service_id }}
|
||||
@endsection
|
||||
|
||||
@section('main-content')
|
||||
<div class="col-md-12">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Service Information</h3>
|
||||
</div>
|
||||
|
||||
<div class="box-body">
|
||||
<div class="col-md-3">
|
||||
@include('u.widgets.service_info')
|
||||
</div>
|
||||
|
||||
@if($o->order_status == 'ORDER-REQUEST')
|
||||
<div class="col-md-3">
|
||||
@include('a.widgets.service_order-request')
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="box-footer">
|
||||
<button type="submit" class="btn btn-info">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
@ -0,0 +1,49 @@
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Service Order Information</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
|
||||
<i class="fa fa-minus"></i></button>
|
||||
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
|
||||
<i class="fa fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form role="form" method="POST" enctype="multipart/form-data">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<div class="box-body">
|
||||
<table class="table table-condensed" width="100%">
|
||||
<tr>
|
||||
<th>Order Info</th>
|
||||
<td>{{ $o->order_info ? join('|',$o->order_info) : '*NONE*' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Order Notes</th>
|
||||
<td>{{ $o->order_notes ?: '*NONE*' }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<div class="row">
|
||||
<div class="control-group form-group col-sm-12 {{ $errors->has('order_notes') ? 'has-error' : '' }}">
|
||||
<span class="help-block">{{ $errors->first('product_options') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group form-group col-sm-12 {{ $errors->has('order_notes') ? 'has-error' : '' }}">
|
||||
<label for="order_notes">Notes To Supplier/Client</label>
|
||||
<textarea name="order_notes" class="form-control" rows="4" placeholder="APPROVE goes to Supplier, REJECT goes to Client.">{{ old('order_notes') }}</textarea>
|
||||
<span class="help-block">{{ $errors->first('order_notes') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="box-footer">
|
||||
<input class="btn btn-success" type="submit" name="action" value="Approve">
|
||||
<input class="btn btn-danger" type="submit" name="action" value="Reject">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
@ -53,24 +53,30 @@
|
||||
url: "/api/r/service_movements"
|
||||
},
|
||||
columns: [
|
||||
{ data: "service_id_url" },
|
||||
{ data: "account_name" },
|
||||
{ data:
|
||||
@if($user->isWholesaler())
|
||||
"admin_service_id_url"
|
||||
@else
|
||||
"service_id_url"
|
||||
@endif
|
||||
},
|
||||
{ data: "account_name" },
|
||||
{ data: "name" },
|
||||
{ data: "status" },
|
||||
{ data: "status" },
|
||||
{ data: "product_name" }
|
||||
],
|
||||
language: {
|
||||
emptyTable: "No Active Clients"
|
||||
},
|
||||
order: [1, 'asc'],
|
||||
rowGroup: {
|
||||
dataSrc: 'product_name',
|
||||
startRender: null,
|
||||
endRender: function ( rows, group ) {
|
||||
return rows.count()+' x ' + group;
|
||||
},
|
||||
},
|
||||
orderFixed: [4, 'asc']
|
||||
rowGroup: {
|
||||
dataSrc: 'account_name',
|
||||
startRender: null,
|
||||
endRender: function ( rows, group ) {
|
||||
return rows.count()+' x ' + group;
|
||||
},
|
||||
},
|
||||
orderFixed: [4, 'asc']
|
||||
});
|
||||
|
||||
$('#service_movements tbody').on('click','tr', function () {
|
||||
|
@ -0,0 +1,46 @@
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Service Information</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
|
||||
<i class="fa fa-minus"></i></button>
|
||||
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
|
||||
<i class="fa fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box-body">
|
||||
<table class="table table-condensed" width="100%">
|
||||
<tr>
|
||||
<th>Account</th><td>{{ $o->account->company }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Active</th><td>{{ $o->active }} ({{ $o->order_status }})</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Billing Period</th><td>{{ $o->recur_schedule }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Billing Amount</th><td>{{ $o->cost }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Product</th><td>{{ $o->product->name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Last Invoice</th><td>{{ $o->date_last_invoice }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Paid Until</th><td>{{ 'TBA' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Next Invoice</th><td>{{ $o->date_next_invoice }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
{{--
|
||||
<div class="box-footer">
|
||||
</div>
|
||||
--}}
|
||||
</div>
|
@ -219,6 +219,35 @@
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-2"><button class="btn btn-block btn-primary">Previous</button></div>
|
||||
<div class="col-sm-2"><button class="btn btn-block btn-primary next">Next</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Additional Notes -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">Notes</h4>
|
||||
</div>
|
||||
|
||||
<div class="panel-collapse margin-bottom-20">
|
||||
<div class="panel-body">
|
||||
<div class="col-md-12">
|
||||
<div class="control-group form-group col-sm-12 {{ $errors->has('order_notes') ? 'has-error' : '' }}">
|
||||
<span class="help-block">{{ $errors->first('product_options') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group form-group col-sm-12 {{ $errors->has('order_notes') ? 'has-error' : '' }}">
|
||||
<label for="order_notes">Notes</label>
|
||||
<textarea name="order_notes" class="form-control" rows="4" placeholder="Enter any special instructions...">{{ old('order_notes') }}</textarea>
|
||||
<span class="help-block">{{ $errors->first('order_notes') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-2"><button class="btn btn-block btn-primary">Previous</button></div>
|
||||
<div class="col-sm-2 pull-right"><input type="submit" class="btn btn-block btn-primary" value="Submit Order"></div>
|
||||
|
30
resources/views/email/admin/order/approve.blade.php
Normal file
30
resources/views/email/admin/order/approve.blade.php
Normal file
@ -0,0 +1,30 @@
|
||||
@component('mail::message',['site'=>$site])
|
||||
# Please order the following service.
|
||||
|
||||
@component('mail::panel')
|
||||
|
||||
@component('mail::table')
|
||||
| Service | Details |
|
||||
| :---------- | :---------------- |
|
||||
| Account | {{ $service->account_name }} ({!! $service->account->account_id_url !!}) |
|
||||
| Service ID | {!! $service->service_id_url !!} |
|
||||
| Product | {{ $service->product_name }} |
|
||||
@switch($service->category)
|
||||
@case('ADSL')
|
||||
| Address | {{ $service->service_adsl->service_address }} |
|
||||
@break;
|
||||
@case('VOIP')
|
||||
| Address | {{ $service->service_voip->service_address }} |
|
||||
| Supplier Details | {{ join(':',$service->order_info) }} |
|
||||
@break;
|
||||
@endswitch
|
||||
|
||||
@endcomponent
|
||||
|
||||
**NOTES:** {{ $notes }}
|
||||
|
||||
@endcomponent
|
||||
|
||||
Thanks,<br>
|
||||
{{ config('app.name') }}
|
||||
@endcomponent
|
@ -4,4 +4,4 @@
|
||||
<img class="pull-left" src="{{ $logo }}"> <div class="pull-right">{{ $slot }}</div>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
@ -1,8 +1,8 @@
|
||||
@component('mail::layout')
|
||||
{{-- Header --}}
|
||||
@slot('header')
|
||||
@component('mail::header', ['url' => config('app.url'),'logo'=>url($logo)])
|
||||
{{ $site_name }}
|
||||
@component('mail::header', ['url' => config('app.url'),'logo'=>url($site->site_logo)])
|
||||
{{ $site->site_name }}
|
||||
@endcomponent
|
||||
@endslot
|
||||
|
||||
@ -24,4 +24,4 @@
|
||||
© {{ date('Y') }} {{ config('app.name') }}. All rights reserved.
|
||||
@endcomponent
|
||||
@endslot
|
||||
@endcomponent
|
||||
@endcomponent
|
@ -21,6 +21,8 @@ Route::get('image/generic/{width}/{height}/{color}/{name?}','MediaController@ima
|
||||
Route::group(['middleware'=>['theme:adminlte-be','auth','role:wholesaler'],'prefix'=>'a'], function() {
|
||||
Route::get('setup','AdminHomeController@setup');
|
||||
Route::post('setup','AdminHomeController@setup_update');
|
||||
Route::get('service/{o}', 'AdminHomeController@service');
|
||||
Route::post('service/{o}', 'AdminHomeController@service_update');
|
||||
|
||||
//Route::get('accounting/connect', 'AccountingController@connect');
|
||||
});
|
||||
@ -41,6 +43,7 @@ Route::group(['middleware'=>['theme:adminlte-be','auth'],'prefix'=>'u'], functio
|
||||
Route::get('home', 'UserHomeController@home');
|
||||
Route::get('invoice/{o}', 'UserHomeController@invoice');
|
||||
Route::get('invoice/{o}/pdf','UserHomeController@invoice_pdf');
|
||||
Route::get('service/{o}', 'UserHomeController@service');
|
||||
});
|
||||
|
||||
// Frontend Routes (Non-Authed Users)
|
||||
|
Loading…
Reference in New Issue
Block a user