function __construct($fieldname = '') { InventoryLineField::$ILFieldsLabel = array('item name' => InventoryLineField::$ILFieldsName['productid'], 'quantity' => InventoryLineField::$ILFieldsName['quantity'], 'list price' => InventoryLineField::$ILFieldsName['listprice'], 'item comment' => InventoryLineField::$ILFieldsName['comment'], 'item discount amount' => InventoryLineField::$ILFieldsName['discount_amount'], 'item discount percent' => InventoryLineField::$ILFieldsName['discount_percent']); $taxes = getAllTaxes('all'); foreach ($taxes as $key => $tax) { $fieldlabel = strtolower($tax['taxlabel']); InventoryLineField::$ILFieldsLabel[$fieldlabel] = array('uitype' => 7, 'fieldtype' => 'double', 'fieldname' => $tax['taxname'], 'columnname' => $tax['taxname'], 'fieldlabel' => $tax['taxlabel'], 'tablename' => 'vtiger_inventoryproductrel', 'typeofdata' => 'N~O', 'mandatory' => 'false'); InventoryLineField::$ILFieldsName[$tax['taxname']] = InventoryLineField::$ILFieldsLabel[$fieldlabel]; } $this->fieldname = $fieldname; }
/** * this function takes in a module name and returns the field information for it */ function getInformationArray($module) { require_once 'include/utils/utils.php'; global $adb; $tabid = getTabid($module); $result = $adb->pquery("select * from vtiger_field where tabid=?", array($tabid)); $count = $adb->num_rows($result); $arr = array(); $data = array(); for ($i = 0; $i < $count; $i++) { $arr['uitype'] = $adb->query_result($result, $i, "uitype"); $arr['fieldname'] = $adb->query_result($result, $i, "fieldname"); $arr['columnname'] = $adb->query_result($result, $i, "columnname"); $arr['tablename'] = $adb->query_result($result, $i, "tablename"); $arr['fieldlabel'] = $adb->query_result($result, $i, "fieldlabel"); $arr['typeofdata'] = $adb->query_result($result, $i, "typeofdata"); $fieldlabel = strtolower($arr['fieldlabel']); $data[$fieldlabel] = $arr; } if (in_array($module, getInventoryModules())) { include_once 'include/fields/InventoryLineField.php'; $ilfields = new InventoryLineField(); $data = array_merge($data, $ilfields->getInventoryLineFieldsByLabel()); } return $data; }
function getInventoryFieldsForExport($tableName) { $sql = ',' . $tableName . '.adjustment AS "Adjustment", ' . $tableName . '.total AS "Total", ' . $tableName . '.subtotal AS "Sub Total", '; $sql .= $tableName . '.taxtype AS "Tax Type", ' . $tableName . '.discount_amount AS "Discount Amount", '; $sql .= $tableName . '.discount_percent AS "Discount Percent", ' . $tableName . '.s_h_amount AS "S&H Amount", '; $sql .= 'vtiger_currency_info.currency_name as "Currency",'; include_once 'include/fields/InventoryLineField.php'; $ilfields = new InventoryLineField(); $inventory_fields = $ilfields->getInventoryLineFieldsByLabel(); foreach ($inventory_fields as $fdesc) { $sql .= $fdesc['tablename'] . '.' . $fdesc['columnname'] . ' AS "' . $fdesc['fieldlabel'] . '",'; } $sql = rtrim($sql, ',') . ' '; return $sql; }
function GenerateReport($outputformat, $filtersql, $directOutput = false, &$returnfieldinfo = array()) { global $adb, $current_user, $php_max_execution_time; global $modules, $app_strings, $mod_strings, $current_language; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $picklistarray = array(); $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); $noofrows = $adb->num_rows($result); $this->number_of_rows = $noofrows; $custom_field_values = $adb->fetch_array($result); $groupslist = $this->getGroupingList($this->reportid); $column_definitions = $adb->getFieldsDefinition($result); $arrayHeaders = array(); $header = ''; for ($x = 0; $x < $y; $x++) { $fld = $adb->field_name($result, $x); $fld_type = $column_definitions[$x]->type; list($module, $fieldLabel) = explode('_', $fld->name, 2); $fieldInfo = getFieldByReportLabel($module, $fieldLabel); if (!empty($fieldInfo)) { $field = WebserviceField::fromArray($adb, $fieldInfo); } if (!empty($fieldInfo)) { $headerLabel = getTranslatedString($field->getFieldLabelKey(), $module); } else { $headerLabel = getTranslatedString(str_replace('_', " ", $fieldLabel), $module); } /*STRING TRANSLATION starts */ $moduleLabel = ''; if (in_array($module, $modules_selected)) { $moduleLabel = getTranslatedString($module, $module); } if (empty($headerLabel)) { $headerLabel = getTranslatedString(str_replace('_', " ", $fld->name)); } if (!empty($this->secondarymodule)) { if ($moduleLabel != '') { $headerLabel = $moduleLabel . " " . $headerLabel; } } $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>'; } $valtemplate = ''; $lastvalue = ''; $secondvalue = ''; $thirdvalue = ''; $sHTML = ''; do { $arraylists = array(); $newvalue = ''; $snewvalue = ''; $tnewvalue = ''; 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 = ''; } 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 ($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 = ''; } } $valtemplate .= "</tr>"; // Performance Optimization: If direct output is required if ($directOutput) { echo $valtemplate; $valtemplate = ''; } $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(document.getElementById('_reportrun_total')) document.getElementById('_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->pquery($sSQL, array()); 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); $this->number_of_rows = $noofrows; $custom_field_values = $adb->fetch_array($result); $column_definitions = $adb->getFieldsDefinition($result); $ILF = new InventoryLineField(); $invMods = getInventoryModules(); do { $arraylists = array(); for ($i = 0; $i < $y - 1; $i++) { $fld = $adb->field_name($result, $i); $fld_type = $column_definitions[$i]->type; list($module, $fieldLabel) = explode('_', $fld->name, 2); $fieldInfo = getFieldByReportLabel($module, $fieldLabel); if (!empty($fieldInfo)) { $field = WebserviceField::fromArray($adb, $fieldInfo); } else { if (in_array($module, $invMods)) { if (substr($fld->table, 0, 26) == 'vtiger_inventoryproductrel') { foreach ($ILF->getInventoryLineFieldsByName() as $ilfname => $ilfinfo) { $ilflabel = getTranslatedString($ilfinfo['fieldlabel'], $module); if ($ilflabel == $fieldLabel) { $fieldInfo = $ilfinfo; $fieldInfo['tabid'] = getTabid($module); $fieldInfo['presence'] = 1; $field = WebserviceField::fromArray($adb, $fieldInfo); break; } } } else { if (substr($fld->table, 0, 15) == 'vtiger_products' or substr($fld->table, 0, 14) == 'vtiger_service') { foreach ($ILF->getInventoryLineProductServiceNameFields() as $ilfname => $ilfinfo) { $ilflabel = getTranslatedString($ilfinfo['fieldlabel'], $module); if ($ilflabel == $fieldLabel) { $fieldInfo = $ilfinfo; $fieldInfo['tabid'] = getTabid($ilfinfo['module']); $fieldInfo['presence'] = 1; $field = WebserviceField::fromArray($adb, $fieldInfo); break; } } } } } } if (!empty($fieldInfo)) { $headerLabel = getTranslatedString($field->getFieldLabelKey(), $module); } else { $headerLabel = getTranslatedString(str_replace('_', " ", $fieldLabel), $module); } /*STRING TRANSLATION starts */ $moduleLabel = ''; if (in_array($module, $modules_selected)) { $moduleLabel = getTranslatedString($module, $module); } if (empty($headerLabel)) { $headerLabel = getTranslatedString(str_replace('_', " ", $fld->name)); } if (!empty($this->secondarymodule)) { if ($moduleLabel != '') { $headerLabel = $moduleLabel . " " . $headerLabel; } } $fieldvalue = getReportFieldValue($this, $picklistarray, $fld, $custom_field_values, $i); if (empty($returnfieldinfo[$headerLabel])) { $returnfieldinfo[$headerLabel] = $field; } $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) and count($this->totallist) > 0) { 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 = decode_html(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"); $coltotalhtml = ''; if (isset($this->totallist) and count($this->totallist) > 0) { 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 = ''; } 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 = decode_html(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 = ''; } } $coltotalhtml .= "</table>"; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } } } 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) { $noofrows = $adb->num_rows($result); $this->number_of_rows = $noofrows; $custom_field_values = $adb->fetch_array($result); $groupslist = $this->getGroupingList($this->reportid); $column_definitions = $adb->getFieldsDefinition($result); $y = $adb->num_fields($result); $arrayHeaders = array(); $header = ''; for ($x = 0; $x < $y - 1; $x++) { $fld = $adb->field_name($result, $x); $fld_type = $column_definitions[$x]->type; list($module, $fieldLabel) = explode('_', $fld->name, 2); $fieldInfo = getFieldByReportLabel($module, $fieldLabel); if (!empty($fieldInfo)) { $field = WebserviceField::fromArray($adb, $fieldInfo); } if (!empty($fieldInfo)) { $headerLabel = getTranslatedString($field->getFieldLabelKey(), $module); } else { $headerLabel = getTranslatedString(str_replace('_', " ", $fieldLabel), $module); } /*STRING TRANSLATION starts */ $moduleLabel = ''; if (in_array($module, $modules_selected)) { $moduleLabel = getTranslatedString($module, $module); } if (empty($headerLabel)) { $headerLabel = getTranslatedString(str_replace('_', " ", $fld->name)); } if (!empty($this->secondarymodule)) { if ($moduleLabel != '') { $headerLabel = $moduleLabel . " " . $headerLabel; } } $header .= "<th>" . $headerLabel . "</th>"; } $valtemplate = ''; $lastvalue = ''; $secondvalue = ''; $thirdvalue = ''; do { $arraylists = array(); $newvalue = ''; $snewvalue = ''; $tnewvalue = ''; 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 - 1; $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"); $coltotalhtml = ''; if (isset($this->totallist) and count($this->totallist) > 0) { 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 = ''; } 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 = decode_html(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 = ''; } } $coltotalhtml .= "</table>"; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } } } return $coltotalhtml; } }
public function getImportableFields($moduleName) { $focus = CRMEntity::getInstance($moduleName); if (method_exists($focus, 'getImportableFields')) { $importableFields = $focus->getImportableFields(); } else { // if we are merging, then selected merge fields must be in selectable fields, so we fill in the mergeFields $mergeFields = array(); if (isset($_REQUEST['merge_type']) and !empty($_REQUEST['merge_fields'])) { $json = vtlib_purify($_REQUEST['merge_fields']); $mergeFields = json_decode($json); } $moduleFields = $this->getAccessibleFields($moduleName); $importableFields = array(); foreach ($moduleFields as $fieldName => $fieldInstance) { if ($this->isEditableField($fieldInstance) && ($fieldInstance->getTableName() != 'vtiger_crmentity' || $fieldInstance->getColumnName() != 'modifiedby') || $fieldInstance->getUIType() == '70' && $fieldName != 'modifiedtime' || in_array($fieldName, $mergeFields)) { $importableFields[$fieldName] = $fieldInstance; } } } if (in_array($moduleName, getInventoryModules())) { include_once 'include/fields/InventoryLineField.php'; $ilfields = new InventoryLineField(); $importableFields = array_merge($importableFields, $ilfields->getInventoryLineFieldsByObject()); } return $importableFields; }