<?php 
$submit_url_search = $file_name."?page=view_admin_invoice"; 
$submit_url_invoice = $file_name."?page=view_admin_invoice&action=$action"; 
$show_all_page = "page=view_admin_invoice";
?>

<button data-toggle="collapse" data-target="#booke_invoice_area" type="button" name="" class="btn btn-primary inv_hide_show <?=$add_invoice_btn_hide;?>" style="margin:0 0 5px 10px;float:left;clear:right;">Add Invoice</button>

<div style="clear:both;"></div>
<div class="panel box box-primary <?=$collapse_invoice_area;?>" id="booke_invoice_area">
	<div class="box-header" >
		<form action="<?php echo $submit_url_invoice;?>" method="post" name="search_form" id="search_form">
			<div class="row">
				<div class="col-sm-3">
					<label for="Invoice Text" class="control-label">Description</label>
					<textarea class="form-control" rows="4" id="invoice_text" name="invoice_text" required><?php echo stripslashes($invoice_text);?></textarea>
					
					<!--<label for="Consultant" class="control-label">Consultant</label>
					<? //Admin::getAdminList("admin_id",$admin_id,"100%",false,"form-control"); ?>-->
				</div>
				<div class="col-sm-3">
					<label for="Invoice" class="control-label">Date</label>
					<input type="text" class="form-control datepicker" id="invoice_date" name="invoice_date" value="<?php (isset($invoice_date) && $invoice_date !="") ? utility::getFormatedDate($invoice_date) : utility::getFormatedDate(date($config->dateFormat));?>" required>
					
					<label for="Invoice Status" class="control-label">Status</label>
					<? $gsi->getInvoiceStatusList("invoice_status",$invoice_status,"100%",false,"form-control select2"); ?>
				</div>
				<div class="col-sm-3">
					<label for="Amount" class="control-label">Amount</label>
					<input type="text" class="form-control" id="amount" name="amount" value="<?php echo $amount;?>" required/>
					
					<label for="Job" class="control-label">Job</label>
					<? //$gsi->getEnqQuoteJobListForInvoice("job_id",$job_id,"100%",false,"form-control select2"); ?>
					<? $gsi->getEnqQuoteJobListForInvoice("job_id",$job_id,"100%",false,"form-control select2 job_id"); ?>
				</div>
				<div class="col-sm-3">
					<label for="Invoice Number" class="control-label">Invoice Number</label>
					<input type="text" class="form-control" id="invoice_number" name="invoice_number" value="<?php echo $invoice_number;?>"/>
					
					<label for="Due Date" class="control-label">Due Date</label>
					<input type="text" class="form-control datepicker" id="due_date" name="due_date" value="<?php (isset($due_date) && $due_date !="") ? utility::getFormatedDate($due_date) : utility::getFormatedDate(date($config->dateFormat,strtotime("+30 days")));?>" required>
				</div>
				<div style="clear:both;"></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="query_string" name="query_string" value="<?php echo $query_string;?>">
					<button type="submit" id="add_master_data" name="add_master_data" class="btn btn-primary"><?=$button_value?>
						<i class="fa fa-refresh fa-spin" style="display:none;" id="page_load_div1"></i>
					</button>
					<button data-toggle="collapse" data-target="#booke_invoice_area" type="button" name="" class="btn btn-primary cancel_inv_btn <?=$cancel_invoice_btn_hide;?>">Cancel</button>
				</div>
			</div>
		</form>
	</div>
</div>

<div class="box-header" id="inv_search_list" style="display:<?=$invoice_search_list;?>;">
<!-- search form -->
<form class="form-horizontal" action="<?php echo $submit_url_search;?>" method="post" name="search_form1" id="search_form1">
	<div class="form-group">
		<div class="card-body">
			<div class="row">
				<div class="col-sm-3">
					<label for="Job" class="control-label">Job</label>
					<? //$gsi->getEnqQuoteJobList("job_id_search",$job_id_search,"100%",false,"form-control select2"); ?>
					<? $gsi->getEnqQuoteJobList("job_id_search",$job_id_search,"100%",false,"form-control select2 job_id"); ?>
				</div>
				<div class="col-sm-2">
					<label for="Consultant" class="control-label">Consultant</label>
					<? Admin::getAdminList("admin_id_search",$admin_id_search,"100%",false,"form-control"); ?>
				</div>
				<div class="col-sm-2">
					<label for="From Appointment Date" class="control-label">From  Date</label>
					<input type="text" class="form-control datepicker" id="from_invoice_date" name="from_invoice_date" value="<?php (isset($from_invoice_date) && $from_invoice_date !="") ? utility::getFormatedDate($from_invoice_date) : "";?>" autoComplete="off">
				</div>
				<div class="col-sm-2">
					<label for="Appointment" class="control-label">To Date</label>
					<input type="text" class="form-control datepicker" id="to_invoice_date" name="to_invoice_date" value="<?php (isset($to_invoice_date) && $to_invoice_date !="") ? utility::getFormatedDate($to_invoice_date) : "";?>" autoComplete="off">
				</div>
				<div class="col-sm-3">
					<label for="Postcode" class="control-label">&nbsp;</label><br>
					<button type="submit" class="btn btn-success">Search
					<i class="fa fa-refresh fa-spin" style="display:none;" id="page_load_div"></i>
					</button>
					<button type="button" value="Show All" onclick="javascript:window.location='?<?php echo $show_all_page ?>'" class="btn btn-info">Show All</button>
				</div>
			</div>
		</div>
	</div>
</form>
<!-- /.search form -->
</div>
<script type="text/javascript">
$(function(){
	$('#search_form1').submit(function(){
		$("#submit").attr("disabled", true);
		$('#page_load_div').show();
	});
	$('#search_form').submit(function(){
		$("#add_master_data").attr("disabled", true);
		$('#page_load_div1').show();
	});
	$("#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/payment_management/index.php?page=ajax_actions&action=get_invoice_number",
				data: form_data,
				success: function(result){
					$("#invoice_number").val(result);
				}
			});
		}
	});
	
	
	$('.inv_hide_show').click(function(){
		$('.inv_hide_show').hide();
		$('.cancel_inv_btn').show();
		$('#inv_search_list').hide();
		$('#inv_listing').hide();
	});
	$('.cancel_inv_btn').click(function(){
		$('.inv_hide_show').show();
		$('#inv_search_list').show();
		$('#inv_listing').show();
	});
});
</script>