<?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">Raw Material </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="#">Raw Material</a>
                  </li>
                  <li class="breadcrumb-item active">Raw Material Updation
                  </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">
			<div class="card">
				<div class="card-header">
					<h4 class="card-title" id="basic-layout-form-center">Raw Material Updation</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">

						 <?php 	foreach($rawItem as $key => $data) ?>

						<form class="form" autocomplete="off" action="<?php echo site_url('Master/updateRaws');?>" method="post" enctype="multipart/form-data">
							<div class="row justify-content-md-center">
								<div class="col-md-6">
									<div class="form-body">
										<div class="form-group">
											<label>Category name</label>
											<select id="category_id" name="category_id" class="select2 form-control" required>
											<optgroup>
												<option value="">Select Category name...</option>
												<?php  
													foreach($category as $row)
													{
													?> <option  <?php if($row->category_id == $data->category_id) echo 'selected="selected"'; ?> value="<?php echo $row->category_id;?>"><?php echo $row->category_name;?></option>
												<?php 	} 
												?>
												
											</select>
										
										</div>
									</div>
								</div>
								<div class="col-md-6">
									<div class="form-body">
										<div class="form-group">
											<label>Product Name</label>
											<input type="text" name="product_name" class="form-control product_name pname" id="product_name" value="<?php echo $data->item_name ?>" required placeholder="Enter Product name"/>
											<input type="hidden" name="itm_id" class="form-control " id="itm_id" value="<?php echo $data->itm_id;?>"   />
											<span id="err" class="redText" style="display:none;">Product Already in Use</span>
											<input type="hidden" class="sub_mod_id" name="sub_mod_id" id="submod_id" value="<?php echo $submod_id; ?>" >
										</div>
									</div>
								</div>
								<div class="col-md-6">
									<div class="form-body">
										<div class="form-group">
											<label>UOM</label>
											<input type="text" name="unit_of_measure" class="form-control unit_of" id="unit_of_measure" value="<?php echo $data->uom;?>"  placeholder="UOM" />
											
											<?php $cur_date = date("Y-m-d"); ?>
											<input class="form-control" type="hidden" name="creation_date"  id="creation_date" value="<?php echo $data->creation_date ?>" readonly >
											
										</div>
									</div>
								</div>
								<div class="col-md-6">
									<div class="form-body">
										<div class="form-group">
											<label>Minimum Stock Level</label>
											<input type="text" name="min_stk" class="form-control" id="min_stk" value="<?php echo $data->min_stk ;?>" placeholder="Minimum Stock Level" />
										</div>
									</div>
								</div>
									<div class="col-md-6">
									<div class="form-body">
										<div class="form-group">
											<label for="eventInput1">Branch</label>
											
											<select name="branch[]" id="branch" class="select2 form-control" required multiple="multiple" >
												
												<?php
														$updated_in = array();
														$updated_id = array();
														foreach($branch as $sbr)
														{
															$updated_in[] = $sbr->branch_name;
															$updated_id[] = $sbr->branch_id;
														}
														$up = array();
														foreach($rbranch as $key => $data3){
															
															$up[] = $data3->branchname;
														}
														for($j=0;$j<count($updated_in);$j++)
														{
															if(in_array($updated_in[$j],$up))
															{
														?>
															<option value="<?php echo $updated_id[$j]?>" selected="selected" ><?php echo $updated_in[$j]?></option>
														<?php
															}
															else
															{
														?>
															<option value="<?php echo $updated_id[$j]?>"><?php echo $updated_in[$j]?></option>
														<?php
															}
														}
														?>
											</select>
											
											<input type="hidden" id="branch_name" name="branch_name"  >
										</div>
									</div>
								</div>
								<div class="col-md-6">
									<div class="col-md-6">
										<div class="form-body">
											<div class="form-group" style="margin-top:38px;">
												<label for="eventInput1">Direct Sales<span class="redText"></span></label>
												<label class="radio-inline">
													<input type="radio" name="direct_sales" id="yes" value="Yes" <?php if($data->direct_sales == 'Yes') echo 'checked="checked"'; ?> />Yes
												</label>
												<label class="radio-inline">
													<input type="radio" name="direct_sales" id="no" value="No"  <?php if($data->direct_sales == 'No') echo 'checked="checked"'; ?> />No 
												</label>
												
											</div>
											
										</div>
									</div>
									<div class="col-md-6" id="sale_branch" style="display:none">
										<div class="form-body">
											<div class="form-group">
												<?php  foreach($salebranch as $data1)
														{
														?>
													<input type="hidden" name="sale_br_id[]" id="sale_br_id" value="<?php echo $data1->branch_id;?>">
													<input type="hidden" id="sale_br_name" name="sale_br_name[]" value="<?php echo $data1->branch_name;?>" >
													<?php
													} 
													?>
												
											</div>
										</div>
									</div>
								</div>
								<div class="col-md-6">
									<div class="col-md-6">
										<div class="form-body">
											<div class="form-group">
												<label for="eventInput1">Allowed for Santhe<span class="redText"></span></label>
												<label class="radio-inline">
													<input type="radio" name="santhe" id="syes" value="Yes"  <?php if($data->santhe == 'Yes') echo 'checked="checked"'; ?>  />Yes
												</label>
												<label class="radio-inline">
													<input type="radio" name="santhe" id="sno" value="No"  <?php if($data->santhe == 'No') echo 'checked="checked"'; ?> />No 
												</label>
												
											</div>
										</div>
									</div>
									<div class="col-md-6" id="santhe_branch" style="display:none">
										<div class="form-body">
											<div class="form-group">
													
													<?php  foreach($santhebranch as $data2)
														{
														?>
														<input type="hidden" name="santhe_br_id[]" id="santhe_br_id" value="<?php echo $data2->branch_id;?>">
														<input type="hidden" id="santhe_br_name[]" name="santhe_br_name[]" value="<?php echo $data2->branch_name;?>" >
													<?php
													} 
													?>
												
												
											</div>
										</div>
									</div>
								</div>
							    <div class="col-md-6">
									<div class="form-body">
										<div class="form-group" style="padding-left:16px;">
											<label for="eventInput1">Expiry Date<span class="redText"></span></label>
											<label class="radio-inline">
												<input type="radio" name="expirydate" id="expiryyes" value="Yes"   <?php if($data->expiry_date == 'Yes') echo 'checked="checked"'; ?> />Yes
											</label>
											<label class="radio-inline">
												<input type="radio" name="expirydate" id="expiryno" value="No" <?php if($data->expiry_date == 'No') echo 'checked="checked"'; ?> />No 
											</label>
											
										</div>
									</div>
								</div>
								
							</div>
							
							<div class="form-actions text-center">
								<button type="reset" class="btn btn-warning mr-1">
									<i class="ft-x"></i> Cancel
								</button>
								<button type="submit" class="btn btn-primary">
									<i class="la la-check-square-o"></i> Save
								</button>
							</div>
						</form>	

					</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 type="text/javascript">
	$(function () {
		$('#branch').multiselect({
			includeSelectAllOption: true
		});
	});
	
	$(function () {
		$('#sale_br_id').multiselect({
			includeSelectAllOption: true
		});
	});
	$(function () {
		$('#santhe_br_id').multiselect({
			includeSelectAllOption: true
		});
	});
	$(document).ready(function(){
	var branch = $("#branch option:selected").map(function () {
		return $(this).text();
		}).get().join(',');
		//alert(branch);
		$('#branch_name').val(branch);
	});
	$("#branch").change(function(){
       //var branch = $('#branch option:selected').text();
		var branch = $("#branch option:selected").map(function () {
		return $(this).text();
		}).get().join(',');
		//alert(branch);
		$('#branch_name').val(branch);
	});
	
	$("#sale_br_id").change(function(){
       //var branch = $('#branch option:selected').text();
		var branch = $("#sale_br_id option:selected").map(function () {
		return $(this).text();
		}).get().join(',');
		//alert(branch);
		$('#sale_br_name').val(branch);
	});
	
	$("#santhe_br_id").change(function(){
       //var branch = $('#branch option:selected').text();
		var branch = $("#santhe_br_id option:selected").map(function () {
		return $(this).text();
		}).get().join(',');
		//alert(branch);
		$('#santhe_br_name').val(branch);
	});

	
	$("input[name='direct_sales']").each(function () {
		if ($("#yes").is(":checked")) {
			var m_status = $("#yes").val();
			//alert(pay_mode);
			$("#sale_branch").show();
			
		} 
		else
		{
			$("#sale_branch").hide();
		}
	});
	$("input[name='direct_sales']").click(function () {
		if ($("#yes").is(":checked")) {
			var m_status = $("#yes").val();
			//alert(pay_mode);
			$("#sale_branch").show();
		} 
		else
		{
			$("#sale_branch").hide();
			
		}
	});
	
	$("input[name='santhe']").each(function () {
		if ($("#syes").is(":checked")) {
			var m_status = $("#syes").val();
			//alert(pay_mode);
			$("#santhe_branch").show();
			
		} 
		else
		{
			$("#santhe_branch").hide();
		}
	});
	$("input[name='santhe']").click(function () {
		if ($("#syes").is(":checked")) {
			var m_status = $("#syes").val();
			//alert(pay_mode);
			$("#santhe_branch").show();
		} 
		else
		{
			$("#santhe_branch").hide();
			
		}
	});
</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>