<?php echo $__env->make('includes/header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php echo $__env->make('includes/leftsidebar', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
		<!-- MAIN CONTENT WRAPPER -->
		<div id="main-content-wrapper" class="content-wrapper ">

			<!-- 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> Add customer</h3> <em> - Add customer records</em>
						</div>
						<div class="widget-content">
<form id="frmmain" name="frmmain" data-parsley-validate novalidate>
<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">						
						
<div class="alert  alert-info " >
    <ul><li class="fa fa-cog  fa-1x fa-fw"></li>Kindly enter User type..</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>
                                </select>
                            <small class="text-danger" id="errstatus"></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">Customer Type*</label>
                                <select name="compname" id="compname" class="form-control" required>
                                    <option value="">Select</option>
                                    <option value="Both">Both</option>
                                    <option value="Active">Buyer</option>
                                    <option value="Inactive">Seller</option>
                                </select>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">Customer name*</label>
                            <input type="text" name="customername" id="customername" class="form-control" >
                            <small class="text-danger" id="errusertype"></small>
                        </div>
                        <div class="form-group">
                            <label>Address</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="text-input1">City</label>
                            <input type="text" name="customername" id="customername" class="form-control" >
                            <small class="text-danger" id="errusertype"></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">State</label>
                            <input type="text" name="customername" id="customername" class="form-control" >
                            <small class="text-danger" id="errusertype"></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">Country</label>
                            <input type="text" name="customername" id="customername" class="form-control" >
                            <small class="text-danger" id="errusertype"></small>
                        </div>
                    </form>
								</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="usertype" id="usertype" class="form-control" >
                            <small class="text-danger" id="errusertype"></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">Contact No. 2</label>
                            <input type="text" name="usertype" id="usertype" class="form-control" >
                            <small class="text-danger" id="errusertype"></small>
                        </div>
                        <div class="form-group">
                            <label for="text-input1">Email ID</label>
                            <input type="text" name="usertype" id="usertype" class="form-control" >
                            <small class="text-danger" id="errusertype"></small>
                        </div>
                        <div class="form-group">
                            <label>Bank Account detail</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>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">Add customer</button></center>
                        </div>
</div>                        
                    </form>
                    
						</div>
					</div>
					<!-- END DATA EXPORT -->

				</div>
			</div>
			<!-- /main -->
			
<?php echo $__env->make('includes/footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<script type="application/javascript">
					$(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>Processing...');
							   
								var _token = $("input[name='_token']").val();
								var usertype = $("input[name='usertype']").val();
								var description = $("#description").val();
								var status = $("#status").val();
								
								document.getElementById("errusertype").innerHTML = "";
						   
							   if(usertype == "")
							   {
									document.getElementById("errusertype").innerHTML = "User 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
							   {
									$.ajax({
										url: "/utype",
										type:'POST',
										data: {_token:_token, usertype:usertype, description:description, status:status},
										success: function(data) {											
											if(data.status == 1)
											{
												printSuccessMsg(data.message);
											}
											else
											{
												printErrorMsg(data.message)
											}
										}
									});					   
							   }							
			
							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);
								//Code to redirect page
								//var url = "/dashboard";
								//$(location).attr('href',url);
							}
                        	return false;
                       });

                      });
</script>					  