示例#1
0
/**
 * Fires after an event's status is updated.
 *
 * Add journal entry.
 *
 * @since	1.3
 * @param	int|bool	$result			The result of the status change function. False is an unsuccessful status update.
 * @param	int			$event_id		The event ID.
 * @param	str			$new_status		The new event status.
 * @param	str			$old_status		The old event status.
 * @param	arr			$args			Arguments passed to the mdjm_update_event_status function
 * @return	void
 */
function mdjm_event_add_journal_after_status_change($result, $event_id, $new_status, $old_status, $args)
{
    if (empty($result)) {
        return;
    }
    $reject_reason = $new_status == 'mdjm-rejected' && !empty($args['reject_reason']) ? '<br />' . $args['reject_reason'] : '';
    $comment_args = array('user_id' => is_user_logged_in() ? get_current_user_id() : 1, 'event_id' => $event_id, 'comment_content' => sprintf(__('%s status updated to %s.%s', 'mobile-dj-manager'), mdjm_get_label_singular(), mdjm_get_event_status($event_id), $reject_reason));
    mdjm_add_journal($comment_args);
}
示例#2
0
/**
 * Update the email content field with the selected template.
 *
 *
 * @since	1.3
 * @return	void
 */
function mdjm_user_events_dropdown_ajax()
{
    $result['event_list'] = '<option value="0">' . __('Select an Event', 'mobile-dj-manager') . '</option>';
    if (!empty($_POST['recipient'])) {
        $statuses = 'any';
        if (mdjm_is_employee($_POST['recipient'])) {
            if (mdjm_get_option('comms_show_active_events_only')) {
                $statuses = array('post_status' => mdjm_active_event_statuses());
            }
            $events = mdjm_get_employee_events($_POST['recipient'], $statuses);
        } else {
            if (mdjm_get_option('comms_show_active_events_only')) {
                $statuses = mdjm_active_event_statuses();
            }
            $events = mdjm_get_client_events($_POST['recipient'], $statuses);
        }
        if ($events) {
            foreach ($events as $event) {
                $result['event_list'] .= '<option value="' . $event->ID . '">';
                $result['event_list'] .= mdjm_get_event_date($event->ID) . ' ';
                $result['event_list'] .= __('from', 'mobile-dj-manager') . ' ';
                $result['event_list'] .= mdjm_get_event_start($event->ID) . ' ';
                $result['event_list'] .= '(' . mdjm_get_event_status($event->ID) . ')';
                $result['event_list'] .= '</option>';
            }
        }
    }
    $result['type'] = 'success';
    $result = json_encode($result);
    echo $result;
    die;
}
/**
 * Output the book event button.
 *
 * If you are filtering the mdjm_get_action_buttons function you may need to adjust the array key
 * within this function.
 *
 * @since	1.3
 * @param	int		$event_id	The event ID.
 * @param	arr		$args		Arguments for button display. See $defaults.
 * @return	str		The Book Event button
 */
function mdjm_display_book_event_button($event_id, $args = array())
{
    if ('mdjm-enquiry' != mdjm_get_event_status($event_id)) {
        return;
    }
    $buttons = mdjm_get_event_action_buttons($event_id);
    if (empty($buttons) || empty($buttons[10])) {
        return;
    }
    $book_button = $buttons[10];
    $defaults = array('colour' => mdjm_get_option('action_button_colour'), 'label' => $book_button['label'], 'fa' => 'fa fa-thumbs-o-up', 'url' => $book_button['url']);
    $args = wp_parse_args($args, $defaults);
    $output = sprintf('<a class="mdjm-action-button mdjm-action-button-%s" href="%s">%s</a>', $args['colour'], $args['url'], $args['label']);
    return apply_filters('mdjm_book_event_button', $output, $event_id, $args);
}
/**
 * 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&#8217; 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 
}
示例#5
0
/**
 * Content tag: event_status.
 * The current event status.
 *
 * @param	int		The event ID.
 * @param
 *
 * @return	str		The current event status label.
 */
