<?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">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 View</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="row">
                <div class="table-responsive col-12">
                    <?php
					foreach($prd_req as $pr)
				?>
                  <table class="table table-bordered table-responsive-lg">
                    <h4 class="heading_a uk-margin-bottom" >Product Inward View</h4>
								<thead>
									<tr>
										<th>REQ No : <?php echo $pr->pr_req_no; ?></th>
										<th>REQ Date : <?php echo $pr->request_date; ?></th>
										<th>INW No : <?php echo $pr->req_rec_no; ?></th>
										<th>INW Date : <?php echo $pr->receipt_date; ?></th>
										<th>Department : <?php echo $pr->dept; ?></th>
										<th>DC No. : <?php echo $pr->dc_no; ?></th>
									</tr>
								
					
									<tr>
										<th colspan="2"><strong>Product Name</strong></th>
										<th><strong>REQ Qty</strong></th>
										<th><strong>INW Qty</strong></th>
										<th colspan="2"><strong>Remarks</strong></th>													
									</tr>
								</thead>
								<tbody>
									<?php
										$count = 1;
										foreach($prd_req_item as $pritem){
											?>
											
											<tr>
												<td colspan="2"><?php echo $pritem->item_name; ?></td>
												<td><?php echo $pritem->required_qty; ?></td>
												<td><?php echo $pritem->quantity; ?></td>
												<td colspan="2"><?php echo $pritem->rc_remarks; ?></td>												
											</tr>
											
									<?php $count++; } ?>	
									
								</tbody>
							</table>
						
						<br/>
							<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>
						</div>
					</div>
					</br>
					
					<div class="row print_receipt">
						<div class="col-md-12">
							<?php //echo $pr->bill_upload;
							if($pr->bill_upload != ""){ ?>
								
								<a href="#invoice_view" class='btn btn-primary category_list' data-toggle='collapse'>View File</a>
								<!--<div class="show-document" id="div1">-->
								<div id="invoice_view" class='collapse'>
									<img src="<?php echo base_url(); ?><?php echo $pr->bill_upload; ?>" class="img-rounded" alt="DC Invoice">
								</div>
							<?php } ?>
						</div>
					</div>
					<div class="doc_viewer">
						<!--<iframe id="viewer" frameborder="0" scrolling="yes" width="950" height="500"></iframe>-->
						<img id="viewer" />
					</div>
					
					
						<div class="card">
							<div class="card-content print_receipt">
							<h4>Inward Remarks</h4>
							<br/>
								<?php
									$rcp_id = $pr->req_rec_id;
									foreach($prd_req as $pr)
									
								
									$query = $this->db->query("select * from cmn_ticket as A inner join(select ticket_no,max(ticket_id) as maxtid,inw_id from cmn_ticket where inw_id='$rcp_id' group by inw_id) as B on A.inw_id=B.inw_id and A.ticket_id=B.maxtid");
									foreach($query->result_array() as $rm_row) 
								?>
								<div class="row" >
									<div class="col-md-6">
										<div class="form-group">
											<!--<label for="exampleInputEmail1">Remarks</label>-->
										<?php 
										if($query->num_rows() > 0){
										?>
										<input type="text" name="rmk_date" id="rmk_date" class="form-control" value="<?php echo date('Y-m-d'); ?>" readonly />
											<textarea name="remark" id="remark" class="form-control" rows="5" placeholder="Remarks" >Rejection : By <?php echo $rm_row['dept']; ?><?php echo "\n"; ?><?php echo $rm_row['remarks']; ?><?php echo "\n"; ?>Ref : <?php echo $rm_row['inw_no']; ?>, <?php echo date('d-m-Y',strtotime($rm_row['inw_date'])); ?>, DC No : <?php echo $rm_row['dc_no']; ?></textarea>
											<?php } else { ?>
												<h5>There are no remarks.</h5>
											<?php } ?>
											
										</div>
									</div>
								
								</div>
							</div>
						</div>
				
				</div>
			</div>
		</div>
	</div>
</div>
</div>
		
<?php 
  $footer_file=APPPATH.'views/include/footer.php';
	require($footer_file);
	?>
		<script type="text/javascript">
			$(document).ready(function () {
				$('.image_file').change(function () {
					var val = $(this).val().toLowerCase();
					var regex = new RegExp("(.*?)\.(jpg|png|jpeg|JPG)$");
					if(!(regex.test(val))) {
						$(this).val('');
						//alert('Please select correct file format');
						document.getElementById('errfn2').innerHTML="Please upload only image file";
					} }); });
		</script> 
		<script type="text/javascript">
			 $(document).ready(function () {
				 $('.image_file').change(function () {
			// function PreviewImage() {
					pdffile=document.getElementById("bill_upload").files[0];
					pdffile_url=URL.createObjectURL(pdffile);
					$('#viewer').attr('src',pdffile_url);
			   // }
				 });
			 });
		</script>
	<script>
	$("#print_receipt").click(function() {
		window.print();
		setTimeout("closePrintView()", 50);
	});
	function closePrintView() {
		window.location = '<?php echo site_url('ProductRequest/str_pride_inward');?>';
	} 
</script>
</body>
</html>