function display()
{
    extract($_REQUEST);
    $fields = array();
    $fields["from_year"] = date("Y");
    $fields["from_month"] = date("m");
    $fields["from_day"] = date("d");
    $fields["to_year"] = date("Y");
    $fields["to_month"] = date("m");
    $fields["to_day"] = date("t");
    $fields["group_id"] = -1;
    $fields["type_id"] = -1;
    extract($fields, EXTR_SKIP);
    $from_date = dateFmt($from_year, $from_month, $from_day);
    $to_date = dateFmt($to_year, $to_month, $to_day);
    $sql = "SELECT * FROM cubit.assetgrp ORDER BY grpname ASC";
    $group_rslt = db_exec($sql) or errDie("Unable to retrieve asset group.");
    if ($group_id == -1) {
        $none_sel = "selected='selected'";
        $all_sel = "";
    } elseif ($group_id == 0) {
        $none_sel = "";
        $all_sel = "selected='selected'";
    } else {
        $none_sel = "";
        $all_sel = "";
    }
    $group_sel = "<select name='group_id' style='width: 100%'\r\n\t\t\t\t  onchange='javascript:document.form.submit()'>";
    $group_sel .= "<option value='-1' {$none_sel}>[None]</option>";
    $group_sel .= "<option value='0' {$all_sel}>[All]</option>";
    while ($group_data = pg_fetch_array($group_rslt)) {
        if ($group_id == $group_data["grpid"]) {
            $sel = "selected='selected'";
        } else {
            $sel = "";
        }
        $group_sel .= "<option value='{$group_data['grpid']}' {$sel}>\r\n\t\t\t{$group_data['grpname']}\r\n\t\t</option>";
    }
    $group_sel .= "</select>";
    $sql = "SELECT * FROM cubit.asset_types ORDER BY name ASC";
    $type_rslt = db_exec($sql) or errDie("Unable to retrieve asset type.");
    if ($type_id == -1) {
        $none_sel = "selected='selected'";
        $all_sel = "";
    } elseif ($type_id == 0) {
        $none_sel = "";
        $all_sel = "selected='selected'";
    } else {
        $none_sel = "";
        $all_sel = "";
    }
    $type_sel = "<select name='type_id' style='width: 100%'\r\n\t\t\t\t onchange='javascript:document.form.submit()'>";
    $type_sel .= "<option value='-1' {$none_sel}>[None]</option>";
    $type_sel .= "<option value='0' {$all_sel}>[All]</option>";
    while ($type_data = pg_fetch_array($type_rslt)) {
        if ($type_id == $type_data["id"]) {
            $sel = "selected='selected'";
        } else {
            $sel = "";
        }
        $type_sel .= "<option value='{$type_data['id']}' {$sel}>\r\n\t\t\t\t\t\t{$type_data['name']}\r\n\t\t\t\t\t  </option>";
    }
    $type_sel .= "</select>";
    $OUTPUT = "\r\n\t<center>\r\n\t<h3>Availability Report</h3>\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td bgcolor='#ff0000'>&nbsp;</td><td>Hired Out</td>\r\n\t\t\t<td bgcolor='#00ff00'>&nbsp;</td><td>Available</td>\r\n\t\t\t<td bgcolor='#ffa200'>&nbsp;</td><td>Booked</td>\r\n\t\t\t<td bgcolor='#ffff00'>&nbsp;</td><td>In Workshop</td>\r\n\t\t</tr>\r\n\t</table>\r\n\t<p></p>\r\n\t<form method='post' action='" . SELF . "' name='form'>\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr>\r\n\t\t\t<th colspan='4'>Date Range</th>\r\n\t\t</tr>\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td>" . mkDateSelect("from", $from_year, $from_month, $from_day) . "</td>\r\n\t\t\t<td><b> To </b></td>\r\n\t\t\t<td>" . mkDateSelect("to", $to_year, $to_month, $to_day) . "</td>\r\n\t\t\t<td><input type='submit' value='Select &raquo' /></td>\r\n\t\t</tr>\r\n\t\t<tr><td colspan='4'>\r\n\t\t<table " . TMPL_tblDflts . " width='100%'>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td colspan='2' width='50%'>{$group_sel}</td>\r\n\t\t\t\t<td colspan='2' width='50%'>{$type_sel}</td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t\t</td></tr>\r\n\t</table>\r\n\t</form>";
    $where = array();
    if ($group_id) {
        $where[] = "grpid='{$group_id}'";
    }
    if ($type_id) {
        $where[] = "type_id='{$type_id}'";
    }
    if (count($where)) {
        $where = "WHERE " . implode(" AND ", $where);
    } else {
        $where = "";
    }
    // Retrieve assets
    $sql = "SELECT * FROM cubit.assets {$where}";
    $asset_rslt = db_exec($sql) or errDie("Unable to retrieve assets.");
    $assets_out = "";
    while ($asset_data = pg_fetch_array($asset_rslt)) {
        if (!isOurs($asset_data["id"])) {
            continue;
        }
        $assets_out .= "<tr class='" . bg_class() . "'>\r\n\t\t\t<td align='center'>\r\n\t\t\t\t" . getSerial($asset_data["id"], 1) . "<br />\r\n\t\t\t\t{$asset_data['des']}\r\n\t\t\t</td>\r\n\t\t\t" . availability($from_date, $to_date, $asset_data["id"]) . "\r\n\t\t</tr>";
    }
    // Do the headers here so we can choose not to show it when no results found
    $headers = date_headers($from_date, $to_date);
    if (empty($assets_out)) {
        $headers = "";
        $assets_out .= "<tr class='" . bg_class() . "'>\r\n\t\t\t<td><li>No results found.</li></td>\r\n\t\t</tr>";
    }
    $OUTPUT .= "<table " . TMPL_tblDflts . ">\r\n\t\t<tr>\r\n\t\t\t<th>Plant</th>\r\n\t\t\t{$headers}\r\n\t\t</tr>\r\n\t\t{$assets_out}\r\n\t</table>";
    return $OUTPUT;
}
示例#2
0
    public function actionOchead()
    {
        global $urlRequestRoot, $moduleFolder, $cmsFolder, $templateFolder, $sourceFolder, $STARTSCRIPTS;
        require_once $sourceFolder . "/upload.lib.php";
        require_once $sourceFolder . "/" . $moduleFolder . "/qaos1/excel.php";
        require_once $sourceFolder . "/" . $moduleFolder . "/oc/oc_common.php";
        $mcId = $this->moduleComponentId;
        $userId = $this->userId;
        if (isset($_POST['downloadFormatExcel'])) {
            displayOCDownload();
        }
        if (isset($_FILES['fileUploadField']['name'])) {
            $date = date_create();
            $timeStamp = date_timestamp_get($date);
            $tempVar = $sourceFolder . "/uploads/temp/" . $timeStamp . $_FILES['fileUploadField']['name'][0];
            move_uploaded_file($_FILES["fileUploadField"]["tmp_name"][0], $tempVar);
            $excelData = readExcelSheet($tempVar);
            $success = 1;
            for ($i = 2; $i <= count($excelData); $i++) {
                $email = $excelData[$i][2] . '@nitt.edu';
                $query = "INSERT IGNORE INTO `oc_valid_emails` (`page_moduleComponentId`,`oc_name`,`oc_valid_email`) \n                                            VALUES ({$mcId},'{$excelData[$i][1]}','{$email}')";
                mysql_query($query) or displayerror($email);
            }
            //echo $c." ".$d;
        }
        $retOcHead = "";
        $uploadValidEmail = getFileUploadForm($mcId, "oc", './+ochead', UPLOAD_SIZE_LIMIT, 1);
        $retOcHead .= <<<FORM
    <form action="./+ochead" method="post">
      <input type="submit" name="downloadFormatExcel" value="Download Event Sample Format"/>
    </form>
FORM;
        $retOcHead .= $uploadValidEmail;
        $displayTags = <<<TAG
    <table>
      <tr>
        <td><a href="./+ochead&subaction=view_whitelist_users"> <div>View Whitelist Registrants</div></a></td>
        <td><a href="./+ochead&subaction=view_registered_users"><div>Registred Users</div></a></td>
        <td><a href="./+ochead&subaction=add_whitelist_email"><div>Add Whitelist Email</div></a></td>
        <td><a href="./+ochead&subaction=availability"><div>Check Availability</div></a></td>
        <td><a href="./+ochead&subaction=reg_status"><div>Current Registration Status</div></a></td>
        <td><a href="./+ochead&subaction=reg_status"><div>Current Registration Status</div></a></td>
        <td><a href="./+ochead&subaction=upload_tshirt_list"><div>Upload TShirt List</div></a></td>
        <td><a href="./+ochead&subaction=download_black_list"><div>Download Black List</div></a></td>
      </tr>
    </table>
TAG;
        if (isset($_GET['subaction']) && $_GET['subaction'] == 'view_registered_users') {
            return $retOcHead . $displayTags . view_registered_users($mcId);
        }
        if (isset($_GET['subaction']) && $_GET['subaction'] == 'view_whitelist_users') {
            return $retOcHead . $displayTags . view_whitelist_emails($mcId);
        }
        if (isset($_GET['subaction']) && $_GET['subaction'] == 'add_whitelist_email') {
            return $retOcHead . $displayTags . add_whitelist_email($mcId);
        }
        if (isset($_GET['subaction']) && $_GET['subaction'] == 'availability') {
            return $retOcHead . $displayTags . availability($mcId);
        }
        if (isset($_GET['subaction']) && $_GET['subaction'] == 'reg_status') {
            return $retOcHead . $displayTags . reg_status($mcId);
        }
        if (isset($_GET['subaction']) && $_GET['subaction'] == 'upload_tshirt_list') {
            return $retOcHead . $displayTags . upload_tshirt_list($mcId);
        }
        if (isset($_GET['subaction']) && $_GET['subaction'] == 'download_black_list') {
            return $retOcHead . $displayTags . download_black_list($mcId);
        }
        return $retOcHead . $displayTags . view_registered_users($mcId);
    }