<?php
if (isset($tpl['status']))
{
	$status = __('status', true);
	switch ($tpl['status'])
	{
		case 2:
			pjUtil::printNotice(NULL, $status[2]);
			break;
	}
} else {
	if (isset($_GET['err']))
	{
		$titles = __('error_titles', true);
		$bodies = __('error_bodies', true);
		pjUtil::printNotice(@$titles[$_GET['err']], @$bodies[$_GET['err']]);
	}
	pjUtil::printNotice(__('infoEnquiriesTitle', true), __('infoEnquiriesDesc', true));
	?>
	<div class="b10">
		<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" class="float_left pj-form r10">
			<input type="hidden" name="controller" value="pjAdminEnquiries" />
			<input type="hidden" name="action" value="pjActionCreate" />
			<input type="submit" class="pj-button" value="<?php __('btnAddEnquiry'); ?>" />
		</form>
		<form action="" method="get" class="float_left pj-form frm-filter">
			<select name="listing_id" id="listing_id" class="pj-form-field w300">
				<option value="">-- <?php __('lblChoosePackage'); ?> --</option>
				<?php
				foreach ($tpl['listing_arr'] as $item)
				{
					?><option value="<?php echo $item['id']; ?>"><?php echo pjMultibyte::substr(stripslashes($item['title'] . sprintf(" (%s)", $item['listing_refid'])), 0, 50); ?></option><?php
				}
				?>
			</select>
		</form>
		
		<?php
		$rs = __('enquiry_statuses', true);
		?>
		<div class="float_right t5">
			<a href="#" class="pj-button btn-all"><?php __('lblAll');?></a>
			<a href="#" class="pj-button btn-confirmed"><?php echo $rs['Confirmed']; ?></a>
			<a href="#" class="pj-button btn-new"><?php echo $rs['New']; ?></a>
		</div>
		<br class="clear_both" />
	</div>

	<div id="grid"></div>
	<script type="text/javascript">
	var pjGrid = pjGrid || {};
	pjGrid.jqDateFormat = "<?php echo pjUtil::jqDateFormat($tpl['option_arr']['o_date_format']); ?>";
	pjGrid.jsDateFormat = "<?php echo pjUtil::jsDateFormat($tpl['option_arr']['o_date_format']); ?>";
	pjGrid.queryString = "";
	<?php
	if (isset($_GET['listing_id']) && (int) $_GET['listing_id'] > 0)
	{
		?>pjGrid.queryString += "&listing_id=<?php echo (int) $_GET['listing_id']; ?>";<?php
	}
	$statuses = __('enquiry_statuses', true);
	?>
	var myLabel = myLabel || {};
	myLabel.date_from = "<?php __('vk_date_from'); ?>";
	myLabel.date_to = "<?php __('vk_date_to'); ?>";
	myLabel.listing = "<?php __('vk_listing'); ?>";
	myLabel.date_submitted = "<?php __('vk_date_submitted'); ?>";
	myLabel.export_selected = "<?php __('vk_export_selected'); ?>";
	myLabel.delete_selected = "<?php __('vk_delete_selected'); ?>";
	myLabel.confirm_selected = "<?php __('vk_confirm_selected'); ?>";
	myLabel.dismiss_selected = "<?php __('vk_dismiss_selected'); ?>";
	myLabel.delete_confirmation = "<?php __('vk_delete_confirmation'); ?>";
	myLabel.status = "<?php __('lblStatus'); ?>";
	myLabel.new_stat = "<?php echo $statuses['New']; ?>";
	myLabel.confirmed_stat = "<?php echo $statuses['Confirmed']; ?>";
	myLabel.empty_date = "<?php __('gridEmptyDate'); ?>";
	myLabel.invalid_date = "<?php __('gridInvalidDate'); ?>";
	myLabel.empty_datetime = "<?php __('gridEmptyDateTime'); ?>";
	myLabel.invalid_datetime = "<?php __('gridInvalidDateTime'); ?>";
	myLabel.csrf_token = "<?php echo pjAppController::getCsrfToken(); ?>";
	</script>
	<?php
}
?>