added filter and change of duration to date/time

This commit is contained in:
skeeter 2000-12-04 01:11:53 +00:00
parent 4373ddb170
commit bf040328ed
16 changed files with 231 additions and 42 deletions

View File

@ -83,7 +83,7 @@
$phpgw->template->set_var("bg_text",$phpgw_info["theme"]["bg_text"]);
$m = mktime(2,0,0,$thismonth,1,$thisyear);
$phpgw->template->set_var("date",lang(strftime("%B",$m))." ".$thisday.", ".$thisyear);
$phpgw->template->set_var("date",lang(date("F",$m))." ".$thisday.", ".$thisyear);
$phpgw->template->set_var("username",$phpgw->common->display_fullname($id,$fn,$ln));
$phpgw->template->set_var("daily_events",$phpgw->calendar->print_day_at_a_glance($now,$owner));
$phpgw->template->set_var("small_calendar",$phpgw->calendar->pretty_small_calendar($now["day"],$now["month"],$now["year"],"day.php"));

View File

@ -101,7 +101,7 @@
$phpgw->template->parse("output","list",True);
// Date
$phpgw->template->set_var("field",lang("Date"));
$phpgw->template->set_var("field",lang("Start Date"));
$day_html = "<select name=\"day\">";
for ($i = 1; $i <= 31; $i++)
@ -125,7 +125,7 @@
$phpgw->template->parse("output","list",True);
// Time
$phpgw->template->set_var("field",lang("Time"));
$phpgw->template->set_var("field",lang("End Time"));
$amsel = "checked"; $pmsel = "";
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
@ -141,12 +141,51 @@
$str .= "<input type=\"radio\" name=\"ampm\" value=\"pm\" $pmsel>pm";
}
// End Date
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
// Duration
$phpgw->template->set_var("field",lang("Duration"));
$phpgw->template->set_var("data","<input name=\"duration\" size=\"3\" value=\"".(!$cal_info->duration?0:$cal_info->duration)."\"> ".lang("minutes"));
$phpgw->template->set_var("field",lang("End Date"));
$day_html = "<select name=\"end_day\">";
for ($i = 1; $i <= 31; $i++)
$day_html .= "<option value=\"$i\"" . ($i == intval($phpgw->common->show_date($cal_info->edatetime,"d")) ? " selected" : "") . ">$i</option>\n";
$day_html .= "</select>";
$month_html = "<select name=\"end_month\">";
for ($i = 1; $i <= 12; $i++) {
$m = lang(date("F",mktime(0,0,0,$i,1,2000)));
$month_html .= "<option value=\"$i\"" . ($i == intval($phpgw->common->show_date($cal_info->edatetime,"n")) ? " selected" : "") . ">$m</option>\n";
}
$month_html .= "</select>";
$year_html = "<select name=\"end_year\">";
for ($i = (intval($phpgw->common->show_date($cal_info->edatetime,"Y")) - 1); $i < (intval($phpgw->common->show_date($cal_info->edatetime,"Y")) + 5); $i++) {
$year_html .= "<option value=\"$i\"" . ($i == intval($phpgw->common->show_date($cal_info->edatetime,"Y")) ? " selected" : "") . ">$i</option>\n";
}
$year_html .= "</select>";
$phpgw->template->set_var("data",$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
$phpgw->template->parse("output","list",True);
// End Time
$phpgw->template->set_var("field",lang("End Time"));
$amsel = "checked"; $pmsel = "";
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
if ($cal_info->end_ampm == "pm") {
$amsel = ""; $pmsel = "checked";
} else {
$amsel = "checked"; $pmsel = "";
}
}
$str = "<input name=\"end_hour\" size=\"2\" VALUE=\"".$phpgw->common->show_date($cal_info->edatetime,"H")."\" maxlength=\"2\">:<input name=\"end_minute\" size=\"2\" value=\"".$phpgw->common->show_date($cal_info->edatetime,"i")."\" maxlength=\"2\">";
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$str .= "<input type=\"radio\" name=\"end_ampm\" value=\"am\" $amsel>am";
$str .= "<input type=\"radio\" name=\"end_ampm\" value=\"pm\" $pmsel>pm";
}
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
// Priority

View File

