WIP export for events
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 30 Mar 2018 18:11:59 +0000 (14:11 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 30 Mar 2018 18:11:59 +0000 (14:11 -0400)
Start work on the event export.

classes/data/dataEvents.php
models/admin/ajax/eventsListExport.php [new file with mode: 0644]
setup/validActions.php
views/admin/ajax/eventsListExport.html [new file with mode: 0644]
views/admin/ajax/eventsListExportCsv.html [new file with mode: 0644]
views/admin/events/eventExportModal.html [new file with mode: 0644]
views/admin/events/list.html

index 4aebbc4..e02d162 100644 (file)
@@ -509,7 +509,7 @@ class GlmDataEvents extends GlmDataAbstract
         if (isset($r['registration_url']) && strlen(trim($r['registration_url'])) > 0  && strtolower(substr($r['registration_url'],0,4)) != 'http') {
             $r['registration_url'] = 'http://'.$r['registration_url'];
         }
-        
+
         // Get Member Category data for this entry
         if ($this->postCategories) {
             $sql = "
@@ -530,7 +530,7 @@ class GlmDataEvents extends GlmDataAbstract
         }
 
         if ($this->postAmenities) {
-      
+
             $sql = "
                 SELECT EC.event AS event_id, C.id, C.name
                   FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "amenities AS C,
@@ -904,10 +904,10 @@ class GlmDataEvents extends GlmDataAbstract
         return $r;
 
     }
-    
+
     /**
      * Get Cities List for Events
-     * 
+     *
      * Searches for cities with both member and internal data.
      * May use option to specify a WHERE clause to limit the events
      * that the cities are drawn from.
@@ -920,20 +920,20 @@ class GlmDataEvents extends GlmDataAbstract
     {
 
         $savedFields                = $this->fields;
-        $savedpostAddTimes          = $this->postAddTimes;          
-        $savedpostAddLocations      = $this->postAddLocations;      
-        $savedpostAddRecurrences    = $this->postAddRecurrences;    
-        $savedpostFirstAndLastTimes = $this->postFirstAndLastTimes; 
-        $savedpostCategories        = $this->postCategories;        
-        $savedpostAmenities         = $this->postAmenities;         
-        
+        $savedpostAddTimes          = $this->postAddTimes;
+        $savedpostAddLocations      = $this->postAddLocations;
+        $savedpostAddRecurrences    = $this->postAddRecurrences;
+        $savedpostFirstAndLastTimes = $this->postFirstAndLastTimes;
+        $savedpostCategories        = $this->postCategories;
+        $savedpostAmenities         = $this->postAmenities;
+
         $this->postAddTimes          = false;
         $this->postAddLocations      = true;
         $this->postAddRecurrences    = false;
         $this->postFirstAndLastTimes = false;
         $this->postCategories        = false;
         $this->postAmenities         = false;
-        
+
         $this->fields = array(
             'id'                    => $savedFields['id'],
             'name'                  => $savedFields['name'],
@@ -941,12 +941,12 @@ class GlmDataEvents extends GlmDataAbstract
             'ref_dest_id'           => $savedFields['ref_dest_id'],
             'other_ref_dest_id'     => $savedFields['other_ref_dest_id']
         );
-        
+
         $events = $this->getList($where);
-        
+
         $eventCities = array();
         foreach ($events as $event) {
-            
+
             if (isset($event['member'])) {
                 $eventCities[$event['member']['city_id']] = array(
                     'id' => $event['member']['city_id'],
@@ -957,23 +957,23 @@ class GlmDataEvents extends GlmDataAbstract
                     'id' => $event['locations']['city']['value'],
                     'name' => $event['locations']['city']['name']
                 );
-            }   
-            
+            }
+
         }
-        
-        $this->fields                = $savedFields;               
-        $this->postAddTimes          = $savedpostAddTimes;         
-        $this->postAddLocations      = $savedpostAddLocations;     
-        $this->postAddRecurrences    = $savedpostAddRecurrences;   
+
+        $this->fields                = $savedFields;
+        $this->postAddTimes          = $savedpostAddTimes;
+        $this->postAddLocations      = $savedpostAddLocations;
+        $this->postAddRecurrences    = $savedpostAddRecurrences;
         $this->postFirstAndLastTimes = $savedpostFirstAndLastTimes;
-        $this->postCategories        = $savedpostCategories;       
-        $this->postAmenities         = $savedpostAmenities;        
-        
+        $this->postCategories        = $savedpostCategories;
+        $this->postAmenities         = $savedpostAmenities;
+
         return $eventCities;
-        
+
     }
-    
-    
+
+
 
 }
 
diff --git a/models/admin/ajax/eventsListExport.php b/models/admin/ajax/eventsListExport.php
new file mode 100644 (file)
index 0000000..6c134a2
--- /dev/null
@@ -0,0 +1,303 @@
+<?php
+
+/**
+ * Gaslight Media Events Database
+ * Events List Export by AJAX
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmEventsDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+
+// Load Event Info data abstract
+require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEvents.php';
+require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataCategories.php';
+require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEventCategories.php';
+
+/**
+ *
+ * This class exports the currently selected events list
+ * to a printable HTML file, to a CSV file, or otherwise.
+ */
+class GlmMembersAdmin_ajax_eventsListExport extends GlmDataEvents
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /**
+     * Constructor
+     *
+     * This constructor sets up this model. At this time that only includes
+     * storing away the WordPress data object.
+     *
+     * @return object Class object
+     *
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        parent::__construct(false, false);
+
+    }
+
+    public function checkFlag($t) {return isset($_REQUEST[$t]) && $_REQUEST[$t] == 'on';}
+    /**
+     * Perform Model Action
+     *
+     * This modelAction takes an AJAX image upload and stores the image in the
+     * media/images directory of the plugin.
+     *
+     * This model action does not return, it simply does it's work then calls die();
+     *
+     * @param $actionData
+     *
+     * Echos JSON string as response and does not return
+     */
+    public function modelAction ($actionData = false)
+    {
+
+        // When processing member info records, also get primary contact data
+        $this->postProcessPrimaryContact = true;
+
+        $where          = ' true ';
+        $categories     = false;
+        $haveEvents     = false;
+        $list           = false;
+        $success        = false;
+        $filterPending  = false;
+        $filterArchived = false;
+        $haveFilter     = false;
+        $numbDisplayed  = false;
+        $lastDisplayed  = false;
+        $paging         = true;
+        $prevStart      = false;
+        $nextStart      = false;
+        $start          = 1;
+        $limit          = 20;        // Set to the number of listings per page
+        $namesList      = false;
+
+        // Check selected fields
+        $select = array(
+            'exportId'              => $this->checkFlag('exportId'),
+            'exportName'            => $this->checkFlag('exportName'),
+            'exportMember'          => $this->checkFlag('exportMember'),
+            'exportStatus'          => $this->checkFlag('exportStatus'),
+            'exportFeatured'        => $this->checkFlag('exportFeatured'),
+            'exportCategories'      => $this->checkFlag('exportCategories'),
+            'exportIntro'           => $this->checkFlag('exportIntro'),
+            'exportDescr'           => $this->checkFlag('exportDescr'),
+            'exportFree'            => $this->checkFlag('exportFree'),
+            'exportCost'            => $this->checkFlag('exportCost'),
+            'exportNotes'           => $this->checkFlag('exportNotes'),
+            'exportLocationName'    => $this->checkFlag('exportLocationName'),
+            'exportAddress'         => $this->checkFlag('exportAddress'),
+            'exportCity'            => $this->checkFlag('exportCity'),
+            'exportState'           => $this->checkFlag('exportState'),
+            'exportZip'             => $this->checkFlag('exportZip'),
+            'exportCountry'         => $this->checkFlag('exportCountry'),
+            'exportRegion'          => $this->checkFlag('exportRegion'),
+            'exportWebUrl'          => $this->checkFlag('exportWebUrl'),
+            'exportTicketingUrl'    => $this->checkFlag('exportTicketingUrl'),
+            'exportRegistrationUrl' => $this->checkFlag('exportRegistrationUrl'),
+            'exportContactName'     => $this->checkFlag('exportContactName'),
+            'exportContactPhone'    => $this->checkFlag('exportContactPhone'),
+            'exportContactEmail'    => $this->checkFlag('exportContactEmail'),
+            'exportAdminName'       => $this->checkFlag('exportAdminName'),
+            'exportAdminOrg'        => $this->checkFlag('exportAdminOrg'),
+            'exportAdminEmail'      => $this->checkFlag('exportAdminEmail'),
+            'exportAdminPhone'      => $this->checkFlag('exportAdminPhone'),
+        );
+
+        // Check for Archived filter
+        if (isset($_REQUEST['filterArchived']) && $_REQUEST['filterArchived'] == 'on') {
+            $filterArchived = true;
+            $_SESSION['search']['archived'] = true;
+            $where .= " AND status = " . $this->config['status_numb']['Archived'];
+        } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterArchived'] ) ) {
+            unset( $_SESSION['search']['archived'] );
+        }
+
+        // Check for Pending filter
+        if (isset($_REQUEST['filterPending']) && $_REQUEST['filterPending'] == 'on') {
+            $filterPending = true;
+            $_SESSION['search']['pending'] = true;
+            $where .= " AND status = " . $this->config['status_numb']['Pending'];
+        } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterPending'] ) ) {
+            unset( $_SESSION['search']['pending'] );
+        }
+
+        // Check for Featured filter
+        if (isset($_REQUEST['filterFeatured']) && $_REQUEST['filterFeatured'] == 'on') {
+            $filterFeatured = true;
+            $_SESSION['search']['featured'] = true;
+            $where .= " AND featured = true";
+        } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterFeatured'] ) ) {
+            unset( $_SESSION['search']['featured'] );
+        }
+
+        // Check if there is a category filter (multi-select)
+        if (isset($_REQUEST['filterCategories']) && count($_REQUEST['filterCategories']) > 0) {
+
+            $cats = '';
+            $catsSep = '';
+
+            // For each selected category
+            foreach($_REQUEST['filterCategories'] as $c) {
+                $cats .= $catsSep.$c;
+                $catsSep = ',';
+                $categories[$c]['selected'] = true;
+            }
+            $_SESSION['search']['cats'] = $cats;
+
+            $where .= " AND id in (
+                    SELECT DISTINCT(EC.event)
+                      FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."event_categories EC,
+                           ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories C
+                     WHERE (
+                           EC.category in ($cats)
+                           OR (C.parent in ($cats) AND EC.category = C.id)
+                           )
+            )";
+        } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterCategories'] ) ) {
+            unset( $_SESSION['search']['cats'] );
+        }
+
+        // If we have a From date
+        $dateWhere = '';
+        if (isset($_REQUEST['fromDate']) && trim($_REQUEST['fromDate']) != '') {
+            $fromDate = date('m/d/Y', strtotime($_REQUEST['fromDate']));
+            $fromMYSQL = date('Y-m-d', strtotime($fromDate));
+            $dateWhere = " end_time >= '$fromMYSQL' ";
+            $_SESSION['search']['fromDate'] = $fromDate;
+        } else if ( !isset( $_REQUEST['searched'] ) ) {
+            $fromDate = date('m/d/Y');
+            $fromMYSQL = date('Y-m-d', strtotime($fromDate));
+            $dateWhere = " end_time >= '$fromMYSQL' ";
+        } else if ( isset( $_REQUEST['searched'] ) && trim($_REQUEST['fromDate']) == '' ) {
+            unset( $_SESSION['search']['fromDate'] );
+        }
+
+        // If we have a to Date
+        if (isset($_REQUEST['toDate']) && trim($_REQUEST['toDate']) != '') {
+
+            $toDate = date('m/d/Y', strtotime($_REQUEST['toDate']));
+            $toMYSQL = date('Y-m-d', strtotime($toDate." +1 day"));
+
+            // If we have a from date then we need Parens and AND
+            if ($dateWhere != '') {
+                $dateWhere = "( ".$dateWhere." AND start_time <= '$toMYSQL' )";
+
+            // Otherwise we don't
+            } else {
+                $dateWhere = " start_time <= '$toMYSQL' ";
+            }
+            $_SESSION['search']['toDate'] = $toDate;
+        } else if ( isset( $_REQUEST['searched'] ) && trim($_REQUEST['toDate']) == '' ) {
+            unset( $_SESSION['search']['toDate'] );
+        }
+
+        // If we have from and to dates, do search for those inclusive
+        if ($dateWhere != '') {
+            $where .= "
+                AND id in (
+                    SELECT DISTINCT(event)
+                      FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."times
+                     WHERE $dateWhere
+                       AND active
+                )
+            ";
+        }
+
+        // Get a current list of events without paging
+        $orderBy = "(select min(start_time) FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE T.id = event),name";
+        $this->postCategories   = true;
+        $this->postAddLocations = true;
+        $list = $this->getList( $where, $orderBy, true );
+
+        // If we have list entries - even if it's an empty list
+        $success     = true;
+        $haveEvents = false;
+        if ($list !== false) {
+
+            $success = true;
+
+            // If we have any entries
+            $memberCount = count($list);
+            if ($memberCount > 0) {
+                $haveEvents = true;
+            }
+        }
+
+        // Compile template data
+        $templateData = array(
+            'category_data'  => $category_data,
+            'select'         => $select,
+            'haveEvents'     => $haveEvents,
+            'events'         => $list,
+            'memberCount'    => $memberCount,
+            'categories'     => $categories,
+            'haveFilter'     => $haveFilter,
+            'filterArchived' => $filterArchived,
+            'filterFeatured' => $filterFeatured,
+            'filterPending'  => $filterPending,
+            'numbDisplayed'  => $numbDisplayed,
+            'lastDisplayed'  => $lastDisplayed,
+            'paging'         => $paging,
+            'prevStart'      => $prevStart,
+            'nextStart'      => $nextStart,
+            'start'          => $start,
+            'limit'          => $limit,
+            'namesList'      => $namesList
+        );
+
+        $view = 'admin/ajax/eventsListExport.html';
+        if ($_REQUEST['type'] == 'csv') {
+            $view = 'admin/ajax/eventsListExportCsv.html';
+            header("Content-Type: text/csv");
+            header("Content-Disposition: attachment; filename=file.csv");
+        } else {
+            header("Content-Type: text/html");
+            header("Content-Disposition: attachment; filename=file.html");
+        }
+
+        // Disable caching
+        header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1
+        header("Pragma: no-cache"); // HTTP 1.0
+        header("Expires: 0"); // Proxies
+
+        // Return status, suggested view, and data to controller
+        return array(
+            'status'           => $success,
+            'menuItemRedirect' => false,
+            'modelRedirect'    => false,
+            'view'             => $view,
+            'data'             => $templateData
+        );
+
+    }
+
+}
index 2ff7c24..7d6128a 100644 (file)
@@ -39,6 +39,7 @@ $glmMembersEventsAddOnValidActions = array(
             'rssFeed'            => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
             'eventsCalMonthAJAX' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
             'icalFeedImport'     => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
+            'eventsListExport'   => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
         ),
         'dashboard' => array(
             'events' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
diff --git a/views/admin/ajax/eventsListExport.html b/views/admin/ajax/eventsListExport.html
new file mode 100644 (file)
index 0000000..ef8c265
--- /dev/null
@@ -0,0 +1,103 @@
+<html>
+    <head>
+    </head>
+    <body>
+
+        <span style="float: right;"><b>Total found: {$memberCount}&nbsp;&nbsp;</b></span>
+        <b>List&nbsp;of&nbsp;{$terms.term_member_cap} Profiles</b>
+        <br clear="all">
+
+        <table>
+            <thead>
+                <tr>
+                    {if $select.exportId}<th align="left">ID</th>{/if}
+                    {if $select.exportName}<th align="left">Event Name</th>{/if}
+                    {if $select.exportMember}<th align="left">{$terms.term_member_cap} Name</th>{/if}
+                    {if $select.exportStatus}<th align="left">Status</th>{/if}
+                    {if $select.exportFeatured}<th align="left">Featured</th>{/if}
+                    {if $select.exportIntro}<th align="left">Intro</th>{/if}
+                    {if $select.exportDescr}<th align="left">Description</th>{/if}
+                    {if $select.exportFree}<th align="left">Free</th>{/if}
+                    {if $select.exportNotes}<th align="left">Notes</th>{/if}
+                    {if $select.exportLocationName}<th align="left">Location Name</th>{/if}
+                    {if $select.exportAddress}<th align="left">Address</th>{/if}
+                    {if $select.exportCity}<th align="left">City</th>{/if}
+                    {if $select.exportState}<th align="left">State</th>{/if}
+                    {if $select.exportZip}<th align="left">ZIP</th>{/if}
+                    {if $select.exportCountry}<th align="left">Country</th>{/if}
+                    {if $select.exportRegion}<th align="left">Region</th>{/if}
+                    {if $select.exportWebUrl}<th align="left">Web URL</th>{/if}
+                    {if $select.exportTicketingUrl}<th align="left">Ticketing URL</th>{/if}
+                    {if $select.exportRegistrationUrl}<th align="left">Registration URL</th>{/if}
+                    {if $select.exportContactName}<th align="left">Contact Name</th>{/if}
+                    {if $select.exportContactPhone}<th align="left">Contact Phone</th>{/if}
+                    {if $select.exportContactEmail}<th align="left">Contact E-Mail</th>{/if}
+                    {if $select.exportAdminName}<th align="left">Admin Contact Name</th>{/if}
+                    {if $select.exportAdminOrg}<th align="left">Admin Contact Organization</th>{/if}
+                    {if $select.exportAdminEmail}<th align="left">Admin Contact E-Mail</th>{/if}
+                    {if $select.exportAdminPhone}<th align="left">Admin Contact Phone</th>{/if}
+                    {if $select.exportCategories}
+                        {if $category_data}
+                            {foreach $category_data as $cat}
+                            <th align="left">{if $cat.parent_name}{$cat.parent_name}:{/if}{$cat.name}</th>
+                            {/foreach}
+                        {/if}
+                    {/if}
+                </tr>
+            </thead>
+            <tbody>
+            {if $haveEvents}
+                {foreach $events as $event}
+                <tr>
+                    {if $select.exportId}<td>{$event.id}</td>{/if}
+                    {if $select.exportName}<td>{$event.name}</td>{/if}
+                    {if $select.exportMember}<td>{$event.ref_dest}</td>{/if}
+                    {if $select.exportStatus}<td>{$event.status.name}</td>{/if}
+                    {if $select.exportFeatured}<td>{$event.featured.name}</td>{/if}
+                    {if $select.exportIntro}<td>{$event.intro}</td>{/if}
+                    {if $select.exportDescr}<td>{$event.descr}</td>{/if}
+                    {if $select.exportFree}<td>{$event.free.name}</td>{/if}
+                    {if $select.exportNotes}<td>{$event.notes}</td>{/if}
+
+                    {if $select.exportLocationName}<td>{if $event.locations.name}{$event.locations.name}{/if}</td>{/if}
+                    {if $select.exportAddress}<td>{if $event.locations.address}{$event.locations.address}{/if}</td>{/if}
+                    {if $select.exportCity}<td>{if $event.locations.city.name}{$event.locations.city.name}{/if}</td>{/if}
+                    {if $select.exportState}<td>{if $event.locations.state.name}{$event.locations.state.name}{/if}</td>{/if}
+                    {if $select.exportZip}<td>{if $event.locations.zip}{$event.locations.zip}{/if}</td>{/if}
+                    {if $select.exportCountry}<td>{if $event.locations.country.name}{$event.locations.country.name}{/if}</td>{/if}
+                    {if $select.exportRegion}<td>{if $event.locations.region.name}{$event.locations.region.name}{/if}</td>{/if}
+
+                    {if $select.exportWebUrl}<td>{$event.url}</td>{/if}
+                    {if $select.exportTicketingUrl}<td>{$event.ticket_url}</td>{/if}
+                    {if $select.exportRegistrationUrl}<td>{$event.registration_url}</td>{/if}
+                    {if $select.exportContactName}<td>{$event.contact_name}</td>{/if}
+                    {if $select.exportContactEmail}<td>{$event.contact_email}</td>{/if}
+                    {if $select.exportContactPhone}<td>{$event.contact_phone}</td>{/if}
+                    {if $select.exportAdminName}<td>{$event.admin_name}</td>{/if}
+                    {if $select.exportAdminOrg}<td>{$event.admin_org}</td>{/if}
+                    {if $select.exportAdminEmail}<td>{$event.admin_email}</td>{/if}
+                    {if $select.exportAdminPhone}<td>{$event.admin_phone}</td>{/if}
+                    {if $select.exportCategories}
+                        {if $category_data}
+                            {foreach $category_data as $cat}
+                                <td>
+                                {$cat_exists=''}
+                                {foreach $event.categories as $t}
+                                    {if $t.id == $cat.id}{$cat_exists='Yes'}{/if}
+                                {/foreach}
+                                {$cat_exists}
+                                </td>
+                            {/foreach}
+                        {/if}
+                    {/if}
+
+                </tr>
+                {/foreach}
+            {else}
+                <tr class="alternate"><td colspan="2">(no {$terms.term_member} profiles listed)</td></tr>
+            {/if}
+            </tbody>
+        </table>
+
+    </body>
+</html>
diff --git a/views/admin/ajax/eventsListExportCsv.html b/views/admin/ajax/eventsListExportCsv.html
new file mode 100644 (file)
index 0000000..7238fad
--- /dev/null
@@ -0,0 +1,61 @@
+{if $haveEvents}
+
+{if $select.exportId}"ID",{/if}
+{if $select.exportName}"Event Name",{/if}
+{if $select.exportMember}"{$terms.term_member_cap} Name",{/if}
+{if $select.exportStatus}"Status",{/if}
+{if $select.exportFeatured}"Featured",{/if}
+{if $select.exportIntro}"Intro",{/if}
+{if $select.exportDescr}"Description",{/if}
+{if $select.exportFree}"Free",{/if}
+{if $select.exportNotes}"Notes",{/if}
+{if $select.exportLocationName}"Location Name",{/if}
+{if $select.exportAddress}"Address",{/if}
+{if $select.exportCity}"City",{/if}
+{if $select.exportState}"State",{/if}
+{if $select.exportZip}"Zip",{/if}
+{if $select.exportCountry}"Country",{/if}
+{if $select.exportRegion}"Region",{/if}
+{if $select.exportWebUrl}"Web URL",{/if}
+{if $select.exportTicketingUrl}"Ticketing URL",{/if}
+{if $select.exportRegistrationUrl}"Registration URL",{/if}
+{if $select.exportContactName}"Contact Name",{/if}
+{if $select.exportContactEmail}"Contact E-Mail",{/if}
+{if $select.exportContactPhone}"Contact Phone",{/if}
+{if $select.exportAdminName}"Admin Contact Name",{/if}
+{if $select.exportAdminOrg}"Admin Contact Organization",{/if}
+{if $select.exportAdminEmail}"Admin Contact E-Mail",{/if}
+{if $select.exportAdminPhone}"Admin Phone",{/if}
+{if $select.exportCategories} {if $category_data} {foreach $category_data as $cat} "{if $cat.parent_name}{$cat.parent_name}:{/if}{$cat.name}" {if !$cat@last},{/if} {/foreach} {/if} {/if}
+
+{foreach $events as $event}
+{if $select.exportId}"{$event.id}",{/if}
+{if $select.exportName}"{$event.name}",{/if}
+{if $select.exportMember}"{$event.ref_dest}",{/if}
+{if $select.exportStatus}"{$event.status.name}",{/if}
+{if $select.exportFeatured}"{$event.featured.value}",{/if}
+{if $select.exportIntro}"{$event.intro}",{/if}
+{if $select.exportDescr}"{$event.descr}",{/if}
+{if $select.exportFree}"{$event.free}",{/if}
+{if $select.exportNotes}"{$event.notes}",{/if}
+{if $select.exportLocationName}"{if $event.locations.name}{$event.locations.name}{/if}",{/if}
+{if $select.exportAddress}"{if $event.locations.address}{$event.locations.address}{/if}",{/if}
+{if $select.exportCity}"{if $event.locations.city.name}{$event.locations.city.name}{/if}",{/if}
+{if $select.exportState}"{if $event.locations.state.name}{$event.locations.state.name}{/if}",{/if}
+{if $select.exportZip}"{if $event.locations.zip}{$event.locations.zip}{/if}",{/if}
+{if $select.exportCountry}"{if $event.locations.country.name}{$event.locations.country.name}{/if}",{/if}
+{if $select.exportRegion}"{if $event.locations.region.name}{$event.locations.region.name}{/if}",{/if}
+{if $select.exportWebUrl}"{$event.url}",{/if}
+{if $select.exportTicketingUrl}"{$event.ticket_url}",{/if}
+{if $select.exportRegistrationUrl}"{$event.registration_url}",{/if}
+{if $select.exportContactName}"{$event.contact_name}",{/if}
+{if $select.exportContactEmail}"{$event.contact_email}",{/if}
+{if $select.exportContactPhone}"{$event.contact_phone}",{/if}
+{if $select.exportAdminName}"{$event.admin_name}",{/if}
+{if $select.exportAdminOrg}"{$event.admin_org}",{/if}
+{if $select.exportAdminEmail}"{$event.admin_email}",{/if}
+{if $select.exportAdminPhone}"{$event.admin_phone}",{/if}
+{if $select.exportCategories} {if $category_data} {foreach $category_data as $cat} {$cat_exists='""'} {foreach $event.categories as $t} {if $t.id == $cat.id}{$cat_exists='"Yes"'}{/if} {/foreach} {$cat_exists} {if !$cat@last},{/if} {/foreach} {/if} {/if}
+
+{/foreach}
+{else}No {$terms.term_member_plur_cap} Selected{/if}
diff --git a/views/admin/events/eventExportModal.html b/views/admin/events/eventExportModal.html
new file mode 100644 (file)
index 0000000..f665d1d
--- /dev/null
@@ -0,0 +1,123 @@
+<div id="exportEventsDialog" class="glm-dialog-box" title="Export Events">
+    <form id="exportForm" action="{$ajaxUrl}" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="action" value="glm_members_admin_ajax">
+        <input type="hidden" name="glm_action" value="eventsListExport">
+        <table class="glm-admin-table">
+            <tr><th>Show Archived Only: </th><td><input type="checkbox" name="filterArchived" {if $filterArchived}checked{/if}></td></tr>
+            <tr><th>Show Pending Only: </th><td><input type="checkbox" name="filterPending" {if $filterPending}checked{/if}></td></tr>
+            <tr><th>Show Featured Only: </th><td><input type="checkbox" name="filterFeatured" {if $filterFeatured}checked{/if}></td></tr>
+            <tr>
+                <th>Categories: </th>
+                <td>
+                    <select id="exportFilterCategories" name="filterCategories[]" multiple="multiple" size="1">
+                        {foreach from=$categories item=v}
+                            <option value="{$v.id}" data-parent="{$v.parent}"{if $v.selected} selected{/if}>
+                                {if $v.parent_id}&nbsp;&nbsp;&nbsp;&nbsp;{/if}{$v.name}
+                            </option>
+                        {/foreach}
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <th>Date Range Search: </th>
+                <td>
+                    <b>From Date: </b><br />
+                    <input type="text" name="fromDate" value="{$fromDate}" class="glm-form-text-input-short glm-date-input"><br />
+                    <b>To Date: </b><br />
+                    <input type="text" name="toDate" value="{$toDate}" class="glm-form-text-input-short glm-date-input"><br />
+                </td>
+            </tr>
+            <tr>
+                <th>Name Search:</th>
+                <td>
+                    <input id="glmEventsExportSearch" name="textSearch" value="{if $searchName}{$searchName}{/if}" />
+                </td>
+            </tr>
+            <tr>
+                <th>Fields to export: </th>
+                <td>
+                    <table padding="3">
+                        <tr>
+                            <td colspan="2"><a id="selectAllExportFields">Check All</a> / <a id="unselectAllExportFields">Uncheck All</a></td>
+                        </tr>
+                        <tr>
+                            <td class="exportFieldsTd">
+                                <input type="checkbox" name="exportId"> Account ID<br>
+                                <input type="checkbox" name="exportName" checked> Event Name<br>
+                                <input type="checkbox" name="exportMember" checked> {$terms.term_member_cap} Name<br>
+                                <input type="checkbox" name="exportStatus" checked> Status<br>
+                                <input type="checkbox" name="exportFeatured" checked> Featured <br>
+                                <input type="checkbox" name="exportCategories" checked> Categories <br>
+                                <input type="checkbox" name="exportIntro" checked> Intro <br>
+                                <input type="checkbox" name="exportDescr" checked> Description <br>
+                                <input type="checkbox" name="exportFree" checked> Free <br>
+                                <input type="checkbox" name="exportCost" checked> Cost <br>
+                                <input type="checkbox" name="exportNotes" checked> Notes <br>
+                            </td>
+                            <td class="exportFieldsTd">
+                                <input type="checkbox" name="exportLocationName" checked> Location Name <br>
+                                <input type="checkbox" name="exportAddress" checked> Address <br>
+                                <input type="checkbox" name="exportCity" checked> City <br>
+                                <input type="checkbox" name="exportState" checked> State <br>
+                                <input type="checkbox" name="exportZip" checked> ZIP / Postal Code <br>
+                                <input type="checkbox" name="exportCountry" checked> Country <br>
+                                <input type="checkbox" name="exportRegion" checked> Region <br>
+                                <input type="checkbox" name="exportWebUrl" checked> Web URL <br>
+                                <input type="checkbox" name="exportTicketingUrl" checked> Ticketing URL <br>
+                                <input type="checkbox" name="exportRegistrationUrl" checked> Registration URL <br>
+                            </td>
+                            <td class="exportFieldsTd">
+                                <input type="checkbox" name="exportContactName" checked> Contact Name <br>
+                                <input type="checkbox" name="exportContactPhone" checked> Contact Phone <br>
+                                <input type="checkbox" name="exportContactEmail" checked> Contact Email <br>
+                                <input type="checkbox" name="exportAdminName" checked> Admin Contact Name <br>
+                                <input type="checkbox" name="exportAdminOrg" checked> Admin Contact Organization <br>
+                                <input type="checkbox" name="exportAdminEmail" checked> Admin Contact Email <br>
+                                <input type="checkbox" name="exportAdminPhone" checked> Admin Contact Phone <br>
+
+                            </td>
+                        </tr>
+                    </table>
+                </td>
+            </tr>
+            <tr>
+                <th>Export to: </th>
+                <td>
+                    <input type="radio" name="type" value="csv" checked="checked"> Export to Spreadsheet (CSV)<br>
+                    <input type="radio" name="type" value="print"> Export for Print
+                </td>
+            </tr>
+        </table>
+        <a id="exportEventsCancel" class="button button-secondary glm-right">Cancel</a>
+        <input type="submit" value="Export" class="button button-primary">
+    </form>
+</div>
+
+<script>
+jQuery(document).ready(function($) {
+    // Setup for the modal box
+    $('#exportEventsDialog').dialog( {
+        autoOpen: false,
+        minWidth: 800,
+        dialogClass: 'glm-dialog-no-close'
+    } );
+    $('#exportEventsButton').click( function(){
+        $('#exportEventsDialog').dialog( 'open' );
+    } );
+    $('#exportEventsCancel').click( function(){
+        $('#exportEventsDialog').dialog( 'close' );
+    } );
+    $('#selectAllExportFields').click(function(){
+        $('.exportFieldsTd input[type="checkbox"]').each(function(){
+            $(this).prop('checked', true);
+        });
+    });
+    $('#unselectAllExportFields').click(function(){
+        $('.exportFieldsTd input[type="checkbox"]').each(function(){
+            $(this).prop('checked', false);
+        });
+    });
+    $('#exportFilterCategories').multiselect();
+
+});
+</script>
index 6a8ba1d..bc35a20 100644 (file)
@@ -6,11 +6,14 @@
 
 {if apply_filters('glm_members_permit_admin_events_index_add_event', true)}
     <h2 style="margin-bottom: 1em;">
-      {if $haveMember} {* This is if we're processing events for a specific member *}
-        <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=events&option=add&member={$memberID}" class="button button-secondary glm-button glm-right">Add A New Event</a>
-      {else}
-        <a href="{$thisUrl}?page={$thisPage}&glm_action=list&option=add" class="button button-secondary glm-button glm-right">Add A New Event</a>
-      {/if}
+        {if !$lockedToMember}
+            <div id="exportEventsButton" class="button button-secondary glm-button glm-right">Events Export</div>
+        {/if}
+        {if $haveMember} {* This is if we're processing events for a specific member *}
+            <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=events&option=add&member={$memberID}" class="button button-secondary glm-button glm-right">Add A New Event</a>
+        {else}
+            <a href="{$thisUrl}?page={$thisPage}&glm_action=list&option=add" class="button button-secondary glm-button glm-right">Add A New Event</a>
+        {/if}
         {if $eventDeleted}<span class="glm-notice glm-flash-updated glm-right">Event Deleted</span>{/if}
         {if $eventDeleteError}<span class="glm-error glm-flash-updated glm-right">Event Delete Error</span>{/if}
     </h2>
@@ -47,7 +50,7 @@
                 </span>
                 <span class="glm-nowrap">
                     <b>Show Archived Only: </b><input type="checkbox" id="filterArchived" name="filterArchived" class="listFilter"{if $filterArchived} checked{/if} style="margin-right: 1em;">
-                    <b>Show Pending Only: </b><input type="checkbox" id="filterPending" name="filterPending" class="listFilter"{if $filterPending} checked{/if} style="margin-right: 1em;">
+                    <b>Show Pending Only:  </b><input type="checkbox" id="filterPending" name="filterPending" class="listFilter"{if $filterPending} checked{/if} style="margin-right: 1em;">
                     <b>Show Featured Only: </b><input type="checkbox" id="filterFeatured" name="filterFeatured" class="listFilter"{if $filterFeatured} checked{/if} style="margin-right: 1em;">
                 </span>
                 <span class="glm-nowrap">
 
     </form>
 
-    <script type="text/javascript">
-        jQuery(document).ready(function($) {
+{if !$lockedToMember}
+    {include file='admin/events/eventExportModal.html'}
+{/if}
 
-            // Add Event Button Action
-            $('#addEventButton').click( function() {
-                window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=list&option=add";
-            });
+<script>
+    jQuery(document).ready(function($) {
 
-            // Date Input
-            $('.glm-date-input').datepicker();
+        // Add Event Button Action
+        $('#addEventButton').click( function() {
+            window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=list&option=add";
+        });
 
-            // 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);
+        // Date Input
+        $('.glm-date-input').datepicker();
 
-            // Filter triggers
+        // 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);
 
-            $("#filterArchived").on('click', function() {
-                $("#filterPending").attr('checked', false);
-                $('input[name=fromDate]').val('');
-            });
+        // Filter triggers
+
+        $("#filterArchived").on('click', function() {
+            $("#filterPending").attr('checked', false);
+            $('input[name=fromDate]').val('');
+        });
 
-            $("#filterPending").on('click', function() {
-                $("#filterArchived").attr('checked', false);
-            });
+        $("#filterPending").on('click', function() {
+            $("#filterArchived").attr('checked', false);
+        });
 /*
-            $(".listFilter" ).change( function() {
+        $(".listFilter" ).change( function() {
 
-                var filter = '';
+            var filter = '';
 
-                // Check for Archived filter
-                if ($("#filterArchived").attr('checked')) {
-                    filter = '&filterArchived=true';
-                }
+            // Check for Archived filter
+            if ($("#filterArchived").attr('checked')) {
+                filter = '&filterArchived=true';
+            }
 
-                // Check for Pending filter
-                if ($("#filterPending").attr('checked')) {
-                    filter = '&filterPending=true';
-                }
+            // Check for Pending filter
+            if ($("#filterPending").attr('checked')) {
+                filter = '&filterPending=true';
+            }
 
-                window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=list" + filter;
+            window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=list" + filter;
 
-                return false;
-            });
+            return false;
+        });
 */
-            /*
-             * Do autocomplete search for member
-             * label: What will be searched
-             * value: What will be displayed when selected
-             * id: Member id added so we can go to the member while showing what was selected
-             * Also note that autocomplete does not properly render HTML codes, so we
-             * "unescape" them for HTML in Smarty.
-             */
-
-             var availableTags = [
-    {foreach $namesList as $e}
-                { label: "{$e.name|replace:'"':"'"}", value: "{$e.name|replace:'"':"'"}", id: '{$e.id}' },
-    {/foreach}
-             ];
-
-             $( "#glmEventsSearch" ).autocomplete({
-                 source: availableTags,
-                 html: true,
-                 position: { my : "left top", at: "left bottom" },
-                 select: function( event, ui ) {
-                     var eventID = ui.item.id;
-                     window.location.replace("{$adminUrl}?page=glm-members-admin-menu-events-index&glm_action=list&option=edit&event=" + eventID );
-                 },
-                 response: function(event, ui) {
-                     if (!ui.content.length) {
-                         var noResult = { value:"",label:"No results found" };
-                         ui.content.push(noResult);
-                     }
+        /*
+         * Do autocomplete search for member
+         * label: What will be searched
+         * value: What will be displayed when selected
+         * id: Member id added so we can go to the member while showing what was selected
+         * Also note that autocomplete does not properly render HTML codes, so we
+         * "unescape" them for HTML in Smarty.
+         */
+
+         var availableTags = [
+        {foreach $namesList as $e}
+            { label: "{$e.name|replace:'"':"'"}", value: "{$e.name|replace:'"':"'"}", id: '{$e.id}' },
+        {/foreach}
+         ];
+
+         $( "#glmEventsSearch" ).autocomplete({
+             source: availableTags,
+             html: true,
+             position: { my : "left top", at: "left bottom" },
+             select: function( event, ui ) {
+                 var eventID = ui.item.id;
+                 window.location.replace("{$adminUrl}?page=glm-members-admin-menu-events-index&glm_action=list&option=edit&event=" + eventID );
+             },
+             response: function(event, ui) {
+                 if (!ui.content.length) {
+                     var noResult = { value:"",label:"No results found" };
+                     ui.content.push(noResult);
                  }
-             });
+             }
+         });
+         $('#glmEventsExportSearch').autocomplete({
+             source: availableTags,
+                html: true,
+             position: { my : "left top", at: "left bottom" },
+             response: function(event, ui) {
+                 if (!ui.content.length) {
+                     var noResult = { value:"",label:"No results found" };
+                     ui.content.push(noResult);
+                 }
+             }
+         });
 
-             // Expand multi-select on hover
-             $('#filterCategories').multiselect();
+         // Expand multi-select on hover
+         $('#filterCategories').multiselect();
 
-        });
-    </script>
+    });
+</script>
 
 
 {include file='admin/footer.html'}