WIP for list and edit obits page.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 17 Feb 2017 22:04:14 +0000 (17:04 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 17 Feb 2017 22:04:14 +0000 (17:04 -0500)
Work on the list and index models for listing and editing obits.

classes/data/dataObits.php
models/admin/obits/index.php [new file with mode: 0644]
models/admin/obits/list.php [new file with mode: 0644]
setup/adminMenus.php
setup/databaseScripts/create_database_V0.0.1.sql
setup/validActions.php
views/admin/obits/edit.html [new file with mode: 0644]
views/admin/obits/header.html [new file with mode: 0644]
views/admin/obits/index.html [new file with mode: 0644]
views/admin/obits/list.html [new file with mode: 0644]

index e607f73..f29e397 100644 (file)
@@ -24,7 +24,7 @@
  *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
  *          Exp $
  */
-class GlmDataObitsManagement extends GlmDataAbstract
+class GlmDataObits extends GlmDataAbstract
 {
 
     /**
@@ -139,6 +139,7 @@ class GlmDataObitsManagement extends GlmDataAbstract
             'b_year' => array(
                 'field'    => 'b_year',
                 'type'     => 'integer',
+                'default'  => '',
                 'required' => true,
                 'use'      => 'a',
             ),
@@ -146,13 +147,15 @@ class GlmDataObitsManagement extends GlmDataAbstract
             'b_yr_range' => array(
                 'field'   => 'b_yr_range',
                 'type'    => 'integer',
-                'default' => true,
+                'default'  => '',
+                'required' => true,
                 'use'     => 'a',
             ),
 
             'd_year' => array(
                 'field'    => 'd_year',
                 'type'     => 'integer',
+                'default'  => '',
                 'required' => true,
                 'use'      => 'a',
             ),
@@ -160,6 +163,7 @@ class GlmDataObitsManagement extends GlmDataAbstract
             'd_yr_range' => array(
                 'field'    => 'd_yr_range',
                 'type'     => 'integer',
+                'default'  => '',
                 'required' => false,
                 'use'      => 'a',
             ),
@@ -250,9 +254,6 @@ class GlmDataObitsManagement extends GlmDataAbstract
      *
      * Perform post-processing for all result entries.
      *
-     * In this case we're using it to append an array of category
-     * data to each member result and also sort by member name.
-     *
      * @param array $r Array of field result data for a single entry
      * @param string $a Action being performed (l, i, g, ...)
      *
@@ -264,6 +265,28 @@ class GlmDataObitsManagement extends GlmDataAbstract
         return $r;
     }
 
-}
 
-?>
+    /**
+     * Get ID/Name list
+     *
+     * @param string $where
+     *
+     * @return array ID/Name pairs
+     */
+    public function getIdName($where = 'true')
+    {
+        $savedFields = $this->fields;
+
+        $this->fields = array(
+            'id' => $savedFields['id'],
+            'last_name' => $savedFields['last_name']
+        );
+
+        $r = $this->getList($where);
+
+        $this->fields = $savedFields;
+        return $r;
+
+    }
+
+}
diff --git a/models/admin/obits/index.php b/models/admin/obits/index.php
new file mode 100644 (file)
index 0000000..374a916
--- /dev/null
@@ -0,0 +1,113 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Obits Dashboard
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+// Load Obits data abstract
+require_once GLM_MEMBERS_OBITS_PLUGIN_CLASS_PATH.'/data/dataObits.php';
+
+class GlmMembersAdmin_obits_index extends GlmDataObits
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Obit ID
+     *
+     * @var $obitID
+     * @access public
+     */
+    public $obitID = false;
+
+    /**
+     * 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 __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        /*
+         * Run constructor for the Obits data class
+         *
+         * Note, the third parameter is a flag that indicates to the Contacts
+         * data class that it should flag a group of fields as 'view_only'.
+         */
+        parent::__construct(false, false, true);
+
+    }
+
+    public function modelAction($actionData = false)
+    {
+
+        $numbObits       = 0;
+        $namesList       = false;
+
+        // Get number of obits
+        $numbObits = $this->getStats();
+
+        // Compile template data
+        $templateData = array(
+            'numbObits'      => $numbObits,
+            'namesList'      => $namesList,
+        );
+             // Return status, any suggested view, and any data to controller
+        return array(
+            'status'        => true,
+            'modelRedirect' => false,
+            'view'          => 'admin/obits/index.html',
+            'data'          => $templateData
+        );
+
+    }
+
+
+}
diff --git a/models/admin/obits/list.php b/models/admin/obits/list.php
new file mode 100644 (file)
index 0000000..09f0334
--- /dev/null
@@ -0,0 +1,324 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Obits List
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+// Load Contacts data class
+require_once GLM_MEMBERS_OBITS_PLUGIN_CLASS_PATH.'/data/dataObits.php';
+
+class GlmMembersAdmin_obits_list extends GlmDataObits
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Obit ID
+     *
+     * @var $obitID
+     * @access public
+     */
+    public $obitID = false;
+
+    /**
+     * Constructor
+     *
+     * This constructor performs the work for this model. This model returns
+     * an array containing the following.
+     *
+     * 'status'
+     *
+     * True if successful and false if there was a fatal failure.
+     *
+     * 'view'
+     *
+     * A suggested view name that the controller 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 __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        /*
+         * Run constructor for the Contacts data class
+         *
+         * Note, the third parameter is a flag that indicates to the Contacts
+         * data class that it should flag a group of fields as 'view_only'.
+         */
+        parent::__construct(false, false, true);
+
+    }
+
+    public function modelAction($actionData = false)
+    {
+
+        $numbObits       = 0;
+        $option          = 'list';
+        $obits           = false;
+        $haveObits       = false;
+        $obit            = false;
+        $haveObit        = false;
+        $this->obitID    = false;
+        $obitUpdated     = false;
+        $obitUpdateError = false;
+        $obitAdded       = false;
+        $obitAddError    = false;
+        $view            = 'list';
+        $fromDate        = false;
+        $toDate          = 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;
+        $obitDeleted     = false;
+        $obitDeleteError = false;
+
+        // Get any provided option
+        if (isset($_REQUEST['option'])) {
+            $option = $_REQUEST['option'];
+        }
+
+        // Get obit ID if supplied
+        if (isset($_REQUEST['obit'])) {
+
+            // Make sure it's numeric
+            $this->obitID = ($_REQUEST['obit'] - 0);
+
+            if ($this->obitID <= 0) {
+                $this->obitID = false;
+            }
+
+        }
+
+        // Check for specific_dates submission
+
+        // Do selected option
+        switch ($option) {
+
+            case 'add':
+
+                $obit = $this->newEntry();
+
+                $view = 'edit';
+
+                break;
+
+            case 'insert':
+
+                $obit = $this->insertEntry();
+
+                $this->obitID = $obit['fieldData']['id'];
+
+                if ($obit['status']) {
+                    $haveObit = true;
+                    $obitAdded = true;
+
+                    // Update created timestamp and name slug for URLs
+                    $this->updateTimestamp('created', $this->obitID);
+                    $this->updateSlug($this->obitID);
+
+                    // Get this again so we have the created date
+                    $obit = $this->editEntry($this->obitID);
+
+                    $option = 'edit';
+                    $obitAdded = true;
+
+                } else {
+                    $option = 'add';
+                    $obitAddError = true;
+                }
+
+                $view = 'edit';
+
+                break;
+
+            case 'edit':
+
+
+
+                $obit = $this->editEntry($this->obitID);
+
+                // If we have a good obit
+                if ($obit['status']) {
+                    $haveObit = true;
+                }
+
+                $view = 'edit';
+                break;
+
+            case 'update':
+
+                // Try to update this obit
+                $obit = $this->updateEntry($this->obitID);
+
+                // Check if that was successful
+                if ($obit['status']) {
+                    $obitUpdated = true;
+
+                    $obit = $this->editEntry($this->obitID);
+                } else {
+                    $obitUpdateError = true;
+                }
+
+                $haveObit = true;
+                $view     = 'edit';
+
+                break;
+
+            case 'delete':
+
+                $obit = $this->deleteObit($this->obitID);
+
+                if ($obit) {
+                    $obitDeleted = true;
+                } else {
+                    $obitDeleteError = true;
+                }
+
+            case 'list':
+            default:
+
+                $where = 'true';
+
+                // Check if we have a Text Search string
+                if (isset($_REQUEST['textSearch']) && trim($_REQUEST['textSearch']) != '') {
+                    $textSearch = trim($_REQUEST['textSearch']);
+                    $where .= " AND last_name LIKE '%$textSearch%'";
+                }
+
+                // Get the total number of obits listed
+                $numbObits = $this->getStats($where);
+
+                // If the number of obits is less than a page, don't do paging
+                if ($numbObits <= $limit) {
+                    $paging = false;
+                }
+
+                // Get full list of names matching this where clause for search box
+                $namesList = $this->getIdName($where);
+
+                // Check if we're doing paging
+                if (isset($_REQUEST['pageSelect'])) {
+
+                    // If request is for Next
+                    if ($_REQUEST['pageSelect'][0] == 'N') {
+                        $newStart = $_REQUEST['nextStart'] - 0;
+
+                    // Otherwise it must be Previous
+                    } else {
+                        $newStart = $_REQUEST['prevStart'] - 0;
+                    }
+
+                    if ($newStart > 0) {
+                        $start = $newStart;
+                    }
+                }
+
+                // Get the list of obits and determine number of obits in list
+                $obitsResult = $this->getList($where, 'last_name', true, 'id', $start, $limit);
+
+                // Get paging results
+                $numbDisplayed = $obitsResult['returned'];
+                $lastDisplayed = $obitsResult['last'];
+                if ($start == 1) {
+                    $prevStart = false;
+                } else {
+                    $prevStart = $start - $limit;
+                    if ($start < 1) {
+                        $start = 1;
+                    }
+                }
+                if ($obitsResult['returned'] == $limit) {
+                    $nextStart = $start + $limit;
+                }
+
+                // since we're doing paging, we have to break out just the obits data
+                $obits = $obitsResult['list'];
+                if (count($obits)>0) {
+                    $haveObits = true;
+                }
+                unset($obitsResult);
+
+                break;
+
+        }
+
+        $templateData = array(
+            'option'          => $option,
+            'obits'           => $obits,
+            'haveObits'       => $haveObits,
+            'obit'            => $obit,
+            'haveObit'        => $haveObit,
+            'obitID'          => $this->obitID,
+            'obitUpdated'     => $obitUpdated,
+            'obitUpdateError' => $obitUpdateError,
+            'obitAdded'       => $obitAdded,
+            'obitAddError'    => $obitAddError,
+            'numbObits'       => $numbObits,
+            'fromDate'        => $fromDate,
+            'toDate'          => $toDate,
+            'numbDisplayed'   => $numbDisplayed,
+            'lastDisplayed'   => $lastDisplayed,
+            'paging'          => $paging,
+            'prevStart'       => $prevStart,
+            'nextStart'       => $nextStart,
+            'start'           => $start = 1,
+            'limit'           => $limit,
+            'namesList'       => $namesList,
+            'obitDeleted'      => $obitDeleted,
+            'obitDeleteError'  => $obitDeleteError,
+
+        );
+
+        // Return status, any suggested view, and any data to controller
+        return array(
+            'status'        => true,
+            'modelRedirect' => false,
+            'view'          => "admin/obits/$view.html",
+            'data'          => $templateData
+        );
+
+    }
+
+
+}
index 32a56c5..57f7142 100644 (file)
@@ -55,8 +55,8 @@ add_submenu_page(
     'Obits',
     'Obits',
     'edit_posts',
-    'glm-members-admin-menu-obits-list',
-    function(){$this->controller('obits', 'list');}
+    'glm-members-admin-menu-obits-index',
+    function(){$this->controller('obits');}
 );
 add_submenu_page(
     'glm-members-admin-menu-members',
index eff0892..49e7fde 100644 (file)
@@ -17,10 +17,10 @@ CREATE TABLE {prefix}obits (
   id INT NOT NULL AUTO_INCREMENT,
   last_name TINYTEXT NOT NULL DEFAULT '',
   first_mid TINYTEXT NOT NULL DEFAULT '',
-  b_year TINYINT NOT NULL DEFAULT 0,                    -- Birth Year
-  b_yr_range TINYINT NOT NULL DEFAULT 0,                -- Birth Year Range (use the start of the decade like 2010 or 2000)
-  d_year TINYINT NOT NULL DEFAULT 0,                    -- Death Year
-  d_yr_range TINYINT NOT NULL DEFAULT 0,                -- Death Year Range (use the start of the decade like 2010 or 2000)
+  b_year SMALLINT NOT NULL DEFAULT 0,                    -- Birth Year
+  b_yr_range SMALLINT NOT NULL DEFAULT 0,                -- Birth Year Range (use the start of the decade like 2010 or 2000)
+  d_year SMALLINT NOT NULL DEFAULT 0,                    -- Death Year
+  d_yr_range SMALLINT NOT NULL DEFAULT 0,                -- Death Year Range (use the start of the decade like 2010 or 2000)
   maiden_other TINYTEXT NULL DEFAULT '',
   spouse_partner TINYTEXT NULL DEFAULT '',
   obit_article TINYTEXT NULL DEFAULT '',
index 6a97e8c..999cc5e 100644 (file)
 
 $glmMembersObitsAddOnValidActions = array(
     'adminActions' => array(
+        'obits' => array(
+            'index' => GLM_MEMBERS_OBITS_PLUGIN_SLUG,
+            'list'  => GLM_MEMBERS_OBITS_PLUGIN_SLUG,
+        ),
     ),
     'frontActions' => array(
     )
 );
 
-?>
\ No newline at end of file
+?>
diff --git a/views/admin/obits/edit.html b/views/admin/obits/edit.html
new file mode 100644 (file)
index 0000000..e972c8d
--- /dev/null
@@ -0,0 +1,260 @@
+{include file='admin/obits/header.html'}
+
+{if apply_filters('glm_members_permit_admin_member_obit', true) && ($option == 'add' || $haveObit)}
+
+    <a href="{$thisUrl}?page={$thisPage}&glm_action=list" class="button button-secondary glm-button glm-right">Return to Obits List</a>
+
+  {if $option == 'edit' || $option == 'update'}
+    <a id="deleteObitButton" class="button button-secondary glm-button glm-right">Delete this Obit</a>
+    <h2>Edit Obit
+  {else}
+    <h2>Add new Obit
+  {/if}
+        &nbsp;&nbsp;&nbsp;
+        {if $obitUpdated}<span class="glm-notice glm-flash-updated">Obit Updated</span>{/if}
+        {if $obitUpdateError}<span class="glm-error glm-flash-updated">Obit Update Error</span>{/if}
+        {if $obitAdded}<span class="glm-notice glm-flash-updated">Obit Added</span>{/if}
+        {if $obitAddError}<span class="glm-error glm-flash-updated">Obit Add Error</span>{/if}
+    </h2>
+
+  {if $obitUpdateError || $obitAddError}
+    <h1 class="glm-error">NOTICE: Your obit has not yet been submitted.<br>Please select the tabs indicating a problem, correct the indicated fields and resubmit.</h1>
+  {else}
+  {/if}
+
+    <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="glm_action" value="list">
+
+    {if $haveObit}
+        <input type="hidden" name="option" value="update">
+        <input type="hidden" name="obit" value="{$obit.fieldData.id}">
+    {else}
+        <input type="hidden" name="option" value="insert">
+    {/if}
+
+       <h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
+            <a id="glm-obit-descr" data-show-table="glm-table-descr" class="glm-obit-tab nav-tab nav-tab-active">Obit</a>
+        </h2>
+
+    <table id="glm-table-descr" class="glm-admin-table glm-obit-table">
+        <tr>
+            <th {if $obit.fieldRequired.last_name}class="glm-required"{/if}>Last Name:</th>
+            <td {if $obit.fieldFail.last_name}class="glm-form-bad-input" data-tabid="glm-obit-descr"{/if}>
+                <input type="text" name="last_name" value="{$obit.fieldData.last_name}" class="glm-form-text-input-small">
+                {if $obit.fieldFail.last_name}<p>{$obit.fieldFail.last_name}</p>{/if}<br>
+            </td>
+        </tr>
+        <tr>
+            <th {if $obit.fieldRequired.first_mid}class="glm-required"{/if}>First and Middle Name:</th>
+            <td {if $obit.fieldFail.first_mid}class="glm-form-bad-input" data-tabid="glm-obit-descr"{/if}>
+                <input type="text" name="first_mid" value="{$obit.fieldData.first_mid}" class="glm-form-text-input-small">
+                {if $obit.fieldFail.first_mid}<p>{$obit.fieldFail.first_mid}</p>{/if}<br>
+            </td>
+        </tr>
+        <tr>
+            <th {if $obit.fieldRequired.b_year}class="glm-required"{/if}>Birth Year:</th>
+            <td {if $obit.fieldFail.b_year}class="glm-form-bad-input" data-tabid="glm-obit-descr"{/if}>
+                <input type="text" name="b_year" value="{$obit.fieldData.b_year}" class="glm-form-text-input-small">
+                {if $obit.fieldFail.b_year}<p>{$obit.fieldFail.b_year}</p>{/if}<br>
+            </td>
+        </tr>
+        <tr>
+            <th {if $obit.fieldRequired.b_yr_range}class="glm-required"{/if}>Birth Year Range:</th>
+            <td {if $obit.fieldFail.b_yr_range}class="glm-form-bad-input" data-tabid="glm-obit-descr"{/if}>
+                <input type="text" name="b_yr_range" value="{$obit.fieldData.b_yr_range}" class="glm-form-text-input-small">
+                {if $obit.fieldFail.b_yr_range}<p>{$obit.fieldFail.b_yr_range}</p>{/if}<br>
+            </td>
+        </tr>
+        <tr>
+            <th {if $obit.fieldRequired.d_year}class="glm-required"{/if}>Death Year:</th>
+            <td {if $obit.fieldFail.d_year}class="glm-form-bad-input" data-tabid="glm-obit-descr"{/if}>
+                <input type="text" name="d_year" value="{$obit.fieldData.d_year}" class="glm-form-text-input-small">
+                {if $obit.fieldFail.d_year}<p>{$obit.fieldFail.d_year}</p>{/if}<br>
+            </td>
+        </tr>
+        <tr>
+            <th {if $obit.fieldRequired.d_yr_range}class="glm-required"{/if}>Death Year Range:</th>
+            <td {if $obit.fieldFail.d_yr_range}class="glm-form-bad-input" data-tabid="glm-obit-descr"{/if}>
+                <input type="text" name="d_yr_range" value="{$obit.fieldData.d_yr_range}" class="glm-form-text-input-small">
+                {if $obit.fieldFail.d_yr_range}<p>{$obit.fieldFail.d_yr_range}</p>{/if}<br>
+            </td>
+        </tr>
+    </table>
+
+        <input id="updateObit" type="submit" value="{if $haveObit}Update Obit{else}Save New Obit{/if}">
+
+    </form>
+
+{else} <!-- Can just display -->
+
+    <h3>Sorry, no obit found or permission not granted.</h3>
+
+{/if}
+
+    <!-- Delete Obit Dialog Box -->
+
+    <div id="deleteObitDialog" class="glm-dialog-box" title="Delete Obit">
+        <center>
+            <p><a id="deleteObitCancel" class="button button-primary">Cancel</a></p>
+            <p><input id="deleteObitSubmit" type="submit" value="Delete this obit"></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 Obit" button above will
+                delete all of the data and images associated with this obit.
+                </span>
+            </p>
+            <p>
+                <span class="glm-error">
+                    Once deleted, this information will no longer be available and cannot be retrieved!
+                    If you are unsure that you want to completely remove this data, consider changing the status
+                    of this obit to "Archived" instead.
+                </span>
+            </p>
+        </div>
+    </div>
+    <script type="text/javascript">
+        jQuery(document).ready(function($) {
+
+            var fullCalendarLoaded = false;
+            var recurrencesInited = false;
+            var locationsInited = false;
+
+            /*
+             * Edit area tabs
+             */
+            $('.glm-obit-tab').click( function() {
+
+                // Clear tabl highlights and hide all tables
+                $('.glm-obit-tab').removeClass('nav-tab-active');
+                $('.glm-obit-table').addClass('glm-hidden');
+
+                // Highlight selected tab
+                $(this).addClass('nav-tab-active');
+
+                // Show selected table
+                var table = $(this).attr('data-show-table');
+                $('#' + table).removeClass('glm-hidden');
+
+                if (table == 'glm-table-recurrence' && !recurrencesInited) {
+                    initRecurrence();
+                    recurrencesInited = true;
+                }
+
+                if (table == 'glm-table-location') {
+
+                    if (!locationsInited) {
+
+                        // Make sure there's at least one location
+                        {if !$locations}
+                                addNewLocationForm();
+                        {/if}
+
+                        initLocations();
+                        initNewCity();
+                        locationsInited = true;
+
+                    }
+
+                }
+
+                // Count remaining characters in field
+                $('.glm-char-count').keyup( function() {
+                    glmCharsRemaining($(this));
+                });
+
+            });
+
+            /*
+             * General Obit Actions
+             */
+
+            // Add Obit Button Action
+            $('#addObitButton').click( function() {
+                window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=list&option=add";
+            });
+
+    {if $haveObit}
+            // Delete Obit dialog
+            $("#deleteObitDialog").dialog({
+                autoOpen: false,
+                minWidth: 400,
+                dialogClass: "glm-dialog-no-close"
+            });
+            $('#deleteObitButton').click( function() {
+                $('#deleteObitDialog').dialog('open');
+            });
+            $('#deleteObitCancel').click( function() {
+                $("#deleteObitDialog").dialog("close");
+            });
+            $('#deleteObitSubmit').click( function() {
+                window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=list&option=delete&obit={$obit.fieldData.id}");
+            });
+    {/if}
+
+            // Init handling click to delete specified date
+            function initDateDelete() {
+                $('.recur-spec-date-delete').unbind();
+                $('.recur-spec-date-delete').on('click', function() {
+                    if (confirm("Do you want to delete this date?")) {
+                        $(this).remove();
+                        glmPageUpdateRequired();
+                    }
+                });
+            }
+
+            /*
+             * Check for bad input or input changes
+             */
+
+            // Check for any field errors and if found change related tab to error color.
+            $('.glm-form-bad-input').each( function(index) {
+
+                tab = $(this).attr('data-tabid');
+
+                if (!$('#' + tab).hasClass('glm-bad-input-area')) {
+                    $('#' + tab).addClass('glm-bad-input-area');
+                }
+            });
+
+            // Check for most input changes
+            $('input, textarea, select').on( 'change', function() {
+                glmPageUpdateRequired();
+            });
+
+            /*
+             * Checks for leaving the page
+             */
+            var glmSubmitRequired = false;
+
+        {if $obitUpdateError}
+            glmPageUpdateRequired();
+        {/if}
+            // Flag submit button when updates are required.
+            function glmPageUpdateRequired() {
+                $('#updateObit').addClass('glm-bad-input-area');
+                glmSubmitRequired = true;
+            }
+            // When submit button is clicked, disable the beforeunload message
+            $('#updateObit').on('click', function() {
+                glmSubmitRequired = false;
+                return true;
+            });
+
+            // If submit is required and we're laving the page, alert the user
+            $(window).bind('beforeunload', function() {
+                if (glmSubmitRequired) {
+
+                    return true;
+                }
+            });
+
+            // 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);
+
+        });
+    </script>
+
+
+{include file='admin/footer.html'}
diff --git a/views/admin/obits/header.html b/views/admin/obits/header.html
new file mode 100644 (file)
index 0000000..b9b9bca
--- /dev/null
@@ -0,0 +1,9 @@
+<div class="wrap">
+    <h2>All Obits</h2>
+    <h2 class="nav-tab-wrapper">
+        <a href="{$thisUrl}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">Dashboard</a>
+        <a href="{$thisUrl}?page=glm-members-admin-menu-obits-list&aoption=list" class="nav-tab{if $thisAction==list} nav-tab-active{/if}">Obit List</a>
+    </h2>
+    <div id="glm-admin-content-container">
+
+
diff --git a/views/admin/obits/index.html b/views/admin/obits/index.html
new file mode 100644 (file)
index 0000000..b37b2fc
--- /dev/null
@@ -0,0 +1,71 @@
+{include file='admin/obits/header.html'}
+
+{if apply_filters('glm_members_permit_admin_obits_index_add_obit', true)}
+    <a href="{$thisUrl}?page={$thisPage}&glm_action=list&option=add" class="button button-primary glm-button glm-right">Add A New Obit</a>
+{/if}
+
+    <table class="glm-admin-table">
+        <tr>
+            <td colspan="2" align="">
+                <input  id="glmObitsList" type="text" id="autoTest" style="margin-left: 2em;">
+                <span class="glm-left">Obits Search:</span>
+            </td>
+        </tr>
+
+{if $numbObits == 0}
+        <tr><td colspan="2">&nbsp;</td></tr>
+        <tr>
+           <th> <span class="glm-error">You do not have any obits listed.</span></th>
+            <td><a href="{$thisUrl}?page={$thisPage}&glm_action=list&option=add">Click here to create your first obit.</a></td>
+        </tr>
+{/if}
+    </table>
+
+    <table class="glm-admin-table">
+        <tr><th>Number of Obits Listed: </th><td>{$numbObits}</td></tr>
+    </table>
+
+{if $namesList}
+    <script type="text/javascript">
+        jQuery(document).ready(function($) {
+
+            /*
+             * Do autocomplete search for obit
+             * label: What will be searched
+             * value: What will be displayed when selected
+             * id: Member id added so we can go to the obit 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}
+             ];
+
+             $( "#glmObitsList" ).autocomplete({
+                 source: availableTags,
+                 html: true,
+                 select: function( obit, ui ) {
+                     var obitID = ui.item.id;
+                {if $lockedToMember}
+                     window.location.replace("{$adminUrl}?page=glm-members-admin-menu-obits-list&glm_action=list&option=edit&obit=" + obitID );
+                {else}
+                     window.location.replace("{$adminUrl}?page=glm-members-admin-menu-obits-index&glm_action=list&option=edit&obit=" + obitID );
+                {/if}
+                 },
+                 response: function(obit, ui) {
+                     if (!ui.content.length) {
+                         var noResult = { value:"",label:"No results found" };
+                         ui.content.push(noResult);
+                     }
+                 }
+             });
+
+        });
+
+    </script>
+{/if}
+
+{include file='admin/footer.html'}
+
diff --git a/views/admin/obits/list.html b/views/admin/obits/list.html
new file mode 100644 (file)
index 0000000..043519b
--- /dev/null
@@ -0,0 +1,163 @@
+{include file='admin/obits/header.html'}
+
+{if apply_filters('glm_members_permit_admin_obits_index_add_obit', true)}
+    <h2 style="margin-bottom: 1em;">
+        <a href="{$thisUrl}?page={$thisPage}&glm_action=list&option=add" class="button button-secondary glm-button glm-right">Add A New Obit</a>
+        {if $obitDeleted}<span class="glm-notice glm-flash-updated glm-right">Obit Deleted</span>{/if}
+        {if $obitDeleteError}<span class="glm-error glm-flash-updated glm-right">Obit Delete Error</span>{/if}
+    </h2>
+{/if}
+
+    <form action="{$thisUrl}?page={$thisPage}" method="post" id="searchForm">
+
+        <input type="hidden" name="prevStart" value="{$prevStart}">
+        <input type="hidden" name="nextStart" value="{$nextStart}">
+        <input type="hidden" name="limit" value="{$limit}">
+        <div class="">
+            <p>
+                <span class="glm-nowrap">
+                    <b>From Date: </b><input type="text" name="fromDate" value="{$fromDate}" class="glm-form-text-input-short glm-date-input">
+                    <b>To Date: </b><input type="text" name="toDate" value="{$toDate}" class="glm-form-text-input-short glm-date-input">
+                </span>
+                <span class="glm-nowrap">
+                    <b>Text Search: </b><input  id="glmObitsSearch" name="textSearch" type="text" id="autoTest">
+                    <input type="submit" value="Submit">
+                </span>
+            <p>
+        </div>
+        <br clear="all">
+
+    <p><b>Total found:</b> {$numbObits}&nbsp;&nbsp;</p>
+
+
+    {if $paging}
+        <input type="Submit" name="pageSelect" value="Previous {$limit} Obits" class="button button-secondary glm-button"{if !$prevStart} disabled{/if}>
+        <input type="Submit" name="pageSelect" value="Next {$limit} Obits" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>
+    {/if}
+
+        <table class="wp-list-table striped glm-admin-table">
+            <thead>
+                <tr>
+                    <th>ID</th>
+                    <th>Obit Name</th>
+                    <th>{$terms.term_member_cap}</th>
+                    <th>Status</th>
+                    <th>First Date</th>
+                    <th>Last Date</th>
+                    <th></th>
+                </tr>
+            </thead>
+            <tbody>
+    {if $haveObits}
+        {assign var="i" value="0"}
+        {foreach $obits as $e}
+            {if $i++ is odd by 1}
+                <tr>
+            {else}
+                <tr class="alternate">
+            {/if}
+                    <td>
+                        {$e.id}
+                    </td>
+                    <td class="glm-nowrap">
+                        <a href="{$thisUrl}?page={$thisPage}&glm_action=list&option=edit&obit={$e.id}">{$e.name}</a>
+                    </td>
+                    <td class="glm-nowrap">
+                        {$e.ref_dest}
+                    </td>
+                    <td class="glm-nowrap">
+                        {$e.status.name}
+                    </td>
+                    <td>
+                        {$e.firstDate}
+                    </td>
+                    <td>
+                        {$e.lastDate}
+                    </td>
+                    <td>
+                        <a href="{$siteBaseUrl}obit-detail/{$e.name_slug}/" target="_blank">View Obit</a>
+                    </td>
+                </tr>
+        {/foreach}
+    {else}
+                <tr class="alternate"><td colspan="2">(no obits listed)</td></tr>
+    {/if}
+            </tbody>
+        </table>
+
+    {if $paging}
+        <input type="Submit" name="pageSelect" value="Previous {$limit} Obits" class="button button-secondary glm-button"{if !$prevStart} disabled{/if}>
+        <input type="Submit" name="pageSelect" value="Next {$limit} Obits" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>
+    {/if}
+
+    </form>
+
+    <script type="text/javascript">
+        jQuery(document).ready(function($) {
+
+            // Add Obit Button Action
+            $('#addObitButton').click( function() {
+                window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=list&option=add";
+            });
+
+            // Date Input
+            $('.glm-date-input').datepicker();
+
+            // 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);
+
+            // Filter triggers
+
+            $(".listFilter" ).change( function() {
+
+                var filter = '';
+
+                // Check for Pending filter
+                if ($("#filterPending").attr('checked')) {
+                    filter = '&filterPending=true';
+                }
+
+                window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=list" + filter;
+
+                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}
+             ];
+
+             $( "#glmObitsSearch" ).autocomplete({
+                 source: availableTags,
+                 html: true,
+                 position: { my : "right top", at: "right bottom" },
+                 select: function( obit, ui ) {
+                     var obitID = ui.item.id;
+                     window.location.replace("{$adminUrl}?page=glm-members-admin-menu-obits-index&glm_action=list&option=edit&obit=" + obitID );
+                 },
+                 response: function(obit, ui) {
+                     if (!ui.content.length) {
+                         var noResult = { value:"",label:"No results found" };
+                         ui.content.push(noResult);
+                     }
+                 }
+             });
+
+             // Expand multi-select on hover
+             $('#filterCategories').multiselect();
+
+        });
+    </script>
+
+
+{include file='admin/footer.html'}