示例#1
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $this->getModule($request);
     $sourceModule = $request->get('src_module');
     $sourceRecord = $request->get('src_record');
     //list of records is narrowed to contacts related to help desks account, only in Help Desk Contacts relation view
     if ($moduleName == 'Contacts' && $sourceModule == 'HelpDesk' && isRecordExists($sourceRecord) && strpos($_SERVER['QUERY_STRING'], 'module=Contacts&src_module=HelpDesk') === 0) {
         $request->set('related_parent_module', 'Accounts');
         $helpDeskRecord = Vtiger_Record_Model::getInstanceById($sourceRecord, 'HelpDesk');
         $request->set('related_parent_id', $helpDeskRecord->get('parent_id'));
         $viewer->assign('SWITCH', true);
     }
     if ($moduleName == 'Contacts' && $sourceModule == 'SSalesProcesses' && isRecordExists($sourceRecord) && strpos($_SERVER['QUERY_STRING'], 'module=Contacts&src_module=SSalesProcesses') === 0) {
         $request->set('related_parent_module', 'Accounts');
         $moduleRecord = Vtiger_Record_Model::getInstanceById($sourceRecord, 'SSalesProcesses');
         $request->set('related_parent_id', $moduleRecord->get('related_to'));
         $viewer->assign('SWITCH', true);
     }
     if ($moduleName == 'Contacts' && $sourceModule == 'Project' && isRecordExists($sourceRecord) && strpos($_SERVER['QUERY_STRING'], 'module=Contacts&src_module=Project') === 0) {
         $request->set('related_parent_module', 'Accounts');
         $moduleRecord = Vtiger_Record_Model::getInstanceById($sourceRecord, 'Project');
         $request->set('related_parent_id', $moduleRecord->get('linktoaccountscontacts'));
         $viewer->assign('SWITCH', true);
     }
     parent::initializeListViewContents($request, $viewer);
 }
示例#2
0
 public function process($fieldName, $moduleName)
 {
     $viewer = new Vtiger_Viewer();
     $viewer->assign('FLD_NAME', $fieldName);
     $viewer->assign('FLD_ID', $fieldName);
     return $viewer->view($this->tplAddress, "Settings:OSSProjectTemplates", true);
 }
function ShowModuleIdField($selected_module, $tab_only = false)
{
    $db = PearDatabase::getInstance();
    $names = array('Emails', 'PBXManager', 'ModComments', 'SMSNotifier', 'OSSPdf');
    foreach ($names as $id) {
        $in .= "'" . $id . "',";
    }
    $in = trim($in, ',');
    $query = "select tabid, name, customized from vtiger_tab where isentitytype = '1' and presence <> '2' and name not in ( {$in} )";
    $wynik = $db->query($query, true);
    $tablist = array();
    for ($i = 0; $i < $db->num_rows($wynik); $i++) {
        $tablist[$i]['id'] = $db->query_result($wynik, $i, "tabid");
        $label = $db->query_result($wynik, $i, "name");
        if ($db->query_result($wynik, $i, "customized") == 0) {
            $tablist[$i]['label'] = getTranslatedString($label);
        } else {
            $tablist[$i]['label'] = getTranslatedString($label, $label);
        }
    }
    if ($selected_module == '') {
        $SMODULE = $tablist[0]['id'];
    } else {
        $SMODULE = $selected_module;
    }
    if ($tab_only == false) {
        $viewer = new Vtiger_Viewer();
        $viewer->assign("TABLIST", $tablist);
        $viewer->assign("SMODULE", $SMODULE);
        $viewer->assign("SELECTED_MODULE", $selected_module);
        return $viewer->fetch('modules/OSSPdf/FieldModuleid.tpl');
    } else {
        return $tablist;
    }
}
 public function process($fieldName, $moduleName)
 {
     $viewer = new Vtiger_Viewer();
     $viewer->assign('OPTION_LIST', $this->getOptions($fieldName));
     $viewer->assign('FLD_ID', $fieldName);
     $viewer->assign('FLD_NAME', $fieldName);
     $viewer->assign('FLD_REQUIRED', $this->fieldIsRequired($fieldName, $moduleName));
     return $viewer->view($this->tplAddress, "Settings:OSSProjectTemplates", true);
 }
示例#5
0
 function viewController()
 {
     $smarty = new Vtiger_Viewer();
     foreach ($this->parameters as $k => $v) {
         $smarty->assign($k, $v);
     }
     $smarty->assign("IS_SAFARI", Mobile::isSafari());
     $smarty->assign("SKIN", Mobile::config('Default.Skin'));
     return $smarty;
 }
示例#6
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $searchValue = $request->get('search_value');
     /*if(empty($orderBy) && empty($searchValue) && empty($pageNumber)) {
           $orderParams = Vtiger_ListView_Model::getSortParamsSession($moduleName);
           if($orderParams) {
               $pageNumber = $orderParams['page'];
               $orderBy = $orderParams['orderby'];
               $sortOrder = $orderParams['sortorder'];
               $searchValue = $orderParams['search_value'];
           }
       } else {
           $params = array('page' => $pageNumber, 'orderby' => $orderBy, 'sortorder' => $sortOrder, 'search_value' => $searchValue);
           Vtiger_ListView_Model::setSortParamsSession($moduleName, $params);
       }*/
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "icon-chevron-down";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "icon-chevron-up";
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $listViewModel = new Portal_ListView_Model();
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!empty($searchValue)) {
         $listViewModel->set('search_value', $searchValue);
     }
     $listviewEntries = $listViewModel->getListViewEntries($pagingModel);
     $viewer->assign('LISTVIEW_ENTRIES', $listviewEntries);
     $viewer->assign('ALPHABET_VALUE', $searchValue);
     $viewer->assign('COLUMN_NAME', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('RECORD_COUNT', count($listviewEntries));
     $viewer->assign('CURRENT_PAGE', $pageNumber);
     $viewer->assign('PAGING_INFO', $listViewModel->calculatePageRange($listviewEntries, $pagingModel));
 }
示例#7
0
 public static function showErrorPage($errorMessage, $errorDetails = false, $customActions = false)
 {
     $viewer = new Vtiger_Viewer();
     $viewer->assign('ERROR_MESSAGE', $errorMessage);
     $viewer->assign('ERROR_DETAILS', $errorDetails);
     $viewer->assign('CUSTOM_ACTIONS', $customActions);
     $viewer->assign('MODULE', 'Import');
     $viewer->view('ImportError.tpl', 'Import');
 }
