<?php 
$submit_url = $file_name."?page=view&action=$action"; 
$status_submit_url = $file_name."?page=view&name=$name"; 


$mobilenos = utility::getTableFieldById("job","phone_no","id",$job_id);
$mobilenos = utility::validate_crypt_data($mobilenos);
$mobilenos = trim($mobilenos);
$mobilenos = str_replace(" ","",$mobilenos);

if(!(isset($mobilenos) && $mobilenos !="")){
	$mobilenos = utility::getTableFieldById("job","landline_phone_no","id",$job_id);
	$mobilenos = utility::validate_crypt_data($mobilenos);
	$mobilenos = trim($mobilenos);
	$mobilenos = str_replace(" ","",$mobilenos);
}

/* if(!(isset($mobilenos) && $mobilenos !="")){
	$mobilenos = utility::getTableFieldById("job","phone_no3","id",$job_id);
	$mobilenos = utility::validate_crypt_data($mobilenos);
	$mobilenos = trim($mobilenos);
	$mobilenos = str_replace(" ","",$mobilenos);
} */
?>
<div class="box-header" >
	<form action="<?php echo $submit_url;?>" method="post" name="search_form" id="search_form">
		<div class="col-sm-12">Message will send to <?=$mobilenos;?></div>
		<div class="col-sm-6">
		  <label for="Email Name" class="control-label">Message Name</label>
			<? 
				$gsi->getMessageTemplateList("message_id",$message_id,"100%",false,"form-control select2"); 
			?>
		</div>
		<div class="col-sm-6">
			<label for="Description" class="control-label">Message</label>
			<textarea class="form-control" rows="4" id="message_text" name="message_text" required><?php echo stripslashes($message_text);?></textarea>
		</div>
		<div class="col-sm-3 hide">
			<label for="Note" class="control-label">Date</label>
			<input type="text" class="form-control" id="message_date" name="message_date" value="<?php (isset($message_date) && $message_date !="") ? utility::getFormatedDate($message_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="id" name="id" value="<?php echo $id;?>">
			<input type="hidden" id="job_id" name="job_id" value="<?php echo $job_id;?>">
			<input type="hidden" id="query_string" name="query_string" value="<?php echo $query_string;?>">
			<input type="hidden" id="source" name="source" value="<?php echo $source;?>">
			<button type="submit" id="submit" name="add_master_data" class="btn btn-primary">
				<?=$button_value?>
				<i class="fa fa-refresh fa-spin" style="display:none;" id="page_load_div"></i>
			</button>
		</div>
	</form>
</div>
<script type="text/javascript">		
$(document).ready(function() {
$('#message_date').datepicker({
		changeMonth: true,
		changeYear: true,
		format: "dd-mm-yyyy",
		autoclose: true
	});
	
	$('#search_form').submit(function(){
		$("#submit").attr("disabled", true);
		$('#page_load_div').show();
	});
	$("#message_id").change(function(){
		var message_id = $(this).val();
		var job_id = $("#job_id").val();
		var form_data   = {'message_id':message_id};       
		$.ajax({
			async: false,
			type: "POST",
			url: site_url+"/modules/mail_schedule/index.php?page=ajax_actions&action=load_message_template",
			data: form_data,
			success: function(result){
					var resultObj = jQuery.parseJSON(result); 
					$("textarea#message_text").val(resultObj.message_body);
					//CKEDITOR.instances['mail_body'].setData(resultObj.mail_body)
			}
		});
	});
});
</script>