public static function render($userInputObject, $user)
 {
     global $list_max_entries_per_page;
     $adb = PearDatabase::getInstance();
     $viewer = new Import_UI_Viewer();
     $ownerId = $userInputObject->get('foruser');
     $owner = new Users();
     $owner->id = $ownerId;
     $owner->retrieve_entity_info($ownerId, 'Users');
     if (!is_admin($user) && $user->id != $owner->id) {
         $viewer->display('OperationNotPermitted.tpl', 'Vtiger');
         exit;
     }
     $userDBTableName = Import_Utils::getDbTableName($owner);
     $moduleName = $userInputObject->get('module');
     $moduleMeta = self::getModuleMeta($moduleName, $user);
     $result = $adb->query('SELECT recordid FROM ' . $userDBTableName . ' WHERE status is NOT NULL AND recordid IS NOT NULL');
     $noOfRecords = $adb->num_rows($result);
     $importedRecordIds = array();
     for ($i = 0; $i < $noOfRecords; ++$i) {
         $importedRecordIds[] = $adb->query_result($result, $i, 'recordid');
     }
     if (count($importedRecordIds) == 0) {
         $importedRecordIds[] = 0;
     }
     $focus = CRMEntity::getInstance($moduleName);
     $queryGenerator = new QueryGenerator($moduleName, $user);
     $customView = new CustomView($moduleName);
     $viewId = $customView->getViewIdByName('All', $moduleName);
     $queryGenerator->initForCustomViewById($viewId);
     $list_query = $queryGenerator->getQuery();
     // Fetch only last imported records
     $list_query .= ' AND ' . $focus->table_name . '.' . $focus->table_index . ' IN (' . implode(',', $importedRecordIds) . ')';
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
         $count_result = $adb->query(mkCountQuery($list_query));
         $noofrows = $adb->query_result($count_result, 0, "count");
     } else {
         $noofrows = null;
     }
     $start = ListViewSession::getRequestCurrentPage($moduleName, $list_query, $viewId, false);
     $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
     $limit_start_rec = ($start - 1) * $list_max_entries_per_page;
     $list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
     $recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows);
     $viewer->assign('recordListRange', $recordListRangeMsg);
     $controller = new ListViewController($adb, $user, $queryGenerator);
     $listview_header = $controller->getListViewHeader($focus, $moduleName, $url_string, $sorder, $order_by, true);
     $listview_entries = $controller->getListViewEntries($focus, $moduleName, $list_result, $navigation_array, true);
     $viewer->assign('CURRENT_PAGE', $start);
     $viewer->assign('LISTHEADER', $listview_header);
     $viewer->assign('LISTENTITY', $listview_entries);
     $viewer->assign('FOR_MODULE', $moduleName);
     $viewer->assign('FOR_USER', $ownerId);
     $isAjax = $userInputObject->get('ajax');
     if (!empty($isAjax)) {
         echo $viewer->fetch('ListViewEntries.tpl');
     } else {
         $viewer->display('ImportListView.tpl');
     }
 }
Exemple #2
0
 public function process(Vtiger_Request $request)
 {
     $viewer = $this->getViewer($request);
     $pageNumber = $request->get('page');
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $pagingModel->set('viewid', $cvId);
     $viewer->assign('PAGING_MODEL', $pagingModel);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $accountListViewModel->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);
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $accountListViewModel->getListViewEntries($pagingModel);
     }
     $noOfEntries = count($this->listViewEntries);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->view('ListViewActions.tpl', $request->getModule());
 }
Exemple #3
0
 /**
  * Function to get order by
  * return string  $order_by    - fieldname(eg: 'campaignname')
  */
 function getOrderBy()
 {
     global $log;
     $log->debug("Entering getOrderBy() method ...");
     $use_default_order_by = '';
     if (PerformancePrefs::getBoolean('LISTVIEW_DEFAULT_SORTING', true)) {
         $use_default_order_by = $this->default_order_by;
     }
     if (isset($_REQUEST['order_by'])) {
         $order_by = $this->db->sql_escape_string($_REQUEST['order_by']);
     } else {
         $order_by = $_SESSION['CAMPAIGN_ORDER_BY'] != '' ? $_SESSION['CAMPAIGN_ORDER_BY'] : $use_default_order_by;
     }
     $log->debug("Exiting getOrderBy method ...");
     return $order_by;
 }
 function getOrderBy()
 {
     global $currentModule;
     $use_default_order_by = '';
     if (PerformancePrefs::getBoolean('LISTVIEW_DEFAULT_SORTING', true)) {
         $use_default_order_by = $this->default_order_by;
     }
     $orderby = $use_default_order_by;
     if ($_REQUEST['order_by']) {
         $orderby = $this->db->sql_escape_string($_REQUEST['order_by']);
     } else {
         if ($_SESSION[$currentModule . '_Order_By']) {
             $orderby = $_SESSION[$currentModule . '_Order_By'];
         }
     }
     return $orderby;
 }
 function saveentity($module, $fileid = '')
 {
     global $current_user, $adb;
     //$adb added by raju for mass mailing
     $insertion_mode = $this->mode;
     $this->db->println("TRANS saveentity starts {$module}");
     $this->db->startTransaction();
     foreach ($this->tab_name as $table_name) {
         if ($table_name == "vtiger_crmentity") {
             $this->insertIntoCrmEntity($module, $fileid);
         } else {
             $this->insertIntoEntityTable($table_name, $module, $fileid);
         }
     }
     //Calling the Module specific save code
     $this->save_module($module);
     $assigntype = vtlib_purify($_REQUEST['assigntype']);
     if (PerformancePrefs::getBoolean('NOTIFY_OWNER_EMAILS', true) === true) {
         if ($module != "Calendar" && $module != "Accounts" && $module != "Contacts") {
             $this->whomToSendMail($module, $this->mode, $assigntype);
         }
     }
     $this->db->completeTransaction();
     $this->db->println("TRANS saveentity ends");
     // vtlib customization: Hook provide to enable generic module relation.
     // Ticket 6386 fix
     global $singlepane_view;
     if ($_REQUEST['return_action'] == 'CallRelatedList' || isset($singlepane_view) && $singlepane_view == true && $_REQUEST['return_action'] == 'DetailView' && !empty($_REQUEST['return_module'])) {
         $for_module = vtlib_purify($_REQUEST['return_module']);
         $for_crmid = vtlib_purify($_REQUEST['return_id']);
         $on_focus = CRMEntity::getInstance($for_module);
         // Do conditional check && call only for Custom Module at present
         // TOOD: $on_focus->IsCustomModule is not required if save_related_module function
         // is used for core modules as well.
         if ($on_focus->IsCustomModule && method_exists($on_focus, 'save_related_module')) {
             $with_module = $module;
             $with_crmid = $this->id;
             $on_focus->save_related_module($for_module, $for_crmid, $with_module, $with_crmid);
         }
     }
     // END
 }
Exemple #6
0
	function process(Vtiger_Request $request)
	{
		$viewer = $this->getViewer($request);
		$moduleName = $request->getModule();
		$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
		$folders = $moduleModel->getFolders();
		$folderId = $request->get('viewname');
		if (empty($folderId) || $folderId == 'undefined') {
			$folderId = 'All';
		}
		$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";
		}

		$listViewModel = new Reports_ListView_Model();
		$listViewModel->set('module', $moduleModel);
		$listViewModel->set('folderid', $folderId);

		if (!empty($orderBy)) {
			$listViewModel->set('orderby', $orderBy);
			$listViewModel->set('sortorder', $sortOrder);
		}
		$listViewMassActionModels = $listViewModel->getListViewMassActions();
		if (empty($pageNumber)) {
			$pageNumber = '1';
		}
		$viewer->assign('MODULE', $moduleName);
		$pagingModel = new Vtiger_Paging_Model();
		$pagingModel->set('page', $pageNumber);
		$viewer->assign('PAGING_MODEL', $pagingModel);

		$viewer->assign('LISTVIEW_MASSACTIONS', $listViewMassActionModels);

		if (!$this->listViewHeaders) {
			$this->listViewHeaders = $listViewModel->getListViewHeaders();
		}
		if ($folderId == 'All') {
			$this->listViewHeaders['foldername'] = 'LBL_FOLDER_NAME';
		}

		if (!$this->listViewEntries) {
			$this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
		}
		$moduleModel = Vtiger_Module_Model::getInstance($moduleName);

		$noOfEntries = count($this->listViewEntries);

		$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('MODULE_MODEL', $moduleModel);
		$viewer->assign('VIEWNAME', $folderId);

		$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('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);
		}

		$viewer->view('ListViewContents.tpl', $moduleName);
	}
