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

$search_url = $file_name."?page=list"; 
$show_all = "page=list";  

?>

<div class="hide_search_div">
<button data-toggle="collapse" data-target="#add_campaign_area" type="button" name="" class="btn btn-primary hide_show <?=$add_btn_hide;?>">Add Contract</button>

<div id="add_campaign_area" class="panel <?=$collapse_add_new_mileage;?>">
	<div class="box-header with-border" style="padding:10px 0;">
		<div class="row">
			<div class="col-12">
				<form action="<?php echo $submit_url;?>" method="post" name="search_form" id="search_form">			
					<div class="row">
						<div class="col-lg-3 col-12">
							<label for="Policy Type" class="control-label">Policy Type</label>
							<? echo Keycode::getKeycodeListValue("policy_type", $policy_type, $width = "100%", "Policy Type", "id", "code", "policy_type","","form-control"); ?>
						</div>
						<div class="col-lg-3 col-12">
							<label for="Contract Status" class="control-label">Contract Status</label>
							<? echo Keycode::getKeycodeListValue("contract_status", $contract_status, $width = "100%", "Contract Status", "id", "code", "contract_status","","form-control"); ?>
						</div>
						<div class="col-lg-3 col-12">
							<label for="Contract value" class="control-label">Contract value</label>
							<input type="text" class="form-control" id="contract_value" name="contract_value" value="<?php echo $contract_value;?>" required>
						</div>
						<div class="col-lg-3 col-12">
							<label for="Date" class="control-label">Renewal date</label>
							<input type="text" class="form-control datepicker" id="renewal_date" name="renewal_date" value="<?php (isset($renewal_date) && $renewal_date !="") ? utility::getFormatedDate($renewal_date) : utility::getFormatedDate(date($config->dateFormat));?>" required>
						</div>
						<div class="col-lg-3 col-12">
							<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" name="add_master_data" id="submit_form" class="btn btn-primary"><?=$button_value?>
								<i class="fa fa-refresh fa-spin" style="display:none;" id="page_load_div"></i>
							</button>
							<button data-toggle="collapse" data-target="#add_campaign_area" type="button" name="" class="btn btn-primary cancel_btn <?=$cancel_btn_hide;?>">Cancel</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<div class="box-header" style="padding:10px 0;" id="contract_search_list" style="display:<?=$search_list;?>;">
<div class="row">
	<form action="<?php echo $search_url;?>" method="post" name="search_form" id="search_form">
		<div class="card-body">
		<div class="row">
		<!--<div class="col-lg-3 col-12">
			<label for="Campaign Name" class="control-label">Campaign Name</label>
			<input type="text" class="form-control" id="camp_name_search" name="camp_name_search" value="<?php echo $camp_name_search;?>" placeholder="Campaign Name">
		</div>-->
		<div class="col-lg-3 col-12">
			<label for="From Renewal Date" class="control-label">From Date</label>
			<input type="text" class="form-control datepicker" id="from_renewal_date" name="from_renewal_date" value="<?php (isset($from_renewal_date) && $from_renewal_date !="") ? utility::getFormatedDate($from_renewal_date) : "";?>">
		</div>
		<div class="col-lg-3 col-12">
			<label for="To Renewal Date" class="control-label">To Date</label>
			<input type="text" class="form-control datepicker" id="to_renewal_date" name="to_renewal_date" value="<?php (isset($to_renewal_date) && $to_renewal_date !="") ? utility::getFormatedDate($to_renewal_date) : "";?>">
		</div>
		<div class="col-lg-4 col-12">
			<div style="clear:both;margin-top:30px;"></div>
			<label for="" class="control-label">&nbsp;</label>			
			<button type="submit" name="search" class="btn btn-success" style="float:left;clear:right;margin-right:10px;">Search</button>
			<button type="button" name="search" class="btn btn-info" onclick="javascript:window.location='?<?php echo $show_all ?>'" style="float:left;clear:right;margin-right:10px;">Show All</button>
			
			<!--<a href="" onClick="window.print();" class="btn btn-default hide_search_div" style="float:right !important;margin-bottom:4px;"><i class="fa fa-print"></i> Print</a>-->
		</div>
		</div>
		</div>
	</form>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
	/*$("#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/job_contract/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 job. First assign consultant.");
						$("#admin_id_div").html(result);
					}
				}
			});
		}
	});*/
	$('#search_form').submit(function(){
		$("#add_master_data").attr("disabled", true);
		$('#page_load_div').show();
	});
	$("#submit_form").click(function(){	
		if($("#span").text() == "No consultant assign to this job. First assign consultant."){
			alert("First select Consultant");
			return false;
		}
	});
	$('.hide_show').click(function(){
		$('.hide_show').hide();
		$('.cancel_btn').show();
		$('#contract_search_list').hide();
		$('#contract_listing').hide();
	});
	$('.cancel_btn').click(function(){
		$('.hide_show').show();
		$('#contract_search_list').show();
		$('#contract_listing').show();
	});
});
</script>