function perform()
 {
     // set display requirements
     $result = array('renderer' => 'template_renderer.inc', 'pageTitle' => SITE_NAME . ' : Finished Report', 'content' => 'content/reportReturn.php');
     // don't lose the db!
     $db = $_REQUEST['db'];
     // where are we?
     $userFinder = new UserFinder($db);
     $user = $userFinder->findById($_SESSION['userId']);
     $result['user'] = $user;
     // gather posted data
     $date1 = trim(grwd('date1'));
     $date2 = trim(grwd('date2'));
     if ($date1 == '') {
         $date1 = '1/1/1990';
     }
     if ($date2 == '') {
         $date2 = 'now';
     }
     $report_id = grwd('report_id');
     $library_id_post = grwd('library_id') + 0;
     $location_id_post = grwd('location_id') + 0;
     // function to sanity check dates
     $date1 = makeDateSane($date1);
     $date1 = date('Y-m-d G:i:s', strtotime($date1));
     $date2 = makeDateSane($date2);
     $date2 = date('Y-m-d G:i:s', strtotime($date2));
     $startDate = array('database_field' => 'questions.question_date', 'relation' => '>=', 'value' => $date1, 'type' => 'DATE');
     $endDate = array('database_field' => 'questions.question_date', 'relation' => '<=', 'value' => $date2, 'type' => 'DATE');
     $library_id = array('database_field' => 'questions.library_id', 'relation' => '=', 'value' => $library_id_post, 'type' => 'INT');
     $location_id = array('database_field' => 'questions.location_id', 'relation' => '=', 'value' => $location_id_post, 'type' => 'INT');
     // pull together all of the search criteria
     $criteria = array('start_date' => $startDate, 'end_date' => $endDate, 'library_id' => $library_id, 'location_id' => $location_id);
     $sql = " WHERE questions.delete_hide = 0 ";
     $i = 0;
     $param = array();
     foreach ($criteria as $value) {
         if (!$value["value"]) {
             continue;
         }
         $sql .= 'AND' . ' ' . $value["database_field"] . ' ' . $value["relation"] . ' ? ';
         $param[$i] = $value["value"];
         $i++;
     }
     // get the relevant data from the Report class
     $reportFinder = new ReportFinder($db);
     $reportCount = $reportFinder->getReportCount();
     $reportQuestionCount = $reportFinder->getReportQuestionCount($sql, $param);
     // call the specific class of the report
     $report_class_handle = new Report();
     $report_class_get = $report_class_handle->get();
     $report_info = new $report_id();
     // declare the report class by using it's ID
     $result['reportList'] = $report_info->info();
     // start preparing the report for processing
     $reportPerform = new $_REQUEST["report_id"]($db);
     $reportResults = $reportPerform->perform($sql, $param);
     $libraryFinder = new LibraryFinder($db);
     $reportLibName = $libraryFinder->getLibraryName($library_id_post);
     if (isset($location_id_post)) {
         $locationFinder = new LocationFinder($db);
         $reportLocName = $locationFinder->getLocation($location_id_post);
     }
     // prepare $results
     // since a CSV report is handled differently with the headers, configure the report here
     if ($report_id == "DataCSVReport" || isset($_REQUEST["csv_export"])) {
         $result['renderer'] = 'template_csv.inc';
         $result['content'] = 'content/outputCSV.php';
     }
     $result['report_id'] = $report_id;
     $result['date1'] = $date1;
     $result['date2'] = $date2;
     $result['library_id'] = $library_id;
     $result['library_id_post'] = $library_id_post;
     $result['library_name'] = $reportLibName;
     $result['location_id'] = $location_id;
     $result['location_id_post'] = $location_id_post;
     $result['location_name'] = $reportLocName;
     $result['reportCount'] = $reportCount;
     $result['reportQuestionCount'] = $reportQuestionCount;
     $result['reportResults'] = $reportResults;
     $result['criteria'] = $criteria;
     $result['sql'] = $sql;
     return $result;
 }
 function perform()
 {
     // set display requirements
     $result = array('renderer' => 'template_renderer.inc', 'pageTitle' => SITE_NAME . ' : Search Results', 'content' => 'content/questionSearchResults.php');
     // The number of questions and page offset we want
     $count = grwd('count', 50);
     $page = grwd('page', 1);
     $result['count'] = $count;
     $result['page'] = $page;
     // don't lose the db!
     $db = $_REQUEST['db'];
     $userFinder = new UserFinder($db);
     $user = $userFinder->findById($_SESSION['userId']);
     $result['user'] = $user;
     // Generate a base URL for this search -- can't have page or count data
     // cos we're going to build pagination links from this
     $criteriaArray = $_GET;
     unset($criteriaArray['page']);
     unset($criteriaArray['count']);
     $advancedSearchString = implode_assoc('=', '&', $criteriaArray, true, true);
     $result['criteria_array'] =& $criteriaArray;
     $baseUrl = 'advancedSearch.do?' . $advancedSearchString;
     $result['advanced_search_string'] = $advancedSearchString;
     // gather request data
     $date1 = grwd('date1');
     $date2 = grwd('date2');
     $library_id_post = grwd('library_id') + 0;
     $location_id_post = grwd('location_id') + 0;
     $initials = grwd('initials');
     $searchString = grwd('searchString');
     $result['searchWords'] = $searchString;
     $questionFinder = new QuestionFinder($db);
     $startDate = array('database_field' => 'questions.question_date', 'relation' => '>=', 'value' => $date1, 'type' => 'DATE');
     $endDate = array('database_field' => 'questions.question_date', 'relation' => '<=', 'value' => $date2, 'type' => 'DATE');
     $library_id = array('database_field' => 'questions.library_id', 'relation' => '=', 'value' => $library_id_post, 'type' => 'INT');
     $location_id = array('database_field' => 'questions.location_id', 'relation' => '=', 'value' => $location_id_post, 'type' => 'INT');
     $initials = array('database_field' => 'questions.initials', 'relation' => 'LIKE', 'value' => $initials, 'type' => 'TEXT');
     $searchCriteria = array('database_field' => array('question', 'answer'), 'relation' => 'fulltext', 'value' => $searchString, 'type' => 'FULLTEXT');
     // pull together all of the search criteria
     $criteria = array('start_date' => $startDate, 'end_date' => $endDate, 'library_id' => $library_id, 'location_id' => $location_id, 'initials' => $initials, 'search_criteria' => $searchCriteria);
     $sql = "";
     $param = array();
     foreach ($criteria as $value) {
         if (!$value["value"]) {
             continue;
         }
         if (count($param) != 0) {
             $sql .= ' AND ';
         }
         if ($value["type"] == "FULLTEXT") {
             // Track if this is the first fulltext in group
             $orNeeded = false;
             $sql .= ' ( ';
             foreach ($value["database_field"] as $field) {
                 if ($orNeeded) {
                     $sql .= " OR ";
                 }
                 $sql .= 'MATCH(' . $field . ") AGAINST(? IN BOOLEAN MODE)";
                 $param[] = mySqlFulltextString($value["value"]);
                 $orNeeded = true;
             }
             $sql .= ' ) ';
         } else {
             if ($value['type'] == "DATE") {
                 // Make dates sane; the only part of this that's special
                 $sDate = makeDateSane($value['value']);
                 $sDate = date('Y-m-d', strtotime($sDate));
                 $sql .= $value["database_field"] . ' ' . $value["relation"] . ' ? ';
                 $param[] = $sDate;
             } else {
                 $sql .= $value["database_field"] . ' ' . $value["relation"] . ' ? ';
                 $param[] = $value["value"];
             }
         }
     }
     $questionFinder = new QuestionFinder($db);
     $qList =& $questionFinder->getPagedList($count, $page, $sql, $param);
     $result['questionList'] =& $qList['list'];
     $result['list_meta'] = $qList['meta'];
     $libraryFinder = new LibraryFinder($db);
     $searchLibName = $libraryFinder->getLibraryName($library_id_post);
     if ($library_id_post == 0) {
         $searchLibName = "All Libraries";
     }
     if (isset($location_id_post)) {
         $locationFinder = new LocationFinder($db);
         $searchLocName = $locationFinder->getLocation($location_id_post);
     }
     $result['origin'] = $baseUrl . "&amp;page={$page}&amp;count={$count}";
     $result['base_url'] = $baseUrl;
     $result['date1'] = $date1;
     $result['date2'] = $date2;
     $result['library_id'] = $library_id;
     $result['library_name'] = $searchLibName;
     $result['search_library_id'] = $library_id_post;
     $result['location_id'] = $location_id;
     $result['location_name'] = $searchLocName;
     $result['criteria'] = $criteria;
     // $result['sql'] = $sql;
     return $result;
 }
<?php

require_once "../Utils.php";
$myDate = grwd('date');
$goodDate = makeDateSane($myDate);
$parsed = (strtotime($goodDate) > 0) + 0;
?>
var el_id = '<?php 
echo $_GET['id'];
?>
';
var unparsedDate = '<?php 
echo $myDate;
?>
';
var goodDate = '<?php 
echo $goodDate;
?>
';
var parsed = <?php 
echo $parsed;
?>
;

if (goodDate == '') {
    $(el_id).style.backgroundColor = '#fff';
} else {    
    if (parsed) {
        $(el_id).value = goodDate;
        new Effect.Highlight(el_id, {startcolor: '#aaeeaa', endcolor: '#ffffff', duration: .5});
    } else {