/** * Function to display the UI for advance search on any of the module * @param Vtiger_Request $request */ function showAdvancedSearch(Vtiger_Request $request) { //Modules for which search is excluded $excludedModuleForSearch = array('Vtiger', 'Reports'); $viewer = $this->getViewer($request); $moduleName = $request->getModule(); if ($request->get('source_module')) { $moduleName = $request->get('source_module'); } $saveFilterPermitted = true; $saveFilterexcludedModules = array('ModComments', 'RSS', 'Portal', 'Integration', 'PBXManager', 'DashBoard'); if (in_array($moduleName, $saveFilterexcludedModules)) { $saveFilterPermitted = false; } //See if it is an excluded module, If so search in home module if (in_array($moduleName, $excludedModuleForSearch)) { $moduleName = 'Home'; } $module = $request->getModule(); $customViewModel = new CustomView_Record_Model(); $customViewModel->setModule($moduleName); $moduleModel = Vtiger_Module_Model::getInstance($moduleName); $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel); $viewer->assign('SEARCHABLE_MODULES', Vtiger_Module_Model::getSearchableModules()); $viewer->assign('CUSTOMVIEW_MODEL', $customViewModel); if ($moduleName == 'Calendar') { $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType(); } else { $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType(); } $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions()); $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType); $dateFilters = Vtiger_Field_Model::getDateFilterTypes(); foreach ($dateFilters as $comparatorKey => $comparatorInfo) { $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']); $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']); $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $module); $dateFilters[$comparatorKey] = $comparatorInfo; } $viewer->assign('DATE_FILTERS', $dateFilters); $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure()); $viewer->assign('SOURCE_MODULE', $moduleName); $viewer->assign('SOURCE_MODULE_MODEL', $moduleModel); $viewer->assign('MODULE', $module); $viewer->assign('SAVE_FILTER_PERMITTED', $saveFilterPermitted); $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel()); echo $viewer->view('AdvanceSearch.tpl', $moduleName, true); }
function preProcess(Vtiger_Request $request, $display = true) { global $current_user; parent::preProcess($request, false); $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $listViewModel = Vtiger_ListView_Model::getInstance($moduleName); $linkParams = array('MODULE' => $moduleName, 'ACTION' => $request->get('view')); $viewer->assign('CUSTOM_VIEWS', CustomView_Record_Model::getAllByGroup($moduleName)); $this->viewName = $request->get('viewname'); if (empty($this->viewName)) { //If not view name exits then get it from custom view //This can return default view id or view id present in session $customView = new CustomView(); $this->viewName = $customView->getViewId($moduleName); } $quickLinkModels = $listViewModel->getSideBarLinks($linkParams); $viewer->assign('QUICK_LINKS', $quickLinkModels); $this->initializeListViewContents($request, $viewer); $viewer->assign('VIEWID', $this->viewName); //Modified by jmangarret 16jun2015 $viewer->assign('ROLEID', $current_user->roleid); if ($display) { $this->preProcessDisplay($request); } }
public function process(Vtiger_Request $request) { ${"GLOBALS"}["fgwbuhrxu"] = "adb"; $symwrz = "customViewModel"; ${${"GLOBALS"}["fgwbuhrxu"]} = PearDatabase::getInstance(); $cerakpgxi = "recordIds"; ${"GLOBALS"}["ydhdsoshkjcr"] = "params"; $cwhzpepgkpy = "params"; ${${"GLOBALS"}["ydhdsoshkjcr"]} = $request->getAll(); ${${"GLOBALS"}["igosddeyg"]} = (int) ${$cwhzpepgkpy}["viewname"]; ${"GLOBALS"}["eqmrcofnhqq"] = "customViewModel"; ${$symwrz} = CustomView_Record_Model::getInstanceById(${${"GLOBALS"}["igosddeyg"]}); if (${${"GLOBALS"}["eqmrcofnhqq"]}) { ${${"GLOBALS"}["virgnuvno"]} = $request->get("search_key"); ${"GLOBALS"}["qeosukvsm"] = "searchValue"; ${"GLOBALS"}["vrykqprgdfxc"] = "recordIds"; ${${"GLOBALS"}["qeosukvsm"]} = $request->get("search_value"); ${${"GLOBALS"}["mnhnltytyh"]} = $request->get("operator"); if (!empty(${${"GLOBALS"}["mnhnltytyh"]})) { $customViewModel->set("operator", ${${"GLOBALS"}["mnhnltytyh"]}); ${"GLOBALS"}["yvrscvp"] = "searchValue"; $customViewModel->set("search_key", ${${"GLOBALS"}["virgnuvno"]}); $customViewModel->set("search_value", ${${"GLOBALS"}["yvrscvp"]}); } ${${"GLOBALS"}["vrykqprgdfxc"]} = $customViewModel->getRecordIds(array(), $customViewModel->getModule()); } die(json_encode(array("ids" => ${$cerakpgxi}))); }
function getRecordsListFromRequest(Vtiger_Request $request) { global $log; $log->debug("Entering ./views/IndexAjax.php::getRecordsListFromRequest"); $cvId = $request->get('cvid'); $selectedIds = $request->get('selected_ids'); $excludedIds = $request->get('excluded_ids'); if (!empty($selectedIds) && $selectedIds != 'all') { if (!empty($selectedIds) && count($selectedIds) > 0) { return $selectedIds; } } $customViewModel = CustomView_Record_Model::getInstanceById($cvId); if ($customViewModel) { $searchKey = $request->get('search_key'); $searchValue = $request->get('search_value'); $operator = $request->get('operator'); if (!empty($operator)) { $customViewModel->set('operator', $operator); $customViewModel->set('search_key', $searchKey); $customViewModel->set('search_value', $searchValue); } return $customViewModel->getRecordIds($excludedIds); } }
function process(Vtiger_Request $request) { global $log; $log->debug("Entering ./views/MiniListWizard.php::process"); $currentUser = Users_Record_Model::getCurrentUserModel(); $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $viewer->assign('MODULE_NAME', $moduleName); $viewer->assign('WIZARD_STEP', $request->get('step')); switch ($request->get('step')) { case 'step1': $modules = Vtiger_Module_Model::getSearchableModules(); //Since comments is not treated as seperate module unset($modules['ModComments']); $viewer->assign('MODULES', $modules); break; case 'step2': $selectedModule = $request->get('selectedModule'); $filters = CustomView_Record_Model::getAllByGroup($selectedModule); $viewer->assign('ALLFILTERS', $filters); break; case 'step3': $selectedModule = $request->get('selectedModule'); $filterid = $request->get('filterid'); $db = PearDatabase::getInstance(); $generator = new QueryGenerator($selectedModule, $currentUser); $generator->initForCustomViewById($filterid); $listviewController = new ListViewController($db, $currentUser, $generator); $listviewController->getListViewHeaderFields(); $viewer->assign('LIST_VIEW_CONTROLLER', $listviewController); $viewer->assign('SELECTED_MODULE', $selectedModule); break; } $viewer->view('dashboards/MiniListWizard.tpl', $moduleName); }
private function getCVModelFromRequest(Vtiger_Request $request) { $cvId = $request->get('cvid'); if (!empty($cvId)) { $customViewModel = CustomView_Record_Model::getInstanceById($cvId); } else { $customViewModel = CustomView_Record_Model::getCleanInstance(); $customViewModel->setModule($request->get('source_module')); } $customViewData = array( 'cvid' => $cvId, 'viewname' => $customViewModel->get('viewname'), 'setdefault' => $customViewModel->get('setdefault'), 'setmetrics' => $customViewModel->get('setmetrics'), 'status' => $customViewModel->get('status') ); $selectedColumnsList = $request->get('columnslist'); if (!empty($selectedColumnsList)) { $customViewData['columnslist'] = $selectedColumnsList; } return $customViewModel->setData($customViewData); }
protected function getRecordsListFromRequest(Vtiger_Request $request) { $cvId = $request->get('viewname'); $module = $request->get('module'); if (!empty($cvId) && $cvId == "undefined") { $sourceModule = $request->get('sourceModule'); $cvId = CustomView_Record_Model::getAllFilterByModule($sourceModule)->getId(); } $selectedIds = $request->get('selected_ids'); $excludedIds = $request->get('excluded_ids'); if (!empty($selectedIds) && $selectedIds != 'all') { if (!empty($selectedIds) && count($selectedIds) > 0) { return $selectedIds; } } $customViewModel = CustomView_Record_Model::getInstanceById($cvId); if ($customViewModel) { $searchKey = $request->get('search_key'); $searchValue = $request->get('search_value'); $operator = $request->get('operator'); if (!empty($operator)) { $customViewModel->set('operator', $operator); $customViewModel->set('search_key', $searchKey); $customViewModel->set('search_value', $searchValue); } $customViewModel->set('search_params', $request->get('search_params')); return $customViewModel->getRecordIds($excludedIds, $module); } }
public function showTree(Vtiger_Request $request) { $moduleName = $request->getModule(); $sourceModule = $request->get('selectedModule'); $viewer = $this->getViewer($request); $this->template = $this->getTemplate(); if ($this->template) { $recordModel = Settings_TreesManager_Record_Model::getInstanceById($this->template); } else { Vtiger_Functions::throwNewException(vtranslate('ERR_TREE_NOT_FOUND', $moduleName)); } if (!$recordModel) { Vtiger_Functions::throwNewException(vtranslate('ERR_TREE_NOT_FOUND', $moduleName)); } if (!in_array($sourceModule, $this->modules)) { Vtiger_Functions::throwNewException(vtranslate('ERR_MODULE_NOT_FOUND', $moduleName)); } $tree = $this->getCategory(); $treeWithItems = $this->getRecords(); $tree = array_merge($tree, $treeWithItems); $viewer->assign('TREE', Zend_Json::encode($tree)); $viewer->assign('MODULES', $this->modules); $viewer->assign('MODULE', $moduleName); $viewer->assign('SELECTED_MODULE_NAME', $sourceModule); $viewer->assign('CUSTOM_VIEWS', CustomView_Record_Model::getAllByGroup($moduleName)); $viewer->view('AccountsListTree.tpl', $moduleName); }
public function process(Vtiger_Request $request) { $viewer = $this->getViewer($request); $moduleName = $request->get('source_module'); $module = $request->getModule(); $record = $request->get('record'); $moduleModel = Vtiger_Module_Model::getInstance($moduleName); $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel); if (!empty($record)) { $customViewModel = CustomView_Record_Model::getInstanceById($record); $viewer->assign('MODE', 'edit'); } else { $customViewModel = new CustomView_Record_Model(); $customViewModel->setModule($moduleName); $viewer->assign('MODE', ''); } $viewer->assign('ADVANCE_CRITERIA', $customViewModel->transformToNewAdvancedFilter()); $viewer->assign('CURRENTDATE', date('Y-n-j')); $viewer->assign('DATE_FILTERS', Vtiger_Field_Model::getDateFilterTypes()); if ($moduleName == 'Calendar') { $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType(); } else { $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType(); } $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions()); $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType); $dateFilters = Vtiger_Field_Model::getDateFilterTypes(); foreach ($dateFilters as $comparatorKey => $comparatorInfo) { $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']); $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']); $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $module); $dateFilters[$comparatorKey] = $comparatorInfo; } $viewer->assign('DATE_FILTERS', $dateFilters); $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance); $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure()); $viewer->assign('CUSTOMVIEW_MODEL', $customViewModel); $viewer->assign('RECORD_ID', $record); $viewer->assign('MODULE', $module); $viewer->assign('SOURCE_MODULE', $moduleName); $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel()); $viewer->assign('CV_PRIVATE_VALUE', CustomView_Record_Model::CV_STATUS_PRIVATE); $viewer->assign('CV_PENDING_VALUE', CustomView_Record_Model::CV_STATUS_PENDING); $viewer->assign('CV_PUBLIC_VALUE', CustomView_Record_Model::CV_STATUS_PUBLIC); $viewer->assign('MODULE_MODEL', $moduleModel); echo $viewer->view('EditView.tpl', $module, true); }
public function process(Vtiger_Request $request) { $customViewModel = CustomView_Record_Model::getInstanceById($request->get('record')); $moduleModel = $customViewModel->getModule(); $customViewModel->delete(); $listViewUrl = $moduleModel->getListViewUrl(); header("Location: {$listViewUrl}"); }
public function postProcess(Vtiger_Request $request) { $moduleName = $request->getModule(); $viewer = $this->getViewer($request); $viewer->assign('CUSTOM_VIEWS', CustomView_Record_Model::getAllByGroup($moduleName)); $viewer->view('TreeRecordsPostProcess.tpl', $moduleName); parent::postProcess($request); }
public function handleEvent($handlerType, $entityData) { switch ($handlerType) { case 'vtiger.dispatch.before': return; require_once 'modules/SwVtTools/filecache.php'; $cacheFile = vglobal('root_directory') . '/modules/SwVtTools/cache/Module.php'; if (!file_exists($cacheFile) || $_REQUEST['clearcache'] == '1') { swtools_filecache(glob(vglobal('root_directory') . '/modules/*/models/Module.php'), $cacheFile); } require_once $cacheFile; break; case 'vtiger.process.customview.editajax.view.finish': if (empty(self::$DATA['recordId'])) { return; } $content = ob_get_contents(); ob_end_clean(); $customViewModel = CustomView_Record_Model::getInstanceById(self::$DATA['recordId']); $blocks = \SwVtTools\VtUtils::getFieldsWithBlocksForModule(self::$DATA['moduleName']); $html = '<h4 class="filterHeaders">Filter Sort Order:</h4><br/>'; $html .= '<div class="contentsBackground well">'; $html .= ' <table cellpadding="4" cellspacing="0" width="100%" border="0"> <tbody><tr> <td class="dvtCellInfo" width="5%" align="right">Column: </td> <td class="dvtCellInfo" width="20%"> <select name="order_col" id="order_col" class="chzn-select"> <option value="">' . getTranslatedString('LBL_NONE') . '</option>'; foreach ($blocks as $blockLabel => $fields) { $html .= '<optgroup label="' . $blockLabel . '">'; foreach ($fields as $field) { $html .= '<option ' . ($customViewModel->get('order_col') == $field->name ? 'selected="selected"' : '') . ' value="' . $field->name . '">' . $field->label . '</option>'; } $html .= '</optgroup>'; } $html .= '</select> </td> <td class="dvtCellInfo" width="20%"> <select name="order_dir" id="order_dir" class="small"> <option value="ASC" ' . ($customViewModel->get('order_dir') == 'ASC' ? 'selected="selected"' : '') . '>↑ ASC Ascending</option> <option value="DESC" ' . ($customViewModel->get('order_dir') == 'DESC' ? 'selected="selected"' : '') . '>↓ DESC Descending</option> </select> </td> <td class="dvtCellInfo" width="10%" align="right">numerische Sortierung: </td> <td class="dvtCellInfo" width="15%"> <input type="checkbox" name="order_numeric_check" value="1" ' . ($customViewModel->get('order_numeric_check') > 0 ? 'checked="checked"' : '') . '> Skip Chars: <input type="text" alt="ignore the first X chars to get a numberic value" title="ignore the first X chars to get a numberic value" style="width:20px;" name="order_numeric" value="' . $customViewModel->get('order_numeric') . '"> </td></tr></table>'; $html .= '</div>'; $content = str_replace('<div class="filterActions">', $html . '<div class="filterActions">', $content); echo $content; break; } }
public function postProcess(Vtiger_Request $request, $display = true) { $moduleName = $request->getModule(); $viewer = $this->getViewer($request); $viewer->assign('CUSTOM_VIEWS', CustomView_Record_Model::getAllByGroup($moduleName)); if ($display) { $this->postProcessDisplay($request); } parent::postProcess($request); }
public function process(Vtiger_Request $request) { $currentUser = Users_Record_Model::getCurrentUserModel(); $customViewModel = CustomView_Record_Model::getInstanceById($request->get('record')); $moduleModel = $customViewModel->getModule(); if ($currentUser->isAdminUser()) { $customViewModel->deny(); } $listViewUrl = $moduleModel->getListViewUrl(); header("Location: {$listViewUrl}"); }
function process(Vtiger_Request $request) { $relatedModuleName = $request->get('relatedModule'); $relatedMduleModel = Vtiger_Module_Model::getInstance($relatedModuleName); $viewer = $this->getViewer($request); $viewer->assign('DEFAULT_CUSTOM_FILTER_ID', $relatedMduleModel->getDefaultCustomFilter()); $viewer->assign('FOLDERS', Documents_Module_Model::getAllFolders()); $viewer->assign('CUSTOM_VIEWS', CustomView_Record_Model::getAllByGroup($relatedModuleName)); $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel()); $viewer->view('CustomFilter.tpl', $request->getModule()); }
/** * Static Function to get the Instance of Vtiger ListView model for a given module and custom view * @param <String> $moduleName - Module Name * @param <Number> $viewId - Custom View Id * @return Vtiger_ListView_Model instance */ public static function getInstance($moduleName, $sourceModule) { $db = PearDatabase::getInstance(); $currentUser = vglobal('current_user'); $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'ListView', $moduleName); $instance = new $modelClassName(); $sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule); $queryGenerator = new QueryGenerator($sourceModuleModel->get('name'), $currentUser); $cvidObj = CustomView_Record_Model::getAllFilterByModule($sourceModuleModel->get('name')); $cvid = $cvidObj->getId('cvid'); $queryGenerator->initForCustomViewById($cvid); $controller = new ListViewController($db, $currentUser, $queryGenerator); return $instance->set('module', $sourceModuleModel)->set('query_generator', $queryGenerator)->set('listview_controller', $controller); }
function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $relatedModuleName = $request->get('relatedModule'); $parentId = $request->get('record'); $label = $request->get('tab_label'); $parentRecordModel = Vtiger_Record_Model::getInstanceById($parentId, $moduleName); $relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName, $label); $relationModel = $relationListView->getRelationModel(); $viewer = $this->getViewer($request); if (array_key_exists($relatedModuleName, $relationModel->getEmailEnabledModulesInfoForDetailView())) { $viewer->assign('CUSTOM_VIEWS', CustomView_Record_Model::getAllByGroup($relatedModuleName)); $viewer->assign('STATUS_VALUES', $relationModel->getCampaignRelationStatusValues()); $viewer->assign('SELECTED_IDS', $request->get('selectedIds')); $viewer->assign('EXCLUDED_IDS', $request->get('excludedIds')); } return parent::process($request); }
protected function getBaseModuleRecordIds(Vtiger_Request $request) { $cvId = $request->get('viewname'); $module = $request->get('from_module'); $selectedIds = $request->get('selected_ids'); $excludedIds = $request->get('excluded_ids'); if (!empty($selectedIds) && $selectedIds != 'all') { if (!empty($selectedIds) && count($selectedIds) > 0) { return $selectedIds; } } if ($selectedIds == 'all') { $customViewModel = CustomView_Record_Model::getInstanceById($cvId); if ($customViewModel) { return $customViewModel->getRecordIds($excludedIds, $module); } } return array(); }
public function process(Vtiger_Request $request) { $viewer = $this->getViewer ($request); $moduleName = $request->getModule(); $qualifiedModuleName = $request->getModule(false); $module = Vtiger_Functions::getModuleName($request->get("module_id")); $adb = PearDatabase::getInstance(); $sql = "select * from vtiger_customview where viewname = ? and entitytype = ? and status = ?"; $result = $adb->pquery($sql, array('All', $module, 0)); while($row = $adb->fetchByAssoc($result)){ $record = $row['cvid']; } $customViewModel = CustomView_Record_Model::getInstanceById($record); $moduleModel = Vtiger_Module_Model::getInstance($module); $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel); $recordStructure = $recordStructureInstance->getStructure(); $viewer->assign('CUSTOMVIEW_MODEL', $customViewModel); $viewer->assign('RECORD_STRUCTURE', $recordStructure); $viewer->assign('RECORD_ID', $record); $viewer->assign('SOURCE_MODULE', $module); $viewer->assign('MODULENAME', $moduleName); echo $viewer->view('List2.tpl', $qualifiedModuleName,true); }
public function getRecordsListFromRequest(Vtiger_Request $request) { global $log; $log->debug("Entering ./views/ComposeEmail.php::getRecordsListFromRequest"); $cvId = $request->get('viewname'); $selectedIds = $request->get('selected_ids'); $excludedIds = $request->get('excluded_ids'); if (!empty($selectedIds) && $selectedIds != 'all') { if (!empty($selectedIds) && count($selectedIds) > 0) { return $selectedIds; } } $sourceRecord = $request->get('sourceRecord'); $sourceModule = $request->get('sourceModule'); if ($sourceRecord && $sourceModule) { $sourceRecordModel = Vtiger_Record_Model::getInstanceById($sourceRecord, $sourceModule); return $sourceRecordModel->getSelectedIdsList($request->get('parentModule'), $excludedIds); } $customViewModel = CustomView_Record_Model::getInstanceById($cvId); if ($customViewModel) { $searchKey = $request->get('search_key'); $searchValue = $request->get('search_value'); $operator = $request->get('operator'); if (!empty($operator)) { $customViewModel->set('operator', $operator); $customViewModel->set('search_key', $searchKey); $customViewModel->set('search_value', $searchValue); } $customViewModel->set('search_params', $request->get('search_params')); return $customViewModel->getRecordIds($excludedIds); } return array(); }
function DeleteCustomview() { if (count($this->cvid) > 0) { foreach ($this->cvid as $cvid) { $customViewModel = CustomView_Record_Model::getInstanceById($cvid[0]); $customViewModel->delete(); } } }
public function process(Vtiger_Request $request) { require_once "libraries/PHPExcel/PHPExcel.php"; $currentUser = Users_Record_Model::getCurrentUserModel(); $module = $request->getModule(false); //this is the type of things in the current view $filter = $request->get('viewname'); //this is the cvid of the current custom filter $recordIds = $this->getRecordsListFromRequest($request); //this handles the 'all' situation. //we now know what we want to render and can get a handle to the respective view, probably should use a listviewcontroller to get the data $selectedModule = $request->get("targetmodule"); //set up our spreadsheet to write out to $workbook = new PHPExcel(); $worksheet = $workbook->setActiveSheetIndex(0); $header_styles = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'E1E0F7')), 'font' => array('bold' => true)); $row = 1; $col = 0; $generator = new QueryGenerator($selectedModule, $currentUser); $generator->initForCustomViewById($filter); $customView = CustomView_Record_Model::getInstanceById($filter); $listviewController = new ListViewController($db, $currentUser, $generator); $headers = $listviewController->getListViewHeaderFields(); //get the column headers, they go in row 0 of the spreadsheet foreach ($headers as $column => $webserviceField) { $fieldObj = Vtiger_Field::getInstance($webserviceField->getFieldId()); //echo $fieldObj->label; $fields[] = $fieldObj; $worksheet->setCellValueExplicitByColumnAndRow($col, $row, decode_html(vtranslate($fieldObj->label, $selectedModule)), PHPExcel_Cell_DataType::TYPE_STRING); $col++; } $row++; $targetModuleFocus = CRMEntity::getInstance($selectedModule); //ListViewController has lots of paging stuff and things we don't want //so lets just itterate across the list of IDs we have and get the field values foreach ($recordIds as $id) { $col = 0; $record = Vtiger_Record_Model::getInstanceById($id, $selectedModule); foreach ($fields as $field) { //depending on the uitype we might want the raw value, the display value or something else. //we might also want the display value sans-links so we can use strip_tags for that //phone numbers need to be explicit strings $value = $record->getDisplayValue($field->name); $uitype = $field->uitype; switch ($uitype) { case 4: //numbers //numbers case 25: case 7: case 71: $worksheet->setCellvalueExplicitByColumnAndRow($col, $row, strip_tags($value), PHPExcel_Cell_DataType::TYPE_NUMERIC); break; case 6: //datetimes //datetimes case 23: case 70: $worksheet->setCellvalueExplicitByColumnAndRow($col, $row, PHPExcel_Shared_Date::PHPToExcel(strtotime($value)), PHPExcel_Cell_DataType::TYPE_NUMERIC); $worksheet->getStyleByColumnAndRow($col, $row)->getNumberFormat()->setFormatCode('DD/MM/YYYY HH:MM:SS'); //format the date to the users preference break; default: $worksheet->setCellValueExplicitByColumnAndRow($col, $row, decode_html(strip_tags($value)), PHPExcel_Cell_DataType::TYPE_STRING); } //echo strip_tags($value); $col++; } //echo "<br>"; $row++; } //having written out all the data lets have a go at getting the columns to auto-size $col = 0; $row = 1; foreach ($headers as $column => $webserviceField) { $cell = $worksheet->getCellByColumnAndRow($col, $row); $worksheet->getStyleByColumnAndRow($col, $row)->applyFromArray($header_styles); $worksheet->getColumnDimension($cell->getColumn())->setAutoSize(true); $col++; } $rootDirectory = vglobal('root_directory'); $tmpDir = vglobal('tmp_dir'); $tempFileName = tempnam($rootDirectory . $tmpDir, 'xls'); $workbookWriter = PHPExcel_IOFactory::createWriter($workbook, 'Excel5'); $workbookWriter->save($tempFileName); if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { header('Pragma: public'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); } header('Content-Type: application/x-msexcel'); header('Content-Length: ' . @filesize($tempFileName)); $filename = decode_html($customView->get('viewname')) . ".xls"; header('Content-disposition: attachment; filename="' . $filename . '"'); $fp = fopen($tempFileName, 'rb'); fpassthru($fp); }
public function process(Vtiger_Request $request) { $customViewModel = CustomView_Record_Model::getInstanceById($request->get('record')); $customViewModel->delete(); }
public function beforeGetTaskform($viewer) { global $adb, $current_language, $mod_strings; $viewer->assign("related_modules", VtUtils::getEntityModules(true)); $search_module = $this->get("search_module"); if (!empty($_POST["task"]["search_module"])) { $parts = explode("#~#", $_POST["task"]["search_module"]); } elseif (!empty($search_module)) { if ($search_module != -1) { $parts = explode("#~#", $search_module); } } else { return; } if (!empty($parts)) { $viewer->assign("related_tabid", $parts[1]); $search_module_name = VtUtils::getModuleName($parts[1]); #$workflowSettings = $this->getWorkflow()->getSettings(); $workflows = $workflows = Workflow2::getWorkflowsForModule($search_module_name, 1); $viewer->assign("workflows", $workflows); $fields = VtUtils::getFieldsWithBlocksForModule($search_module_name); $viewer->assign("sort_fields", $fields); $moduleObj = \Vtiger_Module_Model::getInstance($search_module_name); $viewer->assign('productCache', array()); if ($moduleObj instanceof \Inventory_Module_Model) { $viewer->assign('searchByProduct', true); $product = $this->get('products'); if (!empty($product)) { //$dataObj = \Vtiger_Record_Model::getInstanceById($product); $productCache[$product] = array('label' => \Vtiger_Functions::getCRMRecordLabel($product)); $viewer->assign('productCache', $productCache); } } $views = array(); $allviews = \CustomView_Record_Model::getAll($search_module_name); foreach ($allviews as $view) { $views[$view->get('cvid')] = $view->get('viewname'); } $viewer->assign('customviews', $views); } }
public function beforeGetTaskform($viewer) { $fields = $this->get('fields'); if (empty($fields) || $fields == -1) { $fields = array(); } $viewer->assign("StaticFieldsField", 'fields'); $viewer->assign("fields", $fields); $viewer->assign("fromFields", $this->getFromFields()); $viewer->assign("related_modules", VtUtils::getEntityModules(true)); $search_module = $this->get("search_module"); if (!empty($_POST["task"]["search_module"])) { $parts = explode("#~#", $_POST["task"]["search_module"]); } elseif (!empty($search_module)) { if ($search_module != -1) { $parts = explode("#~#", $search_module); } } else { return; } $views = array(); $allviews = \CustomView_Record_Model::getAll($parts[0]); foreach ($allviews as $view) { $views[$view->get('cvid')] = $view->get('viewname'); } $viewer->assign('customviews', $views); if (!empty($parts)) { $viewer->assign("related_tabid", $parts[1]); $viewer->assign("target_module_name", $parts[0]); } }
public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer) { $currentUser = vglobal('current_user'); $viewer = $this->getViewer($request); $module = $request->getModule(); $moduleModel = Vtiger_Module_Model::getInstance($module); $massActionLink = array('linktype' => 'LISTVIEWBASIC', 'linklabel' => 'LBL_DELETE', 'linkurl' => 'Javascript:Vtiger_FindDuplicates_Js.massDeleteRecords("index.php?module=' . $module . '&action=MassDelete");', 'linkicon' => ''); $massActionLinks[] = Vtiger_Link_Model::getInstanceFromValues($massActionLink); $viewer->assign('LISTVIEW_LINKS', $massActionLinks); $viewer->assign('MODULE_MODEL', $moduleModel); $pageNumber = $request->get('page'); if (empty($pageNumber)) { $pageNumber = '1'; } $pagingModel = new Vtiger_Paging_Model(); $pagingModel->set('page', $pageNumber); $pageLimit = $pagingModel->getPageLimit(); $duplicateSearchFields = $request->get('fields'); $dataModelInstance = Vtiger_FindDuplicate_Model::getInstance($module); $dataModelInstance->set('fields', $duplicateSearchFields); $ignoreEmpty = $request->get('ignoreEmpty'); $ignoreEmptyValue = false; if ($ignoreEmpty == 'on' || $ignoreEmpty == 'true' || $ignoreEmpty == '1') { $ignoreEmptyValue = true; } $dataModelInstance->set('ignoreEmpty', $ignoreEmptyValue); if (!$this->listViewEntries) { $this->listViewEntries = $dataModelInstance->getListViewEntries($pagingModel); } if (!$this->listViewHeaders) { $this->listViewHeaders = $dataModelInstance->getListViewHeaders(); } if (!$this->rows) { $this->rows = $dataModelInstance->getRecordCount(); $viewer->assign('TOTAL_COUNT', $this->rows); } $rowCount = 0; foreach ($this->listViewEntries as $group) { foreach ($group as $row) { $rowCount++; } } //for calculating the page range for ($i = 0; $i < $rowCount; $i++) { $dummyListEntries[] = $i; } $pagingModel->calculatePageRange($dummyListEntries); $viewer->assign('IGNORE_EMPTY', $ignoreEmpty); $viewer->assign('LISTVIEW_ENTIRES_COUNT', $rowCount); $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders); $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries); $viewer->assign('PAGING_MODEL', $pagingModel); $viewer->assign('PAGE_NUMBER', $pageNumber); $viewer->assign('MODULE', $module); $viewer->assign('DUPLICATE_SEARCH_FIELDS', $duplicateSearchFields); $customViewModel = CustomView_Record_Model::getAllFilterByModule($module); $viewer->assign('VIEW_NAME', $customViewModel->getId()); }
Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_field VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", array($tab_id, $field_id, $columnname, "sp_payments", 1, $uitype, $fieldname, $fieldlabel, 1, 0, 0, 100, $field_seq, $block_id, 1, "V~O", 1, NULL, "BAS", 1, NULL, 0)); Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_profile2field SELECT profileid, {$tab_id}, {$field_id}, 0, 1 FROM vtiger_profile", array()); Migration_Index_View::ExecuteQuery("INSERT INTO vtiger_def_org_field VALUES({$tab_id}, {$field_id}, 0, 1)", array()); // End // Begin Update summary fields for PBXManager Migration_Index_View::ExecuteQuery("ALTER TABLE vtiger_systems ADD COLUMN use_mail_account varchar(5) DEFAULT NULL", array()); // End // Begin Set custom view for standard All filter $cvInstance = CustomView_Record_Model::getAllFilterByModule('Act'); $res = $adb->pquery('select * from vtiger_cvcolumnlist where cvid = ? and columnindex = ?', array($cvInstance->getId(), 0)); if ($adb->num_rows($res) == 0) { $sql = "insert into vtiger_cvcolumnlist (cvid, columnindex, columnname) values (?,?,?)"; $params = array($cvInstance->getId(), 0, 'vtiger_sp_act:act_no:act_no:Act_Act_No:V'); $adb->pquery($sql, $params); } $cvInstance = CustomView_Record_Model::getAllFilterByModule('Consignment'); $res = $adb->pquery('select * from vtiger_cvcolumnlist where cvid = ? and columnindex = ?', array($cvInstance->getId(), 0)); if ($adb->num_rows($res) == 0) { $sql = "insert into vtiger_cvcolumnlist (cvid, columnindex, columnname) values (?,?,?)"; $params = array($cvInstance->getId(), 0, 'vtiger_sp_consignment:consignment_no:consignment_no:Consignment_Consignment_No:V'); $adb->pquery($sql, $params); } // End // Begin Update Invoice links if (defined('VTIGER_UPGRADE')) { $updateQuery = 'UPDATE vtiger_links SET linkurl = ? WHERE linklabel = ? AND tabid = ' . getTabid('Invoice'); Migration_Index_View::ExecuteQuery($updateQuery, array('index.php?module=Act&view=Edit&sourceModule=$MODULE$&sourceRecord=$RECORD$&invoice_id=$RECORD$&relationOperation=true', 'LBL_INVOICE_ADD_ACT')); } // End // Begin Folder for Reports Templates $sql = "INSERT INTO vtiger_reportfolder (FOLDERNAME,DESCRIPTION,STATE) VALUES(?,?,?)";
/** * Function returns the record Ids selected in the current filter * @param Vtiger_Request $request * @return integer */ function getRecordsListFromRequest(Vtiger_Request $request, $module = false) { $cvId = $request->get('viewname'); $selectedIds = $request->get('selected_ids'); $excludedIds = $request->get('excluded_ids'); if (empty($module)) { $module = $request->getModule(); } if (!empty($selectedIds) && $selectedIds != 'all') { if (!empty($selectedIds) && count($selectedIds) > 0) { return $selectedIds; } } $sourceRecord = $request->get('sourceRecord'); $sourceModule = $request->get('sourceModule'); if ($sourceRecord && $sourceModule) { $sourceRecordModel = Vtiger_Record_Model::getInstanceById($sourceRecord, $sourceModule); return $sourceRecordModel->getSelectedIdsList($module, $excludedIds); } $customViewModel = CustomView_Record_Model::getInstanceById($cvId); if ($customViewModel) { $searchKey = $request->get('search_key'); $searchValue = $request->get('search_value'); $operator = $request->get('operator'); if (!empty($operator)) { $customViewModel->set('operator', $operator); $customViewModel->set('search_key', $searchKey); $customViewModel->set('search_value', $searchValue); } $customViewModel->set('search_params', $request->get('search_params')); return $customViewModel->getRecordIds($excludedIds, $module); } }
public function process(Vtiger_Request $request) { $viewer = $this->getViewer($request); $moduleName = $request->get('source_module'); $module = $request->getModule(); $record = $request->get('record'); $duplicate = $request->get('duplicate'); $moduleModel = Vtiger_Module_Model::getInstance($moduleName); $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel); if (!empty($record)) { $customViewModel = CustomView_Record_Model::getInstanceById($record); $viewer->assign('MODE', 'edit'); } else { $customViewModel = new CustomView_Record_Model(); $customViewModel->setModule($moduleName); $viewer->assign('MODE', ''); } $viewer->assign('ADVANCE_CRITERIA', $customViewModel->transformToNewAdvancedFilter()); $viewer->assign('CURRENTDATE', date('Y-n-j')); $viewer->assign('DATE_FILTERS', Vtiger_Field_Model::getDateFilterTypes()); if ($moduleName == 'Calendar') { $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType(); } else { $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType(); } $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions()); $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType); $dateFilters = Vtiger_Field_Model::getDateFilterTypes(); foreach ($dateFilters as $comparatorKey => $comparatorInfo) { $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']); $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']); $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $module); $dateFilters[$comparatorKey] = $comparatorInfo; } $viewer->assign('DATE_FILTERS', $dateFilters); $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance); $recordStructure = $recordStructureInstance->getStructure(); // for Inventory module we should now allow item details block if (in_array($moduleName, getInventoryModules())) { $itemsBlock = "LBL_ITEM_DETAILS"; unset($recordStructure[$itemsBlock]); } $viewer->assign('RECORD_STRUCTURE', $recordStructure); // Added to show event module custom fields if ($moduleName == 'Calendar') { $relatedModuleName = 'Events'; $relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModuleName); $relatedRecordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($relatedModuleModel); $eventBlocksFields = $relatedRecordStructureInstance->getStructure(); $viewer->assign('EVENT_RECORD_STRUCTURE_MODEL', $relatedRecordStructureInstance); $viewer->assign('EVENT_RECORD_STRUCTURE', $eventBlocksFields); } $viewer->assign('CUSTOMVIEW_MODEL', $customViewModel); if ($duplicate != '1') { $viewer->assign('RECORD_ID', $record); } $viewer->assign('MODULE', $module); $viewer->assign('SOURCE_MODULE', $moduleName); $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel()); if ($customViewModel->get('viewname') == 'All') { $viewer->assign('CV_PRIVATE_VALUE', CustomView_Record_Model::CV_STATUS_DEFAULT); } else { $viewer->assign('CV_PRIVATE_VALUE', CustomView_Record_Model::CV_STATUS_PRIVATE); } $viewer->assign('CV_PENDING_VALUE', CustomView_Record_Model::CV_STATUS_PENDING); $viewer->assign('CV_PUBLIC_VALUE', CustomView_Record_Model::CV_STATUS_PUBLIC); $viewer->assign('MODULE_MODEL', $moduleModel); echo $viewer->view('EditView.tpl', $module, true); }