public function testMakeDataAndLabelsForSeriesOrRange() { $attributesData = array('a' => array('label' => 'an A'), 'b' => array('label' => 'a b')); $dataAndLabels = ReportUtil::makeDataAndLabelsForSeriesOrRange($attributesData); $compareData = array('a' => 'an A', 'b' => 'a b'); $this->assertEquals($compareData, $dataAndLabels); }
public function actionAdd() { $op = EnvUtil::getRequest("op"); if (!in_array($op, array("new", "save"))) { $op = "new"; } if ($op == "new") { $typeid = intval(EnvUtil::getRequest("typeid")); if (!$typeid) { $typeid = 1; } $uid = Ibos::app()->user->uid; $upUid = UserUtil::getSupUid($uid); $reportType = ReportType::model()->fetchByPk($typeid); $summaryAndPlanDate = ReportUtil::getDateByIntervalType($reportType["intervaltype"], $reportType["intervals"]); $subject = ICReport::handleShowSubject($reportType, strtotime($summaryAndPlanDate["summaryBegin"]), strtotime($summaryAndPlanDate["summaryEnd"])); $lastRep = Report::model()->fetchLastRepByUidAndTypeid($uid, $typeid); $orgPlanList = array(); if (!empty($lastRep)) { $orgPlanList = ReportRecord::model()->fetchRecordByRepidAndPlanflag($lastRep["repid"], 2); } $params = array("typeid" => $typeid, "summaryAndPlanDate" => $summaryAndPlanDate, "intervals" => $reportType["intervals"], "intervaltype" => $reportType["intervaltype"], "subject" => $subject, "upUid" => StringUtil::wrapId($upUid), "uploadConfig" => AttachUtil::getUploadConfig(), "orgPlanList" => $orgPlanList, "isInstallCalendar" => ModuleUtil::getIsEnabled("calendar")); $this->setPageTitle(Ibos::lang("Add report")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Personal Office")), array("name" => Ibos::lang("Work report"), "url" => $this->createUrl("default/index")), array("name" => Ibos::lang("Add report")))); $this->render("add", $params); } else { $this->{$op}(); } }
public function getStamp() { static $stamp = array(); if (empty($stamp)) { $enableStamp = ReportUtil::getEnableStamp(); $stampIds = implode(",", array_keys($enableStamp)); $stamp = Stamp::model()->fetchAllSortByPk("id", array("condition" => "FIND_IN_SET(id,'{$stampIds}')", "order" => "sort ASC")); } return $stamp; }
public function scoreReport($repId, $uid, $stamp) { $record = $this->fetchByAttributes(array("repid" => $repId)); $attributes = array("repid" => $repId, "uid" => $uid, "stamp" => $stamp, "integration" => ReportUtil::getScoreByStamp($stamp), "scoretime" => TIMESTAMP); if (empty($record)) { $this->add($attributes); } else { $this->modify($record["id"], $attributes); } }
public static function getReportsByCid($cid, $startDate, $endDate, $numCat = 4, $desiredPlatform) { $apps = array(); $excludeApps = array(); foreach (AppUtil::getAppsByUid($_SESSION['uid']) as $app) { if ($desiredPlatform == 0 || $desiredPlatform == $app->platform) { $apps[$app->id] = $app->name; } else { $excludeApps[$app->id] = $app->name; } } fb("getRbyCid"); fb("apps", $apps); return ReportUtil::getReportsByIdAndGroup('nid', $cid, 'aid', $startDate, $endDate, $apps, $numCat, $excludeApps); }
public function getXML() { $this->printHeader = false; $this->printFooter = false; $reports = ReportUtil::getNetworkReportsByUid($this->user->id, $this->startDate, $this->endDate); $dates = array(); for ($i = $this->startDate; $i <= $this->endDate; $i = date('Y-m-d', strtotime('+1 day', strtotime($i)))) { $dates[] = $i; } $networks = array(); foreach ($reports['types'] as $type => $discard) { $networks[$type] = isset(Network::$NETWORKS[$type]) ? Network::$NETWORKS[$type]['name'] : 'Unknown'; } $this->smarty->assign('networks', $networks); $this->smarty->assign('reports', $reports); $this->smarty->assign('dates', $dates); return $this->smarty->fetch('../tpl/www/reports/networkReportsXML.tpl'); }
protected function search() { $type = EnvUtil::getRequest("type"); $conditionCookie = MainUtil::getCookie("condition"); if (empty($conditionCookie)) { MainUtil::setCookie("condition", $this->_condition, 10 * 60); } if ($type == "advanced_search") { $search = $_POST["search"]; $this->_condition = ReportUtil::joinSearchCondition($search); } elseif ($type == "normal_search") { $keyword = $_POST["keyword"]; MainUtil::setCookie("keyword", $keyword, 10 * 60); $this->_condition = " ( content LIKE '%{$keyword}%' OR subject LIKE '%{$keyword}%' ) "; } else { $this->_condition = $conditionCookie; } if ($this->_condition != MainUtil::getCookie("condition")) { MainUtil::setCookie("condition", $this->_condition, 10 * 60); } }
/** * @param $savedReport * @return Report */ public static function makeReportBySavedReport($savedReport) { $report = new Report(); if ($savedReport->id > 0) { $report->setId((int) $savedReport->id); } $report->setDescription($savedReport->description); $report->setModuleClassName($savedReport->moduleClassName); $report->setName($savedReport->name); $report->setOwner($savedReport->owner); $report->setType($savedReport->type); $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($savedReport); $report->setExplicitReadWriteModelPermissions($explicitReadWriteModelPermissions); if ($savedReport->serializedData != null) { $unserializedData = unserialize($savedReport->serializedData); if (isset($unserializedData['filtersStructure'])) { $report->setFiltersStructure($unserializedData['filtersStructure']); } if (isset($unserializedData['currencyConversionType'])) { $report->setCurrencyConversionType((int) $unserializedData['currencyConversionType']); } if (isset($unserializedData['spotConversionCurrencyCode'])) { $report->setSpotConversionCurrencyCode($unserializedData['spotConversionCurrencyCode']); } self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_FILTERS], $report, 'Filter'); self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_ORDER_BYS], $report, 'OrderBy'); self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_GROUP_BYS], $report, 'GroupBy'); self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_DISPLAY_ATTRIBUTES], $report, 'DisplayAttribute'); self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_DRILL_DOWN_DISPLAY_ATTRIBUTES], $report, 'DrillDownDisplayAttribute'); if (isset($unserializedData['chart'])) { $moduleClassName = $report->getModuleClassName(); $modelClassName = $moduleClassName::getPrimaryModelName(); $adapter = ModelRelationsAndAttributesToSummationReportAdapter::make($moduleClassName, $modelClassName, $report->getType()); $chart = new ChartForReportForm(ReportUtil::makeDataAndLabelsForSeriesOrRange($adapter->getAttributesForChartSeries($report->getGroupBys(), $report->getDisplayAttributes())), ReportUtil::makeDataAndLabelsForSeriesOrRange($adapter->getAttributesForChartRange($report->getDisplayAttributes()))); $chart->setAttributes($unserializedData['chart']); $report->setChart($chart); } } return $report; }
private function personal() { $uid = Ibos::app()->user->uid; $typeid = EnvUtil::getRequest("typeid"); $getUid = intval(EnvUtil::getRequest("uid")); $condition = "uid = '{$getUid}'"; if (!UserUtil::checkIsSub($uid, $getUid)) { $condition .= " AND FIND_IN_SET('{$uid}', toid )"; } if (!empty($typeid)) { $condition .= " AND typeid = '{$typeid}'"; } if (EnvUtil::getRequest("param") == "search") { $this->search(); } $this->_condition = ReportUtil::joinCondition($this->_condition, $condition); $paginationData = Report::model()->fetchAllByPage($this->_condition); $params = array("dashboardConfig" => Ibos::app()->setting->get("setting/reportconfig"), "typeid" => $typeid, "pagination" => $paginationData["pagination"], "reportList" => ICReport::handelListData($paginationData["data"]), "reportCount" => Report::model()->count("uid = '{$getUid}'"), "commentCount" => Report::model()->count("uid='{$getUid}' AND isreview=1"), "user" => User::model()->fetchByUid($getUid), "supUid" => UserUtil::getSupUid($getUid)); $this->setPageTitle(Ibos::lang("Review subordinate report")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Personal Office")), array("name" => Ibos::lang("Work report"), "url" => $this->createUrl("default/index")), array("name" => Ibos::lang("Subordinate personal report")))); $this->render("personal", $params); }
public function run() { $data = array("config" => ReportUtil::getSetting(), "id" => $this->getController()->getId()); $this->render(self::VIEW, $data); }
/** * @param array $data * @param Report $report */ protected static function resolveChart($data, Report $report) { if ($report->getType() != Report::TYPE_SUMMATION) { return; } $moduleClassName = $report->getModuleClassName(); if ($moduleClassName != null) { $modelClassName = $moduleClassName::getPrimaryModelName(); $adapter = ModelRelationsAndAttributesToSummationReportAdapter::make($moduleClassName, $modelClassName, $report->getType()); $seriesDataAndLabels = ReportUtil::makeDataAndLabelsForSeriesOrRange($adapter->getAttributesForChartSeries($report->getGroupBys(), $report->getDisplayAttributes())); $rangeDataAndLabels = ReportUtil::makeDataAndLabelsForSeriesOrRange($adapter->getAttributesForChartRange($report->getDisplayAttributes())); } else { $seriesDataAndLabels = array(); $rangeDataAndLabels = array(); } $chart = new ChartForReportForm($seriesDataAndLabels, $rangeDataAndLabels); if (null != ($chartData = ArrayUtil::getArrayValue($data, 'ChartForReportForm'))) { $chart->setAttributes($chartData); } $report->setChart($chart); }
public function run() { $data = array("typeid" => EnvUtil::getRequest("typeid"), "lang" => Ibos::getLangSource("report.default"), "deptArr" => UserUtil::getManagerDeptSubUserByUid(Ibos::app()->user->uid), "dashboardConfig" => ReportUtil::getSetting(), "deptRoute" => $this->inStats() ? "stats/review" : "review/index", "userRoute" => $this->inStats() ? "stats/review" : "review/personal"); $this->render(self::VIEW, $data); }
public function actionGetAvailableSeriesAndRangesForChart($type, $id = null, $isBeingCopied = false) { $postData = PostUtil::getData(); $savedReport = null; $report = null; $this->resolveSavedReportAndReportByPostData($postData, $savedReport, $report, $type, $id, (bool) $isBeingCopied); $moduleClassName = $report->getModuleClassName(); $modelClassName = $moduleClassName::getPrimaryModelName(); $modelToReportAdapter = ModelRelationsAndAttributesToReportAdapter::make($moduleClassName, $modelClassName, $report->getType()); if (!$modelToReportAdapter instanceof ModelRelationsAndAttributesToSummationReportAdapter) { throw new NotSupportedException(); } $seriesAttributesData = $modelToReportAdapter->getAttributesForChartSeries($report->getGroupBys(), $report->getDisplayAttributes()); $rangeAttributesData = $modelToReportAdapter->getAttributesForChartRange($report->getDisplayAttributes()); $dataAndLabels = array(); $dataAndLabels['firstSeriesDataAndLabels'] = array('' => Zurmo::t('Core', '(None)')); $dataAndLabels['firstSeriesDataAndLabels'] = array_merge($dataAndLabels['firstSeriesDataAndLabels'], ReportUtil::makeDataAndLabelsForSeriesOrRange($seriesAttributesData)); $dataAndLabels['firstRangeDataAndLabels'] = array('' => Zurmo::t('Core', '(None)')); $dataAndLabels['firstRangeDataAndLabels'] = array_merge($dataAndLabels['firstRangeDataAndLabels'], ReportUtil::makeDataAndLabelsForSeriesOrRange($rangeAttributesData)); $dataAndLabels['secondSeriesDataAndLabels'] = array('' => Zurmo::t('Core', '(None)')); $dataAndLabels['secondSeriesDataAndLabels'] = array_merge($dataAndLabels['secondSeriesDataAndLabels'], ReportUtil::makeDataAndLabelsForSeriesOrRange($seriesAttributesData)); $dataAndLabels['secondRangeDataAndLabels'] = array('' => Zurmo::t('Core', '(None)')); $dataAndLabels['secondRangeDataAndLabels'] = array_merge($dataAndLabels['secondRangeDataAndLabels'], ReportUtil::makeDataAndLabelsForSeriesOrRange($rangeAttributesData)); echo CJSON::encode($dataAndLabels); }
/** * Override to handle report filters * @param SavedCalendar | ModelForm $model * @param string $postVariableName * @throws NotSupportedException(); */ protected function attemptToValidateAjaxFromPost($model, $postVariableName) { if (isset($_POST['ajax']) && $_POST['ajax'] == 'edit-form') { $postData = PostUtil::getData(); $readyToUsePostData = ExplicitReadWriteModelPermissionsUtil::removeIfExistsFromPostData($_POST[$postVariableName]); $sanitizedPostdata = PostUtil::sanitizePostByDesignerTypeForSavingModel($model, $readyToUsePostData); $sanitizedOwnerPostData = PostUtil::sanitizePostDataToJustHavingElementForSavingModel($sanitizedPostdata, 'owner'); $sanitizedPostDataWithoutOwner = PostUtil::removeElementFromPostDataForSavingModel($sanitizedPostdata, 'owner'); $model->setAttributes($sanitizedPostDataWithoutOwner); if ($model->validate()) { $modelToStringValue = strval($model); if ($sanitizedOwnerPostData != null) { $model->setAttributes($sanitizedOwnerPostData); } if ($model instanceof OwnedSecurableItem) { $model->validate(array('owner')); } } $wizardFormClassName = ReportToWizardFormAdapter::getFormClassNameByType(Report::TYPE_ROWS_AND_COLUMNS); if (!isset($postData[$wizardFormClassName])) { throw new NotSupportedException(); } $report = SavedCalendarToReportAdapter::makeReportBySavedCalendar($model); DataToReportUtil::resolveFiltersStructure($postData[$wizardFormClassName], $report); DataToReportUtil::resolveFilters($postData[$wizardFormClassName], $report); //This would do the filter and filter structure validation $reportToWizardFormAdapter = new ReportToWizardFormAdapter($report); $reportForm = $reportToWizardFormAdapter->makeFormByType(); $postData['validationScenario'] = $wizardFormClassName::FILTERS_VALIDATION_SCENARIO; $filtersErrorData = ReportUtil::validateReportWizardForm($postData, $reportForm); $errorData = ZurmoActiveForm::makeErrorsDataAndResolveForOwnedModelAttributes($model); $errorData = array_merge($errorData, $filtersErrorData); echo CJSON::encode($errorData); Yii::app()->end(0, false); } }
public function getXML() { $this->printHeader = false; $this->printFooter = false; $apps = AppUtil::getAppsByUid($_SESSION['uid']); fb("app", $apps); $reports = ReportUtil::getReportsByCid($this->cid, $this->startDate, $this->endDate, $this->numCat, $this->platform); fb("reports", $reports); $new_reports = $this->collapseReport($reports); if ($this->metricTypeSelected == "CTR") { $this->calculateCTR($new_reports); } fb("nr", $new_reports); $this->smarty->assign('reports', $new_reports); $this->smarty->assign('nets', $reports['nets']); $this->smarty->assign('dates', $new_reports['dates']); $this->smarty->assign('metric', strtolower($this->metricTypeSelected)); //fb("smarty",$this->smarty->get_template_vars()); return $this->smarty->fetch('../tpl/www/reports/applicationReportsXML.tpl'); // // foreach($houseAds as $houseAd) { // $houseAd->reports = ReportUtil::getReportsByCid($houseAd->id, $this->startDate, $this->endDate); // } // // $totals = array(); // $dates = array(); // for($i=$this->startDate; $i<=$this->endDate; $i=date('Y-m-d', strtotime('+1 day', strtotime($i)))) { // $dates[] = $i; // // foreach($houseAds as $houseAd) { // if(isset($totals[$i])) { // $totals[$i]['impressions'] += $houseAd->reports[$i]['impressions']; // $totals[$i]['clicks'] += $houseAd->reports[$i]['clicks']; // } // else { // $totals[$i]['impressions'] = $houseAd->reports[$i]['impressions']; // $totals[$i]['clicks'] = $houseAd->reports[$i]['clicks']; // } // } // } // // $this->smarty->assign('houseAds', $houseAds); // $this->smarty->assign('dates', $dates); // $this->smarty->assign('totals', $totals); // // return $this->smarty->fetch('../tpl/www/reports/houseAdReportsXML.tpl'); }
public function getXML() { $this->printHeader = false; $this->printFooter = false; if ($this->aid != null) { $app = new App($this->aid); } else { $apps = AppUtil::getAppsByUid($this->user->id); $app = $apps['0']; } $reports = ReportUtil::getReportsByAid($app->id, $this->startDate, $this->endDate); fb("reports", $reports); $new_reports = $this->collapseReport($reports); fb("nr", $new_reports); $this->smarty->assign('reports', $new_reports); $this->smarty->assign('nets', $reports['nets']); $this->smarty->assign('dates', $new_reports['dates']); $this->smarty->assign('metric', 'impressions'); return $this->smarty->fetch('../tpl/www/reports/applicationReportsXML.tpl'); }