<script type="text/javascript">
function validate_user(){

	var emailFilter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	
	
	
	if($("#name").val()==''){
		$("#msg_user_error_message").html('Please enter name');
		$("#name").addClass('jquery_err');
		$("#name").focus();
		return false;
	}else{
		$("#msg_user_error_message").html('');
		$("#name").removeClass('jquery_err');
	}
	
	
	
	if($("#mobile_no").val()==''){
		$("#msg_user_error_message").html('Please enter contact number');
		$("#mobile_no").focus();
		return false;
	}else{
		$("#msg_user_error_message").html('');
		$("#mobile_no").removeClass('jquery_err');
	}

	if($("#mobile_no").val().length > 16){
		$("#msg_user_error_message").html('Please enter proper digit mobile number');
		$("#mobile_no").focus();
		return false;
	}else{
		$("#msg_user_error_message").html('');
		$("#mobile_no").removeClass('jquery_err');
	}

	if(isNaN($("#mobile_no").val())== true){
		$("#msg_user_error_message").html('Please enter valid mobile number');
		$("#mobile_no").focus();
		return false;
	}else{
		$("#msg_user_error_message").html('');
		$("#mobile_no").removeClass('jquery_err');
	}
		
	
}



</script>
<!-- Content (Right Column) -->

<div id="content" class="box">
  <h1> User &raquo; Add User</h1>
  <?php if(isset($successMsg) && $successMsg!=''){ ?>
  <p class="msg done"><?php echo $successMsg; ?></p>
  <?php } ?>
  <?php if(isset($failedMsg) && $failedMsg!=''){ ?>
  <p class="msg error"><?php echo $failedMsg; ?></p>
  <?php } ?>
  <form action="" method="post" id="userFrm" name="userFrm" onsubmit="return validate_user();" enctype="multipart/form-data">
    <?php if(isset($_REQUEST['id']) && $_REQUEST['id']!=''){ ?>
    <input type="hidden" id="id" name="id" value="<?php echo $userDetail->id ?>" >
    <?php } ?>
    <!-- Login -->
    
    <p class="nomt"> <span class="smaller low message" id="msg_user_error_message" style="font-weight:bold;">&nbsp;</span> </p>
    <div id="tab01" class="eng_tab">
      <fieldset>
        <legend>Basic Details</legend>
        <p class="nomt">
          <label for="inp-01" class="req">Full Name*:</label>
          <br />
          <input type="text" size="50" name="name" id="name" value="<?php echo $userDetail->name; ?>" class="input-text-02" />
          <br/>
          <span class="smaller low message" id="msg_name">&nbsp;</span> </p>
          
          <p class="nomb">
          <label for="inp-03" class="req">User Type :</label>
          <br />
          <select id="type" name="type" class="input-text-02">
            <option value="1">Listener</option>
            <option value="2" <?php echo (isset($userDetail->type) && $userDetail->type==2) ? "selected='selected'" : "" ?>>Restaurant Owner</option>
          </select>
          <br/>
          <span class="smaller low message" id="msg_type">&nbsp;</span> </p>
        <p class="nomt">
          <label for="inp-01" class="req">Email Address:</label>
          <br />
          <input type="text" size="50" name="email" id="email" value="<?php echo $userDetail->email ?>" class="input-text-02" />
          <span id="loading_email" class="aloader" style="display:none"><img src="images/ajaxLoader.gif"></span><br/>
          <span class="smaller low message" id="msg_email">&nbsp;</span> </p>
        
        
        
        <p class="nomt">
          <label for="inp-01" class="req">Cell / Mobile No*:</label>
          <br />
          <input type="text" name="mobile_no" id="mobile_no" class="input-text-02" value="<?php echo $userDetail->mobile_no; ?>" size="50" />
          <br/>
          <span class="smaller low message" id="msg_mobile_no">&nbsp;</span> </p>
          
          <p class="nomt">
          <label for="inp-01" class="req">Designation:</label>
          <br />
           <select id="designation" name="designation" class="input-text-02">
          <option value="" selected="selected">- Select -</option>
            <option value="Owner" <?php echo ($userDetail->designation=='Owner') ? "selected='selected'" : "" ?>>Owner</option>
            <option value="Manager" <?php echo ($userDetail->designation=='Manager') ? "selected='selected'" : "" ?>>Manager</option>
          </select>
          <br/>
          <span class="smaller low message" id="msg_name">&nbsp;</span> </p>
          <p class="nomt">
          <label for="inp-01" class="req">Address:</label>
          <br />
           <input type="text" name="address" id="address" class="input-text-02" value="<?php echo $userDetail->address; ?>" size="50" />
          <br/>
          <span class="smaller low message" id="msg_address">&nbsp;</span> </p>
          
          
          <p class="nomt">
          <label for="inp-01" class="req">Where Did you here?:</label>
          <br />
           <select id="where_did_hear" name="where_did_hear" class="input-text-02">
           <option value="" selected="selected">- Select -</option>
              <option value="Radio" <?php if($userDetail->where_did_hear == 'Radio'){ echo 'selected="selected"';}?>>Radio</option>
              <option value="Website" <?php if($userDetail->where_did_hear == 'Website'){ echo 'selected="selected"';}?>>Website</option>
              <option value="Social Media" <?php if($userDetail->where_did_hear == 'Social Media'){ echo 'selected="selected"';}?>>Social Media</option>
              <option value="Google Search" <?php if($userDetail->where_did_hear == 'Google Search'){ echo 'selected="selected"';}?>>Google Search</option>
              <option value="WhatsApp" <?php if($userDetail->where_did_hear == 'WhatsApp'){ echo 'selected="selected"';}?>>WhatsApp</option>
              <option value="From a Friend" <?php if($userDetail->where_did_hear == 'From a Friend'){ echo 'selected="selected"';}?>>From a Friend</option>
              <option value="Others" <?php if($userDetail->where_did_hear == 'Others'){ echo 'selected="selected"';}?>>Others</option>            
          </select>
          
          <br/>
          <span class="smaller low message" id="msg_address">&nbsp;</span> </p>
          
          
        <p class="nomb">
          <label for="inp-03" class="req">Emirates :</label>
          <br />
          <select id="emirates" name="emirates" class="input-text-02">
             <option value="Abu Dhabi" <?php if($userDetail->emirates == 'Abu Dhabi'){ echo 'selected="selected"';}?> >Abu Dhabi</option>
              <option value="Dubai" <?php if($userDetail->emirates == 'Dubai'){ echo 'selected="selected"';}?>>Dubai</option>
              <option value="Sharjah" <?php if($userDetail->emirates == 'Sharjah'){ echo 'selected="selected"';}?>>Sharjah</option>
              <option value="Ajman" <?php if($userDetail->emirates == 'Ajman'){ echo 'selected="selected"';}?>>Ajman</option>
              <option value="Fujairah" <?php if($userDetail->emirates == 'Fujairah'){ echo 'selected="selected"';}?>>Fujairah</option>
              <option value="Ras Al Khaimah" <?php if($userDetail->emirates == 'Ras Al Khaimah'){ echo 'selected="selected"';}?>>Ras Al Khaimah</option>
              <option value="Umm Al Quwain" <?php if($userDetail->emirates == 'Umm Al Quwain'){ echo 'selected="selected"';}?>>Umm Al Quwain </option>
          </select>
          <br/>
          <span class="smaller low message" id="msg_status">&nbsp;</span> </p>
          
          <p class="nomb">
          <label for="inp-03" class="req">Nationality :</label>
          <br />
          <select id="nationality" name="nationality" class="input-text-02">
          <?php foreach($countryArray as $country){ ?>
             <option value="<?php echo $country;?>" <?php if($userDetail->nationality == $country){ echo 'selected="selected"';}?> ><?php echo $country;?></option>
          <?php } ?>
          </select>
          <br/>
          <span class="smaller low message" id="msg_status">&nbsp;</span> </p>
          
          
        <p class="nomb">
          <label for="inp-03" class="req">Status :</label>
          <br />
          <select id="status" name="status" class="input-text-02">
            <option value="0" <?php echo ($userDetail->status==0) ? "selected='selected'" : "" ?>>Inactive</option>
            <option value="1" <?php echo (!isset($userDetail->status) || $userDetail->status==1) ? "selected='selected'" : "" ?>>Active</option>
          </select>
          <br/>
          <span class="smaller low message" id="msg_status">&nbsp;</span> </p>
      </fieldset>
    </div>
    <?php if(isset($userDetail->id) && $userDetail->id!=''){ ?>
    <p>
      <input type="submit" value="Edit User" id="submit" name="submit" class="input-submit" />
    </p>
    <?php }else{ ?>
    <p>
      <input type="submit" value="Add User" id="submit" name="submit" class="input-submit" />
    </p>
    <?php } ?>
    <input type="button" value="Cancel" id="cancel" name="cancel" class="input-submit" onclick="javascript:window.location='userlist.php'" />
  </form>
</div>
<!-- /content --> 
