Skip to content

Commit

Permalink
complite purchase section
Browse files Browse the repository at this point in the history
  • Loading branch information
rsayed007 committed Sep 7, 2020
1 parent 4afa694 commit 9fd5c72
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 20 deletions.
4 changes: 0 additions & 4 deletions app/Http/Controllers/Admin/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function ProductStore(Request $request){
'created_by' => 'required',
'supplier_id' => 'required',
'category_id' => 'required',
'quantity' => 'required',
'unit_id' => 'required',
'status' => 'required',
]);
Expand All @@ -41,7 +40,6 @@ public function ProductStore(Request $request){
$product->created_by = $request->created_by;
$product->supplier_id = $request->supplier_id;
$product->category_id = $request->category_id;
$product->quantity = $request->quantity;
$product->unit_id = $request->unit_id;
$product->status = $request->status;

Expand Down Expand Up @@ -80,7 +78,6 @@ public function ProductUpdate( Request $request, $id){
'updated_by' => 'required',
'supplier_id' => 'required',
'category_id' => 'required',
'quantity' => 'required',
'unit_id' => 'required',
'status' => 'required',
]);
Expand All @@ -90,7 +87,6 @@ public function ProductUpdate( Request $request, $id){
$product->updated_by = $request->updated_by;
$product->supplier_id = $request->supplier_id;
$product->category_id = $request->category_id;
$product->quantity = $request->quantity;
$product->unit_id = $request->unit_id;
$product->status = $request->status;
$product->created_at = Carbon::now();
Expand Down
21 changes: 21 additions & 0 deletions app/Http/Controllers/Admin/PurchaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,25 @@ public function PurchaseUpdate( Request $request, $id){

return redirect()->route('purchase-list')->with('status','Purchase successfully updated');
}

public function PurchasePending()
{
$pending_data = Purchase::orderBy('date','desc')->orderBy('id','desc')->where('status','0')->get();
return \view('admin.purchase.pending_list', \compact('pending_data'));
}

public function PendingApprove($id)
{
$purchase_item = Purchase::findOrFail($id);
$product = Product::where('id',$purchase_item->product_id)->update([
'quantity' =>$purchase_item->buying_qut
]);
if ($product) {
Purchase::findOrFail($id)->update([
'status' => '1'
]);
}

return redirect()->back()->with('status','product approved');
}
}
2 changes: 2 additions & 0 deletions app/Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
class Purchase extends Model
{

protected $fillable = ['status'];

public function Supplier_Purchase(){
return $this->belongsTo(Supplier::class,'supplier_id','id') ;
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/category/category_list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<td> {!! ($category->status==1)? '<span class=" badge-success badge-pill">active</span>':'<span class="badge-danger badge-pill">disable</span>' !!}</td>
<td>
<a href="{{route('category-edit',$category->id)}}"> <span class="btn btn-sm btn-info" >Edit</span> </a>
<a href="{{route('category-delete',$category->id)}}"> <span class="btn btn-sm btn-danger" >Delete</span></a>
{{-- <a href="{{route('category-delete',$category->id)}}"> <span class="btn btn-sm btn-danger" >Delete</span></a> --}}
</td>
</tr>
@endforeach
Expand Down
5 changes: 3 additions & 2 deletions resources/views/admin/layouts/sidebar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@
<div id="purchase" class="collapse" aria-labelledby="purchase" data-parent="#accordionSidebar">
<div class="bg-white py-2 collapse-inner rounded">
<h6 class="collapse-header">Purchases Components:</h6>
<a class="collapse-item" href="{{route('purchase-add')}}"> Add</a>
<a class="collapse-item" href="{{route('purchase-list')}}"> List</a>
<a class="collapse-item" href="{{route('purchase-add')}}">Add</a>
<a class="collapse-item" href="{{route('purchase-list')}}">List</a>
<a class="collapse-item" href="{{route('purchase-pending-list')}}">Pending List</a>
</div>
</div>
</li>
Expand Down
8 changes: 4 additions & 4 deletions resources/views/admin/product/product_add.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

<div class="row">

<div class="col-md-4" >
<div class="col-md-6" >
<div class="form-group">
<label for="">Category:</label>
<select required class="form-control" name="category_id" id="category_id" value="{{old('category_id')}}">
Expand All @@ -75,14 +75,14 @@
</div>
</div>

<div class="col-md-4" >
{{-- <div class="col-md-4" >
<div class="form-group">
<label for="">Quantity:</label>
<input type="number" required class="form-control" placeholder="Product quantity" value="{{old('quantity')}}" id="quantity" name="quantity">
</div>
</div>
</div> --}}

<div class="col-md-4" >
<div class="col-md-6" >
<div class="form-group">
<label for="">Unit:</label>
<select required class="form-control" name="unit_id" id="unit_id" value="{{old('unit_id')}}">
Expand Down
8 changes: 4 additions & 4 deletions resources/views/admin/product/product_edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

<div class="row">

<div class="col-md-4" >
<div class="col-md-6" >
<div class="form-group">

<label for="">Category:</label>
Expand All @@ -72,15 +72,15 @@
</select>
</div>
</div>

{{--
<div class="col-md-4" >
<div class="form-group">
<label for="">Quantity:</label>
<input type="number" required class="form-control" placeholder="Product quantity" value="{{$product->quantity}}" id="quantity" name="quantity">
</div>
</div>
</div> --}}

<div class="col-md-4" >
<div class="col-md-6" >
<div class="form-group">
<label for="">Unit:</label>
<select required class="form-control" name="unit_id" id="unit_id" value="{{old('unit_id')}}">
Expand Down
97 changes: 97 additions & 0 deletions resources/views/admin/purchase/pending_list.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
@extends('admin/app')


@push('scripts')
<link href="{{asset('admin/vendor/datatables/dataTables.bootstrap4.min.css')}}" >
@endpush


@section('main_content')

<div class="container-fluid">

<!-- Page Heading -->
<h1 class="h3 mb-2 text-gray-800">Purchase List</h1>
<p class="mb-4"></p>

<!-- DataTales Example -->
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">DataTables Example</h6>
</div>

@if (session('status'))
<div class="alert alert-success text-center">
{{ session('status')}}
</div>
@endif

<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>Purchase No</th>
<th>Date</th>
<th>Product Name</th>
<th>Supplier</th>
<th>Quentity</th>
<th>Price</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Purchase No</th>
<th>Date</th>
<th>Product Name</th>
<th>Supplier</th>
<th>Quentity</th>
<th>Price</th>
<th>Status</th>
<th>Action</th>
</tr>
</tfoot>

<tbody>
@foreach ($pending_data as $purchase)

<tr>
<td>{{$purchase->purchase_id}}</td>
<td>{{$purchase->date}}</td>
<td>{{$purchase->Product_Purchase->name}}</td>

<td>{{$purchase->Supplier_Purchase->name}}</td>
<td>{{$purchase->buying_qut}}
<span class=" badge-success text-xs badge-pill">{{$purchase->Product_Purchase->Unit_Product->name}}</span>
</td>
<td>{{$purchase->buying_price}}</td>
<td> {!! ($purchase->status==1)? '<span class=" badge-success badge-pill">active</span>':'<span class="badge-danger badge-pill">pending</span>' !!}</td>
<td>
<a href="{{route('purchase-approve',$purchase->id)}}"> <span class="btn btn-sm btn-info" >Approve</span></a>
</td>
</tr>
@endforeach

</tbody>
</table>
</div>
</div>
</div>

</div>

@endsection

@push('scripts')

<script src="{{asset('admin/vendor/jquery/jquery.min.js')}}"></script>

<!-- Page level plugins -->
<script src="{{asset('admin/vendor/datatables/jquery.dataTables.min.js')}}"></script>
<script src="{{asset('admin/vendor/datatables/dataTables.bootstrap4.min.js')}}"></script>

<!-- Page level custom scripts -->
<script src="{{asset('admin/js/demo/datatables-demo.js')}}"></script>
@endpush
8 changes: 6 additions & 2 deletions resources/views/admin/purchase/purchase_list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@
<td>{{$purchase->buying_price}}</td>
<td> {!! ($purchase->status==1)? '<span class=" badge-success badge-pill">active</span>':'<span class="badge-danger badge-pill">pending</span>' !!}</td>
<td>
<a href="{{route('purchase-edit',$purchase->id)}}"> <span class="btn btn-sm btn-info" >Edit</span> </a>
<a href="{{route('purchase-delete',$purchase->id)}}"> <span class="btn btn-sm btn-danger" >Delete</span></a>
@if ($purchase->status==0)
<a disable href="{{route('purchase-delete',$purchase->id)}}"> <span class="btn btn-sm btn-danger" >Delete</span></a>
@else
<a disable > <span class="btn btn-sm btn-success" >Approved</span></a>

@endif
</td>
</tr>
@endforeach
Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/supplier/supplier_list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<td> {!! ($supplier->status==1)? '<span class=" badge-success badge-pill">active</span>':'<span class="badge-danger badge-pill">disable</span>' !!}</td>
<td>
<a href="{{route('supplier-edit',$supplier->id)}}"> <span class="btn btn-sm btn-info" >Edit</span> </a>
<a href="{{route('supplier-delete',$supplier->id)}}"> <span class="btn btn-sm btn-danger" >Delete</span></a>
{{-- <a href="{{route('supplier-delete',$supplier->id)}}"> <span class="btn btn-sm btn-danger" >Delete</span></a> --}}

</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/unit/unit_list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<td> {!! ($unit->status==1)? '<span class=" badge-success badge-pill">active</span>':'<span class="badge-danger badge-pill">disable</span>' !!}</td>
<td>
<a href="{{route('unit-edit',$unit->id)}}"> <span class="btn btn-sm btn-info" >Edit</span> </a>
<a href="{{route('unit-delete',$unit->id)}}"> <span class="btn btn-sm btn-danger" >Delete</span></a>
{{-- <a href="{{route('unit-delete',$unit->id)}}"> <span class="btn btn-sm btn-danger" >Delete</span></a> --}}
</td>
</tr>
@endforeach
Expand Down
4 changes: 3 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@
Route::get('/add', 'Admin\PurchaseController@PurchaseAdd')->name('purchase-add');
Route::post('/store', 'Admin\PurchaseController@PurchaseStore')->name('purchase-store');
Route::get('/delete/{id}', 'Admin\PurchaseController@PurchaseDelete')->name('purchase-delete');
Route::get('/edit/{id}', 'Admin\PurchaseController@PurchaseEdit')->name('purchase-edit');
Route::get('/pending/list', 'Admin\PurchaseController@PurchasePending')->name('purchase-pending-list');
Route::get('/pending/{id}', 'Admin\PurchaseController@PendingApprove')->name('purchase-approve');

Route::post('/update/{id}', 'Admin\PurchaseController@PurchaseUpdate')->name('purchase-update');

});
Expand Down

0 comments on commit 9fd5c72

Please sign in to comment.