Example #1
0
/** This function returns the detailed block information of a record in a module.
 * Param $module - module name
 * Param $block - block id
 * Param $col_fields - column vtiger_fields array for the module
 * Param $tabid - vtiger_tab id
 * Return type is an array
 */
function getDetailBlockInformation($module, $result, $col_fields, $tabid, $block_label)
{
    global $log;
    $log->debug("Entering getDetailBlockInformation(" . $module . "," . $result . "," . $col_fields . "," . $tabid . "," . $block_label . ") method ...");
    global $adb;
    global $current_user;
    global $mod_strings;
    $label_data = array();
    $noofrows = $adb->num_rows($result);
    for ($i = 0; $i < $noofrows; $i++) {
        $fieldtablename = $adb->query_result($result, $i, "tablename");
        $fieldcolname = $adb->query_result($result, $i, "columnname");
        $uitype = $adb->query_result($result, $i, "uitype");
        $fieldname = $adb->query_result($result, $i, "fieldname");
        $fieldid = $adb->query_result($result, $i, "fieldid");
        $fieldlabel = $adb->query_result($result, $i, "fieldlabel");
        $maxlength = $adb->query_result($result, $i, "maximumlength");
        $block = $adb->query_result($result, $i, "block");
        $generatedtype = $adb->query_result($result, $i, "generatedtype");
        $tabid = $adb->query_result($result, $i, "tabid");
        $displaytype = $adb->query_result($result, $i, 'displaytype');
        $readonly = $adb->query_result($result, $i, 'readonly');
        $custfld = getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid, $module);
        if (is_array($custfld)) {
            $label_data[$block][] = array($custfld[0] => array("value" => $custfld[1], "ui" => $custfld[2], "options" => $custfld["options"], "secid" => $custfld["secid"], "link" => $custfld["link"], "cursymb" => $custfld["cursymb"], "salut" => $custfld["salut"], "notaccess" => $custfld["notaccess"], "cntimage" => $custfld["cntimage"], "isadmin" => $custfld["isadmin"], "tablename" => $fieldtablename, "fldname" => $fieldname, "fldid" => $fieldid, "displaytype" => $displaytype, "readonly" => $readonly));
        }
    }
    foreach ($label_data as $headerid => $value_array) {
        $detailview_data = array();
        for ($i = 0, $j = 0; $i < count($value_array); $j++) {
            $key2 = null;
            $keys = array_keys($value_array[$i]);
            $key1 = $keys[0];
            if (is_array($value_array[$i + 1]) && ($value_array[$i][$key1][ui] != 19 && $value_array[$i][$key1][ui] != 20)) {
                $keys = array_keys($value_array[$i + 1]);
                $key2 = $keys[0];
            }
            // Added to avoid the unique keys
            $use_key1 = $key1;
            if ($key1 == $key2) {
                $use_key1 = " " . $key1;
            }
            if ($value_array[$i][$key1][ui] != 19 && $value_array[$i][$key1][ui] != 20) {
                $detailview_data[$j] = array($use_key1 => $value_array[$i][$key1], $key2 => $value_array[$i + 1][$key2]);
                $i += 2;
            } else {
                $detailview_data[$j] = array($use_key1 => $value_array[$i][$key1]);
                $i++;
            }
        }
        $label_data[$headerid] = $detailview_data;
    }
    foreach ($block_label as $blockid => $label) {
        if ($label == '') {
            $returndata[getTranslatedString($curBlock, $module)] = array_merge((array) $returndata[getTranslatedString($curBlock, $module)], (array) $label_data[$blockid]);
        } else {
            $curBlock = $label;
            if (is_array($label_data[$blockid])) {
                $returndata[getTranslatedString($curBlock, $module)] = array_merge((array) $returndata[getTranslatedString($curBlock, $module)], (array) $label_data[$blockid]);
            }
        }
    }
    $log->debug("Exiting getDetailBlockInformation method ...");
    return $returndata;
}
function getCalendarCustomFields($tabid, $mode = 'edit', $col_fields = '')
{
    global $adb, $log, $current_user;
    $log->debug("Entering getCalendarCustomFields({$tabid}, {$mode}, {$col_fields})");
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    $isduplicate = vtlib_purify($_REQUEST['isDuplicate']);
    $calmode = vtlib_purify($_REQUEST['action']);
    $block = getBlockId($tabid, "LBL_CUSTOM_INFORMATION");
    $custparams = array($block, $tabid);
    if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
        $custquery = "select * from vtiger_field where block=? AND vtiger_field.tabid=? ORDER BY fieldid";
    } else {
        $profileList = getCurrentUserProfileList();
        $custquery = "SELECT vtiger_field.* FROM vtiger_field" . " INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid" . " INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid" . " WHERE vtiger_field.block=? AND vtiger_field.tabid=? AND vtiger_profile2field.visible=0" . " AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")";
        if ($mode == 'edit') {
            $custquery .= "  AND vtiger_profile2field.readonly = 0";
        }
        $custquery .= " GROUP BY vtiger_field.fieldid";
        array_push($custparams, $profileList);
    }
    $custresult = $adb->pquery($custquery, $custparams);
    $custFldArray = array();
    $noofrows = $adb->num_rows($custresult);
    for ($i = 0; $i < $noofrows; $i++) {
        $fieldname = $adb->query_result($custresult, $i, "fieldname");
        $fieldlabel = $adb->query_result($custresult, $i, "fieldlabel");
        $columnName = $adb->query_result($custresult, $i, "columnname");
        $uitype = $adb->query_result($custresult, $i, "uitype");
        $maxlength = $adb->query_result($custresult, $i, "maximumlength");
        $generatedtype = $adb->query_result($custresult, $i, "generatedtype");
        $typeofdata = $adb->query_result($custresult, $i, "typeofdata");
        $defaultvalue = $adb->query_result($custresult, $i, "defaultvalue");
        if (empty($col_fields[$fieldname]) && $mode != 'detail_view' && !$isduplicate && $calmode != 'EventEditView' && $calmode != 'EditView') {
            $col_fields[$fieldname] = $defaultvalue;
        }
        if ($mode == 'edit') {
            $custfld = getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, 'Calendar', $mode, $typeofdata);
        }
        if ($mode == 'detail_view') {
            $custfld = getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid);
        }
        $custFldArray[] = $custfld;
    }
    $log->debug("Exiting getCalendarCustomFields()");
    return $custFldArray;
}
Example #3
0
 }
 if (strpos($columns, 'createdtime') !== false) {
     array_push($col, 'createdtime');
 }
 if (strpos($columns, 'modifiedtime') !== false) {
     array_push($col, 'modifiedtime');
 }
 for ($j = 0; $j < sizeof($col); $j++) {
     if ($col[$j] == '') {
         continue;
     }
     $a = $adb->query("SELECT *\n                                  from vtiger_field\n                                  WHERE columnname='{$col[$j]}'" . " and tabid = '{$tabid}' ");
     $uitype = $adb->query_result($a, 0, 'uitype');
     $fieldname = $adb->query_result($a, 0, 'fieldname');
     $col_fields[$fieldname] = $adb->query_result($query, $i, $col[$j]);
     $block_info = getDetailViewOutputHtml($uitype, $fieldname, '', $col_fields, '', '', $pointing_module);
     $ret_val = $block_info[1];
     if (strpos($ret_val, 'href') !== false) {
         $pos1 = strpos($ret_val, '>');
         $first_sub = substr($ret_val, $pos1 + 1);
         $pos2 = strpos($first_sub, '<');
         $log->debug('ret_val' . $first_sub . ' ' . $pos2);
         $sec_sub = substr($first_sub, 0, $pos2);
         $ret_val = $sec_sub;
     }
     if ($uitype == '10') {
         $content[$i][$col[$j]] = $col_fields[$fieldname];
         $content[$i][$col[$j] . '_display'] = $ret_val;
     } else {
         $content[$i][$col[$j]] = $ret_val;
     }
Example #4
0
function transferForAddIntoTitle($type, $row, $CD)
{
    if ($CD["uitype"] == "66") {
        $Col_Field = array($CD["fieldname"] => $row["parent_id"]);
    } else {
        $Col_Field = array($CD["fieldname"] => $row[$CD["columnname"]]);
    }
    if ($CD["fieldname"] == "duration_hours") {
        $Col_Field["duration_minutes"] = $row["duration_minutes"];
    }
    if ($CD["fieldname"] == "contact_id") {
        $Col_Field["contact_id"] = getAssignedContactsForEvent($row["crmid"]);
        $CD["uitype"] = "1";
    }
    $Cal_Data = getDetailViewOutputHtml($CD["uitype"], $CD["fieldname"], $CD["fieldlabel"], $Col_Field, "2", $calendar_tabid, "Calendar");
    if ($CD["uitype"] == "15") {
        $value = getTranslatedString($Cal_Data[1], 'Calendar');
    } else {
        $value = $Cal_Data[1];
    }
    if ($type == "1") {
        return $Cal_Data[1];
    } else {
        return "<br><b>" . $Cal_Data[0] . "</b>: " . $value;
    }
}
Example #5
0
/** This function returns the detailed block information of a record in a module.
 * Param $module - module name
 * Param $block - block id
 * Param $col_fields - column vtiger_fields array for the module
 * Param $tabid - vtiger_tab id
 * Return type is an array
 */
function getDetailBlockInformation($module, $result, $col_fields, $tabid, $block_label)
{
    global $log, $adb, $current_user, $mod_strings;
    $log->debug("Entering getDetailBlockInformation(" . $module . "," . $result . "," . print_r($col_fields, true) . "," . $tabid . "," . print_r($block_label, true) . ") method ...");
    $label_data = array();
    $noofrows = $adb->num_rows($result);
    for ($i = 0; $i < $noofrows; $i++) {
        $fieldtablename = $adb->query_result($result, $i, "tablename");
        $fieldcolname = $adb->query_result($result, $i, "columnname");
        $uitype = $adb->query_result($result, $i, "uitype");
        $fieldname = $adb->query_result($result, $i, "fieldname");
        $fieldid = $adb->query_result($result, $i, "fieldid");
        $fieldlabel = $adb->query_result($result, $i, "fieldlabel");
        $maxlength = $adb->query_result($result, $i, "maximumlength");
        $block = $adb->query_result($result, $i, "block");
        $generatedtype = $adb->query_result($result, $i, "generatedtype");
        $tabid = $adb->query_result($result, $i, "tabid");
        $displaytype = $adb->query_result($result, $i, 'displaytype');
        $readonly = $adb->query_result($result, $i, 'readonly');
        $custfld = getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid, $module);
        if (is_array($custfld)) {
            $extendedfieldinfo = '';
            if ($custfld[2] == 10) {
                $fldmod_result = $adb->pquery('SELECT relmodule, status FROM vtiger_fieldmodulerel WHERE fieldid=
					(SELECT fieldid FROM vtiger_field, vtiger_tab WHERE vtiger_field.tabid=vtiger_tab.tabid AND fieldname=? AND name=? and vtiger_field.presence in (0,2)) order by sequence', array($fieldname, $module));
                $entityTypes = array();
                $parent_id = $col_fields[$fieldname];
                for ($index = 0; $index < $adb->num_rows($fldmod_result); ++$index) {
                    $entityTypes[] = $adb->query_result($fldmod_result, $index, 'relmodule');
                }
                if (!empty($parent_id)) {
                    if ($adb->num_rows($fldmod_result) == 1) {
                        $valueType = $adb->query_result($fldmod_result, 0, 0);
                    } else {
                        $valueType = getSalesEntityType($parent_id);
                    }
                    $displayValueArray = getEntityName($valueType, $parent_id);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $val) {
                            $displayValue = $val;
                        }
                    }
                } else {
                    $displayValue = '';
                    $valueType = '';
                    $parent_id = '';
                }
                $extendedfieldinfo = array('options' => $entityTypes, 'selected' => $valueType, 'displayvalue' => $displayValue, 'entityid' => $parent_id);
            }
            $label_data[$block][] = array($custfld[0] => array('value' => $custfld[1], "ui" => $custfld[2], 'options' => isset($custfld['options']) ? $custfld['options'] : '', 'secid' => isset($custfld['secid']) ? $custfld['secid'] : '', 'link' => isset($custfld['link']) ? $custfld['link'] : '', 'cursymb' => isset($custfld['cursymb']) ? $custfld['cursymb'] : '', 'salut' => isset($custfld['salut']) ? $custfld['salut'] : '', 'notaccess' => isset($custfld['notaccess']) ? $custfld['notaccess'] : '', 'cntimage' => isset($custfld['cntimage']) ? $custfld['cntimage'] : '', "isadmin" => $custfld["isadmin"], 'tablename' => $fieldtablename, "fldname" => $fieldname, "fldid" => $fieldid, 'displaytype' => $displaytype, "readonly" => $readonly, 'extendedfieldinfo' => $extendedfieldinfo));
        }
    }
    foreach ($label_data as $headerid => $value_array) {
        $detailview_data = array();
        for ($i = 0, $j = 0; $i < count($value_array); $j++) {
            $key2 = null;
            $keys = array_keys($value_array[$i]);
            $key1 = $keys[0];
            if (isset($value_array[$i + 1]) && is_array($value_array[$i + 1]) && ($value_array[$i][$key1]['ui'] != 19 && $value_array[$i][$key1]['ui'] != 20)) {
                $keys = array_keys($value_array[$i + 1]);
                $key2 = $keys[0];
            }
            // Added to avoid the unique keys
            $use_key1 = $key1;
            if ($key1 == $key2) {
                $use_key1 = " " . $key1;
            }
            if ($value_array[$i][$key1]['ui'] != 19 && $value_array[$i][$key1]['ui'] != 20) {
                $detailview_data[$j] = array($use_key1 => $value_array[$i][$key1], $key2 => $value_array[$i + 1][$key2]);
                $i += 2;
            } else {
                $detailview_data[$j] = array($use_key1 => $value_array[$i][$key1]);
                $i++;
            }
        }
        $label_data[$headerid] = $detailview_data;
    }
    $returndata = array();
    foreach ($block_label as $blockid => $label) {
        if ($label == '') {
            $returndata[getTranslatedString($curBlock, $module)] = array_merge((array) $returndata[getTranslatedString($curBlock, $module)], (array) $label_data[$blockid]);
        } else {
            $curBlock = $label;
            if (is_array($label_data[$blockid])) {
                if (isset($returndata[getTranslatedString($curBlock, $module)])) {
                    $returndata[getTranslatedString($curBlock, $module)] = array_merge((array) $returndata[getTranslatedString($curBlock, $module)], (array) $label_data[$blockid]);
                } else {
                    $returndata[getTranslatedString($curBlock, $module)] = (array) $label_data[$blockid];
                }
            } elseif (file_exists("Smarty/templates/modules/{$module}/{$label}_detail.tpl")) {
                $returndata[getTranslatedString($curBlock, $module)] = array_merge((array) $returndata[getTranslatedString($curBlock, $module)], array($label => array()));
            }
        }
    }
    $log->debug("Exiting getDetailBlockInformation method ...");
    return $returndata;
}
Example #6
0
function transferForAddIntoTitle($type, $row, $CD)
{
    global $log, $current_user, $adb;
    list($CD['fieldname'], $void) = explode(':', $CD['fieldname']);
    if ($CD["uitype"] == "66") {
        $Col_Field = array($CD["fieldname"] => $row["parent_id"]);
    } else {
        $Col_Field = array($CD["fieldname"] => $row[$CD["columnname"]]);
    }
    if ($CD["fieldname"] == "duration_hours") {
        $Col_Field["duration_minutes"] = $row["duration_minutes"];
    }
    if ($CD["fieldname"] == "contact_id") {
        $Col_Field["contact_id"] = getAssignedContactsForEvent($row["crmid"]);
        $CD["uitype"] = "1";
    }
    if ($CD['module'] == 'Calendar' or $CD['module'] == 'Events') {
        $Cal_Data = getDetailViewOutputHtml($CD['uitype'], $CD['fieldname'], $CD['fieldlabel'], $Col_Field, '2', $calendar_tabid, 'Calendar');
        $trmodule = 'Calendar';
    } else {
        $queryGenerator = new QueryGenerator($CD['module'], $current_user);
        $queryGenerator->setFields(array($CD['columnname']));
        $queryGenerator->addCondition('id', $row['parent_id'], 'e', $queryGenerator::$AND);
        $rec_query = $queryGenerator->getQuery();
        $recinfo = $adb->pquery($rec_query, array());
        $Cal_Data = array();
        $Cal_Data[0] = getTranslatedString($CD['fieldlabel'], $CD['module']);
        $Cal_Data[1] = $adb->query_result($recinfo, 0, $CD['columnname']);
        $trmodule = $CD['module'];
    }
    if ($CD["uitype"] == "15") {
        $value = getTranslatedString($Cal_Data[1], $trmodule);
    } else {
        $value = $Cal_Data[1];
    }
    if ($type == "1") {
        return $Cal_Data[1];
    } else {
        //		return "<br><b>".$Cal_Data[0]."</b>: ".$value;
        return '<table><tr><td><b>' . $Cal_Data[0] . ':</b></td><td onmouseover="vtlib_listview.trigger(\'cell.onmouseover\', $(this))" onmouseout="vtlib_listview.trigger(\'cell.onmouseout\', $(this))">' . $value . '</td></tr></table>';
    }
}
Example #7
0
/** This function returns the detailed block information of a record in a module.
* Param $module - module name
* Param $block - block id
* Param $col_fields - column ec_fields array for the module
* Param $tabid - ec_tab id
* Return type is an array
*/
function getDetailBlockInformation($module, $result, $col_fields, $tabid, $block_label)
{
    global $log;
    //changed by dingjianting on 2007-11-05 for php5.2.x
    $log->debug("Entering getDetailBlockInformation() method ...");
    global $adb;
    global $mod_strings;
    $label_data = array();
    $returndata = array();
    $noofrows = $adb->num_rows($result);
    for ($i = 0; $i < $noofrows; $i++) {
        $fieldtablename = $adb->query_result($result, $i, "tablename");
        $fieldcolname = $adb->query_result($result, $i, "columnname");
        $uitype = $adb->query_result($result, $i, "uitype");
        $fieldname = $adb->query_result($result, $i, "fieldname");
        $fieldlabel = $adb->query_result($result, $i, "fieldlabel");
        $maxlength = $adb->query_result($result, $i, "maximumlength");
        $block = $adb->query_result($result, $i, "block");
        $generatedtype = $adb->query_result($result, $i, "generatedtype");
        $displaytype = $adb->query_result($result, $i, "displaytype");
        $tabid = $adb->query_result($result, $i, "tabid");
        $custfld = getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid);
        if (is_array($custfld)) {
            $link = isset($custfld["link"]) ? $custfld["link"] : "";
            $label_data[$block][] = array($custfld[0] => array("value" => $custfld[1], "ui" => $custfld[2], "link" => $link, "fldname" => $fieldname));
        }
        $i++;
        if ($i < $noofrows) {
            $fieldtablename = $adb->query_result($result, $i, "tablename");
            $fieldcolname = $adb->query_result($result, $i, "columnname");
            $uitype = $adb->query_result($result, $i, "uitype");
            $fieldname = $adb->query_result($result, $i, "fieldname");
            $fieldlabel = $adb->query_result($result, $i, "fieldlabel");
            $maxlength = $adb->query_result($result, $i, "maximumlength");
            $block = $adb->query_result($result, $i, "block");
            $generatedtype = $adb->query_result($result, $i, "generatedtype");
            $displaytype = $adb->query_result($result, $i, "displaytype");
            $tabid = $adb->query_result($result, $i, "tabid");
            $custfld = getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid);
            if (is_array($custfld)) {
                $link = isset($custfld["link"]) ? $custfld["link"] : "";
                $label_data[$block][] = array($custfld[0] => array("value" => $custfld[1], "ui" => $custfld[2], "link" => $link, "fldname" => $fieldname));
            }
        }
    }
    foreach ($label_data as $headerid => $value_array) {
        $detailview_data = array();
        for ($i = 0, $j = 0; $i < count($value_array); $i = $i + 2, $j++) {
            $key2 = null;
            $keys = array_keys($value_array[$i]);
            $key1 = $keys[0];
            if (isset($value_array[$i + 1]) && is_array($value_array[$i + 1])) {
                $keys = array_keys($value_array[$i + 1]);
                $key2 = $keys[0];
            }
            $value_ke2 = "";
            if (isset($value_array[$i + 1][$key2])) {
                $value_ke2 = $value_array[$i + 1][$key2];
            }
            $detailview_data[$j] = array($key1 => $value_array[$i][$key1], $key2 => $value_ke2);
        }
        $label_data[$headerid] = $detailview_data;
    }
    foreach ($block_label as $blockid => $label) {
        if ($label == '') {
            if (isset($mod_strings[$curBlock])) {
                $curBlock = $mod_strings[$curBlock];
            }
            $returndata[$curBlock] = array_merge((array) $returndata[$curBlock], (array) $label_data[$blockid]);
        } else {
            $curBlock = $label;
            if (isset($mod_strings[$label])) {
                $label = $mod_strings[$label];
            }
            if (isset($returndata[$label]) && is_array($returndata[$label])) {
                $returndata_arr = $returndata[$label];
            } else {
                $returndata_arr = array();
            }
            if (isset($label_data[$blockid]) && is_array($label_data[$blockid])) {
                $returndata[$label] = array_merge((array) $returndata_arr, (array) $label_data[$blockid]);
            }
        }
    }
    $log->debug("Exiting getDetailBlockInformation method ...");
    return $returndata;
}
Example #8
0
function transferForAddIntoTitle($type, $row, $CD)
{
    if ($CD["uitype"] == "66") {
        $Col_Field = array($CD["fieldname"] => $row["parent_id"]);
    } else {
        $Col_Field = array($CD["fieldname"] => $row[$CD["columnname"]]);
    }
    if ($CD["fieldname"] == "duration_hours") {
        $Col_Field["duration_minutes"] = $row["duration_minutes"];
    }
    if ($CD["fieldname"] == "contact_id") {
        $Col_Field["contact_id"] = getAssignedContactsForEvent($row["crmid"]);
        $CD["uitype"] = "1";
    }
    $Cal_Data = getDetailViewOutputHtml($CD["uitype"], $CD["fieldname"], $CD["fieldlabel"], $Col_Field, "2", $calendar_tabid, "Calendar");
    if ($CD["uitype"] == "15") {
        $value = getTranslatedString($Cal_Data[1], 'Calendar');
    } else {
        $value = $Cal_Data[1];
    }
    if ($type == "1") {
        return $Cal_Data[1];
    } else {
        //		return "<br><b>".$Cal_Data[0]."</b>: ".$value;
        return '<table><tr><th>' . $Cal_Data[0] . ':</th><td onmouseover="vtlib_listview.trigger(\'cell.onmouseover\', $(this))" onmouseout="vtlib_listview.trigger(\'cell.onmouseout\', $(this))">' . $value . '</td></tr></table>';
    }
}