<div class="QuotationPrint">
<div class="content" >
	
	<div class="main-content">
		<!-- DATA EXPORT -->
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-user"></i> Quotation request</h3> <em> - Add New Quotation Request Record</em>
				<div class="btn-group widget-header-toolbar">
					<a class="btn-borderless btn-focus clickme" href="QuotationRequestview" title="Focus" ><i class="fa fa-eye"></i></a>
				</div>
				
			</div>
			<div class="widget-content">
				
				<input type="hidden" name="_token" value="{{ csrf_token() }}">						
				
				<div class="alert  alert-info " >
					<ul><li class="fa fa-cog  fa-1x fa-fw"></li>Kindly enter Quotation request details..</ul>
				</div>						
				<div class="alert alert-success print-success-msg" style="display:none">
					<ul></ul>
				</div>	
				<div class="alert alert-danger print-error-msg" style="display:none">
					<ul></ul>
				</div>
				
				<div class="col-md-6">
					<!-- ADVANCED VALIDATION -->
					<div class="widget-content">  
						
						<div class="form-group">
							<label for="text-input1">Quotation No.*</label>
							<input type="text" name="itemcode" id="itemcode" class="form-control" value="{{ $data['Quotatn']}}" onchange="validatecode(this.value)" disabled>
							<small class="text-danger" id="erritemcode"></small>
						</div>
						
						<div class="form-group">
							<label for="multiselect1">Company*</label>
							<select name="itemcategory" id="itemcategory" class="form-control" required onchange="loadsubcat(this.value)">
								<option value="0">-- Select --</option>
								<?php
								foreach($data['company'] as $comp)
								{
									echo "<option value='".$comp->cmp_id."' >".$comp->cmp_name."</option>";
								}
								?>
							</select>
							<small class="text-danger" id="erritemcategory"></small>
						</div> 
						
					</div>
					<!-- END ADVANCED VALIDATION -->
				</div>
				
				<div class="col-md-6">
					<!-- ADVANCED VALIDATION -->
					<div class="widget-content">
						
						<div class="form-group">
							<label for="text-input1">Quotation date*</label>
							<input type="date" name="salescost" id="salescost" class="form-control" value="<?php echo date('Y-m-d');?>" data-date-format="yyyy-mm-dd" >
							<small class="text-danger" id="erritemtype"></small>
						</div>
						
						<div class="form-group">
							<label for="multiselect1">Seller*</label>
							<select name="itemcategory1" id="itemcategory1" class="form-control" required onchange="loadsubcat(this.value)">
								<option value="0">-- Select --</option>
							</select>
							<small class="text-danger" id="erritemcategory"></small>
						</div>
					</div>
					<!-- END ADVANCED VALIDATION -->
				</div>                    
				
				
			</div>
			
		</div>
		<!-- END DATA EXPORT -->
		
		
		<!-- DATA EXPORT -->
		<div class="widget">
			<div class="widget-header">
				<h3><i class="fa fa-user"></i> Item Record</h3> <em> - Add item details</em>
			</div>
			<div class="widget-content">
				<form id="frmmain" name="frmmain" data-parsley-validate novalidate>
					<div class="panel-body">
						<input type="hidden"  id="num" name="num" value="1" ><br>
						
						<div class="col-sm-4 nopadding">
							<div class="form-group">
								<label for="multiselect1">Item Name*</label>
								<br/>
								<select name="Schoolname1" id="Schoolname1" class="form-control" onclick="product()" required>
									<option value="0">Select</option>
									<?php foreach($data['itemCompany'] as $item){
								      	echo "<option value='".$item->itm_id."' >".$item->itm_name."";
									    echo "</option>";
									}?>
								</select>
							</div>
						</div>
						<div class="col-sm-2 nopadding">
							<div class="form-group">
								<label for="multiselect1">Quantity*</label>
								<br/>
								<input type="text" class="form-control" id="Major1" name="Major1" value="" placeholder="Item Quantity" required>
							</div>
						</div>
						<div class="col-sm-4 nopadding">
							<div class="form-group">
								<label for="multiselect1">Description*</label>
								<br/>
								<input type="text" class="form-control" id="Degree1" name="Degree1" value="" placeholder="Item Description"required>
							</div>
						</div>				
						<div class="col-sm-2 nopadding">
							<div class="form-group">
								<label for="multiselect1">     </label>
								<br/>
								<div class="input-group">
									
									<div class="input-group-btn">
										
									</div>
								</div>
							</div>
						</div>
						<div class="clear"></div>
						<div id="education_fields">
							
						</div>
						
						<div class="col-sm-3 nopadding">
							<div class="form-group">
								<div class="input-group">
									
									<div class="input-group-btn">
										
										<button type="button"  value="Add" class="form-control" onclick="education_fields();" >ADD</button>
									</div>
								</div>
							</div>
						</div>
						
					</div>
					

					
				</form>
				
			</div>
			
		</div>
		<!-- END DATA EXPORT -->
		
		
		<!-- DATA EXPORT -->
		<div class="widget widget-table">
			<div class="widget-header">
				<h3><i class="fa fa-user"></i> Billing</h3> <em> - Billing Calculation</em>
			</div>
			<div class="widget-content">
				
				
				
				
				<div class="col-md-12">
					<!-- ADVANCED VALIDATION -->
					<div class="widget-content">
						
						<div class="form-group">
							<label>Note (Any note)</label>
							<textarea class="form-control" name="description" id="description" rows="4" cols="30" required></textarea>
							<small class="text-danger" id="errdescription" ></small>
						</div>
						<div class="form-group">
							<label for="multiselect1">Status*</label>
							<br/>
							<select name="status" id="status" class="form-control" required>
								<option value="Active" >Active</option>
								<option value="Inactive">Inactive</option>
							</select>
							<small class="text-danger" id="errstatus"></small>
						</div>
					</div>
					<!-- END ADVANCED VALIDATION -->
				</div>
				<div class="col-md-12">
					<div class="form-group">
		<center><button class="btn btn-primary SubmitQutaion">Submit Quotation Request</button></center>
					</div>
				</div>                        
				
				
			</div>
			
		</div>
		<!-- END DATA EXPORT -->
		
	</div>
