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


Login with username, password and session length

Search

 
Advanced search

8040 Posts in 1853 Topics- by 2099 Members - Latest Member: roi
Calendar Script CommunityCustomizationCustomizing CalendarScript (Moderators: scott, DanO, Marty)Displaying date and time on Approval page
Pages: [1]   Go Down
Print
Author Topic: Displaying date and time on Approval page  (Read 465 times)
0 Members and 1 Guest are viewing this topic.
lacrymosa
New Member
*

Karma: 0
Offline Offline

Posts: 0

IT tech


WWW
« on: January 30, 2002, 12:11:00 AM »

Ok,

I was banging my head aginst this one for a couple of hours this evening, and I'm not sure where to go next, as I'm still a novice in the perl side of this.

I'd like to display the date and time of the events that are pending approval so the administrators can see when events are scheduled to take place without editing the event. Right now the "Schedule" section for each pending event comes up blank.

I have some kind of idea that I'm going to have to add some lines to the foreach statement and take the event id and do a search/display for the corresponding schedule but I'm not sure how I would do this as the commands for the admin script aren't as documented.

any help?

-Lacrymosa

Logged
lacrymosa
New Member
*

Karma: 0
Offline Offline

Posts: 0

IT tech


WWW
« Reply #1 on: January 30, 2002, 04:18:00 PM »

Once again, I have answered my own question. It took 7 hours of pounding on one section of code, but I finally got it. I added some text from the schedule disply html page to the approve.html page. What I did is below.
code:

