Add expire notices to jobs
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 12 Mar 2019 17:30:09 +0000 (13:30 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 12 Mar 2019 17:31:44 +0000 (13:31 -0400)
New Fields:
expire notice message
expire notice enable flag

Send email to Contact Email on the job when job posting expires.

15 files changed:
classes/data/dataEmailJobsNotifications.php
classes/helper/notifications.php
index.php
models/admin/ajax/jobsSendExpireNotice.php [new file with mode: 0644]
models/admin/jobs/index.php
models/front/jobs/list.php
setup/adminHooks.php
setup/databaseScripts/create_database_V0.0.4.sql [deleted file]
setup/databaseScripts/create_database_V0.0.5.sql [new file with mode: 0644]
setup/databaseScripts/dbVersions.php
setup/databaseScripts/update_database_V0.0.5.sql [new file with mode: 0644]
setup/validActions.php
views/admin/jobs/edit.html
views/admin/jobs/expireNoticeEmail.html [new file with mode: 0644]
views/admin/settings/emailJobsNotifications.html

index ce7a661..9340d4f 100644 (file)
@@ -116,46 +116,58 @@ class GlmDataEmailJobsNotifications extends GlmDataAbstract
         $this->fields = array (
 
             'id' => array (
-                'field' => 'id',
-                'type' => 'integer',
+                'field'     => 'id',
+                'type'      => 'integer',
                 'view_only' => true,
-                'use' => 'a'
+                'use'       => 'a'
             ),
 
             // Email Notification Message
             'job_email_notification' => array(
-                'field' => 'job_email_notification',
-                'type' => 'text',
+                'field'    => 'job_email_notification',
+                'type'     => 'text',
                 'required' => false,
-                'use' => 'a'
+                'use'      => 'a'
             ),
             // Event Declined Message
             'job_declined_message' => array(
-                'field' => 'job_declined_message',
-                'type' => 'text',
+                'field'    => 'job_declined_message',
+                'type'     => 'text',
                 'required' => false,
-                'use' => 'a'
+                'use'      => 'a'
             ),
             // Event Declined Message
             'job_approved_message' => array(
-                'field' => 'job_approved_message',
-                'type' => 'text',
+                'field'    => 'job_approved_message',
+                'type'     => 'text',
                 'required' => false,
-                'use' => 'a'
+                'use'      => 'a'
             ),
             // To Email address
             'job_to_email' => array(
-                'field' => 'job_to_email',
-                'type' => 'text',
+                'field'    => 'job_to_email',
+                'type'     => 'text',
                 'required' => false,
-                'use' => 'a'
+                'use'      => 'a'
             ),
             // From Email Address
             'job_from_email' => array(
-                'field' => 'job_from_email',
-                'type' => 'text',
+                'field'    => 'job_from_email',
+                'type'     => 'text',
                 'required' => false,
-                'use' => 'a'
+                'use'      => 'a'
+            ),
+            'job_expire_notices' => array (
+                'field' => 'job_expire_notices',
+                'type'  => 'checkbox',
+                'use'   => 'a'
+            ),
+            // Email Expired Message
+            'job_expired_message' => array(
+                'field'    => 'job_expired_message',
+                'type'     => 'text',
+                'required' => false,
+                'use'      => 'a'
             ),
 
         );
@@ -181,5 +193,3 @@ class GlmDataEmailJobsNotifications extends GlmDataAbstract
         return $r;
     }
 }
-
-?>
index 486ccca..001bda7 100644 (file)
@@ -75,6 +75,12 @@ class GlmMembersAdmin_jobs_notification extends GlmDataMembers
     }
 
 
+    public function isExpireNoticesEnabled()
+    {
+        $settings = $this->config['settings'];
+        return $settings['job_expire_notices'];
+    }
+
     /**
      * Send the member a notice.
      *
@@ -82,16 +88,16 @@ class GlmMembersAdmin_jobs_notification extends GlmDataMembers
      * If not found use the member info record email.
      * If nothing in either one then return.
      */
