<?php 
	$header_file=APPPATH.'views/include/header.php';
	require($header_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-12 col-12 mb-2 breadcrumb-new">
            <h3 class="content-header-title mb-0 d-inline-block">Requset order list</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="#">Product Request</a>
                  </li>
                  <li class="breadcrumb-item active">Requset order list
                  </li>
                </ol>
              </div>
            </div>
          </div>
        
        </div>
        <div class="content-body"><!-- Zero configuration table -->
<section id="configuration">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <!--<div class="card-header">
                    <h4 class="card-title">Requset order list</h4>
                    <a class="heading-elements-toggle"><i class="la la-ellipsis-v font-medium-3"></i></a>
                    <div class="heading-elements">
                        <ul class="list-inline mb-0">
                            <li><a data-action="collapse"><i class="ft-minus"></i></a></li>
                            <li><a data-action="reload"><i class="ft-rotate-cw"></i></a></li>
                            <li><a data-action="expand"><i class="ft-maximize"></i></a></li>
                            <li><a data-action="close"><i class="ft-x"></i></a></li>
                        </ul>
                    </div>
                </div>-->
                <div class="card-content collapse show">
                    <div class="card-body card-dashboard">
                        <div class="table-responsive">
						    <table class="table">
                                <thead>
                                    <tr>
                                        <th>REQ No</th>
										<th>REQ Date</th>
										<th>Department</th>
										<th>Manual Close</th>
									</tr>
                                </thead>
                                <tbody>
								 <?php
									$count =1;
									foreach($req_list as $rlist)
									{
								?>
                                    <tr>
									<td><?php echo $rlist->pr_req_no; ?></td>
									<td><?php echo $rlist->request_date; ?></td>
									<td><?php echo $rlist->dept; ?></td>
									<?php 
										$req_id = $rlist->request_id;
										$q1 = $this->db->query("SELECT * FROM product_request P inner join product_request_item PI on P.request_id=PI.request_id where P.request_id='$req_id'");
										$req_res = $q1->result();
										$count1 = 0;
										$count2 = 0;
										$count3 = 0;
										$count4 = 0;
										$status;
										$rec_status = 'equal';
										$rev_status = 'equal';
										foreach($req_res as $req_row)
										{
											$status = $req_row->mclose_status;
											if(($req_row->recieved_qty == $req_row->receipt_qty))
											{	
												$count2++;	
											}
											$count1++;
											if($req_row->recieved_qty == '0')
											{	
												$count3++;	
											}
											if($req_row->receipt_qty == '0')
											{	
												$count4++;	
											}
											if($count1 == $count3)
											{
												$rec_status = 'equal';
											}
											else {
												$rec_status = 'rcnotequal';
											}
											if($count1 == $count4)
											{
												$rev_status = 'equal';
											}
											else {
												$rev_status = 'rvnotequal';
											}
										}
									?>
									<td>
										<?php if($req_row->status == 'Closed') { ?>
										<!--<button class="btn btn-lg btn-success font-medium-1 grid-form-dialog-btn mt-1">Close Manuals</button>-->
									<div class="col-lg-4 col-sm-4 col-12">
										<div class="form-group text-center">
											<button class="btn btn-sm btn-success font-medium-1 grid-form-dialog-btn mt-1">Close Manual</button>
											<p class="font-small-3 mt-1"></p>
											<div class="grid-form-dialog" title="Manual Request Close">
												<div class="container">
													<form action="" class="uk-form-stacked"  method="post" autocomplete="off">
														<div class="form-group row">
															<label for="inputEmail3" class="col-sm-2 col-form-label">Enter Remarks</label>
															<div class="col-sm-10">
															<input name="request_id" id="request_id" type="hidden" class="textbox" value="<?php echo $rlist->request_id; ?>" >
																<input type="text" class="form-control"name="req_remark" id="req_remark">
															</div>
														</div>
														
														<div class="form-group row">
															<div class="offset-sm-2 col-sm-10">
																<button type="button" class="md-btn md-btn-flat uk-modal-close">Close</button>
																<input type="button" class="md-btn md-btn-flat md-btn-flat-primary" value="Confirm" name="submit3" id="submit3">
															</div>
														</div>
													</form>
												</div>
											</div>
										</div>
									</div>
									<?php } else { ?>
										<button class="btn btn-sm btn-danger disabled">Close Manual</button>
									<?php } ?> 
									
									</td>
								</tr>
                                    
                                   <?php
								  $count++;
								}
							  
							?>
							</tbody>
                            </table>
						</div>
						
						<div class="table-responsive">
						    <table class="table">
                                <thead>
                                    <tr>
                                        <th>Issue No </th>
										<th>Issue Date</th>
										<th>Issue Status</th>
										<th>View</th>
									</tr>
                                </thead>
                                <tbody>
								 <?php
									$count =1;
									foreach($req_iss_list as $rqlist)
									{
								?>
                                    <tr>
									<td><?php echo $rqlist->issue_no; ?></td>
									<td><?php echo $rqlist->issue_date; ?></td>
									<?php if($rqlist->issue_status == 'Pending') { ?>
									<td class="pending_data"><?php echo $rqlist->issue_status; ?></td>
									<td class="uk-text-nowrap">
										<a href="<?php echo site_url('ProductRequest/issueInward/'. $rqlist->request_id .'/'. $rqlist->issue_id); ?>" class="btn btn-sm btn-info"> Add Receipt</a>
									</td>
									<?php } else { ?>
									<td class="success_data"><?php echo $rqlist->issue_status; ?></td>
									<td class="uk-text-nowrap">
										<a href="#" class="btn btn-sm btn-info disabled"> Add Receipt</a>
									</td>
									<?php } ?>
								</tr>
                                    
                                   <?php
								  $count++;
								}
							  
							?>
							</tbody>
                            </table>
						</div>
					
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<!--/ Zero configuration table -->



<!--/ Language - Comma decimal place table -->

        </div>
      </div>
    </div>
    <!-- END: Content-->

   <?php //require('include/theme_customizer.php');?>
 <?php 
  $footer_file=APPPATH.'views/include/footer.php';
	require($footer_file);
	?>
	
<script>
	$('#submit3').click(function() {
		var req_remark = $('#req_remark').val();
		var req_id = $('#request_id').val();
		if(req_remark == '')
		{
			alert("Please Enter Remarks");
			return false;
		}
		else
		{
			$.ajax({
				type: "POST",
				dataType:'json',
				data : { req_id : req_id, req_remark : req_remark },
				url: "<?php echo base_url();?>index.php/MaterialRequest/requestRmkissUpdate",
				success: function(dataz) { 
					setTimeout(function() {
						window.location.href = '<?php echo site_url('MaterialRequest/requestClosedList');?>';
					}, 200);
				}
			});
		}
	});
</script>
<script>
	$('.param_check').each(function() { $(this).on( {'click contextmenu': function() {
		//contextmenu
		var i = $(this).data('value');
		var anchor = $("a");
		var anchorTarget = $(this).parent().find('.parmetre').val();
		var submodid = $(this).parent().find('.submod_id').val();
		var link = $(this).attr('href');
		$(this).attr("href", link + submodid +'/'+anchorTarget);

		location.reload();
	}
	})
	})
</script>  
  </body>
  <!-- END: Body-->

<!-- Mirrored from pixinvent.com/modern-admin-clean-bootstrap-4-dashboard-html-template/html/ltr/vertical-modern-menu-template/form-layout-basic.html by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Apr 2020 09:38:02 GMT -->
</html>