</div>
</div>
<!-- /main -->
<script src="js/jquery.validate.min.js"></script>
<script src="js/bootstrap-datepicker.js"/>	
<script>
	$('.clickme').click(function(e)
	{
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href'));
	});
	
	$('.view').click(function(e)
	{
		$('#sideMenu').load('QuotationRequestview');
	});
	
	$('#itemcategory').change(function(e)
	{
		id=$('#itemcategory').val();
		e.preventDefault();
		$.ajax({
			url: 'SubCompanyDetail',
			type: 'get',
			data:'&compId='+id,
			success: function(data) {
				
				var sel = document.getElementById('itemcategory1');
				for (i = sel.length - 1; i >= 0; i--) {
					sel.remove(i);
				}
				
				var jsonData = JSON.parse(data);
				for (var i = 0; i < jsonData.length; i++) {
					var prop = jsonData[i];
					$("#itemcategory1").append("<option value=\"" + prop.cst_id +"\">"+ prop.cst_name +"</option>");
				}
				
			}
		});
	});
	
	var room = 1;
	function education_fields() {		
		room++;
		var objTo = document.getElementById('education_fields')
		var divtest = document.createElement("div");
		divtest.setAttribute("class", "form-group removeclass"+room);
		var rdiv = 'removeclass'+room;
		divtest.innerHTML = '<div class="col-sm-4 nopadding"><div class="form-group"> <select name="Schoolname'+ room +'" id="Schoolname'+ room +'" class="form-control" required><option value="0"></option><?php foreach($data['itemCompany'] as $item){echo"<option value=".$item->itm_id.">".$item->itm_name."</option>";}?></option></select></div></div><div class="col-sm-2 nopadding"><div class="form-group"> <input type="text" class="form-control" id="Major" name="Major'+ room +'" value="" placeholder="Item Quantity" required></div></div><div class="col-sm-4 nopadding"><div class="form-group"> <input type="text" class="form-control" id="Degree" name="Degree'+ room +'" value="" placeholder="Item Description"required></div></div><div class="col-sm-2 nopadding"><div class="form-group"><div class="input-group"> <div class="input-group-btn"><button type="button" class="form-control" onclick="remove_education_fields('+ room +');" >REMOVE</button></div></div></div></div><div class="clear"></div>';
		
		objTo.appendChild(divtest)
		$('#num').val(room);
	}
	function remove_education_fields(rid) {
		room--;
		$('.removeclass'+rid).remove();
		$('#num').val(room);
	}

	$('.SubmitQutaion').click(function(e)
	{
		$('#frmmain').validate({
			rules:
			{
				Major:
				{
					required:true,
					number:true
				},
				
			}
		});
		if($('#frmmain').valid())
		{
			e.preventDefault();
			description=$('#description').val();
			itemcategory1=$('#itemcategory1').val();
			itemcode=$('#itemcode').val();
			saleorderdate=$('#saleorderdate').val();
			itemcategory=$('#itemcategory').val();
			status=$('#status').val();
			$.ajax({
				url: 'QutationRequest',
				type: 'get',
				data:$('#frmmain').serialize() +'&description='+description+'&itemcategory1='+itemcategory1+'&itemcode='+itemcode+'&saleorderdate='+saleorderdate+'&itemcategory='+itemcategory+'&status='+status,
				success: function(data)
				{
					Qutatationprint(data); 
					//$('#sideMenu').load('QuotationRequestview');
				}
			});
		}
	});
	
	function Qutatationprint(Billno)
	{
		$.ajax({
					url: 'QuotationPrint',
					type: 'get',
					data:'&Billno='+Billno,
					success: function(data)
					{
						$('.QuotationPrint').html(data)
					}
			});	
	}
</script>