Exemple #7
0
 /**
  * Function returns related records
  * @param Vtiger_Request $request
  * @return <type>
  */
 function showRelatedList(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $relatedModuleName = $request->get('relatedModule');
     $parentId = $request->get('record');
     $label = $request->get('tab_label');
     $requestedPage = $request->get('page');
     if (empty($requestedPage)) {
         $requestedPage = 1;
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $requestedPage);
     $parentRecordModel = Vtiger_Record_Model::getInstanceById($parentId, $moduleName);
     $relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName, $label);
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     if (empty($orderBy) && empty($sortOrder)) {
         $moduleInstance = CRMEntity::getInstance($relatedModuleName);
         $orderBy = $moduleInstance->default_order_by;
         $sortOrder = $moduleInstance->default_sort_order;
     }
     if ($sortOrder == "ASC") {
         $nextSortOrder = "DESC";
         $sortImage = "glyphicon glyphicon-chevron-down";
     } else {
         $nextSortOrder = "ASC";
         $sortImage = "glyphicon glyphicon-chevron-up";
     }
     if (!empty($orderBy)) {
         $relationListView->set('orderby', $orderBy);
         $relationListView->set('sortorder', $sortOrder);
     }
     $models = $relationListView->getEntries($pagingModel);
     $links = $relationListView->getLinks();
     $header = $relationListView->getHeaders();
     $noOfEntries = count($models);
     $parentRecordCurrencyId = $parentRecordModel->get('currency_id');
     if ($parentRecordCurrencyId) {
         $relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModuleName);
         foreach ($models as $recordId => $recorModel) {
             $productIdsList[$recordId] = $recordId;
         }
         $unitPricesList = $relatedModuleModel->getPricesForProducts($parentRecordCurrencyId, $productIdsList);
         foreach ($models as $recordId => $recorModel) {
             $recorModel->set('unit_price', $unitPricesList[$recordId]);
         }
     }
     $relationModel = $relationListView->getRelationModel();
     $relationField = $relationModel->getRelationField();
     $viewer = $this->getViewer($request);
     $viewer->assign('RELATED_RECORDS', $models);
     $viewer->assign('PARENT_RECORD', $parentRecordModel);
     $viewer->assign('RELATED_LIST_LINKS', $links);
     $viewer->assign('RELATED_HEADERS', $header);
     $viewer->assign('RELATED_MODULE', $relationModel->getRelationModuleModel());
     $viewer->assign('RELATED_ENTIRES_COUNT', $noOfEntries);
     $viewer->assign('RELATION_FIELD', $relationField);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         $totalCount = $relationListView->getRelatedEntriesCount();
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('TOTAL_ENTRIES', $totalCount);
         $viewer->assign('PERFORMANCE', true);
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('PAGING', $pagingModel);
     $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('USER_MODEL', Users_Record_Model::getCurrentUserModel());
     return $viewer->view('RelatedList.tpl', $moduleName, 'true');
 }
function getRecordRangeMessage($listResult, $limitStartRecord, $totalRows = '')
{
    global $adb, $app_strings;
    $numRows = $adb->num_rows($listResult);
    $recordListRangeMsg = '';
    if ($numRows > 0) {
        $recordListRangeMsg = $app_strings['LBL_SHOWING'] . ' ' . $app_strings['LBL_RECORDS'] . ' ' . ($limitStartRecord + 1) . ' - ' . ($limitStartRecord + $numRows);
        if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
            $recordListRangeMsg .= ' ' . $app_strings['LBL_LIST_OF'] . " {$totalRows}";
        }
    }
    return $recordListRangeMsg;
}
 /**
  * Constructor
  */
 function PearDatabase($dbtype = '', $host = '', $dbname = '', $username = '', $passwd = '')
 {
     global $currentModule;
     $this->log =& LoggerManager::getLogger('PearDatabase_' . $currentModule);
     $this->resetSettings($dbtype, $host, $dbname, $username, $passwd);
     // Initialize performance parameters
     $this->isdb_default_utf8_charset = PerformancePrefs::getBoolean('DB_DEFAULT_CHARSET_UTF8');
     $this->enableCache = PerformancePrefs::getBoolean('CACHE_QUERY_RESULT', false);
     // END
     if (!isset($this->dbType)) {
         $this->println("ADODB Connect : DBType not specified");
         return;
     }
     // Initialize the cache object to use.
     if (isset($this->enableCache) && $this->enableCache) {
         $this->__setCacheInstance(new PearDatabaseCache($this));
     }
     // END
 }
