本文整理汇总了PHP中GetRelatedList函数的典型用法代码示例。如果您正苦于以下问题:PHP GetRelatedList函数的具体用法?PHP GetRelatedList怎么用?PHP GetRelatedList使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetRelatedList函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_vendors
/**
* Function to get Contact related vendors.
* @param integer $id - contactid
* returns related vendor records in array format
*/
function get_vendors($id, $cur_tab_id, $rel_tab_id, $actions = false)
{
global $log, $singlepane_view, $currentModule, $current_user;
$log->debug("Entering get_vendors(" . $id . ") method ...");
$this_module = $currentModule;
$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once "modules/{$related_module}/{$related_module}.php";
$other = new $related_module();
vtlib_setup_modulevars($related_module, $other);
$singular_modname = vtlib_toSingular($related_module);
$parenttab = getParentTab();
if ($singlepane_view == 'true') {
$returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
} else {
$returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
}
$button = '';
if ($actions) {
if (is_string($actions)) {
$actions = explode(',', strtoupper($actions));
}
if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}&parenttab={$parenttab}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'> ";
}
if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'> ";
}
}
$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
$query = "SELECT case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name,\n\t\t\t\tvtiger_crmentity.crmid, vtiger_vendor.*, vtiger_vendorcf.*\n\t\t\t\tfrom vtiger_vendor inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_vendor.vendorid\n\t\t\t\tINNER JOIN vtiger_vendorcontactrel on vtiger_vendorcontactrel.vendorid=vtiger_vendor.vendorid\n\t\t\t\tLEFT JOIN vtiger_vendorcf on vtiger_vendorcf.vendorid=vtiger_vendor.vendorid\n\t\t\t\tLEFT JOIN vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid\n\t\t\t\tWHERE vtiger_crmentity.deleted=0 and vtiger_vendorcontactrel.contactid=" . $id;
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if ($return_value == null) {
$return_value = array();
}
$return_value['CUSTOM_BUTTON'] = $button;
$log->debug("Exiting get_vendors method ...");
return $return_value;
}
示例2: get_generalmodules
/**
* Function to get related custom module records
* @param integer $id - current tab record id
* returns related custom module records in array format
*/
function get_generalmodules($id, $related_tabname)
{
global $log, $singlepane_view, $currentModule;
$log->debug("Entering get_generalmodules() method ...");
require_once "modules/{$related_tabname}/{$related_tabname}.php";
$focus = new $related_tabname();
$button = '';
if ($singlepane_view == 'true') {
$returnset = '&return_module=' . $currentModule . '&return_action=DetailView&return_id=' . $id;
} else {
$returnset = '&return_module=' . $currentModule . '&return_action=CallRelatedList&return_id=' . $id;
}
$key = "generalmodules_" . $currentModule . "_query_" . $related_tabname;
$query = getSqlCacheData($key);
$related_bean = substr($related_tabname, 0, -1);
$related_bean = strtolower($related_bean);
$lowerCurrentModule = strtolower($currentModule);
if (!$query) {
$query = "SELECT ec_" . $related_bean . "s.*,\n\t\t\t\tec_" . $related_bean . "s." . $related_bean . "sid as crmid,ec_users.user_name\n\t\t\t\tFROM ec_" . $related_bean . "s\n\t\t\t\tINNER JOIN ec_" . $lowerCurrentModule . "\n\t\t\t\t\tON ec_" . $lowerCurrentModule . "." . $lowerCurrentModule . "id = ec_" . $related_bean . "s." . $lowerCurrentModule . "id\n\t\t\t\tLEFT JOIN ec_users\n\t\t\t\t\tON ec_" . $related_bean . "s.smownerid = ec_users.id\n\t\t\t\tWHERE ec_" . $related_bean . "s.deleted = 0";
setSqlCacheData($key, $query);
}
$query .= " and ec_" . $related_bean . "s." . $lowerCurrentModule . "id = " . $id . " ";
$log->debug("Exiting get_generalmodules method ...");
return GetRelatedList($currentModule, $related_tabname, $focus, $query, $button, $returnset);
}
示例3: get_services
/**
* Function to get Product's related Products
* @param integer $id - productid
* returns related Products record in array format
*/
function get_services($id, $cur_tab_id, $rel_tab_id, $actions = false)
{
$log = vglobal('log');
$current_user = vglobal('current_user');
$singlepane_view = vglobal('singlepane_view');
$currentModule = vglobal('currentModule');
$log->debug("Entering get_products(" . $id . ") method ...");
$this_module = $currentModule;
$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once "modules/{$related_module}/{$related_module}.php";
$other = new $related_module();
vtlib_setup_modulevars($related_module, $other);
$singular_modname = vtlib_toSingular($related_module);
if ($singlepane_view == 'true') {
$returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
} else {
$returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
}
$button = '';
if ($actions && $this->ismember_check() === 0) {
if (is_string($actions)) {
$actions = explode(',', strtoupper($actions));
}
if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'> ";
}
if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
$button .= "<input type='hidden' name='createmode' id='createmode' value='link' />" . "<input title='" . getTranslatedString('LBL_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\";' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'> ";
}
}
$query = "SELECT vtiger_service.serviceid, vtiger_service.servicename,\n\t\t\tvtiger_service.service_no, vtiger_service.commissionrate,\n\t\t\tvtiger_service.service_usageunit, vtiger_service.unit_price,\n\t\t\tvtiger_crmentity.crmid, vtiger_crmentity.smownerid\n\t\t\tFROM vtiger_service\n\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_service.serviceid\n\t\t\tINNER JOIN vtiger_servicecf\n\t\t\t\tON vtiger_service.serviceid = vtiger_servicecf.serviceid\n\t\t\tLEFT JOIN vtiger_crmentityrel ON vtiger_crmentityrel.relcrmid = vtiger_service.serviceid AND vtiger_crmentityrel.module='Services'\n\t\t\tLEFT JOIN vtiger_users\n\t\t\t\tON vtiger_users.id=vtiger_crmentity.smownerid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_crmentityrel.crmid = {$id} ";
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if ($return_value == null) {
$return_value = array();
}
$return_value['CUSTOM_BUTTON'] = $button;
$log->debug("Exiting get_products method ...");
return $return_value;
}
示例4: get_activities
/** function used to get the list of activities which are related to the Quotes
* @param int $id - quote id
* @return array - return an array which will be returned from the function GetRelatedList
*/
function get_activities($id, $cur_tab_id, $rel_tab_id, $actions = false)
{
global $log, $singlepane_view, $currentModule, $current_user;
$log->debug("Entering get_activities(" . $id . ") method ...");
$this_module = $currentModule;
$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once "modules/{$related_module}/Activity.php";
$other = new Activity();
vtlib_setup_modulevars($related_module, $other);
$singular_modname = vtlib_toSingular($related_module);
$parenttab = getParentTab();
if ($singlepane_view == 'true') {
$returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
} else {
$returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
}
$button = '';
$button .= '<input type="hidden" name="activity_mode">';
if ($actions) {
if (is_string($actions)) {
$actions = explode(',', strtoupper($actions));
}
if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_NEW') . " " . getTranslatedString('LBL_TODO', $related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\";this.form.return_module.value=\"{$this_module}\";this.form.activity_mode.value=\"Task\";' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString('LBL_TODO', $related_module) . "'> ";
}
}
$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,vtiger_recurringevents.recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid where vtiger_seactivityrel.crmid=" . $id . " and vtiger_crmentity.deleted=0 and activitytype='Task' and (vtiger_activity.status is not NULL and vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL and vtiger_activity.status != 'Deferred')";
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if ($return_value == null) {
$return_value = array();
}
$return_value['CUSTOM_BUTTON'] = $button;
$log->debug("Exiting get_activities method ...");
return $return_value;
}
示例5: get_dependents_list
/**
* Default (generic) function to handle the dependents list for the module.
* NOTE: UI type '10' is used to stored the references to other modules for a given record.
* These dependent records can be retrieved through this function.
* For eg: A trouble ticket can be related to an Account or a Contact.
* From a given Contact/Account if we need to fetch all such dependent trouble tickets, get_dependents_list function can be used.
*/
function get_dependents_list($id, $cur_tab_id, $relTabId, $actions = false)
{
$app_strings = vglobal('app_strings');
$current_user = vglobal('current_user');
$singlepane_view = vglobal('singlepane_view');
$currentModule = vtlib_getModuleNameById($cur_tab_id);
$relatedModule = vtlib_getModuleNameById($relTabId);
$other = CRMEntity::getInstance($relatedModule);
// Some standard module class doesn't have required variables
// that are used in the query, they are defined in this generic API
vtlib_setup_modulevars($currentModule, $this);
vtlib_setup_modulevars($relatedModule, $other);
$singular_modname = 'SINGLE_' . $relatedModule;
$button = '';
$row = [];
// To make the edit or del link actions to return back to same view.
if ($singlepane_view == 'true') {
$returnset = "&return_module={$currentModule}&return_action=DetailView&return_id={$id}";
} else {
$returnset = "&return_module={$currentModule}&return_action=CallRelatedList&return_id={$id}";
}
$return_value = null;
$dependentFieldSql = $this->db->pquery('SELECT tabid, fieldname, columnname FROM vtiger_field WHERE uitype = 10 AND' . ' fieldid IN (SELECT fieldid FROM vtiger_fieldmodulerel WHERE relmodule=? AND module=?)', [$currentModule, $relatedModule]);
if ($dependentFieldSql->rowCount()) {
$row = $this->db->getRow($dependentFieldSql);
} else {
$depProcessFieldSql = $this->db->pquery('SELECT fieldname AS `name`, fieldid AS id, fieldlabel AS label, columnname AS `column`, tablename AS `table`, vtiger_field.* FROM vtiger_field WHERE `uitype` IN (66,67,68) AND `tabid` = ?;', [$relTabId]);
while ($rowProc = $this->db->getRow($depProcessFieldSql)) {
$className = Vtiger_Loader::getComponentClassName('Model', 'Field', $relatedModule);
$fieldModel = new $className();
foreach ($rowProc as $properName => $propertyValue) {
$fieldModel->{$properName} = $propertyValue;
}
$moduleList = $fieldModel->getUITypeModel()->getReferenceList();
if (in_array($currentModule, $moduleList)) {
$row = $rowProc;
break;
}
}
}
if (!empty($row)) {
$dependentColumn = $row['columnname'];
$dependentField = $row['fieldname'];
$button .= '<input type="hidden" name="' . $dependentColumn . '" id="' . $dependentColumn . '" value="' . $id . '">';
$button .= '<input type="hidden" name="' . $dependentColumn . '_type" id="' . $dependentColumn . '_type" value="' . $currentModule . '">';
if ($actions) {
if (is_string($actions)) {
$actions = explode(',', strtoupper($actions));
}
if (in_array('ADD', $actions) && isPermitted($relatedModule, 1, '') == 'yes' && getFieldVisibilityPermission($relatedModule, $current_user->id, $dependentField, 'readwrite') == '0') {
$button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $relatedModule) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$relatedModule}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $relatedModule) . "'> ";
}
}
$query = "SELECT vtiger_crmentity.*, {$other->table_name}.*";
$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
$query .= ", CASE WHEN (vtiger_users.user_name NOT LIKE '') THEN {$userNameSql} ELSE vtiger_groups.groupname END AS user_name";
$more_relation = '';
if (!empty($other->related_tables)) {
foreach ($other->related_tables as $tname => $relmap) {
$query .= ", {$tname}.*";
// Setup the default JOIN conditions if not specified
if (empty($relmap[1])) {
$relmap[1] = $other->table_name;
}
if (empty($relmap[2])) {
$relmap[2] = $relmap[0];
}
$more_relation .= " LEFT JOIN {$tname} ON {$tname}.{$relmap['0']} = {$relmap['1']}.{$relmap['2']}";
}
}
$query .= " FROM {$other->table_name}";
$query .= " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = {$other->table_name}.{$other->table_index}";
$query .= " INNER JOIN {$this->table_name} ON {$this->table_name}.{$this->table_index} = {$other->table_name}.{$dependentColumn}";
$query .= $more_relation;
$query .= " LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid";
$query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= " WHERE vtiger_crmentity.deleted = 0 AND {$this->table_name}.{$this->table_index} = {$id}";
$return_value = GetRelatedList($currentModule, $relatedModule, $other, $query, $button, $returnset);
}
if ($return_value == null) {
$return_value = array();
}
$return_value['CUSTOM_BUTTON'] = $button;
return $return_value;
}
示例6: get_emails
function get_emails($id, $cur_tab_id, $rel_tab_id, $actions = false)
{
$log = vglobal('log');
$current_user = vglobal('current_user');
$singlepane_view = vglobal('singlepane_view');
$currentModule = vglobal('currentModule');
$log->debug("Entering get_emails(" . $id . ") method ...");
$this_module = $currentModule;
$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once "modules/{$related_module}/{$related_module}.php";
$other = new $related_module();
vtlib_setup_modulevars($related_module, $other);
$singular_modname = vtlib_toSingular($related_module);
if ($singlepane_view == 'true') {
$returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
} else {
$returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
}
$button = '';
$button .= '<input type="hidden" name="email_directing_module"><input type="hidden" name="record">';
if ($actions) {
if (is_string($actions)) {
$actions = explode(',', strtoupper($actions));
}
if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'> ";
}
if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' accessyKey='F' class='crmbutton small create' onclick='fnvshobj(this,\"sendmail_cont\");sendmail(\"{$this_module}\",{$id});' type='button' name='button' value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'></td>";
}
}
$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
$query = "SELECT vtiger_ossmailview.*, vtiger_crmentity.modifiedtime, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name FROM vtiger_ossmailview \n\t\t\tINNER JOIN vtiger_ossmailview_relation ON vtiger_ossmailview_relation.ossmailviewid = vtiger_ossmailview.ossmailviewid\n\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_ossmailview.ossmailviewid \n\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid=vtiger_crmentity.smownerid \n\t\t\tLEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id\n\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_ossmailview_relation.crmid = " . $id . " ";
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if ($return_value == null) {
$return_value = array();
}
$return_value['CUSTOM_BUTTON'] = $button;
$log->debug("Exiting get_emails method ...");
return $return_value;
}
示例7: get_project_mail
function get_project_mail($id, $cur_tab_id, $rel_tab_id, $actions = false)
{
global $currentModule, $app_strings, $singlepane_view;
$this_module = $currentModule;
$related_module = vtlib_getModuleNameById($rel_tab_id);
$other = CRMEntity::getInstance($related_module);
vtlib_setup_modulevars($related_module, $other);
$singular_modname = vtlib_toSingular($related_module);
$button = '';
if ($actions) {
if (is_string($actions)) {
$actions = explode(',', strtoupper($actions));
}
if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'> ";
}
if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
$button .= "<input type='hidden' name='createmode' id='createmode' value='link' />" . "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'> ";
}
}
if ($singlepane_view == 'true') {
$returnset = "&return_module={$this_module}&return_action=DetailView&return_id={$id}";
} else {
$returnset = "&return_module={$this_module}&return_action=CallRelatedList&return_id={$id}";
}
$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
$query = "SELECT case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name,\n\t\t\t\tvtiger_crmentity.*, vtiger_project.*, vtiger_projectcf.*\n\t\t\t\tFROM vtiger_project\n\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_project.projectid\n\t\t\t\tLEFT JOIN vtiger_projectcf ON vtiger_projectcf.projectid = vtiger_project.projectid\n\t\t\t\tLEFT JOIN vtiger_ossmailview_project ON vtiger_ossmailview_project.crmid = vtiger_project.projectid\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_ossmailview_project.ossmailviewid = '{$id}'";
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if ($return_value == null) {
$return_value = array();
}
$return_value['CUSTOM_BUTTON'] = $button;
return $return_value;
}
示例8: get_payments
static function get_payments($module, $id, $cur_tab_id, $rel_tab_id, $actions = false)
{
global $log, $singlepane_view, $currentModule, $current_user;
$log->debug("Entering get_contacts(" . $id . ") method ...");
$this_module = $currentModule;
$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once "modules/{$related_module}/{$related_module}.php";
$other = new $related_module();
vtlib_setup_modulevars($related_module, $other);
$singular_modname = vtlib_toSingular($related_module);
$parenttab = getParentTab();
if ($singlepane_view == 'true') {
$returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
} else {
$returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
}
$button = '';
if ($actions) {
if (is_string($actions)) {
$actions = explode(',', strtoupper($actions));
}
if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}&parenttab={$parenttab}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'> ";
}
if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString('SINGLE_Accounting', 'Accounting') . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString('SINGLE_Accounting', 'Accounting') . "'> ";
}
}
if ($module == "Invoice") {
$rel_tabla = "vtiger_invoice";
$rel_id = "invoiceid";
$acc_rel_field = "accountingrelated2";
} else {
if ($module == "SalesOrder") {
$rel_tabla = "vtiger_salesorder";
$rel_id = "salesorderid";
$acc_rel_field = "accountingrelated2";
} else {
if ($module == "PurchaseOrder") {
$rel_tabla = "vtiger_purchaseorder";
$rel_id = "purchaseorderid";
$acc_rel_field = "accountingrelated2";
} else {
if ($module == "Accounts") {
$rel_tabla = "vtiger_account";
$rel_id = "accountid";
$acc_rel_field = "accountingrelated1";
} else {
if ($module == "Contacts") {
$rel_tabla = "vtiger_contactdetails";
$rel_id = "contactid";
$acc_rel_field = "accountingrelated1";
} else {
if ($module == "Vendors") {
$rel_tabla = "vtiger_vendor";
$rel_id = "vendorid";
$acc_rel_field = "accountingrelated1";
} else {
if ($module == "Project") {
$rel_tabla = "vtiger_project";
$rel_id = "projectid";
$acc_rel_field = "accountingrelated1";
} else {
if ($module == "Potentials") {
$rel_tabla = "vtiger_potential";
$rel_id = "potentialid";
$acc_rel_field = "accountingrelated1";
}
}
}
}
}
}
}
}
$query = "SELECT vtiger_accounting.*,\n\t\t\t\tvtiger_crmentity.crmid,\n\t vtiger_crmentity.smownerid,\n\t\t\t\tvtiger_accounting.paymentref,\n\t\t\t\tcase when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name\n\t\t\t\tFROM vtiger_accounting\n\t\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\t\tON vtiger_crmentity.crmid = vtiger_accounting.accountingid\n\t\t\t\tLEFT JOIN " . $rel_tabla . "\n\t\t\t\t\tON " . $rel_tabla . "." . $rel_id . " = vtiger_accounting.accountingid\n\t\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_users\n\t\t\t\t\tON vtiger_crmentity.smownerid = vtiger_users.id\n\t\t\t\tWHERE vtiger_crmentity.deleted = 0\n\t\t\t\tAND vtiger_accounting." . $acc_rel_field . " = " . $id;
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if (($module == "Invoice" || $module == "PurchaseOrder" || $module == "SalesOrder") && count($return_value['entries']) > 0) {
$button = "";
}
if ($return_value == null) {
$return_value = array();
}
$return_value['CUSTOM_BUTTON'] = $button;
$log->debug("Exiting get_contacts method ...");
return $return_value;
}
示例9: get_emails
/** Returns a list of the associated emails
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
* All Rights Reserved..
* Contributor(s): ______________________________________..
*/
function get_emails($id, $cur_tab_id, $rel_tab_id, $actions = false)
{
global $log, $singlepane_view, $currentModule, $current_user;
$log->debug("Entering get_emails(" . $id . ") method ...");
$this_module = $currentModule;
$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once "modules/{$related_module}/{$related_module}.php";
$other = new $related_module();
vtlib_setup_modulevars($related_module, $other);
$singular_modname = vtlib_toSingular($related_module);
$parenttab = getParentTab();
if ($singlepane_view == 'true') {
$returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
} else {
$returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
}
$button = '';
$button .= '<input type="hidden" name="email_directing_module"><input type="hidden" name="record">';
if ($actions) {
if (is_string($actions)) {
$actions = explode(',', strtoupper($actions));
}
if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' accessyKey='F' class='crmbutton small create' onclick='fnvshobj(this,\"sendmail_cont\");sendmail(\"{$this_module}\",{$id});' type='button' name='button' value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'></td>";
}
}
$userNameSql = getSqlForNameInDisplayFormat(array('f' => 'vtiger_users.first_name', 'l' => 'vtiger_users.last_name'));
$query = "SELECT case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name,\n\t\t\tvtiger_activity.activityid, vtiger_activity.subject,\n\t\t\tvtiger_activity.activitytype, vtiger_crmentity.modifiedtime,\n\t\t\tvtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_activity.date_start, vtiger_seactivityrel.crmid as parent_id \n\t\t\tFROM vtiger_activity, vtiger_seactivityrel, vtiger_vendor, vtiger_users, vtiger_crmentity\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid=vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_seactivityrel.activityid = vtiger_activity.activityid\n\t\t\t\tAND vtiger_vendor.vendorid = vtiger_seactivityrel.crmid\n\t\t\t\tAND vtiger_users.id=vtiger_crmentity.smownerid\n\t\t\t\tAND vtiger_crmentity.crmid = vtiger_activity.activityid\n\t\t\t\tAND vtiger_vendor.vendorid = " . $id . "\n\t\t\t\tAND vtiger_activity.activitytype='Emails'\n\t\t\t\tAND vtiger_crmentity.deleted = 0";
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if ($return_value == null) {
$return_value = array();
}
$return_value['CUSTOM_BUTTON'] = $button;
$log->debug("Exiting get_emails method ...");
return $return_value;
}
示例10: get_salesorder
/**
* Function to get Potential related SalesOrder
* @param integer $id - potentialid
* returns related SalesOrder record in array format
*/
function get_salesorder($id, $cur_tab_id, $rel_tab_id, $actions = false)
{
global $log, $singlepane_view, $currentModule, $current_user;
$log->debug("Entering get_salesorder(" . $id . ") method ...");
$this_module = $currentModule;
$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once "modules/{$related_module}/{$related_module}.php";
$other = new $related_module();
vtlib_setup_modulevars($related_module, $other);
$singular_modname = vtlib_toSingular($related_module);
$parenttab = getParentTab();
if ($singlepane_view == 'true') {
$returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
} else {
$returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
}
$button = '';
if ($actions && getFieldVisibilityPermission($related_module, $current_user->id, 'potential_id', 'readwrite') == '0') {
if (is_string($actions)) {
$actions = explode(',', strtoupper($actions));
}
if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}&parenttab={$parenttab}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'> ";
}
if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'> ";
}
}
$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
$query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename\n\t\t\t, vtiger_account.accountname, vtiger_potential.potentialname,case when\n\t\t\t(vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname\n\t\t\tend as user_name from vtiger_salesorder\n\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid\n\t\t\tleft outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid\n\t\t\tleft outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid\n\t\t\tleft outer join vtiger_potential on vtiger_potential.potentialid=vtiger_salesorder.potentialid\n\t\t\tleft join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid\n LEFT JOIN vtiger_salesordercf ON vtiger_salesordercf.salesorderid = vtiger_salesorder.salesorderid\n LEFT JOIN vtiger_invoice_recurring_info ON vtiger_invoice_recurring_info.start_period = vtiger_salesorder.salesorderid\n\t\t\tLEFT JOIN vtiger_sobillads ON vtiger_sobillads.sobilladdressid = vtiger_salesorder.salesorderid\n\t\t\tLEFT JOIN vtiger_soshipads ON vtiger_soshipads.soshipaddressid = vtiger_salesorder.salesorderid\n\t\t\tleft join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid\n\t\t\t where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid = " . $id;
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if ($return_value == null) {
$return_value = array();
}
$return_value['CUSTOM_BUTTON'] = $button;
$log->debug("Exiting get_salesorder method ...");
return $return_value;
}
示例11: get_products
/**
* Function to get Account related Products
* @param integer $id - accountid
* returns related Products record in array format
*/
function get_products($id, $cur_tab_id, $rel_tab_id, $actions = false)
{
global $log, $singlepane_view, $currentModule, $current_user;
$log->debug("Entering get_products(" . $id . ") method ...");
$this_module = $currentModule;
$related_module = vtlib_getModuleNameById($rel_tab_id);
require_once "modules/{$related_module}/{$related_module}.php";
$other = new $related_module();
vtlib_setup_modulevars($related_module, $other);
$singular_modname = vtlib_toSingular($related_module);
$parenttab = getParentTab();
if ($singlepane_view == 'true') {
$returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id;
} else {
$returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id;
}
$button = '';
if ($actions) {
if (is_string($actions)) {
$actions = explode(',', strtoupper($actions));
}
if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module={$related_module}&return_module={$currentModule}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$id}&parenttab={$parenttab}','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'> ";
}
if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes') {
$button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname) . "'> ";
}
}
$query = "SELECT vtiger_products.productid, vtiger_products.productname,\n\t\t\tvtiger_products.productcode, vtiger_products.commissionrate,\n\t\t\tvtiger_products.qty_per_unit, vtiger_products.unit_price,\n\t\t\tvtiger_crmentity.crmid, vtiger_crmentity.smownerid\n\t\t\tFROM vtiger_products\n\t\t\tINNER JOIN vtiger_seproductsrel ON vtiger_products.productid = vtiger_seproductsrel.productid and vtiger_seproductsrel.setype='Accounts'\n\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_products.productid\n\t\t\tINNER JOIN vtiger_account ON vtiger_account.accountid = vtiger_seproductsrel.crmid\n\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_account.accountid = {$id}";
$return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset);
if ($return_value == null) {
$return_value = array();
}
$return_value['CUSTOM_BUTTON'] = $button;
$log->debug("Exiting get_products method ...");
return $return_value;
}
示例12: get_product_pricebooks
/** function used to get the list of pricebooks which are related to the product
* @param int $id - product id
* @return array - array which will be returned from the function GetRelatedList
*/
function get_product_pricebooks($id)
{
global $log, $singlepane_view;
$log->debug("Entering get_product_pricebooks(" . $id . ") method ...");
global $mod_strings;
require_once 'modules/PriceBooks/PriceBooks.php';
$focus = new PriceBooks();
$button = '';
if ($singlepane_view == 'true') {
$returnset = '&return_module=Products&return_action=DetailView&return_id=' . $id;
} else {
$returnset = '&return_module=Products&return_action=CallRelatedList&return_id=' . $id;
}
$query = "SELECT ec_pricebook.pricebookid as crmid,\n\t\t\tec_pricebook.*,\n\t\t\tec_pricebookproductrel.productid as prodid\n\t\t\tFROM ec_pricebook\n\t\t\tINNER JOIN ec_pricebookproductrel\n\t\t\t\tON ec_pricebookproductrel.pricebookid = ec_pricebook.pricebookid\n\t\t\tWHERE ec_pricebook.deleted = 0\n\t\t\tAND ec_pricebookproductrel.productid = " . $id;
$log->debug("Exiting get_product_pricebooks method ...");
return GetRelatedList('Products', 'PriceBooks', $focus, $query, $button, $returnset);
}
示例13: get_qunfas
function get_qunfas($id)
{
global $log, $singlepane_view;
global $app_strings;
$log->debug("Entering get_qunfas(" . $id . ") method ...");
require_once 'modules/Qunfas/Qunfas.php';
$focus = new Qunfas();
$button = '';
if ($singlepane_view == 'true') {
$returnset = '&return_module=Accounts&return_action=DetailView&return_id=' . $id;
} else {
$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id=' . $id;
}
$query = "SELECT ec_qunfas.*,ec_users.user_name, ec_users.id,ec_qunfas.qunfasid as crmid\n\t\t\tFROM ec_qunfas\t\n\t\t\tLEFT JOIN ec_users\n\t\t\t\tON ec_qunfas.smownerid = ec_users.id\n\t\t\tWHERE ec_qunfas.accountid like '%," . $id . ",%'\n\t\t\tAND ec_qunfas.deleted = 0";
$log->debug("Exiting get_qunfas method ...");
return GetRelatedList('Accounts', 'Qunfas', $focus, $query, $button, $returnset);
}
示例14: get_salesorder
/** function used to get the list of sales orders which are related to the Quotes
* @param int $id - quote id
* @return array - return an array which will be returned from the function GetRelatedList
*/
function get_salesorder($id)
{
global $log, $singlepane_view;
$log->debug("Entering get_salesorder(" . $id . ") method ...");
require_once 'modules/SalesOrder/SalesOrder.php';
$focus = new SalesOrder();
$button = '';
if ($singlepane_view == 'true') {
$returnset = '&return_module=Quotes&return_action=DetailView&return_id=' . $id;
} else {
$returnset = '&return_module=Quotes&return_action=CallRelatedList&return_id=' . $id;
}
$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
$query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename\n\t\t\t, vtiger_account.accountname,case when (vtiger_users.user_name not like '') then\n\t\t\t{$userNameSql} else vtiger_groups.groupname end as user_name\n\t\tfrom vtiger_salesorder\n\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid\n\t\tleft outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid\n\t\tleft outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid\n\t\tleft join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid\n LEFT JOIN vtiger_salesordercf ON vtiger_salesordercf.salesorderid = vtiger_salesorder.salesorderid\n LEFT JOIN vtiger_invoice_recurring_info ON vtiger_invoice_recurring_info.start_period = vtiger_salesorder.salesorderid\n\t\tLEFT JOIN vtiger_salesorderaddress ON vtiger_salesorderaddress.salesorderaddressid = vtiger_salesorder.salesorderid\n\t\tleft join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid\n\t\twhere vtiger_crmentity.deleted=0 and vtiger_salesorder.quoteid = " . $id;
$log->debug("Exiting get_salesorder method ...");
return GetRelatedList('Quotes', 'SalesOrder', $focus, $query, $button, $returnset);
}
示例15: get_dependents_list
/**
* Default (generic) function to handle the dependents list for the module.
* NOTE: UI type '10' is used to stored the references to other modules for a given record.
* These dependent records can be retrieved through this function.
* For eg: A trouble ticket can be related to an Account or a Contact.
* From a given Contact/Account if we need to fetch all such dependent trouble tickets, get_dependents_list function can be used.
*/
function get_dependents_list($id, $cur_tab_id, $rel_tab_id, $actions = false)
{
global $currentModule, $app_strings, $singlepane_view, $current_user;
$parenttab = getParentTab();
$related_module = vtlib_getModuleNameById($rel_tab_id);
$other = CRMEntity::getInstance($related_module);
// Some standard module class doesn't have required variables
// that are used in the query, they are defined in this generic API
vtlib_setup_modulevars($currentModule, $this);
vtlib_setup_modulevars($related_module, $other);
$singular_modname = 'SINGLE_' . $related_module;
$button = '';
// To make the edit or del link actions to return back to same view.
if ($singlepane_view == 'true') {
$returnset = "&return_module={$currentModule}&return_action=DetailView&return_id={$id}";
} else {
$returnset = "&return_module={$currentModule}&return_action=CallRelatedList&return_id={$id}";
}
$return_value = null;
$dependentFieldSql = $this->db->pquery("SELECT tabid, fieldname, columnname FROM vtiger_field WHERE uitype='10' AND" . " fieldid IN (SELECT fieldid FROM vtiger_fieldmodulerel WHERE relmodule=? AND module=?)", array($currentModule, $related_module));
$numOfFields = $this->db->num_rows($dependentFieldSql);
if ($numOfFields > 0) {
$dependentColumn = $this->db->query_result($dependentFieldSql, 0, 'columnname');
$dependentField = $this->db->query_result($dependentFieldSql, 0, 'fieldname');
$button .= '<input type="hidden" name="' . $dependentColumn . '" id="' . $dependentColumn . '" value="' . $id . '">';
$button .= '<input type="hidden" name="' . $dependentColumn . '_type" id="' . $dependentColumn . '_type" value="' . $currentModule . '">';
if ($actions) {
if (is_string($actions)) {
$actions = explode(',', strtoupper($actions));
}
if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes' && getFieldVisibilityPermission($related_module, $current_user->id, $dependentField, 'readwrite') == '0') {
$button .= "<input title='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EditView\";this.form.module.value=\"{$related_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString($singular_modname, $related_module) . "'> ";
}
}
$query = "SELECT vtiger_crmentity.*, {$other->table_name}.*";
$userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
$query .= ", CASE WHEN (vtiger_users.user_name NOT LIKE '') THEN {$userNameSql} ELSE vtiger_groups.groupname END AS user_name";
$more_relation = '';
if (!empty($other->related_tables)) {
foreach ($other->related_tables as $tname => $relmap) {
$query .= ", {$tname}.*";
// Setup the default JOIN conditions if not specified
if (empty($relmap[1])) {
$relmap[1] = $other->table_name;
}
if (empty($relmap[2])) {
$relmap[2] = $relmap[0];
}
$more_relation .= " LEFT JOIN {$tname} ON {$tname}.{$relmap['0']} = {$relmap['1']}.{$relmap['2']}";
}
}
$query .= " FROM {$other->table_name}";
$query .= " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = {$other->table_name}.{$other->table_index}";
$query .= " INNER JOIN {$this->table_name} ON {$this->table_name}.{$this->table_index} = {$other->table_name}.{$dependentColumn}";
$query .= $more_relation;
$query .= " LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid";
$query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= " WHERE vtiger_crmentity.deleted = 0 AND {$this->table_name}.{$this->table_index} = {$id}";
$return_value = GetRelatedList($currentModule, $related_module, $other, $query, $button, $returnset);
}
if ($return_value == null) {
$return_value = array();
}
$return_value['CUSTOM_BUTTON'] = $button;
return $return_value;
}