added newspaper settings data, to CRUD the newspaper names associated with the
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 2 Mar 2017 17:58:52 +0000 (12:58 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 2 Mar 2017 17:58:52 +0000 (12:58 -0500)
obits data. Added a function in class/supportFunctions.php getObitYearRange
that takesa a year range and generates a list of date ranges for the obits views

classes/supportFunctions.php [new file with mode: 0644]
defines.php
models/admin/obits/list.php
views/admin/obits/edit.html

diff --git a/classes/supportFunctions.php b/classes/supportFunctions.php
new file mode 100644 (file)
index 0000000..efd0236
--- /dev/null
@@ -0,0 +1,131 @@
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Obits Support function class
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package  GLM Member-DB
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: dataAddedInfoFields.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**
+ * GlmSupportFunctionsClass
+ *
+ * PHP version 5
+ *
+ * @category Data
+ * @package GLM Member DB
+ * @author  Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ *          @release SVN: $Id: dataAddedInfoFields.php,v 1.0 2011/01/25 19:31:47 cscott
+ *          Exp $
+ */
+class GlmSupportFunctions
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Data Table Name
+     *
+     * @var $table
+     * @access public
+     */
+    public $table;
+    /**
+     * Field definitions
+     *
+     * 'type' is type of field as defined by the application
+     * text Regular text field
+     * pointer Pointer to an entry in another table
+     * 'filters' is the filter name for a particular filter ID in PHP filter
+     * functions
+     * See PHP filter_id()
+     *
+     * 'use' is when to use the field
+     * l = List
+     * g = Get
+     * n = New
+     * i = Insert
+     * e = Edit
+     * u = Update
+     * d = Delete
+     * a = All
+     *
+     * @var $ini
+     * @access public
+     */
+    public $fields = false;
+
+    /**
+     * Constructor
+     *
+     * @param object $d database connection
+     * @param array $config Configuration array
+     * @param bool $limitedEdit Flag to say indicate limited edit requested
+     *
+     * @return void
+     * @access public
+     */
+    public function __construct($wpdb, $config, $limitedEdit = false)
+    {
+
+        // If this class is not being extended along with existing $wpdb and $config
+        if (!$this->wpdb) {
+
+            // Save WordPress Database object
+            $this->wpdb = $wpdb;
+
+            // Save plugin configuration object
+            $this->config = $config;
+
+        }
+
+     
+    }
+     /**
+     * getObitYearRange
+     *
+     * @param year range starting date
+     *
+     * @return array of date ranges
+     * @access public
+     */
+    
+    public function getObitYearRange($start){
+         
+        $start_range = $start;
+
+        $current = date('Y');
+        
+        for($start_range; $start_range <= $current; $start_range += 10){
+            $end_calc = $start_range + 9;
+            if($end_calc <= $current){
+                $end = $end_calc;
+            } else {
+                $end = 'Present';
+            }
+            $ranges[] = array('start' => $start_range, 'end' => $end);
+        }
+            return array_reverse( $ranges );
+    }
+
+}
+
+?>
\ No newline at end of file
index 0f8f02d..ff235ee 100644 (file)
@@ -62,3 +62,8 @@ $pluginsPath = str_replace(GLM_MEMBERS_OBITS_PLUGIN_SLUG, '', GLM_MEMBERS_OBITS_
 define('GLM_MEMBERS_OBITS_MAIN_PLUGIN_PATH', $pluginsPath.'/glm-member-db');
 define('GLM_MEMBERS_OBITS_PLUGIN_LIB_PATH', GLM_MEMBERS_OBITS_MAIN_PLUGIN_PATH.'/lib');
 
+// Parameters for the starting range of the birth and death year range search
+define('BIRTH_YEAR_START', '1800');
+define('DEATH_YEAR_START', '1880');
+
+
index 04d06c0..383d81d 100644 (file)
  * @release  index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
  * @link     http://dev.gaslightmedia.com/
  */
-
-// Load Contacts data class
+// Load Obits data class
 require_once GLM_MEMBERS_OBITS_PLUGIN_CLASS_PATH.'/data/dataObits.php';
 
+// Load support functions class
+require_once GLM_MEMBERS_OBITS_PLUGIN_CLASS_PATH . '/supportFunctions.php';
+
 class GlmMembersAdmin_obits_list extends GlmDataObits
 {
 
@@ -87,6 +90,7 @@ class GlmMembersAdmin_obits_list extends GlmDataObits
 
     public function modelAction($actionData = false)
     {
+        $year_range = new GlmSupportFunctions();
 
         $numbObits       = 0;
         $option          = 'list';
@@ -112,6 +116,7 @@ class GlmMembersAdmin_obits_list extends GlmDataObits
         $namesList       = false;
         $obitDeleted     = false;
         $obitDeleteError = false;
+        $birth_death_range = array('birth' => $year_range->getObitYearRange(BIRTH_YEAR_START), 'death' => $year_range->getObitYearRange(DEATH_YEAR_START) );
 
         // Get any provided option
         if (isset($_REQUEST['option'])) {
@@ -138,7 +143,6 @@ class GlmMembersAdmin_obits_list extends GlmDataObits
             case 'add':
 
                 $obit = $this->newEntry();
-
                 $view = 'edit';
 
                 break;
@@ -146,7 +150,7 @@ class GlmMembersAdmin_obits_list extends GlmDataObits
             case 'insert':
 
                 $obit = $this->insertEntry();
-
+//               echo '<pre>', print_r($obit), '</pre>';
                 $this->obitID = $obit['fieldData']['id'];
 
                 if ($obit['status']) {
@@ -306,6 +310,7 @@ class GlmMembersAdmin_obits_list extends GlmDataObits
             'namesList'       => $namesList,
             'obitDeleted'     => $obitDeleted,
             'obitDeleteError' => $obitDeleteError,
+            'birthDeathRange' => $birth_death_range 
 
         );
 
index 6493ac3..e37154a 100644 (file)
             </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-short">
-                {if $obit.fieldFail.b_yr_range}<p>{$obit.fieldFail.b_yr_range}</p>{/if}<br>
+<!--                <input type="text" name="b_yr_range" value="{$obit.fieldData.b_yr_range}" class="glm-form-text-input-short">
+                {if $obit.fieldFail.b_yr_range}<p>{$obit.fieldFail.b_yr_range}</p>{/if}<br>-->
+                <select id="b_yr_range" data-id="b_yr_range" name="b_yr_range">
+                    <option value="">Select a date range</option>
+                    {foreach from=$birthDeathRange.birth item=r}
+                        <option value="{$r.start}" {if $obit.fieldData.b_yr_range == {$r.start}} selected="selected"{/if}>
+                            {$r.start} - {$r.end}
+                        </option>
+                    {/foreach}
+                </select>
             </td>
         </tr>
         <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-short">
-                {if $obit.fieldFail.d_yr_range}<p>{$obit.fieldFail.d_yr_range}</p>{/if}<br>
+<!--                <input type="text" name="d_yr_range" value="{$obit.fieldData.d_yr_range}" class="glm-form-text-input-short">
+                {if $obit.fieldFail.d_yr_range}<p>{$obit.fieldFail.d_yr_range}</p>{/if}<br>-->
+                <select id="d_yr_range" data-id="d_yr_range" name="d_yr_range">
+                    <option value="">Select a date range</option>
+                    {foreach from=$birthDeathRange.death item=r}
+                        <option value="{$r.start}" {if $obit.fieldData.d_yr_range == {$r.start}} selected="selected"{/if}>
+                            {$r.start} - {$r.end}
+                        </option>
+                    {/foreach}
+                </select>
             </td>
         </tr>
         <tr>
         <tr>
             <th {if $obit.fieldRequired.newspaper} class="glm-required"}{/if}>Newspaper</th>
             <td {if $obit.fieldFail.newspaper}class="glm-form-bad-input" data-tabid="glm-obits-newspaper"{/if}>
-            <input type="text" name="newspaper" value="{$obit.fieldData.newspaper}" class="glm-form-text-input-short">
-            {if $obit.fieldFail.newspaper}<p>{$obit.fieldFail.newspaper}</p>{/if}<br>
+               <select id="default-code-type" data-id="code_type" name="newspaper">
+                    <option value="">Select a Newspaper</option>
+                    {foreach from=$obit.fieldData.newspaper.list item=v}
+                    <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+                        {$v.name}
+                    </option>
+                    {/foreach}
+                </select>
             </td>
         </tr>
         <tr>