dt_widget_day (public, deprecated)

 dt_widget_day [ -calendar_details calendar_details ] [ -date date ] \
    [ -hour_template hour_template ] [ -start_hour start_hour ] \
    [ -end_hour end_hour ] [ -show_nav show_nav ] \
    [ -prev_nav_template prev_nav_template ] \
    [ -next_nav_template next_nav_template ] \
    [ -master_bgcolor master_bgcolor ] \
    [ -header_bgcolor header_bgcolor ] \
    [ -header_text_color header_text_color ] \
    [ -header_text_size header_text_size ] \
    [ -calendar_width calendar_width ] [ -day_bgcolor day_bgcolor ] \
    [ -today_bgcolor today_bgcolor ] \
    [ -day_text_color day_text_color ] \
    [ -empty_bgcolor empty_bgcolor ] [ -overlap_p overlap_p ]

Defined in packages/acs-datetime/tcl/acs-calendar-2-procs.tcl

Deprecated. Invoking this procedure generates a warning.

Returns a calendar for a specific day, with details supplied by hour. Defaults to today. DEPRECATED: this proc uses hardcoded markup and is therefore difficult to style. It is also not localized. Many of the date operations happening here have now good tcl support through the clock api, which would make this code probably faster. Future reimplementations should leverage the templating system more.

Switches:
-calendar_details (optional)
-date (optional)
-hour_template (defaults to "$display_hour") (optional)
-start_hour (defaults to "0") (optional)
-end_hour (defaults to "23") (optional)
-show_nav (defaults to "1") (optional)
-prev_nav_template (defaults to "<a href="?date=[ns_urlencode $yesterday]"><img border="0" src="[dt_left_arrow]" alt="[_ acs-datetime.back_one_day]"></a>") (optional)
-next_nav_template (defaults to "<a href="?date=[ns_urlencode $tomorrow]"><img border="0" src="[dt_right_arrow]" alt="[_ acs-datetime.forward_one_day]"></a>") (optional)
-master_bgcolor (defaults to "black") (optional)
-header_bgcolor (defaults to "black") (optional)
-header_text_color (defaults to "white") (optional)
-header_text_size (defaults to "+2") (optional)
-calendar_width (defaults to "100%") (optional)
-day_bgcolor (defaults to "#DDDDDD") (optional)
-today_bgcolor (defaults to "yellow") (optional)
-day_text_color (defaults to "white") (optional)
-empty_bgcolor (defaults to "white") (optional)
-overlap_p (defaults to "0") (optional)

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.
Source code:
ns_log Notice "Deprecated proc dt_widget_day used:\n[ad_get_tcl_call_stack]"


    if {$date eq ""} {
        set date [dt_sysdate]
    }

    set current_date $date

    # Initialize the ns_set
    if {$calendar_details eq ""} {
        set calendar_details [ns_set create calendar_details]
    }

    # Collect some statistics about the events (for overlap)
    for {set hour $start_hour} {$hour <= 23} {incr hour} {
        set n_events($hour) 0
        set n_starting_events($hour) 0
    }

    set calendar_details_2 [ns_set copy $calendar_details]

    for {set hour $start_hour} {$hour <= $end_hour} {incr hour} {
        if {$hour < 10} {
            set index_hour "0$hour"
        } else {
            set index_hour $hour
        }

        # Go through events
        while {1} {
            set index [ns_set find $calendar_details_2 $index_hour]
            if {$index == -1} {
                break
            }

            set item_val [ns_set value $calendar_details_2 $index]
            ns_set delete $calendar_details_2 $index
            # Count the num of events starting at this hour
            set n_starting_events($hour) [expr {$n_starting_events($hour) + 1}]

            # Diff the hours
            set hours_diff [dt_hour_diff -start_time [lindex $item_val 0] -end_time [lindex $item_val 1]]

            # Count the num of events at the hours of operations
            for {set i 0} {$i <= $hours_diff} {incr i} {
                set the_hour [expr {$hour + $i}]
                set n_events($the_hour) [expr {$n_events([expr {$the_hour - $i}]) + 1}]
            }
        }
    }

    # the MAX num of events
    set max_n_events 1
    for {set hour $start_hour} {$hour <= $end_hour} {incr hour} {
        if {$max_n_events < $n_events($hour)} {
            set max_n_events $n_events($hour)
            ns_log debug "BMA-DEBUG-CAL: Setting max_n_events to $max_n_events"
        }
    }

    # Select some basic stuff, sets day_of_the_week, yesterday, tomorrow vars
    db_1row select_day_info {}

    set return_html ""

    if {$show_nav} {
        set prev_nav [subst $prev_nav_template]
        set next_nav [subst $next_nav_template]
        append return_html "<table border=0 cellspacing=0 cellpadding=0 width=$calendar_width><tr class=\"table-header\"><th> $prev_nav &nbsp; &nbsp; $day_of_the_week $next_nav &nbsp; &nbsp; </th></tr>
</table>"
    }

    # Loop through the hours of the day
    append return_html "<table border=0 cellpadding=0 cellspacing=0 width=$calendar_width><tr><td><table cellpadding=1 cellspacing=0 border=0 width=100%>