示例#8
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $qualifiedModuleName = $request->getModule(false);
     $listViewModel = Settings_Vtiger_ListView_Model::getInstance($qualifiedModuleName);
     $listViewModel->set('orderby', 'sequence');
     $pagingModel = new Vtiger_Paging_Model();
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $viewer->assign('MODULE_MODEL', $listViewModel->getModule());
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
 }
 public function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $widgetView = new Reports_ChartDetail_View();
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $widget = Vtiger_Widget_Model::getInstance($request->get('linkid'), $currentUser->getId());
     $widget->applyTemplateRecordId($request->get('report_record_id'));
     $viewer = new Vtiger_Viewer();
     $viewer->assign('WIDGET', $widget);
     $viewer->assign('MODULE_NAME', $moduleName);
     $content = $request->get('content');
     $reportDisplay = $widgetView->getReport($request, true);
     if (!empty($content)) {
         echo $reportDisplay;
     } else {
         $viewer->assign('CHART_REPORT_WIDGET_CONTENTS', $reportDisplay);
         $viewer->view('dashboards/ChartReportWidget.tpl', $moduleName);
     }
 }
示例#10
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $this->getModule($request);
     $recordId = $request->get('record');
     $tooltipViewModel = Vtiger_TooltipView_Model::getInstance($moduleName, $recordId);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('MODULE_MODEL', $tooltipViewModel->getRecord()->getModule());
     $viewer->assign('TOOLTIP_FIELDS', $tooltipViewModel->getFields());
     $viewer->assign('RECORD', $tooltipViewModel->getRecord());
     $viewer->assign('RECORD_STRUCTURE', $tooltipViewModel->getStructure());
     $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
 }
示例#11
0
	public function checkLimits(Vtiger_Request $request)
	{
		$moduleName = $request->getModule();
		$record = $request->get('record');
		$currency = $request->get('currency');
		$price = $request->get('price');
		$limitConfig = $request->get('limitConfig');
		$limitFieldName = 'creditlimit';
		$balanceFieldName = 'inventorybalance';

		$moduleInstance = Vtiger_Module_Model::getInstance('Accounts');
		$limitField = Vtiger_Field_Model::getInstance($limitFieldName, $moduleInstance);
		$balanceField = Vtiger_Field_Model::getInstance($balanceFieldName, $moduleInstance);
		if (!$limitField->isActiveField() || !$balanceField->isActiveField()) {
			$response = new Vtiger_Response();
			$response->setResult(['status' => true]);
			$response->emit();
			return;
		}
		$recordModel = Vtiger_Record_Model::getInstanceById($record, 'Accounts');
		$limitID = $recordModel->get($limitFieldName);
		$balance = $recordModel->get($balanceFieldName);
		$limit = reset(Vtiger_InventoryLimit_UIType::getValues($limitID))['value'];

		$baseCurrency = Vtiger_Util_Helper::getBaseCurrency();
		$symbol = $baseCurrency['currency_symbol'];
		if ($baseCurrency['id'] != $currency) {
			$selectedCurrency = Vtiger_Functions::getCurrencySymbolandRate($currency);
			$price = floatval($price) * $selectedCurrency['rate'];
			$symbol = $selectedCurrency['symbol'];
		}
		$totalPrice = $price + $balance;

		$status = $totalPrice > $limit ? false : true;
		if (!$status) {
			$viewer = new Vtiger_Viewer();
			$viewer->assign('PRICE', $price);
			$viewer->assign('BALANCE', $balance);
			$viewer->assign('SYMBOL', $symbol);
			$viewer->assign('LIMIT', $limit);
			$viewer->assign('TOTALS', $totalPrice);
			$viewer->assign('LIMIT_CONFIG', $limitConfig);
			$html = $viewer->view('InventoryLimitAlert.tpl', $moduleName, true);
		}
		$response = new Vtiger_Response();
		$response->setResult([
			'status' => $status,
			'html' => $html
		]);
		$response->emit();
	}
示例#12
0
 static function throwNewException($Message)
 {
     $request = new Vtiger_Request($_REQUEST);
     if (!$request->get('action') != '') {
         $viewer = new Vtiger_Viewer();
         $viewer->assign('MESSAGE', $Message);
         $viewer->view('OperationNotPermitted.tpl', 'Vtiger');
     } else {
         echo $Message;
     }
 }
示例#13
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $cvId = $this->viewName;
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "icon-chevron-down";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "icon-chevron-up";
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $listViewModel = Vtiger_ListView_Model::getInstance($moduleName, $cvId);
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $linkParams = array('MODULE' => $moduleName, 'ACTION' => $request->get('view'), 'CVID' => $cvId);
     $linkModels = $listViewModel->getListViewMassActions($linkParams);
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $pagingModel->set('viewid', $request->get('viewname'));
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     $searchKey = $request->get('search_key');
     $searchValue = $request->get('search_value');
     $operator = $request->get('operator');
     if (!empty($operator)) {
         $listViewModel->set('operator', $operator);
         $viewer->assign('OPERATOR', $operator);
         $viewer->assign('ALPHABET_VALUE', $searchValue);
     }
     if (!empty($searchKey) && !empty($searchValue)) {
         $listViewModel->set('search_key', $searchKey);
         $listViewModel->set('search_value', $searchValue);
     }
     $searchParmams = $request->get('search_params');
     if (empty($searchParmams)) {
         $searchParmams = array();
     }
     $transformedSearchParams = $this->transferListSearchParamsToFilterCondition($searchParmams, $listViewModel->getModule());
     $listViewModel->set('search_params', $transformedSearchParams);
     //To make smarty to get the details easily accesible
     foreach ($searchParmams as $fieldListGroup) {
         foreach ($fieldListGroup as $fieldSearchInfo) {
             $fieldSearchInfo['searchValue'] = $fieldSearchInfo[2];
             $fieldSearchInfo['fieldName'] = $fieldName = $fieldSearchInfo[0];
             $searchParmams[$fieldName] = $fieldSearchInfo;
         }
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $noOfEntries = count($this->listViewEntries);
     $viewer->assign('MODULE', $moduleName);
     if (!$this->listViewLinks) {
         $this->listViewLinks = $listViewModel->getListViewLinks($linkParams);
     }
     $viewer->assign('LISTVIEW_LINKS', $this->listViewLinks);
     $viewer->assign('LISTVIEW_MASSACTIONS', $linkModels['LISTVIEWMASSACTION']);
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('COLUMN_NAME', $orderBy);
     if ($moduleName == 'SalesOrder') {
         /**
          * красим поле "сумма счета" (cf_773) или "оплата водителю"(cf_791)
          * по полям "дата оплаты счета"(cf_819) и  "водитель оплачен"/"водитель поставлен на оплату" (cf_892/897 )
          */
         $filterFields = $listViewModel->get('query_generator')->getFields();
         if (in_array('cf_773', $filterFields) || in_array('cf_791', $filterFields)) {
             $analysisFields = $listViewModel->getFieldsForPainting($this->listViewEntries);
             foreach ($this->listViewEntries as $key => &$entry) {
                 $rawData = $entry->getRawData();
                 $billPayedAt = $analysisFields[$rawData['salesorderid']]['cf_819'];
                 $driverQueue = $analysisFields[$rawData['salesorderid']]['cf_897'];
                 $driverPayed = $analysisFields[$rawData['salesorderid']]['cf_892'];
                 //дополняем значениями
                 if (!empty($billPayedAt)) {
                     $rawData['colored_bill'] = 'rgb(73, 215, 73)';
                     //нам оплатили
                 } else {
                     $rawData['colored_bill'] = '';
                     //нам не оплатили
                 }
                 if ($driverPayed == '1') {
                     $rawData['colored_driver'] = 'rgb(249, 81, 81)';
                     //если оплатили
                 } elseif ($driverQueue == '1') {
                     $rawData['colored_driver'] = 'yellow';
                     //поставлен в очередь на оплату
                 } else {
                     $rawData['colored_driver'] = 'white';
                     //должны
                 }
                 $this->listViewEntries[$key]->setRawData($rawData);
             }
         }
         /**
          * прописываем ширины для некоторых столбцов
          */
         $fieldsWidth = array('bill_street' => 120, 'ship_street' => 120, 'cf_864' => 120, 'smownerid' => 120, 'description' => 200);
         foreach ($this->listViewHeaders as $key => $header) {
             if (isset($fieldsWidth[$header->get('column')])) {
                 $this->listViewHeaders[$key]->set('listviewwidth', $fieldsWidth[$header->get('column')]);
             } else {
                 $this->listViewHeaders[$key]->set('listviewwidth', '');
             }
         }
     }
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
     $viewer->assign('LIST_VIEW_MODEL', $listViewModel);
     $viewer->assign('GROUPS_IDS', Vtiger_Util_Helper::getGroupsIdsForUsers($currentUser->getId()));
     $viewer->assign('IS_MODULE_EDITABLE', $listViewModel->getModule()->isPermitted('EditView'));
     $viewer->assign('IS_MODULE_DELETABLE', $listViewModel->getModule()->isPermitted('Delete'));
     $viewer->assign('SEARCH_DETAILS', $searchParmams);
 }