<%
$total = 0;
foreach $e (@$events) {
   $total++;
   $id = $e->{'details'}->{'id'};
   $title = $e->{'details'}->{'title'};
   $desc = $e->{'details'}->{'description'};
   $author = $e->{'details'}->{'author_name'}." (".$e->{'details'}->{'author_id'}.")";
#Added this below.

   $config = $main::Config;
   #unless ($event) {
      $event_id = $id;
      $event = $events_db->getRecord( {'event_id'=>$event_id} );
   #   }
   $schedule = $schedule_db->getRecord( {'event_id'=>$event->{'id'}} );
$_static_dates_range = "dates";
if ($schedule) {
#foreach $key (sort keys %$schedule) { print "$key = $schedule->{$key}<BR>\n"; }
   if ($schedule->{'recurrence_type'} eq "") {
      my (@dates);
      my ($occurences) = $schedule_db->getRecords( {'event_id'=>$event->{'id'}} );

      if ($#{$occurences} > 0) {
         # More than one occurrence
         #print ("more than one occurrence");
         foreach $occurence (@$occurences) {
            push(@dates,&SimpleDateFormat::formatDate($occurence->{'start'},$config->get("date_format")));
            }
         $_static_dates_range = "dates";
         $_static_dates = join(",",@dates);
         }
      else {
         # Only one!
         #print ("only once occurrence");
         if ($schedule->{'start'} == $schedule->{'end'}) {
            $_static_dates_range = "dates";
            $_static_dates = &SimpleDateFormat::formatDate($schedule->{'start'},$config->get("date_format"));
            }
         else {
            $_static_dates_range = "range";
            $_static_start_date = &SimpleDateFormat::formatDate($schedule->{'start'},$config->get("date_format"));
            $_static_end_date = &SimpleDateFormat::formatDate($schedule->{'end'},$config->get("date_format"));
            }
         }
      }
   }
if (!$schedule) {
   $schedule = {};
   }
else {
   if ($schedule->{'all_day'}) {
      $_all_day = "CHECKED";
      $schedule->{'start_time'} = "";
      $schedule->{'end_time'} = "";
      }
   }   
   
   
   
   
   
   $time_format = "24";
   $week_start_day = $config->get("week_start_day");

   ($_start_hh,$_start_mm) = ($schedule->{'start_time'} =~ /(\d\d)(\d\d)/);
   ($_end_hh,$_end_mm) = ($schedule->{'end_time'} =~ /(\d\d)(\d\d)/);
      
   $monthnames = $config->get("month_names");
   $daynames = $config->get("day_names");
   $dayabbreviations = $config->get("day_abbreviations");

#/Added this below

%>
<TR>
   <TD ALIGN="center" VALIGN="top">
      <SELECT NAME="APPROVE_<%=$id%>"><OPTION VALUE="">No Action</OPTION><OPTION VALUE="APPROVE">Approve</OPTION><OPTION VALUE="REJECT">Reject</OPTION></SELECT>
      <BR>
      <INPUT TYPE="button" CLASS="button" VALUE="Edit" onClick="edit_event('<%=$id%>')">
   </TD>
   <TD ALIGN="left" VALIGN="top">
      <B>Workstation: </B><%=$title%><BR>
      <!--<B>Description: </B><%=$desc%><BR>-->
      <B>User: </B><%=$author%><BR>
      <B>ID: </B><%= $id%><BR>
      <B>Schedule: </B>from: <%=$_start_hh%>:<%=$_start_mm%> to: <%=$_end_hh%>:<%=$_end_mm%> on <%= $_static_dates %><BR>
   </TD>
</TR>


-Lacrymosa

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

Logged
ErikLarson
Guest
« Reply #2 on: May 31, 2003, 04:59:00 PM »

Thanks for this code... very helpful.

I found that it was also necessary to add to the calendar_admin.pl script:

require "SimpleDateFormat.pm";

Logged
mraj
New Member
*

Karma: 0
Offline Offline

Posts: 0

Software Engineer


« Reply #3 on: March 19, 2005, 11:49:00 AM »

This is just what I was looking for, thanks!

I made some changes:
- fix all day events
- add 'am' and 'pm' to times
- remove unnecessary lines
Here are the changes (this is in approve.html):

<%
$total = 0;
$config = $main::Config;
foreach $e (@$events) {
   $total++;
   $id = $e->{details}->{id};
   $title = $e->{details}->{title};
   $desc = $e->{details}->{description};
   $author = $e->{details}->{author_name}." (".$e->{details}->{author_id}.")";

   $event_id = $id;
   $event = $events_db->getRecord( {'event_id'=>$event_id} );
   $schedule = $schedule_db->getRecord( {'event_id'=>$event->{id}} );
   $_static_dates_range = "dates";
   if ($schedule) {
      #foreach $key (sort keys %$schedule) { print "$key = $schedule->{$key}<BR>\n"; }
      if ($schedule->{'recurrence_type'} eq "") {
         my (@dates);
         my ($occurences) = $schedule_db->getRecords( {'event_id'=>$event->{id}} );
         if ($#{$occurences} > 0) {
            # More than one occurrence
            #print ("more than one occurrence");
            foreach $occurence (@$occurences) {
               push(@dates,&SimpleDateFormat::formatDate($occurence->{start},$config->get("date_format")));
            }
            $_static_dates_range = "dates";
            $_static_dates = join(", ",@dates);
         } else {
            # Only one!
            #print ("only once occurrence");
            if ($schedule->{'start'} == $schedule->{end}) {
               $_static_dates_range = "dates";
               $_static_dates = &SimpleDateFormat::formatDate($schedule->{start},$config->get("date_format"));
            } else {
               $_static_dates_range = "range";
               $_static_start_date = &SimpleDateFormat::formatDate($schedule->{start},$config->get("date_format"));
               $_static_end_date = &SimpleDateFormat::formatDate($schedule->{end},$config->get("date_format"));
            }
         }
      }
   }
%>
<TR>
   <TD ALIGN="center" VALIGN="top">
      <SELECT NAME="APPROVE_<%=$id%>"><OPTION VALUE="">No Action</OPTION><OPTION VALUE="APPROVE">Approve</OPTION><OPTION VALUE="REJECT">Reject</OPTION></SELECT>
      <BR>
      <INPUT TYPE="button" CLASS="button" VALUE="Edit" onClick="edit_event('<%=$id%>')">
   </TD>
   <TD ALIGN="left" VALIGN="top"><table border=0 cellpadding=0>
      <tr><td valign='top'><b>Title:</B><td><%=$title%><BR>
      <tr><td valign='top'><b>Description:</B><td><%=$desc%><BR>
      <tr><td><b>User:</B><td><%=$author%><BR>
      <tr><td><b>Event ID:</B><td><font color=crimson><%= $id%></font><BR>
      <tr><td valign='top'><b>Schedule:</B><td>
         <%if($schedule) {
            if ($schedule->{all_day}) { print 'all day';
            } else {
               ($_start_hh,$_start_mm) = ($schedule->{start_time} =~ /(\d\d)(\d\d)/);
               $_start_ampm = 'am';
               if($_start_hh > 12) { $_start_hh -= 12; $_start_ampm = 'pm' }
               ($_end_hh,$_end_mm) = ($schedule->{end_time} =~ /(\d\d)(\d\d)/);
               $_end_ampm = 'am';
               if($_end_hh > 12) { $_end_hh -= 12; $_end_ampm = 'pm' }
               print $_start_hh,':',$_start_mm,' ',$_start_ampm,
                  ' to ',$_end_hh,':',$_end_mm,' ',$_end_ampm,' on';
            }
            print '<br>',$_static_dates;
         } else {
            print 'not scheduled';
         }%>
         <BR>
      </table>
   </TD>
</TR>
<% } %>
<% if ($total==0) { %>

------------------
See some of my modifications to CalendarScript at  http://www.prayforoneanother.org/cgi-bin/cal/calendar.pl

[This message has been edited by mraj (edited March 19, 2005).]

Logged

See some of my modifications to CalendarScript at
http://www.prayforoneanother.org/cgi-bin/cal/calendar.pl
Jason S
New Member
*

Karma: 0
Offline Offline

Posts: 3


WWW
« Reply #4 on: April 25, 2005, 11:35:00 AM »

I love the code for displaying all of the dates and it works fine if I just use the "Individual Date(s)" field, but when I use the "Recurring Schedule" or "Date Range" it will just repeat the dates from the event displayed before it.  Any ideas on how to fix this issue.

Thanks

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

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 227

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


WWW
« Reply #5 on: December 02, 2006, 02:33:00 PM »

** I found that it was also necessary to add to the calendar_admin.pl script: require "SimpleDateFormat.pm"; **

It should only be necessary to add the require... line to the top of the approve.html file, anywhere after the first <% tag.

Modifying the calendar_admin.pl itself could make updating the script in the future harder.

JFYI

Dan O.

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

Logged
idesign123
Guest
« Reply #6 on: May 23, 2007, 02:02:00 AM »

Thanks for posting this solution in the forum.

I'm using the 'fydayspan' template, and still don't see any dates listed (I tried both versions of the fix + added require "SimpleDateFormat.pm"; to the top of approve.html (right after the first <% tag.

Right now the table says...
Title:
Description:
User:
Event ID:
Schedule: all day

Isn't there a way to add 'Dates' or 'Date Range' to this list?

Thanks for any tips.

:Stacey

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