Delete old notes older than 2 years.
$success = true;
$option = isset( $_REQUEST['option'] ) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING ) : '';
- trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
+ // trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
$lead_id = filter_var( $_REQUEST['lead_id'], FILTER_VALIDATE_INT );
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Registrants Database
+ * Registrants List Export by AJAX
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmRegistrantsDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+
+// Load Registrant Info data abstract
+require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH.'/data/dataLeads.php';
+require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH . '/data/dataContacts.php';
+require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH . '/data/dataNotes.php';
+
+/**
+ *
+ * This class exports the currently selected registrants list
+ * to a printable HTML file, to a CSV file, or otherwise.
+ */
+class GlmMembersAdmin_ajax_travelLeadsNotesCron
+{
+
+ /**
+ * 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);
+
+ }
+
+ /**
+ * 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 )
+ {
+
+ // Remove old notes that are older than 2 years.
+ $this->wpdb->query(
+ $this->wpdb->prepare(
+ "DELETE
+ FROM " . GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . "lead_notes
+ WHERE updated < %s",
+ date( 'Y-m-d', mktime( 0, 0, 0, date( 'n' ), date( 'j' ), date( 'Y' ) - 2 ) )
+ )
+ );
+
+ trigger_error( 'Delete old Notes', E_USER_NOTICE );
+
+ exit;
+
+
+ }
+
+
+}
$success = true;
$option = isset($_REQUEST['option']) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING ) : '';
- trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
+ // trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
switch ( $option ) {
case 'update':
$referredby = false;
$option = isset($_REQUEST['option']) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING ) : '';
- trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
+ // trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
switch ( $option ) {
case 'update':
$option = isset( $_REQUEST['option'] ) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING ) : '';
$term = isset( $_REQUEST['term'] ) ? filter_var( $_REQUEST['term'], FILTER_SANITIZE_STRING ) : '';
- trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
+ // trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
switch ( $option ) {
case 'company':
// Initialize the grouped_interests array
$grouped_interests = array();
- // echo '<pre>$this->config: ' . print_r( $this->config, true ) . '</pre>';
-
switch ( $option ) {
case 'delete':
if ( $this->entryId ) {
}
$_REQUEST['updated'] = date( 'Y-m-d H:i:s' );
$entry = $this->updateEntry( $this->entryId );
- // echo '<pre>$entry: ' . print_r( $entry, true ) . '</pre>';
- // $view = 'index.html';
$entry = $this->editEntry( $this->entryId );
$view = 'edit.html';
}
$order = "T.lname, T.fname";
}
- // echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
- // echo '<pre>$order: ' . print_r( $order, true ) . '</pre>';
// Check if we're doing paging
if (isset($_REQUEST['pageSelect'])) {
// If request is for Next
$alphaList = $this->getAlphaList(' AND '.$where, $alphaSelected);
- // echo '<pre>$alphaWhere: ' . print_r( $alphaWhere, true ) . '</pre>';
-
- // echo '<pre>$alphaList: ' . print_r( $alphaList, true ) . '</pre>';
-
// Get paging results
$params = '';
$numbDisplayed = $entryResults['returned'];
$start = 1;
}
}
- // if ( $entryResults['returned'] == $limit ) {
- // $nextStart = $start + $limit;
- // }
if ( $start + $limit <= $stats ) {
$nextStart = $start + $limit;
}
10,
2
);
+
+/**
+ * Setup cron task request to run travelLeadsNotesCron
+ *
+ * Run only once per week.
+ */
+add_filter(
+ 'glm_associate_cron_request',
+ function( $cron_task ) {
+ $new_cron = array(
+ array(
+ 'menu' => 'ajax',
+ 'action' => 'travelLeadsNotesCron',
+ 'daysOfWeek' => array( 1 ),
+ 'times' => array( 6 ),
+ 'params' => array()
+ )
+ );
+ return array_merge( $cron_task, $new_cron );
+ }
+);
$glmMembersTravelAddOnValidActions = array(
'adminActions' => array(
'ajax' => array(
- 'travelContacts' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
- 'travelReferredby' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
- 'travelSearch' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
- 'travelNotes' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
- 'leadCsvExport' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
- 'leadPdfExport' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
+ 'travelContacts' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
+ 'travelReferredby' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
+ 'travelSearch' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
+ 'travelNotes' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
+ 'leadCsvExport' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
+ 'leadPdfExport' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
+ 'travelLeadsNotesCron' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,
),
'settings' => array(
'referredBy' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG,