/** * Return all relevant action buttons for the event. * * Allow filtering of the buttons so they can be re-ordered, re-named etc. * * @since 1.3 * @param int $event_id The event ID. * @param bool $min True returns only minimal action buttons used within loop. * @return arr Array of event action buttons. */ function mdjm_get_event_action_buttons($event_id, $min = true) { $event_status = get_post_status($event_id); $buttons = array(); // Buttons for events in enquiry state if ($event_status == 'mdjm-enquiry') { if (mdjm_get_option('online_enquiry', '0')) { $buttons[5] = apply_filters('mdjm_quote_action_button', array('label' => __('View Quote', 'mobile-dj-manager'), 'id' => 'mdjm-quote-button', 'fa' => 'fa fa-file', 'url' => add_query_arg('event_id', $event_id, mdjm_get_formatted_url(mdjm_get_option('quotes_page'), true)))); } $buttons[10] = apply_filters('mdjm_book_action_button', array('label' => sprintf(__('Book %s', 'mobile-dj-manager'), mdjm_get_label_singular()), 'id' => 'mdjm-book-button', 'fa' => 'fa fa-check', 'url' => add_query_arg(array('mdjm_action' => 'accept_enquiry', 'mdjm_nonce' => wp_create_nonce('accept_enquiry')), mdjm_get_event_uri($event_id)))); } // Buttons for events in awaiting contract state if ($event_status == 'mdjm-contract') { $buttons[15] = apply_filters('mdjm_sign_contract_action_button', array('label' => __('Sign Contract', 'mobile-dj-manager'), 'id' => 'mdjm-sign-contract-button', 'fa' => 'fa fa-pencil', 'url' => add_query_arg('event_id', $event_id, mdjm_get_formatted_url(mdjm_get_option('contracts_page'), true)))); } // Buttons for events in approved state if ($event_status == 'mdjm-approved' && mdjm_contract_is_signed($event_id)) { $buttons[20] = apply_filters('mdjm_view_contract_action_button', array('label' => __('View Contract', 'mobile-dj-manager'), 'id' => 'mdjm-view-contract-button', 'fa' => 'fa fa-file-text', 'url' => add_query_arg('event_id', $event_id, mdjm_get_formatted_url(mdjm_get_option('contracts_page'), true)))); } // Playlist action button if (mdjm_playlist_is_open($event_id)) { if ($event_status == 'mdjm-approved' || $event_status == 'mdjm-contract') { $buttons[25] = apply_filters('mdjm_manage_playlist_action_button', array('label' => __('Manage Playlist', 'mobile-dj-manager'), 'id' => 'mdjm-manage-playlist-button', 'fa' => 'fa fa-music', 'url' => add_query_arg('event_id', $event_id, mdjm_get_formatted_url(mdjm_get_option('playlist_page'), true)))); } } // Payment button if (mdjm_has_gateway() && mdjm_get_event_balance($event_id) > 0) { $buttons[30] = apply_filters('mdjm_make_payment_button', array('label' => __('Make a Payment', 'mobile-dj-manager'), 'id' => 'mdjm-make-a-payment-button', 'fa' => 'fa fa-credit-card-alt', 'url' => add_query_arg('event_id', $event_id, mdjm_get_formatted_url(mdjm_get_option('payments_page'), true)))); } if (empty($min)) { $buttons[50] = apply_filters('mdjm_update_profile_action_button', array('label' => __('Update Profile', 'mobile-dj-manager'), 'id' => 'mdjm-update-profile-button', 'fa' => 'fa fa-user', 'url' => mdjm_get_formatted_url(mdjm_get_option('profile_page'), false))); } $buttons = apply_filters('mdjm_event_action_buttons', $buttons, $event_id); ksort($buttons); return $buttons; }
/** * Updates an event once a payment is completed. * * @since 1.3.8 * @param arr $txn_data Transaction data from gateway. * @return void */ function mdjm_update_event_after_payment($txn_data) { $type = mdjm_get_txn_type($txn_data['txn_id']); if ($type == mdjm_get_deposit_label()) { $meta['_mdjm_event_deposit_status'] = 'Paid'; } else { if ($type == mdjm_get_balance_label()) { $meta['_mdjm_event_deposit_status'] = 'Paid'; $meta['_mdjm_event_balance_status'] = 'Paid'; } else { if (mdjm_get_event_remaining_deposit($txn_data['event_id']) < 1) { $meta['_mdjm_event_deposit_status'] = 'Paid'; } if (mdjm_get_event_balance($txn_data['event_id']) < 1) { $meta['_mdjm_event_deposit_status'] = 'Paid'; $meta['_mdjm_event_balance_status'] = 'Paid'; } } } mdjm_update_event_meta($txn_data['event_id'], $meta); // Update the journal mdjm_add_journal(array('user_id' => $txn_data['client_id'], 'event_id' => $txn_data['event_id'], 'comment_content' => sprintf(__('%s of %s received via %s', 'mobile-dj-manager'), $type, mdjm_currency_filter(mdjm_format_amount($txn_data['total'])), mdjm_get_gateway_admin_label($txn_data['gateway'])))); }
/** * 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 '—'; } 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 '—'; } 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 '—'; } 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 '—'; } break; } // switch }