/** * Output the event transaction list 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_txn_add_new_row($event_id) { global $mdjm_event, $mdjm_event_update; mdjm_insert_datepicker(array('id' => 'mdjm_txn_display_date', 'altfield' => 'mdjm_txn_date', 'maxdate' => 'today')); ?> <div id="mdjm-event-add-txn-table"> <table id="mdjm_event_add_txn_table" class="widefat mdjm_event_add_txn_table mdjm_form_fields"> <thead> <tr> <th colspan="3"><?php _e('Add Transaction', 'mobile-dj-manager'); ?> <a id="toggle_add_txn_fields" class="mdjm-small mdjm-fake"><?php _e('show form', 'mobile-dj-manager'); ?> </a></th> </tr> </thead> <tbody class="mdjm-hidden"> <tr> <td><label for="mdjm_txn_amount"><?php _e('Amount:', 'mobile-dj-manager'); ?> </label><br /> <?php echo mdjm_currency_symbol() . MDJM()->html->text(array('name' => 'mdjm_txn_amount', 'class' => 'mdjm-input-currency', 'placeholder' => mdjm_sanitize_amount('10'))); ?> </td> <td><label for="mdjm_txn_display_date"><?php _e('Date:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->text(array('name' => 'mdjm_txn_display_date', 'class' => '')) . MDJM()->html->hidden(array('name' => 'mdjm_txn_date')); ?> </td> <td><label for="mdjm_txn_amount"><?php _e('Direction:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->select(array('name' => 'mdjm_txn_direction', 'options' => array('In' => __('Incoming', 'mobile-dj-manager'), 'Out' => __('Outgoing', 'mobile-dj-manager')), 'show_option_all' => false, 'show_option_none' => false)); ?> </td> </tr> <tr> <td><span id="mdjm_txn_from_container"><label for="mdjm_txn_from"><?php _e('From:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->text(array('name' => 'mdjm_txn_from', 'class' => '', 'placeholder' => __('Leave empty if client', 'mobile-dj-manager'))); ?> </span> <span id="mdjm_txn_to_container" class="mdjm-hidden"><label for="mdjm_txn_to"><?php _e('To:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->text(array('name' => 'mdjm_txn_to', 'class' => '', 'placeholder' => __('Leave empty if client', 'mobile-dj-manager'))); ?> </span></td> <td><label for="mdjm_txn_for"><?php _e('For:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->txn_type_dropdown(); ?> </td> <td><label for="mdjm_txn_src"><?php _e('Paid via:', 'mobile-dj-manager'); ?> </label><br /> <?php echo MDJM()->html->select(array('name' => 'mdjm_txn_src', 'options' => mdjm_get_txn_source(), 'selected' => mdjm_get_option('default_type', 'Cash'), 'show_option_all' => false, 'show_option_none' => false)); ?> </td> </tr> <?php if (mdjm_get_option('manual_payment_cfm_template')) { ?> <tr id="mdjm-txn-email"> <td colspan="3"><?php echo MDJM()->html->checkbox(array('name' => 'mdjm_manual_txn_email', 'current' => mdjm_get_option('manual_payment_cfm_template') ? true : false, 'class' => 'mdjm-checkbox')); ?> <?php _e('Send manual payment confirmation email?', 'mobile-dj-manager'); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <p id="save-event-txn" class="mdjm-hidden"><a id="save_transaction" class="button button-primary button-small"><?php _e('Add Transaction', 'mobile-dj-manager'); ?> </a></p> <?php }
/> <?php echo esc_html(mdjm_get_balance_label()); ?> – <?php echo mdjm_currency_filter(mdjm_format_amount($mdjm_event->get_balance())); ?> <br /> <input type="radio" name="mdjm_payment_amount" id="mdjm-payment-part" value="part_payment"<?php checked($selected, 'part_payment'); ?> /> <?php echo mdjm_get_other_amount_label(); ?> <span id="mdjm-payment-custom"<?php echo $other_amount_style; ?> ><?php echo mdjm_currency_symbol(); ?> <input type="text" class="mdjm_other_amount_input mdjm-input" name="part_payment" id="part-payment" placeholder="0.00" size="10" value="<?php echo mdjm_sanitize_amount(mdjm_get_option('other_amount_default', true, false)); ?> " /></span> <span class="mdjm-description"><?php printf(__('To pay a custom amount, select %s and enter the value into the text field.', 'mobile-dj-manager'), mdjm_get_other_amount_label()); ?> </span> </p> </fieldset>
function display_price($amount, $symbol = true) { _deprecated_function(__FUNCTION__, '1.3', 'display_price()'); global $mdjm_settings; if (empty($amount) || !is_numeric($amount)) { $amount = '0.00'; } $symbol = isset($symbol) ? $symbol : true; $dec = $mdjm_settings['payments']['decimal']; $tho = $mdjm_settings['payments']['thousands_seperator']; // Currency before price if ($mdjm_settings['payments']['currency_format'] == 'before') { return (!empty($symbol) ? mdjm_currency_symbol() : '') . number_format($amount, 2, $dec, $tho); } elseif ($mdjm_settings['payments']['currency_format'] == 'before with space') { return (!empty($symbol) ? mdjm_currency_symbol() . ' ' : '') . number_format($amount, 2, $dec, $tho); } elseif ($mdjm_settings['payments']['currency_format'] == 'after') { return number_format($amount, 2, $dec, $tho) . (!empty($symbol) ? mdjm_currency_symbol() : ''); } elseif ($mdjm_settings['payments']['currency_format'] == 'after with space') { return number_format($amount, 2, $dec, $tho) . ' ' . (!empty($symbol) ? mdjm_currency_symbol() : ''); } // Default return (!empty($symbol) ? mdjm_currency_symbol() : '') . number_format($amount, 2, $dec, $tho); }
/** * Formats the currency display * * @since 1.3 * @param str $price Price * @return arr $currency Currencies displayed correctly */ function mdjm_currency_filter($price = '', $currency = '') { if (empty($currency)) { $currency = mdjm_get_currency(); } $position = mdjm_get_option('currency_format', 'before'); $negative = $price < 0; if ($negative) { $price = substr($price, 1); // Remove proceeding "-" - } $symbol = mdjm_currency_symbol($currency); if ($position == 'before') { switch ($currency) { case "GBP": case "BRL": case "EUR": case "USD": case "AUD": case "CAD": case "HKD": case "MXN": case "NZD": case "SGD": case "JPY": $formatted = $symbol . $price; break; default: $formatted = $currency . ' ' . $price; break; } $formatted = apply_filters('mdjm_' . strtolower($currency) . '_currency_filter_before', $formatted, $currency, $price); } else { switch ($currency) { case "GBP": case "BRL": case "EUR": case "USD": case "AUD": case "CAD": case "HKD": case "MXN": case "SGD": case "JPY": $formatted = $price . $symbol; break; default: $formatted = $price . ' ' . $currency; break; } $formatted = apply_filters('mdjm_' . strtolower($currency) . '_currency_filter_after', $formatted, $currency, $price); } if ($negative) { // Prepend the minus sign before the currency sign $formatted = '-' . $formatted; } return $formatted; }
/** * Load Admin Scripts * * Enqueues the required scripts for admin. * * @since 1.3 * @return void */ function mdjm_register_admin_scripts($hook) { $js_dir = MDJM_PLUGIN_URL . '/assets/js/'; wp_register_script('jquery-chosen', $js_dir . 'chosen.jquery.js', array('jquery'), MDJM_VERSION_NUM); wp_enqueue_script('jquery-chosen'); wp_enqueue_script('jquery-ui-datepicker', array('jquery')); if (strpos($hook, 'mdjm')) { wp_enqueue_script('jquery'); } $editing_event = false; $require_validation = array('mdjm-event_page_mdjm-comms'); $sortable = array('admin_page_mdjm-custom-event-fields', 'admin_page_mdjm-custom-client-fields'); if ('post.php' == $hook || 'post-new.php' == $hook) { if (isset($_GET['post']) && 'mdjm-addon' == get_post_type($_GET['post'])) { $sortable[] = 'post.php'; $sortable[] = 'post-new.php'; } if (isset($_GET['post']) && 'mdjm-event' == get_post_type($_GET['post'])) { $editing_event = true; } if (isset($_GET['post_type']) && 'mdjm-event' == $_GET['post_type']) { $editing_event = true; } if ($editing_event) { $require_validation[] = 'post.php'; $require_validation[] = 'post-new.php'; } } if (in_array($hook, $require_validation)) { wp_register_script('jquery-validation-plugin', '//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js', false); wp_enqueue_script('jquery-validation-plugin'); } if (in_array($hook, $sortable)) { wp_enqueue_script('jquery-ui-sortable'); } wp_register_script('mdjm-admin-scripts', $js_dir . 'admin-scripts.js', array('jquery'), MDJM_VERSION_NUM); wp_enqueue_script('mdjm-admin-scripts'); wp_localize_script('mdjm-admin-scripts', 'mdjm_admin_vars', apply_filters('mdjm_admin_script_vars', array('ajaxurl' => mdjm_get_ajax_url(), 'current_page' => $hook, 'editing_event' => $editing_event, 'load_recipient' => isset($_GET['recipient']) ? $_GET['recipient'] : false, 'ajax_loader' => MDJM_PLUGIN_URL . '/assets/images/loading.gif', 'no_client_first_name' => __('Enter a first name for the client', 'mobile-dj-manager'), 'no_client_email' => __('Enter an email address for the client', 'mobile-dj-manager'), 'no_txn_amount' => __('Enter a transaction value', 'mobile-dj-manager'), 'no_txn_date' => __('Enter a transaction date', 'mobile-dj-manager'), 'no_txn_for' => __('What is the transaction for?', 'mobile-dj-manager'), 'no_txn_src' => __('Enter a transaction source', 'mobile-dj-manager'), 'no_venue_name' => __('Enter a name for the venue', 'mobile-dj-manager'), 'currency' => mdjm_get_currency(), 'currency_symbol' => mdjm_currency_symbol(), 'currency_sign' => mdjm_currency_filter(''), 'currency_position' => mdjm_get_option('currency_format', 'before'), 'currency_decimals' => mdjm_currency_decimal_filter(), 'deposit_is_pct' => 'percentage' == mdjm_get_event_deposit_type() ? true : false, 'update_deposit' => 'percentage' == mdjm_get_event_deposit_type() ? true : false, 'select_months' => __('Select Months', 'mobile-dj-manager'), 'one_month_min' => __('You must have a pricing option for at least one month', 'mobile-dj-manager'), 'one_item_min' => __('Select at least one Add-on', 'mobile-dj-manager'), 'min_travel_distance' => mdjm_get_option('travel_min_distance'), 'update_travel_cost' => mdjm_get_option('travel_add_cost', false)))); wp_register_script('jquery-flot', $js_dir . 'jquery.flot.js'); wp_enqueue_script('jquery-flot'); }