示例#14
0
文件: List.php 项目: nvh3010/quancrm
	public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer) {
		$moduleName = $request->getModule();
		$cvId = $request->get('viewname');
		$pageNumber = $request->get('page');
		$orderBy = $request->get('orderby');
		$sortOrder = $request->get('sortorder');
		if($sortOrder == "ASC"){
			$nextSortOrder = "DESC";
			$sortImage = "icon-chevron-down";
		}else{
			$nextSortOrder = "ASC";
			$sortImage = "icon-chevron-up";
		}

		if(empty ($pageNumber)){
			$pageNumber = '1';
		}

		$listViewModel = EmailTemplates_ListView_Model::getInstance($moduleName, $cvId);
		$linkParams = array('MODULE'=>$moduleName, 'ACTION'=>$request->get('view'), 'CVID'=>$cvId);
		$linkModels = $listViewModel->getListViewMassActions($linkParams);
		$pagingModel = new Vtiger_Paging_Model();
		$pagingModel->set('page', $pageNumber);

		if(!empty($orderBy)) {
			$listViewModel->set('orderby', $orderBy);
			$listViewModel->set('sortorder',$sortOrder);
		}

		$searchKey = $request->get('search_key');
		$searchValue = $request->get('search_value');
		$operator = $request->get('operator');
		if(!empty($operator)) {
			$listViewModel->set('operator', $operator);
			$viewer->assign('OPERATOR',$operator);
			$viewer->assign('ALPHABET_VALUE',$searchValue);
		}
		if(!empty($searchKey) && !empty($searchValue)) {
			$listViewModel->set('search_key', $searchKey);
			$listViewModel->set('search_value', $searchValue);
		}
		if(!$this->listViewHeaders){
			$this->listViewHeaders = $listViewModel->getListViewHeaders();
		}
		if(!$this->listViewEntries){
			$this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
		}
		$noOfEntries = count($this->listViewEntries);
		$viewer->assign('VIEWID', $cvId);
		$viewer->assign('MODULE', $moduleName);
		
		if(!$this->listViewLinks){
			$this->listViewLinks = $listViewModel->getListViewLinks($linkParams);
		}
		$viewer->assign('LISTVIEW_LINKS', $this->listViewLinks);
		$viewer->assign('LISTVIEW_MASSACTIONS', $linkModels['LISTVIEWMASSACTION']);

		$viewer->assign('PAGING_MODEL', $pagingModel);
		$viewer->assign('PAGE_NUMBER',$pageNumber);

		$viewer->assign('ORDER_BY',$orderBy);
		$viewer->assign('SORT_ORDER',$sortOrder);
		$viewer->assign('NEXT_SORT_ORDER',$nextSortOrder);
		$viewer->assign('SORT_IMAGE',$sortImage);
		$viewer->assign('COLUMN_NAME',$orderBy);

		$viewer->assign('LISTVIEW_ENTIRES_COUNT',$noOfEntries);
		$viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
		$viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);

		if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
			if(!$this->listViewCount){
				$this->listViewCount = $listViewModel->getListViewCount();
			}
			$viewer->assign('LISTVIEW_COUNT', $this->listViewCount);
		}

		$viewer->assign('IS_MODULE_EDITABLE', $listViewModel->getModule()->isPermitted('EditView'));
		$viewer->assign('IS_MODULE_DELETABLE', $listViewModel->getModule()->isPermitted('Delete'));
	}
示例#15
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->get('for_module');
     $cvId = $request->get('viewname');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "downArrowSmall.png";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "upArrowSmall.png";
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $listViewModel = Import_ListView_Model::getInstance($moduleName, $cvId);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $noOfEntries = count($this->listViewEntries);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('COLUMN_NAME', $orderBy);
     $viewer->assign('LISTVIEW_ENTIRES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel());
 }
示例#16
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $sourceModule = $request->get('sourceModule');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "icon-chevron-down";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "icon-chevron-up";
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $listViewModel = RecycleBin_ListView_Model::getInstance($moduleName, $sourceModule);
     $moduleModel = RecycleBin_Module_Model::getInstance($moduleName);
     $linkParams = array('MODULE' => $moduleName, 'ACTION' => $request->get('view'));
     $linkModels = $moduleModel->getListViewMassActions($linkParams);
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $noOfEntries = count($this->listViewEntries);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('LISTVIEW_LINKS', $moduleModel->getListViewLinks());
     $viewer->assign('LISTVIEW_MASSACTIONS', $linkModels);
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('COLUMN_NAME', $orderBy);
     $viewer->assign('LISTVIEW_ENTIRES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     $viewer->assign('MODULE_LIST', $moduleModel->getAllModuleList());
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $viewer->assign('LISTVIEW_COUNT', $this->listViewCount);
     }
     $viewer->assign('IS_MODULE_DELETABLE', $listViewModel->getModule()->isPermitted('Delete'));
 }
