public function execute() { $this->forceSystemAuthentication(); $this->partners_stat = array(); $start = microtime(true); $file_path = dirname(__FILE__) . "/../data/viewPartnersData.txt"; $partner_groups = new partnerGroups($file_path); $this->partner_group_list = $partner_groups->partner_group_list; $group_rest = new partnerGroup(); $group_rest->setName("_rest"); $this->partner_group_list[] = $group_rest; $this->from_date = $this->getP("from_date"); $this->to_date = $this->getP("to_date", date("Y-m-d", time())); $this->days = $this->getP("days", 7); if ($this->days) { $timeStamp = strtotime($this->to_date); $timeStamp -= 24 * 60 * 60 * ($this->days - 1); // because it's inclusive-inclusive - reduce one day $this->from_date = date("Y-m-d", $timeStamp); } $input_filter = new reportsInputFilter(); $input_filter->from_date = strtotime($this->from_date); $input_filter->to_date = strtotime($this->to_date); list($header, $data, $totalCount) = myReportsMgr::getTable(null, myReportsMgr::REPORT_TYPE_SYSTEM_GENERIC_PARTNER_TYPE, $input_filter, "", 300, null, null); $this->data = $data; // create total summary line $totals = array(); $i = 0; foreach ($this->data[0] as $columns) { $totals[$i] = $i < 3 ? "TOTAL" : 0; $i++; } foreach ($this->data as $line) { $i = 0; foreach ($line as $val) { if (is_numeric($val)) { @($totals[$i] += $val); } $i++; } } $this->data[] = $totals; $this->header = $header; $end = microtime(true); $this->go = $this->getP("go"); $this->bench = $end - $start; $this->format = $this->getP("format", "row"); }
public function execute() { $this->forceSystemAuthentication(); $this->partners_stat = array(); $start = microtime(true); $file_path = dirname(__FILE__) . "/../data/viewPartnersData.txt"; $partner_groups = new partnerGroups($file_path); $this->partner_group_list = $partner_groups->partner_group_list; $group_rest = new partnerGroup(); $group_rest->setName("_rest"); $this->partner_group_list[] = $group_rest; $this->from_date = $this->getP("from_date"); $this->to_date = $this->getP("to_date", date("Y-m-d", time())); $this->days = $this->getP("days", 7); if ($this->days) { $timeStamp = strtotime($this->to_date); $timeStamp -= 24 * 60 * 60 * ($this->days - 1); // because it's inclusive-inclusive - reduce one day $this->from_date = date("Y-m-d", $timeStamp); } }
public function __construct($file_name) { $this->partner_group_list = array(); $partner_group = null; $content = file_get_contents($file_name); $lines = explode("\n", $content); foreach ($lines as $line) { $trimmed_line = trim($line); if (!$trimmed_line) { continue; } if (strpos($trimmed_line, ":")) { //echo "new group: $trimmed_line<br>"; // add the previous $partner_group (if exists) to the list if ($partner_group) { $partner_group->calculateValue(); $this->partner_group_list[$partner_group->name] = $partner_group; } // define a new partnerGroup $partner_group = new partnerGroup(); list($name, $fields) = explode(":", $trimmed_line); $partner_group->setName($name); $partner_group->setField($fields); //echo "new group: [$partner_group->name]<br>"; } else { if ($partner_group) { //echo "data: $trimmed_line<br>"; // add it's data $partner_group->addToValue($trimmed_line); } else { // error - data comes before the first partner_group ! echo "Attempting to add {$trimmed_line} to no group at all!"; } } } if ($partner_group) { $partner_group->calculateValue(); $this->partner_group_list[$partner_group->name] = $partner_group; } // print_r ( $partner_group_list ); }