<?php
include_once PJ_VIEWS_PATH . 'pjFront/elements/header.php';
?>
<div class="container-fluid pjMbContainer pjMbContent">
	<?php
	if(!empty($tpl['cart_arr']['product_arr']) || !empty($tpl['cart_arr']['package_arr']))
	{ 
		?>
		<div id="pjCsCartContainer_<?php echo $_GET['index'];?>">
			<?php include_once PJ_VIEWS_PATH . 'pjFront/elements/cart.php';?>
		</div>
		
		<?php
		$months = __('months', true);
		$short_months = __('short_months', true);
		ksort($months);
		ksort($short_months);
		$days = __('days', true);
		$short_days = __('short_days', true);
		
		$FORM = isset($_SESSION[$controller->defaultForm]) ? $_SESSION[$controller->defaultForm] : array();
		
		?>
		<form id="pjCsCheckoutForm_<?php echo $_GET['index'];?>" name="pjCsCheckoutForm" action="" method="post" role="form" data-toggle="validator">
		
			<input type="hidden" name="cs_checkout" value="1" />
			
			<div class="pjMbContentBody">
				<h2><?php __('front_your_details');?></h2>
			</div>
			
			<div id="pjCsCalendarLocale" style="display: none;" data-months="<?php echo implode("_", $months);?>" data-days="<?php echo implode("_", $short_days);?>"></div>
			
			<?php
			$fields = 1;
			ob_start();
			?>	
				<div class="col-sm-4 col-sm-6">
					<label for="" class="control-label text-capitalize"><?php __('front_delivery_date');?></label>

					<div class="row">
						<div class="col-sm-6">
							<div class="input-group pjCsDatePicker">
								<input type="text" id="pjCsDeliveryDate_<?php echo $_GET['index'];?>" name="delivery_date" readonly="readonly" value="<?php echo isset($FORM['delivery_date']) ? htmlspecialchars(stripslashes(@$FORM['delivery_date'])) : NULL; ?>" class="form-control required" data-msg-required="<?php __('front_field_required');?>"/>
							
								<span class="input-group-addon">
									<span class="glyphicon glyphicon-calendar" aria-hidden="true"></span>
								</span>
							</div><!-- /.input-group pjNcbDate -->
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div>
					
						<div class="col-sm-6">
							<div class="input-group pjCrTimePicker pjCsTimePicker">
								<span class="input-group-addon pjCrCursorPointer">
									<span class="glyphicon glyphicon-time" aria-hidden="true"></span>
								</span>
								<input type="text" name="delivery_time" class="form-control required" readonly="readonly" value="<?php echo isset($FORM['delivery_time']) ? htmlspecialchars(stripslashes(@$FORM['delivery_time'])) : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
								<input type="hidden" name="delivery_hour" value="<?php echo isset($FORM['delivery_hour']) ? htmlspecialchars(stripslashes(@$FORM['delivery_hour'])) : NULL; ?>" />
								<input type="hidden" name="delivery_minute" value="<?php echo isset($FORM['delivery_minute']) ? htmlspecialchars(stripslashes(@$FORM['delivery_minute'])) : NULL; ?>" />
								
							</div>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div>
					</div><!-- /.row --><!-- /.form-group -->
				</div><!-- /.col-sm-6 -->
				
				<?php
				if (in_array($tpl['option_arr']['o_bf_include_title'], array(2, 3)))
				{
					?>
					<div class="col-sm-4 col-sm-6">
						<div class="form-group">
							<label for="" class="control-label text-capitalize"><?php __('front_title'); ?></label>
							
							<select name="c_title" class="form-control<?php echo ($tpl['option_arr']['o_bf_include_title'] == 3) ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>">
								<option value="">----</option>
								<?php
								$title_arr = pjUtil::getTitles();
								$name_titles = __('personal_titles', true, false);
								foreach ($title_arr as $v)
								{
									?><option value="<?php echo $v; ?>"<?php echo isset($FORM['c_title']) ? (@$FORM['c_title'] == $v ? ' selected="selected"' : NULL) : NULL; ?>><?php echo $name_titles[$v]; ?></option><?php
								}
								?>
							</select>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.form-group -->
					</div><!-- /.col-sm-6 -->
					<?php
					$fields++;
				}
				if (in_array($tpl['option_arr']['o_bf_include_name'], array(2, 3)))
				{
					?>
					<div class="col-sm-4 col-sm-6">
						<div class="form-group">
							<label for="" class="control-label text-capitalize"><?php __('front_name'); ?></label>
							<input type="text" name="c_name" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_include_name'] === 3 ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_name']) ? htmlspecialchars(stripslashes(@$FORM['c_name'])) : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.form-group -->
					</div><!-- /.col-sm-6 -->
					<?php
					$fields++;
					if($fields == 3)
					{
						$content = ob_get_contents();
						ob_end_clean();
						?><div class="row"><?php echo $content;?></div><?php
						ob_start();
						$fields = 0;
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_email'], array(2, 3)))
				{
					?>
					<div class="col-sm-4 col-sm-6">
						<div class="form-group">
							<label for="" class="control-label text-capitalize"><?php __('front_email'); ?></label>
							<input type="text" name="c_email" class="form-control email<?php echo (int) $tpl['option_arr']['o_bf_include_email'] === 3 ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_email']) ? htmlspecialchars(stripslashes(@$FORM['c_email'])) : NULL; ?>" data-msg-required="<?php __('front_field_required');?>" data-msg-email="<?php __('front_email_not_valid');?>"/>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.form-group -->
					</div><!-- /.col-sm-6 -->
					<?php
					$fields++;
					if($fields == 3)
					{
						$content = ob_get_contents();
						ob_end_clean();
						?><div class="row"><?php echo $content;?></div><?php
						ob_start();
						$fields = 0;
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_phone'], array(2, 3)))
				{ 
					?>
					<div class="col-sm-4 col-sm-6">
						<div class="form-group">
							<label for="" class="control-label text-capitalize"><?php __('front_phone'); ?></label>
							<input type="text" name="c_phone" class="form-control fdW50p<?php echo (int) $tpl['option_arr']['o_bf_include_phone'] === 3 ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_phone']) ? htmlspecialchars(stripslashes(@$FORM['c_phone'])) : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.form-group -->
					</div><!-- /.col-sm-6 -->
					<?php
					$fields++;
					if($fields == 3)
					{
						$content = ob_get_contents();
						ob_end_clean();
						?><div class="row"><?php echo $content;?></div><?php
						ob_start();
						$fields = 0;
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_company'], array(2, 3)))
				{ 
					?>
					<div class="col-sm-4 col-sm-6">
						<div class="form-group">
							<label for="" class="control-label text-capitalize"><?php __('front_company'); ?></label>
							<input type="text" name="c_company" class="form-control fdW100p<?php echo (int) $tpl['option_arr']['o_bf_include_company'] === 3 ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_company']) ? htmlspecialchars(stripslashes(@$FORM['c_company'])) : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.form-group -->
					</div><!-- /.col-sm-6 -->
					<?php
					$fields++;
					if($fields == 3)
					{
						$content = ob_get_contents();
						ob_end_clean();
						?><div class="row"><?php echo $content;?></div><?php
						ob_start();
						$fields = 0;
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_address'], array(2, 3)))
				{
					?>
					<div class="col-sm-4 col-sm-6">
						<div class="form-group">
							<label for="" class="control-label text-capitalize"><?php __('front_address'); ?></label>
							<input type="text" name="c_address" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_include_address'] === 3 ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_address']) ? htmlspecialchars(stripslashes(@$FORM['c_address'])) : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.form-group -->
					</div><!-- /.col-sm-6 -->
					<?php
					$fields++;
					if($fields == 3)
					{
						$content = ob_get_contents();
						ob_end_clean();
						?><div class="row"><?php echo $content;?></div><?php
						ob_start();
						$fields = 0;
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_city'], array(2, 3)))
				{
					?>
					<div class="col-sm-4 col-sm-6">
						<div class="form-group">
							<label for="" class="control-label text-capitalize"><?php __('front_city'); ?></label>
							<input type="text" name="c_city" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_include_city'] === 3 ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_city']) ? htmlspecialchars(stripslashes(@$FORM['c_city'])) : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.form-group -->
					</div><!-- /.col-sm-6 -->
					<?php
					$fields++;
					if($fields == 3)
					{
						$content = ob_get_contents();
						ob_end_clean();
						?><div class="row"><?php echo $content;?></div><?php
						ob_start();
						$fields = 0;
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_state'], array(2, 3)))
				{ 
					?>
					<div class="col-sm-4 col-sm-6">
						<div class="form-group">
							<label for="" class="control-label text-capitalize"><?php __('front_state'); ?></label>
							<input type="text" name="c_state" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_include_state'] === 3 ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_state']) ? htmlspecialchars(stripslashes(@$FORM['c_state'])) : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.form-group -->
					</div><!-- /.col-sm-6 -->
					<?php
					$fields++;
					if($fields == 3)
					{
						$content = ob_get_contents();
						ob_end_clean();
						?><div class="row"><?php echo $content;?></div><?php
						ob_start();
						$fields = 0;
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_zip'], array(2, 3)))
				{ 
					?>
					<div class="col-sm-4 col-sm-6">
						<div class="form-group">
							<label for="" class="control-label text-capitalize"><?php __('front_zip'); ?></label>
							<input type="text" name="c_zip" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_include_zip'] === 3 ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_zip']) ? htmlspecialchars(stripslashes(@$FORM['c_zip'])) : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.form-group -->
					</div><!-- /.col-sm-6 -->
					<?php
					$fields++;
					if($fields == 3)
					{
						$content = ob_get_contents();
						ob_end_clean();
						?><div class="row"><?php echo $content;?></div><?php
						ob_start();
						$fields = 0;
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_country'], array(2, 3)))
				{ 
					?>
					<div class="col-sm-4 col-sm-6">
						<div class="form-group">
							<label for="" class="control-label text-capitalize"><?php __('front_country'); ?></label>
							
								<select name="c_country" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_include_country'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>">
									<option value="">-- <?php __('front_choose'); ?> --</option>
									<?php
									foreach ($tpl['country_arr'] as $country)
									{
										?><option value="<?php echo $country['id']; ?>"<?php echo isset($FORM['c_country']) ? (@$FORM['c_country'] == $country['id'] ? ' selected="selected"' : NULL) : NULL; ?>><?php echo stripslashes($country['country_title']); ?></option><?php
									}
									?>
								</select>
								<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.form-group -->
					</div><!-- /.col-sm-6 -->
					<?php
					$fields++;
					if($fields == 3)
					{
						$content = ob_get_contents();
						ob_end_clean();
						?><div class="row"><?php echo $content;?></div><?php
						ob_start();
						$fields = 0;
					}
				}
				if (in_array($tpl['option_arr']['o_bf_include_notes'], array(2, 3)))
				{
					?>
					<div class="col-sm-4 col-sm-6">
						<div class="form-group">
							<label for="" class="control-label text-capitalize"><?php __('front_notes'); ?></label>
							<textarea name="c_notes" class="form-control<?php echo (int) $tpl['option_arr']['o_bf_include_notes'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"><?php echo isset($FORM['c_notes']) ? htmlspecialchars(stripslashes(@$FORM['c_notes'])) : NULL; ?></textarea>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.form-group -->
					</div><!-- /.col-sm-6 -->
					<?php
					$fields++;
				} 
				$content = ob_get_contents();
				ob_end_clean();
				?><div class="row"><?php echo $content;?></div><?php
				ob_start();
				$fields = 0;
				if($tpl['option_arr']['o_payment_disable'] == 'No')
				{
					?>
					<div class="row">
						<div class="col-sm-4 col-sm-6">
							<div class="form-group">
								<label for="" class="control-label text-capitalize"><?php __('front_payment_medthod'); ?></label>
								
								<select id="fdPaymentMethod_<?php echo $_GET['index'];?>" name="payment_method" class="form-control required" data-msd-required="<?php __('front_field_required');?>">
									<option value="">----</option>
									<?php
									foreach (__('payment_methods', true, false) as $k => $v)
									{
										if($tpl['option_arr']['o_allow_' . $k] == 'Yes')
										{
											?><option value="<?php echo $k; ?>"<?php echo isset($FORM['payment_method']) && $FORM['payment_method'] == $k ? ' selected="selected"' : NULL; ?>><?php echo $v; ?></option><?php
										}
									}
									?>
								</select>
								<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
							</div><!-- /.form-group -->
						</div><!-- /.col-sm-6 -->
	
						<div class="pjCsBankWrap" style="display: <?php echo isset($FORM['payment_method']) && $FORM['payment_method'] == 'bank' ? 'block' : 'none'; ?>">
							<div class="col-sm-4 col-sm-6">
								<div class="form-group">
									<label for="" class="control-label text-capitalize">&nbsp;</label>
									<p class="fdParagraph fdTermsConditions">
										<?php echo nl2br(pjSanitize::clean($tpl['option_arr']['o_bank_account']));?>
									</p>
								</div>
							</div><!-- /.col-sm-6 -->
						</div>
	
						<div class="pjCsCCWrap" style="display: <?php echo isset($FORM['payment_method']) && $FORM['payment_method'] == 'creditcard' ? 'block' : 'none'; ?>">
							<div class="col-sm-4 col-sm-6">
								<div class="form-group">
									<label for="" class="control-label text-capitalize"><?php __('front_cc_type'); ?></label>
									
										<select name="cc_type" class="form-control required" data-err="<?php __('front_field_required');?>">
											<option value="">----</option>
											<?php
											foreach (__('cc_types', true, false) as $k => $v)
											{
												?><option value="<?php echo $k; ?>"<?php echo isset($FORM['cc_type']) && $FORM['cc_type'] == $k ? ' selected="selected"' : NULL; ?>><?php echo $v; ?></option><?php
											}
											?>
										</select>
										<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
							</div><!-- /.col-sm-6 -->
	
							<div class="col-sm-4 col-sm-6">
								<div class="form-group">
									<label for="" class="control-label text-capitalize"><?php __('front_cc_number'); ?></label>
									<input type="text" name="cc_num" class="form-control required" value="<?php echo htmlspecialchars(stripslashes(@$FORM['cc_num'])); ?>" data-err="<?php __('front_field_required');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
							</div><!-- /.col-sm-6 -->
	
							<div class="col-sm-4 col-sm-6">
								<div class="form-group">
									<label for="" class="control-label text-capitalize"><?php __('front_cc_exp'); ?></label>
									<div class="row">
										<div class="col-lg-5 col-md-4 col-sm-4 col-xs-4">
											<?php
											$rand = rand(1, 99999);
											$time = pjTime::factory()
												->attr('name', 'cc_exp_month')
												->attr('id', 'cc_exp_month_' . $rand)
												->attr('class', 'form-control 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();
											?>
										</div><!-- /.col-lg-5 col-md-4 col-sm-4 col-xs-4 -->
						
										<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
											<?php
											$time = pjTime::factory()
												->attr('name', 'cc_exp_year')
												->attr('id', 'cc_exp_year_' . $rand)
												->attr('class', 'form-control 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><!-- /.col-lg-3 col-md-4 col-sm-4 col-xs-4 -->
									</div>
								</div><!-- /.form-group -->
							</div><!-- /.col-sm-6 -->
	
							<div class="col-sm-4 col-sm-6">
								<div class="form-group">
									<label for="" class="control-label text-capitalize"><?php __('front_cc_code'); ?></label>
									<input type="text" name="cc_code" class="form-control required" value="<?php echo htmlspecialchars(stripslashes(@$FORM['cc_code'])); ?>" data-err="<?php __('front_field_required');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
							</div><!-- /.col-sm-6 -->
						</div>
					</div>
					<?php
				} 
				?>
				<div class="row">
				<?php
				if (in_array($tpl['option_arr']['o_bf_include_captcha'], array(2, 3))){
					?>
					<div class="col-sm-4 col-sm-6">
						<div class="form-group">
							<label for="" class="control-label text-capitalize"><?php __('front_captcha'); ?></label>
							<div class="row">
								<div class="col-md-6">
									<input type="text" id="pjCsCaptcha_<?php echo $_GET['index'];?>" maxlength="6" name="captcha" class="form-control <?php echo ($tpl['option_arr']['o_bf_include_captcha'] == 3) ? ' required' : NULL; ?>" autocomplete="off" data-err="<?php __('front_field_required');?>" data-msg-remote="<?php __('frotn_incorrect_captcha');?>"/>
								</div>
								<div class="col-md-6">
									<img src="<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjFront&action=pjActionCaptcha&rand=<?php echo rand(1, 9999); ?><?php echo isset($_GET['session_id']) ? '&session_id=' . $_GET['session_id'] : NULL;?>" alt="Captcha" style="border: solid 1px #E0E3E8;"/>
								</div>
							</div>
							<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
						</div><!-- /.form-group -->
					</div><!-- /.col-sm-6 -->
					<?php
				}
				$terms = __('front_agree_with_terms', true);
				if(!empty($tpl['terms_conditions']))
				{
					$terms = str_replace("{STAG}", '<a href="#" class="pjTbModalTrigger" data-toggle="modal" data-target="#pjNcbTermModal" data-title="'.__('front_terms_title', true).'">', $terms);
					$terms = str_replace("{ETAG}", '</a>', $terms);
				}else{
					$terms = str_replace("{STAG}", '', $terms);
					$terms = str_replace("{ETAG}", '', $terms);
				}  
				?>
				<div class="col-sm-4 col-sm-6">
					<div class="form-group">
						<label for="" class="control-label text-capitalize">&nbsp;</label>
						<div class="pjMrBCheckbox pjMrBCustomCheckbox">
							<input type="checkbox" id="pjMrBCCheckboxTerms" name="terms" value="1" checked="checked" class="required" data-msg-required="<?php __('front_field_required'); ?>">
															
							<label for="pjMrBCCheckboxTerms"><?php echo $terms;?></label>
						</div><!-- /.pjMrBCheckbox pjMrBCustomCheckbox -->
															
						<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
					</div><!-- /.form-group -->
				</div><!-- /.col-sm-6 -->
			</div>
			<div class="form-group">
				<button type="submit" class="btn btn-primary"><?php __('front_btn_preview_booking');?></button>
			</div>
		</form>
		
		<div class="modal fade pjTbModal" id="pjNcbTermModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		  	<div class="modal-dialog">
		    	<div class="modal-content">
		      		<div class="modal-header">
		        		<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only"><?php __('front_btn_close');?></span></button>
		        		<h4 class="modal-title pjTbModalTitle" id="myModalLabel"><?php __('front_terms_title', false, true); ?></h4>
		      		</div>
				    <div class="modal-body">
				    	<?php echo nl2br(stripslashes($tpl['terms_conditions'])); ?>
				    </div>
			      	<div class="modal-footer">
			        	<button type="button" class="btn btn-default" data-dismiss="modal"><?php __('front_btn_close');?></button>
			      	</div>
		    	</div>
		  	</div>
		</div>
		<?php
	}else{
		?>
		<div class="pjCsCartContent">
			<div class="text-alert"><?php __('front_cart_empty');?></div><!-- /.text-center -->
		</div>
		<?php
	} 
	?>
</div><!-- /.container-fluid pjMbContainer pjMbContent -->