示例#17
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $qualifiedModuleName = $request->getModule(false);
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $sourceModule = $request->get('sourceModule');
     $forModule = $request->get('formodule');
     $searchKey = $request->get('search_key');
     $searchValue = $request->get('search_value');
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "icon-chevron-down";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "icon-chevron-up";
     }
     if (empty($pageNumber)) {
         $pageNumber = 1;
     }
     $listViewModel = Settings_Vtiger_ListView_Model::getInstance($qualifiedModuleName);
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     if (!empty($searchKey) && !empty($searchValue)) {
         $listViewModel->set('search_key', $searchKey);
         $listViewModel->set('search_value', $searchValue);
     }
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!empty($sourceModule)) {
         $listViewModel->set('sourceModule', $sourceModule);
     }
     if (!empty($forModule)) {
         $listViewModel->set('formodule', $forModule);
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $noOfEntries = count($this->listViewEntries);
     if (!$this->listViewLinks) {
         $this->listViewLinks = $listViewModel->getListViewLinks();
     }
     $viewer->assign('LISTVIEW_LINKS', $this->listViewLinks);
     $configure = Settings_GravityForm_Module_Model::getConfigueUrl();
     $viewer->assign('CONFIGURE', $configure);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
     $viewer->assign('MODULE_MODEL', $listViewModel->getModule());
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('COLUMN_NAME', $orderBy);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel());
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
 }
 function process(Vtiger_Request $request)
 {
     Vtiger_Session::init();
     // Better place this here as session get initiated
     //skipping the csrf checking for the forgot(reset) password
     if ($request->get('mode') != 'reset' && $request->get('action') != 'Login') {
         require_once 'libraries/csrf-magic/csrf-magic.php';
     }
     // TODO - Get rid of global variable $current_user
     // common utils api called, depend on this variable right now
     $currentUser = $this->getLogin();
     vglobal('current_user', $currentUser);
     global $default_language;
     vglobal('default_language', $default_language);
     $currentLanguage = Vtiger_Language_Handler::getLanguage();
     vglobal('current_language', $currentLanguage);
     $module = $request->getModule();
     $qualifiedModuleName = $request->getModule(false);
     if ($currentUser && $qualifiedModuleName) {
         $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage, $qualifiedModuleName);
         vglobal('mod_strings', $moduleLanguageStrings['languageStrings']);
     }
     if ($currentUser) {
         $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage);
         vglobal('app_strings', $moduleLanguageStrings['languageStrings']);
     }
     $view = $request->get('view');
     $action = $request->get('action');
     $response = false;
     try {
         if ($this->isInstalled() === false && $module != 'Install') {
             header('Location:index.php?module=Install&view=Index');
             exit;
         }
         if (empty($module)) {
             if ($this->hasLogin()) {
                 $defaultModule = vglobal('default_module');
                 if (!empty($defaultModule) && $defaultModule != 'Home') {
                     $module = $defaultModule;
                     $qualifiedModuleName = $defaultModule;
                     $view = 'List';
                     if ($module == 'Calendar') {
                         // To load MyCalendar instead of list view for calendar
                         //TODO: see if it has to enhanced and get the default view from module model
                         $view = 'Calendar';
                     }
                 } else {
                     $module = 'Home';
                     $qualifiedModuleName = 'Home';
                     $view = 'DashBoard';
                 }
             } else {
                 $module = 'Users';
                 $qualifiedModuleName = 'Settings:Users';
                 $view = 'Login';
             }
             $request->set('module', $module);
             $request->set('view', $view);
         }
         if (!empty($action)) {
             $componentType = 'Action';
             $componentName = $action;
         } else {
             $componentType = 'View';
             if (empty($view)) {
                 $view = 'Index';
             }
             $componentName = $view;
         }
         $handlerClass = Vtiger_Loader::getComponentClassName($componentType, $componentName, $qualifiedModuleName);
         $handler = new $handlerClass();
         if ($handler) {
             vglobal('currentModule', $module);
             // Ensure handler validates the request
             $handler->validateRequest($request);
             if ($handler->loginRequired()) {
                 $this->checkLogin($request);
             }
             //TODO : Need to review the design as there can potential security threat
             $skipList = array('Users', 'Home', 'CustomView', 'Import', 'Export', 'Inventory', 'Vtiger', 'PriceBooks', 'Migration', 'Install');
             if (!in_array($module, $skipList) && stripos($qualifiedModuleName, 'Settings') === false) {
                 $this->triggerCheckPermission($handler, $request);
             }
             // Every settings page handler should implement this method
             if (stripos($qualifiedModuleName, 'Settings') === 0 || $module == 'Users') {
                 $handler->checkPermission($request);
             }
             $notPermittedModules = array('ModComments', 'Integration', 'DashBoard');
             if (in_array($module, $notPermittedModules) && $view == 'List') {
                 header('Location:index.php?module=Home&view=DashBoard');
             }
             $this->triggerPreProcess($handler, $request);
             $response = $handler->process($request);
             $this->triggerPostProcess($handler, $request);
         } else {
             throw new AppException(vtranslate('LBL_HANDLER_NOT_FOUND'));
         }
     } catch (Exception $e) {
         if ($view) {
             // Log for developement.
             error_log($e->getTraceAsString(), E_NOTICE);
             $viewer = new Vtiger_Viewer();
             $viewer->assign('MESSAGE', $e->getMessage());
             $viewer->view('OperationNotPermitted.tpl', 'Vtiger');
         } else {
             $response = new Vtiger_Response();
             $response->setEmitType(Vtiger_Response::$EMIT_JSON);
             $response->setError($e->getMessage());
         }
     }
     if ($response) {
         $response->emit();
     }
 }
