<div class="clearfix"></div>

  <div class="content-wrapper">

    <div class="container-fluid">

      <!-- Breadcrumb-->

     <div class="row pt-2 pb-2">

        <div class="col-sm-9">

		    <h4 class="page-title">Orders Details</h4>

	   </div>

     

     </div>

    <!-- End Breadcrumb-->

      <div class="row">

            <div class="col-sm-9">



                <div class="card">



                  <div class="card-body" style="padding:40px;" id="printsec">



                    <div class="pull-right text-right">



                      <h3 class="font-semibold mgbt-xs-20">INVOICE</h3>



                      <table class="table table-bordered">



                        <tr>



                          <th>Invoice No.</th>



                          <th>Y1O00<?php echo $order->oid;?></th>



                        </tr>
                        <tr>



                          <th>Invoice Date</th>



                          <th><?php echo date("d M Y",strtotime($order->odate));?></th>



                        </tr>
                         <tr>



                          <th>Payment Mode</th>



                          <th><?php echo $order->pay_method;?></th>



                        </tr>
                        <?php if($order->pay_method!='COD'){?>

                           <tr><th>Transaction ID</th><th><strong> <?php echo $order->trans_id;?></strong></th></tr>
                          <!-- <tr><th>Transaction Ref</th><th><strong> <?php //echo $order->txn_ref;?></strong></th></tr>-->

<?php }?>
                         



                        

                        



                      </table>



                    </div>



                    <div class="mgbt-xs-20"><img style="height:60px;" alt="logo" src="<?php echo base_url();?>assets/logo.png" /></div>



                    <address>

					<?php $add=$this->db->get("admin")->row();
					echo '<b>'.$add->comp_name.'</b><br/>';

                    echo $add->address.'<br/>';
                    echo $add->city.' '.$add->pincode.'<br/>';?>

                    <abbr title="Phone">Ph :</abbr> <?php echo $add->mobile;?>



                    <br />



                     <?php echo $add->email;?>



                    </address>



                    <hr/>



                    <br/>



                    <div class="pd-25">



                      <div class="row">



                        <div class="col-md-8">



                          <address>



                          <strong>Bill To:</strong><br>



                          <p><?php echo $order->bname;?><br>
                          <?php echo $order->baddress;?><br>
                          <?php echo $order->blandmark.' '.$order->bcity.' '.$order->bstate.' '.$order->bpin;?><br>
                          <i class="fa fa-phone"></i> <?php echo $order->bphone.' '.$order->mobile;?></p>



                          </address>



                        </div>



                       <!-- <div class="col-xs-4">



                          <address>



                          <strong>Ship To:</strong><br>



                          John Doe<br>



                          795 Folsom Ave, Suite 600<br/>



                          San Francisco, CA 94107<br>



                          </address>



                        </div>-->



                       <!-- <div class="col-xs-2">



                          <address>



                          <strong>Due Date:</strong><br>



                          24 July 2013



                          </address>



                        </div>-->



                        <div class="col-md-4">



                          <div class="text-right">



                          <strong>Total Amount:</strong><br>



                          <h4 class="text-warning"><?php echo $order->curr.' '.$order->ototal;?>/-</h4>


                          </div>



                        </div>



                      </div>



                    </div>



                    <table class="table table-condensed table-striped">



                      <thead>



                        <tr>



                          <th>SKU</th>



                          <th>DESCRIPTION</th>



                          <th class="text-center" style="width:20px;">QTY</th>



                          <th class="text-right" style="width:120px;">SubTotal</th>






                          <th class="text-right" style="width:120px;">TOTAL</th>



                        </tr>



                      </thead>



                      <tbody>



                      <?php $oi=1;foreach($items as $item){
						  
						  $pro=$this->db->get_where("products",array("pid"=>$item->pid))->row();
						  $var=$this->db->get_where("prod_variants",array("pvid"=>$item->vrid))->row();?>



                        <tr>



                          <td class="text-center"><?php echo $oi;?></td>



                          <td class="text-center">



                          <img  width="100px" class="img img-responsive pull-left" src="<?php echo $item->pimg;?>"> 
						  <?php echo '<h4>'.$pro->brand.'</h4>'.$item->pname.'<br/> <span class="badge badge-warning">UID - '.$item->item_wid.'</span>';?></td>



                          <td><?php echo $item->qty?></td>



                          <td class="text-right"> <?php echo $item->price.'/- ';?></td>






                          <td class="text-right"> <?php echo $item->subtotal;?>/-</td>



                          



                        </tr>



                        <?php $oi++;}?>



                      </tbody>



                      <tfoot bgcolor="#FFFFCC">



                        <tr>



                          <th colspan="3" rowspan="4" class="bdr">



                            <!--<h4>Offer Code Used - 



                            <b class="text-danger"><?php if($order->offer!=""){



							  $of=$this->db->get_where("promos",array("promo_id"=>$order->offer))->row();



							  echo $of->promo_code;}?></b></h4>--></th>



                          <th class="text-left pd-10">Sub Total</th>



                          <th class="text-right pd-10"><?php echo $order->ototal;?>/-</th>



                        </tr>




                        


