<div class="hide_search_div">
<button type="button" id="add_reminder_for_clients" class="btn btn-primary" style="margin:0 0 5px 10px;">Add Reminder</button>
<div class="panel box box-primary <?=$collapse_add_area;?>" id="reminder_for_clients_area">
  <div class="box-header" >
	<form action="" method="post" name="add_reminder_for_clients_form" id="add_reminder_for_clients_form">
		<div class="col-sm-3">
			<label for="Description" class="control-label">Description</label>
			<textarea class="form-control" rows="4" id="reminder_text" name="reminder_text" required><?php echo stripslashes($reminder_text);?></textarea>
		</div>
		<? if(isset($view_reminder_for_admin)){ ?>
		<div class="col-sm-3">
			<label for="Contact" class="control-label">Contact</label>
			<? $gsi->getEnqQuoteJobList("job_id",$job_id,"100%",true,"form-control select2 job_id","required",$source); ?>
		</div>
		<? }else {?>
				<input type="hidden" id="reminder_job_id" name="job_id" value="<?php echo $job_id;?>">
		<? }?>
		<div class="col-sm-3">
			<label for="Consultant" class="control-label">Consultant</label>
				<div id="admin_id_div">
				<? 
					$admin_ids = "";
					$sql_for_admin = "SELECT * FROM job_admin_mapping WHERE job_id = $job_id";
					$rs_for_admin = mysqli_query($conn,$sql_for_admin);
					if(mysqli_num_rows($rs_for_admin) > 0){
						$c=0;
						while($row_for_admin = mysqli_fetch_assoc($rs_for_admin)){
							if($c==0){
								$default_admin = $row_for_admin["admin_id"];								
							}
							$c=$c+1;
							$admin_ids .= $row_for_admin["admin_id"].",";
						}
						$admin_ids = substr($admin_ids,0,-1);
					}
					if($c==1 && $_REQUEST['action'] != 'edit'){
						$admin_id = $default_admin;
					}
					Admin::getAdminList("r_admin_id",$r_admin_id,"100%",true,"form-control","required",$admin_ids); 
				?>
			   </div>	
		</div>
		<div class="col-sm-3">
			<label for="reminder" class="control-label">Date</label>
			<input type="text" class="form-control datepicker" id="reminder_date" name="reminder_date" value="<?php (isset($reminder_date) && $reminder_date !="") ? utility::getFormatedDate($reminder_date) : utility::getFormatedDate(date($config->dateFormat));?>" required>
		</div>
		<div class="col-sm-3">
			<label for="Time" class="control-label">Time</label>
			<div class="bootstrap-timepicker">
				<? utility::getTimeList("reminder_time", $reminder_time, "Time", "100%","form-control select2");?>
			</div>
		</div>
		<div class="col-sm-3">
			<div style="clear:both;margin-top:23px;"></div>
			<input type="hidden" id="reminder_id" name="reminder_id" value="<?php echo $reminder_id;?>">
			<input type="hidden" id="query_string" name="query_string" value="<?php echo $query_string;?>">
			<input type="hidden" id="page_action_reminder" name="page_action_reminder" value="<?php echo $page_action_reminder;?>">
			<input type="hidden" id="source" name="source" value="<?php echo $source;?>">
			<button type="submit" name="add_master_data" id="submit_form_reminder" class="btn btn-primary"><?=$button_value_reminder;?>
			</button>
			<i class="fa fa-refresh fa-spin" style="display:none;" id="page_load_div_for_reminder_for_clients"></i>
			<i class="fa fa-check" id="reminder_for_clients_done" style="color:#bad23a;font-size: 20px;display:none;"></i>
		</div>
	</form>
  </div>
</div>
</div>
<script type="text/javascript">		
$(document).ready(function() {
	$('#add_reminder_for_clients_form').submit(function(){
		$("#add_master_data").attr("disabled", true);
		$('#page_load_div').show();
	});
	$("#admin_id").change(function(){	
		if($("#reminder_job_id").val() == ""){
			alert("First select Contact");
			$(this).val("");
			return false;
		}
	});
	$("#reminder_job_id").change(function(){	
		var job_id = $(this).val();
		if(job_id != ""){
		var form_data   = {'job_id':job_id};       
			$.ajax({
				async: false,
				type: "POST",
				url: site_url+"/modules/notes/index.php?page=ajax_actions&action=get_admin_by_job",
				data: form_data,
				success: function(result){  
					if(result){
						$("#admin_id_div").html(result);
					}else{
						alert("No consultant assign to this contact. First assign consultant.");
						$("#admin_id_div").html(result);
					}
				}
			});
		}
	});
/* 	$('#reminder_date').datepicker({
		changeMonth: true,
		changeYear: true,
		format: "dd-mm-yyyy",
		autoclose: true
	}); */
	
	$("#reminder_text").focus().val();
	//$("#reminder_text").trigger("click");
	
});
</script>