<?php 
	$header_file=APPPATH.'views/include/header.php';
	require($header_file);
	$sidenav_file=APPPATH.'views/include/sidenav.php';
	require($sidenav_file);	
	$c_t_w_file=APPPATH.'views/currency_to_words.php';
  require($c_t_w_file);
	?>
<!-- BEGIN: Content-->
<style>
    .sub_heading{
    font-weight: 500!important;
    }
    td {
    font-size: 18px!important;
    }
    h6 {
    font-size: 18px!important;
    }
    table.table.table-bordered {
        width: 87%!important;
    }
    @media print {
	@page {
	size: A5;
	margin: 0;
	}
	.sub_heading{
    font-weight: 500!important;
    }
    td {
    font-size: 18px!important;
    }
    h6 {
    font-size: 18px!important;
    }
    table.table.table-bordered {
        width: 83%!important;
    }
    }
</style>
    <div class="app-content content">
      <div class="content-overlay"></div>
      <div class="content-wrapper">
        <div class="content-header row">
          <div class="content-header-left col-md-6 col-12 mb-2 breadcrumb-new">
            <h3 class="content-header-title mb-0 d-inline-block">Inward</h3>
            <div class="row breadcrumbs-top d-inline-block">
              <div class="breadcrumb-wrapper col-12">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="#">Home</a>
                  </li>
                  <li class="breadcrumb-item"><a href="#">Inward List</a>
                  </li>
                  <li class="breadcrumb-item active">Inward
                  </li>
                </ol>
              </div>
            </div>
          </div>
         
        </div>
        <div class="content-body"><section class="card">
  <div id="invoice-template" class="card-body p-4">
    <!-- Invoice Items Details -->
    <div id="invoice-items-details" class="pt-2">
      
        <div class="table-responsive col-12" id="ele3">
            <div class="col-sm-12" style="    margin-bottom: 10px;">
                <h1 style="text-align:center;"> <strong >By2Coffee </strong ></h1></td>
            		 <h5 style="text-align:center;"><strong >	No 25, ASI Industrial Area <br/> Nayandahalli, Bangalore-65<br/>GSTIN No:29AYMPR0184Q1ZF<br/> FSSAI Lic No. 11218332000098</strong ></h5>
            		 <h4 style="text-align:center;margin-top: -3px;"><strong >TAX INVOICE</strong></h4>
            	<hr>
               
            </div>
            <div class="col-sm-12">
          <table class="table table-bordered ">
            
				<?php
					foreach($prd_iss as $prdi)
				?>
					<!--<h4 class="heading_a uk-margin-bottom" >Delivery Challan No - <?php //echo $prdi->issue_no; ?></h4>-->
					
				<thead>
				    <tr>
    					<td colspan="4" class="border_none">
					    	<h6 align="left"><strong >Invoice Date</strong><strong >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong><strong><?php echo date('d-m-Y',strtotime($prdi->issue_date)); ?></strong></h6>
							
						    <!--<h6 align="left"><strong>Invoice Time</strong><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong><strong><?php //echo $prdi->issue_time; ?></strong></h6>-->
							
							<h6 align="left"><strong>Invoice No</strong><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong><strong><?php echo $prdi->invoice_no; ?></strong></h6>
						
    						
    					</td>
    					<td colspan="6" class="border_none">
    					    <h6 align="right"><strong>Branch Name</strong><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong><strong><?php //echo $order->outlet_name; ?>
									<?php 
								$oname = $prdi->outlet;
								$query = $this->db->query("select * from user where username='$oname'");
        						foreach($query->result_array() as $row)
        						$address_id=$row['address_id'];
								echo $row['branch_title']; ?></strong></h6>
								
    					    <h6 align="right"><strong>Vehicle Name</strong><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong><strong><?php echo $prdi->vehicle_name; ?></strong></h6>
								
    					    <h6 align="right"><strong>GSTIN No</strong><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;</strong><strong><?php 
								$q1 = $this->db->query("select * from address where address_id='$address_id'");
        						foreach($q1->result_array() as $r1)
        						$gstin_no=$r1['gstin_no'];
								
								echo $gstin_no; ?></strong></h6>
								
    						
    					</td>
    				</tr>
					<!--<tr>
						<th>REQ  No : <?php //echo $prdi->pr_req_no; ?></th>	
						<th colspan="1" >REQ Date : <?php //echo $prdi->request_date; ?></th>
						<th colspan="2" >Issue No : <?php //echo $prdi->issue_no; ?></th>
						<th colspan="3" >Issue Date : <?php //echo $prdi->issue_date; ?></th>
						<th colspan="3">Outlet : <?php //echo $prdi->outlet; ?></th>
					</tr>-->
					<tr>
						<td  class="sub_heading">Sl.No</td>
						<td colspan="2" class="sub_heading">Item Name</td>
						<td class="sub_heading">HSN Code</td>
						
						<td class="sub_heading">Rate</td>
						<td class="sub_heading"> Qty</td>
						<td class="sub_heading">Value</td>
						<td class="sub_heading">Tax(%)</td>
						<td class="sub_heading">Tax Amt</td>
						<td class="sub_heading">Total Amt</td>
					</tr>
			   	</thead>
			   	<tbody>
					<?php
						
						$count = 1;
						$tot_amt = 0;
						$tot_tax_amt = 0;
						$tot_basic = 0;
						
							// displaying records.
							foreach($prd_iss_item as $prdiitem){
							    $tot_amt = $tot_amt + $prdiitem->total_price;
								$tot_tax_amt = $tot_tax_amt + $prdiitem->tax_amount;
								$tot_basic = $tot_basic + $prdiitem->basic_price;
							?>
							<tr>
								<td><?php echo $count; ?></td>
								<td colspan="2"><?php echo $prdiitem->issue_item_name; ?></td>
								<td><?php //echo $prdiitem->hsn_code;
								$recipe_id=$prdiitem->recipe_id;
            					$s3=$this->db->query("select * from recipe where recipe_id='$recipe_id'");
            				    $res = $s3->row_array();
            					$hsncode= $res['hsn_code'];
            					echo $hsncode;?>
            					</td>
								
								<td><?php echo $prdiitem->price; ?></td>
								
								<td><?php echo $prdiitem->issued_qty; ?></td>
								<td><?php echo $prdiitem->basic_price; ?></td>
								<td><?php echo $prdiitem->tax; ?></td>
								<td><?php echo $prdiitem->tax_amount; ?></td>
								<td><?php echo $prdiitem->total_price; ?></td>
							</tr>
						<?php $count++; } ?>
						
					<tr>
						<td colspan="8">
						<p id="output" class="text-left">
						   <strong>Amount In Words:</strong> </br>
							<span style="font-size:16px!important;font-weight:500!important;"><?php echo $currency_object->get_bd_amount_in_text($tot_amt); ?></span>
						</p>
						</td>
						
						<td><strong>Grand Total</strong></td>
						<td><?php echo round($tot_amt); ?></td>
					</tr>
				</tbody>    	
				
          </table>
          </div>
        </div>
      
  
    </div>

    <!-- Invoice Footer -->
    <div id="invoice-footer">
      <div class="row">
        <div class="col-sm-7 col-12 text-center text-sm-left">
          <!--<h6>Terms & Condition</h6>
          <p>Test pilot isn't always the healthiest business.</p>-->
        </div>
        <div class="col-sm-5 col-12 text-center">
          <button type="button" id="print_receipt" class="btn btn-info print_receipt  btn-sm my-1"><i class="fa ft-printer"></i></button>
        </div>
      </div>
    </div>
    <!-- Invoice Footer -->

  </div>
</section>
<!-- // Basic form layout section end -->
        </div>
      </div>
    </div>
    <?php //require('include/theme_customizer.php');?>

   <?php 
  $footer_file=APPPATH.'views/include/footer.php';
	require($footer_file);
	?>
<script>
	/*$("#print_receipt").click(function() {
		window.print();
		setTimeout("closePrintView()", 50);
	});
	function closePrintView() {
		window.location = '<?php echo site_url('ProductRequest/productIssueList');?>';
	} 
	*/
	$("#print_receipt").click(function() {
    jQuery.print('#ele3');
    setTimeout("closePrintView()", 50);
  });
  function closePrintView() {
    window.location = '<?php echo site_url('ProductRequest/productIssueList');?>';
  } 
</script>
	