Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8043 Posts in 1856 Topics- by 2099 Members - Latest Member: roi
Pages: [1]   Go Down
Print
Author Topic: set default start times  (Read 507 times)
0 Members and 1 Guest are viewing this topic.
wderzawiec
New Member
*

Karma: 0
Offline Offline

Posts: 15

Web site coordinator


WWW
« on: May 10, 2006, 12:46:00 PM »

Does anyone know how to make the schedule event page show a default start time?  I'm setting up a calendar where most events start at 9 a.m., it would be great if 9  and 00 could show up in the form as defaults, but could be changed if needed.  Thanks.
Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #1 on: May 10, 2006, 06:27:00 PM »

** Does anyone know how to make the schedule event page show a default start time? **

Change the 2 form fields on the 2 event scheduling templates to add a 'default' value. Maybe something like changing:

<%=$_start_hh%> to <%=$_start_hh || "9"%>

and

<%=$_start_mm%> to <%=$_start_mm || "00"%>

This is untested though! Use at your own risk.

** it would be great if 9 and 00 could show up in the form as defaults **

Maybe so but it might lead to some strange errors with the JavaScript form validation on the page though. It also might cause problem when editing existing event schedules as the same templates are used for add and editing event schedules.


 This forum software usually adds a space between double || characters. Make sure any extra space between such characters is removed from code copied and pasted from these forums.

Dan O.

------------------

Logged
wderzawiec
New Member
*

Karma: 0
Offline Offline

Posts: 15

Web site coordinator


WWW
« Reply #2 on: May 10, 2006, 08:31:00 PM »

I see your point, thank you.  Veering off the original topic a little, does that mean that the one-click plugin form and your new Grid Add Event plugin form can be used for editing as well as adding events?

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #3 on: May 10, 2006, 09:20:00 PM »

** [can the template from the] Grid Add Event plugin be used for editing as well as adding events? **

No. It is only for adding events.

BTW. If you are using that plug-in (you never originally said), you'd need to alter that template as well (or instead, as the case may be).  

Dan O.

------------------

Logged
wderzawiec
New Member
*

Karma: 0
Offline Offline

Posts: 15

Web site coordinator


WWW
« Reply #4 on: May 11, 2006, 06:18:00 AM »

**BTW. If you are using that plug-in (you never originally said), you'd need to alter that template as well**

Yes, I understand.  I did download the plugin and it works great.  Instead of applying the code to the Day View in Grid style, I added it to the monthly grid, so that when you click on the number of the day, instead of going to Day View you go directly to the new Grid Add Event Form.  Exactly what I wanted, (well, except for the default time).

Now I'm wondering if the same concept of the Grid Add Event can't be used to grab times for the form from the Day View?  In other words, calendar script is creating months and days, and the plugin is using that information to automatically set the date for the Grid Add Event. Could the hours that are being created in the Day View be plugged in to the form as well somehow?  I'm just thinking out loud right now.  Thanks very much, thanks for all the work you are doing to help folks.

w

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #5 on: May 11, 2006, 01:10:00 PM »

** Could the hours that are being created in the Day View be plugged in to the form as well somehow? **

Anything's possible.

In fact, even your first request might work Ok on that plug-in's template since it is only used for adding events and not editing them. I still don't know about the form validation routines for it though, someone would have to test it.

Dan O.

------------------

Logged
wderzawiec
New Member
*

Karma: 0
Offline Offline

Posts: 15

Web site coordinator


WWW
« Reply #6 on: May 12, 2006, 07:23:00 PM »

Well, I'm giving your suggestion of changing
<%=$_start_hh%> to <%=$_start_hh | | "9"%>

and

<%=$_start_mm%> to <%=$_start_mm | | "00"%>

a try. So far so good I think, I will let you know if I run into any problems.

w

------------------

Logged
wderzawiec
New Member
*

Karma: 0
Offline Offline

Posts: 15

Web site coordinator


WWW
« Reply #7 on: May 14, 2006, 03:17:00 PM »

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).]

Logged
Pages: [1]   Go Up
Print
Jump to: