<?php
if (isset($tpl['bi_arr']) && !empty($tpl['bi_arr']))
{
	?>
	<div class="table-responsive table-responsive-secondary">
		<table class="table table-striped table-hover" id="tblBookingServices">
			<thead>
				<tr>
					<th><?php __('booking_service_employee'); ?></th>
					<th class="text-center"><?php __('booking_allow_double_booking'); ?></th>
					<th><?php __('booking_dt'); ?></th>
					<?php if ($controller->_get->check('booking_id') && $controller->_get->toInt('booking_id') > 0) { ?>
						<th><?php __('booking_apprentices'); ?></th>
					<?php } ?>
					<th><?php __('booking_price'); ?></th>
					<th class="text-center"><?php __('booking_service_order'); ?></th>
					<th></th>
				</tr>
			</thead>
			<tbody class="table-sortable">
				<?php
				foreach ($tpl['bi_arr'] as $item)
				{
					?>
					<tr id="<?php echo $item['id'];?>">
						<td>
							<?php echo pjSanitize::html($item['service']); ?>
							<br/>
							<?php echo pjSanitize::html($item['employee']); ?>
						</td>
						<td class="text-center">
							<input type="checkbox" class="pjBsAllowDoubleBooking" name="allow_double_booking_<?php echo $item['id'];?>" value="<?php echo $item['id'];?>" <?php echo $item['allow_double_booking'] == 'T' ? 'checked="checked"' : '';?> />
						</td>
						<td><?php echo date($tpl['option_arr']['o_date_format'] . ' ' . $tpl['option_arr']['o_time_format'], $item['start_ts']); ?></td>
						<?php if ($controller->_get->check('booking_id') && $controller->_get->toInt('booking_id') > 0) { ?>
							<td><?php echo isset($tpl['be_arr'][$item['id']]) ? pjSanitize::html($tpl['be_arr'][$item['id']]['employee_name']) : '';?> <a href="#" class="btn btn-primary btn-outline item-add-apprentices" title="<?php __('booking_service_choose_apprentices')?>" data-id="<?php echo $item['id']; ?>" data-toggle="modal" data-target="#modalAddApprentices"><i class="fa <?php echo $tpl['be_arr'][$item['id']] ? 'fa-pencil' : 'fa-plus';?>"></i></a></td>
						<?php } ?>
						<td><?php echo pjCurrency::formatPrice($item['price']); ?></td>
						<td class="text-center"><?php echo $item['order'];?></td>
						<td>
							<div class="m-t-xs text-right">
								<a href="javascript:void(0);" class="btn btn-primary btn-outline item-add" data-id="<?php echo $item['id']; ?>" data-toggle="modal" data-target="#modalAddItem"><i class="fa fa-pencil"></i></a>
								<?php if (!$controller->_get->check('tmp_hash')) : ?>
									<a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminBookings" class="btn btn-primary btn-outline item-email" data-id="<?php echo $item['id']; ?>"><i class="fa fa-envelope"></i></a>
									<a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminBookings" class="btn btn-primary btn-outline item-sms" data-id="<?php echo $item['id']; ?>"><i class="fa fa-phone"></i></a>
								<?php endif; ?>
								<a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminBookings" class="btn btn-danger btn-outline btn-delete item-delete" data-id="<?php echo $item['id']; ?>"><i class="fa fa-trash"></i></a>
							</div>
						</td>
					</tr>
					<?php 
				}
				?>
			</tbody>
		</table>
	</div>
	<?php
} else {
	?><span class="left"><?php __('booking_i_empty'); ?></span><?php
}
?>