Skip to content

Commit 32d0b3f

Browse files
committed
panding order page
1 parent c6b2fbb commit 32d0b3f

8 files changed

+360
-19
lines changed

app/Http/Controllers/CartController.php

+84-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use App\Models\Setting;
77
use Gloudemans\Shoppingcart\Facades\Cart;
88
use Illuminate\Http\Request;
9-
9+
use Illuminate\Support\Facades\DB;
1010

1111
class CartController extends Controller
1212
{
@@ -67,4 +67,87 @@ public function invoice(Request $request){
6767
$customer_info = Customer::find($request->cus_id);
6868
return view('dashbord.Pos.invoice',compact('customer_info','setting'));
6969
}
70+
71+
72+
//order information save in database
73+
public function order_store(Request $request){
74+
75+
76+
if (!empty($request->pay)) {//just check not empty pay fild
77+
78+
$input_amount =$request->pay + $request->due;
79+
$order = Cart::total();
80+
if ($input_amount > $order) {
81+
$notification = array(
82+
'message' => 'Your Payment Amount And Your Order Bill not same',
83+
'alert-type' => 'error'
84+
);
85+
return redirect()->back()->with($notification);
86+
}else{
87+
$data = array();
88+
$data['customar_id'] = $request->customer_id;
89+
$data['order_date'] = date('d/m/y');
90+
$data['order_status'] = 'panding';
91+
$data['total_products'] = Cart::count();
92+
$data['sub_total'] = Cart::subtotal();
93+
$data['vat'] = Cart::tax();//set vat 5%
94+
$data['total'] = Cart::total();
95+
$data['payment_status'] = $request->payment_status;
96+
$data['pay'] = $request->pay;
97+
$data['due'] = $request->due;
98+
99+
$order_id = DB::table('orders')->insertGetId($data);
100+
101+
102+
//right now insert data in orderdetails table
103+
$contant = Cart::content(); //all cart information save this variable
104+
foreach ($contant as $contant_item) {
105+
$order_data = array();
106+
$order_data['order_id'] = $order_id;//same id of orders
107+
$order_data['product_id'] = $contant_item->id;
108+
$order_data['quentity'] = $contant_item->qty;
109+
$order_data['unitcost'] = $contant_item->price;
110+
$order_data['total'] = $contant_item->total;
111+
112+
//insert order data in orderdatils table
113+
$order_insert = DB::table('orderdatils')->insert($order_data);
114+
}
115+
if ($order_insert) {
116+
Cart::destroy();
117+
$notification = array(
118+
'message' => 'Complete order',
119+
'alert-type' => 'info'
120+
);
121+
return redirect()->route('dashboard')->with($notification);
122+
}else{
123+
$notification = array(
124+
'message' => 'Plz try agin',
125+
'alert-type' => 'error'
126+
);
127+
return redirect()->route('dashboard')->with($notification);
128+
}
129+
130+
}
131+
132+
133+
} else {
134+
$notification = array(
135+
'message' => 'Required pay fild',
136+
'alert-type' => 'error'
137+
);
138+
return redirect()->back()->with($notification);
139+
}
140+
141+
}
142+
//panding order
143+
public function panding_order(){
144+
$panding_order = DB::table('orders')
145+
->join('customers','orders.customar_id','customers.id')
146+
->select('customers.name','customers.email','orders.*')
147+
->where('order_status','panding')->get();
148+
return view('dashbord.Order.pandingorder',compact('panding_order'));
149+
}
150+
151+
152+
70153
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('orders', function (Blueprint $table) {
15+
$table->id();
16+
$table->integer('customar_id');
17+
$table->string('order_date');
18+
$table->string('order_status');
19+
$table->string('total_products');
20+
$table->string('sub_total');
21+
$table->string('vat');
22+
$table->string('total');
23+
$table->string('payment_status');
24+
$table->integer('pay');
25+
$table->integer('due')->nullable()->default(0);
26+
$table->timestamps();
27+
});
28+
}
29+
30+
/**
31+
* Reverse the migrations.
32+
*/
33+
public function down(): void
34+
{
35+
Schema::dropIfExists('orders');
36+
}
37+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('orderdatils', function (Blueprint $table) {
15+
$table->id();
16+
$table->integer('order_id');
17+
$table->string('product_id');
18+
$table->string('quentity');
19+
$table->string('unitcost');
20+
$table->string('total');
21+
$table->timestamps();
22+
});
23+
}
24+
25+
/**
26+
* Reverse the migrations.
27+
*/
28+
public function down(): void
29+
{
30+
Schema::dropIfExists('orderdatils');
31+
}
32+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
@include('dashbord.header')
5+
</head>
6+
7+
8+
9+
<body class="fixed-left">
10+
11+
<!-- Begin page -->
12+
<div id="wrapper">
13+
14+
<!-- Top Bar Start -->
15+
@include('dashbord.navbar')
16+
<!-- Top Bar End -->
17+
18+
19+
<!-- ========== Left Sidebar Start ========== -->
20+
@include('dashbord.left_sife_menu')
21+
<!-- Left Sidebar End -->
22+
23+
<!-- ============================================================== -->
24+
<!-- Start right Content here -->
25+
<!-- ============================================================== -->
26+
<div class="content-page">
27+
<!-- Start content -->
28+
<div class="content">
29+
<div class="container">
30+
{{-- <div class="row">
31+
<div class="col-md-12">
32+
<div class="panel panel-default">
33+
<div class="panel-heading">
34+
<h3 class="panel-title">Datatable</h3>
35+
</div>
36+
<div class="panel-body">
37+
<div class="row">
38+
<div class="col-md-12 col-sm-12 col-xs-12">
39+
<div id="datatable_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer"><div class="row"><div class="col-sm-6"><div class="dataTables_length" id="datatable_length"><label>Show <select name="datatable_length" aria-controls="datatable" class="form-control input-sm"><option value="10">10</option><option value="25">25</option><option value="50">50</option><option value="100">100</option></select> entries</label></div></div><div class="col-sm-6"><div id="datatable_filter" class="dataTables_filter"><label>Search:<input type="search" class="form-control input-sm" placeholder="" aria-controls="datatable"></label></div></div></div><div class="row"><div class="col-sm-12"><table id="datatable" class="table table-striped table-bordered dataTable no-footer" role="grid" aria-describedby="datatable_info">
40+
<thead>
41+
<tr role="row">
42+
<th class="sorting_asc" tabindex="0" aria-controls="datatable" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Name: activate to sort column descending" style="width: 127px;">Name</th>
43+
<th class="sorting" tabindex="0" aria-controls="datatable" rowspan="1" colspan="1" aria-label="Position: activate to sort column ascending" style="width: 190px;">Qty</th>
44+
<th class="sorting" tabindex="0" aria-controls="datatable" rowspan="1" colspan="1" aria-label="Office: activate to sort column ascending" style="width: 112px;">Total</th>
45+
<th class="sorting" tabindex="0" aria-controls="datatable" rowspan="1" colspan="1" aria-label="Age: activate to sort column ascending" style="width: 86px;">Order Status</th>
46+
<th class="sorting" tabindex="0" aria-controls="datatable" rowspan="1" colspan="1" aria-label="Start date: activate to sort column ascending" style="width: 164px;">Order Date</th>
47+
<th class="sorting" tabindex="0" aria-controls="datatable" rowspan="1" colspan="1" aria-label="Start date: activate to sort column ascending" style="width: 164px;">Payment Status</th>
48+
49+
<th class="sorting" tabindex="0" aria-controls="datatable" rowspan="1" colspan="1" aria-label="Salary: activate to sort column ascending" style="width: 116px;">Action</th></tr>
50+
</thead>
51+
52+
53+
<tbody>
54+
55+
@foreach ($panding_order as $order_info)
56+
<tr role="row" class="odd">
57+
<td >{{ $order_info->name }}</td>
58+
<td>{{ $order_info->total_products }}</td>
59+
<td>{{ $order_info->total }}</td>
60+
<td>{{ $order_info->order_status }}</td>
61+
<td>{{ $order_info->order_date }}</td>
62+
<td>{{ $order_info->payment_status }}</td>
63+
<td>
64+
<button> view</button>
65+
</td>
66+
</tr>
67+
@endforeach
68+
69+
70+
</tbody>
71+
</table></div></div><div class="row"><div class="col-sm-6"><div class="dataTables_info" id="datatable_info" role="status" aria-live="polite">Showing 1 to 1 of 1 entries</div></div><div class="col-sm-6"><div class="dataTables_paginate paging_simple_numbers" id="datatable_paginate"><ul class="pagination"><li class="paginate_button previous disabled" aria-controls="datatable" tabindex="0" id="datatable_previous"><a href="#">Previous</a></li><li class="paginate_button active" aria-controls="datatable" tabindex="0"><a href="#">1</a></li><li class="paginate_button next disabled" aria-controls="datatable" tabindex="0" id="datatable_next"><a href="#">Next</a></li></ul></div></div></div></div>
72+
73+
</div>
74+
</div>
75+
</div>
76+
</div>
77+
</div>
78+
79+
</div> --}}
80+
</div>
81+
82+
</div> <!-- content -->
83+
<footer class="footer text-right">
84+
2015 © Moltran.
85+
</footer>
86+
</div>
87+
<!-- ============================================================== -->
88+
<!-- End Right content here -->
89+
90+
<!-- ============================================================== -->
91+
<!-- Right Sidebar -->
92+
@include('dashbord.right_slider')
93+
<!-- /Right-bar -->
94+
95+
</div>
96+
97+
<!-- END wrapper -->
98+
@include('dashbord.script')<!--script link-->
99+
<!-- COPY TO JAVASCRIPT SECTION -->
100+
<script type="text/javascript">
101+
function readURL(input) {
102+
if (input.files && input.files[0]) {
103+
var reader = new FileReader();
104+
reader.onload = function(e) {
105+
$('#image')
106+
.attr('src', e.target.result);
107+
};
108+
reader.readAsDataURL(input.files[0]);
109+
}
110+
}
111+
112+
</script>
113+
</body>
114+
</html>

