<div class="panel panel-primary">

	<div class="panel-heading">

		<?php __('front_selected_timeslots'); ?>

	</div><!-- /.panel-heading -->

	<?php

	if (isset($tpl['cart_arr']))

	{ 

	    

		if (!empty($tpl['cart_arr']) && array_key_exists($controller->_get->toInt('cid'), $tpl['cart_arr']) && !empty($tpl['cart_arr'][$controller->_get->toInt('cid')]))

		{

			$hidePrices = (int) $tpl['option_arr']['o_hide_prices'] === 1;

			

			$total = 0;

			foreach ($tpl['cart_arr'] as $cid => $date_arr)

			{

				if ($cid != $controller->_get->toInt('cid'))

				{

					continue;

				}

				foreach ($date_arr as $date => $time_arr)

				{

					foreach ($time_arr as $time => $q)

					{

						$total += @$tpl['cart_price_arr'][$cid][$time];

					}

				}

			}

			?>

			<div class="panel-body">

				<ul class="tooltip-view-table">

					<li>

						<div class="col-size-3"><strong><?php __('front_cart_date'); ?></strong></div><!-- /.col-size-1 -->

						<div class="col-size-3"><strong><?php __('front_cart_start_time'); ?></strong></div><!-- /.col-size-1 -->

						<div class="col-size-3"><strong><?php __('front_cart_end_time'); ?></strong></div><!-- /.col-size-1 -->

						<?php

						if (!$hidePrices)

						{

							?>

							<div class="col-size-3"><strong><?php __('front_cart_price'); ?></strong></div><!-- /.col-size-3 -->

							<?php

						}else{

							?>

							<div class="col-size-3"><strong>&nbsp;</strong></div><!-- /.col-size-3 -->

							<?php

						} 

						?>

						<div class="col-size-3"><strong><?php __('front_cart_slots'); ?></strong></div>

					</li>

					<?php

					foreach ($tpl['cart_arr'] as $cid => $date_arr)

					{ 

						if ($cid != $controller->_get->toInt('cid'))

						{

							continue;

						}

						foreach ($date_arr as $date => $time_arr)

						{

							foreach ($time_arr as $time => $q)

							{

								list($start_ts, $end_ts) = explode("|", $time);

								$sd = date("Y-m-d", $start_ts);

								$_date = $date == $sd ? $date : $sd;

								?>

								<li>

									<div class="col-size-3"><span><?php echo date($tpl['option_arr']['o_date_format'], strtotime($_date)); ?></span></div><!-- /.col-size-1 -->

									<div class="col-size-3"><span><?php echo date($tpl['option_arr']['o_time_format'], $start_ts); ?></span></div><!-- /.col-size-1 -->

									<div class="col-size-3"><span><?php echo date($tpl['option_arr']['o_time_format'], $end_ts); ?></span></div><!-- /.col-size-1 -->

									<div class="col-size-3">

										<?php

										if (!$hidePrices)

										{

											?>

											<strong><?php echo pjCurrency::formatPrice(@$tpl['cart_price_arr'][$cid][$time]); ?></strong>

											<?php

										} 

										?> 

									</div><!-- /.col-size-1 -->

									<div class="col-size-3"><?php echo $_SESSION[$controller->defaultSlots][$controller->_get->toInt('cid')][$time]; ?></div>

								</li>

								<?php

							}

						}

					} 

					?>

				</ul><!-- /.tooltip-view-table -->

			</div><!-- /.panel-body -->

			<?php

		}

	}

	?>

