<?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-12 col-12 mb-2 breadcrumb-new">
            <h3 class="content-header-title mb-0 d-inline-block">Rejection</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="#">Material Request</a>
                  </li>
                  <li class="breadcrumb-item active">Rejection 
                  </li>
                </ol>
              </div>
            </div>
          </div>
          
        </div>
        <div class="content-body"><!-- Basic form layout section start -->
<section id="basic-form-layouts">
	



	<div class="row justify-content-md-center">
		<div class="col-md-12">
		    <form class="form" autocomplete="off" action="<?php echo site_url('MaterialRequest/addRejection');?>" method="post" enctype="multipart/form-data">
			<div class="card">
				
				<div class="card-content collapse show">
					<div class="card-body">

						
					<?php 	foreach($receipt as $rcp) ?>
						
							<div class="row justify-content-md-left">
							<div class="col-md-3">
								<div class="form-group">
									<label>Issue NO</label>
									<input type="text" name="issue_no" id="issue_no" class="form-control" value="<?php echo $rcp->issue_no; ?>" readonly />
								</div>
							</div>
							<div class="col-md-3">
								<div class="form-group">
									<label>RCP NO</label>
									<input type="text" name="rcp_no" id="rcp_no" class="form-control" value="<?php echo $rcp->req_rec_no; ?>" readonly />
								</div>
							</div>
							<div class="col-md-2">
								<div class="form-group">
									<label>RCP DATE</label>
										<input class="form-control" type="text" name="rcp_date"  id="rcp_date" value="<?php echo $rcp->receipt_date; ?>" readonly >
								</div>
							</div>
							<div class="col-md-2">
								<div class="form-group">
									<label>Rejection DATE</label>
									<?php $cur_date = date("d-m-Y"); ?>
										<input class="form-control" type="text" name="rjn_date"  id="rjn_date" value="<?php echo $cur_date; ?>" readonly >
								</div>
							</div>
							<div class="col-md-2">
								<div class="form-group">
									<label>Store</label>
									<input class="form-control" type="text" name="store" id="store" value="<?php echo $rcp->store; ?>" >
									<input class="form-control" type="hidden" name="rcp_id" id="rcp_id" value="<?php echo $rcp->req_rec_id; ?>" >
									<input class="form-control" type="hidden" name="iss_id" id="iss_id" value="<?php echo $rcp->issue_id; ?>" >
									<input type="hidden" name="branchname" id="branchname" class="form-control" value="<?php echo $_SESSION['branch_name']?>"/>
									<input type="hidden" name="branch_id" id="branch_id" class="form-control" value="<?php echo $_SESSION['branch_id']?>"/>
									<input type="hidden" name="uname" id="uname" class="form-control" value="<?php echo $_SESSION['username']?>"/>
									<input type="hidden" name="user_name" id="user_name" class="form-control" value="<?php echo $_SESSION['full_name']?>"/>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="row">		
								
						<?php
					
					$count = 1;
					foreach($receipt_item as $rcpitem){
					?>
					 <div class="col-md-5">
    			<div class="card">
    				<div class="card-content collapse show">
    					<div class="card-body">
					
						
									<div class="row">
											<div class="col-md-6">
												<div class="form-group">
													<input class="form-control" type="text" name="iname[]" id="iname" value="<?php echo $rcpitem->indent_item_name; ?>" readonly />
												</div>
											</div>
											<div class="col-md-3">
												<div class="form-group">
													<input class="form-control" type="text" name="iqty[]"  id="iqty" value="<?php echo $rcpitem->indent_qty; ?>" readonly />
												</div>
											</div>
											<div class="col-md-3">
												<div class="form-group">
													<input class="form-control" type="text" name="rc_qty[]" id="rc_qty" value="<?php echo $rcpitem->quantity; ?>" disabled />
												</div>
											</div>
										</div>
									
							</div>
                    </div>
                </div>
            </div>
            
            <div class="col-md-7">
    			<div class="card">
    				<div class="card-content collapse show">
    					<div class="card-body">			
										<?php
											if($rcpitem->quantity == $rcpitem->rejected_qty) {
										?>
										
										<div class="row">
											<div class="col-md-2">
												<div class="form-group">
													<input class="form-control" type="text" name="rqty"  id="rqty[]" value="<?php echo $rcpitem->rejected_qty; ?>" data-uk-tooltip="{pos:'bottom'}" title="Rejected Qty" value="<?php echo $rcpitem->rejected_qty; ?>" disabled />
												</div>
											</div>
											<div class="col-md-1">
												<div class="form-group">
													<img src="<?php echo base_url(); ?>app-assets/images/right.png" alt="" class="img_main"/>
												</div>
											</div>
											<div class="col-md-2">
												<div class="form-group">
													<span>Rejected</span>
												</div>
											</div>
										</div>
										
										<?php
											} else {
										?>
										
											<div class="row">
													<?php $item = $rcpitem->indent_item_name;
													$branch_id = $_SESSION['branch_id'];
													$q1 = $this->db->query("SELECT * from item_creation where item_name='$item' and branch_id='$branch_id'");
													$qr = $q1->row_array();
													?>
													<input class="form-control col-md-2 qty" type="text" name="rjn_quantity[]"  id="rjn_quantity"  placeholder="Qty" data-uk-tooltip="{pos:'bottom'}" title="Enter Less or Equal : <?php echo $rcpitem->rejection_bal_qty; ?> Qty" />
													<input class="form-control col-md-2 rej_qty" type="text" name="rejected_qty[]" id="rejected_qty" value="<?php echo $rcpitem->rejected_qty; ?>" data-uk-tooltip="{pos:'bottom'}" title="Rejected Qty" style="margin-left: 10px!important;" />
													<input class="form-control col-md-2 qty_pending" type="hidden" name="rejection_bal_qty[]" id="rejection_bal_qty" value="<?php echo $rcpitem->rejection_bal_qty; ?>" />
													<input class="form-control col-md-2 stk" type="text" name="stock[]" id="stock" value="<?php echo $qr['stock_item']; ?>" />
													<input class="form-control col-md-3 remarks" type="text" name="rjn_remarks[]" id="rjn_remarks" placeholder="Remarks" />
																									
													<input class="form-control" type="hidden" name="rcp_item_id[]" id="rcp_item_id" value="<?php echo $rcpitem->receipt_item_id; ?>">
													<input class="form-control" type="hidden" name="item_name[]" id="item_name" value="<?php echo $rcpitem->indent_item_name; ?>" readonly />
													<input class="form-control" type="hidden" name="issue_qty[]" id="issue_qty" value="<?php echo $rcpitem->indent_qty; ?>" readonly />
													<input class="form-control" type="hidden" name="rcp_qty[]"  id="rcp_qty" value="<?php echo $rcpitem->quantity; ?>" readonly />
													<input class="form-control" type="hidden" name="item_id[]" id="item_id" value="<?php echo $qr['item_id']; ?>">
													<input class="form-control" type="hidden" name="itm_id[]" id="itm_id" value="<?php echo $qr['itm_id']; ?>">
													<input class="form-control" type="hidden" name="cat_id[]" id="cat_id" value="<?php echo $qr['category_id']; ?>">
													<img src="<?php echo base_url(); ?>app-assets/images/wrong.png" alt="" class="img_main col-md-1" style="    margin-left: 26px!important;"/>
												</div>
											
										
										<?php
										}
									?>	
								</div>
                    </div>
                </div>
            </div>
            <?php $count++; } ?>
		</div>			
				<br/>
				<div class="card">
							<div class="content">
								<div class="row">
									<div class="col-md-12 ">
										<div class="form-group text-right" style="margin-top: 10px!important;margin-right: 39px!important;">
											<button type="submit" id="submit" class="btn btn-primary" onclick="return confirm('Are you sure you want to submit?')">
												<i class="la la-check-square-o"></i> Submit
											</button>
										</div>
									</div>
								</div>
							</div>
						</div>
				
			</form>
			<br/>
				</div>
				</div>
			</div>
		</div>
	</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>
		
			$(".qty").each( function(){ $(this).on( {'keyup': function() { 
				var q1 = $(this).parent().find('.qty').val();
				var q2 = $(this).parent().find('.qty_pending').val();
				//var grand = $(this).parent().find('.grand').val();
				if(parseFloat(q1) <= parseFloat(q2)){
					//alert("sucess");
				}
				else{
					alert("You cant reject more than the recieved balance quantity");
					$(this).parent().find('.qty').val('0');
				}
			}
			})
			})
	
	</script>
	<script>
		
			$(".qty").each( function(){ $(this).on( {'keyup': function() { 
				var q1 = $(this).parent().find('.qty').val();
				var q2 = $(this).parent().find('.stk').val();
				//var grand = $(this).parent().find('.grand').val();
				if(parseFloat(q1) <= parseFloat(q2)){
					//alert("sucess");
				}
				else{
					alert("You cant enter more than the present stock");
					$(this).parent().find('.qty').val('0');
				}
			}
			})
			})
	
	</script>
     <script>
	$(window).on('beforeunload', function () {
         //$("input[type=submit], input[type=button]").prop("disabled", "disabled");
		 $("input[type=submit]").prop("disabled", "disabled");
		 $("#submit").css("background-color","#dcdcdc");
    });
    
    $(document).ready(function() {
  $(window).keydown(function(event){
    if(event.keyCode == 13) {
      event.preventDefault();
      return false;
    }
  });
});
</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>