From: Chuck Scott Date: Tue, 14 Nov 2017 22:02:34 +0000 (-0500) Subject: Added ajax edit/update feature to calendar cells in registration event dashboard. X-Git-Tag: v1.0.0^2~270 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=b9813ddeb6a9c74fad7935db10a1196d8fb0a7fd;p=WP-Plugins%2Fglm-member-db-registrations.git Added ajax edit/update feature to calendar cells in registration event dashboard. --- diff --git a/models/admin/ajax/updateAvailability.php b/models/admin/ajax/updateAvailability.php new file mode 100644 index 0000000..e37d121 --- /dev/null +++ b/models/admin/ajax/updateAvailability.php @@ -0,0 +1,112 @@ + + * @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' ) + ); + + + } + } diff --git a/models/admin/registrations/events.php b/models/admin/registrations/events.php index ce7fd73..43cf857 100644 --- a/models/admin/registrations/events.php +++ b/models/admin/registrations/events.php @@ -400,7 +400,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent update_option('glmMembersDatabaseRegistrationsRegEventID', $regEventID); } - //echo "
".print_r($regEvent,1)."
"; + // echo "
".print_r($regEvent,1)."
"; // Compile template data $templateData = array( diff --git a/setup/validActions.php b/setup/validActions.php index 8cb4ce9..d835104 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -64,7 +64,8 @@ $glmMembersRegistrationsAddOnValidActions = array( 'regAdmin' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'regFront' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'cartLinkWidget' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, - 'summaryContent' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG + 'summaryContent' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'updateAvailability' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG ), 'registrations' => array( 'index' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, diff --git a/views/admin/registrations/eventDashboard.html b/views/admin/registrations/eventDashboard.html index 0da391c..0818070 100644 --- a/views/admin/registrations/eventDashboard.html +++ b/views/admin/registrations/eventDashboard.html @@ -108,11 +108,30 @@

Did not find selected event.

{/if} +
+ + + + + + + +
Maximum Attendees:
Registered Attendees:
Pending in Carts:
Available for Registration:
+
Upate
+
+