本文整理汇总了PHP中getEntityField函数的典型用法代码示例。如果您正苦于以下问题:PHP getEntityField函数的具体用法?PHP getEntityField怎么用?PHP getEntityField使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getEntityField函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildSearchQueryForFieldTypes
/** END * */
function buildSearchQueryForFieldTypes($uitypes, $value = false)
{
global $adb;
if (!is_array($uitypes)) {
$uitypes = array($uitypes);
}
$module = get_class($this);
$cachedModuleFields = VTCacheUtils::lookupFieldInfo_Module($module);
if ($cachedModuleFields === false) {
getColumnFields($module);
// This API will initialize the cache as well
// We will succeed now due to above function call
$cachedModuleFields = VTCacheUtils::lookupFieldInfo_Module($module);
}
$lookuptables = array();
$lookupcolumns = array();
foreach ($cachedModuleFields as $fieldinfo) {
if (in_array($fieldinfo['uitype'], $uitypes)) {
$lookuptables[] = $fieldinfo['tablename'];
$lookupcolumns[] = $fieldinfo['columnname'];
}
}
$entityfields = getEntityField($module);
$querycolumnnames = implode(',', $lookupcolumns);
$entitycolumnnames = $entityfields['fieldname'];
$query = "select crmid as id, {$querycolumnnames}, {$entitycolumnnames} as name ";
$query .= " FROM {$this->table_name} ";
$query .= " INNER JOIN vtiger_crmentity ON {$this->table_name}.{$this->table_index} = vtiger_crmentity.crmid AND deleted = 0 ";
//remove the base table
$LookupTable = array_unique($lookuptables);
$indexes = array_keys($LookupTable, $this->table_name);
if (!empty($indexes)) {
foreach ($indexes as $index) {
unset($LookupTable[$index]);
}
}
foreach ($LookupTable as $tablename) {
$query .= " INNER JOIN {$tablename}\n\t\t\t\t\t\ton {$this->table_name}.{$this->table_index} = {$tablename}." . $this->tab_name_index[$tablename];
}
if (!empty($lookupcolumns) && $value !== false) {
$query .= " WHERE ";
$i = 0;
$columnCount = count($lookupcolumns);
foreach ($lookupcolumns as $columnname) {
if (!empty($columnname)) {
if ($i == 0 || $i == $columnCount) {
$query .= sprintf("%s = '%s'", $columnname, $value);
} else {
$query .= sprintf(" OR %s = '%s'", $columnname, $value);
}
$i++;
}
}
}
return $query;
}
示例2: buildSearchQueryWithUIType
public function buildSearchQueryWithUIType($uitype, $value, $module)
{
if (empty($value)) {
return false;
}
$cachedModuleFields = VTCacheUtils::lookupFieldInfo_Module($module);
if ($cachedModuleFields === false) {
getColumnFields($module);
// This API will initialize the cache as well
// We will succeed now due to above function call
$cachedModuleFields = VTCacheUtils::lookupFieldInfo_Module($module);
}
$lookuptables = array();
$lookupcolumns = array();
foreach ($cachedModuleFields as $fieldinfo) {
if (in_array($fieldinfo['uitype'], array($uitype))) {
$lookuptables[] = $fieldinfo['tablename'];
$lookupcolumns[] = $fieldinfo['columnname'];
}
}
$entityfields = getEntityField($module);
$querycolumnnames = implode(',', $lookupcolumns);
$entitycolumnnames = $entityfields['fieldname'];
$query = "select id as id, {$querycolumnnames}, {$entitycolumnnames} as name ";
$query .= " FROM vtiger_users";
if (!empty($lookupcolumns)) {
$query .= " WHERE deleted=0 AND ";
$i = 0;
$columnCount = count($lookupcolumns);
foreach ($lookupcolumns as $columnname) {
if (!empty($columnname)) {
if ($i == 0 || $i == $columnCount) {
$query .= sprintf("%s = '%s'", $columnname, $value);
} else {
$query .= sprintf(" OR %s = '%s'", $columnname, $value);
}
$i++;
}
}
}
return $query;
}
示例3: add_related_to
/**
* This function handles the import for uitype 10 fieldtype
* @param string $module - the current module name
* @param string fieldname - the related to field name
*/
function add_related_to($module, $fieldname)
{
global $adb, $imported_ids, $current_user;
$related_to = $this->column_fields[$fieldname];
if (empty($related_to)) {
return false;
}
//check if the field has module information; if not get the first module
if (!strpos($related_to, "::::")) {
$module = getFirstModule($module, $fieldname);
$value = $related_to;
} else {
//check the module of the field
$arr = array();
$arr = explode("::::", $related_to);
$module = $arr[0];
$value = $arr[1];
}
$focus1 = CRMEntity::getInstance($module);
$entityNameArr = getEntityField($module);
$entityName = $entityNameArr['fieldname'];
$query = "SELECT vtiger_crmentity.deleted, {$focus1->table_name}.* \n\t\t\t\t\tFROM {$focus1->table_name}\n\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid={$focus1->table_name}.{$focus1->table_index}\n\t\t\t\t\t\twhere {$entityName}=? and vtiger_crmentity.deleted=0";
$result = $adb->pquery($query, array($value));
if (!isset($this->checkFlagArr[$module])) {
$this->checkFlagArr[$module] = isPermitted($module, 'EditView', '') == 'yes';
}
if ($adb->num_rows($result) > 0) {
//record found
$focus1->id = $adb->query_result($result, 0, $focus1->table_index);
} elseif ($this->checkFlagArr[$module]) {
//record not found; create it
$focus1->column_fields[$focus1->list_link_field] = $value;
$focus1->column_fields['assigned_user_id'] = $current_user->id;
$focus1->column_fields['modified_user_id'] = $current_user->id;
$focus1->save($module);
$last_import = new UsersLastImport();
$last_import->assigned_user_id = $current_user->id;
$last_import->bean_type = $module;
$last_import->bean_id = $focus1->id;
$last_import->save();
} else {
//record not found and cannot create
$this->column_fields[$fieldname] = "";
return false;
}
if (!empty($focus1->id)) {
$this->column_fields[$fieldname] = $focus1->id;
return true;
} else {
$this->column_fields[$fieldname] = "";
return false;
}
}
示例4: BasicSearch
//.........这里部分代码省略.........
$where = "{$table_name}.{$column_name} = '1'";
} elseif (strtolower($search_string) == 'no') {
$where = "{$table_name}.{$column_name} = '0'";
} else {
$where = "{$table_name}.{$column_name} = '-1'";
}
} elseif ($uitype == 15 || $uitype == 16) {
if (is_uitype($uitype, '_picklist_')) {
// Get all the keys for the for the Picklist value
$mod_keys = array_keys($mod_strings, $search_string);
if (sizeof($mod_keys) >= 1) {
// Iterate on the keys, to get the first key which doesn't start with LBL_ (assuming it is not used in PickList)
foreach ($mod_keys as $mod_idx => $mod_key) {
$stridx = strpos($mod_key, 'LBL_');
// Use strict type comparision, refer strpos for more details
if ($stridx !== 0) {
$search_string = $mod_key;
if ($input['operator'] == 'e' && getFieldVisibilityPermission("Calendar", $current_user->id, 'taskstatus') == '0' && ($column_name == "status" || $column_name == "eventstatus")) {
$where = "(vtiger_activity.status ='" . $search_string . "' or vtiger_activity.eventstatus ='" . $search_string . "')";
} else {
if (getFieldVisibilityPermission("Calendar", $current_user->id, 'taskstatus') == '0' && ($column_name == "status" || $column_name == "eventstatus")) {
$where = "(vtiger_activity.status like '" . formatForSqlLike($search_string) . "' or vtiger_activity.eventstatus like '" . formatForSqlLike($search_string) . "')";
} else {
$where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
}
}
break;
} else {
//if the mod strings cointains LBL , just return the original search string. Not the key
$where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
}
}
} else {
if (getFieldVisibilityPermission("Calendar", $current_user->id, 'taskstatus') == '0' && ($table_name == "vtiger_activity" && ($column_name == "status" || $column_name == "eventstatus"))) {
$where = "(vtiger_activity.status like '" . formatForSqlLike($search_string) . "' or vtiger_activity.eventstatus like '" . formatForSqlLike($search_string) . "')";
} else {
$where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
}
}
}
} elseif ($table_name == "vtiger_crmentity" && $column_name == "smownerid") {
$where = get_usersid($table_name, $column_name, $search_string);
} elseif ($table_name == "vtiger_crmentity" && $column_name == "modifiedby") {
$concatSql = getSqlForNameInDisplayFormat(array('last_name' => 'vtiger_users2.last_name', 'first_name' => 'vtiger_users2.first_name'), 'Users');
$where .= "(trim({$concatSql}) like '" . formatForSqlLike($search_string) . "' or vtiger_groups2.groupname like '" . formatForSqlLike($search_string) . "')";
} else {
if (in_array($column_name, $column_array)) {
$where = getValuesforColumns($column_name, $search_string, 'cts', $input);
} else {
if ($input['type'] == 'entchar') {
$where = "{$table_name}.{$column_name} = '" . $search_string . "'";
} else {
$where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
}
}
}
}
}
if (stristr($where, "like '%%'")) {
$where_cond0 = str_replace("like '%%'", "like ''", $where);
$where_cond1 = str_replace("like '%%'", "is NULL", $where);
if ($module == "Calendar") {
$where = "(" . $where_cond0 . " and " . $where_cond1 . ")";
} else {
$where = "(" . $where_cond0 . " or " . $where_cond1 . ")";
}
}
// commented to support searching "%" with the search string.
if ($input['type'] == 'alpbt') {
$where = str_replace_once("%", "", $where);
}
//uitype 10 handling
if ($uitype == 10) {
$where = array();
$sql = "select fieldid from vtiger_field where tabid=? and fieldname=?";
$result = $adb->pquery($sql, array(getTabid($module), $search_field));
if ($adb->num_rows($result) > 0) {
$fieldid = $adb->query_result($result, 0, "fieldid");
$sql = "select * from vtiger_fieldmodulerel where fieldid=?";
$result = $adb->pquery($sql, array($fieldid));
$count = $adb->num_rows($result);
$searchString = formatForSqlLike($search_string);
for ($i = 0; $i < $count; $i++) {
$relModule = $adb->query_result($result, $i, "relmodule");
$relInfo = getEntityField($relModule);
$relTable = $relInfo["tablename"];
$relField = $relInfo["fieldname"];
if (strpos($relField, 'concat') !== false) {
$where[] = "{$relField} like '{$searchString}'";
} else {
$where[] = "{$relTable}.{$relField} like '{$searchString}'";
}
}
$where = implode(" or ", $where);
}
$where = "({$where}) ";
}
$log->debug("Exiting BasicSearch method ...");
return $where;
}
示例5: count
//.........这里部分代码省略.........
}
$lastacc = $row[0];
*/
if ($bMultiple == false) {
array_push($rows2, $row);
$payments[$row[0]] = array();
} else {
$sub++;
}
$idx = 1;
$paid = $row[$ret_field_count - $idx++];
if ($acc_config["associnvoice"] == "true") {
$associnv = $row[$ret_field_count - $idx++];
}
$paymentmethod = $row[$ret_field_count - $idx++];
if ($acc_config["showvat"] == "true") {
$tax = $row[$ret_field_count - $idx++];
}
$amount = $row[$ret_field_count - $idx++];
$paymentdate = $row[$ret_field_count - $idx++];
$paymentduedate = $row[$ret_field_count - $idx++];
$ref = $row[$ret_field_count - $idx++];
$invid = '';
$assocmodule = '';
$assocdisplay = '';
if ($associnv != "") {
//check the module of the field
$arr = array();
$arr = explode("::::", $associnv);
$assocmodule = $arr[0];
$assocdisplay = $arr[1];
$focus1 = CRMEntity::getInstance($assocmodule);
$entityNameArr = getEntityField($assocmodule);
$entityName = $entityNameArr['fieldname'];
$query = "SELECT vtiger_crmentity.deleted, {$focus1->table_name}.*\n\t\t\t\t\t\tFROM {$focus1->table_name}\n\t\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid={$focus1->table_name}.{$focus1->table_index}\n\t\t\t\t\t\t\twhere {$entityName}=? and vtiger_crmentity.deleted=0";
$result = $adb->pquery($query, array($assocdisplay));
$invid = $adb->query_result($result, 0, $focus1->table_index);
}
$payment = array('ref' => $ref, 'paymentduedate' => $paymentduedate, 'paymentdate' => $paymentdate, 'amount' => $amount, 'paymenttax' => $tax, 'paymentmethod' => $paymentmethod, 'associnv' => $invid, 'associnv_display' => $assocdisplay, 'paymentassoc_mod' => $assocmodule, 'paid' => $paid);
array_push($payments[$row[0]], $payment);
}
$totalnoofrows -= $sub;
$rows1 = $rows2;
$recordcount = count($rows1);
foreach ($rows1 as $row) {
$adb->println("Going to Save the row " . $ii . " =====> ");
$adb->println($row);
global $mod_strings;
$do_save = 1;
//MWC
$my_userid = $current_user->id;
//If we want to set default values for some fields for each entity then we have to set here
if ($module == 'Products' || $module == 'Services') {
//discontinued is not null. if we unmap active, NULL will be inserted and query will fail
$focus->column_fields['discontinued'] = 'on';
}
for ($field_count = 0; $field_count < $ret_field_count; $field_count++) {
p("col_pos[" . $field_count . "]=" . $col_pos_to_field[$field_count]);
if (isset($col_pos_to_field[$field_count])) {
p("set =" . $field_count);
if (!isset($row[$field_count])) {
continue;
}
p("setting");
// TODO: add check for user input