function getListViewEntries2($focus, $module, $list_result, $navigation_array, $relatedlist = '', $returnset = '', $edit_action = 'EditView', $del_action = 'Delete', $oCv = '', $page = '', $selectedfields = '', $contRelatedfields = '', $skipActions = false)
{
    global $log;
    global $mod_strings;
    $log->debug("Entering getListViewEntries(" . get_class($focus) . "," . $module . "," . $list_result . "," . $navigation_array . "," . $relatedlist . "," . $returnset . "," . $edit_action . "," . $del_action . "," . (is_object($oCv) ? get_class($oCv) : $oCv) . ") method ...");
    $tabname = getParentTab();
    global $adb, $current_user;
    global $app_strings;
    $noofrows = $adb->num_rows($list_result);
    $list_block = array();
    global $theme;
    $evt_status = '';
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    //getting the vtiger_fieldtable entries from database
    $tabid = getTabid($module);
    //added for vtiger_customview 27/5
    if ($oCv) {
        if (isset($oCv->list_fields)) {
            $focus->list_fields = $oCv->list_fields;
        }
    }
    if (is_array($selectedfields) && $selectedfields != '') {
        $focus->list_fields = $selectedfields;
    }
    // Remove fields which are made inactive
    $focus->filterInactiveFields($module);
    //Added to reduce the no. of queries logging for non-admin user -- by minnie-start
    $field_list = array();
    $j = 0;
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    foreach ($focus->list_fields as $name => $tableinfo) {
        $fieldname = $focus->list_fields_name[$name];
        if ($oCv) {
            if (isset($oCv->list_fields_name)) {
                $fieldname = $oCv->list_fields_name[$name];
            }
        }
        if ($fieldname == 'accountname' && $module != 'Accounts') {
            $fieldname = 'account_id';
        }
        if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) {
            $fieldname = 'contact_id';
        }
        if ($fieldname == 'productname' && $module != 'Products') {
            $fieldname = 'product_id';
        }
        array_push($field_list, $fieldname);
        $j++;
    }
    $field = array();
    if ($is_admin == false) {
        if ($module == 'Emails') {
            $query = "SELECT fieldname FROM vtiger_field WHERE tabid = ? and vtiger_field.presence in (0,2)";
            $params = array($tabid);
        } else {
            $profileList = getCurrentUserProfileList();
            $params = array();
            $query = "SELECT DISTINCT vtiger_field.fieldname\r\n\t\t\t\tFROM vtiger_field\r\n\t\t\t\tINNER JOIN vtiger_profile2field\r\n\t\t\t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\r\n\t\t\t\tINNER JOIN vtiger_def_org_field\r\n\t\t\t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid";
            if ($module == "Calendar") {
                $query .= " WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)";
            } else {
                $query .= " WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)";
                array_push($params, $tabid);
            }
            $query .= " AND vtiger_profile2field.visible = 0\r\n\t\t\t\t\tAND vtiger_profile2field.visible = 0\r\n\t\t\t\t\tAND vtiger_def_org_field.visible = 0\r\n\t\t\t\t\tAND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")\r\n\t\t\t\t\tAND vtiger_field.fieldname IN (" . generateQuestionMarks($field_list) . ")";
            array_push($params, $profileList, $field_list);
        }
        $result = $adb->pquery($query, $params);
        for ($k = 0; $k < $adb->num_rows($result); $k++) {
            $field[] = $adb->query_result($result, $k, "fieldname");
        }
    }
    //constructing the uitype and columnname array
    $ui_col_array = array();
    $params = array();
    $query = "SELECT uitype, columnname, fieldname FROM vtiger_field ";
    if ($module == "Calendar") {
        $query .= " WHERE vtiger_field.tabid in (9,16) and vtiger_field.presence in (0,2)";
    } else {
        $query .= " WHERE vtiger_field.tabid = ? and vtiger_field.presence in (0,2)";
        array_push($params, $tabid);
    }
    $query .= " AND fieldname IN (" . generateQuestionMarks($field_list) . ") ";
    array_push($params, $field_list);
    $result = $adb->pquery($query, $params);
    $num_rows = $adb->num_rows($result);
    for ($i = 0; $i < $num_rows; $i++) {
        $tempArr = array();
        $uitype = $adb->query_result($result, $i, 'uitype');
        $columnname = $adb->query_result($result, $i, 'columnname');
        $field_name = $adb->query_result($result, $i, 'fieldname');
        $tempArr[$uitype] = $columnname;
        $ui_col_array[$field_name] = $tempArr;
    }
    //end
    if ($navigation_array['start'] != 0) {
        for ($i = 1; $i <= $noofrows; $i++) {
            $list_header = array();
            //Getting the entityid
            if ($module != 'Users') {
                $entity_id = $adb->query_result($list_result, $i - 1, "crmid");
                $owner_id = $adb->query_result($list_result, $i - 1, "smownerid");
            } else {
                $entity_id = $adb->query_result($list_result, $i - 1, "id");
            }
            // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
            // begin: Armando Lüscher 05.07.2005 -> §priority
            // Code contri buted by fredy Desc: Set Priority color
            $priority = $adb->query_result($list_result, $i - 1, "priority");
            $font_color_high = "color:#00DD00;";
            $font_color_medium = "color:#DD00DD;";
            $P_FONT_COLOR = "";
            switch ($priority) {
                case 'High':
                    $P_FONT_COLOR = $font_color_high;
                    break;
                case 'Medium':
                    $P_FONT_COLOR = $font_color_medium;
                    break;
                default:
                    $P_FONT_COLOR = "";
            }
            //end: Armando Lüscher 05.07.2005 -> §priority
            foreach ($focus->list_fields as $name => $tableinfo) {
                $fieldname = $focus->list_fields_name[$name];
                //added for vtiger_customview 27/5
                if ($oCv) {
                    if (isset($oCv->list_fields_name)) {
                        $fieldname = $oCv->list_fields_name[$name];
                        if ($fieldname == 'accountname' && $module != 'Accounts') {
                            $fieldname = 'account_id';
                        }
                        if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) {
                            $fieldname = 'contact_id';
                        }
                        if ($fieldname == 'productname' && $module != 'Products') {
                            $fieldname = 'product_id';
                        }
                    } else {
                        $fieldname = $focus->list_fields_name[$name];
                    }
                } else {
                    $fieldname = $focus->list_fields_name[$name];
                    if ($fieldname == 'accountname' && $module != 'Accounts') {
                        $fieldname = 'account_id';
                    }
                    if ($fieldname == 'lastname' && ($module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Invoice' || $module == 'Quotes' || $module == 'Calendar')) {
                        $fieldname = 'contact_id';
                    }
                    if ($fieldname == 'productname' && $module != 'Products') {
                        $fieldname = 'product_id';
                    }
                }
                if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || in_array($fieldname, $field) || $fieldname == '' || $name == 'Close' && $module == 'Calendar') {
                    if ($fieldname == '') {
                        $table_name = '';
                        $column_name = '';
                        foreach ($tableinfo as $tablename => $colname) {
                            $table_name = $tablename;
                            $column_name = $colname;
                        }
                        $value = $adb->query_result($list_result, $i - 1, $colname);
                    } else {
                        if ($module == 'Calendar') {
                            $act_id = $adb->query_result($list_result, $i - 1, "activityid");
                            $cal_sql = "select activitytype from vtiger_activity where activityid=?";
                            $cal_res = $adb->pquery($cal_sql, array($act_id));
                            if ($adb->num_rows($cal_res) >= 0) {
                                $activitytype = $adb->query_result($cal_res, 0, "activitytype");
                            }
                        }
                        if (($module == 'Calendar' || $module == 'Emails' || $module == 'HelpDesk' || $module == 'Invoice' || $module == 'Leads' || $module == 'Contacts') && ($fieldname == 'parent_id' || $name == 'Contact Name' || $name == 'Close' || $fieldname == 'firstname')) {
                            if ($module == 'Calendar') {
                                if ($fieldname == 'status') {
                                    if ($activitytype == 'Task') {
                                        $fieldname = 'taskstatus';
                                    } else {
                                        $fieldname = 'eventstatus';
                                    }
                                }
                                if ($activitytype == 'Task') {
                                    if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') {
                                        $has_permission = 'yes';
                                    } else {
                                        $has_permission = 'no';
                                    }
                                } else {
                                    if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') {
                                        $has_permission = 'yes';
                                    } else {
                                        $has_permission = 'no';
                                    }
                                }
                            }
                            if ($module != 'Calendar' || $module == 'Calendar' && $has_permission == 'yes') {
                                if ($fieldname == 'parent_id') {
                                    $value = getRelatedTo($module, $list_result, $i - 1);
                                }
                                if ($name == 'Contact Name') {
                                    $contact_id = $adb->query_result($list_result, $i - 1, "contactid");
                                    $contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts");
                                    $value = "";
                                    //Added to get the contactname for activities custom view - t=2190
                                    if ($contact_id != '' && !empty($contact_name)) {
                                        $contact_name = getContactName($contact_id);
                                    }
                                    if ($contact_name != "" && $contact_id != 'NULL') {
                                        // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
                                        $value = "<a href='index.php?module=Contacts&action=DetailView&parenttab=" . $tabname . "&record=" . $contact_id . "' style='" . $P_FONT_COLOR . "'>" . $contact_name . "</a>";
                                        // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR"
                                    }
                                }
                                if ($fieldname == "firstname") {
                                    $first_name = textlength_check($adb->query_result($list_result, $i - 1, "firstname"));
                                    $value = '<a href="index.php?action=DetailView&module=' . $module . '&parenttab=' . $tabname . '&record=' . $entity_id . '">' . $first_name . '</a>';
                                }
                                if ($name == 'Close') {
                                    $status = $adb->query_result($list_result, $i - 1, "status");
                                    $activityid = $adb->query_result($list_result, $i - 1, "activityid");
                                    if (empty($activityid)) {
                                        $activityid = $adb->query_result($list_result, $i - 1, "tmp_activity_id");
                                    }
                                    $activitytype = $adb->query_result($list_result, $i - 1, "activitytype");
                                    // TODO - Picking activitytype when it is not present in the Custom View.
                                    // Going forward, this column should be added to the select list if not already present as a performance improvement.
                                    if (empty($activitytype)) {
                                        $activitytypeRes = $adb->pquery('SELECT activitytype FROM vtiger_activity WHERE activityid=?', array($activityid));
                                        if ($adb->num_rows($activitytypeRes) > 0) {
                                            $activitytype = $adb->query_result($activitytypeRes, 0, 'activitytype');
                                        }
                                    }
                                    if ($activitytype != 'Task' && $activitytype != 'Emails') {
                                        $eventstatus = $adb->query_result($list_result, $i - 1, "eventstatus");
                                        if (isset($eventstatus)) {
                                            $status = $eventstatus;
                                        }
                                    }
                                    if ($status == 'Deferred' || $status == 'Completed' || $status == 'Held' || $status == '') {
                                        $value = "";
                                    } else {
                                        if ($activitytype == 'Task') {
                                            $evt_status = '&status=Completed';
                                        } else {
                                            $evt_status = '&eventstatus=Held';
                                        }
                                        if (isPermitted("Calendar", 'EditView', $activityid) == 'yes') {
                                            if ($returnset == '') {
                                                $returnset = '&return_module=Calendar&return_action=ListView&return_id=' . $activityid . '&return_viewname=' . $oCv->setdefaultviewid;
                                            }
                                            // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
                                            $value = "<a href='index.php?action=Save&module=Calendar&record=" . $activityid . "&parenttab=" . $tabname . "&change_status=true" . $returnset . $evt_status . "&start=" . $navigation_array['current'] . "' style='" . $P_FONT_COLOR . "'>X</a>";
                                            // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR"
                                        } else {
                                            $value = "";
                                        }
                                    }
                                }
                            } else {
                                $value = "";
                            }
                        } elseif ($module == "Documents" && ($fieldname == 'filelocationtype' || $fieldname == 'filename' || $fieldname == 'filesize' || $fieldname == 'filestatus' || $fieldname == 'filetype')) {
                            $value = $adb->query_result($list_result, $i - 1, $fieldname);
                            if ($fieldname == 'filelocationtype') {
                                if ($value == 'I') {
                                    $value = getTranslatedString('LBL_INTERNAL', $module);
                                } elseif ($value == 'E') {
                                    $value = getTranslatedString('LBL_EXTERNAL', $module);
                                } else {
                                    $value = ' --';
                                }
                            }
                            if ($fieldname == 'filename') {
                                $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype');
                                if ($downloadtype == 'I') {
                                    $fld_value = $value;
                                    $ext_pos = strrpos($fld_value, ".");
                                    $ext = substr($fld_value, $ext_pos + 1);
                                    $ext = strtolower($ext);
                                    if ($value != '') {
                                        if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') {
                                            $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                                        } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') {
                                            $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                                        } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') {
                                            $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                                        } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') {
                                            $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>";
                                        } else {
                                            $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                                        }
                                    }
                                } elseif ($downloadtype == 'E') {
                                    if (trim($value) != '') {
                                        $fld_value = $value;
                                        $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>";
                                    } else {
                                        $fld_value = '--';
                                        $fileicon = '';
                                    }
                                } else {
                                    $fld_value = ' --';
                                    $fileicon = '';
                                }
                                $file_name = $adb->query_result($list_result, $i - 1, 'filename');
                                $notes_id = $adb->query_result($list_result, $i - 1, 'crmid');
                                $folder_id = $adb->query_result($list_result, $i - 1, 'folderid');
                                $download_type = $adb->query_result($list_result, $i - 1, 'filelocationtype');
                                $file_status = $adb->query_result($list_result, $i - 1, 'filestatus');
                                $fileidQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?";
                                $fileidres = $adb->pquery($fileidQuery, array($notes_id));
                                $fileid = $adb->query_result($fileidres, 0, 'attachmentsid');
                                if ($file_name != '' && $file_status == 1) {
                                    if ($download_type == 'I') {
                                        $fld_value = "<a href='index.php?module=uploads&action=downloadfile&entityid={$notes_id}&fileid={$fileid}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$notes_id});'>" . $fld_value . "</a>";
                                    } elseif ($download_type == 'E') {
                                        $fld_value = "<a target='_blank' href='{$file_name}' onclick='javascript:dldCntIncrease({$notes_id});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . $fld_value . "</a>";
                                    } else {
                                        $fld_value = ' --';
                                    }
                                }
                                $value = $fileicon . $fld_value;
                            }
                            if ($fieldname == 'filesize') {
                                $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype');
                                if ($downloadtype == 'I') {
                                    $filesize = $value;
                                    if ($filesize < 1024) {
                                        $value = $filesize . ' B';
                                    } elseif ($filesize > 1024 && $filesize < 1048576) {
                                        $value = round($filesize / 1024, 2) . ' KB';
                                    } else {
                                        if ($filesize > 1048576) {
                                            $value = round($filesize / (1024 * 1024), 2) . ' MB';
                                        }
                                    }
                                } else {
                                    $value = ' --';
                                }
                            }
                            if ($fieldname == 'filestatus') {
                                $filestatus = $value;
                                if ($filestatus == 1) {
                                    $value = getTranslatedString('yes', $module);
                                } elseif ($filestatus == 0) {
                                    $value = getTranslatedString('no', $module);
                                } else {
                                    $value = ' --';
                                }
                            }
                            if ($fieldname == 'filetype') {
                                $downloadtype = $adb->query_result($list_result, $i - 1, 'filelocationtype');
                                $filetype = $adb->query_result($list_result, $i - 1, 'filetype');
                                if ($downloadtype == 'E' || $downloadtype != 'I') {
                                    $value = ' --';
                                } else {
                                    $value = $filetype;
                                }
                            }
                            if ($fieldname == 'notecontent') {
                                $value = decode_html($value);
                                $value = textlength_check($value);
                            }
                        } elseif ($module == "Products" && $name == "Related to") {
                            $value = getRelatedTo($module, $list_result, $i - 1);
                        } elseif ($name == 'Contact Name' && ($module == 'SalesOrder' || $module == 'Quotes' || $module == 'PurchaseOrder')) {
                            if ($name == 'Contact Name') {
                                $contact_id = $adb->query_result($list_result, $i - 1, "contactid");
                                $contact_name = getFullNameFromQResult($list_result, $i - 1, "Contacts");
                                $value = "";
                                if ($contact_name != "" && $contact_id != 'NULL') {
                                    $value = "<a href='index.php?module=Contacts&action=DetailView&parenttab=" . $tabname . "&record=" . $contact_id . "' style='" . $P_FONT_COLOR . "'>" . $contact_name . "</a>";
                                }
                            }
                        } elseif ($name == 'Product') {
                            $product_id = textlength_check($adb->query_result($list_result, $i - 1, "productname"));
                            $value = $product_id;
                        } elseif ($name == 'Account Name') {
                            //modified for vtiger_customview 27/5
                            if ($module == 'Accounts') {
                                $account_id = $adb->query_result($list_result, $i - 1, "crmid");
                                //$account_name = getAccountName($account_id);
                                $account_name = textlength_check($adb->query_result($list_result, $i - 1, "accountname"));
                                // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
                                $value = '<a href="index.php?module=Accounts&action=DetailView&record=' . $account_id . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $account_name . '</a>';
                                // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR"
                            } elseif ($module == 'Potentials' || $module == 'Contacts' || $module == 'Invoice' || $module == 'SalesOrder' || $module == 'Quotes') {
                                //Potential,Contacts,Invoice,SalesOrder & Quotes  records   sort by Account Name
                                $accountname = textlength_check($adb->query_result($list_result, $i - 1, "accountname"));
                                $accountid = $adb->query_result($list_result, $i - 1, "accountid");
                                $value = '<a href="index.php?module=Accounts&action=DetailView&record=' . $accountid . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $accountname . '</a>';
                            } else {
                                $account_id = $adb->query_result($list_result, $i - 1, "accountid");
                                $account_name = getAccountName($account_id);
                                $acc_name = textlength_check($account_name);
                                // Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
                                $value = '<a href="index.php?module=Accounts&action=DetailView&record=' . $account_id . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $acc_name . '</a>';
                                // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR"
                            }
                        } elseif (($module == 'HelpDesk' || $module == 'PriceBook' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'Faq') && $name == 'Product Name') {
                            if ($module == 'HelpDesk' || $module == 'Faq') {
                                $product_id = $adb->query_result($list_result, $i - 1, "product_id");
                            } else {
                                $product_id = $adb->query_result($list_result, $i - 1, "productid");
                            }
                            if ($product_id != '') {
                                $product_name = getProductName($product_id);
                            } else {
                                $product_name = '';
                            }
                            $value = '<a href="index.php?module=Products&action=DetailView&parenttab=' . $tabname . '&record=' . $product_id . '">' . textlength_check($product_name) . '</a>';
                        } elseif ($module == 'Quotes' && $name == 'Potential Name' || $module == 'SalesOrder' && $name == 'Potential Name') {
                            $potential_id = $adb->query_result($list_result, $i - 1, "potentialid");
                            $potential_name = getPotentialName($potential_id);
                            $value = '<a href="index.php?module=Potentials&action=DetailView&parenttab=' . $tabname . '&record=' . $potential_id . '">' . textlength_check($potential_name) . '</a>';
                        } elseif ($module == 'Emails' && $relatedlist != '' && ($name == 'Subject' || $name == 'Date Sent' || $name == 'To')) {
                            $list_result_count = $i - 1;
                            $tmp_value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid);
                            $value = '<a href="javascript:;" onClick="ShowEmail(\'' . $entity_id . '\');">' . textlength_check($tmp_value) . '</a>';
                            if ($name == 'Date Sent') {
                                $sql = "select email_flag from vtiger_emaildetails where emailid=?";
                                $result = $adb->pquery($sql, array($entity_id));
                                $email_flag = $adb->query_result($result, 0, "email_flag");
                                if ($email_flag != 'SAVED') {
                                    $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid);
                                } else {
                                    $value = '';
                                }
                            }
                        } elseif ($module == 'Calendar' && ($fieldname != 'taskstatus' && $fieldname != 'eventstatus')) {
                            if ($activitytype == 'Task') {
                                if (getFieldVisibilityPermission('Calendar', $current_user->id, $fieldname) == '0') {
                                    $list_result_count = $i - 1;
                                    $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid);
                                } else {
                                    $value = '';
                                }
                            } else {
                                if (getFieldVisibilityPermission('Events', $current_user->id, $fieldname) == '0') {
                                    $list_result_count = $i - 1;
                                    $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid);
                                } else {
                                    $value = '';
                                }
                            }
                        } elseif ($module == "Accounting" && $fieldname == "accounting_id") {
                            $list_result_count = $i - 1;
                            $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid);
                            $value = '<a href="index.php?action=DetailView&module=' . $module . '&parenttab=' . $tabname . '&record=' . $entity_id . '">' . $value . '</a>';
                        } else {
                            $list_result_count = $i - 1;
                            $value = getValue($ui_col_array, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, "list", "", $returnset, $oCv->setdefaultviewid);
                        }
                    }
                    // vtlib customization: For listview javascript triggers
                    $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$entity_id}' vtfieldname='{$fieldname}' vtmodule='{$module}' style='display:none;'></span>";
                    // END
                    if ($module == "Calendar" && $name == $app_strings['Close']) {
                        if (isPermitted("Calendar", "EditView") == 'yes') {
                            if (getFieldVisibilityPermission('Events', $current_user->id, 'eventstatus') == '0' || getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') {
                                array_push($list_header, $value);
                            }
                        }
                    } else {
                        $list_header[] = $value;
                    }
                }
            }
            $varreturnset = '';
            if ($returnset == '') {
                $varreturnset = '&return_module=' . $module . '&return_action=index';
            } else {
                $varreturnset = $returnset;
            }
            if ($module == 'Calendar') {
                $actvity_type = $adb->query_result($list_result, $list_result_count, 'activitytype');
                if ($actvity_type == 'Task') {
                    $varreturnset .= '&activity_mode=Task';
                } else {
                    $varreturnset .= '&activity_mode=Events';
                }
            }
            //Added for Actions ie., edit and delete links in listview
            $links_info = "";
            if (!(is_array($selectedfields) && $selectedfields != '')) {
                if (isPermitted($module, "EditView", "") == 'yes') {
                    $edit_link = getListViewEditLink($module, $entity_id, $relatedlist, $varreturnset, $list_result, $list_result_count);
                    if (isset($_REQUEST['start']) && $_REQUEST['start'] > 1 && $module != 'Emails') {
                        $links_info .= "<a href=\"{$edit_link}&start=" . vtlib_purify($_REQUEST['start']) . "\">" . $app_strings["LNK_EDIT"] . "</a> ";
                    } else {
                        $links_info .= "<a href=\"{$edit_link}\">" . $app_strings["LNK_EDIT"] . "</a> ";
                    }
                }
                if (isPermitted($module, "Delete", "") == 'yes') {
                    $del_link = getListViewDeleteLink($module, $entity_id, $relatedlist, $varreturnset);
                    if ($links_info != "" && $del_link != "") {
                        $links_info .= " | ";
                    }
                    if ($del_link != "") {
                        $links_info .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . $app_strings["LNK_DELETE"] . "</a>";
                    }
                }
            }
            // Record Change Notification
            if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) {
                if (!$focus->isViewed($entity_id)) {
                    $links_info .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>";
                }
            }
            // END
            if ($links_info != "" && !$skipActions) {
                $list_header[] = $links_info;
            }
            //	$list_block[$entity_id] = $list_header;
            if (isset($_SESSION['partialpaymentview']) && $_SESSION['partialpaymentview'] == "true") {
                $list_block[$entity_id . "_" . $i] = $list_header;
            } else {
                $list_block[$entity_id] = $list_header;
            }
        }
    }
    $log->debug("Exiting getListViewEntries method ...");
    return $list_block;
}
Exemple #11
0
 /**
  * Function used to get the order by value for Documents listview
  * @return String order by column for a given folder.
  */
 function getOrderByForFolder($folderId)
 {
     $use_default_order_by = '';
     if (PerformancePrefs::getBoolean('LISTVIEW_DEFAULT_SORTING', true)) {
         $use_default_order_by = $this->default_order_by;
     }
     if (isset($_REQUEST['order_by']) && $_REQUEST['folderid'] == $folderId) {
         $order_by = $this->db->sql_escape_string($_REQUEST['order_by']);
     } elseif (is_array($_SESSION['NOTES_FOLDER_ORDER_BY']) && !empty($_SESSION['NOTES_FOLDER_ORDER_BY'][$folderId])) {
         $order_by = $_SESSION['NOTES_FOLDER_ORDER_BY'][$folderId];
     } else {
         $order_by = $use_default_order_by;
     }
     return $order_by;
 }
