<script src="assets/js/king-table.js"></script>
			<!-- main -->
			<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> Buyer</h3> <em> - Add Buyer records</em>
									<div class="btn-group widget-header-toolbar">
										<a class="btn-borderless btn-focus clickme" href="customerView" title="Focus" ><i class="fa fa-eye"></i></a>
										<!--<a href="#" title="Expand/Collapse" class="btn-borderless btn-toggle-expand"><i class="fa fa-chevron-up"></i></a>
										<a href="#" title="Remove" class="btn-borderless btn-remove"><i class="fa fa-times"></i></a>-->
									</div>
						</div>
						<div class="widget-content">
<?php /* <form id="frmmain" method="POST" action={{route('seller.store')}} name="frmmain" data-parsley-validate novalidate> */ ?>

                    <form id="frmmain" name="frmmain" data-parsley-validate novalidate>
					
<?php echo csrf_field(); ?>

<div class="alert  alert-info " >
    <ul><li class="fa fa-cog  fa-1x fa-fw"></li>Kindly enter Buyer 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="multiselect1">Company Name*</label>
                                <select name="compname" id="compname" class="form-control" required>
								<option value="0">-- Select --</option>
                                </select>
                            <small class="text-danger" id="errcompname"></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">Buyer Type*</label>
                                <select name="custtype" id="custtype" class="form-control" required>                                   
                                    <option value="Buyer">Buyer</option>
									 <option value="Buyer & Seller">Buyer & Seller</option>
                                </select>
								<small class="text-danger" id="errcusttype"></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">Buyer name*</label>
                            <input type="text" name="customername" id="customername" class="form-control" >
                            <small class="text-danger" id="errcustomername"></small>
                        </div>
                        <div class="form-group">
                            <label>Address</label>
                            <textarea class="form-control" name="address" id="address" rows="5" cols="30" ></textarea>
                            <small class="text-danger" id="erraddress" ></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">City</label>
                            <input type="text" name="city" id="city" class="form-control" >
                            <small class="text-danger" id="errcity"></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">State</label>
                            <input type="text" name="state" id="state" class="form-control" >
                            <small class="text-danger" id="errstate"></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">Country</label>
                            <input type="text" name="country" id="country" class="form-control" >
                            <small class="text-danger" id="errcountry"></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">Website</label>
                            <input type="text" name="wwwweb" id="wwwweb" class="form-control" >
                            <small class="text-danger" id="errcountry"></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">Contact No. 1*</label>
                            <input type="text" name="contact1" id="contact1" class="form-control" >
                            <small class="text-danger" id="errcontact1"></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">Contact No. 2</label>
                            <input type="text" name="contact2" id="contact2" class="form-control" >
                            <small class="text-danger" id="errcontact2"></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">Email ID</label>
                            <input type="text" name="emailid" id="emailid" class="form-control" >
                            <small class="text-danger" id="erremailid"></small>
                        </div>
                        <div class="form-group">
                            <label>Bank Account detail</label>
                            <textarea class="form-control" name="bankacct" id="bankacct" rows="5" cols="30" ></textarea>
                            <small class="text-danger" id="errbankacct" ></small>
                        </div>
                        <div class="form-group">
                            <label>Note (Any note)</label>
                            <textarea class="form-control" name="description" id="description" rows="5" cols="30" ></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 type="submit" id="submit" name="submit" class="btn btn-primary">Submit</button></center>
				</div>
</div>                        
                    </form>
                    
						</div>
					</div>
					<!-- END DATA EXPORT -->

				</div>
			</div>
			<!-- /main -->
			
				
