<!DOCTYPE html>
<html>
<body>
 <style type="text/css">
  #text{
      max-width: 1000px;
      padding:5px 15px;
    background: white;
  }
  
  .pull-right{
      float:right;
  }

b, strong {
    font-weight: 600;
}
.container-fluid {
    width: 100%;
    padding-right: 12px;
    padding-left: 12px;
    margin-right: auto;
    margin-left: auto;
}

.h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 {
    margin: 10px 0;
    font-weight: 500;
    font-family: Roboto,sans-serif;
    color: #343a40;
}

.h5, h5 {
    font-size: 1.125rem;
}
.h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 {
    margin-bottom: .5rem;
    font-weight: 500;
    line-height: 1.2;
}

hr{
    border-style: dashed;
}

.border {
    border: 1px solid #fff!important;
}

button, input {
    overflow: visible;
}
button, input, optgroup, select, textarea {
    margin: 0;
    width: 50%;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}


.row {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    margin-right: 0;
    margin-left: -12px;
}

.col, .col-1, .col-10, .col-11, .col-12, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-auto, .col-lg, .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-auto, .col-md, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-auto, .col-sm, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-auto {
    position: relative;
    width: 100%;
    padding-right: 12px;
    padding-left: 12px;
}


#btn{
      padding:10px;
      border: 0px;
      margin: 50px;
      cursor: pointer;
    }
    
    .table-bordered {
    border: 1px solid #e9ecef;
}
.table {
    width: 100%;
    margin-bottom: 1rem;
    color: #495057;
}
table {
    border-collapse: collapse;
}
.table-bordered thead td, .table-bordered thead th {
    border-bottom-width: 2px;
}
.table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid #e9ecef;
}
.table th {
    font-weight: 500;
}
.table-bordered td, .table-bordered th {
    border: 1px solid #e9ecef;
}
.table td, .table th {
    padding: .75rem;
    vertical-align: top;
    border-top: 1px solid #e9ecef;
}
th {
    text-align: inherit;
}

.text-right{
    text-align: right;
}
  </style>
<div id="text">

<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->