@ -33,7 +33,7 @@
$cal_info->owner = $cal_info->participants[0];
}
$phpgw->common->appsession($cal_info);
$overlapping_events = $phpgw->calendar->overlap($cal_info->month,$cal_info->day,$cal_info->year,$cal_info->hour,$cal_info->minute,$cal_info->ampm,$cal_info->duration,$cal_info->participants,$cal_info->id);
$overlapping_events = $phpgw->calendar->overlap($cal_info->month,$cal_info->day,$cal_info->year,$cal_info->hour,$cal_info->minute,$cal_info->ampm,$cal_info->end_month,$cal_info->end_day,$cal_info->end_year,$cal_info->end_hour,$cal_info->end_minute,$cal_info->end_ampm,$cal_info->participants,$cal_info->id);
} else {
$cal_info = $phpgw->common->appsession();
}
@ -50,6 +50,12 @@
$time = $phpgw->calendar->fixtime($cal_info->hour,$cal_info->minute,$cal_info->ampm);
$calendar_overlaps = $phpgw->calendar->getevent($overlapping_events);
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$format = "h:i:s a";
} else {
$format = "H:i:s";
}
$overlap = "";
for($i=0;$i<count($calendar_overlaps);$i++) {
$cal_over = $calendar_overlaps[$i];
@ -59,9 +65,7 @@
$overlap .= "(PRIVATE)";
else
$overlap .= $phpgw->calendar->link_to_entry($cal_over->id,"circle.gif",$cal_over->name);
$disp_start_time = $phpgw->calendar->build_time_for_display($phpgw->calendar->fixtime($cal_over->hour,$cal_over->minute,$cal_over->ampm));
$disp_stop_time = $phpgw->calendar->build_time_for_display($phpgw->calendar->addduration($cal_over->hour,$cal_over->minute,$cal_over->ampm,$cal_over->duration));
$overlap .= " (".$disp_start_time." - ".$disp_stop_time.")<br>";
$overlap .= " (".$phpgw->common->show_date($cal_over->datetime,$format)." - ".$phpgw->common->show_date($cal_over->edatetime,$format).")<br>";
}
}
if(strlen($overlap)) {

View File

@ -1,6 +1,7 @@
<?php
global $date, $year, $month, $day, $thisyear, $thismonth, $thisday;
global $date, $year, $month, $day, $thisyear, $thismonth, $thisday, $filter, $keywords;
// global $filter_method;
if(!isset($phpgw_info["user"]["preferences"]["calendar"]["weekdaystarts"]))
$phpgw_info["user"]["preferences"]["calendar"]["weekdaystarts"] = "Sunday";
@ -23,12 +24,20 @@
$thisyear = $year;
}
// if($filter=="all") $filter_method = "All";
// if($filter=="private") $filter_method = "Private Only";
// if($filter=="public") $filter_method = "Global Public Only";
// if($filter=="group") $filter_method = "Group Public Only";
// if($filter=="private+public") $filter_method = "Private and Global Public";
// if($filter=="private+group") $filter_method = "Private and Group Public";
// if($filter=="public+private") $filter_method = "Global Public and Group Public";
if (!isset($phpgw_info["flags"]["nocalendarheader"]) ||
!$phpgw_info["flags"]["nocalendarheader"]) {
?>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<table border="0" width="100%" cols="8" cellpadding="0" cellspacing="0">
<tr>
<td width="2%">
&nbsp;
@ -58,8 +67,9 @@
<img src="<?php echo $phpgw_info["server"]["app_images"]; ?>/view.gif" alt="<?php echo lang("Daily Matrix View"); ?>" border="0">
</a>
</td>
<td align="right">
<form action="<?php echo $phpgw->link("search.php"); ?>" method="POST">
<form action="<?php echo $phpgw->link(""); ?>" name="filtermethod" method="POST">
<td width="55%" align="center" valign="center">
<b><?php echo lang("Filter"); ?>:</b>
<input type="hidden" name="from" value="<?php echo $PHP_SELF; ?>">
<?php if(isset($date) && $date) { ?>
<input type="hidden" name="date" value="<?php echo $date; ?>">
@ -67,12 +77,39 @@
<input type="hidden" name="month" value="<?php echo $thismonth; ?>">
<input type="hidden" name="day" value="<?php echo $thisday; ?>">
<input type="hidden" name="year" value="<?php echo $thisyear; ?>">
<input name="keywords">
<?php if(isset($keywords) && $keywords) { ?>
<input type="hidden" name="keywords" value="<?php echo $keywords; ?>">
<?php } ?>
<select name="filter" onchange="document.filtermethod.submit()">
<option value="all"<?php if((!isset($filter) || !$filter) || $filter=="all") echo " selected"; ?>>All</option>
<option value="private"<?php if($filter=="private") echo " selected"; ?>>Private Only</option>
<option value="public"<?php if($filter=="public") echo " selected"; ?>>Global Public Only</option>
<option value="group"<?php if($filter=="group") echo " selected"; ?>>Group Public Only</option>
<option value="private+public"<?php if($filter=="private+public") echo " selected"; ?>>Private and Global Public</option>
<option value="private+group"<?php if($filter=="private+group") echo " selected"; ?>>Private and Group Public</option>
<option value="public+group"<?php if($filter=="public+group") echo " selected"; ?>>Global Public and Group Public</option>
</select>
</td>
</form>
<form action="<?php echo $phpgw->link("search.php"); ?>" method="POST">
<td align="right" valign="center">
<input type="hidden" name="from" value="<?php echo $PHP_SELF; ?>">
<?php if(isset($date) && $date) { ?>
<input type="hidden" name="date" value="<?php echo $date; ?>">
<?php } ?>
<input type="hidden" name="month" value="<?php echo $thismonth; ?>">
<input type="hidden" name="day" value="<?php echo $thisday; ?>">
<input type="hidden" name="year" value="<?php echo $thisyear; ?>">
<?php if(isset($filter) && $filter) { ?>
<input type="hidden" name="filter" value="<?php echo $filter; ?>">
<?php } ?>
<input name="keywords"<?php if($keywords) echo " value=\"".$keywords."\""; ?>>
<input type="submit" name="submit" value="<?php echo lang("Search"); ?>">
</form>
</td>
</td>
</form>
</tr>
</table>
<?php
flush();
}
?>

View File

@ -1,4 +1,3 @@
<?php php_track_vars?>
<?php
/**************************************************************************\
* phpGroupWare - Calendar *

View File

@ -19,11 +19,14 @@
$db2 = $phpgw->db;
$phpgw->db->query("SELECT cal_datetime, cal_mdatetime, cal_id FROM calendar_entry ORDER BY cal_id",__LINE__,__FILE__);
$phpgw->db->query("SELECT cal_datetime, cal_mdatetime, cal_id, cal_owner FROM calendar_entry ORDER BY cal_id",__LINE__,__FILE__);
if($phpgw->db->num_rows()) {
while($phpgw->db->next_record()) {
$datetime = $phpgw->db->f("cal_datetime") - ((60*60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]);
$mdatetime = $phpgw->db->f("cal_mdatetime") - ((60*60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]);
$db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$db->("cal_owner"),__LINE__,__FILE__);
$db2->next_record();
$tz = $db2->f("preference_value");
$datetime = $phpgw->db->f("cal_datetime") + ((60*60) * $tz);
$mdatetime = $phpgw->db->f("cal_mdatetime") + ((60*60) * $tz);
$db2->query("UPDATE calendar_entry SET cal_datetime=".$datetime.", cal_mdatetime=".$mdatetime." WHERE cal_id=".$phpgw->db->f("cal_id"),__LINE__,__FILE__);
}
}

View File

@ -17,7 +17,7 @@
$phpgw_info["flags"] = array("currentapp" => "calendar", "enable_calendar_class" => True, "enable_nextmatchs_class" => True);
if (! $keywords) {
// If we reach this it becuase they didn't search for anything,
// If we reach this, it is because they didn't search for anything,
// attempt to send them back to where they where.
Header("Location: " . $phpgw->link($from,"date=$datemonth=$month&day=$day&year=$year"));
}
@ -46,14 +46,33 @@
. "WHERE "
. "(UPPER(calendar_entry.cal_name) LIKE UPPER('%".$words[$i]."%') OR "
. " UPPER(calendar_entry.cal_description) LIKE UPPER('%".$words[$i]."%')) AND "
. "calendar_entry_user.cal_id=calendar_entry.cal_id AND "
. "(((calendar_entry_user.cal_login=".$phpgw_info["user"]["account_id"].") AND "
. "(calendar_entry.cal_access='private')) "
. $phpgw->calendar->group_search()
. "OR calendar_entry.cal_access='public') "
. "ORDER BY cal_datetime";
. "calendar_entry_user.cal_id=calendar_entry.cal_id AND ";
$phpgw->db->query($sql);
$sqlfilter = "";
// Private
if($phpgw->calendar->filter==" all " || strpos($phpgw->calendar->filter,"private")) {
$sqlfilter .= "(calendar_entry_user.cal_login = ".$phpgw_info["user"]["account_id"]." AND calendar_entry.cal_access='private') ";
}
// Group Public
if($phpgw->calendar->filter==" all " || strpos($phpgw->calendar->filter,"group")) {
if($sqlfilter)
$sqlfilter .= "OR ";
$sqlfilter .= $phpgw->calendar->group_search($phpgw_info["user"]["account_id"])." ";
}
// Global Public
if($phpgw->calendar->filter==" all " || strpos($phpgw->calendar->filter,"public")) {
if($sqlfilter)
$sqlfilter .= "OR ";
$sqlfilter .= "calendar_entry.cal_access='public' ";
}
$orderby = " ORDER BY calendar_entry.cal_datetime ASC";
if($sqlfilter) $sql .= "(".$sqlfilter.") ";
$sql .= $orderby;
$phpgw->db->query($sql,__LINE__,__FILE__);
while ($phpgw->db->next_record()) {
$matches++;
$ids[strval( $phpgw->db->f(0) )]++;

View File

@ -23,6 +23,20 @@ function validate_and_submit() {
document.addform.minute.focus();
return false;
}
h = parseInt(document.addform.end_hour.value);
m = parseInt(document.addform.end_minute.value);
if (h < 0 || h > 23) {
alert ("{time_error}");
document.addform.end_hour.select();
document.addform.end_hour.focus();
return false;
}
if (m < 0 || m > 59) {
alert ("{time_error}");
document.addform.end_minute.select();
document.addform.end_minute.focus();
return false;
}
// would be nice to also check date to not allow Feb 31, etc...
document.addform.submit();
// return true;

View File

@ -76,20 +76,21 @@
$thismonth = (int)$cal_info->month;
$thisday = (int)$cal_info->day;
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$format = "h:i:s a";
} else {
$format = "H:i:s";
}
if(intval($phpgw->common->show_date($cal_info->datetime,"H")) || intval($phpgw->common->show_date($cal_info->datetime,"i"))) {
$phpgw->template->set_var("field",lang("Time"));
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$format .= "h:i:s a";
} else {
$format .= "H:i:s";
}
$phpgw->template->set_var("data",$phpgw->common->show_date($cal_info->datetime,$format));
$phpgw->template->parse("output","list",True);
}
if ($cal_info->duration > 0) {
$phpgw->template->set_var("field",lang("Duration"));
$phpgw->template->set_var("data",$cal_info->duration." ".lang("minutes"));
if(($cal_info->datetime <> $cal_info->edatetime) && (intval($phpgw->common->show_date($cal_info->datetime,"Hi")) <> 0 && intval($phpgw->common->show_date($cal_info->edatetime,"Hi")) <> 2359)) {
$phpgw->template->set_var("field",lang("End Time"));
$phpgw->template->set_var("data",$phpgw->common->show_date($cal_info->edatetime,$format));
$phpgw->template->parse("output","list",True);
}

View File

@ -34,6 +34,8 @@
- Fix possible problem connecting to LDAP server.
- Fix home page display of calendar events.
- Added ability to set users defaut calendar view of top icon.
- Changed calednar duration to a true date/time.
- Added ability to filter calendar events based on access.
[0.9.6] - Fix user permissions where not being checked properly.

View File

@ -225,7 +225,8 @@
echo "<input type=\"submit\" name=\"action\" value=\"Dont touch my data\">\n";
echo "</form>\n";
echo '</td></tr>';
}elseif ($stage == 2.5) {
}
if ($stage == 2.5) {
echo '<tr><td align="center">O</td><td>';
echo "<table width=\"100%\">\n";
echo " <tr bgcolor=\"486591\"><td><font color=\"fefefe\">&nbsp;<b>$subtitle</b></font></td></tr>\n";

View File

@ -179,7 +179,7 @@
cal_group varchar(255),
cal_datetime int(11),
cal_mdatetime int(11),
cal_duration int(11) DEFAULT '0' NOT NULL,
cal_duration int(11),
cal_priority int(11) DEFAULT '2' NOT NULL,
cal_type varchar(10),
cal_access varchar(10),

View File

@ -686,6 +686,28 @@
update_version_table();
}
if ($currentver == "0.9.7pre2") {
$db2 = $db;
$sql = "ALTER TABLE calendar_entry CHANGE cal_duration cal_edatetime int(11)";
$db->query($sql,__LINE__,__FILE__);
$db->query("SELECT cal_id,cal_datetime,cal_owner,cal_edatetime,cal_mdatetime FROM calendar_entry ORDER BY cal_id",__LINE__,__FILE__);
if($db->num_rows()) {
while($db->next_record()) {
$db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$db->("cal_owner"),__LINE__,__FILE__);
$db2->next_record();
$tz = $db2->f("preference_value");
$cal_id = $db->f("cal_id");
$datetime = $db->f("cal_datetime") - ((60 * 60) * $tz);
$mdatetime = $db->f("cal_mdatetime") - ((60 * 60) * $tz);
$edatetime = $datetime + (60 * $db->f("cal_edatetime"));
$db2->query("UPDATE calendar_entry SET cal_datetime=".$datetime.", cal_edatetime=".$edatetime.", cal_mdatetime=".$mdatetime." WHERE cal_id=".$cal_id,__LINE__,__FILE__);
}
}
$currentver = "0.9.7pre3";
update_version_table();
}
if ($oldversion != $currentver){
echo " </tr><td>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";

View File

@ -157,7 +157,7 @@
cal_group varchar(255),
cal_datetime int4,
cal_mdatetime int4,
cal_duration int DEFAULT 0 NOT NULL,
cal_edatetime int4,
cal_priority int DEFAULT 2,
cal_type varchar(10),
cal_access varchar(10),
@ -265,4 +265,4 @@
$currentver = "0.9.7pre2";
$oldversion = $currentver;
update_version_table();
?>
?>

View File

@ -679,6 +679,54 @@
update_version_table();
}
if ($currentver == "0.9.7pre2") {
$db2 = $db;
$sql = "CREATE TABLE TEMP AS SELECT * FROM calendar_entry";
$db->query($sql,__LINE__,__FILE__);
$sql = "DROP TABLE calendar_entry";
$db->query($sql,__LINE__,__FILE__);
$sql = "CREATE TABLE calendar_entry (
cal_id serial,
cal_owner int DEFAULT 0 NOT NULL,
cal_group varchar(255) NULL,
cal_datetime int4,
cal_mdatetime int4,
cal_edatetime int4,
cal_priority int DEFAULT 2,
cal_type varchar(10),
cal_access varchar(10),
cal_name varchar(80) NOT NULL,
cal_description text)";
$db->query($sql,__LINE__,__FILE__);
$db->query("SELECT cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description FROM TEMP ORDER BY cal_id",__LINE__,__FILE__);
while($db->next_record()) {
$db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$db->f("cal_owner"),__LINE__,__FILE__);
$db2->next_record();
$tz = $db2->f("preference_value");
$cal_id = $db->f("cal_id");
$cal_owner = $db->f("cal_owner");
$cal_group = $db->f("cal_group");
$cal_datetime = $db->f("cal_datetime") - ((60 * 60) * $tz);
$cal_mdatetime = $db->f("cal_mdatetime") - ((60 * 60) * $tz);
$cal_edatetime = $cal_datetime + (60 * $db->f("cal_duration"));
$cal_priority = $db->f("cal_priority");
$cal_type = $db->f("cal_type");
$cal_access = $db->f("cal_access");
$cal_name = $db->f("cal_name");
$cal_description = $db->f("cal_description");
$db2->query("INSERT INTO calendar_entry(cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_edatetime,cal_priority,cal_type,cal_access,cal_name,cal_description) VALUES(".$cal_id.",".$cal_owner.",'".$cal_group."',".cal_datetime.",".$cal_mdatetime.",".$cal_edatetime.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')",__LINE__,__FILE__);
}
}
$sql = "DROP TABLE TEMP";
$db->query($sql,__LINE__,__FILE__);
$currentver = "0.9.7pre3";
update_version_table();
}
if ($oldversion != $currentver){
echo " </tr><td>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";

View File

@ -11,5 +11,5 @@
/* $Id$ */
$phpgw_info["server"]["version"] = "0.9.7pre2";
$phpgw_info["server"]["version"] = "0.9.7pre3";
$phpgw_info["server"]["current_header_version"] = "1.4";