Exemple #12
0
 /**	Function to display the Services which are related to the PriceBook
  *	@param string $query - query to get the list of products which are related to the current PriceBook
  *	@param object $focus - PriceBook object which contains all the information of the current PriceBook
  *	@param string $returnset - return_module, return_action and return_id which are sequenced with & to pass to the URL which is optional
  *	return array $return_data which will be formed like array('header'=>$header,'entries'=>$entries_list) where as $header contains all the header columns and $entries_list will contain all the Service entries
  */
 function getPriceBookRelatedServices($query, $focus, $returnset = '')
 {
     global $log;
     $log->debug("Entering getPriceBookRelatedServices(" . $query . "," . get_class($focus) . "," . $returnset . ") method ...");
     global $adb;
     global $app_strings;
     global $current_language, $current_user;
     $current_module_strings = return_module_language($current_language, 'Services');
     global $list_max_entries_per_page;
     global $urlPrefix;
     global $theme;
     $pricebook_id = $_REQUEST['record'];
     $theme_path = "themes/" . $theme . "/";
     $image_path = $theme_path . "images/";
     $computeCount = $_REQUEST['withCount'];
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true || (bool) $computeCount == true) {
         $noofrows = $adb->query_result($adb->query(mkCountQuery($query)), 0, 'count');
     } else {
         $noofrows = null;
     }
     $module = 'PriceBooks';
     $relatedmodule = 'Services';
     if (!$_SESSION['rlvs'][$module][$relatedmodule]) {
         $modObj = new ListViewSession();
         $modObj->sortby = $focus->default_order_by;
         $modObj->sorder = $focus->default_sort_order;
         $_SESSION['rlvs'][$module][$relatedmodule] = get_object_vars($modObj);
     }
     if (isset($_REQUEST['relmodule']) && $_REQUEST['relmodule'] != '' && $_REQUEST['relmodule'] == $relatedmodule) {
         $relmodule = vtlib_purify($_REQUEST['relmodule']);
         if ($_SESSION['rlvs'][$module][$relmodule]) {
             setSessionVar($_SESSION['rlvs'][$module][$relmodule], $noofrows, $list_max_entries_per_page, $module, $relmodule);
         }
     }
     global $relationId;
     $start = RelatedListViewSession::getRequestCurrentPage($relationId, $query);
     $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
     $limit_start_rec = ($start - 1) * $list_max_entries_per_page;
     if ($adb->dbType == "pgsql") {
         $list_result = $adb->pquery($query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array());
     } else {
         $list_result = $adb->pquery($query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
     }
     $header = array();
     $header[] = $current_module_strings['LBL_LIST_SERVICE_NAME'];
     if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') {
         $header[] = $current_module_strings['LBL_SERVICE_UNIT_PRICE'];
     }
     $header[] = $current_module_strings['LBL_PB_LIST_PRICE'];
     if (isPermitted("PriceBooks", "EditView", "") == 'yes' || isPermitted("PriceBooks", "Delete", "") == 'yes') {
         $header[] = $app_strings['LBL_ACTION'];
     }
     $currency_id = $focus->column_fields['currency_id'];
     $numRows = $adb->num_rows($list_result);
     for ($i = 0; $i < $numRows; $i++) {
         $entity_id = $adb->query_result($list_result, $i, "crmid");
         $unit_price = $adb->query_result($list_result, $i, "unit_price");
         if ($currency_id != null) {
             $prod_prices = getPricesForProducts($currency_id, array($entity_id), 'Services');
             $unit_price = $prod_prices[$entity_id];
         }
         $listprice = $adb->query_result($list_result, $i, "listprice");
         $field_name = $entity_id . "_listprice";
         $entries = array();
         $entries[] = textlength_check($adb->query_result($list_result, $i, "servicename"));
         if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') {
             $entries[] = CurrencyField::convertToUserFormat($unit_price, null, true);
         }
         $entries[] = CurrencyField::convertToUserFormat($listprice, null, true);
         $action = "";
         if (isPermitted("PriceBooks", "EditView", "") == 'yes' && isPermitted('Services', 'EditView', $entity_id) == 'yes') {
             $action .= '<img style="cursor:pointer;" src="themes/images/editfield.gif" border="0" onClick="fnvshobj(this,\'editlistprice\'),editProductListPrice(\'' . $entity_id . '\',\'' . $pricebook_id . '\',\'' . $listprice . '\')" alt="' . $app_strings["LBL_EDIT_BUTTON"] . '" title="' . $app_strings["LBL_EDIT_BUTTON"] . '"/>';
         } else {
             $action .= '<img src="' . vtiger_imageurl('blank.gif', $theme) . '" border="0" />';
         }
         if (isPermitted("PriceBooks", "Delete", "") == 'yes' && isPermitted('Services', 'Delete', $entity_id) == 'yes') {
             if ($action != "") {
                 $action .= '&nbsp;|&nbsp;';
             }
             $action .= '<img src="themes/images/delete.gif" onclick="if(confirm(\'' . $app_strings['ARE_YOU_SURE'] . '\')) deletePriceBookProductRel(' . $entity_id . ',' . $pricebook_id . ');" alt="' . $app_strings["LBL_DELETE"] . '" title="' . $app_strings["LBL_DELETE"] . '" style="cursor:pointer;" border="0">';
         }
         if ($action != "") {
             $entries[] = $action;
         }
         $entries_list[] = $entries;
     }
     $navigationOutput[] = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows);
     $navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, '', $module, $relatedmodule, $focus->id);
     $return_data = array('header' => $header, 'entries' => $entries_list, 'navigation' => $navigationOutput);
     $log->debug("Exiting getPriceBookRelatedServices method ...");
     return $return_data;
 }
