'field' => 'attendee_max',
'type' => 'integer',
'required' => false,
+ 'default' => 0,
'use' => 'a'
),
$firstTime = false;
$lastTime = false;
- // Check for reg_time data (are we still using this?)
+ // Check for reg_time data
if (is_array($this->regEventData['reg_time']) && count($this->regEventData['reg_time']) > 0) {
foreach ($this->regEventData['reg_time'] as $time) {
// If the time is not for non-time-specific inventory
if (!$time['non_time_specific']['value']) {
-
if (!$firstTime || $time['start_datetime']['timestamp'] < $firstTime) {
$firstTime = $time['start_datetime']['timestamp'];
}
if (!$lastTime || $time['start_datetime']['timestamp'] > $lastTime) {
$lastTime = $time['start_datetime']['timestamp'];
}
-
}
-
}
}
// Generate date as used in results
- $firstDateTime = date('Y-m-d H:i:s', $firstTime);
- $lastDateTime = date('Y-m-d H:i:s', $lastTime);
+ $firstDateTime = array('datetime' => date('m/d/Y h:i A', $firstTime), 'timestamp' => $firstTime, 'mysql_datetime' => date('Y-m-d H:i:s', $firstTime));
+ $lastDateTime = array('datetime' => date('m/d/Y h:i A', $lastTime), 'timestamp' => $lastTime, 'mysql_datetime' => date('Y-m-d H:i:s', $lastTime));
// Check if we need to update first and/or last event times in database - if so, do that
if ($this->regEventData['first_datetime']['timestamp'] != $firstTime ||
) {
// Update the regEventData first and last times
- $this->regEventData['first_dateTime'] = array('datetime' => $firstDateTime, 'timestamp' => $firstTime);
- $this->regEventData['last_dateTime'] = array('datetime' => $lastDateTime, 'timestamp' => $lastTime);
+ $this->regEventData['first_datetime'] = $firstDateTime;
+ $this->regEventData['last_datetime'] = $lastDateTime;
// Update the database
$this->wpdb->update(
GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_event',
array(
- 'first_datetime' => date('Y-m-d H:i:s', $firstTime),
- 'last_datetime' => date('Y-m-d H:i:s', $lastTime),
+ 'first_datetime' => $firstDateTime['mysql_datetime'],
+ 'last_datetime' => $lastDateTime['mysql_datetime'],
),
array( 'id' => $this->regEventData['id'] ),
array(
) {
// Update this reg_time entry - NOTE: for non-time-specific entries the end_datetime is the start of the last occurance of the event
- $this->regEventData['reg_time'][$regTimeKey]['start_datetime'] = array('datetime' => $firstDateTime, 'timestamp' => $firstTime);
- $this->regEventData['reg_time'][$regTimeKey]['end_datetime'] = array('datetime' => $lastDateTime, 'timestamp' => $lastTime);
+ $this->regEventData['reg_time'][$regTimeKey]['start_datetime'] = $firstDateTime;
+ $this->regEventData['reg_time'][$regTimeKey]['end_datetime'] = $lastDateTime;
// Update the database
$this->wpdb->update(
);
} // If times changed
-
} // is non_time_specific
-
} // each reg_time
-
} // non_time_specific
-
// Add Recurrence summary to event data
// $this->regEventData['recurrenceSummary'] = $recurrenceSummary;
*
* @param integer $regEventId Optional ID of a reg event record. If provided, load all registration data using getEventConfig() above
* This is not required if the event data has already been loaded using getEVentConfig() by the calling code
- * @param boolean $deleteRemovedTimes Optional flag to ask that times removed from the event are removed from registration
- * @param boolean $nonDateSpecificOnly Optional flag to check only for the default non-date-specific time entry.
*
* @return array updated reg_times data or false if not regEventData has been provided or no recurrence data
*/
- public function checkEventTimes($regEventId = false, $deleteTimes = false, $nonDateSpecificOnly = false)
+ public function checkEventTimes($regEventId = false )
{
+echo "<p>checkEventTimes()</p>";
+
$needTimesReloaded = false;
$message = '';
// If we've been passed a reg event id, get the configuration (with recurrence data)
if ($regEventId && $regEventId > 0) {
- $this->getEventConfig($regEventId, false, false, true);
+ $this->getEventConfig($regEventId, true, false, true, false, true);
}
// If we don't have event data
return false;
}
- // Only do this if we haven't requested only non-date-specific time entry check
- if (!$nonDateSpecificOnly) {
-
- // If we don't have recurrences for the event
- if (!is_array($this->regEventData['recurrences']) || count($this->regEventData['recurrences']) == 0) {
- return false;
- }
-
- // For each recurrence
- foreach ($this->regEventData['recurrences'] as $recurKey=>$recurVal) {
-
- // If we have times for this recurrence
- if ($recurVal['times'] && count($recurVal['times']) > 0) {
-
- // If this is a time specific event
- if ($this->regEventData['time_specific']['value']) {
-
- // Check all event times for matching reg event times
- foreach ($recurVal['times'] as $eventTimeKey=>$eventTimeVal) {
-
- $id = false;
-
- // If we have any times entries in this event
- if (is_array($this->regEventData['reg_time']) && count($this->regEventData['reg_time']) > 0) {
+ /*
+ * For each time entry from the event, check to see if it needs to be added to registrations
+ */
- // Check if this time from the event already exists in reg_times array
- reset($this->regEventData['reg_time']);
- foreach($this->regEventData['reg_time'] as $regTimeKey=>$regTimeVal) {
- if ($regTimeVal['event_time'] == $eventTimeKey) {
+ foreach ($this->regEventData['times'] as $eventTimeKey=>$eventTimeVal) {
- // Set ID to say we found this one.
- $id = $regTimeKey;
+ $id = false;
- // Also add OK to the reg_time to say that it matches a recur time - see below
- $this->regEventData['reg_time'][$regTimeKey]['OK'] = true;
- }
- }
+ // If we have any times entries in this event
+ if (is_array($this->regEventData['reg_time']) && count($this->regEventData['reg_time']) > 0) {
- }
- // If it wasn't found, then add it
- if (!$id) {
-
- $needTimesReloaded = true;
- $message .= "<br> New dates and/or times have been added";
-
- $sTime = date('Y-m-d H:i:s',strtotime($eventTimeVal['start_time']['datetime']));
- $eTime = date('Y-m-d H:i:s',strtotime($eventTimeVal['end_time']['datetime']));
-
- // Add reg event time
- $this->wpdb->insert(
- GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time",
- array(
- 'reg_event' => $this->regEventData['id'],
- 'active' => false,
- 'event_time' => $eventTimeKey,
- 'start_datetime' => $sTime,
- 'end_datetime' => $eTime,
- 'all_day' => $eventTimeVal['all_day']['value'],
- 'non_time_specific' => false,
- 'attendees' => $this->regEventData['attendees']['value'],
- 'attendee_max' => $this->regEventData['attendee_max'],
- 'attendee_count' => 0,
- 'attendees_pending' => 0,
- 'attendees_available' => $this->regEventData['attendee_max'],
- 'total_base_charge' => 0,
-
- 'total_per_attendee' => 0,
- 'total_other' => 0,
- 'total_taxes' => 0,
- 'total_charges' => 0,
- 'total_discounts' => 0,
- 'total_payments' => 0
- ),
- array(
- '%d', // reg_event
- '%d', // event_time record ID
- '%s', // start_datetime
- '%s', // end_datetime
- '%d', // all_day flag
- '%d', // attendees flag
- '%d', // attendee_max
- '%d', // attendee_count
- '%d', // attendees_pending
- '%d', // attendees_available
- '%f', // total_base__charge
- '%f', // total_per_attendee
- '%f', // total_other
- '%f', // total_taxes
- '%f', // total_charges
- '%f', // total_discounts
- '%f' // total_payments
- )
- );
-
- } // If time isn't in reg_times
- } // each recurrence times
- } // time specific
- } // have times for recurrence
-
- } // each recurrence
-
- // If this is a time specific event
- $deleteList = '';
- $deleteSep = '';
- if ($this->regEventData['time_specific']['value']) {
-
- // Check all reg_times we had from before to make sure they were matched with a recur time
+ // Check if this time from the event already exists in reg_times array
+ reset($this->regEventData['reg_time']);
foreach($this->regEventData['reg_time'] as $regTimeKey=>$regTimeVal) {
- if (!isset($regTimeVal['OK'])) {
+ if ($regTimeVal['start_datetime']['timestamp'] == $eventTimeVal['start_time']['timestamp']) {
- // If this time didn't match a recur time, then it must have been removed in the event so add to list
- $deleteList .= $deleteSep.$regTimeKey;
- $deleteSep = ',';
+ // Set ID to say we found this one.
+ $id = $regTimeKey;
+ // Also add OK to the reg_time to say that it matches a recur time - see below
+ $this->regEventData['reg_time'][$regTimeKey]['OK'] = true;
}
}
-
}
- // If requested and there's anything in the delete list, purge them now and say we need a reload
- if ($deleteTimes && $deleteList != '') {
- $this->wpdb->query("
- DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time
- WHERE id IN ($deleteList)
- ");
- $needTimesReloaded = true;
- $message .= '<br> Old dates and/or times have been removed';
- }
-
- // Get rid of all of the recurrence data - No longer needed
- unset($this->regEventData['recurrences']);
+ // If it wasn't found, then add it
+ if (!$id) {
+ $needTimesReloaded = true;
+echo "<P>**** TIME ADDED ****</p>";
+ // Add reg event time
+ $this->wpdb->insert(
+ GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time",
+ array(
+ 'reg_event' => $this->regEventData['id'],
+ 'active' => false,
+ 'event_time' => $eventTimeKey,
+ 'start_datetime' => $eventTimeVal['start_time']['mysql_datetime'],
+ 'end_datetime' => $eventTimeVal['end_time']['mysql_datetime'],
+ 'all_day' => $eventTimeVal['all_day']['value'],
+ 'non_time_specific' => false,
+ 'attendees' => $this->regEventData['attendees']['value'],
+ 'attendee_max' => $this->regEventData['attendee_max'],
+ 'attendee_count' => 0,
+ 'attendees_pending' => 0,
+ 'attendees_available' => $this->regEventData['attendee_max'],
+ 'total_base_charge' => 0,
- } // if time specific check
+ 'total_per_attendee' => 0,
+ 'total_other' => 0,
+ 'total_taxes' => 0,
+ 'total_charges' => 0,
+ 'total_discounts' => 0,
+ 'total_payments' => 0
+ ),
+ array(
+ '%d', // reg_event
+ '%d', // event_time record ID
+ '%s', // start_datetime
+ '%s', // end_datetime
+ '%d', // all_day flag
+ '%d', // attendees flag
+ '%d', // attendee_max
+ '%d', // attendee_count
+ '%d', // attendees_pending
+ '%d', // attendees_available
+ '%f', // total_base__charge
+ '%f', // total_per_attendee
+ '%f', // total_other
+ '%f', // total_taxes
+ '%f', // total_charges
+ '%f', // total_discounts
+ '%f' // total_payments
+ )
+ );
+ } // If time isn't in reg_times
+ } // each recurrence times
// If this event is not time specific
if (!$this->regEventData['time_specific']['value']) {
break;
}
}
-
-
}
// If no default time, create one now.
'%f', // total_discounts
'%f' // total_payments
)
- );
-
+ );
} // no default time
-
} // not times specific
// Check if we need the times entries reloaded
$RegTime = new GlmDataRegistrationsRegTime($this->wpdb, $this->config);
$this->regEventData['reg_time'] = $RegTime->getList('T.reg_event = '.$this->regEventData['id'], 'start_datetime', true);
- $this->regEventData['message'] = 'Dates and Times have been updated due to changes in the "Dates Schedules" for this event.'.$message;
-
-
}
// echo "<pre>".print_r($this->regEventData,1)."</pre>";