<div class="panel panel-default pjErBody pjErCheckout">
	<div class="panel-body">
		<?php
		if (isset($tpl['status']) && $tpl['status'] == 'OK')
		{ 
			$index = pjObject::escapeString($_GET['index']);
			?>
			<form action="" method="post" class="erSelectorCheckoutForm" data-toggle="validator" role="form">
				<input type="hidden" name="er_checkout" value="1" />
				<?php
				include PJ_VIEWS_PATH . 'pjFrontEnd/elements/summary.php';
				$FORM = @$_SESSION[$controller->defaultForm];
				?>
				<div class="pjErCheckoutBody">
					<?php
					ob_start();
					$number_of_cols = 0;
					if (in_array((int) $tpl['option_arr']['o_bf_name'], array(2,3)))
					{
						?>
						<div class="col-md-4 col-sm-6 col-xs-12">
							<div class="form-group">
								<label for="" class="control-label"><?php __('booking_name'); ?><?php echo (int) $tpl['option_arr']['o_bf_name'] === 3 ? ' *' : NULL;?></label>
								<input type="text" name="c_name" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_name'] === 3 ? ' erRequired' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_name']); ?>" data-msg-required="<?php __('front_field_required');?>"/>
								<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
							</div><!-- /.form-group -->
						</div><!-- /.col-lg-4 col-md-4 col-sm-6 col-xs-12 -->
						<?php
						$number_of_cols++;
					}
					if (in_array((int) $tpl['option_arr']['o_bf_email'], array(2,3)))
					{
						?>
						<div class="ccol-md-4 col-sm-6 col-xs-12">
							<div class="form-group">
								<label for="" class="control-label"><?php __('booking_email'); ?><?php echo (int) $tpl['option_arr']['o_bf_email'] === 3 ? ' *' : NULL;?></label>
								<input type="text" name="c_email" class="form-control email<?php echo (int) $tpl['option_arr']['o_bf_name'] === 3 ? ' erRequired' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_email']); ?>" data-msg-required="<?php __('front_field_required');?>" data-msg-email="<?php __('front_email_invalid');?>"/>
								<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
							</div><!-- /.form-group -->
						</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
						<?php
						$number_of_cols++;
					}
					if (in_array((int) $tpl['option_arr']['o_bf_phone'], array(2,3)))
					{
						?>
						<div class="col-md-4 col-sm-6 col-xs-12">
							<div class="form-group">
								<label for="" class="control-label"><?php __('booking_phone'); ?><?php echo (int) $tpl['option_arr']['o_bf_phone'] === 3 ? ' *' : NULL;?></label>
								<input type="text" name="c_phone" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_phone'] === 3 ? ' erRequired' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_phone']); ?>" data-msg-required="<?php __('front_field_required');?>"/>
								<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
							</div><!-- /.form-group -->
						</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
						<?php
						$number_of_cols++;
					}
					if($number_of_cols == 3)
					{
						$ob_fields = ob_get_contents();
						ob_end_clean();
						?>
						<div class="row"><?php echo $ob_fields; ?></div>
						<?php
						ob_start();
						$number_of_cols = 0;
					}
					if (in_array((int) $tpl['option_arr']['o_bf_address_1'], array(2,3)))
					{
						?>
						<div class="col-md-4 col-sm-6 col-xs-12">
							<div class="form-group">
								<label for="" class="control-label"><?php __('booking_address_1'); ?><?php echo (int) $tpl['option_arr']['o_bf_address_1'] === 3 ? ' *' : NULL;?></label>
								<input type="text" name="c_address_1" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_address_1'] === 3 ? ' erRequired' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_address_1']); ?>" data-msg-required="<?php __('front_field_required');?>"/>
								<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
							</div><!-- /.form-group -->
						</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
						<?php
						$number_of_cols++;
					}
					if($number_of_cols == 3)
					{
						$ob_fields = ob_get_contents();
						ob_end_clean();
						?>
						<div class="row"><?php echo $ob_fields; ?></div>
						<?php
						ob_start();
						$number_of_cols = 0;
					}
					if (in_array((int) $tpl['option_arr']['o_bf_address_2'], array(2,3)))
					{
						?>
						<div class="col-md-4 col-sm-6 col-xs-12">
							<div class="form-group">
								<label for="" class="control-label"><?php __('booking_address_2'); ?><?php echo (int) $tpl['option_arr']['o_bf_address_2'] === 3 ? ' *' : NULL;?></label>
								<input type="text" name="c_address_2" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_address_2'] === 3 ? ' erRequired' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_address_2']); ?>" data-msg-required="<?php __('front_field_required');?>"/>
								<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
							</div><!-- /.form-group -->
						</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
						<?php
						$number_of_cols++;
					}
					if($number_of_cols == 3)
					{
						$ob_fields = ob_get_contents();
						ob_end_clean();
						?>
						<div class="row"><?php echo $ob_fields; ?></div>
						<?php
						ob_start();
						$number_of_cols = 0;
					}
					if (in_array((int) $tpl['option_arr']['o_bf_country'], array(2,3)))
					{
						?>
						<div class="col-md-4 col-sm-6 col-xs-12">
							<div class="form-group">
								<label for="" class="control-label"><?php __('booking_country'); ?><?php echo (int) $tpl['option_arr']['o_bf_country'] === 3 ? ' *' : NULL;?></label>
								<select name="c_country_id" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_country'] === 3 ? ' erRequired' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>">
									<option value="">-- <?php __('co_select_country'); ?> --</option>
									<?php
									foreach ($tpl['country_arr'] as $country)
									{
										?><option value="<?php echo $country['id']; ?>"<?php echo $country['id'] != @$FORM['c_country_id'] ? NULL : ' selected="selected"'; ?>><?php echo pjSanitize::html($country['name']); ?></option><?php
									}
									?>
								</select>
								<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
							</div><!-- /.form-group -->
						</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
						<?php
						$number_of_cols++;
					}
					if($number_of_cols == 3)
					{
						$ob_fields = ob_get_contents();
						ob_end_clean();
						?>
						<div class="row"><?php echo $ob_fields; ?></div>
						<?php
						ob_start();
						$number_of_cols = 0;
					}
					if (in_array((int) $tpl['option_arr']['o_bf_state'], array(2,3)))
					{
						?>
						<div class="col-md-4 col-sm-6 col-xs-12">
							<div class="form-group">
								<label for="" class="control-label"><?php __('booking_state'); ?><?php echo (int) $tpl['option_arr']['o_bf_state'] === 3 ? ' *' : NULL;?></label>
								<input type="text" name="c_state" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_state'] === 3 ? ' erRequired' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_state']); ?>" data-msg-required="<?php __('front_field_required');?>"/>
								<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
							</div><!-- /.form-group -->
						</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
						<?php
						$number_of_cols++;
					}
					if($number_of_cols == 3)
					{
						$ob_fields = ob_get_contents();
						ob_end_clean();
						?>
						<div class="row"><?php echo $ob_fields; ?></div>
						<?php
						ob_start();
						$number_of_cols = 0;
					}
					if (in_array((int) $tpl['option_arr']['o_bf_city'], array(2,3)))
					{
						?>
						<div class="col-md-4 col-sm-6 col-xs-12">
							<div class="form-group">
								<label for="" class="control-label"><?php __('booking_city'); ?><?php echo (int) $tpl['option_arr']['o_bf_city'] === 3 ? ' *' : NULL;?></label>
								<input type="text" name="c_city" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_city'] === 3 ? ' erRequired' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_city']); ?>" data-msg-required="<?php __('front_field_required');?>"/>
								<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
							</div><!-- /.form-group -->
						</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
						<?php
						$number_of_cols++;
					}
					if($number_of_cols == 3)
					{
						$ob_fields = ob_get_contents();
						ob_end_clean();
						?>
						<div class="row"><?php echo $ob_fields; ?></div>
						<?php
						ob_start();
						$number_of_cols = 0;
					}
					if (in_array((int) $tpl['option_arr']['o_bf_zip'], array(2,3)))
					{
						?>
						<div class="col-md-4 col-sm-6 col-xs-12">
							<div class="form-group">
								<label for="" class="control-label"><?php __('booking_zip'); ?><?php echo (int) $tpl['option_arr']['o_bf_zip'] === 3 ? ' *' : NULL;?></label>
								<input type="text" name="c_zip" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_zip'] === 3 ? ' erRequired' : NULL; ?>" value="<?php echo pjSanitize::html(@$FORM['c_zip']); ?>" data-msg-required="<?php __('front_field_required');?>"/>
								<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
							</div><!-- /.form-group -->
						</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
						<?php
						$number_of_cols++;
					}
					$ob_fields = ob_get_contents();
					ob_end_clean();
					if(!empty($ob_fields))
					{
						?>
						<div class="row"><?php echo $ob_fields; ?></div>
						<?php
					}
					if (in_array((int) $tpl['option_arr']['o_bf_notes'], array(2,3)))
					{
						?>
						<div class="row">
							<div class="col-xs-12">
								<div class="form-group">
									<label for="" class="control-label"><?php __('booking_notes'); ?><?php echo (int) $tpl['option_arr']['o_bf_notes'] === 3 ? ' *' : NULL;?></label>
									<textarea name="c_notes" rows="10" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_notes'] === 3 ? ' erRequired' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"><?php echo pjSanitize::html(@$FORM['c_notes']); ?></textarea>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
							</div><!-- /.col-xs-12 -->
						</div>
						<?php
					}
					if ((int) $tpl['option_arr']['o_disable_payments'] === 0)
					{
						?>
						<div class="row">
							<div class="col-md-4 col-sm-6 col-xs-12">
								<div class="form-group">
									<label for="" class="control-label"><?php __('booking_payment_method'); ?> *</label>
									<select name="payment_method" class="form-control erRequired" data-msg-required="<?php __('front_field_required');?>">
										<option value="">-- <?php __('front_select_payment'); ?> --</option>
										<?php
										foreach (__('payment_methods', true) as $k => $v)
										{
											if ((int) $tpl['option_arr']['o_allow_' . $k] === 1)
											{
												?><option value="<?php echo $k; ?>"<?php echo @$FORM['payment_method'] != $k ? NULL : ' selected="selected"'; ?>><?php echo $v; ?></option><?php
											}
										}
										?>
									</select>
								</div><!-- /.form-group -->
							</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
							<div class="col-md-4 col-sm-6 col-xs-12 erSelectorBank" style="display: <?php echo @$FORM['payment_method'] != 'bank' ? 'none' : NULL; ?>">
								<div class="form-group">
									<label for="" class="control-label"><?php __('booking_bank_account'); ?></label>
									<p class="form-control-static"><?php echo nl2br(stripslashes($tpl['option_arr']['o_bank_account'])); ?></p>
								</div><!-- /.form-group -->
							</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
							
							<div class="col-md-4 col-sm-6 col-xs-12 erSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
								<div class="form-group">
									<label for="" class="control-label"><?php __('booking_cc_type'); ?> *</label>
									<select name="cc_type" class="form-control erRequired" data-msg-required="<?php __('front_field_required');?>">
										<option value="">-- <?php __('front_select_cc_type'); ?> --</option>
										<?php
										foreach (__('booking_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 class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
							</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
							<div class="col-md-4 col-sm-6 col-xs-12 erSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
								<div class="form-group">
									<label for="" class="control-label"><?php __('booking_cc_num'); ?> *</label>
									<input type="text" name="cc_num" class="form-control erRequired" value="<?php echo pjSanitize::html(@$FORM['cc_num']); ?>" autocomplete="off"  data-msg-required="<?php __('front_field_required');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
							</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
						</div>
						<div class="row">
							<div class="col-md-4 col-sm-6 col-xs-12 erSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
								<div class="form-group">
									<label for="" class="control-label"><?php __('booking_cc_code'); ?> *</label>
									<input type="text" name="cc_code" class="form-control erRequired" value="<?php echo pjSanitize::html(@$FORM['cc_code']); ?>" autocomplete="off"  data-msg-required="<?php __('front_field_required');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
							</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
							<div class="col-md-4 col-sm-6 col-xs-12 erSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
								<div class="form-group">
									<label for="" class="control-label"><?php __('booking_cc_exp'); ?> *</label>
									<?php
									$time = pjTime::factory()
										->attr('name', 'cc_exp_month')
										->attr('id', 'cc_exp_month_' . $index)
										->attr('class', 'form-control erRequired')
										->prop('format', 'F');
				
									if (isset($FORM['cc_exp_month']))
									{
										$time->prop('selected', $FORM['cc_exp_month']);
									}
									echo $time->month();
									?>
								</div><!-- /.form-group -->
							</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
							<div class="col-md-4 col-sm-6 col-xs-12 erSelectorCCard" style="display: <?php echo @$FORM['payment_method'] != 'creditcard' ? 'none' : NULL; ?>">
								<div class="form-group">
									<label for="" class="control-label">&nbsp;</label>
									<?php
									$time = pjTime::factory()
										->attr('name', 'cc_exp_year')
										->attr('id', 'cc_exp_year_' . $index)
										->attr('class', 'form-control erRequired')
										->prop('left', 0)
										->prop('right', 6);
				
									if (isset($FORM['cc_exp_year']))
									{
										$time->prop('selected', $FORM['cc_exp_year']);
									}
									echo $time->year();
									?>
								</div><!-- /.form-group -->
							</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
						</div>
						<?php
					} 
					?>
					<div class="row">
						<?php
						if (in_array((int) $tpl['option_arr']['o_bf_captcha'], array(3)))
						{
							?>
							<div class="col-md-4 col-sm-6 col-xs-12">
								<div class="form-group pjErCaptcha">
									<label for="" class="control-label"><?php __('co_captcha'); ?><?php echo (int) $tpl['option_arr']['o_bf_captcha'] === 3 ? ' *' : NULL;?></label>
		
									<div class="row pjErFormControls">
	  								  	<div class="col-md-3 col-sm-4 col-xs-12">
	  								    	<img id="pjErCaptchaImage_<?php echo $index;?>" alt="Captcha" src="<?php echo PJ_INSTALL_FOLDER; ?>index.php?controller=pjFrontEnd&action=pjActionCaptcha&rand=<?php echo rand(1000, 999999); ?><?php echo isset($_GET['session_id']) ? "&session_id=" . pjSanitize::clean($_GET['session_id']) : NULL; ?>" style="vertical-align: middle; cursor: pointer;" />
	  								  	</div>
	  								  	<div class="col-md-6 col-sm-4 col-xs-12">
	  								  		<input type="text" id="pjErCaptcha_<?php echo $index;?>" name="captcha" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_captcha'] === 3 ? ' erRequired' : NULL; ?>" maxlength="6" autocomplete="off" data-msg-required="<?php __('front_field_required');?>"  data-msg-remote="<?php __('front_captcha_not_correct');?>">
	  								  	</div>
	  								  	<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
	  								</div>
								</div><!-- /.form-group pjErCaptcha -->
							</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
							<?php
						}
						if (in_array((int) $tpl['option_arr']['o_bf_terms'], array(3)))
						{
							?>
							<div class="col-md-4 col-sm-6 col-xs-12">
								<div class="form-group">
									<label for="" class="control-label">&nbsp;</label>
									<div class="pjErCheckbox">
										<input type="checkbox" name="terms" id="terms_<?php echo $index; ?>" value="1" class="<?php echo (int) $tpl['option_arr']['o_bf_terms'] === 3 ? ' erRequired' : NULL; ?>" style="margin: 0" data-msg-required="<?php __('front_field_required');?>"/>
										<label for="terms_<?php echo $index; ?>" style=""><?php __('co_terms'); ?></label>
									</div><!-- /.pjErCheckbox -->
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
							</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
							<?php
						}
						if (isset($tpl['terms_arr']) && !empty($tpl['terms_arr']))
						{
							$t_url = $tpl['terms_arr']['terms_url'];
							$t_body = trim($tpl['terms_arr']['terms_body']);
							?>
							<div class="col-md-4 col-sm-6 col-xs-12">
								<div class="form-group">
									<label for="" class="control-label">&nbsp;</label>
									<div class="pjErCheckbox">
										<?php
										if (!empty($t_url) && preg_match('/^http(s)?:\/\//i', $t_url))
										{
											?><a href="<?php echo pjSanitize::html($t_url); ?>" target="_blank"><?php __('front_terms_link'); ?></a><?php
										} elseif (!empty($t_body)) {
											?><a href="#" class="pjTbModalTrigger" data-toggle="modal" data-target="#pjCpbTermModal"><?php __('front_terms_link'); ?></a><?php
										}
										?>
									</div><!-- /.pjErCheckbox -->
								</div><!-- /.form-group -->
							</div><!-- /.col-md-4 col-sm-6 col-xs-12 -->
							<?php
						} 
						?>
					</div><!-- /.row -->
				</div><!-- /.pjErCheckoutBody -->
	
				<footer class="pjErCheckoutFoot">
					<div class="clearfix pjErCheckoutActions">
						<a href="<?php echo pjUtil::getReferer(); ?>#!/Cart" class="btn btn-default pull-left pjErBtn pjErBtnSecondary erSelectorButton erSelectorCart"><?php __('button_back'); ?></a>
						<button type="submit" class="btn btn-default pull-right pjErBtn erSelectorButton pjErBtnPrimary"><?php __('button_preview'); ?></button>
					</div><!-- /.clearfix pjErCheckoutActions -->
				</footer><!-- /.pjErCheckoutFoot -->
			</form>
			<?php
		} elseif (isset($tpl['status']) && $tpl['status'] == 'ERR') { 
			if (isset($tpl['code']))
			{
				switch ($tpl['code'])
				{
					case 101:
						__('co_empty_notice');
						break;
					case 104:
						__('accept_bookings_notice');
						break;
				}
			}
		}
		?>
	</div><!-- /.panel-body -->
</div><!-- /.panel panel-default pjErBody pjErCheckout -->