</div><!-- /.panel -->


	<div id="pjTsBookingSummaryBox">
    	<div class="panel panel-primary">
    		<div class="panel-heading">
    			<?php __('front_recurring'); ?>
    		</div><!-- /.panel-heading -->
    	
    		<div class="panel-body">
    			<div class="pj-calendar-booking-recurring">
 
    					<div class="row">
    						<?php if(!isset($FORM['ts_checkout'])){ ?>
								<div class="col-sm-12">
									<input type="checkbox" name="is_bar_allow" class="is_bar_allow" value="" />
									<label class="control-label is_bar_allow_label"><?php __('front_bar'); ?></label><!-- /.col-sm-4 -->
								</div><!-- /.col-sm-8 -->

								<?php 
								//if($tpl['is_full_day_booking'] == 1){ 
								?>
								<div class="col-sm-12">
									<input type="checkbox" name="is_recurring_booking" class="is_recurring_booking" value="" />
									<label class="control-label is_recurring_booking_label"><?php __('front_is_recurring_booking'); ?></label><!-- /.col-sm-4 -->
								</div><!-- /.col-sm-8 -->

								<div class="col-sm-12 repeat_booking_parent" style="display: none;">
									<h5 class="repeat_booking_heading"><?php __('front_repeat_booking'); ?></h5>
									<?php 

										$keys = array_keys($tpl['cart_arr'][$controller->_get->toInt('cid')]);
										$recurring_day = date("jS", strtotime($keys[0]));
										$recurring_day_month = date("jS F", strtotime($keys[0]));
										$third_week_every_year = date('l \of F', strtotime($keys[0]));
										$every_week = date('l', strtotime($keys[0]));

										$dateTime = new DateTime($keys[0]);

									    // Get the first day of the given month
									    $startOfMonth = new DateTime($keys[0]);
									    $startOfMonth->modify('first day of this month');

									    // Get the difference in days between the provided date and the first day of the month
									    $diffInDays = $dateTime->diff($startOfMonth)->days;

									    // Calculate the week number by dividing by 7 (days in a week) and adding 1
									    $weekNumber = floor($diffInDays / 7) + 1;
									    $weekDay = '';
									    switch ($weekNumber) {
									        case 1:
									            $weekDay = 'First';
									            break;
									        case 2:
									            $weekDay = 'Second';
									            break;
									        case 3:
									            $weekDay = 'Third';
									            break;
									        case 4:
									            $weekDay = 'Fourth';
									            break;
									        case 5:
									            $weekDay = 'Fifth';
									            break;
									        case 6:
									        	$weekDay = 'Sixth';
									        	break;
									        case 7:
									        	$weekDay = 'Seventh';
									        	break;
									        default:
									            $weekDay = 'Eighth';
									            break;
									    }
									?>
									<div class="col-sm-12">
											<input type="radio" name="is_recurring_booking_radio" class="is_recurring_booking_radio" value="per_month" checked/>
										
											<label class="control-label is_recurring_booking_label"><?php echo "Repeat this booking on " .$recurring_day. " every month"; ?></label><!-- /.col-sm-4 -->
										
									</div>

									<div class="col-sm-12">
										
											<input type="radio" name="is_recurring_booking_radio" class="is_recurring_booking_radio" value="per_year" />
										
											<label class="control-label is_recurring_booking_label"><?php echo "Repeat this booking on " .$recurring_day_month. " every year"; ?></label><!-- /.col-sm-4 -->
										
									</div>
									<div class="col-sm-12">
										
											<input type="radio" name="is_recurring_booking_radio" class="is_recurring_booking_radio" value="third_week_per_year" />
										
											<label class="control-label is_recurring_booking_label"><?php echo "Repeat this booking on each ".$weekDay." ".$third_week_every_year." every year"; ?></label><!-- /.col-sm-4 -->
										
									</div>

									<div class="col-sm-12">
										
											<input type="radio" name="is_recurring_booking_radio" class="is_recurring_booking_radio" value="every_week" />
										
											<label class="control-label is_recurring_booking_label"><?php echo "Repeat this booking on every ".$every_week; ?></label><!-- /.col-sm-4 -->
										
									</div>

									<div class="form-group">
	                                                    <div class="input-group">
	                                                        <span class="input-group-addon"><?php __('lblFrom'); ?></span>

	                                                        <input type="text" name="date_from" id="datepick" class="form-control datepick" readonly="readonly"/>

	                                                        <span class="input-group-addon"><?php __('lblTo'); ?></span>

	                                                        <input type="text" name="date_to" class="form-control datepick" readonly="readonly"/>
	                                                    </div>
	                                                </div><!-- /.form-group -->
								</div><!-- /.col-sm-8 -->
							<?php 
							//} 
							} else { ?>
								<div class="col-sm-12">
									<label class="control-label is_bar_allow_label col-sm-4"><?php __('front_bar'); ?></label><!-- /.col-sm-4 -->
									<span class="is_bar_allow_text"> 
										<?php 
											if(isset($FORM['is_bar_needed']) && $FORM['is_bar_needed'] == 1){
												echo "Yes";
											}else{
												echo "No";
											}
										?>
									</span>
								</div><!-- /.col-sm-8 -->
								<?php if(isset($FORM['is_recurring_booking_needed'])){ ?>
									<div class="col-sm-12">
										<label class="control-label is_recurring_booking_label col-sm-4"><?php __('front_is_recurring_booking'); ?></label><!-- /.col-sm-4 -->
										<span class="is_recurring_booking_text"> 
											<?php
												if(isset($FORM['is_recurring_booking_needed']) && $FORM['is_recurring_booking_needed'] == 1){
													echo "Yes";
												}else{
													echo "No";
												}
											?>
										</span>
									</div><!-- /.col-sm-8 -->
									<?php
									if(isset($FORM['is_recurring_booking_needed']) && $FORM['is_recurring_booking_needed'] == 1){ ?>
										<div class="col-sm-12">
											<label class="control-label is_recurring_booking_from_label col-sm-4"><?php __('lblFrom'); ?></label><!-- /.col-sm-4 -->
											<span class="is_recurring_booking_from_text"> 
												<?php if(isset($FORM['per_recurring_booking_from_date']) && $FORM['per_recurring_booking_from_date']!=''){
													echo date('d.m.y', strtotime($FORM['per_recurring_booking_from_date']));
													
												} ?>  
											</span>
										</div><!-- /.col-sm-8 -->
										<div class="col-sm-12">
											<label class="control-label is_recurring_booking_to_label col-sm-4"> <?php __('lblTo'); ?></label><!-- /.col-sm-4 -->
											<span class="is_recurring_booking_to_txt"> 
												<?php if(isset($FORM['per_recurring_booking_to_date']) && $FORM['per_recurring_booking_to_date']!=''){
													echo date('d.m.y', strtotime($FORM['per_recurring_booking_to_date']));
												} ?>
											</span>
										</div><!-- /.col-sm-8 -->
									<?php } ?>
							<?php } } ?>
						</div><!-- /.row -->

    					
    			</div><!-- /.pj-calendar-booking-summary -->
    		</div><!-- /.panel-body -->
    	</div><!-- /.panel -->
	</div>