"

    # The items that have no hour
    set hour ""
    set next_hour ""
    set start_time ""
    set odd_row_p 0
    set display_hour [subst {<img border="0" align="center" src="/resources/acs-subsite/diamond.gif" alt="[_ acs-datetime.All_day]">}]
    append return_html [subst {
        <tr class="odd"><td class="center" align="left" width="60" nowrap><span style="font-size: smaller;">[subst $hour_template]</span></td>
        <td colspan="$max_n_events"><span style="font-size: smaller">}]

    # Go through events
    while {1} {
        set index [ns_set find $calendar_details "X"]
        if {$index == -1} {
            break
        }

        if {$overlap_p} {
            append return_html "[lindex [ns_set value $calendar_details $index] 2]<br>"
        } else {
            append return_html "[ns_set value $calendar_details $index]<br>\n"
        }

        ns_set delete $calendar_details $index
    }

    append return_html "</span>
    </td></tr>"

    for {set hour $start_hour} {$hour <= $end_hour} {incr hour} {

        set next_hour [expr {$hour + 1}]

        if {$hour < 10} {
            set index_hour "0$hour"
        } else {
            set index_hour $hour
        }

        # display stuff
        if {$hour >= 12} {
            set ampm_hour [expr {$hour - 12}]
            set pm 1
        } else {
            set ampm_hour $hour
            set pm 0
        }

        if {$ampm_hour == 0} {
            set ampm_hour 12
        }

        if {$ampm_hour < 10} {
            set display_hour "$ampm_hour"
        } else {
            set display_hour "$ampm_hour"
        }

        append display_hour ":00 "

        if {$pm} {
            append display_hour "pm"
        } else {
            append display_hour "am"
        }

        if { $odd_row_p } {
            set class "odd"
            set odd_row_p 0
        } else {
            set class "even"
            set odd_row_p 1
        }

        set display_hour [subst $hour_template]
        append return_html "<tr class=\"$class\"><td class=\"center\" align=left width=\"60\" \"nowrap\"><nobr><span style=\"font-size: smaller\">$display_hour</span></nobr></td>\n"

        set n_processed_events 0

        # A flag to force completion of the row
        set must_complete_p 0

        # Go through events
        while {1} {
            set index [ns_set find $calendar_details $index_hour]
            if {$index == -1} {
                break
            }

            incr n_processed_events

            if {$overlap_p} {
                set one_item_val [ns_set value $calendar_details $index]

                set hour_diff [dt_hour_diff -start_time [lindex $one_item_val 0] -end_time [lindex $one_item_val 1]]

                set start_time $hour

                # Calculate the colspan
                if {$n_processed_events == $n_starting_events($hour)} {
                    # This is the last one, make it as wide as possible
                    if {$hour_diff > 0} {
                        set colspan 1
                        set must_complete_p 1
                    } else {
                        # HACK
                        set colspan 1
                        set must_complete_p 1
                        #set colspan [expr {$max_n_events - $n_events($hour) + 1}]
                    }
                } {
                    # Just make it one
                    set colspan 1
                }

                append return_html "<td valign=top rowspan=[expr {$hour_diff + 1}] colspan=$colspan><span style=\"font-size: smaller\">[lindex $one_item_val 2]</span></td>"
            } else {
                append return_html "[ns_set value $calendar_details $index]<br>\n"
            }

            ns_set delete $calendar_details $index
        }

        if {$n_processed_events == 0 || ($n_events($hour) < $max_n_events && $must_complete_p)} {
            if {$n_events($hour) == 0 || $n_events($hour) == $n_processed_events} {
                append return_html "<td colspan=\"[expr {$max_n_events - $n_events($hour)}]\" class=\"$class\">&nbsp;</td>"
            } else {
                for {set i 0} {$i < $max_n_events - $n_events($hour)} {incr i} {
                    append return_html "<td colspan=\"1\" class=$class>&nbsp;</td>"
                }
            }
        }

        append return_html "</tr>\n"
    }

    append return_html "</table>
</td></tr>
</table>"

    return $return_html
XQL Not present:
Generic
PostgreSQL XQL file:
<fullquery name="dt_widget_day.select_day_info">
    <querytext>
select   to_char(to_date(:current_date, 'yyyy-mm-dd'), 'Day, DD Month YYYY') 
as day_of_the_week,
to_char(to_date(:current_date, 'yyyy-mm-dd') - cast('1 day' as interval), 'yyyy-mm-dd')
as yesterday,
to_char(to_date(:current_date, 'yyyy-mm-dd') + cast('1 day' as interval), 'yyyy-mm-dd')
as tomorrow
from     dual
</querytext>
</fullquery>
packages/acs-datetime/tcl/acs-calendar-2-procs-postgresql.xql

Oracle XQL file:
<fullquery name="dt_widget_day.select_day_info">
    <querytext>
select   to_char(to_date(:current_date, 'yyyy-mm-dd'), 'Day, DD Month YYYY') 
as day_of_the_week,
to_char(to_date(:current_date, 'yyyy-mm-dd')-1, 'yyyy-mm-dd')
as yesterday,
to_char(to_date(:current_date, 'yyyy-mm-dd')+1, 'yyyy-mm-dd')
as tomorrow
from     dual
</querytext>
</fullquery>
packages/acs-datetime/tcl/acs-calendar-2-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: