/** * Renders an HTML Dropdown of months * * @access public * @since 1.3.7 * @param arr $args see @defaults. * @return str $output Month dropdown */ public function month_dropdown($args) { $defaults = array('name' => 'month', 'selected' => 0, 'fullname' => false, 'multiple' => false, 'chosen' => false, 'placeholder' => __('Select a Month', 'mobile-dj-manager')); $args = wp_parse_args($args, $defaults); $month = 1; $options = array(); $selected = empty($args['selected']) && !$args['multiple'] ? date('n') : $args['selected']; while ($month <= 12) { $options[absint($month)] = mdjm_month_num_to_name($month, $args['fullname']); $month++; } $output = $this->select(array('name' => $args['name'], 'selected' => $selected, 'options' => $options, 'show_option_all' => false, 'show_option_none' => false, 'multiple' => $args['multiple'], 'chosen' => $args['chosen'], 'placeholder' => $args['placeholder'])); return $output; }
/** * Retrieve data for an addon. * * @since 1.4 * @param int|obj $package The addon WP_Post object, or post ID. * @return arr */ function mdjm_get_addon_data($addon) { $addon_id = is_object($addon) ? $addon->ID : $addon; $events = mdjm_get_addon_event_types($addon_id); $users = mdjm_get_employees_with_addon($addon_id); $packages = mdjm_get_packages_with_addons($addon_id); $cats = get_the_terms($addon_id, 'addon-category'); $employees = array(); $months = array(); $categories = array(); $in_packages = array(); if (!mdjm_addon_is_restricted_by_date($addon_id)) { $months[] = __('Always', 'mobile-dj-manager'); } else { $availability = mdjm_get_addon_months_available($addon_id); if (!$availability) { $months[] = __('Always', 'mobile-dj-manager'); } else { $i = 0; foreach ($availability as $month) { $months[] = mdjm_month_num_to_name($availability[$i]); $i++; } } } if (in_array('all', $users)) { $employees[] = __('All Employees', 'mobile-dj-manager'); } else { foreach ($users as $employee_id) { if ('all' == $employee_id) { continue; } $employees[] = array($employee_id => mdjm_get_employee_display_name($employee_id)); } } if (in_array('all', $events)) { $event_types = sprintf(__('All %s Types', 'mobile-dj-manager'), mdjm_get_label_singular()); } else { foreach ($events as $event) { $term = get_term($event, 'event-types'); if (!empty($term)) { $event_types[] = $term->name; } } } if (mdjm_addon_has_variable_prices($addon_id)) { $range = mdjm_get_addon_price_range($addon_id); $price = mdjm_get_currency() . ' ' . mdjm_format_amount($range['low']) . ' — ' . mdjm_format_amount($range['high']); } else { $price = mdjm_get_currency() . ' ' . mdjm_format_amount(mdjm_get_addon_price($addon_id)); } if ($packages) { foreach ($packages as $package) { $in_packages[] = array($package->ID => mdjm_get_package_name($package->ID)); } } if ($cats) { foreach ($cats as $cat) { $categories[] = $cat->name; } } $addon_data = array('name' => mdjm_get_addon_name($addon_id), 'categories' => $categories, 'availability' => array('months' => $months, 'employees' => $employees, 'event_types' => $event_types), 'price' => $price, 'packages' => $in_packages, 'usage' => array('packages' => mdjm_count_packages_with_addon($addon_id), 'events' => mdjm_count_events_with_addon($addon_id))); return apply_filters('mdjm_get_addon_data', $addon_data); }
/** * Show report graph date filters * * @since 1.4 * @return void */ function mdjm_reports_graph_controls() { $date_options = apply_filters('mdjm_report_date_options', array('this_week' => __('This Week', 'mobile-dj-manager'), 'last_week' => __('Last Week', 'mobile-dj-manager'), 'this_month' => __('This Month', 'mobile-dj-manager'), 'last_month' => __('Last Month', 'mobile-dj-manager'), 'this_quarter' => __('This Quarter', 'mobile-dj-manager'), 'last_quarter' => __('Last Quarter', 'mobile-dj-manager'), 'this_year' => __('This Year', 'mobile-dj-manager'), 'last_year' => __('Last Year', 'mobile-dj-manager'), 'other' => __('Custom', 'mobile-dj-manager'))); $dates = mdjm_get_report_dates(); $display = $dates['range'] == 'other' ? '' : 'style="display:none;"'; $view = mdjm_get_reporting_view(); $taxes = !empty($_GET['exclude_taxes']) ? false : true; if (empty($dates['day_end'])) { $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y')); } ?> <form id="mdjm-graphs-filter" method="get"> <div class="tablenav top"> <div class="alignleft actions"> <input type="hidden" name="post_type" value="mdjm-event"/> <input type="hidden" name="page" value="mdjm-reports"/> <input type="hidden" name="view" value="<?php echo esc_attr($view); ?> "/> <?php if (isset($_GET['event-id'])) { ?> <input type="hidden" name="event-id" value="<?php echo absint($_GET['event-id']); ?> "/> <?php } ?> <select id="mdjm-graphs-date-options" name="range"> <?php foreach ($date_options as $key => $option) { ?> <option value="<?php echo esc_attr($key); ?> "<?php selected($key, $dates['range']); ?> ><?php echo esc_html($option); ?> </option> <?php } ?> </select> <div id="mdjm-date-range-options" <?php echo $display; ?> > <span><?php _e('From', 'mobile-dj-manager'); ?> </span> <select id="mdjm-graphs-month-start" name="m_start"> <?php for ($i = 1; $i <= 12; $i++) { ?> <option value="<?php echo absint($i); ?> " <?php selected($i, $dates['m_start']); ?> ><?php echo mdjm_month_num_to_name($i); ?> </option> <?php } ?> </select> <select id="mdjm-graphs-day-start" name="day"> <?php for ($i = 1; $i <= 31; $i++) { ?> <option value="<?php echo absint($i); ?> " <?php selected($i, $dates['day']); ?> ><?php echo $i; ?> </option> <?php } ?> </select> <select id="mdjm-graphs-year-start" name="year"> <?php for ($i = 2007; $i <= date('Y'); $i++) { ?> <option value="<?php echo absint($i); ?> " <?php selected($i, $dates['year']); ?> ><?php echo $i; ?> </option> <?php } ?> </select> <span><?php _e('To', 'mobile-dj-manager'); ?> </span> <select id="mdjm-graphs-month-end" name="m_end"> <?php for ($i = 1; $i <= 12; $i++) { ?> <option value="<?php echo absint($i); ?> " <?php selected($i, $dates['m_end']); ?> ><?php echo mdjm_month_num_to_name($i); ?> </option> <?php } ?> </select> <select id="mdjm-graphs-day-end" name="day_end"> <?php for ($i = 1; $i <= 31; $i++) { ?> <option value="<?php echo absint($i); ?> " <?php selected($i, $dates['day_end']); ?> ><?php echo $i; ?> </option> <?php } ?> </select> <select id="mdjm-graphs-year-end" name="year_end"> <?php for ($i = 2007; $i <= date('Y'); $i++) { ?> <option value="<?php echo absint($i); ?> " <?php selected($i, $dates['year_end']); ?> ><?php echo $i; ?> </option> <?php } ?> </select> </div> <div class="mdjm-graph-filter-submit graph-option-section"> <input type="hidden" name="mdjm-action" value="filter_reports" /> <input type="submit" class="button-secondary" value="<?php _e('Filter', 'mobile-dj-manager'); ?> "/> </div> </div> </div> </form> <?php }
/** * Define the data to be displayed in each of the custom columns for the Addon post types * * @since 1.4 * @param str $column_name The name of the column to display * @param int $post_id The current post ID * @return */ function mdjm_addon_posts_custom_column($column_name, $post_id) { global $post; switch ($column_name) { // Category case 'addon_category': echo get_the_term_list($post_id, 'addon-category', '', ', ', ''); break; // Availability // Availability case 'availability': $output = array(); if (!mdjm_addon_is_restricted_by_date($post_id)) { $output[] = __('Always', 'mobile-dj-manager'); } else { $availability = mdjm_get_addon_months_available($post_id); if (!$availability) { $output[] = __('Always', 'mobile-dj-manager'); } else { $i = 0; foreach ($availability as $month) { $output[] = mdjm_month_num_to_name($availability[$i]); $i++; } } } echo implode(', ', $output); break; // Event Types // Event Types case 'event_types': $output = array(); $event_label = mdjm_get_label_singular(); $event_types = mdjm_get_addon_event_types($post_id); if (in_array('all', $event_types)) { $output[] = sprintf(__('All %s Types', 'mobile-dj-manager'), $event_label); } else { foreach ($event_types as $event_type) { $term = get_term($event_type, 'event-types'); if (!empty($term)) { $output[] = $term->name; } } } echo implode(', ', $output); break; // Employees // Employees case 'employees': $employees = mdjm_get_employees_with_addon($post_id); $output = array(); if (in_array('all', $employees)) { $output[] = __('All Employees', 'mobile-dj-manager'); } else { foreach ($employees as $employee) { if ('all' == $employee) { continue; } $output[] = '<a href="' . get_edit_user_link($employee) . '">' . mdjm_get_employee_display_name($employee) . '</a>'; } } echo implode('<br />', $output); break; // Price // Price case 'price': if (mdjm_addon_has_variable_prices($post_id)) { $range = mdjm_get_addon_price_range($post_id); echo mdjm_currency_filter(mdjm_format_amount($range['low'])); echo ' — '; echo mdjm_currency_filter(mdjm_format_amount($range['high'])); } else { echo mdjm_currency_filter(mdjm_format_amount(mdjm_get_addon_price($post_id))); } break; // Usage // Usage case 'usage': $packages = mdjm_count_packages_with_addon($post_id); $events = mdjm_count_events_with_addon($post_id); echo $packages . _n(' Package', ' Packages', $packages, 'mobile-dj-manager') . '<br />'; echo $events . ' ' . _n(mdjm_get_label_singular(), mdjm_get_label_plural(), $events, 'mobile-dj-manager'); break; } // switch }