Exemple #13
0
 /**
  * Function to get order by
  * return string  $order_by    - fieldname(eg: 'accountname')
  */
 function getOrderBy()
 {
     global $log, $currentModule;
     $log->debug("Entering getOrderBy() method ...");
     $use_default_order_by = '';
     if (PerformancePrefs::getBoolean('LISTVIEW_DEFAULT_SORTING', true)) {
         $use_default_order_by = $this->default_order_by;
     }
     $order_by = $use_default_order_by;
     if (isset($_REQUEST['order_by'])) {
         $order_by = $this->db->sql_escape_string($_REQUEST['order_by']);
     } else {
         if (!empty($_SESSION[$currentModule . '_Order_By'])) {
             $order_by = $_SESSION[$currentModule . '_Order_By'];
         }
     }
     $log->debug("Exiting getOrderBy method ...");
     return $order_by;
 }
Exemple #14
0
	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'));
	}
 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 (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('TARGET_MODULE', $moduleName);
     $viewer->assign('MODULE', $request->getModule());
     $viewer->assign('GETURL', 'getTaxesURL');
     $viewer->assign('VIEW', 'ProductsPopup');
     $viewer->assign('SEARCH_DETAILS', $searchParmams);
 }
 function logSqlTime($startat, $endat, $sql, $params = false)
 {
     if (!PerformancePrefs::getBoolean('SQL_LOG_INCLUDE_CALLER', false)) {
         return;
     }
     $today = date('Y-m-d H:i:s');
     $logtable = 'vtiger_sqltimelog';
     $logsql = 'INSERT INTO ' . $logtable . '(id, type, started, ended, data, loggedon) VALUES (?,?,?,?,?,?)';
     if ($this->logSqlTimeID === false) {
         $this->logSqlTimeID = $this->getUniqueID($logtable);
         $type = php_sapi_name() == 'cli' ? 'CLI' : 'REQ';
         $data = '';
         if (isset($_SERVER['REQUEST_METHOD'])) {
             $uri = $_SERVER['REQUEST_URI'];
             $qmarkIndex = strpos($_SERVER['REQUEST_URI'], '?');
             if ($qmarkIndex !== false) {
                 $uri = substr($uri, 0, $qmarkIndex);
             }
             $data = $uri . '?' . http_build_query($_SERVER['REQUEST_METHOD'] == 'GET' ? $_GET : $_POST);
         } else {
             if ($argv) {
                 $data = implode(' ', $argv);
             }
         }
         $this->database->Execute($logsql, array($this->logSqlTimeID, $type, NULL, NULL, $data, $today));
     }
     $type = 'SQL';
     $data = trim($sql);
     if (is_array($params) && !empty($params)) {
         $data .= "\n[" . implode(",", $params) . "]";
     }
     $this->database->Execute($logsql, array($this->logSqlTimeID, $type, $startat, $endat, $data, $today));
     $type = 'CALLERS';
     $data = array();
     $callers = debug_backtrace();
     for ($calleridx = 0, $callerscount = count($callers); $calleridx < $callerscount; ++$calleridx) {
         if ($calleridx == 0) {
             continue;
         }
         if ($calleridx < $callerscount) {
             $callerfunc = $callers[$calleridx + 1]['function'];
             if (!empty($callerfunc)) {
                 $callerfunc = " ({$callerfunc}) ";
             }
         }
         $data[] = "CALLER: (" . $callers[$calleridx]['line'] . ') ' . $callers[$calleridx]['file'] . $callerfunc;
     }
     $this->database->Execute($logsql, array($this->logSqlTimeID, $type, NULL, NULL, implode("\n", $data), $today));
 }
Exemple #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);
     }
 }
Exemple #18
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'));
 }
Exemple #19
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);
 }
