Пример #1
0
/**
 * 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'] . '"/>&nbsp;|&nbsp;<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;
}
Пример #2
0
/**
 * Function to get customfield entries
 * @param string $module - Module name
 * return array  $cflist - customfield entries
 */
function getCFListEntries($module)
{
    global $adb, $app_strings, $theme, $smarty, $log;
    $tabid = getTabid($module);
    if ($module == 'Calendar') {
        $tabid = array(9, 16);
    }
    $theme_path = "themes/" . $theme . "/";
    $image_path = "themes/images/";
    $dbQuery = "select fieldid,columnname,fieldlabel,uitype,displaytype,block,vtiger_convertleadmapping.cfmid,tabid from vtiger_field left join vtiger_convertleadmapping on  vtiger_convertleadmapping.leadfid = vtiger_field.fieldid where tabid in (" . generateQuestionMarks($tabid) . ") and vtiger_field.presence in (0,2) and generatedtype = 2 order by sequence";
    $result = $adb->pquery($dbQuery, array($tabid));
    $row = $adb->fetch_array($result);
    $count = 1;
    $cflist = array();
    if ($row != '') {
        do {
            $cf_element = array();
            $cf_element['no'] = $count;
            $cf_element['label'] = getTranslatedString($row["fieldlabel"], $module);
            $fld_type_name = getCustomFieldTypeName($row["uitype"]);
            $cf_element['type'] = $fld_type_name;
            $cf_tab_id = $row["tabid"];
            if ($module == 'Leads') {
                $mapping_details = getListLeadMapping($row["cfmid"]);
                $cf_element[] = $mapping_details['accountlabel'];
                $cf_element[] = $mapping_details['contactlabel'];
                $cf_element[] = $mapping_details['potentiallabel'];
            }
            if ($module == 'Calendar') {
                if ($cf_tab_id == '9') {
                    $cf_element['activitytype'] = getTranslatedString('Task', $module);
                } else {
                    $cf_element['activitytype'] = getTranslatedString('Event', $module);
                }
            }
            if ($module == 'Calendar') {
                $cf_element['tool'] = '&nbsp;<img style="cursor:pointer;" onClick="deleteCustomField(' . $row["fieldid"] . ',\'' . $module . '\', \'' . $row["columnname"] . '\', \'' . $row["uitype"] . '\')" src="' . vtiger_imageurl('delete.gif', $theme) . '" border="0"  alt="' . $app_strings['LBL_DELETE_BUTTON_LABEL'] . '" title="' . $app_strings['LBL_DELETE_BUTTON_LABEL'] . '"/></a>';
            }
            $cflist[] = $cf_element;
            $count++;
        } while ($row = $adb->fetch_array($result));
    }
    return $cflist;
}
Пример #3
0
/**
 * Function to get customfield entries for leads
 * @param string $module - Module name
 * return array  $cflist - customfield entries
 */
function getCFLeadMapping($module)
{
    global $adb, $app_strings, $theme, $smarty, $log;
    $tabid = getTabid($module);
    $theme_path = "themes/" . $theme . "/";
    $image_path = "themes/images/";
    $dbQuery = "SELECT fieldid,columnname,fieldlabel,uitype,displaytype,block,vtiger_convertleadmapping.cfmid,vtiger_convertleadmapping.editable,tabid FROM vtiger_convertleadmapping LEFT JOIN vtiger_field\n\t\t\t\tON  vtiger_field.fieldid=vtiger_convertleadmapping.leadfid \n\t\t\t\tWHERE tabid IN (" . generateQuestionMarks($tabid) . ")\n\t\t\t\tAND vtiger_field.presence IN (0,2)\n\t\t\t\tAND generatedtype IN (1,2)\n\t\t\t\tAND vtiger_field.fieldname NOT IN('assigned_user_id','createdtime','modifiedtime','lead_no','modifiedby','campaignrelstatus')\n\t\t\t\tORDER BY vtiger_field.fieldlabel";
    $result = $adb->pquery($dbQuery, array($tabid));
    $row = $adb->fetch_array($result);
    $count = 1;
    $cflist = array();
    if ($row != '') {
        do {
            $cf_element = array();
            $cf_element['map']['no'] = $count;
            $cf_element['map']['label'] = getTranslatedString($row["fieldlabel"], $module);
            $fld_type_name = getCustomFieldTypeName($row["uitype"]);
            $cf_element['map']['type'] = $fld_type_name;
            $cf_tab_id = $row["tabid"];
            $cf_element['cfmid'] = $row["cfmid"];
            $cf_element['editable'] = $row["editable"];
            if ($module == 'Leads') {
                $mapping_details = getListLeadMapping($row["cfmid"]);
                $cf_element['map'][] = $mapping_details['accountlabel'];
                $cf_element['map'][] = $mapping_details['contactlabel'];
                $cf_element['map'][] = $mapping_details['potentiallabel'];
            }
            $cflist[] = $cf_element;
            $count++;
        } while ($row = $adb->fetch_array($result));
    }
    return $cflist;
}
Пример #4
0
/**
 * Function to get customfield entries
 * @param string $module - Module name
 * return array  $cflist - customfield entries
 */
