diff --git a/app/Http/Controllers/admin/AdminController.php b/app/Http/Controllers/admin/AdminController.php index 0dc5685..703a2fc 100644 --- a/app/Http/Controllers/admin/AdminController.php +++ b/app/Http/Controllers/admin/AdminController.php @@ -1118,6 +1118,14 @@ class AdminController extends Controller )); } - + + + public function viewCommission() + { + $AdminModel = new AdminModel; + $array_commission = $AdminModel->selectCommission(); + return view('admin_pages.commission') + ->with("array_commission", $array_commission); + } } \ No newline at end of file diff --git a/app/Http/routes.php b/app/Http/routes.php index 4101b5d..ba933a5 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -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'); diff --git a/app/Models/admin/AdminModel.php b/app/Models/admin/AdminModel.php index c59a3fb..d7fc29b 100644 --- a/app/Models/admin/AdminModel.php +++ b/app/Models/admin/AdminModel.php @@ -406,5 +406,22 @@ class AdminModel extends Model ->update($data); 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; + } } diff --git a/resources/views/admin/main.blade.php b/resources/views/admin/main.blade.php index 2324999..ca27bef 100644 --- a/resources/views/admin/main.blade.php +++ b/resources/views/admin/main.blade.php @@ -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 = $('') + .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( '' ) + } ); + } ); + }, + dom: 'Bfrtip', + buttons: [ + { + extend: 'csv', + className : "btn btn-default", + text: " CSV", + title : function() { + return "Commission Reports"; + } + }, + { + extend: 'excel', + className : "btn btn-default", + text: " 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,42 +369,16 @@ 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: " 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 : " 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){ diff --git a/resources/views/admin/sidebar.blade.php b/resources/views/admin/sidebar.blade.php index 473a0f4..2919998 100644 --- a/resources/views/admin/sidebar.blade.php +++ b/resources/views/admin/sidebar.blade.php @@ -72,14 +72,26 @@
| Teamstore | +Invoice No. | +Total | +Subtotal | +Tax | +Currency | +Commission Rate | +25% | +5% | +
|---|---|---|---|---|---|---|---|---|
| {{ $c->StoreName }} | +{{ $c->InvoiceNumber }} | +{{ $c->Total }} | +{{ $c->SubTotal }} | +{{ $c->Tax }} | +{{ $c->Currency }} | +{{ $c->commission_rate }} | +{{ $c->twenty_five_percent }} | +{{ $c->five_percent }} | +