Exemple #20
0
 function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $relatedModuleName = $request->get('relatedModule');
     $parentId = $request->get('record');
     $label = $request->get('tab_label');
     $requestedPage = $request->get('page');
     if (empty($requestedPage)) {
         $requestedPage = 1;
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $requestedPage);
     $parentRecordModel = Vtiger_Record_Model::getInstanceById($parentId, $moduleName);
     $relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName, $label);
     $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($orderBy)) {
         $relationListView->set('orderby', $orderBy);
         $relationListView->set('sortorder', $sortOrder);
     }
     $models = $relationListView->getEntries($pagingModel);
     $links = $relationListView->getLinks();
     $header = $relationListView->getHeaders();
     $noOfEntries = count($models);
     $relationModel = $relationListView->getRelationModel();
     $relatedModuleModel = $relationModel->getRelationModuleModel();
     $relationField = $relationModel->getRelationField();
     $viewer = $this->getViewer($request);
     $viewer->assign('RELATED_RECORDS', $models);
     $viewer->assign('PARENT_RECORD', $parentRecordModel);
     $viewer->assign('RELATED_LIST_LINKS', $links);
     $viewer->assign('RELATED_HEADERS', $header);
     $viewer->assign('RELATED_MODULE', $relatedModuleModel);
     $viewer->assign('RELATED_ENTIRES_COUNT', $noOfEntries);
     $viewer->assign('RELATION_FIELD', $relationField);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         $totalCount = $relationListView->getRelatedEntriesCount();
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('TOTAL_ENTRIES', $totalCount);
         $viewer->assign('PERFORMANCE', true);
     }
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('PAGING', $pagingModel);
     $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('IS_EDITABLE', $relationModel->isEditable());
     $viewer->assign('IS_DELETABLE', $relationModel->isDeletable());
     $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->assign('VIEW', $request->get('view'));
     $viewer->assign('TOTALBS', 0);
     $viewer->assign('TOTALDS', 0);
     $viewer->assign('CANTIDAD', 0);
     return $viewer->view('RelatedList.tpl', $moduleName, 'true');
 }