function getFieldListEntries($module)
{
    $tabid = getTabid($module);
    global $adb, $smarty, $log, $current_user;
    global $theme;
    $theme_path = "themes/" . $theme . "/";
    $image_path = "themes/images/";
    $dbQuery = "select vtiger_blocks.*,vtiger_tab.presence as tabpresence  from vtiger_blocks" . " inner join vtiger_tab on vtiger_tab.tabid = vtiger_blocks.tabid" . " where vtiger_blocks.tabid=?  and vtiger_tab.presence = 0 order by sequence";
    $result = $adb->pquery($dbQuery, array($tabid));
    $row = $adb->fetch_array($result);
    $focus = CRMEntity::getInstance($module);
    $nonEditableUiTypes = array('4', '70');
    // To get reference field names
    require_once 'include/Webservices/Utils.php';
    $handler = vtws_getModuleHandlerFromName($module, $current_user);
    $meta = $handler->getMeta();
    $referenceFieldNames = array_keys($meta->getReferenceFieldDetails());
    $cflist = array();
    $i = 0;
    if ($row != '') {
        do {
            if ($row["blocklabel"] == 'LBL_CUSTOM_INFORMATION') {
                $smarty->assign("CUSTOMSECTIONID", $row["blockid"]);
            }
            if ($row["blocklabel"] == 'LBL_RELATED_PRODUCTS') {
                $smarty->assign("RELPRODUCTSECTIONID", $row["blockid"]);
            }
            if ($row["blocklabel"] == 'LBL_COMMENTS' || $row['blocklabel'] == 'LBL_COMMENT_INFORMATION') {
                $smarty->assign("COMMENTSECTIONID", $row["blockid"]);
            }
            if ($row['blocklabel'] == 'LBL_TICKET_RESOLUTION') {
                $smarty->assign("SOLUTIONBLOCKID", $row["blockid"]);
            }
            if ($row['blocklabel'] == '') {
                continue;
            }
            $cflist[$i]['tabpresence'] = $row['tabpresence'];
            $cflist[$i]['module'] = $module;
            $cflist[$i]['blocklabel'] = getTranslatedString($row["blocklabel"], $module);
            $cflist[$i]['blockid'] = $row["blockid"];
            $cflist[$i]['display_status'] = $row["display_status"];
            $cflist[$i]['tabid'] = $tabid;
            $cflist[$i]['blockselect'] = $row["blockid"];
            $cflist[$i]['sequence'] = $row["sequence"];
            $cflist[$i]['iscustom'] = $row["iscustom"];
            if ($module != 'Invoices' && $module != 'Quotes' && $module != 'SalesOrder' && $module != 'Invoice') {
                $sql_field = "select * from  vtiger_field where block=? and vtiger_field.displaytype IN (1,2,4) order by sequence";
                $sql_field_params = array($row["blockid"]);
            } else {
                $sql_field = "select * from  vtiger_field where block=? and (vtiger_field.fieldlabel!='Total' and vtiger_field.fieldlabel!='Sub Total' and vtiger_field.fieldlabel!='Tax') and vtiger_field.displaytype IN (1,2,4) order by sequence";
                $sql_field_params = array($row["blockid"]);
            }
            $result_field = $adb->pquery($sql_field, $sql_field_params);
            $row_field = $adb->fetch_array($result_field);
            if ($row_field != '') {
                $cf_element = array();
                $cf_hidden_element = array();
                $count = 0;
                $hiddencount = 0;
                do {
                    $fieldid = $row_field['fieldid'];
                    $presence = $row_field['presence'];
                    $fieldname = $row_field['fieldname'];
                    $customfieldflag = InStrCount($row_field['fieldname'], 'cf_', true);
                    $quickcreate = $row_field['quickcreate'];
                    $massedit = $row_field['masseditable'];
                    $typeofdata = $row_field['typeofdata'];
                    $displaytype = $row_field['displaytype'];
                    $uitype = $row_field['uitype'];
                    $fld_type_name = getCustomFieldTypeName($row_field['uitype']);
                    $defaultValue = $row_field['defaultvalue'];
                    if (!empty($defaultValue) && ($uitype == '5' || $uitype == '6' || $uitype == '23')) {
                        $defaultValue = getValidDisplayDate($defaultValue);
                    }
                    $fieldlabel = getTranslatedString($row_field['fieldlabel'], $module);
                    $defaultPermitted = true;
                    $strictlyMandatory = false;
                    if (isset($focus->mandatory_fields) && !empty($focus->mandatory_fields) && in_array($fieldname, $focus->mandatory_fields)) {
                        $strictlyMandatory = true;
                        $defaultPermitted = false;
                    } elseif (in_array($uitype, $nonEditableUiTypes) || $displaytype == 2) {
                        $strictlyMandatory = true;
                        $defaultPermitted = false;
                    }
                    if (in_array($fieldname, $referenceFieldNames)) {
                        $defaultPermitted = false;
                    }
                    $visibility = getFieldInfo($fieldname, $typeofdata, $quickcreate, $massedit, $presence, $strictlyMandatory, $customfieldflag, $displaytype, $uitype);
                    $allValues = array();
                    if (in_array($uitype, array('15', '16', '33'))) {
                        $allValues = getAllPickListValues($fieldname);
                    }
                    if ($presence == 0 || $presence == 2) {
                        $cf_element[$count]['fieldselect'] = $fieldid;
                        $cf_element[$count]['blockid'] = $row['blockid'];
                        $cf_element[$count]['tabid'] = $tabid;
                        $cf_element[$count]['no'] = $count;
                        $cf_element[$count]['label'] = $fieldlabel;
                        $cf_element[$count]['fieldlabel'] = $row_field['fieldlabel'];
                        $cf_element[$count]['type'] = $fld_type_name;
                        $cf_element[$count]['typeofdata'] = $typeofdata;
                        $cf_element[$count]['uitype'] = $uitype;
                        $cf_element[$count]['columnname'] = $row_field['columnname'];
                        $cf_element[$count]['defaultvalue'] = array('permitted' => $defaultPermitted, 'value' => $defaultValue, '_allvalues' => $allValues);
                        $cf_element[$count] = array_merge($cf_element[$count], $visibility);
                        $count++;
                    } else {
                        $cf_hidden_element[$hiddencount]['fieldselect'] = $fieldid;
                        $cf_hidden_element[$hiddencount]['blockid'] = $row['blockid'];
                        $cf_hidden_element[$hiddencount]['tabid'] = $tabid;
                        $cf_hidden_element[$hiddencount]['no'] = $hiddencount;
                        $cf_hidden_element[$hiddencount]['label'] = $fieldlabel;
                        $cf_hidden_element[$hiddencount]['fieldlabel'] = $row_field['fieldlabel'];
                        $cf_hidden_element[$hiddencount]['type'] = $fld_type_name;
                        $cf_hidden_element[$hiddencount]['typeofdata'] = $typeofdata;
                        $cf_hidden_element[$hiddencount]['uitype'] = $uitype;
                        $cf_hidden_element[$hiddencount]['columnname'] = $row_field['columnname'];
                        $cf_hidden_element[$hiddencount]['defaultvalue'] = array('permitted' => $defaultPermitted, 'value' => $defaultValue, '_allvalues' => $allValues);
                        $cf_hidden_element[$hiddencount] = array_merge($cf_hidden_element[$hiddencount], $visibility);
                        $hiddencount++;
                    }
                } while ($row_field = $adb->fetch_array($result_field));
                $cflist[$i]['no'] = $count;
                $cflist[$i]['hidden_count'] = $hiddencount;
            } else {
                $cflist[$i]['no'] = 0;
            }
            $query_fields_not_in_block = 'select fieldid,fieldlabel,block from vtiger_field ' . 'inner join vtiger_blocks on vtiger_field.block=vtiger_blocks.blockid ' . 'where vtiger_field.block != ? and vtiger_blocks.blocklabel not in ("LBL_TICKET_RESOLUTION","LBL_COMMENTS","LBL_COMMENT_INFORMATION") ' . 'AND vtiger_field.tabid = ? and vtiger_field.displaytype IN (1,2,4) order by vtiger_field.sequence';
            $params = array($row['blockid'], $tabid);
            $fields = $adb->pquery($query_fields_not_in_block, $params);
            $row_field = $adb->fetch_array($fields);
            if ($row_field != '') {
                $movefields = array();
                $movefieldcount = 0;
                do {
                    $movefields[$movefieldcount]['fieldid'] = $row_field['fieldid'];
                    $movefields[$movefieldcount]['fieldlabel'] = getTranslatedString($row_field['fieldlabel'], $module);
                    $movefieldcount++;
                } while ($row_field = $adb->fetch_array($fields));
                $cflist[$i]['movefieldcount'] = $movefieldcount;
            } else {
                $cflist[$i]['movefieldcount'] = 0;
            }
            $cflist[$i]['field'] = $cf_element;
            $cflist[$i]['hiddenfield'] = $cf_hidden_element;
            $cflist[$i]['movefield'] = $movefields;
            $cflist[$i]['hascustomtable'] = $focus->customFieldTable;
            unset($cf_element);
            unset($cf_hidden_element);
            unset($movefields);
            $i++;
        } while ($row = $adb->fetch_array($result));
    }
    return $cflist;
}
Пример #5
0
$tabid = vtlib_purify($_REQUEST['tabid']);
$mode = vtlib_purify($_REQUEST['mode']);
$fieldid = vtlib_purify($_REQUEST['fieldselect']);
if (isset($_REQUEST['uitype']) && $_REQUEST['uitype'] != '') {
    $uitype = vtlib_purify($_REQUEST['uitype']);
} else {
    $uitype = 1;
}
$readonly = '';
$smarty = new vtigerCRM_Smarty();
if ($_REQUEST['mode'] == 'edit') {
    $mode = 'edit';
    $customfield_columnname = getCustomFieldData($tabid, $fieldid, 'columnname');
    $customfield_typeofdata = getCustomFieldData($tabid, $fieldid, 'typeofdata');
    $customfield_fieldlabel = getCustomFieldData($tabid, $fieldid, 'fieldlabel');
    $customfield_typename = getCustomFieldTypeName($uitype);
    $fieldtype_lengthvalue = getFldTypeandLengthValue($customfield_typename, $customfield_typeofdata);
    list($fieldtype, $fieldlength, $decimalvalue) = explode(";", $fieldtype_lengthvalue);
    $readonly = "readonly";
    $selectedvalue = $typeVal[$fieldtype];
}
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("FLD_MODULE", vtlib_purify($_REQUEST['fld_module']));
$output = '';
$combo_output = '';
$output .= '<div id="orgLay" style="display:block;" class="layerPopup"><script type="text/javascript" src="include/js/customview.js"></script>
			<form action="index.php" method="post" name="addtodb" onsubmit="VtigerJS_DialogBox.block();">
			<input type="hidden" name="module" value="Settings">
			<input type="hidden" name="fld_module" value="' . vtlib_purify($_REQUEST['fld_module']) . '">
