function perform()
 {
     // set display requirements
     $result = array('renderer' => 'template_renderer.inc', 'pageTitle' => SITE_NAME . ' : Add Date Criteria', 'content' => 'content/reportFormDate.php');
     // don't lose the db!
     $db = $_REQUEST['db'];
     // where are we?
     $userFinder = new UserFinder($db);
     $user = $userFinder->findById($_SESSION['userId']);
     $library = $user['library_short_name'];
     $libraryID = $user['library_id'];
     $result['library_id'] = $libraryID;
     $result['library'] = $library;
     $result['user'] = $user;
     $report_id = grwd('report_id');
     $result['report_id'] = $report_id;
     // get all the info on the reports
     $reportFinder = new ReportFinder($db);
     $reportCount = $reportFinder->getReportCount();
     $result['reportCount'] = $reportCount;
     // get the information for the chosen report by requiring Reports.php and all the reports
     $report_class_handle = new Report();
     $report_class_get = $report_class_handle->get();
     // declare the report class by using it's ID
     $report_info = new $report_id();
     $result['reportList'] = $report_info->info();
     $libraryFinder = new LibraryFinder($db);
     $result['libraryList'] = $libraryFinder->getAllLibraries();
     $locationFinder = new LocationFinder($db);
     $result['locationList'] = $locationFinder->getAllLocations();
     return $result;
 }
 function perform()
 {
     // set display requirements
     $result = array('renderer' => 'template_renderer.inc', 'pageTitle' => SITE_NAME . ' : Library Admin	', 'content' => 'content/admin/libraryAdmin.php');
     // don't lose the db!
     $db = $_REQUEST['db'];
     // where are we?
     $uf = new UserFinder($db);
     $user = $uf->findById($_SESSION['userId']);
     $result['user'] = $user;
     $lf = new LibraryFinder($db);
     $libraryList = $lf->getAllLibraries();
     $result['libraryList'] = $libraryList;
     if (isset($_POST['library_id'])) {
         $libraryID = $_POST['library_id'];
         $library = $lf->getLibraryName($libraryID);
     } else {
         $library = $user['library_short_name'];
         $libraryID = $user['library_id'];
     }
     $result['library_id'] = $libraryID;
     $result['library'] = $library;
     $locationFinder = new LocationFinder($db);
     $result['locationList'] = $locationFinder->findByLibraryID($libraryID);
     $result['distinctLocationList'] = $locationFinder->getDistinctLocations();
     $af = new AdminFinder($db);
     $adminTableList = $af->getAdminTables();
     $result['adminTables'] = $adminTableList;
     return $result;
 }
 function perform()
 {
     // set display requirements
     $result = array('renderer' => 'template_renderer.inc', 'pageTitle' => SITE_NAME . ' : Advanced Search', 'content' => 'content/advancedSearchForm.php');
     // don't lose the db!
     $db = $_REQUEST['db'];
     //var_dump($_REQUEST);
     // where are we?
     $userFinder = new UserFinder($db);
     $user = $userFinder->findById($_SESSION['userId']);
     $library = $user['library_short_name'];
     $libraryId = $user['library_id'];
     $result['library_id'] = $libraryId;
     $result['library'] = $library;
     $result['user'] = $user;
     // The library that got searched for last time, probably...
     $selLibId = grwd('search_library_id', $libraryId);
     $result['search_library_id'] = $selLibId;
     $libraryFinder = new LibraryFinder($db);
     $libraryList = $libraryFinder->getAllLibraries();
     array_unshift($libraryList, array('library_id' => $libraryId, 'short_name' => $user['library_short_name'], 'full_name' => $user['library_full_name']), array('library_id' => '0', 'short_name' => 'All Libraries', 'full_name' => 'All Libraries'), array('library_id' => '', 'short_name' => '----------------------------', 'full_name' => '----------------------------'));
     $result['libraryList'] = $libraryList;
     $locationFinder = new LocationFinder($db);
     $result['locationList'] = $locationFinder->getAllLocations();
     return $result;
 }
 function perform()
 {
     // don't lose the db!
     $db = $_REQUEST['db'];
     if (isset($_POST['all'])) {
         $location_id = $_POST['all'];
     } else {
         $location_id = $_POST['visible'];
     }
     $short_name = $_POST['library'];
     $lib_f = new LibraryFinder($db);
     $library = $lib_f->getLibraryByName($short_name);
     $library_id = $library['library_id'];
     $lf = new LocationFinder($db);
     $location_name = $lf->getLocation($location_id);
     if (isset($_POST['add'])) {
         $add = $lf->addBridgeItem($location_id, $library_id, $location_name);
     } elseif (isset($_POST['remove'])) {
         $remove = $lf->removeBridgeItem($location_id, $library_id);
     } elseif (isset($_POST['up'])) {
         $location_id = $_POST['visible'];
         $up = $lf->moveBridgeItemUp($location_id, $library_id);
     } elseif (isset($_POST['down'])) {
         $location_id = $_POST['visible'];
         $down = $lf->moveBridgeItemDown($location_id, $library_id);
     }
     $loa = new LibraryAdminFormAction();
     $result = $loa->perform();
     $_REQUEST['library_id'] = $library['library_id'];
     $_REQUEST['library'] = $library['short_name'];
     $_REQUEST['full_name'] = $library['full_name'];
     $_REQUEST['parent_table'] = 'locations';
     $_REQUEST['locationList'] = $lf->findByLibraryID($library['library_id']);
     return $result;
 }
 function perform()
 {
     $layout = grwd('layout', 'menus');
     $optionFunctions = array('pulldown' => 'getSelectPulldown', 'radio' => 'getRadioList', 'menus' => 'getSelectBox');
     $optionFunction = $optionFunctions[$layout];
     // Ensure we have the variable questionId
     $questionId = grwd('questionId', -1) + 0;
     $db = $_REQUEST['db'];
     $tsf = new TimeSpentFinder($db);
     $ptf = new PatronTypeFinder($db);
     $qff = new QuestionFormatFinder($db);
     $qtf = new QuestionTypeFinder($db);
     $if = new InitialsFinder($db);
     $lf = new LocationFinder($db);
     $userFinder = new UserFinder($db);
     $user = $userFinder->findById($_SESSION['userId']);
     if ($questionId != -1) {
         // to the edit form!
         $result = array('renderer' => 'template_renderer.inc', 'pageTitle' => SITE_NAME . ' : Edit Question', 'content' => 'content/questionEditForm.php');
         $result['optionFunction'] = $optionFunction;
         $libId = $user['library_id'];
         $result['timeSpentOpts'] = $tsf->findByLibrary($libId);
         $result['patronTypeOpts'] = $ptf->findByLibrary($libId);
         $result['questionTypeOpts'] = $qtf->findByLibrary($libId);
         $result['questionFormatOpts'] = $qff->findByLibrary($libId);
         $result['locationOpts'] = $lf->findByLibrary($libId);
         $result['locationId'] = $lf->getLastLocationId($_SERVER['REMOTE_ADDR'], $libId);
         $result['user'] = $user;
         $questionFinder = new QuestionFinder($db);
         $result['question'] = $questionFinder->getQuestion($questionId);
         $result['answer'] = $questionFinder->getQuestion($questionId);
         $result['delete_hide'] = gpwd('delete_hide');
         $result['origin'] = grwd('origin', 'questionAddForm.do');
     } else {
         echo "QuestionID {$questionId} not found";
         // Send somewere else
     }
     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;
 }
 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;
 }