<script type="application/javascript">
	i=0;
					$(document).ready(function()
                      {
                       $(document).on('submit', '#frmmain', function()
                       {
						 		$(".alert-info").find("ul").html('<li class="fa fa-cog fa-spin fa-1x fa-fw"></li>Inserting record...');
							   			
								var _token = $("input[name='_token']").val();
								var compname = $("#compname").val();
								var custtype = $("#custtype").val();
								var customername = $("#customername").val();
								var address = $("#address").val();
								var city = $("#city").val();
								var state = $("#state").val();
								var country = $("#country").val();
						   		var wwwweb = $("#wwwweb").val();
								var contact1 = $("#contact1").val();
								var contact2 = $("#contact2").val();
								var emailid = $("#emailid").val();
								var bankacct = $("#bankacct").val();
								var note = $("#description").val();
								var status = $("#status").val();
						   
								document.getElementById("errcompname").innerHTML = "";
								document.getElementById("errcusttype").innerHTML = "";
								document.getElementById("errcustomername").innerHTML = "";
								document.getElementById("errcontact1").innerHTML = "";
						   
							   if(compname == "0")
							   {
									document.getElementById("errcompname").innerHTML = "Company Name should not be empty...";
									$(".alert-info").find("ul").html('<li class="fa fa-cog fa-1x fa-fw"></li>Kindly check the error...');
							   }
							   else if(custtype == "")
							   {
									document.getElementById("errcusttype").innerHTML = "Customer Type should not be empty...";
									$(".alert-info").find("ul").html('<li class="fa fa-cog fa-1x fa-fw"></li>Kindly check the error...');
							   }
							   else if(customername == "")
							   {
									document.getElementById("errcustomername").innerHTML = "Customer Name should not be empty...";
									$(".alert-info").find("ul").html('<li class="fa fa-cog fa-1x fa-fw"></li>Kindly check the error...');
							   }
							   else if(contact1 == "")
							   {
									document.getElementById("errcontact1").innerHTML = "Contact Number should not be empty...";
									$(".alert-info").find("ul").html('<li class="fa fa-cog fa-1x fa-fw"></li>Kindly check the error...');
							   }
							   else
							   {
								   				if(i==0)
												{
													i++;
									$.ajax({
										url: "/Sellerinsert",
										type:'POST',
										data: {
										_token:_token, 
										compname:compname, 
										custtype:custtype, 
										customername:customername,
										address:address,
										city:city,
										state:state,
										country:country,
										contact1:contact1,
										contact2:contact2,
										emailid:emailid,
										wwwweb:wwwweb,
										bankacct:bankacct,
										note:note,
										status:status	
										},
										success: function(data) {
											//alert(data.status);
											//alert(data.message);
											if(data.status == 1)
											{
												
												$("#compname").val('0');
												$("#custtype").val('');
												$("#customername").val('');
												$("#address").val('');
												$("#city").val('');
												$("#state").val('');
												$("#country").val('');
												$("#wwwweb").val('');
												$("#contact1").val('');
												$("#contact2").val('');
												$("#emailid").val('');
												$("#bankacct").val('');
												$("#description").val('');
												$("#status").val('Active');
												
												printSuccessMsg(data.message);
											}
											else
											{
												printErrorMsg(data.message);
											}
										}
									});
												}
							   }						
			
                        	return false;
                       });
                      });
	
	
			function printErrorMsg (msg) {
				$(".alert-info").css('display','none');
				$(".print-success-msg").css('display','none');
				$(".print-error-msg").find("ul").html('');
				$(".print-error-msg").css('display','block');
				$(".print-error-msg").find("ul").append('<li class="fa fa-times-circle fa-1x fa-fw"></li>'+msg);
			}

			function printSuccessMsg (msg) {
				$(".alert-info").css('display','none');
				$(".print-error-msg").css('display','none');
				$(".print-success-msg").find("ul").html('');
				$(".print-success-msg").css('display','block');
				$(".print-success-msg").find("ul").append('<li class="fa fa-check  fa-1x fa-fw"></li>'+msg);
			}
</script>
<script>
	$(document).ready(function(){
	 $.ajax({
            type: "GET",
            url:"/Customergetcompany",
            dataType: "json",
            success: function (data) {
                $.each(data,function(i,obj)
                {
				var div_data="<option value="+obj.cmp_id+">"+obj.cmp_name+ "  (" +obj.cmp_type+")</option>";	
                $(div_data).appendTo('#compname'); 
                });  
                }
          });
        });
		
</script>		
<script>
	
	$('.clickme').click(function(e)
	{
		e.preventDefault();
		$('#sideMenu').load($(this).attr('href'));
	});
	
	
	$('.View').click(function(e)
	{
		$('#sideMenu').load('SellerView');
	});
</script>