/** * Load the custom tags into the MDJM_Content_Tags class. * * @since 1.3 * @param * @return */ public function add_tags() { $query = mdjm_get_custom_fields(); $fields = $query->get_posts(); if ($fields) { foreach ($fields as $field) { mdjm_add_content_tag('mdjm_cf_' . strtolower(str_replace(array(' ', '/'), array('_', ''), get_the_title($field->ID))), $field->post_content, array(&$this, 'do_custom_field_tags')); } } }
/** * Save the event transaction * * */ function mdjm_save_event_transaction_ajax() { global $mdjm_event; $result = array(); $mdjm_event = new MDJM_Event($_POST['event_id']); $mdjm_txn = new MDJM_Txn(); $txn_data = array('post_parent' => $_POST['event_id'], 'post_author' => $mdjm_event->client, 'post_status' => $_POST['direction'] == 'Out' ? 'mdjm-expenditure' : 'mdjm-income', 'post_date' => date('Y-m-d H:i:s', strtotime($_POST['date']))); $txn_meta = array('_mdjm_txn_status' => 'Completed', '_mdjm_payment_from' => $mdjm_event->client, '_mdjm_txn_total' => $_POST['amount'], '_mdjm_payer_firstname' => mdjm_get_client_firstname($mdjm_event->client), '_mdjm_payer_lastname' => mdjm_get_client_lastname($mdjm_event->client), '_mdjm_payer_email' => mdjm_get_client_email($mdjm_event->client), '_mdjm_payment_from' => mdjm_get_client_display_name($mdjm_event->client), '_mdjm_txn_source' => $_POST['src']); if ($_POST['direction'] == 'In') { if (!empty($_POST['from'])) { $txn_meta['_mdjm_payment_from'] = sanitize_text_field($_POST['from']); } else { $txn_meta['_mdjm_payment_from'] = mdjm_get_client_display_name($mdjm_event->client); } } if ($_POST['direction'] == 'Out') { if (!empty($_POST['to'])) { $txn_meta['_mdjm_payment_to'] = sanitize_text_field($_POST['to']); } else { $txn_meta['_mdjm_payment_to'] = mdjm_get_client_display_name($mdjm_event->client); } } $mdjm_txn->create($txn_data, $txn_meta); if ($mdjm_txn->ID > 0) { $result['type'] = 'success'; mdjm_set_txn_type($mdjm_txn->ID, $_POST['for']); $args = array('user_id' => get_current_user_id(), 'event_id' => $_POST['event_id'], 'comment_content' => sprintf(__('%1$s payment of %2$s received for %3$s %4$s.', 'mobile-dj-manager'), $_POST['direction'] == 'In' ? __('Incoming', 'mobile-dj-manager') : __('Outgoing', 'mobile-dj-manager'), mdjm_currency_filter(mdjm_format_amount($_POST['amount'])), mdjm_get_label_singular(true), mdjm_get_event_contract_id($_POST['event_id']))); mdjm_add_journal($args); // Email overide if (empty($_POST['send_notice']) && mdjm_get_option('manual_payment_cfm_template')) { $manual_email_template = mdjm_get_option('manual_payment_cfm_template'); mdjm_update_option('manual_payment_cfm_template', 0); } $payment_for = $mdjm_txn->get_type(); $amount = mdjm_currency_filter(mdjm_format_amount($_POST['amount'])); mdjm_add_content_tag('payment_for', __('Reason for payment', 'mobile-dj-manager'), function () use($payment_for) { return $payment_for; }); mdjm_add_content_tag('payment_amount', __('Payment amount', 'mobile-dj-manager'), function () use($amount) { return $amount; }); mdjm_add_content_tag('payment_date', __('Date of payment', 'mobile-dj-manager'), 'mdjm_content_tag_ddmmyyyy'); /** * Allow hooks into this payment. The hook is suffixed with 'in' or 'out' depending * on the payment direction. i.e. mdjm_post_add_manual_txn_in and mdjm_post_add_manual_txn_out * * @since 1.3.7 * @param int $event_id * @param obj $txn_id */ do_action('mdjm_post_add_manual_txn_' . strtolower($_POST['direction']), $_POST['event_id'], $mdjm_txn->ID); // Email overide if (empty($_POST['send_notice']) && isset($manual_email_template)) { mdjm_update_option('manual_payment_cfm_template', $manual_email_template); } $result['deposit_paid'] = 'N'; $result['balance_paid'] = 'N'; if ($mdjm_event->get_remaining_deposit() < 1) { mdjm_update_event_meta($mdjm_event->ID, array('_mdjm_event_deposit_status' => 'Paid')); $result['deposit_paid'] = 'Y'; } if ($mdjm_event->get_balance() < 1) { mdjm_update_event_meta($mdjm_event->ID, array('_mdjm_event_balance_status' => 'Paid')); mdjm_update_event_meta($mdjm_event->ID, array('_mdjm_event_deposit_status' => 'Paid')); $result['balance_paid'] = 'Y'; $result['deposit_paid'] = 'Y'; } } else { $result['type'] = 'error'; $result['msg'] = __('Unable to add transaction', 'mobile-dj-manager'); } ob_start(); mdjm_do_event_txn_table($_POST['event_id']); $result['transactions'] = ob_get_contents(); ob_get_clean(); echo json_encode($result); die; }
/** * Register the {payment_date} content tag for use within receipt emails. * * @requires PHP version 5.4 due to use of anonymous functions. * * @since 1.3.8 * @param obj $mdjm_txn The transaction object. * @return void */ function mdjm_register_payment_date_content_tag($txn_data) { if (version_compare(phpversion(), '5.4', '<')) { return; } $txn_id = $txn_data['txn_id']; mdjm_add_content_tag('payment_date', __('Date of payment', 'mobile-dj-manager'), function () use($txn_id) { return mdjm_get_txn_date($txn_id); }); }
/** * Add the default MDJM content tags. * * @since 1.3 */ function mdjm_setup_content_tags() { // Setup default tags array $content_tags = array(array('tag' => 'admin_notes', 'description' => __('The admin notes associated with the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_admin_notes'), array('tag' => 'admin_url', 'description' => __('The admin URL to WordPress', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_admin_url'), array('tag' => 'application_home', 'description' => __('The Client Zone application URL', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_application_home'), array('tag' => 'application_name', 'description' => __('The name of this MDJM application', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_application_name'), array('tag' => 'artist_label', 'description' => __('The label defined for artists (default is DJ).', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_artist_label'), array('tag' => 'available_addons', 'description' => __('The list of add-ons available. No price. If an event can be referenced, only lists add-ons not already assigned to the event, or included in the event package', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_available_addons'), array('tag' => 'available_addons_cost', 'description' => __('The list of add-ons available. With price. If an event can be referenced, only lists add-ons not already assigned to the event, or included in the event package', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_available_addons_cost'), array('tag' => 'available_packages', 'description' => __('The list of packages available. No price', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_available_packages'), array('tag' => 'available_packages_cost', 'description' => __('The list of packages available. With price', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_available_packages_cost'), array('tag' => 'balance', 'description' => __('The remaining balance owed for the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_balance'), array('tag' => 'balance_label', 'description' => __('The label used for balance payments', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_balance_label'), array('tag' => 'client_email', 'description' => __('The event clients email address', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_client_email'), array('tag' => 'client_firstname', 'description' => __('The event clients first name', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_client_firstname'), array('tag' => 'client_full_address', 'description' => __('The event clients full address', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_client_full_address'), array('tag' => 'client_fullname', 'description' => __('The event clients full name', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_client_fullname'), array('tag' => 'client_lastname', 'description' => __('The event clients last name', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_client_lastname'), array('tag' => 'client_password', 'description' => sprintf(__('The event clients password for logging into %s', 'mobile-dj-manager'), 'Client Zone'), 'function' => 'mdjm_content_tag_client_password'), array('tag' => 'client_primary_phone', 'description' => __('The event clients primary phone number', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_client_primary_phone'), array('tag' => 'client_alt_phone', 'description' => __('The event clients alternative phone number', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_client_alt_phone'), array('tag' => 'client_username', 'description' => sprintf(__('The event clients username for logging into %s', 'mobile-dj-manager'), 'Client Zone'), 'function' => 'mdjm_content_tag_client_username'), array('tag' => 'company_name', 'description' => __('The name of your company', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_company_name'), array('tag' => 'contact_page', 'description' => __('The URL to your websites contact page', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_contact_page'), array('tag' => 'contract_date', 'description' => __("The date the event contract was signed, or today's date", 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_contract_date'), array('tag' => 'contract_id', 'description' => __('The contract / event ID', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_contract_id'), array('tag' => 'contract_signatory', 'description' => __('The name of the person who signed the contract', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_contract_signatory'), array('tag' => 'contract_signatory_ip', 'description' => __('The IP address recorded during contract signing', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_contract_signatory_ip'), array('tag' => 'contract_url', 'description' => __('The URL for the client to access their event contract', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_contract_url'), array('tag' => 'ddmmyyyy', 'description' => __('Todays date in shortdate format', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_ddmmyyyy'), array('tag' => 'deposit', 'description' => __('The deposit amount for the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_deposit'), array('tag' => 'deposit_label', 'description' => __('The label used for deposit payments', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_deposit_label'), array('tag' => 'deposit_remaining', 'description' => sprintf(__('The remaining %s value due for the %s', 'mobile-dj-manager'), mdjm_get_deposit_label(), mdjm_get_label_singular(true)), 'function' => 'mdjm_content_tag_deposit_remaining'), array('tag' => 'deposit_status', 'description' => __("The deposit payment status. Generally 'Paid' or 'Due'", 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_deposit_status'), array('tag' => 'dj_email', 'description' => __('The email address of the events assigned primary employee', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_dj_email'), array('tag' => 'dj_firstname', 'description' => __('The first name of the events assigned primary employee', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_dj_firstname'), array('tag' => 'dj_lastname', 'description' => __('The last name of the events assigned primary employee', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_dj_lastname'), array('tag' => 'dj_fullname', 'description' => __('The full name of the events assigned primary employee', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_dj_fullname'), array('tag' => 'dj_notes', 'description' => __('The DJ notes that have been entered against the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_dj_notes'), array('tag' => 'dj_primary_phone', 'description' => __('The primary phone number of the events assigned primary employee', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_dj_primary_phone'), array('tag' => 'dj_setup_date', 'description' => __('The setup date for the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_dj_setup_date'), array('tag' => 'dj_setup_time', 'description' => __('The setup time for the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_dj_setup_time'), array('tag' => 'end_date', 'description' => __('The date the event completes', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_end_date'), array('tag' => 'end_time', 'description' => __('The time the event completes', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_end_time'), array('tag' => 'event_addons', 'description' => __('The add-ons included with the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_event_addons'), array('tag' => 'event_addons_cost', 'description' => __('The add-ons included with the event, with costs', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_event_addons_cost'), array('tag' => 'event_date', 'description' => __('The date of the event in long format', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_event_date'), array('tag' => 'event_date_short', 'description' => __('The date of the event in short format', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_event_date_short'), array('tag' => 'event_description', 'description' => __('The contents of the event description field', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_event_description'), array('tag' => 'event_duration', 'description' => __('The duration of the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_event_duration'), array('tag' => 'event_employees', 'description' => __('The list of employees working their event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_event_employees'), array('tag' => 'event_employees_roles', 'description' => __('The list of employees working their event and their assigned role', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_event_employees_roles'), array('tag' => 'event_name', 'description' => __('The assigned name of the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_event_name'), array('tag' => 'event_package', 'description' => sprintf(__('The package associated with the %s or "No Package".', 'mobile-dj-manager'), mdjm_get_label_singular(true)), 'function' => 'mdjm_content_tag_event_package'), array('tag' => 'event_package_cost', 'description' => sprintf(__('The package associated with the %s and its cost, or "No Package".', 'mobile-dj-manager'), mdjm_get_label_singular(true)), 'function' => 'mdjm_content_tag_event_package_cost'), array('tag' => 'event_package_description', 'description' => sprintf(__('The description of the package associated with the %s.', 'mobile-dj-manager'), mdjm_get_label_singular(true)), 'function' => 'mdjm_content_tag_event_package_description'), array('tag' => 'event_status', 'description' => __('The current status of the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_event_status'), array('tag' => 'event_type', 'description' => __('The type of event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_event_type'), array('tag' => 'event_url', 'description' => __('The URL of the event page', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_event_url'), array('tag' => 'final_balance', 'description' => __('The final balance payment for an event which is the total cost minus deposit, even if the deposit is unpaid.', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_final_balance'), array('tag' => 'guest_playlist_url', 'description' => __('The URL to your event playlist page for guests', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_guest_playlist_url'), array('tag' => 'part_payment_label', 'description' => 'The label used for Part Payments. i.e. Not the full amount', 'function' => 'mdjm_content_tag_part_payment_label'), array('tag' => 'payment_history', 'description' => __('An overview of payments made by the client for the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_payment_history'), array('tag' => 'payment_url', 'description' => __('The URL to your payments page', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_payment_url'), array('tag' => 'pdf_pagebreak', 'description' => __('Adds a page break into a PDF document', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_pdf_pagebreak'), array('tag' => 'playlist_close', 'description' => __('The number of days before the event that the playlist closes', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_playlist_close'), array('tag' => 'playlist_duration', 'description' => sprintf(__('The approximate length of the %s playlist', 'mobile-dj-manager'), mdjm_get_label_singular(true)), 'function' => 'mdjm_content_tag_playlist_duration'), array('tag' => 'playlist_url', 'description' => __('The URL to your event playlist page for clients', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_playlist_url'), array('tag' => 'quotes_url', 'description' => __('The URL to your online quotes page', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_quotes_url'), array('tag' => 'start_time', 'description' => __('The event start time', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_start_time'), array('tag' => 'total_cost', 'description' => __('The total cost of the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_total_cost'), array('tag' => 'travel_cost', 'description' => __('The cost of travel for the event', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_travel_cost'), array('tag' => 'venue', 'description' => __('The name of the event venue', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_venue'), array('tag' => 'venue_contact', 'description' => __('The name of the contact at event venue', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_venue_contact'), array('tag' => 'venue_details', 'description' => __('Details stored for the venue', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_venue_details'), array('tag' => 'venue_email', 'description' => __('The email address of the event venue', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_venue_email'), array('tag' => 'venue_full_address', 'description' => __('The full address of the event venue', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_venue_full_address'), array('tag' => 'venue_notes', 'description' => __('Notes associated with the event venue', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_venue_notes'), array('tag' => 'venue_telephone', 'description' => __('The phone number of the event venue', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_venue_telephone'), array('tag' => 'website_url', 'description' => __('The URL to your website', 'mobile-dj-manager'), 'function' => 'mdjm_content_tag_website_url')); // Apply mdjm_content_tags filter $content_tags = apply_filters('mdjm_content_tags', $content_tags); // Add content tags foreach ($content_tags as $content_tag) { mdjm_add_content_tag($content_tag['tag'], $content_tag['description'], $content_tag['function']); } }
/** * MDJM Home Shortcode. * * Displays the Client Zone home page which will render event details if the client only has a single event * or a list of events if they have multiple events in the system. * * @since 1.3 * * @return string */ function mdjm_shortcode_home($atts) { if (is_user_logged_in()) { global $mdjm_event; $mdjm_event = ''; ob_start(); $output = ''; $client_id = get_current_user_id(); mdjm_add_content_tag('event_action_buttons', sprintf(__('%s action buttons within %s', 'mobile-dj-manager'), mdjm_get_label_singular(), mdjm_get_option('app_name')), 'mdjm_do_action_buttons'); if (isset($_GET['event_id'])) { $mdjm_event = mdjm_get_event($_GET['event_id']); if (!empty($mdjm_event->ID)) { ob_start(); mdjm_get_template_part('event', 'single'); $output .= mdjm_do_content_tags(ob_get_contents(), $mdjm_event->ID, $client_id); ob_get_clean(); } else { ob_start(); mdjm_get_template_part('event', 'none'); $output .= mdjm_do_content_tags(ob_get_contents(), '', $client_id); ob_get_clean(); } } else { $client_events = mdjm_get_client_events($client_id, mdjm_active_event_statuses()); if ($client_events) { $slug = 'single'; if (count($client_events) > 1) { $slug = 'loop'; ob_start(); mdjm_get_template_part('event', 'loop-header'); $output .= mdjm_do_content_tags(ob_get_contents(), '', $client_id); do_action('mdjm_pre_event_loop'); ?> <div id="mdjm-event-loop"><?php ob_get_clean(); } foreach ($client_events as $event) { $mdjm_event = new MDJM_Event($event->ID); ob_start(); mdjm_get_template_part('event', $slug); $output .= mdjm_do_content_tags(ob_get_contents(), $mdjm_event->ID, $client_id); ob_get_clean(); } if ($slug == 'loop') { ob_start(); mdjm_get_template_part('event', 'loop-footer'); $output .= mdjm_do_content_tags(ob_get_contents(), '', $client_id); ?> </div><?php do_action('mdjm_post_event_loop', $client_events); ob_get_clean(); } } else { mdjm_get_template_part('event', 'none'); $output .= mdjm_do_content_tags(ob_get_contents(), '', $client_id); ob_get_clean(); } } $mdjm_event = ''; return $output; } else { echo mdjm_login_form(mdjm_get_current_page_url()); } }
/** * Mark the event balance as paid. * * Determines if any balance remains and if so, assumes it has been paid and * creates an associted transaction. * * @since 1.3 * @param int $event_id The event ID. * @return void */ function mdjm_mark_event_balance_paid($event_id) { $mdjm_event = new MDJM_Event($event_id); $txn_id = 0; if ('Paid' == $mdjm_event->get_balance_status()) { return; } $remaining = $mdjm_event->get_balance(); do_action('mdjm_pre_mark_event_balance_paid', $event_id, $remaining); if (!empty($remaining) && $remaining > 0) { $mdjm_txn = new MDJM_Txn(); $txn_meta = array('_mdjm_txn_source' => mdjm_get_option('default_type', __('Cash', 'mobile-dj-manager')), '_mdjm_txn_currency' => mdjm_get_currency(), '_mdjm_txn_status' => 'Completed', '_mdjm_txn_total' => $remaining, '_mdjm_payer_firstname' => mdjm_get_client_firstname($mdjm_event->client), '_mdjm_payer_lastname' => mdjm_get_client_lastname($mdjm_event->client), '_mdjm_payer_email' => mdjm_get_client_email($mdjm_event->client), '_mdjm_payment_from' => mdjm_get_client_display_name($mdjm_event->client)); $mdjm_txn->create(array('post_parent' => $event_id), $txn_meta); if ($mdjm_txn->ID > 0) { mdjm_set_txn_type($mdjm_txn->ID, mdjm_get_txn_cat_id('slug', 'mdjm-balance-payments')); $args = array('user_id' => get_current_user_id(), 'event_id' => $event_id, 'comment_content' => sprintf(__('%1$s payment of %2$s received and %1$s marked as paid.', 'mobile-dj-manager'), mdjm_get_balance_label(), mdjm_currency_filter(mdjm_format_amount($remaining)))); mdjm_add_journal($args); mdjm_add_content_tag('payment_for', __('Reason for payment', 'mobile-dj-manager'), 'mdjm_content_tag_balance_label'); mdjm_add_content_tag('payment_amount', __('Payment amount', 'mobile-dj-manager'), function () use($remaining) { return mdjm_currency_filter(mdjm_format_amount($remaining)); }); mdjm_add_content_tag('payment_date', __('Date of payment', 'mobile-dj-manager'), 'mdjm_content_tag_ddmmyyyy'); do_action('mdjm_post_add_manual_txn_in', $event_id, $mdjm_txn->ID); } } mdjm_update_event_meta($mdjm_event->ID, array('_mdjm_event_deposit_status' => 'Paid', '_mdjm_event_balance_status' => 'Paid')); do_action('mdjm_post_mark_event_balance_paid', $event_id); }