OK, I think I've been able to modify both the DAY VIEW in the default.html template, and some code in the grid_add_non_recurring.html template in the Grid_Add_Event plugin, to make the one-click form show a default start time for an event.
What I was hoping to do, and think maybe I have, is to be able to click on a time in the DAY VIEW, and have the one-click add form display the selected date, and the selected hour, as defaults.
The Grid Add Event plugin sets the day as default already. But I modified the suggested html code to be added to the top of the DAY VIEW area on default.html from this:
<!-- Grid Add Event Plug-in -->
<%if ($User->hasPermission($CALENDAR_KEY,"ADD_EVENT")) { %>
<center><b><a href="<%=$ADMIN_CGI_URL%>?calendar=<%=$CALENDAR_KEY%>&username=<%=$User->{username}%>&template=grid_add_non_recurring.html&add_date=<%= $DAY->{datestring} %>" title="Click to add an event on this date">Add an Event</a></b></center><BR>
<%}%>
to this, linking the hour that is already displayed on the page:
<%if ($User->hasPermission($CALENDAR_KEY,"ADD_EVENT")) { %>
<a href="<%=$ADMIN_CGI_URL%>?calendar=<%=$CALENDAR_KEY%>&username=<%=$User->{username}%>&template=grid_add_non_recurring.html&add_date=<%= $DAY->{datestring} %>&start_hour=<%=$HOUR%>" title="Click to add an event on this date at this time">
<%=Date::formatTime(&Date::LZ($HOUR)."00",$Config->{'time_format'})%>
</a>
<%}%>
so that "start_hour" is passing the value of the hour ($HOUR already created by the template) to the plugin, and"<%=Date::formatTime(&Date::LZ($HOUR)."00",$Config->{'time_format'})%> " is code that is already on the template, displaying the hour.
Then, in the grid_add_non_recurring.html template, I looked at this code from the top part of the page, just below where it says "else { # Coming from Add/Edit screen":
($_start_hh,$_start_mm) = ($schedule->{'start_time'} =~ /(\d\d)(\d\d)/);
($_end_hh,$_end_mm) = ($schedule->{'end_time'} =~ /(\d\d)(\d\d)/);
if ($time_format eq "12") {
if ($_start_hh eq "00") { $_start_hh = "12"; $_start_am="SELECTED"; }
elsif ($_start_hh > 12) { $_start_hh -= 12; $_start_pm="SELECTED"; }
elsif ($_start_hh == 12) { $_start_pm="SELECTED"; }
else { $_start_am="SELECTED"; }
if ($_end_hh eq "00") { $_end_hh = "12"; $_start_am="SELECTED"; }
elsif ($_end_hh > 12) { $_end_hh -= 12; $_end_pm="SELECTED"; }
elsif ($_end_hh == 12) { $_end_pm="SELECTED"; }
else { $_end_am="SELECTED"; }
}
I copied this code and pasted it at the end of all of the perl code, just after it says
"my ($post_yy,$post_mm,$post_dd) = ($main::in{'add_date'} =~ /(\d\d\d\d)(\d\d)(\d\d)/);"
except I changed it to read:
$_start_hh = $main::in{'start_hour'};
#($_end_hh,$_end_mm) = ($schedule->{'end_time'} =~ /(\d\d)(\d\d)/);
if ($time_format eq "12") {
if ($_start_hh == 00) { $_start_hh = "12"; $_start_am="SELECTED"; }
elsif ($_start_hh > 12) { $_start_hh -= 12; $_start_pm="SELECTED"; }
elsif ($_start_hh == 12) { $_start_pm="SELECTED"; }
else { $_start_am="SELECTED"; }
if ($_end_hh eq "00") { $_end_hh = "12"; $_start_am="SELECTED"; }
elsif ($_end_hh > 12) { $_end_hh -= 12; $_end_pm="SELECTED"; }
elsif ($_end_hh == 12) { $_end_pm="SELECTED"; }
else { $_end_am="SELECTED"; }
}
Defining "$_start_hh" as the start_hour value passed from the default.html page seems to allow <%$_start_hh%> in the starting hour field of the add form to display the hour selected from the previous page, and also to cause the AM/PM fields to display correctly.
Also I changed:
if ($_start_hh eq "00") ..
to
if ($_start_hh == 00 ) because that seems to work better for the 12 a.m. time slot.
I havent' thought about addressing the all-day events, mostly because I don't really need it right now.
I hope I've explained this clearly. And I hope it continues to work! Thanks,
w
------------------
[This message has been edited by wderzawiec (edited May 14, 2006).]