protected function GetControlHtml() { $strStyle = $this->GetStyleAttributes(); if ($strStyle) { $strStyle = sprintf('style="%s"', $strStyle); } $strAttributes = $this->GetAttributes(); // Store the Output Buffer locally $strAlreadyRendered = ob_get_contents(); $JavaScriptArray = QApplication::$JavaScriptArray; $AlertMessageArray = QApplication::$AlertMessageArray; $JavaScriptArrayHighPriority = QApplication::$JavaScriptArrayHighPriority; ob_clean(); // Evaluate the template require '../common/header_menu.tpl.php'; $strTemplateEvaluated = ob_get_contents(); ob_clean(); // Restore the output buffer and return evaluated template print $strAlreadyRendered; $strToReturn = sprintf('<span id="%s" %s%s>%s</span>', $this->strControlId, $strStyle, $strAttributes, $strTemplateEvaluated); QApplication::$JavaScriptArray = $JavaScriptArray; QApplication::$AlertMessageArray = $AlertMessageArray; QApplication::$JavaScriptArrayHighPriority = $JavaScriptArrayHighPriority; return $strToReturn; }
public static function RenderJavaScript($blnOutput = true) { $strScript = ''; foreach (QApplication::$AlertMessageArray as $strAlert) { $strAlert = addslashes($strAlert); $strScript .= sprintf('alert("%s"); ', $strAlert); } foreach (QApplication::$JavaScriptArrayHighPriority as $strJavaScript) { $strJavaScript = trim($strJavaScript); if (QString::LastCharacter($strJavaScript) != ';') { $strScript .= sprintf('%s; ', $strJavaScript); } else { $strScript .= sprintf('%s ', $strJavaScript); } } foreach (QApplication::$JavaScriptArray as $strJavaScript) { $strJavaScript = trim($strJavaScript); if (QString::LastCharacter($strJavaScript) != ';') { $strScript .= sprintf('%s; ', $strJavaScript); } else { $strScript .= sprintf('%s ', $strJavaScript); } } QApplication::$AlertMessageArray = array(); QApplication::$JavaScriptArrayHighPriority = array(); QApplication::$JavaScriptArray = array(); if ($strScript) { if ($blnOutput) { _p($strScript, false); } else { return $strScript; } } else { return null; } }
protected function Form_Create() { if (QApplication::QueryString('intDownloadCsv')) { $this->RenderBegin(false); session_cache_limiter('must-revalidate'); // force a "no cache" effect header("Pragma: hack"); // IE chokes on "no cache", so set to something, anything, else. $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT"; header($ExpStr); header('Content-Type: text/csv'); header('Content-Disposition: csv; filename=skipped_records.csv'); $file = fopen(sprintf("%s/%s_contact_skipped.csv", __TRACMOR_TMP__, $_SESSION['intUserAccountId']), "r"); ob_end_clean(); while ($row = fgets($file, 1000)) { print $row; @ob_flush(); flush(); } QApplication::$JavaScriptArray = array(); QApplication::$JavaScriptArrayHighPriority = array(); $this->RenderEnd(false); exit; } // Create the Header Menu $this->ctlHeaderMenu_Create(); //$this->ctlShortcutMenu_Create(); $this->pnlMain_Create(); $this->pnlStepOne_Create(); $this->Buttons_Create(); $this->intStep = 1; $this->intSkippedRecordCount = 0; $this->blnImportEnd = true; $this->btnRemoveArray = array(); $this->arrItemCustomField = array(); $this->Labels_Create(); $this->objDatabase = Asset::GetDatabase(); // Load Custom Field foreach (CustomField::LoadArrayByActiveFlagEntity(1, EntityQtype::Contact) as $objCustomField) { $this->arrItemCustomField[$objCustomField->CustomFieldId] = $objCustomField; } $this->blnError = true; $intRoleId = QApplication::$objUserAccount->RoleId; $objRoleEntityQtypeBuiltInAuthorization = RoleEntityQtypeBuiltInAuthorization::LoadByRoleIdEntityQtypeIdAuthorizationId($intRoleId, EntityQtype::Contact, 2); // Check the user have edit permissions if ($objRoleEntityQtypeBuiltInAuthorization && $objRoleEntityQtypeBuiltInAuthorization->AuthorizedFlag) { $this->blnError = false; } if (isset($intCustomFieldIdArray) && count($intCustomFieldIdArray)) { //QApplication::$Database[1]->EnableProfiling(); // Load restrict permisions for Custom Fields $objConditions = QQ::AndCondition(QQ::Equal(QQN::RoleEntityQtypeCustomFieldAuthorization()->RoleId, (string) $intRoleId), QQ::In(QQN::RoleEntityQtypeCustomFieldAuthorization()->EntityQtypeCustomField->CustomFieldId, $intCustomFieldIdArray), QQ::Equal(QQN::RoleEntityQtypeCustomFieldAuthorization()->AuthorizedFlag, false)); $objClauses = array(); array_push($objClauses, QQ::Expand(QQN::RoleEntityQtypeCustomFieldAuthorization()->EntityQtypeCustomField->EntityQtypeCustomFieldId)); array_push($objClauses, QQ::OrderBy(QQN::RoleEntityQtypeCustomFieldAuthorization()->EntityQtypeCustomFieldId)); $arrRoleEntityQtypeCustomFieldAuthorization = RoleEntityQtypeCustomFieldAuthorization::QueryArray($objConditions, $objClauses); if ($arrRoleEntityQtypeCustomFieldAuthorization) { foreach ($arrRoleEntityQtypeCustomFieldAuthorization as $objRoleAuth) { if (array_key_exists($objRoleAuth->EntityQtypeCustomField->CustomFieldId, $this->arrAssetCustomField)) { unset($this->arrAssetCustomField[$objRoleAuth->EntityQtypeCustomField->CustomFieldId]); } } } //QApplication::$Database[1]->OutputProfiling(); } $this->intUserArray = array(); // Load Users foreach (UserAccount::LoadAll() as $objUser) { $this->intUserArray[strtolower($objUser->Username)] = $objUser->UserAccountId; } $this->strAcceptibleMimeArray = array('text/plain' => 'txt', 'text/comma-separated-values' => 'csv', 'text/csv' => 'csv', 'text/x-comma-separated-values' => 'csv', 'application/vnd.ms-excel' => 'csv', 'application/csv' => 'csv', 'text/x-csv' => 'csv'); }
protected function Form_Create() { if (QApplication::QueryString('intDownloadCsv')) { $this->RenderBegin(false); session_cache_limiter('must-revalidate'); // force a "no cache" effect header("Pragma: hack"); // IE chokes on "no cache", so set to something, anything, else. $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT"; header($ExpStr); header('Content-Type: text/csv'); header('Content-Disposition: csv; filename=skipped_records.csv'); $file = fopen(sprintf("%s%s/%s_skipped.csv", __DOCROOT__ . __SUBDIRECTORY__, __TRACMOR_TMP__, $_SESSION['intUserAccountId']), "r"); ob_end_clean(); while ($row = fgets($file, 1000)) { print $row; @ob_flush(); flush(); } QApplication::$JavaScriptArray = array(); QApplication::$JavaScriptArrayHighPriority = array(); $this->RenderEnd(false); exit; } // Create the Header Menu $this->ctlHeaderMenu_Create(); $this->pnlMain_Create(); $this->pnlStepOne_Create(); $this->Buttons_Create(); $this->intStep = 1; $this->intSkippedRecordCount = 0; $this->blnImportEnd = true; $this->btnRemoveArray = array(); $this->arrAssetCustomField = array(); $this->Labels_Create(); $this->objDatabase = Asset::GetDatabase(); // Load Asset Custom Field foreach (CustomField::LoadArrayByActiveFlagEntity(1, 1) as $objCustomField) { $this->arrAssetCustomField[$objCustomField->CustomFieldId] = $objCustomField; } $this->arrAssetModelCustomField = array(); // Load Asset Model Custom Field foreach (CustomField::LoadArrayByActiveFlagEntity(1, 4) as $objCustomField) { $this->arrAssetModelCustomField[$objCustomField->CustomFieldId] = $objCustomField; } $this->intUserArray = array(); // Load Users foreach (UserAccount::LoadAll() as $objUser) { $this->intUserArray[strtolower($objUser->Username)] = $objUser->UserAccountId; } $this->strAcceptibleMimeArray = array('text/plain' => 'txt', 'text/comma-separated-values' => 'csv', 'text/csv' => 'csv', 'text/x-comma-separated-values' => 'csv', 'application/vnd.ms-excel' => 'csv', 'application/csv' => 'csv', 'text/x-csv' => 'csv'); }
public function lblExportCsv_Click($strFormId, $strControlId, $strParameter) { $this->objForm->RenderCsvBegin(false); session_cache_limiter('must-revalidate'); // force a "no cache" effect header("Pragma: hack"); // IE chokes on "no cache", so set to something, anything, else. $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT"; header($ExpStr); header('Content-Type: text/csv'); header('Content-Disposition: csv; filename=export.csv'); for ($i = 1; $i <= ceil($this->objParentControl->TotalItemCount / 200); $i++) { $this->objParentControl->PageNumber = $i; $this->objParentControl->ItemsPerPage = 200; $this->objParentControl->DataBind(); if ($i == 1) { ob_end_clean(); $this->PrintCsvHeader(); } if ($this->objParentControl->DataSource) { foreach ($this->objParentControl->DataSource as $objObject) { $this->PrintCsvRow($objObject); @ob_flush(); flush(); } } $this->ParentControl->DataSource = null; } QApplication::$JavaScriptArray = array(); QApplication::$JavaScriptArrayHighPriority = array(); $this->objForm->RenderCsvEnd(false); exit; }