<?php $this->load->view('home/header');?>
<section class="user-dashboard">
<div class="container-lg">
<div class="row g-3 g-xl-4 tab-wrap">
<div class="col-lg-4 col-xl-3 sticky">
<?php $this->load->view('home/sidebar');?>
</div>
<div class="col-lg-8 col-xl-9">
<div class="right-content tab-content" id="myTabContent">
<?php
$delivery_charges=$shipping_charge=0;
$this->db->order_by('id','desc');
$query = $this->db->get('settings');
if($query->num_rows()>0){
foreach($query->result() as $rw){
$delivery_charges=$rw->cod_amt;
$shipping_charge=$rw->shipping_amt;
}
}
?>
<table class="table table-border table-responsive" style="width:100%;">
<tr>
<td>S.No</td>
<td>Order No.</td>
<td>Total Amount</td>
<td>Status</td>
<td>Payment Mode</td>
<td>Action</td>
</tr>
<?php
$iii=0;
if($order_res==true){
foreach($order_res as $row){
$can_btn = $edit_btn= $rep_btn="";
$iii++;
$view_btn =' <a style="color:#000;" href="'.base_url('home/veiw_order/'.$row->id).'" title="View Order" id="'.$row->id.'"><i class="fa fa-eye"></i></a> ';
if($row->order_staus=='Processing'){
$can_btn =' <span class="btn_return" title="Cancel Order" order_phone="'.$row->mobile.'" order_id="'.$row->order_no.'" id="'.$row->id.'"><i class="fa fa-trash"></i></a> ';
}
if($row->order_staus=='Completed'){
$rep_btn =' <span class="repeat-order" order_id="'.$row->order_no.'" id="'.$row->id.'"><i class="fa fa-plus"></i></a> ';
}
echo "<tr>";
echo "<td>$iii</td>";
echo "<td>$row->order_no</td>";
echo "<td><i class='fa fa-rupee-sign'></i> $row->order_price</td>";
echo "<td>$row->order_staus</td>";
echo "<td>$row->payment_method</td>";
echo "<td>$view_btn $can_btn $rep_btn</td>";
echo "</tr>";
// echo $this->db->last_query();
$res = $this->Curd->fetch_where("tb_sub_order",array("*"),array("order_no"=>$row->order_no));
if($res==true){
foreach($res as $o_row){
}
}
}
}
echo " </table>";
if(!$order_res){
?>
<div class="account-user-right m-order">
<div class="row">
<div class="col-md-12 text-center">
<div class="notfound-product">
<img src="<?=base_url('assets/images/bag.png')?>" width="200">
<p>Item not available in your order !</p>
<a href="#" class="shadow">Continue Shopping</a>
</div>
</div>
</div>
</div>
<?php }?>
</div>
</div>
</section>
<div class="dialog-popup" id="cancel-box" style="display: none;">
<div class="dialog-box">
<div class="dialog-content">
<div class="dialog-header position-relative">
<h4>Cancel Reason</h4>
<button class="btn-close">×</button>
<span id="user_login_msg"></span>
</div>
<div class="dialog-body">
<div class="login-input">
<input type="hidden" name="cancel_id" id="cancel_id">
<textarea type="text" placeholder="Enter description" class="form-control" id="description"></textarea>
<p class="text-danger m-0 text-left desc_err"></p>
</div>
<div class="login-input mb-0">
<button class="btn btn-login shadow mb-4 pass-show" id="cancel_btn">Confirm</button>
</div>
</div>
</div>
</div>
</div>
<?php $this->load->view('home/footer');?>
<script>
$(".repeat-order_old").click(function(){
var id= $(this).attr("id");
var product_id = $(this).attr("product_id");
var product_weight = $(this).attr("product_weight");
var product_qty = $(this).attr("product_qty");
var delivery_charges = $(this).attr("delivery_charges");
if(id!=""){
$.ajax({
method:"post",
dataType :"json",
url:"<?=base_url('home/repeat_to_cart')?>",
data:{"product_qty":product_qty,"delivery_charges":delivery_charges,"product_id":product_id,"product_weight":product_weight},
success:function(res){
if(res.status==1){
$(".total_count").html(res.total_cart);
alert(res.msg);
window.location.href='<?=base_url("home/cart")?>';
}else if(res.status==2){
alert(res.msg);
window.location.href='<?=base_url("home/cart")?>';
} else if(res.status==0){
alert("Internal Problem");
return false;
}
}
})
}
});
$(".repeat-order").click(function(){
var id= $(this).attr("id");
var order_id = $(this).attr("order_id");
if(id!=""){
$.ajax({
method:"post",
dataType :"json",
url:"<?=base_url('home/repeat_order_to_cart')?>",
data:{"order_id":order_id,"id":id},
success:function(res){
if(res.status==1){
$(".total_count").html(res.total_cart);
alert(res.msg);
window.location.href='<?=base_url("home/cart")?>';
}else if(res.status==2){
alert(res.msg);
window.location.href='<?=base_url("home/cart")?>';
} else if(res.status==0){
alert("Internal Problem");
return false;
}
}
})
}
});
// function repeat_order(){
// var order_id =$(this).data("id");
// // var order_id = $(this).attr("#data-id");
// alert("Test"+order_id);
// }
jQuery(document).ready(function () {
jQuery('#datepicker').datepicker({
format: 'dd-mm-yyyy',
startDate: '+1d'
});
});
$('.cancel-modal').click(function(){
$("#cancel-box").show();
var id= $(this).attr("id");
$("#cancel_id").val(id);
})
$(".btn_return").click(function(){
var result = confirm("Want to delete?");
if (result) {
var id= $(this).attr("id");
var phone= $(this).attr("order_phone");
var order_no= $(this).attr("order_id");
if(id!=""){
$.ajax({
method:"post",
url:"<?=base_url('home/order_cancel_process')?>",
data:{"order_id":id,"phone":phone,"order_no":order_no,"status":'0'},
success:function(res){
if(res==1){
$("#cancel-box").hide();
$("#cancel_msg").text("Cancelled");
location.reload();
}else if(res==0){
alert("Internal Problem");
return false;
}
}
})
}
}
});
$("#cancel_btn").click(function(){
var desc = $("#description").val();
if(desc==""){
$(".desc_err").html('<small>Please enter cancel description</small>');
return false;
}else{
var cancel_id = $("#cancel_id").val();
if(desc!="" && cancel_id!=""){
$.ajax({
method:"post",
url:"<?=base_url('home/order_cancel_process')?>",
data:{"cancel_id":cancel_id,"description":desc},
success:function(res){
if(res==1){
$("#cancel-box").hide();
$("#cancel_msg").text("Cancelled");
location.reload();
}else if(res==0){
alert("Internal Problem");
return false;
}
}
})
}
}
})
</script>