/**
  * Renders an HTML Dropdown of months
  *
  * @access public
  * @since  1.0
  *
  * @param string $name     Name attribute of the dropdown
  * @param int    $selected Month to select automatically
  *
  * @return string $output Month dropdown
  */
 public function month_dropdown($name = 'month', $selected = 0)
 {
     $month = 1;
     $options = array();
     $selected = empty($selected) ? date('n') : $selected;
     while ($month <= 12) {
         $options[absint($month)] = give_month_num_to_name($month);
         $month++;
     }
     $output = $this->select(array('name' => $name, 'selected' => $selected, 'options' => $options, 'show_option_all' => false, 'show_option_none' => false));
     return $output;
 }
Пример #2
0
/**
 * Show report graph date filters
 *
 * @since 1.0
 * @return void
 */
function give_reports_graph_controls()
{
    $date_options = apply_filters('give_report_date_options', array('today' => __('Today', 'give'), 'yesterday' => __('Yesterday', 'give'), 'this_week' => __('This Week', 'give'), 'last_week' => __('Last Week', 'give'), 'this_month' => __('This Month', 'give'), 'last_month' => __('Last Month', 'give'), 'this_quarter' => __('This Quarter', 'give'), 'last_quarter' => __('Last Quarter', 'give'), 'this_year' => __('This Year', 'give'), 'last_year' => __('Last Year', 'give'), 'other' => __('Custom', 'give')));
    $dates = give_get_report_dates();
    $display = $dates['range'] == 'other' ? '' : 'style="display:none;"';
    $view = give_get_reporting_view();
    if (empty($dates['day_end'])) {
        $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y'));
    }
    //echo '<pre>'; print_r( $dates ); echo '</pre>';
    do_action('give_report_graph_controls_before');
    ?>
	<form id="give-graphs-filter" method="get" class="alignright">
		<div class="tablenav top alignright">
			<div class="actions">

				<input type="hidden" name="post_type" value="give_forms" />
				<input type="hidden" name="page" value="give-reports" />
				<input type="hidden" name="view" value="<?php 
    echo esc_attr($view);
    ?>
" />

				<?php 
    if (isset($_GET['form-id'])) {
        ?>
					<input type="hidden" name="form-id" value="<?php 
        echo absint($_GET['form-id']);
        ?>
" />
				<?php 
    }
    ?>

				<div id="give-graphs-date-options-wrap" class="alignright">
					<select id="give-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>

					<input type="submit" class="button-secondary" value="<?php 
    _e('Filter', 'give');
    ?>
" />
				</div>

				<div id="give-date-range-options" <?php 
    echo $display;
    ?>
>
					<span><?php 
    _e('From', 'give');
    ?>
&nbsp;</span>
					<select id="give-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 give_month_num_to_name($i);
        ?>
</option>
						<?php 
    }
    ?>
					</select>
					<select id="give-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="give-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', 'give');
    ?>
&nbsp;</span>
					<select id="give-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 give_month_num_to_name($i);
        ?>
</option>
						<?php 
    }
    ?>
					</select>
					<select id="give-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="give-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>

				<input type="hidden" name="give_action" value="filter_reports" />
			</div>
		</div>
	</form>
	<?php 
    do_action('give_report_graph_controls_after');
}