diff --git a/calendar/edit_entry.php b/calendar/edit_entry.php index bf701031a0..a197cb4924 100755 --- a/calendar/edit_entry.php +++ b/calendar/edit_entry.php @@ -34,6 +34,9 @@ $cal_info->rpt_month = $rpt_date["month"]; $cal_info->rpt_day = $rpt_date["day"]; } + } else if(isset($readsess)) { + $cal_info = $phpgw->common->appsession(); + $can_edit = true; } else { $can_edit = true; @@ -99,7 +102,7 @@ if($can_edit) { $phpgw->template->set_var("action_url",$phpgw->link("edit_entry_handler.php")); - $common_hidden = "\n"; + $common_hidden = "id."\">\n"; $phpgw->template->set_var("common_hidden",$common_hidden); diff --git a/calendar/edit_entry_handler.php b/calendar/edit_entry_handler.php index 3320203fac..01cf844085 100755 --- a/calendar/edit_entry_handler.php +++ b/calendar/edit_entry_handler.php @@ -16,205 +16,68 @@ $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); + if(!isset($readsess)) { + 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->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); + } else { + $cal_info = $phpgw->common->appsession(); } + if(count($overlapping_events)) { + $phpgw->common->phpgw_header(); + $phpgw->common->navbar(); + $phpgw->template->set_file(array("overlap" => "overlap.tpl", + "form_button" => "form_button_script.tpl")); - $phpgw->calendar->add($cal_info,$cal_info->id); + $phpgw->template->set_block("overlap","form_button"); - // 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
"; -// return $ret; -// } + $phpgw->template->set_var("color",$phpgw_info["theme"]["bg_text"]); -// // check to see if two events overlap -// function times_overlap($time1, $duration1, $time2, $duration2) -// { -// //echo "times_overlap ( $time1, $duration1, $time2, $duration2 )
"; -// $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
"; -// -// 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 .= "
  • "; -// if ($phpgw->db->f(5) == 'R' && $phpgw->db->f(0) != $login) -// $overlap .= "(PRIVATE)"; -// else { -// $overlap .= "link("view.php", -// "id=".$phpgw->db->f(4))."\">" -// . $phpgw->db->f(3) . ""; -// } -// $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:", -// $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")); + $time = $phpgw->calendar->fixtime($cal_info->hour,$cal_info->minute,$cal_info->ampm); + $calendar_overlaps = $phpgw->calendar->getevent($overlapping_events); -$phpgw->common->phpgw_footer(); + $overlap = ""; + for($i=0;$iaccess) == "PRIVATE") + $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.")
    "; + } + } + if(strlen($overlap)) { + $phpgw->template->set_var("overlap_text",lang("Your suggested time of x - x conflicts with the following existing calendar entries:",$phpgw->calendar->build_time_for_display($time),$phpgw->calendar->build_time_for_display($phpgw->calendar->addduration($cal_info->hour,$cal_info->minute,$cal_info->ampm,$cal_info->duration)))); + $phpgw->template->set_var("overlap_list",$overlap); + } else { + $phpgw->template->set_var("overlap_text",""); + $phpgw->template->set_var("overlap_list",""); + } + + $phpgw->template->set_var("action_url_button",$phpgw->link("","readsess=".$cal_info->id)); + $phpgw->template->set_var("action_text_button",lang("Ignore Conflict")); + $phpgw->template->set_var("action_confirm_button",""); + $phpgw->template->parse("resubmit_button","form_button"); + + $phpgw->template->set_var("action_url_button",$phpgw->link("edit_entry.php","readsess=".$cal_info->id)); + $phpgw->template->set_var("action_text_button",lang("Re-Edit New Event")); + $phpgw->template->set_var("action_confirm_button",""); + $phpgw->template->parse("reedit_button","form_button"); + + $phpgw->template->pparse("out","overlap"); + } else { + $phpgw->calendar->add($cal_info,$cal_info->id); + Header("Location: ".$phpgw->link("index.php","year=$year&month=$month&cd=14")); + } + $phpgw->common->phpgw_footer(); ?> diff --git a/calendar/templates/default/overlap.tpl b/calendar/templates/default/overlap.tpl new file mode 100755 index 0000000000..a1e8563cc3 --- /dev/null +++ b/calendar/templates/default/overlap.tpl @@ -0,0 +1,14 @@ + + +
    +

    + Scheduling Conflict +

    + + + +
    {overlap_text}
      {overlap_list}
    + {resubmit_button} + {reedit_button} +
    + diff --git a/calendar/view.php b/calendar/view.php index c5e2b36b42..2b8fc7a3f4 100755 --- a/calendar/view.php +++ b/calendar/view.php @@ -165,9 +165,6 @@ $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","link("edit_entry.php","id=$id")."\">".lang("Edit").""); -// $phpgw->template->set_var("delete","link("delete.php","id=$id")."\" onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."');\">".lang("Delete").""); } else { $phpgw->template->set_var("edit_button",""); $phpgw->template->set_var("delete_button","");