Пример #1
0
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy)
 {
     parent::__construct(page_ViewGroups::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     //Get person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $this->personID = $accessManager->getPersonID();
     echo "ViewerID: " . $this->viewer->getViewerID() . " <br>personID: " . $this->personID . "<br>";
     /*
      * The code below contains the different permission cases for view groups.
      * 
      * Check 1 = check if the user is a SUPER ADMIN
      * Check 2 = check if the user is a STAFF and which campuses he/she is assigned to, taken from HRDB
      * Check 3 =check cim_sch_permissionCampusAdmin for which CAMPUSES this user is ADMIN for
      * Check 4 = check cim_sch_permissionGroupAdmin for which GROUPS this user is ADMIN for
      * If check 1-4 FAIL then ViewGroup will show nothing. (This user is a normal user and have not created any groups .
      */
     $multiTableManager = new MultiTableManager();
     $groupManager = new RowManager_GroupManager();
     $superAdminManager = new RowManager_PermissionsSuperAdminManager();
     //SUPER ADMIN
     //Check if user's Viewer_id is in the PermissionSuperAdmin table
     if ($superAdminManager->loadByViewerID($this->viewer->getViewerID())) {
         // the viewer is a super admin
         echo "ViewerID[" . $this->viewer->getViewerID() . "] is a super admin<br/>";
         $campusGroupManager = new RowManager_CampusGroupManager();
         $multiTableManager->addRowManager($groupManager);
         $multiTableManager->addRowManager($campusGroupManager, new JoinPair($campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_LEFT));
     } else {
         //STAFF
         // This array stores all the campuses associated to the user.
         //This array is continually populated
         $campusArray = array();
         //check HRDB if the user is a staff
         $assignmentManager = new RowManager_AssignmentsManager();
         $assignmentManager->setPersonID($this->personID);
         $assignmentManager->setAssignmentStatus(CA_STAFF);
         $assList = new ListIterator($assignmentManager);
         $assList->setFirst();
         while ($assList->moveNext()) {
             $assMan = $assList->getCurrent(new RowManager_AssignmentsManager());
             //for each campuses found, store in array
             $campusArray[] = $assMan->getCampusID();
         }
         //CAMPUS ADMIN
         //Check cim_sch_permissionsCampusAdmin for the viewer id of the user
         $permissionsCampusAdmin = new RowManager_PermissionsCampusAdminManager();
         $permissionsCampusAdmin->setViewerID($this->viewer->getViewerID());
         $campusAdminList = new ListIterator($permissionsCampusAdmin);
         $campusAdminList->setFirst();
         while ($campusAdminList->moveNext()) {
             $permCampus = $campusAdminList->getCurrent(new RowManager_PermissionsCampusAdminManager());
             //for each campuses found, store in array
             $campusArray[] = $permCampus->getCampusID();
         }
         //remove any duplicate campus ID in the array
         $campusArray = array_unique($campusArray);
         //GROUP ADMIN
         $permissionsGroupAdminManager = new RowManager_PermissionsGroupAdminManager();
         $campusGroupManager = new RowManager_CampusGroupManager();
         //send a list of campues and the viewer ID to constrict the search condition
         //The Viewer_id is use to check the cim_sch_permissionsGroupAdmin table for
         // groups that were created by the user
         $searchCond = $campusGroupManager->returnSearchCondition($campusArray, $this->viewer->getViewerID());
         //create the appropriate join between 3 tables
         //Join cim_sch_group and cim_sch_permissionsGroupAdmin and cim_sch_campusGroup
         $multiTableManager->addRowManager($groupManager);
         $multiTableManager->addRowManager($campusGroupManager, new JoinPair($campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_LEFT));
         $multiTableManager->addRowManager($permissionsGroupAdminManager, new JoinPair($permissionsGroupAdminManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_LEFT));
         $multiTableManager->addSearchCondition($searchCond);
     }
     /*Case 3: Group Admin - access to an individual group and can create other group admins 
     				(ex. DGL)
     				Normal User - can only submit schedule, assume this unless given other permissions
     					Check the group admin table 
     	
     				check cim_sch_permissiongroupadmin -> cim_sch_campusgroup -> cim_sch_group
     				filter on viewer id 
     
     
     		Case 4: All staff - implicit access to all groups on all campuses where their status is staff 
     				check cim_hrdb_staff table
     					if true
     						get all campuses from cim_hrdb_assignment where assignment status id = 3
     
     
             */
     /*$groupManager = new RowManager_GroupManager();
       $multiTableManager = new MultiTableManager();
       
       $campusGroupManager = new RowManager_CampusGroupManager();
       
       $multiTableManager->addRowManager( $campusGroupManager );
       $multiTableManager->addRowManager( $groupManager, new JoinPair( $campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_RIGHT ) );*/
     // $dataAccessObject = $multiTableManager;
     $multiTableManager->setSortOrder('campus_id');
     //******Not sure this is the way to do it*****
     //       $this->listManager = new GroupList( $sortBy );
     $this->listManager = $multiTableManager->getListIterator();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_sch::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_sch::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_ViewGroups::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // Uncomment the following line if you want to create a template
     // tailored for this page:
     $path = $this->pathModuleRoot . 'templates/';
     // Otherwise use the standard Templates for the site:
     //$path = SITE_PATH_TEMPLATES;
     // The weeks
     $weekManager = new RowManager_WeekManager();
     $weekManager->setSemesterID($this->semester_id);
     $weekManager->setSortByDate();
     $staffArray = array();
     // figure out all the people we want to report on
     $isCD = $this->permManager->isCD();
     if ($isCD) {
         // get all the people from this campus who have reported stats
         $wklyReportManager = new RowManager_WeeklyReportManager();
         $wklyReportManager->setCampusID($this->campus_id);
         $anotherWeekManager = new RowManager_WeekManager();
         $anotherWeekManager->setSemesterID($this->semester_id);
         $multiTableManager = new MultiTableManager();
         $multiTableManager->addRowManager($wklyReportManager);
         $multiTableManager->addRowManager($anotherWeekManager, new JoinPair($wklyReportManager->getJoinOnWeekID(), $anotherWeekManager->getJoinOnWeekID()));
         $this->listIterator = $multiTableManager->getListIterator();
         $this->listIterator->setFirst();
         while ($this->listIterator->moveNext()) {
             $reportRow = $this->listIterator->getCurrent(new RowManager_WeeklyReportManager());
             $staffArray[] = $reportRow->getStaffID();
         }
         $staffArray = array_unique($staffArray);
         // echo '<pre>'.print_r($staffArray, true).'</pre>';
     } else {
         // just get the stats for the staff viewing the page
         $staffArray[] = $this->staff_id;
     }
     $infoArray = array();
     foreach ($staffArray as $indx => $staffID) {
         //IndSemesterInfo
         $indInfo = new IndSemesterInfo();
         $staffManager = new RowManager_StaffManager($staffID);
         $personID = $staffManager->getPersonID();
         $personManager = new RowManager_PersonManager($personID);
         $personManager->setLabelTemplateLastNameFirstName();
         $indInfo->staffName = $personManager->getLabel();
         $indInfo->staffID = $staffID;
         // calendar
         $indInfo->calendar = array();
         $currentMonth = 0;
         // actual data
         // dataArray[weekID] = arrayOfData
         $indInfo->dataArray = array();
         $weekList = new ListIterator($weekManager);
         $weekList->setFirst();
         while ($weekList->moveNext()) {
             $week = $weekList->getCurrent(new RowManager_WeekManager());
             $weekID = $week->getID();
             // setup stuff for the calendar in the report
             $endDate = $week->getEndDate();
             list($year, $month, $day) = explode('-', $endDate);
             $month = ltrim($month, "0");
             // $day = ltrim($day, "0");
             if ($currentMonth != $month) {
                 // echo 'start new array<br/>';
                 $currentMonth = $month;
             }
             $indInfo->calendar[$currentMonth][$day] = $weekID;
             // end calendar stuff
             // check if an entry exists in the table for
             $weeklyReport = new RowManager_WeeklyReportManager($weekID, $staffID, $this->campus_id);
             if ($weeklyReport->isLoaded()) {
                 // echo $week->getEndDate() . ' loaded <br/>';
                 $indInfo->dataArray[$weekID] = $weeklyReport->getArrayOfValues();
                 // echo '<pre>'.print_r( $weeklyReport->getArrayOfValues() ).'</pre>';
             } else {
                 $indInfo->dataArray[$weekID] = null;
                 // echo $week->getEndDate() . ' NOT loaded <br/>';
             }
         }
         // echo '<pre>'.print_r($calendar,true).'</pre>';
         $infoArray[] = $indInfo;
     }
     /*
      * Update any label tags ...
      */
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     $campusJumpLinkSelectedValue = $this->linkValues['campusJumpLink'] . $this->campus_id;
     $semesterJumpLinkSelectedValue = $this->linkValues['semesterJumpLink'] . $this->semester_id;
     // NOTE:  this parent method prepares the $this->template with the
     // common Display data.
     $this->prepareTemplate($path);
     // $this->template->set( 'calendar', $calendar );
     // $this->template->set( 'dataArray', $dataArray );
     $this->template->set('infoArray', $infoArray);
     $this->template->set('campusJumpLinkSelectedValue', $campusJumpLinkSelectedValue);
     $this->template->set('semesterJumpLinkSelectedValue', $semesterJumpLinkSelectedValue);
     // campus list
     $jumpLink = $this->linkValues['campusJumpLink'];
     $campusArray = array();
     $this->campusListIterator->setFirst();
     while ($this->campusListIterator->moveNext()) {
         $campusObject = $this->campusListIterator->getCurrent(new RowManager_CampusManager());
         $region_id = $campusObject->getRegionID();
         if ($region_id == 1 || $region_id == 2 || $region_id == 3) {
             $campusArray[$jumpLink . $campusObject->getID()] = $campusObject->getLabel();
         }
     }
     // echo '<pre>'.print_r($campusArray, true ).'</pre>';
     $this->template->set('list_campus_id', $campusArray);
     // semester list
     $jumpLink = $this->linkValues['semesterJumpLink'];
     $semesterArray = array();
     $semesterManager = new RowManager_SemesterManager();
     $this->semesterListIterator = $semesterManager->getListIterator();
     $this->semesterListIterator->setFirst();
     while ($this->semesterListIterator->moveNext()) {
         $semesterObject = $this->semesterListIterator->getCurrent(new RowManager_SemesterManager());
         $semesterArray[$jumpLink . $semesterObject->getID()] = $semesterObject->getLabel();
     }
     // echo '<pre>'.print_r($campusArray, true ).'</pre>';
     $this->template->set('list_semester_id', $semesterArray);
     // uncomment this line if you are creating a template for this page
     $templateName = 'page_StaffSemesterReport.php';
     // otherwise use the generic site template
     //$templateName = '';
     return $this->template->fetch($templateName);
 }
Пример #3
0
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // Uncomment the following line if you want to create a template
     // tailored for this page:
     $path = $this->pathModuleRoot . 'templates/';
     // Otherwise use the standard Templates for the site:
     //$path = SITE_PATH_TEMPLATES;
     // NOTE:  this parent method prepares the $this->template with the
     // common Form data.
     $this->prepareTemplate($path);
     // TODO: when implementing staff-specific stats reporting,
     //       refer to page_StaffSemesterReport.php in app_cim_stats module
     /** The frequency values (weeks, days,.. whatever was chosen) **/
     //this->freqValManager;
     //         $infoArray = array();
     $statNames = array();
     //ReportInfo
     $statReportInfo = new ReportInfo();
     /*** Determine which frequency is acting as the parent frequency (i.e. month is parent of week) **/
     $freqType = new RowManager_FreqTypeManager($this->freq_id);
     //              $freqType->setFreqID($this->freq_id);
     $freqTypeList = $freqType->getListIterator();
     $freqTypeArray = $freqTypeList->getDataList();
     // should be only 1 match for the frequency ID
     $parent_freq_id = '';
     $date_field_id = '';
     if (count($freqTypeArray) == 1) {
         $record = current($freqTypeArray);
         $parent_freq_id = $record['freq_parent_freq_id'];
         $date_field_id = $record['freq_parent_date_field_index'] - 1;
         //IMPORTANT: database stores 1-based index (to allow 0 default)
         //              echo ' freqTypeArray = <pre>'.print_r($freqTypeArray,true).'</pre>';
         // 	             echo ' dateFieldValues = <pre>'.print_r($dateFieldValues,true).'</pre>';
         //             	 echo ' date field index = '.$date_field_id;
     }
     $parentDateValues = array();
     $parentIndex = 0;
     // calendar
     $statReportInfo->calendar = array();
     $currentParentFreqVal = 0;
     // i.e. could be default starting month value if child stat is 'weekly'
     // actual data
     // dataArray[freqValID] = arrayOfData
     $statReportInfo->dataArray = array();
     $freqValList = new ListIterator($this->freqValManager);
     $freqValList->setFirst();
     while ($freqValList->moveNext()) {
         // TODO: check if below filters properly based on $this->freqValManager
         $freqVal = $freqValList->getCurrent(new RowManager_FreqValueManager());
         // i.e. week for weekly stats
         $freqValID = $freqVal->getID();
         // i.e. weekID for weekly stats
         // setup stuff for the calendar in the report
         $freqVal_dateTime = $freqVal->getFreqValue();
         // i.e. getEndDate for weekly stats in app_cim_stats
         $freqVal_date = substr($freqVal_dateTime, 0, 10);
         $freqVal_time = substr($freqVal_dateTime, 10);
         //              list( $year, $month, $day ) = explode('-', $freqVal_date );
         $dateFieldValues = explode('-', $freqVal_date);
         $timeFieldValues = explode(':', $freqVal_time);
         //              $month = ltrim($month, "0");		// strips '0's from in front of $month...
         // $day = ltrim($day, "0");
         $dateTimeValues = array_merge($dateFieldValues, $timeFieldValues);
         $parentDateFieldVal = 0;
         if (isset($dateFieldValues) && $date_field_id >= 0) {
             $parentDateFieldVal = $dateFieldValues[$date_field_id];
         }
         if ($currentParentFreqVal != $parentDateFieldVal) {
             // echo 'start new array<br/>';
             $currentParentFreqVal = $parentDateFieldVal;
         }
         //              echo 'parent val = '.$currentParentFreqVal;
         //              $currentParentFreqVal = ltrim($currentParentFreqVal,"0");	// trim any leading zeroes
         $parentDateValues[$parentIndex] = $currentParentFreqVal;
         $currentFreqVal = $dateTimeValues[$date_field_id + 1];
         // i.e. current freq = (some) hour if the parent = (some) day
         $statReportInfo->calendar[$currentParentFreqVal][$currentFreqVal] = $freqValID;
         // i.e. calendar[month][day] = $weekID
         // end calendar stuff
         // check if an entry exists in the stat values table for the current freq. value
         $this->dataManager->clearValues();
         $this->dataManager->setFreqValueID($freqValID);
         $statsManager = new RowManager_StatisticManager();
         $freqVal_statVals = new MultiTableManager();
         $freqVal_statVals->addRowManager($this->dataManager);
         $freqVal_statVals->addRowManager($statsManager, new JoinPair($statsManager->getJoinOnStatID(), $this->dataManager->getJoinOnStatID()));
         $statValsList = $freqVal_statVals->getListIterator();
         $statValsArray = $statValsList->getDataList();
         // retrieve stat values associated with some freq val (used for display)
         $stat_name = '';
         $stat_val = '';
         $freqValStatValsArray = array();
         //              echo '<br>stat vals array <pre>'.print_r( $statValsArray,true ).'</pre>';
         reset($statValsArray);
         foreach (array_keys($statValsArray) as $key) {
             $record = current($statValsArray);
             $stat_name = $record['statistic_name'];
             $stat_val = $record['statvalues_value'];
             // re-package array into simpler form for list display use
             $freqValStatValsArray[$stat_name] = $stat_val;
             next($statValsArray);
         }
         if (count($freqValStatValsArray) > 0) {
             $statReportInfo->dataArray[$freqValID] = $freqValStatValsArray;
             //                   echo 'freq val stat vals array: <pre>'.print_r( $freqValStatValsArray,true ).'</pre>';
         } else {
             $statReportInfo->dataArray[$freqValID] = null;
         }
         $parentIndex++;
     }
     //          echo 'calendar = <pre>'.print_r($statReportInfo->calendar,true).'</pre>';
     //          $infoArray[] = $statReportInfo;
     /*
      * Update any label tags ...
      */
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     //         $campusJumpLinkSelectedValue = $this->linkValues['campusJumpLink'].$this->campus_id;
     //         $semesterJumpLinkSelectedValue = $this->linkValues['semesterJumpLink'].$this->semester_id;
     //
     // 			$this->template->set( 'calendar', $calendar );
     // 			$this->template->set( 'dataArray', $dataArray );
     //         $this->template->set( 'infoArray', $infoArray );
     $this->template->set('statReportInfo', $statReportInfo);
     // 		echo '<br> stat report: <pre>'.print_r($statReportInfo,true).'</pre>';
     $this->template->set('statsArray', $this->stat_names_array);
     // need to create a static array of parent frequency values (i.e. like list of months as headers for week values)
     $parent_freqs_array = array();
     if (isset($parent_freq_id) && $parent_freq_id > 0) {
         $parentFreqValues = new RowManager_FreqValueManager();
         $parentFreqValues->setFreqID($parent_freq_id);
         $parentFreqValuesList = $parentFreqValues->getListIterator();
         $parentFreqValuesArray = $parentFreqValuesList->getDataList();
         $i = 0;
         reset($parentFreqValuesArray);
         foreach (array_keys($parentFreqValuesArray) as $key) {
             $record = current($parentFreqValuesArray);
             //              $date_field_value = $parentDateValues[$i];
             //              echo "date field = ".$date_field_value;
             //              echo "record = ".$record['freqvalue_desc'];
             //              if ($date_field_value ==  $record['freqvalue_desc'])
             //              {
             //              	$parent_freqs_array[$date_field_value] = $record['freqvalue_desc'];
             //              	$i++;
             //           	 }
             $freqVal_dateTime = $record['freqvalue_value'];
             $freqVal_date = substr($freqVal_dateTime, 0, 10);
             $freqVal_time = substr($freqVal_dateTime, 10);
             $dateFieldValues = explode('-', $freqVal_date);
             $timeFieldValues = explode(':', $freqVal_time);
             $dateTimeValues = array_merge($dateFieldValues, $timeFieldValues);
             // setup array to have date field value (i.e. one of YYYY, MM, DD, HH, min, sec   values) as index
             // the value is the frequency type description (i.e. 'January' for MM = 01)
             $parent_freqs_array[$dateFieldValues[$date_field_id]] = $record['freqvalue_desc'];
             next($parentFreqValuesArray);
         }
         //            echo "parent freqs = <pre>".print_r($parent_freqs_array,true)."</pre>";
         $this->template->set('parentFreqArray', $parent_freqs_array);
         // //           echo 'parent freq id = '.$parent_freq_id;
         // // 			 echo 'parent freq array = <pre>'.print_r($parent_freqs_array, true).'</pre>';
     }
     // setup stuff for the calendar in the report
     $freqVal_dateTime = $freqVal->getFreqValue();
     // i.e. getEndDate for weekly stats in app_cim_stats
     $freqVal_date = substr($freqVal_dateTime, 0, 10);
     $freqVal_time = substr($freqVal_dateTime, 10);
     //              list( $year, $month, $day ) = explode('-', $freqVal_date );
     $dateFieldValues = explode('-', $freqVal_date);
     $timeFieldValues = explode(':', $freqVal_time);
     //              $month = ltrim($month, "0");		// strips '0's from in front of $month...
     // $day = ltrim($day, "0");
     $dateTimeValues = array_merge($dateFieldValues, $timeFieldValues);
     $parentDateFieldVal = 0;
     if (isset($dateFieldValues) && $date_field_id >= 0) {
         $parentDateFieldVal = $dateFieldValues[$date_field_id];
     }
     if ($currentParentFreqVal != $parentDateFieldVal) {
         // echo 'start new array<br/>';
         $currentParentFreqVal = $parentDateFieldVal;
     }
     //              echo 'parent val = '.$currentParentFreqVal;
     $currentParentFreqVal = ltrim($currentParentFreqVal, "0");
     // trim any leading zeroes
     $parentDateValues[$parentIndex] = $currentParentFreqVal;
     // Go through scope array and set template scope names for the scopes that were user-selected
     foreach (array_keys($this->scope_ref_array) as $scope_id) {
         $scope_ref_id = current($this->scope_ref_array);
         if ($scope_ref_id > 0) {
             switch ($scope_id) {
                 case RowManager_ScopeManager::SCOPE_MINISTRY:
                     $ministries = new RowManager_MinistryManager($scope_ref_id);
                     $ministryList = $ministries->getListIterator();
                     $ministryArray = $ministryList->getDataList();
                     $record = current($ministryArray);
                     $ministryName = $record['ministry_name'];
                     $this->template->set('ministryName', $ministryName);
                     break;
                 case RowManager_ScopeManager::SCOPE_DIVISION:
                     $divisions = new RowManager_DivisionManager($scope_ref_id);
                     $divList = $divisions->getListIterator();
                     $divArray = $divList->getDataList();
                     $record = current($divArray);
                     $divisionName = $record['division_name'];
                     $this->template->set('divisionName', $divisionName);
                     break;
                 case RowManager_ScopeManager::SCOPE_REGION:
                     $regions = new RowManager_StatsRegionManager($scope_ref_id);
                     $regionList = $regions->getListIterator();
                     $regionArray = $regionList->getDataList();
                     $record = current($regionArray);
                     $regionName = $record['region_desc'];
                     $this->template->set('regionName', $regionName);
                     break;
                 case RowManager_ScopeManager::SCOPE_LOCATION:
                     $locations = new RowManager_LocationManager($scope_ref_id);
                     $locationList = $locations->getListIterator();
                     $locationArray = $locationList->getDataList();
                     $record = current($locationArray);
                     $locationName = $record['location_desc'];
                     $this->template->set('locationName', $locationName);
                     break;
             }
         }
         next($this->scope_ref_array);
     }
     /** Retrieve values for  $freqDesc   and   $measName **/
     $freqTypes = new RowManager_FreqTypeManager();
     $freqTypes->setFreqID($this->freq_id);
     $freqList = $freqTypes->getListIterator();
     $freqArray = $freqList->getDataList();
     $freqDesc = '';
     if (count($freqArray) == 1) {
         $record = current($freqArray);
         $freqDesc = $record['freq_desc'];
     }
     $measTypes = new RowManager_MeasureTypeManager();
     $measTypes->setMeasureID($this->meas_id);
     $measList = $measTypes->getListIterator();
     $measArray = $measList->getDataList();
     $measName = '';
     if (count($measArray) == 1) {
         $record = current($measArray);
         $measName = $record['meas_name'];
     }
     // set [Instr] label value replacement values
     //       $instrVars = $freqDesc.','.$measName;
     //       $this->template->set('instrVars', $instrVars);
     $this->template->set('measName', $measName);
     $this->template->set('freqName', $freqDesc);
     $calcList = $this->calcManager->getListIterator();
     $calcArray = $calcList->getDataList();
     reset($calcArray);
     $calcNames = array();
     $i = 0;
     foreach (array_keys($calcArray) as $key) {
         $record = current($calcArray);
         $calcNames[$i] = $record['filter_name'];
         next($calcArray);
         $i++;
     }
     // set the additional calculation values (i.e. 'Total', 'Average', etc)
     $this->template->set('calcNames', $calcNames);
     // uncomment this line if you are creating a template for this page
     $templateName = 'page_StatsReport.tpl.php';
     // otherwise use the generic site template
     //$templateName = '';
     return $this->template->fetch($templateName);
 }
