function display()
{
    extract($_REQUEST);
    $fields = array();
    $fields["human_date"] = date("D jS M Y");
    // eg: Mon 2nd Aug 2006
    extract($fields, EXTR_SKIP);
    $sql = "SELECT * FROM cubit.today WHERE date<=now()";
    $today_rslt = db_exec($sql) or errDie("Unable to retrieve today.");
    $today_out = "";
    $prev_out = "";
    while ($today_data = pg_fetch_array($today_rslt)) {
        if (!in_team($today_data["team_id"], USER_ID)) {
            continue;
        }
        $datetime = "{$today_data['date']} / ";
        if (!empty($today_data["time"])) {
            $datetime .= $today_data["time"];
        } else {
            $datetime .= "Entire Day";
        }
        // Retrieve the section
        $sql = "SELECT * FROM cubit.today_sections WHERE id='{$today_data['section_id']}'";
        $section_rslt = db_exec($sql) or errDie("Unable to retrieve section.");
        $section_data = pg_fetch_array($section_rslt);
        $tmp_out = "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$datetime}</td>\n\t\t\t\t<td><a href='javascript:popupOpen(\"{$section_data['link']}\")'>{$section_data['name']}</a></td>\n\t\t\t\t<td><a href='javascript:popupOpen(\"{$today_data['link']}\")'>{$today_data['title']}</a></td>\n\t\t\t\t<td>{$today_data['info']}</td>\n\t\t\t\t<td align='center'>\n\t\t\t\t\t<input type='checkbox' name='rem[{$today_data['id']}]' \n\t\t\t\t\tvalue='{$today_data['id']}' onchange='javascript:document.form.submit()' />\n\t\t\t\t</td>\n\t\t\t</tr>";
        if ($today_data["date"] == date("Y-m-d")) {
            $today_out .= $tmp_out;
        } else {
            $prev_out .= $tmp_out;
        }
    }
    if (empty($today_out)) {
        $today_out = "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td colspan='5'><li>No items found for today</li></td>\n\t\t\t</tr>";
    }
    if (empty($prev_out)) {
        $prev_out = "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td colspan='5'><li>No previous items found</li></td>\n\t\t\t</tr>";
    }
    $OUTPUT = "\n\t\t<h3>Today Action Display for {$human_date}</h3>\n\t\t" . whereis_block() . "\n\t\t<form method='POST' action='" . SELF . "' name='form'>\n\t\t\t<input type='hidden' name='key' value='remove' />\n\t\t\t<a href='" . SELF . "?key=future' style='font-size:12pt; font-weight: bold'>Future Action Dates</a>\n\t\t<p></p>\n\t\t<table cellpadding='5' cellspacing='0' class='shtable'>\n\t\t\t<tr>\n\t\t\t\t<th>Date / Time</th>\n\t\t\t\t<th>Section</th>\n\t\t\t\t<th>Title</th>\n\t\t\t\t<th>Info</th>\n\t\t\t\t<th>Remove</th>\n\t\t\t</tr>\n\t\t\t{$today_out}\n\t\t</table>\n\t\t<p></p>\n\t\t<h3>Previous Actions</h3>\n\t\t<table cellpadding='5' cellspacing='0' class='shtable'>\n\t\t\t<tr>\n\t\t\t\t<th>Date / Time</th>\n\t\t\t\t<th>Section</th>\n\t\t\t\t<th>Title</th>\n\t\t\t\t<th>Info</th>\n\t\t\t\t<th>Remove</th>\n\t\t\t</tr>\n\t\t\t{$prev_out}\n\t\t</table>\n\t\t</form>\n\t\t<p></p>\n\t\t<a href='today_dates.php' style='font-size:12pt; font-weight: bold'>Brought Forward Dates</a><br><br>" . mkQuickLinks(ql("../crmsystem/leads_list.php", "Return To View Leads"));
    return $OUTPUT;
}
function display()
{
    extract($_REQUEST);
    define("SECONDS_IN_DAY", 5184000);
    $yesterday = time() - SECONDS_IN_DAY;
    $fields["hs_day"] = "01";
    $fields["hs_month"] = date("m");
    $fields["hs_year"] = date("Y");
    $fields["he_day"] = date("d", $yesterday);
    $fields["he_month"] = date("m", $yesterday);
    $fields["he_year"] = date("Y", $yesterday);
    extract($fields, EXTR_SKIP);
    // Display the current day
    $date_start = date("Y-m-d") . " 00:00:00";
    $date_end = date("Y-m-d") . " 23:59:59";
    $hs_date = "{$hs_year}-{$hs_month}-{$hs_day} 00:00:00";
    $he_date = "{$he_year}-{$he_month}-{$he_day} 23:59:59";
    $date = mkDate(date("Y"), date("m"), date("d"));
    $OUTPUT = "<center>\n\t<h3>Today Action Display for {$date}</h3>\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<td colspan='5' valign='top' align='center'>" . whereis_block() . "</td>\n\t\t<tr>\n\t\t\t<td align='center' valign='top'>" . diary_block($date_start, $date_end) . "</td>\n\t\t\t<td align='center' valign='top'>" . email_block($date_start, $date_end) . "</td>\n\t\t\t<td align='center' valign='top'>" . cust_block($date_start, $date_end) . "</td>\n\t\t\t<td align='center' valign='top'>" . doc_block($date_start, $date_end) . "</td>\n\t\t\t<td align='center' valign='top'>" . lead_block($date_start, $date_end) . "</td>\n\t\t</tr>\n\t\t<tr><td>&nbsp;</td></tr>\n\t\t<tr>\n\t\t\t<td colspan='5' align='center'><h3>History</h3></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='center' valign='top'>" . diary_block($hs_date, $he_date) . "</td>\n\t\t\t<td align='center' valign='top'>" . email_block($hs_date, $he_date) . "</td>\n\t\t\t<td align='center' valign='top'>" . cust_block($hs_date, $he_date) . "</td>\n\t\t\t<td align='center' valign='top'>" . doc_block($hs_date, $he_date) . "</td>\n\t\t\t<td align='center' valign='top'>" . lead_block($hs_date, $he_date) . "</td>\n\t\t</tr>\n\t</table>\n\t</center>";
    return $OUTPUT;
}