<!-- end page title --> 
<div class="row" style="font-size: 20px;font-family: monospace;">
	<div class="col-md-12">
		    <center>
		        <br>
		        <h2><b style="border: 4px solid green;color: green; border-radius:5px;padding: 5px;">INVOICE</b></h2>
		    </center>
	</div>
	<div class="col-md-12">
		<div class="row pad-top-botm ">
			<div style="float:left;padding-left:15px;">
				<img src="<?=base_url('uploads/website/favicon/'.$data['favicon']);?>" style="width:135px;" /> 
			</div>
			<div style="float: left;width: auto;margin-top: 2%;font-size: 25px;padding-left: 4%;">
				<strong><?php echo $data['base_name'];?></strong>
				<br />Address : <?php echo $data['contact_address'];?>
				<br>Mob. No.: <?php echo $data['contact_phone'];?>
				<br>Email: <?php echo $data['contact_email'];?>
			</div>
		</div>
	</div>
	<div class="col-md-12">
	    <hr>
	</div>
	<div class="col-md-12">
		<div style="width:100%;float:none;min-height: 240px;">
			<div  class=" pad-top-botm client-info">
				<div style="float:left;width:32%;padding-left:2%;">
					<h5>  <strong>Customer Information</strong></h5>
					<?php
						$i=0;
						$statement1 = $this->db->query("SELECT * FROM tbl_payment where payment_id='$_GET[id]'");
						$result1 = $statement1->result_array();							
						foreach ($result1 as $row1) {
						
						  // select Delivery Address for this order
						           $statement2222 = $this->db->query("SELECT * FROM applied_delivery_address WHERE payment_id = ?",array($_GET['id']));
						           $result222 = $statement2222->result_array();
						           foreach ($result222 as $row222) {
						               $SH_name = $row222['name'];
						               $SH_phone = $row222['phone'];
						               $SH_state = $row222['state'];
						               $SH_district = $row222['district'];
						               $SH_pin_code = $row222['pin_code'];
						             //  $SH_address = $row222['address'];
						           }
							?>
					<strong> <input type="text"  title="Customer Name" class="border" value="<?php echo $SH_name; ?>"></strong>
					<br />
					<b>Address :</b> <br> 
					<textarea type="text" title="Address" class="border" ><?php echo $SH_district; ?>, <?php echo $SH_state.' '.$SH_pin_code; ?></textarea>
					<br>
					<b>Call :</b> <input type="text" value="<?php echo $SH_phone; ?>" title="Mobile Number" class="border">
					<br />
					<b>Pin Code :</b> <input type="text" value="<?php echo $SH_pin_code; ?>"  title="Email" class="border">
				</div>
				<div style="float:left;padding-left:1%;width:40%;">
					<h5>  <strong>Bill Details </strong></h5>
					Bill Date : <?php echo date('d-m-Y', strtotime($row1['payment_date']));
						?>
					<br />
					Bill Time : <?php echo date('H:i:s', strtotime($row1['payment_date']));
						?>
					<br />
					Delivery Date : <input type="text" class="border"><br>
					Gst no :  <input type="text" class="border"><br>
					Vehicle Name : <input type="text" class="border"><br>
					Vihicle No : <input type="text"  class="border"><br>
					Reg. State Code : 10<br>
				</div>
				<div style="float:left;width:22%;padding-right:2%;">
					<h5>  <strong>Payment Details </strong></h5>
					<b>Booking By :<?php echo $row1['payment_method']; ?> </b>
					<br />
					<b>Payment Status :  <?php 
						if($row1['payment_method']=='COD')
						{
						 echo 'N/A (COD)';   
						}
						else{
						echo $row1['payment_status']; 
						
						}
						?> 
					</b>
					<br />
					Purchase Date : 
					<?php echo date('d-m-Y h:i:s A',strtotime($row1['payment_date']));?>
				</div>
				<?php } ?>
			</div>
			<br>
		</div>
	</div>
	
	<div class="col-md-12">
	    <hr>
	</div>
	<div class="col-md-12">
		<div class="row">
				<div class="col-lg-12 col-md-12 col-sm-12 col-12 col-xs-12">
					<div class="">
						<table class="table table-striped table-bordered table-hover">
							<thead>
								<tr>
									<th>S. No.</th>
									<th>Perticulars</th>
									<th>Quantity.</th>
									<th>MRP Price</th>
									<th>After Discount</th>
									<th>Discount</th>
									<th>PV</th>
									<th width="15%">Sub Total</th>
								</tr>
							</thead>
							<tbody>
								<?php
									$i=1;
									 $statement1 = $this->db->query("SELECT * FROM tbl_order WHERE payment_id=?",array($row1['payment_id']));
									 $result1 = $statement1->result_array();
									 foreach ($result1 as $row1) { ?>
								<tr>
									<td><?php echo $i++ ?></td>
									<td><?php echo $row1['product_name'];?></td>
									<td>Qty.:<?php echo $row1['quantity'];?><br>
										<?php
											if(!empty($row1['color']))
											{
											?>
										Clour:<?php echo $row1['color'];?><br>
										<?php
											}
											
											if(!empty($row1['size']))
											{
											?>
										Size:<?php echo $row1['size'];?><br>
										<?php
											}
											?>
									</td>
									<td> 
										&#8377;
										<?php echo $row1['mrp_price'];?>
									</td>
									<td> 
										&#8377;
										<?php echo $row1['unit_price'];?>
									</td>
									<td> 
										&#8377;
										<?php echo $row1['mrp_price']-$row1['unit_price'];?>
									</td>
        							<td> 
        								&#8377;
        								<?php echo $row1['pv'];$pvtotal+=($row1['pv'])*($row1['quantity']);?>
        							</td>
									<td>
										&#8377;
										<?php  $total=($row1['unit_price'])*($row1['quantity']);
											echo $total;
											
											
											?>.00
									</td>
								</tr>
								<?php 
									error_reporting(0);
									         
									     }
									     ?>      
							</tbody>
						</table>
					</div>
					<hr />
					<div style="width:60%;float:left;">
						<div style="float:left;width:60%;">
							<b>
								<!--Digital Signature Verified : -->
							</b>
							<br>
							<br>
							<!--<img src="img/signature.png" style="width:120px;height:60px;filter: grayscale(100%);">-->
							<br>Proprietor Name : <b>(Admin)</b>
						</div>
						<div style="float:left;width:40%;">
							<br>
							<br>
							<br>
							<b>Customer Signature </b><br>
						</div>
					</div>
					<div style="width:40%;float:left;">
						<?php
							// select aplied Coupon for this order
							   $statement2222 = $this->db->query("SELECT * FROM applied_coupon WHERE payment_id = ?",array($_GET['id']));
							   $result222 = $statement2222->result_array();
							   foreach ($result222 as $row222) {
							       $coupon_id = $row222['coupon_id'];
							   }
							   
							   // select coupon details for this order
							   $statement2222 = $this->db->query("SELECT * FROM tbl_coupon WHERE coupon_id = ?",array($coupon_id));
							   $result222 = $statement2222->result_array();
							   foreach ($result222 as $row222) {
							       $percentage = $row222['percentage'];
							       $type = $row222['type'];
							   }
							   
							   
							   
							   $statement1 = $this->db->query("SELECT * FROM tbl_order WHERE payment_id=?",array($_GET['id']));
							   $result1 = $statement1->result_array();
							   foreach ($result1 as $row1) {
							       $total=($row1['unit_price'])*($row1['quantity']);
							       $total1+=$total;
							       $total2=($row1['mrp_price'])*($row1['quantity']);
							       $total21+=$total2;
							   }
							   if($percentage){
							     if($type==1)  
							  {
							      $cp = $percentage; 
							  }
							  else
							  {
							   $cp = ($total1/100)*$percentage;
							  }
							   }
							   else
							   {
							       $cp=0.00;
							   }
							   
							   
							   
							   $statement1 = $this->db->query("SELECT * FROM applied_shipping_cost WHERE payment_id=?",array($_GET['id']));
							   $result1 = $statement1->result_array();
							   foreach ($result1 as $row1) {
							       $shipping_cost='&#8377; '.number_format($row1['shipping_cost'],2);
							       $shipping_cost2=$row1['shipping_cost'];
							   }
							   if(empty($shipping_cost)){
							   $shipping_cost="FREE";
							   }
							?>
						<div style="width:300px;float: right;margin-right: 20px;">
							<h5>Sub Total: <strong class="pull-right"><?php echo ' &nbsp;&#8377; '.number_format($total21,2);?></strong></h5>
							<h5>Discount: <strong class="pull-right"><?php echo ' &nbsp;&#8377; '.number_format($total21-$total1,2);?></strong></h5>
							<h5>Total: <strong class="pull-right"><?php echo ' &nbsp;&#8377; '.number_format($total1,2);?></strong></h5>
							<h5>Shipping Cost: <strong class="pull-right"><?php echo $shipping_cost;?></strong></h5>
							<h5>Coupon Discount: <strong class="pull-right"><?php echo ' &nbsp;&#8377; '.number_format($cp,2);?></strong></h5>
							<h5>Self Benefit: <strong class="pull-right"><?php echo ' &nbsp;&#8377; '.number_format($pvtotal,2);?></strong></h5>
							<h4>Bill Amount : <strong class="pull-right"><?php echo ' &nbsp;&#8377; '.number_format($total1-$cp+$shipping_cost2-$pvtotal,2);?></strong></h4>
							<h6> <strong class="text-success pull-right" style="color:green;">You Save <?php echo ' &nbsp;&#8377; '.number_format($total21-$total1+$pvtotal,2);?></strong></h6>
						</div>
						<br>
					</div>
					<div style="width:100%;float:bottom; " class="col-md-12 col-xs-12 col-sm-12 col-12">
						<div style="width:100%;">
							<br>
							<div class="col-lg-12 col-md-12 col-sm-12">
								<strong> Important: </strong>
								<ol>
									<li>
										Please read all terms and polices on  <b><?=$data['web_url'];?></b> for returns, replacement and other issues.
									</li>
								</ol>
							</div>
						</div>
					</div>
				</div>
		</div>
	</div>
