protected function ManageOrders($MsgDesc = "", $MsgStatus = "") { $GLOBALS['HideClearResults'] = "none"; $status = array(); $num_custom_searches = 0; $numOrders = 0; // Fetch any results, place them in the data grid $GLOBALS['OrderDataGrid'] = $this->ManageOrdersGrid($numOrders, $numDeletedOrders); // Was this an ajax based sort? Return the table now if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] == 1) { echo $GLOBALS['OrderDataGrid']; return; } if(isset($_REQUEST['searchQuery']) || isset($_GET['searchId'])) { $GLOBALS['HideClearResults'] = ""; } if(isset($this->_customSearch['searchname'])) { $GLOBALS['ViewName'] = $this->_customSearch['searchname']; if(!empty($this->_customSearch['searchlabel'])) { $GLOBALS['HideDeleteViewLink'] = "none"; } } else { $GLOBALS['ViewName'] = GetLang('AllOrders'); $GLOBALS['HideDeleteViewLink'] = "none"; } // Do we display the add order buton? if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Add_Orders)) { $GLOBALS['AddOrderButton'] = '<input type="button" value="' . GetLang('AddAnOrder') . '..." class="FormButton" style="width:100px" onclick="document.location.href=\'index.php?ToDo=addOrder\'" />'; } else { $GLOBALS['AddOrderButton'] = ''; } $GLOBALS['OrderActionOptions'] = '<option selected="1">' . GetLang('ChooseAction') . '</option>'; $searchDeletedOrders = 'no'; if (isset($_REQUEST['searchDeletedOrders'])) { $searchDeletedOrders = $_REQUEST['searchDeletedOrders']; } if ($searchDeletedOrders != 'only') { // Do we need to disable the delete button? if (!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Delete_Orders) || $numOrders == 0) { $args = 'disabled="disabled"'; } else { $args = 'value="delete"'; } $GLOBALS['OrderActionOptions'] .= '<option ' . $args . '>' . GetLang('DeleteSelected') . '</option>'; } $searchGet = $_GET; if (isset($searchGet['searchId']) && $searchGet['searchId'] == 0) { // this is a nasty hack but I can't right now figure out a better way of making count($_GET) work as // expected when the clicking 'view: all orders' which is '&ToDo=viewOrders&searchId=0' unset($searchGet['searchId']); } if ($searchDeletedOrders != 'no') { if (!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Undelete_Orders) || $numOrders == 0) { $GLOBALS['OrderActionOptions'] .= '<option disabled="disabled">' . isc_html_escape(GetLang('UndeleteSelected')) . '</option>'; } else { $GLOBALS['OrderActionOptions'] .= '<option value="undelete">' . isc_html_escape(GetLang('UndeleteSelected')) . '</option>'; } if (!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Purge_Orders) || $numOrders == 0) { $GLOBALS['OrderActionOptions'] .= '<option disabled="disabled">' . isc_html_escape(GetLang('PurgeSelected')) . '</option>'; } else { $GLOBALS['OrderActionOptions'] .= '<option value="purge">' . isc_html_escape(GetLang('PurgeSelected')) . '</option>'; } } if ($searchDeletedOrders == 'only' && GetConfig('DeletedOrdersAction') == 'purge') { // show a notice about searching for deleted orders when the feature is turned off FlashMessage(GetLang('OrderArchivingIsTurnedOff'), MSG_INFO); } if($numOrders > 0) { if($MsgDesc == "" && (isset($_REQUEST['searchQuery']) || count($searchGet) > 1) && !isset($_GET['selectOrder'])) { if($numOrders == 1) { $MsgDesc = GetLang('OrderSearchResultsBelow1'); } else { $MsgDesc = sprintf(GetLang('OrderSearchResultsBelowX'), $numOrders); } $MsgStatus = MSG_SUCCESS; } $args1 = 'value="printInvoice"'; $args2 = 'value="printSlip"'; } else { $args1 = 'disabled="disabled"'; $args2 = 'disabled="disabled"'; } $GLOBALS['OrderActionOptions'] .= '<option ' . $args1 . '>' . GetLang('PrintInvoicesSelected') . '</option>'; $GLOBALS['OrderActionOptions'] .= '<option ' . $args2 . '>' . GetLang('PrintPackingSlipsSelected') . '</option>'; if(!gzte11(ISC_MEDIUMPRINT)) { $GLOBALS[base64_decode('SGlkZUV4cG9ydA==')] = "none"; $GLOBALS[B('ZGlzYWJsZU9yZGVyRXhwb3J0cw==')] = true; } $GLOBALS['OrderActionOptions'] .= '<option disabled="disabled"></option><optgroup label="' . GetLang('BulkOrderStatus') . '">'; $result = $GLOBALS['ISC_CLASS_DB']->Query("SELECT * FROM [|PREFIX|]order_status ORDER BY statusorder ASC"); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $GLOBALS['OrderActionOptions'] .= '<option value="updateStatus' . $row['statusid'] . '">' . $row['statusdesc'] . '</option>'; } $GLOBALS['OrderActionOptions'] .= '</optgroup>'; if (!isset($_REQUEST['searchId'])) { $_REQUEST['searchId'] = 0; } // Get the custom search as option fields $GLOBALS['CustomSearchOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CUSTOMSEARCH']->GetSearchesAsOptions($_REQUEST['searchId'], $num_custom_searches, "AllOrders", "viewOrders", "customOrderSearch"); // the above is pre-formatted, need it as raw data for the iphone $GLOBALS['customSearchList'] = $GLOBALS['ISC_CLASS_ADMIN_CUSTOMSEARCH']->GetSearches(); if(!isset($_REQUEST['searchId'])) { $GLOBALS['HideDeleteCustomSearch'] = "none"; } else { $GLOBALS['CustomSearchId'] = (int)$_REQUEST['searchId']; } $GLOBALS['OrderIntro'] = GetLang('ManageOrdersIntro'); $GLOBALS['Message'] = ''; // No orders if($numOrders == 0) { $GLOBALS['DisplayGrid'] = "none"; if(count($searchGet) > 1) { // Performing a search of some kind if ($MsgDesc == "") { $GLOBALS['Message'] = MessageBox(GetLang('NoOrderResults'), MSG_ERROR); if ($numDeletedOrders) { $deletedUrl = $searchGet; $deletedUrl['searchDeletedOrders'] = 'only'; $deletedUrl = 'index.php?' . http_build_query($deletedUrl); $GLOBALS['Message'] .= MessageBox(GetLang('DeletedOrdersMatchedYourSearch', array( 'viewDeletedOrdersUrl' => $deletedUrl, )), MSG_INFO, 'MessageBoxTrash'); unset($deletedUrl); } } } else { $GLOBALS['Message'] = MessageBox(GetLang('NoOrders'), MSG_SUCCESS); $GLOBALS['DisplaySearch'] = "none"; } unset($searchGet); } if($MsgDesc != "") { $GLOBALS['Message'] = MessageBox($MsgDesc, $MsgStatus); } $flashMessages = GetFlashMessages(); if(is_array($flashMessages)) { foreach($flashMessages as $flashMessage) { $GLOBALS['Message'] .= MessageBox($flashMessage['message'], $flashMessage['type']); } } if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Export_Orders)) { $GLOBALS['ExportAction'] = "index.php?ToDo=startExport&t=orders"; if (isset($GLOBALS['CustomSearchId']) && $GLOBALS['CustomSearchId'] != '0') { $GLOBALS['ExportAction'] .= "&searchId=" . $GLOBALS['CustomSearchId']; } else { $params = $_GET; unset($params['ToDo']); if (!empty($params)) { $GLOBALS['ExportAction'] .= "&" . http_build_query($params); } } } $selectOrder = ''; if (!empty($_GET['selectOrder']) && isId($_GET['selectOrder'])) { $selectOrder = 'QuickView(' . $_GET['selectOrder'] . ');'; } $GLOBALS['SelectOrder'] = $selectOrder; // Used for iPhone interface $GLOBALS['OrderStatusOptions'] = $this->GetOrderStatusOptions(); if ($numOrders && $GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Export_Orders)) { $exportAction = "index.php?ToDo=startExport&t=orders"; if (isset($GLOBALS['CustomSearchId']) && $GLOBALS['CustomSearchId'] != '0') { $exportAction .= "&searchId=" . $GLOBALS['CustomSearchId']; } else { $params = $_GET; unset($params['ToDo']); if (!empty($params)) { $exportAction .= "&" . http_build_query($params); } } $searchQueryForExport = $_POST + $_GET; foreach ($searchQueryForExport as $index => $value) { if ($value === '') { unset($searchQueryForExport[$index]); } } unset($searchQueryForExport['ToDo'], $searchQueryForExport['SubmitButton1'], $searchQueryForExport['sortField'], $searchQueryForExport['sortOrder'], $searchQueryForExport['SearchButton_x'], $searchQueryForExport['SearchButton_y']); $searchQueryForExport = isc_json_encode($searchQueryForExport); $orderExportMenu = array(); $orderExportMenu[] = array( array( 'backgroundImage' => 'images/export.gif', 'label' => GetLang('EmailIntegrationExportToFile'), 'class' => 'exportMenuLink', 'href' => $exportAction, ), ); $emailModules = ISC_EMAILINTEGRATION::getConfiguredModules(); foreach ($emailModules as /** @var ISC_EMAILINTEGRATION */$emailModule) { if (!$emailModule->supportsBulkExport()) { // not all modules have to support bulk exports continue; } $orderExportMenuModules[] = array( 'backgroundImage' => '../modules/' . str_replace('_', '/', $emailModule->GetId()) . '/images/16x16.png', 'label' => GetLang('EmailIntegrationExportToModule', array('module' => $emailModule->GetName())), 'href' => 'javascript:Interspire_EmailIntegration_ModuleExportMachine.start({ exportType: "Order", exportModule: "' . $emailModule->GetId() . '", exportSearch: ' . $searchQueryForExport . ' });', ); } if (!empty($orderExportMenuModules)) { $orderExportMenu[] = $orderExportMenuModules; $this->engine->bodyScripts[] = '../javascript/fsm.js'; $this->engine->bodyScripts[] = '../javascript/jquery/plugins/disabled/jquery.disabled.js'; $this->engine->bodyScripts[] = '../javascript/ajaxDataProvider.js'; $this->engine->bodyScripts[] = 'script/emailintegration.js'; $this->engine->bodyScripts[] = 'script/emailintegration.export.js'; } $this->template->assign('orderExportMenu', $orderExportMenu); } else { $this->template->assign('disableOrderExports', true); } $this->template->display('orders.manage.tpl'); }
private function ManageCustomers($MsgDesc = "", $MsgStatus = "") { $GLOBALS['HideClearResults'] = "none"; $numCustomers = 0; // Fetch any results, place them in the data grid $GLOBALS['CustomerDataGrid'] = $this->ManageCustomersGrid($numCustomers); // Was this an ajax based sort? Return the table now if (isset($_REQUEST['ajax']) && $_REQUEST['ajax'] == 1) { echo $GLOBALS['CustomerDataGrid']; return; } if (isset($this->_customSearch['searchname'])) { $GLOBALS['ViewName'] = isc_html_escape($this->_customSearch['searchname']); } else { $GLOBALS['ViewName'] = GetLang('AllCustomers'); $GLOBALS['HideDeleteViewLink'] = "none"; } if (isset($this->_customSearch['searchname'])) { $GLOBALS['CustomSearchName'] = ": ".isc_html_escape($this->_customSearch['searchname']); } // Get the custom search as option fields $num_custom_searches = 0; $GLOBALS['CustomSearchOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CUSTOMSEARCH']->GetSearchesAsOptions(@$_GET['searchId'], $num_custom_searches, "AllCustomers", "viewCustomers", "customCustomerSearch"); if (!isset($_REQUEST['searchId'])) { $GLOBALS['HideDeleteCustomSearch'] = "none"; } else { $GLOBALS['CustomSearchId'] = (int)$_REQUEST['searchId']; } // Do we need to disable the add button? if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Add_Customer)) { $GLOBALS['DisableAdd'] = "DISABLED"; } // Do we need to disable the delete button? if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Delete_Customers) || $numCustomers == 0) { $GLOBALS['DisableDelete'] = "DISABLED"; } // Do we need to disable the expory button? if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Export_Customers) || $numCustomers == 0) { $GLOBALS['DisableExport'] = "DISABLED"; } if (isset($_REQUEST['searchQuery']) || isset($_GET['searchId'])) { $GLOBALS['HideClearResults'] = ""; } $GLOBALS['CustomerIntro'] = GetLang('ManageCustomersIntro'); if ($numCustomers > 0) { if ($MsgDesc == "" && (isset($_REQUEST['searchQuery']) || isset($_GET['searchId']))) { if ($numCustomers == 1) { $MsgDesc = GetLang('CustomerSearchResultsBelow1'); } else { $MsgDesc = sprintf(GetLang('CustomerSearchResultsBelowX'), $numCustomers); } $MsgStatus = MSG_SUCCESS; } } else { $GLOBALS['DisplayGrid'] = "none"; if (count($_GET) > 1) { if ($MsgDesc == "") { $GLOBALS['Message'] = MessageBox(GetLang('NoCustomerResults'), MSG_ERROR); } } else { // No actual custoemrs $GLOBALS['DisplaySearch'] = "none"; $GLOBALS['Message'] = MessageBox(GetLang('NoCustomers'), MSG_SUCCESS); } } if (!gzte11(ISC_MEDIUMPRINT)) { $GLOBALS[base64_decode('SGlkZUV4cG9ydA==')] = "none"; } if ($MsgDesc != "") { $GLOBALS['Message'] = MessageBox($MsgDesc, $MsgStatus); } $flashMessages = GetFlashMessages(); if(is_array($flashMessages) && !empty($flashMessages)) { $GLOBALS['Message'] = ''; foreach($flashMessages as $flashMessage) { $GLOBALS['Message'] .= MessageBox($flashMessage['message'], $flashMessage['type']); } } if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Export_Customers)) { $exportAction = "index.php?ToDo=startExport&t=customers"; if (isset($GLOBALS['CustomSearchId']) && $GLOBALS['CustomSearchId'] != '0') { $exportAction .= "&searchId=" . $GLOBALS['CustomSearchId']; } else { $params = $_GET; unset($params['ToDo']); if (!empty($params)) { $exportAction .= "&" . http_build_query($params); } } $searchQueryForExport = $_POST + $_GET; foreach ($searchQueryForExport as $index => $value) { if ($value === '') { unset($searchQueryForExport[$index]); } } unset($searchQueryForExport['ToDo'], $searchQueryForExport['SubmitButton1'], $searchQueryForExport['sortField'], $searchQueryForExport['sortOrder'], $searchQueryForExport['SearchButton_x'], $searchQueryForExport['SearchButton_y']); $searchQueryForExport = isc_json_encode($searchQueryForExport); $customerExportMenu = array(); $customerExportMenu[] = array( array( 'backgroundImage' => 'images/export.gif', 'label' => GetLang('EmailIntegrationExportToFile'), 'class' => 'exportMenuLink', 'href' => $exportAction, ), ); $customerExportMenuModules = array(); $emailModules = ISC_EMAILINTEGRATION::getConfiguredModules(); foreach ($emailModules as /** @var ISC_EMAILINTEGRATION */$emailModule) { if (!$emailModule->supportsBulkExport()) { // not all modules have to support bulk exports continue; } $customerExportMenuModules[] = array( 'backgroundImage' => '../modules/' . str_replace('_', '/', $emailModule->GetId()) . '/images/16x16.png', 'label' => GetLang('EmailIntegrationExportToModule', array('module' => $emailModule->GetName())), 'href' => 'javascript:Interspire_EmailIntegration_ModuleExportMachine.start({ exportType: "Customer", exportModule: "' . $emailModule->GetId() . '", exportSearch: ' . $searchQueryForExport . ' });', ); } if (!empty($customerExportMenuModules)) { $customerExportMenu[] = $customerExportMenuModules; $this->engine->bodyScripts[] = '../javascript/fsm.js'; $this->engine->bodyScripts[] = '../javascript/jquery/plugins/disabled/jquery.disabled.js'; $this->engine->bodyScripts[] = '../javascript/ajaxDataProvider.js'; $this->engine->bodyScripts[] = 'script/emailintegration.js'; $this->engine->bodyScripts[] = 'script/emailintegration.export.js'; // disabled for now until batch rule processing is implemented, as the existing, single-subscription rule processing is too slow for bulk export // $customerExportMenu[] = array( // array( // 'backgroundImage' => 'images/export_to_rules.gif', // 'label' => GetLang('EmailIntegrationExportToNewsletterRules'), // 'href' => 'javascript:Interspire_EmailIntegration_RuleExportMachine.start({ exportType: "Customer", exportRule: "NewsletterSubscribed", exportSearch: ' . $searchQueryForExport . ' });', // ), // ); } $this->template->assign('customerExportMenu', $customerExportMenu); } $this->template->display('customers.manage.tpl'); }
/** * Polls each configured email provider module to determine which format preferences are available * * @return array An array of preference id => description values */ public function GenerateMailFormatPreferences() { $modules = ISC_EMAILINTEGRATION::getConfiguredModules(); $preferences = array(); foreach ($modules as /** @var ISC_EMAILINTEGRATION */$module) { $modulePreferences = $module->getAvailableMailFormatPreferences(); foreach ($modulePreferences as $preference) { if (isset($preferences[$preference])) { continue; } $preferences[$preference] = GetLang('EmailFormatDescription_' . $preference); } } ksort($preferences); return $preferences; }