本文整理汇总了PHP中vtlib_setup_modulevars函数的典型用法代码示例。如果您正苦于以下问题:PHP vtlib_setup_modulevars函数的具体用法?PHP vtlib_setup_modulevars怎么用?PHP vtlib_setup_modulevars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtlib_setup_modulevars函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModelById
protected function loadModelById($local_id)
{
$user = CRMEntity::getInstance("Users");
$user->retrieve_entity_info($local_id, "Users");
vtlib_setup_modulevars("Users", $user);
$user->id = $local_id;
$user->mode = 'edit';
return $user;
}
示例2: get_ventas_list
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;
}
示例3: create_export_query
/**
* Create query to export the records.
*/
function create_export_query($where)
{
global $current_user;
$thismodule = $_REQUEST['module'];
include "include/utils/ExportUtils.php";
//To get the Permitted fields query and the permitted fields list
$sql = getPermittedFieldsQuery($thismodule, "detail_view");
$fields_list = getFieldsListFromQuery($sql);
$query = "SELECT {$fields_list}, vtiger_users.user_name AS user_name \n\t\t\t\tFROM vtiger_crmentity INNER JOIN {$this->table_name} ON vtiger_crmentity.crmid={$this->table_name}.{$this->table_index}";
if (!empty($this->customFieldTable)) {
$query .= " INNER JOIN " . $this->customFieldTable[0] . " ON " . $this->customFieldTable[0] . '.' . $this->customFieldTable[1] . " = {$this->table_name}.{$this->table_index}";
}
$query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= " LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id and vtiger_users.status='Active'";
$linkedModulesQuery = $this->db->pquery("SELECT distinct fieldname, columnname, relmodule FROM vtiger_field" . " INNER JOIN vtiger_fieldmodulerel ON vtiger_fieldmodulerel.fieldid = vtiger_field.fieldid" . " WHERE uitype='10' AND vtiger_fieldmodulerel.module=?", array($thismodule));
$linkedFieldsCount = $this->db->num_rows($linkedModulesQuery);
$rel_mods[$this->table_name] = 1;
for ($i = 0; $i < $linkedFieldsCount; $i++) {
$related_module = $this->db->query_result($linkedModulesQuery, $i, 'relmodule');
$fieldname = $this->db->query_result($linkedModulesQuery, $i, 'fieldname');
$columnname = $this->db->query_result($linkedModulesQuery, $i, 'columnname');
$other = CRMEntity::getInstance($related_module);
vtlib_setup_modulevars($related_module, $other);
if ($rel_mods[$other->table_name]) {
$rel_mods[$other->table_name] = $rel_mods[$other->table_name] + 1;
$alias = $other->table_name . $rel_mods[$other->table_name];
$query_append = "as {$alias}";
} else {
$alias = $other->table_name;
$query_append = '';
$rel_mods[$other->table_name] = 1;
}
$query .= " LEFT JOIN {$other->table_name} {$query_append} ON {$alias}.{$other->table_index} = {$this->table_name}.{$columnname}";
}
$query .= $this->getNonAdminAccessControlQuery($thismodule, $current_user);
$where_auto = " vtiger_crmentity.deleted=0";
if ($where != '') {
$query .= " WHERE ({$where}) AND {$where_auto}";
} else {
$query .= " WHERE {$where_auto}";
}
return $query;
}
示例4: vtlib_purify
require_once "modules/{$currentModule}/{$currentModule}.php";
$focus = new $currentModule();
$smarty->assign("SINGLE_MOD", $currentModule);
if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != '') {
$smarty->assign("RETURN_MODULE", vtlib_purify($_REQUEST['return_module']));
}
$alphabetical = AlphabeticalSearch($currentModule, 'Popup', $focus->def_basicsearch_col, 'true', 'basic', $popuptype, "", "", $url);
if (isset($_REQUEST['select'])) {
$smarty->assign("SELECT", 'enable');
}
break;
// END
}
// vtlib customization: Initialize focus to get generic popup
if ($_REQUEST['form'] == 'vtlibPopupView') {
vtlib_setup_modulevars($currentModule, $focus);
}
// END
$smarty->assign("RETURN_ACTION", vtlib_purify($_REQUEST['return_action']));
//Retreive the list from Database
if ($currentModule == 'PriceBooks') {
$productid = $_REQUEST['productid'];
$currency_id = $_REQUEST['currencyid'];
if ($currency_id == null) {
$currency_id = fetchCurrency($current_user->id);
}
$query = 'select vtiger_pricebook.*, vtiger_pricebookproductrel.productid, vtiger_pricebookproductrel.listprice, ' . 'vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime ' . 'from vtiger_pricebook inner join vtiger_pricebookproductrel on vtiger_pricebookproductrel.pricebookid = vtiger_pricebook.pricebookid ' . 'inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_pricebook.pricebookid ' . 'where vtiger_pricebookproductrel.productid=' . $adb->sql_escape_string($productid) . ' and vtiger_crmentity.deleted=0 ' . 'and vtiger_pricebook.currency_id=' . $adb->sql_escape_string($currency_id) . ' and vtiger_pricebook.active=1';
} else {
if (isset($_REQUEST['recordid']) && $_REQUEST['recordid'] != '') {
$smarty->assign("RECORDID", vtlib_purify($_REQUEST['recordid']));
$url_string .= '&recordid=' . vtlib_purify($_REQUEST['recordid']);
示例5: 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;
}
示例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: listQueryNonAdminChange
public function listQueryNonAdminChange($query, $scope = '')
{
//make the module base table as left hand side table for the joins,
//as mysql query optimizer puts crmentity on the left side and considerably slow down
$query = preg_replace('/\\s+/', ' ', $query);
if (strripos($query, ' WHERE ') !== false) {
vtlib_setup_modulevars($module, $this);
$query = str_ireplace(' where ', " WHERE {$this->table_name}.{$this->table_index} > 0 AND ", $query);
}
return $query;
}
示例8: export_Tables
/**
* Export module base and related tables
* @access private
*/
function export_Tables($moduleInstance)
{
$_exportedTables = array();
$modulename = $moduleInstance->name;
$this->openNode('tables');
if ($moduleInstance->isentitytype) {
$focus = CRMEntity::getInstance($modulename);
// Setup required module variables which is need for vtlib API's
vtlib_setup_modulevars($modulename, $focus);
$tables = array($focus->table_name);
if (!empty($focus->groupTable)) {
$tables[] = $focus->groupTable[0];
}
if (!empty($focus->customFieldTable)) {
$tables[] = $focus->customFieldTable[0];
}
foreach ($tables as $table) {
$this->openNode('table');
$this->outputNode($table, 'name');
$this->outputNode('<![CDATA[' . Vtiger_Utils::CreateTableSql($table) . ']]>', 'sql');
$this->closeNode('table');
$_exportedTables[] = $table;
}
}
// Now export table information recorded in schema file
if (file_exists("modules/{$modulename}/schema.xml")) {
$schema = simplexml_load_file("modules/{$modulename}/schema.xml");
if (!empty($schema->tables) && !empty($schema->tables->table)) {
foreach ($schema->tables->table as $tablenode) {
$table = trim($tablenode->name);
if (!in_array($table, $_exportedTables)) {
$this->openNode('table');
$this->outputNode($table, 'name');
$this->outputNode('<![CDATA[' . Vtiger_Utils::CreateTableSql($table) . ']]>', 'sql');
$this->closeNode('table');
$_exportedTables[] = $table;
}
}
}
}
$this->closeNode('tables');
}
示例9: get_pricebook_services
/** function used to get the services which are related to the pricebook
* @param int $id - pricebook id
* @return array - return an array which will be returned from the function getPriceBookRelatedServices
**/
function get_pricebook_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_pricebook_services(" . $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) {
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='submit' name='button' onclick=\"this.form.action.value='AddServicesToPriceBook';this.form.module.value='{$related_module}';this.form.return_module.value='{$currentModule}';this.form.return_action.value='PriceBookDetailView'\" value='" . getTranslatedString('LBL_SELECT') . " " . getTranslatedString($related_module) . "'> ";
}
}
$query = 'SELECT vtiger_service.serviceid, vtiger_service.servicename, vtiger_service.commissionrate,
vtiger_service.qty_per_unit, vtiger_service.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
vtiger_pricebookproductrel.listprice
FROM vtiger_service
INNER JOIN vtiger_pricebookproductrel on vtiger_service.serviceid = vtiger_pricebookproductrel.productid
INNER JOIN vtiger_crmentity on vtiger_crmentity.crmid = vtiger_service.serviceid
INNER JOIN vtiger_pricebook on vtiger_pricebook.pricebookid = vtiger_pricebookproductrel.pricebookid
LEFT JOIN vtiger_users ON vtiger_users.id=vtiger_crmentity.smownerid
LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid ' . getNonAdminAccessControlQuery($related_module, $current_user) . '
WHERE vtiger_pricebook.pricebookid = ' . $id . ' and vtiger_crmentity.deleted = 0';
$this->retrieve_entity_info($id, $this_module);
$return_value = $other->getPriceBookRelatedServices($query, $this, $returnset);
if ($return_value == null) {
$return_value = array();
}
$return_value['CUSTOM_BUTTON'] = $button;
$log->debug("Exiting get_pricebook_services method ...");
return $return_value;
}
示例10: getEscapedColumns
/** Function to get Escapedcolumns for the field in case of multiple parents
* @ param $selectedfields : Type Array
* returns the case query for the escaped columns
*/
function getEscapedColumns($selectedfields)
{
global $current_user, $adb;
$fieldname = $selectedfields[3];
$tmp = split("_", $selectedfields[2]);
$module = $tmp[0];
if ($fieldname == "parent_id" && ($module == "HelpDesk" || $module == "Calendar")) {
if ($module == "HelpDesk" && $selectedfields[0] == "vtiger_crmentityRelHelpDesk") {
$querycolumn = "case vtiger_crmentityRelHelpDesk.setype when 'Accounts' then vtiger_accountRelHelpDesk.accountname when 'Contacts' then concat(vtiger_contactdetailsRelHelpDesk.lastname,' ',vtiger_contactdetailsRelHelpDesk.firstname) End" . " '" . $selectedfields[2] . "', vtiger_crmentityRelHelpDesk.setype 'Entity_type'";
return $querycolumn;
}
if ($module == "Calendar") {
$querycolumn = "case vtiger_crmentityRelCalendar.setype when 'Accounts' then vtiger_accountRelCalendar.accountname when 'Leads' then concat(vtiger_leaddetailsRelCalendar.lastname,' ',vtiger_leaddetailsRelCalendar.firstname) when 'Potentials' then vtiger_potentialRelCalendar.potentialname when 'Quotes' then vtiger_quotesRelCalendar.subject when 'PurchaseOrder' then vtiger_purchaseorderRelCalendar.subject when 'Invoice' then vtiger_invoiceRelCalendar.subject when 'SalesOrder' then vtiger_salesorderRelCalendar.subject when 'HelpDesk' then vtiger_troubleticketsRelCalendar.title when 'Campaigns' then vtiger_campaignRelCalendar.campaignname End" . " '" . $selectedfields[2] . "', vtiger_crmentityRelCalendar.setype 'Entity_type'";
}
} elseif ($fieldname == "contact_id" && strpos($selectedfields[2], "Contact_Name")) {
if (($this->primarymodule == 'PurchaseOrder' || $this->primarymodule == 'SalesOrder' || $this->primarymodule == 'Quotes' || $this->primarymodule == 'Invoice' || $this->primarymodule == 'Calendar') && $module == $this->primarymodule) {
if (getFieldVisibilityPermission("Contacts", $current_user->id, "firstname") == '0') {
$querycolumn = " case when vtiger_crmentity.crmid!='' then concat(vtiger_contactdetails" . $this->primarymodule . ".lastname,' ',vtiger_contactdetails" . $this->primarymodule . ".firstname) else '-' end as " . $selectedfields[2];
} else {
$querycolumn = " case when vtiger_crmentity.crmid!='' then vtiger_contactdetails" . $this->primarymodule . ".lastname else '-' end as " . $selectedfields[2];
}
}
if (stristr($this->secondarymodule, $module) && ($module == 'Quotes' || $module == 'SalesOrder' || $module == 'PurchaseOrder' || $module == 'Calendar' || $module == 'Invoice')) {
if (getFieldVisibilityPermission("Contacts", $current_user->id, "firstname") == '0') {
$querycolumn = " case when vtiger_crmentity" . $module . ".crmid!='' then concat(vtiger_contactdetails" . $module . ".lastname,' ',vtiger_contactdetails" . $module . ".firstname) else '-' end as " . $selectedfields[2];
} else {
$querycolumn = " case when vtiger_crmentity" . $module . ".crmid!='' then vtiger_contactdetails" . $module . ".lastname else '-' end as " . $selectedfields[2];
}
}
} else {
if (stristr($selectedfields[0], "vtiger_crmentityRel")) {
$module = str_replace("vtiger_crmentityRel", "", $selectedfields[0]);
$fields_query = $adb->pquery("SELECT vtiger_field.fieldname,vtiger_field.tablename,vtiger_field.fieldid from vtiger_field INNER JOIN vtiger_tab on vtiger_tab.name = ? WHERE vtiger_tab.tabid=vtiger_field.tabid and vtiger_field.fieldname=?", array($module, $selectedfields[3]));
if ($adb->num_rows($fields_query) > 0) {
for ($i = 0; $i < $adb->num_rows($fields_query); $i++) {
$field_name = $selectedfields[3];
$field_id = $adb->query_result($fields_query, $i, 'fieldid');
$tab_name = $selectedfields[1];
$ui10_modules_query = $adb->pquery("SELECT relmodule FROM vtiger_fieldmodulerel WHERE fieldid=?", array($field_id));
if ($adb->num_rows($ui10_modules_query) > 0) {
$querycolumn = " case vtiger_crmentityRel{$module}.setype";
for ($j = 0; $j < $adb->num_rows($ui10_modules_query); $j++) {
$rel_mod = $adb->query_result($ui10_modules_query, $j, 'relmodule');
$rel_obj = CRMEntity::getInstance($rel_mod);
vtlib_setup_modulevars($rel_mod, $rel_obj);
$rel_tab_name = $rel_obj->table_name;
$link_field = $rel_tab_name . "Rel" . $module . "." . $rel_obj->list_link_field;
if ($rel_mod == "Contacts" || $rel_mod == "Leads") {
if (getFieldVisibilityPermission($rel_mod, $current_user->id, 'firstname') == 0) {
$link_field = "concat({$link_field},' '," . $rel_tab_name . "Rel{$module}.firstname)";
}
}
$querycolumn .= " when '{$rel_mod}' then {$link_field} ";
}
$querycolumn .= "end as '" . $selectedfields[2] . "', vtiger_crmentityRel{$module}.setype as 'Entity_type'";
}
}
}
}
}
return $querycolumn;
}
示例11: 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;
}
示例12: generateRelatedListModels
function generateRelatedListModels($model)
{
global $adb;
$lists = $adb->pquery("select vtiger_tab.name as relmodulename, vtiger_relatedlists.name as listtype from vtiger_relatedlists inner join vtiger_tab on vtiger_tab.tabid=vtiger_relatedlists.related_tabid where vtiger_relatedlists.tabid=? and vtiger_relatedlists.name in ('get_related_list', 'get_dependents_list')", array(getTabid($this->moduleName)));
for ($i = 0; $i < $adb->num_rows($lists); $i++) {
$relmodulename = $adb->query_result($lists, $i, 'relmodulename');
$listtype = $adb->query_result($lists, $i, 'listtype');
if ($listtype == 'get_related_list') {
$listrecords = $adb->pquery('select vtiger_crmentityrel.relcrmid from vtiger_crmentityrel inner join vtiger_crmentity on (vtiger_crmentity.crmid=vtiger_crmentityrel.crmid and vtiger_crmentity.deleted=0) where vtiger_crmentityrel.crmid=? and vtiger_crmentityrel.relmodule=?', array($this->focus->id, $relmodulename));
for ($j = 0; $j < 10; $j++) {
$entity = CRMEntity::getInstance($relmodulename);
if ($j < $adb->num_rows($listrecords)) {
$relcrmid = $adb->query_result($listrecords, $j, 'relcrmid');
$entity->retrieve_entity_info($relcrmid, $relmodulename);
}
$this->generateEntityModel($entity, $relmodulename, 'Related' . $relmodulename . ($j + 1) . '_', $model);
}
} else {
if ($listtype == 'get_dependents_list') {
$dependentFieldSql = $adb->pquery("SELECT tabid, fieldname, columnname FROM vtiger_field WHERE uitype='10' AND" . " fieldid IN (SELECT fieldid FROM vtiger_fieldmodulerel WHERE relmodule=? AND module=?)", array($this->moduleName, $relmodulename));
$numOfFields = $adb->num_rows($dependentFieldSql);
if ($numOfFields > 0) {
$dependentColumn = $adb->query_result($dependentFieldSql, 0, 'columnname');
$dependentField = $adb->query_result($dependentFieldSql, 0, 'fieldname');
$thisModule = $this->focus;
$other = CRMEntity::getInstance($relmodulename);
vtlib_setup_modulevars($this->moduleName, $this->focus);
vtlib_setup_modulevars($relmodulename, $other);
$query = "SELECT vtiger_crmentity.*";
$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 {$thisModule->table_name} ON {$thisModule->table_name}.{$thisModule->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 {$thisModule->table_name}.{$thisModule->table_index} = {$thisModule->id}";
if ($relmodulename != 'Faq' && $relmodulename != 'PriceBook' && $relmodulename != 'Users') {
global $current_user;
$secQuery = getNonAdminAccessControlQuery($relmodulename, $current_user);
if (strlen($secQuery) > 1) {
$query = appendFromClauseToQuery($query, $secQuery);
}
}
$listrecords = $adb->pquery($query, array());
for ($j = 0; $j < 10; $j++) {
$entity = CRMEntity::getInstance($relmodulename);
if ($j < $adb->num_rows($listrecords)) {
$relcrmid = $adb->query_result($listrecords, $j, 'crmid');
$entity->retrieve_entity_info($relcrmid, $relmodulename);
}
$this->generateEntityModel($entity, $relmodulename, 'Related' . $relmodulename . ($j + 1) . '_', $model);
}
}
}
}
}
}
示例13: 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;
}
示例14: create_export_query
/**
* Create query to export the records.
*/
function create_export_query($where)
{
global $current_user;
include("include/utils/ExportUtils.php");
//To get the Permitted fields query and the permitted fields list
$sql = getPermittedFieldsQuery('ProjectTask', "detail_view");
$fields_list = getFieldsListFromQuery($sql);
$query = "SELECT $fields_list, vtiger_users.user_name AS user_name
FROM vtiger_crmentity INNER JOIN $this->table_name ON vtiger_crmentity.crmid=$this->table_name.$this->table_index";
if(!empty($this->customFieldTable)) {
$query .= " INNER JOIN ".$this->customFieldTable[0]." ON ".$this->customFieldTable[0].'.'.$this->customFieldTable[1] .
" = $this->table_name.$this->table_index";
}
$query .= " LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
$query .= " LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid = vtiger_users.id and vtiger_users.status='Active'";
$linkedModulesQuery = $this->db->pquery("SELECT distinct fieldname, columnname, relmodule FROM vtiger_field" .
" INNER JOIN vtiger_fieldmodulerel ON vtiger_fieldmodulerel.fieldid = vtiger_field.fieldid" .
" WHERE uitype='10' AND vtiger_fieldmodulerel.module=?", array($thismodule));
$linkedFieldsCount = $this->db->num_rows($linkedModulesQuery);
for($i=0; $i<$linkedFieldsCount; $i++) {
$related_module = $this->db->query_result($linkedModulesQuery, $i, 'relmodule');
$fieldname = $this->db->query_result($linkedModulesQuery, $i, 'fieldname');
$columnname = $this->db->query_result($linkedModulesQuery, $i, 'columnname');
$other = CRMEntity::getInstance($related_module);
vtlib_setup_modulevars($related_module, $other);
$query .= " LEFT JOIN $other->table_name ON $other->table_name.$other->table_index = $this->table_name.$columnname";
}
$query .= $this->getNonAdminAccessControlQuery($thismodule,$current_user);
$where_auto = " vtiger_crmentity.deleted=0";
if($where != '') $query .= " WHERE ($where) AND $where_auto";
else $query .= " WHERE $where_auto";
return $query;
}
示例15: elseif
$tablename = $normal_tabs[$type];
}
if ($type == "Users") {
$q = "select {$fieldname} from {$tablename} where id=?";
} elseif ($type == "Leads") {
$q = "select {$fieldname} from {$tablename} where leadid=?";
} elseif ($type == "Contacts") {
$q = "select {$fieldname} from {$tablename} where contactid=?";
} elseif ($type == "Accounts") {
$q = "select {$fieldname} from {$tablename} where accountid=?";
} elseif ($type == "Vendors") {
$q = "select {$fieldname} from {$tablename} where vendorid=?";
} else {
// vtlib customization: Support for email-type custom field for other modules.
$module_focus = CRMEntity::getInstance($type);
vtlib_setup_modulevars($type, $module_focus);
if (!empty($module_focus->customFieldTable)) {
$q = "select {$fieldname} from " . $module_focus->customFieldTable[0] . " where " . $module_focus->customFieldTable[1] . "= ?";
}
// END
}
$email1 = $adb->query_result($adb->pquery($q, array($rec_id)), 0, $fieldname);
} elseif ($rec_type == "email_addy") {
$email1 = $_REQUEST["email_addy"];
}
$smarty->assign('TO_MAIL', trim($email1, ",") . ",");
}
//handled for replying emails
if ($_REQUEST['reply'] == "true") {
$fromadd = $_REQUEST['record'];
$query = "select from_email,idlists,cc_email,bcc_email from vtiger_emaildetails where emailid =?";