<?php 
$titles = __('error_titles', true);
$bodies = __('error_bodies', true);
$months = __('months', true);
ksort($months);
$short_days = __('short_days', true);
$bs = __('booking_statuses', true);
$get = $controller->_get->raw();
?>
<div id="datePickerOptions" style="display:none;" data-wstart="<?php echo (int) $tpl['option_arr']['o_week_start']; ?>" data-format="<?php echo $tpl['date_format']; ?>" data-months="<?php echo implode("_", $months);?>" data-days="<?php echo implode("_", $short_days);?>"></div>
<div class="row wrapper border-bottom white-bg page-heading">
	<div class="col-sm-12 bookings-page-heading">
		<div class="row">
			<div class="col-sm-10">
				<h2><?php __('infoBookingsListTitle');?></h2>
			</div>
		</div><!-- /.row -->

		<p class="m-b-none"><i class="fa fa-info-circle"></i><?php __('infoBookingsListDesc');?></p>
	</div><!-- /.col-md-12 -->
	
</div>

<div class="wrapper wrapper-content animated fadeInRight">
	<?php
	$error_code = $controller->_get->toString('err');
	if (!empty($error_code))
	{
		switch (true)
		{
			case in_array($error_code, array('AR01', 'AR03')):
				?>
				<div class="alert alert-success">
					<i class="fa fa-check m-r-xs"></i>
					<strong><?php echo @$titles[$error_code]; ?></strong>
					<?php echo @$bodies[$error_code];?>
				</div>
				<?php 
				break;
			case in_array($error_code, array('AR04', 'AR08', 'AR09', 'AR10')):	
				?>
				<div class="alert alert-danger">
					<i class="fa fa-exclamation-triangle m-r-xs"></i>
					<strong><?php echo @$titles[$error_code]; ?></strong>
					<?php echo @$bodies[$error_code];?>
				</div>
				<?php
				break;
		}
	} 
	?>
	<div class="tabs-container tabs-reservations m-b-lg">
		<ul class="nav nav-tabs" role="tablist">
			<?php if (pjAuth::factory('pjAdminBookings', 'pjActionIndex')->hasAccess()) { ?>
			<li role="presentation" class="active"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminBookings&amp;action=pjActionIndex" class="nav-tab" aria-controls="bookings" role="tab"><?php __('tabBookings');?></a></li>
			<?php } ?>
			<?php if (pjAuth::factory('pjAdminBookings', 'pjActionExportBookings')->hasAccess()) { ?>
				<li role="presentation"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminBookings&amp;action=pjActionExportBookings" class="nav-tab" aria-controls="export" role="tab"><?php __('tabExport');?></a></li>
			<?php } ?>
		</ul>

		<div class="tab-content">
			<?php if (pjAuth::factory('pjAdminBookings', 'pjActionIndex')->hasAccess()) { ?>
				<div role="tabpanel" class="tab-pane active">
					<div class="panel-body">
						<div class="ibox-content" style="padding:0; border: 0">
							<div class="row m-b-md">
								<form action="" method="get" class="frm-filter">
									<div class="col-sm-3">
										<a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminBookings&amp;action=pjActionCreate" class="btn btn-primary"><i class="fa fa-plus"></i> <?php __('btnAddBooking');?></a>
									</div><!-- /.col-md-6 -->
		
									<div class="col-md-3 col-sm-5">
										<div class="input-group">
											<input type="text" name="q" placeholder="<?php __('btnSearch', false, true); ?>" class="form-control">
				
											<div class="input-group-btn">
												<button class="btn btn-primary" type="submit">
													<i class="fa fa-search"></i>
												</button>
											</div>
										</div>
									</div><!-- /.col-md-3 -->
			
									<div class="col-lg-2 col-md-3 col-sm-4">
										<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" class="btn btn-primary btn-outline btn-advance-search"><?php __('advance_search');?></a>
									</div><!-- /.col-md-2 -->
			
									<div class="col-lg-2 col-lg-offset-2 col-md-12 text-right">
										<select class="form-control pj-filter-status" name="status">
											<option value="">-- <?php __('lblAll');?> --</option>
											<?php foreach ($bs as $k => $v) { ?>
												<option value="<?php echo $k;?>"><?php echo pjSanitize::html($v);?></option>
											<?php } ?>
										</select>
									</div><!-- /.col-md-6 -->
								</form>
							</div><!-- /.row -->
	
							<div id="collapseOne" class="collapse">
								<div class="m-b-lg">
									<ul class="agile-list no-padding">
										<li class="success-element b-r-sm">
											<div class="panel-body">
												<form action="" method="get" class="frm-filter-advanced">
													<div class="row">
														<div class="col-md-3 col-sm-6">
															<div class="form-group">
																<label class="control-label"><?php __('lblBookingID'); ?></label>
		
																<input type="text" name="uuid" id="uuid" class="form-control" value="<?php echo isset($get['uuid']) ? pjSanitize::html($get['uuid']) : NULL; ?>">
															</div><!-- /.form-group -->
														</div><!-- /.col-md-3 col-sm-6 -->
		
														<div class="col-md-3 col-sm-6">
															<div class="form-group">
																<label class="control-label"><?php __('lblSpace'); ?></label>
		
																<select class="form-control" name="space_id">
																	<option value="">-- <?php __('lblChoose');?> --</option>
																	<?php
																	foreach($tpl['space_arr'] as $v)
																	{
																		?><option value="<?php echo $v['id']?>"><?php echo pjSanitize::html($v['name']);?></option><?php
																	} 
																	?>
																</select>
															</div><!-- /.form-group -->
														</div><!-- /.col-md-4 -->
		
														<div class="col-md-3 col-sm-6">
															<div class="form-group">
																<label class="control-label"><?php __('lblStatus'); ?></label>
		
																<select class="form-control" name="status">
																	<option value="">-- <?php __('lblChoose');?> --</option>
																	<?php
																	foreach($bs as $k => $v)
																	{
																		?><option value="<?php echo $k;?>"><?php echo pjSanitize::html($v);?></option><?php
																	} 
																	?>
																</select>
															</div><!-- /.form-group -->
														</div><!-- /.col-md-4 -->
													</div><!-- /.row -->   
		
													<div class="row">
														<div class="col-md-3 col-sm-6">
															<div class="form-group">
																<label class="control-label"><?php __('lblName'); ?></label>
		
																<input type="text" name="c_name" id="c_name" class="form-control" value="<?php echo isset($get['c_name']) ? pjSanitize::html($get['c_name']) : NULL; ?>">
															</div><!-- /.form-group -->
														</div><!-- /.col-md-4 -->
		
														<div class="col-md-3 col-sm-6">
															<div class="form-group">
																<label class="control-label"><?php __('lblBookingEmail'); ?></label>
		
																<input type="text" name="c_email" class="form-control" value="<?php echo isset($get['c_email']) ? pjSanitize::html($get['c_email']) : NULL; ?>">
															</div><!-- /.form-group -->
														</div><!-- /.col-md-4 -->
		
														<div class="col-md-6">
															<div class="form-group">
																<label class="control-label"><?php __('lblBookingFilterDates'); ?></label>
		
																<div class="row">
																	<div class="col-sm-5">
																		<div class="input-group">
																			<input type="text" class="form-control datepick" name="date_from" readonly="readonly" />
		
																			<span class="input-group-addon"><i class="fa fa-calendar"></i></span> 
																		</div>
																	</div><!-- /.col-md-5 -->
		
																	<div class="col-sm-2 text-center">
																		<label class="control-label m-t-xs"><?php __('label_to');?></label>
																	</div><!-- /.col-md-2 -->
		
																	<div class="col-sm-5">
																		<div class="input-group">
																			<input type="text" class="form-control datepick" name="date_to" readonly="readonly" />
		
																			<span class="input-group-addon"><i class="fa fa-calendar"></i></span> 
																		</div>
																	</div><!-- /.col-md-5 -->
																</div><!-- /.row -->
															</div><!-- /.form-group -->
														</div>
													</div><!-- /.row -->
		
													<div class="hr-line-dashed"></div>
		
													<div class="m-t-sm">
														<button class="btn btn-primary" type="submit"><?php __('btnSearch');?></button>
		
														<button class="btn btn-primary btn-outline" type="reset"><?php __('btnCancel');?></button>
													</div>
												</form>
											</div><!-- /.panel-body -->
										</li><!-- /.panel panel-primary -->
									</ul>
								</div><!-- /.m-b-lg -->
							</div>
							<div id="grid"></div>
						</div>
					</div>
				</div>
			<?php } ?>
		</div>
	</div>
</div>
<script type="text/javascript">
var pjGrid = pjGrid || {};
pjGrid.queryString = "";
<?php
if (isset($_GET['space_id']) && (int) $_GET['space_id'] > 0)
{
	?>pjGrid.queryString += "&space_id=<?php echo (int) $_GET['space_id']; ?>";<?php
}
?>
var myLabel = myLabel || {};
myLabel.date_time = "<?php __('lblDateTimeFromTo'); ?>";
myLabel.name = "<?php __('lblName'); ?>";
myLabel.space = "<?php __('lblSpace'); ?>";
myLabel.exported = "<?php __('lblExport'); ?>";
myLabel.delete_selected = "<?php __('delete_selected'); ?>";
myLabel.delete_confirmation = "<?php __('delete_confirmation'); ?>";
myLabel.status = "<?php __('lblStatus'); ?>";
myLabel.pending = "<?php echo $bs['pending']; ?>";
myLabel.confirmed = "<?php echo $bs['confirmed']; ?>";
myLabel.cancelled = "<?php echo $bs['cancelled']; ?>";
myLabel.btn_export = "<?php __('btnExport'); ?>";
myLabel.btn_get_url = "<?php __('btnGetFeedURL'); ?>";
</script>