示例#19
0
 public static function runScheduledImport()
 {
     global $current_user;
     $scheduledImports = self::getScheduledImport();
     $vtigerMailer = new Vtiger_Mailer();
     $vtigerMailer->IsHTML(true);
     foreach ($scheduledImports as $scheduledId => $importDataController) {
         $current_user = $importDataController->user;
         $importDataController->batchImport = false;
         if (!$importDataController->initializeImport()) {
             continue;
         }
         $importDataController->importData();
         $importStatusCount = $importDataController->getImportStatusCount();
         $emailSubject = 'vtiger CRM - Scheduled Import Report for ' . $importDataController->module;
         $viewer = new Vtiger_Viewer();
         $viewer->assign('FOR_MODULE', $importDataController->module);
         $viewer->assign('INVENTORY_MODULES', getInventoryModules());
         $viewer->assign('IMPORT_RESULT', $importStatusCount);
         $importResult = $viewer->view('Import_Result_Details.tpl', 'Import', true);
         $importResult = str_replace('align="center"', '', $importResult);
         $emailData = 'vtiger CRM has just completed your import process. <br/><br/>' . $importResult . '<br/><br/>' . 'We recommend you to login to the CRM and check few records to confirm that the import has been successful.';
         $userName = getFullNameFromArray('Users', $importDataController->user->column_fields);
         $userEmail = $importDataController->user->email1;
         $vtigerMailer->to = array(array($userEmail, $userName));
         $vtigerMailer->Subject = $emailSubject;
         $vtigerMailer->Body = $emailData;
         $vtigerMailer->Send();
         $importDataController->finishImport();
     }
     Vtiger_Mailer::dispatchQueue(null);
 }
示例#20
0
 public static function throwNoPermittedException($message, $die = true)
 {
     $request = new Vtiger_Request($_REQUEST);
     $db = PearDatabase::getInstance();
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $db->insert('s_yf_accesstorecord', ['username' => $currentUser->getDisplayName(), 'date' => date('Y-m-d H:i:s'), 'ip' => self::getRemoteIP(), 'record' => $request->get('record'), 'module' => $request->get('module'), 'url' => Vtiger_Functions::getBrowserInfo()->url, 'description' => '', 'agent' => $_SERVER['HTTP_USER_AGENT']]);
     if ($request->isAjax()) {
         $response = new Vtiger_Response();
         $response->setEmitType(Vtiger_Response::$EMIT_JSON);
         $response->setError($message);
         $response->emit();
     } else {
         $viewer = new Vtiger_Viewer();
         $viewer->assign('MESSAGE', $message);
         $viewer->view('NoPermissionsForRecord.tpl', 'Vtiger');
     }
     if ($die) {
         exit;
     }
 }
示例#21
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     //src_module value is added to just to stop showing inactive products
     $request->set('src_module', $request->getModule());
     $moduleName = $this->getModule($request);
     $cvId = $request->get('cvid');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $sourceModule = $request->get('src_module');
     $sourceField = $request->get('src_field');
     $sourceRecord = $request->get('src_record');
     $searchKey = $request->get('search_key');
     $searchValue = $request->get('search_value');
     $currencyId = $request->get('currency_id');
     $potentialId = $request->get('potentialid');
     $searchParams = $request->get('search_params');
     //To handle special operation when selecting record from Popup
     $getUrl = $request->get('get_url');
     //Check whether the request is in multi select mode
     $multiSelectMode = $request->get('multi_select');
     if (empty($multiSelectMode)) {
         $multiSelectMode = false;
     }
     if (empty($cvId)) {
         $cvId = '0';
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName, $sourceModule);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
     if (empty($orderBy) && empty($sortOrder)) {
         $moduleInstance = CRMEntity::getInstance($moduleName);
         $orderBy = $moduleInstance->default_order_by;
         $sortOrder = $moduleInstance->default_sort_order;
     }
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!empty($sourceModule)) {
         $listViewModel->set('src_module', $sourceModule);
         $listViewModel->set('src_field', $sourceField);
         $listViewModel->set('src_record', $sourceRecord);
     }
     if (!empty($searchKey) && !empty($searchValue)) {
         $listViewModel->set('search_key', $searchKey);
         $listViewModel->set('search_value', $searchValue);
     }
     $searchParmams = $request->get('search_params');
     if (empty($searchParmams)) {
         $searchParmams = array();
     }
     $transformedSearchParams = Vtiger_Util_Helper::transferListSearchParamsToFilterCondition($searchParmams, $moduleModel);
     $listViewModel->set('search_params', $transformedSearchParams);
     //To make smarty to get the details easily accesible
     foreach ($searchParmams as $fieldListGroup) {
         foreach ($fieldListGroup as $fieldSearchInfo) {
             $fieldSearchInfo['searchValue'] = $fieldSearchInfo[2];
             $fieldSearchInfo['fieldName'] = $fieldName = $fieldSearchInfo[0];
             $searchParmams[$fieldName] = $fieldSearchInfo;
         }
     }
     if (Settings_SalesProcesses_Module_Model::checkRelatedToPotentialsLimit() && Settings_SalesProcesses_Module_Model::isLimitForModule($sourceModule)) {
         if ($potentialId == '') {
             $potentialId = -1;
         }
         $listViewModel->set('potential_id', $potentialId);
         $viewer->assign('INVENTORY_LIMITED_FROM_POTENTIALS', true);
     }
     $productModel = Vtiger_Module_Model::getInstance('Products');
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries && $productModel->isActive()) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     if (!$productModel->isActive()) {
         $this->listViewEntries = array();
         $viewer->assign('LBL_MODULE_DISABLED', true);
     }
     foreach ($this->listViewEntries as $key => $listViewEntry) {
         $productId = $listViewEntry->getId();
         $subProducts = $listViewModel->getSubProducts($productId);
         if ($subProducts) {
             $listViewEntry->set('subProducts', $subProducts);
         }
     }
     $noOfEntries = count($this->listViewEntries);
     if (empty($sortOrder)) {
         $sortOrder = "ASC";
     }
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "downArrowSmall.png";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "upArrowSmall.png";
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('MODULE_NAME', $moduleName);
     $viewer->assign('RELATED_MODULE', $moduleName);
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     $viewer->assign('SOURCE_FIELD', $sourceField);
     $viewer->assign('SOURCE_RECORD', $sourceRecord);
     $viewer->assign('SEARCH_KEY', $searchKey);
     $viewer->assign('SEARCH_VALUE', $searchValue);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('GETURL', $getUrl);
     $viewer->assign('CURRENCY_ID', $currencyId);
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     $viewer->assign('POPUPTYPE', vglobal('popupType'));
     if (AppConfig::performance('LISTVIEW_COMPUTE_PAGE_COUNT')) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
     $viewer->assign('MULTI_SELECT', $multiSelectMode);
     $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->assign('TARGET_MODULE', $moduleName);
     $viewer->assign('MODULE', $request->getModule());
     $viewer->assign('GETURL', 'getTaxesURL');
     $viewer->assign('VIEW', 'ProductsPopup');
     $viewer->assign('SEARCH_DETAILS', $searchParmams);
 }
