added commision page on reports

This commit is contained in:
franknstayn
2020-02-10 01:16:26 +08:00
parent 5e663d5891
commit 92e7aae7bb
7 changed files with 195 additions and 51 deletions

View File

@@ -1120,4 +1120,12 @@ class AdminController extends Controller
}
public function viewCommission()
{
$AdminModel = new AdminModel;
$array_commission = $AdminModel->selectCommission();
return view('admin_pages.commission')
->with("array_commission", $array_commission);
}
}

View File

@@ -43,6 +43,7 @@ Route::group(['middleware' => 'auth'], function () {
Route::get('overlay-pattern', 'admin\AdminController@overlayPattern');
Route::get('reports', 'admin\AdminController@viewReports');
Route::get('commission', 'admin\AdminController@viewCommission');
Route::get('clipart-add', 'admin\AdminController@addClipart');
Route::get('cliparts', 'admin\AdminController@viewClipart');

View File

@@ -407,4 +407,21 @@ class AdminModel extends Model
return $i;
}
function selectCommission(){
$i = DB::select("SELECT t.StoreName, pd.InvoiceNumber, pd.CartKey, pd.Total, pd.SubTotal, pd.Tax, pd.Currency,
(pd.Total * 0.029) AS proc_fee,
(pd.SubTotal - 0.29) AS trans_rate, ROUND(((
SELECT trans_rate) - (
SELECT proc_fee)), 2) AS commission_rate, ROUND(((
SELECT commission_rate) * 0.25), 2) AS twenty_five_percent, ROUND(((
SELECT commission_rate) * 0.05), 2) AS five_percent
FROM orders AS o
INNER JOIN payment_details AS pd ON pd.CartKey = o.CartKey
INNER JOIN teamstores AS t ON o.StoreId = t.Id
GROUP BY pd.CartKey
ORDER BY o.DateCreated");
return $i;
}
}

View File

@@ -261,10 +261,54 @@ desired effect
});
$('#store_owners_table').DataTable();
$('#tbl_commission').DataTable({
initComplete: function () {
this.api().columns(0).every( function () {
var column = this;
var select = $('<select class="form-control"><option value=""></option></select>')
.appendTo( $('#store_filter').empty() )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' )
} );
} );
},
dom: 'Bfrtip',
buttons: [
{
extend: 'csv',
className : "btn btn-default",
text: "<i class=\"fa fa-table\"></i> CSV",
title : function() {
return "Commission Reports";
}
},
{
extend: 'excel',
className : "btn btn-default",
text: "<i class=\"fa fa-file-excel-o\"></i> Excel",
title : function() {
return "Commission Reports";
}
}
],
});
$.fn.dataTable.ext.search.push(
function (settings, data, dataIndex) {
if (settings.nTable.id !=='tbl_store_orders') {
return true;
}
var min = $('#min').datepicker("getDate");
var max = $('#max').datepicker("getDate");
var startDate = new Date(data[10]);
@@ -273,11 +317,11 @@ desired effect
if(max == null && startDate >= min) {return true;}
if (startDate <= max && startDate >= min) { return true; }
return false;
}
},
);
$("#min").datepicker({ onSelect: function () { table.draw(); }, changeMonth: true, changeYear: true });
$("#max").datepicker({ onSelect: function () { table.draw(); }, changeMonth: true, changeYear: true });
var table = $('#tbl_store_orders').DataTable({
initComplete: function () {
@@ -325,43 +369,17 @@ desired effect
return "ORDER REPORTS";
}
}
//,
// {
// extend: 'pdf',
// exportOptions: {
// columns: [ 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ]
// },
// className : "btn btn-default",
// text: "<i class=\"fa fa-file-pdf-o\"></i> PDF",
// orientation: 'landscape',
// pageSize: 'LEGAL',
// title : function() {
// return "ORDER REPORTS";
// }
// },
// {
// extend: 'print',
// exportOptions: {
// columns: [ 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ]
// },
// className : "btn btn-default",
// text : "<i class=\"fa fa-print\"></i> Print",
// orientation: 'landscape',
// pageSize: 'LEGAL',
// title : function() {
// return "ORDER REPORTS";
// }
// }
],
columnDefs: [
{ targets: 9, type: 'date', visible: false },
{ targets: 9, type: 'date' }
{ targets: 10, type: 'date', visible: false },
{ targets: 10, type: 'date' }
],
});
$("#min").datepicker({ onSelect: function () { table.draw(); }, changeMonth: true, changeYear: true });
$("#max").datepicker({ onSelect: function () { table.draw(); }, changeMonth: true, changeYear: true });
$(document).on('a click', '.btn-order-item-details', function(e){
e.preventDefault();

View File

@@ -72,14 +72,26 @@
<li class="{{ Request::is('admin/orders') ? 'active' : '' }}">
<a href="{{ url('/admin/orders') }}">
<i class="fa fa-list-alt"></i> <span>Orders</span>
<i class="fa fa-list-alt"></i> <span>Print Orders</span>
</a>
</li>
<!-- <li class="active"><a href="#"><i class="fa fa-dashboard"></i> <span>Dashboard</span></a></li> -->
<li class="{{ Request::is('admin/reports') ? 'active' : '' }}">
<!-- <li class="{{ Request::is('admin/reports') ? 'active' : '' }}">
<a href="{{ url('/admin/reports') }}">
<i class="fa fa-line-chart"></i> <span>Reports</span>
</a>
</li> -->
@php $under_reports = array("/admin/reports", "/admin/commission") @endphp
<li class="treeview {{ (in_array($getrequest_url, $under_reports)) ? 'active' : '' }}">
<a href="#"><i class="fa fa-line-chart"></i> <span>Reports</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu">
<li {{ ($getrequest_url == '/admin/reports') ? 'class=active' : '' }}><a href="{{ url('/admin/reports') }}"><i class="fa fa-circle-o"></i> Store Orders</a></li>
<li {{ ($getrequest_url == '/admin/commission') ? 'class=active' : '' }}><a href="{{ url('/admin/commission') }}"><i class="fa fa-circle-o"></i> Commission</a></li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,102 @@
@extends('admin.main')
@section('content')
<style>
.previewImage {
height: 150px;
width: 95%;
overflow: hidden;
object-fit: contain;
}
</style>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Commission
<!-- <small>Optional description</small> -->
</h1>
<ol class="breadcrumb">
<li><a href="{{ url ('admin') }}"><i class="fa fa-dashboard"></i> Dashboard</a></li>
<li class="active"> Reports</li>
<li class="active"> Commission</li>
</ol>
</section>
<!-- Main content -->
<section class="content container-fluid">
<div class="row">
<div class="col-md-12">
<div class="box">
<div class="box-header with-border">
<h4 class="box-title">Commission</h4>
</div>
<div class="box-body">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label class="control-label">Filter By Store</label>
<div id="store_filter"></div>
</div>
</div>
<div class="col-md-12">
<table class="table table-bordered table-condensed nowrap" id="tbl_commission">
<thead>
<tr>
<th>Teamstore</th>
<th>Invoice No.</th>
<th>Total</th>
<th>Subtotal</th>
<th>Tax</th>
<th>Currency</th>
<th>Commission Rate</th>
<th>25%</th>
<th>5%</th>
</tr>
</thead>
<tbody>
@foreach($array_commission as $c)
<tr>
<td>{{ $c->StoreName }}</td>
<td><a href="{{ url('admin/orders/view') . '/' . $c->CartKey }}">{{ $c->InvoiceNumber }}</a></td>
<td>{{ $c->Total }}</td>
<td>{{ $c->SubTotal }}</td>
<td>{{ $c->Tax }}</td>
<td>{{ $c->Currency }}</td>
<td>{{ $c->commission_rate }}</td>
<td>{{ $c->twenty_five_percent }}</td>
<td>{{ $c->five_percent }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- /.content -->
</div>
<div class="modal fade" id="modal_store_order_details" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Order Details</h4>
</div>
<div class="modal-body">
<div id="modal_store_order_details_body_content">
<p> Loading content <i class="fa fa-spinner fa-spin"></i> </p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
@endsection

View File

@@ -23,20 +23,6 @@
</div>
<div class="box-body">
<div class="row">
{{-- <div class="col-md-3">
<div class="form-group">
<label class="control-label">Select Date From: <span class="required">*</span></label>
<input type="text" name="min" class="form-control datepicker-reports" id="min" placeholder="Select Date" required autocomplete="off"/>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label class="control-label">Select Date To: <span class="required">*</span></label>
<input type="text" name="max" class="form-control datepicker-reports" id="max" placeholder="Select Date" required autocomplete="off"/>
</div>
</div>
</div> --}}
<div class="col-md-12">
<div class="table-responsive">
<table id="orders_table" class="table table-bordered table-hover">