2000-08-18 05:24:22 +02: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 );
2000-08-18 05:24:22 +02:00
include ( " ../header.inc.php " );
2001-01-12 05:07:40 +01:00
$sb = CreateObject ( " phpgwapi.sbox " );
2000-08-18 05:24:22 +02:00
2001-01-13 22:15:11 +01:00
$cal_info = CreateObject ( 'calendar.calendar_item' );
2000-11-18 22:44:05 +01:00
2000-12-23 17:33:22 +01:00
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 );
}
2000-12-05 02:14:18 +01:00
if ( $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " timeformat " ] == " 12 " ) {
2000-12-06 03:51:41 +01:00
$hourformat = " h " ;
2000-12-05 02:14:18 +01:00
} else {
2000-12-06 03:51:41 +01:00
$hourformat = " H " ;
2000-12-05 02:14:18 +01:00
}
2000-11-18 22:44:05 +01:00
if ( $id > 0 ) {
2000-11-25 04:48:10 +01:00
$cal = $phpgw -> calendar -> getevent ( intval ( $id ));
2000-11-18 22:44:05 +01:00
$cal_info = $cal [ 0 ];
2000-08-18 05:24:22 +02:00
2000-11-23 02:37:50 +01:00
$can_edit = false ;
2000-12-06 03:51:41 +01:00
if (( $cal_info -> owner == $phpgw_info [ " user " ][ " account_id " ]) || $phpgw_info [ " user " ][ " apps " ][ " admin " ])
2000-11-23 02:37:50 +01:00
$can_edit = true ;
if ( ! $cal_info -> rpt_end_use ) {
2000-12-01 04:36:39 +01:00
$cal_info -> rpt_end = $cal_info -> datetime + 86400 ;
2000-11-23 02:37:50 +01:00
}
2000-11-24 23:51:43 +01:00
} else if ( isset ( $readsess )) {
$cal_info = $phpgw -> common -> appsession ();
2000-12-09 05:08:54 +01:00
if ( ! $cal_info -> owner ) $cal_info -> owner = $phpgw_info [ " user " ][ " account_id " ];
2000-11-24 23:51:43 +01:00
$can_edit = true ;
2000-11-18 22:44:05 +01:00
} else {
2000-12-09 05:08:54 +01:00
$cal_info -> id = 0 ;
2000-12-06 13:15:45 +01:00
$cal_info -> owner = $phpgw_info [ " user " ][ " account_id " ];
2000-11-23 02:37:50 +01:00
$can_edit = true ;
2000-11-18 22:44:05 +01:00
if ( ! isset ( $day ) || ! $day )
$thisday = ( int ) $phpgw -> calendar -> today [ " day " ];
2000-08-18 05:24:22 +02:00
else
2000-11-18 22:44:05 +01:00
$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 ;
2000-08-18 05:24:22 +02:00
2000-11-18 22:44:05 +01:00
if ( ! isset ( $hour ))
$thishour = 0 ;
else
$thishour = ( int ) $hour ;
if ( ! isset ( $minute ))
$thisminute = 00 ;
else
$thisminute = ( int ) $minute ;
2000-08-18 05:24:22 +02:00
2000-12-06 03:51:41 +01:00
$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 ;
2000-11-18 22:44:05 +01:00
$cal_info -> name = " " ;
$cal_info -> description = " " ;
2000-12-23 17:33:22 +01:00
$cal_info -> priority = 2 ;
2000-11-18 22:44:05 +01:00
2000-12-01 04:36:39 +01:00
$cal_info -> rpt_end = $cal_info -> datetime + 86400 ;
2000-08-18 05:24:22 +02:00
}
2000-11-23 02:37:50 +01:00
$phpgw -> template -> set_file ( array ( " edit_entry_begin " => " edit.tpl " ,
" list " => " list.tpl " ,
2000-12-26 14:59:24 +01:00
" hr " => " hr.tpl " ,
2000-11-23 02:37:50 +01:00
" edit_entry_end " => " edit.tpl " ,
" form_button " => " form_button_script.tpl " ));
2000-08-18 05:24:22 +02:00
2000-12-26 14:59:24 +01:00
$phpgw -> template -> set_block ( " edit_entry_begin " , " list " , " hr " , " edit_entry_end " , " form_button " );
2000-08-18 05:24:22 +02:00
2000-11-23 02:37:50 +01:00
$phpgw -> template -> set_var ( " bg_color " , $phpgw_info [ " theme " ][ " bg_text " ]);
if ( $id )
$phpgw -> template -> set_var ( " calendar_action " , lang ( " Calendar - Edit " ));
2000-08-18 05:24:22 +02:00
else
2000-11-23 02:37:50 +01:00
$phpgw -> template -> set_var ( " calendar_action " , lang ( " Calendar - Add " ));
2000-08-18 05:24:22 +02:00
2000-11-23 02:37:50 +01:00
if ( $can_edit ) {
$phpgw -> template -> set_var ( " action_url " , $phpgw -> link ( " edit_entry_handler.php " ));
2000-08-18 05:24:22 +02:00
2000-12-09 05:08:54 +01:00
$common_hidden = " <input type= \" hidden \" name= \" cal[id] \" value= \" " . $cal_info -> id . " \" > \n " ;
2000-08-18 05:24:22 +02:00
2000-11-23 02:37:50 +01:00
$phpgw -> template -> set_var ( " common_hidden " , $common_hidden );
2000-08-18 05:24:22 +02:00
2000-11-23 02:37:50 +01:00
$phpgw -> template -> parse ( " out " , " edit_entry_begin " );
2000-08-18 05:24:22 +02:00
2000-11-26 21:10:35 +01:00
// Brief Description
2000-12-23 17:33:22 +01:00
display_item ( lang ( " Brief Description " ), " <input name= \" cal[name] \" size= \" 25 \" value= \" " . $cal_info -> name . " \" > " );
2000-11-26 21:10:35 +01:00
// Full Description
2000-12-23 17:33:22 +01:00
display_item ( lang ( " Full Description " ), " <textarea name= \" cal[description] \" rows= \" 5 \" cols= \" 40 \" wrap= \" virtual \" > " . $cal_info -> description . " </textarea> " );
2000-08-18 05:24:22 +02:00
2000-11-26 21:10:35 +01:00
// Date
2000-12-23 17:33:22 +01:00
$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 ));
2000-08-18 05:24:22 +02:00
2000-11-26 21:10:35 +01:00
// Time
2000-11-23 02:37:50 +01:00
$amsel = " checked " ; $pmsel = " " ;
if ( $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " timeformat " ] == " 12 " ) {
if ( $cal_info -> ampm == " pm " ) {
$amsel = " " ; $pmsel = " checked " ;
} else {
$amsel = " checked " ; $pmsel = " " ;
}
}
2000-12-09 05:08:54 +01:00
$str = " <input name= \" cal[hour] \" size= \" 2 \" VALUE= \" " . $phpgw -> common -> show_date ( $cal_info -> datetime , $hourformat ) . " \" maxlength= \" 2 \" >:<input name= \" cal[minute] \" size= \" 2 \" value= \" " . $phpgw -> common -> show_date ( $cal_info -> datetime , " i " ) . " \" maxlength= \" 2 \" > " ;
2000-11-23 02:37:50 +01:00
if ( $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " timeformat " ] == " 12 " ) {
2000-12-09 05:08:54 +01:00
$str .= " <input type= \" radio \" name= \" cal[ampm] \" value= \" am \" $amsel >am " ;
$str .= " <input type= \" radio \" name= \" cal[ampm] \" value= \" pm \" $pmsel >pm " ;
2000-11-23 02:37:50 +01:00
}
2000-08-18 05:24:22 +02:00
2000-12-23 17:33:22 +01:00
display_item ( lang ( " Start Time " ), $str );
2000-12-04 02:11:53 +01:00
2000-12-23 17:33:22 +01:00
// End Date
2000-12-04 02:11:53 +01:00
2000-12-23 17:33:22 +01:00
$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 ));
2000-12-04 02:11:53 +01:00
// 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 = " " ;
}
}
2000-12-09 05:08:54 +01:00
$str = " <input name= \" cal[end_hour] \" size= \" 2 \" VALUE= \" " . $phpgw -> common -> show_date ( $cal_info -> edatetime , $hourformat ) . " \" maxlength= \" 2 \" >:<input name= \" cal[end_minute] \" size= \" 2 \" value= \" " . $phpgw -> common -> show_date ( $cal_info -> edatetime , " i " ) . " \" maxlength= \" 2 \" > " ;
2000-12-04 02:11:53 +01:00
if ( $phpgw_info [ " user " ][ " preferences " ][ " common " ][ " timeformat " ] == " 12 " ) {
2000-12-09 05:08:54 +01:00
$str .= " <input type= \" radio \" name= \" cal[end_ampm] \" value= \" am \" $amsel >am " ;
$str .= " <input type= \" radio \" name= \" cal[end_ampm] \" value= \" pm \" $pmsel >pm " ;
2000-12-04 02:11:53 +01:00
}
2000-12-23 17:33:22 +01:00
display_item ( lang ( " End Time " ), $str );
2000-11-23 02:37:50 +01:00
2000-11-26 21:10:35 +01:00
// Priority
2000-12-23 17:33:22 +01:00
display_item ( lang ( " Priority " ), $sb -> getPriority ( " cal[priority] " , $cal_info -> priority ));
2000-11-23 02:37:50 +01:00
2000-12-23 17:33:22 +01:00
// Access
display_item ( lang ( " Access " ), $sb -> getAccessList ( " cal[access] " , $cal_info -> access ));
2000-11-23 02:37:50 +01:00
2000-11-26 21:10:35 +01:00
// Groups
2000-12-06 05:34:55 +01:00
$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 " ));
2000-12-23 17:33:22 +01:00
display_item ( lang ( " Groups " ), $sb -> getGroups ( $user_groups , $cal_info -> groups , " cal[groups][] " ));
2000-11-23 02:37:50 +01:00
2000-11-26 19:03:20 +01:00
// Participants
2000-11-24 13:57:45 +01:00
$db2 = $phpgw -> db ;
$db2 -> query ( " select account_id,account_lastname,account_firstname,account_lid "
2000-11-23 02:37:50 +01:00
. " 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 " );
2000-11-24 13:57:45 +01:00
if ( $db2 -> num_rows () > 50 )
2000-11-23 02:37:50 +01:00
$size = 15 ;
2000-11-24 13:57:45 +01:00
else if ( $db2 -> num_rows () > 5 )
2000-11-23 02:37:50 +01:00
$size = 5 ;
else
2000-11-24 13:57:45 +01:00
$size = $db2 -> num_rows ();
2000-12-17 03:16:36 +01:00
$str = " <select name= \" cal[participants][] \" multiple size= \" 5 \" > " ;
2000-11-23 02:37:50 +01:00
for ( $l = 0 ; $l < count ( $cal_info -> participants ); $l ++ )
$parts [ $cal_info -> participants [ $l ]] = True ;
2000-11-24 13:57:45 +01:00
while ( $db2 -> next_record ()) {
$str .= " <option value= \" " . $db2 -> f ( " account_id " ) . " \" " ;
if ( $parts [ $db2 -> f ( " account_id " )])
2000-11-23 02:37:50 +01:00
$str .= " selected " ;
2000-11-24 13:57:45 +01:00
$str .= " > " . $phpgw -> common -> grab_owner_name ( $db2 -> f ( " account_id " )) . " </option> " ;
2000-11-23 02:37:50 +01:00
}
$str .= " </select> " ;
2000-12-23 17:33:22 +01:00
display_item ( lang ( " Participants " ), $str );
2000-11-23 02:37:50 +01:00
2000-11-26 19:03:20 +01:00
// I Participate
$participate = False ;
if ( $id ) {
for ( $i = 0 ; $i < count ( $cal_info -> participants ); $i ++ ) {
if ( $cal_info -> participants [ $i ] == $phpgw_info [ " user " ][ " account_id " ]) {
$participate = True ;
}
}
}
2000-12-09 05:08:54 +01:00
$str = " <input type= \" checkbox \" name= \" cal[participants][] \" value= \" " . $phpgw_info [ " user " ][ " account_id " ] . " \" " ;
2000-11-27 04:20:59 +01:00
if (( $id && $participate ) || ! $id ) {
2000-11-26 19:03:20 +01:00
$str .= " checked " ;
}
$str .= " > " ;
2000-12-23 17:33:22 +01:00
display_item ( lang ( " I Participate " ), $str );
2000-11-26 19:03:20 +01:00
// Repeat Type
2000-12-26 14:59:24 +01:00
$phpgw -> template -> parse ( " output " , " hr " , True );
display_item ( " <hr> " . lang ( " Repeating Event Information " ), " <hr> " );
2000-12-09 05:08:54 +01:00
$str = " <select name= \" cal[rpt_type] \" > " ;
2000-11-23 02:37:50 +01:00
$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 ; $l < count ( $rpt_type_str ); $l ++ ) {
$str .= " <option value= \" " . $rpt_type_str [ $l ] . " \" " ;
if ( ! strcmp ( $cal_info -> rpt_type , $rpt_type_str [ $l ])) $str .= " selected " ;
$str .= " > " . lang ( $rpt_type_out [ $rpt_type_str [ $l ]]) . " </option> " ;
}
$str .= " </select> " ;
2000-12-23 17:33:22 +01:00
display_item ( lang ( " Repeat Type " ), $str );
2000-11-23 02:37:50 +01:00
$phpgw -> template -> set_var ( " field " , lang ( " Repeat End Date " ));
2000-12-09 05:08:54 +01:00
$str = " <input type= \" checkbox \" name= \" cal[rpt_use_end] \" value= \" y \" " ;
2000-12-01 04:36:39 +01:00
if ( $cal_info -> rpt_use_end ) $str .= " checked " ;
2000-11-23 02:37:50 +01:00
$str .= " > " . lang ( " Use End Date " ) . " " ;
2000-12-23 17:33:22 +01:00
$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 " )));
2000-11-23 02:37:50 +01:00
$str .= $phpgw -> common -> dateformatorder ( $year_html , $month_html , $day_html );
2000-12-23 17:33:22 +01:00
display_item ( lang ( " Repeat End Date " ), $str );
2000-12-09 05:08:54 +01:00
$str = " <input type= \" checkbox \" name= \" cal[rpt_sun] \" value= \" 1 \" " . ( $cal_info -> rpt_sun ? " checked " : " " ) . " > " . lang ( " Sunday " ) . " " ;
$str .= " <input type= \" checkbox \" name= \" cal[rpt_mon] \" value= \" 1 \" " . ( $cal_info -> rpt_mon ? " checked " : " " ) . " > " . lang ( " Monday " ) . " " ;
$str .= " <input type= \" checkbox \" name= \" cal[rpt_tue] \" value= \" 1 \" " . ( $cal_info -> rpt_tue ? " checked " : " " ) . " > " . lang ( " Tuesday " ) . " " ;
$str .= " <input type= \" checkbox \" name= \" cal[rpt_wed] \" value= \" 1 \" " . ( $cal_info -> rpt_wed ? " checked " : " " ) . " > " . lang ( " Wednesday " ) . " " ;
$str .= " <input type= \" checkbox \" name= \" cal[rpt_thu] \" value= \" 1 \" " . ( $cal_info -> rpt_thu ? " checked " : " " ) . " > " . lang ( " Thursday " ) . " " ;
$str .= " <input type= \" checkbox \" name= \" cal[rpt_fri] \" value= \" 1 \" " . ( $cal_info -> rpt_fri ? " checked " : " " ) . " > " . lang ( " Friday " ) . " " ;
$str .= " <input type= \" checkbox \" name= \" cal[rpt_sat] \" value= \" 1 \" " . ( $cal_info -> rpt_sat ? " checked " : " " ) . " > " . lang ( " Saturday " ) . " " ;
2000-11-23 02:37:50 +01:00
2000-12-23 17:33:22 +01:00
display_item ( lang ( " Repeat Day " ) . " <br> " . lang ( " (for weekly) " ), $str );
display_item ( lang ( " Frequency " ), " <input name= \" cal[rpt_freq] \" size= \" 4 \" maxlength= \" 4 \" value= \" " . $cal_info -> rpt_freq . " \" > " );
2000-11-23 02:37:50 +01:00
$phpgw -> template -> set_var ( " submit_button " , lang ( " Submit " ));
if ( $id > 0 ) {
2000-11-23 14:28:37 +01:00
$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. " ) . " ') \" " );
2000-11-23 02:37:50 +01:00
$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 " );
}
2000-09-29 07:24:18 +02:00
$phpgw -> common -> phpgw_footer ();
2000-11-23 02:37:50 +01:00
}
2000-08-18 05:24:22 +02:00
?>