晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /proc/thread-self/root/home/akaindir/public_html/crm/modules/PickList/ |
Upload File : |
<?php
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*********************************************************************************/
require_once 'includes/runtime/Cache.php';
/**
* this file will be used to store the functions to be used in the picklist module
*/
/**
* Function to get picklist fields for the given module
* @ param $fld_module
* It gets the picklist details array for the given module in the given format
* $fieldlist = Array(Array('fieldlabel'=>$fieldlabel,'generatedtype'=>$generatedtype,'columnname'=>$columnname,'fieldname'=>$fieldname,'value'=>picklistvalues))
*/
function getUserFldArray($fld_module,$roleid){
global $adb, $log;
$user_fld = Array();
$tabid = getTabid($fld_module);
$query="select vtiger_field.fieldlabel,vtiger_field.columnname,vtiger_field.fieldname, vtiger_field.uitype" .
" FROM vtiger_field inner join vtiger_picklist on vtiger_field.fieldname = vtiger_picklist.name" .
" where (displaytype=1 and vtiger_field.tabid=? and vtiger_field.uitype in ('15','55','33','16') " .
" or (vtiger_field.tabid=? and fieldname='salutationtype' and fieldname !='vendortype')) " .
" and vtiger_field.presence in (0,2) ORDER BY vtiger_picklist.picklistid ASC";
$result = $adb->pquery($query, array($tabid, $tabid));
$noofrows = $adb->num_rows($result);
if($noofrows > 0){
$fieldlist = array();
for($i=0; $i<$noofrows; $i++){
$user_fld = array();
$fld_name = $adb->query_result($result,$i,"fieldname");
$user_fld['fieldlabel'] = $adb->query_result($result,$i,"fieldlabel");
$user_fld['generatedtype'] = $adb->query_result($result,$i,"generatedtype");
$user_fld['columnname'] = $adb->query_result($result,$i,"columnname");
$user_fld['fieldname'] = $adb->query_result($result,$i,"fieldname");
$user_fld['uitype'] = $adb->query_result($result,$i,"uitype");
$user_fld['value'] = getAssignedPicklistValues($user_fld['fieldname'], $roleid, $adb);
$fieldlist[] = $user_fld;
}
}
return $fieldlist;
}
/**
* Function to get modules which has picklist values
* It gets the picklist modules and return in an array in the following format
* $modules = Array($tabid=>$tablabel,$tabid1=>$tablabel1,$tabid2=>$tablabel2,-------------,$tabidn=>$tablabeln)
*/
function getPickListModules(){
global $adb;
// vtlib customization: Ignore disabled modules.
$query = 'select distinct vtiger_field.fieldname,vtiger_field.tabid,vtiger_tab.tablabel, vtiger_tab.name as tabname,uitype from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where uitype IN (15,33) and vtiger_field.tabid != 29 and vtiger_tab.presence != 1 and vtiger_field.presence in (0,2) order by vtiger_field.tabid ASC';
// END
$result = $adb->pquery($query, array());
while($row = $adb->fetch_array($result)){
$modules[$row['tablabel']] = $row['tabname'];
}
return $modules;
}
/**
* this function returns all the roles present in the CRM so that they can be displayed in the picklist module
* @return array $role - the roles present in the CRM in the array format
*/
function getrole2picklist(){
global $adb;
$query = "select rolename,roleid from vtiger_role where roleid not in('H1') order by roleid";
$result = $adb->pquery($query, array());
while($row = $adb->fetch_array($result)){
$role[$row['roleid']] = $row['rolename'];
}
return $role;
}
/**
* this function returns the picklists available for a module
* @param array $picklist_details - the details about the picklists in the module
* @return array $module_pick - the picklists present in the module in an array format
*/
function get_available_module_picklist($picklist_details){
$avail_pick_values = $picklist_details;
foreach($avail_pick_values as $key => $val){
$module_pick[$avail_pick_values[$key]['fieldname']] = getTranslatedString($avail_pick_values[$key]['fieldlabel']);
}
return $module_pick;
}
/**
* this function returns all the picklist values that are available for a given
* @param string $fieldName - the name of the field
* @return array $arr - the array containing the picklist values
*/
function getAllPickListValues($fieldName,$lang = Array() ){
global $adb;
if(Vtiger_Cache::get('AllPicklistValues',$fieldName)){
return Vtiger_Cache::get('AllPicklistValues',$fieldName);
}
$userRecordModel = Users_Record_Model::getCurrentUserModel();
if($fieldName == 'group_id'){
$arr = array_map('decode_html', $userRecordModel->getAccessibleGroups());
}else if ($fieldName == 'assigned_user_id'){
$arr = array_map('decode_html', $userRecordModel->getAccessibleUsers());
}else {
$sql = 'SELECT * FROM vtiger_'.$adb->sql_escape_string($fieldName);
$result = $adb->query($sql);
$count = $adb->num_rows($result);
$arr = array();
for($i=0;$i<$count;$i++){
$pick_val = decode_html($adb->query_result($result, $i, $fieldName));
if($lang[$pick_val] != ''){
$arr[$pick_val] = $lang[$pick_val];
}
else{
$arr[$pick_val] = $pick_val;
}
}
}
Vtiger_Cache::set('AllPicklistValues', $fieldName, $arr);
return $arr;
}
/**
* this function accepts the fieldname and the language string array and returns all the editable picklist values for that fieldname
* @param string $fieldName - the name of the picklist
* @param array $lang - the language string array
* @param object $adb - the peardatabase object
* @return array $pick - the editable picklist values
*/
function getEditablePicklistValues($fieldName, $lang= array(), $adb){
$values = array();
$fieldName = $adb->sql_escape_string($fieldName);
$sql="select $fieldName from vtiger_$fieldName where presence=1 and $fieldName <> '--None--'";
$res = $adb->query($sql);
$RowCount = $adb->num_rows($res);
if($RowCount > 0){
for($i=0;$i<$RowCount;$i++){
$pick_val = $adb->query_result($res,$i,$fieldName);
if($lang[$pick_val] != ''){
$values[$pick_val]=$lang[$pick_val];
}else{
$values[$pick_val]=$pick_val;
}
}
}
return $values;
}
/**
* this function accepts the fieldname and the language string array and returns all the non-editable picklist values for that fieldname
* @param string $fieldName - the name of the picklist
* @param array $lang - the language string array
* @param object $adb - the peardatabase object
* @return array $pick - the no-editable picklist values
*/
function getNonEditablePicklistValues($fieldName, $lang=array(), $adb){
$values = array();
$fieldName = $adb->sql_escape_string($fieldName);
$sql = "select $fieldName from vtiger_$fieldName where presence=0";
$result = $adb->query($sql);
$count = $adb->num_rows($result);
for($i=0;$i<$count;$i++){
$non_val = $adb->query_result($result,$i,$fieldName);
if($lang[$non_val] != ''){
$values[]=$lang[$non_val];
}else{
$values[]=$non_val;
}
}
if(count($values)==0){
$values = "";
}
return $values;
}
/**
* this function returns all the assigned picklist values for the given tablename for the given roleid
* @param string $tableName - the picklist tablename
* @param integer $roleid - the roleid of the role for which you want data
* @param object $adb - the peardatabase object
* @return array $val - the assigned picklist values in array format
*/
function getAssignedPicklistValues($tableName, $roleid, $adb, $lang=array()){
$cache = Vtiger_Cache::getInstance();
if($cache->hasAssignedPicklistValues($tableName,$roleid)) {
return $cache->getAssignedPicklistValues($tableName,$roleid);
} else {
$arr = array();
$sql = "select picklistid from vtiger_picklist where name = ?";
$result = $adb->pquery($sql, array($tableName));
if($adb->num_rows($result)){
$picklistid = $adb->query_result($result, 0, "picklistid");
$sub = getSubordinateRoleAndUsers($roleid);
$subRoles = array($roleid);
$subRoles = array_merge($subRoles, array_keys($sub));
$roleids = array();
foreach($subRoles as $role){
$roleids[] = $role;
}
$sql = "SELECT distinct ".$adb->sql_escape_string($tableName)." FROM ". $adb->sql_escape_string("vtiger_$tableName")
. " inner join vtiger_role2picklist on ".$adb->sql_escape_string("vtiger_$tableName").".picklist_valueid=vtiger_role2picklist.picklistvalueid"
. " and roleid in (".generateQuestionMarks($roleids).") order by sortorderid";
$result = $adb->pquery($sql, $roleids);
$count = $adb->num_rows($result);
if($count) {
while($resultrow = $adb->fetch_array($result)) {
/** Earlier we used to save picklist values by encoding it. Now, we are directly saving those(getRaw()).
* If value in DB is like "test1 & test2" then $abd->fetch_array() is giving it as
* "test1 &$amp; test2" which we should decode two time to get result
*/
$pick_val = trim(decode_html(decode_html($resultrow[$tableName])));
if($lang[$pick_val] != '') {
$arr[$pick_val] = $lang[$pick_val];
}
else {
$arr[$pick_val] = $pick_val;
}
}
}
}
// END
$cache->setAssignedPicklistValues($tableName,$roleid,$arr);
return $arr;
}
}
?>