<?php

if ((int) $tpl['option_arr']['o_disable_payments'] === 0 && (int) $tpl['option_arr']['o_hide_prices'] === 0)

{

	?>	

	<div id="pjTsBookingSummaryBox">

    	<div class="panel panel-primary">

    		<div class="panel-heading">

    			<?php __('front_summary'); ?>

    		</div><!-- /.panel-heading -->

    	

    		<div class="panel-body">

    			<div class="pj-calendar-booking-summary">

    				<ul>

    					<?php

    					if($tpl['amount']['discount'] > 0)

    					{

        					?>

        					<li>

        						<span><?php __('front_summary_price'); ?></span>

        	

        						<strong><?php echo pjCurrency::formatPrice($tpl['amount']['original_price']); ?></strong>

        					</li>

        					<li>

        						<span><?php __('front_summary_discount'); ?></span>

        	

        						<strong><?php echo pjCurrency::formatPrice($tpl['amount']['discount']); ?></strong>

        					</li>

        					<?php

    					}

        				?>

    					<li>

    						<span><?php __('front_summary_subtotal'); ?></span>

    	

    						<strong><?php echo pjCurrency::formatPrice($tpl['amount']['price']); ?></strong>

    					</li>

    					<li>

    						<span><?php __('front_summary_tax'); ?> (<?php echo $tpl['option_arr']['o_tax']?>%)</span>

    	

    						<strong><?php echo pjCurrency::formatPrice($tpl['amount']['tax']); ?></strong>

    					</li>

    	

    					<li>

    						<span><?php __('front_summary_total'); ?></span>

    	

    						<strong><?php echo pjCurrency::formatPrice($tpl['amount']['total']); ?></strong>

    					</li>

    	

    					<li>

    						<span><?php __('front_summary_deposit'); ?><?php echo $tpl['option_arr']['o_deposit_type'] == 'percent' ? ' ('.$tpl['option_arr']['o_deposit'].'%)' : NULL;?></span>

    	

    						<strong><?php echo pjCurrency::formatPrice($tpl['amount']['deposit']); ?></strong>

    					</li>

    				</ul>

    			</div><!-- /.pj-calendar-booking-summary -->

    		</div><!-- /.panel-body -->

    	</div><!-- /.panel -->

	</div>

	<?php

} 

?>