/** * Render the chart output * * @param string $objName object name which is the bizform name * @return void */ public function render($objName) { // get the value of the control that issues the call $chartName = Openbizx::$app->getClientProxy()->getFormInputs("__this"); // get the current UI bizobj $formObj = Openbizx::getObject($objName); // get the existing bizform object $bizDataObj = $formObj->getDataObj(); // get chart config xml file $chartXmlFile = ObjectFactoryHelper::getXmlFileWithPath($objName . "_chart"); $xmlArr = ObjectFactoryHelper::getXmlArray($chartXmlFile); ob_clean(); // get the chart section from config xml file foreach ($xmlArr["BIZFORM_CHART"]["CHARTLIST"]["CHART"] as $chart) { if (count($xmlArr["BIZFORM_CHART"]["CHARTLIST"]["CHART"]) == 1) { $chart = $xmlArr["BIZFORM_CHART"]["CHARTLIST"]["CHART"]; } // try to match the chartName, if no chartName given, always draw the first chart defined in xml file if ($chartName && $chart["ATTRIBUTES"]["NAME"] == $chartName || !$chartName) { if ($chart["ATTRIBUTES"]["GRAPHTYPE"] == 'XY') { $this->xyGraphRender($bizDataObj, $chart); break; } if ($chart["ATTRIBUTES"]["GRAPHTYPE"] == 'Pie') { $this->pieGraphRender($bizDataObj, $chart); break; } } } }
public function loadDialog($formName = null, $id = null) { $formObj1 = Openbizx::getObject($formName); $formObj1->setRecordId($id); //$formObj1->setParentForm($this->formObj->objectName); $output = $formObj1->render(); if (!empty($output)) { Openbizx::$app->getClientProxy()->redrawForm("DIALOG", $output); } }
protected function inheritParentObj() { if (!$this->inheritFrom) { return; } $parentObj = Openbizx::getObject($this->inheritFrom); parent::inheritParentObj(); $this->range = $this->range ? $this->range : $parentObj->range; $this->fixSearchRule = $this->fixSearchRule ? $this->fixSearchRule : $parentObj->fixSearchRule; $this->defaultFixSearchRule = $this->defaultFixSearchRule ? $this->defaultFixSearchRule : $parentObj->defaultFixSearchRule; }
/** * Render the pdf output * * @global BizSystem $g_BizSystem * @param string $viewName name of view object * @return void */ public function renderView($viewName) { $viewObj = Openbizx::getObject($viewName); if ($viewObj) { $viewObj->setConsoleOutput(false); $sHTML = $viewObj->render(); //$sHTML = "Test"; //require_once("dompdf/dompdf_config.inc.php"); $domPdf = new DOMPDF(); $domPdf->load_html($sHTML); //$dompdf->set_paper($_POST["paper"], $_POST["orientation"]); $domPdf->render(); $this->output($domPdf); //$dompdf->stream("dompdf_out.pdf"); } }
/** * Process URL to get the form param and add the form in the FormRefs * * @return void */ protected function processURL() { // if url has form=... $paramForm = isset($_GET['form']) ? $_GET['form'] : null; $paramCForm = isset($_GET['cform']) ? $_GET['cform'] : null; if (!$paramForm) { return; } // add the form in FormRefs if ($paramForm) { if ($this->isInFormRefLibs($paramForm)) { $xmlArr["ATTRIBUTES"]["NAME"] = $paramForm; $xmlArr["ATTRIBUTES"]["SUBFORMS"] = $paramCForm ? $paramCForm : ""; $formRef = new FormReference($xmlArr); $this->formRefs->set($paramForm, $formRef); if ($paramCForm) { if ($this->isInFormRefLibs($paramCForm)) { $xmlArr["ATTRIBUTES"]["NAME"] = $paramCForm; $xmlArr["ATTRIBUTES"]["SUBFORMS"] = ""; $cformRef = new FormReference($xmlArr); $this->formRefs->set($paramCForm, $cformRef); } } } } // check url arg as fld:name=val $getKeys = array_keys($_GET); $paramFields = null; foreach ($getKeys as $key) { if (substr($key, 0, 4) == "fld:") { $fieldName = substr($key, 4); $fieldValue = $_GET[$key]; $paramFields[$fieldName] = $fieldValue; } } if (!$paramFields) { return; } $paramForm = $this->prefixPackage($paramForm); $formObj = Openbizx::getObject($paramForm); $formObj->setRequestParams($paramFields); }
/** * Audit DataObj * * @param string $dataObjName * @return boolean * @todo all return false? really? */ public function audit($dataObjName) { // get audit dataobj $auditDataObj = Openbizx::getObject($this->auditDataObj); if (!$auditDataObj) { return false; } // get the source dataobj $srcDataObj = Openbizx::getObject($dataObjName); if (!$srcDataObj) { return false; } // for each onaudit field, add a record in audit dataobj $auditFields = $srcDataObj->getOnAuditFields(); foreach ($auditFields as $field) { if ($field->oldValue == $field->value) { continue; } $recArr = $auditDataObj->newRecord(); if ($recArr == false) { Openbizx::$app->getLog()->log(LOG_ERR, "DATAOBJ", $auditDataObj->getErrorMessage()); return false; } $profile = Openbizx::$app->getUserProfile(); $recArr['DataObjName'] = $dataObjName; $recArr['ObjectId'] = $srcDataObj->getFieldValue("Id"); $recArr['FieldName'] = $field->objectName; $recArr['OldValue'] = $field->oldValue; $recArr['NewValue'] = $field->value; $recArr['ChangeTime'] = date("Y-m-d H:i:s"); $recArr['ChangeBy'] = $profile["USERID"]; $recArr['ChangeFrom'] = $_SERVER['REMOTE_ADDR']; $recArr['RequestURI'] = $_SERVER['REQUEST_URI']; $recArr['Timestamp'] = date("Y-m-d H:i:s"); $ok = $auditDataObj->insertRecord($recArr); if ($ok == false) { Openbizx::$app->getLog()->log(LOG_ERR, "DATAOBJ", $auditDataObj->getErrorMessage()); return false; } } }
/** * 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)); }
private static function _removeRecord1toM($dataObj, $recArr) { $column = $dataObj->association['Column']; $field = $dataObj->getFieldNameByColumn($column); $column2 = $dataObj->association['Column2']; $field2 = $dataObj->getFieldNameByColumn($column2); $newRecArr["Id"] = $recArr["Id"]; $newRecArr[$field] = ''; if ($field2) { $newRecArr[$field2] = ''; } $cond_column = $dataObj->association['CondColumn']; $cond_value = $dataObj->association['CondValue']; if ($cond_column) { $cond_field = $dataObj->getFieldNameByColumn($cond_column); $newRecArr[$cond_field] = $cond_value; } $ok = Openbizx::getObject($dataObj->objectName, 1)->updateRecord($newRecArr, $recArr); if ($ok == false) { return false; } // requery on this object return true; }
/** * Get raw data to display in the spreadsheet. header and data table * * @param string $objName * @return array */ protected function getDataTable($objName) { /* @var $formObj EasyForm */ $formObj = Openbizx::getObject($objName); // get the existing EasyForm|BizForm object // if BizForm, call BizForm::renderTable if ($formObj instanceof BizForm) { $dataTable = $formObj->renderTable(); } // if EasyForm, call EasyForm->DataPanel::renderTable if ($formObj instanceof EasyForm) { $recordSet = $formObj->fetchDataSet(); $dataSet = $formObj->dataPanel->renderTable($recordSet); foreach ($dataSet['elems'] as $elem) { $labelRow[] = $elem['label']; } $dataTable = array_merge(array($labelRow), $dataSet['data']); } return $dataTable; }
/** * Cancel, clean up the sessions of view and all forms * * @return void */ public function cancel() { // call all step forms Cancel method if (is_array($this->formStates)) { foreach ($this->formStates as $formName => $state) { if ($state['visited']) { Openbizx::getObject($formName)->cancel(); } } } $this->dropSession = true; }
/** * Authenticate User that stored in database * * @param string $userName * @param string $password * @return boolean */ protected function authDBUser($userName, $password) { $boAuth = Openbizx::getObject($this->authticationDataObj); if (!$boAuth) { return false; } $searchRule = "[login]='{$userName}'"; $recordList = array(); $boAuth->fetchRecords($searchRule, $recordList, 1); $encType = $recordList[0]["enctype"]; $realPassword = $recordList[0]["password"]; if ($this->checkPassword($encType, $password, $realPassword)) { return true; } return false; }
/** * Add a record (popup) to the parent form if OK button clicked, (M-M or M-1/1-1) * * @return void */ public function addToParent($recIds = null) { if (!is_array($recIds)) { $recIdArr = array(); $recIdArr[] = $recIds; } else { $recIdArr = $recIds; } /* @var $parentForm EasyForm */ $parentForm = Openbizx::getObject($this->parentFormName); foreach ($recIdArr as $recId) { //clear parent form search rules $this->searchRule = ""; $parentForm->getDataObj()->clearSearchRule(); $do = $this->getDataObj(); $baseSearchRule = $do->baseSearchRule; $do->baseSearchRule = ""; $do->clearSearchRule(); $rec = $do->fetchById($recId); $do->baseSearchRule = $baseSearchRule; if (!$rec) { $rec = Openbizx::getObject($do->objectName, 1)->fetchById($recId); } // add record to parent form's dataObj who is M-M or M-1/1-1 to its parent dataobj $ok = $parentForm->getDataObj()->addRecord($rec, $bPrtObjUpdated); if (!$ok) { return $parentForm->processDataObjError($ok); } } $this->close(); $parentForm->rerender(); if ($parentForm->parentFormName) { $parentForm->renderParent(); } }
/** * Audit trail * * @param array $argList * @return void */ protected function auditTrail($argList) { $auditServiceName = $argList["AuditService"]; $auditService = Openbizx::getObject($auditServiceName); if ($auditService == null) { return; } $dataObjName = $argList["DataObjectName"]; $ok = $auditService->audit($dataObjName); if ($ok == false) { // log $auditSvc->getErrorMsg(); } }
/** * 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; }
/** * Log that an email attemp was made. * We assume it was successfull, since \Zend_Mail throws an exception otherwise * * @param string $subject * @param array $To * @param array $CCs * @param array $BCCs * @return mixed boolean|string|void */ public function logEmail($result, $subject, $body = NULL, $TOs = NULL, $CCs = NULL, $BCCs = NULL) { //Log the email attempt $recipients = ''; // add TO addresses if ($TOs) { foreach ($TOs as $to) { if (is_array($to)) { $recipients .= $to['name'] . "<" . $to['email'] . ">;"; } else { $recipients .= $to . ";"; } } } // add CC addresses if ($CCs) { foreach ($CCs as $cc) { if (is_array($cc)) { $recipients .= $cc['name'] . "<" . $cc['email'] . ">;"; } else { $recipients .= $cc . ";"; } } } // add BCC addresses if ($BCCs) { foreach ($BCCs as $bcc) { if (is_array($bcc)) { $recipients .= $bcc['name'] . "<" . $bcc['email'] . ">;"; } else { $recipients .= $bcc . ";"; } } } if ($this->_logType == 'DB') { $account = $this->accounts->get($this->useAccount); $sender_name = $account->fromName; $sender = $account->fromEmail; // Store the message log $boMessageLog = Openbizx::getObject($this->_logObject); $mlArr = $boMessageLog->newRecord(); $mlArr["sender"] = $sender; $mlArr["sender_name"] = $sender_name; $mlArr["recipients"] = $recipients; $mlArr["subject"] = $subject; $mlArr["content"] = $body; $mlArr["result"] = $result; /* * as long as data could read from db, its no longer need to addslashes //Escape Data since this may contain quotes or other goodies foreach ($mlArr as $key => $value) { $mlArr[$key] = addslashes($value); } */ $ok = $boMessageLog->insertRecord($mlArr); if (!$ok) { return $boMessageLog->getErrorMessage(); } else { return TRUE; } } else { $back_trace = debug_backtrace(); if ($result == 'Success') { $logNum = LOG_INFO; } else { $logNum = LOG_ERR; } Openbizx::$app->getLog()->log($logNum, "EmailService", "Sent email with subject - \"{$subject}\" and body - {$body} to - {$recipients} with result {$result}.", NULL, $back_trace); } }
/** * Import from XML file, the file read from client (uploaded by user) * * @param string $objName * @return void */ public function importXML($objName) { // read in file from $_FILE // read in file data and attributes foreach ($_FILES as $file) { $error = $file['error']; if ($error != 0) { $this->reportError($error); return; } $tmpName = $file['tmp_name']; $xml = simplexml_load_file($tmpName); if (!$xml) { $errorMsg = "Invalid input data format, could not create xml object."; Openbizx::$app->getClientProxy()->showErrorMessage($errorMsg); return; } // only read the first one break; } // get the current UI bizobj /* @var $form EasyForm */ $form = Openbizx::getObject($objName); // get the existing bizform object /* @var $parentForm EasyForm */ $parentForm = Openbizx::getObject($form->GetParentForm()); /* @var $dataObj BizDataObj */ $dataObj = $parentForm->getDataObj(); //$oldCacheMode = $dataObj->GetCacheMode(); //$dataObj->SetCacheMode(0); // turn off cache mode, not affect the current cache // check if BizDataObj name matches $dataObjName = $xml['Name']; if ($dataObj->objectName != ${$dataObjName}) { $errorMsg = "Invalid input data. Input data object is not same as the current data object."; Openbizx::$app->getClientProxy()->showErrorMessage($errorMsg); return; } // read records foreach ($xml->Record as $record) { // insert record // todo: check if there's same user keys in the table $recArray = null; $recArray = $dataObj->newRecord(); foreach ($record as $field) { $value = ""; foreach ($field->attributes() as $attributeName => $attributeValue) { if ($attributeName == 'Name') { $name = $attributeValue . ""; } else { if ($attributeName == 'Value') { $value = $attributeValue . ""; } } } if ($name != "Id") { $recArray[$name] = $value; } } if (!$dataObj->insertRecord($recArray)) { $errorMsg = $dataObj->getErrorMessage(); Openbizx::$app->getClientProxy()->showErrorMessage($errorMsg); return; } } $form->setFormState(1); // indicate the import is done }
protected function prepareSubFormsDataObj() { if ($this->subForms && $this->getDataObj()) { foreach ($this->subForms as $subForm) { $formObj = Openbizx::getObject($subForm); $dataObj = $this->getDataObj()->getRefObject($formObj->dataObjName); if ($dataObj) { $formObj->setDataObj($dataObj); } } } }