<?php
/** 
 * @package     VikRestaurants
 * @subpackage  core
 * @author      E4J s.r.l.
 * @copyright   Copyright (C) 2023 E4J s.r.l. All Rights Reserved.
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @link        https://vikwp.com
 */

// No direct access
defined('ABSPATH') or die('No script kiddies please!');

$specialday = $this->specialday;

$vik = VREApplication::getInstance();

/**
 * Trigger event to display custom HTML.
 * In case it is needed to include any additional fields,
 * it is possible to create a plugin and attach it to an event
 * called "onDisplayViewSpecialdayDetails".
 * It is also possible to use "onDisplayViewSpecialdayDetailsSidebar"
 * to include any additional fieldsets within the right sidebar.
 * The event method receives the view instance as argument.
 *
 * @since 1.9
 */
$detailsForms = $this->onDisplayView('Details');
$sidebarForms = $this->onDisplayView('DetailsSidebar');

?>

<div class="row-fluid">

	<!-- LEFT SIDE -->

	<div class="span8 full-width">

		<!-- SPECIAL DAY -->

		<div class="row-fluid">
			<div class="span12">
				<?php
				echo $vik->openFieldset(JText::translate('VRMANAGEMENU2'));
				echo $this->loadTemplate('specialday');
				?>
					
				<!-- Define role to detect the supported hook -->
				<!-- {"rule":"customizer","event":"onDisplayViewSpecialday","key":"specialday","type":"field"} -->

				<?php	
				/**
				 * Look for any additional fields to be pushed within
				 * the "Special Day" fieldset (left-side).
				 *
				 * @since 1.9
				 */
				if (isset($this->forms['specialday']))
				{
					echo $this->forms['specialday'];

					// unset details form to avoid displaying it twice
					unset($this->forms['specialday']);
				}

				echo $vik->closeFieldset();
				?>
			</div>
		</div>

		<!-- DEPOSIT (RESTAURANT) -->

		<div class="row-fluid restaurant-params" style="<?php echo $specialday->group == 1 ? '' : 'display:none;'; ?>">
			<div class="span12">
				<?php
				echo $vik->openFieldset(JText::translate('VRMANAGERESERVATION9'));
				echo $this->loadTemplate('restaurant_deposit');
				?>
					
				<!-- Define role to detect the supported hook -->
				<!-- {"rule":"customizer","event":"onDisplayViewSpecialday","key":"restaurant.deposit","type":"field"} -->

				<?php	
				/**
				 * Look for any additional fields to be pushed within
				 * the restaurant "Deposit" fieldset (left-side).
				 *
				 * @since 1.9
				 */
				if (isset($this->forms['restaurant.deposit']))
				{
					echo $this->forms['restaurant.deposit'];

					// unset details form to avoid displaying it twice
					unset($this->forms['restaurant.deposit']);
				}

				echo $vik->closeFieldset();
				?>
			</div>
		</div>

		<!-- BOOKING (RESTAURANT) -->

		<div class="row-fluid restaurant-params" style="<?php echo $specialday->group == 1 ? '' : 'display:none;'; ?>">
			<div class="span12">
				<?php
				echo $vik->openFieldset(JText::translate('VRE_BOOKING_FIELDSET'));
				echo $this->loadTemplate('restaurant_booking');
				?>
					
				<!-- Define role to detect the supported hook -->
				<!-- {"rule":"customizer","event":"onDisplayViewSpecialday","key":"restaurant.booking","type":"field"} -->

				<?php	
				/**
				 * Look for any additional fields to be pushed within
				 * the restaurant "Booking" fieldset (left-side).
				 *
				 * @since 1.9
				 */
				if (isset($this->forms['restaurant.booking']))
				{
					echo $this->forms['restaurant.booking'];

					// unset details form to avoid displaying it twice
					unset($this->forms['restaurant.booking']);
				}

				echo $vik->closeFieldset();
				?>
			</div>
		</div>

		<!-- BOOKING (TAKE-AWAY) -->

		<div class="row-fluid takeaway-params" style="<?php echo $specialday->group == 2 ? '' : 'display:none;'; ?>">
			<div class="span12">
				<?php
				echo $vik->openFieldset(JText::translate('VRE_BOOKING_FIELDSET'));
				echo $this->loadTemplate('takeaway_booking');
				?>
					
				<!-- Define role to detect the supported hook -->
				<!-- {"rule":"customizer","event":"onDisplayViewSpecialday","key":"takeaway.booking","type":"field"} -->

				<?php	
				/**
				 * Look for any additional fields to be pushed within
				 * the take-away "Booking" fieldset (left-side).
				 *
				 * @since 1.9
				 */
				if (isset($this->forms['takeaway.booking']))
				{
					echo $this->forms['takeaway.booking'];

					// unset details form to avoid displaying it twice
					unset($this->forms['takeaway.booking']);
				}

				echo $vik->closeFieldset();
				?>
			</div>
		</div>

		<!-- Define role to detect the supported hook -->
		<!-- {"rule":"customizer","event":"onDisplayViewSpecialdayDetails","type":"fieldset"} -->

		<?php
		/**
		 * Iterate remaining forms to be displayed within the main panel.
		 *
		 * @since 1.11
		 */
		foreach ($detailsForms as $formName => $formHtml)
		{
			$title = JText::translate($formName);
			?>
			<div class="row-fluid">
				<div class="span12">
					<?php
					echo $vik->openFieldset($title);
					echo $formHtml;
					echo $vik->closeFieldset();
					?>
				</div>
			</div>
			<?php
		}
		?>

	</div>

	<!-- RIGHT SIDE -->

	<div class="span4 full-width">

		<!-- PUBLISHING -->

		<div class="row-fluid">
			<div class="span12">
				<?php
				echo $vik->openFieldset(JText::translate('JGLOBAL_FIELDSET_PUBLISHING'), 'form-vertical');
				echo $this->loadTemplate('publishing');
				?>
					
				<!-- Define role to detect the supported hook -->
				<!-- {"rule":"customizer","event":"onDisplayViewSpecialday","key":"publishing","type":"field"} -->

				<?php	
				/**
				 * Look for any additional fields to be pushed within
				 * the "Publishing" fieldset (right-side).
				 *
				 * @since 1.9
				 */
				if (isset($this->forms['publishing']))
				{
					echo $this->forms['publishing'];

					// unset details form to avoid displaying it twice
					unset($this->forms['publishing']);
				}

				echo $vik->closeFieldset();
				?>
			</div>
		</div>

		<!-- OPTIONS -->

		<div class="row-fluid">
			<div class="span12">
				<?php
				echo $vik->openFieldset(JText::translate('JGLOBAL_FIELDSET_BASIC'), 'form-vertical');
				echo $this->loadTemplate('options');
				?>
					
				<!-- Define role to detect the supported hook -->
				<!-- {"rule":"customizer","event":"onDisplayViewSpecialday","key":"options","type":"field"} -->

				<?php	
				/**
				 * Look for any additional fields to be pushed within
				 * the "Options" fieldset (right-side).
				 *
				 * @since 1.9
				 */
				if (isset($this->forms['options']))
				{
					echo $this->forms['options'];

					// unset details form to avoid displaying it twice
					unset($this->forms['options']);
				}

				echo $vik->closeFieldset();
				?>
			</div>
		</div>

		<!-- Define role to detect the supported hook -->
		<!-- {"rule":"customizer","event":"onDisplayViewSpecialdayDetailsSidebar","type":"fieldset"} -->

		<?php
		/**
		 * Iterate remaining forms to be displayed within
		 * the sidebar (below "Parameters" fieldset).
		 *
		 * @since 1.11
		 */
		foreach ($sidebarForms as $formName => $formHtml)
		{
			$title = JText::translate($formName);
			?>
			<div class="row-fluid">
				<div class="span12">
					<?php
					echo $vik->openFieldset($title, 'form-vertical');
					echo $formHtml;
					echo $vik->closeFieldset();
					?>
				</div>
			</div>
			<?php
		}
		?>

	</div>

</div>