fix for buttons

This commit is contained in:
skeeter 2000-11-23 13:28:37 +00:00
parent 00fdbec533
commit 51869a8ebf
5 changed files with 212 additions and 233 deletions

View File

@ -99,11 +99,7 @@
if($can_edit) {
$phpgw->template->set_var("action_url",$phpgw->link("edit_entry_handler.php"));
if($id) {
$common_hidden = "<input type=\"hidden\" name=\"id\" value=\"$id\">\n";
} else {
$common_hidden = "";
}
$common_hidden = "<input type=\"hidden\" name=\"id\" value=\"".$id."\">\n";
$phpgw->template->set_var("common_hidden",$common_hidden);
@ -295,8 +291,9 @@
$phpgw->template->set_var("submit_button",lang("Submit"));
if ($id > 0) {
$phpgw->template->set_var("action_url",$phpgw->link("delete.php","id=$id"));
$phpgw->template->set_var("action_text",lang("Delete"));
$phpgw->template->set_var("action_url_button",$phpgw->link("delete.php","id=$id"));
$phpgw->template->set_var("action_text_button",lang("Delete"));
$phpgw->template->set_var("action_confirm_button","onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\"");
$phpgw->template->parse("delete_button","form_button");
$phpgw->template->pparse("out","edit_entry_end");
} else {

View File

@ -1,4 +1,3 @@
<?php php_track_vars?>
<?php
/**************************************************************************\
* phpGroupWare - Calendar *
@ -14,220 +13,208 @@
/* $Id$ */
$phpgw_info["flags"]["noheader"]="True";
$phpgw_info["flags"] = array("currentapp" => "calendar", "noheader" => True, "nonavbar" => True, "enable_calendar_class" => True, "enable_nextmatchs_class" => True);
include("../header.inc.php");
if($REQUEST_METHOD <> "POST") {
}
$cal_info = new calendar_item;
for(reset($HTTP_POST_VARS);$key=key($HTTP_POST_VARS);next($HTTP_POST_VARS)) {
$data = $HTTP_POST_VARS[$key];
$cal_info->set($key,$data);
}
$phpgw->calendar->add($cal_info,$cal_info->id);
// Input time format "2359"
function add_duration($time, $duration)
{
$hour = (int)($time / 10000);
$min = $time % 100;
$minutes = $hour * 60 + $min + $duration;
$h = $minutes / 60;
$m = $minutes % 60;
$ret = sprintf ("%d%02d",$h,$m);
//echo "add_duration ( $time, $duration ) = $ret <BR>";
return $ret;
}
// function add_duration($time, $duration)
// {
// $hour = (int)($time / 10000);
// $min = $time % 100;
// $minutes = $hour * 60 + $min + $duration;
// $h = $minutes / 60;
// $m = $minutes % 60;
// $ret = sprintf ("%d%02d",$h,$m);
// //echo "add_duration ( $time, $duration ) = $ret <BR>";
// return $ret;
// }
// check to see if two events overlap
function times_overlap($time1, $duration1, $time2, $duration2)
{
//echo "times_overlap ( $time1, $duration1, $time2, $duration2 )<BR>";
$hour1 = (int) ($time1 / 100);
$min1 = $time1 % 100;
$hour2 = (int) ($time2 / 100);
$min2 = $time2 % 100;
// convert to minutes since midnight
$tmins1start = $hour1 * 60 + $min1;
$tmins1end = $tmins1start + $duration1;
$tmins2start = $hour2 * 60 + $min2;
$tmins2end = $tmins2start + $duration2;
//echo "tmins1start=$tmins1start, tmins1end=$tmins1end, tmins2start="
// . "$tmins2start, tmins2end=$tmins2end<BR>";
if ($tmins1start >= $tmins2start && $tmins1start <= $tmins2end)
return true;
if ($tmins1end >= $tmins2start && $tmins1end <= $tmins2end)
return true;
if ($tmins2start >= $tmins1start && $tmins2start <= $tmins1end)
return true;
if ($tmins2end >= $tmins1start && $tmins2end <= $tmins1end)
return true;
return false;
}
$phpgw->db->lock(array('webcal_entry','webcal_entry_user','webcal_entry_groups',
'webcal_entry_repeats'));
// first check for any schedule conflicts
if (strlen($hour) > 0) {
$date = mktime(0,0,0,$month,$day,$year);
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$hour %= 12;
if ($ampm == "pm")
$hour += 12;
}
$sql = "SELECT webcal_entry_user.cal_login, webcal_entry.cal_time," .
"webcal_entry.cal_duration, webcal_entry.cal_name, " .
"webcal_entry.cal_id, webcal_entry.cal_access " .
"FROM webcal_entry, webcal_entry_user " .
"WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " .
"AND webcal_entry.cal_date = " . date("Ymd", $date) . " AND ( ";
for ($i = 0; $i < count($participants); $i++) {
if ($i) $sql .= " OR ";
$sql .= " webcal_entry_user.cal_login = '" . $participants[$i] . "'";
}
$sql .= " )";
$phpgw->db->query($sql);
$time1 = sprintf("%d:%02d", $hour, $minute);
$duration1 = sprintf("%d", $duration);
while ($phpgw->db->next_record()) {
// see if either event overlaps one another
if ($phpgw->db->f(4) != $id) {
$time2 = $phpgw->db->f(1);
$duration2 = $phpgw->db->f(2);
if (times_overlap($time1, $duration1, $time2, $duration2)) {
$overlap .= "<LI>";
if ($phpgw->db->f(5) == 'R' && $phpgw->db->f(0) != $login)
$overlap .= "(PRIVATE)";
else {
$overlap .= "<A HREF=\"".$phpgw->link("view.php",
"id=".$phpgw->db->f(4))."\">"
. $phpgw->db->f(3) . "</A>";
}
$overlap .= " (" . display_time($time2);
if ($duration2 > 0)
$overlap .= "-" . display_time(add_duration($time2,$duration2))
. ")";
}
}
}
}
if ($overlap)
$error = lang("The following conflicts with the suggested time:<ul>x</ul>",
$overlap);
if (! $error) {
// now add the entries
if ($id != 0) {
$phpgw->db->query("DELETE FROM webcal_entry WHERE cal_id = $id");
$phpgw->db->query("DELETE FROM webcal_entry_user WHERE cal_id = $id");
$phpgw->db->query("DELETE FROM webcal_entry_repeats WHERE cal_id = $id");
$phpgw->db->query("DELETE FROM webcal_entry_groups WHERE cal_id = $id");
}
$sql = "INSERT INTO webcal_entry (cal_owner, cal_date, " .
"cal_time, cal_mod_date, cal_mod_time, cal_duration, cal_priority, " .
"cal_access, cal_type, cal_name, cal_description ) " .
"VALUES ('" . $phpgw_info["user"]["account_id"] . "', ";
$date = mktime(0,0,0,$month,$day,$year);
$sql .= date("Ymd", $date) . ", ";
if (strlen($hour) > 0) {
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$hour %= 12;
if ($ampm == "pm")
$hour += 12;
}
$sql .= sprintf("%02d%02d00, ",$hour,$minute);
} else
$sql .= "'-1', ";
$sql .= date("Ymd") . ", " . date("Gis") . ", ";
$sql .= sprintf("%d, ",$duration);
$sql .= sprintf("%d, ",$priority);
$sql .= "'$access', ";
if ($rpt_type != 'none')
$sql .= "'M', ";
else
$sql .= "'E', ";
if (strlen($name) == 0)
$name = "Unnamed Event";
$sql .= "'" . addslashes($name) . "', ";
if (! $description)
$sql .= "'" . addslashes($name) . "')";
else
$sql .= "'" . addslashes($description) . "' )";
$error = "";
$phpgw->db->query($sql);
$phpgw->db->query("SELECT MAX(cal_id) FROM webcal_entry");
$phpgw->db->next_record();
$id = $phpgw->db->f(0);
while ($participant = each($participants)) {
$phpgw->db->query("INSERT INTO webcal_entry_user (cal_id,cal_login,cal_status ) "
. "VALUES ($id, '" . $participant[1] . "', 'A')");
}
if (strlen($rpt_type) || ! strcmp($rpt_type,'none') == 0) {
// clearly, we want to delete the old repeats, before inserting new...
$phpgw->db->query("delete from webcal_entry_repeats where cal_id='$id'");
$freq = ($rpt_freq?$rpt_freq:1);
if ($rpt_end_use) {
$end = "'" . date("Ymd",mktime(0,0,0,$rpt_month,$rpt_day,$rpt_year))
. "'";
} else
$end = 0;
if ($rpt_type == 'weekly') {
$days = ($rpt_sun?'y':'n')
. ($rpt_mon?'y':'n')
. ($rpt_tue?'y':'n')
. ($rpt_wed?'y':'n')
. ($rpt_thu?'y':'n')
. ($rpt_fri?'y':'n')
. ($rpt_sat?'y':'n');
} else {
$days = "nnnnnnn";
}
$phpgw->db->query("insert into webcal_entry_repeats (cal_id,cal_type,"
. "cal_end,cal_days,cal_frequency) values($id,'$rpt_type',"
. "$end,'$days',$freq)");
}
$phpgw->db->query("insert into webcal_entry_groups values ($id,'"
. $phpgw->accounts->array_to_string($access,$n_groups) . "') ");
// // check to see if two events overlap
// function times_overlap($time1, $duration1, $time2, $duration2)
// {
// //echo "times_overlap ( $time1, $duration1, $time2, $duration2 )<BR>";
// $hour1 = (int) ($time1 / 100);
// $min1 = $time1 % 100;
// $hour2 = (int) ($time2 / 100);
// $min2 = $time2 % 100;
// // convert to minutes since midnight
// $tmins1start = $hour1 * 60 + $min1;
// $tmins1end = $tmins1start + $duration1;
// $tmins2start = $hour2 * 60 + $min2;
// $tmins2end = $tmins2start + $duration2;
// //echo "tmins1start=$tmins1start, tmins1end=$tmins1end, tmins2start="
// // . "$tmins2start, tmins2end=$tmins2end<BR>";
//
// if ($tmins1start >= $tmins2start && $tmins1start <= $tmins2end)
// return true;
// if ($tmins1end >= $tmins2start && $tmins1end <= $tmins2end)
// return true;
// if ($tmins2start >= $tmins1start && $tmins2start <= $tmins1end)
// return true;
// if ($tmins2end >= $tmins1start && $tmins2end <= $tmins1end)
// return true;
// return false;
// }
//
// $phpgw->db->lock(array('webcal_entry','webcal_entry_user','webcal_entry_groups',
// 'webcal_entry_repeats'));
//
// // first check for any schedule conflicts
// if (strlen($hour) > 0) {
// $date = mktime(0,0,0,$month,$day,$year);
// if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
// $hour %= 12;
// if ($ampm == "pm")
// $hour += 12;
// }
//
// $sql = "SELECT webcal_entry_user.cal_login, webcal_entry.cal_time," .
// "webcal_entry.cal_duration, webcal_entry.cal_name, " .
// "webcal_entry.cal_id, webcal_entry.cal_access " .
// "FROM webcal_entry, webcal_entry_user " .
// "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " .
// "AND webcal_entry.cal_date = " . date("Ymd", $date) . " AND ( ";
//
// for ($i = 0; $i < count($participants); $i++) {
// if ($i) $sql .= " OR ";
// $sql .= " webcal_entry_user.cal_login = '" . $participants[$i] . "'";
// }
// $sql .= " )";
//
// $phpgw->db->query($sql);
// $time1 = sprintf("%d:%02d", $hour, $minute);
// $duration1 = sprintf("%d", $duration);
//
// while ($phpgw->db->next_record()) {
// // see if either event overlaps one another
// if ($phpgw->db->f(4) != $id) {
// $time2 = $phpgw->db->f(1);
// $duration2 = $phpgw->db->f(2);
// if (times_overlap($time1, $duration1, $time2, $duration2)) {
// $overlap .= "<LI>";
// if ($phpgw->db->f(5) == 'R' && $phpgw->db->f(0) != $login)
// $overlap .= "(PRIVATE)";
// else {
// $overlap .= "<A HREF=\"".$phpgw->link("view.php",
// "id=".$phpgw->db->f(4))."\">"
// . $phpgw->db->f(3) . "</A>";
// }
// $overlap .= " (" . display_time($time2);
// if ($duration2 > 0)
// $overlap .= "-" . display_time(add_duration($time2,$duration2))
// . ")";
// }
// }
// }
// }
//
//if ($overlap)
// $error = lang("The following conflicts with the suggested time:<ul>x</ul>",
// $overlap);
//
//if (! $error) {
// // now add the entries
//
// if ($id != 0) {
// $phpgw->db->query("DELETE FROM webcal_entry WHERE cal_id = $id");
// $phpgw->db->query("DELETE FROM webcal_entry_user WHERE cal_id = $id");
// $phpgw->db->query("DELETE FROM webcal_entry_repeats WHERE cal_id = $id");
// $phpgw->db->query("DELETE FROM webcal_entry_groups WHERE cal_id = $id");
// }
//
// $sql = "INSERT INTO webcal_entry (cal_owner, cal_date, " .
// "cal_time, cal_mod_date, cal_mod_time, cal_duration, cal_priority, " .
// "cal_access, cal_type, cal_name, cal_description ) " .
// "VALUES ('" . $phpgw_info["user"]["account_id"] . "', ";
//
// $date = mktime(0,0,0,$month,$day,$year);
// $sql .= date("Ymd", $date) . ", ";
// if (strlen($hour) > 0) {
// if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
// $hour %= 12;
// if ($ampm == "pm")
// $hour += 12;
// }
// $sql .= sprintf("%02d%02d00, ",$hour,$minute);
// } else
// $sql .= "'-1', ";
//
// $sql .= date("Ymd") . ", " . date("Gis") . ", ";
// $sql .= sprintf("%d, ",$duration);
// $sql .= sprintf("%d, ",$priority);
// $sql .= "'$access', ";
//
// if ($rpt_type != 'none')
// $sql .= "'M', ";
// else
// $sql .= "'E', ";
//
// if (strlen($name) == 0)
// $name = "Unnamed Event";
//
// $sql .= "'" . addslashes($name) . "', ";
// if (! $description)
// $sql .= "'" . addslashes($name) . "')";
// else
// $sql .= "'" . addslashes($description) . "' )";
//
// $error = "";
// $phpgw->db->query($sql);
//
// $phpgw->db->query("SELECT MAX(cal_id) FROM webcal_entry");
// $phpgw->db->next_record();
// $id = $phpgw->db->f(0);
//
// while ($participant = each($participants)) {
// $phpgw->db->query("INSERT INTO webcal_entry_user (cal_id,cal_login,cal_status ) "
// . "VALUES ($id, '" . $participant[1] . "', 'A')");
// }
//
// if (strlen($rpt_type) || ! strcmp($rpt_type,'none') == 0) {
// // clearly, we want to delete the old repeats, before inserting new...
// $phpgw->db->query("delete from webcal_entry_repeats where cal_id='$id'");
// $freq = ($rpt_freq?$rpt_freq:1);
//
// if ($rpt_end_use) {
// $end = "'" . date("Ymd",mktime(0,0,0,$rpt_month,$rpt_day,$rpt_year))
// . "'";
// } else
// $end = 0;
//
// if ($rpt_type == 'weekly') {
// $days = ($rpt_sun?'y':'n')
// . ($rpt_mon?'y':'n')
// . ($rpt_tue?'y':'n')
// . ($rpt_wed?'y':'n')
// . ($rpt_thu?'y':'n')
// . ($rpt_fri?'y':'n')
// . ($rpt_sat?'y':'n');
// } else {
// $days = "nnnnnnn";
// }
//
// $phpgw->db->query("insert into webcal_entry_repeats (cal_id,cal_type,"
// . "cal_end,cal_days,cal_frequency) values($id,'$rpt_type',"
// . "$end,'$days',$freq)");
// }
// $phpgw->db->query("insert into webcal_entry_groups values ($id,'"
// . $phpgw->accounts->array_to_string($access,$n_groups) . "') ");
//
//
Header("Location: ".$phpgw->link("index.php","year=$year&month=$month&cd=14"));
}
$phpgw->common->phpgw_header();
$phpgw->common->phpgw_footer();
?>
<?php if (strlen($overlap)) { ?>
<H2><FONT COLOR="<?php echo $H2COLOR;?>">Scheduling Conflict</H2></FONT>
<?php
$time = sprintf("%d:%02d",$hour,$minute);
echo lang("Your suggested time of <B> x - x </B> conflicts with the following existing calendar entries:", display_time($time),display_time(add_duration($time,$duration))); ?>
?>
<UL>
<?php echo $overlap; ?>
</UL>
<?php } else { ?>
<H2><FONT COLOR="<?php echo $H2COLOR;?>">Error</H2></FONT>
<BLOCKQUOTE>
<?php echo $error; ?>
</BLOCKQUOTE>
<?php
}
$phpgw->db->unlock();
$phpgw->common->phpgw_footer();
?>

