Пример #1
0
  * statvalues_modtime [DATE]  the time of the value's insertion/modification
  * person_id [INTEGER]  the id of the person who entered the stat value
  */
 $StatisticValue = new RowManager_StatValueManager();
 $StatisticValue->dropTable();
 $StatisticValue->createTable();
 /*
  * MeasurementType Table
  *
  * Stores a stats measurement type (i.e. 'Personal Ministry')
  *
  * meas_id [INTEGER]  the unique identifier
  * meas_name [STRING]  the name of the Measurement Type
  * meas_desc [STRING]  The Measurement Type description
  */
 $MeasurementType = new RowManager_MeasureTypeManager();
 $MeasurementType->dropTable();
 $MeasurementType->createTable();
 /*
  * Scope Table
  *
  * stores a statistic scope (i.e. Ministry, Region, etc)
  *
  * scope_id [INTEGER]  the object's unique identifier
  * scope_name [STRING]  the name of the Scope
  * scope_reftable [STRING]  the particular scope's reference table (i.e. p2c_stats_ministry)
  */
 $Scope = new RowManager_ScopeManager();
 $Scope->dropTable();
 $Scope->createTable();
 /*
Пример #2
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);
 }
 /**
  * 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;
     // temporarily reset the form values so the defaults show up properly in the jumplists
     $this->formValues['scope_id'] = $this->linkValues['scopeJumpLink'] . $this->scope_id;
     /*
      * store the link values
      */
     // example:
     // $this->linkValues[ 'view' ] = 'add/new/href/data/here';
     // store the link labels
     $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]');
     $this->linkLabels['del'] = $this->labels->getLabel('[Delete]');
     $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]');
     // $this->linkLabels[ 'view' ] = 'new link label here';
     /*
      * store any additional link Columns
      */
     // example:
     //$title = $this->labels->getLabel( '[title_groups]');
     //$columnLabel = $this->labels->getLabel( '[groups]');
     //$link = $this->linkValues[ 'groups' ];
     //$fieldName = 'accessgroup_id';
     //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName);
     /*
      * Update any label tags ...
      */
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     // NOTE:  this parent method prepares the $this->template with the
     // common AdminBox data.
     $this->prepareTemplate($path);
     // store the statevar id to edit
     $this->template->set('editEntryID', $this->statistic_id);
     // store all the fields to the template
     $this->setFormFieldsToTemplate();
     /*
      * Form related Template variables:
      */
     $jumpLink = $this->linkValues['scopeJumpLink'];
     $scope = new RowManager_ScopeManager();
     //           $scope->setScopeID( $this->scope_id );
     $scope->setSortOrder('scope_id');
     $scopeList = new ListIterator($scope);
     $scopeArray = $scopeList->getDropListArray(null, $jumpLink);
     //added jumplink
     $this->template->set('list_scope_id', $scopeArray);
     /*** USE JUMP/CHANGE-LIST TO GET THE CHOSEN SCOPE ID ***/
     /** THEN CREATE A DROP-LIST WITH APPROPRIATE VALUES (i.e. Regions for scope 'Region') **/
     // switch (SCOPE)
     $scopeRefs = $this->scope_ref_manager;
     //new RowManager_ScopeManager();
     //         $scope->setScopeID( $this->scope_id );
     //         $scope->setSortOrder( 'scope_id' );
     $scopeRefsList = new ListIterator($scopeRefs);
     $scopeRefsArray = $scopeRefsList->getDropListArray();
     $this->template->set('list_scope_ref_id', $scopeRefsArray);
     $statDataType = new RowManager_StatDataTypeManager();
     $statDataType->setSortOrder('statistic_type_id');
     $statDataTypeList = new ListIterator($statDataType);
     $dataTypes = $statDataTypeList->getDropListArray();
     $this->template->set('list_statistic_type_id', $dataTypes);
     $freqType = new RowManager_FreqTypeManager();
     $freqType->setFreqID($this->freq_id);
     $freqType->setSortOrder('freq_id');
     $freqTypeList = new ListIterator($freqType);
     $freqTypeArray = $freqTypeList->getDropListArray();
     $this->template->set('list_freq_id', $freqTypeArray);
     $measType = new RowManager_MeasureTypeManager();
     $measType->setMeasureID($this->meas_id);
     $measType->setSortOrder('meas_id');
     $measTypeList = new ListIterator($measType);
     $measTypeArray = $measTypeList->getDropListArray();
     $this->template->set('list_meas_id', $measTypeArray);
     /*
      * Insert the date start/end values for the following date fields:
      */
     // example:
     //$this->template->set( 'startYear_[fieldName]', 2000);
     //$this->template->set( 'endYear_[fieldName]', 2010);
     /*
      * List related Template variables :
      */
     // Store the XML Node name for the Data Access Field List
     $xmlNodeName = RowManager_StatisticManager::XML_NODE_NAME;
     $this->template->set('rowManagerXMLNodeName', $xmlNodeName);
     // store the primary key field name for the data being displayed
     $this->template->set('primaryKeyFieldName', 'statistic_id');
     // store data list to the template
     // NOTE: we initialize it here to make sure we capture any new data
     // from a recent processData() call.
     $dataAccessManager = new RowManager_StatisticManager();
     $dataAccessManager->setSortOrder($this->sortBy);
     //        $this->dataList = new StatisticList( $this->sortBy );
     $this->dataList = $dataAccessManager->getListIterator();
     $this->template->setXML('dataList', $this->dataList->getXML());
     /*
      * Add any additional data required by the template here
      */
     $templateName = 'page_EditStatistic.tpl.php';
     //'siteFormDataList.php';
     // if you are creating a custom template for this page then
     // replace $templateName with the following:
     //$templateName = 'page_EditStatistic.php';
     return $this->template->fetch($templateName);
 }
 /**
  * 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;
     // temporarily reset the form values so the defaults show up properly in the jumplists
     $this->formValues['ministry_id'] = $this->linkValues['ministryJumpLink'] . $this->ministry_id;
     $this->formValues['division_id'] = $this->linkValues['divisionJumpLink'] . $this->division_id;
     $this->formValues['region_id'] = $this->linkValues['regionJumpLink'] . $this->region_id;
     // store the page labels in XML format...
     // NOTE: use this location to update any label tags ...
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     // NOTE:  this parent method prepares the $this->template with the
     // common Form data.
     $this->prepareTemplate($path);
     //         echo "POST = <pre>".print_r($_POST,true)."</pre>";
     /*
      * Form related Template variables:
      */
     // store the button label
     $this->template->set('buttonText', $this->labels->getLabel('[Update]'));
     // Insert the date start/end values for the following date fields:
     // example:
     //$this->template->set( 'startYear_[fieldName]', 2000);
     //$this->template->set( 'endYear_[fieldName]', 2010);
     /*
      * Add any additional data required by the template here
      */
     //         $person_manager = new RowManager_PersonManager( $this->person_id );
     /**** Populate drop-lists for filtering which statistic input fields to show on next page ****/
     $jumpLink = $this->linkValues['ministryJumpLink'];
     $ministryManager = new RowManager_MinistryManager();
     $ministryList = new ListIterator($ministryManager);
     //$ministryManager->getListIterator( );
     $ministryArray = $ministryList->getDropListArray(null, $jumpLink);
     //added jumplink
     $this->template->set('list_ministry_id', $ministryArray);
     $jumpLink2 = $this->linkValues['divisionJumpLink'];
     $divisionManager = $this->division_manager;
     // new RowManager_DivisionManager( );
     $divisionList = new ListIterator($divisionManager);
     //$divisionManager->getListIterator( );
     $divisionArray = $divisionList->getDropListArray(null, $jumpLink2);
     //added jumplink
     $this->template->set('list_division_id', $divisionArray);
     // echo '<pre>'.print_r($divisionArray,true).'</pre>';
     $jumpLink3 = $this->linkValues['regionJumpLink'];
     $regionManager = $this->region_manager;
     //new RowManager_StatsRegionManager( );
     $regionList = new ListIterator($regionManager);
     //$regionManager->getListIterator( );
     $regionArray = $regionList->getDropListArray(null, $jumpLink3);
     //added jumplink
     $this->template->set('list_region_id', $regionArray);
     $locationManager = $this->location_manager;
     //new RowManager_LocationManager( );
     $locationList = $locationManager->getListIterator();
     $locationArray = $locationList->getDropListArray();
     $this->template->set('list_location_id', $locationArray);
     $measureManager = new RowManager_MeasureTypeManager();
     $measureList = $measureManager->getListIterator();
     $measureArray = $measureList->getDropListArray();
     $this->template->set('list_meas_id', $measureArray);
     $freqTypeManager = new RowManager_FreqTypeManager();
     $freqTypeList = $freqTypeManager->getListIterator();
     $freqTypeArray = $freqTypeList->getDropListArray();
     $this->template->set('list_freq_id', $freqTypeArray);
     // uncomment this line if you are creating a template for this page
     //$templateName = 'page_EditMyInfo.php';
     // otherwise use the generic admin box template
     $templateName = 'siteFormSingle.php';
     return $this->template->fetch($templateName);
 }