Пример #4
0
 /**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // Uncomment the following line if you want to create a template
     // tailored for this page:
     $path = $this->pathModuleRoot . 'templates/';
     // Otherwise use the standard Templates for the site:
     //$path = SITE_PATH_TEMPLATES;
     /*
      * Update any label tags ...
      */
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     // do the join
     // campuses
     $campusManager = new RowManager_CampusManager();
     $campusManager->setSortOrder('campus_desc');
     $multiTableManager = new MultiTableManager();
     $multiTableManager->addRowManager($campusManager);
     // prcs
     $prcManager = new RowManager_PRCManager();
     $multiTableManager->addRowManager($prcManager, new JoinPair($campusManager->getJoinOnCampusID(), $prcManager->getJoinOnCampusID()));
     // semester
     $semesterManager = new RowManager_SemesterManager();
     // TODO update the semester
     $semesterManager->setSemesterID(1);
     $multiTableManager->addRowManager($semesterManager, new JoinPair($prcManager->getJoinOnSemesterID(), $prcManager->getJoinOnSemesterID()));
     // prc method
     $prcMethodManager = new RowManager_PrcMethodManager();
     $multiTableManager->addRowManager($prcMethodManager, new JoinPair($prcManager->getJoinOnPrcMethodID(), $prcMethodManager->getJoinOnPrcMethodID()));
     // get ready to make the xml
     $xmlObject = new XMLObject();
     // HEADER
     //$reportInfoXMLObject = new XMLObject('PRC_REPORT');
     //$xmlObject->addXMLObject( $reportInfoXMLObject );
     // END HEADER
     // BODY
     $bodyXMLObject = new XMLObject('PRC_FOR_SEMESTER');
     // construct the iterator
     $list = new ListIterator($multiTableManager);
     $list->setFirst();
     while ($list->moveNext()) {
         $itemXMLObject = $list->getCurrentRowXMLObject(false, 'IndividualPRC');
         // Finally add this row into the bigger picture
         $bodyXMLObject->addXMLObject($itemXMLObject);
     }
     // multiTableManager->moveNext()
     $xmlObject->addXMLObject($bodyXMLObject);
     $xmlDoc = new DOMDocument();
     $xmlDoc->loadXML($xmlObject->getXML(false, 'PRCReport'));
     $numBytesWritten = $xmlDoc->save($this->pathModuleRoot . 'prcReport.xml');
     // echo 'Written '.$numBytesWritten.' bytes';
     // save the xml data onto the server
     // return $xmlDoc->saveXML();
     // ------- PART 2 --------
     // WEEKLY STATS
     $multiTableManager = new MultiTableManager();
     $weeklyManager = new RowManager_WeeklyReportManager();
     $multiTableManager->addRowManager($weeklyManager);
     $campusManager = new RowManager_CampusManager();
     $campusManager->setSortOrder('campus_desc');
     $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $weeklyManager->getJoinOnCampusID()));
     $weekManager = new RowManager_WeekManager();
     $multiTableManager->addRowManager($weekManager, new JoinPair($weekManager->getJoinOnWeekID(), $weeklyManager->getJoinOnWeekID()));
     $staffManager = new RowManager_StaffManager();
     $multiTableManager->addRowManager($staffManager, new JoinPair($weeklyManager->getJoinOnStaffID(), $staffManager->getJoinOnStaffID()));
     $personManager = new RowManager_PersonManager();
     $multiTableManager->addRowManager($personManager, new JoinPair($personManager->getJoinOnPersonID(), $staffManager->getJoinOnPersonID()));
     // get ready to make the xml
     $xmlObject = new XMLObject();
     // HEADER
     //$reportInfoXMLObject = new XMLObject('PRC_REPORT');
     //$xmlObject->addXMLObject( $reportInfoXMLObject );
     // END HEADER
     // BODY
     $bodyXMLObject = new XMLObject('WEEKLY_FOR_SEMESTER');
     // construct the iterator
     $list = new ListIterator($multiTableManager);
     $list->setFirst();
     while ($list->moveNext()) {
         $itemXMLObject = $list->getCurrentRowXMLObject(false, 'IndividualWeek');
         // Finally add this row into the bigger picture
         $bodyXMLObject->addXMLObject($itemXMLObject);
     }
     // multiTableManager->moveNext()
     $xmlObject->addXMLObject($bodyXMLObject);
     $xmlDoc = new DOMDocument();
     $xmlDoc->loadXML($xmlObject->getXML(false, 'Report'));
     $numBytesWritten = $xmlDoc->save($this->pathModuleRoot . 'weeklyReport.xml');
     // echo 'Written '.$numBytesWritten.' bytes';
     // save the xml data onto the server
     // return $xmlDoc->saveXML();
     // ------- PART 3 --------
     $multiTableManager = new MultiTableManager();
     $campusStatsManager = new RowManager_MoreStatsManager();
     $multiTableManager->addRowManager($campusStatsManager);
     $campusManager = new RowManager_CampusManager();
     $campusManager->setSortOrder('campus_desc');
     $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $campusStatsManager->getJoinOnCampusID()));
     $weekManager = new RowManager_WeekManager();
     $multiTableManager->addRowManager($weekManager, new JoinPair($campusStatsManager->getJoinOnWeekID(), $weekManager->getJoinOnWeekID()));
     $expTypeManager = new RowManager_ExposureTypeManager();
     $multiTableManager->addRowManager($expTypeManager, new JoinPair($campusStatsManager->getJoinOnExpTypeID(), $expTypeManager->getJoinOnExpTypeID()));
     $count = 0;
     // get ready to make the xml
     $xmlObject = new XMLObject();
     // HEADER
     //$reportInfoXMLObject = new XMLObject('PRC_REPORT');
     //$xmlObject->addXMLObject( $reportInfoXMLObject );
     // END HEADER
     // BODY
     $bodyXMLObject = new XMLObject('CAMPUS_REPORT');
     // construct the iterator
     $list = new ListIterator($multiTableManager);
     $list->setFirst();
     while ($list->moveNext()) {
         $itemXMLObject = $list->getCurrentRowXMLObject(false, 'Activity');
         $count++;
         // Finally add this row into the bigger picture
         $bodyXMLObject->addXMLObject($itemXMLObject);
     }
     // multiTableManager->moveNext()
     echo 'the count is [' . $count . ']<br/>';
     $xmlObject->addXMLObject($bodyXMLObject);
     $xmlDoc = new DOMDocument();
     $xmlDoc->loadXML($xmlObject->getXML(false, 'Report'));
     $numBytesWritten = $xmlDoc->save($this->pathModuleRoot . 'campusReport.xml');
     // echo 'Written '.$numBytesWritten.' bytes';
     // save the xml data onto the server
     // return $xmlDoc->saveXML();
     // ---------------
     // OK DONE!
     // NOTE:  this parent method prepares the $this->template with the
     // common Display data.
     $this->prepareTemplate($path);
     // uncomment this line if you are creating a template for this page
     $templateName = 'page_Reports.php';
     // otherwise use the generic site template
     //$templateName = '';
     return $this->template->fetch($templateName);
 }
Пример #5
0
 function getScheduleData()
 {
     //The array to be send
     $timeBlocksArray = array();
     if ($this->scheduleID < 1) {
         print "No Schedule found for your ID";
         $timeBlocksArray = null;
     } else {
         //Returns a row of the database with the scheduleID
         $scheduleBlocksManager = new RowManager_ScheduleBlocksManager();
         $scheduleBlocksManager->setScheduleID($this->scheduleID);
         //Go through the row returned
         $scheduleBlocksList = new ListIterator($scheduleBlocksManager);
         $scheduleBlocksList->setFirst();
         $timeBlock = -1;
         while ($scheduleBlocksList->moveNext()) {
             //get the time block in that row
             $blocksManager = $scheduleBlocksList->getCurrent(new RowManager_ScheduleBlocksManager());
             $timeBlock = $blocksManager->getTimeBlock();
             //save the timeblock to the array and keep looping to get all of them
             $timeBlocksArray[] = $timeBlock;
         }
     }
     //Pass the data to the template for display
     return $this->template->set('timeBlocksArray', $timeBlocksArray);
 }