示例#22
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $this->getModule($request);
     $cvId = $request->get('cvid');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $sourceModule = $request->get('src_module');
     $sourceField = $request->get('src_field');
     $sourceRecord = $request->get('src_record');
     $searchKey = $request->get('search_key');
     $searchValue = $request->get('search_value');
     $currencyId = $request->get('currency_id');
     //To handle special operation when selecting record from Popup
     $getUrl = $request->get('get_url');
     //Check whether the request is in multi select mode
     $multiSelectMode = $request->get('multi_select');
     if (empty($multiSelectMode)) {
         $multiSelectMode = false;
     }
     if (empty($cvId)) {
         $cvId = '0';
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName, $sourceModule);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
     if (empty($orderBy) && empty($sortOrder)) {
         $moduleInstance = CRMEntity::getInstance($moduleName);
         $orderBy = $moduleInstance->default_order_by;
         $sortOrder = $moduleInstance->default_sort_order;
     }
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!empty($sourceModule)) {
         $listViewModel->set('src_module', $sourceModule);
         $listViewModel->set('src_field', $sourceField);
         $listViewModel->set('src_record', $sourceRecord);
     }
     if (!empty($searchKey) && !empty($searchValue)) {
         $listViewModel->set('search_key', $searchKey);
         $listViewModel->set('search_value', $searchValue);
     }
     if (!empty($currencyId)) {
         $listViewModel->set('currency_id', $currencyId);
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     //Added to support List Price
     $field = new Vtiger_Field_Model();
     $field->set('name', 'listprice');
     $field->set('column', 'listprice');
     $field->set('label', 'List Price');
     $this->listViewHeaders['listprice'] = $field;
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     foreach ($this->listViewEntries as $recordId => $recordModel) {
         $recordModel->set('listprice', $recordModel->getProductsListPrice($sourceRecord));
     }
     $noOfEntries = count($this->listViewEntries);
     if (empty($sortOrder)) {
         $sortOrder = "ASC";
     }
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "downArrowSmall.png";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "upArrowSmall.png";
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     $viewer->assign('SOURCE_FIELD', $sourceField);
     $viewer->assign('SOURCE_RECORD', $sourceRecord);
     $viewer->assign('SEARCH_KEY', $searchKey);
     $viewer->assign('SEARCH_VALUE', $searchValue);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('GETURL', $getUrl);
     $viewer->assign('CURRENCY_ID', $currencyId);
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
     $viewer->assign('MULTI_SELECT', $multiSelectMode);
     $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel());
 }
示例#23
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $this->getModule($request);
     $cvId = $request->get('cvid');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $sourceModule = $request->get('src_module');
     $sourceField = $request->get('src_field');
     $sourceRecord = $request->get('src_record');
     $searchKey = $request->get('search_key');
     $searchValue = $request->get('search_value');
     $currencyId = $request->get('currency_id');
     $relatedParentModule = $request->get('related_parent_module');
     $relatedParentId = $request->get('related_parent_id');
     //To handle special operation when selecting record from Popup
     $getUrl = $request->get('get_url');
     //Check whether the request is in multi select mode
     $multiSelectMode = $request->get('multi_select');
     if (empty($multiSelectMode)) {
         $multiSelectMode = false;
     }
     if (empty($cvId)) {
         $cvId = '0';
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     if (vglobal('popupAjax')) {
         $pagingModel->set('noLimit', true);
     }
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
     $isRecordExists = Vtiger_Util_Helper::checkRecordExistance($relatedParentId);
     if ($isRecordExists) {
         $relatedParentModule = '';
         $relatedParentId = '';
     } else {
         if ($isRecordExists === NULL) {
             $relatedParentModule = '';
             $relatedParentId = '';
         }
     }
     if (!empty($relatedParentModule) && !empty($relatedParentId)) {
         $parentRecordModel = Vtiger_Record_Model::getInstanceById($relatedParentId, $relatedParentModule);
         $listViewModel = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $moduleName, $label);
     } else {
         $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName, $sourceModule);
     }
     if (empty($orderBy) && empty($sortOrder)) {
         $moduleInstance = CRMEntity::getInstance($moduleName);
         $orderBy = $moduleInstance->default_order_by;
         $sortOrder = $moduleInstance->default_sort_order;
     }
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!empty($sourceModule)) {
         $listViewModel->set('src_module', $sourceModule);
         $listViewModel->set('src_field', $sourceField);
         $listViewModel->set('src_record', $sourceRecord);
     }
     if (!empty($searchKey) && !empty($searchValue)) {
         $listViewModel->set('search_key', $searchKey);
         $listViewModel->set('search_value', $searchValue);
     }
     $searchParmams = $request->get('search_params');
     if (empty($searchParmams)) {
         $searchParmams = array();
     }
     $transformedSearchParams = Vtiger_Util_Helper::transferListSearchParamsToFilterCondition($searchParmams, $moduleModel);
     $listViewModel->set('search_params', $transformedSearchParams);
     //To make smarty to get the details easily accesible
     foreach ($searchParmams as $fieldListGroup) {
         foreach ($fieldListGroup as $fieldSearchInfo) {
             $fieldSearchInfo['searchValue'] = $fieldSearchInfo[2];
             $fieldSearchInfo['fieldName'] = $fieldName = $fieldSearchInfo[0];
             $searchParmams[$fieldName] = $fieldSearchInfo;
         }
     }
     if (!empty($relatedParentModule) && !empty($relatedParentId)) {
         $this->listViewHeaders = $listViewModel->getHeaders();
         $models = $listViewModel->getEntries($pagingModel);
         $noOfEntries = count($models);
         foreach ($models as $recordId => $recordModel) {
             foreach ($this->listViewHeaders as $fieldName => $fieldModel) {
                 $recordModel->set($fieldName, $recordModel->getDisplayValue($fieldName));
             }
             $models[$recordId] = $recordModel;
         }
         $this->listViewEntries = $models;
         if (count($this->listViewEntries) > 0) {
             $parent_related_records = true;
         }
     } else {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     // If there are no related records with parent module then, we should show all the records
     if (!$parent_related_records && !empty($relatedParentModule) && !empty($relatedParentId)) {
         $relatedParentModule = null;
         $relatedParentId = null;
         $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName, $sourceModule);
         $listViewModel->set('search_params', $transformedSearchParams);
         if (!empty($orderBy)) {
             $listViewModel->set('orderby', $orderBy);
             $listViewModel->set('sortorder', $sortOrder);
         }
         if (!empty($sourceModule)) {
             $listViewModel->set('src_module', $sourceModule);
             $listViewModel->set('src_field', $sourceField);
             $listViewModel->set('src_record', $sourceRecord);
         }
         if (!empty($searchKey) && !empty($searchValue)) {
             $listViewModel->set('search_key', $searchKey);
             $listViewModel->set('search_value', $searchValue);
         }
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     // End
     $noOfEntries = count($this->listViewEntries);
     if (empty($sortOrder)) {
         $sortOrder = "ASC";
     }
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "downArrowSmall.png";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "upArrowSmall.png";
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('RELATED_MODULE', $moduleName);
     $viewer->assign('MODULE_NAME', $moduleName);
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     $viewer->assign('SOURCE_FIELD', $sourceField);
     $viewer->assign('SOURCE_RECORD', $sourceRecord);
     $viewer->assign('RELATED_PARENT_MODULE', $relatedParentModule);
     $viewer->assign('RELATED_PARENT_ID', $relatedParentId);
     $viewer->assign('SEARCH_KEY', $searchKey);
     $viewer->assign('SEARCH_VALUE', $searchValue);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('GETURL', $getUrl);
     $viewer->assign('CURRENCY_ID', $currencyId);
     $viewer->assign('POPUPTYPE', vglobal('popupType'));
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
     $viewer->assign('MULTI_SELECT', $multiSelectMode);
     $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->assign('SEARCH_DETAILS', $searchParmams);
 }
