Beispiel #1
0
 public function initiate($settingVars)
 {
     $this->settingVars = $settingVars;
     $this->queryVars = projectsettings\settingsGateway::getInstance();
     $this->ValueVolume = getValueVolume($this->settingVars);
     filters\timeFilter::getSlice($this->settingVars);
     $this->jsonOutput = array();
 }
 /**
  * Use when you need to pull data without realtime filtering
  * */
 public static function LineChart($querypart, &$jsonOutput)
 {
     $tyValues = array();
     $lyValues = array();
     $measureSelectionArr = self::getMeasuresForLineChart();
     self::$ValueVolume = getValueVolume(self::$settingVars);
     $query = " SELECT " . self::$settingVars->yearperiod . " AS YEAR" . "," . self::$settingVars->weekperiod . " AS WEEK" . ",SUM(IFNULL(" . self::$ValueVolume . ",0)) AS " . self::$settingVars->measureArray['M' . ($_GET['ValueVolume'] - 1)]['ALIASE'] . " " . "FROM " . self::$settingVars->tablename . $querypart . " AND (" . filters\timeFilter::$tyWeekRange . " OR " . filters\timeFilter::$lyWeekRange . ") " . "GROUP BY YEAR,WEEK " . "ORDER BY YEAR ASC,WEEK ASC";
     $result = self::$queryVars->queryHandler->runQuery($query, self::$queryVars->linkid, db\ResultTypes::$TYPE_OBJECT);
     foreach ($result as $key => $data) {
         $account = $data['YEAR'] . "-" . $data['WEEK'];
         $numberAccount = $data['YEAR'] . ($data['WEEK'] < 10 ? "0" . $data['WEEK'] : $data['WEEK']);
         $numberFrom = filters\timeFilter::$FromYear . (filters\timeFilter::$FromWeek < 10 ? "0" . filters\timeFilter::$FromWeek : filters\timeFilter::$FromWeek);
         $numberTo = filters\timeFilter::$ToYear . (filters\timeFilter::$ToWeek < 10 ? "0" . filters\timeFilter::$ToWeek : filters\timeFilter::$ToWeek);
         if ($numberAccount >= $numberFrom && $numberAccount <= $numberTo) {
             $tyValues[$account]['VALUE'] = $data[self::$settingVars->measureArray['M' . ($_GET['ValueVolume'] - 1)]['ALIASE']];
         } else {
             $lyValues[$account]['VALUE'] = $data[self::$settingVars->measureArray['M' . ($_GET['ValueVolume'] - 1)]['ALIASE']];
         }
     }
     if (count($tyValues) >= count($lyValues)) {
         $validTimeSlot = "TY";
         $validArray = $tyValues;
     } else {
         $validTimeSlot = "LY";
         $validArray = $lyValues;
     }
     $value = array();
     foreach ($validArray as $key => $data) {
         $temp = array();
         $temp = explode("-", $key);
         $year = $temp[0];
         $week = $temp[1];
         if ($validTimeSlot == "TY") {
             $tyKey = $key;
             $lyKey = $year - 1 . "-" . $week;
         } else {
             $tyKey = $year + 1 . "-" . $week;
             $lyKey = $key;
         }
         $value = array('TYACCOUNT' => $tyKey, 'LYACCOUNT' => $lyKey, 'ACCOUNT' => htmlspecialchars($tyKey), "TY" . self::$settingVars->measureArray['M' . ($_GET['ValueVolume'] - 1)]['ALIASE'] => key_exists($tyKey, $tyValues) ? $tyValues[$tyKey]['VALUE'] : 0, "LY" . self::$settingVars->measureArray['M' . ($_GET['ValueVolume'] - 1)]['ALIASE'] => key_exists($lyKey, $lyValues) ? $lyValues[$lyKey]['VALUE'] : 0);
         $jsonOutput['LineChart'][] = $value;
     }
 }
 public function fetch_all_pod_data()
 {
     $this->ValueVolume = getValueVolume($this->settingVars);
     //ADVICED TO EXECUTE THE FOLLOWING FUNCTION ON TOP AS IT SETS TY_total and LY_total
     $this->totalSales();
     if ($this->pageName == 'CAT_SUMMARY_PAGE') {
         if (isset($this->settingVars->catSummaryPageDataTwoField) && $this->settingVars->catSummaryPageDataTwoField != '') {
             $query = "SELECT db_column FROM " . $this->settingVars->clientconfigtable . " WHERE cid=" . $this->settingVars->aid . " AND db_table='" . $this->settingVars->skutable . "' AND csv_column = '" . $this->settingVars->catSummaryPageDataTwoField . "'";
             $result = $this->queryVars->queryHandler->runQuery($query, $this->queryVars->linkid, db\ResultTypes::$TYPE_OBJECT);
             if (is_array($result) && !empty($result)) {
                 $this->settingVars->pageArray[$this->pageName]["PODS"]["DATA_TWO"] = $result[0]['db_column'];
             }
         }
     }
     //COLLECT REQUIRED POD VARIABLES
     if ($this->pageName == 'EXE_SUMMARY_PAGE') {
         $query = "SELECT csv_column, setting_value from " . $this->settingVars->clientconfigtable . " as a," . $this->settingVars->configTable . " as b" . " WHERE a.cid=" . $this->settingVars->aid . " AND a.db_table='" . $this->settingVars->skutable . "'" . $this->settingVars->projectHelperLink . " AND b.accountID=" . $this->settingVars->aid . " AND a.db_column=b.setting_value AND b.setting_name='pod_one_key'";
         $result = $this->queryVars->queryHandler->runQuery($query, $this->queryVars->linkid, db\ResultTypes::$TYPE_OBJECT);
         if (is_array($result) && !empty($result)) {
             $this->settingVars->pageArray[$this->pageName]["PODS"]["DATA_TWO"] = $this->settingVars->skutable . "." . $result[0]['setting_value'];
             $this->settingVars->pageArray[$this->pageName]["TITLE"]["POD_FOUR"] = "Share by " . $result[0]['csv_column'];
             $this->settingVars->pageArray[$this->pageName]["TITLE"]["POD_FIVE"] = $result[0]['csv_column'] . " Performance";
         }
     }
     if (!empty($this->settingVars->pageArray[$this->pageName]["PODS"])) {
         $pods = $this->settingVars->pageArray[$this->pageName]["PODS"];
         foreach ($pods as $key => $account) {
             $this->Share_By_Name($account, $key);
         }
     }
 }