$selectCurrency = $currency->getSelectOptions($current_user->getPreference('currency')); $ss->assign("CURRENCY", $selectCurrency); } else { $selectCurrency = $currency->getSelectOptions(); $ss->assign("CURRENCY", $selectCurrency); } } global $current_user; if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) { $record = ''; if (!empty($_REQUEST['record'])) { $record = $_REQUEST['record']; } $ss->assign("ADMIN_EDIT", "<a href='index.php?action=index&module=DynamicLayout&from_action=" . $_REQUEST['action'] . "&from_module=" . $_REQUEST['module'] . "&record=" . $record . "'>" . SugarThemeRegistry::current()->getImage("EditLayout", "border='0' alt='Edit Layout' align='bottom'") . "</a>"); } echo $currency->getJavascript(); $seps = get_number_seperators(); $ss->assign("NUM_GRP_SEP", $seps[0]); $ss->assign("DEC_SEP", $seps[1]); //fill out the campaign type dropdown based on type of campaign being created if ($campaign_type == 'general') { //get regular campaign dom object and strip out entries for email and newsletter $myTypeOptionsArr = array(); $OptionsArr = $app_list_strings['campaign_type_dom']; foreach ($OptionsArr as $key => $val) { if ($val == 'Newsletter' || $val == 'Email' || $val == '') { //do not add } else { $myTypeOptionsArr[$key] = $val; } }
function getCurrencyDropDown($focus, $field = 'currency_id', $value = '', $view = 'DetailView') { $view = ucfirst($view); if ($view == 'EditView' || $view == 'MassUpdate' || $view == 'QuickCreate' || $view == 'ConvertLead') { if (isset($_REQUEST[$field]) && !empty($_REQUEST[$field])) { $value = $_REQUEST[$field]; } elseif (empty($focus->id)) { $value = $GLOBALS['current_user']->getPreference('currency'); if (empty($value)) { // -99 is the system default currency $value = -99; } } require_once 'modules/Currencies/ListCurrency.php'; $currency_fields = array(); //Bug 18276 - Fix for php 5.1.6 $defs = $focus->field_defs; // foreach ($defs as $name => $key) { if ($key['type'] == 'currency') { $currency_fields[] = $name; } } $currency = new ListCurrency(); $selectCurrency = $currency->getSelectOptions($value); $currency->setCurrencyFields($currency_fields); $html = '<select name="'; // If it's a lead conversion (ConvertLead view), add the module_name before the $field if ($view == "ConvertLead") { $html .= $focus->module_name; } $html .= $field . '" id="' . $field . '_select" '; if ($view != 'MassUpdate') { $html .= 'onchange="CurrencyConvertAll(this.form);"'; } $html .= '>' . $selectCurrency . '</select>'; if ($view != 'MassUpdate') { $html .= $currency->getJavascript(); } return $html; } else { $currency = new Currency(); $currency->retrieve($value); return $currency->name; } }
/** * @see SugarView::display() */ public function display() { require_once 'modules/Quotes/Layouts.php'; require_once 'include/EditView/EditView2.php'; global $beanFiles; require_once $beanFiles['Quote']; require_once $beanFiles['TaxRate']; require_once $beanFiles['Shipper']; global $mod_strings; global $app_strings; global $app_list_strings; global $current_user; global $timedate; global $locale; $original_quote = BeanFactory::getBean('Quotes'); if ($this->ev->isDuplicate) { $this->bean->id = ""; $this->bean->quote_num = ""; $original_quote->retrieve($_REQUEST['record']); } //needed when creating a new quote only with a default account value passed in if (empty($this->bean->id) && !$this->ev->isDuplicate) { $this->bean->quote_num = ''; $this->bean->total = '0.00'; $this->bean->shipping = '0.00'; $this->bean->tax = '0.00'; $this->bean->subtotal = '0.00'; if (isset($_REQUEST['opportunity_name'])) { $this->bean->opportunity_name = $_REQUEST['opportunity_name']; } if (isset($_REQUEST['opportunity_id'])) { $this->bean->opportunity_id = $_REQUEST['opportunity_id']; } if (isset($_REQUEST['account_name'])) { $this->bean->billing_account_name = $_REQUEST['account_name']; $this->bean->shipping_account_name = $_REQUEST['account_name']; } if (isset($_REQUEST['account_id'])) { $this->bean->billing_account_id = $_REQUEST['account_id']; $this->bean->shipping_account_id = $_REQUEST['account_id']; require_once $beanFiles['Account']; $account = BeanFactory::getBean('Accounts', $this->bean->shipping_account_id); $this->bean->shipping_address_street = $account->shipping_address_street; $this->bean->shipping_address_city = $account->shipping_address_city; $this->bean->shipping_address_state = $account->shipping_address_state; $this->bean->shipping_address_country = $account->shipping_address_country; $this->bean->shipping_address_postalcode = $account->shipping_address_postalcode; $this->bean->billing_address_street = $account->billing_address_street; $this->bean->billing_address_city = $account->billing_address_city; $this->bean->billing_address_state = $account->billing_address_state; $this->bean->billing_address_country = $account->billing_address_country; $this->bean->billing_address_postalcode = $account->billing_address_postalcode; } if (isset($_REQUEST['contact_id'])) { $this->bean->contact_id = $_REQUEST['contact_id']; require_once $beanFiles['Contact']; $contact = BeanFactory::getBean('Contacts', $this->bean->contact_id); $this->bean->billing_contact_name = $locale->formatName($contact); $this->bean->billing_contact_id = $contact->id; $this->bean->shipping_contact_name = $locale->formatName($contact); $this->bean->shipping_contact_id = $contact->id; $this->bean->shipping_address_street = $contact->primary_address_street; $this->bean->shipping_address_city = $contact->primary_address_city; $this->bean->shipping_address_state = $contact->primary_address_state; $this->bean->shipping_address_country = $contact->primary_address_country; $this->bean->shipping_address_postalcode = $contact->primary_address_postalcode; } if (isset($_REQUEST['date_quote_expected_closed'])) { $this->bean->date_quote_expected_closed = $_REQUEST['date_quote_expected_closed']; } if (isset($_REQUEST['currency_id'])) { $this->bean->currency_id = $_REQUEST['currency_id']; } } $currency = BeanFactory::getBean('Currencies', $this->bean->currency_id); // Set the number grouping and decimal separators $seps = get_number_seperators(); $dec_sep = $seps[1]; $num_grp_sep = $seps[0]; $this->ss->assign('NUM_GRP_SEP', $num_grp_sep); $this->ss->assign('DEC_SEP', $dec_sep); $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user); $this->ss->assign('PRECISION', $significantDigits); if ((is_admin($current_user) || is_admin_for_module($GLOBALS['current_user'], 'Quotes')) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) { $record = ''; if (!empty($_REQUEST['record'])) { $record = $_REQUEST['record']; } $this->ss->assign('ADMIN_EDIT', "<a href='index.php?action=index&module=DynamicLayout&from_action=" . $_REQUEST['action'] . "&from_module=" . $_REQUEST['module'] . "&record=" . $record . "'>" . SugarThemeRegistry::current()->getImage("EditLayout", "border='0' align='bottom'", null, null, '.gif', $mod_strings['LBL_EDITLAYOUT']) . "</a>"); } $this->ss->assign('QUOTE_STAGE_OPTIONS', get_select_options_with_id($app_list_strings['quote_stage_dom'], $this->bean->quote_stage)); $this->ss->assign('DEFAULT_PRODUCT_STATUS', $app_list_strings['product_status_quote_key']); if (isset($this->bean->subtotal)) { $this->ss->assign('SUBTOTAL', $this->bean->subtotal); } else { $this->ss->assign('SUBTOTAL', "0.00"); } if (isset($this->bean->tax)) { $this->ss->assign('TAX', $this->bean->tax); } else { $this->ss->assign('TAX', "0.00"); } if (isset($this->bean->shipping)) { $this->ss->assign("SHIPPING", $this->bean->shipping); } else { $this->ss->assign('SHIPPING', "0.00"); } if (isset($this->bean->deal_tot)) { $this->ss->assign('DEAL_TOT', $this->bean->deal_tot); } else { $this->ss->assign('DEAL_TOT', "0.00"); } if (isset($this->bean->new_sub)) { $this->ss->assign('NEW_SUB', $this->bean->new_sub); } else { $this->ss->assign('NEW_SUB', "0.00"); } if (isset($this->bean->total)) { $this->ss->assign('TOTAL', $this->bean->total); } else { $this->ss->assign('TOTAL', "0.00"); } if (isset($this->bean->subtotal_usdollar)) { $this->ss->assign('SUBTOTAL_USDOLLAR', $this->bean->subtotal_usdollar); } else { $this->ss->assign('SUBTOTAL_USDOLLAR', "0.00"); } if (isset($this->bean->tax_usdollar)) { $this->ss->assign('TAX_USDOLLAR', $this->bean->tax_usdollar); } else { $this->ss->assign('TAX_USDOLLAR', "0.00"); } if (isset($this->bean->shipping_usdollar)) { $this->ss->assign('SHIPPING_USDOLLAR', $this->bean->shipping_usdollar); } else { $this->ss->assign('SHIPPING_USDOLLAR', "0.00"); } if (isset($this->bean->total_usdollar)) { $this->ss->assign('TOTAL_USDOLLAR', $this->bean->total_usdollar); } else { $this->ss->assign('TOTAL_USDOLLAR', "0.00"); } $this->ss->assign('USER_DATEFORMAT', '(' . $timedate->get_user_date_format() . ')'); $this->ss->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format()); $taxrate = BeanFactory::getBean('TaxRates'); $this->ss->assign('TAXRATE_OPTIONS', get_select_options_with_id($taxrate->get_taxrates(false), $this->bean->taxrate_id)); if (empty($this->bean->taxrate_value)) { $this->ss->assign('TAXRATE_VALUE', $taxrate->get_default_taxrate_value() / 100); } else { $this->ss->assign('TAXRATE_VALUE', $this->bean->taxrate_value / 100); } $shipper = BeanFactory::getBean('Shippers'); $this->ss->assign('SHIPPER_OPTIONS', get_select_options_with_id($shipper->get_shippers(true), $this->bean->shipper_id)); if (empty($this->bean->assigned_user_id) && empty($this->bean->id)) { $this->bean->assigned_user_id = $current_user->id; } if (empty($this->bean->assigned_name) && empty($this->bean->id)) { $this->bean->assigned_user_name = $current_user->user_name; } $this->ss->assign('ASSIGNED_USER_OPTIONS', get_select_options_with_id(get_user_array(TRUE, 'Active', $this->bean->assigned_user_id), $this->bean->assigned_user_id)); $this->ss->assign('ASSIGNED_USER_NAME', $this->bean->assigned_user_name); $this->ss->assign('ASSIGNED_USER_ID', $this->bean->assigned_user_id); if (!empty($this->bean->calc_grand_total) && $this->bean->calc_grand_total == 1) { $this->ss->assign('CALC_GRAND_TOTAL_CHECKED', 'checked'); } if (!empty($this->bean->show_line_nums) && $this->bean->show_line_nums == 1) { $this->ss->assign('SHOW_LINE_NUMS_CHECKED', 'checked'); } // Set Currency values and currency javascript require_once 'modules/Currencies/ListCurrency.php'; $currency = new ListCurrency(); $base_rate = '1.00'; if (isset($this->bean->currency_id) && !empty($this->bean->currency_id)) { $curid = $this->bean->currency_id; } elseif (isset($_REQUEST['currency_id']) && !empty($_REQUEST['currency_id'])) { $curid = $_REQUEST['currency_id']; } elseif (empty($this->bean->id)) { $curid = $current_user->getPreference('currency'); if (empty($curid)) { $curid = -99; } } else { $curid = -99; } if ($this->bean->isClosed()) { $base_rate = $this->bean->base_rate; } else { $base_rate = null; } $selectCurrency = $currency->getSelectOptions($curid, $base_rate); $this->ss->assign("CURRENCY", $selectCurrency); $this->ss->assign('CURRENCY_JAVASCRIPT', $currency->getJavascript()); if ($this->bean->fetched_row['date_quote_expected_closed'] == '1970-01-01' || $this->bean->fetched_row['date_quote_expected_closed'] == '0001-01-01') { $this->bean->date_quote_expected_closed = ''; } $add_row = array(); if (!empty($this->bean->id)) { $this->bean->load_relationship('product_bundles'); $product_bundle_list = $this->bean->product_bundles->getBeans(); usort($product_bundle_list, array('ProductBundle', 'compareProductBundlesByIndex')); $quote_currency_id = $this->bean->currency_id; $quote_base_rate = $this->bean->base_rate; $convert_format = function ($value, $prod_currency, $prod_base_rate) use($quote_currency_id, $quote_base_rate) { if ($prod_currency !== $quote_currency_id) { $value = SugarCurrency::convertWithRate($value, $prod_base_rate, $quote_base_rate); } return SugarCurrency::formatAmountUserLocale($value, $quote_currency_id, false); }; if (is_array($product_bundle_list)) { foreach ($product_bundle_list as $product_bundle) { $bundle_list = $product_bundle->get_product_bundle_line_items(); $add_row[] = "quotesManager.addTable('{$product_bundle->id}','{$product_bundle->bundle_stage}', '{$product_bundle->name}', '" . format_money($product_bundle->shipping, FALSE) . "' );\n"; if (is_array($bundle_list)) { while (list($key, $line_item) = each($bundle_list)) { if ($line_item->object_name == "Product") { /* @var $line_item Product */ $tax_class_name = isset($line_item->tax_class) ? $line_item->tax_class : ""; $encoded_name = js_escape(br2nl($line_item->name)); $add_row[] = "quotesManager.addRow('{$line_item->id}','" . format_number($line_item->quantity, $significantDigits, $significantDigits) . "','{$line_item->product_template_id}','{$encoded_name}'" . ", '" . $convert_format($line_item->cost_price, $line_item->currency_id, $line_item->base_rate) . "'" . ", '" . $convert_format($line_item->list_price, $line_item->currency_id, $line_item->base_rate) . "'" . ", '" . $convert_format($line_item->discount_price, $line_item->currency_id, $line_item->base_rate) . "'" . ", '', '', '{$line_item->pricing_factor}', '{$line_item->tax_class}', '{$tax_class_name}', '{$line_item->mft_part_num}', '{$product_bundle->id}', '{$product_bundle->bundle_stage}', '{$product_bundle->name}', '" . format_number($product_bundle->shipping) . "', '" . js_escape(br2nl($line_item->description)) . "', '" . $line_item->type_id . "'" . ", '" . format_number($line_item->discount_amount, $significantDigits, $significantDigits) . "'" . ", " . ($line_item->discount_select ? 1 : 0) . ", " . ($line_item->deal_calc ? 1 : 0) . ", '" . $line_item->status . "');\n"; } else { if ($line_item->object_name == "ProductBundleNote") { /* @var $line_item ProductBundleNote */ $encoded_description = js_escape(br2nl($line_item->description)); //$encoded_description = html_entity_decode($encoded_description); $add_row[] = "quotesManager.addCommentRow('{$line_item->id}', '{$product_bundle->id}', '{$encoded_description}');\n"; } } } //while } //if } //foreach } } else { // this else part is to create a new product_bundle for the duplicate quote $original_quote->load_relationship('product_bundles'); $product_bundle_list = $original_quote->product_bundles->getBeans(); usort($product_bundle_list, array('ProductBundle', 'compareProductBundlesByIndex')); if (is_array($product_bundle_list)) { foreach ($product_bundle_list as $product_bundle) { $product_list = $product_bundle->get_products(); if (is_array($product_list)) { foreach ($product_list as $line_item) { $tax_class_name = isset($line_item->tax_class) ? $line_item->tax_class : ""; $add_row[] = "quotesManager.addRow('','{$line_item->quantity}','{$line_item->product_template_id}','{$line_item->name}'" . ", '" . format_number($line_item->cost_usdollar, $significantDigits, $significantDigits, array('convert' => true, 'currency_id' => $curid)) . "'" . ", '" . format_number($line_item->list_usdollar, $significantDigits, $significantDigits, array('convert' => true, 'currency_id' => $curid)) . "'" . ", '" . format_number($line_item->discount_usdollar, $significantDigits, $significantDigits, array('convert' => true, 'currency_id' => $curid)) . "'" . ", '', '', '{$line_item->pricing_factor}', '{$line_item->tax_class}', '{$tax_class_name}',\n\t\t\t\t\t\t\t\t'{$line_item->mft_part_num}', 'group_{$product_bundle->id}', '{$product_bundle->bundle_stage}', '{$product_bundle->name}', '" . format_money($product_bundle->shipping, FALSE) . "', '" . js_escape(br2nl($line_item->description)) . "', '" . $line_item->type_id . "','" . format_number($line_item->discount_amount_usdollar, $significantDigits, $significantDigits, array('convert' => !$line_item->discount_select, 'currency_id' => $curid)) . "'," . ($line_item->discount_select ? 1 : 0) . ",0, '" . $line_item->status . "');\n"; } //foreach if (empty($product_list)) { $add_row[] = "quotesManager.addTable('group_{$product_bundle->id}','{$product_bundle->bundle_stage}', '{$product_bundle->name}' , ' " . format_money($product_bundle->shipping, FALSE) . "');\n"; } //if //bug 39573 - Comments are not duplicated in quotes $bundle_list = $product_bundle->get_product_bundle_line_items(); if (is_array($bundle_list)) { while (list($key, $line_item) = each($bundle_list)) { if ($line_item->object_name == "ProductBundleNote") { $encoded_description = js_escape(br2nl($line_item->description)); $add_row[] = "quotesManager.addCommentRow('{$line_item->id}', 'group_{$product_bundle->id}', '{$encoded_description}');\n"; } } } //end bug 39573 } //if } } } //if-else for !empty($this->bean->id) //Bug#53607: Create the javascript code to store the rendering function in a queue $add_row_js = 'var add_row_stack = [];'; foreach ($add_row as $script_command) { $add_row_js .= "add_row_stack.push(function(){\n {$script_command}\n });"; } //Bug#53607: Rather than executing all rendering row script once, it will keep in a queue. // And it will render the specified number of rows every interval. $add_row_js .= "function add_rows_on_load() {\n if(typeof add_row_stack != 'undefined' && add_row_stack.length > 0) {\n //interval is in msec,\n //size is the number of rows rendering every time\n asyncLoading = true; // to indicate that the content is still loading\n var _interval = 100,\n _size = 3,\n _exec = add_row_stack.splice(0, _size),\n _header_button = document.getElementById('SAVE_HEADER'),\n _footer_button = document.getElementById('SAVE_FOOTER');\n if(_header_button) {\n _header_button.disabled = true;\n }\n if(_footer_button) {\n _footer_button.disabled = true;\n }\n for(idx in _exec) {\n _exec[idx]();\n }\n window.setTimeout(add_rows_on_load, _interval);\n } else {\n asyncLoading = false; // content is loaded\n var _header_button = document.getElementById('SAVE_HEADER'),\n _footer_button = document.getElementById('SAVE_FOOTER');\n if(_header_button) {\n _header_button.disabled = false;\n }\n if(_footer_button) {\n _footer_button.disabled = false;\n }\n }\n }"; $this->ss->assign("ADD_ROWS", $add_row_js); $setup_script = ''; $taxclass = translate('tax_class_dom'); foreach ($taxclass as $value => $name) { $setup_script .= "quotesManager.add_tax_class('{$name}', '{$value}');\n"; } $this->ss->assign("SETUP_SCRIPT", $setup_script); $this->ss->assign('TAXRATE_JAVASCRIPT', $taxrate->get_taxrate_js()); $this->ss->assign('CALCULATE_FUNCTION', '<script type="text/javascript">YAHOO.util.Event.onDOMReady(function(){quotesManager.calculate(document);});</script>'); $this->ss->assign('NO_MATCH_VARIABLE', '<script type="text/javascript">sqs_no_match_text = "' . $app_strings['ERR_SQS_NO_MATCH'] . '";</script>'); $str = "<script language=\"javascript\">\n\t\tYAHOO.util.Event.onAvailable('add_tables', add_rows_on_load);\n\t\t</script>"; $this->ss->assign('SAVED_SEARCH_SELECTS', $str); parent::display(); echo '<script>sqs_must_match = false;</script>'; }
function getCurrencyDropDown($focus, $field = 'currency_id', $value = '', $view = 'DetailView') { if ($view == 'EditView' || $view == 'MassUpdate' || $view == 'QuickCreate') { require_once 'modules/Currencies/ListCurrency.php'; $currency_fields = array(); //Bug 18276 - Fix for php 5.1.6 $defs = $focus->field_defs; // foreach ($defs as $name => $key) { if ($key['type'] == 'currency') { $currency_fields[] = $name; } } $currency = new ListCurrency(); if (!empty($value)) { $selectCurrency = $currency->getSelectOptions($value); } else { if ($GLOBALS['current_user']->getPreference('currency') && empty($focus->id)) { $selectCurrency = $currency->getSelectOptions($GLOBALS['current_user']->getPreference('currency')); } else { $selectCurrency = $currency->getSelectOptions(); } } $currency->setCurrencyFields($currency_fields); $html = '<select name="' . $field . '" '; if ($view != 'MassUpdate') { $html .= 'onchange="CurrencyConvertAll();"'; } $html .= '>' . $selectCurrency . '</select>'; if ($view != 'MassUpdate') { $html .= $currency->getJavascript(); } return $html; } else { $currency = new Currency(); $currency->retrieve($value); return $currency->name; } }
if (!empty($_REQUEST['timeperiod_id'])) { /* if the user is not a manager, get the user's self quota * and use a strip down version of ListView to process the * quota object */ if (!$focus->isManager($current_user->id)) { $ListView->processListView($focus, "", ""); } else { /* if records are available for the direct reports, * get the group quota and process the ListView */ if ($row_count > 0) { $groupQuota = $focus->getGroupQuota($_REQUEST['timeperiod_id']); $ListView->xTemplateAssign("GROUP_QUOTA", outputGroupQuota($focus->getGroupQuota($_REQUEST['timeperiod_id'], false))); $currency->getSelectOptions(); $ListView->xTemplateAssign("JAVASCRIPT2", $currency->getJavascript()); $ListView->processListViewTwo($focus, "main", "QUOTA"); } else { $ListView->xTemplateAssign("NOQUOTA", $mod_strings['LBL_NO_QUOTAS_TIMEPERIOD']); $ListView->processListViewTwo($focus, "main", ""); } /////////////////////////////////////////////////////////////////////////////// //// QUOTAS MODULE EDIT VIEW $GLOBALS['log']->info("Quota edit view"); $committed = ''; $disabled = ''; if ($focus->currency_id == NULL) { $selectCurrency = $currency->getSelectOptions(); } else { $selectCurrency = $currency->getSelectOptions($focus->currency_id); }