<?php
mt_srand();
$index = mt_rand(1, 9999);
$listing_for = __('listing_for', true);
?>
<div id="ylContainer_<?php echo $index;?>" class="ylContainer">
	<?php include_once ROOT_PATH . PJ_TEMPLATE_PATH . $tpl['option_arr']['o_layout']. '/elements/header.php';?>
	<div class="ylMain">
		<?php
		if($tpl['status'] == '200')
		{
			if (@$_GET['controller'] == 'pjListings' && @$_GET['action'] == 'pjActionReserve')
			{
				$back = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $_SERVER['PHP_SELF'] .'?controller=pjListings&amp;action=pjActionView&amp;id=' . $_GET['id'] . (isset($_GET['iframe']) ? '&amp;iframe' : NULL);
			}
			$listing_title = pjSanitize::html(stripslashes($tpl['arr']['title']));
			if ($tpl['option_arr']['o_seo_url'] == 'No')
			{
				$url = $_SERVER['SCRIPT_NAME'] . '?controller=pjListings&amp;action=pjActionView&amp;id=' . $tpl['arr']['id'] .(isset($_GET['iframe']) ? '&amp;iframe' : NULL);
			} else {
				$path = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));
				$path = $path == '/' ? '' : $path;
				$url = $path .'/'. $controller->friendlyURL($tpl['arr']['title']) . "-". $tpl['arr']['id'] . ".html";
			}
			$image = PJ_INSTALL_URL . PJ_TEMPLATE_PATH . $tpl['option_arr']['o_layout'] . '/img/no_img.png';
			if(!empty($tpl['arr']['image']))
			{
				if(is_file(PJ_INSTALL_PATH . $tpl['arr']['image']))
				{
					$image = PJ_INSTALL_URL . $tpl['arr']['image'];
				}
			}
			?>
			<p class="ylButtons">
				<a href="<?php echo $back;?>" class="ylBtn ylBtnBack"><?php __('front_back');?></a>
			</p><!-- /.ylButtons -->
			<div class="ylDetails">
				<div class="ylDetailsHead">
					<h1><?php __('front_booking');?></h1>
				</div><!-- /.ylDetailsHead -->
				
				<div class="ylDetailsInfo ylDetailsInfoSecondary">
					<div class="ylDetailsAside">
						<div class="ylReservation">
							<div class="ylReservationBody">
								<div class="ylReservationRow">
									<p>
										<span><?php __('front_selected_yacht');?></span>
									</p>
									<br/>
									<p>
										<a href="<?php echo $url;?>"><img class="ylReservationImage" src="<?php echo $image;?>"><span class="ylReservationTitle"><?php echo $listing_title;?></span></a>
									</p>
								</div><!-- /.ylReservationRow -->
								<div class="ylReservationRow">
									<p>
										<span class="ylCol2"><?php __('front_selected_period');?></span>
									</p>
									<p class="ylPrice ylPriceUp">
										<small class="ylCol2"><?php __('front_week');?> <?php echo date('W', $_GET['week']);?> <br/> <?php echo date($tpl['option_arr']['o_date_format'], $_GET['week']);?> - <?php echo date($tpl['option_arr']['o_date_format'], ($_GET['week'] + (6 * 60 * 60 * 24)));?></small>
										<strong class="ylCol3"><?php echo pjUtil::formatCurrencySign(number_format($tpl['price_arr']['subtotal'], 2), $tpl['option_arr']['o_currency']);?></strong>
									</p>
								</div><!-- /.ylReservationRow -->
								<div class="ylReservationRow">
									<p class="ylPrice ylPriceUp">
										<span class="ylCol2"><?php __('front_summary');?></span>
	
										<strong class="ylCol3"><?php echo pjUtil::formatCurrencySign(number_format($tpl['price_arr']['subtotal'], 2), $tpl['option_arr']['o_currency']);?></strong>
									</p>
								</div><!-- /.ylReservationRow -->
								<div class="ylReservationRow">
									<p class="ylPrice ylPriceUp">
										<span class="ylCol2"><?php __('front_tax');?></span>
	
										<strong class="ylCol3"><?php echo pjUtil::formatCurrencySign(number_format($tpl['price_arr']['tax'], 2), $tpl['option_arr']['o_currency']);?></strong>
									</p>
								</div><!-- /.ylReservationRow -->
								<div class="ylReservationRow">
									<p class="ylTotal ylPrice">
										<span class="ylCol2"><?php __('front_total');?></span>
	
										<strong class="ylCol3"><?php echo pjUtil::formatCurrencySign(number_format($tpl['price_arr']['total'], 2), $tpl['option_arr']['o_currency']);?></strong>
									</p>
								</div><!-- /.ylReservationRow -->
								<div class="ylReservationRow">
									<p class="ylPrice ylPriceUp">
										<span class="ylCol2"><?php __('front_deposit');?></span>
	
										<strong class="ylCol3"><?php echo pjUtil::formatCurrencySign(number_format($tpl['price_arr']['deposit'], 2), $tpl['option_arr']['o_currency']);?></strong>
									</p>
								</div><!-- /.ylReservationRow -->
							</div><!-- /.ylReservationBody -->
						</div><!-- /.ylReservation -->
					</div><!-- /.ylDetailsAside -->
					
					<div class="ylDetailsContent">
						<div class="ylSectionBody">
							<div class="ylForm ylFormReserve">
								<form action="?controller=pjListings&amp;action=pjActionReserve" method="post" id="frmYLReserve_<?php echo $index;?>" name="frmYLReserve">
									<input type="hidden" name="reserve" value="1" />
									<input type="hidden" name="listing_id" value="<?php echo $tpl['arr']['id'];?>" />
									<input type="hidden" name="week_start" value="<?php echo date('Y-m-d', $_GET['week']);?>" />
									<input type="hidden" name="sub_total" value="<?php echo $tpl['price_arr']['subtotal'];?>" />
									<input type="hidden" name="tax" value="<?php echo $tpl['price_arr']['tax'];?>" />
									<input type="hidden" name="total" value="<?php echo $tpl['price_arr']['total'];?>" />
									<input type="hidden" name="deposit" value="<?php echo $tpl['price_arr']['deposit'];?>" />
									
									<?php
									if (in_array((int) $tpl['option_arr']['o_bf_include_title'], array(2,3)))
									{ 
										?>
										<div class="ylFormRow">
											<label><?php __('front_title');?>:</label>
											<select name="c_title" class="ylField<?php echo (int) $tpl['option_arr']['o_bf_include_title'] === 3 ? ' required' : null;?>" data-err="<?php __('front_title_required');?>">
												<option value="">-- <?php __('front_choose');?> --</option>
												<?php
												foreach(__('personal_titles', true) as $k => $v) 
												{
													?><option value="<?php echo $k;?>"<?php echo isset($_POST['c_title']) ? ($_POST['c_title'] == $k ? ' selected="selected"' : null) : null;?>><?php  echo $v;?></option><?php
												}
												?>
											</select>
										</div><!-- /.ylFormRow -->
										<?php
									}
									if (in_array((int) $tpl['option_arr']['o_bf_include_name'], array(2,3)))
									{ 
										?>
										<div class="ylFormRow">
											<label><?php __('front_name');?>:</label>
											<input type="text" name="c_name" class="ylField<?php echo (int) $tpl['option_arr']['o_bf_include_name'] === 3 ? ' required' : NULL; ?>" data-err="<?php __('front_name_required');?>" value="<?php echo pjSanitize::html(@$FORM['c_name']); ?>">
										</div><!-- /.ylFormRow -->
										<?php
									}
									if (in_array((int) $tpl['option_arr']['o_bf_include_email'], array(2,3)))
									{
										?>
										<div class="ylFormRow">
											<label><?php __('front_email');?>:</label>
											<input type="text" name="c_email" class="ylField email<?php echo (int) $tpl['option_arr']['o_bf_include_email'] === 3 ? ' required' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_email']); ?>" data-err="<?php __('front_email_required');?>" data-email="<?php __('front_email_invalid');?>">
										</div><!-- /.ylFormRow -->
										<?php
									}
									if (in_array((int) $tpl['option_arr']['o_bf_include_phone'], array(2,3)))
									{
										?>
										<div class="ylFormRow">
											<label><?php __('front_phone');?>:</label>
											<input type="text" name="c_phone" class="ylField<?php echo (int) $tpl['option_arr']['o_bf_include_phone'] === 3 ? ' required' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_phone']); ?>" data-err="<?php __('front_phone_required');?>">
										</div><!-- /.ylFormRow -->
										<?php
									}
									if (in_array((int) $tpl['option_arr']['o_bf_include_company'], array(2,3)))
									{
										?>
										<div class="ylFormRow">
											<label><?php __('front_company');?>:</label>
											<input type="text" name="c_company" class="ylField<?php echo (int) $tpl['option_arr']['o_bf_include_company'] === 3 ? ' required' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_company']); ?>" data-err="<?php __('front_company_required');?>">
										</div><!-- /.ylFormRow -->
										<?php
									}
									if (in_array((int) $tpl['option_arr']['o_bf_include_address'], array(2,3)))
									{
										?>
										<div class="ylFormRow">
											<label><?php __('front_address');?>:</label>
											<input type="text" name="c_address" class="ylField<?php echo (int) $tpl['option_arr']['o_bf_include_address'] === 3 ? ' required' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_address']); ?>" data-err="<?php __('front_address_required');?>">
										</div><!-- /.ylFormRow -->
										<?php
									}
									if (in_array((int) $tpl['option_arr']['o_bf_include_country'], array(2,3)))
									{
										?>
										<div class="ylFormRow">
											<label><?php __('front_country');?>:</label>
											<select name="c_country" class="ylField<?php echo (int) $tpl['option_arr']['o_bf_include_country'] === 3 ? ' required' : NULL; ?>" data-err="<?php __('front_country_required');?>">
												<option value="">-- <?php __('front_choose');?> --</option>
												<?php
												foreach($tpl['country_arr'] as $k => $v) 
												{
													?><option value="<?php echo $v['id'];?>"<?php echo isset($FORM['c_country']) ? ($FORM['c_country'] == $v['id'] ? ' selected="selected"' : null) : null;?>><?php  echo $v['name'];?></option><?php
												}
												?>
											</select>
										</div><!-- /.ylFormRow -->
										<?php
									}
									if (in_array((int) $tpl['option_arr']['o_bf_include_state'], array(2,3)))
									{
										?>
										<div class="ylFormRow">
											<label><?php __('front_state');?>:</label>
											<input type="text" name="c_state" class="ylField<?php echo (int) $tpl['option_arr']['o_bf_include_state'] === 3 ? ' required' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_state']); ?>" data-err="<?php __('front_state_required');?>">
										</div><!-- /.ylFormRow -->
										<?php
									}
									if (in_array((int) $tpl['option_arr']['o_bf_include_city'], array(2,3)))
									{
										?>
										<div class="ylFormRow">
											<label><?php __('front_city');?>:</label>
											<input type="text" name="c_city" class="ylField<?php echo (int) $tpl['option_arr']['o_bf_include_city'] === 3 ? ' required' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_city']); ?>" data-err="<?php __('front_city_required');?>">
										</div><!-- /.ylFormRow -->
										<?php
									}
									if (in_array((int) $tpl['option_arr']['o_bf_include_zip'], array(2,3)))
									{
										?>
										<div class="ylFormRow">
											<label><?php __('front_zip');?>:</label>
											<input type="text" name="c_zip" class="ylField<?php echo (int) $tpl['option_arr']['o_bf_include_zip'] === 3 ? ' required' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_zip']); ?>" data-err="<?php __('front_zip_required');?>">
										</div><!-- /.ylFormRow -->
										<?php
									}
									if (in_array((int) $tpl['option_arr']['o_bf_include_notes'], array(2,3)))
									{
										?>
										<div class="ylFormRow">
											<label><?php __('front_notes');?>:</label>
											<textarea name="c_notes" class="ylField<?php echo (int) $tpl['option_arr']['o_bf_include_notes'] === 3 ? ' required' : NULL; ?>" rows="6" data-err="<?php __('front_notes_required');?>"><?php echo pjSanitize::html(@$FORM['c_notes']); ?></textarea>
										</div><!-- /.ylFormRow -->
										<?php
									}
									if ($tpl['option_arr']['o_payment_disable'] == 'No')
									{
										$rand = rand(1, 99999);
										?>
										<div class="ylFormRow">
											<label><?php __('front_payment_method');?>:</label>
											<select id="ylPaymentMethod_<?php echo  $index;?>" name="payment_method" class="ylField required" data-err="<?php __('front_payment_method_required');?>">
									    		<option value="">-- <?php __('front_choose'); ?> --</option>
									    		<?php
												foreach (__('payment_methods', true) as $k => $v)
												{
													if ($tpl['option_arr']['o_allow_'.$k] == 'No')
													{
														continue;
													}
													?><option value="<?php echo $k; ?>"<?php echo @$FORM['payment_method'] != $k ? NULL : ' selected="selected"'; ?>><?php echo $v; ?></option><?php
												}
												?>
									    	</select>
										</div><!-- /.ylFormRow -->
										<div class="ylFormRow ylBankWrap" style="display: <?php echo @$FORM['payment_method'] != 'bank' ? 'none' : NULL; ?>">
											<span><?php echo !empty($tpl['option_arr']['o_bank_account']) ? nl2br($tpl['option_arr']['o_bank_account']) : ''; ?></span>
										</div><!-- /.ylFormRow -->
										
										<div class="ylFormRow ylCcWrap" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
											<label><?php __('front_cc_type');?>:</label>
											<select name="cc_type" class="ylField required" data-err="<?php __('front_cc_type_required');?>">
									    		<option value="">-- <?php __('front_choose'); ?>-- </option>
									    		<?php
												foreach (__('cc_types', true) as $k => $v)
												{
													?><option value="<?php echo $k; ?>"<?php echo @$FORM['cc_type'] != $k ? NULL : ' selected="selected"'; ?>><?php echo $v; ?></option><?php
												}
												?>
									    	</select>
										</div><!-- /.ylFormRow -->
										<div class="ylFormRow ylCcWrap" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
											<label><?php __('front_cc_num');?>:</label>
											<input type="text" name="cc_num" class="ylField required" value="<?php echo pjSanitize::html(@$FORM['cc_num']); ?>"  autocomplete="off" data-err="<?php __('front_cc_num_required');?>"/>
										</div><!-- /.ylFormRow -->
										<div class="ylFormRow ylCcWrap" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
											<label><?php __('front_cc_sec');?>:</label>
											<input type="text" name="cc_code" class="ylField required" value="<?php echo pjSanitize::html(@$FORM['cc_code']); ?>"  autocomplete="off" data-err="<?php __('front_cc_code_required');?>"/>
										</div><!-- /.ylFormRow -->
										<div class="ylFormRow ylCcWrap" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
											<label><?php __('front_cc_exp');?>:</label>
											<?php
											$time = pjTime::factory()
												->attr('name', 'cc_exp_month')
												->attr('id', 'cc_exp_month_' . $rand)
												->attr('class', 'ylField ylCCField required')
												->prop('format', 'F');
											if (isset($FORM['cc_exp_month']) && !is_null($FORM['cc_exp_month']))
											{
												$time->prop('selected', $FORM['cc_exp_month']);
											}
											echo $time->month();
											$time = pjTime::factory()
												->attr('name', 'cc_exp_year')
												->attr('id', 'cc_exp_year_' . $rand)
												->attr('class', 'ylField ylCCField required')
												->prop('left', 0)
												->prop('right', 10);
											if (isset($FORM['cc_exp_year']) && !is_null($FORM['cc_exp_year']))
											{
												$time->prop('selected', $FORM['cc_exp_year']);
											}
											echo $time->year();
											?>
										</div><!-- /.ylFormRow -->
										<?php 
									}
									if (in_array((int) $tpl['option_arr']['o_bf_include_captcha'], array(3)))
									{   
										?>
										<div style="clear: both;"></div><br/>
										<div class="ylFormRow">
											<label><?php __('front_captcha');?>:</label>	
											<div style="clear: both;"></div>
											<div>
												<input type="text" name="captcha" class="ylField ylCaptchaField required" maxlength="6" data-folder="<?php echo PJ_INSTALL_FOLDER;?>" data-err="<?php __('front_captcha_required');?>" data-captcha="<?php __('front_captcha_incorrect');?>"/>
												<img id="ylCaptchaImage_<?php echo $index;?>" src="<?php echo PJ_INSTALL_FOLDER; ?>index.php?controller=pjFront&amp;action=pjActionCaptcha&amp;rand=<?php echo rand(1, 999999); ?>" alt="Captcha" style="vertical-align:top;"/>
											</div>
										</div><!-- /.ylFormRow -->
										<?php
									} 
									?>
									<br/>
									<div class="ylFormControls">
										<a href="<?php echo $back;?>" class="ylBtn ylBtnWhiteColor"><?php __('front_button_cancel');?></a>
										<input type="submit" class="ylBtn ylBtnSubmit" value="<?php __('front_button_continue');?>">
									</div><!-- /.ylFormControls -->
									
									<br/>
									<div class="ylFormRow" style="display: none;">
										<span class="ylFormMessage"><?php __('front_booking_processing');?></span>
									</div>
									<div class="ylFormRow" style="display: none;">
										<span class="ylFormError"><?php __('front_booking_not_saved');?></span>
									</div>
								</form>
								<div id="pjWrapperYachtListing">
									<div id="ylReserveMessage_<?php echo $index;?>" class="ylFormRow" style="display: none;"></div>
								</div>
							</div><!-- /.ylForm -->
						</div><!-- /.ylSectionBody -->
					</div><!-- /.ylDetailsContent -->
				</div><!-- /.ylDetailsInfo ylBox -->
			</div>
			<?php
		}else{
			$listing_statuses = __('listing_statuses', true);
			?>
			<div class="ylDetails">
				<?php echo $listing_statuses[$tpl['status']];?>
			</div>
			<?php
		} 
		?>
	</div><!-- /.ylMain -->
</div>
<br/><br/>
<?php include_once ROOT_PATH . PJ_TEMPLATE_PATH . $tpl['option_arr']['o_layout']. '/elements/loadjs.php';?>