<tr>



                          <th class="text-left  pd-10 no-bd">Shipping</th>



                          <th class="text-right  pd-10 vd_red no-bd"><?php echo $order->shiptot;?>/-</th>



                        </tr>
                        <tr>



                          <th class="text-left  pd-10 no-bd">Discount</th>



                          <th class="text-right  pd-10 vd_red no-bd"><?php echo $order->odis;?>/-</th>



                        </tr>



                        <tr>




                          <th class="text-left  pd-10">Order Total</th>



                          <th class="text-right  pd-10"><span class="vd_green font-sm font-normal"><?php echo $order->ototal+$order->shiptot-$order->odis;//-$order->odis;?>/-</span></th>



                        </tr>



                      </tfoot>



                    </table>



                  </div>



                  <!-- panel-body --> 



                  



                </div>



                <!-- Panel Widget --> 



              </div>

            <div class="col-sm-3">

            	<div class="card">

                <div class="card-body">

                <div class="mgbt-xs-5">

                  <a href="<?php echo base_url();?>admin/orders/<?php echo $order->ostatus;?>" class="btn btn-warning" type="button">

                  <i class="fa fa-arrow-left"></i> Back To All Orders</a>

                </div>

                <div class="mgbt-xs-5">

                  <a class="btn vd_btn vd_bg-grey" target="_blank" href="<?php echo base_url().'admin/print_invoice/'.$order->oid;?>"><i class="fa fa-print append-icon"></i> Print Invoice</a>

                </div>

                <div class="mgbt-xs-5">

                  <a class="btn vd_btn vd_bg-green send_invoice" href="#"><i class="fa fa-envelope"></i> Send Invoice Mail</a>

                </div>

               

                <div class="mgbt-xs-5">

                <hr/>
                
                <h5 class="text-info"><label><input type="checkbox" name="check" id="cod_recd" <?php if($order->pay_recd!=''){echo 'checked';}?>  value="RECD" /> COD Received</label></h5>

                <h5>Update Status</h5>

                <p id="ostresponse" class="text-danger"></p>

                  <select id="changestatus" class="form-control">
						<?php //if($order->ostatus!="Completed"){?>
                  		<option value="Pending" <?php if($order->ostatus=="Pending"){echo "selected";}?>>Pending</option>
                  		<option value="Confirmed" <?php if($order->ostatus=="Confirmed"){echo "selected";}?>>Confirmed</option>
                  		<option value="Dispatched" <?php if($order->ostatus=="Dispatched"){echo "selected";}?>>Dispatched</option>
                  		<option value="Delivered" <?php if($order->ostatus=="Delivered"){echo "selected";}?>>Delivered</option>
                  		<option value="Completed" <?php if($order->ostatus=="Completed"){echo "selected";}?>>Completed</option>
						<?php ////}?>

                       <!-- <option value="Delivered" <?php //if($order->ostatus=="Delivered"){echo "selected";}?>>Delivered</option>-->


                  </select>

                </div>

                </div></div>

              </div>

        </div><!--End Row-->

	  

	  <!--End Row-->



    </div>

    <!-- End container-fluid-->

    

    </div><!--End content-wrapper-->

   <!--Start Back To Top Button-->

    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>

    <!--End Back To Top Button-->

	

	<!--Start footer-->

	<footer class="footer">

      <div class="container">

        <div class="text-center">

          Copyright © 2022</div>

      </div>

    </footer>

	<!--End footer-->

   

  </div><!--End wrapper-->



  <script src="<?php echo base_url();?>adminassets/plugins/bootstrap-datatable/js/jquery.dataTables.min.js"></script>

  <script src="<?php echo base_url();?>adminassets/plugins/bootstrap-datatable/js/dataTables.bootstrap4.min.js"></script>

  <script>

function printPage(id) {

    var html="<html>";

    html+= document.getElementById(id).innerHTML;

    html+="</html>";

    var printWin = window.open('','','left=100,top=100,width=1200,height=600,toolbar=0,scrollbars=0,status =0');

    printWin.document.write(html);

    printWin.document.close();

    printWin.focus();

    printWin.print();

    printWin.close();

}

	$(document).ready(function(){
		
		
		$("#cod_recd").click(function(){

		var id=<?php echo $this->uri->segment(3);?>;

		var v="";

		if ($(this).is(':checked')) {

			var v=$(this).val();

		}

		//alert(v);

		$.ajax({

			 type: "POST",
	
			 url: '<?php echo base_url();?>admin/ajax_cod_recd',
	
			 data: {v:v,id:id},
	
			 success: function(response){
	
			 	//alert(response);
	
			 }

		 });
		 
		});
		
		$("#changestatus").change(function(){

			//alert("AFsd");

			var st=$(this).val();

			$.ajax({

					type:'POST',

					data:{oid:'<?php echo $this->uri->segment(3);?>',st:st,userid:<?php echo $order->userid;?>},

					url:'<?php echo base_url();?>admin/ostatus_change',

					success:function(data){

					   // alert(data);

						$("#ostresponse").html(data); 

						//$('#sectionn').material_select();  

					}

			});

		});
		$(".send_invoice").click(function(e){e.preventDefault();
			$.ajax({

			 type: "POST",
	
			 url: '<?php echo base_url().'admin/invoice_pdf/';?>',
	
			 data: {id:<?php echo $this->uri->segment(3);?>},
	
			 success: function(response){
	
			 	alert(response);
	
			 }

		 });
		});

	});

</script>

  <script src="<?php echo base_url();?>adminassets/js/sidebar-menu.js"></script>

  <!-- Custom scripts -->

  <script src="<?php echo base_url();?>adminassets/js/app-script.js"></script>

</body>

</html>

