<div class="hide_search_div">
<button type="button" id="add_notes_for_clients" class="btn btn-primary" style="margin:0 0 5px 10px;">Add Notes</button>
<div class="panel box box-primary <?=$collapse_add_area;?>" id="notes_for_clients_area">
  <div class="box-header" >
	<form action="" method="post" name="add_notes_for_clients_form" id="add_notes_for_clients_form">
		<div class="col-sm-3">
			<label for="Description" class="control-label">Description</label>
			<textarea class="form-control" rows="4" id="note_text" name="note_text" required><?php echo stripslashes($note_text);?></textarea>
		</div>
		<? if(isset($view_notes_for_admin)){ ?>
		<div class="col-sm-3">
			<label for="Contact" class="control-label">Contact</label>
			<? $gsi->getEnqQuoteJobList("job_id",$job_id,"100%",false,"form-control select2 job_id","required",$source); ?>
		</div>
		<? }else {?>
				<input type="hidden" id="notes_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("admin_id",$admin_id,"100%",false,"form-control","required",$admin_ids); 
				?>
			   </div>	
		</div>
		<div class="col-sm-3">
			<label for="Note" class="control-label">Date</label>
			<input type="text" class="form-control datepicker" id="note_date" name="note_date" value="<?php (isset($note_date) && $note_date !="") ? utility::getFormatedDate($note_date) : utility::getFormatedDate(date($config->dateFormat));?>" required>
		</div>
		<!--<div class="col-sm-3">
			<label for="Job" class="control-label">Job</label>
			<? //$gsi->getEnqQuoteJobList("job_id",$job_id,"100%",false); ?>
		</div>
		<div class="col-sm-3">
			<label for="Consultant" class="control-label">Consultant</label>
			<? //Admin::getAdminList("admin_id",$admin_id,"100%",false); ?>
		</div>-->
		<div class="col-sm-3">
			<div style="clear:both;margin-top:23px;"></div>
			<input type="hidden" id="notes_id" name="notes_id" value="<?php echo $notes_id;?>">
			<input type="hidden" id="query_string" name="query_string" value="<?php echo $query_string;?>">
			<input type="hidden" id="page_action_notes" name="page_action_notes" value="<?php echo $page_action_notes;?>">
			<input type="hidden" id="source" name="source" value="<?php echo $source;?>">
			<button type="submit" name="add_master_data" id="submit_form_notes" class="btn btn-primary"><?=$button_value_notes;?>
			</button>
			<i class="fa fa-refresh fa-spin" style="display:none;" id="page_load_div_for_notes_for_clients"></i>
			<i class="fa fa-check" id="notes_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_notes_for_clients_form').submit(function(){
		$("#add_master_data").attr("disabled", true);
		$('#page_load_div').show();
	});
	$("#admin_id").change(function(){	
		if($("#notes_job_id").val() == ""){
			alert("First select Contact");
			$(this).val("");
			return false;
		}
	});
	$("#notes_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);
					}
				}
			});
		}
	});
/* 	$('#note_date').datepicker({
		changeMonth: true,
		changeYear: true,
		format: "dd-mm-yyyy",
		autoclose: true
	}); */
	
	$("#note_text").focus().val();
	//$("#note_text").trigger("click");
	
});
</script>