<?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>
    @media print {
	 @page
	    {
	        margin : 0.5cm 0cm 1cm 0cm;
	    }
       /* table {page-break-before: always; 
               font-size: 100px;}
        tr{page-break-inside: avoid; 
           page-break-after: auto;}*/

	    }
</style>
<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">Issues</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="#">Issues</a>
                  </li>
                  <li class="breadcrumb-item active">Issues
                  </li>
                </ol>
              </div>
            </div>
          </div>
         
        </div>
        <div class="content-body"><section class="card">
  <div id="invoice-template" class="card-body p-4 page">
    <!-- Invoice Items Details -->
    
    <div id="invoice-items-details" class="pt-2 ">
        
      <div class="row">
     <div id="ele3" class="a">
        <div class="table-responsive col-12" >
            <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</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 ">
           <!--   <table  id="tableID" border="1" style="border:1px solid!important;" class="table table-bordered zero-configuration">-->
               <thead>
				<?php
					foreach($issue as $iss)
					$st_branch = $iss->branchname;
					$out_branch = $iss->out_branch;
					$q1 = $this->db->query("select * from user where branch_name='$st_branch'");
					$r = $q1->row_array();
					$st_adr_id = $r['address_id'];
					$q2 = $this->db->query("select * from user where branch_name='$out_branch'");
					$r2 = $q2->row_array();
					$out_adr_id = $r2['address_id'];
				?>
				<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($iss->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 $iss->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;&nbsp;&nbsp;&nbsp;&nbsp;</strong><strong><?php echo $iss->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 = $iss->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 $iss->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 class="data_details">
					<th>REQ No:</th>
					<th><?php echo $iss->pr_req_no; ?></th>
					<th colspan="">REQ Date: <?php echo $iss->request_date; ?></th>
					<th colspan="3">Issue No: <?php echo $iss->issue_no; ?></th>
					<th colspan="2">Issue Date: <?php echo $iss->issue_date; ?></th>
					<th colspan="2">Outlet: <?php echo $iss->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_tax_amt = 0;
			$tot_basic = 0;
			$tot_amt = 0;
				foreach($issue_item as $isitem){
					$tot_tax_amt = $tot_tax_amt + $isitem->tax_amount;
					$tot_basic = $tot_basic + $isitem->basic_price;
					$tot_amt = $tot_amt + $isitem->total_price;
			?>
				<tr class="data_list">
					<td><?php echo $count; ?></td>
					<td colspan="2"><?php echo $isitem->issue_item_name; ?></td>
					<td><?php //echo $isitem->hsn_code;
					$recipe_id=$isitem->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 $isitem->price; ?></td>
					<td><?php echo $isitem->issued_qty; ?></td>
					<td><?php echo $isitem->basic_price; ?></td>
					<td><?php echo $isitem->tax; ?></td>
					<td><?php echo $isitem->tax_amount; ?></td>
					<td><?php echo $isitem->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>
      </div>
  
    </div>
</br>
    <!-- Invoice Footer -->
    <div id="invoice-footer">
      <div class="row">
      <!--  <div class="col-sm-6 col-6 text-left">
          <button onclick="method(btn)" class="btn btn-info pull-right print_receipt">Export</button>
        </div>-->
   <!--  <div class="col-sm-6 col-6 text-right">
          <button type="button" id="print_receipt" class="btn btn-info print_receipt  btn-lg sm-1"><i class="fa ft-printer"></i></button>
        </div>-->
      <div class="col-sm-6 col-6 text-right">
        <button class="print-link btn btn-info no-print" onclick="jQuery.print('#ele3')">
                        <i class="fa ft-printer"></i>
                        </button>
        </div>
      </div>
    </div>
    <!-- Invoice Footer -->

  </div>
  
</section>
</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');?>';
	} */
</script>
<script type="text/javascript">
	var btn='NewReport';
	</script>
    <script type="text/javascript" src="<?php echo base_url(); ?>assets/js_pdf/tableToExcel.js"></script>
	<script type="text/javascript">
	function method(s) {
	//alert(s);
	//tableToExcel('table', s);
	tableToExcel('tableID', s);
	}
	</script>	