function getModuleValues($moduleid, $module)
{
    global $adb;
    $potentialcf = array();
    switch ($module) {
        case "Accounts":
            $sql = "SELECT fieldid,fieldlabel,uitype,typeofdata,fieldname FROM vtiger_field,vtiger_tab WHERE vtiger_field.tabid=vtiger_tab.tabid\n\t\t\t\t\t\tAND generatedtype IN (1,2)\n\t\t\t\t\t\tAND vtiger_tab.name=?\n\t\t\t\t\t\tAND vtiger_field.fieldname NOT IN('assigned_user_id','createdtime','modifiedtime','lead_no','modifiedby','campaignrelstatus','account_no','account_id','contact_no','contact_id','imagename','potential_no','related_to','campaignid','accountname','email1')\n\t\t\t\t\t\tAND vtiger_field.presence in (0,2)";
            break;
        case "Contacts":
            $sql = "SELECT fieldid,fieldlabel,uitype,typeofdata,fieldname FROM vtiger_field,vtiger_tab WHERE vtiger_field.tabid=vtiger_tab.tabid\n\t\t\t\t\t\tAND generatedtype IN (1,2)\n\t\t\t\t\t\tAND vtiger_tab.name=?\n\t\t\t\t\t\tAND vtiger_field.fieldname NOT IN('assigned_user_id','createdtime','modifiedtime','lead_no','modifiedby','campaignrelstatus','account_no','account_id','contact_no','contact_id','imagename','potential_no','related_to','campaignid','firstname','email','lastname')\n\t\t\t\t\t\tAND vtiger_field.presence in (0,2)";
            break;
        case "Potentials":
            $sql = "SELECT fieldid,fieldlabel,uitype,typeofdata,fieldname FROM vtiger_field,vtiger_tab WHERE vtiger_field.tabid=vtiger_tab.tabid\n\t\t\t\t\t\tAND generatedtype IN (1,2)\n\t\t\t\t\t\tAND vtiger_tab.name=?\n\t\t\t\t\t\tAND vtiger_field.fieldname NOT IN('assigned_user_id','createdtime','modifiedtime','lead_no','modifiedby','campaignrelstatus','account_no','account_id','contact_no','contact_id','imagename','potential_no','related_to','campaignid','potentialname')\n\t\t\t\t\t\tAND vtiger_field.presence in (0,2)";
            break;
        case 'Leads':
            $sql = "SELECT fieldid,fieldlabel,uitype,typeofdata,fieldname FROM vtiger_field,vtiger_tab WHERE vtiger_field.tabid=vtiger_tab.tabid\n\t\t\t\t\t\tAND generatedtype IN (1,2)\n\t\t\t\t\t\tAND vtiger_tab.name=?\n\t\t\t\t\t\tAND vtiger_field.fieldname NOT IN('assigned_user_id','createdtime','modifiedtime','lead_no','modifiedby','campaignrelstatus')\n\t\t\t\t\t\tAND vtiger_field.presence in (0,2)";
            break;
    }
    $result = $adb->pquery($sql, array($module));
    $noofrows = $adb->num_rows($result);
    for ($i = 0; $i < $noofrows; $i++) {
        $module_field['fieldid'] = $adb->query_result($result, $i, "fieldid");
        $module_field['fieldlabel'] = getTranslatedString($adb->query_result($result, $i, "fieldlabel"), $module);
        $module_field['typeofdata'] = $adb->query_result($result, $i, "typeofdata");
        $module_field['fieldtype'] = getCustomFieldTypeName($adb->query_result($result, $i, "uitype"));
        if ($module_field['fieldid'] == $moduleid) {
            $module_field['selected'] = "selected";
        } else {
            $module_field['selected'] = "";
        }
        $module_cfelement[] = $module_field;
    }
    return $module_cfelement;
}
Пример #7
0
/**
 * Function to get leads mapping custom fields
 * return array   $leadcf - mapping custom fields
 */
