Moved out rejected orders

This commit is contained in:
Deon George 2018-11-21 13:46:16 +11:00
parent aeacb726dd
commit 72fcdab84e
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
8 changed files with 139 additions and 4 deletions

View File

@ -21,6 +21,11 @@ class ResellerServicesController extends Controller
return ['data'=>Auth::user()->all_clients()->values()];
}
public function service_inactive()
{
return ['data'=>Auth::user()->all_client_service_inactive()->values()];
}
public function service_movements()
{
return ['data'=>Auth::user()->all_client_service_movements()->values()];

View File

@ -49,6 +49,7 @@ class Service extends Model
private $inactive_status = [
'CANCELLED',
'ORDER-REJECTED',
];
public function account()
@ -96,6 +97,19 @@ class Service extends Model
return $this->belongsTo(Product::class);
}
/**
* Find inactive services.
*
* @param $query
* @return mixed
*/
public function scopeInActive($query)
{
return $query->where(function () use ($query) {
return $query->where('active',FALSE)->orWhereIn('order_status',$this->inactive_status);
});
}
/**
* Only query active categories
*/
@ -118,7 +132,8 @@ class Service extends Model
public function getCategoryAttribute()
{
return $this->product->category;
// @todo: All services should be linked to a product. This might require data cleaning for old services not linked to a product.
return is_object($this->product) ? $this->product->category : 'Unknown Product';
}
public function getNameAttribute()
@ -136,7 +151,8 @@ class Service extends Model
public function getProductNameAttribute()
{
return $this->product->name($this->account->language);
// @todo: All services should be linked to a product. This might require data cleaning for old services not linked to a product.
return is_object($this->product) ? $this->product->name($this->account->language) : 'Unknown Product';
}
public function getServiceExpireAttribute()
@ -197,6 +213,10 @@ class Service extends Model
*/
private function ServicePlugin()
{
// @todo: All services should be linked to a product. This might require data cleaning for old services not linked to a product.
if (! is_object($this->product))
return NULL;
switch ($this->product->prod_plugin_file)
{
case 'ADSL': return $this->service_adsl;

View File

@ -246,6 +246,16 @@ class User extends Authenticatable
return $result->flatten();
}
public function all_client_service_inactive()
{
$s = Service::InActive();
$aa = $this->all_accounts()->pluck('id')->unique()->toArray();
return $s->get()->filter(function($item) use ($aa) {
return in_array($item->account_id,$aa);
});
}
public function all_client_service_movements()
{
$s = Service::active()->where('order_status','!=','ACTIVE');

View File

@ -52,6 +52,9 @@
<div class="col-xs-6">
@include('r.agents')
</div>
<div class="col-xs-6">
@include('r.service_inactive')
</div>
{{--
<div class="col-xs-6">
@include('r.clients')

View File

@ -0,0 +1,87 @@
<div class="box box-warning">
<div class="box-header">
<h3 class="box-title">Services Inactive</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">
@if ($user->all_client_service_inactive()->count())
<table class="table table-bordered table-striped table-hover" id="service_inactive" style="width: 100%;">
<thead>
<tr>
<th>ID</th>
<th>Account</th>
<th>Name</th>
<th>Status</th>
<th>Product</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Count {{ $user->all_client_service_inactive()->count() }}</th>
<th colspan="4">&nbsp;</th>
</tr>
</tfoot>
</table>
@else
<p>No Inactive Services</p>
@endif
</div>
</div>
@section('page-scripts')
@css('https://cdn.datatables.net/responsive/2.2.1/css/responsive.dataTables.min.css')
@css('https://cdn.datatables.net/rowgroup/1.0.2/css/rowGroup.dataTables.min.css')
@js('https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js')
@js('https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js')
<style>
table.dataTable td {
outline: none;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$('#service_inactive').DataTable( {
responsive: true,
ajax: {
url: "/api/r/service_inactive"
},
columns: [
{ data:
@if($user->isWholesaler())
"admin_service_id_url"
@else
"service_id_url"
@endif
},
{ data: "account_name" },
{ data: "name" },
{ data: "status" },
{ data: "product_name" }
],
language: {
emptyTable: "No InActive Services"
},
order: [3, 'asc'],
rowGroup: {
dataSrc: 'account_name',
startRender: null,
endRender: function ( rows, group ) {
return rows.count()+' x ' + group;
},
},
orderFixed: [1, 'asc']
});
$('#service_movements tbody').on('click','tr', function () {
$(this).toggleClass('selected');
});
});
</script>
@append

View File

@ -66,7 +66,7 @@
{ data: "product_name" }
],
language: {
emptyTable: "No Active Clients"
emptyTable: "No Service Movements"
},
order: [3, 'asc'],
rowGroup: {

View File

@ -2,5 +2,14 @@
<li class="header"><b>MENU</b></li>
<!-- Optionally, you can add icons to the links -->
<li @if(Route::current()->getName() == 'home')class="active"@endif><a href="{{ url('home') }}"><i class='fa fa-link'></i> <span>{{ trans('adminlte_lang::message.home') }}</span></a></li>
<li @if(Route::current()->getName() == 'order')class="active"@endif><a href="{{ url('order') }}"><i class='fa fa-shopping-cart'></i> <span>Order</span></a></li>
<li class="@if(Route::current()->getName() == 'order') active @endif treeview">
<a href="#">
<i class='fa fa-shopping-cart'></i> <span>Order</span>
<span class="pull-right-container"><i class="fa fa-angle-left pull-right"></i></span>
</a>
<ul class="treeview-menu">
<li><a href="{{ url('order') }}"><i class="fa fa-circle-o"></i> New Order</a></li>
{{-- <li><a href="{{ url('u/order/rejected') }}"><i class="fa fa-circle-o"></i> Rejected Orders</a></li> --}}
</ul>
</li>
</ul>

View File

@ -24,6 +24,7 @@ Route::group(['middleware'=>['auth:api','role:reseller']], function() {
Route::get('/r/accounts','ResellerServicesController@accounts');
Route::get('/r/clients','ResellerServicesController@clients');
Route::get('/r/service_movements','ResellerServicesController@service_movements');
Route::get('/r/service_inactive','ResellerServicesController@service_inactive');
});
Route::group(['middleware'=>'auth:api'], function() {