示例#24
0
function undoLastImport($obj, $user)
{
    $adb = PearDatabase::getInstance();
    $moduleName = $obj->get('module');
    $ownerId = $obj->get('foruser');
    $owner = new Users();
    $owner->id = $ownerId;
    $owner->retrieve_entity_info($ownerId, 'Users');
    $dbTableName = Import_Utils_Helper::getDbTableName($owner);
    if (!is_admin($user) && $user->id != $owner->id) {
        $viewer = new Vtiger_Viewer();
        $viewer->view('OperationNotPermitted.tpl', 'Vtiger');
        exit;
    }
    $result = $adb->query("SELECT recordid FROM {$dbTableName} WHERE temp_status = " . Import_Data_Controller::$IMPORT_RECORD_CREATED . " AND recordid IS NOT NULL;");
    $noOfRecords = $adb->num_rows($result);
    $noOfRecordsDeleted = 0;
    for ($i = 0; $i < $noOfRecords; ++$i) {
        $recordId = $adb->query_result($result, $i, 'recordid');
        if (isRecordExists($recordId) && isPermitted($moduleName, 'Delete', $recordId) == 'yes') {
            $focus = CRMEntity::getInstance($moduleName);
            $focus->id = $recordId;
            $focus->trash($moduleName, $recordId);
            $noOfRecordsDeleted++;
        }
    }
    $viewer = new Vtiger_Viewer();
    $viewer->assign('FOR_MODULE', $moduleName);
    $viewer->assign('TOTAL_RECORDS', $noOfRecords);
    $viewer->assign('DELETED_RECORDS_COUNT', $noOfRecordsDeleted);
    $viewer->view('ImportUndoResult.tpl');
}
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $cvId = $request->get('cvid');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $sourceModule = $request->get('src_module');
     $sourceField = $request->get('src_field');
     $sourceRecord = $request->get('src_record');
     $searchKey = $request->get('search_key');
     $searchValue = $request->get('search_value');
     if (empty($cvId)) {
         $cvId = '0';
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName, $sourceModule);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
     if (empty($orderBy) && empty($sortOrder)) {
         $moduleInstance = CRMEntity::getInstance($moduleName);
         $orderBy = $moduleInstance->default_order_by;
         $sortOrder = $moduleInstance->default_sort_order;
     }
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!empty($sourceModule)) {
         $listViewModel->set('src_module', $sourceModule);
         $listViewModel->set('src_field', $sourceField);
         $listViewModel->set('src_record', $sourceRecord);
         $sourceRecordModel = Vtiger_Record_Model::getInstanceById($sourceRecord, $sourceModule);
     }
     if (!empty($searchKey) && !empty($searchValue)) {
         $listViewModel->set('search_key', $searchKey);
         $listViewModel->set('search_value', $searchValue);
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     //get the unit prices for the pricebooks based on the product currency
     $productUnitPrice = Vtiger_Functions::getUnitPrice($sourceRecord, $sourceModule);
     $productPriceDetails = getPriceDetailsForProduct($sourceRecord, $productUnitPrice, 'available', $sourceModule);
     $productCurrencyPrice = array();
     foreach ($productPriceDetails as $priceDetails) {
         $productCurrencyPrice[$priceDetails['curid']] = $priceDetails['curvalue'];
     }
     foreach ($this->listViewEntries as $recordId => $recordModel) {
         $recordDetails = $recordModel->getRawData();
         $priceBookCurrencyId = $recordDetails['currency_id'];
         $recordModel->set('unit_price', $productCurrencyPrice[$priceBookCurrencyId]);
     }
     $noOfEntries = count($this->listViewEntries);
     if (empty($sortOrder)) {
         $sortOrder = "ASC";
     }
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "downArrowSmall.png";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "upArrowSmall.png";
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     $viewer->assign('SOURCE_FIELD', $sourceField);
     $viewer->assign('SOURCE_RECORD', $sourceRecord);
     $viewer->assign('SOURCE_RECORD_MODEL', $sourceRecordModel);
     //PARENT_MODULE is used for only translations
     $viewer->assign('PARENT_MODULE', 'PriceBooks');
     $viewer->assign('SEARCH_KEY', $searchKey);
     $viewer->assign('SEARCH_VALUE', $searchValue);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     $viewer->assign('VIEW', 'ProductPriceBookPopup');
 }
示例#26
0
 function getViewer(Vtiger_Request $request)
 {
     if (!$this->viewer) {
         global $YetiForce_current_version;
         $viewer = new Vtiger_Viewer();
         $viewer->assign('APPTITLE', getTranslatedString('APPTITLE'));
         $viewer->assign('YETIFORCE_VERSION', $YetiForce_current_version);
         $this->viewer = $viewer;
     }
     return $this->viewer;
 }
示例#27
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     $moduleName = $request->getModule();
     $sourceModule = $request->get('sourceModule');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "glyphicon glyphicon-chevron-down";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "glyphicon glyphicon-chevron-up";
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $moduleModel = RecycleBin_Module_Model::getInstance($moduleName);
     //If sourceModule is empty, pick the first module name from the list
     if (empty($sourceModule)) {
         foreach ($moduleModel->getAllModuleList() as $model) {
             $sourceModule = $model->get('name');
             break;
         }
     }
     $listViewModel = RecycleBin_ListView_Model::getInstance($moduleName, $sourceModule);
     $linkParams = array('MODULE' => $moduleName, 'ACTION' => $request->get('view'));
     $linkModels = $moduleModel->getListViewMassActions($linkParams);
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     if (empty($orderBy) && empty($sortOrder)) {
         $moduleInstance = CRMEntity::getInstance($moduleName);
         $orderBy = $moduleInstance->default_order_by;
         $sortOrder = $moduleInstance->default_sort_order;
     }
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $noOfEntries = count($this->listViewEntries);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('LISTVIEW_LINKS', $moduleModel->getListViewLinks());
     $viewer->assign('LISTVIEW_MASSACTIONS', $linkModels);
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('COLUMN_NAME', $orderBy);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     $viewer->assign('MODULE_LIST', $moduleModel->getAllModuleList());
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     $viewer->assign('DELETED_RECORDS_TOTAL_COUNT', $moduleModel->getDeletedRecordsTotalCount());
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
     $viewer->assign('IS_MODULE_DELETABLE', $listViewModel->getModule()->isPermitted('Delete'));
 }
