Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
onestartup-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Angel Martin
onestartup-shop
Commits
6e5a34af
Commit
6e5a34af
authored
Jun 01, 2018
by
Angel MAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
view stock
parent
6ce8c3a5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
154 additions
and
0 deletions
+154
-0
AdminProductController.php
src/controllers/AdminProductController.php
+8
-0
StockDataTable.php
src/lib/StockDataTable.php
+108
-0
routes.php
src/routes.php
+5
-0
stock.blade.php
src/views/product/stock.blade.php
+33
-0
No files found.
src/controllers/AdminProductController.php
View file @
6e5a34af
...
...
@@ -11,8 +11,11 @@ use Onestartup\Shop\Model\ProductImageShop as Gallery;
use
Onestartup\Shop\Model\ProductShop
as
Product
;
use
Onestartup\Shop\Model\ExtraField
as
Extra
;
use
Onestartup\Shop\Model\ProductShopInfo
as
ProductInfo
;
use
Onestartup\Shop\DataTables\ClientDataTable
;
use
Onestartup\Shop\DataTables\OrderDataTable
;
use
Onestartup\Shop\DataTables\StockDataTable
;
use
Onestartup\Shop\Model\SaleShop
as
Sale
;
use
Onestartup\Shop\Model\OrderTracking
as
Tracking
;
use
Onestartup\Shop\Libs\Util
;
...
...
@@ -269,6 +272,11 @@ class AdminProductController extends Controller
return
$dataTable
->
render
(
'shop::clients.orders'
);
}
public
function
stock
(
StockDataTable
$dataTable
)
{
return
$dataTable
->
render
(
'shop::product.stock'
);
}
public
function
showOrder
(
$id
)
{
$sale
=
Sale
::
find
(
$id
);
...
...
src/lib/StockDataTable.php
0 → 100644
View file @
6e5a34af
<?php
namespace
Onestartup\Shop\DataTables
;
use
Onestartup\Shop\Model\ProductShop
as
Product
;
use
Yajra\DataTables\Services\DataTable
;
class
StockDataTable
extends
DataTable
{
/**
* Build DataTable class.
*
* @param mixed $query Results from query() method.
* @return \Yajra\DataTables\DataTableAbstract
*/
public
function
dataTable
(
$query
)
{
return
datatables
(
$query
)
->
addColumn
(
'producto'
,
function
(
Product
$product
)
{
return
'Nombre: <b>'
.
$product
->
name
.
'</b>'
.
'<br>Resumen: <b>'
.
$product
->
description
.
'</b>'
.
'<br>Fecha de publicación: <b>'
.
$product
->
publication_date
.
'</b>'
;
})
->
addColumn
(
'informacion_venta'
,
function
(
Product
$product
)
{
$html
=
""
;
$existencia
=
""
;
if
(
$product
->
infoSale
->
quantity
<=
$product
->
infoSale
->
reserve_amount
)
{
$existencia
=
"<span class='badge danger'>"
.
$product
->
infoSale
->
quantity
.
"</span>"
;
}
else
{
$existencia
=
"<span class='badge primary'>"
.
$product
->
infoSale
->
quantity
.
"</span>"
;
}
$html
=
"Precio venta: <b>"
.
$product
->
infoSale
->
sale_price
.
"</b><br>Precio compra: <b>"
.
$product
->
infoSale
->
purchase_price
.
"</b> <br>Existencias:
$existencia
<br>"
;
return
$html
;
})
->
addColumn
(
'action'
,
function
(
Product
$product
){
return
"<a href='"
.
route
(
'admin.shop.product.edit'
,
$product
->
id
)
.
"'>Editar <i class='fa fa-edit'></i></a>"
;
})
->
filterColumn
(
'producto'
,
function
(
$query
,
$keyword
)
{
$query
->
whereRaw
(
"name like ?"
,
[
"%
{
$keyword
}
%"
]);
})
->
rawColumns
([
'producto'
,
'action'
,
'informacion_venta'
]);
}
/**
* Get query source of dataTable.
*
* @param \App\Interested $model
* @return \Illuminate\Database\Eloquent\Builder
*/
public
function
query
(
Product
$model
)
{
return
$model
->
select
([
'id'
,
'name'
,
'slug'
,
'description'
,
'active'
,
'publication_date'
,
'category_id'
])
->
where
(
'active'
,
true
)
->
orderBy
(
'publication_date'
,
'desc'
);
}
/**
* Optional method if you want to use html builder.
*
* @return \Yajra\DataTables\Html\Builder
*/
public
function
html
()
{
return
$this
->
builder
()
->
columns
(
$this
->
getColumns
())
->
parameters
([
'dom'
=>
'Bfrtip'
,
'pageLength'
=>
20
,
'buttons'
=>
[
'excel'
,
'csv'
,
'reset'
,
'reload'
],
]);
}
/**
* Get columns.
*
* @return array
*/
protected
function
getColumns
()
{
return
[
'id'
,
'producto'
,
'informacion_venta'
,
'action'
];
}
/**
* Get filename for export.
*
* @return string
*/
protected
function
filename
()
{
return
'orders'
.
date
(
'YmdHis'
);
}
}
src/routes.php
View file @
6e5a34af
...
...
@@ -65,6 +65,11 @@ Route::group(['middleware' => ['web', 'auth', 'is_admin']], function(){
'Onestartup\Shop\Controller\AdminProductController@trackingStore'
)
->
name
(
'admin-shop-client.trackingStore'
);
Route
::
get
(
'admin/shop/stock'
,
'Onestartup\Shop\Controller\AdminProductController@stock'
)
->
name
(
'admin-shop-client.stock'
);
});
...
...
src/views/product/stock.blade.php
0 → 100644
View file @
6e5a34af
@
extends
(
'crm-admin::main-layout'
)
@
section
(
'content'
)
<
div
class
="
row
">
<div class="
col
-
md
-
12
">
<div class="
box
">
<div class="
box
-
header
dark
">
<h2>Listado de existencias de productos</h2>
</div>
<div class="
box
-
body
">
<div class='table-responsive'>
{!!
$dataTable->table
() !!}
</div>
</div>
<div class="
dker
p
-
a
text
-
right
">
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<link rel="
stylesheet
" href="
https
://
cdn
.
datatables
.
net
/
buttons
/
1.0
.
3
/
css
/
buttons
.
dataTables
.
min
.
css
">
<script src="
https
://
cdn
.
datatables
.
net
/
buttons
/
1.0
.
3
/
js
/
dataTables
.
buttons
.
min
.
js
"></script>
<script src="
/
vendor
/
datatables
/
buttons
.
server
-
side
.
js
"></script>
{!!
$dataTable->scripts
() !!}
@endpush
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment