egroupware_official/calendar/matrixselect.php

138 lines
5.3 KiB
PHP
Raw Normal View History

2000-11-24 13:57:45 +01:00
<?php
/**************************************************************************\
* phpGroupWare - Calendar *
* http://www.phpgroupware.org *
* Based on Webcalendar by Craig Knudsen <cknudsen@radix.net> *
* 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$ */
2000-12-26 21:13:34 +01:00
$phpgw_info["flags"] = array("currentapp" => "calendar", "enable_nextmatchs_class" => True, "parent_page" => "index.php");
2000-11-24 14:54:49 +01:00
2000-11-24 13:57:45 +01:00
include("../header.inc.php");
if(isset($friendly) && $friendly) {
if(!isset($phpgw_info["user"]["preferences"]["calendar"]["weekdaystarts"]))
$phpgw_info["user"]["preferences"]["calendar"]["weekdaystarts"] = "Sunday";
if (isset($date) && strlen($date) > 0) {
$thisyear = substr($date, 0, 4);
$thismonth = substr($date, 4, 2);
$thisday = substr($date, 6, 2);
} else {
if (!isset($day) || !$day)
$thisday = $phpgw->calendar->today["day"];
else
$thisday = $day;
if (!isset($month) || !$month)
$thismonth = $phpgw->calendar->today["month"];
else
$thismonth = $month;
if (!isset($year) || !$year)
$thisyear = $phpgw->calendar->today["year"];
else
$thisyear = $year;
}
}
$phpgw->template->set_file(array("matrix_query_begin" => "matrix_query.tpl",
"list" => "list.tpl",
"matrix_query_end" => "matrix_query.tpl",
"form_button" => "form_button_script.tpl"));
$phpgw->template->set_block("matrix_query_begin","list","matrix_query_end","form_button");
$phpgw->template->set_var("matrix_action",lang("Daily Matrix View"));
2000-11-26 04:19:48 +01:00
$phpgw->template->set_var("action_url",$phpgw->link("viewmatrix.php"));
2000-11-24 13:57:45 +01:00
$phpgw->template->parse("out","matrix_query_begin");
$phpgw->template->set_var("field",lang("Date"));
$day_html = "<select name=\"day\">";
2000-12-29 19:06:01 +01:00
for($i=1;$i<=31;$i++)
$day_html .= "<option value=\"$i\"".($i==$thisday?" selected":"").">$i</option>\n";
2000-11-24 13:57:45 +01:00
$day_html .= "</select>";
$month_html = "<select name=\"month\">";
2000-12-29 19:06:01 +01:00
for($i=1;$i<=12;$i++) {
2000-11-26 04:19:48 +01:00
$m = lang(date("F", mktime(0,0,0,$i,1,$thisyear)));
2000-12-29 19:06:01 +01:00
$month_html .= "<option value=\"$i\"".($i==$thismonth?" selected":"").">$m</option>\n";
2000-11-24 13:57:45 +01:00
}
$month_html .= "</select>";
$year_html = "<select name=\"year\">";
2000-12-29 19:06:01 +01:00
for($i=($thisyear - 1);$i<($thisyear + 5);$i++) {
$year_html .= "<option value=\"$i\"".($i==$thisyear?" selected":"").">$i</option>\n";
2000-11-24 13:57:45 +01:00
}
$year_html .= "</select>";
$phpgw->template->set_var("data",$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
$phpgw->template->parse("output","list",True);
2000-11-26 21:10:35 +01:00
// View type
2000-11-26 04:19:48 +01:00
$phpgw->template->set_var("field",lang("View"));
$str = "<select name=\"matrixtype\">";
$str .= "<option value=\"free/busy\" selected>".lang("free/busy")."</option>\n";
2000-11-26 04:19:48 +01:00
$str .= "<option value=\"weekly\">".lang("Weekly")."</option>\n";
$str .= "</select>\n";
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
2000-11-26 21:10:35 +01:00
// Participants
2000-11-24 13:57:45 +01:00
$phpgw->template->set_var("field",lang("Participants"));
$db2 = $phpgw->db;
$db2->query("select account_id,account_lastname,account_firstname "
. "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");
$num_rows = $db2->num_rows();
if ($num_rows > 50)
$size = 15;
elseif ($num_rows > 5)
$size = 5;
else
$size = $num_rows;
$str = "<select name=\"participants[]\" multiple size=\"$size\">";
while($db2->next_record()) {
$id = $db2->f("account_id");
$str .= "<option value=\"".$id."\">".$phpgw->common->grab_owner_name($id)."</option>\n";
}
$str .= "</select>";
$str .= "<input type=\"hidden\" name=\"participants[]\" value=\"".$phpgw_info["user"]["account_id"]."\">";
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
2000-11-26 21:10:35 +01:00
// Groups
$phpgw->template->set_var("field",lang("Groups"));
$str = "<select name=\"groups[]\" multiple size=\"5\">";
$user_groups = $phpgw->accounts->read_group_names();
for ($i=0;$i<count($user_groups);$i++) {
$str .= "<option value=\"" . $user_groups[$i][0] . "\">" . $user_groups[$i][1] . "</option>\n";
}
$str .= "</select>";
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
$phpgw->template->set_var("submit_button",lang("Submit"));
2000-11-24 13:57:45 +01:00
$phpgw->template->set_var("action_url_button","");
$phpgw->template->set_var("action_text_button",lang("Cancel"));
$phpgw->template->set_var("action_confirm_button","onClick=\"history.back(-1)\"");
$phpgw->template->parse("cancel_button","form_button");
$phpgw->template->pparse("out","matrix_query_end");
$phpgw->common->phpgw_footer();
?>