/** * * @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"; } } }
function print_filter_do_filter_by_date($p_hide_checkbox = false) { global $t_filter; ?> <table cellspacing="0" cellpadding="0"> <?php if (!$p_hide_checkbox) { ?> <tr><td colspan="2"> <input type="checkbox" name="do_filter_by_date" <?php check_checked($t_filter['do_filter_by_date'], 'on'); if (ON == config_get('use_javascript')) { print "onclick=\"SwitchDateFields();\""; } ?> /> <?php echo lang_get('use_date_filters'); ?> </td></tr> <?php } $t_menu_disabled = 'on' == $t_filter['do_filter_by_date'] ? '' : ' disabled '; ?> <!-- Start date --> <tr> <td> <?php echo lang_get('start_date'); ?> : </td> <td nowrap="nowrap"> <?php $t_chars = preg_split('//', config_get('short_date_format'), -1, PREG_SPLIT_NO_EMPTY); foreach ($t_chars as $t_char) { if (strcasecmp($t_char, "M") == 0) { print "<select name=\"start_month\" {$t_menu_disabled}>"; print_month_option_list($t_filter['start_month']); print "</select>\n"; } if (strcasecmp($t_char, "D") == 0) { print "<select name=\"start_day\" {$t_menu_disabled}>"; print_day_option_list($t_filter['start_day']); print "</select>\n"; } if (strcasecmp($t_char, "Y") == 0) { print "<select name=\"start_year\" {$t_menu_disabled}>"; print_year_option_list($t_filter['start_year']); print "</select>\n"; } } ?> </td> </tr> <!-- End date --> <tr> <td> <?php echo lang_get('end_date'); ?> : </td> <td> <?php $t_chars = preg_split('//', config_get('short_date_format'), -1, PREG_SPLIT_NO_EMPTY); foreach ($t_chars as $t_char) { if (strcasecmp($t_char, "M") == 0) { print "<select name=\"end_month\" {$t_menu_disabled}>"; print_month_option_list($t_filter['end_month']); print "</select>\n"; } if (strcasecmp($t_char, "D") == 0) { print "<select name=\"end_day\" {$t_menu_disabled}>"; print_day_option_list($t_filter['end_day']); print "</select>\n"; } if (strcasecmp($t_char, "Y") == 0) { print "<select name=\"end_year\" {$t_menu_disabled}>"; print_year_option_list($t_filter['end_year']); print "</select>\n"; } } ?> </td> </tr> </table> <?php }
/** * Print filter by date fields * @param boolean $p_hide_checkbox Hide data filter checkbox. * @return void */ function print_filter_do_filter_by_date($p_hide_checkbox = false) { global $g_filter; ?> <table cellspacing="0" cellpadding="0"> <?php $t_menu_disabled = ''; if (!$p_hide_checkbox) { ?> <tr> <td colspan="2"> <label> <input type="checkbox" id="use_date_filters" name="<?php echo FILTER_PROPERTY_FILTER_BY_DATE; ?> "<?php check_checked(gpc_string_to_bool($g_filter[FILTER_PROPERTY_FILTER_BY_DATE]), true); ?> /> <?php echo lang_get('use_date_filters'); ?> </label> </td> </tr> <?php if ('on' !== $g_filter[FILTER_PROPERTY_FILTER_BY_DATE]) { $t_menu_disabled = ' disabled="disabled" '; } } ?> <!-- Start date --> <tr> <td> <?php echo lang_get('start_date_label'); ?> </td> <td class="nowrap"> <?php $t_chars = preg_split('//', config_get('short_date_format'), -1, PREG_SPLIT_NO_EMPTY); foreach ($t_chars as $t_char) { if (strcasecmp($t_char, 'M') == 0) { echo '<select name="', FILTER_PROPERTY_START_MONTH, '"', $t_menu_disabled, '>'; print_month_option_list($g_filter[FILTER_PROPERTY_START_MONTH]); print "</select>\n"; } if (strcasecmp($t_char, 'D') == 0) { echo '<select name="', FILTER_PROPERTY_START_DAY, '"', $t_menu_disabled, '>'; print_day_option_list($g_filter[FILTER_PROPERTY_START_DAY]); print "</select>\n"; } if (strcasecmp($t_char, 'Y') == 0) { echo '<select name="', FILTER_PROPERTY_START_YEAR, '"', $t_menu_disabled, '>'; print_year_option_list($g_filter[FILTER_PROPERTY_START_YEAR]); print "</select>\n"; } } ?> </td> </tr> <!-- End date --> <tr> <td> <?php echo lang_get('end_date_label'); ?> </td> <td> <?php $t_chars = preg_split('//', config_get('short_date_format'), -1, PREG_SPLIT_NO_EMPTY); foreach ($t_chars as $t_char) { if (strcasecmp($t_char, 'M') == 0) { echo '<select name="', FILTER_PROPERTY_END_MONTH, '"', $t_menu_disabled, '>'; print_month_option_list($g_filter[FILTER_PROPERTY_END_MONTH]); print "</select>\n"; } if (strcasecmp($t_char, 'D') == 0) { echo '<select name="', FILTER_PROPERTY_END_DAY, '"', $t_menu_disabled, '>'; print_day_option_list($g_filter[FILTER_PROPERTY_END_DAY]); print "</select>\n"; } if (strcasecmp($t_char, 'Y') == 0) { echo '<select name="', FILTER_PROPERTY_END_YEAR, '"', $t_menu_disabled, '>'; print_year_option_list($g_filter[FILTER_PROPERTY_END_YEAR]); print "</select>\n"; } } ?> </td> </tr> </table> <?php }
/** * print filter by date fields with javascript * @todo Javascript should be removed and added dynamically * via external script */ function print_filter_do_filter_by_date($p_hide_checkbox = false) { global $t_filter; ?> <table cellspacing="0" cellpadding="0"> <?php if (!$p_hide_checkbox) { ?> <tr><td colspan="2"> <input type="checkbox" name="<?php echo FILTER_PROPERTY_FILTER_BY_DATE; ?> " <?php check_checked($t_filter[FILTER_PROPERTY_FILTER_BY_DATE], 'on'); if (ON == config_get('use_javascript')) { print "onclick=\"SwitchDateFields();\""; } ?> /> <?php echo lang_get('use_date_filters'); ?> </td></tr> <?php } $t_menu_disabled = 'on' == $t_filter[FILTER_PROPERTY_FILTER_BY_DATE] ? '' : ' disabled '; ?> <!-- Start date --> <tr> <td> <?php echo lang_get('start_date'); ?> : </td> <td nowrap="nowrap"> <?php $t_chars = preg_split('//', config_get('short_date_format'), -1, PREG_SPLIT_NO_EMPTY); foreach ($t_chars as $t_char) { if (strcasecmp($t_char, "M") == 0) { echo '<select name="', FILTER_PROPERTY_START_MONTH, '"', $t_menu_disabled, '>'; print_month_option_list($t_filter[FILTER_PROPERTY_START_MONTH]); print "</select>\n"; } if (strcasecmp($t_char, "D") == 0) { echo '<select name="', FILTER_PROPERTY_START_DAY, '"', $t_menu_disabled, '>'; print_day_option_list($t_filter[FILTER_PROPERTY_START_DAY]); print "</select>\n"; } if (strcasecmp($t_char, "Y") == 0) { echo '<select name="', FILTER_PROPERTY_START_YEAR, '"', $t_menu_disabled, '>'; print_year_option_list($t_filter[FILTER_PROPERTY_START_YEAR]); print "</select>\n"; } } ?> </td> </tr> <!-- End date --> <tr> <td> <?php echo lang_get('end_date'); ?> : </td> <td> <?php $t_chars = preg_split('//', config_get('short_date_format'), -1, PREG_SPLIT_NO_EMPTY); foreach ($t_chars as $t_char) { if (strcasecmp($t_char, "M") == 0) { echo '<select name="', FILTER_PROPERTY_END_MONTH, '"', $t_menu_disabled, '>'; print_month_option_list($t_filter[FILTER_PROPERTY_END_MONTH]); print "</select>\n"; } if (strcasecmp($t_char, "D") == 0) { echo '<select name="', FILTER_PROPERTY_END_DAY, '"', $t_menu_disabled, '>'; print_day_option_list($t_filter[FILTER_PROPERTY_END_DAY]); print "</select>\n"; } if (strcasecmp($t_char, "Y") == 0) { echo '<select name="', FILTER_PROPERTY_END_YEAR, '"', $t_menu_disabled, '>'; print_year_option_list($t_filter[FILTER_PROPERTY_END_YEAR]); print "</select>\n"; } } ?> </td> </tr> </table> <?php }
function Source_Date_Select($p_name, $p_selected = null) { static $s_min = null, $s_max = null; if (is_null($s_min) || is_null($s_max)) { $t_changeset_table = plugin_table('changeset'); $t_query = "SELECT MIN( timestamp ) AS min, MAX( timestamp ) AS max FROM {$t_changeset_table}"; $t_result = db_query_bound($t_query); $t_row = db_fetch_array($t_result); $t_row = array_map('Source_Date_StampArray', $t_row); $s_min = $t_row['min'][0]; $s_max = $t_row['max'][0]; # Handle the case when there are no changesets in the table if (is_null($s_min)) { $s_min = $s_max = idate('Y'); } } if ($p_selected == 'now') { $t_selected = array((int) date('Y'), (int) date('m'), (int) date('d')); echo '<input type="hidden" name="', $p_name, '_default" value="', "{$t_selected['0']}-{$t_selected['1']}-{$t_selected['2']}", '"/>'; } elseif ($p_selected == 'start') { $t_selected = array($s_min, 1, 1); echo '<input type="hidden" name="', $p_name, '_default" value="', "{$t_selected['0']}-{$t_selected['1']}-{$t_selected['2']}", '"/>'; } else { $t_selected = Source_Date_StampArray($p_selected); } echo '<select name="', $p_name, '_year">'; for ($t_year = $s_max; $t_year >= $s_min; $t_year--) { echo '<option value="', $t_year, $t_year === $t_selected[0] ? '" selected="selected"' : '"', '>', $t_year, '</option>'; } echo '</select> '; echo '<select name="', $p_name, '_month">'; print_month_option_list($t_selected[1]); echo '</select> '; echo '<select name="', $p_name, '_day">'; print_day_option_list($t_selected[2]); echo '</select> '; }
/** * 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"; } } }
/** * Show TimeTracking information when viewing bugs. * @param string Event name * @param int Bug ID */ function view_bug_time($p_event, $p_bug_id) { $table = plugin_table('data'); $t_user_id = auth_get_current_user_id(); # Pull all Time-Record entries for the current Bug if (access_has_bug_level(plugin_config_get('view_others_threshold'), $p_bug_id)) { $query_pull_timerecords = "SELECT * FROM {$table} WHERE bug_id = {$p_bug_id} ORDER BY timestamp DESC"; } else { if (access_has_bug_level(plugin_config_get('admin_own_threshold'), $p_bug_id)) { $query_pull_timerecords = "SELECT * FROM {$table} WHERE bug_id = {$p_bug_id} and user = {$t_user_id} ORDER BY timestamp DESC"; } else { // User has no access return; } } $result_pull_timerecords = db_query($query_pull_timerecords); $num_timerecords = db_num_rows($result_pull_timerecords); # Get Sum for this bug $query_pull_hours = "SELECT SUM(hours) as hours FROM {$table} WHERE bug_id = {$p_bug_id}"; $result_pull_hours = db_query($query_pull_hours); $row_pull_hours = db_fetch_array($result_pull_hours); ?> <a name="timerecord" id="timerecord" /><br /> <?php collapse_open('timerecord'); ?> <table class="width100" cellspacing="1"> <tr> <td colspan="6" class="form-title"> <?php collapse_icon('timerecord'); echo plugin_lang_get('title'); ?> </td> </tr> <tr class="row-category"> <td><div align="center"><?php echo plugin_lang_get('user'); ?> </div></td> <td><div align="center"><?php echo plugin_lang_get('expenditure_date'); ?> </div></td> <td><div align="center"><?php echo plugin_lang_get('hours'); ?> </div></td> <td><div align="center"><?php echo plugin_lang_get('information'); ?> </div></td> <td><div align="center"><?php echo plugin_lang_get('entry_date'); ?> </div></td> <td> </td> </tr> <?php if (access_has_bug_level(plugin_config_get('admin_own_threshold'), $p_bug_id)) { $current_date = explode("-", date("Y-m-d")); ?> <form name="time_tracking" method="post" action="<?php echo plugin_page('add_record'); ?> " > <?php echo form_security_field('plugin_TimeTracking_add_record'); ?> <input type="hidden" name="bug_id" value="<?php echo $p_bug_id; ?> "> <tr <?php echo helper_alternate_class(); ?> > <td><?php echo user_get_name(auth_get_current_user_id()); ?> </td> <td nowrap> <div align="center"> <select tabindex="5" name="day"><?php print_day_option_list($current_date[2]); ?> </select> <select tabindex="6" name="month"><?php print_month_option_list($current_date[1]); ?> </select> <select tabindex="7" name="year"><?php print_year_option_list($current_date[0]); ?> </select> </div> </td> <td><div align="right"><input type="text" name="time_value" value="00:00" size="5"></div></td> <td><div align="center"><input type="text" name="time_info"></div></td> <td> </td> <td><input name="<?php echo plugin_lang_get('submit'); ?> " type="submit" value="<?php echo plugin_lang_get('submit'); ?> "></td> </tr> </form> <?php } # END Access Control for ($i = 0; $i < $num_timerecords; $i++) { $row = db_fetch_array($result_pull_timerecords); ?> <tr <?php echo helper_alternate_class(); ?> > <td><?php echo user_get_name($row["user"]); ?> </td> <td><div align="center"><?php echo date(config_get("short_date_format"), strtotime($row["expenditure_date"])); ?> </div></td> <td><div align="right"><?php echo db_minutes_to_hhmm($row["hours"] * 60); ?> </div></td> <td><div align="center"><?php echo string_display_links($row["info"]); ?> </div></td> <td><div align="center"><?php echo date(config_get("complete_date_format"), strtotime($row["timestamp"])); ?> </div></td> <?php $user = auth_get_current_user_id(); if ($user == $row["user"] && access_has_bug_level(plugin_config_get('admin_own_threshold'), $p_bug_id) || access_has_bug_level(plugin_config_get('admin_threshold'), $p_bug_id)) { ?> <td><a href="<?php echo plugin_page('delete_record'); ?> &bug_id=<?php echo $p_bug_id; ?> &delete_id=<?php echo $row["id"]; echo form_security_param('plugin_TimeTracking_delete_record'); ?> "><?php echo plugin_lang_get('delete'); ?> </a></td> <?php } else { ?> <td> </td> <?php } ?> </tr> <?php } # End for loop ?> <tr class="row-category"> <td><?php echo plugin_lang_get('sum'); ?> </td> <td> </td> <td><div align="right"><b><?php echo db_minutes_to_hhmm($row_pull_hours['hours'] * 60); ?> </b></div></td> <td> </td> <td> </td> <td> </td> </tr> </table> <?php collapse_closed('timerecord'); ?> <table class="width100" cellspacing="1"> <tr> <td class="form-title" colspan="2"> <?php collapse_icon('timerecord'); ?> <?php echo plugin_lang_get('title'); ?> </td> </tr> </table> <?php collapse_end('timerecord'); }
/** * print filter by date fields */ function print_filter_do_filter_by_date($p_hide_checkbox = false) { global $t_filter; ?> <table cellspacing="0" cellpadding="0"> <?php if (!$p_hide_checkbox) { ?> <tr> <td colspan="2"> <label><input type="checkbox" id="use_date_filters" name="<?php echo FILTER_PROPERTY_FILTER_BY_DATE; ?> "<?php check_checked($t_filter[FILTER_PROPERTY_FILTER_BY_DATE], 'on'); ?> /><?php echo lang_get('use_date_filters'); ?> </label> </td> </tr> <?php } # Make sure the date selection controls are enabled by default # if we do not use javascript $t_menu_disabled = !config_get('use_javascript') || 'on' == $t_filter[FILTER_PROPERTY_FILTER_BY_DATE] ? '' : ' disabled="disabled" '; ?> <!-- Start date --> <tr> <td> <?php echo lang_get('start_date_label'); ?> </td> <td class="nowrap"> <?php $t_chars = preg_split('//', config_get('short_date_format'), -1, PREG_SPLIT_NO_EMPTY); foreach ($t_chars as $t_char) { if (strcasecmp($t_char, "M") == 0) { echo '<select name="', FILTER_PROPERTY_START_MONTH, '"', $t_menu_disabled, '>'; print_month_option_list($t_filter[FILTER_PROPERTY_START_MONTH]); print "</select>\n"; } if (strcasecmp($t_char, "D") == 0) { echo '<select name="', FILTER_PROPERTY_START_DAY, '"', $t_menu_disabled, '>'; print_day_option_list($t_filter[FILTER_PROPERTY_START_DAY]); print "</select>\n"; } if (strcasecmp($t_char, "Y") == 0) { echo '<select name="', FILTER_PROPERTY_START_YEAR, '"', $t_menu_disabled, '>'; print_year_option_list($t_filter[FILTER_PROPERTY_START_YEAR]); print "</select>\n"; } } ?> </td> </tr> <!-- End date --> <tr> <td> <?php echo lang_get('end_date_label'); ?> </td> <td> <?php $t_chars = preg_split('//', config_get('short_date_format'), -1, PREG_SPLIT_NO_EMPTY); foreach ($t_chars as $t_char) { if (strcasecmp($t_char, "M") == 0) { echo '<select name="', FILTER_PROPERTY_END_MONTH, '"', $t_menu_disabled, '>'; print_month_option_list($t_filter[FILTER_PROPERTY_END_MONTH]); print "</select>\n"; } if (strcasecmp($t_char, "D") == 0) { echo '<select name="', FILTER_PROPERTY_END_DAY, '"', $t_menu_disabled, '>'; print_day_option_list($t_filter[FILTER_PROPERTY_END_DAY]); print "</select>\n"; } if (strcasecmp($t_char, "Y") == 0) { echo '<select name="', FILTER_PROPERTY_END_YEAR, '"', $t_menu_disabled, '>'; print_year_option_list($t_filter[FILTER_PROPERTY_END_YEAR]); print "</select>\n"; } } ?> </td> </tr> </table> <?php }