function getListFiledOfRelatedModule($moduleName) { $db = PearDatabase::getInstance(); $tabid = getTabid($moduleName); $sourceModule = $moduleName; $sql = "select vtiger_field.fieldid, fieldlabel, uitype, vtiger_fieldmodulerel.relmodule from vtiger_field \n\t\t\t\tleft JOIN vtiger_fieldmodulerel ON vtiger_fieldmodulerel.fieldid = vtiger_field.fieldid where tabid = ? AND (uitype = '10' OR uitype = '59' OR uitype = '53' OR uitype = '51')"; $resultModuleList = $db->pquery($sql, array($tabid), true); $moduleList = array(); for ($i = 0; $i < $db->num_rows($resultModuleList); $i++) { $uitype = $db->query_result($resultModuleList, $i, 'uitype'); $fieldid = $db->query_result($resultModuleList, $i, 'fieldid'); $fieldlabel = $db->query_result($resultModuleList, $i, 'fieldlabel'); if ($uitype == 10) { $moduleList[] = array(Vtiger_Functions::getModuleId($db->query_result($resultModuleList, $i, 'relmodule')), $fieldlabel, $fieldid); } elseif ($uitype == 51) { $moduleList[] = array(Vtiger_Functions::getModuleId('Accounts'), $fieldlabel, $fieldid); } elseif ($uitype == 59) { $moduleList[] = array(Vtiger_Functions::getModuleId('Products'), $fieldlabel, $fieldid); } elseif ($uitype == 53) { $moduleList[] = array(Vtiger_Functions::getModuleId('Users'), $fieldlabel, $fieldid); } } $output = array(); for ($i = 0; $i < count($moduleList); $i++) { $moduleInfoSql = "SELECT * FROM vtiger_tab WHERE tabid = ?"; $moduleInfoResult = $db->pquery($moduleInfoSql, array($moduleList[$i][0]), true); $moduleName = $db->query_result($moduleInfoResult, 0, 'name'); $moduleTrLabal = vtranslate($moduleList[$i][1], $sourceModule); $output[$moduleTrLabal] = array(); $output[$moduleTrLabal] = $this->getListFiledOfModule($moduleName, $moduleList[$i][2]); } return $output; }
public function getJoinSQLbyFieldRelation(&$join_array, &$columns_array) { $related_focus = CRMEntity::getInstance($this->relModuleName); $params_fieldname = $this->params["fieldname"]; // first join to vtiger module table $this->params["fieldname"] = $related_focus->tab_name_index[$this->params["tablename"]]; $this->getStJoinSQL($join_array, $columns_array); $r_tabid = getTabid($this->relModuleName); $adb = PEARDatabase::getInstance(); $uirel_row = $adb->fetchByAssoc($adb->pquery("SELECT * FROM vtiger_field WHERE tabid = ? AND fieldname = ?", array($r_tabid, $params_fieldname)), 0); $related_table_name = $related_focus->table_name; $related_table_index = $related_focus->table_index; foreach ($related_focus->tab_name as $other_table) { $related_join_array[$other_table] = $related_focus->tab_name_index[$other_table]; } $field_uitype = $uirel_row["uitype"]; $fieldid = $this->params["fieldid"]; $oth_as = ""; if ($uirel_row["tablename"] == "vtiger_crmentity") { $oth_as = $this->oth_as; $related_table_name = $uirel_row["tablename"]; $related_table_index = $uirel_row["columnname"]; } $using_aliastablename = $related_table_name . $oth_as . $fieldid; $using_columnname = $related_table_index; $params = array('fieldid' => $uirel_row["fieldid"], 'fieldtabid' => $uirel_row["tabid"], 'field_uitype' => $field_uitype, 'fieldname' => $uirel_row["fieldname"], 'columnname' => $uirel_row["columnname"], 'tablename' => $uirel_row["tablename"], 'table_index' => $related_join_array, 'report_primary_table' => $this->params["report_primary_table"], 'primary_table_name' => $related_focus->table_name, 'primary_table_index' => $related_focus->table_index, 'primary_tableid' => $r_tabid, 'using_aliastablename' => $using_array["u_tablename"], 'using_columnname' => $using_array["u_tableindex"], 'old_oth_as' => $oth_as, 'old_oth_fieldid' => $fieldid, 'fld_string' => $this->params["fld_string"]); $using_array = getJoinInformation($params); $params["using_array"] = $using_array; $uifactory = new UIFactory($params); //show("<font color='green'>fielduitype".$field_uitype."_IN_P_".$field_uitype,$related_join_array,$params["using_array"],"</font>"); $uifactory->getJoinSQL($field_uitype, $join_array, $columns_array); }
public function getTabId() { if ($this->tabId == null) { $this->tabId = getTabid($this->objectName); } return $this->tabId; }
/** * Function to get mapping supported field ids list * @return <Array> list of field ids */ public function getMappingSupportedFieldIdsList() { if (!$this->supportedFieldIdsList) { $selectedTabidsList[] = getTabid($this->getName()); $presense = array(0, 2); $restrictedFieldNames = array('campaignrelstatus'); $restrictedUitypes = array(4, 10, 51, 52, 53, 57, 58, 69, 70); $selectedGeneratedTypes = array(1, 2); $db = PearDatabase::getInstance(); $query = 'SELECT fieldid FROM vtiger_field WHERE presence IN (' . generateQuestionMarks($presense) . ') AND tabid IN (' . generateQuestionMarks($selectedTabidsList) . ') AND uitype NOT IN (' . generateQuestionMarks($restrictedUitypes) . ') AND fieldname NOT IN (' . generateQuestionMarks($restrictedFieldNames) . ') AND generatedtype IN (' . generateQuestionMarks($selectedGeneratedTypes) . ')'; $params = array_merge($presense, $selectedTabidsList, $restrictedUitypes, $restrictedFieldNames, $selectedGeneratedTypes); $result = $db->pquery($query, $params); $numOfRows = $db->num_rows($result); $fieldIdsList = array(); for ($i = 0; $i < $numOfRows; $i++) { $fieldIdsList[] = $db->query_result($result, $i, 'fieldid'); } $this->supportedFieldIdsList = $fieldIdsList; } return $this->supportedFieldIdsList; }
/** * Function to retrieve name fields of a module * @return <array> - array which contains fields which together construct name fields */ public function getNameFields() { $nameFieldObject = Vtiger_Cache::get('EntityField', $this->getName()); $moduleName = $this->getName(); if ($nameFieldObject && $nameFieldObject->fieldname) { $this->nameFields = explode(',', $nameFieldObject->fieldname); } else { $adb = PearDatabase::getInstance(); $query = "SELECT fieldname, tablename, entityidfield FROM vtiger_entityname WHERE tabid = ?"; $result = $adb->pquery($query, array(getTabid('Calendar'))); $this->nameFields = array(); if ($result) { $rowCount = $adb->num_rows($result); if ($rowCount > 0) { $fieldNames = $adb->query_result($result, 0, 'fieldname'); $this->nameFields = explode(',', $fieldNames); } } $entiyObj = new stdClass(); $entiyObj->basetable = $adb->query_result($result, 0, 'tablename'); $entiyObj->basetableid = $adb->query_result($result, 0, 'entityidfield'); $entiyObj->fieldname = $fieldNames; Vtiger_Cache::set('EntityField', $this->getName(), $entiyObj); } return $this->nameFields; }
public function beforeGetTaskform($viewer) { $viewer->assign("ENABLE_PDFMAKER", false); $viewer->assign("pdfmaker_templates", array()); if (getTabid('PDFMaker') && vtlib_isModuleActive('PDFMaker')) { require_once 'modules/PDFMaker/PDFMaker.php'; if (class_exists("PDFMaker")) { $PDFMaker = $PDFMaker = new PDFMaker_PDFMaker_Model(); if (method_exists($PDFMaker, "GetAvailableTemplates")) { $viewer->assign("ENABLE_PDFMAKER", true); $templates = $PDFMaker->GetAvailableTemplates($this->getModuleName()); foreach ($templates as $index => $value) { $pdftemplates[$index] = $value["templatename"]; } $viewer->assign("pdfmaker_templates", $pdftemplates); $templateid = $this->get("template"); if (!empty($templateid) && $templateid != -1 && $this->get("attachments") == -1) { $this->set("attachments", '{"pdfmaker#' . $templateid . '":"title"}'); } else { if ($this->get("attachments") == -1) { $this->set("attachments", '{}'); } } } } } }
public function updateProgressMilestone($id) { $adb = PearDatabase::getInstance(); //TODO need to handle security if (!isRecordExists($id)) { return; } $focus = CRMEntity::getInstance($this->getName()); $relatedListMileston = $focus->get_dependents_list($id, $this->getId(), getTabid('ProjectTask')); $resultMileston = $adb->query($relatedListMileston['query']); $num = $adb->num_rows($resultMileston); $estimatedWorkTime = 0; $progressInHours = 0; for ($i = 0; $i < $num; $i++) { $row = $adb->query_result_rowdata($resultMileston, $i); $estimatedWorkTime += $row['estimated_work_time']; $recordProgress = $row['estimated_work_time'] * (int) $row['projecttaskprogress'] / 100; $progressInHours += $recordProgress; } if (!$estimatedWorkTime) { return; } $projectMilestoneProgress = round(100 * $progressInHours / $estimatedWorkTime); $focus->retrieve_entity_info($id, $this->getName()); $focus->column_fields['projectmilestone_progress'] = $projectMilestoneProgress . '%'; $focus->column_fields['mode'] = 'edit'; $focus->saveentity($this->getName(), $id); }
/** Function to create list query * @param reference variable - where condition is passed when the query is executed * Returns Query. */ function create_list_query($order_by, $where) { $log = vglobal('log'); $current_user = vglobal('current_user'); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; $tab_id = getTabid("Potentials"); $log->debug("Entering create_list_query(" . $order_by . "," . $where . ") method ..."); // Determine if the vtiger_account name is present in the where clause. $account_required = preg_match("/accounts\\.name/", $where); if ($account_required) { $query = "SELECT vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_potential.dateclosed FROM vtiger_potential, vtiger_account "; $where_auto = "account.accountid = vtiger_potential.related_to AND vtiger_crmentity.deleted=0 "; } else { $query = 'SELECT vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_crmentity.smcreatorid, vtiger_potential.closingdate FROM vtiger_potential inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid LEFT JOIN vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid '; $where_auto = ' AND vtiger_crmentity.deleted=0'; } $query .= $this->getNonAdminAccessControlQuery('Potentials', $current_user); if ($where != "") { $query .= " where {$where} " . $where_auto; } else { $query .= " where " . $where_auto; } if ($order_by != "") { $query .= " ORDER BY {$order_by}"; } $log->debug("Exiting create_list_query method ..."); return $query; }
/** * Detect the related modules based on the entity relation information for this instance. */ function detectRelatedModules() { global $adb, $current_user; // Pick the distinct modulenames based on related records. $result = $adb->pquery("SELECT distinct setype FROM vtiger_crmentity WHERE crmid in (\n\t\t\tSELECT relcrmid FROM vtiger_crmentityrel INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_crmentityrel.crmid \n\t\t\tWHERE vtiger_crmentity.crmid = ? AND vtiger_crmentity.deleted=0)", array($this->id)); $relatedModules = array(); // Calculate the related module access (similar to getRelatedList API in DetailViewUtils.php) if ($result && $adb->num_rows($result)) { require 'user_privileges/user_privileges_' . $current_user->id . '.php'; while ($resultrow = $adb->fetch_array($result)) { $accessCheck = false; $relatedTabId = getTabid($resultrow['setype']); if ($relatedTabId == 0) { $accessCheck = true; } else { if ($profileTabsPermission[$relatedTabId] == 0) { if ($profileActionPermission[$relatedTabId][3] == 0) { $accessCheck = true; } } } if ($accessCheck) { $relatedModules[$relatedTabId] = $resultrow['setype']; } } } return $relatedModules; }
/** * Function to get customfield entries * @param string $module - Module name * return array $cflist - customfield entries */ function getCFListEntries($module) { $tabid = getTabid($module); global $adb; global $theme; global $mod_strings; global $app_strings; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; //$dbQuery = "select fieldid,columnname,fieldlabel,uitype,displaytype from ec_field where tabid=".$tabid." and generatedtype=2 order by sequence"; $dbQuery = "select multifieldid,multifieldname,totallevel from ec_multifield where tabid=" . $tabid . " order by multifieldid"; $result = $adb->getList($dbQuery); $count = 1; $cflist = array(); foreach ($result as $row) { $cf_element = array(); $cf_element['no'] = $count; $cf_element['label'] = $row["multifieldname"]; $fld_type_name = $row["totallevel"]; /* if(isset($mod_strings[$fld_type_name])) { $fld_type_name = $mod_strings[$fld_type_name]; } */ $cf_element['type'] = $fld_type_name; $cf_element['tool'] = '<img src="' . $image_path . 'editfield.gif" border="0" style="cursor:pointer;" onClick="gotoEditCustomField(\'' . $module . '\',\'' . $row["multifieldid"] . '\',\'' . $tabid . '\',\'' . $row["uitype"] . '\')" alt="' . $app_strings['LBL_EDIT'] . '" title="' . $app_strings['LBL_EDIT'] . '"/> | <img style="cursor:pointer;" onClick="deleteMultiCustomField(' . $row["multifieldid"] . ',\'' . $module . '\', \'' . $row["columnname"] . '\', \'' . $row["uitype"] . '\')" src="' . $image_path . 'delete.gif" border="0" alt="' . $app_strings['LBL_DELETE'] . '" title="' . $app_strings['LBL_DELETE'] . '"/> '; $cflist[] = $cf_element; $count++; } return $cflist; }
/** * 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 vtlib_handler($modulename, $event_type) { $registerLink = false; $displayLabel = 'Time Control'; global $adb, $log; if ($event_type == 'module.postinstall') { $tabid = getTabid($modulename); $adb->query("UPDATE `vtiger_field` SET `summaryfield` = '1' WHERE `tabid` = {$tabid} AND `columnname` IN ('name','osstimecontrol_no','osstimecontrol_status','smownerid','date_start','time_start','time_end','due_date','sum_time','platnosc');", true); $ModuleInstance = CRMEntity::getInstance($modulename); $ModuleInstance->setModuleSeqNumber("configure", $modulename, 'TC', '1'); include_once 'vtlib/Vtiger/Module.php'; $moduleInstance = Vtiger_Module::getInstance($modulename); $docelowy_Module = Vtiger_Module::getInstance('Accounts'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('HelpDesk'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('Project'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('ProjectTask'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('ServiceContracts'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('Assets'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('SalesOrder'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('Potentials'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('Quotes'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('Leads'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $modcommentsModuleInstance = Vtiger_Module::getInstance('ModComments'); if ($modcommentsModuleInstance && file_exists('modules/ModComments/ModComments.php')) { include_once 'modules/ModComments/ModComments.php'; if (class_exists('ModComments')) { ModComments::addWidgetTo(array('OSSTimeControl')); } } } else { if ($event_type == 'module.disabled') { // TODO Handle actions when this module is disabled. } else { if ($event_type == 'module.enabled') { // TODO Handle actions when this module is enabled. } else { if ($event_type == 'module.preuninstall') { // TODO Handle actions when this module is about to be deleted. } else { if ($event_type == 'module.preupdate') { // TODO Handle actions before this module is updated. } else { if ($event_type == 'module.postupdate') { } } } } } } }
/** * Function to get customfield entries * @param string $module - Module name * return array $cflist - customfield entries */ function getBlockListEntries($module) { $tabid = getTabid($module); global $adb; global $theme; global $current_language; if ($module == "Events") { $module = "Calendar"; } $cur_module_strings = return_specified_module_language($current_language, $module); $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $dbQuery = "select blockid,blocklabel,sequence from ec_blocks where tabid={$tabid} and visible = 0 order by sequence"; $result = $adb->query($dbQuery); $row = $adb->fetch_array($result); $count = 1; $cflist = array(); if ($row != '') { do { $cf_element = array(); $cf_element['no'] = $count; if (isset($cur_module_strings[$row["blocklabel"]])) { $cf_element['label'] = $cur_module_strings[$row["blocklabel"]]; } else { $cf_element['label'] = $row["blocklabel"]; } $cf_element['sequence'] = $row["sequence"]; //getCreateCustomBlockForm(customModule,blockid,tabid,label,order) $cf_element['tool'] = '<img src="' . $image_path . 'editfield.gif" border="0" style="cursor:pointer;" onClick="fnvshobj(this,\'createblock\');getCreateCustomBlockForm(\'' . $module . '\',\'' . $row["blockid"] . '\',\'' . $tabid . '\',\'' . $cf_element['label'] . '\',\'' . $row["sequence"] . '\')" alt="Edit" title="Edit"/> | <img style="cursor:pointer;" onClick="deleteCustomBlock(' . $row["blockid"] . ',\'' . $module . '\', \'' . $row["columnname"] . '\', \'' . $row["uitype"] . '\')" src="' . $image_path . 'delete.gif" border="0" alt="Delete" title="Delete"/></a>'; $cflist[] = $cf_element; $count++; } while ($row = $adb->fetch_array($result)); } return $cflist; }
/** * Function to get picklist fields for the given module * @ param $fld_module * It gets the picklist details array for the given module in the given format * $fieldlist = Array(Array('fieldlabel'=>$fieldlabel,'generatedtype'=>$generatedtype,'columnname'=>$columnname,'fieldname'=>$fieldname,'value'=>picklistvalues)) */ function getUserFldArray($fld_module, $roleid) { $adb = PearDatabase::getInstance(); $log = vglobal('log'); $user_fld = array(); $tabid = getTabid($fld_module); $query = "select vtiger_field.fieldlabel,vtiger_field.columnname,vtiger_field.fieldname, vtiger_field.uitype" . " FROM vtiger_field inner join vtiger_picklist on vtiger_field.fieldname = vtiger_picklist.name" . " where (displaytype=1 and vtiger_field.tabid=? and vtiger_field.uitype in ('15','55','33','16') " . " or (vtiger_field.tabid=? and fieldname='salutationtype' and fieldname !='vendortype')) " . " and vtiger_field.presence in (0,2) ORDER BY vtiger_picklist.picklistid ASC"; $result = $adb->pquery($query, array($tabid, $tabid)); $noofrows = $adb->num_rows($result); if ($noofrows > 0) { $fieldlist = array(); for ($i = 0; $i < $noofrows; $i++) { $user_fld = array(); $fld_name = $adb->query_result($result, $i, "fieldname"); $user_fld['fieldlabel'] = $adb->query_result($result, $i, "fieldlabel"); $user_fld['generatedtype'] = $adb->query_result($result, $i, "generatedtype"); $user_fld['columnname'] = $adb->query_result($result, $i, "columnname"); $user_fld['fieldname'] = $adb->query_result($result, $i, "fieldname"); $user_fld['uitype'] = $adb->query_result($result, $i, "uitype"); $user_fld['value'] = getAssignedPicklistValues($user_fld['fieldname'], $roleid, $adb); $fieldlist[] = $user_fld; } } return $fieldlist; }
function vtEditExpressions($adb, $appStrings, $current_language, $theme, $formodule = '') { $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $smarty = new vtigerCRM_Smarty(); $smarty->assign('APP', $appStrings); $mod = array_merge(return_module_language($current_language, 'FieldFormulas'), return_module_language($current_language, 'Settings')); $jsStrings = array('NEED_TO_ADD_A' => $mod['NEED_TO_ADD_A'], 'CUSTOM_FIELD' => $mod['LBL_CUSTOM_FIELD'], 'LBL_USE_FUNCTION_DASHDASH' => $mod['LBL_USE_FUNCTION_DASHDASH'], 'LBL_USE_FIELD_VALUE_DASHDASH' => $mod['LBL_USE_FIELD_VALUE_DASHDASH'], 'LBL_DELETE_EXPRESSION_CONFIRM' => $mod['LBL_DELETE_EXPRESSION_CONFIRM']); $smarty->assign("JS_STRINGS", Zend_Json::encode($jsStrings)); $smarty->assign("MOD", $mod); $smarty->assign("THEME", $theme); $smarty->assign("IMAGE_PATH", $image_path); $smarty->assign("MODULE_NAME", 'FieldFormulas'); $smarty->assign("PAGE_NAME", 'LBL_FIELDFORMULAS'); $smarty->assign("PAGE_TITLE", 'LBL_FIELDFORMULAS'); $smarty->assign("PAGE_DESC", 'LBL_FIELDFORMULAS_DESCRIPTION'); $smarty->assign("FORMODULE", $formodule); if (file_exists("modules/{$formodule}/{$formodule}.php")) { $focus = CRMEntity::getInstance($formodule); $validationArray = split_validationdataArray(getDBValidationData($focus->tab_name, getTabid($formodule))); $smarty->assign('VALIDATION_DATA_FIELDNAME', $validationArray['fieldname']); $smarty->assign('VALIDATION_DATA_FIELDDATATYPE', $validationArray['datatype']); $smarty->assign('VALIDATION_DATA_FIELDLABEL', $validationArray['fieldlabel']); } $smarty->display(vtlib_getModuleTemplate('FieldFormulas', 'EditExpressions.tpl')); }
public function beforeGetTaskform($viewer) { global $adb; if (!\Workflow\VtUtils::existTable("vtiger_wf_customnumbering")) { echo "Create table vtiger_wf_confirmation_user ... ok<br>"; $adb->query("CREATE TABLE IF NOT EXISTS `vtiger_wf_customnumbering` (\r\n `serie` varchar(24) NOT NULL,\r\n `prefix` varchar(16) NOT NULL,\r\n `current` int(10) unsigned NOT NULL,\r\n `length` tinyint(4) NOT NULL,\r\n PRIMARY KEY (`serie`)\r\n ) ENGINE=InnoDB;"); } $crmidColObj = CRMEntity::getInstance($this->getModuleName()); $viewer->assign('crmidCol', $crmidColObj->table_index); $moduleName = $this->getModuleName(); $fields = VtUtils::getFieldsWithBlocksForModule($moduleName, false); $selectedId = $this->get('field'); if ($selectedId === -1 || empty($selectedId)) { $sql = 'SELECT * FROM vtiger_field WHERE uitype = 4 AND tabid = ' . getTabid($moduleName); $result = $adb->query($sql); $selectedId = $adb->query_result($result, 0, 'fieldname'); $this->set('field', $selectedId); } $sql = 'SELECT * FROM vtiger_wf_customnumbering'; $result = $adb->query($sql); $series = array(); while ($row = $adb->fetchByAssoc($result)) { $series[$row['serie']] = $row; } if (isset($series[$this->get('serie')])) { $viewer->assign('lockFields', true); } $viewer->assign('series', $series); $viewer->assign('fields', $fields); /* Insert here source code to create custom configurations pages */ }
/** * Function to get customfield entries * @param string $module - Module name * return array $cflist - customfield entries */ function getCFListEntries($module) { $tabid = getTabid($module); global $adb; global $theme; global $mod_strings; global $app_strings; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $dbQuery = "select fieldid,columnname,fieldlabel,uitype,displaytype from ec_field where tabid=" . $tabid . " and generatedtype=2 and uitype not in('1021','1022','1023') order by sequence"; $result = $adb->query($dbQuery); $row = $adb->fetch_array($result); $count = 1; $cflist = array(); if ($row != '') { do { $cf_element = array(); $cf_element['no'] = $count; $cf_element['label'] = $row["fieldlabel"]; $fld_type_name = getCustomFieldTypeName($row["uitype"]); if (isset($mod_strings[$fld_type_name])) { $fld_type_name = $mod_strings[$fld_type_name]; } $cf_element['type'] = $fld_type_name; $cf_element['tool'] = '<img src="' . $image_path . 'editfield.gif" border="0" style="cursor:pointer;" onClick="fnvshobj(this,\'createcf\');getCreateCustomFieldForm(\'' . $module . '\',\'' . $row["fieldid"] . '\',\'' . $tabid . '\',\'' . $row["uitype"] . '\')" alt="' . $app_strings['LBL_EDIT'] . '" title="' . $app_strings['LBL_EDIT'] . '"/> | <img style="cursor:pointer;" onClick="deleteCustomField(' . $row["fieldid"] . ',\'' . $module . '\', \'' . $row["columnname"] . '\', \'' . $row["uitype"] . '\')" src="' . $image_path . 'delete.gif" border="0" alt="' . $app_strings['LBL_DELETE'] . '" title="' . $app_strings['LBL_DELETE'] . '"/></a>'; $cflist[] = $cf_element; $count++; } while ($row = $adb->fetch_array($result)); } return $cflist; }
/** * To get userid and username of vtiger_users in hierarchy level * @param $id -- The user id :: Type integer * @returns $user_details -- Array in the following format: * $user_details=Array($userid1=>$username, $userid2=>$username,............,$useridn=>$username); */ function getSharingUserName($id) { global $adb, $current_user; $user_details = array(); $assigned_user_id = $current_user->id; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid('Calendar')] == 3 or $defaultOrgSharingPermission[getTabid('Calendar')] == 0)) { $role_seq = implode($parent_roles, "::"); $query = "select id as id,user_name as user_name from vtiger_users where id=? and status='Active' union select vtiger_user2role.userid as id,vtiger_users.user_name as user_name from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like ? and status='Active' union select shareduserid as id,vtiger_users.user_name as user_name from vtiger_tmp_write_user_sharing_per inner join vtiger_users on vtiger_users.id=vtiger_tmp_write_user_sharing_per.shareduserid where status='Active' and vtiger_tmp_write_user_sharing_per.userid=? and vtiger_tmp_write_user_sharing_per.tabid=9"; $params = array($current_user->id, $role_seq . "::%", $current_user->id); if (!empty($assigned_user_id)) { $query .= " OR id=?"; array_push($params, $assigned_user_id); } $query .= " order by user_name ASC"; $result = $adb->pquery($query, $params, true, "Error filling in user array: "); while ($row = $adb->fetchByAssoc($result)) { $temp_result[$row['id']] = $row['user_name']; } $user_details =& $temp_result; unset($user_details[$id]); } else { $user_details = get_user_array(FALSE, "Active", $id); unset($user_details[$id]); } return $user_details; }
function getFieldInfo($fieldName, $moduleName, $column) { $moduleTabId = getTabid($moduleName); $db = PearDatabase::getInstance(); $sql = "SELECT * FROM vtiger_field WHERE tabid = {$moduleTabId} AND fieldname = '{$fieldName}'"; $result = $db->query($sql, true); return $db->query_result($result, 0, $column); }
private function addRelationModue() { global $adb; $id = $adb->getUniqueID('vtiger_relatedlists'); $projectTabId = getTabid('Project'); $potentialsTabId = getTabid('Potentials'); $adb->query("INSERT INTO vtiger_relatedlists VALUES ({$id}, {$potentialsTabId}, {$projectTabId}, 'get_related_list', 16, 'Projects', 0, 'ADD,SELECT')", true); }
/** * This function returns the ec_blocks and its related information for given module. * Input Parameter are $module - module name, $disp_view = display view (edit,detail or create),$mode - edit, $col_fields - * column ec_fields/ * This function returns an array */ function getBlocksForQuickEdit($module, $disp_view, $mode, $col_fields = '', $display_type_check) { global $log; $log->debug("Entering getBlocksForQuickEdit() method ..."); global $adb, $current_user; global $mod_strings; $tabid = getTabid($module); $block_detail = array(); $getBlockinfo = ""; $prev_header = ""; $query = "select blockid,blocklabel,show_title from ec_blocks where tabid={$tabid} and {$disp_view}=0 and visible = 0 order by sequence"; $result = $adb->query($query); $noofrows = $adb->num_rows($result); $blockid_list = '('; for ($i = 0; $i < $noofrows; $i++) { $blockid = $adb->query_result($result, $i, "blockid"); if ($i != 0) { $blockid_list .= ', '; } $blockid_list .= $blockid; $block_label[$blockid] = $adb->query_result($result, $i, "blocklabel"); } $blockid_list .= ')'; //retreive the ec_profileList from database require 'user_privileges/user_privileges_' . $current_user->id . '.php'; if ($is_admin == true) { $sql = "SELECT ec_field.* FROM ec_field INNER JOIN ec_def_org_field ON ec_def_org_field.fieldid=ec_field.fieldid AND ec_def_org_field.visible=0 WHERE ec_field.tabid=" . $tabid . " AND ec_field.block IN " . $blockid_list . " AND " . $display_type_check . " ORDER BY block,sequence"; } else { $profileList = getCurrentUserProfileList(); $sql = "SELECT ec_field.*,ec_profile2field.readonly as profile_readonly FROM ec_field INNER JOIN ec_profile2field ON ec_profile2field.fieldid=ec_field.fieldid INNER JOIN ec_def_org_field ON ec_def_org_field.fieldid=ec_field.fieldid WHERE ec_field.tabid=" . $tabid . " AND ec_field.block IN " . $blockid_list . " AND " . $display_type_check . " AND ec_def_org_field.visible=0 AND ec_profile2field.visible=0 AND ec_profile2field.profileid IN " . $profileList . " ORDER BY block,sequence"; } $result = $adb->query($sql); $getBlockInfo = getBlockInformation($module, $result, $col_fields, $tabid, $block_label, $mode); $index_count = 1; $max_index = 0; if (!isset($getBlockInfo)) { $getBlockInfo = array(); } foreach ($getBlockInfo as $label => $contents) { $no_rows = count($contents); $index_count = $max_index + 1; foreach ($contents as $block_row => $elements) { $max_index = $no_rows + $index_count; for ($i = 0; $i < count($elements); $i++) { if (isset($getBlockInfo[$label][$block_row][$i]) && sizeof($getBlockInfo[$label][$block_row][$i]) != 0) { if ($i == 0) { $getBlockInfo[$label][$block_row][$i][] = array($index_count); } else { $getBlockInfo[$label][$block_row][$i][] = array($max_index); } } } $index_count++; } } $log->debug("Exiting getBlocksForQuickEdit method ..."); return $getBlockInfo; }
/** **Function to populate the default required data during installation */ function create_defautdata($is_upgrade = false) { //$this->db->query( "CREATE SEQUENCE ".$sequence." INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1;"); $query = "select tabid from ec_tab where name='Contacts'"; $result = $this->db->query($query); $noofrows = $this->db->num_rows($result); if ($noofrows > 0) { $tab_id = $this->db->query_result($result, 0, "tabid"); } else { //$tab_id = $this->db->getUniqueID("ec_tab"); $query = "select max(tabid) as tabid from ec_tab"; $result = $this->db->query($query); $tab_id = $this->db->query_result($result, 0, "tabid") + 1; $this->db->query("insert into ec_tab values (" . $tab_id . ",'Contacts',0," . $tab_id . ",'Contacts',null,null,1,1)"); } //echo "tabid:".$tab_id."<br>"; $combo_strings = array(); include "define_fields.php"; if (!isset($block_id1) || empty($block_id1)) { $block_id1 = $this->get_block_id($tab_id); } include 'modules/Contacts/ModuleConfig.php'; $this->insert_def_org_modulefield($tab_id); $this->db->query("insert into ec_entityname values(" . $tab_id . ",'Contacts','ec_contacts','contactname','contactsid')"); //custom view //$query = "select max(cvid) as cvid from ec_customview"; //$result = $this->db->query($query); //$cvid = $this->db->query_result($result,0,"cvid") + 1; $cvid = $this->db->getUniqueID("ec_customview"); $customview_sql = "INSERT INTO ec_customview(cvid,viewname,setdefault,setmetrics,entitytype,setpublic) VALUES('" . $cvid . "','所有','1','0','Contacts','0')"; $this->db->query($customview_sql); $customview_sql = "INSERT INTO ec_cvcolumnlist VALUES (" . $cvid . ", 0, 'ec_contacts:contactname:contactname:Contacts_Contact_Name:V')"; $this->db->query($customview_sql); $customview_sql = "INSERT INTO ec_cvcolumnlist VALUES (" . $cvid . ", 1, 'ec_contacts:smownerid:assigned_user_id:Contacts_Assigned_To:V')"; $this->db->query($customview_sql); $customview_sql = "INSERT INTO ec_cvcolumnlist VALUES (" . $cvid . ", 2, '')"; $this->db->query($customview_sql); $customview_sql = "INSERT INTO ec_cvcolumnlist VALUES (" . $cvid . ", 3, '')"; $this->db->query($customview_sql); $customview_sql = "INSERT INTO ec_cvcolumnlist VALUES (" . $cvid . ", 4, '')"; $this->db->query($customview_sql); $customview_sql = "INSERT INTO ec_cvcolumnlist VALUES (" . $cvid . ", 5, '')"; $this->db->query($customview_sql); $customview_sql = "INSERT INTO ec_cvcolumnlist VALUES (" . $cvid . ", 6, '')"; $this->db->query($customview_sql); $customview_sql = "INSERT INTO ec_cvcolumnlist VALUES (" . $cvid . ", 7, '')"; $this->db->query($customview_sql); $customview_sql = "INSERT INTO ec_cvcolumnlist VALUES (" . $cvid . ", 8, '')"; $this->db->query($customview_sql); //parent tab id:首页 1,客户管理 2,销售 3,售后服务 4,库存管理 5,财务管理 6,统计分析 7 $this->db->query("insert into ec_parenttabrel values ('" . $module_parenttabid . "'," . $tab_id . ",'" . $module_displayorder . "')"); if (isset($module_enable_account) && $module_enable_account) { $this->db->query("insert into ec_relatedlists values (" . $this->db->getUniqueID('ec_relatedlists') . "," . getTabid("Accounts") . "," . $tab_id . ",'get_generalmodules',4,'Contacts',0)"); } foreach ($combo_strings as $key => $value) { insertPicklistValues($value, $key); } }
public function process($ModuleName, $ID, $record_form, $config) { $db = PearDatabase::getInstance(); $userPrivModel = Users_Privileges_Model::getCurrentUserPrivilegesModel(); if (!isset($ID) || $ID == 0 || $ID == '' || !$userPrivModel->hasModuleActionPermission(getTabid($config['modules']), 'EditView')) { return array('save_record' => true); } return array('save_record' => false, 'type' => 1, 'module' => $config['modules']); }
/** * Function to get customfield entries * @param string $module - Module name * return array $cflist - customfield entries */ function getLayoutListEntries($module) { $tabid = getTabid($module); global $adb; global $theme; global $current_language; global $app_strings; if ($module == "Events") { $module = "Calendar"; } $cur_module_strings = return_specified_module_language($current_language, $module); $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $query = "select * from ec_blocks where tabid='" . $tabid . "' order by sequence"; $block_result = $adb->query($query); $blcoklist = array(); while ($block_row = $adb->fetch_array($block_result)) { $blockid = $block_row['blockid']; $blocklabel = $block_row['blocklabel']; if (isset($cur_module_strings[$blocklabel])) { $blocklabel = $cur_module_strings[$blocklabel]; } $dbQuery = "select ec_field.fieldid,ec_field.fieldlabel,ec_field.block,ec_field.sequence,ec_field.typeofdata from ec_field inner join ec_def_org_field on ec_def_org_field.fieldid=ec_field.fieldid where ec_def_org_field.visible=0 and ec_field.tabid={$tabid} and displaytype in(1,2,4) and ec_field.block='" . $blockid . "' order by ec_field.block,ec_field.sequence"; $result = $adb->query($dbQuery); $row = $adb->fetch_array($result); $count = 1; $cflist = array(); if ($row != '') { do { $cf_element = array(); $cf_element['no'] = $count; if (isset($cur_module_strings[$row["fieldlabel"]])) { $cf_element['fieldlabel'] = $cur_module_strings[$row["fieldlabel"]]; } elseif (isset($app_strings[$row["fieldlabel"]])) { $cf_element['fieldlabel'] = $app_strings[$row["fieldlabel"]]; } else { $cf_element['fieldlabel'] = $row["fieldlabel"]; } $cf_element['sequence'] = $row["sequence"]; $typeofdata = $row["typeofdata"]; if (strpos($typeofdata, "~M") > -1) { $typeofdata = "true"; } else { $typeofdata = "false"; } $cf_element['typeofdata'] = $typeofdata; //getCreateCustomBlockForm(customModule,blockid,tabid,label,order) $cf_element['tool'] = '<img src="' . $image_path . 'editfield.gif" border="0" style="cursor:pointer;" onClick="fnvshobj(this,\'createLayout\');getFieldLayoutForm(\'' . $module . '\',\'' . $row["fieldid"] . '\',\'' . $tabid . '\',\'' . $cf_element['fieldlabel'] . '\',\'' . $blocklabel . '\',\'' . $row["sequence"] . '\',\'' . $row['block'] . '\',\'' . $typeofdata . '\')" alt="' . $app_strings['LNK_EDIT'] . '" title="' . $app_strings['LNK_EDIT'] . '"/>'; $cflist[] = $cf_element; $count++; } while ($row = $adb->fetch_array($result)); } $blcoklist[$blocklabel] = $cflist; } return $blcoklist; }
public static function getTablesAll() { $modulesFields = self::getAllField(); foreach ($modulesFields as $key => $fields) { foreach ($fields as $field) { $instance[$key][] = Vtiger_Functions::getModuleFieldInfo(getTabid($field['module']), $field['nameField']); } } return $instance; }
/** * Invoked when special actions are performed on the module. * @param String Module name * @param String Event Type */ function vtlib_handler($moduleName, $eventType) { require_once 'include/utils/utils.php'; global $adb, $mod_strings; if ($eventType == 'module.postinstall') { $portalmodules = array("HelpDesk", "Faq", "Invoice", "Quotes", "Products", "Services", "Documents", "Contacts", "Accounts"); $query = "SELECT max(sequence) AS max_tabseq FROM vtiger_customerportal_tabs"; $res = $adb->pquery($query, array()); $tabseq = $adb->query_result($res, 0, 'max_tabseq'); $i = ++$tabseq; foreach ($portalmodules as $modules) { ++$i; $tabid = getTabid($modules); $adb->query("INSERT INTO vtiger_customerportal_tabs (tabid,visible,sequence) VALUES ({$tabid},1,{$i})"); } for ($j = 0; $j < count($portalmodules); $j++) { $tabid = getTabid($portalmodules[$j]); $adb->query("INSERT INTO vtiger_customerportal_prefs(tabid,prefkey,prefvalue) VALUES ({$tabid},'showrelatedinfo',1)"); } $adb->query("INSERT INTO vtiger_customerportal_prefs(tabid,prefkey,prefvalue) VALUES (0,'userid',1)"); // Mark the module as Standard module $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($moduleName)); $fieldid = $adb->getUniqueID('vtiger_settings_field'); $blockid = getSettingsBlockId('LBL_OTHER_SETTINGS'); $seq_res = $adb->pquery("SELECT max(sequence) AS max_seq FROM vtiger_settings_field WHERE blockid = ?", array($blockid)); if ($adb->num_rows($seq_res) > 0) { $cur_seq = $adb->query_result($seq_res, 0, 'max_seq'); if ($cur_seq != null) { $seq = $cur_seq + 1; } } $adb->pquery('INSERT INTO vtiger_settings_field(fieldid, blockid, name, iconpath, description, linkto, sequence) VALUES (?,?,?,?,?,?,?)', array($fieldid, $blockid, 'LBL_CUSTOMER_PORTAL', 'portal_icon.png', 'PORTAL_EXTENSION_DESCRIPTION', 'index.php?module=CustomerPortal&action=index&parenttab=Settings', $seq)); } else { if ($eventType == 'module.disabled') { // TODO Handle actions when this module is disabled. } else { if ($eventType == 'module.enabled') { // TODO Handle actions when this module is enabled. } else { if ($eventType == 'module.preuninstall') { // TODO Handle actions when this module is about to be deleted. } else { if ($eventType == 'module.preupdate') { // TODO Handle actions before this module is updated. } else { if ($eventType == 'module.postupdate') { // TODO Handle actions after this module is updated. } } } } } } }
/** function used to get the query which will list the permitted fields * @param string $module - module name * @param string $disp_view - view name, this may be create_view, edit_view or detail_view * @return string $sql - query to get the list of fields which are permitted to the current user */ function getPermittedFieldsQuery($module, $disp_view) { global $adb, $log; $log->debug("Entering into the function getPermittedFieldsQuery()"); //To get the permitted blocks $blockid_list = getPermittedBlocks($module, $disp_view); $tabid = getTabid($module); $sql = "SELECT ec_field.columnname, ec_field.fieldlabel, ec_field.tablename FROM ec_field inner join ec_def_org_field on ec_def_org_field.fieldid=ec_field.fieldid left join ec_blocks on ec_blocks.blockid=ec_field.block WHERE ec_def_org_field.visible=0 and ec_field.tabid=" . $tabid . " AND ec_field.block IN {$blockid_list} AND ec_field.displaytype IN (1,2,4) ORDER BY ec_blocks.sequence,ec_field.sequence"; $log->debug("Exit from the function getPermittedFieldsQuery()."); return $sql; }
public static function isLockedForModule($module) { $adb = PearDatabase::getInstance(); if (Vtiger_Utils::CheckTable('vtiger_import_locks')) { $lockResult = $adb->pquery('SELECT * FROM vtiger_import_locks WHERE tabid=?', array(getTabid($module))); if ($lockResult && $adb->num_rows($lockResult) > 0) { $lockInfo = $adb->query_result_rowdata($lockResult, 0); return $lockInfo; } } return null; }
public static function getImportInfo($module, $user) { $db = PearDatabase::getInstance(); if (Vtiger_Utils::CheckTable('vtiger_import_queue')) { $queueResult = $db->pquery('SELECT * FROM vtiger_import_queue WHERE tabid=? AND userid=?', array(getTabid($module), $user->id)); if ($queueResult && $db->num_rows($queueResult) > 0) { $rowData = $db->raw_query_result_rowdata($queueResult, 0); return self::getImportInfoFromResult($rowData); } } return null; }
function process(Mobile_API_Request $request) { global $current_user, $adb, $currentModule; $current_user = $this->getActiveUser(); $response = new Mobile_API_Response(); $record = $request->get('record'); $relatedmodule = $request->get('relatedmodule'); $currentPage = $request->get('page', 0); // Input validation if (empty($record)) { $response->setError(1001, 'Record id is empty'); return $response; } $recordid = vtws_getIdComponents($record); $recordid = $recordid[1]; $module = Mobile_WS_Utils::detectModulenameFromRecordId($record); // Initialize global variable $currentModule = $module; $functionHandler = Mobile_WS_Utils::getRelatedFunctionHandler($module, $relatedmodule); if ($functionHandler) { $sourceFocus = CRMEntity::getInstance($module); $relationResult = call_user_func_array(array($sourceFocus, $functionHandler), array($recordid, getTabid($module), getTabid($relatedmodule))); $query = $relationResult['query']; $querySEtype = "vtiger_crmentity.setype as setype"; if ($relatedmodule == 'Calendar') { $querySEtype = "vtiger_activity.activitytype as setype"; } $query = sprintf("SELECT vtiger_crmentity.crmid, {$querySEtype} %s", substr($query, stripos($query, 'FROM'))); $queryResult = $adb->query($query); // Gather resolved record id's $relatedRecords = array(); while ($row = $adb->fetch_array($queryResult)) { $targetSEtype = $row['setype']; if ($relatedmodule == 'Calendar') { if ($row['setype'] != 'Task' && $row['setype'] != 'Emails') { $targetSEtype = 'Events'; } else { $targetSEtype = $relatedmodule; } } $relatedRecords[] = sprintf("%sx%s", Mobile_WS_Utils::getEntityModuleWSId($targetSEtype), $row['crmid']); } // Perform query to get record information with grouping $wsquery = sprintf("SELECT * FROM %s WHERE id IN ('%s');", $relatedmodule, implode("','", $relatedRecords)); $newRequest = new Mobile_API_Request(); $newRequest->set('module', $relatedmodule); $newRequest->set('query', $wsquery); $newRequest->set('page', $currentPage); $response = parent::process($newRequest); } return $response; }
function __construct() { global $log, $currentModule; $this->column_fields = getColumnFields($currentModule); $this->db = PearDatabase::getInstance(); $this->log = $log; $sql = 'SELECT 1 FROM vtiger_field WHERE uitype=69 and tabid = ?'; $tabid = getTabid($currentModule); $result = $this->db->pquery($sql, array($tabid)); if ($result and $this->db->num_rows($result) == 1) { $this->HasDirectImageField = true; } }