/** * Display the event playlist page. * * @since 1.3 * @param * @return str The event playlist page content. */ function mdjm_display_event_playlist_page() { if (!mdjm_employee_can('read_events') && !mdjm_employee_working_event($_GET['event_id'])) { wp_die('<h1>' . __('Cheatin’ uh?') . '</h1>' . '<p>' . __('You do not have permission to view this playlist.', 'mobile-dj-manager') . '</p>', 403); } if (!class_exists('MDJM_PlayList_Table')) { require_once MDJM_PLUGIN_DIR . '/includes/admin/events/class-mdjm-playlist-table.php'; } $playlist_obj = new MDJM_PlayList_Table(); ?> <div class="wrap"> <h1><?php printf(__('Playlist for %s %s', 'mobile-dj-manager'), mdjm_get_label_singular(), mdjm_get_event_contract_id($_GET['event_id'])); ?> </h1> <form method="post"> <?php $playlist_obj->prepare_items(); $playlist_obj->display_header(); if (count($playlist_obj->items) > 0) { $playlist_obj->views(); } $playlist_obj->display(); $playlist_obj->entry_form(); ?> </form> <br class="clear"> </div> <?php }
/** * Define the columns to be displayed for email template posts * * @since 0.5 * @param arr $columns Array of column names * @return arr $columns Filtered array of column names */ function mdjm_email_template_post_columns($columns) { $columns = array('cb' => '<input type="checkbox" />', 'title' => __('Email Subject', 'mobile-dj-manager'), 'author' => __('Created By', 'mobile-dj-manager'), 'date' => __('Date', 'mobile-dj-manager')); if (!mdjm_employee_can('manage_templates') && isset($columns['cb'])) { unset($columns['cb']); } return $columns; }
/** * Adds a new venue. * * @since 1.3 * @param str $venue_name The name of the venue. * @param arr $venue_meta Meta data for the venue. * @return int|bool $venue_id Post ID of the new venue or false on failure. */ function mdjm_add_venue($venue_name = '', $venue_meta = array()) { if (!mdjm_employee_can('add_venues')) { return false; } if (empty($venue_name) && empty($_POST['venue_name'])) { return false; } elseif (!empty($venue_name)) { $name = $venue_name; } else { $name = $_POST['venue_name']; } $args = array('post_title' => $name, 'post_content' => '', 'post_type' => 'mdjm-venue', 'post_author' => get_current_user_id(), 'post_status' => 'publish'); // Remove the save post hook for venue posts to avoid loops remove_action('save_post_mdjm-venue', 'mdjm_save_venue_post', 10, 3); /** * Allow filtering of the venue post data * * @since 1.3 * @param arr $args Array of user data */ $args = apply_filters('mdjm_add_venue', $args); /** * Fire the `mdjm_pre_add_venue` action. * * @since 1.3 * @param str $name Name of venue * @param arr $venue_meta Array of venue meta data */ do_action('mdjm_pre_add_venue', $name, $venue_meta); $venue_id = wp_insert_post($args); if (empty($venue_id)) { return false; } if (!empty($venue_meta)) { foreach ($venue_meta as $key => $value) { if ($key == 'venue_email' && !is_email($value)) { continue; } if (!empty($value) && $key != 'venue_name') { add_post_meta($venue_id, '_' . $key, $value); } } } /** * Fire the `mdjm_post_add_venue` action. * * @since 1.3 * @param str $venue_id Post ID of new venue */ do_action('mdjm_post_add_venue', $venue_id); // Re-add the save post hook for venue posts add_action('save_post_mdjm-venue', 'mdjm_save_venue_post', 10, 3); return $venue_id; }
public function get_clients() { // Filter our search by role if we need to self::$display_role = !empty($_GET['display_role']) ? $_GET['display_role'] : array('client', 'inactive_client'); self::$orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : 'display_name'; self::$order = !empty($_GET['order']) ? $_GET['order'] : 'ASC'; // Searching if (!empty($_POST['s'])) { // Build out the query args for the WP_User_Query self::$clients = get_users(array('search' => $_POST['s'], 'role__in' => array('client', 'inactive_client'), 'orderby' => self::$orderby, 'order' => self::$order)); } elseif (!empty($_POST['filter_client'])) { self::$clients = mdjm_get_clients(self::$display_role, $_POST['filter_client'], self::$orderby, self::$order); } else { self::$clients = mdjm_get_clients(self::$display_role, !mdjm_employee_can('list_all_clients') ? get_current_user_id() : '', self::$orderby, self::$order); } self::$total_clients = count(mdjm_get_clients()); }
/** * Define and add the metaboxes for the contract post type. * Apply the `mdjm_contract_add_metaboxes` filter to allow for filtering of metaboxes and settings. * Uses function_exists to verify the callback function exists. * * @since 1.3 * @param * @return */ function mdjm_add_contract_meta_boxes($post) { $metaboxes = apply_filters('mdjm_contract_add_metaboxes', array(array('id' => 'mdjm-contract-details', 'title' => sprintf(__('Contract Details', 'mobile-dj-manager'), get_post_type_object('contract')->labels->singular_name), 'callback' => 'mdjm_contract_details_metabox', 'context' => 'side', 'priority' => 'default', 'args' => array(), 'dependancy' => '', 'permission' => ''))); // Runs before metabox output do_action('mdjm_contract_before_metaboxes'); // Begin metaboxes foreach ($metaboxes as $metabox) { // Dependancy check if (!empty($metabox['dependancy']) && $metabox['dependancy'] === false) { continue; } // Permission check if (!empty($metabox['permission']) && !mdjm_employee_can($metabox['permission'])) { continue; } // Callback check if (!is_callable($metabox['callback'])) { continue; } add_meta_box($metabox['id'], $metabox['title'], $metabox['callback'], 'contract', $metabox['context'], $metabox['priority'], $metabox['args']); } // Runs after metabox output do_action('mdjm_contract_after_metaboxes'); }
/** * Define and add the metaboxes for the mdjm_communication post type. * Apply the `mdjm_venue_add_metaboxes` filter to allow for filtering of metaboxes and settings. * Uses function_exists to verify the callback function exists. * * @since 1.3 * @param * @return */ function mdjm_add_communication_meta_boxes($post) { $metaboxes = apply_filters('mdjm_communication_add_metaboxes', array(array('id' => 'mdjm-email-details', 'title' => __('Details', 'mobile-dj-manager'), 'callback' => 'mdjm_communication_details_metabox', 'context' => 'side', 'priority' => 'high', 'args' => array(), 'dependancy' => '', 'permission' => 'mdjm_comms_send'), array('id' => 'mdjm-email-content', 'title' => __('Email Content', 'mobile-dj-manager'), 'callback' => 'mdjm_communication_content_metabox', 'context' => 'normal', 'priority' => 'high', 'args' => array(), 'dependancy' => '', 'permission' => 'mdjm_comms_send'))); // Runs before metabox output do_action('mdjm_communication_before_metaboxes'); // Begin metaboxes foreach ($metaboxes as $metabox) { // Dependancy check if (!empty($metabox['dependancy']) && $metabox['dependancy'] === false) { continue; } // Permission check if (!empty($metabox['permission']) && !mdjm_employee_can($metabox['permission'])) { continue; } // Callback check if (!is_callable($metabox['callback'])) { continue; } add_meta_box($metabox['id'], $metabox['title'], $metabox['callback'], 'mdjm_communication', $metabox['context'], $metabox['priority'], $metabox['args']); } // Runs after metabox output do_action('mdjm_communication_after_metaboxes'); }
/** * Output the event add new venue table * * @since 1.3.7 * @global obj $mdjm_event MDJM_Event class object * @global bool $mdjm_event_update True if this event is being updated, false if new. * @param int $event_id The event ID. * @return str */ function mdjm_event_metabox_venue_add_new_table($event_id) { global $mdjm_event, $mdjm_event_update; $venue_name = mdjm_get_event_venue_meta($event_id, 'name'); $venue_contact = mdjm_get_event_venue_meta($event_id, 'contact'); $venue_email = mdjm_get_event_venue_meta($event_id, 'email'); $venue_address1 = mdjm_get_event_venue_meta($event_id, 'address1'); $venue_address2 = mdjm_get_event_venue_meta($event_id, 'address2'); $venue_town = mdjm_get_event_venue_meta($event_id, 'town'); $venue_county = mdjm_get_event_venue_meta($event_id, 'county'); $venue_postcode = mdjm_get_event_venue_meta($event_id, 'postcode'); $venue_phone = mdjm_get_event_venue_meta($event_id, 'phone'); $employee_id = !empty($mdjm_event->employee_id) ? $mdjm_event->employee_id : ''; $venue_address = array($venue_address1, $venue_address2, $venue_town, $venue_county, $venue_postcode); ?> <div id="mdjm-event-add-new-venue-fields" class="mdjm-hidden"> <table class="widefat mdjm_event_add_venue_table mdjm_form_fields"> <thead> <tr> <th colspan="3"><?php _e('Venue Details', 'mobile-dj-manager'); ?> </th> </tr> </thead> <tbody> <tr> <td><label for="venue_name"><?php _e('Venue Name:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->text(array('name' => 'venue_name', 'class' => '', 'value' => !empty($venue_name) ? $venue_name : '')); ?> </td> <td><label for="venue_contact"><?php _e('Contact Name:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->text(array('name' => 'venue_contact', 'class' => '', 'value' => !empty($venue_contact) ? $venue_contact : '', 'placeholder' => __('Optional', 'mobile-dj-manager'))); ?> </td> <td><label for="venue_email"><?php _e('Contact Email:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->text(array('name' => 'venue_email', 'class' => '', 'type' => 'email', 'value' => !empty($venue_email) ? $venue_email : '', 'placeholder' => __('Optional', 'mobile-dj-manager'))); ?> </td> </tr> <tr> <td><label for="venue_address1"><?php _e('Address Line 1:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->text(array('name' => 'venue_address1', 'class' => '', 'value' => !empty($venue_address1) ? $venue_address1 : '', 'placeholder' => __('Optional', 'mobile-dj-manager'))); ?> </td> <td><label for="venue_address2"><?php _e('Address Line 2:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->text(array('name' => 'venue_address2', 'class' => '', 'value' => !empty($venue_address2) ? $venue_address2 : '', 'placeholder' => __('Optional', 'mobile-dj-manager'))); ?> </td> <td><label for="venue_town"><?php _e('Town:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->text(array('name' => 'venue_town', 'class' => '', 'value' => !empty($venue_town) ? $venue_town : '', 'placeholder' => __('Optional', 'mobile-dj-manager'))); ?> </td> </tr> <tr> <td><label for="venue_county"><?php _e('County:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->text(array('name' => 'venue_county', 'class' => '', 'value' => !empty($venue_county) ? $venue_county : '', 'placeholder' => __('Optional', 'mobile-dj-manager'))); ?> </td> <td><label for="venue_postcode"><?php _e('Postcode:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->text(array('name' => 'venue_postcode', 'class' => '', 'value' => !empty($venue_postcode) ? $venue_postcode : '', 'placeholder' => __('Optional', 'mobile-dj-manager'))); ?> </td> <td><label for="venue_phone"><?php _e('Phone:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->text(array('name' => 'venue_phone', 'class' => '', 'value' => !empty($venue_phone) ? $venue_phone : '', 'placeholder' => __('Optional', 'mobile-dj-manager'))); ?> </td> </tr> <?php if (mdjm_employee_can('add_venues')) { ?> <tr id="mdjm-save-venue-button-row"> <td colspan="3"> <a id="mdjm-save-venue" class="button button-primary button-small"><?php _e('Save Venue', 'mobile-dj-manager'); ?> </a> </td> </tr> <?php } ?> <?php do_action('mdjm_venue_details_table_after_save', $event_id); ?> <?php do_action('mdjm_venue_details_travel_data', $venue_address, $employee_id); ?> </tbody> </table> </div> <?php }
/** * Display the form for adding a new employee to MDJM * * * * */ public static function add_employee_form() { // Ensure user has permssion to add an employee if (!mdjm_employee_can('manage_staff')) { return; } ?> <h3><?php _e('Employee Quick Add', 'mobile-dj-manager'); ?> </h3> <form name="mdjm_employee_add" id="mdjm_employee_add" method="post"> <?php mdjm_admin_action_field('add_employee'); ?> <?php wp_nonce_field('add_employee', 'mdjm_nonce', true, true); ?> <table class="widefat"> <tr> <td style="width: 250px;"><label class="mdjm-label" for="first_name"><?php _e('First Name', 'mobile-dj-manager'); ?> :</label><br /> <input type="text" name="first_name" id="first_name" required /></td> </tr> <tr> <td style="width: 250px;"><label class="mdjm-label" for="last_name"><?php _e('Last Name', 'mobile-dj-manager'); ?> :</label><br /> <input type="text" name="last_name" id="last_name" required /></td> </tr> <tr> <td style="width: 250px;"><label class="mdjm-label" for="user_email"><?php _e('Email Address', 'mobile-dj-manager'); ?> :</label><br /> <input type="text" name="user_email" id="user_email" required /></td> </tr> <tr> <td style="width: 250px;"><label class="mdjm-label" for="employee_role"><?php _e('Role', 'mobile-dj-manager'); ?> :</label><br /> <select name="employee_role" id="employee_role" required> <option value=""><?php _e('Select Role', 'mobile-dj-manager'); ?> …</option> <?php echo MDJM()->roles->roles_dropdown(); ?> </select> </td> </tr> <tr> <td style="text-align: right;"><?php submit_button(__('Add Employee', 'mobile-dj-manager'), 'primary', 'mdjm-add-employee', false); ?> </td> </tr> </table> </form> <?php }
/** * Displays the signed contract for review. * * @since 1.3.6 * @param int $event_id The event ID. * @return void */ function mdjm_review_signed_contract() { if (empty($_GET['mdjm_action'])) { return; } if ('review_contract' !== $_GET['mdjm_action']) { return; } if (!mdjm_employee_can('manage_events')) { return; } $mdjm_event = new MDJM_Event($_GET['event_id']); if (!mdjm_is_admin()) { if (!array_key_exists(get_current_user_id(), $mdjm_event->get_all_employees())) { return; } } if (!$mdjm_event->get_contract_status()) { printf(__('The contract for this %s is not signed', 'mobile-dj-manager'), mdjm_get_label_singular()); exit; } $contract_id = $mdjm_event->get_contract(); if (empty($contract_id)) { return; } echo mdjm_show_contract($contract_id, $mdjm_event); exit; }
/** * Retrieve events filtered by employee, client, date or status. * * @since 1.4 * @return void */ public function list_events() { $response = array(); if (!mdjm_employee_can('read_events', $this->user_id)) { $this->no_permsission(); } if (!isset($this->request['employee_id']) && !mdjm_employee_can('read_events_all', $this->user_id)) { $this->no_permsission(); } do_action('mdjm_before_api_event_list', $this); if (isset($this->request['employee_id'])) { $events = mdjm_get_employee_events($this->request['employee_id']); } elseif (isset($this->request['client_id'])) { $events = mdjm_get_client_events($this->request['client_id']); } elseif (isset($this->request['date'])) { $events = mdjm_get_events_by_date($this->request['date']); } elseif (isset($this->request['status'])) { $events = mdjm_get_events_by_status($this->request['status']); } else { $events = mdjm_get_events(); } if (!$events) { $error = array(); $error['error'] = sprintf(__('No %s found.', 'mobile-dj-manager'), mdjm_get_label_plural(true)); $this->data = $error; $this->output(); } $response['events'] = array(); $i = 0; foreach ($events as $event) { $response['events'][$event->ID] = mdjm_get_event_data($event->ID); $i++; } $response['count'] = $i; $this->data = array_merge($this->data, $response); do_action('mdjm_after_api_event_list', $this); $this->output(); }
/** * Define and add the metaboxes for the mdjm-addon post type. * Apply the `mdjm_addon_add_metaboxes` filter to allow for filtering of metaboxes and settings. * Uses is_callable to verify the callback function exists. * * @since 1.4 * @global $post WP_Post object. * @return void */ function mdjm_register_addon_meta_boxes($post) { $metaboxes = apply_filters('mdjm_addon_metaboxes', array(array('id' => 'mdjm-addon-availability-mb', 'title' => __('Availability', 'mobile-dj-manager'), 'callback' => 'mdjm_addon_metabox_availability_callback', 'context' => 'normal', 'priority' => 'high', 'args' => array(), 'dependancy' => '', 'permission' => ''), array('id' => 'mdjm-addon-pricing-mb', 'title' => __('Pricing Options', 'mobile-dj-manager'), 'callback' => 'mdjm_addon_metabox_pricing_callback', 'context' => 'normal', 'priority' => 'high', 'args' => array(), 'dependancy' => '', 'permission' => ''))); // Runs before metabox output do_action('mdjm_addon_before_metaboxes'); // Begin metaboxes foreach ($metaboxes as $metabox) { // Dependancy check if (!empty($metabox['dependancy']) && $metabox['dependancy'] === false) { continue; } // Permission check if (!empty($metabox['permission']) && !mdjm_employee_can($metabox['permission'])) { continue; } // Callback check if (!is_callable($metabox['callback'])) { continue; } add_meta_box($metabox['id'], $metabox['title'], $metabox['callback'], 'mdjm-addon', $metabox['context'], $metabox['priority'], $metabox['args']); } // Runs after metabox output do_action('mdjm_addon_after_metaboxes'); }
/** * Admin notices for errors * * @access public * @return void */ public function notices() { static $showed_invalid_message; if (empty($this->license)) { return; } if (!mdjm_employee_can('manage_mdjm')) { return; } $messages = array(); $license = get_option($this->item_shortname . '_license_active'); if (is_object($license) && 'valid' !== $license->license && empty($showed_invalid_message)) { if (empty($_GET['tab']) || 'licenses' !== $_GET['tab']) { $messages[] = sprintf(__('You have invalid or expired license keys for MDJM Event Management. Please go to the <a href="%s" title="Go to Licenses page">Licenses page</a> to correct this issue.', 'easy-digital-downloads'), admin_url('edit.php?post_type=mdjm-event&page=mdjm-settings&tab=licenses')); $showed_invalid_message = true; } } if (!empty($messages)) { foreach ($messages as $message) { echo '<div class="error">'; echo '<p>' . $message . '</p>'; echo '</div>'; } } }
/** * Hook into pre_get_posts and limit employees addons if their permissions are not full. * * @since 1.4 * @param arr $query The WP_Query * @return void */ function mdjm_limit_results_to_employee_addons($query) { if (!is_admin() || 'mdjm-addon' != $query->get('post_type') || mdjm_employee_can('mdjm_package_edit')) { return; } global $user_ID; $query->set('meta_query', array(array('key' => '_addon_employees', 'value' => sprintf(':"%s";', $user_ID), 'compare' => 'LIKE'))); }
/** * Save the meta data for the transaction * * @since 0.7 * @param int $post_id The current post ID. * @param obj $post The current post object (WP_Post). * @param bool $update Whether this is an existing post being updated or not. * @return void */ function mdjm_save_txn_post($post_id, $post, $update) { global $mdjm_settings; if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if ($post->post_status == 'trash') { return; } if (empty($update)) { return; } // Permission Check if (!mdjm_employee_can('edit_txns')) { if (MDJM_DEBUG == true) { MDJM()->debug->log_it('PERMISSION ERROR: User ' . get_current_user_id() . ' is not allowed to edit transactions'); } return; } // Remove the save post action to avoid loops remove_action('save_post_mdjm-transaction', 'mdjm_save_txn_post', 10, 3); // Fire our pre-save hook do_action('mdjm_before_txn_save', $post_id, $post, $update); $trans_type = get_term($_POST['mdjm_transaction_type'], 'transaction-types'); // Set the post data $trans_data['ID'] = $post_id; $trans_data['post_status'] = $_POST['transaction_direction'] == 'Out' ? 'mdjm-expenditure' : 'mdjm-income'; $trans_data['post_date'] = date('Y-m-d H:i:s', strtotime($_POST['transaction_date'])); $trans_data['edit_date'] = true; $trans_data['post_author'] = get_current_user_id(); $trans_data['post_type'] = 'mdjm-transaction'; $trans_data['post_category'] = array($_POST['mdjm_transaction_type']); // Set the post meta $trans_meta['_mdjm_txn_status'] = sanitize_text_field($_POST['transaction_status']); $trans_meta['_mdjm_txn_source'] = sanitize_text_field($_POST['transaction_src']); $trans_meta['_mdjm_txn_total'] = $_POST['transaction_amount']; $trans_meta['_mdjm_txn_notes'] = sanitize_text_field($_POST['transaction_description']); if ($_POST['transaction_direction'] == 'In') { $trans_meta['_mdjm_payment_from'] = sanitize_text_field($_POST['transaction_payee']); } elseif ($_POST['transaction_direction'] == 'Out') { $trans_meta['_mdjm_payment_to'] = sanitize_text_field($_POST['transaction_payee']); } $trans_meta['_mdjm_txn_currency'] = mdjm_get_currency(); // Update the post if (MDJM_DEBUG == true) { MDJM()->debug->log_it('Updating the transaction'); } wp_update_post($trans_data); // Set the transaction Type if (MDJM_DEBUG == true) { MDJM()->debug->log_it('Setting the transaction type'); } wp_set_post_terms($post_id, $_POST['mdjm_transaction_type'], 'transaction-types'); // Add the meta data if (MDJM_DEBUG == true) { MDJM()->debug->log_it('Updating the transaction post meta'); } // Loop through the post meta and add/update/delete the meta keys. foreach ($trans_meta as $meta_key => $new_meta_value) { $current_meta_value = get_post_meta($post_id, $meta_key, true); // If we have a value and the key did not exist previously, add it. if (!empty($new_meta_value) && empty($current_meta_value)) { add_post_meta($post_id, $meta_key, $new_meta_value, true); } elseif (!empty($new_meta_value) && $new_meta_value != $current_meta_value) { update_post_meta($post_id, $meta_key, $new_meta_value); } elseif (empty($new_meta_value) && !empty($current_meta_value)) { delete_post_meta($post_id, $meta_key, $new_meta_value); } } // Fire our post txn save hook do_action('mdjm_after_txn_save', $post_id, $post, $update); // Re-add the save post action to avoid loops add_action('save_post_mdjm-transaction', 'mdjm_save_txn_post', 10, 3); }
/** * Admin Messages * * @since 1.3 * @global $mdjm_options Array of all the MDJM Options * @return void */ function mdjm_admin_notices() { global $mdjm_options; // Unattended events if (mdjm_employee_can('manage_all_events') && mdjm_get_option('warn_unattended')) { $unattended = MDJM()->events->mdjm_count_event_status('mdjm-unattended'); if (!empty($unattended) && $unattended > 0) { echo '<div class="notice notice-info is-dismissible">'; echo '<p>' . sprintf(__('You have unattended enquiries. <a href="%s">Click here</a> to manage.', 'mobile-dj-manager'), admin_url('edit.php?post_type=mdjm-event&post_status=mdjm-unattended')) . '</p>'; echo '</div>'; } } if (isset($_GET['mdjm-message']) && 'upgrade-completed' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-upgraded', __('MDJM Event Management has been upgraded successfully.', 'mobile-dj-manager'), 'updated'); } if (isset($_GET['mdjm-message']) && 'song_added' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-added-song', __('Entry added to playlist.', 'mobile-dj-manager'), 'updated'); } if (isset($_GET['mdjm-message']) && 'adding_song_failed' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-adding-song-failed', __('Could not add entry to playlist.', 'mobile-dj-manager'), 'error'); } if (isset($_GET['mdjm-message']) && 'song_removed' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-removed-song', __('The selected songs were removed.', 'mobile-dj-manager'), 'updated'); } if (isset($_GET['mdjm-message']) && 'song_remove_failed' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-remove-faled', __('The songs count not be removed.', 'mobile-dj-manager'), 'error'); } if (isset($_GET['mdjm-message']) && 'security_failed' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-security-failed', __('Security verification failed. Action not completed.', 'mobile-dj-manager'), 'error'); } if (isset($_GET['mdjm-message']) && 'playlist_emailed' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-playlist-emailed', __('The playlist was emailed successfully.', 'mobile-dj-manager'), 'updated'); } if (isset($_GET['mdjm-message']) && 'playlist_email_failed' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-playlist-email-failed', __('The playlist could not be emailed.', 'mobile-dj-manager'), 'error'); } if (isset($_GET['mdjm-message']) && 'employee_added' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-employee_added', __('Employee added.', 'mobile-dj-manager'), 'updated'); } if (isset($_GET['mdjm-message']) && 'employee_add_failed' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-employee_add-failed', __('Could not add employee.', 'mobile-dj-manager'), 'updated'); } if (isset($_GET['mdjm-message']) && 'employee_info_missing' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-employee_info-missing', __('Insufficient information to create employee.', 'mobile-dj-manager'), 'error'); } if (isset($_GET['mdjm-message']) && 'comm_missing_content' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-comm_content-missing', __('Not all required fields have been completed.', 'mobile-dj-manager'), 'error'); } if (isset($_GET['mdjm-message']) && 'comm_sent' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-comm_sent', __('Email sent successfully.', 'mobile-dj-manager'), 'updated'); } if (isset($_GET['mdjm-message']) && 'comm_not_sent' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-comm_not_sent', __('Email not sent.', 'mobile-dj-manager'), 'error'); } if (isset($_GET['mdjm-action']) && 'get_event_availability' == $_GET['mdjm-action']) { if (!wp_verify_nonce($_GET['mdjm_nonce'], 'get_event_availability')) { return; } elseif (!isset($_GET['event_id'])) { return; } else { $date = get_post_meta($_GET['event_id'], '_mdjm_event_date', true); $result = mdjm_do_availability_check($date); if (!empty($result['available'])) { $notice = '<ul>'; foreach ($result['available'] as $employee_id) { $notice .= '<li>' . sprintf(__('<a href="%s" title="Assign & Respond to Enquiry">Assign %s & respond to enquiry</a>', 'mobile-dj-manager'), add_query_arg('primary_employee', $employee_id, get_edit_post_link($_GET['event_id'])), mdjm_get_employee_display_name($employee_id)) . '</li>'; } $notice .= '</ul>'; echo '<div class="notice notice-info is-dismissible">'; echo '<p>' . sprintf(__('You have %d employees available to work %s %s on %s.', 'mobile-dj-manager'), count($result['available']), mdjm_get_label_singular(true), mdjm_get_event_contract_id($_GET['event_id']), mdjm_get_event_long_date($_GET['event_id'])) . $notice . '</p>'; echo '</div>'; } else { echo '<div class="notice notice-error is-dismissible">'; echo '<p>' . sprintf(__('There are no employees available to work %s %s on %s', 'mobile-dj-manager'), mdjm_get_label_singular(true), mdjm_get_event_contract_id($_GET['event_id']), mdjm_get_event_long_date($_GET['event_id'])) . '</p>'; echo '</div>'; } } } if (isset($_GET['mdjm-message']) && 'payment_event_missing' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-payment_event_missing', __('Event not identified.', 'mobile-dj-manager'), 'error'); } if (isset($_GET['mdjm-message']) && 'pay_employee_failed' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-payment_employee_failed', __('Unable to make payment to employee.', 'mobile-dj-manager'), 'error'); } if (isset($_GET['mdjm-message']) && 'pay_all_employees_failed' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-payment_employees_failed', __('Unable to make payment to employees.', 'mobile-dj-manager'), 'error'); } if (isset($_GET['mdjm-message']) && 'pay_all_employees_some_success' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-payment_all_employees_some_success', __('Not all employees could be paid.', 'mobile-dj-manager'), 'notice-info'); } if (isset($_GET['mdjm-message']) && 'pay_employee_success' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-payment_employeee_success', __('Employee successfully paid.', 'mobile-dj-manager'), 'updated'); } if (isset($_GET['mdjm-message']) && 'pay_all_employees_success' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-payment_all_employeees_success', __('Employees successfully paid.', 'mobile-dj-manager'), 'updated'); } if (isset($_GET['mdjm-message']) && 'unattended_enquiries_rejected_success' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-unattended_enquiries_rejected_success', sprintf(_n('%1$s %2$s successfully rejected.', '%1$s %3$s successfully rejected.', $_GET['mdjm-count'], 'mobile-dj-manager'), $_GET['mdjm-count'], mdjm_get_label_singular(), mdjm_get_label_plural()), 'updated'); } if (isset($_GET['mdjm-message']) && 'unattended_enquiries_rejected_failed' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-unattended_enquiries_rejected_failed', __('Errors were encountered.', 'mobile-dj-manager'), 'error'); } if (isset($_GET['mdjm-message']) && 'api-key-generated' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-api-key-generated', __('API keys generated.', 'mobile-dj-manager'), 'updated'); } if (isset($_GET['mdjm-message']) && 'api-key-regenerated' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-api-key-regenerated', __('API keys re-generated.', 'mobile-dj-manager'), 'updated'); } if (isset($_GET['mdjm-message']) && 'api-key-revoked' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-api-key-revoked', __('API keys revoked.', 'mobile-dj-manager'), 'updated'); } if (isset($_GET['mdjm-message']) && 'api-key-failed' == $_GET['mdjm-message']) { add_settings_error('mdjm-notices', 'mdjm-api-key-failed', __('Generating API keys failed.', 'mobile-dj-manager'), 'error'); } settings_errors('mdjm-notices'); }
/** * Generates a System Info download file * * @since 1.4 * @return void */ function mdjm_tools_sysinfo_download() { if (!mdjm_employee_can('manage_mdjm')) { return; } nocache_headers(); header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename="mdjm-system-info.txt"'); echo wp_strip_all_tags($_POST['mdjm-sysinfo']); die; }
/** * Save the meta data for the venue * * @since 1.3 * @param int $post_id The current post ID. * @param obj $post The current post object (WP_Post). * @param bool $update Whether this is an existing post being updated or not. * @return void */ function mdjm_save_venue_post($post_id, $post, $update) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if ($post->post_status == 'trash') { return; } if (empty($update)) { return; } // Permission Check if (!mdjm_employee_can('add_venues')) { if (MDJM_DEBUG == true) { MDJM()->debug->log_it('PERMISSION ERROR: User ' . get_current_user_id() . ' is not allowed to edit venues'); } return; } // Remove the save post action to avoid loops remove_action('save_post_mdjm-venue', 'mdjm_save_venue_post', 10, 3); // Fire our pre-save hook do_action('mdjm_before_venue_save', $post_id, $post, $update); // Loop through all fields sanitizing and updating as required foreach ($_POST as $meta_key => $new_meta_value) { // We're only interested in 'venue_' fields if (substr($meta_key, 0, 6) == 'venue_') { $current_meta_value = get_post_meta($post_id, '_' . $meta_key, true); if ($meta_key == 'venue_postcode' && !empty($new_meta_value)) { $new_meta_value = strtoupper($new_meta_value); } elseif ($meta_key == 'venue_email' && !empty($new_meta_value)) { $new_meta_value = sanitize_email($new_meta_value); } else { $new_meta_value = sanitize_text_field(ucwords($new_meta_value)); } // If we have a value and the key did not exist previously, add it if (!empty($new_meta_value) && empty($current_meta_value)) { add_post_meta($post_id, '_' . $meta_key, $new_meta_value, true); } elseif (!empty($new_meta_value) && $new_meta_value != $current_meta_value) { update_post_meta($post_id, '_' . $meta_key, $new_meta_value); } elseif (empty($new_meta_value) && !empty($current_meta_value)) { delete_post_meta($post_id, '_' . $meta_key, $meta_value); } } } // Fire our post save hook do_action('mdjm_after_venue_save', $post_id, $post, $update); // Re-add the save post action to avoid loops add_action('save_post_mdjm-venue', 'mdjm_save_venue_post', 10, 3); }
/** * Can we export? * * @access public * @since 1.4 * @return bool Whether we can export or not */ public function can_export() { return (bool) apply_filters('mdjm_export_capability', mdjm_employee_can('run_reports')); }
/** * Save the meta data for the contract * * @since 1.3 * @param int $post_id The current post ID. * @param obj $post The current post object (WP_Post). * @param bool $update Whether this is an existing post being updated or not. * @return void */ function mdjm_save_contract_post($post_id, $post, $update) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if (empty($update)) { return; } // Permission Check if (!mdjm_employee_can('manage_templates')) { if (MDJM_DEBUG == true) { MDJM()->debug->log_it('PERMISSION ERROR: User ' . get_current_user_id() . ' is not allowed to edit contracts'); } return; } // Remove the save post action to avoid loops remove_action('save_post_contract', 'mdjm_save_contract_post', 10, 3); // Fire our pre-save hook do_action('mdjm_pre_contract_save', $post_id, $post, $update); // Current value of the contract description for comaprison. $current_desc = get_post_meta($ID, '_contract_description', true); // If we have a value and the key did not exist previously, add it. if (!empty($_POST['contract_description']) && empty($current_desc)) { add_post_meta($ID, '_contract_description', $_POST['contract_description'], true); } elseif (!empty($_POST['contract_description']) && $current_desc != $_POST['contract_description']) { update_post_meta($ID, '_contract_description', $_POST['contract_description']); } elseif (empty($_POST['contract_description']) && !empty($current_desc)) { delete_post_meta($ID, '_contract_description'); } // Fire our post save hook do_action('mdjm_post_contract_save', $post_id, $post, $update); // Re-add the save post action to avoid loops add_action('save_post_contract', 'mdjm_save_contract_post', 10, 3); }
function mdjm_dashboard() { global $mdjm, $my_mdjm, $current_user; if (!class_exists('MDJM_Dashboard')) { require_once MDJM_PLUGIN_DIR . '/includes/admin/mdjm-dashboard.php'; $mdjm_dash = new MDJM_Dashboard(); } wp_enqueue_script('youtube-subscribe'); ?> <?php mdjm_insert_datepicker(array('class' => 'check_custom_date', 'altfield' => 'check_date', 'mindate' => 'today')); ?> <div class="wrap"> <h1>MDJM Event Management - <?php echo $current_user->display_name; ?> (<?php if (!current_user_can('manage_options')) { echo 'DJ'; } else { echo 'Admin'; } ?> )</h1> <hr /> <h2> <?php //$dj_event_count = MDJM()->events->count_events_by_status( 'dj', get_current_user_id() ); ?> </h2> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat"> <tr> <td width="60%"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat"> <tr> <td colspan="2" class="alternate"><strong><?php printf(__('Monthly %s Overview for %s', 'mobile-dj-manager'), mdjm_get_option('artist'), date('F Y')); ?> </strong></td> </tr> <tr> <td width="30%"><?php _e('Active Bookings', 'mobile-dj-manager'); ?> :</td> <td width="70%"><?php echo mdjm_count_employee_events('', array('post_status' => mdjm_active_event_statuses(), 'date' => array(date('Y-m-01'), date('Y-m-t')), 'date_compare' => 'BETWEEN')); ?> </td> </tr> <?php if (mdjm_employee_can('read_events')) { ?> <tr> <td><a href="<?php echo mdjm_get_admin_page('enquiries') . '&mdjm_filter_type&mdjm_filter_date=' . date('Ym'); ?> ">Outstanding Enquiries:</a></td> <td><?php echo $dj_event_count['enquiry_month'] + $dj_event_count['unattended_month'] . (!empty($dj_event_count['unattended_month']) && $dj_event_count['unattended_month'] > 0 ? ' (<a href="' . mdjm_get_admin_page('unattended') . '&mdjm_filter_date=' . date('Ym') . '">' . $dj_event_count['unattended_month'] . ' Unattended)</a>' : ''); ?> </td> </tr> <tr> <td><a href="<?php echo mdjm_get_admin_page('events') . '&post_status=mdjm-lost&mdjm_filter_date=' . date('Ym') . '&mdjm_filter_type'; ?> ">Lost Enquiries:</a></td> <td><?php echo $dj_event_count['lost_month']; ?> </td> </tr> <?php } ?> <tr> <td><a href="<?php echo mdjm_get_admin_page('events') . '&post_status=mdjm-completed&mdjm_filter_date=' . date('Ym') . '&mdjm_filter_type'; ?> ">Completed Bookings:</a></td> <td><?php echo $dj_event_count['completed_month']; ?> </td> </tr> <?php if (mdjm_employee_can('manage_events')) { ?> <tr> <td>Potential Earnings: </td> <td><?php echo $mdjm_dash->period_earnings('month', $current_user->ID, false); ?> </td> </tr> <?php } ?> <tr> <td>Earnings so Far:</td> <td><?php echo $mdjm_dash->period_earnings('month', $current_user->ID, true); ?> </td> </tr> <tr> <td colspan="2" class="alternate"><strong>Annual DJ Overview for <?php echo date('Y'); ?> </strong></td> </tr> <?php if (mdjm_employee_can('manage_events')) { ?> <tr> <td><a href="<?php echo mdjm_get_admin_page('enquiries'); ?> ">Outstanding Enquiries:</a></td> <td><?php echo $dj_event_count['enquiry_year'] + $dj_event_count['unattended_year'] . (!empty($dj_event_count['unattended_year']) && $dj_event_count['unattended_year'] > 0 ? ' (<a href="' . mdjm_get_admin_page('unattended') . '&mdjm_filter_date=' . date('Ym') . '">' . $dj_event_count['unattended_year'] . ' Unattended)</a>' : ''); ?> </td> </tr> <tr> <td>Lost Enquiries:</td> <td><?php echo $dj_event_count['lost_year']; ?> </td> </tr> <?php } ?> <tr> <td>Completed Bookings:</td> <td><?php echo $dj_event_count['completed_year']; ?> </td> </tr> <?php if (mdjm_employee_can('manage_events')) { ?> <tr> <td>Potential Earnings:</td> <td><?php echo $mdjm_dash->period_earnings('year', $current_user->ID, false); ?> </td> </tr> <?php } ?> <tr> <td>Earnings so Far:</td> <td><?php echo $mdjm_dash->period_earnings('year', $current_user->ID, true); ?> </td> </tr> </table> </td> <td width="40%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat"> <tr> <td colspan="2" class="alternate"><strong><?php echo date('l jS F Y'); ?> </strong></td> </tr> <tr> <td width="35%">Your Status:</td> <?php $next_event = MDJM()->events->next_event($current_user->ID, 'dj'); if (!empty($next_event)) { $eventinfo = MDJM()->events->event_detail($next_event[0]->ID); } ?> <td width="65%"> <?php echo isset($eventinfo) && date('Y-m-d', $eventinfo['date']) == date('Y-m-d') ? '<a href="' . get_edit_post_link($next_event[0]->ID) . '">Booked from ' . $eventinfo['start'] . '</a>' : 'Available'; ?> </td> </tr> <?php if (current_user_can('administrator') && MDJM_MULTI == true) { $bookings_today = MDJM()->events->employee_bookings(); ?> <tr> <td>Employee Bookings:</td> <?php if (empty($bookings_today)) { ?> <td>None</td> <?php } else { echo '<td>'; $i = 1; foreach ($bookings_today as $event) { $eventinfo = MDJM()->events->event_detail($event->ID); echo '<a href="' . get_edit_post_link($event->ID) . '">' . $eventinfo['dj']->display_name . ' from ' . $eventinfo['start'] . '</a>' . ($i < count($bookings_today) ? '<br />' : ''); $i++; } echo '</td>'; } ?> </tr> <?php } ?> <form name="availability-check" id="availability-check" method="post" action="<?php echo mdjm_get_admin_page('availability'); ?> "> <?php if (!current_user_can('administrator')) { ?> <input type="hidden" name="check_employee" id="check_employee" value="<?php echo get_current_user_id(); ?> " /><?php } else { ?> <input type="hidden" name="check_employee" id="check_employee" value="all" /><?php } ?> <tr> <td><label for="show_check_date">Availability Check:</label></th> <td><input type="text" name="show_check_date" id="show_check_date" class="check_custom_date" required="required" /> <input type="hidden" name="check_date" id="check_date" /> <?php submit_button('Check Date', 'primary small', 'submit', false, ''); ?> </td> </tr> </form> <tr> <td colspan="2"><p><a href="http://twitter.com/mobiledjmanager" class="twitter-follow-button" data-show-count="false">Follow @mobiledjmanager</a> <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script></p> <p><div class="g-ytsubscribe" data-channelid="UCaD6icd6OZ8haoTBc5YjJrw" data-layout="default" data-count="hidden"></div></p></td> </tr> <tr class="alternate"> <td colspan="2"><strong>Your 7 Day Schedule</strong></td> </tr> <tr> <td colspan="2"><?php get_availability_activity(0, 0); ?> </td> </tr> </table></td> </tr> </table> <?php if (current_user_can('administrator') && MDJM_MULTI == true) { $emp_event_count = MDJM()->events->count_events_by_status(); ?> <hr /> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat"> <tr> <td width="60%"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat"> <tr> <td colspan="2" class="alternate"><strong>Monthly Employer Overview for <?php echo date('F Y'); ?> </strong></td> </tr> <tr> <td width="30%">Active Bookings:</td> <td width="70%"><?php echo $emp_event_count['active_month']; ?> </td> </tr> <tr> <td><a href="<?php echo mdjm_get_admin_page('enquiries') . '&mdjm_filter_type&mdjm_filter_date=' . date('Ym'); ?> ">Outstanding Enquiries:</a></td> <td><?php echo $emp_event_count['enquiry_month'] + $emp_event_count['unattended_month'] . (!empty($emp_event_count['unattended_month']) && $emp_event_count['unattended_month'] > 0 ? ' (<a href="' . mdjm_get_admin_page('unattended') . '&mdjm_filter_date=' . date('Ym') . '">' . $emp_event_count['unattended_month'] . ' Unattended)</a>' : ''); ?> </td> </tr> <tr> <td>Lost Enquiries:</td> <td><?php echo $emp_event_count['lost_month']; ?> </td> </tr> <tr> <td>Completed Bookings:</td> <td><?php echo $emp_event_count['completed_month']; ?> </td> </tr> <tr> <td>Potential Earnings:</td> <td><?php echo $mdjm_dash->period_earnings('month', '', false); ?> </td> </tr> <tr> <td>Earnings so Far:</td> <td><?php echo $mdjm_dash->period_earnings('month', '', true); ?> </td> </tr> <tr> <td colspan="2" class="alternate"><strong>Annual Employer Overview for <?php echo date('Y'); ?> </strong></td> </tr> <tr> <td><a href="<?php echo mdjm_get_admin_page('enquiries') . '&mdjm_filter_type&mdjm_filter_date=' . date('Ym'); ?> ">Outstanding Enquiries:</a></td> <td><?php echo $emp_event_count['enquiry_year'] + $emp_event_count['unattended_year'] . (!empty($emp_event_count['unattended_year']) && $emp_event_count['unattended_year'] > 0 ? ' (<a href="' . mdjm_get_admin_page('unattended') . '&mdjm_filter_date=' . date('Ym') . '">' . $emp_event_count['unattended_year'] . ' Unattended)</a>' : ''); ?> </tr> <tr> <td>Lost Enquiries:</td> <td><?php echo $emp_event_count['lost_year']; ?> </td> </tr> <tr> <td>Completed Bookings:</td> <td><?php echo $emp_event_count['completed_year']; ?> </td> </tr> <tr> <td>Potential Earnings:</td> <td><?php echo $mdjm_dash->period_earnings('year', '', false); ?> </td> </tr> <tr> <td>Earnings so Far:</td> <td><?php echo $mdjm_dash->period_earnings('year', '', true); ?> </td> </tr> </table></td> <td width="40%" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="widefat"> <tr> <td width="100%" class="alternate"><strong>Latest News from <a href="<?php mdjm_get_admin_page('mydjplanner'); ?> ">My DJ Planner</a></strong></td> </tr> <tr> <td><?php wp_widget_rss_output('http://www.mydjplanner.co.uk/category/news/feed/rss2/', $args = array('show_author' => 0, 'show_date' => 1, 'show_summary' => 1, 'items' => 3)); ?> </td> </tr> <tr> <td width="100%" class="alternate"><strong>Latest Support Topics</strong></td> </tr> <tr> <td><?php wp_widget_rss_output('http://www.mydjplanner.co.uk/forums/feed/?post_type=topic', $args = array('show_author' => 0, 'show_date' => 0, 'show_summary' => 0, 'items' => 3)); ?> </td> </tr> </table> </td> </tr> </table> <?php } ?> </div> <?php }
/** * Add event count to At a glance widget * * @since 1.4 * @return void */ function mdjm_dashboard_at_a_glance_widget($items) { $num_posts = mdjm_count_events(); $count = 0; $statuses = mdjm_all_event_status(); foreach ($statuses as $status => $label) { if (!empty($num_posts->{$status})) { $count += $num_posts->{$status}; } } if ($num_posts && $count > 0) { $text = _n('%s ' . mdjm_get_label_singular(), '%s ' . mdjm_get_label_plural(), $count, 'mobile-dj-manager'); $text = sprintf($text, number_format_i18n($count)); if (mdjm_employee_can('read_events')) { $text = sprintf('<a class="event-count" href="edit.php?post_type=mdjm-event">%1$s</a>', $text); } else { $text = sprintf('<span class="event-count">%1$s</span>', $text); } $items[] = $text; } return $items; }
/** * Generate a list of all event employees and output as a HTML table. * * @since 1.3 * @param * @return */ function mdjm_do_event_employees_list_table($event_id) { global $wp_roles; $employees = mdjm_get_event_employees_data($event_id); if (!$employees) { return; } ?> <table class="widefat mdjm_event_employee_list"> <thead> <tr> <th style="text-align:left; width:25%;"><?php _e('Role', 'mobile-dj-manager'); ?> </th> <th style="text-align:left; width:25%;"><?php _e('Name', 'mobile-dj-manager'); ?> </th> <th style="text-align:left; width:20%;"><?php _e('Wage', 'mobile-dj-manager'); ?> </th> <th style="text-align:left;"><?php _e('Status', 'mobile-dj-manager'); ?> </th> </tr> </thead> <tbody> <?php foreach ($employees as $employee) { ?> <tr class="mdjm_field_wrapper"> <td><?php echo translate_user_role($wp_roles->roles[$employee['role']]['name']); ?> </td> <td><?php echo mdjm_get_employee_display_name($employee['id']); ?> </td> <td> <?php if (mdjm_get_option('enable_employee_payments') && mdjm_employee_can('manage_txns')) { ?> <?php echo mdjm_currency_filter(mdjm_sanitize_amount($employee['wage'])); ?> <?php } ?> </td> <td> <?php if (mdjm_employee_can('mdjm_event_edit')) { ?> <?php if ('paid' != mdjm_get_employees_event_payment_status($event_id, $employee['id'])) { ?> <?php printf(__('<a class="button button-secondary button-small remove_event_employee" style="margin: 6px 0 10px;" data-employee_id="%1$d" id="remove-employee-%1$d">Remove</a>', 'mobile-dj-manager'), $employee['id']); ?> <?php } elseif (mdjm_get_option('enable_employee_payments')) { ?> <?php printf(__('<a href="%s">Paid</a>', 'mobile-dj-manager'), !empty($employee['txn_id']) ? get_edit_post_link($employee['txn_id']) : ''); ?> <?php } ?> <?php } ?> </td> </tr> <?php } ?> </tbody> </table> <?php }
function mdjm_admin_toolbar($admin_bar) { if (!current_user_can('mdjm_employee')) { return; } // Build out the toolbar menu structure $admin_bar->add_menu(array('id' => 'mdjm', 'title' => sprintf(__('MDJM %s', 'mobile-dj-manager'), mdjm_get_label_plural()), 'href' => mdjm_employee_can('read_events') ? admin_url('edit.php?post_type=mdjm-event') : '#', 'meta' => array('title' => __('MDJM Event Management', 'mobile-dj-manager')))); if (mdjm_employee_can('read_events')) { // Events $admin_bar->add_menu(array('id' => 'mdjm-events', 'parent' => 'mdjm', 'title' => mdjm_get_label_plural(), 'href' => admin_url('edit.php?post_type=mdjm-event'), 'meta' => array('title' => sprintf(__('MDJM %s', 'mobile-dj-manager'), mdjm_get_label_plural())))); } if (mdjm_employee_can('manage_all_events')) { $admin_bar->add_menu(array('id' => 'mdjm-add-events', 'parent' => 'mdjm-events', 'title' => sprintf(__('Create %s', 'mobile-dj-manager'), mdjm_get_label_singular()), 'href' => admin_url('post-new.php?post_type=mdjm-event'), 'meta' => array('title' => sprintf(__('Create New %s', 'mobile-dj-manager'), mdjm_get_label_singular())))); // Enquiries $event_status = array('mdjm-unattended' => __('Unattended Enquiries', 'mobile-dj-manager'), 'mdjm-enquiry' => __('View Enquiries', 'mobile-dj-manager')); foreach ($event_status as $current_status => $display) { $status_count = MDJM()->events->mdjm_count_event_status($current_status); if (!$status_count) { continue; } $admin_bar->add_menu(array('id' => 'mdjm-' . str_replace(' ', '-', strtolower($display)), 'parent' => 'mdjm-events', 'title' => $display . ' (' . $status_count . ')', 'href' => admin_url('edit.php?post_status=' . $current_status . '&post_type=mdjm-event'), 'meta' => array('title' => $display))); } // Event Types $admin_bar->add_menu(array('id' => 'mdjm-event-types', 'parent' => 'mdjm-events', 'title' => sprintf(__('%s Types', 'mobile-dj-manager'), mdjm_get_label_singular()), 'href' => admin_url('edit-tags.php?taxonomy=event-types&post_type=mdjm-event'), 'meta' => array('title' => sprintf(__('Manage %s Types', 'mobile-dj-manager'), mdjm_get_label_singular())))); // Playlist Categories $admin_bar->add_menu(array('id' => 'mdjm-playlist-cats', 'parent' => 'mdjm-events', 'title' => __('Playlist Categories', 'mobile-dj-manager'), 'href' => admin_url('edit-tags.php?taxonomy=playlist-category&post_type=mdjm-playlist'), 'meta' => array('title' => __('Manage Playlist Categories', 'mobile-dj-manager')))); // Enquiry Sources $admin_bar->add_menu(array('id' => 'mdjm-enquiry-sources', 'parent' => 'mdjm-events', 'title' => __('Enquiry Sources', 'mobile-dj-manager'), 'href' => admin_url('edit-tags.php?taxonomy=enquiry-source&post_type=mdjm-event'), 'meta' => array('title' => __('Manage Enquiry Sources', 'mobile-dj-manager')))); } // Dashboard /*$admin_bar->add_menu( array( 'id' => 'mdjm-dashboard', 'parent' => 'mdjm', 'title' => __( 'Dashboard', 'mobile-dj-manager' ), 'href' => admin_url( 'admin.php?page=mdjm-dashboard' ), 'meta' => array( 'title' => __( 'MDJM Dashboard', 'mobile-dj-manager' ), ), ) ); */ // Settings if (mdjm_is_admin()) { $admin_bar->add_menu(array('id' => 'mdjm-settings', 'parent' => 'mdjm', 'title' => __('Settings', 'mobile-dj-manager'), 'href' => admin_url('admin.php?page=mdjm-settings'), 'meta' => array('title' => __('MDJM Settings', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'mdjm-settings-general', 'parent' => 'mdjm-settings', 'title' => __('General', 'mobile-dj-manager'), 'href' => admin_url('admin.php?page=mdjm-settings&tab=general'), 'meta' => array('title' => __('MDJM General Settings', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'mdjm-settings-events', 'parent' => 'mdjm-settings', 'title' => mdjm_get_label_plural(), 'href' => admin_url('admin.php?page=mdjm-settings&tab=events'), 'meta' => array('title' => __('MDJM Event Settings', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'mdjm-settings-permissions', 'parent' => 'mdjm-settings', 'title' => __('Permissions', 'mobile-dj-manager'), 'href' => admin_url('admin.php?page=mdjm-settings&tab=general§ion=mdjm_app_permissions'), 'meta' => array('title' => __('MDJM Permission Settings', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'mdjm-settings-emails', 'parent' => 'mdjm-settings', 'title' => sprintf(__('Email %s Template Settings', 'mobile-dj-manager'), '&'), 'href' => admin_url('admin.php?page=mdjm-settings&tab=emails'), 'meta' => array('title' => sprintf(__('MDJM Email %s Template Settings', 'mobile-dj-manager'), '&')))); $admin_bar->add_menu(array('id' => 'mdjm-settings-client-zone', 'parent' => 'mdjm-settings', 'title' => sprintf(__('%s Settings', 'mobile-dj-manager'), mdjm_get_option('app_name', __('Client Zone', 'mobile-dj-manager'))), 'href' => admin_url('admin.php?page=mdjm-settings&tab=client_zone'), 'meta' => array('title' => sprintf(__('%s Settings', 'mobile-dj-manager'), mdjm_get_option('app_name', __('Client Zone', 'mobile-dj-manager')))))); $admin_bar->add_menu(array('id' => 'mdjm-settings-payments', 'parent' => 'mdjm-settings', 'title' => __('Payment Settings', 'mobile-dj-manager'), 'href' => admin_url('admin.php?page=mdjm-settings&tab=payments'), 'meta' => array('title' => __('MDJM Payment Settings', 'mobile-dj-manager')))); } do_action('mdjm_admin_bar_settings_items', $admin_bar); if (mdjm_is_employer() && mdjm_employee_can('manage_employees')) { // Employees $admin_bar->add_menu(array('id' => 'mdjm-employees', 'parent' => 'mdjm', 'title' => __('Employees', 'mobile-dj-manager'), 'href' => admin_url('admin.php?page=mdjm-employees'), 'meta' => array('title' => __('Employees', 'mobile-dj-manager')))); } if (mdjm_is_admin()) { // Employee Availability $admin_bar->add_menu(array('id' => 'mdjm-availability', 'parent' => mdjm_is_employer() ? 'mdjm-employees' : 'mdjm', 'title' => __('Employee Availability', 'mobile-dj-manager'), 'href' => admin_url('admin.php?page=mdjm-availability'), 'meta' => array('title' => __('Employee Availability', 'mobile-dj-manager')))); // Automated Tasks $admin_bar->add_menu(array('id' => 'mdjm-tasks', 'parent' => 'mdjm', 'title' => __('Automated Tasks', 'mobile-dj-manager'), 'href' => admin_url('admin.php?page=mdjm-tasks'), 'meta' => array('title' => __('Automated Tasks', 'mobile-dj-manager')))); } if (mdjm_employee_can('view_clients_list')) { // Clients $admin_bar->add_menu(array('id' => 'mdjm-clients', 'parent' => 'mdjm', 'title' => __('Clients', 'mobile-dj-manager'), 'href' => admin_url('admin.php?page=mdjm-clients'), 'meta' => array('title' => __('Clients', 'mobile-dj-manager')))); } if (mdjm_employee_can('list_all_clients')) { $admin_bar->add_menu(array('id' => 'mdjm-add-client', 'parent' => 'mdjm-clients', 'title' => __('Add Client', 'mobile-dj-manager'), 'href' => admin_url('user-new.php'), 'meta' => array('title' => __('Add New Client', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'mdjm-custom-client-fields', 'parent' => 'mdjm-clients', 'title' => __('Custom Client Fields', 'mobile-dj-manager'), 'href' => admin_url('admin.php?page=mdjm-custom-client-fields'), 'meta' => array('title' => __('Custom Client Field', 'mobile-dj-manager')))); } // Communications if (mdjm_employee_can('send_comms')) { $admin_bar->add_menu(array('id' => 'mdjm-comms', 'parent' => 'mdjm', 'title' => __('Communications', 'mobile-dj-manager'), 'href' => admin_url('admin.php?page=mdjm-comms'), 'meta' => array('title' => __('Communications', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'edit.php?post_type=mdjm_communication', 'parent' => 'mdjm-comms', 'title' => __('Communication History', 'mobile-dj-manager'), 'href' => admin_url('edit.php?post_type=mdjm_communication'), 'meta' => array('title' => __('Communication History', 'mobile-dj-manager')))); } // Filter for MDJM DCF Admin Bar Items do_action('mdjm_dcf_admin_bar_items', $admin_bar); if (mdjm_employee_can('manage_templates')) { // Contract Templates $admin_bar->add_menu(array('id' => 'mdjm-contracts', 'parent' => 'mdjm', 'title' => __('Contract Templates', 'mobile-dj-manager'), 'href' => admin_url('edit.php?post_type=contract'), 'meta' => array('title' => __('Contract Templates', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'mdjm-new-contract', 'parent' => 'mdjm-contracts', 'title' => __('Add Contract Template', 'mobile-dj-manager'), 'href' => admin_url('post-new.php?post_type=contract'), 'meta' => array('title' => __('New Contract Template', 'mobile-dj-manager')))); } if (mdjm_employee_can('manage_templates')) { // Email Templates $admin_bar->add_menu(array('id' => 'mdjm-email-templates', 'parent' => 'mdjm', 'title' => __('Email Templates', 'mobile-dj-manager'), 'href' => admin_url('edit.php?post_type=email_template'), 'meta' => array('title' => __('Email Templates', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'mdjm-new-email-template', 'parent' => 'mdjm-email-templates', 'title' => __('Add Template', 'mobile-dj-manager'), 'href' => admin_url('post-new.php?post_type=email_template'), 'meta' => array('title' => __('New Email Template', 'mobile-dj-manager')))); } // Equipment Packages & Add-ons if (mdjm_packages_enabled() && mdjm_employee_can('manage_packages')) { $admin_bar->add_menu(array('id' => 'mdjm-packages', 'parent' => 'mdjm', 'title' => __('Packages', 'mobile-dj-manager'), 'href' => admin_url('edit.php?post_type=mdjm-package'), 'meta' => array('title' => __('Packages', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'mdjm-package-cats', 'parent' => 'mdjm-packages', 'title' => __('Package Categories', 'mobile-dj-manager'), 'href' => admin_url('edit-tags.php?taxonomy=package-category&post_type=mdjm-package'), 'meta' => array('title' => __('Package Categories', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'mdjm-addons', 'parent' => 'mdjm-packages', 'title' => __('Add-ons', 'mobile-dj-manager'), 'href' => admin_url('edit.php?post_type=mdjm-addon'), 'meta' => array('title' => __('Add-ons', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'mdjm-addon-cats', 'parent' => 'mdjm-packages', 'title' => __('Addon Categories', 'mobile-dj-manager'), 'href' => admin_url('edit-tags.php?taxonomy=addon-category&post_type=mdjm-addon'), 'meta' => array('title' => __('Addon Categories', 'mobile-dj-manager')))); } // Custom Event Fields if (mdjm_is_admin()) { $admin_bar->add_menu(array('id' => 'mdjm-event-fields', 'parent' => 'mdjm-events', 'title' => sprintf(__('Custom %s Fields', 'mobile-dj-manager'), mdjm_get_label_singular()), 'href' => admin_url('admin.php?page=mdjm-custom-event-fields'), 'meta' => array('title' => sprintf(__('Manage Custom %s Fields', 'mobile-dj-manager'), mdjm_get_label_singular())))); } // Event Quotes if (mdjm_get_option('online_enquiry', false) && mdjm_employee_can('list_own_quotes')) { $admin_bar->add_menu(array('id' => 'mdjm-event-quotes', 'parent' => 'mdjm-events', 'title' => sprintf(__('%s Quotes', 'mobile-dj-manager'), mdjm_get_label_singular()), 'href' => admin_url('edit.php?post_type=mdjm-quotes'), 'meta' => array('title' => sprintf(__('View %s Quotes', 'mobile-dj-manager'), mdjm_get_label_singular())))); } // Reporting /*if( current_user_can( 'manage_options' ) ) { $admin_bar->add_menu( array( 'id' => 'mdjm-reports', 'parent' => 'mdjm', 'title' => __( 'Reports', 'mobile-dj-manager' ), 'href' => admin_url( 'admin.php?page=mdjm-reports' ), 'meta' => array( 'title' => __( 'MDJM Reports', 'mobile-dj-manager' ), ), ) ); }*/ if (mdjm_employee_can('edit_txns')) { // Transactions $admin_bar->add_menu(array('id' => 'mdjm-transactions', 'parent' => 'mdjm', 'title' => __('Transactions', 'mobile-dj-manager'), 'href' => 'edit.php?post_type=mdjm-transaction', 'meta' => array('title' => __('MDJM Transactions', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'mdjm-add-transaction', 'parent' => 'mdjm-transactions', 'title' => __('Add Transaction', 'mobile-dj-manager'), 'href' => admin_url('post-new.php?post_type=mdjm-transaction'), 'meta' => array('title' => __('Add Transaction', 'mobile-dj-manager')))); // Transaction Types $admin_bar->add_menu(array('id' => 'mdjm-transaction-types', 'parent' => 'mdjm-transactions', 'title' => __('Transaction Types', 'mobile-dj-manager'), 'href' => admin_url('edit-tags.php?taxonomy=transaction-types&post_type=mdjm-transaction'), 'meta' => array('title' => __('View / Edit Transaction Types', 'mobile-dj-manager')))); } if (mdjm_employee_can('list_venues')) { // Venues $admin_bar->add_menu(array('id' => 'mdjm-venues', 'parent' => 'mdjm', 'title' => __('Venues', 'mobile-dj-manager'), 'href' => admin_url('edit.php?post_type=mdjm-venue'), 'meta' => array('title' => __('Venues', 'mobile-dj-manager')))); if (mdjm_employee_can('add_venues')) { $admin_bar->add_menu(array('id' => 'mdjm-add-venue', 'parent' => 'mdjm-venues', 'title' => __('Add Venue', 'mobile-dj-manager'), 'href' => admin_url('post-new.php?post_type=mdjm-venue'), 'meta' => array('title' => __('Add New Venue', 'mobile-dj-manager')))); $admin_bar->add_menu(array('id' => 'mdjm-venue-details', 'parent' => 'mdjm-venues', 'title' => __('Venue Details', 'mobile-dj-manager'), 'href' => admin_url('edit-tags.php?taxonomy=venue-details&post_type=mdjm-venue'), 'meta' => array('title' => __('View / Edit Venue Details', 'mobile-dj-manager')))); } } // MDJM Links $admin_bar->add_menu(array('id' => 'mdjm-user-guides', 'parent' => 'mdjm', 'title' => sprintf(__('%sDocumentation%s', 'mobile-dj-manager'), '<span style="color:#F90">', '</span>'), 'href' => 'http://mdjm.co.uk/support/', 'meta' => array('title' => __('Documentation', 'mobile-dj-manager'), 'target' => '_blank'))); $admin_bar->add_menu(array('id' => 'mdjm-support', 'parent' => 'mdjm', 'title' => sprintf(__('%sSupport%s', 'mobile-dj-manager'), '<span style="color:#F90">', '</span>'), 'href' => 'http://www.mydjplanner.co.uk/forums/', 'meta' => array('title' => __('MDJM Support Forums', 'mobile-dj-manager'), 'target' => '_blank'))); }
function f_mdjm_edit_task($task) { global $mdjm_settings; $mdjm_schedules = get_option('mdjm_schedules'); if (isset($mdjm_schedules[$task]['default']) && $mdjm_schedules[$task]['default'] == 'Y') { $ro = ' readonly'; } else { $ro = ''; } ?> <h2>Edit Task</h2> <form name="form_task_edit" method="post" action="<?php echo mdjm_get_admin_page('tasks') . '&task_updated=1'; ?> "> <input type="hidden" name="slug" value="<?php echo $mdjm_schedules[$task]['slug']; ?> " /> <table class="widefat"> <tr> <td width="75%"> <table class="widefat"> <tr> <th colspan="4" class="alternate"><strong><?php echo $mdjm_schedules[$task]['name']; ?> </strong></th> </tr> <tr> <th class="row-title" width="15%"><label for="name">Task Name:</label></th> <td width="35%"><input type="text" name="name" id="name" value="<?php echo $mdjm_schedules[$task]['name']; ?> "<?php echo $ro; ?> /></td> <th scope="row-title" width="15%"><label for="frequency">Frequency:</label></th> <td width="35%"><select name="frequency" id="frequency"> <option value="Hourly" <?php selected($mdjm_schedules[$task]['frequency'], 'Hourly'); ?> >Hourly</option> <option value="Daily" <?php selected($mdjm_schedules[$task]['frequency'], 'Daily'); ?> >Daily</option> <option value="Twice Daily" <?php selected($mdjm_schedules[$task]['frequency'], 'Twice Daily'); ?> >Twice Daily</option> <option value="Weekly" <?php selected($mdjm_schedules[$task]['frequency'], 'Weekly'); ?> >Weekly</option> <option value="Monthly" <?php selected($mdjm_schedules[$task]['frequency'], 'Monthly'); ?> >Monthly</option> <option value="Yearly" <?php selected($mdjm_schedules[$task]['frequency'], 'Yearly'); ?> >Yearly</option> </select> </td> </tr> <tr> <th class="row-title"><label for="desc">Description:</label></th> <td colspan="3"><textarea name="desc" id="desc" cols="60" rows="2"><?php echo esc_attr(stripslashes($mdjm_schedules[$task]['desc'])); ?> </textarea></td> </tr> <?php if ($mdjm_schedules[$task]['slug'] != 'upload-playlists') { ?> <tr> <th scope="row-title">Notifications:</th> <td colspan="3"><label for="notify_admin">Admin</label> <input type="checkbox" name="notify_admin" id="notify_admin" value="Y" <?php checked($mdjm_schedules[$task]['options']['notify_admin'], 'Y'); ?> /> <?php if (mdjm_employee_can('edit_txns')) { ?> <label for="notify_dj">DJ</label> <input type="checkbox" name="notify_dj" id="notify_dj" value="Y" <?php checked($mdjm_schedules[$task]['options']['notify_dj'], 'Y'); ?> /> <?php } else { echo '<input type="hidden" name="notify_dj" id="notify_dj" value="N" />' . "\r\n"; } ?> <span class="description">Who to notify when the task completes</span> </td> </tr> <?php } if ($mdjm_schedules[$task]['slug'] != 'upload-playlists' && $mdjm_schedules[$task]['slug'] != 'purge-clients') { ?> <th scope="row-title"><label for="event_execute_time">Run:</label></th> <td colspan="3"><select name="event_execute_time" id="event_execute_time"> <?php if ($mdjm_schedules[$task]['options']['run_when'] != '0') { $when = explode(' ', $mdjm_schedules[$task]['options']['age']); } if ($mdjm_schedules[$task]['slug'] != 'fail-enquiry') { ?> <option value="N/A">N/A</option> <?php } ?> <option value="1"<?php selected($when[0], '1'); ?> >1</option> <option value="2"<?php selected($when[0], '2'); ?> >2</option> <option value="3"<?php selected($when[0], '3'); ?> >3</option> <option value="4"<?php selected($when[0], '4'); ?> >4</option> <option value="5"<?php selected($when[0], '5'); ?> >5</option> <option value="6"<?php selected($when[0], '6'); ?> >6</option> <option value="7"<?php selected($when[0], '7'); ?> >7</option> <option value="8"<?php selected($when[0], '8'); ?> >8</option> <option value="9"<?php selected($when[0], '9'); ?> >9</option> <option value="10"<?php selected($when[0], '10'); ?> >10</option> <option value="11"<?php selected($when[0], '11'); ?> >11</option> <option value="12"<?php selected($when[0], '12'); ?> >12</option> </select> <select name="event_execute_period" id="event_execute_period"> <?php if ($mdjm_schedules[$task]['slug'] != 'fail-enquiry') { ?> <option value="N/A">N/A</option> <?php } ?> <option value="HOUR"<?php selected($when[1], 'HOUR'); ?> >Hour(s)</option> <option value="DAY"<?php selected($when[1], 'DAY'); ?> >Day(s)</option> <option value="WEEK"<?php selected($when[1], 'WEEK'); ?> >Week(s)</option> <option value="MONTH"<?php selected($when[1], 'MONTH'); ?> >Month(s)</option> </select> <select name="execute_when" id="execute_when"> <?php if ($mdjm_schedules[$task]['slug'] != 'fail-enquiry' && $mdjm_schedules[$task]['slug'] != 'request-deposit') { ?> <option value="N/A">N/A</option> <?php } ?> <option value="after_approval"<?php selected($mdjm_schedules[$task]['options']['run_when'], 'after_approval'); ?> >After Contract Accepted</option> <?php if ($mdjm_schedules[$task]['slug'] != 'request-deposit') { ?> <option value="event_created"<?php selected($mdjm_schedules[$task]['options']['run_when'], 'event_created'); ?> >After Enquiry Created</option> <?php } if ($mdjm_schedules[$task]['slug'] != 'fail-enquiry' && $mdjm_schedules[$task]['slug'] != 'request-deposit') { ?> <option value="before_event"<?php selected($mdjm_schedules[$task]['options']['run_when'], 'before_event'); ?> >Before Event Starts</option> <option value="after_event"<?php selected($mdjm_schedules[$task]['options']['run_when'], 'after_event'); ?> >After Event Finishes</option> <?php } ?> </select> </td> </tr> <?php if ($mdjm_schedules[$task]['slug'] == 'client-feedback') { echo '<tr>'; echo '<td colspan="4">'; echo '<span class="description">Note: This task will ignore all events completed over 1 month ago to avoid emailing clients whose events ended prior to that</span>'; echo '</td>'; echo '</tr>'; } } if ($mdjm_schedules[$task]['slug'] != 'upload-playlists' && $mdjm_schedules[$task]['slug'] != 'complete-events' && $mdjm_schedules[$task]['slug'] != 'fail-enquiry' && $mdjm_schedules[$task]['slug'] != 'purge-clients') { ?> <tr> <th class="alternate" colspan="4"><strong>Email Options</strong></th> </tr> <tr> <th scope="row-title"><label for="email_client">Emails Client:</label></th> <td><input type="checkbox" name="email_client" id="email_client" value="Y"<?php checked($mdjm_schedules[$task]['options']['email_client'], 'Y'); ?> /></td> <th scope="row-title"><label for="email_template">Template:</label></th> <td> <select name="email_template" id="email_template"> <option value="0"<?php selected($mdjm_schedules[$task]['options']['email_template'], '0'); ?> >None</option> <?php $email_template_args = array('post_type' => 'email_template', 'orderby' => 'name', 'order' => 'ASC', 'posts_per_page' => -1); $email_template_query = new WP_Query($email_template_args); if ($email_template_query->have_posts()) { while ($email_template_query->have_posts()) { $email_template_query->the_post(); echo '<option value="' . get_the_id() . '"'; if ($mdjm_schedules[$task]['options']['email_template'] == get_the_id()) { echo ' selected="selected"'; } echo '>' . get_the_title() . '</option>' . "\n"; } } wp_reset_postdata(); ?> </select> </td> </tr> <tr> <th scope="row-title"><label for="email_subject">Subject</label></th> <td><input type="text" name="email_subject" id="email_subject" class="regular-text" value="<?php echo esc_attr(stripslashes($mdjm_schedules[$task]['options']['email_subject'])); ?> " /></td> <th scope="row-title"><label for="email_from">From:</label></th> <td> <select name="email_from" id="email_from"> <option value="0" <?php selected($mdjm_schedules[$task]['options']['email_from'], '0'); ?> >N/A</option> <option value="admin" <?php selected($mdjm_schedules[$task]['options']['email_from'], 'admin'); ?> >Admin</option> <option value="dj" <?php selected($mdjm_schedules[$task]['options']['email_from'], 'dj'); ?> >DJ</option> </select> </td> </tr> <?php } ?> <tr> <td><?php submit_button('Update Task', 'primary', 'submit', false); ?> </td> <td colspan="3"><a class="button-secondary" href="<?php echo $_SERVER['HTTP_REFERER']; ?> " title="<?php _e('Back'); ?> "><?php _e('Back'); ?> </a></td> </tr> </table> </td> <td width="25%"> <?php /***** This is where we display the task overview */ ?> <table class="widefat"> <tr> <th colspan="2" class="alternate"><strong>Task Overview</strong></th> </tr> <tr> <td width="40%">Status:</td> <td><?php if ($mdjm_schedules[$task]['active'] == 'Y') { echo '<font style="color:#090">Active'; } else { echo '<font style="color:#F00">Inactive'; } ?> </font></td> </tr> <tr> <td>Frequency:</td> <td><?php echo $mdjm_schedules[$task]['frequency']; ?> </td> </tr> <tr> <td>Last Run:</td> <td><?php if ($mdjm_schedules[$task]['lastran'] != 'Never') { echo get_date_from_gmt(date('Y-m-d H:i:s', $mdjm_schedules[$task]['lastran']), MDJM_TIME_FORMAT . ' d M Y'); } else { echo $mdjm_schedules[$task]['lastran']; } ?> </td> </tr> <tr> <td>Next Run:</td> <td><?php if ($mdjm_schedules[$task]['nextrun'] != 'N/A') { echo get_date_from_gmt(date('Y-m-d H:i:s', $mdjm_schedules[$task]['nextrun']), MDJM_TIME_FORMAT . ' d M Y'); } else { echo $mdjm_schedules[$task]['nextrun']; } ?> </td> </tr> <tr> <td>Total Runs:</td> <td><?php echo $mdjm_schedules[$task]['totalruns']; ?> </td> </tr> <?php if ($mdjm_schedules[$task]['slug'] == 'upload-playlists' && $mdjm_schedules[$task]['active'] == 'Y') { ?> <tr> <td><?php _e('Pending Upload:', 'mobile-dj-manager'); ?> </td> <td><?php echo mdjm_get_pending_upload_playlist_entry_count(); ?> </td> </tr> <tr> <td><?php _e('Total Uploaded:', 'mobile-dj-manager'); ?> </td> <td><?php echo mdjm_get_uploaded_playlist_entry_count(); ?> </td> </tr> <?php } ?> </table> </td> </tr> </table> <?php }
/** * Actions taken once an event is set to the Unattended Enquiry Status * * @param int post_id The event (post) ID * obj post * * @return * @since 1.1.3 */ public function status_unattended($post_id, $post, $event_data, $field_updates) { global $mdjm, $mdjm_settings; if (MDJM_DEBUG == true) { MDJM()->debug->log_it('*** Starting Unattended Enquiry procedures ***' . "\r\n", true); } /* -- Permission Check -- */ if (!mdjm_employee_can('manage_events')) { return $post_id; } /* -- Update Journal with event creation -- */ if (MDJM_JOURNAL == true) { if (MDJM_DEBUG == true) { MDJM()->debug->log_it(' -- Adding journal entry'); } $this->add_journal(array('user' => get_current_user_id(), 'comment_content' => 'Event created via Admin <br /><br />' . (isset($field_updates) ? implode('<br />', $field_updates) : '') . '<br />(' . time() . ')', 'comment_type' => 'mdjm-journal'), array('type' => 'create-event', 'visibility' => '1')); } else { if (MDJM_DEBUG == true) { MDJM()->debug->log_it(' -- Journalling is disabled'); } } if (MDJM_DEBUG == true) { MDJM()->debug->log_it('*** Completed Unattended Enquiry procedures ***' . "\r\n", true); } }
/** * Display the send email form on the communications page. * * @since 1.3 * @param * @return Outputs the page content */ function mdjm_comms_page() { if (!mdjm_employee_can('send_comms')) { wp_die('<h1>' . __('Cheatin’ uh?') . '</h1>' . '<p>' . __('You do not have permission to access this page.', 'mobile-dj-manager') . '</p>', 403); } global $current_user; if (mdjm_employee_can('list_all_clients')) { $clients = mdjm_get_clients(); } else { $clients = mdjm_get_employee_clients(); } if (mdjm_employee_can('mdjm_employee_edit')) { $employees = mdjm_get_employees(); } ?> <div class="wrap"> <h1><?php _e('Client and Employee Communications', 'mobile-dj-manager'); ?> </h1> <form name="mdjm_form_send_comms" id="mdjm_form_send_comms" method="post" enctype="multipart/form-data"> <?php wp_nonce_field('send_comm_email', 'mdjm_nonce', true, true); ?> <?php mdjm_admin_action_field('send_comm_email'); ?> <input type="hidden" name="mdjm_email_from_address" id="mdjm_email_from_address" value="<?php echo $current_user->user_email; ?> " /> <input type="hidden" name="mdjm_email_from_name" id="mdjm_email_from_name" value="<?php echo $current_user->display_name; ?> " /> <?php do_action('mdjm_pre_comms_table'); ?> <table class="form-table"> <?php do_action('mdjm_add_comms_fields_before_recipient'); ?> <tr> <th scope="row"><label for="mdjm_email_to"><?php _e('Select a Recipient', 'mobile-dj-manager'); ?> </label></th> <td> <select name="mdjm_email_to" id="mdjm_email_to"> <option value=""><?php _e('Select a Recipient', 'mobile-dj-manager'); ?> </option> <optgroup label="<?php _e('Clients', 'mobile-dj-manager'); ?> "> <?php if (empty($clients)) { echo '<option disabled="disabled">' . __('No Clients Found', 'mobile-dj-manager') . '</option>'; } else { foreach ($clients as $client) { echo '<option value="' . $client->ID . '">' . $client->display_name . '</option>'; } } ?> </optgroup> <?php if (!empty($employees)) { echo '<optgroup label="' . __('Employees', 'mobile-dj-manager') . '">'; foreach ($employees as $employee) { echo '<option value="' . $employee->ID . '">' . $employee->display_name . '</option>'; } echo '</optgroup>'; } ?> </select> </td> </tr> <?php do_action('mdjm_add_comms_fields_before_subject'); ?> <tr> <th scope="row"><label for="mdjm_email_subject"><?php _e('Subject', 'mobile-dj-manager'); ?> </label></th> <td><input type="text" name="mdjm_email_subject" id="mdjm_email_subject" class="regular-text" value="<?php echo isset($_GET['template']) ? esc_attr(get_the_title($_GET['template'])) : ''; ?> " /></td> </tr> <tr> <th scope="row"><label for="mdjm_email_copy_to"><?php _e('Copy Yourself?', 'mobile-dj-manager'); ?> </label></th> <td><input type="checkbox" name="mdjm_email_copy_to" id="mdjm_email_copy_to" value="<?php echo $current_user->user_email; ?> " /> <span class="description"><?php _e('Settings may dictate that additional email copies are also sent', 'mobile-dj-manager'); ?> </span></td> </tr> <?php do_action('mdjm_add_comms_fields_before_template'); ?> <tr> <th scope="row"><label for="mdjm_email_template"><?php _e('Select a Template', 'mobile-dj-manager'); ?> </label></th> <td> <select name="mdjm_email_template" id="mdjm_email_template"> <option value="0"><?php _e('No Template', 'mobile-dj-manager'); ?> </option> <?php $template = isset($_GET['template']) ? $_GET['template'] : 0; ?> <?php echo mdjm_comms_template_options($template); ?> </select> </td> </tr> <?php do_action('mdjm_add_comms_fields_before_event'); ?> <tr> <th scope="row"><label for="mdjm_email_event"><?php printf(__('Associated %s', 'mobile-dj-manager'), mdjm_get_label_singular()); ?> </label></th> <td> <?php if (isset($_GET['event_id']) || isset($_GET['mdjm-action']) && $_GET['mdjm-action'] == 'respond_unavailable') { ?> <?php $value = mdjm_get_event_date($_GET['event_id']) . ' '; $value .= __('from', 'mobile-dj-manager') . ' '; $value .= mdjm_get_event_start($_GET['event_id']) . ' '; $value .= '(' . mdjm_get_event_status($_GET['event_id']) . ')'; ?> <input type="text" name="mdjm_email_event_show" id="mdjm_email_event_show" value="<?php echo $value; ?> " readonly="readonly" size="50" /> <input type="hidden" name="mdjm_email_event" id="mdjm_email_event" value="<?php echo $_GET['event_id']; ?> " /> <?php } else { ?> <select name="mdjm_email_event" id="mdjm_email_event"> <option value="0"><?php _e('Select an Event', 'mobile-dj-manager'); ?> </option> </select> <?php } ?> <p class="description"><?php printf(__('If no %s is selected <code>{event_*}</code> content tags may not be used', 'mobile-dj-manager'), mdjm_get_label_singular(true)); ?> </p> </td> </tr> <?php do_action('mdjm_add_comms_fields_before_file'); ?> <tr> <th scope="row"><label for="mdjm_email_upload_file"><?php _e('Attach a File', 'mobile-dj-manager'); ?> </label></th> <td><input type="file" name="mdjm_email_upload_file" id="mdjm_email_upload_file" class="regular-text" value="" /> <p class="description"><?php printf(__('Max file size %dMB. Change php.ini <code>post_max_size</code> to increase', 'mobile-dj-manager'), ini_get('post_max_size')); ?> </p> </td> </tr> <?php do_action('mdjm_add_comms_fields_before_content'); ?> <tr> <td colspan="2"> <?php $content = isset($_GET['template']) ? mdjm_get_email_template_content($_GET['template']) : ''; wp_editor($content, 'mdjm_email_content', array('media_buttons' => true, 'textarea_rows' => '10', 'editor_class' => 'required')); ?> </td> </tr> </table> <?php do_action('mdjm_post_comms_table'); ?> <?php submit_button(__('Send Email', 'mobile-dj-manager'), 'primary', 'submit', true); ?> </form> </div> <?php }
/** * Renders the 'Export' tab on the Reports Page * * @since 1.4 * @return void */ function mdjm_reports_tab_export() { if (!mdjm_employee_can('run_reports')) { wp_die(__('You do not have permission to export reports', 'mobile-dj-manager'), __('Error', 'mobile-dj-manager'), array('response' => 403)); } $label_single = mdjm_get_label_singular(); $label_plural = mdjm_get_label_plural(); ?> <div id="mdjm-dashboard-widgets-wrap"> <div class="metabox-holder"> <div id="post-body"> <div id="post-body-content"> <?php do_action('mdjm_reports_tab_export_content_top'); ?> <div class="postbox mdjm-export-events-earnings"> <h3><span><?php _e('Export Transaction History', 'mobile-dj-manager'); ?> </span></h3> <div class="inside"> <p><?php _e('Download a CSV of all transactions recorded.'); ?> </p> <form id="mdjm-export-txns" class="mdjm-export-form mdjm-import-export-form" method="post"> <?php mdjm_insert_datepicker(array('id' => 'mdjm-txn-export-start', 'altfield' => 'txn_start')); ?> <?php echo MDJM()->html->date_field(array('id' => 'mdjm-txn-export-start', 'name' => 'display_start_date', 'placeholder' => __('Select Start Date', 'mobile-dj-manager'))); ?> <?php echo MDJM()->html->hidden(array('name' => 'txn_start')); ?> <?php mdjm_insert_datepicker(array('id' => 'mdjm-txn-export-end', 'altfield' => 'txn_end')); ?> <?php echo MDJM()->html->date_field(array('id' => 'mdjm-txn-export-end', 'name' => 'display_end_date', 'placeholder' => __('Select End Date', 'mobile-dj-manager'))); ?> <?php echo MDJM()->html->hidden(array('name' => 'txn_end')); ?> <select name="txn_status"> <option value=""><?php _e('All Statuses', 'mobile-dj-manager'); ?> </option> <option value="Completed"><?php _e('Completed', 'mobile-dj-manager'); ?> </option> <option value="Pending"><?php _e('Pending', 'mobile-dj-manager'); ?> </option> <option value="Cancelled"><?php _e('Cancelled', 'mobile-dj-manager'); ?> </option> </select> <?php wp_nonce_field('mdjm_ajax_export', 'mdjm_ajax_export'); ?> <input type="hidden" name="mdjm-export-class" value="MDJM_Batch_Export_Txns"/> <span> <input type="submit" value="<?php _e('Generate CSV', 'mobile-dj-manager'); ?> " class="button-secondary"/> <span class="spinner"></span> </span> </form> </div><!-- .inside --> </div><!-- .postbox --> <div class="postbox mdjm-export-events"> <h3><span><?php printf(__('Export %s', 'mobile-dj-manager'), $label_plural); ?> </span></h3> <div class="inside"> <p><?php printf(__('Download a CSV of %s data.'), $label_plural); ?> </p> <form id="mdjm-export-events" class="mdjm-export-form mdjm-import-export-form" method="post"> <?php mdjm_insert_datepicker(array('id' => 'mdjm-event-export-start', 'altfield' => 'event_start')); ?> <?php echo MDJM()->html->date_field(array('id' => 'mdjm-event-export-start', 'name' => 'display_start_date', 'placeholder' => __('Select Start Date', 'mobile-dj-manager'))); ?> <?php echo MDJM()->html->hidden(array('name' => 'event_start')); ?> <?php mdjm_insert_datepicker(array('id' => 'mdjm-event-export-end', 'altfield' => 'event_end')); ?> <?php echo MDJM()->html->date_field(array('id' => 'mdjm-event-export-end', 'name' => 'display_end_date', 'placeholder' => __('Select End Date', 'mobile-dj-manager'))); ?> <?php echo MDJM()->html->hidden(array('name' => 'event_end')); ?> <select name="event_status"> <option value="any"><?php _e('All Statuses', 'mobile-dj-manager'); ?> </option> <?php foreach (mdjm_all_event_status() as $status => $label) { ?> <option value="<?php echo $status; ?> "><?php echo $label; ?> </option> <?php } ?> </select> <?php wp_nonce_field('mdjm_ajax_export', 'mdjm_ajax_export'); ?> <input type="hidden" name="mdjm-export-class" value="MDJM_Batch_Export_Events"/> <span> <input type="submit" value="<?php _e('Generate CSV', 'mobile-dj-manager'); ?> " class="button-secondary"/> <span class="spinner"></span> </span> </form> </div><!-- .inside --> </div><!-- .postbox --> <div class="postbox mdjm-export-clients"> <h3><span><?php _e('Export Clients', 'mobile-dj-manager'); ?> </span></h3> <div class="inside"> <p><?php _e('Download a CSV of clients.', 'mobile-dj-manager'); ?> </p> <form id="mdjm-export-clients" class="mdjm-export-form mdjm-import-export-form" method="post"> <?php wp_nonce_field('mdjm_ajax_export', 'mdjm_ajax_export'); ?> <input type="hidden" name="mdjm-export-class" value="MDJM_Batch_Export_Clients"/> <input type="submit" value="<?php _e('Generate CSV', 'mobile-dj-manager'); ?> " class="button-secondary"/> </form> </div><!-- .inside --> </div><!-- .postbox --> <?php if (mdjm_is_employer()) { ?> <div class="postbox mdjm-export-employees"> <h3><span><?php _e('Export Employees', 'mobile-dj-manager'); ?> </span></h3> <div class="inside"> <p><?php _e('Download a CSV of employees.', 'mobile-dj-manager'); ?> </p> <form id="mdjm-export-employees" class="mdjm-export-form mdjm-import-export-form" method="post"> <?php wp_nonce_field('mdjm_ajax_export', 'mdjm_ajax_export'); ?> <input type="hidden" name="mdjm-export-class" value="MDJM_Batch_Export_Employees"/> <input type="submit" value="<?php _e('Generate CSV', 'mobile-dj-manager'); ?> " class="button-secondary"/> </form> </div><!-- .inside --> </div><!-- .postbox --> <?php } ?> </div><!-- .post-body-content --> </div><!-- .post-body --> </div><!-- .metabox-holder --> </div><!-- #mdjm-dashboard-widgets-wrap --> <?php }
/** * Adds a new client. * * We assume that $data is passed from the $_POST super global but $user_data can be passed. * * @since 1.3 * @param arr $user_data Array of client data. See $defaults. * @return int|false $user_id User ID of the new client or false on failure. */ function mdjm_add_client($user_data = array()) { if (!mdjm_employee_can('list_all_clients')) { return false; } $first_name = !empty($_POST['client_firstname']) ? ucwords($_POST['client_firstname']) : ''; $last_name = !empty($_POST['client_lastname']) ? ucwords($_POST['client_lastname']) : ''; $email = !empty($_POST['client_email']) ? $_POST['client_email'] : ''; $phone = !empty($_POST['client_phone']) ? $_POST['client_phone'] : ''; $defaults = array('first_name' => $first_name, 'last_name' => $last_name, 'user_email' => $email, 'user_pass' => wp_generate_password(mdjm_get_option('pass_length')), 'role' => 'client', 'client_phone' => $phone); $defaults['display_name'] = $defaults['first_name'] . ' ' . $defaults['last_name']; $defaults['nickname'] = $defaults['display_name']; $defaults['user_login'] = is_email($defaults['user_email']); $user_data = wp_parse_args($user_data, $defaults); do_action('mdjm_pre_add_client'); $user_id = wp_insert_user($user_data); if (is_wp_error($user_id)) { if (MDJM_DEBUG == true) { MDJM()->debug->log_it('Error creating user: '******'first_name' => $user_data['first_name'], 'last_name' => $user_data['last_name'], 'show_admin_bar_front' => false, 'marketing' => 'Y', 'phone1' => isset($user_data['client_phone']) ? $user_data['client_phone'] : '', 'phone2' => isset($user_data['client_phone2']) ? $user_data['client_phone2'] : ''); $user_meta = apply_filters('mdjm_add_client_meta_data', $user_meta); foreach ($user_meta as $key => $value) { update_user_meta($user_id, $key, $value); } do_action('mdjm_post_add_client', $user_id); return $user_id; }
/** * Customise the view filter counts * * @since 1.0 * @param arr $views Array of views * @return arr $views Filtered Array of views */ function mdjm_quote_view_filters($views) { // We only run this filter if the user has restrictive caps and the post type is mdjm-event if (!is_post_type_archive('mdjm-quotes') || mdjm_employee_can('list_all_quotes')) { return $views; } global $user_ID; $events = mdjm_get_employee_events($user_ID); $all = 0; if ($events) { foreach ($events as $event) { $quote = mdjm_get_event_quote_id($event->ID); $quote_status = get_post_status($quote); if (!isset($status[$quote_status])) { $status[$quote_status] = 1; } else { $status[$quote_status]++; } $all++; } } // The All filter $views['all'] = preg_replace('/\\(.+\\)/U', '(' . mdjm_count_employee_events() . ')', $views['all']); $event_statuses = mdjm_all_event_status(); foreach ($event_statuses as $status => $label) { $events = mdjm_get_employee_events('', array('post_status' => $status)); if (empty($events)) { if (isset($views[$status])) { unset($views[$status]); } continue; } $views[$status] = preg_replace('/\\(.+\\)/U', '(' . count($events) . ')', $views[$status]); } // Only show the views we want foreach ($views as $status => $link) { if ($status != 'all' && !array_key_exists($status, $event_stati)) { unset($views[$status]); } } return $views; }
public function balance_reminder() { global $mdjm, $mdjm_settings; if (MDJM_DEBUG == true) { MDJM()->debug->log_it('*** Starting the Request Balance task ***', true); } $cron_start = microtime(true); /* -- Calculate the time period for which the task should run -- */ $due_date = date('Y-m-d', strtotime("-" . $this->schedules['balance-reminder']['options']['age'])); $args = array('posts_per_page' => -1, 'post_type' => 'mdjm-event', 'post_status' => 'mdjm-approved', 'meta_query' => array('relation' => 'AND', array('key' => '_mdjm_event_date', 'compare' => '>=', 'value' => $due_date, 'type' => 'date'), array('key' => '_mdjm_event_balance_status', 'compare' => '==', 'value' => 'Due'), array('key' => '_mdjm_event_cost', 'value' => '0.00', 'compare' => '>'), array('key' => '_mdjm_event_tasks', 'value' => 'balance-reminder', 'compare' => 'NOT IN'))); // Retrieve events for which balance is due $events = get_posts($args); $notify = array(); $x = 0; if (count($events) > 0) { // Events to process if (MDJM_DEBUG == true) { MDJM()->debug->log_it(count($events) . ' ' . _n('event', 'events', count($events)) . ' where the balance is due'); } remove_action('save_post_mdjm-event', 'mdjm_save_event_post', 10, 3); /* -- Loop through the enquiries and update as completed -- */ foreach ($events as $event) { $cronned = get_post_meta($event->ID, '_mdjm_event_tasks', true); if (!empty($cronned) && $cronned != '') { $cron_update = json_decode($cronned, true); } if (array_key_exists('balance-reminder', $cron_update)) { // Task has already run for this event continue; } if (!is_array($cron_update)) { $cron_update = array(); } $cron_update[$this->schedules['balance-reminder']['slug']] = time(); wp_update_post(array('ID' => $event->ID, 'post_modified' => date('Y-m-d H:i:s'))); update_post_meta($event->ID, '_mdjm_event_last_updated_by', 0); update_post_meta($event->ID, '_mdjm_event_tasks', json_encode($cron_update)); /* -- Update Journal -- */ if (MDJM_JOURNAL == true) { if (MDJM_DEBUG == true) { MDJM()->debug->log_it(' -- Adding journal entry'); } mdjm_add_journal(array('user_id' => 1, 'event_id' => $event->ID, 'comment_content' => mdjm_get_balance_label() . ' Reminder Scheduled Task executed<br /><br />' . time()), array('type' => 'added-note', 'visibility' => '0')); } else { if (MDJM_DEBUG == true) { MDJM()->debug->log_it(' -- Journalling is disabled'); } } $notify_dj = isset($this->schedules['balance-reminder']['options']['notify_dj']) ? $this->schedules['balance-reminder']['options']['notify_dj'] : ''; $notify_admin = isset($this->schedules['balance-reminder']['options']['notify_admin']) ? $this->schedules['balance-reminder']['options']['notify_admin'] : ''; $client = get_post_meta($event->ID, '_mdjm_event_client', true); $dj = get_post_meta($event->ID, '_mdjm_event_dj', true); $event_date = get_post_meta($event->ID, '_mdjm_event_date', true); $event_dj = !empty($dj) ? get_userdata($dj) : 'DJ not found'; $event_client = !empty($client) ? get_userdata($client) : 'Client not found'; $event_deposit = get_post_meta($event->ID, '_mdjm_event_deposit', true); $event_cost = get_post_meta($event->ID, '_mdjm_event_cost', true); $venue_post_id = get_post_meta($event->ID, '_mdjm_event_venue_id', true); $event_venue = MDJM()->events->mdjm_get_venue_details($venue_post_id, $event->ID); $contact_client = isset($this->schedules['balance-reminder']['options']['email_client']) && $this->schedules['balance-reminder']['options']['email_client'] == 'Y' ? true : false; $email_template = isset($this->schedules['balance-reminder']['options']['email_template']) && is_string(get_post_status($this->schedules['balance-reminder']['options']['email_template'])) ? $this->schedules['balance-reminder']['options']['email_template'] : false; /* -- Client Deposit Request Email -- */ if (!empty($contact_client) && !empty($email_template)) { // Email the client if (MDJM_DEBUG == true) { MDJM()->debug->log_it('Task ' . $this->schedules['balance-reminder']['name'] . ' is configured to notify client that deposit is due'); } $request = $mdjm->send_email(array('content' => $email_template, 'to' => $event_client->ID, 'from' => $mdjm_settings['templates']['enquiry_from'] == 'dj' ? $event_dj->ID : 0, 'journal' => 'email-client', 'event_id' => $event->ID, 'html' => true, 'cc_dj' => isset($mdjm_settings['email']['bcc_dj_to_client']) ? true : false, 'cc_admin' => isset($mdjm_settings['email']['bcc_admin_to_client']) ? true : false, 'source' => __('Request ' . mdjm_get_balance_label() . ' Scheduled Task'))); if ($request) { if (MDJM_DEBUG == true) { MDJM()->debug->log_it(' -- Balance reminder sent to ' . $event_client->display_name . '. ' . $request . ' ID '); } } else { if (MDJM_DEBUG == true) { MDJM()->debug->log_it(' ERROR: Balance reminder was not sent'); } } } else { if (MDJM_DEBUG == true) { MDJM()->debug->log_it('Task ' . $this->schedules['balance-reminder']['name'] . ' is not configured to notify client'); } } /* Prepare admin notification email data array */ if (!empty($notify_admin) && $notify_admin == 'Y') { if (MDJM_DEBUG == true) { MDJM()->debug->log_it(' -- Admin notifications are enabled'); } if (!isset($notify['admin']) || !is_array($notify['admin'])) { $notify['admin'] = array(); } $notify['admin'][$event->ID] = array('id' => $event->ID, 'client' => $event_client->display_name, 'deposit' => !empty($event_deposit) ? $event_deposit : '0', 'cost' => !empty($event_cost) ? $event_cost : '0', 'venue' => !empty($event_venue['name']) ? $event_venue['name'] : 'No Venue Set', 'djinfo' => $event_dj, 'date' => !empty($event_date) ? date("d M Y", strtotime($event_date)) : 'Date not found'); } // End if( !empty( $notify_admin ) && $notify_admin == 'Y' ) /* Prepare DJ notification email data array */ if (!empty($notify_dj) && $notify_dj == 'Y' && mdjm_employee_can('edit_txns')) { if (MDJM_DEBUG == true) { MDJM()->debug->log_it(' -- DJ notifications are enabled'); } if (!isset($notify['dj']) || !is_array($notify['dj'])) { $notify['dj'] = array(); } $notify['dj'][$dj] = array(); $notify['dj'][$dj][$event->ID] = array('id' => $event->id, 'client' => $event_client->display_name, 'deposit' => !empty($event_deposit) ? $event_deposit : '0', 'cost' => !empty($event_cost) ? $event_cost : '0', 'venue' => !empty($event_venue['name']) ? $event_venue['name'] : 'No Venue Set', 'djinfo' => $event_dj, 'date' => !empty($event_date) ? date("d M Y", strtotime($event_date)) : 'Date not found'); } // End if( !empty( $notify_dj ) && $notify_dj == 'Y' ) $x++; } // End foreach $cron_end = microtime(true); /* -- Prepare the Admin notification email -- */ if (!empty($notify_admin) && $notify_admin == 'Y') { $notify_email_args = array('data' => $notify['admin'], 'taskinfo' => $this->schedules['balance-reminder'], 'start' => $cron_start, 'end' => $cron_end, 'total' => $x); // $notify_email_args $mdjm->send_email(array('content' => $this->notification_content($notify_email_args), 'to' => $mdjm_settings['email']['system_email'], 'subject' => 'Balance Reminder Scheduled Task Completed - ' . MDJM_APP, 'journal' => false, 'html' => false, 'cc_admin' => false, 'cc_dj' => false, 'filter' => false, 'log_comm' => false)); } // if( !empty( $notify_admin ) && $notify_admin == 'Y' ) { /* -- Prepare the DJ notification email -- */ if (!empty($notify_dj) && $notify_dj == 'Y' && mdjm_employee_can('edit_txns')) { foreach ($notify['dj'] as $notify_dj) { foreach ($notify_dj as $dj) { $notify_email_args = array('data' => $notify_dj, 'taskinfo' => $this->schedules['balance-reminder'], 'start' => $cron_start, 'end' => $cron_end, 'total' => $x); // $notify_email_args $mdjm->send_email(array('content' => $this->notification_content($notify_email_args), 'to' => $dj->ID, 'subject' => 'Balance Reminder Scheduled Task Completed - ' . MDJM_APP, 'journal' => false, 'html' => false, 'cc_admin' => false, 'cc_dj' => false, 'filter' => false, 'log_comm' => false)); } // foreach( $notify_dj as $dj ) } // foreach( $notify['dj'] as $notify_dj ) } // if( !empty( $notify_dj ) && $notify_dj == 'Y' ) add_action('save_post_mdjm-event', 'mdjm_save_event_post', 10, 3); } else { if (MDJM_DEBUG == true) { MDJM()->debug->log_it('No balances are due'); } } // Prepare next run time $this->update_nextrun('balance-reminder'); if (MDJM_DEBUG == true) { MDJM()->debug->log_it('*** Completed the Balance Reminder task ***', true); } }