function binaryTemplateAction() { $templateId = (int) $this->_getParam('templateId'); $reportTemplate = new ReportTemplate(); $reportTemplate->reportTemplateId = $templateId; $reportTemplate->populate(); $this->getResponse()->setHeader('Content-Type', 'application/pdf'); $this->view->content = $reportTemplate->template; $this->render(); }
function populate() { parent::populate(); $db = Zend_Registry::get('dbAdapter'); $repSelect = $db->select()->from('reportQueries')->joinUsing('reportsToQueries', "reportQueryId")->where('reportsToQueries.reportId =' . (int) $this->id); foreach ($db->query($repSelect)->fetchAll() as $row) { $rq = new ReportQuery(); $rq->populateWithArray($row); $this->reportQueries[] = $rq; } $repSelect = $db->select()->from('reportTemplates')->joinUsing('reportsToTemplates', "reportTemplateId")->where('reportsToTemplates.reportId =' . (int) $this->id); foreach ($db->query($repSelect)->fetchAll() as $row) { $rt = new ReportTemplate(); $rt->populateWithArray($row); $this->reportTemplates[] = $rt; } }
function execute($format, $parameter_values = array()) { global $sugar_config, $current_user; global $zuckerreports_config; $result = FALSE; $rt = new ReportTemplate(); $base = substr($this->filename, 0, strrpos($this->filename, ".")); $date = date("ymd_His"); $this->report_result_type = "FORWARD"; if ($this->extension == "stw" || $this->extension == "odt") { $this->report_result_name = $date . "_" . $base . ".zro"; } else { if ($this->extension == "doc") { $this->report_result_name = $date . "_" . $base . ".zrw"; } } $this->report_result_name = strtolower(join("_", explode(" ", $this->report_result_name))); $this->report_result = $this->archive_dir . "/" . $this->report_result_name; $tempdir = $this->get_temp_dir() . create_guid(); $cmdfile = $tempdir . "/cmd.xml"; mkdir($tempdir, 0700); if ($rt->isWindows()) { $abs_report_result = realpath(str_replace("/", "\\", $this->archive_dir)) . "\\" . $this->report_result_name; $abs_tempdir = realpath(str_replace("/", "\\", $tempdir)); } else { $abs_report_result = realpath($this->archive_dir) . "/" . $this->report_result_name; $abs_tempdir = realpath($tempdir); } if ($this->extension == "stw" || $this->extension == "odt") { $data_format = "CSV"; } else { if ($this->extension == "doc") { $data_format = "SIMPLEHTML"; } } $data_success = false; if ($this->querytemplate->object_name == "ListingTemplate") { $this->querytemplate->archive_dir = $tempdir; $this->querytemplate->include_header = TRUE; $this->querytemplate->col_delim = ","; $this->querytemplate->row_delim = "\n"; $data_success = $this->querytemplate->execute($data_format, $parameter_values); } else { if ($this->querytemplate->object_name == "QueryTemplate") { $this->querytemplate->archive_dir = $tempdir; $this->querytemplate->include_header = TRUE; $this->querytemplate->col_delim = ","; $this->querytemplate->row_delim = "\n"; $data_success = $this->querytemplate->execute($data_format, $parameter_values); } } if ($data_success) { $datafile = $this->querytemplate->report_result_name; copy($this->get_resources_dir() . $this->filename, $tempdir . "/" . $this->filename); $f = fopen($cmdfile, "w"); fwrite($f, "<ZuckerReportsCommand><ZuckerReports>\n"); if ($this->extension == "stw") { fwrite($f, " <Application>StarWriter</Application>\n"); } else { if ($this->extension == "odt") { fwrite($f, " <Application>OpenOffice</Application>\n"); } else { if ($this->extension == "doc") { fwrite($f, " <Application>Word</Application>\n"); } } } fwrite($f, " <Destination>" . $format . "</Destination>\n"); if ($format == "Save") { fwrite($f, " <SavePath>" . $this->save_path . "</SavePath>\n"); } fwrite($f, " <DataPath>" . $datafile . "</DataPath>\n"); fwrite($f, " <TemplatePath>" . $this->filename . "</TemplatePath>\n"); fwrite($f, " <Sugar>\n"); fwrite($f, " <SiteUrl>" . $sugar_config['site_url'] . "/</SiteUrl>\n"); fwrite($f, " </Sugar>\n"); fwrite($f, " <Parameter name=\"SUGAR_USER_ID\" value=\"" . $current_user->id . "\"/>\n"); fwrite($f, " <Parameter name=\"SUGAR_USER_NAME\" value=\"" . $current_user->user_name . "\"/>\n"); fwrite($f, " <Parameter name=\"SUGAR_SESSION_ID\" value=\"" . $_REQUEST['PHPSESSID'] . "\"/>\n"); foreach ($parameter_values as $name => $value) { fwrite($f, " <Parameter name=\"" . $name . "\" value=\"" . $value . "\"/>\n"); } fwrite($f, "</ZuckerReports></ZuckerReportsCommand>\n"); fclose($f); $zip_pattern = $zuckerreports_config["zip_cmdline"]; if (empty($zip_pattern) || $zip_pattern == "java") { $success = $rt->execute_java("sun.tools.jar.Main cfM " . $this->report_result . " -C " . $tempdir . " ."); } else { if ($zip_pattern == "zip") { if ($rt->isWindows()) { $exec_path = realpath("modules\\ZuckerReports\\resources") . "\\zip.exe"; } else { $exec_path = "zip"; } $cmdline = "cd \"" . $abs_tempdir . "\" && \"" . $exec_path . "\" \"" . $abs_report_result . "\" *"; $success = $rt->execute_cmd($cmdline); } else { $cmdline = $zip_pattern; $cmdline = str_replace("%DIR%", $abs_tempdir, $cmdline); $cmdline = str_replace("%FILE%", $abs_report_result, $cmdline); $success = $rt->execute_cmd($cmdline); } } if ($success) { $result = TRUE; } else { $this->report_output = $rt->report_output; $result = FALSE; } } else { $this->report_output = $this->querytemplate->report_output; $result = FALSE; } $rt->rec_delete($tempdir); return $result; }
public function actionChallanReport() { $model = new Challan('search'); $table = $this::getTableNameFromModel($model); $colArr = $this::getColumnNames($table); //print_r($_GET);exit; if ($_GET['yt2'] == "Save" && !empty($_GET['Challan']['fields'])) { $template = new ReportTemplate(); $template->on_table = "challan"; $template->name = $_GET['Challan']['temp_name']; $template->fields = implode(",", $_GET['Challan']['fields']); $template->user_id = Yii::app()->User->Id; $template->created = date("Y-m-d H:i:s", time()); if ($template->save()) { Yii::app()->user->setFlash('success1 message1', "Template successfully saved."); $this->render('challanReport', array('model' => $model, 'name' => $name)); } else { Yii::app()->user->setFlash('error1 message1', "There was an error saving this template."); } } elseif ($_GET['yt2'] == "Save" && empty($_GET['Challan']['fields'])) { Yii::app()->user->setFlash('error1 message1', "Please select the report fields."); } elseif ($_GET['yt2'] == "Save" && empty($_GET['Challan']['temp_name'])) { Yii::app()->user->setFlash('error1 message1', "Please enter template name."); } if (!empty($_GET['Challan']['save_search']) && $_GET['Challan']['save_search'] != '') { $_SESSION['qs'][count($_SESSION['qs'])]['name'] = $_GET['Challan']['save_search']; $_SESSION['qs'][count($_SESSION['qs'])]['search'] = $_SERVER['QUERY_STRING']; } $name = array(); foreach ($colArr as $i => $v) { $name[$v] = $model->getAttributeLabel($v); } if (isset($_GET['Challan'])) { $model->attributes = $_GET['Challan']; } //print_r($model);exit; $this->render('challanReport', array('model' => $model, 'name' => $name)); }
function get_by_filename($filename) { $seed = new ReportTemplate(); $results = $seed->get_full_list("", "filename='" . $filename . "'"); if (!empty($results)) { $result = $results[0]; $result->retrieve(); return $result; } else { return NULL; } }
<?php require_once 'include/formbase.php'; require_once 'include/upload_file.php'; require_once 'modules/ZuckerReportTemplate/ReportTemplate.php'; if (isset($_REQUEST['record'])) { $template = new ReportTemplate(); $template->retrieve($_REQUEST['record']); if (!$template->ACLAccess('Delete')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $template->unlink_all_files(); $template->mark_deleted($_REQUEST['record']); } header("Location: index.php?module=" . $_REQUEST['return_module'] . "&action=" . $_REQUEST['return_action'] . "&record=" . $_REQUEST['return_id']);
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return ReportTemplate the loaded model * @throws CHttpException */ public function loadModel($id) { $model = ReportTemplate::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php if ($_GET['yt0'] == "load" && !empty($_GET['Challan']['load_temp_name'])) { $data = ReportTemplate::model()->findByPk($_GET['Challan']['load_temp_name']); $options = array(); $d = explode(",", $data['fields']); foreach ($d as $i => $v) { $options[$v] = array("selected" => true); } // print_r($options);exit; } elseif (!empty($_GET['Challan']['fields'])) { $options = array(); foreach ($_GET['Challan']['fields'] as $i => $v) { $options[$v] = array("selected" => true); } } echo $form->dropDownList($model, 'load_temp_name', CHtml::listData(ReportTemplate::model()->findAllByAttributes(array('user_id' => Yii::app()->user->Id), array('order' => 'name ASC')), 'id', 'name'), array('options' => array($_GET['Challan']['load_temp_name'] => array('selected' => true))), array('empty' => 'Select Template', 'style' => 'float:left;')); ?> <span class="" style="margin-left:10px;"> <?php echo TbHtml::submitButton('Load Template', array('value' => 'load', 'color' => TbHtml::BUTTON_COLOR_SUCCESS, 'style' => 'margin-bottom:10px;')); ?> </span> <span class="" style="margin-left:10px;"> <?php echo CHtml::link(CHtml::button('Manage Template', array('class' => 'btn btn-info', 'disabled' => $mode, 'style' => 'margin-bottom:10px')), Yii::app()->createUrl('/reportTemplate/admin')); ?> </span> </div>