/**
 * Whether or not an employee has been paid for an event.
 *
 * @since	1.3
 * @param	int		$event_id		The event ID
 * @param	int		$employee_id	The employee user ID
 * @return	bool	True if paid, otherwise false.
 */
function mdjm_get_employees_event_payment_status($event_id, $employee_id = '')
{
    $employee_id = !empty($employee_id) ? $employee_id : get_current_user_id();
    $payment_status = 'unpaid';
    if ($employee_id == mdjm_get_event_primary_employee($event_id)) {
        $payment_data = get_post_meta($event_id, '_mdjm_event_dj_payment_status', true);
        $payment_status = empty($payment_data) ? 'unpaid' : $payment_data['payment_status'];
    } else {
        $employees_data = mdjm_get_event_employees_data($event_id);
        if (!empty($employees_data)) {
            foreach ($employees_data as $employee_data) {
                if ($employee_data['id'] == $employee_id) {
                    $payment_status = $employee_data['payment_status'];
                }
            }
        }
    }
    return $payment_status;
}
Beispiel #2
0
/**
 * Define the data to be displayed in each of the custom columns for the Transaction post types
 *
 * @since	0.9
 * @param	str		$column_name	The name of the column to display
 * @param	int		$post_id		The current post ID
 * @return
 */
function mdjm_event_posts_custom_column($column_name, $post_id)
{
    global $post;
    if (mdjm_employee_can('edit_txns') && ($column_name == 'value' || $column_name == 'balance')) {
        $value = mdjm_get_event_price($post_id);
    }
    switch ($column_name) {
        // Event Date
        case 'event_date':
            if (mdjm_employee_can('read_events')) {
                echo '<strong><a href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . date('d M Y', strtotime(get_post_meta($post_id, '_mdjm_event_date', true))) . '</a>';
            } else {
                echo '<strong>' . date('d M Y', strtotime(get_post_meta($post_id, '_mdjm_event_date', true))) . '</strong>';
            }
            break;
            // Client
        // Client
        case 'client':
            $client = get_userdata(get_post_meta($post->ID, '_mdjm_event_client', true));
            if (!empty($client)) {
                if (mdjm_employee_can('send_comms')) {
                    printf('<a href="%s">%s</a>', add_query_arg(array('recipient' => $client->ID, 'event_id' => $post_id), admin_url('admin.php?page=mdjm-comms')), $client->display_name);
                } else {
                    echo $client->display_name;
                }
            } else {
                _e('<span class="mdjm-form-error">Not Assigned</span>', 'mobile-dj-manager');
            }
            break;
            // Employees
        // Employees
        case 'employees':
            global $wp_roles;
            $primary = get_userdata(mdjm_get_event_primary_employee($post->ID));
            $employees = mdjm_get_event_employees_data($post->ID);
            if (!empty($primary)) {
                if (mdjm_employee_can('send_comms')) {
                    printf('<a href="%s" title="%s">%s</a>', add_query_arg(array('recipient' => $primary->ID, 'event_id' => $post_id), admin_url('admin.php?page=mdjm-comms')), mdjm_get_option('artist', __('DJ', 'mobile-dj-manager')), $primary->display_name);
                } else {
                    echo '<a title="' . mdjm_get_option('artist', __('DJ', 'mobile-dj-manager')) . '">' . $primary->display_name . '</a>';
                }
            } else {
                _e('<span class="mdjm-form-error">Not Assigned</span>', 'mobile-dj-manager');
            }
            if (!empty($employees)) {
                echo '<br />';
                $i = 1;
                foreach ($employees as $employee) {
                    echo '<em>';
                    if (mdjm_employee_can('send_comms')) {
                        printf('<a href="%s" title="%s">%s</a>', add_query_arg(array('recipient' => $employee['id'], 'event_id' => $post_id), admin_url('admin.php?page=mdjm-comms')), translate_user_role($wp_roles->roles[$employee['role']]['name']), mdjm_get_employee_display_name($employee['id']));
                    } else {
                        echo '<a title="' . translate_user_role($wp_roles->roles[$employee['role']]['name']) . '">' . mdjm_get_employee_display_name($employee['id']) . '</a>';
                    }
                    echo '</em>';
                    if ($i != count($employees)) {
                        echo '<br />';
                    }
                }
            }
            break;
            // Status
        // Status
        case 'event_status':
            echo get_post_status_object($post->post_status)->label;
            break;
            // Event Type
        // Event Type
        case 'event_type':
            $event_types = get_the_terms($post_id, 'event-types');
            if (is_array($event_types)) {
                foreach ($event_types as $key => $event_type) {
                    $event_types[$key] = $event_type->name;
                }
                echo implode("<br/>", $event_types);
            }
            break;
            // Value
        // Value
        case 'value':
            if (mdjm_employee_can('edit_txns')) {
                if (!empty($value) && $value != '0.00') {
                    echo mdjm_currency_filter(mdjm_format_amount($value));
                    echo '<br />';
                } else {
                    echo '<span class="mdjm-form-error">' . mdjm_currency_filter(mdjm_format_amount('0.00')) . '</span>';
                }
            } else {
                echo '&mdash;';
            }
            break;
            // Balance
        // Balance
        case 'balance':
            if (mdjm_employee_can('edit_txns')) {
                echo mdjm_currency_filter(mdjm_format_amount(mdjm_get_event_balance($post_id)));
                echo '<br />';
                $deposit_status = mdjm_get_event_deposit_status($post_id);
                if ('Paid' == mdjm_get_event_deposit_status($post_id)) {
                    printf(__('<i title="%s %s paid" class="fa fa-check-square-o" aria-hidden="true">', 'mobile-dj-manager'), mdjm_currency_filter(mdjm_format_amount(mdjm_get_event_deposit($post_id))), mdjm_get_deposit_label());
                }
            } else {
                echo '&mdash;';
            }
            break;
            // Playlist
        // Playlist
        case 'playlist':
            if (mdjm_employee_can('read_events')) {
                $total = mdjm_count_playlist_entries($post_id);
                echo '<a href="' . mdjm_get_admin_page('playlists') . $post_id . '">' . $total . ' ' . _n('Song', 'Songs', $total, 'mobile-dj-manager') . '</a>' . "\r\n";
            } else {
                echo '&mdash;';
            }
            break;
            // Journal
        // Journal
        case 'journal':
            if (mdjm_employee_can('read_events_all')) {
                $total = wp_count_comments($post_id)->approved;
                echo '<a href="' . admin_url('/edit-comments.php?p=' . $post_id) . '">' . $total . ' ' . _n('Entry', 'Entries', $total, 'mobile-dj-manager') . '</a>' . "\r\n";
            } else {
                echo '&mdash;';
            }
            break;
    }
    // switch
}