Added account detail to accounts list in the admin Accounts page.
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 2 Oct 2018 16:56:24 +0000 (12:56 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 2 Oct 2018 16:56:24 +0000 (12:56 -0400)
classes/data/dataAccount.php [changed mode: 0644->0755]
models/admin/registrations/accounts.php
setup/databaseScripts/create_database_V1.0.1.sql
views/admin/registrations/accountsDashboard.html
views/admin/registrations/eventsDashboard.html

old mode 100644 (file)
new mode 100755 (executable)
index ed6faae..112c53c
@@ -72,6 +72,19 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract
      * @access public
      */
     public $fields = false;
+    /**
+     * Get Account Activity Flag
+     *
+     * If this is set then post-processing will include two additional lists under
+     * each account record, one for attendee records and the other for request records
+     * associated with this account.
+     *
+     * This option is false by default and must be specifically set if it is desired.
+     *
+     * @var $getAccountActivity
+     * @access public
+     */
+    public $getAccountActivity = false;
 
     /**
      * Constructor
@@ -632,20 +645,41 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract
     public function entryPostProcessing( $result_data, $action )
     {
 
-        // If doing the following actions
+        // If doing and Insert set the create date
         if (in_array($action, array('i'))) {
 
             // Set the created date
             $date = date('Y-m-d');
             $this->wpdb->update(
-                GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request_event",
-                array('date_created' => $deate),
+                GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."account",
+                array('date_created' => $date),
                 array('id' => $result_data['id']),
                 array('%s')
             );
 
         }
 
+        // If doing a list operation
+        if (in_array($action, array('l'))) {
+
+            // If getAccountActivity is set and this is a list request
+            if ($this->getAccountActivity) {
+
+                // Load data classes for requests and registrants and get related entries for this account
+                require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequest.php';
+                $RegRequest = new GlmDataRegistrationsRegRequest($this->wpdb, $this->config);
+                $result_data['requests'] = $RegRequest-> getList('T.account = '.$result_data['id'], 'bill_fname, bill_lname');
+                $result_data['numb_requests'] = is_array($result_data['requests']) * count($result_data['requests']);
+
+                require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequestRegistrant.php';
+                $RegRequestRegistrant = new GlmDataRegistrationsRequestRegistrant($this->wpdb, $this->config);
+                $result_data['registrants'] = $RegRequestRegistrant-> getList('T.account = '.$result_data['id'], 'event_datetime');
+                $result_data['numb_registrants'] = is_array($result_data['registrants']) * count($result_data['registrants']);
+
+            }
+
+        }
+
         return $result_data;
 
     }
index 2b08d22..9cc8029 100755 (executable)
@@ -87,6 +87,7 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount
 
     public function modelAction($actionData = false)
     {
+        $inputData          = false;
         $option             = 'dashboard';
         $view               = 'accountsDashboard';
         $reason             = false;
@@ -264,19 +265,66 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount
                 }
             }
 
+            // filter form input
+            $inputData = filter_input_array( INPUT_POST,
+                [
+                    'textSearch' => [ 'filter'  => FILTER_SANITIZE_STRING ],
+                    'withRequests' => [ 'filter' => FILTER_VALIDATE_BOOLEAN ],
+                    'withAttendees' => [ 'filter' => FILTER_VALIDATE_BOOLEAN ],
+                    'withNoData' => [ 'filter' => FILTER_VALIDATE_BOOLEAN ],
+                    'inactive' => [ 'filter' => FILTER_VALIDATE_BOOLEAN ]
+                ]
+            );
+
             // Check if we have a Text Search string
-            if ( isset( $_REQUEST['textSearch'] ) && trim( $_REQUEST['textSearch'] ) != '' ) {
-                $textSearch = trim( $_REQUEST['textSearch'] );
+            if ($inputData['textSearch']) {
+                $textSearch = trim(addslashes($inputData['textSearch']));
                 $where .= " AND (
                     CONCAT_WS( ' ', fname, lname) LIKE '%$textSearch%' or
                     org LIKE '%$textSearch%' OR
                     email LIKE '%$textSearch%' OR
+                    phone LIKE '%$textSearch%' OR
                     id = '$textSearch'
                 )";
             }
 
+            // Submitted Requests
+            if ($inputData['withRequests']) {
+                $where .= " AND (
+                    SELECT COUNT(id)
+                      FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_request
+                     WHERE account = T.id
+                )";
+            }
+
+            // Attending Events
+            if ($inputData['withAttendees']) {
+                $where .= " AND (
+                    SELECT COUNT(id)
+                      FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_request_registrant
+                     WHERE account = T.id
+                )";
+
+            }
+
+            // Empty Accounts
+            if (!$inputData['withNoData']) {
+                $where .= " AND CONCAT_WS( ' ', fname, lname, email, org, phone) != ''";
+            }
+
+            // If not showing inactive show active only
+            if ($inputData['inactive']) {
+                $where .= " AND !active";
+            } else {
+                $where .= " AND active";
+            }
+
+            // Compile input values array
+
+
+            $this->getAccountActivity = true;
             $accountsResult = $this->getList( $where, 'lname', true, 'id', $start, $limit  );
           // echo '<pre>$accountsResult: ' . print_r( $accountsResult, true ) . '</pre>';
//echo '<pre>$accountsResult: ' . print_r( $accountsResult, true ) . '</pre>';
 
             //$accounts    = $this->getList( $where );
             // echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
@@ -321,6 +369,7 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount
 
         // Compile template data
         $templateData = array(
+            'inputData'          => $inputData,
             'hasAccounts'        => $hasAccounts,
             'numbAccounts'       => $numbAccounts,
             'accounts'           => $accounts,
@@ -348,8 +397,7 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount
             'haveRequests'       => $haveRequests,
             'registered'         => $registered,
             'haveRegistered'     => $haveRegistered,
-            'reason'             => $reason,
-            'textSearch'         => $textSearch
+            'reason'             => $reason
         );
              // Return status, any suggested view, and any data to controller
         return array(
index fe3819a..c988a4b 100755 (executable)
@@ -388,7 +388,7 @@ CREATE TABLE {prefix}account (
     active BOOLEAN NULL,                                        -- Is active flag (may be accessed or used) - default is true
     validated BOOLEAN NULL,                                     -- Flag indicating that the account has been validated - Set to false when recovering password
     validation_code TINYTEXT NULL,                              -- Validation code and timestamp ("{validation code}-{timestamp}) - Clear this after validation
-    registered_by INT NULL,                                     -- Account
+    registered_by INT NULL,                                     -- Account *** THIS FIELD NEEDS TO BE DELETED ***
     member_id TINYTEXT NULL,                                    -- Free-form field for a member ID (not a GLM Associate member ID - See "contact_member_id" below)
     fname TINYTEXT NULL,                                        -- Account primary address
     lname TINYTEXT NULL,
index ebdf4f8..419c43d 100755 (executable)
         <div class="">
             <p>
                 <span class="glm-nowrap">
-                    <b>Name / E-mail / Organization / ID Search: </b><input  id="glmEventsSearch" name="textSearch" type="text" id="autoTest">
-                    <input type="submit" value="Submit">
+                    <b>Name / E-mail / Organization / Phone / ID Search: </b><input  id="glmEventsSearch" name="textSearch" type="text" id="autoTest" value="{$inputData.textSearch}">
                 </span>
             <p>
+            <p>
+                <span class="glm-nowrap"><input type="checkbox" name="withRequests"{if $inputData.withRequests} checked="checked"{/if}> Accounts with submitted requests</span>
+                <span class="glm-nowrap"><input type="checkbox" name="withAttendees"{if $inputData.withAttendees} checked="checked"{/if}> Accounts {$terms.reg_term_registered} for an {$terms.reg_term_event}</span>
+                <span class="glm-nowrap"><input type="checkbox" name="withNoData"{if $inputData.withNoData} checked="checked"{/if}> Empty Accounts</span>
+                <span class="glm-nowrap"><input type="checkbox" name="inactive"{if $inputData.inactive} checked="checked"{/if}> Inactive Accounts</span>
+                &nbsp;<input type="submit" value="Submit">
+            </p>
+            
         </div>
 
         <br clear="all">
                 <th>Last Name</th>
                 <th>E-Mail Address</th>
                 <th>Organization</th>
-                <th>Title</th>
-                <th>City</th>
-                <th>State</th>
                 <th>Phone</th>
+                <th>Requests</th>
+                <th>{$terms.reg_term_registered_cap}</th>
                 <th>Created</th>                
             </tr>
         </thead>
         <tbody>
     {foreach $accounts as $account}
-        {if $i++ is odd by 1}
-            <tr>
-        {else}
-            <tr class="alternate">
-        {/if}
-            <td><a href="{$thisUrl}?page=glm-members-admin-menu-registrations-accounts&glm_action=accounts&option=accountDashboard&accountID={$account.id}">{$account.id}</a></td>
-            <td>{$account.member_id}</td>
-            <td>{$account.active.name}</td>
-            <td>{$account.validated.name}</td>
-            <td>{$account.fname}</td>
-            <td>{$account.lname}</td>
-            <td>{$account.email}</td>
-            <td>{$account.org}</td>
-            <td>{$account.title}</td>
-            <td>{$account.city}</td>
-            <td>{$account.state.name}</td>
-            <td>{$account.phone}</td>
-            <td>{$account.date_created.timestamp|date_format:"%D"}</td>
-        </tr>
+    
+            <tr id="glmRegAccountLine_{$account.id}" data-account="{$account.id}" class="glm-account-line"{if $i++ is odd by 1} alternate{/if}>
+                <td><a href="{$thisUrl}?page=glm-members-admin-menu-registrations-accounts&glm_action=accounts&option=accountDashboard&accountID={$account.id}">{$account.id}</a></td>
+                <td>{$account.member_id}</td>
+                <td>{$account.active.name}</td>
+                <td>{$account.validated.name}</td>
+                <td>{$account.fname}</td>
+                <td>{$account.lname}</td>
+                <td>{$account.email}</td>
+                <td>{$account.org}</td>
+                <td>{$account.phone}</td>
+                <td>{$account.numb_requests}</td>
+                <td>{$account.numb_registrants}</td>
+                <td>{$account.date_created.timestamp|date_format:"%D"}</td>
+            </tr>
+            <tr id="accountLinks_{$account.id}" class="glm-account-links glm-hidden">
+                <td colspan="12" colspan="6" style="padding: .8rem; background-color: #fff;">
+                    <span>
+                        <a href="#" data-account="{$account.id}" class="glm-account-link">Show Account Detail</a>
+                    </span>
+                </td>
+            </tr>
+            <tr id="accountEdit_{$account.id}" class="glm-account-edit-area glm-hidden">
+                <td colspan="6" style="padding: .8rem; background-color: #f8ffff; border: 1px solid black;">
+                    <div class="close-account-edit-area button button-small">Close Account Detail</div>
+                    <div>
+                        <div style="float: left; margin-right: 2em;">
+                            <p>{if $account.is_member}<b>Member ID:</b> {$account.member_id}&nbsp;&nbsp;{if $account.active}Active{/if}{/if}</p>
+                            <p>
+                                {if $account.lname != '' || $account.fname != '' || $account.title != ''}
+                                    {$account.lname}, {$account.fname}{if $account.title}{if $account.lname != '' || $account.fname != ''} - {/if}{$account.title}{/if}
+                                {/if}<br>
+                                {if $account.org != ''}{$account.org}<br>{/if}
+                                {if $account.add1 != ''}{$account.addr1}<br>{/if}
+                                {if $account.add2 != ''}{$account.addr2}<br>{/if}
+                                {if $account.city != ''}{$account.city}{/if}
+                                {if $account.state.value != ''}{if $account.city != ''},ddd {/if}{$account.state.name}{/if}
+                                {if $account.country.value}{$account.country.name}{/if}
+                                {if $account.city || $account.state.value || $account.country.value}<br>{/if}
+                                {if $account.phone != ''}<b>Phone:</b> {$account.phone}<br>{/if}
+                                {if $account.email != ''}<b>Email Address:</b> {$account.email}<br>{/if}
+                            </p>
+                            
+                        </div>
+            {if $account.numb_requests}
+                        <div style="float: left; margin-right: 2em;">
+                            <p />
+                            <h4>Requests Submitted</h4>
+                            <p />
+                            <table class="glm-admin-table wp-list-table striped glm-nowrap">
+                                <tr>
+                                    <td style="padding-right: 1em;">ID</td>
+                                    <td style="padding-right: 1em;">Date Submitted</td>
+                                    <td style="padding-right: 1em;">Pay Method</td>
+                                    <td style="padding-right: 1em;">Status</td>
+                                    <td>{$terms.reg_term_attendee_plur_cap}</td>
+                                </tr>
+          {foreach $account.requests as $request}                            
+                                <tr>
+                                    <td><a href="{$thisUrl}?page=glm-members-admin-menu-registrations-requests&option=requestDashboard&requestID={$request.id}">{$request.id}</a></td>
+                                    <td>{$request.date_submitted.datetime}</td>
+                                    <td>{$request.pay_method.name}</td>
+                                    <td>{$request.status.name}</td>
+                                    <td>{$request.registrants}</td>
+                                </tr>                                
+          {/foreach}
+                            </table>
+                        </div>
+            {/if}
+            {if $account.numb_registrants}
+                        <div style="float: left; margin-right: 2em;">
+                            <p />
+                            <h4>{$terms.reg_term_event_plur_cap} {$terms.reg_term_attended}/{$terms.reg_term_attending} </h4>
+                            <p />
+                            <table class="glm-admin-table wp-list-table striped glm-nowrap">
+                                <tr>
+                                    <td style="padding-right: 1em;">ID</td>
+                                    <td style="padding-right: 1em;">Name</td>
+                                    <td style="padding-right: 1em;">{$terms.reg_term_event_cap}</td>
+                                    <td style="padding-right: 1em;">Level</td>
+                                    <td style="padding-right: 1em;">Rate</td>
+                                    <td style="padding-right: 1em;">Requeest Status</td>
+                                    <td>Attending</td>
+                                </tr>
+          {foreach $account.registrants as $registrant}                            
+                                <tr>
+                                    <td><a href="{$thisUrl}?page=glm-members-admin-menu-registrations-requests&option=requestDashboard&requestID={$request.id}">{$registrant.id}</a></td>
+                                    <td>{$registrant.fname} {$registrant.lname}</td>
+                                    <td>{$registrant.event_name}</td>
+                                    <td>{$registrant.class_name}</td>
+                                    <td>{$registrant.rate_name}</td>
+                                    <td>{$registrant.request_status_name}</td>
+                                    <td>{if $registrant.not_attending.value}No{else}Yes{/if}</td>
+                                </tr>                                
+          {/foreach}
+                            </table>
+                        </div>
+            {/if}
+                    </div>
+                </td>
+            </tr>
         </tbody>
     {/foreach}
     </table>
                      }
                  }
              });
+
+             // Account Line Hover Action
+             var accountEditId = false;
+             var accountHoverId = false;
+             $('.glm-account-line').mouseenter( function() {
+                 if (accountEditId) {
+                     return;
+                 }
+                 accountHoverId = $(this).attr('data-account');
+                 $('.glm-account-links').addClass('glm-hidden');
+                 $('#accountLinks_' + accountHoverId).removeClass('glm-hidden');
+             });
+
+             // Account Edit Action
+             $('.glm-account-link').on('click', function() {
+                 if (accountEditId) {
+                     $('.glm-account-edit-area').addClass('glm-hidden');
+                     accountEditId = false;
+                     return;
+                 }
+                 accountEditId = $(this).attr('data-account');
+                 $('#accountEdit_' + accountEditId).removeClass('glm-hidden');
+             });
+
+             // Close edit action
+             $('.close-account-edit-area').on('click', function() {
+                 if (accountEditId) {
+                     $('.glm-account-edit-area').addClass('glm-hidden');
+                     accountEditId = false;
+                     return;
+                 }
+             });
+             
         });
     </script>
 
index 8d1e972..9771900 100755 (executable)
             </tr>
             <tr id="requestLinks_{$r.id}" class="glm-hidden glm-request-links">
                 <td colspan="6" style="padding: .8rem; background-color: #fff;">
-                    <span class="attendee-edit-link">
-                        <a id="glm-request-link_{$r.id}" href="#" data-request="{$r.id}" class="glm-request-link">Edit Request Status</a> | 
+                    <span>
+                        <a href="#" data-request="{$r.id}" class="glm-request-link">Edit Request Status</a> | 
                         <a href="{$thisUrl}?page=glm-members-admin-menu-registrations-requests&option=requestDashboard&requestID={$r.id}">View Request Detail</a>
                     </span>
                     <br>