<?php
	$this->load->view('master/common/header.php', $data);
	$base_name = $data['base_name'];
?>

<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
	<div class="col-12">
		<div class="page-title-box">
			<div class="page-title-right">
				<ol class="breadcrumb m-0">
					<li class="breadcrumb-item"><a href="javascript: void(0);"><?= $base_name; ?></a></li>
					<li class="breadcrumb-item active text-capitalize"><?= $page; ?></li>
				</ol>
			</div>
			<h4 class="page-title text-uppercase"><?= $page; ?></h4>
		</div>
	</div>
</div>
<!-- end page title --> 
<div class="row" style="font-size:16px;">

	<div class="col-md-12" style="<?php if($x==1){echo "display:none;";}?>">
		<div style="width:100%;" style="border:1px solid black;" id="printableArea">
			<div style="width:100%;float:none">
				<div class="row pad-top-botm ">
					<div style="float:left;padding-left:15px;">
						<img src="<?=base_url('uploads/website/favicon/'.$data['favicon']);?>" style="padding-bottom:20px;width:110px;" /> 
					</div>
					<div style="float:left;width:500px;padding-left:15px">
						<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 style="width:100%;float:none">
				<div  class=" pad-top-botm client-info">
					<div style="float:left;width:440px;padding-left:20px;">
						<h5>  <strong>Customer Information</strong></h5>
						<?php
							$i=0;
							$statement1 = $this->db->query("SELECT * FROM customer_invoice_list where bill_no='$payid'");
							$result1 = $statement1->result_array();							
							foreach ($result1 as $row1) {
							$c_id = $row1['customer_id'];
							  $queryds1 = $this->db->query("SELECT * FROM tbl_customer where cust_phone='$c_id'");
                             $rowds1 = $queryds1->row();
				               $SH_name = $rowds1->cust_name;
				               $SH_phone = $rowds1->cust_phone;
				               $SH_state = $rowds1->cust_state;
				               $SH_district = $rowds1->cust_city;
				               $SH_pin_code = $rowds1->cust_zip;
				               $SH_address = $rowds1->cust_address;
				               
				               $queryds12 = $this->db->query("SELECT * FROM tbl_state where id='$SH_state'");
                                 $rowds12 = $queryds12->row();
				               $SH_state = $rowds12->state;
				               
				               $queryds121 = $this->db->query("SELECT * FROM tbl_district where id='$SH_district'");
                                 $rowds121 = $queryds121->row();
				               $SH_district = $rowds121->district;
								?>
						<strong> <input type="text"  title="Customer Name" class="noborderq" value="<?php echo $SH_name; ?>"></strong>
						<br />
						<b>Address :</b> <br> 
						<textarea  type="text" title="Address" class="noborderq" ><?php echo $SH_address; ?>,<?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="noborderq">
						<br />
						<b>Pin Code :</b> <input type="text" value="<?php echo $SH_pin_code; ?>"  title="Email" class="noborderq">
					</div>
					<div style="float:left;padding-left:5px;width:240px;">
						<h5>  <strong>Bill Details </strong></h5>
						Bill Date : <?php echo date('d-m-Y H:i:s', strtotime($row1['addon']));
							?>
						<br />
						<b>Payment Status : Paid
						</b><br />
					</div>
					
					<?php } ?>
				</div>
				<br>
			</div>
		</div>
		<br>
		<div style="width:100%;float:none">
			<div style="width:100%;">
				<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>Discounted Price</th>
									<th>Discount</th>
									<th>PV</th>
									<th>Sub Total</th>
								</tr>
							</thead>
							<tbody>
								<?php
									$i=1;
									 $statement1 = $this->db->where('user_id',$_SESSION['admin']['id']);
                    				   $statement1 = $this->db->where('bill_no',$payid);
                    				   $statement1 = $this->db->get('customer_invoice');
									 $result1 = $statement1->result();
									 foreach ($result1 as $row) { ?>
								<tr>
									<td><?php echo $i++ ?></td>
									<td><?php
                                                $pid=$row->pid;
                                                $this->db->where('p_id',$pid); $pro = $this->db->get('tbl_product')->row_array();
                                                echo $pro['p_name'];
                                                ?></td>
									<td>Qty.: <?php echo  $row->qty;?><br>
									<?php
                                                $colori=$row->color_id;
                                                if(!empty($colori)) {
                                                    $this->db->where('color_id',$colori); $pro = $this->db->get('tbl_color')->row_array();
                                                    echo 'Color: '.$pro['color_name'].'<br>';
                                                }
                                                ?>
                                                <?php
                                                $size=$row->size_id;
                                                $this->db->where('size_id',$size); $pro = $this->db->get('tbl_size')->row_array();
                                                $pro['size_name'];
                                                ?>
										<?php
										
											if(!empty($pro['size_name']))
											{
											?>
										Size:<?php echo $pro['size_name'];?><br>
										<?php
											}
											?>
									</td>
									<td> 
									<?php
    									$this->db->where('p_id',$pid);
    									$this->db->where('size_id',$size);
    									if(!empty($colori)) { $this->db->where('color_id',$colori); }
    									$prodetails = $this->db->get('tbl_product_size')->row();
									?>
									
										<i class="fa fa-inr" aria-hidden="true"></i>&nbsp;
										<?php 
    										if(empty($prodetails->p_old_price) || $prodetails->p_old_price < $row->mrp){
        										echo $old = $row->mrp; 
    										} else {
        										echo $old = $prodetails->p_old_price; 
    										}
    										$oldtotal +=$old*$row->qty;
										?>
									</td>
									<td> 
										<i class="fa fa-inr" aria-hidden="true"></i>&nbsp;
										<?php echo $row->mrp;?>
									</td>
									<td> 
										<i class="fa fa-inr" aria-hidden="true"></i>&nbsp;
										<?php echo $discount = $old-$row->mrp; $discounttotal +=$discount;?>
									</td>
									<td> 
										<i class="fa fa-inr" aria-hidden="true"></i>&nbsp;
										<?php echo $row->pv;$pvtotal+=($row->pv)*($row->qty);?>
									</td>
									<td>
										<i class="fa fa-inr" aria-hidden="true"></i>&nbsp;
										<?php  $total=($row->mrp)*($row->qty);
											echo $total;
											$total1 +=$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>
							<!--<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>
							<b>Customer Signature </b><br>
						</div>
					</div>
					<div style="width:40%;float:left;">
						<div style="width:300px;float: right;">
							<h5>MRP Total: <strong class="pull-right"><?php echo ' &nbsp;&#8377; '.number_format($oldtotal,2);?></strong></h5>
							<h5>Discount: <strong class="pull-right"><?php echo ' &nbsp;&#8377; '.number_format($discounttotal,2);?></strong></h5>
							<h5>Sub Total: <strong class="pull-right"><?php echo ' &nbsp;&#8377; '.number_format($total1,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-$pvtotal,2);?></strong></h4>
							<h6> <strong class="text-success pull-right" style="color:green;">You Save <?php echo ' &nbsp;&#8377; '.number_format($discounttotal+$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>
		<br>      
		<div class="row pad-top-botm print-hide">
			<div class="col-lg-12 col-md-12 col-sm-12">
				<hr />
				<input class="btn btn-primary btn-lg" type="button" onclick="printDiv('printableArea')" value="Print Invoice" />
			</div>
		</div>
		<script>
			function printDiv(divName) {
			   
			     window.print();
			
			}
		</script>
	</div>

</div>
</section>
<style>
	.pad-top-botm {
	padding-bottom:10px;
	padding-top:20px;
	}
	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{
	    .noborderq{
	        border: 0px solid #fff;
	        border-color: transparent;
	        box-shadow: 0 0 0 #fff;
            width: 100%;
            background: #f7f9fa;
	    }
	.print-hide{
	display:none;
	}
	pre, blockquote { page-break-inside: avoid;}
	
	.cds{
	display:block !important;
	}
	
	}
</style>
<?php
	$this->load->view('master/common/footer.php');
	?>