function getTopPotentials($maxval, $calCnt) { $log = LoggerManager::getLogger('top opportunity_list'); $log->debug("Entering getTopPotentials() method ..."); require_once "data/Tracker.php"; require_once 'modules/Potentials/Potentials.php'; require_once 'include/logging.php'; require_once 'include/ListView/ListView.php'; global $app_strings; global $adb; global $current_language; global $current_user; $current_module_strings = return_module_language($current_language, "Potentials"); $title = array(); $title[] = 'myTopOpenPotentials.gif'; $title[] = $current_module_strings['LBL_TOP_OPPORTUNITIES']; $title[] = 'home_mypot'; $where = "AND vtiger_potential.potentialid > 0 AND vtiger_potential.sales_stage not in ('Closed Won','Closed Lost','" . $current_module_strings['Closed Won'] . "','" . $current_module_strings['Closed Lost'] . "') AND vtiger_crmentity.smownerid='" . $current_user->id . "' AND vtiger_potential.amount > 0"; $header = array(); $header[] = $current_module_strings['LBL_LIST_OPPORTUNITY_NAME']; //$header[]=$current_module_strings['LBL_LIST_ACCOUNT_NAME']; $currencyid = fetchCurrency($current_user->id); $rate_symbol = getCurrencySymbolandCRate($currencyid); $rate = $rate_symbol['rate']; $curr_symbol = $rate_symbol['symbol']; $header[] = $current_module_strings['LBL_LIST_AMOUNT'] . '(' . $curr_symbol . ')'; $list_query = "SELECT vtiger_crmentity.crmid, vtiger_potential.potentialname,\n\t\t\tvtiger_potential.amount, potentialid\n\t\t\tFROM vtiger_potential\n\t\t\tIGNORE INDEX(PRIMARY) INNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_potential.potentialid"; $list_query .= getNonAdminAccessControlQuery('Potentials', $current_user); $list_query .= "WHERE vtiger_crmentity.deleted = 0 " . $where; $list_query .= " ORDER BY amount DESC"; $list_query .= " LIMIT " . $adb->sql_escape_string($maxval); if ($calCnt == 'calculateCnt') { $list_result_rows = $adb->query(mkCountQuery($list_query)); return $adb->query_result($list_result_rows, 0, 'count'); } $list_result = $adb->query($list_query); $open_potentials_list = array(); $noofrows = $adb->num_rows($list_result); $entries = array(); if ($noofrows) { for ($i = 0; $i < $noofrows; $i++) { $open_potentials_list[] = array('name' => $adb->query_result($list_result, $i, 'potentialname'), 'id' => $adb->query_result($list_result, $i, 'potentialid'), 'amount' => $adb->query_result($list_result, $i, 'amount')); $potentialid = $adb->query_result($list_result, $i, 'potentialid'); $potentialname = $adb->query_result($list_result, $i, 'potentialname'); $Top_Potential = strlen($potentialname) > 20 ? substr($potentialname, 0, 20) . '...' : $potentialname; $value = array(); $value[] = '<a href="index.php?action=DetailView&module=Potentials&record=' . $potentialid . '">' . $Top_Potential . '</a>'; $value[] = CurrencyField::convertToUserFormat($adb->query_result($list_result, $i, 'amount')); $entries[$potentialid] = $value; } } $advft_criteria_groups = array('1' => array('groupcondition' => null)); $advft_criteria = array(array('groupid' => 1, 'columnname' => 'vtiger_potential:sales_stage:sales_stage:Potentials_Sales_Stage:V', 'comparator' => 'k', 'value' => 'closed', 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_potential:amount:amount:Potentials_Amount:N', 'comparator' => 'g', 'value' => '0', 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_crmentity:smownerid:assigned_user_id:Leads_Assigned_To:V', 'comparator' => 'e', 'value' => getFullNameFromArray('Users', $current_user->column_fields), 'columncondition' => null)); $search_qry = '&advft_criteria=' . Zend_Json::encode($advft_criteria) . '&advft_criteria_groups=' . Zend_Json::encode($advft_criteria_groups) . '&searchtype=advance&query=true'; $values = array('ModuleName' => 'Potentials', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry); if (count($open_potentials_list) == 0 || count($open_potentials_list) > 0) { $log->debug("Exiting getTopPotentials method ..."); return $values; } }
function getTopAccounts($maxval, $calCnt) { $log = LoggerManager::getLogger('top accounts_list'); $log->debug("Entering getTopAccounts() method ..."); require_once "data/Tracker.php"; require_once 'modules/Potentials/Potentials.php'; require_once 'include/logging.php'; require_once 'include/ListView/ListView.php'; global $app_strings; global $adb; global $current_language; global $current_user; $current_module_strings = return_module_language($current_language, "Accounts"); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; $list_query = "select vtiger_account.accountid, vtiger_account.accountname, vtiger_account.tickersymbol, sum(vtiger_potential.amount) as amount from vtiger_potential inner join vtiger_crmentity on (vtiger_potential.potentialid=vtiger_crmentity.crmid) left join vtiger_account on (vtiger_potential.related_to=vtiger_account.accountid) left join vtiger_groups on (vtiger_groups.groupid = vtiger_crmentity.smownerid) where vtiger_crmentity.deleted=0 AND vtiger_crmentity.smownerid='" . $current_user->id . "' and vtiger_potential.sales_stage not in ('Closed Won', 'Closed Lost','" . $app_strings['LBL_CLOSE_WON'] . "','" . $app_strings['LBL_CLOSE_LOST'] . "')"; if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[6] == 3) { $sec_parameter = getListViewSecurityParameter('Accounts'); $list_query .= $sec_parameter; } $list_query .= " group by vtiger_account.accountid, vtiger_account.accountname, vtiger_account.tickersymbol order by amount desc"; $list_query .= " LIMIT 0," . $adb->sql_escape_string($maxval); if ($calCnt == 'calculateCnt') { $list_result_rows = $adb->query(mkCountQuery($list_query)); return $adb->query_result($list_result_rows, 0, 'count'); } $list_result = $adb->query($list_query); $open_accounts_list = array(); $noofrows = $adb->num_rows($list_result); if ($noofrows) { for ($i = 0; $i < $noofrows; $i++) { $open_accounts_list[] = array('accountid' => $adb->query_result($list_result, $i, 'accountid'), 'accountname' => $adb->query_result($list_result, $i, 'accountname'), 'amount' => $adb->query_result($list_result, $i, 'amount'), 'tickersymbol' => $adb->query_result($list_result, $i, 'tickersymbol')); } } $title = array(); $title[] = 'myTopAccounts.gif'; $title[] = $current_module_strings['LBL_TOP_ACCOUNTS']; $title[] = 'home_myaccount'; $header = array(); $header[] = $current_module_strings['LBL_LIST_ACCOUNT_NAME']; $currencyid = fetchCurrency($current_user->id); $rate_symbol = getCurrencySymbolandCRate($currencyid); $rate = $rate_symbol['rate']; $curr_symbol = $rate_symbol['symbol']; $header[] = $current_module_strings['LBL_LIST_AMOUNT'] . '(' . $curr_symbol . ')'; $entries = array(); foreach ($open_accounts_list as $account) { $value = array(); $account_fields = array('ACCOUNT_ID' => $account['accountid'], 'ACCOUNT_NAME' => $account['accountname'], 'AMOUNT' => $account['amount']); $Top_Accounts = strlen($account['accountname']) > 20 ? substr($account['accountname'], 0, 20) . '...' : $account['accountname']; $value[] = '<a href="index.php?action=DetailView&module=Accounts&record=' . $account['accountid'] . '">' . $Top_Accounts . '</a>'; $value[] = convertFromDollar($account['amount'], $rate); $entries[$account['accountid']] = $value; } $values = array('ModuleName' => 'Accounts', 'Title' => $title, 'Header' => $header, 'Entries' => $entries); $log->debug("Exiting getTopAccounts method ..."); if ($display_empty_home_blocks && count($entries) == 0 || count($entries) > 0) { return $values; } }
function getTopPotentials($maxval, $calCnt) { $log = LoggerManager::getLogger('top opportunity_list'); $log->debug("Entering getTopPotentials() method ..."); require_once "data/Tracker.php"; require_once 'modules/Potentials/Potentials.php'; require_once 'include/logging.php'; require_once 'include/ListView/ListView.php'; global $app_strings; global $adb; global $current_language; global $current_user; $current_module_strings = return_module_language($current_language, "Potentials"); $title = array(); $title[] = 'myTopOpenPotentials.gif'; $title[] = $current_module_strings['LBL_TOP_OPPORTUNITIES']; $title[] = 'home_mypot'; $where = "AND vtiger_potential.potentialid > 0 AND vtiger_potential.sales_stage not in ('Closed Won','Closed Lost','" . $current_module_strings['Closed Won'] . "','" . $current_module_strings['Closed Lost'] . "') AND vtiger_crmentity.smownerid='" . $current_user->id . "' AND vtiger_potential.amount > 0"; $header = array(); $header[] = $current_module_strings['LBL_LIST_OPPORTUNITY_NAME']; //$header[]=$current_module_strings['LBL_LIST_ACCOUNT_NAME']; $currencyid = fetchCurrency($current_user->id); $rate_symbol = getCurrencySymbolandCRate($currencyid); $rate = $rate_symbol['rate']; $curr_symbol = $rate_symbol['symbol']; $header[] = $current_module_strings['LBL_LIST_AMOUNT'] . '(' . $curr_symbol . ')'; $list_query = "SELECT vtiger_crmentity.crmid, vtiger_potential.potentialname,\n\t\t\tvtiger_potential.amount, potentialid\n\t\t\tFROM vtiger_potential\n\t\t\tIGNORE INDEX(PRIMARY) INNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_potential.potentialid"; $list_query .= getNonAdminAccessControlQuery('Potentials', $current_user); $list_query .= "WHERE vtiger_crmentity.deleted = 0 " . $where; $list_query .= " ORDER BY amount DESC"; $list_query .= " LIMIT " . $adb->sql_escape_string($maxval); if ($calCnt == 'calculateCnt') { $list_result_rows = $adb->query(mkCountQuery($list_query)); return $adb->query_result($list_result_rows, 0, 'count'); } $list_result = $adb->query($list_query); $open_potentials_list = array(); $noofrows = $adb->num_rows($list_result); $entries = array(); if ($noofrows) { for ($i = 0; $i < $noofrows; $i++) { $open_potentials_list[] = array('name' => $adb->query_result($list_result, $i, 'potentialname'), 'id' => $adb->query_result($list_result, $i, 'potentialid'), 'amount' => $adb->query_result($list_result, $i, 'amount')); $potentialid = $adb->query_result($list_result, $i, 'potentialid'); $potentialname = $adb->query_result($list_result, $i, 'potentialname'); $Top_Potential = strlen($potentialname) > 20 ? substr($potentialname, 0, 20) . '...' : $potentialname; $value = array(); $value[] = '<a href="index.php?action=DetailView&module=Potentials&record=' . $potentialid . '">' . $Top_Potential . '</a>'; $value[] = convertFromDollar($adb->query_result($list_result, $i, 'amount'), $rate); $entries[$potentialid] = $value; } } $search_qry = "&query=true&Fields0=assigned_user_id&Condition0=e&Srch_value0=" . $current_user->column_fields['user_name'] . "&Fields1=sales_stage&Condition1=k&Srch_value1=closed&searchtype=advance&search_cnt=2&matchtype=all"; $values = array('ModuleName' => 'Potentials', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry); if ($display_empty_home_blocks && count($open_potentials_list) == 0 || count($open_potentials_list) > 0) { $log->debug("Exiting getTopPotentials method ..."); return $values; } }
function updateListPrices() { global $log, $adb; $log->debug("Entering function updateListPrices..."); $pricebook_currency = $this->column_fields['currency_id']; $prod_res = $adb->pquery("select * from vtiger_pricebookproductrel where pricebookid=? AND usedcurrency != ?", array($this->id, $pricebook_currency)); $numRows = $adb->num_rows($prod_res); for ($i = 0; $i < $numRows; $i++) { $product_id = $adb->query_result($prod_res, $i, 'productid'); $list_price = $adb->query_result($prod_res, $i, 'listprice'); $used_currency = $adb->query_result($prod_res, $i, 'usedcurrency'); $product_currency_info = getCurrencySymbolandCRate($used_currency); $product_conv_rate = $product_currency_info['rate']; $pricebook_currency_info = getCurrencySymbolandCRate($pricebook_currency); $pb_conv_rate = $pricebook_currency_info['rate']; $conversion_rate = $pb_conv_rate / $product_conv_rate; $computed_list_price = $list_price * $conversion_rate; $query = "update vtiger_pricebookproductrel set listprice=?, usedcurrency=? where pricebookid=? and productid=?"; $params = array($computed_list_price, $pricebook_currency, $this->id, $product_id); $adb->pquery($query, $params); } $log->debug("Exiting function updateListPrices..."); }
/** * Function that gives the Currency Symbol * @params $result $adb object - resultset * $column String column name * Return $value - Currency Symbol */ function getCurrencySymbol($result, $i, $column) { global $adb; $currencyid = $adb->query_result($result, $i, $column); $curr = getCurrencySymbolandCRate($currencyid); $value = "(" . $curr['symbol'] . ")"; return $value; }
private function getSubGroupRow($group_value = "", $currency_id, $agi = 1, $g_con_sql = "") { global $log; $log->debug("Entering ./modules/ITS4YouReports/GenerateObj.php::getSubGroupRow"); global $log; $log->debug("Entering ./modules/ITS4YouReports/GenerateObj.php::getSubGroupRow"); global $log; $log->debug("Entering ./modules/ITS4YouReports/GenerateObj.php::getSubGroupRow"); global $log; $log->debug("Entering ./modules/ITS4YouReports/GenerateObj.php::getSubGroupRow"); $return_html = ""; $return_arr = array(); // groups 0 1 2 $bg_color = $this->g_colors[$agi]; // $agi = actual group id, to get previous group i pgi $pgi = $agi - 1; $ngi = $agi + 1; if ($agi > 0) { $agi_first_td_class = "rpt4youGrpHead_{$agi}"; $ngi_first_td_class = "rpt4youGrpHead_{$ngi}"; } //if ($group_value != "") { $adb = PearDatabase::getInstance(); $group_sql_name = "group_sql_{$agi}"; $g_con_name = "gi_con_{$pgi}"; $exp_gsql = explode("GROUP BY", $this->{$group_sql_name}); if (count(explode("WHERE", $exp_gsql[0])) > 1 || $g_con_sql != "") { $wstr = "AND"; } else { $wstr = "WHERE"; } if (isset($this->report_obj->reportinformations["timeline_columnstr{$agi}"]) && $this->report_obj->reportinformations["timeline_columnstr{$agi}"] != "" && $this->report_obj->reportinformations["timeline_columnstr{$agi}"] != "@vlv@") { $g_con_col_sql = $this->getTimeLineColumnSql($this->{$g_con_name}, $this->report_obj->reportinformations["timeline_columnstr{$agi}"]); } else { $g_con_col_sql = $this->{$g_con_name}; } if ($group_value == "" || $group_value == "-") { $g_con_sql .= " {$wstr} ( " . $g_con_col_sql . " = '' OR " . $g_con_col_sql . " IS NULL )"; } else { $g_con_sql .= " {$wstr} " . $g_con_col_sql . " = '{$group_value}'"; } //ITS4YouReports::sshow("Problem2-".$group_value); if ($currency_id != "") { $g_con_sql .= " AND " . $this->currency_id_sql . " = '{$currency_id}' "; } global $default_charset; $g_con_sql = html_entity_decode($g_con_sql, ENT_QUOTES, $default_charset); $f_gsql = $exp_gsql[0] . " " . $g_con_sql; if (isset($exp_gsql[1]) && $exp_gsql[1] != "") { $f_gsql .= " GROUP BY " . $exp_gsql[1]; } //$adb->setDebug(true); $result = $adb->pquery($f_gsql, array()); //$adb->setDebug(false); $num_rows = $adb->num_rows($result); if ($num_rows > 0) { while ($row = $adb->fetchByAssoc($result)) { $group2_value = $g2_html = ""; if ($this->outputformat != "XLS") { $return_html .= "<tr>"; } $r_i = 0; $currency_id = ""; if (isset($row["currency_id"]) && $row["currency_id"] != "") { $currency_id = $row["currency_id"]; } foreach ($row as $fld_name => $fld_value) { $is_hid = strpos($fld_name, "_hid"); $clear_fld_name_arr = explode("_", $fld_name); $clear_fld_calculation_type = strtoupper($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); unset($clear_fld_name_arr[count($clear_fld_name_arr) - 1]); $clear_fld_name = implode("_", $clear_fld_name_arr); if ($r_i > 0 && $this->report_obj->in_multiarray($this->columns_array[$clear_fld_name] . ":{$clear_fld_calculation_type}", $this->summaries_columns, "columnname") !== true) { continue; } if ($fld_value == "") { // $fld_value = number_format("0", 3); $fld_value = "-"; } if ($is_hid === false && !in_array($fld_name, $this->skip_fields) && !in_array($clear_fld_name, $this->skip_fields)) { if ($fld_name == $this->g_flds[$agi]) { $group2_value = $fld_value; } if ($agi == 1 && !empty($this->charts) && !empty($this->charts["charttypes"])) { $ch_fldname = strtolower($fld_name); $this->setChArrayValues("charttitle", '', $this->charts["charttitle"]); // chart data population start if ($this->charts["x_group"] == "group2" && in_array($ch_fldname, $this->charts["charts_ds_columns"])) { $this->setDataseriesArray($group2_value, $fld_value, $currency_id, $ch_fldname, $group_value); } // chart data population end } if ($fld_name != $this->g_flds[$pgi] && $fld_name != $this->g_flds[$ngi] && $fld_name != $this->g_flds[$pgi - 1]) { if ($currency_id != "") { if ($group2_value != "" && $agi != 2) { $return_arr[$group_value][$group2_value][$fld_name][$currency_id] = $fld_value; } elseif ($group2_value != "" && $agi == 2) { $return_arr[$group2_value][$fld_name][$currency_id] = $fld_value; } else { $return_arr[$group_value][$fld_name][$currency_id] = $fld_value; } } else { if ($agi == 1 && $group2_value != "") { $return_arr[$group_value][$group2_value][$fld_name] = $fld_value; } elseif ($agi == 2 && $group2_value != "") { $return_arr[$group2_value][$fld_name] = $fld_value; } elseif ($agi == 1) { $return_arr[$group_value][$fld_name] = $fld_value; } elseif ($agi == 2) { $return_arr[$group_value][$fld_name] = $fld_value; } } $r_i++; } } } if ($agi != 2 && isset($this->g_colors[$ngi]) && $this->g_colors[$ngi] != "") { //$return_html .= $this->getSubGroupRow($group2_value, $ngi, $g_con_sql); $return_arr_sub = $this->getSubGroupRow($group2_value, $currency_id, $ngi, $g_con_sql); $return_arr[$group_value][$group2_value]["sub_row"] = $return_arr_sub; } } } if (!empty($return_arr[$group_value])) { $xls_r_i = 0; foreach ($return_arr[$group_value] as $g1column_alias => $g1column_values) { $sp_cname_i = 0; foreach ($g1column_values as $column_alias => $column_values) { if ($sp_cname_i == 0) { $td_class = $agi_first_td_class; } else { $td_class = "rpt4youGrpHead"; } if ($column_alias != "sub_row") { $column_arr = explode("_", $column_alias); $calculation_type = strtolower($column_arr[count($column_arr) - 1]); $cl_c_alias_arr = array(); for ($cl_c_i = 0; $cl_c_i < count($column_arr) - 1; $cl_c_i++) { $cl_c_alias_arr[] = $column_arr[$cl_c_i]; } $cl_c_alias = implode("_", $cl_c_alias_arr); if (is_array($column_values)) { $column_values_f = ""; ksort($column_values); $column_values_count = count($column_values); $column_values_i = 0; foreach ($column_values as $currency_id => $column_value) { if ($column_value != "") { //$txt_align = $this->getFldAlignment($column_alias, $column_value); $fld_style_arr = $this->getFldStyle($column_alias, $column_value); $fld_style = $this->getFldStyleString($fld_style_arr); $rate_symbol = getCurrencySymbolandCRate($currency_id); $fld_value = $this->getFldNumberFormat($column_alias, $column_value, $currency_id); /* if (is_numeric($fld_value) && $calculation_type != "count" && $cl_c_alias != "quantity" && !in_array($column_alias, $this->g_flds)) { $fld_value = CurrencyField::appendCurrencySymbol($fld_value, $rate_symbol['symbol']); } */ $column_values_f .= $fld_value; $column_values_i++; if ($column_values_i < $column_values_count) { $column_values_f .= "<br>"; } } } if ($this->outputformat == "XLS") { $return_html[$xls_r_i][] = $column_values_f; } else { $return_html .= "<td class='{$td_class}' style='background-color:{$bg_color};{$fld_style}' nowrap >" . $column_values_f . "</td>"; } } else { //$txt_align = $this->getFldAlignment($column_alias, $column_values); $fld_style_arr = $this->getFldStyle($column_alias, $column_value); $fld_style = $this->getFldStyleString($fld_style_arr); if ($this->outputformat == "XLS") { $return_html[$xls_r_i][] = $this->getFldNumberFormat($column_alias, $column_values, ""); } else { $return_html .= "<td class='{$td_class}' style='background-color:{$bg_color};{$fld_style}' nowrap >" . $this->getFldNumberFormat($column_alias, $column_values, "") . "</td>"; } } // charts array population start if ($column_alias == $this->charts["charts_ds_column"]) { if (!isset($this->ch_array["dataseries_label"])) { $this->setDataseriesLabel($column_alias); } $this->addToSubvalChArrayValues("dataseries", $group_value, $column_values, $this->getFldNumberFormat($this->group_cols_array[$ngi], $g1column_alias, "", true), $currency_id); } // charts array population end } else { $xls_r_i++; $sub_bg_color = $this->g_colors[$ngi]; foreach ($column_values as $sub_column_alias => $sub_column_arr) { if ($this->outputformat != "XLS") { $return_html .= "</tr><tr>"; } $n_ri = 0; foreach ($sub_column_arr as $sub_column_alias => $sub_column_values) { if ($n_ri == 0) { $td_class = $ngi_first_td_class; } else { $td_class = "rpt4youGrpHead"; } $column_arr = explode("_", $sub_column_alias); $calculation_type = strtolower($column_arr[count($column_arr) - 1]); $cl_c_alias_arr = array(); for ($cl_c_i = 0; $cl_c_i < count($column_arr) - 1; $cl_c_i++) { $cl_c_alias_arr[] = $column_arr[$cl_c_i]; } $cl_c_alias = implode("_", $cl_c_alias_arr); if (is_array($sub_column_values)) { $column_values_f = ""; ksort($sub_column_values); $column_values_count = count($sub_column_values); $column_values_i = 0; foreach ($sub_column_values as $currency_id => $column_value) { if ($column_value != "") { //$txt_align = $this->getFldAlignment($sub_column_alias, $column_value); $fld_style_arr = $this->getFldStyle($sub_column_alias, $column_value); $fld_style = $this->getFldStyleString($fld_style_arr); $fld_value = $this->getFldNumberFormat($sub_column_alias, $column_value, $currency_id); /* if (is_numeric($fld_value) && $calculation_type != "count" && $cl_c_alias != "quantity" && !in_array($sub_column_alias, $this->g_flds)) { $fld_value = CurrencyField::appendCurrencySymbol($fld_value, $this->currency_symbols[$currency_id]); } */ $column_values_f .= $fld_value; $column_values_i++; if ($column_values_i < ${$column_values_count}) { $column_values_f .= "<br>"; } } } if ($this->outputformat == "XLS") { $return_html[$xls_r_i][] = $column_values_f; } else { $return_html .= "<td class='{$td_class}' style='background-color:{$sub_bg_color};{$fld_style}' nowrap >" . $column_values_f . "</td>"; } } else { //$txt_align = $this->getFldAlignment($sub_column_alias, $sub_column_values); $fld_style_arr = $this->getFldStyle($sub_column_alias, $sub_column_values); $fld_style = $this->getFldStyleString($fld_style_arr); if ($this->outputformat == "XLS") { $return_html[$xls_r_i][] = $this->getFldNumberFormat($sub_column_alias, $sub_column_values, ""); } else { $return_html .= "<td class='{$td_class}' style='background-color:{$sub_bg_color};{$fld_style}' nowrap >" . $this->getFldNumberFormat($sub_column_alias, $sub_column_values, "") . "</td>"; } } $n_ri++; } } } $sp_cname_i++; } if ($this->outputformat != "XLS") { $return_html .= "</tr><tr>"; } $xls_r_i++; } } // DETAIL OF RECORDS START // details for group 2 rows /* if ($agi == 1) { $this->agi1_group_value = $group_value; } if ($agi == 1 && isset($this->result_details_array[$this->agi1_group_value]) && !empty($this->result_details_array[$this->agi1_group_value])) { $selectedcolumns_arr = $this->report_obj->getSelectedColumnListArray($this->report_obj->record); if (!empty($selectedcolumns_arr)) { if ($currency_id != "" && isset($this->result_details_array[$this->agi1_group_value][$currency_id])) { $group_details_array = $this->result_details_array[$this->agi1_group_value][$currency_id]; } else { $group_details_array = $this->result_details_array[$this->agi1_group_value]; } $return_html .= $this->returnGroupDetailRecords($group_details_array, $r_i, $selectedcolumns_arr, $currency_id); } } */ // DETAIL OF RECORDS END //} if ($agi == 2) { return $return_arr; } else { return $return_html; } //return $return_arr; }
function GenerateReport($outputformat, $filtersql, $directOutput = false) { global $adb, $current_user, $php_max_execution_time; global $modules, $app_strings; global $mod_strings, $current_language; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $modules_selected = array(); $modules_selected[] = $this->primarymodule; if (!empty($this->secondarymodule)) { $sec_modules = explode(":", $this->secondarymodule); for ($i = 0; $i < count($sec_modules); $i++) { $modules_selected[] = $sec_modules[$i]; } } // Update Reference fields list list $referencefieldres = $adb->pquery("SELECT tabid, fieldlabel, uitype from vtiger_field WHERE uitype in (10,101)", array()); if ($referencefieldres) { foreach ($referencefieldres as $referencefieldrow) { $uiType = $referencefieldrow['uitype']; $modprefixedlabel = getTabModuleName($referencefieldrow['tabid']) . ' ' . $referencefieldrow['fieldlabel']; $modprefixedlabel = str_replace(' ', '_', $modprefixedlabel); if ($uiType == 10 && !in_array($modprefixedlabel, $this->ui10_fields)) { $this->ui10_fields[] = $modprefixedlabel; } elseif ($uiType == 101 && !in_array($modprefixedlabel, $this->ui101_fields)) { $this->ui101_fields[] = $modprefixedlabel; } } } if ($outputformat == "HTML") { $sSQL = $this->sGetSQLforReport($this->reportid, $filtersql, $outputformat); $result = $adb->query($sSQL); $error_msg = $adb->database->ErrorMsg(); if (!$result && $error_msg != '') { // Performance Optimization: If direct output is requried if ($directOutput) { echo getTranslatedString('LBL_REPORT_GENERATION_FAILED', $currentModule) . "<br>" . $error_msg; $error_msg = false; } // END return $error_msg; } // Performance Optimization: If direct output is required if ($directOutput) { echo '<table cellpadding="5" cellspacing="0" align="center" class="rptTable"><tr>'; } // END if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { $picklistarray = $this->getAccessPickListValues(); } if ($result) { $y = $adb->num_fields($result); $arrayHeaders = array(); for ($x = 0; $x < $y; $x++) { $fld = $adb->field_name($result, $x); if (in_array($this->getLstringforReportHeaders($fld->name), $arrayHeaders)) { $headerLabel = str_replace("_", " ", $fld->name); $arrayHeaders[] = $headerLabel; } else { $headerLabel = str_replace($modules, " ", $this->getLstringforReportHeaders($fld->name)); $headerLabel = str_replace("_", " ", $this->getLstringforReportHeaders($fld->name)); $arrayHeaders[] = $headerLabel; } /*STRING TRANSLATION starts */ $mod_name = explode(' ', $headerLabel, 2); $moduleLabel = ''; if (in_array($mod_name[0], $modules_selected)) { $moduleLabel = getTranslatedString($mod_name[0], $mod_name[0]); } if (!empty($this->secondarymodule)) { if ($moduleLabel != '') { $headerLabel_tmp = $moduleLabel . " " . getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } else { if ($moduleLabel != '') { $headerLabel_tmp = getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } if ($headerLabel == $headerLabel_tmp) { $headerLabel = getTranslatedString($headerLabel_tmp); } else { $headerLabel = $headerLabel_tmp; } /*STRING TRANSLATION ends */ $header .= "<td class='rptCellLabel'>" . $headerLabel . "</td>"; // Performance Optimization: If direct output is required if ($directOutput) { echo $header; $header = ''; } // END } // Performance Optimization: If direct output is required if ($directOutput) { echo '</tr><tr>'; } // END $noofrows = $adb->num_rows($result); $custom_field_values = $adb->fetch_array($result); $groupslist = $this->getGroupingList($this->reportid); $column_definitions = $adb->getFieldsDefinition($result); do { $arraylists = array(); if (count($groupslist) == 1) { $newvalue = $custom_field_values[0]; } elseif (count($groupslist) == 2) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; } elseif (count($groupslist) == 3) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; $tnewvalue = $custom_field_values[2]; } if ($newvalue == "") { $newvalue = "-"; } if ($snewvalue == "") { $snewvalue = "-"; } if ($tnewvalue == "") { $tnewvalue = "-"; } $valtemplate .= "<tr>"; // Performance Optimization if ($directOutput) { echo $valtemplate; $valtemplate = ''; } // END for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); $fld_type = $column_definitions[$i]->type; $fieldvalue = getReportFieldValue($this, $picklistarray, $fld, $custom_field_values, $i); //check for Roll based pick list $temp_val = $fld->name; if ($fieldvalue == "") { $fieldvalue = "-"; } else { if ($fld->name == 'LBL_ACTION' && $fieldvalue != '-') { $fieldvalue = "<a href='index.php?module={$this->primarymodule}&action=DetailView&record={$fieldvalue}' target='_blank'>" . getTranslatedString('LBL_VIEW_DETAILS') . "</a>"; } } if ($lastvalue == $fieldvalue && $this->reporttype == "summary") { if ($this->reporttype == "summary") { $valtemplate .= "<td class='rptEmptyGrp'> </td>"; } else { $valtemplate .= "<td class='rptData'>" . $fieldvalue . "</td>"; } } else { if ($secondvalue === $fieldvalue && $this->reporttype == "summary") { if ($lastvalue === $newvalue) { $valtemplate .= "<td class='rptEmptyGrp'> </td>"; } else { $valtemplate .= "<td class='rptGrpHead'>" . $fieldvalue . "</td>"; } } else { if ($thirdvalue === $fieldvalue && $this->reporttype == "summary") { if ($secondvalue === $snewvalue) { $valtemplate .= "<td class='rptEmptyGrp'> </td>"; } else { $valtemplate .= "<td class='rptGrpHead'>" . $fieldvalue . "</td>"; } } else { if ($this->reporttype == "tabular") { $valtemplate .= "<td class='rptData'>" . $fieldvalue . "</td>"; } else { $valtemplate .= "<td class='rptGrpHead'>" . $fieldvalue . "</td>"; } } } } // Performance Optimization: If direct output is required if ($directOutput) { echo $valtemplate; $valtemplate = ''; } // END } $valtemplate .= "</tr>"; // Performance Optimization: If direct output is required if ($directOutput) { echo $valtemplate; $valtemplate = ''; } // END $lastvalue = $newvalue; $secondvalue = $snewvalue; $thirdvalue = $tnewvalue; $arr_val[] = $arraylists; set_time_limit($php_max_execution_time); } while ($custom_field_values = $adb->fetch_array($result)); // Performance Optimization if ($directOutput) { echo "</tr></table>"; echo "<script type='text/javascript' id='__reportrun_directoutput_recordcount_script'>\n\t\t\t\t\t\tif(\$('_reportrun_total')) \$('_reportrun_total').innerHTML={$noofrows};</script>"; } else { $sHTML = '<table cellpadding="5" cellspacing="0" align="center" class="rptTable"> <tr>' . $header . '<!-- BEGIN values --> <tr>' . $valtemplate . '</tr> </table>'; } //<<<<<<<<construct HTML>>>>>>>>>>>> $return_data[] = $sHTML; $return_data[] = $noofrows; $return_data[] = $sSQL; return $return_data; } } elseif ($outputformat == "PDF") { $sSQL = $this->sGetSQLforReport($this->reportid, $filtersql); $result = $adb->query($sSQL); if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { $picklistarray = $this->getAccessPickListValues(); } if ($result) { $y = $adb->num_fields($result); $noofrows = $adb->num_rows($result); $custom_field_values = $adb->fetch_array($result); $column_definitions = $adb->getFieldsDefinition($result); do { $arraylists = array(); for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); $fld_type = $column_definitions[$i]->type; list($module, $fieldLabel) = explode('_', $fld->name, 2); $fieldInfo = getFieldByReportLabel($module, $fieldLabel); $fieldType = null; if (!empty($fieldInfo)) { $field = WebserviceField::fromArray($adb, $fieldInfo); $fieldType = $field->getFieldDataType(); } if (!empty($fieldInfo)) { $translatedLabel = getTranslatedString($field->getFieldLabelKey(), $module); } else { $translatedLabel = getTranslatedString(str_replace('_', " ", $fieldLabel), $module); } /*STRING TRANSLATION starts */ $moduleLabel = ''; if (in_array($module, $modules_selected)) { $moduleLabel = getTranslatedString($module, $module); } if (empty($translatedLabel)) { $translatedLabel = getTranslatedString(str_replace('_', " ", $fld->name)); } $headerLabel = $translatedLabel; if (!empty($this->secondarymodule)) { if ($moduleLabel != '') { $headerLabel = $moduleLabel . " " . $translatedLabel; } } // Check for role based pick list $temp_val = $fld->name; if ($fieldType == 'currency') { // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion $cur_value = $custom_field_values[$i]; if ($field->getUIType() == '72') { $curid_value = explode("::", $cur_value); if (count($curid_value) == 2) { $currency_id = $curid_value[0]; $currency_value = $curid_value[1]; $cur_sym_rate = getCurrencySymbolandCRate($currency_id); } else { $currency_value = $curid_value[0]; $cur_sym_rate['symbol'] = ''; } $arraylists[$headerLabel] = number_format($currency_value, 2, '.', ''); $arraylists[getTranslatedString('LBL_CURRENCY') . ' ' . $headerLabel] = $cur_sym_rate['symbol']; } else { $currencyField = new CurrencyField($cur_value); $fieldvalue = $currencyField->getDisplayValue(); $arraylists[$headerLabel] = number_format($fieldvalue, 2, '.', ''); } } else { $fieldvalue = getReportFieldValue($this, $picklistarray, $fld, $custom_field_values, $i); $arraylists[$headerLabel] = $fieldvalue; } } $arr_val[] = $arraylists; set_time_limit($php_max_execution_time); } while ($custom_field_values = $adb->fetch_array($result)); return $arr_val; } } elseif ($outputformat == "TOTALXLS") { $escapedchars = array('_SUM', '_AVG', '_MIN', '_MAX'); $totalpdf = array(); $sSQL = $this->sGetSQLforReport($this->reportid, $filtersql, "COLUMNSTOTOTAL"); if (isset($this->totallist)) { if ($sSQL != "") { $result = $adb->query($sSQL); $y = $adb->num_fields($result); $custom_field_values = $adb->fetch_array($result); foreach ($this->totallist as $key => $value) { $fieldlist = explode(":", $key); $mod_query = $adb->pquery("SELECT distinct(tabid) as tabid, uitype as uitype from vtiger_field where tablename = ? and columnname=?", array($fieldlist[1], $fieldlist[2])); if ($adb->num_rows($mod_query) > 0) { $module_name = getTabModuleName($adb->query_result($mod_query, 0, 'tabid')); $fieldlabel = trim(str_replace($escapedchars, " ", $fieldlist[3])); $fieldlabel = str_replace("_", " ", $fieldlabel); if ($module_name) { $field = getTranslatedString($module_name, $module_name) . " " . getTranslatedString($fieldlabel, $module_name); } else { $field = getTranslatedString($fieldlabel); } } $uitype_arr[str_replace($escapedchars, " ", $module_name . "_" . $fieldlist[3])] = $adb->query_result($mod_query, 0, "uitype"); $totclmnflds[str_replace($escapedchars, " ", $module_name . "_" . $fieldlist[3])] = $field; } for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); $keyhdr[$fld->name] = $custom_field_values[$i]; } $rowcount = 0; foreach ($totclmnflds as $key => $value) { $col_header = trim(str_replace($modules, " ", $value)); $fld_name_1 = $this->primarymodule . "_" . trim($value); $fld_name_2 = $this->secondarymodule . "_" . trim($value); if ($uitype_arr[$key] == 71 || $uitype_arr[$key] == 72 || in_array($fld_name_1, $this->append_currency_symbol_to_value) || in_array($fld_name_2, $this->append_currency_symbol_to_value)) { $col_header .= " (" . $app_strings['LBL_IN'] . " " . $current_user->currency_symbol . ")"; $convert_price = true; } else { $convert_price = false; } $value = trim($key); $arraykey = $value . '_SUM'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]); } else { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true); } $totalpdf[$rowcount][$arraykey] = $conv_value; } else { $totalpdf[$rowcount][$arraykey] = ''; } $arraykey = $value . '_AVG'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]); } else { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true); } $totalpdf[$rowcount][$arraykey] = $conv_value; } else { $totalpdf[$rowcount][$arraykey] = ''; } $arraykey = $value . '_MIN'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]); } else { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true); } $totalpdf[$rowcount][$arraykey] = $conv_value; } else { $totalpdf[$rowcount][$arraykey] = ''; } $arraykey = $value . '_MAX'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]); } else { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true); } $totalpdf[$rowcount][$arraykey] = $conv_value; } else { $totalpdf[$rowcount][$arraykey] = ''; } $rowcount++; } } } return $totalpdf; } elseif ($outputformat == "TOTALHTML") { $escapedchars = array('_SUM', '_AVG', '_MIN', '_MAX'); $sSQL = $this->sGetSQLforReport($this->reportid, $filtersql, "COLUMNSTOTOTAL"); if (isset($this->totallist)) { if ($sSQL != "") { $result = $adb->query($sSQL); $y = $adb->num_fields($result); $custom_field_values = $adb->fetch_array($result); $coltotalhtml .= "<table align='center' width='60%' cellpadding='3' cellspacing='0' border='0' class='rptTable'><tr><td class='rptCellLabel'>" . $mod_strings[Totals] . "</td><td class='rptCellLabel'>" . $mod_strings[SUM] . "</td><td class='rptCellLabel'>" . $mod_strings[AVG] . "</td><td class='rptCellLabel'>" . $mod_strings[MIN] . "</td><td class='rptCellLabel'>" . $mod_strings[MAX] . "</td></tr>"; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } // END foreach ($this->totallist as $key => $value) { $fieldlist = explode(":", $key); $mod_query = $adb->pquery("SELECT distinct(tabid) as tabid, uitype as uitype from vtiger_field where tablename = ? and columnname=?", array($fieldlist[1], $fieldlist[2])); if ($adb->num_rows($mod_query) > 0) { $module_name = getTabModuleName($adb->query_result($mod_query, 0, 'tabid')); $fieldlabel = trim(str_replace($escapedchars, " ", $fieldlist[3])); $fieldlabel = str_replace("_", " ", $fieldlabel); if ($module_name) { $field = getTranslatedString($module_name, $module_name) . " " . getTranslatedString($fieldlabel, $module_name); } else { $field = getTranslatedString($fieldlabel); } } $uitype_arr[str_replace($escapedchars, " ", $module_name . "_" . $fieldlist[3])] = $adb->query_result($mod_query, 0, "uitype"); $totclmnflds[str_replace($escapedchars, " ", $module_name . "_" . $fieldlist[3])] = $field; } for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); $keyhdr[$fld->name] = $custom_field_values[$i]; } foreach ($totclmnflds as $key => $value) { $coltotalhtml .= '<tr class="rptGrpHead" valign=top>'; $col_header = trim(str_replace($modules, " ", $value)); $fld_name_1 = $this->primarymodule . "_" . trim($value); $fld_name_2 = $this->secondarymodule . "_" . trim($value); if ($uitype_arr[$key] == 71 || $uitype_arr[$key] == 72 || in_array($fld_name_1, $this->append_currency_symbol_to_value) || in_array($fld_name_2, $this->append_currency_symbol_to_value)) { $col_header .= " (" . $app_strings['LBL_IN'] . " " . $current_user->currency_symbol . ")"; $convert_price = true; } else { $convert_price = false; } $coltotalhtml .= '<td class="rptData">' . $col_header . '</td>'; $value = trim($key); $arraykey = $value . '_SUM'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]); } else { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true); } if (substr($arraykey, 0, 21) == 'Timecontrol_TotalTime' or substr($arraykey, 0, 18) == 'TCTotals_TotalTime') { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td class="rptTotal">' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td class="rptTotal"> </td>'; } $arraykey = $value . '_AVG'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]); } else { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true); } if (substr($arraykey, 0, 21) == 'Timecontrol_TotalTime' or substr($arraykey, 0, 18) == 'TCTotals_TotalTime') { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td class="rptTotal">' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td class="rptTotal"> </td>'; } $arraykey = $value . '_MIN'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]); } else { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true); } if (substr($arraykey, 0, 21) == 'Timecontrol_TotalTime' or substr($arraykey, 0, 18) == 'TCTotals_TotalTime') { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td class="rptTotal">' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td class="rptTotal"> </td>'; } $arraykey = $value . '_MAX'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]); } else { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true); } if (substr($arraykey, 0, 21) == 'Timecontrol_TotalTime' or substr($arraykey, 0, 18) == 'TCTotals_TotalTime') { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td class="rptTotal">' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td class="rptTotal"> </td>'; } $coltotalhtml .= '<tr>'; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } // END } $coltotalhtml .= "</table>"; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } // END } } return $coltotalhtml; } elseif ($outputformat == "PRINT") { $sSQL = $this->sGetSQLforReport($this->reportid, $filtersql); $result = $adb->query($sSQL); if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { $picklistarray = $this->getAccessPickListValues(); } if ($result) { $y = $adb->num_fields($result); $arrayHeaders = array(); for ($x = 0; $x < $y; $x++) { $fld = $adb->field_name($result, $x); if (in_array($this->getLstringforReportHeaders($fld->name), $arrayHeaders)) { $headerLabel = str_replace("_", " ", $fld->name); $arrayHeaders[] = $headerLabel; } else { $headerLabel = str_replace($modules, " ", $this->getLstringforReportHeaders($fld->name)); $headerLabel = str_replace("_", " ", $this->getLstringforReportHeaders($fld->name)); $arrayHeaders[] = $headerLabel; } /*STRING TRANSLATION starts */ $mod_name = explode(' ', $headerLabel, 2); $moduleLabel = ''; if (in_array($mod_name[0], $modules_selected)) { $moduleLabel = getTranslatedString($mod_name[0], $mod_name[0]); } if (!empty($this->secondarymodule)) { if ($moduleLabel != '') { $headerLabel_tmp = $moduleLabel . " " . getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } else { if ($moduleLabel != '') { $headerLabel_tmp = getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } if ($headerLabel == $headerLabel_tmp) { $headerLabel = getTranslatedString($headerLabel_tmp); } else { $headerLabel = $headerLabel_tmp; } /*STRING TRANSLATION ends */ $header .= "<th>" . $headerLabel . "</th>"; } $noofrows = $adb->num_rows($result); $custom_field_values = $adb->fetch_array($result); $groupslist = $this->getGroupingList($this->reportid); $column_definitions = $adb->getFieldsDefinition($result); do { $arraylists = array(); if (count($groupslist) == 1) { $newvalue = $custom_field_values[0]; } elseif (count($groupslist) == 2) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; } elseif (count($groupslist) == 3) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; $tnewvalue = $custom_field_values[2]; } if ($newvalue == "") { $newvalue = "-"; } if ($snewvalue == "") { $snewvalue = "-"; } if ($tnewvalue == "") { $tnewvalue = "-"; } $valtemplate .= "<tr>"; for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); $fld_type = $column_definitions[$i]->type; $fieldvalue = getReportFieldValue($this, $picklistarray, $fld, $custom_field_values, $i); if ($lastvalue == $fieldvalue && $this->reporttype == "summary") { if ($this->reporttype == "summary") { $valtemplate .= "<td style='border-top:1px dotted #FFFFFF;'> </td>"; } else { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } } else { if ($secondvalue == $fieldvalue && $this->reporttype == "summary") { if ($lastvalue == $newvalue) { $valtemplate .= "<td style='border-top:1px dotted #FFFFFF;'> </td>"; } else { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } } else { if ($thirdvalue == $fieldvalue && $this->reporttype == "summary") { if ($secondvalue == $snewvalue) { $valtemplate .= "<td style='border-top:1px dotted #FFFFFF;'> </td>"; } else { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } } else { if ($this->reporttype == "tabular") { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } else { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } } } } } $valtemplate .= "</tr>"; $lastvalue = $newvalue; $secondvalue = $snewvalue; $thirdvalue = $tnewvalue; $arr_val[] = $arraylists; set_time_limit($php_max_execution_time); } while ($custom_field_values = $adb->fetch_array($result)); $sHTML = '<tr>' . $header . '</tr>' . $valtemplate; $return_data[] = $sHTML; $return_data[] = $noofrows; return $return_data; } } elseif ($outputformat == "PRINT_TOTAL") { $escapedchars = array('_SUM', '_AVG', '_MIN', '_MAX'); $sSQL = $this->sGetSQLforReport($this->reportid, $filtersql, "COLUMNSTOTOTAL"); if (isset($this->totallist)) { if ($sSQL != "") { $result = $adb->query($sSQL); $y = $adb->num_fields($result); $custom_field_values = $adb->fetch_array($result); $coltotalhtml .= "<br /><table align='center' width='60%' cellpadding='3' cellspacing='0' border='1' class='printReport'><tr><td class='rptCellLabel'>" . $mod_strings['Totals'] . "</td><td><b>" . $mod_strings['SUM'] . "</b></td><td><b>" . $mod_strings['AVG'] . "</b></td><td><b>" . $mod_strings['MIN'] . "</b></td><td><b>" . $mod_strings['MAX'] . "</b></td></tr>"; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } // END foreach ($this->totallist as $key => $value) { $fieldlist = explode(":", $key); $mod_query = $adb->pquery("SELECT distinct(tabid) as tabid, uitype as uitype from vtiger_field where tablename = ? and columnname=?", array($fieldlist[1], $fieldlist[2])); if ($adb->num_rows($mod_query) > 0) { $module_name = getTabModuleName($adb->query_result($mod_query, 0, 'tabid')); $fieldlabel = trim(str_replace($escapedchars, " ", $fieldlist[3])); $fieldlabel = str_replace("_", " ", $fieldlabel); if ($module_name) { $field = getTranslatedString($module_name, $module_name) . " " . getTranslatedString($fieldlabel, $module_name); } else { $field = getTranslatedString($fieldlabel); } } $uitype_arr[str_replace($escapedchars, " ", $module_name . "_" . $fieldlist[3])] = $adb->query_result($mod_query, 0, "uitype"); $totclmnflds[str_replace($escapedchars, " ", $module_name . "_" . $fieldlist[3])] = $field; } for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); $keyhdr[$fld->name] = $custom_field_values[$i]; } foreach ($totclmnflds as $key => $value) { $coltotalhtml .= '<tr class="rptGrpHead">'; $col_header = getTranslatedString(trim(str_replace($modules, " ", $value))); $fld_name_1 = $this->primarymodule . "_" . trim($value); $fld_name_2 = $this->secondarymodule . "_" . trim($value); if ($uitype_arr[$key] == 71 || $uitype_arr[$key] == 72 || in_array($fld_name_1, $this->append_currency_symbol_to_value) || in_array($fld_name_2, $this->append_currency_symbol_to_value)) { $col_header .= " (" . $app_strings['LBL_IN'] . " " . $current_user->currency_symbol . ")"; $convert_price = true; } else { $convert_price = false; } $coltotalhtml .= '<td class="rptData">' . $col_header . '</td>'; $value = trim($key); $arraykey = $value . '_SUM'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]); } else { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true); } $coltotalhtml .= "<td class='rptTotal'>" . $conv_value . '</td>'; } else { $coltotalhtml .= "<td class='rptTotal'> </td>"; } $arraykey = $value . '_AVG'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]); } else { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true); } $coltotalhtml .= "<td class='rptTotal'>" . $conv_value . '</td>'; } else { $coltotalhtml .= "<td class='rptTotal'> </td>"; } $arraykey = $value . '_MIN'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]); } else { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true); } $coltotalhtml .= "<td class='rptTotal'>" . $conv_value . '</td>'; } else { $coltotalhtml .= "<td class='rptTotal'> </td>"; } $arraykey = $value . '_MAX'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]); } else { $conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true); } $coltotalhtml .= "<td class='rptTotal'>" . $conv_value . '</td>'; } else { $coltotalhtml .= "<td class='rptTotal'> </td>"; } $coltotalhtml .= '</tr>'; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } // END } $coltotalhtml .= "</table>"; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } // END } } return $coltotalhtml; } }
function generateData() { $db = PearDatabase::getInstance(); $chartSQL = $this->getQuery(); $result = $db->pquery($chartSQL, array()); $rows = $db->num_rows($result); $values = array(); $queryColumnsByFieldModel = $this->getQueryColumnsByFieldModel(); $recordCountLabel = ''; if($this->isRecordCount()) { $recordCountLabel = 'RECORD_COUNT'; } $groupByColumnsByFieldModel = $this->getGroupbyColumnsByFieldModel(); $currentUserModel = Users_Record_Model::getCurrentUserModel(); $currencyRateAndSymbol = getCurrencySymbolandCRate($currentUserModel->currency_id); $links = array(); for($i = 0; $i < $rows; $i++) { $row = $db->query_result_rowdata($result, $i); if($recordCountLabel) { $values[$i][] = (int) $row[strtolower($recordCountLabel)]; } if($queryColumnsByFieldModel) { foreach($queryColumnsByFieldModel as $fieldModel) { if($fieldModel->get('uitype') == '71' || $fieldModel->get('uitype') == '72') { $value = (float) ($row[strtolower($fieldModel->get('reportlabel'))]); $values[$i][] = CurrencyField::convertFromDollar($value, $currencyRateAndSymbol['rate']); } else { $values[$i][] = (int) $row[strtolower($fieldModel->get('reportlabel'))]; } } } if($groupByColumnsByFieldModel) { foreach($groupByColumnsByFieldModel as $gFieldModel) { $fieldDataType = $gFieldModel->getFieldDataType(); if($fieldDataType == 'picklist') { $label = vtranslate($row[strtolower($gFieldModel->get('reportlabel'))], $gFieldModel->getModuleName()); } else if($fieldDataType == 'multipicklist') { $multiPicklistValue = $row[strtolower($gFieldModel->get('reportlabel'))]; $multiPicklistValues = explode(' |##| ', $multiPicklistValue); foreach($multiPicklistValues as $multiPicklistValue) { $labelList[] = vtranslate($multiPicklistValue, $gFieldModel->getModuleName()); } $label = implode(',', $labelList); } else if($fieldDataType == 'date') { $label = Vtiger_Date_UIType::getDisplayDateValue($row[strtolower($gFieldModel->get('reportlabel'))]); } else if($fieldDataType == 'datetime') { $label = Vtiger_Date_UIType::getDisplayDateTimeValue($row[strtolower($gFieldModel->get('reportlabel'))]); } else { // SalesPlatform.ru begin $primaryModule = $this->getPrimaryModule(); if($primaryModule == 'PBXManager') { $label = getUserFullName($row[strtolower($gFieldModel->get('reportlabel'))]); } else { $label = $row[strtolower($gFieldModel->get('reportlabel'))]; } //$label = $row[strtolower($gFieldModel->get('reportlabel'))]; // SalesPlatform.ru end } //SalesPlatform.ru begin $labels[] = (mb_strlen($label, 'UTF-8') > 30) ? mb_substr($label, 0, 30).'..' : $label; //$labels[] = (strlen($label) > 30) ? substr($label, 0, 30).'..' : $label; //SalesPlatform.ru end $links[] = $this->generateLink($gFieldModel->get('reportcolumninfo'), $row[strtolower($gFieldModel->get('reportlabel'))]); } } } $data = array( 'labels' => $labels, 'values' => $values, 'links' => $links, 'type' => (count($values[0]) == 1) ? 'singleBar' : 'multiBar', 'data_labels' => $this->getDataLabels(), 'graph_label' => $this->getGraphLabel() ); return $data; }
function GenerateReport($outputformat, $filterlist, $directOutput = false) { global $adb, $current_user, $php_max_execution_time; global $modules, $app_strings; global $mod_strings, $current_language; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $modules_selected = array(); $modules_selected[] = $this->primarymodule; if (!empty($this->secondarymodule)) { $sec_modules = split(":", $this->secondarymodule); for ($i = 0; $i < count($sec_modules); $i++) { $modules_selected[] = $sec_modules[$i]; } } // Update Currency Field list $currencyfieldres = $adb->pquery("SELECT tabid, fieldlabel, uitype from vtiger_field WHERE uitype in (71,72,10)", array()); if ($currencyfieldres) { foreach ($currencyfieldres as $currencyfieldrow) { $modprefixedlabel = getTabModuleName($currencyfieldrow['tabid']) . ' ' . $currencyfieldrow['fieldlabel']; $modprefixedlabel = str_replace(' ', '_', $modprefixedlabel); if ($currencyfieldrow['uitype'] != 10) { if (!in_array($modprefixedlabel, $this->convert_currency) && !in_array($modprefixedlabel, $this->append_currency_symbol_to_value)) { $this->convert_currency[] = $modprefixedlabel; } } else { if (!in_array($modprefixedlabel, $this->ui10_fields)) { $this->ui10_fields[] = $modprefixedlabel; } } } } if ($outputformat == "HTML") { $sSQL = $this->sGetSQLforReport($this->reportid, $filterlist); $result = $adb->query($sSQL); $error_msg = $adb->database->ErrorMsg(); if (!$result && $error_msg != '') { // Performance Optimization: If direct output is requried if ($directOutput) { echo getTranslatedString('LBL_REPORT_GENERATION_FAILED', $currentModule) . "<br>" . $error_msg; $error_msg = false; } // END return $error_msg; } // Performance Optimization: If direct output is required if ($directOutput) { echo '<table cellpadding="5" cellspacing="0" align="center" class="rptTable"><tr>'; } // END if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { $picklistarray = $this->getAccessPickListValues(); } if ($result) { $y = $adb->num_fields($result); $arrayHeaders = array(); for ($x = 0; $x < $y; $x++) { $fld = $adb->field_name($result, $x); if (in_array($this->getLstringforReportHeaders($fld->name), $arrayHeaders)) { $headerLabel = str_replace("_", " ", $fld->name); $arrayHeaders[] = $headerLabel; } else { $headerLabel = str_replace($modules, " ", $this->getLstringforReportHeaders($fld->name)); $headerLabel = str_replace("_", " ", $this->getLstringforReportHeaders($fld->name)); $arrayHeaders[] = $headerLabel; } /*STRING TRANSLATION starts */ $mod_name = split(' ', $headerLabel, 2); $module = ''; if (in_array($mod_name[0], $modules_selected)) { $module = getTranslatedString($mod_name[0], $mod_name[0]); } if (!empty($this->secondarymodule)) { if ($module != '') { $headerLabel_tmp = $module . " " . getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } else { if ($module != '') { $headerLabel_tmp = getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } if ($headerLabel == $headerLabel_tmp) { $headerLabel = getTranslatedString($headerLabel_tmp); } else { $headerLabel = $headerLabel_tmp; } /*STRING TRANSLATION ends */ $header .= "<td class='rptCellLabel'>" . $headerLabel . "</td>"; // Performance Optimization: If direct output is required if ($directOutput) { echo $header; $header = ''; } // END } // Performance Optimization: If direct output is required if ($directOutput) { echo '</tr><tr>'; } // END $noofrows = $adb->num_rows($result); $custom_field_values = $adb->fetch_array($result); $groupslist = $this->getGroupingList($this->reportid); $column_definitions = $adb->getFieldsDefinition($result); do { $arraylists = array(); if (count($groupslist) == 1) { $newvalue = $custom_field_values[0]; } elseif (count($groupslist) == 2) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; } elseif (count($groupslist) == 3) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; $tnewvalue = $custom_field_values[2]; } if ($newvalue == "") { $newvalue = "-"; } if ($snewvalue == "") { $snewvalue = "-"; } if ($tnewvalue == "") { $tnewvalue = "-"; } $valtemplate .= "<tr>"; // Performance Optimization if ($directOutput) { echo $valtemplate; $valtemplate = ''; } // END for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); $fld_type = $column_definitions[$i]->type; if (in_array($fld->name, $this->convert_currency)) { if ($custom_field_values[$i] != '') { $fieldvalue = convertFromMasterCurrency($custom_field_values[$i], $current_user->conv_rate); } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } } elseif (in_array($fld->name, $this->append_currency_symbol_to_value)) { $curid_value = explode("::", $custom_field_values[$i]); $currency_id = $curid_value[0]; $currency_value = $curid_value[1]; $cur_sym_rate = getCurrencySymbolandCRate($currency_id); if ($custom_field_values[$i] != '') { $fieldvalue = $cur_sym_rate['symbol'] . " " . $currency_value; } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } } elseif ($fld->name == "PurchaseOrder_Currency" || $fld->name == "SalesOrder_Currency" || $fld->name == "Invoice_Currency" || $fld->name == "Quotes_Currency") { if ($custom_field_values[$i] != '') { $fieldvalue = getCurrencyName($custom_field_values[$i]); } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } } elseif (in_array($fld->name, $this->ui10_fields) && !empty($custom_field_values[$i])) { $type = getSalesEntityType($custom_field_values[$i]); $tmp = getEntityName($type, $custom_field_values[$i]); foreach ($tmp as $key => $val) { $fieldvalue = $val; break; } } else { if ($custom_field_values[$i] != '') { $fieldvalue = getTranslatedString($custom_field_values[$i]); } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } } $fieldvalue = str_replace("<", "<", $fieldvalue); $fieldvalue = str_replace(">", ">", $fieldvalue); //check for Roll based pick list $temp_val = $fld->name; if (is_array($picklistarray)) { if (array_key_exists($temp_val, $picklistarray)) { if (!in_array($custom_field_values[$i], $picklistarray[$fld->name]) && $custom_field_values[$i] != '') { $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE']; } } } if (is_array($picklistarray[1])) { if (array_key_exists($temp_val, $picklistarray[1])) { $temp = explode(",", str_ireplace(' |##| ', ',', $fieldvalue)); $temp_val = array(); foreach ($temp as $key => $val) { if (!in_array(trim($val), $picklistarray[1][$fld->name]) && trim($val) != '') { $temp_val[] = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $temp_val[] = $val; } } $fieldvalue = is_array($temp_val) ? implode(", ", $temp_val) : ''; } } if ($fieldvalue == "") { $fieldvalue = "-"; } else { if (stristr($fieldvalue, "|##|")) { $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); } else { if ($fld_type == "date" || $fld_type == "datetime") { $fieldvalue = getDisplayDate($fieldvalue); } } } if ($lastvalue == $fieldvalue && $this->reporttype == "summary") { if ($this->reporttype == "summary") { $valtemplate .= "<td class='rptEmptyGrp'> </td>"; } else { $valtemplate .= "<td class='rptData'>" . $fieldvalue . "</td>"; } } else { if ($secondvalue === $fieldvalue && $this->reporttype == "summary") { if ($lastvalue === $newvalue) { $valtemplate .= "<td class='rptEmptyGrp'> </td>"; } else { $valtemplate .= "<td class='rptGrpHead'>" . $fieldvalue . "</td>"; } } else { if ($thirdvalue === $fieldvalue && $this->reporttype == "summary") { if ($secondvalue === $snewvalue) { $valtemplate .= "<td class='rptEmptyGrp'> </td>"; } else { $valtemplate .= "<td class='rptGrpHead'>" . $fieldvalue . "</td>"; } } else { if ($this->reporttype == "tabular") { $valtemplate .= "<td class='rptData'>" . $fieldvalue . "</td>"; } else { $valtemplate .= "<td class='rptGrpHead'>" . $fieldvalue . "</td>"; } } } } // Performance Optimization: If direct output is required if ($directOutput) { echo $valtemplate; $valtemplate = ''; } // END } $valtemplate .= "</tr>"; // Performance Optimization: If direct output is required if ($directOutput) { echo $valtemplate; $valtemplate = ''; } // END $lastvalue = $newvalue; $secondvalue = $snewvalue; $thirdvalue = $tnewvalue; $arr_val[] = $arraylists; set_time_limit($php_max_execution_time); } while ($custom_field_values = $adb->fetch_array($result)); // Performance Optimization if ($directOutput) { echo "</tr></table>"; echo "<script type='text/javascript' id='__reportrun_directoutput_recordcount_script'>\n\t\t\t\t\t\tif(\$('_reportrun_total')) \$('_reportrun_total').innerHTML={$noofrows};</script>"; } else { $sHTML = '<table cellpadding="5" cellspacing="0" align="center" class="rptTable"> <tr>' . $header . '<!-- BEGIN values --> <tr>' . $valtemplate . '</tr> </table>'; } //<<<<<<<<construct HTML>>>>>>>>>>>> $return_data[] = $sHTML; $return_data[] = $noofrows; $return_data[] = $sSQL; return $return_data; } } elseif ($outputformat == "PDF") { $sSQL = $this->sGetSQLforReport($this->reportid, $filterlist); $result = $adb->query($sSQL); if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { $picklistarray = $this->getAccessPickListValues(); } if ($result) { $y = $adb->num_fields($result); $noofrows = $adb->num_rows($result); $custom_field_values = $adb->fetch_array($result); $column_definitions = $adb->getFieldsDefinition($result); do { $arraylists = array(); for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); if (in_array($fld->name, $this->convert_currency)) { $fieldvalue = convertFromMasterCurrency($custom_field_values[$i], $current_user->conv_rate); } elseif (in_array($fld->name, $this->append_currency_symbol_to_value)) { $curid_value = explode("::", $custom_field_values[$i]); $currency_id = $curid_value[0]; $currency_value = $curid_value[1]; $cur_sym_rate = getCurrencySymbolandCRate($currency_id); $fieldvalue = $cur_sym_rate['symbol'] . " " . $currency_value; } elseif ($fld->name == "PurchaseOrder_Currency" || $fld->name == "SalesOrder_Currency" || $fld->name == "Invoice_Currency" || $fld->name == "Quotes_Currency") { $fieldvalue = getCurrencyName($custom_field_values[$i]); } elseif (in_array($fld->name, $this->ui10_fields) && !empty($custom_field_values[$i])) { $type = getSalesEntityType($custom_field_values[$i]); $tmp = getEntityName($type, $custom_field_values[$i]); foreach ($tmp as $key => $val) { $fieldvalue = $val; break; } } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } $append_cur = str_replace($fld->name, "", decode_html($this->getLstringforReportHeaders($fld->name))); $headerLabel = str_replace("_", " ", $fld->name); /*STRING TRANSLATION starts */ $mod_name = split(' ', $headerLabel, 2); $module = ''; if (in_array($mod_name[0], $modules_selected)) { $module = getTranslatedString($mod_name[0], $mod_name[0]); } if (!empty($this->secondarymodule)) { if ($module != '') { $headerLabel_tmp = $module . " " . getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } else { if ($module != '') { $headerLabel_tmp = getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } if ($headerLabel == $headerLabel_tmp) { $headerLabel = getTranslatedString($headerLabel_tmp); } else { $headerLabel = $headerLabel_tmp; } /*STRING TRANSLATION starts */ if (trim($append_cur) != "") { $headerLabel .= $append_cur; } $fieldvalue = str_replace("<", "<", $fieldvalue); $fieldvalue = str_replace(">", ">", $fieldvalue); // Check for role based pick list $temp_val = $fld->name; if (is_array($picklistarray)) { if (array_key_exists($temp_val, $picklistarray)) { if (!in_array($custom_field_values[$i], $picklistarray[$fld->name]) && $custom_field_values[$i] != '') { $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE']; } } } if (is_array($picklistarray[1])) { if (array_key_exists($temp_val, $picklistarray[1])) { $temp = explode(",", str_ireplace(' |##| ', ',', $fieldvalue)); $temp_val = array(); foreach ($temp as $key => $val) { if (!in_array(trim($val), $picklistarray[1][$fld->name]) && trim($val) != '') { $temp_val[] = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $temp_val[] = $val; } } $fieldvalue = is_array($temp_val) ? implode(", ", $temp_val) : ''; } } if ($fieldvalue == "") { $fieldvalue = "-"; } else { if (stristr($fieldvalue, "|##|")) { $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); } else { if ($fld_type == "date" || $fld_type == "datetime") { $fieldvalue = getDisplayDate($fieldvalue); } } } if (array_key_exists($this->getLstringforReportHeaders($fld->name), $arraylists)) { $arraylists[$headerLabel] = $fieldvalue; } else { $arraylists[$headerLabel] = $fieldvalue; } } $arr_val[] = $arraylists; set_time_limit($php_max_execution_time); } while ($custom_field_values = $adb->fetch_array($result)); return $arr_val; } } elseif ($outputformat == "TOTALHTML") { $escapedchars = array('_SUM', '_AVG', '_MIN', '_MAX'); $sSQL = $this->sGetSQLforReport($this->reportid, $filterlist, "COLUMNSTOTOTAL"); if (isset($this->totallist)) { if ($sSQL != "") { $result = $adb->query($sSQL); $y = $adb->num_fields($result); $custom_field_values = $adb->fetch_array($result); $coltotalhtml .= "<table align='center' width='60%' cellpadding='3' cellspacing='0' border='0' class='rptTable'><tr><td class='rptCellLabel'>" . $mod_strings[Totals] . "</td><td class='rptCellLabel'>" . $mod_strings[SUM] . "</td><td class='rptCellLabel'>" . $mod_strings[AVG] . "</td><td class='rptCellLabel'>" . $mod_strings[MIN] . "</td><td class='rptCellLabel'>" . $mod_strings[MAX] . "</td></tr>"; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } // END foreach ($this->totallist as $key => $value) { $fieldlist = explode(":", $key); $mod_query = $adb->pquery("SELECT distinct(tabid) as tabid, uitype as uitype from vtiger_field where tablename = ? and columnname=?", array($fieldlist[1], $fieldlist[2])); if ($adb->num_rows($mod_query) > 0) { $module_name = getTabName($adb->query_result($mod_query, 0, 'tabid')); $fieldlabel = trim(str_replace($escapedchars, " ", $fieldlist[3])); $fieldlabel = str_replace("_", " ", $fieldlabel); if ($module_name) { $field = getTranslatedString($module_name) . " " . getTranslatedString($fieldlabel, $module_name); } else { $field = getTranslatedString($module_name) . " " . getTranslatedString($fieldlabel); } } $uitype_arr[str_replace($escapedchars, " ", $module_name . "_" . $fieldlist[3])] = $adb->query_result($mod_query, 0, "uitype"); $totclmnflds[str_replace($escapedchars, " ", $module_name . "_" . $fieldlist[3])] = $field; } for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); $keyhdr[$fld->name] = $custom_field_values[$i]; } foreach ($totclmnflds as $key => $value) { $coltotalhtml .= '<tr class="rptGrpHead" valign=top>'; $col_header = trim(str_replace($modules, " ", $value)); $fld_name_1 = $this->primarymodule . "_" . trim($value); $fld_name_2 = $this->secondarymodule . "_" . trim($value); if ($uitype_arr[$value] == 71 || in_array($fld_name_1, $this->convert_currency) || in_array($fld_name_1, $this->append_currency_symbol_to_value) || in_array($fld_name_2, $this->convert_currency) || in_array($fld_name_2, $this->append_currency_symbol_to_value)) { $col_header .= " (" . $app_strings['LBL_IN'] . " " . $current_user->currency_symbol . ")"; $convert_price = true; } else { $convert_price = false; } $coltotalhtml .= '<td class="rptData">' . $col_header . '</td>'; $value = trim($key); $arraykey = $value . '_SUM'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td class="rptTotal">' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td class="rptTotal"> </td>'; } $arraykey = $value . '_AVG'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td class="rptTotal">' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td class="rptTotal"> </td>'; } $arraykey = $value . '_MIN'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td class="rptTotal">' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td class="rptTotal"> </td>'; } $arraykey = $value . '_MAX'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td class="rptTotal">' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td class="rptTotal"> </td>'; } $coltotalhtml .= '<tr>'; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } // END } $coltotalhtml .= "</table>"; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } // END } } return $coltotalhtml; } elseif ($outputformat == "PRINT") { $sSQL = $this->sGetSQLforReport($this->reportid, $filterlist); $result = $adb->query($sSQL); if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { $picklistarray = $this->getAccessPickListValues(); } if ($result) { $y = $adb->num_fields($result); $arrayHeaders = array(); for ($x = 0; $x < $y; $x++) { $fld = $adb->field_name($result, $x); if (in_array($this->getLstringforReportHeaders($fld->name), $arrayHeaders)) { $headerLabel = str_replace("_", " ", $fld->name); $arrayHeaders[] = $headerLabel; } else { $headerLabel = str_replace($modules, " ", $this->getLstringforReportHeaders($fld->name)); $arrayHeaders[] = $headerLabel; } /*STRING TRANSLATION starts */ $mod_name = split(' ', $headerLabel, 2); $module = ''; if (in_array($mod_name[0], $modules_selected)) { $module = getTranslatedString($mod_name[0], $mod_name[0]); } if (!empty($this->secondarymodule)) { if ($module != '') { $headerLabel_tmp = $module . " " . getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } else { if ($module != '') { $headerLabel_tmp = getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } if ($headerLabel == $headerLabel_tmp) { $headerLabel = getTranslatedString($headerLabel_tmp); } else { $headerLabel = $headerLabel_tmp; } /*STRING TRANSLATION ends */ $header .= "<th>" . $headerLabel . "</th>"; } $noofrows = $adb->num_rows($result); $custom_field_values = $adb->fetch_array($result); $groupslist = $this->getGroupingList($this->reportid); $column_definitions = $adb->getFieldsDefinition($result); do { $arraylists = array(); if (count($groupslist) == 1) { $newvalue = $custom_field_values[0]; } elseif (count($groupslist) == 2) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; } elseif (count($groupslist) == 3) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; $tnewvalue = $custom_field_values[2]; } if ($newvalue == "") { $newvalue = "-"; } if ($snewvalue == "") { $snewvalue = "-"; } if ($tnewvalue == "") { $tnewvalue = "-"; } $valtemplate .= "<tr>"; for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); if (in_array($fld->name, $this->convert_currency)) { $fieldvalue = convertFromMasterCurrency($custom_field_values[$i], $current_user->conv_rate); } elseif (in_array($fld->name, $this->append_currency_symbol_to_value)) { $curid_value = explode("::", $custom_field_values[$i]); $currency_id = $curid_value[0]; $currency_value = $curid_value[1]; $cur_sym_rate = getCurrencySymbolandCRate($currency_id); $fieldvalue = $cur_sym_rate['symbol'] . " " . $currency_value; } elseif ($fld->name == "PurchaseOrder_Currency" || $fld->name == "SalesOrder_Currency" || $fld->name == "Invoice_Currency" || $fld->name == "Quotes_Currency") { $fieldvalue = getCurrencyName($custom_field_values[$i]); } elseif (in_array($fld->name, $this->ui10_fields) && !empty($custom_field_values[$i])) { $type = getSalesEntityType($custom_field_values[$i]); $tmp = getEntityName($type, $custom_field_values[$i]); foreach ($tmp as $key => $val) { $fieldvalue = $val; break; } } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } $fieldvalue = str_replace("<", "<", $fieldvalue); $fieldvalue = str_replace(">", ">", $fieldvalue); //Check For Role based pick list $temp_val = $fld->name; if (is_array($picklistarray)) { if (array_key_exists($temp_val, $picklistarray)) { if (!in_array($custom_field_values[$i], $picklistarray[$fld->name]) && $custom_field_values[$i] != '') { $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE']; } } } if (is_array($picklistarray[1])) { if (array_key_exists($temp_val, $picklistarray[1])) { $temp = explode(",", str_ireplace(' |##| ', ',', $fieldvalue)); $temp_val = array(); foreach ($temp as $key => $val) { if (!in_array(trim($val), $picklistarray[1][$fld->name]) && trim($val) != '') { $temp_val[] = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $temp_val[] = $val; } } $fieldvalue = is_array($temp_val) ? implode(", ", $temp_val) : ''; } } if ($fieldvalue == "") { $fieldvalue = "-"; } else { if (stristr($fieldvalue, "|##|")) { $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); } else { if ($fld_type == "date" || $fld_type == "datetime") { $fieldvalue = getDisplayDate($fieldvalue); } } } if ($lastvalue == $fieldvalue && $this->reporttype == "summary") { if ($this->reporttype == "summary") { $valtemplate .= "<td style='border-top:1px dotted #FFFFFF;'> </td>"; } else { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } } else { if ($secondvalue == $fieldvalue && $this->reporttype == "summary") { if ($lastvalue == $newvalue) { $valtemplate .= "<td style='border-top:1px dotted #FFFFFF;'> </td>"; } else { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } } else { if ($thirdvalue == $fieldvalue && $this->reporttype == "summary") { if ($secondvalue == $snewvalue) { $valtemplate .= "<td style='border-top:1px dotted #FFFFFF;'> </td>"; } else { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } } else { if ($this->reporttype == "tabular") { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } else { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } } } } } $valtemplate .= "</tr>"; $lastvalue = $newvalue; $secondvalue = $snewvalue; $thirdvalue = $tnewvalue; $arr_val[] = $arraylists; set_time_limit($php_max_execution_time); } while ($custom_field_values = $adb->fetch_array($result)); $sHTML = '<tr>' . $header . '</tr>' . $valtemplate; $return_data[] = $sHTML; $return_data[] = $noofrows; return $return_data; } } elseif ($outputformat == "PRINT_TOTAL") { $escapedchars = array('_SUM', '_AVG', '_MIN', '_MAX'); $sSQL = $this->sGetSQLforReport($this->reportid, $filterlist, "COLUMNSTOTOTAL"); if (isset($this->totallist)) { if ($sSQL != "") { $result = $adb->query($sSQL); $y = $adb->num_fields($result); $custom_field_values = $adb->fetch_array($result); $coltotalhtml .= '<table width="100%" border="0" cellpadding="5" cellspacing="0" align="center" class="printReport" ><tr><th>' . $mod_strings[Totals] . '</th><th>' . $mod_strings[SUM] . '</th><th>' . $mod_strings[AVG] . '</th><th>' . $mod_strings[MIN] . '</th><th>' . $mod_strings[MAX] . '</th></tr>'; foreach ($this->totallist as $key => $value) { $fieldlist = explode(":", $key); $totclmnflds[str_replace($escapedchars, " ", $fieldlist[3])] = str_replace($escapedchars, " ", $fieldlist[3]); } for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); $keyhdr[$fld->name] = $custom_field_values[$i]; } foreach ($totclmnflds as $key => $value) { $coltotalhtml .= '<tr valign=top>'; $col_header = getTranslatedString(trim(str_replace($modules, " ", $value))); $fld_name_1 = $this->primarymodule . "_" . trim($value); $fld_name_2 = $this->secondarymodule . "_" . trim($value); if (in_array($fld_name_1, $this->convert_currency) || in_array($fld_name_1, $this->append_currency_symbol_to_value) || in_array($fld_name_2, $this->convert_currency) || in_array($fld_name_2, $this->append_currency_symbol_to_value)) { $col_header .= " (" . $app_strings['LBL_IN'] . " " . $current_user->currency_symbol . ")"; $convert_price = true; } else { $convert_price = false; } $coltotalhtml .= '<td>' . $col_header . '</td>'; $arraykey = trim($value) . '_SUM'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td>' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td> </td>'; } $arraykey = trim($value) . '_AVG'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td>' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td> </td>'; } $arraykey = trim($value) . '_MIN'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td>' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td> </td>'; } $arraykey = trim($value) . '_MAX'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td>' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td> </td>'; } $coltotalhtml .= '<tr>'; } $coltotalhtml .= "</table>"; } } return $coltotalhtml; } }
* defined return URL. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ require_once 'modules/Quotes/Quotes.php'; require_once 'include/logging.php'; require_once 'include/database/PearDatabase.php'; include_once "modules/Emails/mail.php"; $local_log =& LoggerManager::getLogger('index'); $focus = new Quotes(); //added to fix 4600 $search = vtlib_purify($_REQUEST['search_url']); setObjectValuesFromRequest($focus); $focus->column_fields['currency_id'] = $_REQUEST['inventory_currency']; $cur_sym_rate = getCurrencySymbolandCRate($_REQUEST['inventory_currency']); $focus->column_fields['conversion_rate'] = $cur_sym_rate['rate']; if ($_REQUEST['assigntype'] == 'U') { $focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_user_id']; } elseif ($_REQUEST['assigntype'] == 'T') { $focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_group_id']; } $focus->save("Quotes"); $return_id = $focus->id; $parenttab = getParentTab(); if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") { $return_module = vtlib_purify($_REQUEST['return_module']); } else { $return_module = "Quotes"; } if (isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") {
function getListViewRecords($focus, $module, $result) { global $listview_max_textlength, $theme, $default_charset; require 'user_privileges/user_privileges_' . $this->user->id . '.php'; $fields = $this->queryGenerator->getFields(); $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule()); $moduleFields = $this->queryGenerator->getModuleFields(); $accessibleFieldList = array_keys($moduleFields); $listViewFields = array_intersect($fields, $accessibleFieldList); $referenceFieldList = $this->queryGenerator->getReferenceFieldList(); foreach ($referenceFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $this->fetchNameList($field, $result); } } $db = PearDatabase::getInstance(); $rowCount = $db->num_rows($result); $ownerFieldList = $this->queryGenerator->getOwnerFieldList(); foreach ($ownerFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $idList = array(); for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $field->getColumnName()); if (!isset($this->ownerNameList[$fieldName][$id])) { $idList[] = $id; } } if (count($idList) > 0) { if (!is_array($this->ownerNameList[$fieldName])) { $this->ownerNameList[$fieldName] = getOwnerNameList($idList); } else { //array_merge API loses key information so need to merge the arrays // manually. $newOwnerList = getOwnerNameList($idList); foreach ($newOwnerList as $id => $name) { $this->ownerNameList[$fieldName][$id] = $name; } } } } } foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) { $this->setupAccessiblePicklistValueList($fieldName); } } $useAsterisk = get_use_asterisk($this->user->id); $data = array(); for ($i = 0; $i < $rowCount; ++$i) { //Getting the recordId if ($module != 'Users') { $baseTable = $meta->getEntityBaseTable(); $moduleTableIndexList = $meta->getEntityTableIndexList(); $baseTableIndex = $moduleTableIndexList[$baseTable]; $recordId = $db->query_result($result, $i, $baseTableIndex); } else { $recordId = $db->query_result($result, $i, "id"); } $row = array(); foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; $uitype = $field->getUIType(); $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); if (in_array($uitype, array(15, 33, 16))) { $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset); } else { $value = $rawValue; } if ($module == 'Documents' && $fieldName == 'filename') { $downloadtype = $db->query_result($result, $i, 'filelocationtype'); $fileName = $db->query_result($result, $i, 'filename'); $downloadType = $db->query_result($result, $i, 'filelocationtype'); $status = $db->query_result($result, $i, 'filestatus'); $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($recordId)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($fileName != '' && $status == 1) { if ($downloadType == 'I') { $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="index.php?module=Documents&action=DownloadFile&record=' . $recordId . '&fileid=' . $fileId . '"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>'; } elseif ($downloadType == 'E') { $value = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="' . $fileName . '" target="_blank"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $module) . '" >' . textlength_check($value) . '</a>'; } else { $value = ' --'; } } $value = $fileicon . $value; } elseif ($module == 'Documents' && $fieldName == 'filesize') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } elseif ($module == 'Documents' && $fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($module == 'Documents' && $fieldName == 'filetype') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'E' || $downloadType != 'I') { $value = '--'; } } elseif ($module == 'OSSTimeControl' && $fieldName == 'sum_time') { $value = Vtiger_Functions::decimalTimeFormat($value); $value = $value['short']; } elseif ($field->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } $value = Vtiger_Functions::textLength($value); } elseif ($field->getFieldDataType() == 'picklist') { $value = Vtiger_Language_Handler::getTranslatedString($value, $module); $value = textlength_check($value); } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') { if ($value != '' && $value != '0000-00-00') { $fieldDataType = $field->getFieldDataType(); if ($module == 'Calendar' && ($fieldName == 'date_start' || $fieldName == 'due_date')) { if ($fieldName == 'date_start') { $timeField = 'time_start'; } else { if ($fieldName == 'due_date') { $timeField = 'time_end'; } } $timeFieldValue = $this->db->query_result($result, $i, $timeField); if (!empty($timeFieldValue)) { $value .= ' ' . $timeFieldValue; //TO make sure it takes time value as well $fieldDataType = 'datetime'; } } if ($fieldDataType == 'datetime') { $value = Vtiger_Datetime_UIType::getDateTimeValue($value); } else { if ($fieldDataType == 'date') { $date = new DateTimeField($value); $value = $date->getDisplayDate(); } } } elseif ($value == '0000-00-00') { $value = ''; } } elseif ($field->getFieldDataType() == 'time') { if (!empty($value)) { $userModel = Users_Privileges_Model::getCurrentUserModel(); if ($userModel->get('hour_format') == '12') { $value = Vtiger_Time_UIType::getTimeValueInAMorPM($value); } } } elseif ($field->getFieldDataType() == 'currency') { if ($value != '') { if ($field->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $module); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($module, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $value = CurrencyField::convertToUserFormat($value, null, true); $row['currencySymbol'] = $currencySymbol; $value = CurrencyField::appendCurrencySymbol($value, $currencySymbol); } else { if (!empty($value)) { $value = CurrencyField::convertToUserFormat($value); $currencyModal = new CurrencyField($value); $currencyModal->initialize(); $value = $currencyModal->appendCurrencySymbol($value, $currencyModal->currencySymbol); } } } } elseif ($field->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $rawValue, $matches); if (!empty($matches[0])) { $value = '<a class="urlField cursorPointer" title="' . $rawValue . '" href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a class="urlField cursorPointer" title="' . $rawValue . '" href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'email') { $current_user = vglobal('current_user'); if ($current_user->internal_mailer == 1) { //check added for email link in user detailview $value = "<a class='emailField' onclick=\"Vtiger_Helper_Js.getInternalMailer({$recordId}," . "'{$fieldName}','{$module}');\">" . textlength_check($value) . "</a>"; } else { $value = '<a class="emailField" href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'boolean') { if ($value === 'on') { $value = 1; } else { if ($value == 'off') { $value = 0; } } if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($field->getUIType() == 98) { $value = '<a href="index.php?module=Roles&parent=Settings&view=Edit&record=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>'; } elseif ($field->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; if (!$is_admin && $value != '') { $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array(); $tmp = ''; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) { $tmpArray[] = $val; $tmp .= ', ' . $val; } else { $tmpArray[] = '...'; $tmp .= '...'; } } $value = implode(', ', $tmpArray); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'skype') { $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : ""; } elseif ($field->getUIType() == 11) { $outgoingCallPermission = Vtiger_Mobile_Model::checkPermissionForOutgoingCall(); if ($outgoingCallPermission && !empty($value)) { $phoneNumber = preg_replace('/[-()\\s]/', '', $value); $value = '<a class="phoneField" data-phoneNumber="' . $phoneNumber . '" record="' . $recordId . '" onclick="Vtiger_Mobile_Js.registerOutboundCall(\'' . $phoneNumber . '\', ' . $recordId . ')">' . textlength_check($value) . '</a>'; $callUsers = Vtiger_Mobile_Model::getPrivilegesUsers(); if ($callUsers) { $value .= ' <a class="btn btn-xs noLinkBtn" onclick="Vtiger_Mobile_Js.registerOutboundCallToUser(this,\'' . $phoneNumber . '\',' . $recordId . ')" data-placement="right" data-original-title="' . vtranslate('LBL_SELECT_USER_TO_CALL', $module) . '" data-content=\'<select class="select sesectedUser" name="sesectedUser">'; foreach ($callUsers as $key => $item) { $value .= '<option value="' . $key . '">' . $item . '</option>'; } $value .= '</select><br /><a class="btn btn-success popoverCallOK">' . vtranslate('LBL_BTN_CALL', $module) . '</a> <a class="btn btn-inverse popoverCallCancel">' . vtranslate('LBL_CANCEL', $module) . '</a>\' data-trigger="manual"><i class="icon-user"></i></a>'; } } else { $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'reference') { $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList(); $moduleList = $referenceFieldInfoList[$fieldName]; if (count($moduleList) == 1) { $parentModule = reset($moduleList); } else { $parentModule = $this->typeList[$value]; } if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) { $parentMeta = $this->queryGenerator->getMeta($parentModule); $value = textlength_check($this->nameList[$fieldName][$value]); if ($parentMeta->isModuleEntity() && $parentModule != "Users") { $value = "<a class='moduleColor_{$parentModule}' href='?module={$parentModule}&view=Detail&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>"; } } else { $value = '--'; } } elseif ($field->getFieldDataType() == 'owner') { $value = textlength_check($this->ownerNameList[$fieldName][$value]); } elseif ($field->getUIType() == 25) { //TODO clean request object reference. $contactId = $_REQUEST['record']; $emailId = $this->db->query_result($result, $i, "activityid"); $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId)); $value = $this->db->query_result($result1, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($field->getUIType() == 8) { if (!empty($value)) { $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } elseif ($field->getFieldDataType() == 'taxes') { if (!empty($value)) { $valueArray = $value != "" ? explode(',', $value) : []; $tmp = ''; $tmpArray = []; $taxs = Vtiger_Taxes_UIType::getTaxes(); foreach ($valueArray as $index => $tax) { if (isset($taxs[$tax])) { $tmpArray[] = $taxs[$tax]['value'] . '% - ' . $taxs[$tax]['name']; } } $value = implode(', ', $tmpArray); $value = Vtiger_Functions::textLength($value); } } elseif ($field->getFieldDataType() == 'inventoryLimit') { if (!empty($value)) { $valueArray = $value != "" ? explode(',', $value) : []; $tmp = ''; $tmpArray = []; $limits = Vtiger_InventoryLimit_UIType::getLimits(); foreach ($valueArray as $index => $limit) { if (isset($limits[$limit])) { $tmpArray[] = $limits[$limit]['value'] . ' - ' . $limits[$limit]['name']; } } $value = implode(', ', $tmpArray); $value = Vtiger_Functions::textLength($value); } } elseif ($field->getFieldDataType() == 'multiReferenceValue') { $params = $field->getFieldParams(); $fieldModel = Vtiger_Field_Model::getInstanceFromFieldId($params['field']); $valueTmp = trim($value, '|#|'); $valueTmp = $valueTmp != "" ? explode('|#|', $valueTmp) : []; foreach ($valueTmp as $index => $tmp) { $valueTmp[$index] = $fieldModel->getUITypeModel()->getDisplayValue($tmp); } $value = implode(', ', $valueTmp); $value = Vtiger_Functions::textLength($value); } elseif (in_array($uitype, array(7, 9, 90))) { $value = "<span align='right'>" . textlength_check($value) . "</div>"; } else { $value = Vtiger_Functions::textLength($value); } // // vtlib customization: For listview javascript triggers // $value = "$value <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=". // "'{$fieldName}' vtmodule='$module' style='display:none;'></span>"; // // END $row[$fieldName] = $value; } $data[$recordId] = $row; } return $data; }
/** * Function that converts the Number into Users Currency along with currency symbol * @param Users $user * @param Boolean $skipConversion * @return Formatted Currency */ public function getDetailViewDisplayValue($value, $recordId, $uiType) { $currencyModal = new CurrencyField($value); $currencyModal->initialize(); if ($uiType == '72' && $recordId) { $moduleName = $this->get('field')->getModuleName(); if ($this->get('field')->getName() == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $moduleName); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($moduleName, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } } else { $currencySymbol = $currencyModal->currencySymbol; } return $currencyModal->appendCurrencySymbol($value, $currencySymbol); }
/** * Initializes the User's Currency Details * @global Users $current_user * @param Users $user */ public function initialize($user = null) { global $current_user, $default_charset; if (empty($user)) { $user = $current_user; } if (!empty($user->currency_grouping_pattern)) { $this->currencyFormat = html_entity_decode($user->currency_grouping_pattern, ENT_QUOTES, $default_charset); $this->currencySeparator = str_replace("Â ", ' ', html_entity_decode($user->currency_grouping_separator, ENT_QUOTES, $default_charset)); $this->decimalSeparator = str_replace("Â ", ' ', html_entity_decode($user->currency_decimal_separator, ENT_QUOTES, $default_charset)); } if (!empty($user->currency_id)) { $this->currencyId = $user->currency_id; } else { $this->currencyId = self::getDBCurrencyId(); } $currencyRateAndSymbol = getCurrencySymbolandCRate($this->currencyId); $this->currencySymbol = $currencyRateAndSymbol['symbol']; $this->conversionRate = $currencyRateAndSymbol['rate']; $this->currencySymbolPlacement = $user->currency_symbol_placement; $this->numberOfDecimal = getCurrencyDecimalPlaces(); }
public function getPDFMakerFieldValue($report, $picklistArray, $dbField, $valueArray, $fieldName) { global $current_user, $default_charset; $db = PearDatabase::getInstance(); $value = $valueArray[$fieldName]; $fld_type = $dbField->type; list($module, $fieldLabel) = explode('_', $dbField->name, 2); $fieldInfo = $this->getFieldByPDFMakerLabel($module, $fieldLabel); $fieldType = null; $fieldvalue = $value; if (!empty($fieldInfo)) { $field = WebserviceField::fromArray($db, $fieldInfo); $fieldType = $field->getFieldDataType(); } if ($fieldType == 'currency' && $value != '') { // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion if ($field->getUIType() == '72') { $curid_value = explode("::", $value); $currency_id = $curid_value[0]; $currency_value = $curid_value[1]; $cur_sym_rate = getCurrencySymbolandCRate($currency_id); if ($value != '') { if ($dbField->name == 'Products_Unit_Price') { // need to do this only for Products Unit Price if ($currency_id != 1) { $currency_value = (double) $cur_sym_rate['rate'] * (double) $currency_value; } } $formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true); $fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']); } } else { $currencyField = new CurrencyField($value); $fieldvalue = $currencyField->getDisplayValue(); } } elseif ($dbField->name == "PurchaseOrder_Currency" || $dbField->name == "SalesOrder_Currency" || $dbField->name == "Invoice_Currency" || $dbField->name == "Quotes_Currency" || $dbField->name == "PriceBooks_Currency") { if ($value != '') { $fieldvalue = getTranslatedCurrencyString($value); } } elseif (in_array($dbField->name, $this->ui101_fields) && !empty($value)) { $entityNames = getEntityName('Users', $value); $fieldvalue = $entityNames[$value]; } elseif ($fieldType == 'date' && !empty($value)) { if ($module == 'Calendar' && $field->getFieldName() == 'due_date') { $endTime = $valueArray['calendar_end_time']; if (empty($endTime)) { $recordId = $valueArray['calendar_id']; $endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId); } $date = new DateTimeField($value . ' ' . $endTime); $fieldvalue = $date->getDisplayDate(); } else { $fieldvalue = DateTimeField::convertToUserFormat($value); } } elseif ($fieldType == "datetime" && !empty($value)) { $date = new DateTimeField($value); $fieldvalue = $date->getDisplayDateTimeValue(); } elseif ($fieldType == 'time' && !empty($value) && $field->getFieldName() != 'duration_hours') { if ($field->getFieldName() == "time_start" || $field->getFieldName() == "time_end") { $date = new DateTimeField($value); $fieldvalue = $date->getDisplayTime(); } else { $fieldvalue = $value; } } elseif ($fieldType == "picklist" && !empty($value)) { if (is_array($picklistArray)) { if (is_array($picklistArray[$dbField->name]) && $field->getFieldName() != 'activitytype' && !in_array($value, $picklistArray[$dbField->name])) { $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $fieldvalue = $this->getTranslatedString($value, $module); } } else { $fieldvalue = $this->getTranslatedString($value, $module); } } elseif ($fieldType == "multipicklist" && !empty($value)) { if (is_array($picklistArray[1])) { $valueList = explode(' |##| ', $value); $translatedValueList = array(); foreach ($valueList as $value) { if (is_array($picklistArray[1][$dbField->name]) && !in_array($value, $picklistArray[1][$dbField->name])) { $translatedValueList[] = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $translatedValueList[] = $this->getTranslatedString($value, $module); } } } if (!is_array($picklistArray[1]) || !is_array($picklistArray[1][$dbField->name])) { $fieldvalue = str_replace(' |##| ', ', ', $value); } else { implode(', ', $translatedValueList); } } elseif ($fieldType == 'double') { if ($current_user->truncate_trailing_zeros == true) { $fieldvalue = decimalFormat($fieldvalue); } } if ($fieldvalue == "") { return "-"; } $fieldvalue = str_replace("<", "<", $fieldvalue); $fieldvalue = str_replace(">", ">", $fieldvalue); $fieldvalue = decode_html($fieldvalue); if (stristr($fieldvalue, "|##|") && empty($fieldType)) { $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); } elseif ($fld_type == "date" && empty($fieldType)) { $fieldvalue = DateTimeField::convertToUserFormat($fieldvalue); } elseif ($fld_type == "datetime" && empty($fieldType)) { $date = new DateTimeField($fieldvalue); $fieldvalue = $date->getDisplayDateTimeValue(); } // Added to render html tag for description fields if ($fieldInfo['uitype'] == '19' && ($module == 'Documents' || $module == 'Emails')) { return $fieldvalue; } return htmlentities($fieldvalue, ENT_QUOTES, $default_charset); }
function importRecord($obj, $inventoryFieldData, $lineItems) { global $adb, $log; $moduleName = $obj->module; $inventoryHandler = vtws_getModuleHandlerFromName($moduleName, $obj->user); $inventoryMeta = $inventoryHandler->getMeta(); $currency = ''; if (isset($inventoryFieldData['currency_id'])) { $currency = $inventoryFieldData['currency_id']; unset($inventoryFieldData['currency_id']); } $fieldData = $obj->transformForImport($inventoryFieldData, $inventoryMeta); $fieldData['pdoInformation'] = $lineItems; if (empty($fieldData) || empty($fieldData['pdoInformation'])) { return null; } $wsrs = $adb->pquery('select id from vtiger_ws_entity where name=?', array('Currency')); if ($wsrs and $adb->num_rows($wsrs) == 1) { $wsid = $adb->query_result($wsrs, 0, 0); } else { $wsid = 0; } if ($currency == ' ' or empty($currency)) { $currid = 1; } else { $currid = getCurrencyId($currency); } $cur_sym_rate = getCurrencySymbolandCRate($currid); $fieldData['currency_id'] = $wsid . 'x' . $currid; $fieldData['conversion_rate'] = $cur_sym_rate['rate']; $entityInfo = vtws_create($moduleName, $fieldData, $obj->user); $entityInfo['status'] = $obj->getImportRecordStatus('created'); return $entityInfo; }
/** Function used to get the converted amount from dollar which will be showed to the user * @param float $price - amount in dollor which we want to convert to the user configured amount * @return float $conv_price - amount in user configured currency */ function getConvertedPriceFromDollar($price) { global $current_user; $currencyid = fetchCurrency($current_user->id); $rate_symbol = getCurrencySymbolandCRate($currencyid); $conv_price = convertFromDollar($price, $rate_symbol['rate']); return $conv_price; }
function save_module($module) { global $current_user, $log, $adb; $cypid = $this->id; $data = $this->column_fields; // Entity has been saved, take next action $currencyid = fetchCurrency($current_user->id); $rate_symbol = getCurrencySymbolandCRate($currencyid); $rate = $rate_symbol['rate']; $value = 0; if (isset($data['amount']) and isset($data['cost'])) { $value = convertToDollar($data['amount'] - $data['cost'], $rate); } $adb->query("update vtiger_cobropago set benefit='{$value}' where cobropagoid=" . $cypid); $relatedId = $this->column_fields['related_id']; if (!empty($relatedId) and self::invoice_control_installed()) { Invoice::updateAmountDue($relatedId); } // Calculate related module balance $this->calculateRelatedTotals($this->column_fields['parent_id']); }
/** This function returns the vtiger_field details for a given vtiger_fieldname. * Param $uitype - UI type of the vtiger_field * Param $fieldname - Form vtiger_field name * Param $fieldlabel - Form vtiger_field label name * Param $maxlength - maximum length of the vtiger_field * Param $col_fields - array contains the vtiger_fieldname and values * Param $generatedtype - Field generated type (default is 1) * Param $module_name - module name * Return type is an array */ function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module_name, $mode = '', $typeofdata = null) { global $log, $app_strings, $adb, $default_charset, $theme, $mod_strings, $current_user; $log->debug("Entering getOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $maxlength . "," . print_r($col_fields, true) . "," . $generatedtype . "," . $module_name . ") method ..."); require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $fieldlabel = from_html($fieldlabel); $fieldvalue = array(); $final_arr = array(); $value = $col_fields[$fieldname]; $custfld = ''; $ui_type[] = $uitype; $editview_fldname[] = $fieldname; // vtlib customization: Related type field if ($uitype == '10') { global $adb; $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_name)); $entityTypes = array(); $parent_id = $value; for ($index = 0; $index < $adb->num_rows($fldmod_result); ++$index) { $entityTypes[] = $adb->query_result($fldmod_result, $index, 'relmodule'); } if (!empty($value)) { if ($adb->num_rows($fldmod_result) == 1) { $valueType = $adb->query_result($fldmod_result, 0, 0); } else { $valueType = getSalesEntityType($value); } $displayValueArray = getEntityName($valueType, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $value) { $displayValue = $value; } } } else { $displayValue = ''; $valueType = ''; $value = ''; } $editview_label[] = array('options' => $entityTypes, 'selected' => $valueType, 'displaylabel' => getTranslatedString($fieldlabel, $module_name)); $fieldvalue[] = array('displayvalue' => $displayValue, 'entityid' => $parent_id); } else { if ($uitype == 5 || $uitype == 6 || $uitype == 23) { $log->info("uitype is " . $uitype); if ($value == '') { //modified to fix the issue in trac(http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/1469) if ($fieldname != 'birthday' && $generatedtype != 2 && getTabid($module_name) != 14) { $disp_value = getNewDisplayDate(); } if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 6) { $curr_time = date('H:i', strtotime('+5 minutes')); } if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) { $curr_time = date('H:i', strtotime('+10 minutes')); } //Added to display the Contact - Support End Date as one year future instead of //today's date -- 30-11-2005 if ($fieldname == 'support_end_date' && $_REQUEST['module'] == 'Contacts') { $addyear = strtotime("+1 year"); $disp_value = DateTimeField::convertToUserFormat(date('Y-m-d', $addyear)); } elseif ($fieldname == 'validtill' && $_REQUEST['module'] == 'Quotes') { $disp_value = ''; } } else { if ($uitype == 6) { if ($col_fields['time_start'] != '' && ($module_name == 'Events' || $module_name == 'Calendar')) { $curr_time = $col_fields['time_start']; $value = $value . ' ' . $curr_time; } else { $curr_time = date('H:i', strtotime('+5 minutes')); } } if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) { if ($col_fields['time_end'] != '') { $curr_time = $col_fields['time_end']; $value = $value . ' ' . $curr_time; } else { $curr_time = date('H:i', strtotime('+10 minutes')); } } $disp_value = getValidDisplayDate($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); if (!empty($curr_time)) { if (($module_name == 'Events' || $module_name == 'Calendar') && ($uitype == 23 || $uitype == 6)) { $curr_time = DateTimeField::convertToUserTimeZone($curr_time); $curr_time = $curr_time->format('H:i'); } } else { $curr_time = ''; } if (empty($disp_value)) { $disp_value = ''; } $fieldvalue[] = array($disp_value => $curr_time); if ($uitype == 5 || $uitype == 23) { if ($module_name == 'Events' && $uitype == 23) { $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']); } else { $fieldvalue[] = array($date_format => $current_user->date_format); } } else { $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']); } } elseif ($uitype == 16) { require_once 'modules/PickList/PickListUtils.php'; $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldname = $adb->sql_escape_string($fieldname); $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid"; $params = array(); $pickListResult = $adb->pquery($pick_query, $params); $noofpickrows = $adb->num_rows($pickListResult); $options = array(); $pickcount = 0; $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $value = decode_html($value); $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname))); if ($value == trim($pickListValue)) { $chk_val = "selected"; $pickcount++; $found = true; } else { $chk_val = ''; } $pickListValue = to_html($pickListValue); if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } $fieldvalue[] = $options; } elseif ($uitype == 1613) { require_once 'modules/PickList/PickListUtils.php'; $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldname = $adb->sql_escape_string($fieldname); $pickListResult = getAllowedPicklistModules(); $options = array(); $options[] = ""; $pickcount = 0; $found = false; foreach ($pickListResult as $pKey => $pValue) { $value = decode_html($value); $pickListValue = decode_html($pValue); if ($value == trim($pickListValue)) { $chk_val = "selected"; $pickcount++; $found = true; } else { $chk_val = ''; } $pickListValue = to_html($pickListValue); if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue, $pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue, $pickListValue), $pickListValue, $chk_val); } } uasort($options, function ($a, $b) { return strtolower($a[0]) < strtolower($b[0]) ? -1 : 1; }); $fieldvalue[] = $options; } elseif ($uitype == 15 || $uitype == 33) { require_once 'modules/PickList/PickListUtils.php'; $roleid = $current_user->roleid; $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); $valueArr = explode("|##|", $value); foreach ($valueArr as $key => $value) { $valueArr[$key] = trim(html_entity_decode($value, ENT_QUOTES, $default_charset)); } $pickcount = 0; if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { if (in_array(trim($pickListValue), $valueArr)) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected'); } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $options; } elseif ($uitype == 3313) { require_once 'modules/PickList/PickListUtils.php'; $picklistValues = getAllowedPicklistModules(); $valueArr = explode("|##|", $value); foreach ($valueArr as $key => $value) { $valueArr[$key] = trim(html_entity_decode($value, ENT_QUOTES, $default_charset)); } $pickcount = 0; if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { if (in_array(trim($pickListValue), $valueArr)) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue, $pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue, $pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected'); } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); uasort($options, function ($a, $b) { return strtolower($a[0]) < strtolower($b[0]) ? -1 : 1; }); $fieldvalue[] = $options; } elseif ($uitype == 1024) { $options = array(); $arr_evo = explode(' |##| ', $value); $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); $uservalues = array_merge($subrole, array($roleid)); for ($i = 0; $i < sizeof($uservalues); $i++) { $currentValId = $uservalues[$i]; $currentValName = getRoleName($currentValId); if (in_array(trim($currentValId), $arr_evo)) { $chk_val = 'selected'; } else { $chk_val = ''; } $options[] = array($currentValName, $currentValId, $chk_val); } $fieldvalue[] = $options; $editview_label[] = getTranslatedString($fieldlabel, $module_name); } elseif ($uitype == 17) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 85) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 14) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 19 || $uitype == 20) { if (isset($_REQUEST['body'])) { $value = $_REQUEST['body']; } if ($fieldname == 'terms_conditions') { //Assign the value from focus->column_fields (if we create Invoice from SO the SO's terms and conditions will be loaded to Invoice's terms and conditions, etc.,) $value = $col_fields['terms_conditions']; //if the value is empty then only we should get the default Terms and Conditions if ($value == '' && $mode != 'edit') { $value = getTermsandConditions(); } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 21 || $uitype == 24) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 22) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 52 || $uitype == 77) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); global $current_user; if ($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } if ($uitype == 52) { $combo_lbl_name = 'assigned_user_id'; } elseif ($uitype == 77) { $combo_lbl_name = 'assigned_user_id1'; } //Control will come here only for Products - Handler and Quotes - Inventory Manager if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); } $fieldvalue[] = $users_combo; } elseif ($uitype == 53) { global $noof_group_rows; $editview_label[] = getTranslatedString($fieldlabel, $module_name); //Security Checks if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $result = get_current_user_access_groups($module_name); } else { $result = get_group_options(); } if ($result) { $nameArray = $adb->fetch_array($result); } $assigned_user_id = empty($value) ? $current_user->id : $value; if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); } if ($noof_group_rows != 0) { if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id), $assigned_user_id); } } $fieldvalue[] = $users_combo; $fieldvalue[] = $groups_combo; } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) { if (!isset($_REQUEST['convertmode']) || $_REQUEST['convertmode'] != 'update_quote_val' && $_REQUEST['convertmode'] != 'update_so_val') { if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') { $value = vtlib_purify($_REQUEST['account_id']); } } if ($value != '') { $account_name = getAccountName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $account_name; $fieldvalue[] = $value; } elseif ($uitype == 54) { $options = array(); $editview_label[] = getTranslatedString($fieldlabel, $module_name); $pick_query = "select * from vtiger_groups"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, "name"); if ($value == $pickListValue) { $chk_val = "selected"; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $fieldvalue[] = $options; } elseif ($uitype == 55 || $uitype == 255) { require_once 'modules/PickList/PickListUtils.php'; if ($uitype == 255) { $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'firstname', 'readwrite'); } if ($uitype == 255 && $fieldpermission == '0') { $fieldvalue[] = ''; } else { $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'salutationtype', 'readwrite'); if ($fieldpermission == '0') { $roleid = $current_user->roleid; $picklistValues = getAssignedPicklistValues('salutationtype', $roleid, $adb); $pickcount = 0; $salt_value = $col_fields["salutationtype"]; foreach ($picklistValues as $order => $pickListValue) { if ($salt_value == trim($pickListValue)) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && $salt_value != '') { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $salt_value, 'selected'); } $fieldvalue[] = $options; } else { $fieldvalue[] = ''; } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 59) { if ($_REQUEST['module'] == 'HelpDesk') { if (isset($_REQUEST['product_id']) & $_REQUEST['product_id'] != '') { $value = $_REQUEST['product_id']; } } elseif (isset($_REQUEST['parent_id']) & $_REQUEST['parent_id'] != '') { $value = vtlib_purify($_REQUEST['parent_id']); } if ($value != '') { $product_name = getProductName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $product_name; $fieldvalue[] = $value; } elseif ($uitype == 63) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); if ($value == '') { $value = 1; } $options = array(); $pick_query = "select * from vtiger_duration_minutes order by sortorderid"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); $salt_value = $col_fields["duration_minutes"]; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, "duration_minutes"); if ($salt_value == $pickListValue) { $chk_val = "selected"; } else { $chk_val = ''; } $options[$pickListValue] = $chk_val; } $fieldvalue[] = $value; $fieldvalue[] = $options; } elseif ($uitype == 64) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); $fieldvalue[] = $value; } elseif ($uitype == 156) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; $fieldvalue[] = $is_admin; } elseif ($uitype == 56) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; } elseif ($uitype == 57) { if ($value != '') { $displayValueArray = getEntityName('Contacts', $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } } elseif (isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') { if ($_REQUEST['module'] == 'Contacts' && ($fieldname = 'contact_id')) { $contact_name = ''; } else { $value = $_REQUEST['contact_id']; $displayValueArray = getEntityName('Contacts', $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } } } //Checking for contacts duplicate $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $contact_name; $fieldvalue[] = $value; } elseif ($uitype == 58) { if ($value != '') { $campaign_name = getCampaignName($value); } elseif (isset($_REQUEST['campaignid']) && $_REQUEST['campaignid'] != '') { if ($_REQUEST['module'] == 'Campaigns' && ($fieldname = 'campaignid')) { $campaign_name = ''; } else { $value = $_REQUEST['campaignid']; $campaign_name = getCampaignName($value); } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $campaign_name; $fieldvalue[] = $value; } elseif ($uitype == 61) { if ($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } if ($module_name == 'Emails' && $col_fields['record_id'] != '') { $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])); //to fix the issue in mail attachment on forwarding mails if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') { global $att_id_list; } for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) { $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid'); if ($attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); if ($attachmentsname != '') { $fieldvalue[$attachmentid] = '[ ' . $attachmentsname . ' ]'; } if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') { $att_id_list .= $attachmentid . ';'; } } } } else { if ($col_fields['record_id'] != '') { $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } } if ($value != '') { $filename = ' [ ' . $value . ' ]'; } if ($filename != '') { $fieldvalue[] = $filename; } if ($value != '') { $fieldvalue[] = $value; } } $editview_label[] = getTranslatedString($fieldlabel, $module_name); } elseif ($uitype == 28) { if ($col_fields['record_id'] != '') { $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } } if ($value != '' && $module_name != 'Documents') { $filename = ' [ ' . $value . ' ]'; } elseif ($value != '' && $module_name == 'Documents') { $filename = $value; } if ($filename != '') { $fieldvalue[] = $filename; } if ($value != '') { $fieldvalue[] = $value; } $editview_label[] = getTranslatedString($fieldlabel, $module_name); } elseif ($uitype == 69) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); if ($col_fields['record_id'] != "") { if ($module_name == 'Products') { $query = 'select vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name ,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?'; $params = array($col_fields['record_id']); } else { if ($module_name == 'Contacts') { $imageattachment = 'Image'; } else { $imageattachment = 'Attachment'; } $query = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t\t from vtiger_attachments\n\t\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid\n\t\t\t\t where vtiger_crmentity.setype='{$module_name} {$imageattachment}'\n\t\t\t\t and vtiger_attachments.name = ?\n\t\t\t\t and vtiger_seattachmentsrel.crmid=?"; $params = array($col_fields[$fieldname], $col_fields['record_id']); } $result_image = $adb->pquery($query, $params); for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) { $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid'); //decode_html - added to handle UTF-8 characters in file names //urlencode - added to handle special characters like #, %, etc., $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name'))); $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name')); $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path'); } if (is_array($image_array)) { for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) { $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr] . $image_id_array[$img_itr] . "_", "orgname" => $image_orgname_array[$img_itr]); } } else { $fieldvalue[] = ''; } } else { $fieldvalue[] = ''; } } elseif ($uitype == 62) { if (isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') { $value = vtlib_purify($_REQUEST['parent_id']); } if ($value != '') { $parent_module = getSalesEntityType($value); } if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') { $parent_module = "Accounts"; $value = $_REQUEST['account_id']; } if ($parent_module != 'Contacts') { if ($parent_module == "Leads") { $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $parent_name = $field_value; } } $lead_selected = "selected"; } elseif ($parent_module == "Accounts") { $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "accountname"); $account_selected = "selected"; } elseif ($parent_module == "Potentials") { $sql = "select * from vtiger_potential where potentialid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "potentialname"); $potential_selected = "selected"; } elseif ($parent_module == "Products") { $sql = "select * from vtiger_products where productid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "productname"); $product_selected = "selected"; } elseif ($parent_module == "PurchaseOrder") { $sql = "select * from vtiger_purchaseorder where purchaseorderid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "subject"); $porder_selected = "selected"; } elseif ($parent_module == "SalesOrder") { $sql = "select * from vtiger_salesorder where salesorderid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "subject"); $sorder_selected = "selected"; } elseif ($parent_module == "Invoice") { $sql = "select * from vtiger_invoice where invoiceid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "subject"); $invoice_selected = "selected"; } elseif ($parent_module == "Quotes") { $sql = "select * from vtiger_quotes where quoteid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "subject"); $quote_selected = "selected"; } elseif ($parent_module == "HelpDesk") { $sql = "select * from vtiger_troubletickets where ticketid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "title"); $ticket_selected = "selected"; } } $editview_label[] = array($app_strings['COMBO_LEADS'], $app_strings['COMBO_ACCOUNTS'], $app_strings['COMBO_POTENTIALS'], $app_strings['COMBO_PRODUCTS'], $app_strings['COMBO_INVOICES'], $app_strings['COMBO_PORDER'], $app_strings['COMBO_SORDER'], $app_strings['COMBO_QUOTES'], $app_strings['COMBO_HELPDESK']); $editview_label[] = array($lead_selected, $account_selected, $potential_selected, $product_selected, $invoice_selected, $porder_selected, $sorder_selected, $quote_selected, $ticket_selected); $editview_label[] = array("Leads&action=Popup", "Accounts&action=Popup", "Potentials&action=Popup", "Products&action=Popup", "Invoice&action=Popup", "PurchaseOrder&action=Popup", "SalesOrder&action=Popup", "Quotes&action=Popup", "HelpDesk&action=Popup"); $fieldvalue[] = $parent_name; $fieldvalue[] = $value; } elseif ($uitype == 66) { if (!empty($_REQUEST['parent_id'])) { $value = vtlib_purify($_REQUEST['parent_id']); } if (!empty($value)) { $parent_module = getSalesEntityType($value); if ($parent_module != "Contacts") { $entity_names = getEntityName($parent_module, $value); $parent_name = $entity_names[$value]; $fieldvalue[] = $parent_name; $fieldvalue[] = $value; } } // Check for vtiger_activity type if task orders to be added in select option $act_mode = $_REQUEST['activity_mode']; $parentModulesList = array('Leads' => $app_strings['COMBO_LEADS'], 'Accounts' => $app_strings['COMBO_ACCOUNTS'], 'Potentials' => $app_strings['COMBO_POTENTIALS'], 'HelpDesk' => $app_strings['COMBO_HELPDESK'], 'Campaigns' => $app_strings['COMBO_CAMPAIGNS'], 'Vendors' => $app_strings['COMBO_VENDORS']); if ($act_mode == "Task") { $parentModulesList['Quotes'] = $app_strings['COMBO_QUOTES']; $parentModulesList['PurchaseOrder'] = $app_strings['COMBO_PORDER']; $parentModulesList['SalesOrder'] = $app_strings['COMBO_SORDER']; $parentModulesList['Invoice'] = $app_strings['COMBO_INVOICES']; } $parentModuleNames = array_keys($parentModulesList); $parentModuleLabels = array_values($parentModulesList); $editview_label[0] = $parentModuleLabels; $editview_label[1] = array_fill(0, count($parentModulesList), ''); $selectedModuleIndex = array_search($parent_module, $parentModuleNames); if ($selectedModuleIndex > -1) { $editview_label[1][$selectedModuleIndex] = 'selected'; } $parentModulePopupUrl = array(); foreach ($parentModuleNames as $parentModule) { $parentModulePopupUrl[] = $parentModule . '&action=Popup'; } $editview_label[2] = $parentModulePopupUrl; } elseif ($uitype == 357) { $pmodule = $_REQUEST['pmodule']; if (empty($pmodule)) { $pmodule = $_REQUEST['par_module']; } if ($pmodule == 'Contacts') { $contact_selected = 'selected'; } elseif ($pmodule == 'Accounts') { $account_selected = 'selected'; } elseif ($pmodule == 'Leads') { $lead_selected = 'selected'; } elseif ($pmodule == 'Vendors') { $vendor_selected = 'selected'; } elseif ($pmodule == 'Users') { $user_selected = 'selected'; } elseif ($pmodule == 'Project') { $project_selected = 'selected'; } elseif ($pmodule == 'ProjectTask') { $projecttask_selected = 'selected'; } elseif ($pmodule == 'Potentials') { $potentials_selected = 'selected'; } elseif ($pmodule == 'HelpDesk') { $helpdesk_selected = 'selected'; } if (isset($_REQUEST['emailids']) && $_REQUEST['emailids'] != '') { $parent_id = $_REQUEST['emailids']; $parent_name = ''; $myids = explode("|", $parent_id); for ($i = 0; $i < count($myids) - 1; $i++) { $realid = explode("@", $myids[$i]); $entityid = $realid[0]; $nemail = count($realid); if ($pmodule == 'Accounts') { require_once 'modules/Accounts/Accounts.php'; $myfocus = new Accounts(); $myfocus->retrieve_entity_info($entityid, "Accounts"); $fullname = br2nl($myfocus->column_fields['accountname']); $account_selected = 'selected'; } elseif ($pmodule == 'Contacts') { require_once 'modules/Contacts/Contacts.php'; $myfocus = new Contacts(); $myfocus->retrieve_entity_info($entityid, "Contacts"); $fname = br2nl($myfocus->column_fields['firstname']); $lname = br2nl($myfocus->column_fields['lastname']); $fullname = $lname . ' ' . $fname; $contact_selected = 'selected'; } elseif ($pmodule == 'Leads') { require_once 'modules/Leads/Leads.php'; $myfocus = new Leads(); $myfocus->retrieve_entity_info($entityid, "Leads"); $fname = br2nl($myfocus->column_fields['firstname']); $lname = br2nl($myfocus->column_fields['lastname']); $fullname = $lname . ' ' . $fname; $lead_selected = 'selected'; } elseif ($pmodule == 'Project') { require_once 'modules/Project/Project.php'; $myfocus = new Project(); $myfocus->retrieve_entity_info($entityid, "Project"); $fname = br2nl($myfocus->column_fields['projectname']); $lname = br2nl($myfocus->column_fields['projectid']); $fullname = $fname; $project_selected = 'selected'; } elseif ($pmodule == 'ProjectTask') { require_once 'modules/ProjectTask/ProjectTask.php'; $myfocus = new ProjectTask(); $myfocus->retrieve_entity_info($entityid, "ProjectTask"); $fname = br2nl($myfocus->column_fields['projecttaskname']); $lname = br2nl($myfocus->column_fields['projecttaskid']); $fullname = $fname; $projecttask_selected = 'selected'; } elseif ($pmodule == 'Potentials') { require_once 'modules/Potentials/Potentials.php'; $myfocus = new Potentials(); $myfocus->retrieve_entity_info($entityid, "Potentials"); $fname = br2nl($myfocus->column_fields['potentialname']); $lname = br2nl($myfocus->column_fields['potentialid']); $fullname = $fname; $potentials_selected = 'selected'; } elseif ($pmodule == 'HelpDesk') { require_once 'modules/HelpDesk/HelpDesk.php'; $myfocus = new HelpDesk(); $myfocus->retrieve_entity_info($entityid, "HelpDesk"); $fname = br2nl($myfocus->column_fields['title']); $lname = br2nl($myfocus->column_fields['ticketid']); $fullname = $fname; $helpdesk_selected = 'selected'; } for ($j = 1; $j < $nemail; $j++) { $querystr = 'select columnname from vtiger_field where fieldid=? and vtiger_field.presence in (0,2)'; $result = $adb->pquery($querystr, array($realid[$j])); $temp = $adb->query_result($result, 0, 'columnname'); $temp1 = br2nl($myfocus->column_fields[$temp]); //Modified to display the entities in red which don't have email id if (!empty($temp_parent_name) && strlen($temp_parent_name) > 150) { $parent_name .= '<br>'; $temp_parent_name = ''; } if ($temp1 != '') { $parent_name .= $fullname . '<' . $temp1 . '>; '; $temp_parent_name .= $fullname . '<' . $temp1 . '>; '; } else { $parent_name .= "<b style='color:red'>" . $fullname . '<' . $temp1 . '>; ' . "</b>"; $temp_parent_name .= "<b style='color:red'>" . $fullname . '<' . $temp1 . '>; ' . "</b>"; } } } } else { if ($_REQUEST['record'] != '' && $_REQUEST['record'] != NULL) { $parent_name = ''; $parent_id = ''; $myemailid = $_REQUEST['record']; $mysql = "select crmid from vtiger_seactivityrel where activityid=?"; $myresult = $adb->pquery($mysql, array($myemailid)); $mycount = $adb->num_rows($myresult); if ($mycount > 0) { for ($i = 0; $i < $mycount; $i++) { $mycrmid = $adb->query_result($myresult, $i, 'crmid'); $parent_module = getSalesEntityType($mycrmid); if ($parent_module == "Leads") { $sql = "select firstname,lastname,email from vtiger_leaddetails where leadid=?"; $result = $adb->pquery($sql, array($mycrmid)); $full_name = getFullNameFromQResult($result, 0, "Leads"); $myemail = $adb->query_result($result, 0, "email"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $full_name . '<' . $myemail . '>; '; $lead_selected = 'selected'; } elseif ($parent_module == "Contacts") { $sql = "select * from vtiger_contactdetails where contactid=?"; $result = $adb->pquery($sql, array($mycrmid)); $full_name = getFullNameFromQResult($result, 0, "Contacts"); $myemail = $adb->query_result($result, 0, "email"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $full_name . '<' . $myemail . '>; '; $contact_selected = 'selected'; } elseif ($parent_module == "Accounts") { $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($mycrmid)); $account_name = $adb->query_result($result, 0, "accountname"); $myemail = $adb->query_result($result, 0, "email1"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $account_name . '<' . $myemail . '>; '; $account_selected = 'selected'; } elseif ($parent_module == "Users") { $sql = "select user_name,email1 from vtiger_users where id=?"; $result = $adb->pquery($sql, array($mycrmid)); $account_name = $adb->query_result($result, 0, "user_name"); $myemail = $adb->query_result($result, 0, "email1"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $account_name . '<' . $myemail . '>; '; $user_selected = 'selected'; } elseif ($parent_module == "Vendors") { $sql = "select * from vtiger_vendor where vendorid=?"; $result = $adb->pquery($sql, array($mycrmid)); $vendor_name = $adb->query_result($result, 0, "vendorname"); $myemail = $adb->query_result($result, 0, "email"); $parent_id .= $mycrmid . '@0|'; //make it such that the email adress sent is remebered and only that one is retrived $parent_name .= $vendor_name . '<' . $myemail . '>; '; $vendor_selected = 'selected'; } } } } $custfld .= '<td width="20%" class="dataLabel">' . $app_strings['To'] . ' </td>'; $custfld .= '<td width="90%" colspan="3"><input name="parent_id" type="hidden" value="' . $parent_id . '"><textarea readonly name="parent_name" cols="70" rows="2">' . $parent_name . '</textarea> <select name="parent_type" >'; $custfld .= '<OPTION value="Contacts" selected>' . $app_strings['COMBO_CONTACTS'] . '</OPTION>'; $custfld .= '<OPTION value="Accounts" >' . $app_strings['COMBO_ACCOUNTS'] . '</OPTION>'; $custfld .= '<OPTION value="Leads" >' . $app_strings['COMBO_LEADS'] . '</OPTION>'; $custfld .= '<OPTION value="Vendors" >' . $app_strings['COMBO_VENDORS'] . '</OPTION></select><img src="' . vtiger_imageurl('select.gif', $theme) . '" alt="Select" title="Select" LANGUAGE=javascript onclick=\'$log->debug("Exiting getOutputHtml method ..."); return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&popuptype=set_$log->debug("Exiting getOutputHtml method ..."); return_emails&form=EmailEditView&form_submit=false","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");\' align="absmiddle" style=\'cursor:hand;cursor:pointer\'> <input type="image" src="' . vtiger_imageurl('clear_field.gif', $theme) . '" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=\'\';this.form.parent_name.value=\'\';$log->debug("Exiting getOutputHtml method ..."); return false;" align="absmiddle" style=\'cursor:hand;cursor:pointer\'></td>'; $editview_label[] = array('Contacts' => $contact_selected, 'Accounts' => $account_selected, 'Vendors' => $vendor_selected, 'Leads' => $lead_selected, 'Users' => $user_selected); $fieldvalue[] = $parent_name; $fieldvalue[] = $parent_id; } } elseif ($uitype == 68) { if (empty($value) && isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') { $value = vtlib_purify($_REQUEST['parent_id']); } if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Contacts") { $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $parent_name = $field_value; } } $contact_selected = "selected"; } elseif ($parent_module == "Accounts") { $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $parent_name = $adb->query_result($result, 0, "accountname"); $account_selected = "selected"; } else { $parent_name = ""; $value = ""; } } $editview_label[0] = array(); $editview_label[1] = array(); $editview_label[2] = array(); if (vtlib_isModuleActive('Accounts')) { array_push($editview_label[0], $app_strings['COMBO_ACCOUNTS']); array_push($editview_label[1], $account_selected); array_push($editview_label[2], "Accounts"); } if (vtlib_isModuleActive('Contacts')) { array_push($editview_label[0], $app_strings['COMBO_CONTACTS']); array_push($editview_label[1], $contact_selected); array_push($editview_label[2], "Contacts"); } $fieldvalue[] = $parent_name; $fieldvalue[] = $value; } elseif ($uitype == 9 || $uitype == 7) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fldrs = $adb->pquery('select typeofdata from vtiger_field where vtiger_field.fieldname=? and vtiger_field.tabid=?', array($fieldname, getTabid($module_name))); $typeofdata = $adb->query_result($fldrs, 0, 0); $typeinfo = explode('~', $typeofdata); if ($typeinfo[0] == 'I') { $fieldvalue[] = $value; } else { $currencyField = new CurrencyField($value); $decimals = CurrencyField::getDecimalsFromTypeOfData($typeofdata); $currencyField->initialize($current_user); $currencyField->setNumberofDecimals(min($decimals, $currencyField->getCurrencyDecimalPlaces())); $fieldvalue[] = $currencyField->getDisplayValue(null, false, true); } } elseif ($uitype == 71 || $uitype == 72) { $currencyField = new CurrencyField($value); // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion if ($col_fields['record_id'] != '' && $uitype == 72) { if ($fieldname == 'unit_price') { $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module_name)); $currencySymbol = $rate_symbol['symbol']; } else { $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']); $currencySymbol = $currency_info['currency_symbol']; } $fieldvalue[] = $currencyField->getDisplayValue(null, true); } else { $decimals = CurrencyField::getDecimalsFromTypeOfData($typeofdata); $currencyField->initialize($current_user); $currencyField->setNumberofDecimals(min($decimals, $currencyField->getCurrencyDecimalPlaces())); $fieldvalue[] = $currencyField->getDisplayValue(null, false, true); $currencySymbol = $currencyField->getCurrencySymbol(); } $editview_label[] = getTranslatedString($fieldlabel, $module_name) . ': (' . $currencySymbol . ')'; } elseif ($uitype == 75 || $uitype == 81) { if ($value != '') { $vendor_name = getVendorName($value); } elseif (isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id'] != '') { $value = $_REQUEST['vendor_id']; $vendor_name = getVendorName($value); } $pop_type = 'specific'; if ($uitype == 81) { $pop_type = 'specific_vendor_address'; } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $vendor_name; $fieldvalue[] = $value; } elseif ($uitype == 76) { if ($value != '') { $potential_name = getPotentialName($value); } elseif (isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '') { $value = $_REQUEST['potental_id']; $potential_name = getPotentialName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $potential_name; $fieldvalue[] = $value; } elseif ($uitype == 78) { if ($value != '') { $quote_name = getQuoteName($value); } elseif (isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] != '') { $value = $_REQUEST['quote_id']; $potential_name = getQuoteName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $quote_name; $fieldvalue[] = $value; } elseif ($uitype == 79) { if ($value != '') { $purchaseorder_name = getPoName($value); } elseif (isset($_REQUEST['purchaseorder_id']) && $_REQUEST['purchaseorder_id'] != '') { $value = $_REQUEST['purchaseorder_id']; $purchaseorder_name = getPoName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $purchaseorder_name; $fieldvalue[] = $value; } elseif ($uitype == 80) { if ($value != '') { $salesorder_name = getSoName($value); } elseif (isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') { $value = $_REQUEST['salesorder_id']; $salesorder_name = getSoName($value); } $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $salesorder_name; $fieldvalue[] = $value; } elseif ($uitype == 30) { $rem_days = 0; $rem_hrs = 0; $rem_min = 0; if ($value != '') { $SET_REM = 'CHECKED'; } else { $SET_REM = ''; } $rem_days = floor($col_fields[$fieldname] / (24 * 60)); $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60); $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60; $editview_label[] = getTranslatedString($fieldlabel, $module_name); $day_options = getReminderSelectOption(0, 31, 'remdays', $rem_days); $hr_options = getReminderSelectOption(0, 23, 'remhrs', $rem_hrs); $min_options = getReminderSelectOption(10, 59, 'remmin', $rem_min); $fieldvalue[] = array(array(0, 32, 'remdays', getTranslatedString('LBL_DAYS', 'Calendar'), $rem_days), array(0, 24, 'remhrs', getTranslatedString('LBL_HOURS', 'Calendar'), $rem_hrs), array(10, 60, 'remmin', getTranslatedString('LBL_MINUTES', 'Calendar') . ' ' . getTranslatedString('LBL_BEFORE_EVENT', 'Calendar'), $rem_min)); $fieldvalue[] = array($SET_REM, getTranslatedString('LBL_YES'), getTranslatedString('LBL_NO')); $SET_REM = ''; } elseif ($uitype == 115) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname); $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname)); if ($value == $pickListValue) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } $fieldvalue[] = $options; $fieldvalue[] = $is_admin; } elseif ($uitype == 116 || $uitype == 117) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name'); $currency_id = $adb->query_result($pickListResult, $j, 'id'); if ($value == $currency_id) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[$currency_id] = array($pickListValue => $chk_val); } $fieldvalue[] = $options; $fieldvalue[] = $is_admin; } elseif ($uitype == 98) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; $fieldvalue[] = getRoleName($value); $fieldvalue[] = $is_admin; } elseif ($uitype == 105) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); if (isset($col_fields['record_id']) && $col_fields['record_id'] != '') { $query = "select vtiger_attachments.path, vtiger_attachments.name from vtiger_contactdetails left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_contactdetails.contactid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where vtiger_contactdetails.imagename=vtiger_attachments.name and contactid=?"; $result_image = $adb->pquery($query, array($col_fields['record_id'])); for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) { $image_array[] = $adb->query_result($result_image, $image_iter, 'name'); $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path'); } } if (is_array($image_array)) { for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) { $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr]); } } else { $fieldvalue[] = ''; } } elseif ($uitype == 101) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = getOwnerName($value); $fieldvalue[] = $value; } elseif ($uitype == 26) { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $folderid = $col_fields['folderid']; $foldername_query = 'select foldername from vtiger_attachmentsfolder where folderid = ?'; $res = $adb->pquery($foldername_query, array($folderid)); $foldername = $adb->query_result($res, 0, 'foldername'); if ($foldername != '' && $folderid != '') { $fldr_name[$folderid] = $foldername; } $sql = "select foldername,folderid from vtiger_attachmentsfolder order by foldername"; $res = $adb->pquery($sql, array()); for ($i = 0; $i < $adb->num_rows($res); $i++) { $fid = $adb->query_result($res, $i, "folderid"); $fldr_name[$fid] = $adb->query_result($res, $i, "foldername"); } $fieldvalue[] = $fldr_name; } elseif ($uitype == 27) { if ($value == 'E') { $external_selected = "selected"; $filename = $col_fields['filename']; } else { $internal_selected = "selected"; $filename = $col_fields['filename']; } $editview_label[] = array(getTranslatedString('Internal'), getTranslatedString('External')); $editview_label[] = array($internal_selected, $external_selected); $editview_label[] = array("I", "E"); $editview_label[] = getTranslatedString($fieldlabel, $module_name); $fieldvalue[] = $value; $fieldvalue[] = $filename; } elseif ($uitype == '31') { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $options = array(); $themeList = get_themes(); foreach ($themeList as $theme) { if ($value == $theme) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($theme), $theme, $selected); } $fieldvalue[] = $options; } elseif ($uitype == '32') { $editview_label[] = getTranslatedString($fieldlabel, $module_name); $options = array(); $languageList = Vtiger_Language::getAll(); foreach ($languageList as $prefix => $label) { if ($value == $prefix) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($label), $prefix, $selected); } $fieldvalue[] = $options; } else { //Added condition to set the subject if click Reply All from web mail if ($_REQUEST['module'] == 'Emails' && $_REQUEST['mg_subject'] != '') { $value = $_REQUEST['mg_subject']; } $editview_label[] = getTranslatedString($fieldlabel, $module_name); if ($fieldname == 'fileversion') { if (empty($value)) { $value = ''; } else { $fieldvalue[] = $value; } } else { $fieldvalue[] = $value; } } } // Mike Crowe Mod --------------------------------------------------------force numerics right justified. if (!preg_match("/id=/i", $custfld)) { $custfld = preg_replace("/<input/iS", "<input id='{$fieldname}' ", $custfld); } if (in_array($uitype, array(71, 72, 7, 9, 90))) { $custfld = preg_replace("/<input/iS", "<input align=right ", $custfld); } $final_arr[] = $ui_type; $final_arr[] = $editview_label; $final_arr[] = $editview_fldname; $final_arr[] = $fieldvalue; $type_of_data = explode('~', $typeofdata); $final_arr[] = $type_of_data[1]; $log->debug('Exiting getOutputHtml method ...'); return $final_arr; }
/** Function to insert values in the specifed table for the specified module * @param $table_name -- table name:: Type varchar * @param $module -- module:: Type varchar */ function insertIntoEntityTable($table_name, $module, $fileid = '') { global $log; global $current_user, $app_strings; $log->info("function insertIntoEntityTable " . $module . ' vtiger_table name ' . $table_name); global $adb; $insertion_mode = $this->mode; //Checkin whether an entry is already is present in the vtiger_table to update if ($insertion_mode == 'edit') { $tablekey = $this->tab_name_index[$table_name]; // Make selection on the primary key of the module table to check. $check_query = "select {$tablekey} from {$table_name} where {$tablekey}=?"; $check_result = $adb->pquery($check_query, array($this->id)); $num_rows = $adb->num_rows($check_result); if ($num_rows <= 0) { $insertion_mode = ''; } } $tabid = getTabid($module); if ($module == 'Calendar' && $this->column_fields["activitytype"] != null && $this->column_fields["activitytype"] != 'Task') { $tabid = getTabid('Events'); } if ($insertion_mode == 'edit') { $update = array(); $update_params = array(); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { $sql = "select * from vtiger_field where tabid in (" . generateQuestionMarks($tabid) . ") and tablename=? and displaytype in (1,3) and presence in (0,2) group by columnname"; $params = array($tabid, $table_name); } else { $profileList = getCurrentUserProfileList(); if (count($profileList) > 0) { $sql = "SELECT *\n\t\t\t \t\t\tFROM vtiger_field\n\t\t\t \t\t\tINNER JOIN vtiger_profile2field\n\t\t\t \t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t \t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t \t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t \t\t\tWHERE vtiger_field.tabid = ?\n\t\t\t \t\t\tAND vtiger_profile2field.visible = 0 \n\t\t\t \t\t\tAND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")\n\t\t\t \t\t\tAND vtiger_def_org_field.visible = 0 and vtiger_field.tablename=? and vtiger_field.displaytype in (1,3) and vtiger_field.presence in (0,2) group by columnname"; $params = array($tabid, $profileList, $table_name); } else { $sql = "SELECT *\n\t\t\t \t\t\tFROM vtiger_field\n\t\t\t \t\t\tINNER JOIN vtiger_profile2field\n\t\t\t \t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t \t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t \t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t \t\t\tWHERE vtiger_field.tabid = ?\n\t\t\t \t\t\tAND vtiger_profile2field.visible = 0 \n\t\t\t \t\t\tAND vtiger_def_org_field.visible = 0 and vtiger_field.tablename=? and vtiger_field.displaytype in (1,3) and vtiger_field.presence in (0,2) group by columnname"; $params = array($tabid, $table_name); } } } else { $table_index_column = $this->tab_name_index[$table_name]; if ($table_index_column == 'id' && $table_name == 'vtiger_users') { $currentuser_id = $adb->getUniqueID("vtiger_users"); $this->id = $currentuser_id; } $column = array($table_index_column); $value = array($this->id); $sql = "select * from vtiger_field where tabid=? and tablename=? and displaytype in (1,3,4) and vtiger_field.presence in (0,2)"; $params = array($tabid, $table_name); } $result = $adb->pquery($sql, $params); $noofrows = $adb->num_rows($result); for ($i = 0; $i < $noofrows; $i++) { $fieldname = $adb->query_result($result, $i, "fieldname"); $columname = $adb->query_result($result, $i, "columnname"); $uitype = $adb->query_result($result, $i, "uitype"); $generatedtype = $adb->query_result($result, $i, "generatedtype"); $typeofdata = $adb->query_result($result, $i, "typeofdata"); $typeofdata_array = explode("~", $typeofdata); $datatype = $typeofdata_array[0]; if ($uitype == 4 && $insertion_mode != 'edit') { $this->column_fields[$fieldname] = $this->setModuleSeqNumber("increment", $module); $fldvalue = $this->column_fields[$fieldname]; } if (isset($this->column_fields[$fieldname])) { if ($uitype == 56) { if ($this->column_fields[$fieldname] == 'on' || $this->column_fields[$fieldname] == 1) { $fldvalue = '1'; } else { $fldvalue = '0'; } } elseif ($uitype == 15 || $uitype == 16) { if ($this->column_fields[$fieldname] == $app_strings['LBL_NOT_ACCESSIBLE']) { //If the value in the request is Not Accessible for a picklist, the existing value will be replaced instead of Not Accessible value. $sql = "select {$columname} from {$table_name} where " . $this->tab_name_index[$table_name] . "=?"; $res = $adb->pquery($sql, array($this->id)); $pick_val = $adb->query_result($res, 0, $columname); $fldvalue = $pick_val; } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 33) { if (is_array($this->column_fields[$fieldname])) { $field_list = implode(' |##| ', $this->column_fields[$fieldname]); } else { $field_list = $this->column_fields[$fieldname]; } $fldvalue = $field_list; } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23) { if ($_REQUEST['action'] == 'Import') { $fldvalue = $this->column_fields[$fieldname]; } else { //Added to avoid function call getDBInsertDateValue in ajax save if (isset($current_user->date_format)) { $fldvalue = getValidDBInsertDateValue($this->column_fields[$fieldname]); } else { $fldvalue = $this->column_fields[$fieldname]; } } } elseif ($uitype == 7) { //strip out the spaces and commas in numbers if given ie., in amounts there may be , $fldvalue = str_replace(",", "", $this->column_fields[$fieldname]); //trim($this->column_fields[$fieldname],","); } elseif ($uitype == 26) { if (empty($this->column_fields[$fieldname])) { $fldvalue = 1; //the documents will stored in default folder } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 28) { if ($this->column_fields[$fieldname] == null) { $fileQuery = $adb->pquery("SELECT filename from vtiger_notes WHERE notesid = ?", array($this->id)); $fldvalue = null; if (isset($fileQuery)) { $rowCount = $adb->num_rows($fileQuery); if ($rowCount > 0) { $fldvalue = $adb->query_result($fileQuery, 0, 'filename'); } } } else { $fldvalue = $this->column_fields[$fieldname]; } } elseif ($uitype == 8) { $this->column_fields[$fieldname] = rtrim($this->column_fields[$fieldname], ','); $ids = explode(',', $this->column_fields[$fieldname]); $json = new Zend_Json(); $fldvalue = $json->encode($ids); } elseif ($uitype == 12) { $query = "SELECT email1 FROM vtiger_users WHERE id = ?"; $res = $adb->pquery($query, array($current_user->id)); $rows = $adb->num_rows($res); if ($rows > 0) { $fldvalue = $adb->query_result($res, 0, 'email1'); } } elseif ($uitype == 71 && $generatedtype == 2) { // Convert currency to base currency value before saving for custom fields of type currency $currency_id = $current_user->currency_id; $curSymCrate = getCurrencySymbolandCRate($currency_id); $fldvalue = convertToDollar($this->column_fields[$fieldname], $curSymCrate['rate']); } else { $fldvalue = $this->column_fields[$fieldname]; } if ($uitype != 33 && $uitype != 8) { $fldvalue = from_html($fldvalue, $insertion_mode == 'edit' ? true : false); } } else { $fldvalue = ''; } if ($fldvalue == '') { $fldvalue = $this->get_column_value($columname, $fldvalue, $fieldname, $uitype, $datatype); } if ($insertion_mode == 'edit') { if ($table_name != 'vtiger_ticketcomments' && $uitype != 4) { array_push($update, $columname . "=?"); array_push($update_params, $fldvalue); } } else { array_push($column, $columname); array_push($value, $fldvalue); } } if ($insertion_mode == 'edit') { if ($_REQUEST['module'] == 'Potentials') { $dbquery = 'select sales_stage from vtiger_potential where potentialid = ?'; $sales_stage = $adb->query_result($adb->pquery($dbquery, array($this->id)), 0, 'sales_stage'); if ($sales_stage != $_REQUEST['sales_stage'] && $_REQUEST['sales_stage'] != '') { $date_var = date('YmdHis'); $closingdate = $_REQUEST['ajxaction'] == 'DETAILVIEW' ? $this->column_fields['closingdate'] : getDBInsertDateValue($this->column_fields['closingdate']); $sql = "insert into vtiger_potstagehistory values(?,?,?,?,?,?,?,?)"; $params = array('', $this->id, $this->column_fields['amount'], decode_html($sales_stage), $this->column_fields['probability'], 0, $adb->formatDate($closingdate, true), $adb->formatDate($date_var, true)); $adb->pquery($sql, $params); } } elseif ($_REQUEST['module'] == 'PurchaseOrder' || $_REQUEST['module'] == 'SalesOrder' || $_REQUEST['module'] == 'Quotes' || $_REQUEST['module'] == 'Invoice') { //added to update the history for PO, SO, Quotes and Invoice $history_field_array = array("PurchaseOrder" => "postatus", "SalesOrder" => "sostatus", "Quotes" => "quotestage", "Invoice" => "invoicestatus"); $inventory_module = $_REQUEST['module']; if ($_REQUEST['ajxaction'] == 'DETAILVIEW') { if ($inventory_module == "PurchaseOrder") { $relatedname = getVendorName($this->column_fields['vendor_id']); } else { $relatedname = getAccountName($this->column_fields['account_id']); } $total = $this->column_fields['hdnGrandTotal']; } else { if ($inventory_module == "PurchaseOrder") { $relatedname = $_REQUEST["vendor_name"]; } else { $relatedname = $_REQUEST["account_name"]; } $total = $_REQUEST['total']; } if ($this->column_fields["{$history_field_array[$inventory_module]}"] == $app_strings['LBL_NOT_ACCESSIBLE']) { //If the value in the request is Not Accessible for a picklist, the existing value will be replaced instead of Not Accessible value. $his_col = $history_field_array[$inventory_module]; $his_sql = "select {$his_col} from {$this->table_name} where " . $this->table_index . "=?"; $his_res = $adb->pquery($his_sql, array($this->id)); $status_value = $adb->query_result($his_res, 0, $his_col); $stat_value = $status_value; } else { $stat_value = $this->column_fields["{$history_field_array[$inventory_module]}"]; } $oldvalue = getSingleFieldValue($this->table_name, $history_field_array[$inventory_module], $this->table_index, $this->id); if ($this->column_fields["{$history_field_array[$inventory_module]}"] != '' && $oldvalue != $stat_value) { addInventoryHistory($inventory_module, $this->id, $relatedname, $total, $stat_value); } } //Check done by Don. If update is empty the the query fails if (count($update) > 0) { $sql1 = "update {$table_name} set " . implode(",", $update) . " where " . $this->tab_name_index[$table_name] . "=?"; array_push($update_params, $this->id); $adb->pquery($sql1, $update_params); } } else { $sql1 = "insert into {$table_name}(" . implode(",", $column) . ") values(" . generateQuestionMarks($value) . ")"; $adb->pquery($sql1, $value); } }
/** * Function that gives the Currency Symbol * @params $result $adb object - resultset * $column String column name * Return $value - Currency Symbol */ function getCurrencySymbol($result, $i, $column) { $adb = PearDatabase::getInstance(); $currencyid = $adb->query_result($result, $i, $column); $curr = getCurrencySymbolandCRate($currencyid); $value = "(" . $curr['symbol'] . ")"; return $value; }
function getListViewEntries($focus, $module, $result, $navigationInfo, $skipActions = false) { require 'user_privileges/user_privileges_' . $this->user->id . '.php'; global $listview_max_textlength, $theme, $default_charset; $fields = $this->queryGenerator->getFields(); $whereFields = $this->queryGenerator->getWhereFields(); $meta = $this->queryGenerator->getMeta($this->queryGenerator->getModule()); $moduleFields = $meta->getModuleFields(); $accessibleFieldList = array_keys($moduleFields); $listViewFields = array_intersect($fields, $accessibleFieldList); $referenceFieldList = $this->queryGenerator->getReferenceFieldList(); foreach ($referenceFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $this->fetchNameList($field, $result); } } $db = PearDatabase::getInstance(); $rowCount = $db->num_rows($result); $ownerFieldList = $this->queryGenerator->getOwnerFieldList(); foreach ($ownerFieldList as $fieldName) { if (in_array($fieldName, $listViewFields)) { $field = $moduleFields[$fieldName]; $idList = array(); for ($i = 0; $i < $rowCount; $i++) { $id = $this->db->query_result($result, $i, $field->getColumnName()); if (!isset($this->ownerNameList[$fieldName][$id])) { $idList[] = $id; } } if (count($idList) > 0) { if (!is_array($this->ownerNameList[$fieldName])) { $this->ownerNameList[$fieldName] = getOwnerNameList($idList); } else { //array_merge API loses key information so need to merge the arrays // manually. $newOwnerList = getOwnerNameList($idList); foreach ($newOwnerList as $id => $name) { $this->ownerNameList[$fieldName][$id] = $name; } } } } } foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; if (!$is_admin && ($field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) { $this->setupAccessiblePicklistValueList($fieldName); } } $useAsterisk = get_use_asterisk($this->user->id); $data = array(); for ($i = 0; $i < $rowCount; ++$i) { //Getting the recordId if ($module != 'Users') { $baseTable = $meta->getEntityBaseTable(); $moduleTableIndexList = $meta->getEntityTableIndexList(); $baseTableIndex = $moduleTableIndexList[$baseTable]; $recordId = $db->query_result($result, $i, $baseTableIndex); $ownerId = $db->query_result($result, $i, "smownerid"); } else { $recordId = $db->query_result($result, $i, "id"); } $row = array(); foreach ($listViewFields as $fieldName) { $field = $moduleFields[$fieldName]; $uitype = $field->getUIType(); $rawValue = $this->db->query_result($result, $i, $field->getColumnName()); if ($module == 'Calendar') { $activityType = $this->db->query_result($result, $i, 'activitytype'); } if ($uitype != 8) { $value = html_entity_decode($rawValue, ENT_QUOTES, $default_charset); } else { $value = $rawValue; } if ($module == 'Documents' && $fieldName == 'filename') { $downloadtype = $db->query_result($result, $i, 'filelocationtype'); if ($downloadtype == 'I') { $ext = substr($value, strrpos($value, ".") + 1); $ext = strtolower($ext); if ($value != '') { if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } } elseif ($downloadtype == 'E') { if (trim($value) != '') { $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' title='" . getTranslatedString('LBL_EXTERNAL_LNK', $module) . "' hspace='3' align='absmiddle' border='0'>"; } else { $value = '--'; $fileicon = ''; } } else { $value = ' --'; $fileicon = ''; } $fileName = $db->query_result($result, $i, 'filename'); $downloadType = $db->query_result($result, $i, 'filelocationtype'); $status = $db->query_result($result, $i, 'filestatus'); $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?"; $fileIdRes = $db->pquery($fileIdQuery, array($recordId)); $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid'); if ($fileName != '' && $status == 1) { if ($downloadType == 'I') { $value = "<a href='index.php?module=uploads&action=downloadfile&" . "entityid={$recordId}&fileid={$fileId}' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "' onclick='javascript:dldCntIncrease({$recordId});'>" . textlength_check($value) . "</a>"; } elseif ($downloadType == 'E') { $value = "<a target='_blank' href='{$fileName}' onclick='javascript:" . "dldCntIncrease({$recordId});' title='" . getTranslatedString("LBL_DOWNLOAD_FILE", $module) . "'>" . textlength_check($value) . "</a>"; } else { $value = ' --'; } } $value = $fileicon . $value; } elseif ($module == 'Documents' && $fieldName == 'filesize') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'I') { $filesize = $value; if ($filesize < 1024) { $value = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $value = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $value = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $value = ' --'; } } elseif ($module == 'Documents' && $fieldName == 'filestatus') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($module == 'Documents' && $fieldName == 'filetype') { $downloadType = $db->query_result($result, $i, 'filelocationtype'); if ($downloadType == 'E' || $downloadType != 'I') { $value = '--'; } } elseif ($field->getUIType() == '27') { if ($value == 'I') { $value = getTranslatedString('LBL_INTERNAL', $module); } elseif ($value == 'E') { $value = getTranslatedString('LBL_EXTERNAL', $module); } else { $value = ' --'; } } elseif ($field->getFieldDataType() == 'picklist') { if ($value != '' && !$is_admin && $this->picklistRoleMap[$fieldName] && !in_array($value, $this->picklistValueMap[$fieldName])) { $value = "<font color='red'>" . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; } else { $value = getTranslatedString($value, $module); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'date' || $field->getFieldDataType() == 'datetime') { if ($value != '' && $value != '0000-00-00') { $date = new DateTimeField($value); $value = $date->getDisplayDate(); if ($field->getFieldDataType() == 'datetime') { $value .= ' ' . $date->getDisplayTime(); } } elseif ($value == '0000-00-00') { $value = ''; } } elseif ($field->getFieldDataType() == 'currency') { if ($value != '') { if ($field->getUIType() == 72) { if ($fieldName == 'unit_price') { $currencyId = getProductBaseCurrency($recordId, $module); $cursym_convrate = getCurrencySymbolandCRate($currencyId); $currencySymbol = $cursym_convrate['symbol']; } else { $currencyInfo = getInventoryCurrencyInfo($module, $recordId); $currencySymbol = $currencyInfo['currency_symbol']; } $value = number_format($value, 2, '.', ''); $currencyValue = CurrencyField::convertToUserFormat($value, null, true); $value = CurrencyField::appendCurrencySymbol($currencyValue, $currencySymbol); } else { //changes made to remove vtiger_currency symbol infront of each //vtiger_potential amount if ($value != 0) { $value = CurrencyField::convertToUserFormat($value); } } } } elseif ($field->getFieldDataType() == 'url') { $matchPattern = "^[\\w]+:\\/\\/^"; preg_match($matchPattern, $rawValue, $matches); if (!empty($matches[0])) { $value = '<a href="' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } else { $value = '<a href="http://' . $rawValue . '" target="_blank">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'email') { if ($_SESSION['internal_mailer'] == 1) { //check added for email link in user detailview $fieldId = $field->getFieldId(); $value = "<a href=\"javascript:InternalMailer({$recordId},{$fieldId}," . "'{$fieldName}','{$module}','record_id');\">" . textlength_check($value) . "</a>"; } else { $value = '<a href="mailto:' . $rawValue . '">' . textlength_check($value) . '</a>'; } } elseif ($field->getFieldDataType() == 'boolean') { if ($value == 1) { $value = getTranslatedString('yes', $module); } elseif ($value == 0) { $value = getTranslatedString('no', $module); } else { $value = '--'; } } elseif ($field->getUIType() == 98) { $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=' . 'Settings&roleid=' . $value . '">' . textlength_check(getRoleName($value)) . '</a>'; } elseif ($field->getFieldDataType() == 'multipicklist') { $value = $value != "" ? str_replace(' |##| ', ', ', $value) : ""; if (!$is_admin && $value != '') { $valueArray = $rawValue != "" ? explode(' |##| ', $rawValue) : array(); $notaccess = '<font color="red">' . getTranslatedString('LBL_NOT_ACCESSIBLE', $module) . "</font>"; $tmp = ''; $tmpArray = array(); foreach ($valueArray as $index => $val) { if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $tmp)) > $listview_max_textlength)) { if (!$is_admin && $this->picklistRoleMap[$fieldName] && !in_array(trim($val), $this->picklistValueMap[$fieldName])) { $tmpArray[] = $notaccess; $tmp .= ', ' . $notaccess; } else { $tmpArray[] = $val; $tmp .= ', ' . $val; } } else { $tmpArray[] = '...'; $tmp .= '...'; } } $value = implode(', ', $tmpArray); $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'skype') { $value = $value != "" ? "<a href='skype:{$value}?call'>" . textlength_check($value) . "</a>" : ""; } elseif ($field->getFieldDataType() == 'phone') { if ($useAsterisk == 'true') { $value = "<a href='javascript:;' onclick='startCall("{$value}", " . ""{$recordId}")'>" . textlength_check($value) . "</a>"; } else { $value = textlength_check($value); } } elseif ($field->getFieldDataType() == 'reference') { $referenceFieldInfoList = $this->queryGenerator->getReferenceFieldInfoList(); $moduleList = $referenceFieldInfoList[$fieldName]; if (count($moduleList) == 1) { $parentModule = $moduleList[0]; } else { $parentModule = $this->typeList[$value]; } if (!empty($value) && !empty($this->nameList[$fieldName]) && !empty($parentModule)) { $parentMeta = $this->queryGenerator->getMeta($parentModule); $value = textlength_check($this->nameList[$fieldName][$value]); if ($parentMeta->isModuleEntity() && $parentModule != "Users") { $value = "<a href='index.php?module={$parentModule}&action=DetailView&" . "record={$rawValue}' title='" . getTranslatedString($parentModule, $parentModule) . "'>{$value}</a>"; } } else { $value = '--'; } } elseif ($field->getFieldDataType() == 'owner') { $value = textlength_check($this->ownerNameList[$fieldName][$value]); } elseif ($field->getUIType() == 25) { //TODO clean request object reference. $contactId = $_REQUEST['record']; $emailId = $this->db->query_result($result, $i, "activityid"); $result1 = $this->db->pquery("SELECT access_count FROM vtiger_email_track WHERE " . "crmid=? AND mailid=?", array($contactId, $emailId)); $value = $this->db->query_result($result1, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($field->getUIType() == 8) { if (!empty($value)) { $temp_val = html_entity_decode($value, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } elseif (in_array($uitype, array(7, 9, 90))) { $value = "<span align='right'>" . textlength_check($value) . "</div>"; } elseif ($field->getUIType() == 55) { $value = getTranslatedString($value, $currentModule); } else { $value = textlength_check($value); } $parenttab = getParentTab(); $nameFields = $this->queryGenerator->getModuleNameFields($module); $nameFieldList = explode(',', $nameFields); if (in_array($fieldName, $nameFieldList) && $module != 'Emails') { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } elseif ($fieldName == $focus->list_link_field && $module != 'Emails') { $value = "<a href='index.php?module={$module}&parenttab={$parenttab}&action=DetailView&record=" . "{$recordId}' title='" . getTranslatedString($module, $module) . "'>{$value}</a>"; } // vtlib customization: For listview javascript triggers $value = "{$value} <span type='vtlib_metainfo' vtrecordid='{$recordId}' vtfieldname=" . "'{$fieldName}' vtmodule='{$module}' style='display:none;'></span>"; // END $row[] = $value; } //Added for Actions ie., edit and delete links in listview $actionLinkInfo = ""; if (isPermitted($module, "EditView", "") == 'yes') { $edit_link = $this->getListViewEditLink($module, $recordId); if (isset($navigationInfo['start']) && $navigationInfo['start'] > 1 && $module != 'Emails') { $actionLinkInfo .= "<a href=\"{$edit_link}&start=" . $navigationInfo['start'] . "\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } else { $actionLinkInfo .= "<a href=\"{$edit_link}\">" . getTranslatedString("LNK_EDIT", $module) . "</a> "; } } if (isPermitted($module, "Delete", "") == 'yes') { $del_link = $this->getListViewDeleteLink($module, $recordId); if ($actionLinkInfo != "" && $del_link != "") { $actionLinkInfo .= " | "; } if ($del_link != "") { $actionLinkInfo .= "<a href='javascript:confirmdelete(\"" . addslashes(urlencode($del_link)) . "\")'>" . getTranslatedString("LNK_DELETE", $module) . "</a>"; } } // Record Change Notification if (method_exists($focus, 'isViewed') && PerformancePrefs::getBoolean('LISTVIEW_RECORD_CHANGE_INDICATOR', true)) { if (!$focus->isViewed($recordId)) { $actionLinkInfo .= " | <img src='" . vtiger_imageurl('important1.gif', $theme) . "' border=0>"; } } // END if ($actionLinkInfo != "" && !$skipActions) { $row[] = $actionLinkInfo; } $data[$recordId] = $row; } return $data; }
function getValue($field_result, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, $mode, $popuptype, $returnset = '', $viewid = '') { global $log, $listview_max_textlength, $app_strings, $current_language, $currentModule; $log->debug("Entering getValue(" . $field_result . "," . $list_result . "," . $fieldname . "," . get_class($focus) . "," . $module . "," . $entity_id . "," . $list_result_count . "," . $mode . "," . $popuptype . "," . $returnset . "," . $viewid . ") method ..."); global $adb, $current_user, $default_charset; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $tabname = getParentTab(); $tabid = getTabid($module); $current_module_strings = return_module_language($current_language, $module); $uicolarr = $field_result[$fieldname]; foreach ($uicolarr as $key => $value) { $uitype = $key; $colname = $value; } //added for getting event status in Custom view - Jaguar if ($module == 'Calendar' && ($colname == "status" || $colname == "eventstatus")) { $colname = "activitystatus"; } //Ends $field_val = $adb->query_result($list_result, $list_result_count, $colname); if (stristr(html_entity_decode($field_val), "<a href") === false && $uitype != 8) { $temp_val = textlength_check($field_val); } elseif ($uitype != 8) { $temp_val = html_entity_decode($field_val, ENT_QUOTES); } else { $temp_val = $field_val; } // vtlib customization: New uitype to handle relation between modules if ($uitype == '10') { $parent_id = $field_val; if (!empty($parent_id)) { $parent_module = getSalesEntityType($parent_id); $valueTitle = $parent_module; if ($app_strings[$valueTitle]) { $valueTitle = $app_strings[$valueTitle]; } $displayValueArray = getEntityName($parent_module, $parent_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $value) { $displayValue = $value; } } $value = "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>{$displayValue}</a>"; } else { $value = ''; } } else { if ($uitype == 53) { $value = textlength_check($adb->query_result($list_result, $list_result_count, 'user_name')); // When Assigned To field is used in Popup window if ($value == '') { $user_id = $adb->query_result($list_result, $list_result_count, 'smownerid'); if ($user_id != null && $user_id != '') { $value = getOwnerName($user_id); } } } elseif ($uitype == 52) { $value = getUserName($adb->query_result($list_result, $list_result_count, $colname)); } elseif ($uitype == 51) { $parentid = $adb->query_result($list_result, $list_result_count, "parentid"); if ($module == 'Accounts') { $entity_name = textlength_check(getAccountName($parentid)); } elseif ($module == 'Products') { $entity_name = textlength_check(getProductName($parentid)); } $value = '<a href="index.php?module=' . $module . '&action=DetailView&record=' . $parentid . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $entity_name . '</a>'; } elseif ($uitype == 77) { $value = getUserName($adb->query_result($list_result, $list_result_count, 'inventorymanager')); } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70) { if ($temp_val != '' && $temp_val != '0000-00-00') { $value = getDisplayDate($temp_val); } elseif ($temp_val == '0000-00-00') { $value = ''; } else { $value = $temp_val; } } elseif ($uitype == 15 || $uitype == 55 && $fieldname == "salutationtype") { $temp_val = decode_html($adb->query_result($list_result, $list_result_count, $colname)); if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $temp_val != '') { $temp_acttype = $adb->query_result($list_result, $list_result_count, 'activitytype'); if ($temp_acttype != 'Task' && $fieldname == "taskstatus") { $temptable = "eventstatus"; } else { $temptable = $fieldname; } $roleid = $current_user->roleid; $roleids = array(); $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = $subrole; } array_push($roleids, $roleid); //here we are checking wheather the table contains the sortorder column .If sortorder is present in the main picklist table, then the role2picklist will be applicable for this table... $sql = "select * from vtiger_{$temptable} where {$temptable}=?"; $res = $adb->pquery($sql, array(decode_html($temp_val))); $picklistvalueid = $adb->query_result($res, 0, 'picklist_valueid'); if ($picklistvalueid != null) { $pick_query = "select * from vtiger_role2picklist where picklistvalueid={$picklistvalueid} and roleid in (" . generateQuestionMarks($roleids) . ")"; $res_val = $adb->pquery($pick_query, array($roleids)); $num_val = $adb->num_rows($res_val); } if ($num_val > 0 || $temp_acttype == 'Task' && $fieldname == 'activitytype') { $temp_val = $temp_val; } else { $temp_val = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; } } $value = $current_module_strings[$temp_val] != '' ? $current_module_strings[$temp_val] : ($app_strings[$temp_val] != '' ? $app_strings[$temp_val] : $temp_val); if ($value != "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>") { $value = textlength_check($value); } } elseif ($uitype == 16) { $value = getTranslatedString($temp_val, $currentModule); } elseif ($uitype == 71 || $uitype == 72) { if ($temp_val != '') { if ($fieldname == 'unit_price') { $currency_id = getProductBaseCurrency($entity_id, $module); $cursym_convrate = getCurrencySymbolandCRate($currency_id); $value = "<font style='color:grey;'>" . $cursym_convrate['symbol'] . "</font> " . $temp_val; } else { $rate = $user_info['conv_rate']; //changes made to remove vtiger_currency symbol infront of each vtiger_potential amount if ($temp_val != 0) { $value = convertFromDollar($temp_val, $rate); } else { $value = $temp_val; } } } else { $value = ''; } } elseif ($uitype == 17) { $value = '<a href="http://' . $field_val . '" target="_blank">' . $temp_val . '</a>'; } elseif ($uitype == 13 || $uitype == 104 && ($_REQUEST['action'] != 'Popup' && $_REQUEST['file'] != 'Popup')) { if ($_SESSION['internal_mailer'] == 1) { //check added for email link in user detailview if ($module == 'Calendar') { if (getActivityType($entity_id) == 'Task') { $tabid = 9; } else { $tabid = 16; } } else { $tabid = getTabid($module); } $fieldid = getFieldid($tabid, $fieldname); if (empty($popuptype)) { $value = '<a href="javascript:InternalMailer(' . $entity_id . ',' . $fieldid . ',\'' . $fieldname . '\',\'' . $module . '\',\'record_id\');">' . $temp_val . '</a>'; } else { $value = $temp_val; } } else { $value = '<a href="mailto:' . $field_val . '">' . $temp_val . '</a>'; } } elseif ($uitype == 56) { if ($temp_val == 1) { $value = $app_strings['yes']; } elseif ($temp_val == 0) { $value = $app_strings['no']; } else { $value = ''; } } elseif ($uitype == 57) { if ($temp_val != '') { $sql = "SELECT * FROM vtiger_contactdetails WHERE contactid=?"; $result = $adb->pquery($sql, array($temp_val)); $value = ''; if ($adb->num_rows($result)) { $name = getFullNameFromQResult($result, 0, "Contacts"); $value = '<a href=index.php?module=Contacts&action=DetailView&record=' . $temp_val . '>' . $name . '</a>'; } } else { $value = ''; } } elseif ($uitype == 58) { if ($temp_val != '') { $sql = "SELECT * FROM vtiger_campaign WHERE campaignid=?"; $result = $adb->pquery($sql, array($temp_val)); $campaignname = $adb->query_result($result, 0, "campaignname"); $value = '<a href=index.php?module=Campaigns&action=DetailView&record=' . $temp_val . '>' . $campaignname . '</a>'; } else { $value = ''; } } elseif ($uitype == 59) { if ($temp_val != '') { $value = getProductName($temp_val); } else { $value = ''; } } elseif ($uitype == 61) { $attachmentid = $adb->query_result($adb->pquery("SELECT * FROM vtiger_seattachmentsrel WHERE crmid = ?", array($entity_id)), 0, 'attachmentsid'); $value = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $module . '&fileid=' . $attachmentid . '&filename=' . $temp_val . '">' . $temp_val . '</a>'; } elseif ($uitype == 62) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == "Leads") { $tablename = "vtiger_leaddetails"; $fieldname = "lastname"; $idname = "leadid"; } if ($parenttype == "Accounts") { $tablename = "vtiger_account"; $fieldname = "accountname"; $idname = "accountid"; } if ($parenttype == "Products") { $tablename = "vtiger_products"; $fieldname = "productname"; $idname = "productid"; } if ($parenttype == "HelpDesk") { $tablename = "vtiger_troubletickets"; $fieldname = "title"; $idname = "ticketid"; } if ($parenttype == "Invoice") { $tablename = "vtiger_invoice"; $fieldname = "subject"; $idname = "invoiceid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>'; } else { $value = ''; } } elseif ($uitype == 66) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == "Leads") { $tablename = "vtiger_leaddetails"; $fieldname = "lastname"; $idname = "leadid"; } if ($parenttype == "Accounts") { $tablename = "vtiger_account"; $fieldname = "accountname"; $idname = "accountid"; } if ($parenttype == "HelpDesk") { $tablename = "vtiger_troubletickets"; $fieldname = "title"; $idname = "ticketid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>'; } else { $value = ''; } } elseif ($uitype == 67) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == "Leads") { $tablename = "vtiger_leaddetails"; $fieldname = "lastname"; $idname = "leadid"; } if ($parenttype == "Contacts") { $tablename = "vtiger_contactdetails"; $fieldname = "contactname"; $idname = "contactid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>'; } else { $value = ''; } } elseif ($uitype == 68) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == '' && $parentid != '') { $parenttype = getSalesEntityType($parentid); } if ($parenttype == "Contacts") { $tablename = "vtiger_contactdetails"; $fieldname = "contactname"; $idname = "contactid"; } if ($parenttype == "Accounts") { $tablename = "vtiger_account"; $fieldname = "accountname"; $idname = "accountid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>'; } else { $value = ''; } } elseif ($uitype == 78) { if ($temp_val != '') { $quote_name = getQuoteName($temp_val); $value = '<a href=index.php?module=Quotes&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($quote_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 79) { if ($temp_val != '') { $purchaseorder_name = getPoName($temp_val); $value = '<a href=index.php?module=PurchaseOrder&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($purchaseorder_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 80) { if ($temp_val != '') { $salesorder_name = getSoName($temp_val); $value = "<a href=index.php?module=SalesOrder&action=DetailView&record={$temp_val}&parenttab=" . urlencode($tabname) . ">" . textlength_check($salesorder_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 75 || $uitype == 81) { if ($temp_val != '') { $vendor_name = getVendorName($temp_val); $value = '<a href=index.php?module=Vendors&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($vendor_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 98) { $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=Settings&roleid=' . $temp_val . '">' . textlength_check(getRoleName($temp_val)) . '</a>'; } elseif ($uitype == 33) { $value = $temp_val != "" ? str_ireplace(' |##| ', ', ', $temp_val) : ""; if (!$is_admin && $value != '') { $value = $field_val != "" ? str_ireplace(' |##| ', ', ', $field_val) : ""; if ($value != '') { $value_arr = explode(',', trim($value)); $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = $subrole; array_push($roleids, $roleid); } else { $roleids = $roleid; } if (count($roleids) > 0) { $pick_query = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where roleid in (" . generateQuestionMarks($roleids) . ") and picklistid in (select picklistid from vtiger_{$fieldname}) order by {$fieldname} asc"; $params = array($roleids); } else { $pick_query = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where picklistid in (select picklistid from vtiger_{$fieldname}) order by {$fieldname} asc"; $params = array(); } $pickListResult = $adb->pquery($pick_query, $params); $picklistval = array(); for ($i = 0; $i < $adb->num_rows($pickListResult); $i++) { $picklistarr[] = $adb->query_result($pickListResult, $i, $fieldname); } $value_temp = array(); $string_temp = ''; $str_c = 0; foreach ($value_arr as $ind => $val) { $notaccess = '<font color="red">' . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $string_temp)) > $listview_max_textlength)) { $value_temp1 = in_array(trim($val), $picklistarr) ? $val : $notaccess; if ($str_c != 0) { $string_temp .= ' , '; } $string_temp .= $value_temp1; $str_c++; } else { $string_temp .= '...'; } } $value = $string_temp; } } } elseif ($uitype == 85) { $value = $temp_val != "" ? "<a href='skype:{$temp_val}?call'>{$temp_val}</a>" : ""; } elseif ($uitype == 116) { $value = $temp_val != "" ? getCurrencyName($temp_val) : ""; } elseif ($uitype == 117) { // NOTE: Without symbol the value could be used for filtering/lookup hence avoiding the translation $value = $temp_val != "" ? getCurrencyName($temp_val, false) : ""; } elseif ($uitype == 26) { $sql = "select foldername from vtiger_attachmentsfolder where folderid = ?"; $res = $adb->pquery($sql, array($temp_val)); $foldername = $adb->query_result($res, 0, 'foldername'); $value = $foldername; } elseif ($uitype == 11) { // Fix added for Trac Id: 6139 if (vtlib_isModuleActive('PBXManager')) { $value = "<a href='javascript:;' onclick='startCall("{$temp_val}", "{$entity_id}")'>" . $temp_val . "</a>"; } else { $value = $temp_val; } } elseif ($uitype == 25) { $contactid = $_REQUEST['record']; $emailid = $adb->query_result($list_result, $list_result_count, "activityid"); $result = $adb->pquery("SELECT access_count FROM vtiger_email_track WHERE crmid=? AND mailid=?", array($contactid, $emailid)); $value = $adb->query_result($result, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($uitype == 8) { if (!empty($temp_val)) { $temp_val = html_entity_decode($temp_val, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } else { if ($fieldname == $focus->list_link_field) { if ($mode == "search") { if ($popuptype == "specific" || $popuptype == "toDospecific") { // Added for get the first name of contact in Popup window if ($colname == "lastname" && $module == 'Contacts') { $temp_val = getFullNameFromQResult($list_result, $list_result_count, "Contacts"); } $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); //Added to avoid the error when select SO from Invoice through AjaxEdit if ($module == 'SalesOrder') { $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '","' . $_REQUEST['form'] . '");\'>' . $temp_val . '</a>'; } elseif ($module == 'Contacts') { require_once 'modules/Contacts/Contacts.php'; $cntct_focus = new Contacts(); $cntct_focus->retrieve_entity_info($entity_id, "Contacts"); $slashes_temp_val = popup_from_html($temp_val); //ADDED TO CHECK THE FIELD PERMISSIONS FOR $xyz = array('mailingstreet', 'mailingcity', 'mailingzip', 'mailingpobox', 'mailingcountry', 'mailingstate', 'otherstreet', 'othercity', 'otherzip', 'otherpobox', 'othercountry', 'otherstate'); for ($i = 0; $i < 12; $i++) { if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') { $cntct_focus->column_fields[$xyz[$i]] = $cntct_focus->column_fields[$xyz[$i]]; } else { $cntct_focus->column_fields[$xyz[$i]] = ''; } } // For ToDo creation the underlying form is not named as EditView $form = !empty($_REQUEST['form']) ? $_REQUEST['form'] : ''; if (!empty($form)) { $form = htmlspecialchars($form, ENT_QUOTES, $default_charset); } $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcity']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercity']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcountry']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercountry']) . '","' . popup_decode_html($cntct_focus->column_fields['mailingpobox']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherpobox']) . '","' . $form . '");\'>' . $temp_val . '</a>'; } else { if ($popuptype == 'toDospecific') { $value = '<a href="javascript:window.close();" onclick=\'set_return_toDospecific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } } } elseif ($popuptype == "detailview") { if ($colname == "lastname" && ($module == 'Contacts' || $module == 'Leads')) { $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module); } $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $focus->record_id = $_REQUEST['recordid']; if ($_REQUEST['return_module'] == "Calendar") { $value = '<a href="javascript:window.close();" id="calendarCont' . $entity_id . '" LANGUAGE=javascript onclick=\'add_data_to_relatedlist_incal("' . $entity_id . '","' . decode_html($slashes_temp_val) . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'add_data_to_relatedlist("' . $entity_id . '","' . $focus->record_id . '","' . $module . '");\'>' . $temp_val . '</a>'; } } elseif ($popuptype == "formname_specific") { $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'set_return_formname_specific("' . $_REQUEST['form'] . '", "' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $tax_details = getAllTaxes(); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ','; } $tax_str = trim($tax_str, ','); $rate = $user_info['conv_rate']; if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); if ($_REQUEST['currencyid'] != null) { $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id)); $unitprice = $prod_prices[$entity_id]; } } else { $unit_price = ''; } $sub_products = ''; $sub_prod = ''; $sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id)); for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) { //$sub_prod=array(); $id = $adb->query_result($sub_prod_query, $i, "productid"); $str_sep = ''; if ($i > 0) { $str_sep = ":"; } $sub_products .= $str_sep . $id; $sub_prod .= $str_sep . " - " . $adb->query_result($sub_prod_query, $i, "productname"); } $sub_det = $sub_products . "::" . str_replace(":", "<br>", $sub_prod); $qty_stock = $adb->query_result($list_result, $list_result_count, 'qtyinstock'); //fix for T6943 $slashes_temp_val = popup_from_html($field_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description')); $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset)); $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc); $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "qtyinstk" => "{$qty_stock}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}", "subprod_ids" => "{$sub_det}"); require_once 'include/Zend/Json.php'; $prod_arr = Zend_Json::encode($tmp_arr); $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $qty_stock . '","' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '");\' vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod_po") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $tax_details = getAllTaxes(); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ','; } $tax_str = trim($tax_str, ','); $rate = $user_info['conv_rate']; if (getFieldVisibilityPermission($module, $current_user->id, 'unit_price') == '0') { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); if ($_REQUEST['currencyid'] != null) { $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module); $unitprice = $prod_prices[$entity_id]; } } else { $unit_price = ''; } $sub_products = ''; $sub_prod = ''; $sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id)); for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) { //$sub_prod=array(); $id = $adb->query_result($sub_prod_query, $i, "productid"); $str_sep = ''; if ($i > 0) { $str_sep = ":"; } $sub_products .= $str_sep . $id; $sub_prod .= $str_sep . " - {$id}." . $adb->query_result($sub_prod_query, $i, "productname"); } $sub_det = $sub_products . "::" . str_replace(":", "<br>", $sub_prod); $slashes_temp_val = popup_from_html($field_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description')); $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset)); $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc); $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "qtyinstk" => "{$qty_stock}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}", "subprod_ids" => "{$sub_det}"); require_once 'include/Zend/Json.php'; $prod_arr = Zend_Json::encode($tmp_arr); $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory_po("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '"); \' vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_service") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $tax_details = getAllTaxes(); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ','; } $tax_str = trim($tax_str, ','); $rate = $user_info['conv_rate']; if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); if ($_REQUEST['currencyid'] != null) { $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module); $unitprice = $prod_prices[$entity_id]; } } else { $unit_price = ''; } $slashes_temp_val = popup_from_html($field_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description')); $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset)); $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc); $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}"); require_once 'include/Zend/Json.php'; $prod_arr = Zend_Json::encode($tmp_arr); $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '");\' vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_pb") { $prod_id = $_REQUEST['productid']; $flname = $_REQUEST['fldname']; $listprice = getListPrice($prod_id, $entity_id); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_pb("' . $listprice . '", "' . $flname . '"); \'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_account_address") { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($entity_id, "Accounts"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state'); for ($i = 0; $i < 12; $i++) { if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') { $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]]; } else { $acct_focus->column_fields[$xyz[$i]] = ''; } } $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street'])); $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street'])); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_contact_account_address") { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($entity_id, "Accounts"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street'])); $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street'])); $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_potential_account_address") { $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); // For B2C support, Potential was enabled to be linked to Contacts also. // Hence we need case handling for it. $relatedid = $adb->query_result($list_result, $list_result_count, "related_to"); $relatedentity = getSalesEntityType($relatedid); if ($relatedentity == 'Accounts') { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($relatedid, "Accounts"); $account_name = getAccountName($relatedid); $slashes_account_name = popup_from_html($account_name); $slashes_account_name = htmlspecialchars($slashes_account_name, ENT_QUOTES, $default_charset); $xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state'); for ($i = 0; $i < 12; $i++) { if (getFieldVisibilityPermission('Accounts', $current_user->id, $xyz[$i]) == '0') { $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]]; } else { $acct_focus->column_fields[$xyz[$i]] = ''; } } $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street'])); $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street'])); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_account_name)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } else { if ($relatedentity == 'Contacts') { require_once 'modules/Contacts/Contacts.php'; $contact_name = getContactName($relatedid); $slashes_contact_name = popup_from_html($contact_name); $slashes_contact_name = htmlspecialchars($slashes_contact_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'set_return_contact("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_contact_name)) . '");\'>' . $temp_val . '</a>'; } else { $value = $temp_val; } } } elseif ($popuptype == "set_return_emails") { if ($module == 'Accounts') { $name = $adb->query_result($list_result, $list_result_count, 'accountname'); $accid = $adb->query_result($list_result, $list_result_count, 'accountid'); if (CheckFieldPermission('email1', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email1"); $email_check = 1; } else { $email_check = 0; } if ($emailaddress == '') { if (CheckFieldPermission('email2', $module) == 'true') { $emailaddress2 = $adb->query_result($list_result, $list_result_count, "email2"); $email_check = 2; } else { if ($email_check == 1) { $email_check = 4; } else { $email_check = 3; } } } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email1 or email2 $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>'; } elseif ($module == 'Vendors') { $name = $adb->query_result($list_result, $list_result_count, 'vendorname'); $venid = $adb->query_result($list_result, $list_result_count, 'vendorid'); if (CheckFieldPermission('email', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); $email_check = 1; } else { $email_check = 0; } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email1 or email2 $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>'; } elseif ($module == 'Contacts' || $module == 'Leads') { $name = getFullNameFromQResult($list_result, $list_result_count, $module); if (CheckFieldPermission('email', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); $email_check = 1; } else { $email_check = 0; } if ($emailaddress == '') { if (CheckFieldPermission('yahooid', $module) == 'true') { $emailaddress2 = $adb->query_result($list_result, $list_result_count, "yahooid"); $email_check = 2; } else { if ($email_check == 1) { $email_check = 4; } else { $email_check = 3; } } } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email or yahooid $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . $name . '</a>'; } else { $firstname = $adb->query_result($list_result, $list_result_count, "first_name"); $lastname = $adb->query_result($list_result, $list_result_count, "last_name"); $name = $lastname . ' ' . $firstname; $emailaddress = $adb->query_result($list_result, $list_result_count, "email1"); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $email_check = 1; $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',-1,"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>'; } } elseif ($popuptype == "specific_vendor_address") { require_once 'modules/Vendors/Vendors.php'; $acct_focus = new Vendors(); $acct_focus->retrieve_entity_info($entity_id, "Vendors"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $xyz = array('street', 'city', 'postalcode', 'pobox', 'country', 'state'); for ($i = 0; $i < 6; $i++) { if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') { $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]]; } else { $acct_focus->column_fields[$xyz[$i]] = ''; } } $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['street'])); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . popup_decode_html($acct_focus->column_fields['city']) . '", "' . popup_decode_html($acct_focus->column_fields['state']) . '", "' . popup_decode_html($acct_focus->column_fields['postalcode']) . '", "' . popup_decode_html($acct_focus->column_fields['country']) . '","' . popup_decode_html($acct_focus->column_fields['pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_campaign") { $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'set_return_specific_campaign("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } else { if ($colname == "lastname") { $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module); } $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $log->debug("Exiting getValue method ..."); if ($_REQUEST['maintab'] == 'Calendar') { $value = '<a href="javascript:window.close();" onclick=\'set_return_todo("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'set_return("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } } } else { if ($module == "Leads" && $colname == "lastname" || $module == "Contacts" && $colname == "lastname") { $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($module == "Calendar") { $actvity_type = $adb->query_result($list_result, $list_result_count, 'activitytype'); $actvity_type = $actvity_type != '' ? $actvity_type : $adb->query_result($list_result, $list_result_count, 'type'); if ($actvity_type == "Task") { $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&activity_mode=Task&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } else { $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&activity_mode=Events&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } } elseif ($module == "Vendors") { $value = '<a href="index.php?action=DetailView&module=Vendors&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($module == "PriceBooks") { $value = '<a href="index.php?action=DetailView&module=PriceBooks&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($module == "SalesOrder") { $value = '<a href="index.php?action=DetailView&module=SalesOrder&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($module == 'Emails') { $value = $temp_val; } else { $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } } } elseif ($fieldname == 'expectedroi' || $fieldname == 'actualroi' || $fieldname == 'actualcost' || $fieldname == 'budgetcost' || $fieldname == 'expectedrevenue') { $rate = $user_info['conv_rate']; $value = convertFromDollar($temp_val, $rate); } elseif (($module == 'Invoice' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder') && ($fieldname == 'hdnGrandTotal' || $fieldname == 'hdnSubTotal' || $fieldname == 'txtAdjustment' || $fieldname == 'hdnDiscountAmount' || $fieldname == 'hdnS_H_Amount')) { $currency_info = getInventoryCurrencyInfo($module, $entity_id); $currency_id = $currency_info['currency_id']; $currency_symbol = $currency_info['currency_symbol']; $value = $currency_symbol . $temp_val; } else { $value = $temp_val; } } } // Mike Crowe Mod --------------------------------------------------------Make right justified and vtiger_currency value if (in_array($uitype, array(71, 72, 7, 9, 90))) { $value = '<span align="right">' . $value . '</div>'; } $log->debug("Exiting getValue method ..."); return $value; }
/** * * @global Users $current_user * @param ReportRun $report * @param Array $picklistArray * @param ADOFieldObject $dbField * @param Array $valueArray * @param String $fieldName * @return String */ function getReportFieldValue($report, $picklistArray, $dbField, $valueArray, $fieldName) { global $current_user, $default_charset; $db = PearDatabase::getInstance(); $value = $valueArray[$fieldName]; $fld_type = $dbField->type; list($module, $fieldLabel) = explode('__', $dbField->name, 2); $fieldInfo = getFieldByReportLabel($module, $fieldLabel); $fieldType = null; $fieldvalue = $value; if (!empty($fieldInfo)) { $field = WebserviceField::fromArray($db, $fieldInfo); $fieldType = $field->getFieldDataType(); } if ($fieldType == 'currency' && $value != '') { // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion if ($field->getUIType() == '72') { $curid_value = explode("::", $value); $currency_id = $curid_value[0]; $currency_value = $curid_value[1]; $cur_sym_rate = getCurrencySymbolandCRate($currency_id); if ($value != '') { if ($dbField->name == 'Products_Unit_Price') { // need to do this only for Products Unit Price if ($currency_id != 1) { $currency_value = (double) $cur_sym_rate['rate'] * (double) $currency_value; } } $formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true); $fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']); } } else { $currencyField = new CurrencyField($value); $fieldvalue = $currencyField->getDisplayValue(); } } elseif ($dbField->name == "PriceBooks_Currency") { if ($value != '') { $fieldvalue = getTranslatedCurrencyString($value); } } elseif (in_array($dbField->name, $report->ui101_fields) && !empty($value)) { $entityNames = getEntityName('Users', $value); $fieldvalue = $entityNames[$value]; } elseif ($fieldType == 'date' && !empty($value)) { if ($module == 'Calendar' && $field->getFieldName() == 'due_date') { $endTime = $valueArray['calendar_end_time']; if (empty($endTime)) { $recordId = $valueArray['calendar_id']; $endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId); } $date = new DateTimeField($value . ' ' . $endTime); $fieldvalue = $date->getDisplayDate(); } else { if (!($field->getUIType() == '5')) { $date = new DateTimeField($fieldvalue); $fieldvalue = $date->getDisplayDateTimeValue(); } } } elseif ($fieldType == "datetime" && !empty($value)) { $date = new DateTimeField($value); $fieldvalue = $date->getDisplayDateTimeValue(); } elseif ($fieldType == 'time' && !empty($value) && $field->getFieldName() != 'duration_hours') { if ($field->getFieldName() == "time_start" || $field->getFieldName() == "time_end") { $date = new DateTimeField($value); $fieldvalue = $date->getDisplayTime(); } else { $userModel = Users_Privileges_Model::getCurrentUserModel(); if ($userModel->get('hour_format') == '12') { $value = Vtiger_Time_UIType::getTimeValueInAMorPM($value); } $fieldvalue = $value; } } elseif ($fieldType == "picklist" && !empty($value)) { if (is_array($picklistArray)) { if (is_array($picklistArray[$dbField->name]) && $field->getFieldName() != 'activitytype' && !in_array($value, $picklistArray[$dbField->name])) { $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $fieldvalue = getTranslatedString($value, $module); } } else { $fieldvalue = getTranslatedString($value, $module); } } elseif ($fieldType == "multipicklist" && !empty($value)) { if (is_array($picklistArray[1])) { $valueList = explode(' |##| ', $value); $translatedValueList = array(); foreach ($valueList as $value) { if (is_array($picklistArray[1][$dbField->name]) && !in_array($value, $picklistArray[1][$dbField->name])) { $translatedValueList[] = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $translatedValueList[] = getTranslatedString($value, $module); } } } if (!is_array($picklistArray[1]) || !is_array($picklistArray[1][$dbField->name])) { $fieldvalue = str_replace(' |##| ', ', ', $value); } else { implode(', ', $translatedValueList); } } elseif ($fieldType == 'double') { if ($current_user->truncate_trailing_zeros == true) { $fieldvalue = decimalFormat($fieldvalue); } } elseif ($fieldType == 'boolean') { if (strtolower($value) === 'yes' || strtolower($value) === 'on' || $value == 1) { $fieldvalue = vtranslate('LBL_YES'); } else { $fieldvalue = vtranslate('LBL_NO'); } } elseif ($field && $field->getUIType() == 117 && $value != '') { if ($value != '0') { $currencyList = Settings_Currency_Record_Model::getAll(); $fieldvalue = $currencyList[$value]->getName() . ' (' . $currencyList[$value]->get('currency_symbol') . ')'; } else { $fieldvalue = '-'; } } if ('vtiger_crmentity' == $dbField->table && false != strpos($dbField->name, 'Share__with__users')) { if ($value) { $listId = explode(',', $value); $usersSqlFullName = getSqlForNameInDisplayFormat(['first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'], 'Users'); $getListUserSql = "select {$usersSqlFullName} as uname from vtiger_users WHERE id IN (" . generateQuestionMarks($listId) . ') '; $getListUserResult = $db->pquery($getListUserSql, array($listId), TRUE); $fieldvalue = ''; $finalList = array(); $listUsers = $getListUserResult->GetAll(); for ($i = 0; $i < count($listUsers); $i++) { $finalList[] = $listUsers[$i][0]; } $fieldvalue = implode(', ', $finalList); } } if ($fieldvalue == "") { return "-"; } $fieldvalue = str_replace("<", "<", $fieldvalue); $fieldvalue = str_replace(">", ">", $fieldvalue); $fieldvalue = decode_html($fieldvalue); if (stristr($fieldvalue, "|##|") && empty($fieldType)) { $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); } elseif ($fld_type == "date" && empty($fieldType)) { $fieldvalue = DateTimeField::convertToUserFormat($fieldvalue); } elseif ($fld_type == "datetime" && empty($fieldType)) { $date = new DateTimeField($fieldvalue); $fieldvalue = $date->getDisplayDateTimeValue(); } // Added to render html tag for description fields if ($fieldInfo['uitype'] == '19' && ($module == 'Documents' || $module == 'Emails')) { return $fieldvalue; } return htmlentities($fieldvalue, ENT_QUOTES, $default_charset); }
public function save() { ${"GLOBALS"}["ducixeik"] = "additionalProductFields"; ${${"GLOBALS"}["wtrcwdueuts"]} = PearDatabase::getInstance(); ${${"GLOBALS"}["ducixeik"]} = $this->getAdditionalProductFields(); ${"GLOBALS"}["molcrpc"] = "manualUpdateFields"; ${"GLOBALS"}["gbmhcqh"] = "tmp"; ${"GLOBALS"}["ewjsruuy"] = "fieldName"; ${${"GLOBALS"}["molcrpc"]} = array(); foreach (${${"GLOBALS"}["vptmrj"]} as ${${"GLOBALS"}["ewjsruuy"]} => ${${"GLOBALS"}["gbmhcqh"]}) { if (${${"GLOBALS"}["ykppheofobwk"]}["implemented"] == false) { $jpmxewcq = "relData"; ${"GLOBALS"}["fkfnvsuaox"] = "manualUpdateFields"; ${${"GLOBALS"}["fkfnvsuaox"]}[] = ${${"GLOBALS"}["thpgoyrlu"]}; ${$jpmxewcq} = $this->_getProductRelData(); } } require_once "modules/Emails/mail.php"; if (!empty($this->_id) && $this->_changed == true) { $this->_changedProducts = $this->_changed; if ($this->_listitems === null) { $this->_loadProducts(); } } parent::save(); $this->prepareTransfer(); if (!empty($this->_currencyID)) { ${${"GLOBALS"}["xkutivbm"]} = $this->_currencyID; } else { $ogqhrcro = "currency_id"; ${$ogqhrcro} = false; } $this->clearData(); if ($this->_changedProducts === true) { ${"GLOBALS"}["tgkrfb"] = "shipping_handling_charge"; ${"GLOBALS"}["negltbro"] = "field"; ${${"GLOBALS"}["amsupsflnmf"]} = $this->get("hdnTaxType"); ${"GLOBALS"}["hxnewftfdqn"] = "i"; ${"GLOBALS"}["etqhqirsnh"] = "taxtype"; $agoclef = "adjustment"; ${$agoclef} = 0; ${${"GLOBALS"}["tgkrfb"]} = 0; $qwpblm = "i"; ${"GLOBALS"}["krxwtxw"] = "fields"; ${${"GLOBALS"}["whqnrjvsw"]} = getAllTaxes(); $nxxrnbh = "intObject"; $mdwcbjhvim = "availTaxes"; $vaqwwrr = "value"; $_REQUEST["totalProductCount"] = count($this->_listitems); $_REQUEST["taxtype"] = ${${"GLOBALS"}["etqhqirsnh"]}; $_REQUEST["subtotal"] = 0; ${${"GLOBALS"}["pponynktout"]} = $this->getProductFields(); foreach (${${"GLOBALS"}["krxwtxw"]} as ${${"GLOBALS"}["negltbro"]} => ${$vaqwwrr}) { $_REQUEST[${${"GLOBALS"}["mlsoidilfq"]}] = ${${"GLOBALS"}["cqlhrtj"]}; } for (${${"GLOBALS"}["hxnewftfdqn"]} = 1; ${${"GLOBALS"}["jsntgvnqkf"]} <= count($this->_listitems); ${${"GLOBALS"}["jsntgvnqkf"]}++) { ${"GLOBALS"}["zepdlqparq"] = "i"; $_REQUEST["subtotal"] += ${${"GLOBALS"}["pponynktout"]}["productTotal" . ${${"GLOBALS"}["zepdlqparq"]}]; } $klivirms = "intObject"; $cnavotvg = "globalTaxValue"; ${"GLOBALS"}["ouawiowlgku"] = "shipTaxValue"; $_REQUEST["discount_percentage_final"] = $this->get("hdnDiscountPercent"); $_REQUEST["discount_percentage_final"] = floatval($_REQUEST["discount_percentage_final"]); $_REQUEST["discount_amount_final"] = $this->get("hdnDiscountAmount"); $_REQUEST["discount_amount_final"] = floatval($_REQUEST["discount_amount_final"]); $_REQUEST["discount_type_final"] = !empty($_REQUEST["discount_percentage_final"]) ? "percentage" : "amount"; $_REQUEST["total"] = $_REQUEST["subtotal"]; if ($_REQUEST["discount_type_final"] == "amount") { $_REQUEST["total"] -= $_REQUEST["discount_amount_final"]; } elseif ($_REQUEST["discount_type_final"] == "percentage") { $_REQUEST["total"] -= $_REQUEST["total"] * ($_REQUEST["discount_percentage_final"] / 100); } ${$cnavotvg} = 0; if (${${"GLOBALS"}["amsupsflnmf"]} == "group") { ${"GLOBALS"}["yirabwmnwgyp"] = "globalTaxValue"; $oplkjyxi = "availTaxes"; foreach (${$oplkjyxi} as ${${"GLOBALS"}["wfuwxbmiwytq"]}) { $psuluqnb = "request_tax_name"; $enefpgduf = "tax"; ${"GLOBALS"}["wxlvsgkcw"] = "request_tax_name"; ${${"GLOBALS"}["hvjpdk"]} = ${$enefpgduf}["taxname"]; ${${"GLOBALS"}["wxlvsgkcw"]} = ${${"GLOBALS"}["hvjpdk"]} . "_group_percentage"; $lifliipv = "request_tax_name"; $_REQUEST[${${"GLOBALS"}["hwivgkl"]}] = isset($this->_groupTax[${${"GLOBALS"}["hwivgkl"]}]) ? $this->_groupTax[${$psuluqnb}] : 0; $bltbxkcxbjyp = "tmpTaxValue"; ${${"GLOBALS"}["fvbuscvwjf"]} = $_REQUEST["total"] * ($_REQUEST[${$lifliipv}] / 100); ${${"GLOBALS"}["zjswudci"]} += ${$bltbxkcxbjyp}; } $_REQUEST["total"] += ${${"GLOBALS"}["yirabwmnwgyp"]}; } $_REQUEST["shipping_handling_charge"] = $this->_shippingCost; ${${"GLOBALS"}["cxnjuagap"]} = 0; $bbluqvmmcrl = "tax"; foreach (${$mdwcbjhvim} as ${$bbluqvmmcrl}) { $rbwcrso = "request_tax_name"; ${"GLOBALS"}["woxvppdlct"] = "tmpTaxValue"; $xeqhidsvg = "shipTaxValue"; ${"GLOBALS"}["rihoezbjibn"] = "tax_name"; ${${"GLOBALS"}["rihoezbjibn"]} = ${${"GLOBALS"}["wfuwxbmiwytq"]}["taxname"]; ${$rbwcrso} = ${${"GLOBALS"}["hvjpdk"]} . "_sh_percent"; $uaabpfjmwc = "request_tax_name"; $_REQUEST["sh" . ${${"GLOBALS"}["hwivgkl"]}] = isset($this->_shipTaxes[${${"GLOBALS"}["hwivgkl"]}]) ? $this->_shipTaxes[${${"GLOBALS"}["hwivgkl"]}] : 0; ${${"GLOBALS"}["fvbuscvwjf"]} = $_REQUEST["shipping_handling_charge"] * ($_REQUEST["sh" . ${$uaabpfjmwc}] / 100); ${$xeqhidsvg} += ${${"GLOBALS"}["woxvppdlct"]}; } $_REQUEST["total"] += ${${"GLOBALS"}["ouawiowlgku"]} + $_REQUEST["shipping_handling_charge"]; $_REQUEST["adjustment"] = floatval($this->get("txtAdjustment")); $_REQUEST["total"] += $_REQUEST["adjustment"]; ${$nxxrnbh} = $this->getInternalObject(); $intObject->mode = "edit"; $intObject->isLineItemUpdate = true; @saveInventoryProductDetails(${$klivirms}, $this->getModuleName()); for (${${"GLOBALS"}["jsntgvnqkf"]} = 1; ${${"GLOBALS"}["jsntgvnqkf"]} <= count($this->_listitems); ${$qwpblm}++) { ${"GLOBALS"}["xzgznik"] = "values"; ${${"GLOBALS"}["xzgznik"]} = array(); $dqnotemwlbq = "params"; ${$dqnotemwlbq} = array(); foreach (${${"GLOBALS"}["ogvkpmc"]} as ${${"GLOBALS"}["nctgtuliixp"]}) { ${"GLOBALS"}["fjordnwx"] = "values"; ${${"GLOBALS"}["fjordnwx"]}[] = "`" . ${${"GLOBALS"}["nctgtuliixp"]} . "` = ?"; ${${"GLOBALS"}["tjyzhfdvth"]}[] = $this->_listitems[${${"GLOBALS"}["jsntgvnqkf"]} - 1][${${"GLOBALS"}["nctgtuliixp"]}]; } if (count(${${"GLOBALS"}["ibmlnecaubpt"]}) > 0) { $nvtwyqcc = "params"; $wbzhsv = "i"; $glpeqaibe = "params"; ${${"GLOBALS"}["tjyzhfdvth"]}[] = $this->getId(); $mjhhtobppu = "sql"; ${$nvtwyqcc}[] = ${$wbzhsv}; ${${"GLOBALS"}["hdblop"]} = "UPDATE vtiger_inventoryproductrel SET " . implode(",", ${${"GLOBALS"}["ibmlnecaubpt"]}) . " WHERE id = ? AND sequence_no = ?"; $adb->pquery(${$mjhhtobppu}, ${$glpeqaibe}); } } } if (!empty(${${"GLOBALS"}["xkutivbm"]})) { $wrqjvjvs = "update_query"; ${"GLOBALS"}["ryhoienvnsn"] = "cur_sym_rate"; $xepbzcbhw = "update_params"; ${"GLOBALS"}["ohiigcodbwo"] = "conversion_rate"; $pcrolhc = "currency_id"; ${"GLOBALS"}["udferc"] = "conversion_rate"; $fkgwwhoop = "intObject"; ${"GLOBALS"}["nglnmk"] = "update_query"; ${"GLOBALS"}["nvezfxsotm"] = "currency_id"; if (strpos(${${"GLOBALS"}["nvezfxsotm"]}, "x") !== false) { ${"GLOBALS"}["twtpeleg"] = "parts"; ${${"GLOBALS"}["bbeqpsqwehf"]} = explode("x", ${${"GLOBALS"}["xkutivbm"]}); ${${"GLOBALS"}["xkutivbm"]} = ${${"GLOBALS"}["twtpeleg"]}[1]; } else { ${"GLOBALS"}["kuscdvfpt"] = "currency_id"; ${${"GLOBALS"}["kuscdvfpt"]} = ${${"GLOBALS"}["xkutivbm"]}; } $ksoimju = "cur_sym_rate"; ${$ksoimju} = getCurrencySymbolandCRate(${${"GLOBALS"}["xkutivbm"]}); ${${"GLOBALS"}["ohiigcodbwo"]} = ${${"GLOBALS"}["ryhoienvnsn"]}["rate"]; ${"GLOBALS"}["epcnplti"] = "update_params"; ${$fkgwwhoop} = $this->getInternalObject(); ${$wrqjvjvs} = "update " . $intObject->table_name . " set currency_id = ?, conversion_rate = ? WHERE " . $intObject->table_index . " = ?"; ${$xepbzcbhw} = array(${$pcrolhc}, ${${"GLOBALS"}["udferc"]}, $this->_id); $adb->pquery(${${"GLOBALS"}["nglnmk"]}, ${${"GLOBALS"}["epcnplti"]}); } if (file_exists(vglobal("root_directory") . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . "Invoice" . DIRECTORY_SEPARATOR . "InvoiceHandler.php")) { ${"GLOBALS"}["hebripdxg"] = "entityData"; ${"GLOBALS"}["llplslhg"] = "adb"; require_once "modules/Invoice/InvoiceHandler.php"; require_once "include/events/VTEventHandler.inc"; require_once "data/VTEntityDelta.php"; ${${"GLOBALS"}["hebripdxg"]} = \VTEntityData::fromEntityId(${${"GLOBALS"}["llplslhg"]}, $this->getId(), $this->getModuleName()); $omsgxnkjeni = "handler"; ${$omsgxnkjeni} = new \InvoiceHandler(); $handler->handleEvent("vtiger.entity.aftersave", ${${"GLOBALS"}["xxguhqgid"]}); } $this->afterTransfer(); $this->_data = false; }
function getTopAccounts($maxval, $calCnt) { $log = LoggerManager::getLogger('top accounts_list'); $log->debug("Entering getTopAccounts() method ..."); require_once "data/Tracker.php"; require_once 'modules/Potentials/Potentials.php'; require_once 'include/logging.php'; require_once 'include/ListView/ListView.php'; global $app_strings; global $adb; global $current_language; global $current_user; $current_module_strings = return_module_language($current_language, "Accounts"); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; $list_query = "select vtiger_potential.potentialname,vtiger_account.accountid, vtiger_account.accountname, " . "vtiger_account.tickersymbol, sum(vtiger_potential.amount) as amount from vtiger_potential " . "inner join vtiger_crmentity on (vtiger_potential.potentialid=vtiger_crmentity.crmid) " . "inner join vtiger_account on (vtiger_potential.related_to=vtiger_account.accountid) "; $list_query .= " WHERE vtiger_crmentity.deleted = 0 " . $where . " AND vtiger_potential.potentialid>0"; $list_query .= " AND vtiger_crmentity.smownerid='" . $current_user->id . "' " . "and vtiger_potential.sales_stage not in ('Closed Won', 'Closed Lost','" . $app_strings['LBL_CLOSE_WON'] . "','" . $app_strings['LBL_CLOSE_LOST'] . "')"; $list_query .= " group by vtiger_account.accountid, vtiger_account.tickersymbol order by amount desc"; $list_query .= " LIMIT 0," . $adb->sql_escape_string($maxval); if ($calCnt == 'calculateCnt') { $list_result_rows = $adb->query(mkCountQuery($list_query)); return $adb->query_result($list_result_rows, 0, 'count'); } $list_result = $adb->query($list_query); $open_accounts_list = array(); $noofrows = $adb->num_rows($list_result); if ($noofrows) { for ($i = 0; $i < $noofrows; $i++) { $open_accounts_list[] = array('accountid' => $adb->query_result($list_result, $i, 'accountid'), 'accountname' => $adb->query_result($list_result, $i, 'accountname'), 'amount' => $adb->query_result($list_result, $i, 'amount'), 'tickersymbol' => $adb->query_result($list_result, $i, 'tickersymbol')); } } $title = array(); $title[] = 'myTopAccounts.gif'; $title[] = $current_module_strings['LBL_TOP_ACCOUNTS']; $title[] = 'home_myaccount'; $header = array(); $header[] = $current_module_strings['LBL_LIST_ACCOUNT_NAME']; $currencyid = fetchCurrency($current_user->id); $rate_symbol = getCurrencySymbolandCRate($currencyid); $rate = $rate_symbol['rate']; $curr_symbol = $rate_symbol['symbol']; $header[] = $current_module_strings['LBL_LIST_AMOUNT'] . '(' . $curr_symbol . ')'; $header[] = $current_module_strings['LBL_POTENTIAL_TITLE']; $entries = array(); foreach ($open_accounts_list as $account) { $value = array(); $account_fields = array('ACCOUNT_ID' => $account['accountid'], 'ACCOUNT_NAME' => $account['accountname'], 'AMOUNT' => $account['amount']); // JFV - fix wrongly truncationed utf8 string if (function_exists("mb_strimwidth")) { $Top_Accounts = mb_strimwidth($account['accountname'], 0, 30, '...', "UTF-8"); } else { // JFV END $Top_Accounts = strlen($account['accountname']) > 20 ? substr($account['accountname'], 0, 20) . '...' : $account['accountname']; // JFV } // JFV END $value[] = '<a href="index.php?action=DetailView&module=Accounts&record=' . $account['accountid'] . '">' . $Top_Accounts . '</a>'; $value[] = CurrencyField::convertToUserFormat($account['amount']); $entries[$account['accountid']] = $value; } $values = array('ModuleName' => 'Accounts', 'Title' => $title, 'Header' => $header, 'Entries' => $entries); $log->debug("Exiting getTopAccounts method ..."); if ($display_empty_home_blocks && count($entries) == 0 || count($entries) > 0) { return $values; } }
private function x10($x92, $x93, $x94 = false, $x95 = false) { global $x15d, $x15e, $x15f, $x160, $x161, $x162, $x163, $x164, $x165, $x166, $x167, $x168, $x169, $x16a, $x16b, $x16c, $x16d, $x16e, $x16f, $x170, $x171, $x172, $x173, $x174, $x175, $x176, $x177, $x178; $x96 = Users_Record_Model::getCurrentUserModel(); $x97 = array("related_to", "relatedto", "parent_id", "parentid", "product_id", "productid", "service_id", "serviceid", "vendor_id", "product", "account", "invoiceid", "linktoaccountscontacts", "projectid", "sc_related_to"); if ($x95 !== false) { $x98 = array(); } $x51 = getTabid($x92); $x99 = $x92; if ($x94 === false) { $x9a = ""; } else { $x9a = "R_"; if ($x94 !== true) { $x99 = $x94; } } $x9b = array(); $x9c = array(); $x9d = array(); $x9e = array(); $x9f = array(); $xa0 = array(); $xa1 = array(); if ($x51 == '9') { $x3d = "SELECT fieldname, uitype FROM vtiger_field WHERE tabid IN (9,16)"; } else { $x3d = "SELECT fieldname, uitype FROM vtiger_field WHERE tabid = '" . $x51 . "'"; } $x3e = self::$x0f->query($x3d); while ($x42 = self::$x0f->fetchByAssoc($x3e)) { switch ($x42['uitype']) { case '19': case '20': case '21': case '24': $x9d[] = $x42['fieldname']; break; case '5': case '6': case '23': case '70': $x9e[] = $x42['fieldname']; break; case '15': $x9c[] = $x42['fieldname']; break; case '56': $x9b[] = $x42['fieldname']; break; case '33': $x9f[] = $x42['fieldname']; break; case '71': $xa0[] = $x42['fieldname']; break; case '9': $xa1[] = $x42['fieldname']; break; } if ($x42["fieldname"] == "salutationtype") { $x9c[] = $x42["fieldname"]; } } foreach ($x93->column_fields as $xa2 => $x83) { if ($xa2 == "assigned_user_id") { $x83 = $this->x1e($x83); } elseif ($xa2 == "account_id") { $x83 = getAccountName($x83); } elseif ($xa2 == "potential_id") { $x83 = getPotentialName($x83); } elseif ($xa2 == "contact_id") { $x83 = getContactName($x83); } elseif ($xa2 == "quote_id") { $x83 = getQuoteName($x83); } elseif ($xa2 == "salesorder_id") { $x83 = getSoName($x83); } elseif ($xa2 == "campaignid") { $x83 = getCampaignName($x83); } elseif ($xa2 == "terms_conditions") { $x83 = $this->x25($x83); } elseif ($xa2 == "comments") { $x83 = $this->x26($x93); } elseif ($xa2 == "folderid") { $x83 = $this->x27($x83); } elseif ($xa2 == "time_start" || $xa2 == "time_end") { $xa3 = DateTimeField::convertToUserTimeZone($x83); $x83 = $xa3->format('H:i'); } elseif ($x168($xa2, $x97)) { if ($x83 != "") { $xa4 = getSalesEntityType($x83); $xa5 = getEntityName($xa4, $x83); if (!empty($xa5)) { foreach ($xa5 as $xa6) { $x83 = $xa6; } } if ($xa2 == "invoiceid" && $x83 == "0") { $x83 = ""; } } } if ($x168($xa2, $x9e)) { if ($x92 == "Events" || $x92 == "Calendar") { if ($xa2 == "date_start" && $x93->column_fields["time_start"] != "") { $xa3 = $x93->column_fields['time_start']; $x83 = $x83 . ' ' . $xa3; } elseif ($xa2 == "due_date" && $x93->column_fields["time_end"] != "") { $xa3 = $x93->column_fields['time_end']; $x83 = $x83 . ' ' . $xa3; } } if ($x83 != "") { $x83 = getValidDisplayDate($x83); } } elseif ($x168($xa2, $x9c)) { if (!$x168($x178($x83), self::$x18)) { $x83 = $this->x20($x83, $x92); } else { $x83 = ""; } } elseif ($x168($xa2, $x9b)) { if ($x83 == 1) { $x83 = vtranslate('LBL_YES'); } else { $x83 = vtranslate('LBL_NO'); } } elseif ($x168($xa2, $x9d)) { $x83 = $x16d($x83); $x83 = $x165($x83, ENT_QUOTES, self::$x11); } elseif ($x168($xa2, $x9f)) { $x83 = $x173(' |##| ', ', ', $x83); } elseif ($x168($xa2, $xa0)) { if ($x16a($x83)) { if ($x95 === false) { $xa7 = getCurrencySymbolandCRate($x96->currency_id); $xa8 = $xa7["rate"]; } else { $xa8 = $x95["conversion_rate"]; } $x83 = $x83 * $xa8; } $x83 = $this->x23($x83); } elseif ($x168($xa2, $xa1)) { $x83 = $this->x23($x83); } if ($x95 !== false) { $x98[$x175($x92 . "_" . $xa2)] = $x83; } else { self::$x21["\$" . $x9a . $x175($x99 . "_" . $xa2) . "\$"] = $x83; } } if ($x95 !== false) { return $x98; } else { $this->x15(); } }
global $app_strings, $mod_strings, $current_language, $currentModule, $theme, $adb, $log, $current_user; require_once 'Smarty_setup.php'; require_once 'data/Tracker.php'; require_once 'include/CustomFieldUtil.php'; require_once 'include/utils/utils.php'; $focus = CRMEntity::getInstance($currentModule); $smarty = new vtigerCRM_Smarty(); $category = getParentTab($currentModule); $record = vtlib_purify($_REQUEST['record']); $isduplicate = vtlib_purify($_REQUEST['isDuplicate']); //added to fix the issue4600 $searchurl = getBasic_Advance_SearchURL(); $smarty->assign("SEARCH", $searchurl); //4600 ends $currencyid = fetchCurrency($current_user->id); $rate_symbol = getCurrencySymbolandCRate($currencyid); $rate = $rate_symbol['rate']; if (isset($_REQUEST['record']) && $_REQUEST['record'] != '') { $focus->id = $record; $focus->mode = 'edit'; $focus->retrieve_entity_info($record, 'PurchaseOrder'); $focus->name = $focus->column_fields['subject']; } if ($isduplicate == 'true') { $smarty->assign('DUPLICATE_FROM', $focus->id); $PO_associated_prod = getAssociatedProducts($currentModule, $focus); $inventory_cur_info = getInventoryCurrencyInfo($currentModule, $focus->id); $currencyid = $inventory_cur_info['currency_id']; $focus->id = ''; $focus->mode = ''; }
/** Function used to get all the price details for different currencies which are associated to the given product * @param int $productid - product id to which we want to get all the associated prices * @param decimal $unit_price - Unit price of the product * @param string $available - available or available_associated where as default is available, if available then the prices in the currencies which are available now will be returned, otherwise if the value is available_associated then prices of all the associated currencies will be retruned * @return array $price_details - price details as a array with productid, curid, curname */ function getPriceDetailsForProduct($productid, $unit_price, $available = 'available', $itemtype = 'Products') { global $log, $adb; $log->debug("Entering into function getPriceDetailsForProduct({$productid})"); if ($productid != '') { $product_currency_id = getProductBaseCurrency($productid, $itemtype); $product_base_conv_rate = getBaseConversionRateForProduct($productid, 'edit', $itemtype); // Detail View if ($available == 'available_associated') { $query = "select vtiger_currency_info.*, vtiger_productcurrencyrel.converted_price, vtiger_productcurrencyrel.actual_price\n\t\t\t\t\tfrom vtiger_currency_info\n\t\t\t\t\tinner join vtiger_productcurrencyrel on vtiger_currency_info.id = vtiger_productcurrencyrel.currencyid\n\t\t\t\t\twhere vtiger_currency_info.currency_status = 'Active' and vtiger_currency_info.deleted=0\n\t\t\t\t\tand vtiger_productcurrencyrel.productid = ? and vtiger_currency_info.id != ?"; $params = array($productid, $product_currency_id); } else { // Edit View $query = "select vtiger_currency_info.*, vtiger_productcurrencyrel.converted_price, vtiger_productcurrencyrel.actual_price\n\t\t\t\t\tfrom vtiger_currency_info\n\t\t\t\t\tleft join vtiger_productcurrencyrel\n\t\t\t\t\ton vtiger_currency_info.id = vtiger_productcurrencyrel.currencyid and vtiger_productcurrencyrel.productid = ?\n\t\t\t\t\twhere vtiger_currency_info.currency_status = 'Active' and vtiger_currency_info.deleted=0"; $params = array($productid); } //Postgres 8 fixes if ($adb->dbType == "pgsql") { $query = fixPostgresQuery($query, $log, 0); } $res = $adb->pquery($query, $params); for ($i = 0; $i < $adb->num_rows($res); $i++) { $price_details[$i]['productid'] = $productid; $price_details[$i]['currencylabel'] = $adb->query_result($res, $i, 'currency_name'); $price_details[$i]['currencycode'] = $adb->query_result($res, $i, 'currency_code'); $price_details[$i]['currencysymbol'] = $adb->query_result($res, $i, 'currency_symbol'); $currency_id = $adb->query_result($res, $i, 'id'); $price_details[$i]['curid'] = $currency_id; $price_details[$i]['curname'] = 'curname' . $adb->query_result($res, $i, 'id'); $cur_value = $adb->query_result($res, $i, 'actual_price'); // Get the conversion rate for the given currency, get the conversion rate of the product currency to base currency. // Both together will be the actual conversion rate for the given currency. $conversion_rate = $adb->query_result($res, $i, 'conversion_rate'); $actual_conversion_rate = $product_base_conv_rate * $conversion_rate; if ($cur_value == null || $cur_value == '') { $price_details[$i]['check_value'] = false; if ($unit_price != null) { $cur_value = convertFromMasterCurrency($unit_price, $actual_conversion_rate); } else { $cur_value = '0'; } } else { $price_details[$i]['check_value'] = true; } $price_details[$i]['curvalue'] = CurrencyField::convertToUserFormat($cur_value, null, true); $price_details[$i]['conversionrate'] = $actual_conversion_rate; $is_basecurrency = false; if ($currency_id == $product_currency_id) { $is_basecurrency = true; } $price_details[$i]['is_basecurrency'] = $is_basecurrency; } } else { if ($available == 'available') { // Create View global $current_user; $user_currency_id = fetchCurrency($current_user->id); $query = "select vtiger_currency_info.* from vtiger_currency_info\n\t\t\t\t\twhere vtiger_currency_info.currency_status = 'Active' and vtiger_currency_info.deleted=0"; $params = array(); $res = $adb->pquery($query, $params); for ($i = 0; $i < $adb->num_rows($res); $i++) { $price_details[$i]['currencylabel'] = $adb->query_result($res, $i, 'currency_name'); $price_details[$i]['currencycode'] = $adb->query_result($res, $i, 'currency_code'); $price_details[$i]['currencysymbol'] = $adb->query_result($res, $i, 'currency_symbol'); $currency_id = $adb->query_result($res, $i, 'id'); $price_details[$i]['curid'] = $currency_id; $price_details[$i]['curname'] = 'curname' . $adb->query_result($res, $i, 'id'); // Get the conversion rate for the given currency, get the conversion rate of the product currency(logged in user's currency) to base currency. // Both together will be the actual conversion rate for the given currency. $conversion_rate = $adb->query_result($res, $i, 'conversion_rate'); $user_cursym_convrate = getCurrencySymbolandCRate($user_currency_id); $product_base_conv_rate = 1 / $user_cursym_convrate['rate']; $actual_conversion_rate = $product_base_conv_rate * $conversion_rate; $price_details[$i]['check_value'] = false; $price_details[$i]['curvalue'] = '0'; $price_details[$i]['conversionrate'] = $actual_conversion_rate; $is_basecurrency = false; if ($currency_id == $user_currency_id) { $is_basecurrency = true; } $price_details[$i]['is_basecurrency'] = $is_basecurrency; } } else { $log->debug("Product id is empty. we cannot retrieve the associated prices."); } } $log->debug("Exit from function getPriceDetailsForProduct({$productid})"); return $price_details; }
$search = vtlib_purify($_REQUEST['search_url']); $focus = new $currentModule(); setObjectValuesFromRequest($focus); list($void, $canaddcomments) = cbEventHandler::do_filter('corebos.filter.ModComments.canAdd', array(vtlib_purify($_REQUEST['related_to']), true)); if ($canaddcomments) { $mode = vtlib_purify($_REQUEST['mode']); $record = vtlib_purify($_REQUEST['record']); if ($mode) { $focus->mode = $mode; } if ($record) { $focus->id = $record; } if (isset($_REQUEST['inventory_currency'])) { $focus->column_fields['currency_id'] = vtlib_purify($_REQUEST['inventory_currency']); $cur_sym_rate = getCurrencySymbolandCRate(vtlib_purify($_REQUEST['inventory_currency'])); $focus->column_fields['conversion_rate'] = $cur_sym_rate['rate']; } if ($_REQUEST['assigntype'] == 'U') { $focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_user_id']; } elseif ($_REQUEST['assigntype'] == 'T') { $focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_group_id']; } list($saveerror, $errormessage, $error_action, $returnvalues) = $focus->preSaveCheck($_REQUEST); if ($saveerror) { // there is an error so we go back to EditView. $return_module = $return_id = $return_action = ''; if (!empty($_REQUEST['return_action'])) { $return_action = '&return_action=' . vtlib_purify($_REQUEST['return_action']); } if (!empty($_REQUEST['return_module'])) {
/** This function returns the detail view form vtiger_field and and its properties in array format. * Param $uitype - UI type of the vtiger_field * Param $fieldname - Form vtiger_field name * Param $fieldlabel - Form vtiger_field label name * Param $col_fields - array contains the vtiger_fieldname and values * Param $generatedtype - Field generated type (default is 1) * Param $tabid - vtiger_tab id to which the Field belongs to (default is "") * Return type is an array */ function getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid = '', $module = '') { global $log; $log->debug("Entering getDetailViewOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $col_fields . "," . $generatedtype . "," . $tabid . ") method ..."); global $adb; global $mod_strings; global $app_strings; global $current_user; global $theme; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $fieldlabel = from_html($fieldlabel); $custfld = ''; $value = ''; $arr_data = array(); $label_fld = array(); $data_fld = array(); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; // vtlib customization: New uitype to handle relation between modules if ($uitype == '10') { $fieldlabel = getTranslatedString($fieldlabel, $module); $parent_id = $col_fields[$fieldname]; if (!empty($parent_id)) { $parent_module = getSalesEntityType($parent_id); $valueTitle = getTranslatedString($parent_module, $parent_module); $displayValueArray = getEntityName($parent_module, $parent_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $value) { $displayValue = $value; } } // vtlib customization: For listview javascript triggers $modMetaInfo = getEntityFieldNames($parent_module); $modEName = is_array($modMetaInfo['fieldname']) ? $modMetaInfo['fieldname'][0] : $modMetaInfo['fieldname']; $vtlib_metainfo = "<span type='vtlib_metainfo' vtrecordid='{$parent_id}' vtfieldname=" . "'{$modEName}' vtmodule='{$parent_module}' style='display:none;'></span>"; // END $label_fld = array($fieldlabel, "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>{$displayValue}</a>{$vtlib_metainfo}"); } else { $moduleSpecificMessage = 'MODULE_NOT_SELECTED'; if ($mod_strings[$moduleSpecificMessage] != "") { $moduleSpecificMessage = $mod_strings[$moduleSpecificMessage]; } $label_fld = array($fieldlabel, ''); } } else { if ($uitype == 99) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; if ($fieldname == 'confirm_password') { return null; } } elseif ($uitype == 116 || $uitype == 117) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = getCurrencyName($col_fields[$fieldname]); $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0"; $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name'); $currency_id = $adb->query_result($pickListResult, $j, 'id'); if ($col_fields[$fieldname] == $currency_id) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[$currency_id] = array($pickListValue => $chk_val); } $label_fld["options"] = $options; } elseif ($uitype == 13 || $uitype == 104) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 16) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = getTranslatedString($col_fields[$fieldname], $module); $fieldname = $adb->sql_escape_string($fieldname); $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid"; $params = array(); $pickListResult = $adb->pquery($pick_query, $params); $noofpickrows = $adb->num_rows($pickListResult); $options = array(); $count = 0; $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname))); $col_fields[$fieldname] = decode_html($col_fields[$fieldname]); if ($col_fields[$fieldname] == $pickListValue) { $chk_val = "selected"; $count++; $found = true; } else { $chk_val = ''; } $pickListValue = to_html($pickListValue); $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } $label_fld["options"] = $options; } elseif ($uitype == 15) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; $roleid = $current_user->roleid; $valueArr = explode("|##|", $col_fields[$fieldname]); $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); //Mikecrowe fix to correctly default for custom pick lists $options = array(); $count = 0; $found = false; if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { if (in_array(trim($pickListValue), array_map("trim", $valueArr))) { $chk_val = "selected"; $pickcount++; } else { $chk_val = ''; } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected'); } } $label_fld["options"] = $options; } elseif ($uitype == 115) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = getTranslatedString($col_fields[$fieldname]); $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname); $pickListResult = $adb->pquery($pick_query, array()); $noofpickrows = $adb->num_rows($pickListResult); $options = array(); $found = false; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname)); if ($col_fields[$fieldname] == $pickListValue) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $label_fld["options"] = $options; } elseif ($uitype == 33) { //uitype 33 added for multiselector picklist - Jeri $roleid = $current_user->roleid; $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = str_ireplace(' |##| ', ', ', $col_fields[$fieldname]); $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb); $options = array(); $selected_entries = array(); $selected_entries = explode(' |##| ', $col_fields[$fieldname]); if (!empty($picklistValues)) { foreach ($picklistValues as $order => $pickListValue) { foreach ($selected_entries as $selected_entries_value) { if (trim($selected_entries_value) == trim(htmlentities($pickListValue, ENT_QUOTES, $default_charset))) { $chk_val = 'selected'; $pickcount++; break; } else { $chk_val = ''; } } if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') { $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val); } else { $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val); } } if ($pickcount == 0 && !empty($value)) { $not_access_lbl = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; $options[] = array($not_access_lbl, trim($selected_entries_value), 'selected'); } } $label_fld["options"] = $options; } elseif ($uitype == 17) { $label_fld[] = getTranslatedString($fieldlabel, $module); $matchPattern = "^[\\w]+:\\/\\/^"; $value = $col_fields[$fieldname]; preg_match($matchPattern, $value, $matches); if (!empty($matches[0])) { $fieldValue = str_replace($matches, "", $value); $label_fld[] = $value; } else { if ($value != null) { $label_fld[] = 'http://' . $value; } else { $label_fld[] = ''; } } } elseif ($uitype == 19) { if ($fieldname == 'notecontent' or $module == 'Timecontrol') { $col_fields[$fieldname] = decode_html($col_fields[$fieldname]); } else { $col_fields[$fieldname] = str_replace("<br />", "<br>", $col_fields[$fieldname]); } $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 20 || $uitype == 21 || $uitype == 22 || $uitype == 24) { // Armando LC<scher 11.08.2005 -> B'descriptionSpan -> Desc: removed $uitype == 19 and made an aditional elseif above if ($uitype == 20) { //Fix the issue #4680 $col_fields[$fieldname] = $col_fields[$fieldname]; } else { $col_fields[$fieldname] = nl2br($col_fields[$fieldname]); } $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) { $account_id = $col_fields[$fieldname]; if ($account_id != '') { $account_name = getAccountName($account_id); } $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $account_name; $label_fld["secid"] = $account_id; $label_fld["link"] = "index.php?module=Accounts&action=DetailView&record=" . $account_id; //Account Name View } elseif ($uitype == 52 || $uitype == 77 || $uitype == 101) { $label_fld[] = getTranslatedString($fieldlabel, $module); $user_id = $col_fields[$fieldname]; $user_name = getOwnerName($user_id); if ($user_id != '') { $assigned_user_id = $user_id; } else { $assigned_user_id = $current_user->id; } if (is_admin($current_user)) { $label_fld[] = '<a href="index.php?module=Users&action=DetailView&record=' . $user_id . '">' . $user_name . '</a>'; } else { $label_fld[] = $user_name; } if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $user_id), $assigned_user_id); } $label_fld["options"] = $users_combo; } elseif ($uitype == 11) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 53) { global $noof_group_rows, $adb; $owner_id = $col_fields[$fieldname]; $user = '******'; $result = $adb->pquery("SELECT count(*) as count from vtiger_users where id = ?", array($owner_id)); if ($adb->query_result($result, 0, 'count') > 0) { $user = '******'; } $owner_name = getOwnerName($owner_id); $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $owner_name; if (is_admin($current_user)) { $label_fld["secid"][] = $owner_id; if ($user == 'no') { $label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=" . $owner_id; } else { $label_fld["link"][] = "index.php?module=Users&action=DetailView&record=" . $owner_id; } //$label_fld["secid"][] = $groupid; //$label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=".$groupid; } //Security Checks if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) { $result = get_current_user_access_groups($module_name); } else { $result = get_group_options(); } if ($result) { $nameArray = $adb->fetch_array($result); } global $current_user; //$value = $user_id; if ($owner_id != '') { if ($user == 'yes') { $label_fld["options"][] = 'User'; $assigned_user_id = $owner_id; $user_checked = "checked"; $team_checked = ''; $user_style = 'display:block'; $team_style = 'display:none'; } else { //$record = $col_fields["record_id"]; //$module = $col_fields["record_module"]; $label_fld["options"][] = 'Group'; $assigned_group_id = $owner_id; $user_checked = ''; $team_checked = 'checked'; $user_style = 'display:none'; $team_style = 'display:block'; } } else { $label_fld["options"][] = 'User'; $assigned_user_id = $current_user->id; $user_checked = "checked"; $team_checked = ''; $user_style = 'display:block'; $team_style = 'display:none'; } if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id, 'private'), $assigned_user_id); } else { $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id), $assigned_user_id); } if ($noof_group_rows != 0) { if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id, 'private'), $current_user->id); } else { $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id), $current_user->id); } } $label_fld["options"][] = $users_combo; $label_fld["options"][] = $groups_combo; } elseif ($uitype == 55 || $uitype == 255) { if ($tabid == 4) { $query = "select vtiger_contactdetails.imagename from vtiger_contactdetails where contactid=?"; $result = $adb->pquery($query, array($col_fields['record_id'])); $imagename = $adb->query_result($result, 0, 'imagename'); if ($imagename != '') { $imgpath = "test/contact/" . $imagename; $label_fld[] = getTranslatedString($fieldlabel, $module); } else { $label_fld[] = getTranslatedString($fieldlabel, $module); } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); } $value = $col_fields[$fieldname]; if ($uitype == 255) { global $currentModule; $fieldpermission = getFieldVisibilityPermission($currentModule, $current_user->id, 'firstname'); } if ($uitype == 255 && $fieldpermission == 0 && $fieldpermission != '') { $fieldvalue[] = ''; } else { $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = implode("','", $subrole); $roleids = $roleids . "','" . $roleid; } else { $roleids = $roleid; } if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { $pick_query = "select salutationtype from vtiger_salutationtype order by salutationtype"; $params = array(); } else { $pick_query = "select * from vtiger_salutationtype left join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid=vtiger_salutationtype.picklist_valueid where picklistid in (select picklistid from vtiger_picklist where name='salutationtype') and roleid=? order by salutationtype"; $params = array($current_user->roleid); } $pickListResult = $adb->pquery($pick_query, $params); $noofpickrows = $adb->num_rows($pickListResult); $sal_value = $col_fields["salutationtype"]; $salcount = 0; for ($j = 0; $j < $noofpickrows; $j++) { $pickListValue = $adb->query_result($pickListResult, $j, "salutationtype"); if ($sal_value == $pickListValue) { $chk_val = "selected"; $salcount++; } else { $chk_val = ''; } } if ($salcount == 0 && $sal_value != '') { $notacc = $app_strings['LBL_NOT_ACCESSIBLE']; } $sal_value = $col_fields["salutationtype"]; if ($sal_value == '--None--') { $sal_value = ''; } $label_fld["salut"] = getTranslatedString($sal_value); $label_fld["notaccess"] = $notacc; } $label_fld[] = $value; } elseif ($uitype == 56) { $label_fld[] = getTranslatedString($fieldlabel, $module); $value = $col_fields[$fieldname]; if ($value == 1) { //Since "yes" is not been translated it is given as app strings here.. $displayValue = $app_strings['yes']; } else { $displayValue = $app_strings['no']; } $label_fld[] = $displayValue; } elseif ($uitype == 156) { $label_fld[] = getTranslatedString($fieldlabel, $module); $value = $col_fields[$fieldname]; if ($value == 'on') { //Since "yes" is not been translated it is given as app strings here.. $displayValue = $app_strings['yes']; } else { $displayValue = $app_strings['no']; } $label_fld[] = $displayValue; } elseif ($uitype == 57) { $label_fld[] = getTranslatedString($fieldlabel, $module); $contact_id = $col_fields[$fieldname]; if ($contact_id != '') { $displayValueArray = getEntityName('Contacts', $contact_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } } $label_fld[] = $contact_name; $label_fld["secid"] = $contact_id; $label_fld["link"] = "index.php?module=Contacts&action=DetailView&record=" . $contact_id; } elseif ($uitype == 58) { $label_fld[] = getTranslatedString($fieldlabel, $module); $campaign_id = $col_fields[$fieldname]; if ($campaign_id != '') { $campaign_name = getCampaignName($campaign_id); } $label_fld[] = $campaign_name; $label_fld["secid"] = $campaign_id; $label_fld["link"] = "index.php?module=Campaigns&action=DetailView&record=" . $campaign_id; } elseif ($uitype == 59) { $label_fld[] = getTranslatedString($fieldlabel, $module); $product_id = $col_fields[$fieldname]; if ($product_id != '') { $product_name = getProductName($product_id); } //Account Name View $label_fld[] = $product_name; $label_fld["secid"] = $product_id; $label_fld["link"] = "index.php?module=Products&action=DetailView&record=" . $product_id; } elseif ($uitype == 61) { global $adb; $label_fld[] = getTranslatedString($fieldlabel, $module); if ($tabid == 10) { $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])); for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) { $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid'); if ($attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); if ($attachmentsname != '') { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '">' . $attachmentsname . '</a>'; } else { $custfldval = ''; } } $label_fld['options'][] = $custfldval; } } else { $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } //This is added to strip the crmid and _ from the file name and show the original filename //$org_filename = ltrim($col_fields[$fieldname],$col_fields['record_id'].'_'); /* Above line is not required as the filename in the database is stored as it is and doesn't have crmid attached to it. This was the cause for the issue reported in ticket #4645 */ $org_filename = $col_fields[$fieldname]; // For Backward Compatibility version < 5.0.4 $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_'); if ($filename_pos === 0) { $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_'); $org_filename = substr($org_filename, $start_idx); } if ($org_filename != '') { if ($col_fields['filelocationtype'] == 'E') { if ($col_fields['filestatus'] == 1) { //&& strlen($col_fields['filename']) > 7 ){ $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } elseif ($col_fields['filelocationtype'] == 'I') { if ($col_fields['filestatus'] == 1) { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } else { $custfldval = ''; } } $label_fld[] = $custfldval; } } elseif ($uitype == 28) { $label_fld[] = getTranslatedString($fieldlabel, $module); $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from vtiger_attachments where attachmentsid=?"; $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name'); } $org_filename = $col_fields[$fieldname]; // For Backward Compatibility version < 5.0.4 $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_'); if ($filename_pos === 0) { $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_'); $org_filename = substr($org_filename, $start_idx); } if ($org_filename != '') { if ($col_fields['filelocationtype'] == 'E') { if ($col_fields['filestatus'] == 1) { //&& strlen($col_fields['filename']) > 7 ){ $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } elseif ($col_fields['filelocationtype'] == 'I') { if ($col_fields['filestatus'] == 1) { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>'; } else { $custfldval = $col_fields[$fieldname]; } } else { $custfldval = ''; } } $label_fld[] = $custfldval; } elseif ($uitype == 69) { $label_fld[] = getTranslatedString($fieldlabel, $module); if ($tabid == 14) { $images = array(); $query = 'select productname, vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?'; $result_image = $adb->pquery($query, array($col_fields['record_id'])); for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) { $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid'); //decode_html - added to handle UTF-8 characters in file names //urlencode - added to handle special characters like #, %, etc., $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name'))); $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name')); $imagepath_array[] = $adb->query_result($result_image, $image_iter, 'path'); } if (count($image_array) > 1) { if (count($image_array) < 4) { $sides = count($image_array) * 2; } else { $sides = 8; } $image_lists = '<div id="Carousel" style="position:relative;vertical-align: middle;"> <img src="modules/Products/placeholder.gif" width="571" height="117" style="position:relative;"> </div><script>var Car_NoOfSides=' . $sides . '; Car_Image_Sources=new Array('; for ($image_iter = 0; $image_iter < count($image_array); $image_iter++) { $images[] = '"' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '","' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '"'; } $image_lists .= implode(',', $images) . ');</script><script language="JavaScript" type="text/javascript" src="modules/Products/Productsslide.js"></script><script language="JavaScript" type="text/javascript">Carousel();</script>'; $label_fld[] = $image_lists; } elseif (count($image_array) == 1) { list($pro_image_width, $pro_image_height) = getimagesize($imagepath_array[0] . $image_id_array[0] . "_" . $image_orgname_array[0]); if ($pro_image_width > 450 || $pro_image_height > 300) { $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="450" height="300">'; } else { $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="' . $pro_image_width . '" height="' . $pro_image_height . '">'; } } else { $label_fld[] = ''; } } else { if ($module == 'Contacts') { $imageattachment = 'Image'; } else { $imageattachment = 'Attachment'; } //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname]; $sql = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t from vtiger_attachments\n\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid\n\t\t\t where vtiger_crmentity.setype='{$module} {$imageattachment}'\n\t\t\t and vtiger_attachments.name = ?\n\t\t\t and vtiger_seattachmentsrel.crmid=?"; $image_res = $adb->pquery($sql, array($col_fields[$fieldname], $col_fields['record_id'])); $image_id = $adb->query_result($image_res, 0, 'attachmentsid'); $image_path = $adb->query_result($image_res, 0, 'path'); //decode_html - added to handle UTF-8 characters in file names //urlencode - added to handle special characters like #, %, etc., $image_name = urlencode(decode_html($adb->query_result($image_res, 0, 'name'))); $imgpath = $image_path . $image_id . "_" . $image_name; if ($image_name != '') { $ftype = $adb->query_result($image_res, 0, 'type'); $isimage = stripos($ftype, 'image') !== false; if ($isimage) { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('Image'); $label_fld[] = '<img src="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '" style="max-width: 500px;">'; } else { $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('SINGLE_Documents'); $label_fld[] = '<a href="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '">' . $image_name . '</a>'; } } else { $label_fld[] = ''; } } } elseif ($uitype == 62) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $account_name = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>'; } elseif ($parent_module == "Potentials") { $label_fld[] = $app_strings['LBL_POTENTIAL_NAME']; $sql = "select * from vtiger_potential where potentialid=?"; $result = $adb->pquery($sql, array($value)); $potentialname = $adb->query_result($result, 0, "potentialname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>'; } elseif ($parent_module == "Products") { $label_fld[] = $app_strings['LBL_PRODUCT_NAME']; $sql = "select * from vtiger_products where productid=?"; $result = $adb->pquery($sql, array($value)); $productname = $adb->query_result($result, 0, "productname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $productname . '</a>'; } elseif ($parent_module == "PurchaseOrder") { $label_fld[] = $app_strings['LBL_PORDER_NAME']; $sql = "select * from vtiger_purchaseorder where purchaseorderid=?"; $result = $adb->pquery($sql, array($value)); $pordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>'; } elseif ($parent_module == "SalesOrder") { $label_fld[] = $app_strings['LBL_SORDER_NAME']; $sql = "select * from vtiger_salesorder where salesorderid=?"; $result = $adb->pquery($sql, array($value)); $sordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>'; } elseif ($parent_module == "Invoice") { $label_fld[] = $app_strings['LBL_INVOICE_NAME']; $sql = "select * from vtiger_invoice where invoiceid=?"; $result = $adb->pquery($sql, array($value)); $invoicename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>'; } elseif ($parent_module == "Quotes") { $label_fld[] = $app_strings['LBL_QUOTES_NAME']; $sql = "select * from vtiger_quotes where quoteid=?"; $result = $adb->pquery($sql, array($value)); $quotename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>'; } elseif ($parent_module == "HelpDesk") { $label_fld[] = $app_strings['LBL_HELPDESK_NAME']; $sql = "select * from vtiger_troubletickets where ticketid=?"; $result = $adb->pquery($sql, array($value)); $title = $adb->query_result($result, 0, "title"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $title . '</a>'; } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 105) { //Added for user image $label_fld[] = getTranslatedString($fieldlabel, $module); //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname]; $sql = "select vtiger_attachments.* from vtiger_attachments left join vtiger_salesmanattachmentsrel on vtiger_salesmanattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid where vtiger_salesmanattachmentsrel.smid=?"; $image_res = $adb->pquery($sql, array($col_fields['record_id'])); $image_id = $adb->query_result($image_res, 0, 'attachmentsid'); $image_path = $adb->query_result($image_res, 0, 'path'); $image_name = $adb->query_result($image_res, 0, 'name'); $imgpath = $image_path . $image_id . "_" . $image_name; if ($image_name != '') { //Added the following check for the image to retain its in original size. list($pro_image_width, $pro_image_height) = getimagesize(decode_html($imgpath)); $label_fld[] = '<a href="' . $imgpath . '" target="_blank"><img src="' . $imgpath . '" width="' . $pro_image_width . '" height="' . $pro_image_height . '" alt="' . $col_fields['user_name'] . '" title="' . $col_fields['user_name'] . '" border="0"></a>'; } else { $label_fld[] = ''; } } elseif ($uitype == 66) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $account_name = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>'; } elseif ($parent_module == "Potentials") { $label_fld[] = $app_strings['LBL_POTENTIAL_NAME']; $sql = "select * from vtiger_potential where potentialid=?"; $result = $adb->pquery($sql, array($value)); $potentialname = $adb->query_result($result, 0, "potentialname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>'; } elseif ($parent_module == "Quotes") { $label_fld[] = $app_strings['LBL_QUOTE_NAME']; $sql = "select * from vtiger_quotes where quoteid=?"; $result = $adb->pquery($sql, array($value)); $quotename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>'; } elseif ($parent_module == "PurchaseOrder") { $label_fld[] = $app_strings['LBL_PORDER_NAME']; $sql = "select * from vtiger_purchaseorder where purchaseorderid=?"; $result = $adb->pquery($sql, array($value)); $pordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>'; } elseif ($parent_module == "SalesOrder") { $label_fld[] = $app_strings['LBL_SORDER_NAME']; $sql = "select * from vtiger_salesorder where salesorderid=?"; $result = $adb->pquery($sql, array($value)); $sordername = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>'; } elseif ($parent_module == "Invoice") { $label_fld[] = $app_strings['LBL_INVOICE_NAME']; $sql = "select * from vtiger_invoice where invoiceid=?"; $result = $adb->pquery($sql, array($value)); $invoicename = $adb->query_result($result, 0, "subject"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>'; } elseif ($parent_module == "Campaigns") { $label_fld[] = $app_strings['LBL_CAMPAIGN_NAME']; $sql = "select * from vtiger_campaign where campaignid=?"; $result = $adb->pquery($sql, array($value)); $campaignname = $adb->query_result($result, 0, "campaignname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $campaignname . '</a>'; } elseif ($parent_module == "HelpDesk") { $label_fld[] = $app_strings['LBL_HELPDESK_NAME']; $sql = "select * from vtiger_troubletickets where ticketid=?"; $result = $adb->pquery($sql, array($value)); $tickettitle = $adb->query_result($result, 0, "title"); if (strlen($tickettitle) > 25) { $tickettitle = substr($tickettitle, 0, 25) . '...'; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $tickettitle . '</a>'; } elseif ($parent_module == "Vendors") { //MSL $label_fld[] = $app_strings['LBL_VENDOR_NAME']; $sql = "select vendorname from vtiger_vendor where vendorid=?"; $result = $adb->pquery($sql, array($value)); $vendor_name = $adb->query_result($result, 0, "vendorname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $vendor_name . '</a>'; } //MSL ------------------------------------------- } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 67) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Contacts") { $label_fld[] = $app_strings['LBL_CONTACT_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>'; } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 357) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_name = ''; $parent_id = ''; $myemailid = $_REQUEST['record']; $mysql = "select crmid from vtiger_seactivityrel where activityid=?"; $myresult = $adb->pquery($mysql, array($myemailid)); $mycount = $adb->num_rows($myresult); if ($mycount > 1) { $label_fld[] = $app_strings['LBL_RELATED_TO']; $label_fld[] = $app_strings['LBL_MULTIPLE']; } else { $parent_module = getSalesEntityType($value); if ($parent_module == "Leads") { $label_fld[] = $app_strings['LBL_LEAD_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $lead_name = $field_value; } } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>'; } elseif ($parent_module == "Contacts") { $label_fld[] = $app_strings['LBL_CONTACT_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $accountname = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $accountname . '</a>'; } } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 68) { $value = $col_fields[$fieldname]; if ($value != '') { $parent_module = getSalesEntityType($value); if ($parent_module == "Contacts") { $label_fld[] = $app_strings['LBL_CONTACT_NAME']; $displayValueArray = getEntityName($parent_module, $value); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $field_value) { $contact_name = $field_value; } } else { $contact_name = ''; } $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>'; } elseif ($parent_module == "Accounts") { $label_fld[] = $app_strings['LBL_ACCOUNT_NAME']; $sql = "select * from vtiger_account where accountid=?"; $result = $adb->pquery($sql, array($value)); $account_name = $adb->query_result($result, 0, "accountname"); $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>'; } else { $value = ''; $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $value; } } elseif ($uitype == 63) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname] . 'h ' . $col_fields['duration_minutes'] . 'm'; } elseif ($uitype == 6) { $label_fld[] = getTranslatedString($fieldlabel, $module); if ($col_fields[$fieldname] == '0') { $col_fields[$fieldname] = ''; } if ($col_fields['time_start'] != '') { $start_time = $col_fields['time_start']; } $dateValue = $col_fields[$fieldname]; if ($col_fields[$fieldname] == '0000-00-00' || empty($dateValue)) { $displayValue = ''; } else { if (empty($start_time) && strpos($col_fields[$fieldname], ' ') == false) { $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]); } else { if (!empty($start_time)) { $date = new DateTimeField($col_fields[$fieldname] . ' ' . $start_time); } else { $date = new DateTimeField($col_fields[$fieldname]); } $displayValue = $date->getDisplayDateTimeValue(); } } $label_fld[] = $displayValue; } elseif ($uitype == 5 || $uitype == 23 || $uitype == 70) { $label_fld[] = getTranslatedString($fieldlabel, $module); $dateValue = $col_fields[$fieldname]; if ($col_fields['time_end'] != '' && ($tabid == 9 || $tabid == 16) && $uitype == 23) { $end_time = $col_fields['time_end']; } if ($dateValue == '0000-00-00' || empty($dateValue)) { $displayValue = ''; } else { if (empty($end_time) && strpos($dateValue, ' ') == false) { $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]); } else { if (!empty($end_time)) { $date = new DateTimeField($col_fields[$fieldname] . ' ' . $end_time); } else { $date = new DateTimeField($col_fields[$fieldname]); } $displayValue = $date->getDisplayDateTimeValue(); } } $label_fld[] = $displayValue; } elseif ($uitype == 71 || $uitype == 72) { $label_fld[] = getTranslatedString($fieldlabel, $module); $currencyField = new CurrencyField($col_fields[$fieldname]); if ($uitype == 72) { // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion if ($fieldname == 'unit_price') { $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module)); $label_fld[] = $currencyField->getDisplayValue(null, true); $label_fld["cursymb"] = $rate_symbol['symbol']; } else { $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']); $label_fld[] = $currencyField->getDisplayValue(null, true); $label_fld["cursymb"] = $currency_info['currency_symbol']; } } else { $label_fld[] = $currencyField->getDisplayValue(); $label_fld["cursymb"] = $currencyField->getCurrencySymbol(); } } elseif ($uitype == 75 || $uitype == 81) { $label_fld[] = getTranslatedString($fieldlabel, $module); $vendor_id = $col_fields[$fieldname]; if ($vendor_id != '') { $vendor_name = getVendorName($vendor_id); } $label_fld[] = $vendor_name; $label_fld["secid"] = $vendor_id; $label_fld["link"] = "index.php?module=Vendors&action=DetailView&record=" . $vendor_id; } elseif ($uitype == 76) { $label_fld[] = getTranslatedString($fieldlabel, $module); $potential_id = $col_fields[$fieldname]; if ($potential_id != '') { $potential_name = getPotentialName($potential_id); } $label_fld[] = $potential_name; $label_fld["secid"] = $potential_id; $label_fld["link"] = "index.php?module=Potentials&action=DetailView&record=" . $potential_id; } elseif ($uitype == 78) { $label_fld[] = getTranslatedString($fieldlabel, $module); $quote_id = $col_fields[$fieldname]; if ($quote_id != '') { $quote_name = getQuoteName($quote_id); } $label_fld[] = $quote_name; $label_fld["secid"] = $quote_id; $label_fld["link"] = "index.php?module=Quotes&action=DetailView&record=" . $quote_id; } elseif ($uitype == 79) { $label_fld[] = getTranslatedString($fieldlabel, $module); $purchaseorder_id = $col_fields[$fieldname]; if ($purchaseorder_id != '') { $purchaseorder_name = getPoName($purchaseorder_id); } $label_fld[] = $purchaseorder_name; $label_fld["secid"] = $purchaseorder_id; $label_fld["link"] = "index.php?module=PurchaseOrder&action=DetailView&record=" . $purchaseorder_id; } elseif ($uitype == 80) { $label_fld[] = getTranslatedString($fieldlabel, $module); $salesorder_id = $col_fields[$fieldname]; if ($salesorder_id != '') { $salesorder_name = getSoName($salesorder_id); } $label_fld[] = $salesorder_name; $label_fld["secid"] = $salesorder_id; $label_fld["link"] = "index.php?module=SalesOrder&action=DetailView&record=" . $salesorder_id; } elseif ($uitype == 30) { $rem_days = 0; $rem_hrs = 0; $rem_min = 0; $reminder_str = ""; $rem_days = floor($col_fields[$fieldname] / (24 * 60)); $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60); $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60; $label_fld[] = getTranslatedString($fieldlabel, $module); if ($col_fields[$fieldname]) { $reminder_str = $rem_days . ' ' . $mod_strings['LBL_DAYS'] . ' ' . $rem_hrs . ' ' . $mod_strings['LBL_HOURS'] . ' ' . $rem_min . ' ' . $mod_strings['LBL_MINUTES'] . ' ' . $mod_strings['LBL_BEFORE_EVENT']; } $label_fld[] = ' ' . $reminder_str; } elseif ($uitype == 98) { $label_fld[] = getTranslatedString($fieldlabel, $module); if (is_admin($current_user)) { $label_fld[] = '<a href="index.php?module=Settings&action=RoleDetailView&roleid=' . $col_fields[$fieldname] . '">' . getRoleName($col_fields[$fieldname]) . '</a>'; } else { $label_fld[] = getRoleName($col_fields[$fieldname]); } } elseif ($uitype == 85) { //Added for Skype by Minnie $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 26) { $label_fld[] = getTranslatedString($fieldlabel, $module); $query = "select foldername from vtiger_attachmentsfolder where folderid = ?"; $result = $adb->pquery($query, array($col_fields[$fieldname])); $folder_name = $adb->query_result($result, 0, "foldername"); $label_fld[] = $folder_name; } elseif ($uitype == 27) { if ($col_fields[$fieldname] == 'I') { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $mod_strings['LBL_INTERNAL']; } else { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $mod_strings['LBL_EXTERNAL']; } } elseif ($uitype == 31) { $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = $col_fields[$fieldname]; $options = array(); $themeList = get_themes(); foreach ($themeList as $theme) { if ($current_user->theme == $theme) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($theme), $theme, $selected); } $label_fld["options"] = $options; } elseif ($uitype == 32) { $options = array(); $languageList = Vtiger_Language::getAll(); $label_fld[] = getTranslatedString($fieldlabel, $module); $label_fld[] = isset($languageList[$col_fields[$fieldname]]) ? $languageList[$col_fields[$fieldname]] : $col_fields[$fieldname]; foreach ($languageList as $prefix => $label) { if ($current_user->language == $prefix) { $selected = 'selected'; } else { $selected = ''; } $options[] = array(getTranslatedString($label), $prefix, $selected); } $label_fld["options"] = $options; } else { $label_fld[] = getTranslatedString($fieldlabel, $module); if ($col_fields[$fieldname] == '0' && $fieldname != 'filedownloadcount' && $fieldname != 'filestatus' && $fieldname != 'filesize') { $col_fields[$fieldname] = ''; } //code for Documents module :start if ($tabid == 8) { $downloadtype = $col_fields['filelocationtype']; if ($fieldname == 'filename') { if ($downloadtype == 'I') { //$file_value = $mod_strings['LBL_INTERNAL']; $fld_value = $col_fields['filename']; $ext_pos = strrpos($fld_value, "."); $ext = substr($fld_value, $ext_pos + 1); $ext = strtolower($ext); if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') { $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') { $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') { $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') { $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>"; } else { $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>"; } } else { $fld_value = $col_fields['filename']; $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' title='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' hspace='3' align='absmiddle' border='0'>"; } $label_fld[] = $fileicon . $fld_value; } if ($fieldname == 'filesize') { if ($col_fields['filelocationtype'] == 'I') { $filesize = $col_fields[$fieldname]; if ($filesize < 1024) { $label_fld[] = $filesize . ' B'; } elseif ($filesize > 1024 && $filesize < 1048576) { $label_fld[] = round($filesize / 1024, 2) . ' KB'; } else { if ($filesize > 1048576) { $label_fld[] = round($filesize / (1024 * 1024), 2) . ' MB'; } } } else { $label_fld[] = ' --'; } } if ($fieldname == 'filetype' && $col_fields['filelocationtype'] == 'E') { $label_fld[] = ' --'; } /* if($fieldname == 'filestatus') { $filestatus = $col_fields[$fieldname]; if($filestatus == 0) $label_fld[]=$mod_strings['LBL_ACTIVE']; else $label_fld[]=$mod_strings['LBL_INACTIVE']; } */ } //code for Documents module :end $label_fld[] = $col_fields[$fieldname]; } } $label_fld[] = $uitype; //sets whether the currenct user is admin or not if (is_admin($current_user)) { $label_fld["isadmin"] = 1; } else { $label_fld["isadmin"] = 0; } $log->debug("Exiting getDetailViewOutputHtml method ..."); return $label_fld; }