function customFieldMappings()
{
    global $adb;
    $convert_sql = "select vtiger_convertleadmapping.*,uitype,fieldlabel,typeofdata from vtiger_convertleadmapping left join vtiger_field on vtiger_field.fieldid = vtiger_convertleadmapping.leadfid and vtiger_field.presence in (0,2)";
    $convert_result = $adb->pquery($convert_sql, array());
    $no_rows = $adb->num_rows($convert_result);
    for ($j = 0; $j < $no_rows; $j++) {
        $leadid = $adb->query_result($convert_result, $j, "leadfid");
        $accountid = $adb->query_result($convert_result, $j, "accountfid");
        $contactid = $adb->query_result($convert_result, $j, "contactfid");
        $potentialid = $adb->query_result($convert_result, $j, "potentialfid");
        $lead_field['sno'] = $j + 1;
        $lead_field['leadid'] = getTranslatedString($adb->query_result($convert_result, $j, "fieldlabel"), 'Leads');
        $lead_field['typeofdata'] = $adb->query_result($convert_result, $j, "typeofdata");
        $lead_field['fieldtype'] = getCustomFieldTypeName($adb->query_result($convert_result, $j, "uitype"));
        $lead_field['account'] = getAccountCustomValues($leadid, $accountid);
        $lead_field['contact'] = getContactCustomValues($leadid, $contactid);
        $lead_field['potential'] = getPotentialCustomValues($leadid, $potentialid);
        $leadcf[] = $lead_field;
    }
    return $leadcf;
}