<?php $base_name = $data['base_name'];?>
<style>
#printableArea{
    width: 200px;
    font-size: 8px;
    font-family: monospace;
}

.w-100{
    width: 100%;
}

.p1{
    padding: 5px 0;
}
.w-50{
    width: 50%;
}
.pull-right{
    float: right;
}
.last .h5{
    margin: 5px 0;
    display: block;
    font-weight: bold;
}
.last .h4{
    margin: 5px 0;
    display: block;
    font-size: 10px;
    font-weight: bold;
}
.last .h6{
    margin: 5px 0;
    display: block;
    font-size: 7px;
    font-weight: bold;
}

.content{
    float: left;
    width: 160px;
    padding: 5px 5px 0 10px;
}
.logo{
    padding-bottom:5px;width:40px;
}
.p012{
    padding: 0 12px
}
.bdb1{
    border-bottom: 1px dashed #000;
}
.border{
    display:inline;
    border:1px solid #cccccc42;
    font-size:8px;
    padding: 0;
}
.pb1{
    padding-bottom:5px;
}
.d-flex{
    display: flex;
}
.cih3{
    margin: 5px 0;
}
.table{
    padding:0;
    width:198px;
    font-size: 8px;
}
th{
    text-align: left;
    border-bottom: 1px dashed #ccc;
}

@media print{
    .media{
        display:none;
    }
    .border{
        border: 0px;
    }
}
</style>
        <div id="printableArea">
			<div class="w-100 bdb1 pb1">
				<div style="display: flex;">
					<div style="float:left;padding-left:5px;">
						<img src="<?=base_url('uploads/website/favicon/'.$data['favicon']);?>" class="logo" /> 
					</div>
					<div class="content">
						<strong><?=$data['base_name'];?></strong>
						<br />Address : <?=$data['contact_address'];?>
						<br>Mob. No.: <?=$data['contact_phone'];?>
					</div>
				</div>
				<div class="w-100 p012">
				    Email: <?=$data['contact_email'];?>
				</div>
			</div>
			<div class="w-100">
				<h3 class="cih3">  <strong>Customer Information: </strong></h3>
				<?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'];
					           }
						?>
				<div class="w-100 bdb1 pb1">
                    <div class="d-flex"><b>Name:</b> &nbsp;&nbsp; <input type="text"  title="Customer Name" class="border" value="<?=$SH_name; ?>"></div>
                    <div class="d-flex"><b>Address :</b> </div>
                    <textarea type="text" title="Address" class="border w-100" ><?=$SH_district; ?>, <?=$SH_state.' '.$SH_pin_code; ?></textarea>
                    <div class="d-flex"><b>Phone No.:</b> &nbsp;&nbsp; <input type="text" value="<?=$SH_phone; ?>" title="Mobile Number" class="border"></div>
                    <div class="d-flex"><b>Pin Code:</b> &nbsp;&nbsp; <input type="text" value="<?=$SH_pin_code; ?>"  title="Email" class="border"></div>
				</div>
			</div>
			<div class="w-100 bdb1 pb1">
				<h3 class="cih3">  <strong>Bill Details: </strong></h3>
					Bill Date : <?=date('d-m-Y 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 class="w-100 bdb1 pb1">
				<h3 class="cih3">  <strong>Payment Details: </strong></h5>
				<b>Booking By :<?=$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 : 
				<?=date('d-m-Y h:i:s A',strtotime($row1['payment_date']));?>
			</div>
    			<?php } ?>
			<div class="w-100 bdb1 pb1">
				<table class="table">
					<thead>
						<tr>
							<th>#</th>
							<th>Perticulars</th>
							<th>Qty</th>
							<th>MRP</th>
							<th>Discount</th>
							<th>PV</th>
							<th>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><?=$i++ ?>.</td>
							<td><?=$row1['product_name'];?><br>
								<?php
									if(!empty($row1['color']))
									{
									?>
							    <?=$row1['color'];?><br>
								<?php
									}
									
									if(!empty($row1['size']))
									{
									?>
								<?=$row1['size'];?><br>
								<?php
									}
									?></td>
							<td><?=$row1['quantity'];?>
							</td>
							<td> 
								&#8377;
								<?=$row1['mrp_price'];?>
							</td>
						<!--	<td> 
								&#8377;
								<?=$row1['unit_price'];?>
							</td>-->
							<td> 
								&#8377;
								<?=$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>
			<div class="w-100 bdb1 p1 d-flex">
				<div class="w-50">
				    Proprietor Name:
				</div>
				<div class="w-50">
					<b>(Admin)</b>
				</div>
			</div>
			<div class="w-100 bdb1 pb1">
				<?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 class="last">
					<div class="h5">MRP Total: <strong class="pull-right"><?=' &nbsp;&#8377; '.number_format($total21,2);?></strong></div>
					<div class="h5">Discount: <strong class="pull-right"><?=' &nbsp;&#8377; '.number_format($total21-$total1,2);?></strong></div>
					<div class="h5">Sub Total: <strong class="pull-right"><?=' &nbsp;&#8377; '.number_format($total1,2);?></strong></div>
					<div class="h5">Shipping Cost: <strong class="pull-right"><?=$shipping_cost;?></strong></div>
					<div class="h5">Coupon Discount: <strong class="pull-right"><?=' &nbsp;&#8377; '.number_format($cp,2);?></strong></div>
					<div class="h5">Self Benefit: <strong class="pull-right"><?=' &nbsp;&#8377; '.number_format($pvtotal,2);?></strong></div>
					<div class="h4">Bill Amount : <strong class="pull-right"><?=' &nbsp;&#8377; '.number_format($total1-$cp+$shipping_cost2-$pvtotal,2);?></strong></div>
					<div class="h6"> &nbsp;<strong class="text-success pull-right" style="color:green;">You Save <?=' &nbsp;&#8377; '.number_format($total21-$total1+$pvtotal,2);?></strong></div>
				</div>
			</div>
			<div class="w-100 bdb1" 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 style="padding-left: 14px;">
							<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 style="margin-top:10px;" class="media">
		    <input class="btn btn-primary btn-lg" type="button" onclick="printDiv('printableArea')" value="Print Invoice" />
		</div>
		
		<script>
			function printDiv(divName) {
			   
			     window.print();
			
			}
		</script>