-    public function sendMemberNotice( $memberId, $data )
+    public function sendExpireNotice( $email, $contact )
     {
-        $member = $this->getEntry( $memberId );
-        // find notify_to
-        // See if there's a primary member contact for this member
-        $notify_to = $settings['job_to_email'];
+        $notify_to = $email;
         if ( !$notify_to ) {
             return false;
         }
-        $validEmail = filter_var( $notify_to, FILTER_VALIDATE_EMAIL );
+        $settings       = $this->config['settings'];
+        $notify_from    = $settings['job_from_email'];
+        $notify_message = $settings['job_expired_message'];
+        $validEmail     = filter_var( $email, FILTER_VALIDATE_EMAIL );
         if ( !$validEmail ) {
             return false;
         }
@@ -104,17 +110,17 @@ class GlmMembersAdmin_jobs_notification extends GlmDataMembers
 
         // Setup the Smarty Engine
         $smarty   = new smartyTemplateSupport();
-        $viewPath = GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/views';
+        $viewPath = GLM_MEMBERS_JOBS_PLUGIN_PATH . '/views';
         $smarty->template->setTemplateDir( $viewPath );
 
         // Add standard parameters
-        require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
-        $viewFile   = 'admin/events/memberEmail.html';
+        require GLM_MEMBERS_PLUGIN_SETUP_PATH . '/standardTemplateParams.php';
+        $viewFile = 'admin/jobs/expireNoticeEmail.html';
 
-        $dataList = GLM_MEMBERS_EVENTS_PLUGIN_ADMIN_URL ."?page=glm-members-admin-menu-events-list&glm_action=list";
-        $smarty->templateAssign( 'location', 'Member Events' );
-        $smarty->templateAssign( 'name', $data['fieldData']['name'] );
-        $smarty->templateAssign( 'pendingEvents', $dataList );
+        $dataList = GLM_MEMBERS_JOBS_PLUGIN_ADMIN_URL . "?page=glm-members-admin-menu-jobs-index";
+        $smarty->templateAssign( 'notify_message', $notify_message );
+        $smarty->templateAssign( 'name', $contact );
+        $smarty->templateAssign( 'job_list', $dataList );
 
         // Generate output from model data and view
         $htmlMessage = $smarty->template->fetch( $viewFile );
@@ -131,7 +137,7 @@ class GlmMembersAdmin_jobs_notification extends GlmDataMembers
         // Send confirmation email, set the content type to allow html by using this filter
         add_filter( 'wp_mail_content_type', array( $this, 'set_content_type' ) );
 
-        $subject  = 'Event Approved';
+        $subject  = 'Your Job Posting Expired';
         $message  = $htmlMessage;
         $header[] = 'From:' . $notify_from;
         $header[] = 'Reply-To:' . $notify_from;
@@ -178,7 +184,7 @@ class GlmMembersAdmin_jobs_notification extends GlmDataMembers
         $smarty->templateAssign( 'notify_message', $notify_message);
         $smarty->templateAssign( 'member', $member );
         $smarty->templateAssign( 'name', $data['fieldData']['title']['name'] );
-     
+
         // Generate output from model data and view
         $htmlMessage = $smarty->template->fetch( $viewFile );
 
index dc2f4ff..ccfa628 100644 (file)
--- a/index.php
+++ b/index.php
@@ -38,7 +38,7 @@
  *  version from this plugin.
  */
 define('GLM_MEMBERS_JOBS_PLUGIN_VERSION', '0.0.1');
-define('GLM_MEMBERS_JOBS_PLUGIN_DB_VERSION', '0.0.4');
+define('GLM_MEMBERS_JOBS_PLUGIN_DB_VERSION', '0.0.5');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
 define('GLM_MEMBERS_JOBS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0');
diff --git a/models/admin/ajax/jobsSendExpireNotice.php b/models/admin/ajax/jobsSendExpireNotice.php
new file mode 100644 (file)
index 0000000..7e88dba
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/**
+ * Steve Note...
+ *
+ * You can get to this using the following URL.
+ *
+ * {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=jobsSendExpireNotice
+ *
+ * You should be able to do this as POST or GET and should be able to add and read additional parameters.
+ * I added a "mystuff" parameter to the URL above and it does output from the code in the
+ * modelAction() function below.
+ *
+ * To add another model under models/admin/ajax all you need to do is create it and add it to the
+ * setup/validActions.php file.
+ *
+ */
+
+// Load Members data abstract
+require_once GLM_MEMBERS_JOBS_PLUGIN_CLASS_PATH . '/helper/notifications.php';
+
+/**
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_jobsSendExpireNotice
+{
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+    }
+
+    public function modelAction( $actionData = false ) {
+        // Grab list of emails for the notifications.
+        // Getting only the emails (if set) as contact email for the jobs that
+        // expire today.
+
+        $notification = new GlmMembersAdmin_jobs_notification( $this->wpdb, $this->config );
+
+        $expireNoticesEnabled = $notification->isExpireNoticesEnabled();
+
+        if ( $expireNoticesEnabled ) {
+
+            $expire_list = $this->wpdb->get_results(
+                "SELECT email_location,contact_name
+                   FROM " . GLM_MEMBERS_JOBS_PLUGIN_DB_PREFIX . "jobs
+                  WHERE CURDATE() = DATE_ADD( updated, INTERVAL job_expiration DAY ) AND active = true",
+                ARRAY_A
+            );
+
+            if ( isset( $expire_list ) && is_array( $expire_list ) && !empty( $expire_list ) ) {
+                foreach ( $expire_list as $expire_item ) {
+                    $notification->sendExpireNotice( $expire_item['email_location'], $expire_item['contact_name'] );
+                }
+            }
+            // echo '<pre>$expire_list: ' . print_r( $expire_list, true ) . '</pre>';
+        }
+
+    }
+}
index 0d0fbfc..e23ce45 100644 (file)
@@ -95,21 +95,21 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs
         $job_titles = new GlmDataJobTitles($this->wpdb,$this->config);
 
 
-        $success_message    = "";
-        $haveJob            = false;
-        $option             = false;
-        $job                = false;
-        $job_data           = false;
-        $jobUpdated         = false;
-        $jobUpdateError     = false;
-        $jobAdded           = false;
-        $jobAddError        = false;
-        $view_file          = 'index';
-        $lockedToMember     = false;
-        $isModerated        = false;
-        $memberID           = false;
-        $haveMember         = false;
-        $where              = ' TRUE ';
+        $success_message = "";
+        $haveJob         = false;
+        $option          = false;
+        $job             = false;
+        $job_data        = false;
+        $jobUpdated      = false;
+        $jobUpdateError  = false;
+        $jobAdded        = false;
+        $jobAddError     = false;
+        $view_file       = 'index';
+        $lockedToMember  = false;
+        $isModerated     = false;
+        $memberID        = false;
+        $haveMember      = false;
+        $where           = ' TRUE ';
 
 
         $isPending  = ( !empty( $_REQUEST['pending-job'] ) ) ? true : false;
@@ -126,7 +126,7 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs
         if ($lockedToMember) {
 
             $isModerated = true;//apply_filters('glm_user_is_moderated', $lockedToMember);
-            $memberID = $lockedToMember;
+            $memberID    = $lockedToMember;
 
             $this->fields['admin_name']['required']  = true;
             $this->fields['admin_email']['required'] = true;
@@ -213,13 +213,13 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs
 
             case 'insert':
 
-                $job = $this->insertEntry();
+                $job          = $this->insertEntry();
                 $this->job_id = $job['fieldData']['id'];
                 $this->checkNewJobTitles();
                 $updated = $this->getUpdatedTime($this->job_id);
 
                 if ($job['status']) {
-                    $haveJob = true;
+                    $haveJob  = true;
                     $jobAdded = true;
 
                     // Update created timestamp and name slug for URLs
@@ -231,13 +231,13 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs
                     $this->updateTimestamp('updated', $this->job_id,$job,$updated);
                     // $job = $this->addNewTitle($job);
 
-                    $option = 'edit';
+                    $option   = 'edit';
                     $jobAdded = true;
 
 
 
                 } else {
-                    $option = 'add';
+                    $option      = 'add';
                     $jobAddError = true;
                 }
 
@@ -260,7 +260,7 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs
                 // If we're locked to a member as a contact user and the event member doesn't equal the contact member
                 if ($lockedToMember && $job['fieldData']['member']['value'] != $lockedToMember) {
                     $haveJob = false;
-                    $job = false;
+                    $job     = false;
                 }
                 // If we have a good Job
                 if ($job['status']) {
@@ -268,7 +268,7 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs
                 }
                 $job_titles = $job_titles->getList();
                 // echo '<pre>', print_r($job), '</pre>';
-                $job_data = $this->getList($where);
+                $job_data  = $this->getList($where);
                 $view_file = 'edit';
                 break;
 
@@ -286,11 +286,11 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs
                 } else {
                     $jobUpdateError = true;
                 }
-                $job_titles     = $job_titles->getList();
+                $job_titles = $job_titles->getList();
                 $job_data   = $this->getList($where);
                 $this->updateTimestamp('updated', $this->job_id,$job,$updated);
-                $haveJob        = true;
-                $view_file      = 'edit';
+                $haveJob    = true;
+                $view_file  = 'edit';
 
                 break;
 
@@ -302,10 +302,10 @@ class GlmMembersAdmin_jobs_index extends GlmDataJobs
                     $jobDeleteError = true;
                 }
                 $view_file = "index";
-                $job_data = $this->getList($where, "post_date DESC");
+                $job_data  = $this->getList($where, "post_date DESC");
                 break;
             default:
-                $job_data = $this->getList($where, "post_date DESC");
+                $job_data  = $this->getList($where, "post_date DESC");
                 $view_file = 'index';
 
                 break;
index 0a92d0c..68ed8fd 100644 (file)
@@ -104,44 +104,44 @@ class GlmMembersFront_jobs_list extends GlmDatajobs
 
     public function modelAction($actionData = false)
     {
-        $jobs_where             = ' TRUE ';
-        $job_titles_where       = ' TRUE ';
-        $exclude_jobs           = ( !empty( $actionData['request']['exclude-jobs'] )  ) ? $actionData['request']['exclude-jobs'] : false;
-        $members_only           = ( !empty( $actionData['request']['members-only'] )  ) ? $actionData['request']['members-only'] : false;
-        $members_only_page      = get_option(GLM_MEMBERS_PLUGIN_OPTION_MEMBERS_ONLY_ID);
-        $is_members_only        = is_in_tree($members_only_page);
-        $job_titles             = new GlmDataJobTitles($this->wpdb,$this->config);
-        $listUrl                = GLM_MEMBERS_JOBS_SITE_BASE_URL ."/job-postings";
-
-        $sql = "SELECT list_page_id FROM " . GLM_MEMBERS_JOBS_PLUGIN_DB_PREFIX . "management";
+        $jobs_where        = ' TRUE ';
+        $job_titles_where  = ' TRUE ';
+        $exclude_jobs      = ( !empty( $actionData['request']['exclude-jobs'] ) ) ? $actionData['request']['exclude-jobs'] : false;
+        $members_only      = ( !empty( $actionData['request']['members-only'] ) ) ? $actionData['request']['members-only'] : false;
+        $members_only_page = get_option(GLM_MEMBERS_PLUGIN_OPTION_MEMBERS_ONLY_ID);
+        $is_members_only   = is_in_tree($members_only_page);
+        $job_titles        = new GlmDataJobTitles($this->wpdb,$this->config);
+        $listUrl           = GLM_MEMBERS_JOBS_SITE_BASE_URL ."/job-postings";
+
+        $sql          = "SELECT list_page_id FROM " . GLM_MEMBERS_JOBS_PLUGIN_DB_PREFIX . "management";
         $list_page_id = $this->wpdb->get_results($sql, 'ARRAY_A');
 
         if(!empty($list_page_id)){
-            $listUrl  = get_permalink($list_page_id[0]['list_page_id']);
+            $listUrl = get_permalink($list_page_id[0]['list_page_id']);
         }
-  
+
         if( $exclude_jobs && ( !$is_members_only && $members_only ) ){
             $job_titles_where .= "AND id NOT IN ( $exclude_jobs ) ";
-            $jobs_where .= "AND title NOT IN ( $exclude_jobs ) ";
+            $jobs_where       .= "AND title NOT IN ( $exclude_jobs ) ";
         }else if($exclude_jobs){
             $job_titles_where .= "AND id NOT IN ( $exclude_jobs ) ";
-            $jobs_where .= "AND title NOT IN ( $exclude_jobs ) ";
+            $jobs_where       .= "AND title NOT IN ( $exclude_jobs ) ";
         }
-        
-        $job_titles = $job_titles->getList($job_titles_where);
+
+        $job_titles      = $job_titles->getList($job_titles_where);
 
         $success_message = "";
-        $option = false;
+        $option          = false;
         if (isset($_REQUEST['option']) && trim($_REQUEST['option']) != '') {
             $option = $_REQUEST['option'];
         }
         $jobs_where .= "AND CURDATE() <= DATE_ADD(updated, INTERVAL job_expiration DAY) AND active = true ";
-       
+
         if (isset($_REQUEST['job_titles']) && $_REQUEST['job_titles'] !== '') {
             // Make sure it's numeric
             $job_title_id = ($_REQUEST['job_titles'] - 0);
-            $jobs_where .= "AND title = $job_title_id";
-            $job_data = $this->getList($jobs_where);
+            $jobs_where  .= "AND title = $job_title_id";
+            $job_data     = $this->getList($jobs_where);
         } else {
             $job_data = $this->getList($jobs_where);
         }
@@ -151,17 +151,17 @@ class GlmMembersFront_jobs_list extends GlmDatajobs
         $templateData = array(
             'jobData'       => $job_data,
             'jobTitles'     => $job_titles,
-            'siteBaseUrl'   => GLM_MEMBERS_JOBS_SITE_BASE_URL, 
+            'siteBaseUrl'   => GLM_MEMBERS_JOBS_SITE_BASE_URL,
             'currentUrl'    => GLM_MEMBERS_JOBS_PLUGIN_CURRENT_URL,
             'listUrl'       => $listUrl
         );
 
         // Return status, any suggested view, and any data to controller
         return array(
-                'status' => true,
+                'status'        => true,
                 'modelRedirect' => false,
-                'view' => 'front/jobs/'.$view_file.'.html',
-                'data' => $templateData
+                'view'          => 'front/jobs/'.$view_file.'.html',
+                'data'          => $templateData
         );
 
     }
index 53de97e..29efc8a 100644 (file)
@@ -48,3 +48,20 @@ add_filter(
         return true;
     },10,1
 );
+
+// Setup cron task for sending emails.
+add_filter(
+    'glm_associate_cron_request',
+    function( $cron_task ){
+        $new_cron = array(
+            array(
+                'menu'       => 'ajax',
+                'action'     => 'jobsSendExpireNotice',
+                'daysOfWeek' => false,
+                'times'      => array( 5 ),
+                'params'     => array()
+            )
+        );
+        return array_merge( $cron_task, $new_cron );
+    }
+);
diff --git a/setup/databaseScripts/create_database_V0.0.4.sql b/setup/databaseScripts/create_database_V0.0.4.sql
deleted file mode 100644 (file)
index 312dc05..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
--- Gaslight Media Members Database - Job Postings
--- File Created: 11/20/17 15:27:15
--- Database Version: 0.0.3
--- Database Creation Script
---
--- This file is called to create a new set of tables for this
--- add-on for the most receint database version for this add-on.
---
--- There should only be one such file in this directory
---
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
-
--- Conditions Table
-CREATE TABLE {prefix}jobs (
-    id INT NOT NULL AUTO_INCREMENT,
-    old_id int NULL ,
-    title int NULL ,
-    descr TEXT NULL ,
-    salary TINYTEXT NULL ,
-    email_location TINYTEXT NULL ,
-    resume_location TINYTEXT NULL ,
-    contact_name TINYTEXT NULL ,
-    contact_phone TINYTEXT NULL ,
-    post_date DATETIME NULL,
-    updated DATETIME NULL,
-    active BOOL NULL,
-    facility_operation TEXT NULL,
-    requirements TEXT NULL,
-    benefits TEXT NULL ,
-    job_location TINYTEXT NULL ,
-    job_expiration INT NULL,
-    duration TINYTEXT NULL ,
-    deadline TINYTEXT NULL ,
-    company TINYTEXT NULL ,
-    repost TINYTEXT NULL ,
-    position_available TINYTEXT NULL ,
-    member INT NULL,
-    PRIMARY KEY (id)
-);
-
-----
-
--- Job Titles
-CREATE TABLE {prefix}job_titles (
-  id INT NOT NULL AUTO_INCREMENT,
-  old_id INT NULL,
-  job_title TINYTEXT NULL ,
-  PRIMARY KEY (id)
-);
-
-----
-
--- Event Email Notifications
-CREATE TABLE {prefix}email_notifications (
-    id INT NOT NULL AUTO_INCREMENT,
-    job_declined_message TEXT NULL,    -- Event declined message
-    job_approved_message TEXT NULL,    -- Event approved message
-    job_to_email TINYTEXT NULL,        -- To Email Address
-    job_from_email TINYTEXT NULL,      -- From Email Address
-    job_email_notification TEXT NULL,  -- Email notification message
-    PRIMARY KEY (id)
-);
-
-----
-
--- Event Email Notifications
-CREATE TABLE {prefix}management (
-    id INT NOT NULL AUTO_INCREMENT,
-    list_page_id INT NULL,
-    PRIMARY KEY (id)
-);
-
-----
-
--- Set default event email settings
-INSERT INTO {prefix}email_notifications
-    ( id, job_declined_message, job_approved_message )
-   VALUES
-    ( 1, 'The Job parameters do not comply with our event guidelines.', 'Your Job has been approved.' )
-;
-
-----
-
--- Job Titles default entries in table
--- INSERT INTO {prefix}job_titles ( id,old_id,job_title) VALUES
--- (1,1, 'Supervisor'),(2,1,'Groundskeeper'),(3,1,'Janitor');
-
-----
-
--- Job Titles default entries in table
--- INSERT INTO {prefix}jobs ( 
--- id,old_id,title,descr,salary, email_location,resume_location,contact_name,contact_phone,post_date,updated,visible, 
--- facility_operation,requirements,job_location,job_expiration,duration,deadline,position_available,
--- company,member,benefits
--- ) VALUES ( 1,1, 1,"DESCRIPTION",'SALARY', 'EMAIL LOCATION', 'RESUME LOCATION','CONTACT NAME', '453-3443', NOW(),NOW(), true,
--- 'facility operations', 'REQUIREMENTS', 'JOB LOCATION', 30, 'JOB DURATION', 'DEADLINE', 'POSITION AVAILABLE',
--- 'COMPANY', 1, 'JOB BENEFITS'
--- );
\ No newline at end of file
diff --git a/setup/databaseScripts/create_database_V0.0.5.sql b/setup/databaseScripts/create_database_V0.0.5.sql
new file mode 100644 (file)
index 0000000..15bd90a
--- /dev/null
@@ -0,0 +1,101 @@
+-- Gaslight Media Members Database - Job Postings
+-- File Created: 11/20/17 15:27:15
+-- Database Version: 0.0.5
+-- Database Creation Script
+--
+-- This file is called to create a new set of tables for this
+-- add-on for the most receint database version for this add-on.
+--
+-- There should only be one such file in this directory
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+-- Conditions Table
+CREATE TABLE {prefix}jobs (
+    id INT NOT NULL AUTO_INCREMENT,
+    old_id int NULL ,
+    title int NULL ,
+    descr TEXT NULL ,
+    salary TINYTEXT NULL ,
+    email_location TINYTEXT NULL ,
+    resume_location TINYTEXT NULL ,
+    contact_name TINYTEXT NULL ,
+    contact_phone TINYTEXT NULL ,
+    post_date DATETIME NULL,
+    updated DATETIME NULL,
+    active BOOL NULL,
+    facility_operation TEXT NULL,
+    requirements TEXT NULL,
+    benefits TEXT NULL ,
+    job_location TINYTEXT NULL ,
+    job_expiration INT NULL,
+    duration TINYTEXT NULL ,
+    deadline TINYTEXT NULL ,
+    company TINYTEXT NULL ,
+    repost TINYTEXT NULL ,
+    position_available TINYTEXT NULL ,
+    member INT NULL,
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Job Titles
+CREATE TABLE {prefix}job_titles (
+  id INT NOT NULL AUTO_INCREMENT,
+  old_id INT NULL,
+  job_title TINYTEXT NULL ,
+  PRIMARY KEY (id)
+);
+
+----
+
+-- Event Email Notifications
+CREATE TABLE {prefix}email_notifications (
+    id INT NOT NULL AUTO_INCREMENT,
+    job_declined_message TEXT NULL,         -- Event declined message
+    job_approved_message TEXT NULL,         -- Event approved message
+    job_to_email TINYTEXT NULL,             -- To Email Address
+    job_from_email TINYTEXT NULL,           -- From Email Address
+    job_email_notification TEXT NULL,       -- Email notification message
+    job_expire_notices BOOLEAN DEFAULT '0', -- Turn on expire notices
+    job_expired_message TEXT NULL,          -- Event Expired message
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Event Email Notifications
+CREATE TABLE {prefix}management (
+    id INT NOT NULL AUTO_INCREMENT,
+    list_page_id INT NULL,
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Set default event email settings
+INSERT INTO {prefix}email_notifications
+    ( id, job_declined_message, job_approved_message, job_expired_message, job_expire_notices )
+   VALUES
+    ( 1, 'The Job parameters do not comply with our event guidelines.', 'Your Job has been approved.', 'Your Job posting has expired.', false )
+;
+
+----
+
+-- Job Titles default entries in table
+-- INSERT INTO {prefix}job_titles ( id,old_id,job_title) VALUES
+-- (1,1, 'Supervisor'),(2,1,'Groundskeeper'),(3,1,'Janitor');
+
+----
+
+-- Job Titles default entries in table
+-- INSERT INTO {prefix}jobs (
+-- id,old_id,title,descr,salary, email_location,resume_location,contact_name,contact_phone,post_date,updated,visible,
+-- facility_operation,requirements,job_location,job_expiration,duration,deadline,position_available,
+-- company,member,benefits
+-- ) VALUES ( 1,1, 1,"DESCRIPTION",'SALARY', 'EMAIL LOCATION', 'RESUME LOCATION','CONTACT NAME', '453-3443', NOW(),NOW(), true,
+-- 'facility operations', 'REQUIREMENTS', 'JOB LOCATION', 30, 'JOB DURATION', 'DEADLINE', 'POSITION AVAILABLE',
+-- 'COMPANY', 1, 'JOB BENEFITS'
+-- );
index 35200ae..23ff089 100644 (file)
@@ -38,4 +38,5 @@ $glmMembersjobsDbVersions = array(
     '0.0.2' => array('version' => '0.0.2', 'tables' => 2, 'date' => '11/21/2017'),
     '0.0.3' => array('version' => '0.0.3', 'tables' => 3, 'date' => '12/21/2017'),
     '0.0.4' => array('version' => '0.0.4', 'tables' => 4, 'date' => '07/31/2018'),
+    '0.0.5' => array('version' => '0.0.5', 'tables' => 4, 'date' => '03/11/2019'),
 );
diff --git a/setup/databaseScripts/update_database_V0.0.5.sql b/setup/databaseScripts/update_database_V0.0.5.sql
new file mode 100644 (file)
index 0000000..b18a58e
--- /dev/null
@@ -0,0 +1,18 @@
+-- Gaslight Media Members Database  - Events Add-On
+-- File Created: 2019-03-11
+-- Database Version: 0.0.5
+-- Database Update From Previous Version Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+-- Event Email Notifications
+ALTER TABLE {prefix}email_notifications ADD COLUMN job_expire_notices BOOLEAN DEFAULT '0';
+
+----
+
+ALTER TABLE {prefix}email_notifications ADD COLUMN job_expired_message TEXT NULL;
+
+----
+
+UPDATE {prefix}email_notifications SET job_expired_message = 'Your Job posting has expired.', job_expire_notices = false WHERE id = 1;
index 464e8d9..0566b75 100644 (file)
 
 $glmMembersjobsAddOnValidActions = array(
     'adminActions' => array(
-        'jobs' => array( 
+        'ajax' => array(
+            'jobsSendExpireNotice' => GLM_MEMBERS_JOBS_PLUGIN_SLUG,
+        ),
+        'jobs' => array(
             'index' => GLM_MEMBERS_JOBS_PLUGIN_SLUG,
         ),
         'settings' => array(
@@ -71,11 +74,11 @@ $glmMembersjobsAddOnValidActions = array(
         )
     ),
     'frontActions' => array(
-        'jobs' => array( 
+        'jobs' => array(
             'list' => GLM_MEMBERS_JOBS_PLUGIN_SLUG,
             'detail'   => GLM_MEMBERS_JOBS_PLUGIN_SLUG,
         ),
     )
 );
 
-?>
\ No newline at end of file
+?>
index 8548701..50a5e39 100644 (file)
@@ -42,7 +42,7 @@
                         Visible
                 </div>
                 <div class="glm-small-12 glm-medium-5 glm-columns admin-job-input">
-                        <input id="job-active" data-id="job-active" type="checkbox" name="active" class="active-checkbox" {if $job.fieldData.active.value} checked{/if}>
+                    <input id="job-active" data-id="job-active" type="checkbox" name="active" class="active-checkbox" {if $job.fieldData.active.value} checked{/if}>
                 </div>
             </div>
             <!-- RE-POST -->
diff --git a/views/admin/jobs/expireNoticeEmail.html b/views/admin/jobs/expireNoticeEmail.html
new file mode 100644 (file)
index 0000000..cc2c419
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="content-type" content="text/html;charset=utf-8">
+    </head>
+    <body>
+        <h1 id="title"> Job Posting Expired Notification</h1>
+
+        <div style="width: 500px">
+            <p>{$notify_message}</p>
+        </div>
+
+        <table cellspacing="0" cellpadding="0" width="500" style="background: lightgrey;border:1px solid #ccc;border-collapse:collapse;">
+            <tr>
+                <td style="font-weight:bold;width:200px;padding:5px;border:1px solid #ccc;">Contact Name:</td>
+                <td style="width:200px;padding:5px;border:1px solid #ccc;">{$name}</td>
+            </tr>
+        </table>
+
+        <div id="emailFooter">
+            <p style="margin-bottom: 0px;">A Job Posting has expired.</p>
+            <p style="margin-top: 0px;">To view it, please go to the <a style="color: rgb(5, 104, 179);" href="{$job_list}">Jobs</a> page in your admin.</p>
+        </div>
+    </body>
+</html>
index 34c3773..79eb3a2 100644 (file)
                 )}
             </div>
         </div>
+        <div class="glm-row">
+            <div class="glm-small-12 glm-medium-3 glm-columns email-notification-label"> Enable Expire Notifications </div>
+            <div class="glm-small-12 glm-medium-9 glm-columns email-notification-editor">
+                <label>
+                    <input id="job-active" data-id="job-active" type="checkbox" name="job_expire_notices" class="active-checkbox" {if $email_settings.job_expire_notices.value} checked{/if}>
+                    Enable
+                </label>
+            </div>
+        </div>
+        <div class="glm-row">
+            <div class="glm-small-12 glm-medium-3 glm-columns email-notification-label"> Expired Message </div>
+            <div class="glm-small-12 glm-medium-9 glm-columns email-notification-editor">
+                {wp_editor(
+                    $email_settings.job_expired_message|escape:quotes,
+                    'glm_job_expired',
+                    json_decode('{
+                        "media_buttons":    false,
+                        "quicktags":        false,
+                        "textarea_name":    "job_expired_message",
+                        "editor_height":    300
+                    }', true)
+                )}
+            </div>
+        </div>
+
          <input type="submit" value="Update Settings" class="button-primary">
     </form>