function populateCurrency() { global $mod_strings; require_once 'modules/Currencies/Currency.php'; $currency = new Currency(); $currText = ''; if (isset($this->bean->currency_id) && !empty($this->bean->currency_id)) { $currency->retrieve($this->bean->currency_id); if ($currency->deleted != 1) { $currText = $currency->iso4217 . ' ' . $currency->symbol; } else { $currText = $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol(); } } else { $currText = $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol(); } $javascript = "<script language='javascript'>\n"; $javascript .= "var CurrencyText = new Array(); \n"; $javascript .= "CurrencyText['-99'] = '" . $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol() . "';\n"; $sql = "SELECT id, iso4217, symbol FROM currencies"; $res = $this->bean->db->query($sql); while ($row = $this->bean->db->fetchByAssoc($res)) { $javascript .= "CurrencyText['" . $row['id'] . "'] = '" . $row['iso4217'] . ' ' . $row['symbol'] . "';\n"; } $javascript .= "</script>"; echo $javascript; $this->ss->assign('CURRENCY', "<div id =curr_symbol>{$currText}</div>"); $mod_strings['LBL_LIST_PRICE'] .= " (" . $currText . ")"; $mod_strings['LBL_UNIT_PRICE'] .= " (" . $currText . ")"; $mod_strings['LBL_VAT_AMT'] .= " (" . $currText . ")"; $mod_strings['LBL_TOTAL_PRICE'] .= " (" . $currText . ")"; $mod_strings['LBL_SERVICE_PRICE'] .= " (" . $currText . ")"; }
function display() { $currency = new Currency(); if (isset($this->bean->currency_id) && !empty($this->bean->currency_id)) { $currency->retrieve($this->bean->currency_id); if ($currency->deleted != 1) { $this->ss->assign('CURRENCY', $currency->iso4217 . ' ' . $currency->symbol); } else { $this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol()); } } else { $this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol()); } parent::display(); }
function display() { global $app_list_strings; $this->ss->assign('APP_LIST', $app_list_strings); if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'set_target') { require_once 'modules/Campaigns/utils.php'; //call function to create campaign logs $mess = track_campaign_prospects($this->bean); $confirm_msg = "var ajax_C_LOG_Status = new SUGAR.ajaxStatusClass(); \n window.setTimeout(\"ajax_C_LOG_Status.showStatus('" . $mess . "')\",1000); \n window.setTimeout('ajax_C_LOG_Status.hideStatus()', 1500); \n window.setTimeout(\"ajax_C_LOG_Status.showStatus('" . $mess . "')\",2000); \n window.setTimeout('ajax_C_LOG_Status.hideStatus()', 5000); "; $this->ss->assign("MSG_SCRIPT", $confirm_msg); } if ($this->bean->campaign_type == 'Email' || $this->bean->campaign_type == 'NewsLetter') { $this->ss->assign("ADD_BUTTON_STATE", "submit"); $this->ss->assign("TARGET_BUTTON_STATE", "hidden"); } else { $this->ss->assign("ADD_BUTTON_STATE", "hidden"); $this->ss->assign("DISABLE_LINK", "display:none"); $this->ss->assign("TARGET_BUTTON_STATE", "submit"); } $currency = new Currency(); if (isset($this->bean->currency_id) && !empty($this->bean->currency_id)) { $currency->retrieve($this->bean->currency_id); if ($currency->deleted != 1) { $this->ss->assign('CURRENCY', $currency->iso4217 . ' ' . $currency->symbol); } else { $this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol()); } } else { $this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol()); } parent::display(); //We want to display subset of available, panels, so we will call subpanel //object directly instead of using sugarview. $GLOBALS['focus'] = $this->bean; require_once 'include/SubPanel/SubPanelTiles.php'; $subpanel = new SubPanelTiles($this->bean, $this->module); //get available list of subpanels $alltabs = $subpanel->subpanel_definitions->get_available_tabs(); if (!empty($alltabs)) { //iterate through list, and filter out all but 3 subpanels foreach ($alltabs as $key => $name) { if ($name != 'prospectlists' && $name != 'emailmarketing' && $name != 'tracked_urls') { //exclude subpanels that are not prospectlists, emailmarketing, or tracked urls $subpanel->subpanel_definitions->exclude_tab($name); } } //only show email marketing subpanel for email/newsletter campaigns if ($this->bean->campaign_type != 'Email' && $this->bean->campaign_type != 'NewsLetter') { //exclude emailmarketing subpanel if not on an email or newsletter campaign $subpanel->subpanel_definitions->exclude_tab('emailmarketing'); // Bug #49893 - 20120120 - Captivea (ybi) - Remove trackers subpanels if not on an email/newsletter campaign (useless subpannl) $subpanel->subpanel_definitions->exclude_tab('tracked_urls'); } } //show filtered subpanel list echo $subpanel->display(); }
function populateCurrency() { global $mod_strings; require_once 'modules/Currencies/Currency.php'; $currency = new Currency(); $currText = ''; if (isset($this->bean->currency_id) && !empty($this->bean->currency_id)) { $currency->retrieve($focus->currency_id); if ($currency->deleted != 1) { $currText = $currency->iso4217 . ' ' . $currency->symbol; } else { $currText = $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol(); } } else { $currText = $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol(); } $this->ss->assign('CURRENCY', $currText); $mod_strings['LBL_LIST_PRICE'] .= " (" . $currText . ")"; $mod_strings['LBL_UNIT_PRICE'] .= " (" . $currText . ")"; $mod_strings['LBL_VAT_AMT'] .= " (" . $currText . ")"; $mod_strings['LBL_TOTAL_PRICE'] .= " (" . $currText . ")"; }
$query_click .= " AND marketing_id ='{$marketing_id}'"; } $query_click .= " GROUP BY activity_type, target_type"; $query_click .= " ORDER BY activity_type, target_type"; $result = $campaign->db->query($query_click); $xtpl->assign("OPP_COUNT", $opp_data1['opp_count']); $xtpl->assign("ACTUAL_COST", $opp_data1['actual_cost']); $xtpl->assign("PLANNED_BUDGET", $opp_data1['budget']); $xtpl->assign("EXPECTED_REVENUE", $opp_data1['expected_revenue']); $currency = new Currency(); if (isset($focus->currency_id) && !empty($focus->currency_id)) { $currency->retrieve($focus->currency_id); if ($currency->deleted != 1) { $xtpl->assign("CURRENCY", $currency->iso4217 . ' ' . $currency->symbol); } else { $xtpl->assign("CURRENCY", $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol()); } } else { $xtpl->assign("CURRENCY", $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol()); } global $current_user; if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) { $xtpl->assign("ADMIN_EDIT", "<a href='index.php?action=index&module=DynamicLayout&from_action=" . $_REQUEST['action'] . "&from_module=" . $_REQUEST['module'] . "&record=" . $_REQUEST['record'] . "'>" . SugarThemeRegistry::current()->getImage("EditLayout", "border='0' align='bottom'", null, null, '.gif', $mod_strings['LBL_EDIT_LAYOUT']) . "</a>"); } //$detailView->processListNavigation($xtpl, "CAMPAIGN", $offset, $focus->is_AuditEnabled()); // adding custom fields: //require_once('modules/DynamicFields/templates/Files/DetailView.php'); /* we need to build the dropdown of related marketing values $latest_marketing_id = ''; $selected_marketing_id = ''; if(isset($_REQUEST['mkt_id'])) $selected_marketing_id = $_REQUEST['mkt_id'];
if (!empty($datef)) { $sugar_smarty->assign("DATEFORMAT", $sugar_config['date_formats'][$datef]); } if (!empty($timef)) { $sugar_smarty->assign("TIMEFORMAT", $sugar_config['time_formats'][$timef]); } $num_grp_sep = $focus->getPreference('num_grp_sep'); $dec_sep = $focus->getPreference('dec_sep'); $sugar_smarty->assign("NUM_GRP_SEP", empty($num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $num_grp_sep); $sugar_smarty->assign("DEC_SEP", empty($dec_sep) ? $sugar_config['default_decimal_seperator'] : $dec_sep); $currency = new Currency(); if ($focus->getPreference('currency')) { $currency->retrieve($focus->getPreference('currency')); $sugar_smarty->assign("CURRENCY", $currency->iso4217 . ' ' . $currency->symbol); } else { $sugar_smarty->assign("CURRENCY", $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol()); } $sugar_smarty->assign('CURRENCY_SIG_DIGITS', $locale->getPrecedentPreference('default_currency_significant_digits', $focus)); $sugar_smarty->assign('NAME_FORMAT', $focus->getLocaleFormatDesc()); $sugar_smarty->assign("DESCRIPTION", nl2br(url2html($focus->description))); $sugar_smarty->assign("TITLE", $focus->title); $sugar_smarty->assign("DEPARTMENT", $focus->department); $sugar_smarty->assign("REPORTS_TO_ID", $focus->reports_to_id); $sugar_smarty->assign("REPORTS_TO_NAME", $focus->reports_to_name); $sugar_smarty->assign("PHONE_HOME", $focus->phone_home); $sugar_smarty->assign("PHONE_MOBILE", $focus->phone_mobile); $sugar_smarty->assign("PHONE_WORK", $focus->phone_work); $sugar_smarty->assign("PHONE_OTHER", $focus->phone_other); $sugar_smarty->assign("PHONE_FAX", $focus->phone_fax); if (!empty($focus->employee_status)) { $sugar_smarty->assign("EMPLOYEE_STATUS", $app_list_strings['employee_status_dom'][$focus->employee_status]);
protected function setupAdvancedTabLocaleSettings() { global $locale, $sugar_config, $app_list_strings; /////////////////////////////////////////////////////////////////////////////// //// LOCALE SETTINGS //// Date/time format $dformat = $locale->getPrecedentPreference($this->bean->id ? 'datef' : 'default_date_format', $this->bean); $tformat = $locale->getPrecedentPreference($this->bean->id ? 'timef' : 'default_time_format', $this->bean); $nformat = $locale->getPrecedentPreference('default_locale_name_format', $this->bean); if (!array_key_exists($nformat, $sugar_config['name_formats'])) { $nformat = $sugar_config['default_locale_name_format']; } $timeOptions = get_select_options_with_id($sugar_config['time_formats'], $tformat); $dateOptions = get_select_options_with_id($sugar_config['date_formats'], $dformat); $nameOptions = get_select_options_with_id($locale->getUsableLocaleNameOptions($sugar_config['name_formats']), $nformat); $this->ss->assign('TIMEOPTIONS', $timeOptions); $this->ss->assign('DATEOPTIONS', $dateOptions); $this->ss->assign('NAMEOPTIONS', $nameOptions); $this->ss->assign('DATEFORMAT', $sugar_config['date_formats'][$dformat]); $this->ss->assign('TIMEFORMAT', $sugar_config['time_formats'][$tformat]); $this->ss->assign('NAMEFORMAT', $sugar_config['name_formats'][$nformat]); //// Timezone if (empty($this->bean->id)) { // remove default timezone for new users(set later) $this->bean->user_preferences['timezone'] = ''; } $userTZ = $this->bean->getPreference('timezone'); if (empty($userTZ) && !$this->bean->is_group && !$this->bean->portal_only) { $userTZ = TimeDate::guessTimezone(); $this->bean->setPreference('timezone', $userTZ); } if (!$this->bean->getPreference('ut')) { $this->ss->assign('PROMPTTZ', ' checked'); } $this->ss->assign('TIMEZONE_CURRENT', $userTZ); $this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList()); $this->ss->assign("TIMEZONE", TimeDate::tzName($userTZ)); // FG - Bug 4236 - Managed First Day of Week $fdowDays = array(); foreach ($app_list_strings['dom_cal_day_long'] as $d) { if ($d != "") { $fdowDays[] = $d; } } $this->ss->assign("FDOWOPTIONS", $fdowDays); $currentFDOW = $this->bean->get_first_day_of_week(); if (!isset($currentFDOW)) { $currentFDOW = 0; } $this->ss->assign("FDOWCURRENT", $currentFDOW); $this->ss->assign("FDOWDISPLAY", $fdowDays[$currentFDOW]); //// Numbers and Currency display require_once 'modules/Currencies/ListCurrency.php'; $currency = new ListCurrency(); // 10/13/2006 Collin - Changed to use Localization.getConfigPreference // This was the problem- Previously, the "-99" currency id always assumed // to be defaulted to US Dollars. However, if someone set their install to use // Euro or other type of currency then this setting would not apply as the // default because it was being overridden by US Dollars. $cur_id = $locale->getPrecedentPreference('currency', $this->bean); if ($cur_id) { $selectCurrency = $currency->getSelectOptions($cur_id); $this->ss->assign("CURRENCY", $selectCurrency); } else { $selectCurrency = $currency->getSelectOptions(); $this->ss->assign("CURRENCY", $selectCurrency); } $currencyList = array(); foreach ($locale->currencies as $id => $val) { $currencyList[$id] = $val['symbol']; } $currencySymbolJSON = json_encode($currencyList); $this->ss->assign('currencySymbolJSON', $currencySymbolJSON); $currencyDisplay = new Currency(); if (isset($cur_id)) { $currencyDisplay->retrieve($cur_id); $this->ss->assign('CURRENCY_DISPLAY', $currencyDisplay->iso4217 . ' ' . $currencyDisplay->symbol); } else { $this->ss->assign("CURRENCY_DISPLAY", $currencyDisplay->getDefaultISO4217() . ' ' . $currencyDisplay->getDefaultCurrencySymbol()); } // fill significant digits dropdown $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $this->bean); $sigDigits = ''; for ($i = 0; $i <= 6; $i++) { if ($significantDigits == $i) { $sigDigits .= "<option value=\"{$i}\" selected=\"true\">{$i}</option>"; } else { $sigDigits .= "<option value=\"{$i}\">{$i}</option>"; } } $this->ss->assign('sigDigits', $sigDigits); $this->ss->assign('CURRENCY_SIG_DIGITS', $significantDigits); $num_grp_sep = $this->bean->getPreference('num_grp_sep'); $dec_sep = $this->bean->getPreference('dec_sep'); $this->ss->assign("NUM_GRP_SEP", empty($num_grp_sep) ? $GLOBALS['sugar_config']['default_number_grouping_seperator'] : $num_grp_sep); $this->ss->assign("DEC_SEP", empty($dec_sep) ? $GLOBALS['sugar_config']['default_decimal_seperator'] : $dec_sep); $this->ss->assign('getNumberJs', $locale->getNumberJs()); //// Name display format $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($this->bean)); $this->ss->assign('getNameJs', $locale->getNameJs()); $this->ss->assign('NAME_FORMAT', $this->bean->getLocaleFormatDesc()); //// END LOCALE SETTINGS }
private function getProductCatalogVariables($productCatalog) { $rootCategoriesSmarty = $this->getSmartyCategories($productCatalog->getAllCategories()); $this->insertProducts($rootCategoriesSmarty); $description = htmlToLatex(from_html($productCatalog->description)); //1.7.6 TODO create error handling here if ($description == null) { $GLOBALS['log']->error('OQC: Product catalog description is null!'); //return null; } global $timedate; $validfrom = $timedate->to_display_date($productCatalog->validfrom); $validto = $timedate->to_display_date($productCatalog->validto); $frontpage = null; $attachment = null; if ($productCatalog->frontpage_id != null || $productCatalog->attachment_id != null) { $doc = new Document(); if ($doc->retrieve($productCatalog->frontpage_id)) { $frontpage = str_replace("\\", '/', TMP_DIR . DIRECTORY_SEPARATOR . $doc->document_revision_id . '.pdf'); copy(getcwd() . DIRECTORY_SEPARATOR . getDocumentFilename($doc->document_revision_id), $frontpage); } if ($doc->retrieve($productCatalog->attachment_id)) { $attachment = str_replace("\\", '/', TMP_DIR . DIRECTORY_SEPARATOR . $doc->document_revision_id . '.pdf'); copy(getcwd() . DIRECTORY_SEPARATOR . getDocumentFilename($doc->document_revision_id), $attachment); } } //ProductCatalog currency setup $currencyArray = array(); $currency = new Currency(); $currency_id = $currency->retrieve_id_by_name($productCatalog->currency_id); //$GLOBALS['log']->error('Contract variables: currency: '. var_export($currency_id,true)); if ($currency_id) { $currency->retrieve($currency_id); $currencyArray['currency_id'] = $currency->iso4217; $currencyArray['currency_symbol'] = $currency->symbol; $currencyArray['currency_ratio'] = $currency->conversion_rate; } else { $currencyArray['currency_id'] = $currency->getDefaultISO4217(); $currencyArray['currency_symbol'] = $currency->getDefaultCurrencySymbol(); $currencyArray['currency_ratio'] = 1.0; } $currencyArray['currency_symbol'] = str_replace("€", '\\euro{}', $currencyArray['currency_symbol']); $currencyArray['currency_symbol'] = str_replace('$', '\\$', $currencyArray['currency_symbol']); $currencyArray['currency_symbol'] = str_replace("£", '{\\pounds}', $currencyArray['currency_symbol']); $currencyArray['currency_symbol'] = str_replace("¥", '{Y\\hspace*{-1.4ex}--}', $currencyArray['currency_symbol']); $productCatalogVariables = array('name' => $productCatalog->name, 'validfrom' => $validfrom, 'validto' => $validto, 'graphicsDir' => LATEX_GRAPHICS_DIR, 'categoriesAndProducts' => $rootCategoriesSmarty, 'description' => $description, 'frontpage' => $frontpage, 'attachment' => $attachment, 'year' => date('Y'), 'currency' => $currencyArray, 'discount' => 1.0 - $productCatalog->oqc_catalog_discount / 100); //$GLOBALS['log']->error('Product Catalog variables: '. var_export($productCatalogVariables,true)); return $productCatalogVariables; }
function display() { if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'set_target') { require_once 'modules/Campaigns/utils.php'; //call function to create campaign logs $mess = track_campaign_prospects($this->bean); $confirm_msg = "var ajax_C_LOG_Status = new SUGAR.ajaxStatusClass(); \n window.setTimeout(\"ajax_C_LOG_Status.showStatus('" . $mess . "')\",1000); \n window.setTimeout('ajax_C_LOG_Status.hideStatus()', 1500); \n window.setTimeout(\"ajax_C_LOG_Status.showStatus('" . $mess . "')\",2000); \n window.setTimeout('ajax_C_LOG_Status.hideStatus()', 5000); "; $this->ss->assign("MSG_SCRIPT", $confirm_msg); } # tracy: use the sms.lang.php language file to override the regular Campaign lang if ($this->bean->campaign_type == "SMS") { global $mod_strings; $mod_strings['LBL_QUEUE_BUTTON_LABEL'] = "Send SMS"; } if ($this->bean->campaign_type == 'Email' || $this->bean->campaign_type == 'NewsLetter' || $this->bean->campaign_type == 'SMS') { $this->ss->assign("ADD_BUTTON_STATE", "submit"); $this->ss->assign("TARGET_BUTTON_STATE", "hidden"); } else { $this->ss->assign("ADD_BUTTON_STATE", "hidden"); $this->ss->assign("DISABLE_LINK", "display:none"); $this->ss->assign("TARGET_BUTTON_STATE", "submit"); } $currency = new Currency(); if (isset($this->bean->currency_id) && !empty($this->bean->currency_id)) { $currency->retrieve($this->bean->currency_id); if ($currency->deleted != 1) { $this->ss->assign('CURRENCY', $currency->iso4217 . ' ' . $currency->symbol); } else { $this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol()); } } else { $this->ss->assign('CURRENCY', $currency->getDefaultISO4217() . ' ' . $currency->getDefaultCurrencySymbol()); } parent::display(); //We want to display subset of available, panels, so we will call subpanel //object directly instead of using sugarview. $GLOBALS['focus'] = $this->bean; require_once 'include/SubPanel/SubPanelTiles.php'; $subpanel = new SubPanelTiles($this->bean, $this->module); //get available list of subpanels # tracy: change the title key of email marketing subpanel for SMS if ($this->bean->campaign_type == "SMS") { $subpanel->subpanel_definitions->layout_defs['subpanel_setup']['emailmarketing']['title_key'] = "SMS Маркетинг"; } $alltabs = $subpanel->subpanel_definitions->get_available_tabs(); if (!empty($alltabs)) { //iterate through list, and filter out all but 3 subpanels foreach ($alltabs as $key => $name) { if ($this->bean->campaign_type == 'SMS' && $name == 'tracked_urls') { # tracy: hide trackers for SMS $subpanel->subpanel_definitions->exclude_tab($name); } elseif ($name != 'prospectlists' && $name != 'emailmarketing' && $name != 'tracked_urls') { //exclude subpanels that are not prospectlists, emailmarketing, or tracked urls $subpanel->subpanel_definitions->exclude_tab($name); } } //only show email marketing subpanel for email/newsletter campaigns # tracy: include SMS if ($this->bean->campaign_type != 'Email' && $this->bean->campaign_type != 'NewsLetter' && $this->bean->campaign_type != 'SMS') { //exclude subpanels that are not prospectlists, emailmarketing, or tracked urls $subpanel->subpanel_definitions->exclude_tab('emailmarketing'); } } //show filtered subpanel list $this->options['show_subpanels'] = 0; echo $subpanel->display(); }
public function testgetDefaultISO4217() { $currency = new Currency(); $this->assertEquals('USD', $currency->getDefaultISO4217()); }
function getContractVariables($contract) { $contractData = sanatizeBeanArrayForLatex($contract->toArray(true)); $clientContact = new Contact(); if ($clientContact->retrieve($contract->clientcontact_id)) { $contractData['clientContact'] = sanatizeBeanArrayForLatex($clientContact->toArray(true)); // Gets data from DB only $clientAccount = new Account(); if ($clientAccount->retrieve($clientContact->account_id)) { //$GLOBALS['log']->error('Account variables: variables transferred to latex template: '. var_export($clientAccount->toArray(true),true)); $contractData['clientContact']['account'] = sanatizeBeanArrayForLatex($clientAccount->toArray(true)); } //gets data from DB only } // only date is needed (not time) and we have to convert it to the user format global $timedate; //$GLOBALS['log']->error('Contract variables: date_modified: '. var_export($contract->date_modified,true)); //$contractData['date_modified'] = $timedate->to_display_date($contract->date_modified); $contractData['date_modified'] = $timedate->getDatePart($contract->date_modified); //$contractData['startdate'] = $timedate->to_display_date($contract->startdate); //$contractData['enddate'] = $timedate->to_display_date($contract->enddate); //$contractData['deadline'] = $timedate->to_display_date($contract->deadline); // translate global $app_list_strings; if (isset($contractData['periodofnotice'])) { $contractData['periodofnotice'] = $app_list_strings['periodofnotice_list'][$contractData['periodofnotice']]; } //contract currency setup $currency = new Currency(); $currency_id = $currency->retrieve_id_by_name($contract->currency_id); //$GLOBALS['log']->error('Contract variables: currency: '. var_export($currency_id,true)); if ($currency_id) { $currency->retrieve($currency_id); $contractData['currency_id'] = $currency->iso4217; $contractData['currency_symbol'] = $currency->symbol; } else { $contractData['currency_id'] = $currency->getDefaultISO4217(); $contractData['currency_symbol'] = $currency->getDefaultCurrencySymbol(); } $contractData['currency_symbol'] = str_replace("€", '\\euro{}', $contractData['currency_symbol']); $contractData['currency_symbol'] = str_replace('$', '\\$', $contractData['currency_symbol']); $contractData['currency_symbol'] = str_replace("£", '{\\pounds}', $contractData['currency_symbol']); $contractData['currency_symbol'] = str_replace("¥", '{Y\\hspace*{-1.4ex}--}', $contractData['currency_symbol']); // Get Sugar user information $userData = oqc_getUserVariables(); $contractData = array_merge($contractData, $userData); $outputData = array('contract' => $contractData, 'graphicsDir' => LATEX_GRAPHICS_DIR); //$GLOBALS['log']->error('Contract variables: variables transferred to latex template: '. var_export($contractData,true)); return $outputData; }
function get_next_row($result_field_name = 'result', $column_field_name = 'display_columns', $skip_non_summary_columns = false, $exporting = false) { global $current_user; $chart_cells = array(); if ($this->do_export) { $db_row = $this->db->fetchByAssoc($this->{$result_field_name}, false); } else { $db_row = $this->db->fetchByAssoc($this->{$result_field_name}); } if ($db_row == 0 || sizeof($db_row) == 0) { return 0; } // Call custom hooks if (isset($this->full_bean_list) && is_array($this->full_bean_list) && array_key_exists('self', $this->full_bean_list) && is_object($this->full_bean_list['self']) && method_exists($this->full_bean_list['self'], 'call_custom_logic')) { $this->full_bean_list['self']->call_custom_logic('process_report_row', array('row' => &$db_row, 'reporter' => $this)); } if ($result_field_name == 'summary_result') { if (!empty($this->child_filter) && !empty($db_row[$this->child_filter_name])) { $this->child_filter_by = $db_row[$this->child_filter_name]; } else { $this->child_filter = ''; $this->child_filter_by = ''; $this->child_filter_name = ''; } } $row = array(); $cells = array(); $fields = array(); foreach ($db_row as $key => $value) { //if value is null or not set, then change to empty string. This prevents array index errors while processing $fields[strtoupper($key)] = is_null($value) ? '' : $value; } // here we want to make copies, so use foreach foreach ($this->report_def[$column_field_name] as $display_column) { $display_column['table_alias'] = $this->getTableFromField($display_column); $this->register_field_for_query($display_column); if ($skip_non_summary_columns && empty($display_column['group_function'])) { if ($exporting || $this->plain_text_output) { array_push($cells, ' '); } else { array_push($cells, ' '); } continue; } $display_column['fields'] = $fields; if ($this->plain_text_output == true) { /*nsingh: bug 13554- date and time fields must be displayed using user's locale settings. * Since to_pdf uses plain_text_output=true, we handle the date and time case here by using the 'List' context of the layout_manager */ if ($display_column['type'] == 'date' || $display_column['type'] == 'time' || $display_column['type'] == 'datetimecombo') { $this->layout_manager->setAttribute('context', 'List'); } else { $this->layout_manager->setAttribute('context', 'ListPlain'); } } else { $this->layout_manager->setAttribute('context', 'List'); } // Make sure 'AVG' aggregate is shown as float, regardless of the original field type if (!empty($display_column['group_function']) && strtolower($display_column['group_function']) === 'avg' && $display_column['type'] != 'currency') { $display_column['type'] = 'float'; } if ($display_column['type'] != 'currency' || substr_count($display_column['name'], '_usdoll') == 0 && (isset($display_column['group_function']) ? $display_column['group_function'] != 'weighted_amount' && $display_column['group_function'] != 'weighted_sum' : true)) { $pos = $display_column['table_key']; $module_name = ''; if ($pos) { $module_name = substr($pos, strrpos($pos, ':') + 1); } $field_name = $this->getColumnFieldName($display_column); if ($module_name == 'currencies' && empty($display_column['fields'][$field_name])) { switch ($display_column['name']) { case 'iso4217': $display = $this->currency_obj->getDefaultISO4217(); break; case 'symbol': $display = $this->currency_obj->getDefaultCurrencySymbol(); break; case 'name': $display = $this->currency_obj->getDefaultCurrencyName(); break; default: $display = $this->layout_manager->widgetDisplay($display_column); } $display_column['fields'][$field_name] = $display; } else { if (!empty($field_name) && isset($display_column['fields'][$field_name])) { $display_column['fields'][$field_name] = $this->db->fromConvert($display_column['fields'][$field_name], $display_column['type']); } $display = $this->layout_manager->widgetDisplay($display_column); } } else { if (isset($display_column['group_function'])) { $field_name = $this->getTruncatedColumnAlias(strtoupper($display_column['table_alias']) . "_" . strtoupper($display_column['group_function']) . "_" . strtoupper($display_column['name'])); } else { unset($field_name); } if (!isset($field_name) || !isset($display_column['fields'][$field_name])) { $field_name = $this->getTruncatedColumnAlias(strtoupper($display_column['table_alias']) . "_" . strtoupper($display_column['name'])); } if (isset($display_column['fields'][$field_name])) { $display = $display_column['fields'][$field_name]; } } if ($display_column['type'] == 'currency' && (strpos($display_column['name'], '_usdoll') !== false || !empty($display_column['group_function']))) { // convert base to user preferred if set in user prefs if ($current_user->getPreference('currency_show_preferred')) { $userCurrency = SugarCurrency::getUserLocaleCurrency(); $raw_display = SugarCurrency::convertWithRate($display_column['fields'][$field_name], 1.0, $userCurrency->conversion_rate); $display = SugarCurrency::formatAmountUserLocale($raw_display, $userCurrency->id); } else { $raw_display = $display_column['fields'][$field_name]; $display = SugarCurrency::formatAmountUserLocale($raw_display, SugarCurrency::getBaseCurrency()->id); } } else { $raw_display = $display; } if (isset($display_column['type']) && $display_column['type'] == 'float') { $display = $this->layout_manager->widgetDisplay($display_column); } if (isset($display_column['type'])) { $alias = $this->alias_lookup[$display_column['table_key']]; $array_key = strtoupper($alias . '__count'); if (array_key_exists($array_key, $display_column['fields'])) { $displayData = $display_column['fields'][$array_key]; if (empty($displayData) && $display_column['type'] != 'bool' && ($display_column['type'] != 'enum' || $display_column['type'] == 'enum' && $displayData != '0')) { $display = ""; } } // if $module_bean = BeanFactory::getBean($this->module); if (is_array($module_bean->field_defs)) { if (isset($module_bean->field_defs[$display_column['type']])) { if (isset($module_bean->field_defs[$display_column['type']]['options'])) { $trans_options = translate($module_bean->field_defs[$display_column['type']]['options']); if (isset($trans_options[$display_column['fields'][$field_name]])) { $display = $trans_options[$display_column['fields'][$field_name]]; } } } } } // if // for charts if ($column_field_name == 'summary_columns' && $this->do_chart) { //_pp($display); $raw_value = ""; $keys = array_keys($fields); foreach ($this->report_def['summary_columns'] as $index => $column) { if ($column['name'] == $display_column['name'] && isset($keys[$index]) && isset($fields[$keys[$index]])) { $raw_value = $fields[$keys[$index]]; break; } } $cell_arr = array('val' => $raw_display, 'key' => $display_column['column_key'], 'raw_value' => $raw_value); //_pp($cell_arr); array_push($chart_cells, $cell_arr); } if ($exporting) { global $app_list_strings; // parse out checkboxes // TODO: wp this should be done in the widget if (preg_match('/type.*=.*checkbox/Uis', $display)) { if (preg_match('/checked/i', $display)) { $display = $app_list_strings['dom_switch_bool']['on']; } else { $display = $app_list_strings['dom_switch_bool']['off']; } } } array_push($cells, $display); } // END foreach $row['cells'] = $cells; // calculate summary rows count as the product of all count fields in summary $count = 1; $count_exists = false; foreach ($db_row as $count_column => $count_value) { if (substr($count_column, -10) == "__allcount" || $count_column == 'count') { $count *= max($count_value, 1); $count_exists = true; } } if ($count_exists) { $row['count'] = $count; } // for charts if ($column_field_name == 'summary_columns' && $this->do_chart) { $chart_row = 0; if (!empty($db_row['count'])) { $chart_row = array('cells' => $chart_cells, 'count' => $db_row['count']); } else { $chart_row = array('cells' => $chart_cells); } array_push($this->chart_rows, $chart_row); } if ($column_field_name == 'summary_columns' && isset($this->chart_group_position) && isset($this->group_header)) { $row['group_pos'] = $this->chart_group_position; $row['group_header'] = $this->group_header; $row['group_column_is_invisible'] = $this->group_column_is_invisible; } return $row; }