/** * render the report output * * @param string $objName object name which is the bizform name * @return void */ public function render($objName) { // get the current UI bizobj $bizform = Openbizx::getObject($objName); // get the existing bizform object $bizobj = $bizform->getDataObj(); $h = opendir($this->targetReportPath); if (!$h) { echo "cannot read dir " . $this->targetReportPath; exit; } // create a tmp csv file for hold the data, then feed csv file to report engine $uid = $this->getUniqueString(); $tmpfname = $this->targetReportPath . $uid . ".csv"; //echo "csv file is at $tmpfname.<br>"; $fp = fopen($tmpfname, 'w'); $keyList = $bizform->recordRow->GetSortControlKeys(); $fieldNames = array(); foreach ($keyList as $key) { $fieldNames[] = $bizform->GetControl($key)->bizFieldName; } fputcsv($fp, $fieldNames); $recList = $bizobj->directFetch(); foreach ($recList as $recArray) { unset($fieldValues); $fieldValues = array(); $line = ""; foreach ($keyList as $key) { $fieldValues[] = $recArray[$bizform->GetControl($key)->bizFieldName]; } fputcsv($fp, $fieldValues); } fclose($fp); $i = 0; foreach ($keyList as $key) { $rpt_fields[$i]["name"] = $bizform->GetControl($key)->bizFieldName; $rpt_fields[$i]["type"] = $bizobj->getField($rpt_fields[$i]["name"])->type; $i++; } // dataobj.rptdesign.tpl // $rpt_data_dir, $rpt_title, $rpt_csv_file, $rpt_fields[](name,type) $smarty = TemplateHelper::getSmartyTemplate(); $smarty->assign("rpt_data_dir", $this->targetReportPath); $smarty->assign("rpt_title", $bizform->title); $smarty->assign("rpt_csv_file", basename($tmpfname)); $smarty->assign("rpt_fields", $rpt_fields); $reportContent = $smarty->fetch($this->rptTemplate); $tmpRptDsgn = $this->targetReportPath . $uid . ".rptdesign"; //echo "temp rpt design file is at $tmpRptDsgn.<br>"; $fp = fopen($tmpRptDsgn, 'w'); fwrite($fp, $reportContent); fclose($fp); ob_clean(); $designFileName = $uid . ".rptdesign"; $content = "<div style='font-family:Arial; font-size:12px; background-color:#FCFCFC;'>"; $content .= "Reports can be viewed as "; $content .= "<li><a href='" . $this->birtViewer . "/run?__report=report\\{$designFileName}' target='__blank'>HTML report</a></li>"; $content .= "<li><a href='" . $this->birtViewer . "/run?__report=report\\{$designFileName}&__format=pdf' target='__blank'>PDF report</a></li>"; $content .= "<li><a href='" . $this->birtViewer . "/frameset?__report=report\\{$designFileName}' target='__blank'>Interactive report</a></li>"; $content .= "</div>"; echo $content; exit; }
/** * Render PHP template for form object * * @param EasyForm $formObj * @param string $tplFile * @return string result of rendering process */ protected static function renderPHP($formObj, $tplAttributes = array()) { $form = TemplateHelper::getZendTemplate(); $tplFile = TemplateHelper::getTplFileWithPath($formObj->templateFile, $formObj->package); $form->addScriptPath(dirname($tplFile)); /* $formOutput = $formObj->outputAttrs(); foreach ($formOutput as $k=>$v) { $form->$k = $v; } */ foreach ($tplAttributes as $key => $value) { if ($value == NULL) { $form->{$key} = ''; } else { $form->{$key} = $value; } } // render the formobj attributes //$form->form = $formOutput; return $form->render($formObj->templateFile); }
/** * Render the html tabs * * @global BizSystem $g_BizSystem * @return string html content of the tabs */ public function render() { $curView = Openbizx::$app->getCurrentViewName(); $curViewobj = $curView ? Openbizx::getObject($curView) : null; $profile = Openbizx::$app->getUserProfile(); $svcobj = Openbizx::getService(ACCESS_SERVICE); $role = isset($profile["ROLE"]) ? $profile["ROLE"] : null; // list all views and highlight the current view // pass $tabs(caption, url, target, icon, current) to template $smarty = TemplateHelper::getSmartyTemplate(); $tabs = array(); $i = 0; $hasForms = false; foreach ($this->tabViews as $tview) { // tab is renderd if no definition is found in accessservice.xml (default) if ($svcobj->allowViewAccess($tview->view, $role)) { $tabs[$i]['name'] = $tview->objectName; //Name of each tab--jmmz $tabs[$i]['forms'] = $this->_renderJSCodeForForms($tview->forms); //Configuration of the forms to hide or show--jmmz $tabs[$i]['caption'] = $tview->caption; $tabs[$i]['url'] = $this->_renderURL($tview); //Call the method to render the url--jmmz //If I have forms to hide or show I add the event because I don't need an URL, I need an event if ((bool) $tview->hasForms()) { $tabs[$i]['event'] = $tabs[$i]['url']; //Assign The url rendered to the event on click $tabs[$i]['url'] = 'javascript:void(0)'; //If I put url in '' then the href want send me to another direction $this->setCurrentTabInSession($tview, $curViewobj, $curView); //I set the current tab wrote in session $hasForms = TRUE; } $tabs[$i]['target'] = $tview->target; $tabs[$i]['icon'] = $tview->icon; $tabs[$i]['current'] = $this->isCurrentTab($tview, $curViewobj, $curView); //I get the current tab. $i++; } } $this->setClientScripts($tabs, $hasForms); $smarty->assign("tabs", $tabs); $smarty->assign("tabs_Name", $this->objectName); return $smarty->fetch(TemplateHelper::getTplFileWithPath($this->templateFile, $this->package)); }
/** * Render PHP template for view object * * @param EasyForm $formObj * @param string $tplFile * @return string result of rendering process */ protected static function renderPHP($viewObj, $tplAttributes = array()) { $view = TemplateHelper::getZendTemplate(); $tplFile = TemplateHelper::getTplFileWithPath($viewObj->templateFile, $viewObj->package); $view->addScriptPath(dirname($tplFile)); //Translate Array of template variables to \Zend template object foreach ($tplAttributes as $key => $value) { if ($value == NULL) { $view->{$key} = ''; } else { $view->{$key} = $value; } } if ($viewObj->consoleOutput) { echo $view->render($viewObj->templateFile); } else { return $view->render($viewObj->templateFile); } }