Exemple #21
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);
 }
 function getListViewEntries($focus, $module, $result, $navigationInfo, $skipActions = false)
 {
     require 'user_privileges/user_privileges_' . $this->user->id . '.php';
     global $listview_max_textlength, $theme, $default_charset;
     $fields = $this->queryGenerator->getFields();
     $whereFields = $this->queryGenerator->getWhereFields();
     $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule());
     $moduleFields = $meta->getModuleFields();
     $accessibleFieldList = array_keys($moduleFields);
     $listViewFields = array_intersect($fields, $accessibleFieldList);
     $referenceFieldList = $this->queryGenerator->getReferenceFieldList();
     foreach ($referenceFieldList as $fieldName) {
         if (in_array($fieldName, $listViewFields)) {
             $field = $moduleFields[$fieldName];
             $this->fetchNameList($field, $result);
         }
     }
     $db = PearDatabase::getInstance();
     $rowCount = $db->num_rows($result);
     $ownerFieldList = $this->queryGenerator->getOwnerFieldList();
     foreach ($ownerFieldList as $fieldName) {
         if (in_array($fieldName, $listViewFields)) {
             $field = $moduleFields[$fieldName];
             $idList = array();
             for ($i = 0; $i < $rowCount; $i++) {
                 $id = $this->db->query_result($result, $i, $field->getColumnName());
                 if (!isset($this->ownerNameList[$fieldName][$id])) {
                     $idList[] = $id;
                 }
             }
             if (count($idList) > 0) {
                 if (!is_array($this->ownerNameList[$fieldName])) {
                     $this->ownerNameList[$fieldName] = getOwnerNameList($idList);
                 } else {
                     //array_merge API loses key information so need to merge the arrays
                     // manually.
                     $newOwnerList = getOwnerNameList($idList);
                     foreach ($newOwnerList as $id => $name) {
                         $this->ownerNameList[$fieldName][$id] = $name;
                     }
                 }
             }
         }
     }
     foreach ($listViewFields as $fieldName) {
         $field = $moduleFields[$fieldName];
         if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) {
             $this->setupAccessiblePicklistValueList($fieldName);
         }
     }
     $useAsterisk = get_use_asterisk($this->user->id);
     $data = array();
     for ($i = 0; $i < $rowCount; ++$i) {
         //Getting the recordId
         if ($module != 'Users') {
             $baseTable = $meta->getEntityBaseTable();
             $moduleTableIndexList = $meta->getEntityTableIndexList();
             $baseTableIndex = $moduleTableIndexList[$baseTable];
             $recordId = $db->query_result($result, $i, $baseTableIndex);
             $ownerId = $db->query_result($result, $i, "smownerid");
         } else {
             $recordId = $db->query_result($result, $i, "id");
         }
         $row = array();
         foreach ($listViewFields as $fieldName) {
             $field = $moduleFields[$fieldName];
             $uitype = $field->getUIType();
             $rawValue = $this->db->query_result($result, $i, $field->getColumnName());
             if ($module == 'Calendar') {
                 $activityType = $this->db->query_result($result, $i, 'activitytype');
             }
             if ($uitype != 8) {
                 $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset);
             } else {
                 $value = $rawValue;
             }
             if ($module == 'Documents' && $fieldName == 'filename') {
                 $downloadtype = $db->query_result($result, $i, 'filelocationtype');
                 if ($downloadtype == 'I') {
                     $ext = substr($value, strrpos($value, ".") + 1);
                     $ext = strtolower($ext);
                     if ($value != '') {
                         if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') {
                             $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                         } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') {
                             $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                         } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') {
                             $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                         } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') {
                             $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>";
                         } else {
                             $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                         }
                     }
                 } elseif ($downloadtype == 'E') {
                     if (trim($value) != '') {
                         $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>";
                     } else {
                         $value = '--';
                         $fileicon = '';
                     }
                 } else {
                     $value = ' --';
                     $fileicon = '';
                 }
                 $fileName = $db->query_result($result, $i, 'filename');
                 $downloadType = $db->query_result($result, $i, 'filelocationtype');
                 $status = $db->query_result($result, $i, 'filestatus');
                 $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?";
                 $fileIdRes = $db->pquery($fileIdQuery, array($recordId));
                 $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid');
                 if ($fileName != '' && $status == 1) {
                     if ($downloadType == 'I') {
                         $value = "<a href='index.php?module=uploads&action=downloadfile&" . "entityid={$recordId}&fileid={$fileId}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$recordId});'>" . textlength_check($value) . "</a>";
                     } elseif ($downloadType == 'E') {
                         $value = "<a target='_blank' href='{$fileName}' onclick='javascript:" . "dldCntIncrease({$recordId});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . textlength_check($value) . "</a>";
                     } else {
                         $value = ' --';
                     }
                 }
                 $value = $fileicon . $value;
             } elseif ($module == 'Documents' && $fieldName == 'filesize') {
                 $downloadType = $db->query_result($result, $i, 'filelocationtype');
                 if ($downloadType == 'I') {
                     $filesize = $value;
                     if ($filesize < 1024) {
                         $value = $filesize . ' B';
                     } elseif ($filesize > 1024 && $filesize < 1048576) {
                         $value = round($filesize / 1024, 2) . ' KB';
                     } else {
                         if ($filesize > 1048576) {
                             $value = round($filesize / (1024 * 1024), 2) . ' MB';
                         }
                     }
                 } else {
                     $value = ' --';
                 }
             } elseif ($module == 'Documents' && $fieldName == 'filestatus') {
                 if ($value == 1) {
                     $value = getTranslatedString('yes', $module);
                 } elseif ($value == 0) {
                     $value = getTranslatedString('no', $module);
                 } else {
                     $value = '--';
                 }
             } elseif ($module == 'Documents' && $fieldName == 'filetype') {
                 $downloadType = $db->query_result($result, $i, 'filelocationtype');
                 if ($downloadType == 'E' || $downloadType != 'I') {
                     $value = '--';
                 }
             } elseif ($field->getUIType() == '27') {
                 if ($value == 'I') {
                     $value = getTranslatedString('LBL_INTERNAL', $module);
                 } elseif ($value == 'E') {
                     $value = getTranslatedString('LBL_EXTERNAL', $module);
                 } else {
                     $value = ' --';
                 }
             } elseif ($field->getFieldDataType() == 'picklist') {
                 if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName])) {
                     $value = "<font color='red'>" . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>";
                 } else {
                     $value = getTranslatedString($value, $module);
                     $value = textlength_check($value);
                 }
             } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') {
                 if ($value != '' && $value != '0000-00-00') {
                     $date = new DateTimeField($value);
                     $value = $date->getDisplayDate();
                     if ($field->getFieldDataType() == 'datetime') {
                         $value .= ' ' . $date->getDisplayTime();
                     }
                 } elseif ($value == '0000-00-00') {
                     $value = '';
                 }
             } elseif ($field->getFieldDataType() == 'currency') {
                 if ($value != '') {
                     if ($field->getUIType() == 72) {
                         if ($fieldName == 'unit_price') {
                             $currencyId = getProductBaseCurrency($recordId, $module);
                             $cursym_convrate = getCurrencySymbolandCRate($currencyId);
                             $currencySymbol = $cursym_convrate['symbol'];
                         } else {
                             $currencyInfo = getInventoryCurrencyInfo($module, $recordId);
                             $currencySymbol = $currencyInfo['currency_symbol'];
                         }
                         $value = number_format($value, 2, '.', '');
                         $currencyValue = CurrencyField::convertToUserFormat($value, null, true);
                         $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol);
                     } else {
                         //changes made to remove vtiger_currency symbol infront of each
                         //vtiger_potential amount
                         if ($value != 0) {
                             $value = CurrencyField::convertToUserFormat($value);
                         }
                     }
                 }
             } elseif ($field->getFieldDataType() == 'url') {
                 $matchPattern = "^[\\w]+:\\/\\/^";
                 preg_match($matchPattern, $rawValue, $matches);
                 if (!empty($matches[0])) {
                     $value = '<a href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>';
                 } else {
                     $value = '<a href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>';
                 }
             } elseif ($field->getFieldDataType() == 'email') {
                 if ($_SESSION['internal_mailer'] == 1) {
                     //check added for email link in user detailview
                     $fieldId = $field->getFieldId();
                     $value = "<a href=\"javascript:InternalMailer({$recordId},{$fieldId}," . "'{$fieldName}','{$module}','record_id');\">" . textlength_check($value) . "</a>";
                 } else {
                     $value = '<a href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>';
                 }
             } elseif ($field->getFieldDataType() == 'boolean') {
                 if ($value == 1) {
                     $value = getTranslatedString('yes', $module);
                 } elseif ($value == 0) {
                     $value = getTranslatedString('no', $module);
                 } else {
                     $value = '--';
                 }
             } elseif ($field->getUIType() == 98) {
                 $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=' . 'Settings&roleid=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>';
             } elseif ($field->getFieldDataType() == 'multipicklist') {
                 $value = $value != "" ? str_replace(' |##| ', ', ', $value) : "";
                 if (!$is_admin && $value != '') {
                     $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array();
                     $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>";
                     $tmp = '';
                     $tmpArray = array();
                     foreach ($valueArray as $index => $val) {
                         if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) {
                             if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim($val), $this->picklistValueMap[$fieldName])) {
                                 $tmpArray[] = $notaccess;
                                 $tmp .= ', ' . $notaccess;
                             } else {
                                 $tmpArray[] = $val;
                                 $tmp .= ', ' . $val;
                             }
                         } else {
                             $tmpArray[] = '...';
                             $tmp .= '...';
                         }
                     }
                     $value = implode(', ', $tmpArray);
                     $value = textlength_check($value);
                 }
             } elseif ($field->getFieldDataType() == 'skype') {
                 $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : "";
             } elseif ($field->getFieldDataType() == 'phone') {
                 if ($useAsterisk == 'true') {
                     $value = "<a href='javascript:;' onclick='startCall(&quot;{$value}&quot;, " . "&quot;{$recordId}&quot;)'>" . textlength_check($value) . "</a>";
                 } else {
                     $value = textlength_check($value);
                 }
             } elseif ($field->getFieldDataType() == 'reference') {
                 $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList();
                 $moduleList = $referenceFieldInfoList[$fieldName];
                 if (count($moduleList) == 1) {
                     $parentModule = $moduleList[0];
                 } else {
                     $parentModule = $this->typeList[$value];
                 }
                 if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) {
                     $parentMeta = $this->queryGenerator->getMeta($parentModule);
                     $value = textlength_check($this->nameList[$fieldName][$value]);
                     if ($parentMeta->isModuleEntity() && $parentModule != "Users") {
                         $value = "<a href='index.php?module={$parentModule}&action=DetailView&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>";
                     }
                 } else {
                     $value = '--';
                 }
             } elseif ($field->getFieldDataType() == 'owner') {
                 $value = textlength_check($this->ownerNameList[$fieldName][$value]);
             } elseif ($field->getUIType() == 25) {
                 //TODO clean request object reference.
                 $contactId = $_REQUEST['record'];
                 $emailId = $this->db->query_result($result, $i, "activityid");
                 $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId));
                 $value = $this->db->query_result($result1, 0, "access_count");
                 if (!$value) {
                     $value = 0;
                 }
             } elseif ($field->getUIType() == 8) {
                 if (!empty($value)) {
                     $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset);
                     $json = new Zend_Json();
                     $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val)));
                 }
             } elseif (in_array($uitype, array(7, 9, 90))) {
                 $value = "<span align='right'>" . textlength_check($value) . "</div>";
             } elseif ($field->getUIType() == 55) {
                 $value = getTranslatedString($value, $currentModule);
             } else {
                 $value = textlength_check($value);
             }
             $parenttab = getParentTab();
             $nameFields = $this->queryGenerator->getModuleNameFields($module);
             $nameFieldList = explode(',', $nameFields);
             if (in_array($fieldName, $nameFieldList) && $module != 'Emails') {
                 $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>";
             } elseif ($fieldName == $focus->list_link_field && $module != 'Emails') {
                 $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>";
             }
             // vtlib customization: For listview javascript triggers
             $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=" . "'{$fieldName}' vtmodule='{$module}' style='display:none;'></span>";
             // END
             $row[] = $value;
         }
         //Added for Actions ie., edit and delete links in listview
         $actionLinkInfo = "";
         if (isPermitted($module, "EditView", "") == 'yes') {
             $edit_link = $this->getListViewEditLink($module, $recordId);
             if (isset($navigationInfo['start']) && $navigationInfo['start'] > 1 && $module != 'Emails') {
                 $actionLinkInfo .= "<a href=\"{$edit_link}&start=" . $navigationInfo['start'] . "\">" . getTranslatedString("LNK_EDIT", $module) . "</a> ";
             } else {
                 $actionLinkInfo .= "<a href=\"{$edit_link}\">" . getTranslatedString("LNK_EDIT", $module) . "</a> ";
             }
         }
         if (isPermitted($module, "Delete", "") == 'yes') {
             $del_link = $this->getListViewDeleteLink($module, $recordId);
             if ($actionLinkInfo != "" && $del_link != "") {
                 $actionLinkInfo .= " | ";
             }
             if ($del_link != "") {
                 $actionLinkInfo .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . getTranslatedString("LNK_DELETE", $module) . "</a>";
             }
         }
         // Record Change Notification
         if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) {
             if (!$focus->isViewed($recordId)) {
                 $actionLinkInfo .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>";
             }
         }
         // END
         if ($actionLinkInfo != "" && !$skipActions) {
             $row[] = $actionLinkInfo;
         }
         $data[$recordId] = $row;
     }
     return $data;
 }
 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);
 }
 function logSqlTime($startat, $endat, $sql, $params = false)
 {
     if (!PerformancePrefs::getBoolean('SQL_LOG_INCLUDE_CALLER', false)) {
         return;
     }
     $db = PearDatabase::getInstance('log');
     $now = date('Y-m-d H:i:s');
     $logTable = 'l_yf_sqltime';
     $logQuery = 'INSERT INTO ' . $logTable . '(id, type, qtime, data, date) VALUES (?,?,?,?,?)';
     if ($this->logSqlTimeID === false) {
         $stmt = $db->database->query('SELECT MAX(id) FROM ' . $logTable);
         $this->logSqlTimeID = (int) $this->getSingleValue($stmt) + 1;
         $type = PHP_SAPI;
         $data = '';
         if (isset($_SERVER['REQUEST_METHOD'])) {
             $uri = $_SERVER['REQUEST_URI'];
             $qmarkIndex = strpos($_SERVER['REQUEST_URI'], '?');
             if ($qmarkIndex !== false) {
                 $uri = substr($uri, 0, $qmarkIndex);
             }
             $data = $uri . '?' . http_build_query($_SERVER['REQUEST_METHOD'] == 'GET' ? $_GET : $_POST);
         }
         $stmt = $db->database->prepare($logQuery);
         $stmt->execute([$this->logSqlTimeID, $type, NULL, $data, $now]);
     }
     $type = 'SQL';
     $data = trim($sql);
     if (is_array($params) && !empty($params)) {
         $data .= '[' . implode(',', $params) . ']';
     }
     $qtime = round(($endat - $startat) * 1000) / 1000;
     $stmt = $db->database->prepare($logQuery);
     $stmt->execute([$this->logSqlTimeID, $type, $qtime, $data, $now]);
     $type = 'CALLERS';
     $data = [];
     $callers = debug_backtrace();
     for ($calleridx = 0, $callerscount = count($callers); $calleridx < $callerscount; ++$calleridx) {
         if ($calleridx == 0) {
             continue;
         }
         if ($calleridx < $callerscount) {
             $callerfunc = $callers[$calleridx + 1]['function'];
             if (!empty($callerfunc)) {
                 $callerfunc = " ({$callerfunc}) ";
             }
         }
         $data[] = 'CALLER: (' . $callers[$calleridx]['line'] . ') ' . $callers[$calleridx]['file'] . $callerfunc;
     }
     $stmt = $db->database->prepare($logQuery);
     $stmt->execute([$this->logSqlTimeID, $type, NULL, implode('\\n', $data), $now]);
 }
