Example #1
0
/**
 *
 * @param string $p_name
 * @param string $p_format
 * @param int $p_date
 * @param bool $p_default_disable
 * @param bool $p_allow_blank
 * @param int $p_year_start
 * @param int $p_year_end
 * @return null
 * @access public
 */
function print_date_selection_set($p_name, $p_format, $p_date = 0, $p_default_disable = false, $p_allow_blank = false, $p_year_start = 0, $p_year_end = 0)
{
    $t_chars = preg_split('//', $p_format, -1, PREG_SPLIT_NO_EMPTY);
    if ($p_date != 0) {
        $t_date = preg_split('/-/', date('Y-m-d', $p_date), -1, PREG_SPLIT_NO_EMPTY);
    } else {
        $t_date = array(0, 0, 0);
    }
    $t_disable = '';
    if ($p_default_disable == true) {
        $t_disable = ' disabled="disabled"';
    }
    $t_blank_line = '';
    if ($p_allow_blank == true) {
        $t_blank_line = "<option value=\"0\"></option>";
    }
    foreach ($t_chars as $t_char) {
        if (strcmp($t_char, "M") == 0) {
            echo "<select ", helper_get_tab_index(), " name=\"" . $p_name . "_month\"{$t_disable}>";
            echo $t_blank_line;
            print_month_option_list($t_date[1]);
            echo "</select>\n";
        }
        if (strcmp($t_char, "m") == 0) {
            echo "<select ", helper_get_tab_index(), " name=\"" . $p_name . "_month\"{$t_disable}>";
            echo $t_blank_line;
            print_numeric_month_option_list($t_date[1]);
            echo "</select>\n";
        }
        if (strcasecmp($t_char, "D") == 0) {
            echo "<select ", helper_get_tab_index(), " name=\"" . $p_name . "_day\"{$t_disable}>";
            echo $t_blank_line;
            print_day_option_list($t_date[2]);
            echo "</select>\n";
        }
        if (strcasecmp($t_char, "Y") == 0) {
            echo "<select ", helper_get_tab_index(), " name=\"" . $p_name . "_year\"{$t_disable}>";
            echo $t_blank_line;
            print_year_range_option_list($t_date[0], $p_year_start, $p_year_end);
            echo "</select>\n";
        }
    }
}
Example #2
0
/**
 * Print <select> tag for selecting a date
 * @param string  $p_name            Name for html select field attribute.
 * @param string  $p_format          Date format e.g. YmD.
 * @param integer $p_date            Integer timestamp representing date.
 * @param boolean $p_default_disable Whether date selector is disabled.
 * @param boolean $p_allow_blank     Whether blank/null date is allowed.
 * @param integer $p_year_start      First year to display in drop down.
 * @param integer $p_year_end        Last year to display in drop down.
 * @return void
 * @access public
 */
function print_date_selection_set($p_name, $p_format, $p_date = 0, $p_default_disable = false, $p_allow_blank = false, $p_year_start = 0, $p_year_end = 0)
{
    $t_chars = preg_split('//', $p_format, -1, PREG_SPLIT_NO_EMPTY);
    if ($p_date != 0) {
        $t_date = preg_split('/-/', date('Y-m-d', $p_date), -1, PREG_SPLIT_NO_EMPTY);
    } else {
        $t_date = array(0, 0, 0);
    }
    $t_disable = '';
    if ($p_default_disable == true) {
        $t_disable = ' disabled="disabled"';
    }
    $t_blank_line = '';
    if ($p_allow_blank == true) {
        $t_blank_line = '<option value="0"></option>';
    }
    foreach ($t_chars as $t_char) {
        if (strcmp($t_char, 'M') == 0) {
            echo '<select ' . helper_get_tab_index() . ' name="' . $p_name . '_month"' . $t_disable . '>';
            echo $t_blank_line;
            print_month_option_list($t_date[1]);
            echo "</select>\n";
        }
        if (strcmp($t_char, 'm') == 0) {
            echo '<select ' . helper_get_tab_index() . ' name="' . $p_name . '_month"' . $t_disable . '>';
            echo $t_blank_line;
            print_month_option_list($t_date[1]);
            echo '</select>' . "\n";
        }
        if (strcasecmp($t_char, 'D') == 0) {
            echo '<select ' . helper_get_tab_index() . ' name="' . $p_name . '_day"' . $t_disable . '>';
            echo $t_blank_line;
            print_day_option_list($t_date[2]);
            echo '</select>' . "\n";
        }
        if (strcasecmp($t_char, 'Y') == 0) {
            echo '<select ' . helper_get_tab_index() . ' name="' . $p_name . '_year"' . $t_disable . '>';
            echo $t_blank_line;
            print_year_range_option_list($t_date[0], $p_year_start, $p_year_end);
            echo '</select>' . "\n";
        }
    }
}