private function GetMethodSettings($templateid = 0) { $settings = array(); //$html = ""; // get a list of each method $methods = ISC_ADMIN_EXPORTMETHOD_FACTORY::GetExportMethodList(); foreach ($methods as $file => $details) { $method = ISC_ADMIN_EXPORTMETHOD_FACTORY::GetExportMethod($details['name']); if ($method->HasSettings()) { $settings[$details['name']] = $method->GetSettings($templateid); } } return $settings; }
private function RunExport() { try { // check for a selected template if (!isset($_POST["template"]) || !$_POST["template"]) { throw new Exception(GetLang("NoTemplateSelected")); } if (!isset($_POST['format'])) { throw new Exception(GetLang("NoMethodSelected")); } $templateid = $_POST["template"]; // check template exists $template = $this->templates->GetTemplate($templateid); // check the file type is available for this template if (!in_array($this->type, explode(",", $template['usedtypes']))) { throw new Exception(sprintf(GetLang("TypeNotAvailable"), $this->type)); } $where = ""; // get the custom search fields if (isset($_POST['ids'])) { $ids = explode(',', $_POST['ids']); $ids = implode(', ', array_map(array($GLOBALS['ISC_CLASS_DB'], "Quote"), $ids)); $details = $this->filetype->GetTypeDetails(); $where = $details['idfield'] . " IN (" . $_POST["ids"] . ")"; } elseif (isset($_POST['searchId'])) { // get the where statement for this search $ret = $this->filetype->GetWhereFromSearch($_POST['searchId']); $where = $ret['where']; } elseif (isset($_POST['params'])) { $params = $this->GetParams($_POST['params']); $where = $this->filetype->GetWhereFromParams($params); } //$_SESSION['mywhere'] = $where; // this variable used in the function ExportRows() by blessen // get the export method the user has chosen $method = ISC_ADMIN_EXPORTMETHOD_FACTORY::GetExportMethod($_POST['format']); // Initialise the export $method->Init($this->filetype, $templateid, $where, $this->vendorid); $details = $this->filetype->GetTypeDetails(); if ($_POST['format'] == "CSV" && $details['name'] == "customers" && $method->settings['AltCustomers']) { // hackery to use alternate customers class $this->filetype = ISC_ADMIN_EXPORTFILETYPE_FACTORY::GetExportFileType("customersalt"); // reinitialise the method with alternate file type $method->Init($this->filetype, $templateid, $where, $this->vendorid); } // run the export $file = $method->Export(); $method_details = $method->GetMethodDetails(); // log the export $GLOBALS['ISC_CLASS_LOG']->LogAdminAction($this->type_title, $template['exporttemplatename'], $method_details['name']); // send the file to the user DownloadFile($file, $this->type . "-" . isc_date("Y-m-d") . "." . $method_details['extension']); exit; } catch (Exception $ex) { FlashMessage($ex->getMessage(), MSG_ERROR); $this->StartExport(); } }
private function RunExport() { try { // check for a selected template if (empty($_REQUEST["template"]) && !$this->filetype->ignore) { throw new Exception(GetLang("NoTemplateSelected")); } if (!isset($_REQUEST['format'])) { throw new Exception(GetLang("NoMethodSelected")); } $details = $this->filetype->GetTypeDetails(); $templateid = $_REQUEST["template"]; if (!$this->filetype->ignore) { // check template exists $template = $this->templates->GetTemplate($templateid); // check the file type is available for this template if (!in_array($this->type, explode(",", $template['usedtypes']))) { throw new Exception(sprintf(GetLang("TypeNotAvailable"), $this->type)); } $templateName = $template['exporttemplatename']; } else { $templateName = $details['title']; } $where = ""; $having = ""; // get the custom search fields if (isset($_REQUEST['ids'])) { $ids = explode(',', $_REQUEST['ids']); $ids = implode(', ', array_map(array($GLOBALS['ISC_CLASS_DB'], "Quote"), $ids)); $where = $details['idfield'] . " IN (" . $_REQUEST["ids"] . ")"; } elseif (isset($_REQUEST['params'])) { $params = $this->GetParams($_REQUEST['params']); $ret = $this->filetype->BuildWhereFromFields($params); if (is_array($ret)) { $where = $ret['where']; if (isset($ret['having'])) { $having = $ret['having']; } } else { $where = $ret; } } // get the export method the user has chosen $method = ISC_ADMIN_EXPORTMETHOD_FACTORY::GetExportMethod($_REQUEST['format']); $method_details = $method->GetMethodDetails(); $options = new ISC_ADMIN_EXPORTOPTIONS(); $options->setFileType($this->filetype) ->setTemplateId($templateid) ->setWhere($where) ->setHaving($having); // Initialise the export $method->Init($options); // run the export $file = $method->HandleToDo('ExportIntro'); exit; } catch (Exception $ex) { FlashMessage($ex->getMessage(), MSG_ERROR); $this->StartExport(); } }