View File

@ -32,13 +32,8 @@ function validate_and_submit() {
<!-- BEGIN edit_entry_end -->
</table>
<script language="JavaScript">
document.writeln ('<INPUT TYPE="button" VALUE="{submit_button}" ONCLICK="validate_and_submit()">');
</script>
<noscript>
<input type="submit" value="{submit_button}">
</noscript>
<input type="hidden" name="participant_list" value="">
<!-- <input type="hidden" name="participant_list" value=""> -->
<input type="submit" value="{submit_button}" onClick="validate_and_submit()">
</form>
{delete_button}

View File

@ -1,6 +1,6 @@
<!-- $Id$ -->
<!-- BEGIN form_button -->
<form action="{action_url}" method="post" name="{action_text}form">
<input type="submit" value="{action_text}" {action_confirm}>
<form action="{action_url_button}" method="post" name="{action_text_button}form">
<input type="submit" value="{action_text_button}" {action_confirm_button}>
</form>
<!-- END form_button -->

View File

@ -53,7 +53,7 @@
$phpgw->template->set_block("view_begin","list","view_end","form_button");
$phpgw->template->set_var("bg_color",$phpgw_info["theme"]["bg_text"]);
$phpgw->template->set_var("bg_text",$phpgw_info["theme"]["bg_text"]);
$phpgw->template->set_var("name",$cal_info->name);
$phpgw->template->parse("out","view_begin");
@ -156,14 +156,14 @@
}
if ($is_my_event) {
$phpgw->template->set_var("action_url",$phpgw->link("edit_entry.php","id=$id"));
$phpgw->template->set_var("action_text"," ".lang("Edit")." ");
$phpgw->template->set_var("action_confirm","");
$phpgw->template->set_var("action_url_button",$phpgw->link("edit_entry.php","id=$id"));
$phpgw->template->set_var("action_text_button"," ".lang("Edit")." ");
$phpgw->template->set_var("action_confirm_button","");
$phpgw->template->parse("edit_button","form_button");
$phpgw->template->set_var("action_url",$phpgw->link("delete.php","id=$id"));
$phpgw->template->set_var("action_text",lang("Delete"));
$phpgw->template->set_var("action_confirm","onClick=\"confirm(".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."\")");
$phpgw->template->set_var("action_url_button",$phpgw->link("delete.php","id=$id"));
$phpgw->template->set_var("action_text_button",lang("Delete"));
$phpgw->template->set_var("action_confirm_button","onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\"");
$phpgw->template->parse("delete_button","form_button");
// $phpgw->template->set_var("edit","<a href=\"".$phpgw->link("edit_entry.php","id=$id")."\">".lang("Edit")."</a>");