/** * @param ReportWizardForm $formModel */ protected function setCommonAttributes(ReportWizardForm $formModel) { $formModel->id = $this->report->getId(); $formModel->description = $this->report->getDescription(); $formModel->moduleClassName = $this->report->getModuleClassName(); if ($this->report->getOwner()->id > 0) { $formModel->ownerId = (int) $this->report->getOwner()->id; $formModel->ownerName = strval($this->report->getOwner()); } $formModel->name = $this->report->getName(); $formModel->type = $this->report->getType(); $formModel->filtersStructure = $this->report->getFiltersStructure(); $formModel->currencyConversionType = $this->report->getCurrencyConversionType(); $formModel->spotConversionCurrencyCode = $this->report->getSpotConversionCurrencyCode(); if ($this->report->isNew()) { $formModel->setIsNew(); } $formModel->setExplicitReadWriteModelPermissions($this->report->getExplicitReadWriteModelPermissions()); $formModel->filters = $this->report->getFilters(); $formModel->orderBys = $this->report->getOrderBys(); $formModel->groupBys = $this->report->getGroupBys(); $formModel->displayAttributes = $this->report->getDisplayAttributes(); $formModel->drillDownDisplayAttributes = $this->report->getDrillDownDisplayAttributes(); $formModel->chart = $this->report->getChart(); }
?> <?php if ($report->canDelete(logged_user())) { ?> <a style="margin-right:5px" class="internalLink coViewAction ico-delete" href="javascript:og.deleteReport(<?php echo $report->getId(); ?> )"><?php echo lang('delete'); ?> </a> <?php } ?> <div style="padding-left:15px"><?php echo $report->getDescription(); ?> </div> </div> </li> <?php } //foreach ?> </ul> <?php } else { echo lang('no custom reports', lang($reportPages[$type_id]['name'])) . '<br/>'; } // if count // Add new custom report
<a style="margin-right:5px" class="internalLink coViewAction ico-edit" href="<?php echo get_url('reporting','edit_custom_report', array('id' => $report->getId()))?>"><?php echo lang('edit') ?></a> <?php } ?> <?php if ($report->canDelete(logged_user())) { ?> <a style="margin-right:5px" class="internalLink coViewAction ico-delete" href="javascript:og.deleteReport(<?php echo $report->getId() ?>)"><?php echo lang('delete') ?></a> <?php } ?> </div> <div style="float:right;max-width:700px;" id="report-<?php echo $report->getId();?>"> <span class="breadcrumb"></span> <script> <?php $crumbOptions = json_encode($report->getMembersToDisplayPath()); $crumbJs = " og.getCrumbHtml($crumbOptions) ";?> var crumbHtml = <?php echo $crumbJs;?>; $("#report-<?php echo $report->getId()?> .breadcrumb").html(crumbHtml); </script> </div> <div class="desc"><?php echo $report->getDescription() ?></div> </div> </li> <?php } //foreach?> </ul> <?php } else { echo lang('no custom reports', lang($reportPages[$type_id]['name'])) . '<br/>'; } // if count // Add new custom report if ($can_add_reports) { ?> <br/><a class="internalLink coViewAction ico-add" href="<?php echo get_url('reporting', 'add_custom_report', array('type' => $type_id)) ?>"><?php echo lang('add custom report')?></a> <?php } ?> </div> <?php } // MAIN PAGES?>
/** * @param Report $report * @param SavedReport$savedReport */ public static function resolveReportToSavedReport(Report $report, SavedReport $savedReport) { $savedReport->description = $report->getDescription(); $savedReport->moduleClassName = $report->getModuleClassName(); $savedReport->name = $report->getName(); $savedReport->owner = $report->getOwner(); $savedReport->type = $report->getType(); $data = array(); $data['filtersStructure'] = $report->getFiltersStructure(); $data['currencyConversionType'] = $report->getCurrencyConversionType(); $data['spotConversionCurrencyCode'] = $report->getSpotConversionCurrencyCode(); $data[ComponentForReportForm::TYPE_FILTERS] = self::makeArrayFromComponentFormsAttributesData($report->getFilters()); $data[ComponentForReportForm::TYPE_ORDER_BYS] = self::makeArrayFromComponentFormsAttributesData($report->getOrderBys()); $data[ComponentForReportForm::TYPE_GROUP_BYS] = self::makeArrayFromComponentFormsAttributesData($report->getGroupBys()); $data[ComponentForReportForm::TYPE_DISPLAY_ATTRIBUTES] = self::makeArrayFromComponentFormsAttributesData($report->getDisplayAttributes()); $data[ComponentForReportForm::TYPE_DRILL_DOWN_DISPLAY_ATTRIBUTES] = self::makeArrayFromComponentFormsAttributesData($report->getDrillDownDisplayAttributes()); if ($report->getChart()->type != null) { $data['chart'] = self::makeArrayFromChartForReportFormAttributesData($report->getChart()); } $savedReport->serializedData = serialize($data); }
public function testSave() { $rep = new Report(); $now = date("Y-m-d H:i:s"); $rep->setDescription("test desc"); $rep->setInvolvementKindID(2); $rep->setReportKindID(1); $rep->setLocationID(1); $rep->setPersonID(1); $rep->setDepartmentID(2); $rep->setDateTime($now); $rep->setStatusID(2); $rep->setActionTaken("nothing has been done"); $rep->save(); $this->assertTrue($rep->getID() != NULL); $fetched = new Report(); $fetched->fetch($rep->getID()); $this->assertEquals($rep->getID(), $fetched->getID()); $this->assertEquals($rep->getDescription(), $fetched->getDescription()); $this->assertEquals($rep->getInvolvementKindID(), $fetched->getInvolvementKindID()); $this->assertEquals($rep->getReportKindID(), $fetched->getReportKindID()); $this->assertEquals($rep->getLocationID(), $fetched->getLocationID()); $this->assertEquals($rep->getPersonID(), $fetched->getPersonID()); $this->assertEquals($rep->getDepartmentID(), $fetched->getDepartmentID()); $this->assertEquals($rep->getDateTime(), $fetched->getDateTime()); $this->assertEquals($rep->getStatusID(), $fetched->getStatusID()); $this->assertEquals($rep->getActionTaken(), $fetched->getActionTaken()); //delete from DB for cleanup //TODO -- replace with proper delete method $sql = "DELETE FROM `reports` WHERE id=?"; $sql = $this->db->prepareQuery($sql, $rep->getID()); $this->db->query($sql); }