<script type="text/javascript">

function getUserByCnic(event,route)
{
        showLoader();

	$.get(route, function(data, status)
	{
    	alert("Data: " + data + "\nStatus: " + status);
        removeLoader();

    });
}


    // AJAX REQUEST TO STORE USER(EMPLOYEE) WHILE COMMISSION
	function storeEmployee(event,obj)
	{
		event.preventDefault();
		var obj = $('#form_add_employee');
		var route = obj.attr('action');
	    var formdata = obj.serialize();

        showLoader();

		$.post(route, formdata, function(result)
		{
			if(result.id)
		    {

		    	  var view = '<option value = "'+result.id+'">'+result.name+' '+result.designation+'</option>';
		         $('.user_list').append(view);
		            $('.employee_list').append(view);

				 $('#md_add_employee').modal('hide');

			    messageToaster('success','Employee has been registered.','Success');

		    }
        removeLoader();


        },'json')
        .fail(function(data) {
			       ajax_show_error(data);

		  });
	}

	 //AJAX REQUEST TO STORE USER(DEALER) WHILE COMMISSION
	function storeDealer(event,obj)
	{

		event.preventDefault();
		var obj = $('#form_add_dealer');
		var route = obj.attr('action');
	    var formdata = obj.serialize();

        showLoader();


		$.post(route, formdata, function(result)
		{
			if(result.id)
		    {

		      var view = '<option value = "'+result.id+'">'+result.name+'</option>';
		      $('.user_list').append(view);
		       $('.dealer_list').append(view);



				$('#md_add_dealer').modal('hide');

			    messageToaster('success','Dealer has been registered.','Success');

		    }
        removeLoader();


        },'json')
        .fail(function(data) {
			       ajax_show_error(data);

		  });
    }



</script>
