/** * 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; }
/** * 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); }
/** * 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; }
/** 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; }
/** * 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; }
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; }
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; }
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; }
/** 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; }
/** * 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; }
/** * 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; }
/** 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); }
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); }
/** 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); }
/** * 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; }
/** * Function to handle the related list for the module. * NOTE: Vtiger_Module::setRelatedList sets reference to this function in vtiger_relatedlists table * if function name is not explicitly specified. */ function get_related_list($id, $cur_tab_id, $rel_tab_id, $actions = false) { global $currentModule, $app_strings, $singlepane_view; $current_module = vtlib_getModuleNameById($cur_tab_id); $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($current_module, $this); vtlib_setup_modulevars($related_module, $other); $singular_modname = 'SINGLE_' . $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=$current_module&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, $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, $related_module) . "'> "; } } // To make the edit or del link actions to return back to same view. if ($singlepane_view == 'true') { $returnset = "&return_module=$current_module&return_action=DetailView&return_id=$id"; } else { $returnset = "&return_module=$current_module&return_action=CallRelatedList&return_id=$id"; } $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]"; } } $entityIds = $this->getRelatedContactsIds(); array_push($entityIds, $id); $entityIds = implode(',', $entityIds); $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query = "SELECT vtiger_crmentity.*, $other->table_name.*, CASE WHEN (vtiger_users.user_name NOT LIKE '') THEN $userNameSql ELSE vtiger_groups.groupname END AS user_name FROM $other->table_name INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = $other->table_name.$other->table_index INNER JOIN vtiger_crmentityrel ON (vtiger_crmentityrel.relcrmid = vtiger_crmentity.crmid OR vtiger_crmentityrel.crmid = vtiger_crmentity.crmid) $more_relation LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid WHERE vtiger_crmentity.deleted = 0 AND (vtiger_crmentityrel.crmid IN (" . $entityIds . ") OR vtiger_crmentityrel.relcrmid IN (" . $entityIds . "))"; $return_value = GetRelatedList($current_module, $related_module, $other, $query, $button, $returnset); if ($return_value == null) $return_value = Array(); $return_value['CUSTOM_BUTTON'] = $button; return $return_value; }
/** function used to get the list of pricebooks which are related to the service * @param int $id - service id * @return array - array which will be returned from the function GetRelatedList */ function get_service_pricebooks($id, $cur_tab_id, $rel_tab_id, $actions = false) { global $currentModule, $log, $singlepane_view, $mod_strings; $log->debug("Entering get_service_pricebooks(" . $id . ") method ..."); $related_module = vtlib_getModuleNameById($rel_tab_id); checkFileAccessForInclusion("modules/{$related_module}/{$related_module}.php"); require_once "modules/{$related_module}/{$related_module}.php"; $focus = new $related_module(); $singular_modname = vtlib_toSingular($related_module); 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}"; } $button = ''; if ($actions) { if (is_string($actions)) { $actions = explode(',', strtoupper($actions)); } if (in_array('ADD', $actions) && isPermitted($related_module, 1, '') == 'yes' && isPermitted($currentModule, 'EditView', $id) == 'yes') { $button .= "<input title='" . getTranslatedString('LBL_ADD_TO') . " " . getTranslatedString($related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"AddServiceToPriceBooks\";this.form.module.value=\"{$currentModule}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_TO') . " " . getTranslatedString($singular_modname) . "'> "; } } $query = "SELECT vtiger_crmentity.crmid,\n\t\t\tvtiger_pricebook.*,\n\t\t\tvtiger_pricebookproductrel.productid as prodid\n\t\t\tFROM vtiger_pricebook\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_pricebook.pricebookid\n\t\t\tINNER JOIN vtiger_pricebookproductrel\n\t\t\t\tON vtiger_pricebookproductrel.pricebookid = vtiger_pricebook.pricebookid\n\t\t\tWHERE vtiger_crmentity.deleted = 0\n\t\t\tAND vtiger_pricebookproductrel.productid = " . $id; $log->debug("Exiting get_product_pricebooks method ..."); $return_value = GetRelatedList($currentModule, $related_module, $focus, $query, $button, $returnset); if ($return_value == null) { $return_value = array(); } $return_value['CUSTOM_BUTTON'] = $button; $log->debug("Exiting get_service_pricebooks method ..."); return $return_value; }
/** * Function to get Campaign related Activities * @param integer $id - campaignid * returns related activities record in array format */ 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') { if (getFieldVisibilityPermission('Calendar', $current_user->id, 'parent_id', 'readwrite') == '0') { $button .= "<input title='" . getTranslatedString('LBL_NEW') . " " . getTranslatedString('LBL_TODO', $related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EventEditView\";this.form.module.value=\"Calendar4You\";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) . "'> "; } if (getFieldVisibilityPermission('Events', $current_user->id, 'parent_id', 'readwrite') == '0') { $button .= "<input title='" . getTranslatedString('LBL_NEW') . " " . getTranslatedString('LBL_TODO', $related_module) . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"EventEditView\";this.form.module.value=\"Calendar4You\";this.form.return_module.value=\"{$this_module}\";this.form.activity_mode.value=\"Events\";' type='submit' name='button'" . " value='" . getTranslatedString('LBL_ADD_NEW') . " " . getTranslatedString('LBL_EVENT', $related_module) . "'>"; } } } $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query = "SELECT vtiger_contactdetails.lastname,\n\t\t\tvtiger_contactdetails.firstname,\n\t\t\tvtiger_contactdetails.contactid,\n\t\t\tvtiger_activity.*,\n\t\t\tvtiger_seactivityrel.*,\n\t\t\tvtiger_crmentity.crmid, vtiger_crmentity.smownerid,\n\t\t\tvtiger_crmentity.modifiedtime,\n\t\t\tCASE when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name,\n\t\t\tvtiger_recurringevents.recurringtype\n\t\t\tFROM vtiger_activity\n\t\t\tINNER JOIN vtiger_seactivityrel\n\t\t\t\tON vtiger_seactivityrel.activityid = vtiger_activity.activityid\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid=vtiger_activity.activityid\n\t\t\tLEFT JOIN vtiger_cntactivityrel\n\t\t\t\tON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\t\tLEFT JOIN vtiger_contactdetails\n\t\t\t\tON vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid\n\t\t\tLEFT JOIN vtiger_users\n\t\t\t\tON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\tLEFT OUTER JOIN vtiger_recurringevents\n\t\t\t\tON vtiger_recurringevents.activityid = vtiger_activity.activityid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_seactivityrel.crmid=" . $id . "\n\t\t\tAND vtiger_crmentity.deleted = 0\n\t\t\tAND (activitytype = 'Task'\n\t\t\t\tOR activitytype !='Emails')"; $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; }
/** * Invoked when special actions are performed on the module. * @param String Module name * @param String Event Type (module.postinstall, module.disabled, module.enabled, module.preuninstall) */ function get_osstimecontrol($id, $cur_tab_id, $rel_tab_id, $actions = false) { global $log, $singlepane_view, $currentModule, $current_user; $log->debug("Entering get_osstimecontrol(" . $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); $record = Vtiger_Record_Model::getInstanceById($id); $userId = $record->get('assigned_user_id'); 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, 'parent_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}','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, vtiger_users.id,\n\t\t\t\tvtiger_osstimecontrol.name, vtiger_osstimecontrol.osstimecontrolid as crmid, vtiger_osstimecontrol.osstimecontrol_status, vtiger_osstimecontrol.payment,\n\t\t\t\tvtiger_osstimecontrol.osstimecontrol_no, vtiger_osstimecontrol.date_start, vtiger_osstimecontrol.due_date, vtiger_osstimecontrol.time_end, vtiger_osstimecontrol.sum_time, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime\n\t\t\t\tFROM vtiger_osstimecontrol\n\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_osstimecontrol.osstimecontrolid\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_crmentity.`smownerid`= " . $userId; $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_osstimecontrol method ..."); return $return_value; }
/** Function to get the invoices associated with the Sales Order * This function accepts the id as arguments and execute the MySQL query using the id * and sends the query and the id as arguments to renderRelatedInvoices() method. */ function get_invoices($id) { global $log, $singlepane_view; $log->debug("Entering get_invoices(" . $id . ") method ..."); require_once 'modules/Invoice/Invoice.php'; $focus = new Invoice(); $button = ''; if ($singlepane_view == 'true') { $returnset = '&return_module=SalesOrder&return_action=DetailView&return_id=' . $id; } else { $returnset = '&return_module=SalesOrder&return_action=CallRelatedList&return_id=' . $id; } $userNameSql = getSqlForNameInDisplayFormat(array('f' => 'vtiger_users.first_name', 'l' => 'vtiger_users.last_name')); $query = "select vtiger_crmentity.*, vtiger_invoice.*, vtiger_account.accountname, \r\n\t\t\tvtiger_salesorder.subject as salessubject, case when \r\n\t\t\t(vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname\r\n\t\t\tend as user_name from vtiger_invoice \r\n\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_invoice.invoiceid \r\n\t\t\tleft outer join vtiger_account on vtiger_account.accountid=vtiger_invoice.accountid \r\n\t\t\tinner join vtiger_salesorder on vtiger_salesorder.salesorderid=vtiger_invoice.salesorderid \r\n\t\t\tleft join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid\r\n\t\t\tleft join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid \r\n\t\t\twhere vtiger_crmentity.deleted=0 and vtiger_salesorder.salesorderid=" . $id; $log->debug("Exiting get_invoices method ..."); return GetRelatedList('SalesOrder', 'Invoice', $focus, $query, $button, $returnset); }
/** Returns a list of the associated contacts * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. * All Rights Reserved.. * Contributor(s): ______________________________________.. */ function get_contacts($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(); $returnset = '&return_module=' . $this_module . '&return_action=DetailView&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('BULKMAIL', $actions) && isPermitted($related_module, 1, '') == 'yes') { $button .= "<input title='" . getTranslatedString('LBL_BULK_MAILS') . "' class='crmbutton small create'" . " onclick='this.form.action.value=\"sendmail\";this.form.module.value=\"{$this_module}\"' type='submit' name='button'" . " value='" . getTranslatedString('LBL_BULK_MAILS') . "'>"; } } $query = 'select vtiger_contactdetails.accountid, vtiger_contactdetails.contactid, vtiger_contactdetails.firstname,vtiger_contactdetails.lastname, vtiger_contactdetails.department, vtiger_contactdetails.title, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_contactdetails.emailoptout, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_contactdetails inner join vtiger_cntactivityrel on vtiger_cntactivityrel.contactid=vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid where vtiger_cntactivityrel.activityid=' . $adb->quote($id) . ' and 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_contacts method ..."); return $return_value; }
/** * Function to get Product's related Products * @param integer $id - productid * returns related Products record in array format */ function get_parent_products($id) { global $log, $singlepane_view, $app_strings; $log->debug("Entering get_products(" . $id . ") method ..."); $focus = new Products(); $button = ''; if (isPermitted("Products", 1, "") == 'yes') { $button .= '<input title="' . $app_strings['LBL_NEW_PRODUCT'] . '" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Products\';this.form.return_module.value=\'Products\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="' . $app_strings['LBL_NEW_PRODUCT'] . '"> '; } if ($singlepane_view == 'true') { $returnset = '&return_module=Products&return_action=DetailView&is_parent=1&return_id=' . $id; } else { $returnset = '&return_module=Products&return_action=CallRelatedList&is_parent=1&return_id=' . $id; } $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_crmentity ON vtiger_crmentity.crmid = vtiger_products.productid\n\t\t\tINNER JOIN vtiger_seproductsrel ON vtiger_seproductsrel.productid = vtiger_products.productid AND vtiger_seproductsrel.setype='Products'\n\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_seproductsrel.crmid = {$id} "; $log->debug("Exiting get_products method ..."); return GetRelatedList('Products', 'Products', $focus, $query, $button, $returnset); }
/** * Function to get Activity related Users * @param integer $id - activityid * returns related Users record in array format */ function get_users($id) { global $log, $app_strings; $log->debug("Entering get_contacts(" . $id . ") method ..."); $focus = new Users(); $button = '<input title="Change" accessKey="" tabindex="2" type="button" class="crmbutton small edit" value="' . getTranslatedString('LBL_SELECT_USER_BUTTON_LABEL') . '" name="button" LANGUAGE=javascript onclick=\'return window.open("index.php?module=Users&return_module=Calendar&return_action={$return_modname}&activity_mode=Events&action=Popup&popuptype=detailview&form=EditView&form_submit=true&select=enable&return_id=' . $id . '&recordid=' . $id . '","test","width=640,height=525,resizable=0,scrollbars=0")\';>'; $returnset = '&return_module=Calendar&return_action=CallRelatedList&return_id=' . $id; $query = 'SELECT vtiger_users.id, vtiger_users.first_name,vtiger_users.last_name, vtiger_users.user_name, vtiger_users.email1, vtiger_users.email2, vtiger_users.status, vtiger_users.is_admin, vtiger_user2role.roleid, vtiger_users.secondaryemail, vtiger_users.phone_home, vtiger_users.phone_work, vtiger_users.phone_mobile, vtiger_users.phone_other, vtiger_users.phone_fax,vtiger_activity.date_start,vtiger_activity.due_date,vtiger_activity.time_start,vtiger_activity.duration_hours,vtiger_activity.duration_minutes from vtiger_users inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.smid=vtiger_users.id inner join vtiger_activity on vtiger_activity.activityid=vtiger_salesmanactivityrel.activityid inner join vtiger_user2role on vtiger_user2role.userid=vtiger_users.id where vtiger_activity.activityid=' . $id; $return_data = GetRelatedList('Calendar', 'Users', $focus, $query, $button, $returnset); if ($return_data == null) { $return_data = array(); } $return_data['CUSTOM_BUTTON'] = $button; $log->debug("Exiting get_users method ..."); return $return_data; }
function get_ventas_list($id, $cur_tab_id, $rel_tab_id, $actions = false) { global $adb; $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">'; $sql = "SELECT registrodeventasid FROM vtiger_registrodepagos WHERE registrodepagosid = ?"; $result = $adb->pquery($sql, array($id)); $row = $adb->fetchByAssoc($result); $ventaid = $row["registrodeventasid"]; $query = 'SELECT vtiger_crmentity.crmid,vtiger_registrodeventas.contacto, vtiger_registrodeventas.registrodeventastype, vtiger_crmentity.smownerid, vtiger_registrodeventas.registrodeventasname FROM vtiger_registrodeventas INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_registrodeventas.registrodeventasid INNER JOIN vtiger_crmentityrel ON (vtiger_crmentityrel.relcrmid = vtiger_crmentity.crmid OR vtiger_crmentityrel.crmid = vtiger_crmentity.crmid) LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid WHERE vtiger_crmentity.deleted = 0 AND (vtiger_crmentityrel.crmid = ' . $ventaid . ' OR vtiger_crmentityrel.relcrmid = ' . $ventaid . ') '; //var_dump($query); exit; $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); return $return_value; }