<?php 
	$header_file=APPPATH.'views/include/header.php';
	require($header_file);
	$sidenav_file=APPPATH.'views/include/sidenav.php';
	require($sidenav_file);	?>
<!-- BEGIN: Content-->

    <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">Product 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">Product Issues
                  </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="row">
        <div class="table-responsive col-12">
          <table class="table table-bordered table-responsive-lg">
            <thead>
				<?php
					foreach($issue as $iss)
					$st_branch = $iss->branchname;
					$out_branch = $iss->outlet;
					$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 username='$out_branch'");
					$r2 = $q2->row_array();
					$out_adr_id = $r2['address_id'];
				?>
				<tr class="main_heading">
					<th colspan="11"><span>Issue View</span></th>
				</tr>
				<?php 
				/*	$fq = $this->db->query("select org_name,address1,address2,address3,gstin_no from address where address_id='$st_adr_id'");
					$fr = $fq->row_array();
					
					$tq = $this->db->query("select org_name,address1,address2,address3,gstin_no from address where address_id='$out_adr_id'");
					$tr = $tq->row_array();*/
				?>
				
				<!--<tr>
					<td colspan="5" class="border_none">
						<h6 align="left"><strong>From</strong></h6>
						<h6 align="left"><strong><?php echo $fr['org_name']; ?></strong></h6>
						<h6 align="left"><strong><?php echo $fr['address1']; ?></strong></h6>
						<h6 align="left"><strong><?php echo $fr['address2']; ?></strong></h6>
						<h6 align="left"><strong><?php echo $fr['address3']; ?></strong></h6>
						<h6 align="left"><strong>GSTIN : <?php echo $fr['gstin_no']; ?></strong></h6>
					</td>
					<td colspan="5" class="border_none">
						<h6 align="right"><strong>To</strong></h6>
						<h6 align="right"><strong><?php echo $tr['org_name']; ?></strong></h6>
						<h6 align="right"><strong><?php echo $tr['address1']; ?></strong></h6>
						<h6 align="right"><strong><?php echo $tr['address2']; ?></strong></h6>
						<h6 align="right"><strong><?php echo $tr['address3']; ?></strong></h6>
						<h6 align="right"><strong>GSTIN : <?php echo $tr['gstin_no']; ?></strong></h6>
					</td>
				</tr>-->
			
				 <tr class="data_details">
					
					<th colspan="4">Issue No: <?php echo $iss->issue_no; ?></th>
					<th colspan="3">Issue Date: <?php echo date('d-m-Y',strtotime($iss->issue_date)); ?></th>
					<th colspan="3">Outlet: <?php echo $iss->outlet; ?></th>
				</tr>
				<tr class="data_heading">
					<th>Sl.No</th>
					<th colspan="2">Product Name</th>
					<th>UOM</th>
					<th>Iss Qty</th>
					<th>Price</th>
					<th>Tot Price</th>
					<th>Tax(%)</th>
					<th>Tax Amt</th>
					<th>Total</th>
				</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->issue_uom; ?></td>
					<td><?php echo $isitem->issued_qty; ?></td>
					<td><?php echo $isitem->price; ?></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="6" >Total Amount</td>
				<td><?php echo $tot_basic; ?></td>
				<td></td>
				<td><?php echo $tot_tax_amt; ?></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-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>
    </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/issueCPrList');?>';
	} 
</script>
	