'use' => 'a'
),
- // Any MagicForm data associated with registrant
- 'mf_data' => array (
- 'field' => 'mf_data',
- 'type' => 'text',
- 'use' => 'a'
- ),
-
// System operator's notes for this registration request
'notes' => array (
'field' => 'notes',
}
+ /**
+ * Get registration request list simplified
+ *
+ * @param string $where Where clause to filter list
+ * @param boolean $getStats Flag to get additional stats for cart
+ *
+ * @return object Class object
+ */
+ public function getRegRequestListSimplified($where = false, $getStats = false)
+ {
+
+ $savedFields = $this->fields;
+ $savedPostProcess = $this->postProcRegRequest;
+
+ if ($getStats) {
+ $this->postProcRegRequest = true;
+ }
+
+ $this->fields = array(
+ 'id' => $savedFields['id'],
+ 'account_fname' => $savedFields['account_fname'],
+ 'account_lname' => $savedFields['account_lname'],
+ 'status' => $savedFields['status'],
+ 'last_update' => $savedFields['last_update']
+ );
+
+ $requestsSimplified = $this->getList($where);
+ $this->fields = $savedFields;
+ $this->postProcRegRequest = $savedPostProcess;
+
+ return $requestsSimplified;
+
+ }
+
}
$res = $this->wpdb->insert(
GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_request',
array(
- 'account' => $account,
- 'validated' => false,
- 'user_trace_info' => $_SERVER["REMOTE_ADDR"]." - ".date("m/d/Y H:i:s")
+ 'account' => $account,
+ 'validated' => false,
+ 'status' => $this->config['submission_status_numb']['CART'],
+ 'user_trace_info' => $_SERVER["REMOTE_ADDR"]." - ".date("m/d/Y H:i:s")
),
array(
+ '%d',
'%d',
'%d',
'%s'
return $this->cart;
}
- // Check if the person looking at this cart is permitted to do so
+ // Check if the person looking at this cart is not permitted to do so
if (!$this->checkRequestingAccount($requestId)) {
return $this->cart;
}
$eventCharges = 0;
$eventDiscounts = 0;
$removeEvent = false;
+ $deleteEventNow = false;
$haveClasses = false;
$this->cart['events'][$eventKey]['removed'] = false;
$classCharges = 0;
$classDiscounts = 0;
$removeClass = false;
+ $deleteClassNow = false;
$haveRates = false;
$this->cart['events'][$eventKey]['classes'][$classKey]['removed'] = false;
$rateRegistrantCharges = 0;
$rateDiscounts = 0;
$removeRate = false;
+ $deleteRateNow = false;
$haveRegistrants = false;
$this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['removed'] = false;
if (!$haveRegistrants) {
$this->cart['messages'][] = 'Rate '.$rate['rate_name'].' has no registrants.';
$removeRate = true;
+ $deleteRateNow = true;
}
}
+ if ($deleteRateNow) {
+ unset($this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]);
+ }
+
} // Each Rate
} // Have rates
if (!$haveRates) {
$this->cart['messages'][] = 'Class '.$class['class_name'].' has no rates.';
$removeClass = true;
+ $deleteClassNow = true;
}
// If class has been flagged for removal from cart, delete it from cart in database
}
+ if ($deleteClassNow) {
+ unset($this->cart['events'][$eventKey]['classes'][$classKey]);
+ }
+
} // Each class
} // Have Classes
if (!$haveClasses) {
$this->cart['messages'][] = 'Event '.$event['event_name'].' has no classes.';
$removeEvent = true;
+ $deleteEventNow = true;
}
// If has been flagged for removal from cart, delete it from cart in database
}
+ if ($deleteEventNow) {
+ unset($this->cart['events'][$eventKey]);
+ }
+
} // Each event
} // Have events
// Check if Event Time exists in Events add-on
-// echo "<pre>".print_r($this->cart,1)."</pre>";
+ // echo "<pre>".print_r($this->cart,1)."</pre>";
// Check if no messages then cart validated
if (count($this->cart['messages']) == 0) {
return false;
}
- // If the user is an WordPress administrator or we have contacts add-on and WordPress user with adequate permissions
- if (current_user_can('administrator') && apply_filters('glm_members_menu_members', true)) {
- return true;
- }
-
// If there's no logged in registrations user
if (!isset($_SESSION) || !isset($_SESSION['LoginAccount']) || !is_array($_SESSION['LoginAccount'])) {
- // If it's a guest account and the request ID is in the current session - allow cart
- if ($_SESSION['LoginAccount']['id'] == 0 && $_SESSION['glm_reg_cart_id'] == $requestId) {
- return true;
- }
-
}
- echo "<pre>".print_r($_SESSION,1).print_r($regRequest,1)."</pre>";
- // If there's a logged in registrations user
+
+ // echo "<pre>".print_r($_SESSION,1).print_r($regRequest,1)."</pre>";
+
+ // If there's a logged in registrations user (overrides any WordPress adminstrator or contact logins
if (isset($_SESSION) && isset($_SESSION['LoginAccount']) && is_array($_SESSION['LoginAccount'])) {
// If the registrations user owns the cart
$updated = $this->wpdb->update(
GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_request',
array(
- 'account' => $_SESSION['LogInAccount']['id']
+ 'account' => $_SESSION['LoginAccount']['id']
),
array( 'id' => $requestId ),
array(
}
}
+
+ // Otherwise no logged in registrations user
+ } else {
+
+ // If the user is an WordPress administrator or we have contacts add-on and WordPress user with adequate permissions
+ if (!current_user_can('administrator') && apply_filters('glm_members_menu_members', true)) {
+ return true;
+ }
+
+ // If it's a guest account and the request ID is in the current session - allow cart
+ if ($_SESSION['LoginAccount']['id'] == 0 && $_SESSION['glm_reg_cart_id'] == $requestId) {
+ return true;
+ }
+
}
return false;
$RegRequest = new GlmDataRegistrationsRegRequest($this->wpdb, $this->config);
$cartSummary = $RegRequest->getRegRequestSimplified($requestId, true);
+ $cartSummary['regRequests'] = false;
+ $cartSummary['haveOtherRequests'] = false;
+
+ // If there's a logged in registrations user
+ if (isset($_SESSION) && isset($_SESSION['LoginAccount']) && isset($_SESSION['LoginAccount']['id'])) {
+
+ $accountId = ($_SESSION['LoginAccount']['id'] - 0);
+
+ // If it's a possibly valid account ID
+ if ($accountId > 0) {
+
+ // Build where clause to get any other pending carts for this logged in registrations user
+ $where = "
+ T.account = $accountId
+ AND T.id != $requestId
+ AND T.status = ".$this->config['submission_status_numb']['CART']."
+ ";
+
+ // Try to get the full list of pending carts for this user
+ $RegRequest = new GlmDataRegistrationsRegRequest($this->wpdb, $this->config);
+ $cartSummary['regRequests'] = $RegRequest->getRegRequestListSimplified($where);
+
+ if ($cartSummary['regRequests'] && count($cartSummary['regRequests'])) {
+ $cartSummary['haveOtherRequests'] = true;
+ }
+ }
+
+ }
+
return $cartSummary;
}
<a href="{$cartUrl}">
<div id="registrations-cart-link-widget" style="width: 80px; height: 75px; padding: 5px; background-color: #ffffff; border: 1px black solid; position: relative">
<img src="{$assetUrl}/registrationBlue.svg" width="50" style="position: absolute; z-index: 1;">
- <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 14px; top: 65px; z-index: 2; font-style: italic;">REGISTRATION</div>
+ <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 14px; top: 63px; z-index: 2; font-style: italic;">REGISTRATION</div>
<div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 22px; top: 44px; z-index: 2;">
{$numb_events} Event{if $numb_events == 0 || $numb_events > 1}s{/if}<br>
{$numb_registrants} Registrant{if $numb_registrants == 0 || $numb_registrants > 1}s{/if}
</div>
{/if}
+{if $haveOtherRequests}
+<a id='glm-cart-select-action' href="" onClick="return false;">
+ <div id="registrations-cart-link-widget-requests" style="width: 80px; height: 1em; padding: 1px; background-color: #ffffff; border: 1px black solid; position: relative">
+ <div style="font-size: .55em; line-height: 1.1em; position: absolute; left:3px; top: 3px; z-index: 2;">
+ Select other Carts
+ </div>
+ </div>
+</a>
+<div id="glm-cart-select-dialog" title="" class="glm-hidden">
+ <center>
+ <h4>Your other pending registration requests</h4>
+ <table>
+ <thead>
+ <tr><th>ID</th><th>Date request was created</th></tr>
+ </thead>
+ <tbody>
+ {foreach $regRequests as $rr}
+ <tr>
+ <td><a href="{$cartUrl}&cartId={$rr.id}">{$rr.id}</a></td>
+ <td>{$rr.last_update.datetime}</td>
+ </tr>
+ {/foreach}
+ </tbody>
+ </table>
+ </center>
+</div>
+<script type="text/javascript">
+ jQuery(document).ready(function($) {
+
+ $("#glm-cart-select-action").click(function () {
+ $("#glm-cart-select-dialog").dialog({
+ autoOpen: true,
+ resizable: false,
+ modal: true
+ });
+ });
+
+ });
+</script>
+{/if}
+