Merged pull request #60 which fixes issue #56

This commit is contained in:
Alex Tselegidis 2015-10-07 22:51:12 +02:00
parent 6eb710801b
commit daa4d28a6e
2 changed files with 128 additions and 118 deletions

View File

@ -114,6 +114,7 @@ class Appointments extends CI_Controller {
// sync is enabled then add the appointment to the provider's account. // sync is enabled then add the appointment to the provider's account.
try { try {
$view = array();
$post_data = json_decode($_POST['post_data'], true); $post_data = json_decode($_POST['post_data'], true);
$appointment = $post_data['appointment']; $appointment = $post_data['appointment'];
$customer = $post_data['customer']; $customer = $post_data['customer'];
@ -213,6 +214,11 @@ class Appointments extends CI_Controller {
} catch(Exception $exc) { } catch(Exception $exc) {
$view['exceptions'][] = $exc; $view['exceptions'][] = $exc;
} }
// Save any exceptions to the session and redirect to another page so that the user
// will not add a new appointment on page reload.
$this->load->helper('url');
$view['exceptions'] = (!empty($view['exceptions'])) ? $view['exceptions'] : array();
$this->session->set_flashdata('book_exceptions', $view['exceptions']); $this->session->set_flashdata('book_exceptions', $view['exceptions']);
redirect('appointments/book_success/'.$appointment['id']); redirect('appointments/book_success/'.$appointment['id']);
} }

View File

