<?php 
	$header_file=APPPATH.'views/include/header.php';
	require($header_file);
	$sidenav_file=APPPATH.'views/include/sidenav.php';
	require($sidenav_file);	?>
   
   <style>
		.redText{ color : red; }
	</style>
	
    <!-- 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 Creation
                  </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('Master/itemInsert');?>" method="post" enctype="multipart/form-data">
			<div class="card">
				<div class="card-header">
					<h4 class="card-title" id="basic-layout-form-center">Raw Material Creation</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">

                	
							<div class="row justify-content-md-center card_margin">
								<div class="col-md-4">
									<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)
													{
														echo '<option value="'.$row->category_id.'">'.$row->category_name.'</option>';
													} 
												?>
												
											</select>
										<input type="hidden" name="cat_name" id="cat_name">
										</div>
									</div>
								</div>
								<div class="col-md-4">
									<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"  required placeholder="Enter Product name"/>
											<span id="err" class="redText" style="display:none;">Product Already in Use</span>
										</div>
									</div>
								</div>
								<div class="col-md-4">
									<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" required  placeholder="UOM" />
											<input type="hidden" name="unitid" class="form-control unitid" id="unitid"    />
											<?php $cur_date = date("Y-m-d"); ?>
											<input class="form-control" type="hidden" name="creation_date"  id="creation_date" value="<?php echo $cur_date ?>" readonly >
											
										</div>
									</div>
								</div>
								<div class="col-md-4">
									<div class="form-body">
										<div class="form-group">
											<label>HSN Code</label>
											<input type="text" name="hsn_code" class="form-control" id="hsn_code" placeholder="HSN Code"  />
										</div>
									</div>
								</div>
								<div class="col-md-4">
									<div class="form-body">
										<div class="form-group">
											<label>Price</label>
											<input type="text" name="price" class="form-control" id="price" placeholder="Price"  />
										</div>
									</div>
								</div>
								<div class="col-md-4">
									<div class="form-body">
										<div class="form-group">
											<label>Tax</label>
											<input type="text" name="tax" class="form-control" id="tax" placeholder="Tax"  />
										</div>
									</div>
								</div>
								
								<?php 
        							foreach($branch as $row) { ?>
        								<input class="form-control" type="hidden" name="branch[]"  id="branch" value="<?php echo $row->branch_id ?>" readonly >
        								<input class="form-control" type="hidden" name="branch_name[]" id="branch_name" value="<?php echo $row->branch_name ?>" readonly >
    							<?php 
    							}
    							?>
    						
								
							</div>
						</div>
					</div>
				</div>
			
			<div class="card">
				<div class="card-content collapse show">
					<div class="card-body">
					    <div class="text-right">
					        <div class="row card_margin">
							    <div class="col-md-4">
									<?php
									    $user = 'CEO';
        								$q1 = $this->db->query("SELECT * FROM user where username='$user'");
        								foreach($q1->result_array() as $r1) 
        								$phone_no = $r1['ph_no'];
									?>
									<input type="hidden" name="ph_no" id="ph_no" value="<?php echo $phone_no ?>" >
								</div>
								
								<div class="col-md-8 mleft">
    								<button type="reset" class="btn btn-sm btn-secondary ">
    									<i class="ft-x-circle"></i> Cancel
    								</button>
    								<button type="submit" class="btn btn-sm btn-primary" onClick="return req_fr_item_apprv();" >
    									<i class="ft-save"></i> Submit
    								</button>
    							</div>
							</div>
						</div>

					</div>
				</div>
			</div>
			</form>	
		</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">
    $("#category_id").change(function (){
		var cat_name = $(this).find("option:selected").text();
		$("#cat_name").val(cat_name);
	});
    
	$(function () {
		$('#branch').multiselect({
			includeSelectAllOption: true
		});
	});
	
	$(function () {
		$('#sale_br_id').multiselect({
			includeSelectAllOption: true
		});
	});
	$(function () {
		$('#santhe_br_id').multiselect({
			includeSelectAllOption: true
		});
	});
	$("#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();
			
		}
	});
	
	$("#unit_of_measure").autocomplete({ 
		minLength: 1,
		source: '<?php echo 
		base_url();?>index.php/Master/get_auoto_uom',
		select:function(evt, ui)
		{	
			//alert(ui.item.price);
			$('#unitid').val(ui.item.unitid);
				$('#unitid').blur();
		}	
	});
	
	$("#product_name").autocomplete({ 
		minLength: 1,
		source: '<?php echo 
		base_url();?>index.php/Master/get_auoto_item',
		select:function(evt, ui)
		{	
			//alert(ui.item.price);
			$('#unitid').val(ui.item.unitid);
				$('#unitid').blur();
		}	
	});
</script>
<script>
	$("#product_name").change(function(){
		var product_name = $("#product_name").val();
		//alert(product_name);
		$.ajax({
			type :'POST',
			dataType:'json',
			data : { product_name : product_name },
			url : '<?php echo base_url();?>index.php/Master/item_check',
			success: function(data) {
				//$("div#er").css("display","block");
				//$('#er').html(data.c);
				
				ct = (data.counts);
				//alert(ct);
				if(ct>0)
				{
					//alert("You cant add Register for this Sponsor  ");
					$("#submit").attr("disabled", "disabled");
					$("span#err").css("display","block");
					
					}else{
					$("#submit").removeAttr("disabled");
					$("span#err").css("display","none");
				}
			}
		});
	});
	

</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>