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; }
/** * This function is used to get the Quick create form vtiger_field parameters for a given module. * Param $module - module name * returns the value in array format */ function QuickCreate($module) { global $log; $log->debug("Entering QuickCreate(" . $module . ") method ..."); global $adb; global $current_user; global $mod_strings; $tabid = getTabid($module); //Adding Security Check require 'user_privileges/user_privileges_' . $current_user->id . '.php'; if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { $quickcreate_query = "select * from vtiger_field where quickcreate in (0,2) and tabid = ? and vtiger_field.presence in (0,2) and displaytype != 2 order by quickcreatesequence"; $params = array($tabid); } else { $profileList = getCurrentUserProfileList(); $quickcreate_query = "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.tabid=? AND quickcreate in (0,2) AND vtiger_profile2field.visible=0 AND vtiger_profile2field.readonly = 0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ") and vtiger_field.presence in (0,2) and displaytype != 2 GROUP BY vtiger_field.fieldid ORDER BY quickcreatesequence"; $params = array($tabid, $profileList); //Postgres 8 fixes if ($adb->dbType == "pgsql") { $quickcreate_query = fixPostgresQuery($quickcreate_query, $log, 0); } } $category = getParentTab(); $result = $adb->pquery($quickcreate_query, $params); $noofrows = $adb->num_rows($result); $fieldName_array = array(); for ($i = 0; $i < $noofrows; $i++) { $fieldtablename = $adb->query_result($result, $i, 'tablename'); $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"); $generatedtype = $adb->query_result($result, $i, "generatedtype"); $typeofdata = $adb->query_result($result, $i, "typeofdata"); $defaultvalue = $adb->query_result($result, $i, "defaultvalue"); $col_fields[$fieldname] = $defaultvalue; //to get validationdata $fldLabel_array = array(); $fldLabel_array[getTranslatedString($fieldlabel)] = $typeofdata; $fieldName_array[$fieldname] = $fldLabel_array; // These fields should not be shown in the UI as they are already shown as part of other fields, but are required for validation. if ($fieldname == 'time_start' || $fieldname == 'time_end') { continue; } $custfld = getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module, '', $typeofdata); $qcreate_arr[] = $custfld; } for ($i = 0, $j = 0; $i < count($qcreate_arr); $i = $i + 2, $j++) { $key1 = $qcreate_arr[$i]; if (is_array($qcreate_arr[$i + 1])) { $key2 = $qcreate_arr[$i + 1]; } else { $key2 = array(); } $return_data[$j] = array(0 => $key1, 1 => $key2); } $form_data['form'] = $return_data; $form_data['data'] = $fieldName_array; $log->debug("Exiting QuickCreate method ..." . print_r($form_data, true)); return $form_data; }
function getBlockInformation($module, $result, $col_fields, $tabid, $block_label, $mode, $supportmultiapprove = false) { global $log; //changed by dingjianting on 2007-11-05 for php5.2.x $log->debug("Entering getBlockInformation() method ..."); global $adb; $editview_arr = array(); $returndata = array(); global $current_user, $mod_strings; $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"); $block = $adb->query_result($result, $i, "block"); $maxlength = $adb->query_result($result, $i, "maximumlength"); $generatedtype = $adb->query_result($result, $i, "generatedtype"); $typeofdata = $adb->query_result($result, $i, "typeofdata"); //$multifieldid=$adb->query_result($result,$i,"multifieldid"); $mandatory = 0; if (substr_count($typeofdata, "~M") > 0) { $mandatory = 1; } $readonly = 1; $custfld = getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module, $mode, $mandatory, $typeofdata); $custfld[0][1] = $readonly; $custfld[0][2] = $mandatory; $editview_arr[$block][] = $custfld; //if (isset($mvAdd_flag) && $mvAdd_flag == true) { // $mvAdd_flag = false; //} $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"); $block = $adb->query_result($result, $i, "block"); $maxlength = $adb->query_result($result, $i, "maximumlength"); $generatedtype = $adb->query_result($result, $i, "generatedtype"); $typeofdata = $adb->query_result($result, $i, "typeofdata"); //$multifieldid=$adb->query_result($result,$i,"multifieldid"); $mandatory = 0; if (substr_count($typeofdata, "~M") > 0) { $mandatory = 1; } //added by dingjianting on 2007-2-5 for approve function by read/write permittion $readonly = 1; $custfld = getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module, $mode, $mandatory, $typeofdata); $custfld[0][1] = $readonly; $custfld[0][2] = $mandatory; $editview_arr[$block][] = $custfld; } } foreach ($editview_arr as $headerid => $editview_value) { $editview_data = array(); for ($i = 0, $j = 0; $i < count($editview_value); $i = $i + 2, $j++) { $key1 = $editview_value[$i]; $key2 = null; if (isset($editview_value[$i + 1]) && is_array($editview_value[$i + 1])) { $key2 = $editview_value[$i + 1]; } else { $key2 = array(); } $editview_data[$j] = array(0 => $key1, 1 => $key2); } $editview_arr[$headerid] = $editview_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) $editview_arr[$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($editview_arr[$blockid]) && is_array($editview_arr[$blockid])) { //$returndata[$label]=array_merge((array)$returndata[$label],(array)$editview_arr[$blockid]); $returndata[$label] = array_merge((array) $returndata_arr, (array) $editview_arr[$blockid]); } } } $log->debug("Exiting getBlockInformation method ..."); return $returndata; }
$smarty->assign('MODE', $focus->mode); } elseif (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') { $smarty->assign('ASSOCIATEDPRODUCTS', $associated_prod); $smarty->assign('AVAILABLE_PRODUCTS', 'true'); $smarty->assign('MODE', $focus->mode); } $cbMap = cbMap::getMapByName($currentModule . 'InventoryDetails', 'MasterDetailLayout'); if ($cbMap != null) { $cbMapFields = $cbMap->MasterDetailLayout(); $smarty->assign('moreinfofields', "'" . implode("','", $cbMapFields['detailview']['fieldnames']) . "'"); if (empty($associated_prod)) { // creating $product_Detail = $col_fields = array(); foreach ($cbMapFields['detailview']['fields'] as $mdfield) { $col_fields[$mdfield['fieldinfo']['name']] = ''; $foutput = getOutputHtml($mdfield['fieldinfo']['uitype'], $mdfield['fieldinfo']['name'], $mdfield['fieldinfo']['label'], 100, $col_fields, 0, 'InventoryDetails', 'edit', $mdfield['fieldinfo']['typeofdata']); $product_Detail['moreinfo'][] = $foutput; } $associated_prod = $product_Detail; } } $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod); if (isset($_REQUEST['return_module'])) { $smarty->assign("RETURN_MODULE", vtlib_purify($_REQUEST['return_module'])); } else { $smarty->assign("RETURN_MODULE", "Issuecards"); } if (isset($_REQUEST['return_action'])) { $smarty->assign("RETURN_ACTION", vtlib_purify($_REQUEST['return_action'])); } else { $smarty->assign("RETURN_ACTION", "index");
/** This function returns the detail block information of a record for given block id. * Param $module - module name * Param $block - block name * Param $mode - view type (detail/edit/create) * Param $col_fields - vtiger_fields array * Param $tabid - vtiger_tab id * Param $info_type - information type (basic/advance) default "" * Return type is an object array */ function getBlockInformation($module, $result, $col_fields, $tabid, $block_label, $mode) { global $log, $adb, $current_user, $mod_strings; $log->debug("Entering getBlockInformation(" . $module . "," . print_r($col_fields, true) . "," . $tabid . "," . print_r($block_label, true) . ") method ..."); $isduplicate = vtlib_purify($_REQUEST['isDuplicate']); $editview_arr = 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"); $block = $adb->query_result($result, $i, "block"); $maxlength = $adb->query_result($result, $i, "maximumlength"); $generatedtype = $adb->query_result($result, $i, "generatedtype"); $typeofdata = $adb->query_result($result, $i, "typeofdata"); $defaultvalue = $adb->query_result($result, $i, "defaultvalue"); if (($mode == '' or $mode == 'create') && empty($col_fields[$fieldname]) && !$isduplicate) { $col_fields[$fieldname] = $defaultvalue; } $custfld = getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module, $mode, $typeofdata); $editview_arr[$block][] = $custfld; } foreach ($editview_arr as $headerid => $editview_value) { $editview_data = array(); for ($i = 0, $j = 0; $i < count($editview_value); $j++) { $key1 = $editview_value[$i]; if (is_array($editview_value[$i + 1]) && ($key1[0][0] != 19 && $key1[0][0] != 20)) { $key2 = $editview_value[$i + 1]; } else { $key2 = array(); } if ($key1[0][0] != 19 && $key1[0][0] != 20) { $editview_data[$j] = array(0 => $key1, 1 => $key2); $i += 2; } else { $editview_data[$j] = array(0 => $key1); $i++; } } $editview_arr[$headerid] = $editview_data; } $returndata = array(); foreach ($block_label as $blockid => $label) { if (isset($editview_arr[$blockid]) and $editview_arr[$blockid] != null) { if ($label == '') { $returndata[getTranslatedString($curBlock, $module)] = array_merge((array) $returndata[getTranslatedString($curBlock, $module)], (array) $editview_arr[$blockid]); } else { $curBlock = $label; if (is_array($editview_arr[$blockid])) { $returndata[getTranslatedString($curBlock, $module)] = array_merge((array) $returndata[getTranslatedString($curBlock, $module)], (array) $editview_arr[$blockid]); } } } elseif (file_exists("Smarty/templates/modules/{$module}/{$label}_edit.tpl")) { $returndata[getTranslatedString($label, $module)] = array_merge((array) $returndata[getTranslatedString($label, $module)], array($label => array())); } } $log->debug("Exiting getBlockInformation method ..."); return $returndata; }
/** This function returns the detail block information of a record for given block id. * Param $module - module name * Param $block - block name * Param $mode - view type (detail/edit/create) * Param $col_fields - vtiger_fields array * Param $tabid - vtiger_tab id * Param $info_type - information type (basic/advance) default "" * Return type is an object array */ function getBlockInformation($module, $result, $col_fields, $tabid, $block_label, $mode) { global $log; $log->debug("Entering getBlockInformation(" . $module . "," . $result . "," . $col_fields . "," . $tabid . "," . $block_label . ") method ..."); global $adb; $editview_arr = array(); global $current_user, $mod_strings; $noofrows = $adb->num_rows($result); if (($module == 'Accounts' || $module == 'Contacts' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Invoice') && $block == 2) { global $log; $log->info("module is " . $module); $mvAdd_flag = true; $moveAddress = "<td rowspan='6' valign='middle' align='center'><input title='Copy billing address to shipping address' class='button' onclick='return copyAddressRight(EditView)' type='button' name='copyright' value='»' style='padding:0px 2px 0px 2px;font-size:12px'><br><br>\n\t\t\t\t<input title='Copy shipping address to billing address' class='button' onclick='return copyAddressLeft(EditView)' type='button' name='copyleft' value='«' style='padding:0px 2px 0px 2px;font-size:12px'></td>"; } 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"); $block = $adb->query_result($result, $i, "block"); $maxlength = $adb->query_result($result, $i, "maximumlength"); $generatedtype = $adb->query_result($result, $i, "generatedtype"); $typeofdata = $adb->query_result($result, $i, "typeofdata"); $defaultvalue = $adb->query_result($result, $i, "defaultvalue"); if ($mode == '' && empty($col_fields[$fieldname])) { $col_fields[$fieldname] = $defaultvalue; } $custfld = getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module, $mode, $typeofdata); $editview_arr[$block][] = $custfld; if ($mvAdd_flag == true) { $mvAdd_flag = false; } } foreach ($editview_arr as $headerid => $editview_value) { $editview_data = array(); for ($i = 0, $j = 0; $i < count($editview_value); $j++) { $key1 = $editview_value[$i]; if (is_array($editview_value[$i + 1]) && ($key1[0][0] != 19 && $key1[0][0] != 20)) { $key2 = $editview_value[$i + 1]; } else { $key2 = array(); } if ($key1[0][0] != 19 && $key1[0][0] != 20) { $editview_data[$j] = array(0 => $key1, 1 => $key2); $i += 2; } else { $editview_data[$j] = array(0 => $key1); $i++; } } $editview_arr[$headerid] = $editview_data; } foreach ($block_label as $blockid => $label) { if ($editview_arr[$blockid] != null) { if ($label == '') { $returndata[getTranslatedString($curBlock, $module)] = array_merge((array) $returndata[getTranslatedString($curBlock, $module)], (array) $editview_arr[$blockid]); } else { $curBlock = $label; if (is_array($editview_arr[$blockid])) { $returndata[getTranslatedString($curBlock, $module)] = array_merge((array) $returndata[getTranslatedString($curBlock, $module)], (array) $editview_arr[$blockid]); } } } } $log->debug("Exiting getBlockInformation method ..."); return $returndata; }