Exemplo n.º 1
0
 protected function getFieldValuesArray($scopeRefList, $freqID = '', $measID = '')
 {
     $statvalues = new RowManager_StatValueManager();
     $statvalues->setSortByStatID();
     $stats = new RowManager_StatisticManager();
     /** TODO
      * 	scopeID == ''  means we either don't proceed or assume all possible scopes
      *	   scopeRefID == '' can be ignored if the prev is true, otherwise could assume all values for given scope (i.e ministry, division, etc)
      *		freqID == '' means we don't proceed since we need to interpret frequency value properly
      *		measID == '' means we don't proceed since, for instance, Personal Ministry <> Team Ministry (or can we have stats count for both?)
      **/
     $fieldInfo = new MultiTableManager();
     $fieldInfo->addRowManager($statvalues);
     $fieldInfo->addRowManager($stats, new JoinPair($statvalues->getJoinOnStatID(), $stats->getJoinOnStatID()));
     // filter the statistic fields shown using the parameters
     $searchConditions = '';
     if (isset($scopeRefList)) {
         reset($scopeRefList);
         foreach (array_keys($scopeRefList) as $k) {
             $scopeID = key($scopeRefList);
             $scopeRefID = current($scopeRefList);
             $searchConditions .= '(p2c_stats_statistic.scope_id = ' . $scopeID;
             $searchConditions .= ' AND p2c_stats_statistic.scope_ref_id = ' . $scopeRefID . ')';
             $searchConditions .= ' OR ';
             next($scopeRefList);
         }
         $searchConditions = substr($searchConditions, 0, -4);
         // remove last OR
         $fieldInfo->addSearchCondition($searchConditions);
     }
     if ($freqID != '') {
         $fieldInfo->addSearchCondition('p2c_stats_statistic.freq_id = ' . $freqID);
     }
     if ($measID != '') {
         $fieldInfo->addSearchCondition('p2c_stats_statistic.meas_id = ' . $measID);
     }
     $valuesIterator = $fieldInfo->getListIterator();
     $valuesArray = $valuesIterator->getDataList();
     //        echo "field values:<br><pre>".print_r($valuesArray,true)."</pre>";
     // since each field value is located in a DB row the result array has several arrays - one per field value
     // need to extract each field value and store it as a non-array record in a result array
     $fieldValues = array();
     $record = array();
     $idx = 0;
     reset($valuesArray);
     foreach (array_keys($valuesArray) as $k) {
         $record = current($valuesArray);
         /*				if ($isIndexedByValueID == true)
         				{
         					$fieldValues[$record['fieldvalues_id']] = $record['fieldvalues_value'];
         				}
         				else
         				{		*/
         $fieldValues['form_field' . $idx] = $record['statvalues_value'];
         //$fieldValues['form_field'.$idx+1] = $record['freqvalue_id'];
         //				}
         // store mapping associating form field label with fieldvalues_id
         $this->formFieldToValueIDmapper['form_field' . $idx] = $record['statvalues_id'];
         //$this->formFieldToValueIDmapper['form_field'.++$idx] = $record['statvalues_id'];
         next($valuesArray);
         $idx++;
     }
     return $fieldValues;
 }
Exemplo n.º 2
0
 /*
  * StatisticValue Table
  *
  * a specific statistic value (i.e. '45' for '# of Gospel Presentations')
  *
  * statvalues_id [INTEGER]  the unique id for the Statistic Value
  * statistic_id [INTEGER]  the id of the statistic associated with this value
  * scope_id [INTEGER]  the scope of the stored stat value
  * scope_ref_id [INTEGER]  the specific scope instance associated with the stat value
  * freqvalue_id [INTEGER]  the id of the specific frequency value associated with the stat value (i.e. a particular day,week,month, or others etc)
  * meastype_id [INTEGER]  The particular measurement type associated with the stat value (OBSOLETE??)
  * statvalues_value [STRING]  The actual statistics value
  * 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();
 /*