Testing registration link addition to event list
authorLaury GvR <laury@gaslightmedia.com>
Fri, 19 May 2017 19:21:58 +0000 (15:21 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Fri, 19 May 2017 19:21:58 +0000 (15:21 -0400)
models/admin/registrations/events.php
setup/adminHooks.php
views/admin/registrations/editEvent.html [new file with mode: 0644]
views/admin/registrations/events.html

index 97f0e3e..eaeb69f 100644 (file)
@@ -109,6 +109,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
         $registrationCart    = false;
         $option         = 'list';
         $errorMsg       = false;
+        $view               = "events";
 
         // Load registrations support class
         require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/registrationsSupport.php';
@@ -135,14 +136,70 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
 
         // Perform selected option
         switch ($option) {
+            case 'add':
+                $registration = $this->newEntry();
+                $view = "editEvent";
+                break;
+
+            case 'insert':
+                $registration = $this->insertEntry();
+                if ( $registration['status'] ) {
+                    $registrationAdded = true;
+                } else {
+                    $registrationAddError = true;
+                }
+                break;
+
+            case 'edit':
+                $registration = $this->editEntry( $this->registrationID );
+                //echo '<pre>$registration: ' . print_r( $registration, true ) . '</pre>';
+                if ( $registration['status'] ) {
+                    $haveAccount = true;
+                }
+                //echo '<pre>$registration: ' . print_r( $registration, true ) . '</pre>';
+
+                $view = "editEvent";
+                break;
+
+
+            case 'update':
+                $registration = $this->updateEntry( $this->registrationID );
+
+                if ( $registration['status'] ) {
+                    //echo '<pre>$registration: ' . print_r( $registration, true ) . '</pre>';
+                    $registrationUpdated = true;
+                    // Retrieve the Edit Entry again
+                    $registration = $this->editEntry( $this->registrationID );
+                    if ( $registration['status'] ) {
+                        $haveAccount = true;
+                    }
+                } else {
+                    $registrationUpdateError = true;
+                }
+
+                break;
+
+            case 'delete':
+                $oldAccount = $this->deleteEntry( $this->registrationID, true );
+                $view   = 'registration';
 
             // Check registration and update holds
             case 'check':
 
+                break;
+
+//            case 'add':
+//
+//
+//                break;
+
+
 //                $registrationCart = $regSupport->checkRegistrationRegistration($registrationId);
 
             // Display/Edit a registration registration
-            case 'edit':
+//            case 'edit':
+//
+//                break;
 
                 // If a registration ID has been supplied
 //                if ($registrationId) {
@@ -196,7 +253,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
         return array(
             'status'        => true,
             'modelRedirect' => false,
-            'view'          => 'admin/registrations/events.html',
+            'view'          => "admin/registrations/$view.html",
             'data'          => $templateData
         );
 
index c2b0eaf..6bde7c0 100644 (file)
@@ -57,3 +57,21 @@ add_filter(
     10,
     2
 );
+
+// Add a filter to include a link to either create registrations for an event or to update that.
+add_filter(
+    'glm_members_admin_events_list_table_data',
+    function( $eventId ){
+
+        // Check if there's an existing reg_event record for the supplied event ID.
+        require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequest.php';
+        $sql = "SELECT id FROM " .GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_event WHERE event='".$eventId."';";
+        $result = $this->wpdb->query($sql);
+
+        $return = "<td><a href='#'>Link for registration for event " . $result . "</a></td>";
+
+        return $return;
+    },
+    10,
+    2
+);
diff --git a/views/admin/registrations/editEvent.html b/views/admin/registrations/editEvent.html
new file mode 100644 (file)
index 0000000..a94ec88
--- /dev/null
@@ -0,0 +1,115 @@
+
+{include file='admin/registrations/header.html'}
+
+    <div class="glm-right">
+<!--        <p><a href="{$thisUrl}?page={$thisPage}&glm_action=events&option=check&requestID={$cart.request.id}" class="button button-secondary glm-button">Check Reguest & Update Holds</a></p>-->
+    </div>
+
+Here
+
+  {if $option == 'edit' || $option == 'update'}
+*** Edit or Update ***<!--
+    <a id="deleteAccountButton" class="button button-secondary glm-button glm-right">Delete this Account</a>
+    <div id="deleteAccountDialog" class="glm-dialog-box" title="Delete Account">
+        <center>
+            <p><a id="deleteAccountCancel" class="button button-primary">Cancel</a></p>
+            <p><input id="deleteAccountSubmit" type="submit" value="Delete this contact"></p>
+        </center>
+        <div class="glm-item-container">
+            <p><center><span class="glm-error">WARNING:</span></center></p>
+            <p>
+                <span class="glm-warning">Clicking the "Delete this Account" button above will
+                delete all of the data and images associated with this contact.
+                </span>
+            </p>
+            <p>
+                <span class="glm-error">Once deleted, this information will no longer be available and cannot be retrieved!</span>
+            </p>
+        </div>
+    </div>
+    <h2>Edit Account
+-->
+  {else}
+  *** Add new one***
+<!--    {$req = $cart.request}
+
+    <table class="glm-admin-table">
+        <tr>
+            <td>
+                <table class="glm-admin-table glm-account-table glm-admin-table-close-spaced">
+                    <tr><th>Request ID: </th><td>{$req.id}</td></tr>
+                    <tr><th>Date Submitted: </th><td>{$req.date_submitted.datetime}</td></tr>
+                    <tr><th>Status: </th><td>{$req.status.name}</td></tr>
+                </table>
+            </td>
+            <td>
+                <table id="glm-table-account" class="glm-admin-table glm-account-table glm-admin-table-border glm-admin-table-close-spaced">
+                    <tr><th><center>Billing Information</center></th></tr>
+                    <tr>
+                        <td>
+                            <table>
+                                <tr><th>Name: </th><td>{$req.bill_fname} {$req.bill_lname}{if $req.bill_title}, {$req.bill_title}{/if}</td></tr>
+                {if $req.bill_org}
+                                <tr><th>Organization: </th><td>{$req.bill_org}</td></tr>
+                {/if}
+                                <tr><th>Address: </th><td>{$req.bill_addr1}</td></tr>
+                {if $req.bill_addr2}
+                                <tr><th></th><td>{$req.bill_addr2}</td></tr>
+                {/if}
+                                <tr><th></th><td>{$req.bill_city}, {$req.bill_state} {$req.bill_zip} {$req.bill_country}</td></tr>
+                                <tr><th>Payment Method: </th><td>{$req.pay_method.name}</td></tr>
+                {if $req.status == 'CC_PAID'}
+                                <tr><th>Card Type: </th><td>{$req.cc_type.value}</td></tr>
+                                <tr><th>Card Number: </th><td>{$req.cc_numb}</td></tr>
+                                <tr><th>Confirmation: </th><td>{$req.cc_conf}</td></tr>
+                {/if}
+                            </table>
+                        </td>
+                    </tr>
+                </table>
+            </td>
+    {if $req.notes}
+
+            <td>
+                <table class="glm-admin-table glm-account-table glm-admin-table-border glm-admin-table-close-spaced">
+                    <tr><th><center>Notes</center></th></tr>
+                    <tr><td>{$req.notes}</td></tr>
+                </table>
+            </td>
+    {/if}
+        </tr>
+    <table class="glm-admin-table glm-account-table glm-admin-table-border glm-admin-table-close-spaced">
+        <tr><th><center>Registrations Selected</center></th></tr>
+        <tr>
+            <td>
+                <table>
+                    <tr><th>Event</th><th>Start Date/Time</th><th>Class</th><th>Rate</th><th>Credits<th>Registrants</th><th>Charge</th></tr>
+    {foreach $cart.events as $event}
+                    <tr>
+                        <td>{$event.event_name}</td><td>{$event.event_datetime.daetime}</td>
+                    </tr>
+        {foreach $event.classes as $class}
+                    <tr>
+                        <td colspan="2">&nbsp;</td><td>{$class.class_name}</td>
+                    </tr>
+            {foreach $class.rates as $rate}
+                    <tr>
+                        <td colspan="3">&nbsp;</td><td>{$rate.rate_name}</td><td>{$rate.registrant_credits}</td><td>&nbsp;</td><td align="right">{$rate.base_rate}</td>
+                    </tr>
+                {foreach $rate.registrants as $registrant}
+                    <tr>
+                        <td colspan="5">&nbsp;</td><td>{$registrant.fname} {$registrant.lname}</td><td align="right">{$rate.per_registrant}</td>
+                    </tr>
+                {/foreach}
+            {/foreach}
+        {/foreach}
+                    </tr>
+    {/foreach}
+                </table>
+            </td>
+        </tr>
+    </table>
+    -->
+  {/if}
+
+{include file='admin/footer.html'}
index a973b1b..3a51388 100644 (file)
@@ -2,6 +2,8 @@
 
 <h3>Registrations Events List</h3>
 
+<a href="{$thisUrl}?page=glm-members-admin-menu-registrations-events&glm_action=events&option=add" class="button button-secondary glm-button glm-right">Add A New Registration</a>
+
 <table>
     <tr>
         <th>ID</th>