resources/views/dashbord/Pos/index.blade.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@
9191
<span>Price : {{ Cart::subtotal(); }}</span><br>
9292
<span>Vat : {{ Cart::tax(); }} (5%)</span><br>
9393
<span>Total Price : {{ Cart::total(); }}</span><br>
94-
95-
94+
95+
9696

9797
</div>
98-
99-
98+
99+
100100
</div>
101-
<form action="{{ route('cart.invoice') }}" method="post">
101+
<form action="{{ route('cart.invoice') }}" method="POST" enctype="multipart/form-data">
102102
@csrf
103103
<div class="row">
104104
@if ($errors->any())
@@ -118,15 +118,15 @@
118118
@endforeach
119119
</select>
120120
</div>
121-
121+
122122
<button class="btn btn-primary waves-effect waves-light" data-toggle="modal" data-target="#custom-width-modal">Add Cusstomer</button>
123-
123+
124124
</div>
125125
<button type="submit" class="btn btn-danger waves-effect waves-light" style="margin-left: 40%;margin-top: 5%;margin-bottom: 2%;">Invoice</button>
126126
</form>
127127

128128
</div>
129-
129+
130130
</div>
131131
<!-- sample modal content -->
132132
<div id="custom-width-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="custom-width-modalLabel" aria-hidden="true" style="display: none;">
@@ -229,7 +229,7 @@
229229
@foreach ($product as $item)
230230

231231
<tr>
232-
<form action="{{ route('add.cart') }}" method="post" enctype="multipart/form-data">
232+
<form action="{{ route('add.cart') }}" method="POST">
233233
@csrf
234234
<input type="hidden" name="id" value="{{ $item->id }}">
235235
<input type="hidden" name="name" value="{{ $item->product_name }}">

0 commit comments

Comments
 (0)