function mdjm_content_tag_event_status($event_id = '')
{
    if (empty($event_id)) {
        return;
    }
    return mdjm_get_event_status($event_id);
}
    /**
     * Displays the playlist details.
     *
     * @since	1.3
     * 
     * 
     * @return	str
     */
    function display_header()
    {
        ?>
        <p><?php 
        printf(__('<strong>Date</strong>: %s', 'mobile-dj-manager'), mdjm_get_event_long_date($_GET['event_id']));
        ?>
        <br />
        <?php 
        printf(__('<strong>Status</strong>: %s', 'mobile-dj-manager'), mdjm_get_event_status($_GET['event_id']));
        ?>
        <br />
        <?php 
        printf(__('<strong>Type</strong>: %s', 'mobile-dj-manager'), mdjm_get_event_type($_GET['event_id']));
        ?>
        <br />
        <?php 
        printf(__('<strong>Primary Employee</strong>: %s', 'mobile-dj-manager'), mdjm_get_employee_display_name(mdjm_get_event_primary_employee_id($_GET['event_id'])));
        ?>
        <br />
        <?php 
        printf(__('<strong>Client</strong>: %s', 'mobile-dj-manager'), mdjm_get_employee_display_name(mdjm_get_event_client_id($_GET['event_id'])));
        ?>
        <br />
        <?php 
        printf(__('<strong>Total Songs</strong>: %s', 'mobile-dj-manager'), count($this->items));
        ?>
        <br />
        <?php 
        printf(__('<strong>Current Status</strong>: %s', 'mobile-dj-manager'), mdjm_playlist_is_open($_GET['event_id']) ? __('Open', 'mobile-dj-manager') : __('Closed', 'mobile-dj-manager'));
        ?>
        </p>
        
        <?php 
        if ($this->count_entries($_GET['event_id']) > 0) {
            ?>
        
            <p>
            <form method="post" target="_blank">
                <?php 
            mdjm_admin_action_field('print_playlist');
            ?>
                <input type="hidden" name="print_playlist_event_id" id="print_playlist_event_id" value="<?php 
            echo $_GET['event_id'];
            ?>
" />
                <?php 
            wp_nonce_field('print_playlist_entry', 'mdjm_nonce', true, true);
            ?>
                <?php 
            submit_button('Print this List', 'primary small', 'submit_print_pl', false);
            ?>
 
                <?php 
            _e('ordered by', 'mobile-dj-manager');
            ?>
 <select name="print_order_by" id="print_order_by">
                <option value="date" selected="selected"><?php 
            _e('Date Added', 'mobile-dj-manager');
            ?>
</option>
                <option value="artist"><?php 
            _e('Artist Name', 'mobile-dj-manager');
            ?>
</option>
                <option value="song"><?php 
            _e('Song Name', 'mobile-dj-manager');
            ?>
</option>
                <option value="category"><?php 
            _e('Category', 'mobile-dj-manager');
            ?>
</option>
                </select> <?php 
            _e('and repeating headers after', 'mobile-dj-manager');
            ?>
 <input type="text" name="print_repeat_headers" id="print_repeat_headers" class="small-text" value="20" /> <?php 
            _e('rows', 'mobile-dj-manager');
            ?>
 <code><?php 
            _e('Enter 0 for no repeat of headers', 'mobile-dj-manager');
            ?>
</code>
            </form>
                    
            <form method="post">
                <?php 
            mdjm_admin_action_field('email_playlist');
            ?>
                <?php 
            wp_nonce_field('email_playlist_entry', 'mdjm_nonce', true, true);
            ?>
                <input type="hidden" name="email_playlist_event_id" id="email_playlist_event_id" value="<?php 
            echo $_GET['event_id'];
            ?>
" />
                <?php 
            submit_button('Email this List', 'primary small', 'submit_email_pl', false);
            ?>
 
                <?php 
            _e('ordered by', 'mobile-dj-manager');
            ?>
 <select name="email_order_by" id="email_order_by">
                <option value="date" selected="selected"><?php 
            _e('Date Added', 'mobile-dj-manager');
            ?>
</option>
                <option value="artist"><?php 
            _e('Artist Name', 'mobile-dj-manager');
            ?>
</option>
                <option value="song"><?php 
            _e('Song Name', 'mobile-dj-manager');
            ?>
</option>
                <option value="category"><?php 
            _e('Category', 'mobile-dj-manager');
            ?>
</option>
                </select> <?php 
            _e('and repeating headers after', 'mobile-dj-manager');
            ?>
 <input type="text" name="repeat_headers" id="repeat_headers" class="small-text" value="20" /> <?php 
            _e('rows', 'mobile-dj-manager');
            ?>
 <code><?php 
            _e('Enter 0 for no repeat of headers', 'mobile-dj-manager');
            ?>
</code>
            </form>
            </p>
            <?php 
        }
    }