--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * Update availability in reg_time records
+ * Called from admin time update dialog box
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release summary.php,v 1.0 2017/11/10 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+ require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegTime.php';
+
+ class GlmMembersAdmin_ajax_updateAvailability extends GlmDataRegistrationsRegTime {
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+ /**
+ * Constructor
+ *
+ * This contructor performs the work for this model. This model returns
+ * an array containing the following.
+ *
+ * 'status'
+ *
+ * True if successfull and false if there was a fatal failure.
+ *
+ * 'view'
+ *
+ * A suggested view name that the contoller should use instead of the
+ * default view for this model or false to indicate that the default view
+ * should be used.
+ *
+ * 'data'
+ *
+ * Data that the model is returning for use in merging with the view to
+ * produce output.
+ *
+ * @wpdb object WordPress database object
+ *
+ * @return array Array containing status, suggested view, and any data
+ */
+
+ public function modelAction($actionData = false)
+ {
+
+ $haveRequest = false;
+
+ // Get the max attendees value
+ if (!isset($_REQUEST['max'])) {
+ wp_die();
+ }
+ $max = ($_REQUEST['max'] - 0);
+ if ($max <= 0) {
+ wp_die();
+ }
+
+trigger_error("1111",E_USER_NOTICE);
+ // Get the reg_time entry id
+ if (!isset($_REQUEST['reg_time'])) {
+ wp_die();
+ }
+ $regTimeId = ($_REQUEST['reg_time'] - 0);
+ if ($regTimeId <= 0) {
+ wp_die();
+ }
+
+trigger_error("regTimeId = $regTimeId",E_USER_NOTICE);
+ // Try to get the reg_time entry
+ $regTime = $this->getEntry($regTimeId);
+ if (!$regTime) {
+ wp_die();
+ }
+
+trigger_error("3333",E_USER_NOTICE);
+ // re-calculate the total
+ $avail = $max - $regTime['attendee_count'] - $regTime['attendees_pending'];
+trigger_error("max = $max, avail = $avail", E_USER_NOTICE);
+ // Try to update the reg_time entry
+ $this->wpdb->update(
+ $this->table,
+ array(
+ 'attendee_max' => $max,
+ 'attendees_available' => $avail
+ ),
+ array('id' => $regTimeId),
+ array(
+ '%d',
+ '%d'
+ ),
+ array( '%d' )
+ );
+
+
+ }
+ }
<h3>Did not find selected event.</h3>
{/if}
</div>
+<div id="availabilityEditDialog" class="glm-dialog-box" title="Availability Edit">
+ <table>
+ <tr><th id="availabilityTitle" colspan="2"></th></tr>
+ <tr><th style="text-align: left">Maximum Attendees:</th><td><input class="glm-form-text-input-veryshort availabilityInput" type="text" id="dialogMaxAtt" value=""></td></tr>
+ <tr><th style="text-align: left">Registered Attendees:</th><td id="dialogRegAtt"></td></tr>
+ <tr><th style="text-align: left">Pending in Carts:</th><td id="dialogPendAtt"></td></tr>
+ <tr><th style="text-align: left">Available for Registration:</th><td id="dialogAvailAtt"></td></tr>
+ <tr><td style="text-align: right">
+ <div id="availabilitySubmit" class="button-primary" data-timeid="">Upate</div>
+ </td></tr>
+ </table>
+</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
+ // Summary Dialog Box
+ $("#availabilityEditDialog").dialog({
+ autoOpen: false,
+ width: 'auto',
+ resizable: true
+ });
+
var fullCalendarLoaded = false;
// If this is a time specific event, then display the calendar
/*
* Initialize the Full Calendar
*/
+
function initFullCalendar(){
$('#eventCalendar').fullCalendar({
- {if $regEvent}
- events: [
- {$sep = ''}
- {foreach $regEvent.reg_time as $t}
- {$sep}{
- {if $t.attendee_max == 0}
- title : 'unlimited',
- {else}
- title : '{$t.attendee_max}-{$t.attendee_count}-{$t.attendees_pending}-{$t.attendees_available}',
- {/if}
- start : '{$t.start_datetime.datetime}',
- end : '{$t.end_datetime.datetime}',
- allday : {$t.all_day.value}
- }
- {$sep = ','}
- {/foreach}
- ],
- defaultDate : '{$regEventFirstTime.start_time.datetime}',
- timeFormat : 'h:mma',
- fixedWeekCount : false,
- eventClick: function(calEvent, jsEvent, view) {
- $("#occurrences").dialog();
- $(this).css('border-color', 'red');
+ {if $regEvent}
+ events: [
+ {$sep = ''}
+ {foreach $regEvent.reg_time as $t}
+ {$sep}{
+ {if $t.attendee_max == 0}
+ title : 'unlimited',
+ {else}
+ title : '{$t.attendee_max}-{$t.attendee_count}-{$t.attendees_pending}-{$t.attendees_available}',
+ {/if}
+ start : '{$t.start_datetime.datetime}',
+ end : '{$t.end_datetime.datetime}',
+ allday : {$t.all_day.value},
+ max: {$t.attendee_max},
+ count: {$t.attendee_count},
+ pending: {$t.attendees_pending},
+ available: {$t.attendees_available},
+ datetime: '{$t.start_datetime.datetime}',
+ timeid: {$t.id}
+
}
- {/if}
+ {$sep = ','}
+ {/foreach}
+ ],
+ eventMouseover : function(event, jsEvent, view) {
+ $('.fc-event').css( 'cursor', 'pointer' );
+ },
+ defaultDate : '{$regEventFirstTime.start_time.datetime}',
+ timeFormat : 'h:mma',
+ fixedWeekCount : false,
+ eventClick: function(calEvent, jsEvent, view) {
+ $("#occurrences").dialog();
+ $(this).css('border-color', 'red');
+
+ $('#availabilityEditDialog').dialog('open');
+
+ $('#availabilityTitle').html(calEvent.datetime);
+ $('#dialogMaxAtt').val(calEvent.max);
+ $('#dialogRegAtt').html(calEvent.count);
+ $('#dialogPendAtt').html(calEvent.pending);
+ $('#dialogAvailAtt').html(calEvent.available);
+ $('#availabilitySubmit').attr('data-timeid', calEvent.timeid);
+ // Re-calculate total available when entering
+
+ $('#dialogMaxAtt').on('change', function() {
+ var max = $('#dialogMaxAtt').val();
+ max = max -0;
+ var available = max - calEvent.count - calEvent.pending;
+ if (available < 0) {
+ max = max - available;
+ $('#dialogMaxAtt').val(max);
+ available = 0;
+ }
+ calEvent.available = available;
+ $('#dialogAvailAtt').html(available);
+ $('#dialogMaxAtt').off('change');
+ });
+
+ $('#availabilitySubmit').on('click', function() {
+ var max = $('#dialogMaxAtt').val();
+ var timeid = $('#availabilitySubmit').attr('data-timeid');
+ $.ajax({
+ url: "{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=updateAvailability&max=" + max + "®_time=" + timeid
+ });
+ $('#availabilityEditDialog').dialog('close');
+ $('#availabilitySubmit').off('click');
+
+ calEvent.title = max + '-' + calEvent.count + '-' + calEvent.pending + '-' + calEvent.available;
+ $('#eventCalendar').fullCalendar('updateEvent', calEvent);
+ });
+
+
+ }
+ {/if}
});
}
initFullCalendar();
}
-
+
// Flash certain elements for a short time after display
$(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);