*
* http://www.radix.net/~cknudsen *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$phpgw_info["flags"] = array("currentapp" => "calendar", "enable_calendar_class" => True, "enable_nextmatchs_class" => True);
include("../header.inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_utilities_sbox.inc.php");
$sb = new sbox;
$cal_info = new calendar_item;
function display_item($field,$data) {
global $phpgw;
$phpgw->template->set_var("field",$field);
$phpgw->template->set_var("data",$data);
$phpgw->template->parse("output","list",True);
}
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$hourformat = "h";
} else {
$hourformat = "H";
}
if ($id > 0) {
$cal = $phpgw->calendar->getevent(intval($id));
$cal_info = $cal[0];
$can_edit = false;
if(($cal_info->owner == $phpgw_info["user"]["account_id"]) || $phpgw_info["user"]["apps"]["admin"])
$can_edit = true;
if(!$cal_info->rpt_end_use) {
$cal_info->rpt_end = $cal_info->datetime + 86400;
}
} else if(isset($readsess)) {
$cal_info = $phpgw->common->appsession();
if(!$cal_info->owner) $cal_info->owner = $phpgw_info["user"]["account_id"];
$can_edit = true;
} else {
$cal_info->id = 0;
$cal_info->owner = $phpgw_info["user"]["account_id"];
$can_edit = true;
if (!isset($day) || !$day)
$thisday = (int)$phpgw->calendar->today["day"];
else
$thisday = $day;
if (!isset($month) || !$month)
$thismonth = (int)$phpgw->calendar->today["month"];
else
$thismonth = $month;
if (!isset($year) || !$year)
$thisyear = (int)$phpgw->calendar->today["year"];
else
$thisyear = $year;
if (!isset($hour))
$thishour = 0;
else
$thishour = (int)$hour;
if (!isset($minute))
$thisminute = 00;
else
$thisminute = (int)$minute;
$cal_info->datetime = mktime($thishour,$thisminute,0,$thismonth,$thisday,$thisyear) - ((60 * 60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]);
$cal_info->edatetime = $cal_info->datetime;
$cal_info->name = "";
$cal_info->description = "";
$cal_info->priority = 2;
$cal_info->rpt_end = $cal_info->datetime + 86400;
}
$phpgw->template->set_file(array("edit_entry_begin" => "edit.tpl",
"list" => "list.tpl",
"edit_entry_end" => "edit.tpl",
"form_button" => "form_button_script.tpl"));
$phpgw->template->set_block("edit_entry_begin","list","edit_entry_end","form_button");
$phpgw->template->set_var("bg_color",$phpgw_info["theme"]["bg_text"]);
if($id)
$phpgw->template->set_var("calendar_action",lang("Calendar - Edit"));
else
$phpgw->template->set_var("calendar_action",lang("Calendar - Add"));
if($can_edit) {
$phpgw->template->set_var("action_url",$phpgw->link("edit_entry_handler.php"));
$common_hidden = "id."\">\n";
$phpgw->template->set_var("common_hidden",$common_hidden);
$phpgw->template->parse("out","edit_entry_begin");
// Brief Description
display_item(lang("Brief Description"),"name."\">");
// Full Description
display_item(lang("Full Description"),"");
// Date
$day_html = $sb->getDays("cal[day]",intval($phpgw->common->show_date($cal_info->datetime,"d")));
$month_html = $sb->getMonthText("cal[month]",intval($phpgw->common->show_date($cal_info->datetime,"n")));
$year_html = $sb->getYears("cal[year]",intval($phpgw->common->show_date($cal_info->datetime,"Y")),intval($phpgw->common->show_date($cal_info->datetime,"Y")));
display_item(lang("Start Date"),$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
// Time
$amsel = "checked"; $pmsel = "";
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
if ($cal_info->ampm == "pm") {
$amsel = ""; $pmsel = "checked";
} else {
$amsel = "checked"; $pmsel = "";
}
}
$str = "common->show_date($cal_info->datetime,$hourformat)."\" maxlength=\"2\">:common->show_date($cal_info->datetime,"i")."\" maxlength=\"2\">";
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$str .= "am";
$str .= "pm";
}
display_item(lang("Start Time"),$str);
// End Date
$day_html = $sb->getDays("cal[end_day]",intval($phpgw->common->show_date($cal_info->edatetime,"d")));
$month_html = $sb->getMonthText("cal[end_month]",intval($phpgw->common->show_date($cal_info->edatetime,"n")));
$year_html = $sb->getYears("cal[end_year]",intval($phpgw->common->show_date($cal_info->edatetime,"Y")),intval($phpgw->common->show_date($cal_info->edatetime,"Y")));
display_item(lang("End Date"),$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
// 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 = "common->show_date($cal_info->edatetime,$hourformat)."\" maxlength=\"2\">:common->show_date($cal_info->edatetime,"i")."\" maxlength=\"2\">";
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$str .= "am";
$str .= "pm";
}
display_item(lang("End Time"),$str);
// Priority
display_item(lang("Priority"),$sb->getPriority("cal[priority]",$cal_info->priority));
// Access
display_item(lang("Access"),$sb->getAccessList("cal[access]",$cal_info->access));
// Groups
$db2 = $phpgw->db;
$db2->query("SELECT account_lid FROM accounts WHERE account_id=".$cal_info->owner,__LINE__,__FILE__);
$db2->next_record();
$user_groups = $phpgw->accounts->read_group_names($db2->f("account_lid"));
display_item(lang("Groups"),$sb->getGroups($user_groups,$cal_info->groups,"cal[groups][]"));
// Participants
$db2 = $phpgw->db;
$db2->query("select account_id,account_lastname,account_firstname,account_lid "
. "from accounts where account_status !='L' and "
. "account_id != ".$phpgw_info["user"]["account_id"]." "
. "and account_permissions like '%:calendar:%' "
. "order by account_lastname,account_firstname,account_lid");
if ($db2->num_rows() > 50)
$size = 15;
else if ($db2->num_rows() > 5)
$size = 5;
else
$size = $db2->num_rows();
$str = "";
display_item(lang("Participants"),$str);
// I Participate
$participate = False;
if($id) {
for($i=0;$iparticipants);$i++) {
if($cal_info->participants[$i] == $phpgw_info["user"]["account_id"]) {
$participate = True;
}
}
}
$str = "";
$rpt_type_str = Array("none","daily","weekly","monthlybyday","monthlybydate","yearly");
$rpt_type_out = Array("none" => "None", "daily" => "Daily", "weekly" => "Weekly", "monthlybyday" => "Monthly (by day)", "monthlybydate" => "Monthly (by date)", "yearly" => "yearly");
for($l=0;$lrpt_type,$rpt_type_str[$l])) $str .= " selected";
$str .= ">".lang($rpt_type_out[$rpt_type_str[$l]])."";
}
$str .= "";
display_item(lang("Repeat Type"),$str);
$phpgw->template->set_var("field",lang("Repeat End Date"));
$str = "rpt_use_end) $str .= " checked";
$str .= ">".lang("Use End Date")." ";
$day_html = $sb->getDays("cal[rpt_day]",intval($phpgw->common->show_date($cal_info->rpt_end,"d")));
$month_html = $sb->getMonthText("cal[rpt_month]",intval($phpgw->common->show_date($cal_info->rpt_end,"n")));
$year_html = $sb->getYears("cal[rpt_year]",intval($phpgw->common->show_date($cal_info->rpt_end,"Y")),intval($phpgw->common->show_date($cal_info->rpt_end,"Y")));
$str .= $phpgw->common->dateformatorder($year_html,$month_html,$day_html);
display_item(lang("Repeat End Date"),$str);
$str = "rpt_sun?"checked":"")."> ".lang("Sunday")." ";
$str .= "rpt_mon?"checked":"")."> ".lang("Monday")." ";
$str .= "rpt_tue?"checked":"")."> ".lang("Tuesday")." ";
$str .= "rpt_wed?"checked":"")."> ".lang("Wednesday")." ";
$str .= "rpt_thu?"checked":"")."> ".lang("Thursday")." ";
$str .= "rpt_fri?"checked":"")."> ".lang("Friday")." ";
$str .= "rpt_sat?"checked":"")."> ".lang("Saturday")." ";
display_item(lang("Repeat Day")."
".lang("(for weekly)"),$str);
display_item(lang("Frequency"),"rpt_freq."\">");
$phpgw->template->set_var("submit_button",lang("Submit"));
if ($id > 0) {
$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 {
$phpgw->template->set_var("delete_button","");
$phpgw->template->pparse("out","edit_entry_end");
}
$phpgw->common->phpgw_footer();
}
?>