示例#28
0
 public static function throwNewException($message, $die = true, $tpl = 'OperationNotPermitted.tpl')
 {
     $request = new Vtiger_Request($_REQUEST);
     if ($request->isAjax()) {
         $response = new Vtiger_Response();
         $response->setEmitType(Vtiger_Response::$EMIT_JSON);
         $response->setError($message);
         $response->emit();
     } else {
         $viewer = new Vtiger_Viewer();
         $viewer->assign('MESSAGE', $message);
         $viewer->view($tpl, 'Vtiger');
     }
     if ($die) {
         exit;
     }
 }
示例#29
0
 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     //src_module value is added to just to stop showing inactive products
     $request->set('src_module', $request->getModule());
     $moduleName = $this->getModule($request);
     $cvId = $request->get('cvid');
     $pageNumber = $request->get('page');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $sourceField = $request->get('src_field');
     $sourceRecord = $request->get('src_record');
     $searchKey = $request->get('search_key');
     $searchValue = $request->get('search_value');
     $currencyId = $request->get('currency_id');
     //To handle special operation when selecting record from Popup
     $getUrl = $request->get('get_url');
     // To handle subproducts in popup view
     $subProductsPopup = $request->get('subProductsPopup');
     $parentProductId = $request->get('productid');
     //Check whether the request is in multi select mode
     $multiSelectMode = $request->get('multi_select');
     if (empty($multiSelectMode)) {
         $multiSelectMode = false;
     }
     if (empty($cvId)) {
         $cvId = '0';
     }
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName);
     $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel);
     if (!empty($orderBy)) {
         $listViewModel->set('orderby', $orderBy);
         $listViewModel->set('sortorder', $sortOrder);
     }
     if (!empty($sourceModule)) {
         $listViewModel->set('src_module', $sourceModule);
         $listViewModel->set('src_field', $sourceField);
         $listViewModel->set('src_record', $sourceRecord);
     }
     if (!empty($searchKey) && !empty($searchValue)) {
         $listViewModel->set('search_key', $searchKey);
         $listViewModel->set('search_value', $searchValue);
     }
     if ($subProductsPopup && $parentProductId) {
         $listViewModel->set('subProductsPopup', true);
         $listViewModel->set('productId', $parentProductId);
         $viewer->assign('SUBPRODUCTS_POPUP', $subProductsPopup);
         $viewer->assign('PARENT_PRODUCT_ID', $parentProductId);
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $noOfEntries = count($this->listViewEntries);
     if (empty($sortOrder)) {
         $sortOrder = "ASC";
     }
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "downArrowSmall.png";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "upArrowSmall.png";
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('SOURCE_MODULE', $sourceModule);
     $viewer->assign('SOURCE_FIELD', $sourceField);
     $viewer->assign('SOURCE_RECORD', $sourceRecord);
     $viewer->assign('SEARCH_KEY', $searchKey);
     $viewer->assign('SEARCH_VALUE', $searchValue);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('GETURL', $getUrl);
     $viewer->assign('CURRENCY_ID', $currencyId);
     $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
     $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
     $viewer->assign('MULTI_SELECT', $multiSelectMode);
     $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->assign('MODULE', $request->getModule());
     $viewer->assign('GETURL', 'getTaxesURL');
     $viewer->assign('VIEW', 'SubProductsPopup');
     $viewer->assign('MAIN_PRODUCT_POPUP', true);
 }
示例#30
0
 public function mStep3(Vtiger_Request $request)
 {
     $system = $request->get('system');
     $source_directory = $request->get('source_directory');
     $username = $request->get('username');
     $password = $request->get('password');
     $errorText = '';
     $loginStatus = false;
     $migrationURL = 'Install.php?mode=execute&ajax=true&system=' . $system . '&user='******'result']) {
         include 'config/config.inc.php';
         $adb = new PearDatabase($dbconfig['db_type'], $dbconfig['db_hostname'], $dbconfig['db_name'], $dbconfig['db_username'], $dbconfig['db_password']);
         vglobal('adb', $adb);
         $query = "SELECT crypt_type, user_name FROM vtiger_users WHERE user_name=?";
         $result = $adb->requirePsSingleResult($query, array($username), true);
         if ($adb->num_rows($result) > 0) {
             $crypt_type = $adb->query_result($result, 0, 'crypt_type');
             $salt = substr($username, 0, 2);
             if ($crypt_type == 'MD5') {
                 $salt = '$1$' . $salt . '$';
             } elseif ($crypt_type == 'BLOWFISH') {
                 $salt = '$2$' . $salt . '$';
             } elseif ($crypt_type == 'PHP5.3MD5') {
                 $salt = '$1$' . str_pad($salt, 9, '0');
             }
             $encrypted_password = crypt($password, $salt);
             $query = "SELECT 1 from vtiger_users where user_name=? AND user_password=? AND status = ?";
             $result = $adb->requirePsSingleResult($query, array($username, $encrypted_password, 'Active'), true);
             if ($adb->num_rows($result) > 0) {
                 $loginStatus = true;
             }
         }
         if (!$loginStatus) {
             $errorText = 'LBL_WRONG_USERNAME_OR_PASSWORD';
             file_put_contents('config/config.inc.php', '');
         }
     } else {
         $errorText = $createConfig['text'];
     }
     $viewer->setTemplateDir('install/tpl/');
     $viewer->assign('LANG', $request->get('lang'));
     $viewer->assign('MIGRATIONURL', $migrationURL);
     $viewer->assign('ERRORTEXT', $errorText);
     $viewer->assign('MIGRATIONRESULT', $migrationResult);
     echo $viewer->fetch('mStep3.tpl');
     if ($loginStatus) {
         echo $viewer->fetch('mStep3Pre.tpl');
         $migrationResult = Install_InitSchema_Model::executeMigrationSchema($system, $username, $source_directory);
         echo $viewer->fetch('mStep3Post.tpl');
     }
 }