Example #8
0
<?php

// Better debugging; can't cache the contents of this page
ini_set("display_errors", 1);
header("Cache-Control: no-cache");
$db = $_REQUEST['db'];
var_dump($_REQUEST);
$lookupField = isset($_REQUEST['lookupField']) ? $_REQUEST['lookupField'] : '';
//$datestr = isset($_REQUEST['datestr']) ? $_REQUEST['datestr'] : '';
$lookupField = 3;
$locationFinder = new LocationFinder($db);
$locations = $locationFinder->findByLibrary($lookupField);
var_dump($locations);
?>

<html><head></head>
<?php 
echo "<body onload=\"parent.setOption('{$option}', '{$parsedDateStr}', '{$success}');\">";
//debugging
//echo ("<script type=\"text/javascript\">alert(\"$parserDateStr\");</script");
//echo ('PARSED: ' . $parsedDateStr);
//echo "MONKEY";
?>
</body></html>
 function perform()
 {
     $times = array();
     $start = 0;
     $end = 0;
     $result = array('renderer' => 'template_renderer.inc', 'pageTitle' => SITE_NAME . ' : Add Question', 'content' => 'content/questionAddForm.php');
     // The number of questions and page offset we want
     $count = grwd('count', 50);
     $page = grwd('page', 1);
     $result['count'] = $count;
     $result['page'] = $page;
     // Learn what kind of menus we need
     $layout = grwd('layout', 'menus');
     $optionFunction = array('pulldown' => 'getSelectPulldown', 'radio' => 'getRadioList', 'menus' => 'getSelectBox');
     $result['optionFunction'] = $optionFunction[$layout];
     $db = $_REQUEST['db'];
     $tsf = new TimeSpentFinder($db);
     $ptf = new PatronTypeFinder($db);
     $qff = new QuestionFormatFinder($db);
     $qtf = new QuestionTypeFinder($db);
     $if = new InitialsFinder($db);
     $lf = new LocationFinder($db);
     $userFinder = new UserFinder($db);
     $start = mTimeFloat();
     $user = $userFinder->findById($_SESSION['userId']);
     $end = mTimeFloat();
     $times['userfind'] = $end - $start;
     $clientIp = getRemoteIp();
     $libId = $user['library_id'];
     $start = mTimeFloat();
     $result['timeSpentOpts'] = $tsf->findByLibrary($libId);
     $result['patronTypeOpts'] = $ptf->findByLibrary($libId);
     $result['questionTypeOpts'] = $qtf->findByLibrary($libId);
     $result['questionFormatOpts'] = $qff->findByLibrary($libId);
     $result['locationOpts'] = $lf->findByLibrary($libId);
     $times['menus'] = mTimeFloat() - $start;
     $start = mTimeFloat();
     // Load the default (last used) values for this client
     $result['locationId'] = $lf->getLastLocationId($clientIp, $libId);
     if ($result['locationId'] == null) {
         $result['locationId'] = $result['locationOpts'][0]['location_id'];
     }
     $start = mTimeFloat();
     $result['lastInitials'] = $if->getLastInitials($clientIp);
     $times['lastInitials'] = mTimeFloat() - $start;
     $start = mTimeFloat();
     $result['lastTimeSpent'] = $tsf->getLast($clientIp);
     $times['lastTimeSpent'] = mTimeFloat() - $start;
     $start = mTimeFloat();
     $result['lastPatronType'] = $ptf->getLast($clientIp);
     $times['lastPatronType'] = mTimeFloat() - $start;
     $start = mTimeFloat();
     $result['lastQuestionType'] = $qtf->getLast($clientIp);
     $times['lastQuestionType'] = mTimeFloat() - $start;
     $start = mTimeFloat();
     $result['lastQuestionFormat'] = $qff->getLast($clientIp);
     $times['lastQuestionFormat'] = mTimeFloat() - $start;
     $result['user'] = $user;
     $questionFinder = new QuestionFinder($db);
     $start = mTimeFloat();
     $result['lastAdded'] = $questionFinder->getLastQuestionTime($clientIp, $libId);
     if ($result['lastAdded'] != null) {
         $result['lastAdded'] = date('n/d g:i A', strtotime($result['lastAdded']));
     }
     $times['lastAdded'] = mTimeFloat() - $start;
     $start = mTimeFloat();
     $qResult = $questionFinder->getPagedList($count, $page, 'questions.library_id = ?', array((int) $libId));
     $result['questionList'] =& $qResult['list'];
     $result['list_meta'] = $qResult['meta'];
     $result['questionCount'] = $qResult['meta']['totalQuestions'];
     $result['nonemptyQuestionCount'] = $qResult['meta']['nonemptyQuestions'];
     $times['getQuestions'] = mTimeFloat() - $start;
     $origin = "questionAddForm.do?page=" . $result['page'] . "&amp;count=" . $result['count'];
     $result['origin'] = $origin;
     $result['target'] = 'questionAddForm.do';
     // Disabled debugging output
     // echo "<!-- ";
     // var_dump($times);
     // echo " -->";
     return $result;
 }