@ -1,118 +1,122 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#35A768"> <meta name="theme-color" content="#35A768">
<title><?php echo $this->lang->line('appointment_registered') . ' - ' . $company_name; ?></title> <title><?php echo $this->lang->line('appointment_registered') . ' - ' . $company_name; ?></title>
<?php <?php
// ------------------------------------------------------------ // ------------------------------------------------------------
// INCLUDE CSS FILES // INCLUDE CSS FILES
// ------------------------------------------------------------ ?> // ------------------------------------------------------------ ?>
<link rel="stylesheet" type="text/css" <link rel="stylesheet" type="text/css"
href="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/css/bootstrap.min.css"> href="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" <link rel="stylesheet" type="text/css"
href="<?php echo $this->config->item('base_url'); ?>/assets/css/frontend.css"> href="<?php echo $this->config->item('base_url'); ?>/assets/css/frontend.css">
<?php <?php
// ------------------------------------------------------------ // ------------------------------------------------------------
// SET PAGE FAVICON // SET PAGE FAVICON
// ------------------------------------------------------------ ?> // ------------------------------------------------------------ ?>
<link rel="icon" type="image/x-icon" <link rel="icon" type="image/x-icon"
href="<?php echo $this->config->item('base_url'); ?>/assets/img/favicon.ico"> href="<?php echo $this->config->item('base_url'); ?>/assets/img/favicon.ico">
<link rel="icon" sizes="192x192" <link rel="icon" sizes="192x192"
href="<?php echo $this->config->item('base_url'); ?>/assets/img/logo.png"> href="<?php echo $this->config->item('base_url'); ?>/assets/img/logo.png">
</head> </head>
<body> <body>
<div id="main" class="container"> <div id="main" class="container">
<div class="wrapper row"> <div class="wrapper row">
<div id="success-frame" class="frame-container <div id="success-frame" class="frame-container
col-xs-12 col-xs-12
col-sm-offset-1 col-sm-10 col-sm-offset-1 col-sm-10
col-md-offset-2 col-md-8 col-md-offset-2 col-md-8
col-lg-offset-2 col-lg-8"> col-lg-offset-2 col-lg-8">
<div class="col-xs-12 col-sm-2"> <div class="col-xs-12 col-sm-2">
<img id="success-icon" class="pull-right" src="<?php echo $this->config->item('base_url'); ?>/assets/img/success.png" /> <img id="success-icon" class="pull-right" src="<?php echo $this->config->item('base_url'); ?>/assets/img/success.png" />
</div> </div>
<div class="col-xs-12 col-sm-10"> <div class="col-xs-12 col-sm-10">
<?php <?php
echo '<h3>' . $this->lang->line('appointment_registered') . '</h3>'; echo '
echo '<p>' . $this->lang->line('appointment_details_was_sent_to_you') . '</p>'; <h3>' . $this->lang->line('appointment_registered') . '</h3>
echo '<a href="'.$this->config->item('base_url').'" class="btn btn-primary btn-large"> <p>' . $this->lang->line('appointment_details_was_sent_to_you') . '</p>
<span class="glyphicon glyphicon-calendar"></span>'.$this->lang->line('go_to_booking_page').'</a>'; <a href="'.$this->config->item('base_url').'" class="btn btn-success btn-large">
<span class="glyphicon glyphicon-calendar"></span>' .
if ($this->config->item('ea_google_sync_feature')) { $this->lang->line('go_to_booking_page') . '
echo ' </a>
<button id="add-to-google-calendar" class="btn btn-primary"> ';
<span class="glyphicon glyphicon-plus"></span>
' . $this->lang->line('add_to_google_calendar') . ' if ($this->config->item('ea_google_sync_feature')) {
</button>'; echo '
} <button id="add-to-google-calendar" class="btn btn-primary">
<span class="glyphicon glyphicon-plus"></span>
// Display exceptions (if any). ' . $this->lang->line('add_to_google_calendar') . '
if (isset($exceptions)) { </button>';
echo '<div class="col-xs-12" style="margin:10px">'; }
echo '<h4>Unexpected Errors</h4>';
foreach($exceptions as $exc) { // Display exceptions (if any).
echo exceptionToHtml($exc); if (isset($exceptions)) {
} echo '<div class="col-xs-12" style="margin:10px">';
echo '</div>'; echo '<h4>Unexpected Errors</h4>';
} foreach($exceptions as $exc) {
?> echo exceptionToHtml($exc);
</div> }
</div> echo '</div>';
</div> }
</div> ?>
</div>
</div>
<?php </div>
// ------------------------------------------------------------ </div>
// INCLUDE JS FILES
// ------------------------------------------------------------ ?>
<script <?php
type="text/javascript" // ------------------------------------------------------------
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/jquery/jquery.min.js"></script> // INCLUDE JS FILES
<script // ------------------------------------------------------------ ?>
type="text/javascript" <script
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/js/bootstrap.min.js"></script> type="text/javascript"
<script src="<?php echo $this->config->item('base_url'); ?>/assets/ext/jquery/jquery.min.js"></script>
type="text/javascript" <script
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/datejs/date.js"></script> type="text/javascript"
<script src="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/js/bootstrap.min.js"></script>
type="text/javascript" <script
src="https://apis.google.com/js/client.js"></script> type="text/javascript"
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/datejs/date.js"></script>
<?php <script
// ------------------------------------------------------------ type="text/javascript"
// CUSTOM PAGE JS src="https://apis.google.com/js/client.js"></script>
// ------------------------------------------------------------ ?>
<script type="text/javascript"> <?php
var GlobalVariables = { // ------------------------------------------------------------
'csrfToken' : <?php echo json_encode($this->security->get_csrf_hash()); ?>, // CUSTOM PAGE JS
'appointmentData' : <?php echo json_encode($appointment_data); ?>, // ------------------------------------------------------------ ?>
'providerData' : <?php echo json_encode($provider_data); ?>, <script type="text/javascript">
'serviceData' : <?php echo json_encode($service_data); ?>, var GlobalVariables = {
'companyName' : <?php echo '"' . $company_name . '"'; ?>, 'csrfToken' : <?php echo json_encode($this->security->get_csrf_hash()); ?>,
'googleApiKey' : <?php echo '"' . Config::GOOGLE_API_KEY . '"'; ?>, 'appointmentData' : <?php echo json_encode($appointment_data); ?>,
'googleClientId' : <?php echo '"' . Config::GOOGLE_CLIENT_ID . '"'; ?>, 'providerData' : <?php echo json_encode($provider_data); ?>,
'googleApiScope' : 'https://www.googleapis.com/auth/calendar' 'serviceData' : <?php echo json_encode($service_data); ?>,
}; 'companyName' : <?php echo '"' . $company_name . '"'; ?>,
'googleApiKey' : <?php echo '"' . Config::GOOGLE_API_KEY . '"'; ?>,
var EALang = <?php echo json_encode($this->lang->language); ?>; 'googleClientId' : <?php echo '"' . Config::GOOGLE_CLIENT_ID . '"'; ?>,
</script> 'googleApiScope' : 'https://www.googleapis.com/auth/calendar'
};
<script
type="text/javascript" var EALang = <?php echo json_encode($this->lang->language); ?>;
src="<?php echo $this->config->item('base_url'); ?>/assets/js/frontend_book_success.js"></script> </script>
<script <script
type="text/javascript" type="text/javascript"
src="<?php echo $this->config->item('base_url'); ?>/assets/js/general_functions.js"></script> src="<?php echo $this->config->item('base_url'); ?>/assets/js/frontend_book_success.js"></script>
</body>
</html> <script
type="text/javascript"
src="<?php echo $this->config->item('base_url'); ?>/assets/js/general_functions.js"></script>
</body>
</html>