</div>
</section>
</div>
</div>

<style>
	.pad-top-botm {
	/*padding-bottom:10px;*/
	/*padding-top:10px;*/
	}
	h4 {
	text-transform:uppercase;
	}
	/* =============================================================
	PAGE STYLES
	============================================================ */
	.contact-info span {
	/*font-size:14px;*/
	padding:0px 50px 0px 50px;
	}
	.contact-info hr {
	margin-top: 0px;
	margin-bottom: 0px;
	}
	b{
	/*font-size:12px;*/
	}
/*	.client-info {
	font-size:14px;
	}*/
	.ttl-amts {
	text-align:right;
	padding-right:50px;
	}
	@media print{
	html{
	background-color: #f7f9fa;
	}
	.navbar-custom{
	display: none;
	}
	.left-side-menu{
	display: none;
	}
	.page-title-box{
	display: none;
	}
	}
	@media print{
	    .border{
	        border: 0px solid #fff;
	        border-color: transparent;
            width: 100%;
            background: #f7f9fa;
	    }
	.print-hide{
	display:none;
	}
	pre, blockquote { page-break-inside: avoid;}
	
	.cds{
	display:block !important;
	}
	.border{
	border:0px solid #f7f9fa;
	border:0px solid #f7f9fa;
	}
	}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"></script>
<script>
 function myfunction(){
     var height = 315+<?=$i;?>*28;
    let pdf = new jsPDF('p', 'px', [350, height]);
    let section=$('#text');
    let page= function() {
        pdf.save('bill_<?=$_GET['id'];?>.pdf');
    };
    pdf.addHTML(section,page);
    
    window.location= '<?=base_url('master/order/');?>';
}

 myfunction();

</script>

</body>
</html>