Exemplo n.º 1
0
  * freq_parent_freq_id [INTEGER]  The frequency type id associated with the parent frequency (may be case that no freq specified - i.e. 'yearly' is at top and has no parent freq)
  */
 $FrequencyType = new RowManager_FreqTypeManager();
 $FrequencyType->dropTable();
 $FrequencyType->createTable();
 /*
  * FrequencyValue Table
  *
  * Stores a specific frequency value (i.e. 'January 2008'.
  *
  * freqvalue_id [INTEGER]  the unique identifier
  * freq_id [INTEGER]  the id of the parent frequency type
  * freqvalue_value [DATE]  the actual frequency value (in date-time form)
  * freqvalue_desc [STRING]  The user-friendly description of the frequency value (i.e. 'January 2008' for '2008-01-01 00:00:00')
  */
 $FrequencyValue = new RowManager_FreqValueManager();
 $FrequencyValue->dropTable();
 $FrequencyValue->createTable();
 /*
  * Statistic Table
  *
  * A statistic description
  *
  * statistic_id [INTEGER]  unique identifier for this Statistic
  * statistic_name [STRING]  the Statistic's name
  * statistic_desc [STRING]  The Statistic description
  * statistic_type [STRING]  the data-type of this Statistic (i.e. numeric, boolean, etc)
  * scope_id [INTEGER]  the id indicating the scope of the statistic (i.e. ministry-level, division-level, etc)
  * scope_ref_id [INTEGER]  The particular scope instance associated with the statistic (i.e. project-level stat assigned to OEX Project)
  * freq_id [INTEGER]  the id indicating the frequency type associated with this statistic
  * meas_id [INTEGER]  the id of the measurement type associated with this statistic (i.e. 'Personal Ministry')
Exemplo n.º 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;
     // 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);
     /*    $labelManager = new  MultilingualManager();
     		    $labelManager->addSeries( modulecim_reg::MULTILINGUAL_SERIES_KEY );
     		    
     		    
     		    
     		    // Create General Field labels for modulecim_reg 
     		    $labelManager->addPage( modulecim_reg::MULTILINGUAL_PAGE_FIELDS );
     			 $labelManager->addPage( modulecim_reg::PAGE_EDITFIELDVALUES );
     		    
     		    //
     		    // Event table
     		    //
     			$labelManager->addLabel( "[title_event_deposit]", "Deposit", "en" );        
     		
     		*/
     // NOTE:  this parent method prepares the $this->template with the
     // common Form data.
     $this->prepareTemplate($path);
     //         $this->formValues['freq_id'] = $this->freq_id;
     //         $this->formValues['meas_id'] = $this->meastype_id;
     // 		  $this->formValues['form_name'] = 'statValuesForm';
     // 			$_POST['freq_id'] = $this->freq_id;
     // 			$_POST['meas_id'] = $this->meastype_id;
     // store all the fields to the template
     $this->setFormFieldsToTemplate();
     $this->template->set('formLabels', $this->formLabels);
     /*
      * Form related Template variables:
      */
     // store the button label
     $this->template->set('buttonText', $this->labels->getLabel('[Update]'));
     /*** Fill the frequency value droplists with appropriate values (i.e. years, weeks, days, etc) **/
     // NOTE: moving code below into the loop would allow for different freq types per statistic input
     $freqValueManager = new RowManager_FreqValueManager();
     $freqValueManager->setFreqID($this->freq_id);
     // set whether we filtered by annual, weekly, etc. type stats
     $freqValueList = $freqValueManager->getListIterator();
     $freqValueArray = $freqValueList->getDropListArray();
     //         echo "<pre>".print_r($freqValueArray,true)."</pre>";
     reset($this->formFieldToStatIDmapper);
     foreach (array_keys($this->formFieldToStatIDmapper) as $k) {
         next($this->formFieldToStatIDmapper);
         // every other field will be a freq type dropbox
         $this->template->set('list_' . $k, $freqValueArray);
         next($this->formFieldToStatIDmapper);
     }
     // 		  echo 'fields = <pre>'.print_r($this->formFieldToStatIDmapper,true).'</pre>';
     /*
      * Add any additional data required by the template here
      */
     if ($this->disable_heading == true) {
         $this->template->set('disableHeading', true);
     }
     //           $labelManager->addLabel( "[NoStatsFound]", "NO statistics found... please choose different filter values.", "en" );
     if (count($this->formFieldToStatIDmapper) < 1) {
         // see also: $templateTools->getPageLabel('[NoStatsFound]') );
         $this->template->set('specialInfo', '<div class="notice">NO statistics found... please choose different filter values.</div>');
     }
     $this->template->set('formAnchor', 'StatValuesForm');
     // uncomment this line if you are creating a template for this page
     //$templateName = 'page_EditFieldValues.php';
     // otherwise use the generic admin box template
     $templateName = 'siteFormSingle_dynamic.php';
     return $this->template->fetch($templateName);
 }
Exemplo n.º 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);
 }