if ($Calendar4You->CheckPermissions("DELETE", $record)) {
    $smarty->assign("DELETE", "permitted");
}
if ($Calendar4You->CheckPermissions("EDIT", $record)) {
    $smarty->assign("EDIT_PERMISSION", "permitted");
}
$check_button = Button_Check($module);
$smarty->assign("CHECK", $check_button);
$tabid = getTabid($tab_type);
$validationData = getDBValidationData($focus->tab_name, $tabid);
$data2 = split_validationdataArray($validationData);
$smarty->assign("VALIDATION_DATA_FIELDNAME", $data2['fieldname']);
$smarty->assign("VALIDATION_DATA_FIELDDATATYPE", $data2['datatype']);
$smarty->assign("VALIDATION_DATA_FIELDLABEL", $data2['fieldlabel']);
$smarty->assign("MODULE", $currentModule);
if (PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($_SESSION[$currentModule . '_listquery'])) {
    $recordNavigationInfo = ListViewSession::getListViewNavigation($focus->id);
    VT_detailViewNavigation($smarty, $recordNavigationInfo, $focus->id);
}
// Gather the custom link information to display
include_once 'vtlib/Vtiger/Link.php';
$customlink_params = array('MODULE' => 'Calendar', 'RECORD' => $focus->id, 'ACTION' => vtlib_purify($_REQUEST['action']));
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid("Calendar"), array('DETAILVIEWBASIC', 'DETAILVIEW', 'DETAILVIEWWIDGET'), $customlink_params));
// END
$custom_fields_data = getCalendarCustomFields($tabid, 'detail_view', $focus->column_fields);
$smarty->assign("CUSTOM_FIELDS_DATA", $custom_fields_data);
$smarty->assign("IS_REL_LIST", isPresentRelatedLists($rel_tab_type));
if ($singlepane_view == 'true') {
    $related_array = getRelatedLists($tab_type, $focus);
    $smarty->assign("RELATEDLISTS", $related_array);
    require_once 'include/ListView/RelatedListViewSession.php';
Exemple #26
0
 /**
  * Function returns related records based on related moduleName
  * @param Vtiger_Request $request
  * @return <type>
  */
 function showRelatedRecords(Vtiger_Request $request)
 {
     $parentId = $request->get('record');
     $pageNumber = $request->get('page');
     $limit = $request->get('limit');
     $whereCondition = $request->get('whereCondition');
     $relatedModuleName = $request->get('relatedModule');
     $orderBy = $request->get('orderby');
     $sortOrder = $request->get('sortorder');
     $moduleName = $request->getModule();
     if (empty($pageNumber)) {
         $pageNumber = 1;
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     if (!empty($limit)) {
         $pagingModel->set('limit', $limit);
     } else {
         $pagingModel->set('limit', 10);
     }
     if ($sortOrder == 'ASC') {
         $nextSortOrder = 'DESC';
         $sortImage = 'glyphicon glyphicon-chevron-down';
     } else {
         $nextSortOrder = 'ASC';
         $sortImage = 'glyphicon glyphicon-chevron-up';
     }
     if (empty($orderBy) && empty($sortOrder)) {
         if (is_numeric($relatedModuleName)) {
             $relatedModuleName = Vtiger_Functions::getModuleName($relatedModuleName);
         }
         $relatedInstance = CRMEntity::getInstance($relatedModuleName);
         $orderBy = $relatedInstance->default_order_by;
         $sortOrder = $relatedInstance->default_sort_order;
     }
     $parentRecordModel = Vtiger_Record_Model::getInstanceById($parentId, $moduleName);
     $relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName);
     if (!empty($whereCondition)) {
         $relationListView->set('whereCondition', $whereCondition);
     }
     if (!empty($orderBy)) {
         $relationListView->set('orderby', $orderBy);
         $relationListView->set('sortorder', $sortOrder);
     }
     $models = $relationListView->getEntries($pagingModel);
     $links = $relationListView->getLinks();
     $header = $relationListView->getHeaders();
     $relationModel = $relationListView->getRelationModel();
     $relatedModuleModel = $relationModel->getRelationModuleModel();
     $relationField = $relationModel->getRelationField();
     $noOfEntries = count($models);
     $viewer = $this->getViewer($request);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('COLUMNS', $request->get('col'));
     $viewer->assign('LIMIT', $request->get('limit'));
     $viewer->assign('RELATED_RECORDS', $models);
     $viewer->assign('RELATED_HEADERS', $header);
     $viewer->assign('RELATED_MODULE', $relatedModuleModel);
     $viewer->assign('RELATED_MODULE_NAME', $relatedModuleName);
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->assign('PARENT_RECORD', $parentRecordModel);
     $viewer->assign('RELATED_LIST_LINKS', $links);
     $viewer->assign('RELATED_ENTIRES_COUNT', $noOfEntries);
     $viewer->assign('RELATION_FIELD', $relationField);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         $totalCount = $relationListView->getRelatedEntriesCount();
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('TOTAL_ENTRIES', $totalCount);
         $viewer->assign('PERFORMANCE', true);
     }
     $viewer->assign('PAGING', $pagingModel);
     $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('IS_EDITABLE', $relationModel->isEditable());
     $viewer->assign('IS_DELETABLE', $relationModel->isDeletable());
     return $viewer->view('SummaryWidgets.tpl', $moduleName, 'true');
 }
        }
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('SalesOrder', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY ' . $tablename . $order_by;
        }
        $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
}
///Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $list_query = fixPostgresQuery($list_query, $log, 0);
}
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->query(mkCountQuery($list_query));
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
    $noofrows = null;
}
$queryMode = isset($_REQUEST['query']) && $_REQUEST['query'] == 'true';
$start = ListViewSession::getRequestCurrentPage($currentModule, $list_query, $viewid, $queryMode);
$navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
$limit_start_rec = ($start - 1) * $list_max_entries_per_page;
if ($adb->dbType == "pgsql") {
    $list_result = $adb->pquery($list_query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array());
} else {
    $list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
}
$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec);
Exemple #28
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'));
 }
function HelpDesk_notifyOwnerOnTicketChange($entityData)
{
    global $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID;
    $moduleName = $entityData->getModuleName();
    $wsId = $entityData->getId();
    $parts = explode('x', $wsId);
    $entityId = $parts[1];
    $isNew = $entityData->isNew();
    if (!$isNew) {
        $reply = 'Re : ';
    } else {
        $reply = '';
    }
    // SalesPlatform.ru begin
    $subject = ' [ ' . getTranslatedString('Ticket No', $moduleName) . ' ' . $entityData->get('ticket_no') . ' ] ' . $reply . $entityData->get('ticket_title');
    //$subject = $entityData->get('ticket_no') . ' [ '.getTranslatedString('LBL_TICKET_ID', $moduleName)
    //					.' : '.$entityId.' ] '.$reply.$entityData->get('ticket_title');
    // SalesPlatform.ru end
    $email_body = HelpDesk::getTicketEmailContents($entityData, true);
    if (PerformancePrefs::getBoolean('NOTIFY_OWNER_EMAILS', true) === true) {
        //send mail to the assigned to user and the parent to whom this ticket is assigned
        require_once 'modules/Emails/mail.php';
        $wsAssignedUserId = $entityData->get('assigned_user_id');
        $userIdParts = explode('x', $wsAssignedUserId);
        $ownerId = $userIdParts[1];
        $ownerType = vtws_getOwnerType($ownerId);
        if ($ownerType == 'Users') {
            $to_email = getUserEmailId('id', $ownerId);
        }
        if ($ownerType == 'Groups') {
            $to_email = implode(',', getDefaultAssigneeEmailIds($ownerId));
        }
        if ($to_email != '') {
            if ($isNew) {
                $mail_status = send_mail('HelpDesk', $to_email, $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID, $subject, $email_body);
            } else {
                $entityDelta = new VTEntityDelta();
                $statusHasChanged = $entityDelta->hasChanged($entityData->getModuleName(), $entityId, 'ticketstatus');
                $solutionHasChanged = $entityDelta->hasChanged($entityData->getModuleName(), $entityId, 'solution');
                $ownerHasChanged = $entityDelta->hasChanged($entityData->getModuleName(), $entityId, 'assigned_user_id');
                $descriptionHasChanged = $entityDelta->hasChanged($entityData->getModuleName(), $entityId, 'description');
                if ($statusHasChanged && $entityData->get('ticketstatus') == "Closed" || $solutionHasChanged || $ownerHasChanged || $descriptionHasChanged) {
                    $mail_status = send_mail('HelpDesk', $to_email, $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID, $subject, $email_body);
                }
            }
            $mail_status_str = $to_email . "=" . $mail_status . "&&&";
        } else {
            $mail_status_str = "'" . $to_email . "'=0&&&";
        }
        if ($mail_status != '') {
            $mail_error_status = getMailErrorString($mail_status_str);
        }
    }
}
$smarty->assign("TODO_PERMISSION", CheckFieldPermission('parent_id', 'Calendar'));
$smarty->assign("EVENT_PERMISSION", CheckFieldPermission('parent_id', 'Events'));
$check_button = Button_Check($module);
$smarty->assign("CHECK", $check_button);
$smarty->assign("EDIT_PERMISSION", isPermitted($currentModule, 'EditView', $_REQUEST['record']));
$smarty->assign("IS_REL_LIST", isPresentRelatedLists($currentModule));
if ($singlepane_view == 'true') {
    $related_array = getRelatedLists($currentModule, $focus);
    $smarty->assign("RELATEDLISTS", $related_array);
    require_once 'include/ListView/RelatedListViewSession.php';
    if (!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) {
        RelatedListViewSession::addRelatedModuleToSession(vtlib_purify($_REQUEST['relation_id']), vtlib_purify($_REQUEST['selected_header']));
    }
    $open_related_modules = RelatedListViewSession::getRelatedModulesFromSession();
    $smarty->assign("SELECTEDHEADERS", $open_related_modules);
}
$smarty->assign("SinglePane_View", $singlepane_view);
if (PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($_SESSION[$currentModule . '_listquery'])) {
    $recordNavigationInfo = ListViewSession::getListViewNavigation($focus->id);
    VT_detailViewNavigation($smarty, $recordNavigationInfo, $focus->id);
}
// Record Change Notification
$focus->markAsViewed($current_user->id);
// END
// Gather the custom link information to display
include_once 'vtlib/Vtiger/Link.php';
$customlink_params = array('MODULE' => $currentModule, 'RECORD' => $focus->id, 'ACTION' => vtlib_purify($_REQUEST['action']));
$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), array('DETAILVIEWBASIC', 'DETAILVIEW', 'DETAILVIEWWIDGET'), $customlink_params));
// END
$smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true));
$smarty->display("Inventory/InventoryDetailView.tpl");