function getSVNumbersHtml($focus, $name, $value, $view)
{
    if ('EditView' != $view && 'DetailView' != $view) {
        return "";
        // skip the rest of the method if another view calls this method
    }
    global $app_list_strings;
    global $sugar_config;
    $json = getJSONobj();
    $svnumbersSmartyArray = $focus->getSVNumbersArray();
    $svnumberQuicksearch = getSVNumberQuicksearch('svnumber', 'svnumber_id');
    $smarty = new Sugar_Smarty();
    $smarty->assign('sugarDateFormat', getSugarCrmLocale('datef'));
    //$smarty->assign('sugarDateFormat', $sugar_config['default_date_format']);
    $smarty->assign('sqsJavaScript', $svnumberQuicksearch);
    $smarty->assign('svnumbersArray', $svnumbersSmartyArray);
    $smarty->assign('languageStringsCommon', getLanguageStrings("common"));
    if ('DetailView' === $view) {
        // transfer ide into ajvascript code so that we can determine the urls in the ajax call
        $smarty->assign('id', $focus->id);
        //		$smarty->assign('languageStringsDocuments', getLanguageStrings('Documents'));
    }
    $sep = get_number_seperators();
    $smarty->assign('sugarDecimalSeperator', $sep[1]);
    return $smarty->fetch('include/oqc/ExternalContracts/SVNumbers.' . $view . '.html');
}
 function process()
 {
     global $current_user, $timedate, $app_list_strings, $current_language, $mod_strings;
     $mod_strings = return_module_language($current_language, 'Opportunities');
     $json = getJSONobj();
     parent::process();
     list($num_grp_sep, $dec_sep) = get_number_seperators();
     $this->ss->assign('NUM_GRP_SEP', $num_grp_sep);
     $this->ss->assign('DEC_SEP', $dec_sep);
     $this->ss->assign('CURRENCY_ID', $current_user->getPreference('currency'));
     $this->ss->assign("SALES_STAGE_OPTIONS", get_select_options_with_id($app_list_strings['sales_stage_dom'], ''));
     $this->ss->assign("LEAD_SOURCE_OPTIONS", get_select_options_with_id($app_list_strings['lead_source_dom'], ''));
     $this->ss->assign('prob_array', $json->encode($app_list_strings['sales_probability_dom']));
     if ($this->viaAJAX) {
         // override for ajax call
         $this->ss->assign('saveOnclick', "onclick='if(check_form(\"opportunitiesQuickCreate\")) return SUGAR.subpanelUtils.inlineSave(this.form.id, \"opportunities\"); else return false;'");
         $this->ss->assign('cancelOnclick', "onclick='return SUGAR.subpanelUtils.cancelCreate(\"subpanel_opportunities\")';");
     }
     $this->ss->assign('viaAJAX', $this->viaAJAX);
     $this->javascript = new javascript();
     $this->javascript->setFormName('opportunitiesQuickCreate');
     $focus = new Opportunity();
     $this->javascript->setSugarBean($focus);
     $this->javascript->addAllFields('');
     $this->ss->assign('additionalScripts', $this->javascript->getScript(false));
 }
Exemple #3
0
 public function testFormatNumber()
 {
     global $current_user;
     $testValue = "100000.50";
     $formattedValue = format_number($testValue);
     $this->assertEquals($formattedValue, "100,000.50", "Assert that 100000.50 becomes 100,000.50. Formatted value is: " . $formattedValue);
     //Switch the num_grp_sep and dec_sep values
     $current_user->setPreference('num_grp_sep', '.');
     $current_user->setPreference('dec_sep', ',');
     $current_user->save();
     //Force reset on dec_sep and num_grp_sep because the dec_sep and num_grp_sep values are stored as static variables
     get_number_seperators(true);
     $testValue = "100000.50";
     $formattedValue = format_number($testValue);
     $this->assertEquals($formattedValue, "100.000,50", "Assert that 100000.50 becomes 100.000,50. Formatted value is: " . $formattedValue);
 }
function getPdfVariables($contract)
{
    global $app_list_strings;
    global $locale;
    $serviceArrays = array();
    $oneTimeServiceArrays = array();
    $productArrays = array();
    $oneTimeProductArrays = array();
    $pdfDataArray = array();
    $contractVariables = array();
    $calculatedCosts = array();
    $imagesExist = false;
    $sep = get_number_seperators();
    $vat_default = floatval(str_replace($sep[1], '.', $app_list_strings['oqc_vat_list']['default'])) / 100;
    //Get contract variables
    $contractVariables = getContractVariables($contract);
    //Get service data for processing
    $services = $contract->get_linked_beans('oqc_service', 'oqc_Service');
    if (!empty($services)) {
        usort($services, array('oqc_Service', 'oqc_service_compare_position'));
        foreach ($services as $service) {
            $serviceArray = $service->toArray();
            $serviceArray = sanatizeBeanArrayForLatex($serviceArray);
            $product = getProductBean($service);
            if ($product) {
                $productArray = $product->toArray();
                $productArray = sanatizeBeanArrayForLatex($productArray);
            } else {
                $productArray = array();
            }
            if (!empty($service->description)) {
                // Rewrite description with Latex converter output.
                $convertor = new oqc_HtmlToLatexConverter();
                $serviceArray['description'] = $convertor->html2latex('<html><head></head><body>' . from_html($service->description) . '</body></html>');
            } elseif (!empty($product->description)) {
                $convertor = new oqc_HtmlToLatexConverter();
                $productArray['description'] = $convertor->html2latex('<html><head></head><body>' . from_html($product->description) . '</body></html>');
            }
            // translate
            $serviceArray['zeitbezug_translated'] = $app_list_strings['zeitbezug_list'][$serviceArray['zeitbezug']];
            if ($app_list_strings['unit_list'][$serviceArray['unit']]) {
                $serviceArray['unit'] = $app_list_strings['unit_list'][$serviceArray['unit']];
            }
            $calc_vat = $serviceArray['oqc_vat'] == 'default' ? $vat_default : ($serviceArray['oqc_vat'] !== '' ? $serviceArray['oqc_vat'] : $vat_default);
            $serviceArray['oqc_vat'] = $calc_vat * 100;
            $serviceArray['discounted_price'] = $service->getDiscountedPrice($calc_vat);
            $serviceArray['discounted_price_tax_free'] = $service->getDiscountedPriceTaxFree();
            $serviceArray['image_url'] = false;
            if ($product) {
                if ($product->getImageFilenameUrl()) {
                    if (WINDOWS) {
                        $serviceArray['image_url'] = str_replace("\\", "/", '"' . getcwd() . '"/' . $product->getImageFilenameUrl());
                    } else {
                        $serviceArray['image_url'] = str_replace("\\", "/", getcwd() . '/' . $product->getImageFilenameUrl());
                    }
                }
            }
            $serviceArray['has_image'] = $serviceArray['image_url'] !== FALSE;
            // convenient flag for access from latex template
            $serviceArray['startdate'] = $contract->startdate;
            $serviceArray['enddate'] = $contract->enddate;
            //$GLOBALS['log']->error('getPdfVariables: '. var_export($serviceArray['oqc_vat'],true));
            if (!empty($serviceArray['service_currency_id'])) {
                $currency = new Currency();
                //$currency_id = -99;
                $currency->retrieve($serviceArray['service_currency_id']);
                //Convert currency symbols to latex equivalents here
                $serviceArray['currency_symbol'] = $currency->symbol;
                $serviceArray['currency_symbol'] = str_replace("€", '\\euro{}', $serviceArray['currency_symbol']);
                $serviceArray['currency_symbol'] = str_replace('$', '\\$', $serviceArray['currency_symbol']);
                $serviceArray['currency_symbol'] = str_replace("£", '{\\pounds}', $serviceArray['currency_symbol']);
                $serviceArray['currency_symbol'] = str_replace("¥", '{Y\\hspace*{-1.4ex}--}', $serviceArray['currency_symbol']);
            }
            if (!$imagesExist && $serviceArray['has_image']) {
                $imagesExist = true;
            }
            if ($service->zeitbezug == 'once') {
                $oneTimeServiceArrays[] = $serviceArray;
                $oneTimeProductArrays[] = $productArray;
            } else {
                $serviceArrays[] = $serviceArray;
                $productArrays[] = $productArray;
            }
        }
        // merge data from products and services, prefering service data
        $serviceData = array_map('array_merge', $productArrays, $serviceArrays);
        $oneTimeServiceData = array_map('array_merge', $oneTimeProductArrays, $oneTimeServiceArrays);
    }
    $costsTotal = calculateTotalCosts($serviceData, false);
    $oneTimeCostsTotal = calculateTotalCosts($oneTimeServiceData);
    //$currency_symbol =
    $serviceData = array('imagesExist' => $imagesExist, 'services' => $serviceData, 'oneTimeServices' => $oneTimeServiceData);
    $pdfDataArray = array_merge($contractVariables, $serviceData, $costsTotal, $oneTimeCostsTotal);
    //$GLOBALS['log']->error('Services: variable transferred to pdf: '. var_export($pdfDataArray,true));
    return $pdfDataArray;
}
Exemple #5
0
 /**
  * Get JS validation code for views
  */
 public static function getJavascriptValidation()
 {
     global $timedate;
     $cal_date_format = $timedate->get_cal_date_format();
     $timereg = $timedate->get_regular_expression($timedate->get_time_format());
     $datereg = $timedate->get_regular_expression($timedate->get_date_format());
     $date_pos = '';
     foreach ($datereg['positions'] as $type => $pos) {
         if (empty($date_pos)) {
             $date_pos .= "'{$type}': {$pos}";
         } else {
             $date_pos .= ",'{$type}': {$pos}";
         }
     }
     $time_separator = $timedate->timeSeparator();
     $hour_offset = $timedate->getUserUTCOffset() * 60;
     // Add in the number formatting styles here as well, we have been handling this with individual modules.
     require_once 'modules/Currencies/Currency.php';
     list($num_grp_sep, $dec_sep) = get_number_seperators();
     $the_script = "<script type=\"text/javascript\">\n" . "\tvar time_reg_format = '" . $timereg['format'] . "';\n" . "\tvar date_reg_format = '" . $datereg['format'] . "';\n" . "\tvar date_reg_positions = { {$date_pos} };\n" . "\tvar time_separator = '{$time_separator}';\n" . "\tvar cal_date_format = '{$cal_date_format}';\n" . "\tvar time_offset = {$hour_offset};\n" . "\tvar num_grp_sep = '{$num_grp_sep}';\n" . "\tvar dec_sep = '{$dec_sep}';\n" . "</script>";
     return $the_script;
 }
/**
 * Copy of format_number() from currency with fix for sugarpdf.
 * @return String formatted currency value
 * @see modules/Currencies/Currency.php
 */
function format_number_sugarpdf($amount, $round = null, $decimals = null, $params = array())
{
    global $app_strings, $current_user, $sugar_config, $locale;
    static $current_users_currency = null;
    static $last_override_currency = null;
    static $override_currency_id = null;
    static $currency;
    $seps = get_number_seperators();
    $num_grp_sep = $seps[0];
    $dec_sep = $seps[1];
    // cn: bug 8522 - sig digits not honored in pdfs
    if (is_null($decimals)) {
        $decimals = $locale->getPrecision();
    }
    if (is_null($round)) {
        $round = $locale->getPrecision();
    }
    // only create a currency object if we need it
    if (!empty($params['currency_symbol']) && $params['currency_symbol'] || !empty($params['convert']) && $params['convert'] || !empty($params['currency_id'])) {
        // if we have an override currency_id
        if (!empty($params['currency_id'])) {
            if ($override_currency_id != $params['currency_id']) {
                $override_currency_id = $params['currency_id'];
                $currency = new Currency();
                $currency->retrieve($override_currency_id);
                $last_override_currency = $currency;
            } else {
                $currency = $last_override_currency;
            }
        } elseif (!isset($current_users_currency)) {
            // else use current user's
            $current_users_currency = new Currency();
            if ($current_user->getPreference('currency')) {
                $current_users_currency->retrieve($current_user->getPreference('currency'));
            } else {
                $current_users_currency->retrieve('-99');
            }
            // use default if none set
            $currency = $current_users_currency;
        }
    }
    if (!empty($params['convert']) && $params['convert']) {
        $amount = $currency->convertFromDollar($amount, 6);
    }
    if (!empty($params['currency_symbol']) && $params['currency_symbol']) {
        if (!empty($params['symbol_override'])) {
            $symbol = $params['symbol_override'];
        } elseif (!empty($params['type']) && $params['type'] == 'sugarpdf') {
            $symbol = $currency->symbol;
            $symbol_space = false;
        } else {
            if (empty($currency->symbol)) {
                $symbol = $currency->getDefaultCurrencySymbol();
            } else {
                $symbol = $currency->symbol;
            }
            $symbol_space = true;
        }
    } else {
        $symbol = '';
    }
    if (isset($params['charset_convert'])) {
        $symbol = $locale->translateCharset($symbol, 'UTF-8', $locale->getExportCharset());
    }
    if (empty($params['human'])) {
        $amount = number_format(round($amount, $round), $decimals, $dec_sep, $num_grp_sep);
        $amount = format_place_symbol($amount, $symbol, empty($params['symbol_space']) ? false : true);
    } else {
        // If amount is more greater than a thousand(postiive or negative)
        if (strpos($amount, '.') > 0) {
            $checkAmount = strlen(substr($amount, 0, strpos($amount, '.')));
        }
        if ($checkAmount >= 1000 || $checkAmount <= -1000) {
            $amount = round($amount / 1000, 0);
            $amount = $amount . 'k';
            $amount = format_place_symbol($amount, $symbol, empty($params['symbol_space']) ? false : true);
        } else {
            $amount = format_place_symbol($amount, $symbol, empty($params['symbol_space']) ? false : true);
        }
    }
    if (!empty($params['percentage']) && $params['percentage']) {
        $amount .= $app_strings['LBL_PERCENTAGE_SYMBOL'];
    }
    return $amount;
}
Exemple #7
0
function unformat_number($string)
{
    // Just in case someone passes an already unformatted number through.
    if (!is_string($string)) {
        return $string;
    }
    static $currency = null;
    if (!isset($currency)) {
        global $current_user;
        $currency = new Currency();
        if (!empty($current_user->id)) {
            if ($current_user->getPreference('currency')) {
                $currency->retrieve($current_user->getPreference('currency'));
            } else {
                $currency->retrieve('-99');
                // use default if none set
            }
        } else {
            $currency->retrieve('-99');
            // use default if none set
        }
    }
    $seps = get_number_seperators();
    // remove num_grp_sep and replace decimal separator with decimal
    $string = trim(str_replace(array($seps[0], $seps[1], $currency->symbol), array('', '.', ''), $string));
    if (preg_match('/^[+-]?\\d(\\.\\d+)?[Ee]([+-]?\\d+)?$/', $string)) {
        $string = sprintf("%.0f", $string);
    }
    //for scientific number format. After round(), we may get this number type.
    preg_match('/[\\-\\+]?[0-9\\.]*/', $string, $string);
    $out_number = trim($string[0]);
    if ($out_number == '') {
        return '';
    } else {
        return (double) $out_number;
    }
}
/**
 * Advanced OpenSales, Advanced, robust set of sales modules.
 * @package Advanced OpenSales for SugarCRM
 * @copyright SalesAgility Ltd http://www.salesagility.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with this program; if not, see http://www.gnu.org/licenses
 * or write to the Free Software Foundation,Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301  USA
 *
 * @author SalesAgility <*****@*****.**>
 */
function display_lines($focus, $field, $value, $view)
{
    global $sugar_config, $locale, $app_list_strings, $mod_strings;
    $enable_groups = (int) $sugar_config['aos']['lineItems']['enableGroups'];
    $total_tax = (int) $sugar_config['aos']['lineItems']['totalTax'];
    $html = '';
    if ($view == 'EditView') {
        $html .= '<script src="modules/AOS_Products_Quotes/line_items.js"></script>';
        if (file_exists('custom/modules/AOS_Products_Quotes/line_items.js')) {
            $html .= '<script src="custom/modules/AOS_Products_Quotes/line_items.js"></script>';
        }
        $html .= '<script language="javascript">var sig_digits = ' . $locale->getPrecision() . ';';
        $html .= 'var module_sugar_grp1 = "' . $focus->module_dir . '";';
        $html .= 'var enable_groups = ' . $enable_groups . ';';
        $html .= 'var total_tax = ' . $total_tax . ';';
        $html .= '</script>';
        $html .= "<table border='0' cellspacing='4' width='37.5%' id='lineItems'></table>";
        if ($enable_groups) {
            $html .= "<div style='padding-top: 10px; padding-bottom:10px;'>";
            $html .= "<input type=\"button\" tabindex=\"116\" class=\"button\" value=\"" . $mod_strings['LBL_ADD_GROUP'] . "\" id=\"addGroup\" onclick=\"insertGroup(0)\" />";
            $html .= "</div>";
        }
        $html .= '<input type="hidden" name="vathidden" id="vathidden" value="' . get_select_options_with_id($app_list_strings['vat_list'], '') . '">
				  <input type="hidden" name="discounthidden" id="discounthidden" value="' . get_select_options_with_id($app_list_strings['discount_list'], '') . '">';
        require_once 'modules/AOS_Products_Quotes/AOS_Products_Quotes.php';
        require_once 'modules/AOS_Line_Item_Groups/AOS_Line_Item_Groups.php';
        $sql = "SELECT pg.id, pg.group_id FROM aos_products_quotes pg LEFT JOIN aos_line_item_groups lig ON pg.group_id = lig.id WHERE pg.parent_type = '" . $focus->object_name . "' AND pg.parent_id = '" . $focus->id . "' AND pg.deleted = 0 ORDER BY lig.number ASC, pg.number ASC";
        $result = $focus->db->query($sql);
        $html .= "<script>\n\t\t\tif(typeof sqs_objects == 'undefined'){var sqs_objects = new Array;}\n\t\t\t</script>";
        while ($row = $focus->db->fetchByAssoc($result)) {
            $line_item = new AOS_Products_Quotes();
            $line_item->retrieve($row['id']);
            $line_item = json_encode($line_item->toArray());
            $group_item = 'null';
            if ($row['group_id'] != null) {
                $group_item = new AOS_Line_Item_Groups();
                $group_item->retrieve($row['group_id']);
                $group_item = json_encode($group_item->toArray());
            }
            $html .= "<script>\n\t\t\t\t\tinsertLineItems(" . $line_item . "," . $group_item . ");\n\t\t\t\t</script>";
        }
        if (!$enable_groups) {
            $html .= '<script>insertGroup();</script>';
        }
    } else {
        if ($view == 'DetailView') {
            $params = array('currency_id' => $focus->currency_id);
            $sql = "SELECT pg.id, pg.group_id FROM aos_products_quotes pg LEFT JOIN aos_line_item_groups lig ON pg.group_id = lig.id WHERE pg.parent_type = '" . $focus->object_name . "' AND pg.parent_id = '" . $focus->id . "' AND pg.deleted = 0 ORDER BY lig.number ASC, pg.number ASC";
            $result = $focus->db->query($sql);
            $sep = get_number_seperators();
            $html .= "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
            $i = 0;
            $productCount = 0;
            $serviceCount = 0;
            $group_id = '';
            $groupStart = '';
            $groupEnd = '';
            $product = '';
            $service = '';
            while ($row = $focus->db->fetchByAssoc($result)) {
                $line_item = new AOS_Products_Quotes();
                $line_item->retrieve($row['id']);
                if ($enable_groups && ($group_id != $row['group_id'] || $i == 0)) {
                    $html .= $groupStart . $product . $service . $groupEnd;
                    if ($i != 0) {
                        $html .= "<tr><td colspan='9' nowrap='nowrap'><br></td></tr>";
                    }
                    $groupStart = '';
                    $groupEnd = '';
                    $product = '';
                    $service = '';
                    $i = 1;
                    $productCount = 0;
                    $serviceCount = 0;
                    $group_id = $row['group_id'];
                    $group_item = new AOS_Line_Item_Groups();
                    $group_item->retrieve($row['group_id']);
                    $groupStart .= "<tr>";
                    $groupStart .= "<td class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>&nbsp;</td>";
                    $groupStart .= "<td class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_GROUP_NAME'] . ":</td>";
                    $groupStart .= "<td class='tabDetailViewDL' colspan='7' style='text-align: left;padding:2px;'>" . $group_item->name . "</td>";
                    $groupStart .= "</tr>";
                    $groupEnd = "<tr><td colspan='9' nowrap='nowrap'><br></td></tr>";
                    $groupEnd .= "<tr>";
                    $groupEnd .= "<td class='tabDetailViewDL' colspan='8' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_TOTAL_AMT'] . ":&nbsp;&nbsp;</td>";
                    $groupEnd .= "<td class='tabDetailViewDL' style='text-align: right;padding:2px;'>" . currency_format_number($group_item->total_amt, $params) . "</td>";
                    $groupEnd .= "</tr>";
                    $groupEnd .= "<tr>";
                    $groupEnd .= "<td class='tabDetailViewDL' colspan='8' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_DISCOUNT_AMOUNT'] . ":&nbsp;&nbsp;</td>";
                    $groupEnd .= "<td class='tabDetailViewDL' style='text-align: right;padding:2px;'>" . currency_format_number($group_item->discount_amount, $params) . "</td>";
                    $groupEnd .= "</tr>";
                    $groupEnd .= "<tr>";
                    $groupEnd .= "<td class='tabDetailViewDL' colspan='8' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_SUBTOTAL_AMOUNT'] . ":&nbsp;&nbsp;</td>";
                    $groupEnd .= "<td class='tabDetailViewDL' style='text-align: right;padding:2px;'>" . currency_format_number($group_item->subtotal_amount, $params) . "</td>";
                    $groupEnd .= "</tr>";
                    $groupEnd .= "<tr>";
                    $groupEnd .= "<td class='tabDetailViewDL' colspan='8' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_TAX_AMOUNT'] . ":&nbsp;&nbsp;</td>";
                    $groupEnd .= "<td class='tabDetailViewDL' style='text-align: right;padding:2px;'>" . currency_format_number($group_item->tax_amount, $params) . "</td>";
                    $groupEnd .= "</tr>";
                    $groupEnd .= "<tr>";
                    $groupEnd .= "<td class='tabDetailViewDL' colspan='8' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_GRAND_TOTAL'] . ":&nbsp;&nbsp;</td>";
                    $groupEnd .= "<td class='tabDetailViewDL' style='text-align: right;padding:2px;'>" . currency_format_number($group_item->total_amount, $params) . "</td>";
                    $groupEnd .= "</tr>";
                }
                if ($line_item->product_id != '0' && $line_item->product_id != null) {
                    if ($productCount == 0) {
                        $product .= "<tr>";
                        $product .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>&nbsp;</td>";
                        $product .= "<td width='10%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_PRODUCT_QUANITY'] . "</td>";
                        $product .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_PRODUCT_NAME'] . "</td>";
                        $product .= "<td width='12%' class='tabDetailViewDL' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_LIST_PRICE'] . "</td>";
                        $product .= "<td width='12%' class='tabDetailViewDL' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_DISCOUNT_AMT'] . "</td>";
                        $product .= "<td width='12%' class='tabDetailViewDL' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_UNIT_PRICE'] . "</td>";
                        $product .= "<td width='12%' class='tabDetailViewDL' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_VAT'] . "</td>";
                        $product .= "<td width='12%' class='tabDetailViewDL' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_VAT_AMT'] . "</td>";
                        $product .= "<td width='12%' class='tabDetailViewDL' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_TOTAL_PRICE'] . "</td>";
                        $product .= "</tr>";
                    }
                    $product .= "<tr>";
                    $product_note = wordwrap($line_item->description, 40, "<br />\n");
                    $product .= "<td class='tabDetailViewDF' style='text-align: left; padding:2px;'>" . ++$productCount . "</td>";
                    $product .= "<td class='tabDetailViewDF' style='padding:2px;'>" . rtrim(rtrim(format_number($line_item->product_qty), '0'), $sep[1]) . "</td>";
                    $product .= "<td class='tabDetailViewDF' style='padding:2px;'><a href='index.php?module=AOS_Products&action=DetailView&record=" . $line_item->product_id . "' class='tabDetailViewDFLink'>" . $line_item->name . "</a><br />" . $product_note . "</td>";
                    $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . currency_format_number($line_item->product_list_price, $params) . "</td>";
                    $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . get_discount_string($line_item->discount, $line_item->product_discount, $params, $locale, $sep) . "</td>";
                    $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . currency_format_number($line_item->product_unit_price, $params) . "</td>";
                    if ($locale->getPrecision()) {
                        $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . rtrim(rtrim(format_number($line_item->vat), '0'), $sep[1]) . "%</td>";
                    } else {
                        $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . format_number($line_item->vat) . "%</td>";
                    }
                    $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . currency_format_number($line_item->vat_amt, $params) . "</td>";
                    $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . currency_format_number($line_item->product_total_price, $params) . "</td>";
                    $product .= "</tr>";
                } else {
                    if ($serviceCount == 0) {
                        $service .= "<tr>";
                        $service .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>&nbsp;</td>";
                        $service .= "<td width='46%' class='dataLabel' style='text-align: left;padding:2px;' colspan='2' scope='row'>" . $mod_strings['LBL_SERVICE_NAME'] . "</td>";
                        $service .= "<td width='12%' class='dataLabel' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_SERVICE_LIST_PRICE'] . "</td>";
                        $service .= "<td width='12%' class='dataLabel' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_SERVICE_DISCOUNT'] . "</td>";
                        $service .= "<td width='12%' class='dataLabel' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_SERVICE_PRICE'] . "</td>";
                        $service .= "<td width='12%' class='dataLabel' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_VAT'] . "</td>";
                        $service .= "<td width='12%' class='dataLabel' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_VAT_AMT'] . "</td>";
                        $service .= "<td width='12%' class='dataLabel' style='text-align: right;padding:2px;' scope='row'>" . $mod_strings['LBL_TOTAL_PRICE'] . "</td>";
                        $service .= "</tr>";
                    }
                    $service .= "<tr>";
                    $service .= "<td class='tabDetailViewDF' style='text-align: left; padding:2px;'>" . ++$serviceCount . "</td>";
                    $service .= "<td class='tabDetailViewDF' style='padding:2px;' colspan='2'>" . $line_item->name . "</td>";
                    $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . currency_format_number($line_item->product_list_price, $params) . "</td>";
                    $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . get_discount_string($line_item->discount, $line_item->product_discount, $params, $locale, $sep) . "</td>";
                    $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . currency_format_number($line_item->product_unit_price, $params) . "</td>";
                    $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . rtrim(rtrim(format_number($line_item->vat), '0'), $sep[1]) . "%</td>";
                    $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . currency_format_number($line_item->vat_amt, $params) . "</td>";
                    $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>" . currency_format_number($line_item->product_total_price, $params) . "</td>";
                    $service .= "</tr>";
                }
            }
            $html .= $groupStart . $product . $service . $groupEnd;
            $html .= "</table>";
        }
    }
    return $html;
}
Exemple #9
0
    function populateLineItems()
    {
        global $app_list_strings, $app_strings, $mod_strings;
        $vat_value = $app_list_strings['vat_list'];
        $vat_value2 = array_keys($vat_value);
        $sql = "SELECT * FROM aos_products_quotes WHERE parent_type = 'AOS_Quotes' AND parent_id = '" . $this->bean->id . "' AND deleted = 0";
        $result = $this->bean->db->query($sql);
        $countLine = $this->bean->db->getRowCount($result);
        $html = "";
        $html .= "<table border='0' width='100%' id='productLine'>";
        $html .= "<tr>";
        $html .= "<td width='15%' class='dataLabel' style='text-align: left;'>" . $mod_strings['LBL_PRODUCT_NAME'] . "</td>";
        $html .= "<td width='10%' class='dataLabel' style='text-align: left;'>Asset</td>";
        $html .= "<td width='5%' class='dataLabel' style='text-align: left;'>" . $mod_strings['LBL_UNIT_PRICE'] . "</td>";
        $html .= "<td width='5%' class='dataLabel' style='text-align: left;'>Product Rate</td>";
        $html .= "<td width='5%' class='dataLabel' style='text-align: left;'>Start Date</td>";
        $html .= "<td width='5%' class='dataLabel' style='text-align: left;'>Stop Date</td>";
        $html .= "<td width='10%' class='dataLabel' style='text-align: left;'>Notes</td>";
        $html .= "<td width='10%' class='dataLabel' style='text-align: left;'>&nbsp;</td>";
        $html .= "</tr>";
        $i = 0;
        while ($row = $this->bean->db->fetchByAssoc($result)) {
            $row['id'] = isset($_REQUEST['Duplicate']) && trim($_REQUEST['Duplicate']) == 'Duplicate' ? "" : $row['id'];
            $html .= "<tr id='product_line{$i}'>";
            $html .= "<td class='dataField'><input tabindex='3' type='text' name='product_name[]' id='product_name{$i}' size='25' maxlength='50' value='" . $row['name'] . "' title=''><input type='hidden' name='product_id[]' id='product_id{$i}' value='" . $row['product_id'] . "'>&nbsp;<input title='" . $app_strings['LBL_SELECT_BUTTON_TITLE'] . "' accessKey='" . $app_strings['LBL_SELECT_BUTTON_KEY'] . "' type='button' tabindex='3' class='button' value='" . $app_strings['LBL_SELECT_BUTTON_LABEL'] . "' name='btn1' onclick='openProductPopup({$i})'></td>";
            $html .= "<td class='dataField'><textarea tabindex='3' name='product_note[]' id='product_note{$i}' rows='1' cols='25'>" . $row['description'] . "</textarea></td>";
            $html .= "<td class='dataField'><input tabindex='3' type='text' name='product_unit_price[]' id='product_unit_price{$i}' size='10' maxlength='50' value='" . format_number($row['product_unit_price']) . "' title='' onfocus='copyListPrice({$i});' onblur='calculateProductLine({$i});'></td>";
            $html .= "<td class='dataField'><input tabindex='3' type='text' name='product_rate[]' id='product_rate{$i}' size='10' maxlength='50' value='" . $row['product_rate'] . "' title=''></td>";
            $html .= "<td class='dataField'><input tabindex='3' type='text' name='start_date[]' id='start_date{$i}' size='15' maxlength='50' value='" . substr($row['start_date'], 0, 10) . "' title=''></td>";
            $html .= "<td class='dataField'><input tabindex='3' type='text' name='stop_date[]' id='stop_date{$i}' size='15' maxlength='50' value='" . substr($row['stop_date'], 0, 10) . "' title=''></td>";
            $html .= "<td class='dataField'><textarea tabindex='3' name='product_note2[]' id='product_note2{$i}' rows='1' cols='25'>" . $row['description2'] . "</textarea></td>";
            $html .= "<td class='dataField'><input type='hidden' name='deleted[]' id='deleted{$i}' value='0'><input type='hidden' name='product_quote_id[]' value='" . $row['id'] . "'><input type='button' class='button' value='" . $mod_strings['LBL_REMOVE_PRODUCT_LINE'] . "' tabindex='3' onclick='markProductLineDeleted({$i})'></td>";
            $html .= "</tr>";
            /*
            			$html .= "<td class='dataField'>&nbsp;&nbsp;Vat&nbsp;&nbsp;%&nbsp;&nbsp; :&nbsp;&nbsp;<select name='vat[]' id='vat$i' onchange='calculateProductLine($i)'>";
            			for($j=0;$j < count($vat_value2); $j++)
            			{
            			if($row['vat']==$vat_value2[$j])
            			$html .= "<option value='".$vat_value2[$j]."' selected>".$vat_value2[$j]."</option>";
            			else
            			$html .= "<option value='".$vat_value2[$j]."'>".$vat_value2[$j]."</option>";
            			}
            			
            			
            			$html .= "</select></td>";
            */
            $html .= "<td class='dataField' colspan='5'></td>";
            $html .= "</tr>";
            $i++;
        }
        $html .= "</table>";
        $html .= "<div style='padding-top: 10px; padding-bottom:10px;'>";
        $html .= "<input type=\"button\" class=\"button\" value=\"" . $mod_strings['LBL_ADD_PRODUCT_LINE'] . "\" id=\"addProductLine\" onclick=\"insertProductLine(" . $countLine . ")\" />";
        $html .= "</div>";
        $sep = get_number_seperators();
        $html .= '<input type="hidden" name="vathidden" id="vathidden" value="' . get_select_options_with_id($vat_value, '') . '">
				  <input type="hidden" id="grp_seperator" name="grp_seperator" value="' . $sep[0] . '" />
				  <input type="hidden" id="dec_seperator" name="dec_seperator" value="' . $sep[1] . '" />
				  <input type="hidden" id="currency_symbol" name="currency_symbol" value="{CURRENCY_SYMBOL}" />';
        $this->ss->assign('LINE_ITEMS', $html);
    }
function get_worksheet_defintion($user_id, $forecast_type, $timeperiod_id, $allow_commit = false)
{
    //global variable references.
    global $current_user;
    global $current_language;
    global $app_strings;
    global $even_bg, $odd_bg;
    global $mod_strings;
    $sel_user = BeanFactory::getBean('Users', $user_id);
    $json = new JSON(JSON_LOOSE_TYPE);
    //make list view happy.
    $_REQUEST['module'] = 'Forecasts';
    $_REQUEST['action'] = 'Index';
    //initialize hierarchy helper function.
    $hhelper = new Common();
    $hhelper->set_current_user($user_id);
    $hhelper->setup();
    $seedForecastOpportunities = BeanFactory::getBean('ForecastOpportunities');
    if (strtolower($forecast_type) == 'direct') {
        require_once 'include/ListView/ListViewXTPL.php';
        require_once 'include/ListView/ListViewSmarty.php';
        $lv = new ListViewSmarty();
        $lv->lvd->additionalDetailsAjax = false;
        $lv->showMassupdateFields = false;
        $where = "opportunities.deleted=0 ";
        $where .= " AND opportunities.assigned_user_id = '{$user_id}'";
        $where .= " AND opportunities.date_closed >= timeperiods.start_date";
        $where .= " AND opportunities.date_closed <= timeperiods.end_date";
        $where .= " AND opportunities.sales_stage != '" . Opportunity::STAGE_CLOSED_LOST . "'";
        $where .= " AND timeperiods.id = '{$timeperiod_id}'";
        $hhelper->get_timeperiod_start_end_date($timeperiod_id);
        $seedForecastOpportunities->current_user_id = $user_id;
        $seedForecastOpportunities->current_timeperiod_id = $timeperiod_id;
        //set forecast owner details.
        $seedForecastOpportunities->fo_user_id = $current_user->id;
        $seedForecastOpportunities->fo_timeperiod_id = $timeperiod_id;
        //use the current users' forecsat type is allow commit is set.
        //this allows for seprate worksheets for same user on one page.
        if ($allow_commit) {
            $seedForecastOpportunities->fo_forecast_type = $forecast_type;
        } else {
            $seedForecastOpportunities->fo_forecast_type = 'Rollup';
        }
        $opp_summary = $seedForecastOpportunities->get_opportunity_summary();
        //build the summary information. do not show it if the logged in current view user is not the logged in
        //user.
        $directsummary = "";
        if ($allow_commit && $user_id == $current_user->id && ACLController::checkAccess('Forecasts', 'edit', true)) {
            $lv->ss->assign("commit_allowed", 'true');
        }
        $lv->ss->assign("CURRENCY_SYMBOL", $seedForecastOpportunities->currency->symbol);
        $prev_commit = $seedForecastOpportunities->get_last_committed_direct_forecast();
        $lv->ss->assign("PREV_COMMIT_DATE", $prev_commit['DATE_ENTERED']);
        $lv->ss->assign("PREV_BEST_CASE", $prev_commit['BEST_CASE']);
        $lv->ss->assign("PREV_LIKELY_CASE", $prev_commit['LIKELY_CASE']);
        $lv->ss->assign("PREV_WORST_CASE", $prev_commit['WORST_CASE']);
        $totals = array('NAME' => translate('LBL_TOTAL_VALUE', 'Forecasts'), 'REVENUE' => $opp_summary['TOTAL_AMOUNT'], 'PROBABILITY' => '&nbsp;', 'WEIGHTED_VALUE' => $opp_summary['WEIGHTEDVALUE'], 'WK_BEST_CASE' => $opp_summary['TOTAL_WK_BEST_CASE'], 'WK_LIKELY_CASE' => $opp_summary['TOTAL_WK_LIKELY_CASE'], 'WK_WORST_CASE' => $opp_summary['TOTAL_WK_WORST_CASE']);
        $lv->ss->assign("totals", $totals);
        $lv->ss->assign("COPY_LINK", buildExportLink('direct'));
        $lv->ss->assign("USER_ID", $current_user->id);
        $lv->ss->assign("TIMEPERIOD_ID", $timeperiod_id);
        if ($allow_commit) {
            $lv->ss->assign("FORECASTTYPE", $forecast_type);
            //top level forecast type.
        } else {
            $lv->ss->assign("FORECASTTYPE", 'Rollup');
            //top level forecast type.
        }
        //set current users forecast  details into the form.
        $lv->ss->assign("SEL_USER_ID", $user_id);
        $lv->ss->assign("SEL_TIMEPERIOD_ID", $timeperiod_id);
        $lv->ss->assign("SEL_FORECASTTYPE", $forecast_type);
        //assign opp count and total weighted amount.
        $lv->ss->assign("CURRENTOPPORTUNITYCOUNT", $opp_summary['OPPORTUNITYCOUNT']);
        $lv->ss->assign("CURRENTWEIGHTEDVALUENUMBER", $opp_summary['WEIGHTEDVALUENUMBER']);
        //assign the qota amount.
        $lv->ss->assign("QUOTA_VALUE", $seedForecastOpportunities->get_quota());
        global $listViewDefs;
        include 'modules/Forecasts/metadata/listviewdefs.php';
        $lv->displayColumns = $listViewDefs['ForecastOpportunities'];
        //disable some features.
        $lv->multiSelect = false;
        $lv->export = false;
        $lv->delete = false;
        $lv->select = false;
        $lv->show_mass_update_form = false;
        $lv->setup($seedForecastOpportunities, 'modules/Forecasts/ListViewForecast.tpl', $where);
    } else {
        //create where clause....
        if (user_owns_opps($user_id, null)) {
            $where = " users.deleted=0 ";
            $where .= " AND (users.id = '{$user_id}'";
            $where .= " or users.reports_to_id = '{$user_id}')";
        } else {
            $where = " users.deleted=0 ";
            $where .= " AND users.reports_to_id = '{$user_id}'";
        }
        $hhelper->get_timeperiod_start_end_date($timeperiod_id);
        //Get the forecasts created by the direct reports.
        $DirReportsFocus = new ForecastDirectReports();
        $DirReportsFocus->current_user_id = $user_id;
        $DirReportsFocus->current_timeperiod_id = $timeperiod_id;
        //list totals.
        $DirReportsFocus->compute_rollup_totals('', $where);
        //create totals array for all field in the list view.
        ///user_name, opportunities, weighted amount, committed amount, Date committed, Adjusted amount
        $totals = array('USER_NAME' => $mod_strings['LBL_TOTAL_VALUE'], 'BEST_CASE' => $DirReportsFocus->total_best_case_number, 'LIKELY_CASE' => $DirReportsFocus->total_likely_case_number, 'WORST_CASE' => $DirReportsFocus->total_worst_case_number, 'DATE_COMMITTED' => '&nbsp;', 'WK_BEST_CASE' => $DirReportsFocus->total_wk_best_case_number, 'WK_LIKELY_CASE' => $DirReportsFocus->total_wk_likely_case_number, 'WK_WORST_CASE' => $DirReportsFocus->total_wk_worst_case_number);
        //build list view contents.
        if (ACLController::checkAccess('Forecasts', 'list', true)) {
            require_once 'include/ListView/ListViewXTPL.php';
            require_once 'include/ListView/ListViewSmarty.php';
            $lv = new ListViewSmarty();
            $lv->lvd->additionalDetailsAjax = false;
            global $listViewDefs;
            include 'modules/Forecasts/metadata/listviewdefs.php';
            $lv->displayColumns = $listViewDefs['ForecastDirectReports'];
            //disable some features.
            $lv->multiSelect = false;
            $lv->delete = false;
            $lv->select = false;
            $lv->export = false;
            $lv->show_mass_update_form = false;
            $lv->setup($DirReportsFocus, 'modules/Forecasts/ListViewForecast.tpl', $where);
            //assign logged in user's forecast details.
            //this is for user who owns the forecast.
            $lv->ss->assign("USER_ID", $current_user->id);
            $lv->ss->assign("TIMEPERIOD_ID", $timeperiod_id);
            $lv->ss->assign("FORECASTTYPE", 'Rollup');
            //top level forecast type.
            //set current users forecast  details into the form.
            $lv->ss->assign("SEL_USER_ID", $user_id);
            $lv->ss->assign("SEL_TIMEPERIOD_ID", $timeperiod_id);
            $lv->ss->assign("SEL_FORECASTTYPE", $forecast_type);
            //commit allowed for this user.
            if ($allow_commit && $user_id == $current_user->id && ACLController::checkAccess('Forecasts', 'edit', true)) {
                $lv->ss->assign("commit_allowed", 'true');
                $lv->ss->assign("COPY_LINK", buildExportLink('rollup'));
            }
            $prev_commit = $DirReportsFocus->get_last_committed_forecast();
            $lv->ss->assign("PREV_COMMIT_DATE", $prev_commit['DATE_ENTERED']);
            $lv->ss->assign("PREV_BEST_CASE", $prev_commit['BEST_CASE']);
            $lv->ss->assign("PREV_LIKELY_CASE", $prev_commit['LIKELY_CASE']);
            $lv->ss->assign("PREV_WORST_CASE", $prev_commit['WORST_CASE']);
            $lv->ss->assign("totals", $totals);
        }
        $lv->ss->assign("CURRENCY_SYMBOL", $DirReportsFocus->currency->symbol);
        $lv->ss->assign("CURRENTOPPORTUNITYCOUNT", $DirReportsFocus->total_opp_count);
        $lv->ss->assign("CURRENTWEIGHTEDVALUENUMBER", $DirReportsFocus->total_weigh_value_number);
        //assign the qota amount.
        $lv->ss->assign("QUOTA_VALUE", $DirReportsFocus->get_quota());
    }
    //process page urls.
    if (isset($lv->data['pageData']['urls']['endPage'])) {
        $lv->ss->assign("endPageJSON", processnavigation($lv->data['pageData']['urls']['endPage'], $json));
        $lv->data['pageData']['urls']['endPage'] = 'javascript:goToNav(3)';
    }
    if (isset($lv->data['pageData']['urls']['startPage'])) {
        $lv->ss->assign("startPageJSON", processnavigation($lv->data['pageData']['urls']['startPage'], $json));
        $lv->data['pageData']['urls']['startPage'] = 'javascript:goToNav(0)';
    }
    if (isset($lv->data['pageData']['urls']['nextPage'])) {
        $lv->ss->assign("nextPageJSON", processnavigation($lv->data['pageData']['urls']['nextPage'], $json));
        $lv->data['pageData']['urls']['nextPage'] = 'javascript:goToNav(2)';
    }
    if (isset($lv->data['pageData']['urls']['prevPage'])) {
        $lv->ss->assign("prevPageJSON", processnavigation($lv->data['pageData']['urls']['prevPage'], $json));
        $lv->data['pageData']['urls']['prevPage'] = 'javascript:goToNav(1)';
    }
    //process display columns
    $orderby_array = processnavigation($lv->data['pageData']['urls']['orderBy']);
    //{$pageData.urls.orderBy}{$params.orderBy|default:$colHeader|lower}'
    foreach ($lv->displayColumns as $key => $values) {
        if (!empty($values['orderBy'])) {
            $orderby_array[$lv->lvd->var_order_by] = strtolower($values['orderBy']);
        } else {
            if (!empty($values['tablename'])) {
                $orderby_array[$lv->lvd->var_order_by] = $values['tablename'] . '.' . strtolower($key);
            } else {
                $orderby_array[$lv->lvd->var_order_by] = strtolower($key);
            }
        }
        $lv->displayColumns[$key]['order_by_object'] = $json->encode($orderby_array);
    }
    $lv->ss->assign('displayColumns', $lv->displayColumns);
    //assign label values to the template.
    $lv->ss->assign("LBL_DV_LAST_COMMIT_DATE", $mod_strings['LBL_DV_LAST_COMMIT_DATE']);
    $lv->ss->assign("LBL_DV_LAST_COMMIT_AMOUNT", $mod_strings['LBL_DV_LAST_COMMIT_AMOUNT']);
    $lv->ss->assign("LBL_COMMIT_NOTE", $mod_strings['LBL_COMMIT_NOTE']);
    $lv->ss->assign("LBL_QC_COMMIT_BUTTON", $mod_strings['LBL_QC_COMMIT_BUTTON']);
    $lv->ss->assign("LBL_SAVE_WOKSHEET", $mod_strings['LBL_SAVE_WOKSHEET']);
    $lv->ss->assign("LBL_RESET_WOKSHEET", $mod_strings['LBL_RESET_WOKSHEET']);
    $lv->ss->assign("LBL_RESET_CHECK", $mod_strings['LBL_RESET_CHECK']);
    $lv->ss->assign("LBL_BEST_CASE", $mod_strings['LBL_BEST_CASE']);
    $lv->ss->assign("LBL_LIKELY_CASE", $mod_strings['LBL_LIKELY_CASE']);
    $lv->ss->assign("LBL_WORST_CASE", $mod_strings['LBL_WORST_CASE']);
    $lv->ss->assign("ERR_FORECAST_AMOUNT", $mod_strings['ERR_FORECAST_AMOUNT']);
    $lv->ss->assign("LBL_COMMIT_MESSAGE", $mod_strings['LBL_COMMIT_MESSAGE']);
    $lv->ss->assign("LBL_SHOW_CHART", $mod_strings['LBL_SHOW_CHART']);
    $lv->ss->assign("LBL_FORECAST_FOR", $mod_strings['LBL_FORECAST_FOR']);
    //
    $seps = get_number_seperators();
    $lv->ss->assign("NUM_GRP_SEP", $seps[0]);
    $lv->ss->assign("DEC_SEP", $seps[1]);
    $forecast_for = $sel_user->name . " ";
    if (strtolower($forecast_type) == 'direct') {
        $forecast_for .= $mod_strings['LBL_FMT_DIRECT_FORECAST'];
    } else {
        $forecast_for .= $mod_strings['LBL_FMT_ROLLUP_FORECAST'];
    }
    $lv->ss->assign("USER_FORECAST_TYPE", $forecast_for);
    $lv->ss->assign("LBL_TP_QUOTA", $mod_strings['LBL_TP_QUOTA']);
    $contents = $lv->display(false);
    echo $contents;
}
 public function setupAll($showTitle = false, $ajaxSave = false, $moduleName = '', $readonly = false)
 {
     global $mod_strings, $sugar_config, $app_strings, $app_list_strings, $theme, $current_user;
     if (isset($this->defs['templateMeta']['javascript'])) {
         if (is_array($this->defs['templateMeta']['javascript'])) {
             $this->th->ss->assign('externalJSFile', $this->defs['templateMeta']['javascript']);
         } else {
             $this->th->ss->assign('scriptBlocks', $this->defs['templateMeta']['javascript']);
         }
     }
     $this->setupOriginalEditView();
     $this->th->ss->assign('id', $this->fieldDefs['id']['value']);
     $this->th->ss->assign('offset', $this->offset + 1);
     $this->th->ss->assign('APP', $app_strings);
     $this->th->ss->assign('MOD', $mod_strings);
     $this->th->ss->assign('footerTpl', isset($this->defs['templateMeta']['form']['footerTpl']) ? $this->defs['templateMeta']['form']['footerTpl'] : null);
     $this->fieldDefs = $this->setDefaultAllFields($this->fieldDefs);
     // default editview
     if ($readonly) {
         $this->fieldDefs = $this->setReadOnlyAllFields($this->fieldDefs);
     } else {
         $this->fieldDefs = $this->processReadOnlyFields($this->fieldDefs);
         $this->fieldDefs = $this->processRequiredFields($this->fieldDefs);
     }
     $this->th->ss->assign('fields', $this->fieldDefs);
     $this->sectionPanels = $this->processSectionPanels($this->sectionPanels);
     $this->th->ss->assign('sectionPanels', $this->sectionPanels);
     $this->th->ss->assign('config', $sugar_config);
     $this->th->ss->assign('returnModule', $this->returnModule);
     $this->th->ss->assign('returnAction', $this->returnAction);
     $this->th->ss->assign('returnId', $this->returnId);
     $this->th->ss->assign('isDuplicate', $this->isDuplicate);
     $this->th->ss->assign('def', $this->defs);
     $this->th->ss->assign('useTabs', isset($this->defs['templateMeta']['useTabs']) && isset($this->defs['templateMeta']['tabDefs']) ? $this->defs['templateMeta']['useTabs'] : false);
     $this->th->ss->assign('maxColumns', isset($this->defs['templateMeta']['maxColumns']) ? $this->defs['templateMeta']['maxColumns'] : 2);
     $this->th->ss->assign('module', $moduleName);
     $this->th->ss->assign('current_user', $current_user);
     $this->th->ss->assign('bean', $this->focus);
     $this->th->ss->assign('gridline', $current_user->getPreference('gridline') == 'on' ? '1' : '0');
     $this->th->ss->assign('tabDefs', isset($this->defs['templateMeta']['tabDefs']) ? $this->defs['templateMeta']['tabDefs'] : false);
     $this->th->ss->assign('VERSION_MARK', getVersionedPath(''));
     if (isset($this->relationshipChart[$moduleName])) {
         foreach ($this->relationshipChart[$moduleName] as $relName => $ssName) {
             $this->bean->load_relationship($relName);
             $tempBeanList = $this->bean->{$relName}->getBeans();
             $this->th->ss->assign($ssName, $tempBeanList);
         }
     }
     global $js_custom_version;
     global $sugar_version;
     $this->th->ss->assign('SUGAR_VERSION', $sugar_version);
     $this->th->ss->assign('JS_CUSTOM_VERSION', $js_custom_version);
     //this is used for multiple forms on one page
     if (!empty($this->formName)) {
         $form_id = $this->formName;
         $form_name = $this->formName;
     } else {
         $form_id = $this->view;
         $form_name = $this->view;
     }
     if ($ajaxSave && empty($this->formName)) {
         $form_id = 'form_' . $this->view . '_' . $moduleName;
         $form_name = $form_id;
         $this->view = $form_name;
     }
     $form_name = $form_name == 'QuickCreate' ? "QuickCreate_{$moduleName}" : $form_name;
     $form_id = $form_id == 'QuickCreate' ? "QuickCreate_{$moduleName}" : $form_id;
     if (isset($this->defs['templateMeta']['preForm'])) {
         $this->th->ss->assign('preForm', $this->defs['templateMeta']['preForm']);
     }
     if (isset($this->defs['templateMeta']['form']['closeFormBeforeCustomButtons'])) {
         $this->th->ss->assign('closeFormBeforeCustomButtons', $this->defs['templateMeta']['form']['closeFormBeforeCustomButtons']);
     }
     if (isset($this->defs['templateMeta']['form']['enctype'])) {
         $this->th->ss->assign('enctype', 'enctype="' . $this->defs['templateMeta']['form']['enctype'] . '"');
     }
     //for SugarFieldImage, we must set form enctype to "multipart/form-data"
     foreach ($this->fieldDefs as $field) {
         if (isset($field['type']) && $field['type'] == 'image') {
             $this->th->ss->assign('enctype', 'enctype="multipart/form-data"');
             break;
         }
     }
     $this->th->ss->assign('showDetailData', $this->showDetailData);
     $this->th->ss->assign('showSectionPanelsTitles', $this->showSectionPanelsTitles);
     $this->th->ss->assign('form_id', $form_id);
     $this->th->ss->assign('form_name', $form_name);
     //$form_name change by id form showCaseForm
     $this->th->ss->assign('set_focus_block', get_set_focus_js());
     $this->th->ss->assign('form', isset($this->defs['templateMeta']['form']) ? $this->defs['templateMeta']['form'] : null);
     $this->th->ss->assign('includes', isset($this->defs['templateMeta']['includes']) ? $this->defs['templateMeta']['includes'] : null);
     $this->th->ss->assign('view', $this->view);
     $admin = new Administration();
     $admin->retrieveSettings();
     if (isset($admin->settings['portal_on']) && $admin->settings['portal_on']) {
         $this->th->ss->assign("PORTAL_ENABLED", true);
     } else {
         $this->th->ss->assign("PORTAL_ENABLED", false);
     }
     //Calculate time & date formatting (may need to calculate this depending on a setting)
     global $timedate;
     $this->th->ss->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format());
     $this->th->ss->assign('USER_DATEFORMAT', $timedate->get_user_date_format());
     $time_format = $timedate->get_user_time_format();
     $this->th->ss->assign('TIME_FORMAT', $time_format);
     $date_format = $timedate->get_cal_date_format();
     $time_separator = ':';
     if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) {
         $time_separator = $match[1];
     }
     // Create Smarty variables for the Calendar picker widget
     $t23 = strpos($time_format, '23') !== false ? '%H' : '%I';
     if (!isset($match[2]) || $match[2] == '') {
         $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M');
     } else {
         $pm = $match[2] == 'pm' ? '%P' : '%p';
         $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M' . $pm);
     }
     $this->th->ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week());
     $this->th->ss->assign('TIME_SEPARATOR', $time_separator);
     $seps = get_number_seperators();
     $this->th->ss->assign('NUM_GRP_SEP', $seps[0]);
     $this->th->ss->assign('DEC_SEP', $seps[1]);
     if ($this->view == 'EditView' || $this->view == 'BpmView') {
         $height = $current_user->getPreference('text_editor_height');
         $width = $current_user->getPreference('text_editor_width');
         $height = isset($height) ? $height : '300px';
         $width = isset($width) ? $width : '95%';
         $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height);
         $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width);
     } else {
         $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px');
         $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%');
     }
     $this->th->ss->assign('SHOW_VCR_CONTROL', $this->showVCRControl);
     $str = $this->showTitle($showTitle);
     $ajaxSave = false;
     //Use the output filter to trim the whitespace
     $this->th->ss->load_filter('output', 'trimwhitespace');
     $form_name = $this->view;
     if ($this->th->checkTemplate($this->bean->module_name, $this->view) && !empty($this->dyn_uid)) {
         $nameTemplateTmp = $this->dyn_uid;
     } else {
         $nameTemplateTmp = 'PMSEDetailView';
     }
     $this->th->buildTemplate($this->bean->module_name, $nameTemplateTmp, $this->tpl, $ajaxSave, $this->defs);
     $this->th->deleteTemplate($this->bean->module_name, $form_name);
     $newTplFile = $this->th->cacheDir . $this->th->templateDir . $this->bean->module_name . '/' . $nameTemplateTmp . '.tpl';
     $str .= $this->th->ss->fetch($newTplFile);
     return $str;
 }
Exemple #12
0
 public function tearDown()
 {
     global $sugar_config;
     $this->currency_system->symbol = $this->backupSymbol;
     $this->currency_system->save(false);
     $sugar_config['default_currency_symbol'] = $this->backupSymbol;
     format_number(0, 0, 0, array('currency_id' => $this->currency_51568->id, 'currency_symbol' => $this->currency_51568->symbol));
     format_number(0, 0, 0, array('currency_id' => -99, 'currency_symbol' => $this->currency_51568->getDefaultCurrencySymbol()));
     $this->currency_51568->mark_deleted($this->currency_51568->id);
     SugarTestHelper::tearDown();
     get_number_seperators(true);
 }
Exemple #13
0
 /**
  * @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>';
 }
 public function testget_number_seperators()
 {
     $this->assertEquals(array(',', '.'), get_number_seperators());
     $this->assertEquals(array(',', '.'), get_number_seperators(false));
 }
 function parse_template_bean($string, $bean_name, &$focus)
 {
     global $app_strings, $module;
     $repl_arr = array();
     foreach ($focus->field_defs as $field_def) {
         if ($field_def['type'] == 'enum' && isset($field_def['options'])) {
             $translated = translate($field_def['options'], $bean_name, $focus->{$field_def}['name']);
             if (isset($translated) && !is_array($translated)) {
                 $repl_arr[strtolower($focus->module_dir) . "_" . $field_def['name']] = $translated;
             } else {
                 // unset enum field, make sure we have a match string to replace with ""
                 $repl_arr[strtolower($focus->module_dir) . "_" . $field_def['name']] = '';
             }
         } elseif ($field_def['type'] == 'currency') {
             //Custom kiem tra kieu currency
             $repl_arr[strtolower($focus->module_dir) . "_" . $field_def['name']] = number_format($focus->{$field_def}['name'], '2', '.', '');
         } else {
             $repl_arr[strtolower($focus->module_dir) . "_" . $field_def['name']] = $focus->{$field_def}['name'];
         }
     }
     // end foreach()
     krsort($repl_arr);
     reset($repl_arr);
     foreach ($repl_arr as $name => $value) {
         if (strpos($name, 'amt') > 0 || strpos($name, 'amount') > 0 || strpos($name, 'price') > 0) {
             $value = currency_format_number($value, $params = array('currency_symbol' => false));
         } else {
             if (strpos($name, 'product_discount') > 0) {
                 if ($value != '' && $value != '0.00') {
                     if ($repl_arr[aos_products_quotes_discount] == 'Percentage') {
                         $sep = get_number_seperators();
                         $value = trim(trim(currency_format_number($value, $params = array('currency_symbol' => false)), '0'), $sep[1]) . $app_strings['LBL_PERCENTAGE_SYMBOL'];
                     } else {
                         $value = currency_format_number($value, $params = array('currency_symbol' => false));
                     }
                 } else {
                     $value = '';
                 }
             }
         }
         if ($name === 'aos_products_quotes_vat' || strpos($name, 'pct') > 0 || strpos($name, 'percent') > 0 || strpos($name, 'percentage') > 0) {
             $sep = get_number_seperators();
             $value = trim(trim(currency_format_number($value, $params = array('currency_symbol' => false)), '0'), $sep[1]) . $app_strings['LBL_PERCENTAGE_SYMBOL'];
         }
         // Kiem tra kieu ngay
         $fieldsname = explode('_', $name, 2);
         if (strpos($fieldsname[1], 'date') > 0 || strpos($fieldsname[1], 'expiration') > 0) {
             if ($value != '') {
                 $dt = explode(' ', $value);
                 $value = $dt[0];
             }
         }
         if ($value != '' && is_string($value)) {
             $string = str_replace("\${$name}", $value, $string);
         } else {
             if (strpos($name, 'address') > 0) {
                 $string = str_replace("\${$name}<br />", '', $string);
                 $string = str_replace("\${$name} <br />", '', $string);
                 $string = str_replace("\${$name}", '', $string);
             } else {
                 $string = str_replace("\${$name}", '&nbsp;', $string);
             }
         }
     }
     return $string;
 }
Exemple #16
0
/**
 * @param $string
 * @param bool $useBaseCurrency default user locale
 * @return float|string
 */
function unformat_number($string, $useBaseCurrency = false)
{
    static $currency = null;
    if (!isset($currency)) {
        global $current_user;
        if (!$useBaseCurrency && !empty($current_user->id)) {
            $currency_id = $current_user->getPreference('currency');
        }
        if (empty($currency_id)) {
            $currency_id = '-99';
        }
        $currency = BeanFactory::getBean('Currencies', $currency_id);
    }
    $seps = get_number_seperators();
    // remove num_grp_sep and replace decimal separator with decimal
    $string = trim(str_replace(array($seps[0], $seps[1], $currency->symbol), array('', '.', ''), $string));
    if (preg_match('/^[+-]?\\d(\\.\\d+)?[Ee]([+-]?\\d+)?$/', $string)) {
        $string = sprintf("%.0f", $string);
    }
    //for scientific number format. After round(), we may get this number type.
    preg_match('/[\\-\\+]?[0-9\\.]*/', $string, $string);
    $out_number = trim($string[0]);
    if ($out_number == '') {
        return '';
    } else {
        return (double) $out_number;
    }
}
function getProductOptionsHtml($focus, $name, $value, $view)
{
    if ('EditView' != $view && 'DetailView' != $view) {
        return "";
        // skip the rest of the method if another view calls this method
    }
    global $app_list_strings;
    global $mod_strings;
    global $locale;
    $smarty = new Sugar_Smarty();
    // setup the popups link
    $popup_request_data = array('call_back_function' => 'popup_return_option', 'formName' => 'EditView', 'field_to_name_array' => array("price" => "price", "is_recurring" => "is_recurring", "version" => "version", "name" => "name", "id" => "id", "status" => "status", "date_modified" => "date_modified", "modified_by_name" => "modified_by_name", "currency_id" => "currency_id"), 'passthru_data' => array());
    $json = getJSONobj();
    $encoded_request_data = $json->encode($popup_request_data);
    //$languageStrings = array_merge($app_list_strings["oqc"]["ProductOptions"], $mod_strings);
    $languageStrings = $json->encode($app_list_strings["oqc"]["ProductOptions"]);
    //2.2RC get product currency
    if (isset($focus->currency_id) && $focus->currency_id != '') {
        $currentCurrency = new Currency();
        $currentCurrency->retrieve($focus->currency_id);
        $currencySymbol = $currentCurrency->symbol;
        $current_ratio = $currentCurrency->conversion_rate;
        $current_id = $currentCurrency->id;
    } else {
        $currencySymbol = $locale->getPrecedentPreference('default_currency_symbol');
        $current_ratio = 1;
        $current_id = '-99';
    }
    $currencyScript = option_configureCurrencyVariables();
    if (isset($focus->optionssequence)) {
        $c = get_all_linked_product_options($focus);
        $smarty->assign('productOptions', buildProductOptionsArray($c, $current_id, $current_ratio));
    } else {
        $smarty->assign('productOptions', array());
    }
    $sep = get_number_seperators();
    $smarty->assign('currencySymbol', $currencySymbol);
    $smarty->assign('current_rate', $current_ratio);
    $smarty->assign('current_id', $current_id);
    $smarty->assign('optionCurrencyJavascript', $currencyScript);
    $smarty->assign('thousandsSeparator', $sep[0]);
    $smarty->assign('decimalSeparator', $sep[1]);
    $smarty->assign('moduleName', 'oqc_Product');
    $smarty->assign('languageStringsProductOptions', $languageStrings);
    $smarty->assign('addOption', $app_list_strings["oqc"]["ProductOptions"]['add']);
    $smarty->assign($mod_strings);
    $smarty->assign('options_popup_encoded_request_data', $encoded_request_data);
    //	$smarty->assign('create_popup_encoded_request_data', $encoded_request_data);
    //	$smarty->assign('upload_revision_encoded_request_data', $encoded_revision_request_data);
    $smarty->assign('initialFilter', "\"&is_option=1\"");
    return $smarty->fetch('include/oqc/ProductOptions/' . $view . '.html');
}
 public function tearDown()
 {
     SugarTestHelper::tearDown();
     get_number_seperators(true);
 }
 function parse_template_bean($string, $key, &$focus)
 {
     global $app_strings;
     $repl_arr = array();
     foreach ($focus->field_defs as $field_def) {
         if ($field_def['type'] == 'currency') {
             $repl_arr[$key . "_" . $field_def['name']] = currency_format_number($focus->{$field_def}['name'], $params = array('currency_symbol' => false));
         } else {
             if ($field_def['type'] == 'enum' && isset($field_def['options'])) {
                 $repl_arr[$key . "_" . $field_def['name']] = translate($field_def['options'], $focus->module_dir, $focus->{$field_def}['name']);
             } else {
                 if ($field_def['type'] == 'multienum' && isset($field_def['options'])) {
                     $repl_arr[$key . "_" . $field_def['name']] = implode(', ', unencodeMultienum($focus->{$field_def}['name']));
                 } else {
                     $repl_arr[$key . "_" . $field_def['name']] = $focus->{$field_def}['name'];
                 }
             }
         }
     }
     // end foreach()
     krsort($repl_arr);
     reset($repl_arr);
     foreach ($repl_arr as $name => $value) {
         if (strpos($name, 'product_discount') > 0) {
             if ($value != '' && $value != '0.00') {
                 if ($repl_arr['aos_products_quotes_discount'] == 'Percentage') {
                     $sep = get_number_seperators();
                     $value = rtrim(rtrim(format_number($value), '0'), $sep[1]);
                     //.$app_strings['LBL_PERCENTAGE_SYMBOL'];
                 } else {
                     $value = currency_format_number($value, $params = array('currency_symbol' => false));
                 }
             } else {
                 $value = '';
             }
         }
         if ($name === 'aos_products_product_image') {
             $value = '<img src="' . $value . '"width="50" height="50"/>';
         }
         if ($name === 'aos_products_quotes_product_qty') {
             $sep = get_number_seperators();
             $value = rtrim(rtrim(format_number($value), '0'), $sep[1]);
         }
         if ($name === 'aos_products_quotes_vat' || strpos($name, 'pct') > 0 || strpos($name, 'percent') > 0 || strpos($name, 'percentage') > 0) {
             $sep = get_number_seperators();
             $value = rtrim(rtrim(format_number($value), '0'), $sep[1]) . $app_strings['LBL_PERCENTAGE_SYMBOL'];
         }
         if (strpos($name, 'date') > 0 || strpos($name, 'expiration') > 0) {
             if ($value != '') {
                 $dt = explode(' ', $value);
                 $value = $dt[0];
             }
         }
         if ($value != '' && is_string($value)) {
             $string = str_replace("\${$name}", $value, $string);
         } else {
             if (strpos($name, 'address') > 0) {
                 $string = str_replace("\${$name}<br />", '', $string);
                 $string = str_replace("\${$name} <br />", '', $string);
                 $string = str_replace("\${$name}", '', $string);
             } else {
                 $string = str_replace("\${$name}", '&nbsp;', $string);
             }
         }
     }
     return $string;
 }
Exemple #20
0
function unformat_number($string)
{
    static $currency = null;
    if (!isset($currency)) {
        global $current_user;
        $currency = new Currency();
        if ($current_user->getPreference('currency')) {
            $currency->retrieve($current_user->getPreference('currency'));
        } else {
            $currency->retrieve('-99');
        }
        // use default if none set
    }
    $seps = get_number_seperators();
    // remove num_grp_sep and replace decimal seperater with decimal
    $string = trim(str_replace(array($seps[0], $seps[1], $currency->symbol), array('', '.', ''), $string));
    if (preg_match('/^[+-]?\\d(\\.\\d+)?[Ee]([+-]?\\d+)?$/', $string)) {
        $string = sprintf("%.0f", $string);
    }
    //for scientific number format. After round(), we may get this number type.
    preg_match('/[\\-\\+]?[0-9\\.]*/', $string, $string);
    return trim($string[0]);
}
Exemple #21
0
    /**
     * display
     * This method makes the Smarty variable assignments and then displays the
     * generated view.
     * @param $showTitle boolean value indicating whether or not to show a title on the resulting page
     * @param $ajaxSave boolean value indicating whether or not the operation is an Ajax save request
     * @return HTML display for view as String
     */
    function display($showTitle = true, $ajaxSave = false)
    {
        global $mod_strings, $sugar_config, $app_strings, $app_list_strings, $theme, $current_user;
        if (isset($this->defs['templateMeta']['javascript'])) {
            if (is_array($this->defs['templateMeta']['javascript'])) {
                //$this->th->ss->assign('externalJSFile', 'modules/' . $this->module . '/metadata/editvewdefs.js');
                $this->th->ss->assign('externalJSFile', $this->defs['templateMeta']['javascript']);
            } else {
                $this->th->ss->assign('scriptBlocks', $this->defs['templateMeta']['javascript']);
            }
        }
        $this->th->ss->assign('id', $this->fieldDefs['id']['value']);
        $this->th->ss->assign('offset', $this->offset + 1);
        $this->th->ss->assign('APP', $app_strings);
        $this->th->ss->assign('MOD', $mod_strings);
        $this->th->ss->assign('fields', $this->fieldDefs);
        $this->th->ss->assign('sectionPanels', $this->sectionPanels);
        $this->th->ss->assign('config', $sugar_config);
        $this->th->ss->assign('returnModule', $this->returnModule);
        $this->th->ss->assign('returnAction', $this->returnAction);
        $this->th->ss->assign('returnId', $this->returnId);
        $this->th->ss->assign('isDuplicate', $this->isDuplicate);
        $this->th->ss->assign('def', $this->defs);
        $this->th->ss->assign('useTabs', isset($this->defs['templateMeta']['useTabs']) && isset($this->defs['templateMeta']['tabDefs']) ? $this->defs['templateMeta']['useTabs'] : false);
        $this->th->ss->assign('maxColumns', isset($this->defs['templateMeta']['maxColumns']) ? $this->defs['templateMeta']['maxColumns'] : 2);
        $this->th->ss->assign('module', $this->module);
        $this->th->ss->assign('headerTpl', isset($this->defs['templateMeta']['form']['headerTpl']) ? $this->defs['templateMeta']['form']['headerTpl'] : 'include/' . $this->view . '/header.tpl');
        $this->th->ss->assign('footerTpl', isset($this->defs['templateMeta']['form']['footerTpl']) ? $this->defs['templateMeta']['form']['footerTpl'] : 'include/' . $this->view . '/footer.tpl');
        $this->th->ss->assign('current_user', $current_user);
        $this->th->ss->assign('bean', $this->focus);
        $this->th->ss->assign('isAuditEnabled', $this->focus->is_AuditEnabled());
        $this->th->ss->assign('gridline', $current_user->getPreference('gridline') == 'on' ? '1' : '0');
        $this->th->ss->assign('tabDefs', isset($this->defs['templateMeta']['tabDefs']) ? $this->defs['templateMeta']['tabDefs'] : false);
        $this->th->ss->assign('VERSION_MARK', getVersionedPath(''));
        global $js_custom_version;
        global $sugar_version;
        $this->th->ss->assign('SUGAR_VERSION', $sugar_version);
        $this->th->ss->assign('JS_CUSTOM_VERSION', $js_custom_version);
        //this is used for multiple forms on one page
        if (!empty($this->formName)) {
            $form_id = $this->formName;
            $form_name = $this->formName;
        } else {
            $form_id = $this->view;
            $form_name = $this->view;
        }
        if ($ajaxSave && empty($this->formName)) {
            $form_id = 'form_' . $this->view . '_' . $this->module;
            $form_name = $form_id;
            $this->view = $form_name;
            //$this->defs['templateMeta']['form']['buttons'] = array();
            //$this->defs['templateMeta']['form']['buttons']['ajax_save'] = array('id' => 'AjaxSave', 'customCode'=>'<input type="button" class="button" value="Save" onclick="this.form.action.value=\'AjaxFormSave\';return saveForm(\''.$form_name.'\', \'multiedit_form_{$module}\', \'Saving {$module}...\');"/>');
        }
        $form_name = $form_name == 'QuickCreate' ? "QuickCreate_{$this->module}" : $form_name;
        $form_id = $form_id == 'QuickCreate' ? "QuickCreate_{$this->module}" : $form_id;
        if (isset($this->defs['templateMeta']['preForm'])) {
            $this->th->ss->assign('preForm', $this->defs['templateMeta']['preForm']);
        }
        if (isset($this->defs['templateMeta']['form']['closeFormBeforeCustomButtons'])) {
            $this->th->ss->assign('closeFormBeforeCustomButtons', $this->defs['templateMeta']['form']['closeFormBeforeCustomButtons']);
        }
        if (isset($this->defs['templateMeta']['form']['enctype'])) {
            $this->th->ss->assign('enctype', 'enctype="' . $this->defs['templateMeta']['form']['enctype'] . '"');
        }
        //for SugarFieldImage, we must set form enctype to "multipart/form-data"
        foreach ($this->fieldDefs as $field) {
            if (isset($field['type']) && $field['type'] == 'image') {
                $this->th->ss->assign('enctype', 'enctype="multipart/form-data"');
                break;
            }
        }
        $this->th->ss->assign('showDetailData', $this->showDetailData);
        $this->th->ss->assign('showSectionPanelsTitles', $this->showSectionPanelsTitles);
        $this->th->ss->assign('form_id', $form_id);
        $this->th->ss->assign('form_name', $form_name);
        $this->th->ss->assign('set_focus_block', get_set_focus_js());
        $this->th->ss->assign('form', isset($this->defs['templateMeta']['form']) ? $this->defs['templateMeta']['form'] : null);
        $this->th->ss->assign('includes', isset($this->defs['templateMeta']['includes']) ? $this->defs['templateMeta']['includes'] : null);
        $this->th->ss->assign('view', $this->view);
        //Calculate time & date formatting (may need to calculate this depending on a setting)
        global $timedate;
        $this->th->ss->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format());
        $this->th->ss->assign('USER_DATEFORMAT', $timedate->get_user_date_format());
        $time_format = $timedate->get_user_time_format();
        $this->th->ss->assign('TIME_FORMAT', $time_format);
        $date_format = $timedate->get_cal_date_format();
        $time_separator = ':';
        if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) {
            $time_separator = $match[1];
        }
        // Create Smarty variables for the Calendar picker widget
        $t23 = strpos($time_format, '23') !== false ? '%H' : '%I';
        if (!isset($match[2]) || $match[2] == '') {
            $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M');
        } else {
            $pm = $match[2] == 'pm' ? '%P' : '%p';
            $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M' . $pm);
        }
        $this->th->ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week());
        $this->th->ss->assign('TIME_SEPARATOR', $time_separator);
        $seps = get_number_seperators();
        $this->th->ss->assign('NUM_GRP_SEP', $seps[0]);
        $this->th->ss->assign('DEC_SEP', $seps[1]);
        if ($this->view == 'EditView') {
            $height = $current_user->getPreference('text_editor_height');
            $width = $current_user->getPreference('text_editor_width');
            $height = isset($height) ? $height : '300px';
            $width = isset($width) ? $width : '95%';
            $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height);
            $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width);
        } else {
            $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px');
            $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%');
        }
        $this->th->ss->assign('SHOW_VCR_CONTROL', $this->showVCRControl);
        $str = $this->showTitle($showTitle);
        //Use the output filter to trim the whitespace
        $this->th->ss->load_filter('output', 'trimwhitespace');
        $str .= $this->th->displayTemplate($this->module, $form_name, $this->tpl, $ajaxSave, $this->defs);
        /* BEGIN - SECURITY GROUPS */
        //if popup select add panel if user is a member of multiple groups to metadataFile
        global $sugar_config;
        if (isset($sugar_config['securitysuite_popup_select']) && $sugar_config['securitysuite_popup_select'] == true && empty($this->focus->fetched_row['id']) && $this->focus->module_dir != "Users" && $this->focus->module_dir != "SugarFeed") {
            //there are cases such as uploading an attachment to an email template where the request module may
            //not be the same as the current bean module. If that happens we can just skip it
            //however...let quickcreate through
            if ($this->view != 'QuickCreate' && (empty($_REQUEST['module']) || $_REQUEST['module'] != $this->focus->module_dir)) {
                return $str;
            }
            require_once 'modules/SecurityGroups/SecurityGroup.php';
            $groupFocus = new SecurityGroup();
            $security_modules = $groupFocus->getSecurityModules();
            if (in_array($this->focus->module_dir, array_keys($security_modules))) {
                global $current_user;
                $group_count = $groupFocus->getMembershipCount($current_user->id);
                if ($group_count > 1) {
                    $groups = $groupFocus->getUserSecurityGroups($current_user->id);
                    $group_options = '';
                    foreach ($groups as $group) {
                        $group_options .= '<option value="' . $group['id'] . '" label="' . $group['name'] . '" selected="selected">' . $group['name'] . '</option>';
                    }
                    //multilingual support
                    global $current_language;
                    $ss_mod_strings = return_module_language($current_language, 'SecurityGroups');
                    $lbl_securitygroups_select = $ss_mod_strings['LBL_GROUP_SELECT'];
                    $lbl_securitygroups = $ss_mod_strings['LBL_LIST_FORM_TITLE'];
                    $group_panel = <<<EOQ
<div class="edit view edit508 " id="detailpanel_securitygroups">
    <h4>&nbsp;&nbsp;
    {$lbl_securitygroups_select}
    </h4>
    <table width="100%" cellspacing="1" cellpadding="0" border="0" class="edit view panelContainer" id="LBL_PANEL_SECURITYGROUPS">
    <tbody><tr>
    <td width="12.5%" valign="top" scope="col" id="account_type_label">
        {$lbl_securitygroups}:
    </td>
    <td width="37.5%" valign="top">
        <select title="" id="securitygroup_list" name="securitygroup_list[]" multiple="multiple" size="{$group_count}">
        {$group_options}
        </select>
    </td>
    </tr>
    </tbody></table>
</div>
EOQ;
                    $group_panel = preg_replace("/[\r\n]+/", "", $group_panel);
                    $group_panel_append = <<<EOQ
<script>
    \$('#{$form_name}_tabs div:first').append(\$('{$group_panel}'));
</script>
EOQ;
                    $str .= $group_panel_append;
                }
            }
        }
        /* END - SECURITY GROUPS */
        return $str;
    }
    function populateLineItems()
    {
        global $locale, $app_list_strings, $app_strings, $mod_strings, $popup_request_data, $sugar_config;
        $json = getJSONobj();
        $encoded_contact_popup_request_data = $json->encode($popup_request_data);
        $sql = "SELECT * FROM aos_products_quotes WHERE parent_type = 'AOS_Invoices' AND parent_id = '" . $this->bean->id . "' AND product_id != '0' AND deleted = 0 ORDER BY number ASC";
        $result = $this->bean->db->query($sql);
        $html = "";
        $html .= '<script language="javascript">setModule("AOS_Invoices");</script>';
        $html .= "<table border='0' width='37.5%' id='productLine'>";
        $html .= "<tr id='productHeader' style='display: none'>";
        $html .= "<td width='15%' class='dataLabel' style='text-align: left;'>" . $mod_strings['LBL_PRODUCT_QUANITY'] . "</td>";
        $html .= "<td width='15%' class='dataLabel' style='text-align: left;' colspan='2'>" . $mod_strings['LBL_PRODUCT_NAME'] . "</td>";
        $html .= "<td width='15%' class='dataLabel' id='list_price' style='text-align: left;'>" . $mod_strings['LBL_LIST_PRICE'] . "</td>";
        $html .= "<td width='15%' class='dataLabel' style='text-align: left;'>" . $mod_strings['LBL_DISCOUNT_AMT'] . "</td>";
        $html .= "<td width='15%' class='dataLabel' id='unit_price' style='text-align: left;'>" . $mod_strings['LBL_UNIT_PRICE'] . "</td>";
        $html .= "<td width='15%' class='dataLabel' id='vat_amt' style='text-align: left;'>" . $mod_strings['LBL_VAT_AMT'] . "</td>";
        $html .= "<td width='15%' class='dataLabel' id='total_price' style='text-align: left;'>" . $mod_strings['LBL_TOTAL_PRICE'] . "</td>";
        $html .= "<td width='10%' class='dataLabel' style='text-align: left;'>&nbsp;</td>";
        $html .= "</tr>";
        $decimals = $locale->getPrecision();
        $sep = get_number_seperators();
        $i = 0;
        while ($row = $this->bean->db->fetchByAssoc($result)) {
            if ($i == 0) {
                $html .= '<script language="javascript">showProductHeader(true);</script>';
            }
            $sqs_objects = array('product_name[' . $i . ']' => array('form' => 'EditView', 'method' => 'query', 'modules' => array('AOS_Products'), 'group' => 'or', 'field_list' => array('name', 'id', 'cost', 'price'), 'populate_list' => array('product_name[' . $i . ']', 'product_id[' . $i . ']', 'product_cost_price[' . $i . ']', 'product_list_price[' . $i . ']'), 'required_list' => array('product_id[' . $i . ']'), 'conditions' => array(array('name' => 'name', 'op' => 'like_custom', 'end' => '%', 'value' => '')), 'order' => 'name', 'limit' => '30', 'post_onblur_function' => 'formatListPrice(' . $i . ');', 'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']));
            $quicksearch_js = '<script language="javascript">';
            $quicksearch_js .= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}';
            foreach ($sqs_objects as $sqsfield => $sqsfieldArray) {
                $quicksearch_js .= "sqs_objects['{$sqsfield}']={$json->encode($sqsfieldArray)};";
            }
            $html .= $quicksearch_js . '</script>';
            $row['id'] = isset($_REQUEST['Duplicate']) && trim($_REQUEST['Duplicate']) == 'Duplicate' ? "" : $row['id'];
            $html .= "<tr id='product_line{$i}'>";
            $html .= "<td class='dataField'><input tabindex='116' type='text' name='product_qty[{$i}]' id='product_qty{$i}' size='6' maxlength='6' value='" . rtrim(rtrim(format_number($row['product_qty']), '0'), $sep[1]) . "' title='' onblur='Quantity_formatNumber({$i});calculateProductLine({$i});'></td>";
            $html .= "<td class='dataField'><input class='sqsEnabled' autocomplete='off' tabindex='116' type='text' name='product_name[{$i}]' id='product_name{$i}' size='16' maxlength='50' value='" . $row['name'] . "' title=''><input type='hidden' name='product_id[{$i}]' id='product_id{$i}' value='" . $row['product_id'] . "'></td>";
            $html .= "<td class='dataField'><button title='" . $app_strings['LBL_SELECT_BUTTON_TITLE'] . "' accessKey='" . $app_strings['LBL_SELECT_BUTTON_KEY'] . "' type='button' tabindex='116' class='button' value='" . $app_strings['LBL_SELECT_BUTTON_LABEL'] . "' name='btn1' onclick='openProductPopup({$i})'><img src='themes/default/images/id-ff-select.png' alt='" . $app_strings['LBL_SELECT_BUTTON_LABEL'] . "'></button></td>";
            $html .= "<td class='dataField'><input tabindex='116' type='text' name='product_list_price[{$i}]' id='product_list_price{$i}' size='16' maxlength='50' value='" . format_number($row['product_list_price']) . "' title='' onfocus='calculateDiscount({$i});'><input type='hidden' name='product_cost_price[{$i}]' id='product_cost_price{$i}' value='" . format_number($row['product_cost_price']) . "' /></td>";
            $html .= "<td class='dataField'><input tabindex='116' type='text' name='product_discount[]' id='product_discount{$i}' size='16' maxlength='50' value='" . format_number($row['product_discount']) . "' title='' tabindex='116' onfocus='calculateDiscount({$i});' onblur='calculateDiscount({$i});'><input type='hidden' name='product_discount_amount[]' id='product_discount_amount{$i}' value='" . format_number($row['product_discount_amount']) . "' /></td>";
            $html .= "<td class='dataField'><input tabindex='116' type='text' name='product_unit_price[]' id='product_unit_price{$i}' size='16' maxlength='50' value='" . format_number($row['product_unit_price']) . "' title='' onfocus='calculateDiscount({$i});' onblur='calculateProductLine({$i});' readonly='readonly'></td>";
            $html .= "<td class='dataField'><input tabindex='116' type='text' name='vat_amt[]' id='vat_amt{$i}' size='16' maxlength='50' value='" . format_number($row['vat_amt']) . "' readonly title=''></td>";
            $html .= "<td class='dataField'><input tabindex='116' type='text' name='product_total_price[]' id='product_total_price{$i}' size='16' maxlength='50' value='" . format_number($row['product_total_price']) . "' title='' readonly='readonly'></td>";
            $html .= "<td class='dataField'><input type='hidden' name='product_deleted[]' id='product_deleted{$i}' value='0'><input type='hidden' name='product_quote_id[]' value='" . $row['id'] . "'><button type='button' class='button' value='" . $mod_strings['LBL_REMOVE_PRODUCT_LINE'] . "' tabindex='116' onclick='markProductLineDeleted({$i})'><img src='themes/default/images/id-ff-clear.png' alt='" . $mod_strings['LBL_REMOVE_PRODUCT_LINE'] . "'></button></td>";
            $html .= "</tr>";
            $html .= "<tr><td height='1px'></td></tr><tr id='product_note_line{$i}'>";
            $html .= "<td class='dataField' align='right'>" . $mod_strings['LBL_PRODUCT_NOTE'] . " :&nbsp</td>";
            $html .= "<td class='dataField' colspan='3'><textarea tabindex='116' name='product_note[]' id='product_note{$i}' rows='1' cols='23'>" . $row['description'] . "</textarea></td>";
            $html .= "<td class='dataField' colspan='2'>" . $mod_strings['LBL_DISCOUNT_TYPE'] . "&nbsp;:&nbsp;<select tabindex='116' name='discount[]' id='discount{$i}' onchange='calculateDiscount({$i});'>" . get_select_options_with_id($app_list_strings['discount_list'], $row['discount']) . "</select></td>";
            $html .= "<td class='dataField'>" . $mod_strings['LBL_VAT'] . " %&nbsp; :&nbsp;&nbsp;<select tabindex='116' name='vat[]' id='vat{$i}' onchange='calculateProductLine({$i});'>" . get_select_options_with_id($app_list_strings['vat_list'], $row['vat']) . "</select></td>";
            $html .= "<td class='dataField' colspan='1'></td>";
            $html .= "</tr>";
            $html .= '<script language="javascript">currencyFields.push("product_list_price' . $i . '","product_unit_price' . $i . '","product_total_price' . $i . '","vat_amt' . $i . '","product_cost_price' . $i . '");</script>';
            $i++;
        }
        $html .= '<script language="javascript">prodLine = ' . $i . ';</script>';
        $html .= "</table>";
        $sql = "SELECT * FROM aos_products_quotes WHERE parent_type = 'AOS_Invoices' AND parent_id = '" . $this->bean->id . "' AND product_id = '0' AND deleted = 0 ORDER BY number ASC";
        $result = $this->bean->db->query($sql);
        if (preg_match('/^6\\.?[2-9]/', $sugar_config['sugar_version'])) {
            $html .= "<table border='0' cellspacing='4' width='100%' id='serviceLine'>";
        } else {
            $html .= "<table border='0' cellspacing='4' width='37.5%' id='serviceLine'>";
        }
        $html .= "<tr id='serviceHeader' style='display: none'>";
        $html .= "<td width='60%' class='dataLabel' style='text-align: left;' colspan='4'>" . $mod_strings['LBL_SERVICE_NAME'] . "</td>";
        $html .= "<td width='15%' class='dataLabel' id='service_price' style='text-align: left;'>" . $mod_strings['LBL_SERVICE_PRICE'] . "</td>";
        $html .= "<td width='15%' class='dataLabel' id='lbl_serv_vat_amt' style='text-align: left;'>" . $mod_strings['LBL_VAT_AMT'] . "</td>";
        $html .= "<td width='15%' class='dataLabel' id='lbl_serv_total_price' style='text-align: left;'>" . $mod_strings['LBL_TOTAL_PRICE'] . "</td>";
        $html .= "<td width='10%' class='dataLabel' style='text-align: left;'>&nbsp;</td>";
        $html .= "</tr>";
        $k = 0;
        while ($row = $this->bean->db->fetchByAssoc($result)) {
            if ($k == 0) {
                $html .= '<script language="javascript">showServiceHeader(true);</script>';
            }
            $row['id'] = isset($_REQUEST['Duplicate']) && trim($_REQUEST['Duplicate']) == 'Duplicate' ? "" : $row['id'];
            $html .= "<tr id='service_line{$k}'>";
            $html .= "<td class='dataField' colspan='4'><textarea tabindex='116' type='text' name='product_name[]' id='service_name{$k}' size='16' cols='60' title='' maxlength='255' onkeypress='return imposeMaxLength(this);'>" . $row['name'] . "</textarea><input type='hidden' name='product_id[]' id='service_id{$k}' value='" . $row['product_id'] . "'></td>";
            $html .= "<td class='dataField'><input tabindex='116' type='text' name='product_unit_price[]' id='service_unit_price{$k}' size='16' maxlength='50' value='" . format_number($row['product_unit_price']) . "' title=''  onblur='calculateServiceLine({$k});'></td>";
            $html .= "<td class='dataField'><input tabindex='116' type='text' name='vat_amt[]' id='ser_vat_amt{$k}' size='16' maxlength='50' value='" . format_number($row['vat_amt']) . "' readonly title=''><br />" . $mod_strings['LBL_VAT'] . " %&nbsp; :&nbsp;&nbsp;<select tabindex='116' name='vat[]' id='ser_vat{$k}' onchange='calculateServiceLine({$k});'>" . get_select_options_with_id($app_list_strings['vat_list'], $row['vat']) . "</select></td>";
            $html .= "<td class='dataField'><input tabindex='116' type='text' name='product_total_price[]' id='service_total_price{$k}' size='16' maxlength='50' value='" . format_number($row['product_total_price']) . "' title='' readonly='readonly'></td>";
            $html .= "<td class='dataField'><input type='hidden' name='product_deleted[]' id='ser_deleted{$k}' value='0'><input type='hidden' name='product_quote_id[]' value='" . $row['id'] . "'><button type='button' class='button' value='" . $mod_strings['LBL_REMOVE_PRODUCT_LINE'] . "' tabindex='116' onclick='markServiceLineDeleted({$k})'><img src='themes/default/images/id-ff-clear.png' alt='" . $mod_strings['LBL_REMOVE_PRODUCT_LINE'] . "'></button></td>";
            $html .= "</tr>";
            $html .= '<script language="javascript">currencyFields.push("service_unit_price' . $k . '","service_total_price' . $k . '","ser_vat_amt' . $k . '");</script>';
            $k++;
        }
        $html .= "</table>";
        $html .= '<script language="javascript">servLine = ' . $k . ';</script>';
        $html .= "<div style='padding-top: 10px; padding-bottom:10px;'>";
        $html .= "<input type=\"button\" tabindex=\"116\" class=\"button\" value=\"" . $mod_strings['LBL_ADD_PRODUCT_LINE'] . "\" id=\"addProductLine\" onclick=\"insertProductLine(" . $i . ")\" />";
        $html .= " <input type=\"button\" tabindex=\"116\" class=\"button\" value=\"" . $mod_strings['LBL_ADD_SERVICE_LINE'] . "\" id=\"addServiceLine\" onclick=\"insertServiceLine(" . $k . ")\" />";
        $html .= "</div>";
        $html .= '<input type="hidden" name="vathidden" id="vathidden" value="' . get_select_options_with_id($app_list_strings['vat_list'], '') . '">
			  <input type="hidden" name="discounthidden" id="discounthidden" value="' . get_select_options_with_id($app_list_strings['discount_list'], '') . '">
				  <input type="hidden" id="significant_digits" name="significant_digits" value="' . $decimals . '" />
				  <input type="hidden" id="grp_seperator" name="grp_seperator" value="' . $sep[0] . '" />
				  <input type="hidden" id="dec_seperator" name="dec_seperator" value="' . $sep[1] . '" />
				  <input type="hidden" id="currency_symbol" name="currency_symbol" value="{CURRENCY_SYMBOL}" />';
        $this->ss->assign('LINE_ITEMS', $html);
    }
 /**
  * display
  * This method makes the Smarty variable assignments and theautocomplete_ajax'vars the
  * generated view.
  * @param $showTitle boolean value indicating whether or not to show a title on the resulting page
  * @param $ajaxSave boolean value indicating whether or not the operation is an Ajax save request
  * @return HTML display for view as String
  */
 function display($showTitle = true, $ajaxSave = false)
 {
     global $mod_strings, $sugar_config, $app_strings, $app_list_strings, $theme, $current_user;
     if (isset($this->defs['templateMeta']['javascript'])) {
         if (is_array($this->defs['templateMeta']['javascript'])) {
             //$this->th->ss->assign('externalJSFile', 'modules/' . $this->module . '/metadata/editvewdefs.js');
             $this->th->ss->assign('externalJSFile', $this->defs['templateMeta']['javascript']);
         } else {
             $this->th->ss->assign('scriptBlocks', $this->defs['templateMeta']['javascript']);
         }
     }
     $this->th->ss->assign('id', $this->fieldDefs['id']['value']);
     $this->th->ss->assign('offset', $this->offset + 1);
     $this->th->ss->assign('APP', $app_strings);
     $this->th->ss->assign('MOD', $mod_strings);
     $this->th->ss->assign('fields', $this->fieldDefs);
     $this->th->ss->assign('sectionPanels', $this->sectionPanels);
     $this->th->ss->assign('config', $sugar_config);
     $this->th->ss->assign('returnModule', $this->returnModule);
     $this->th->ss->assign('returnAction', $this->returnAction);
     $this->th->ss->assign('returnId', $this->returnId);
     $this->th->ss->assign('isDuplicate', $this->isDuplicate);
     $this->th->ss->assign('def', $this->defs);
     $this->th->ss->assign('useTabs', isset($this->defs['templateMeta']['useTabs']) ? $this->defs['templateMeta']['useTabs'] : false);
     $this->th->ss->assign('maxColumns', isset($this->defs['templateMeta']['maxColumns']) ? $this->defs['templateMeta']['maxColumns'] : 2);
     $this->th->ss->assign('module', $this->module);
     $this->th->ss->assign('headerTpl', isset($this->defs['templateMeta']['form']['headerTpl']) ? $this->defs['templateMeta']['form']['headerTpl'] : 'include/' . $this->view . '/header.tpl');
     $this->th->ss->assign('footerTpl', isset($this->defs['templateMeta']['form']['footerTpl']) ? $this->defs['templateMeta']['form']['footerTpl'] : 'include/' . $this->view . '/footer.tpl');
     $this->th->ss->assign('current_user', $current_user);
     $this->th->ss->assign('bean', $this->focus);
     $this->th->ss->assign('isAuditEnabled', $this->focus->is_AuditEnabled());
     $this->th->ss->assign('gridline', $current_user->getPreference('gridline') == 'on' ? '1' : '0');
     global $js_custom_version;
     global $sugar_version;
     $this->th->ss->assign('SUGAR_VERSION', $sugar_version);
     $this->th->ss->assign('JS_CUSTOM_VERSION', $js_custom_version);
     //this is used for multiple forms on one page
     if (!empty($this->formName)) {
         $form_id = $this->formName;
         $form_name = $this->formName;
     } else {
         $form_id = $this->view;
         $form_name = $this->view;
     }
     if ($ajaxSave && empty($this->formName)) {
         $form_id = 'form_' . $this->view . '_' . $this->module;
         $form_name = $form_id;
         $this->view = $form_name;
         //$this->defs['templateMeta']['form']['buttons'] = array();
         //$this->defs['templateMeta']['form']['buttons']['ajax_save'] = array('id' => 'AjaxSave', 'customCode'=>'<input type="button" class="button" value="Save" onclick="this.form.action.value=\'AjaxFormSave\';return saveForm(\''.$form_name.'\', \'multiedit_form_{$module}\', \'Saving {$module}...\');"/>');
     }
     $form_name = $form_name == 'QuickCreate' ? "QuickCreate_{$this->module}" : $form_name;
     $form_id = $form_id == 'QuickCreate' ? "QuickCreate_{$this->module}" : $form_id;
     if (isset($this->defs['templateMeta']['preForm'])) {
         $this->th->ss->assign('preForm', $this->defs['templateMeta']['preForm']);
     }
     if (isset($this->defs['templateMeta']['form']['closeFormBeforeCustomButtons'])) {
         $this->th->ss->assign('closeFormBeforeCustomButtons', $this->defs['templateMeta']['form']['closeFormBeforeCustomButtons']);
     }
     if (isset($this->defs['templateMeta']['form']['enctype'])) {
         $this->th->ss->assign('enctype', 'enctype="' . $this->defs['templateMeta']['form']['enctype'] . '"');
     }
     //for SugarFieldImage, we must set form enctype to "multipart/form-data"
     foreach ($this->fieldDefs as $field) {
         if (isset($field['type']) && $field['type'] == 'image') {
             $this->th->ss->assign('enctype', 'enctype="multipart/form-data"');
             break;
         }
     }
     $this->th->ss->assign('showDetailData', $this->showDetailData);
     $this->th->ss->assign('showSectionPanelsTitles', $this->showSectionPanelsTitles);
     $this->th->ss->assign('form_id', $form_id);
     $this->th->ss->assign('form_name', $form_name);
     $this->th->ss->assign('set_focus_block', get_set_focus_js());
     $this->th->ss->assign('form', isset($this->defs['templateMeta']['form']) ? $this->defs['templateMeta']['form'] : null);
     $this->th->ss->assign('includes', isset($this->defs['templateMeta']['includes']) ? $this->defs['templateMeta']['includes'] : null);
     $this->th->ss->assign('view', $this->view);
     //Calculate time & date formatting (may need to calculate this depending on a setting)
     global $timedate;
     $this->th->ss->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format());
     $this->th->ss->assign('USER_DATEFORMAT', $timedate->get_user_date_format());
     $time_format = $timedate->get_user_time_format();
     $this->th->ss->assign('TIME_FORMAT', $time_format);
     $date_format = $timedate->get_cal_date_format();
     $time_separator = ':';
     if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) {
         $time_separator = $match[1];
     }
     // Create Smarty variables for the Calendar picker widget
     $t23 = strpos($time_format, '23') !== false ? '%H' : '%I';
     if (!isset($match[2]) || $match[2] == '') {
         $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M');
     } else {
         $pm = $match[2] == 'pm' ? '%P' : '%p';
         $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M' . $pm);
     }
     $this->th->ss->assign('TIME_SEPARATOR', $time_separator);
     $seps = get_number_seperators();
     $this->th->ss->assign('NUM_GRP_SEP', $seps[0]);
     $this->th->ss->assign('DEC_SEP', $seps[1]);
     if ($this->view == 'EditView') {
         $height = $current_user->getPreference('text_editor_height');
         $width = $current_user->getPreference('text_editor_width');
         $height = isset($height) ? $height : '300px';
         $width = isset($width) ? $width : '95%';
         $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height);
         $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width);
     } else {
         $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px');
         $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%');
     }
     $this->th->ss->assign('SHOW_VCR_CONTROL', $this->showVCRControl);
     $str = $this->showTitle($showTitle);
     //Use the output filter to trim the whitespace
     $this->th->ss->load_filter('output', 'trimwhitespace');
     $str .= $this->th->displayTemplate($this->module, $form_name, $this->tpl, $ajaxSave, $this->defs);
     return $str;
 }
 function populateLineItems()
 {
     global $app_strings, $mod_strings;
     $params = array('currency_id' => $this->bean->currency_id);
     $sql = "SELECT * FROM aos_products_quotes WHERE parent_type = 'AOS_Quotes' AND parent_id = '" . $this->bean->id . "' AND product_id != '0' AND deleted = 0 ORDER BY number ASC";
     $result = $this->bean->db->query($sql);
     $countLine = $this->bean->db->getRowCount($result);
     $sep = get_number_seperators();
     $html = "";
     $html .= "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
     if ($countLine != 0) {
         $html .= "<tr>";
         $html .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;padding:2px;'>&nbsp;</td>";
         $html .= "<td width='10%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_PRODUCT_QUANITY'] . "</td>";
         $html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_PRODUCT_NAME'] . "</td>";
         $html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_LIST_PRICE'] . "</td>";
         $html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_DISCOUNT_AMT'] . "</td>";
         $html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_UNIT_PRICE'] . "</td>";
         $html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_VAT'] . "</td>";
         $html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_VAT_AMT'] . "</td>";
         $html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_TOTAL_PRICE'] . "</td>";
         $html .= "</tr>";
     }
     $i = 1;
     while ($row = $this->bean->db->fetchByAssoc($result)) {
         $html .= "<tr>";
         $product_note = wordwrap($row['description'], 40, "<br />\n");
         $html .= "<td class='tabDetailViewDF' style='text-align: left; padding:2px;'>" . $i++ . "</td>";
         $html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . rtrim(rtrim(format_number($row['product_qty']), '0'), $sep[1]) . "</td>";
         $html .= "<td class='tabDetailViewDF' style='padding:2px;'><a href='index.php?module=AOS_Products&action=DetailView&record=" . $row['product_id'] . "' class='tabDetailViewDFLink'>" . $row['name'] . "</a><br />" . $product_note . "</td>";
         $html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['product_list_price'], $params) . "</td>";
         if ($row['product_discount'] != '' && $row['product_discount'] != '0.00') {
             if ($row['discount'] == 'Amount') {
                 $html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['product_discount'], $params) . "</td>";
             } else {
                 $html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . rtrim(rtrim(format_number($row['product_discount']), '0'), $sep[1]) . "%</td>";
             }
         } else {
             $html .= "<td class='tabDetailViewDF' style='padding:2px;'>-</td>";
         }
         $html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['product_unit_price'], $params) . "</td>";
         $html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . rtrim(rtrim(format_number($row['vat']), '0'), $sep[1]) . "%</td>";
         $html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['vat_amt'], $params) . "</td>";
         $html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['product_total_price'], $params) . "</td>";
         $html .= "</tr>";
     }
     $sql = "SELECT * FROM aos_products_quotes WHERE parent_type = 'AOS_Quotes' AND parent_id = '" . $this->bean->id . "' AND product_id = '0' AND deleted = 0 ORDER BY number ASC";
     $result = $this->bean->db->query($sql);
     $countLine = $this->bean->db->getRowCount($result);
     if ($i != 1 && $countLine != 0) {
         $html .= "<tr>";
         $html .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;padding:2px; padding-top:12px;'>&nbsp;</td>";
         $html .= "<td width='46%' class='dataLabel' style='text-align: left;padding:2px; padding-top:12px;' colspan='4' scope='row'>" . $mod_strings['LBL_SERVICE_NAME'] . "</td>";
         $html .= "<td width='12%' class='dataLabel' style='text-align: left;padding:2px; padding-top:12px;' scope='row'>" . $mod_strings['LBL_SERVICE_PRICE'] . "</td>";
         $html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px; padding-top:12px;' scope='row'>" . $mod_strings['LBL_VAT'] . "</td>";
         $html .= "<td width='12%' class='dataLabel' style='text-align: left;padding:2px; padding-top:12px;' scope='row'>" . $mod_strings['LBL_VAT_AMT'] . "</td>";
         $html .= "<td width='12%' class='dataLabel' style='text-align: left;padding:2px; padding-top:12px;' scope='row'>" . $mod_strings['LBL_TOTAL_PRICE'] . "</td>";
         $html .= "</tr>";
     } else {
         if ($countLine != 0) {
             $html .= "<tr>";
             $html .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;padding:2px;'>&nbsp;</td>";
             $html .= "<td width='46%' class='dataLabel' style='text-align: left;padding:2px;' colspan='4' scope='row'>" . $mod_strings['LBL_SERVICE_NAME'] . "</td>";
             $html .= "<td width='12%' class='dataLabel' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_SERVICE_PRICE'] . "</td>";
             $html .= "<td width='12%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_VAT'] . "</td>";
             $html .= "<td width='12%' class='dataLabel' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_VAT_AMT'] . "</td>";
             $html .= "<td width='12%' class='dataLabel' style='text-align: left;padding:2px;' scope='row'>" . $mod_strings['LBL_TOTAL_PRICE'] . "</td>";
             $html .= "</tr>";
         }
     }
     while ($row = $this->bean->db->fetchByAssoc($result)) {
         $html .= "<tr>";
         $html .= "<td class='tabDetailViewDF' style='text-align: left; padding:2px;'>" . $i++ . "</td>";
         $html .= "<td class='tabDetailViewDF' style='padding:2px;' colspan='4'>" . $row['name'] . "</td>";
         $html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['product_unit_price'], $params) . "</td>";
         $html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . rtrim(rtrim(format_number($row['vat']), '0'), $sep[1]) . "%</td>";
         $html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['vat_amt'], $params) . "</td>";
         $html .= "<td class='tabDetailViewDF' style='padding:2px;'>" . currency_format_number($row['product_total_price'], $params) . "</td>";
         $html .= "</tr>";
     }
     $html .= "</table>";
     $this->ss->assign('LINE_ITEMS', $html);
 }
Exemple #25
0
 /**
  * Get Javascript variables setup for user date format validation
  * @todo: move to separate utility class?
  *
  * @return string JS code
  */
 function get_javascript_validation()
 {
     $cal_date_format = $this->get_cal_date_format();
     $timereg = $this->get_regular_expression($this->get_time_format());
     $datereg = $this->get_regular_expression($this->get_date_format());
     $date_pos = '';
     foreach ($datereg['positions'] as $type => $pos) {
         if (empty($date_pos)) {
             $date_pos .= "'{$type}': {$pos}";
         } else {
             $date_pos .= ",'{$type}': {$pos}";
         }
     }
     $date_pos = '{' . $date_pos . '}';
     if (preg_match('/\\)([^\\d])\\(/', $timereg['format'], $match)) {
         $time_separator = $match[1];
     } else {
         $time_separator = ":";
     }
     $hour_offset = $this->get_hour_offset() * 60 * 60;
     // Add in the number formatting styles here as well, we have been handling this with individual modules.
     require_once 'modules/Currencies/Currency.php';
     list($num_grp_sep, $dec_sep) = get_number_seperators();
     $the_script = "<script type=\"text/javascript\">\n" . "\tvar time_reg_format = '" . $timereg['format'] . "';\n" . "\tvar date_reg_format = '" . $datereg['format'] . "';\n" . "\tvar date_reg_positions = {$date_pos};\n" . "\tvar time_separator = '{$time_separator}';\n" . "\tvar cal_date_format = '{$cal_date_format}';\n" . "\tvar time_offset = {$hour_offset};\n" . "\tvar num_grp_sep = '{$num_grp_sep}';\n" . "\tvar dec_sep = '{$dec_sep}';\n" . "</script>";
     return $the_script;
 }
function getServicesHtml($focus, $name, $value, $view)
{
    if ('EditView' != $view && 'DetailView' != $view) {
        return "";
        // skip the rest of the method if another view calls this method
    }
    global $app_list_strings;
    global $app_strings;
    $smarty = new Sugar_Smarty();
    // setup the popup link
    $popup_request_data = array('call_back_function' => 'OqcServices.handlePopUpClosed', 'formName' => 'EditView', 'field_to_name_array' => array("price" => "price", "is_recurring" => "is_recurring", "unit" => "unit", "name" => "name", "id" => "productId", "zeitbezug" => "zeitbezug", "currency_id" => "currency_id"), 'passthru_data' => array('unit_hours' => $app_list_strings['unit_list']['hours'], 'unit_pieces' => $app_list_strings['unit_list']['pieces'], 'zeitbezug_once' => $app_list_strings['zeitbezug_list']['once'], 'zeitbezug_monthly' => $app_list_strings['zeitbezug_list']['monthly'], 'zeitbezug_annually' => $app_list_strings['zeitbezug_list']['annually']));
    $json = getJSONobj();
    $encoded_request_data = $json->encode($popup_request_data);
    $languageStrings = $app_list_strings["oqc"]["Services"];
    //YUI error messages
    $languageStrings['LBL_NO_RECORDS_MESSAGE'] = $app_strings['LBL_NO_RECORDS_MESSAGE'];
    $languageStrings['LBL_DATA_ERROR_MESSAGE'] = $app_strings['LBL_DATA_ERROR_MESSAGE'];
    $languageStrings['LBL_LOADING_MESSAGE'] = $app_strings['LBL_LOADING_MESSAGE'];
    $languageStringsJSON = $json->encode($languageStrings);
    // $_GLOBALS['log']->fatal("asasdasd " . $languageStrings['totalNegotiatedPrice']);
    global $timedate;
    global $locale;
    $sqsJavascript = '<script type="text/javascript" src="include/oqc/QuickSearch/oqcQS.js"></script>';
    $sqsJavascript .= '<script type="text/javascript" language="javascript">';
    $sqsJavascript .= 'addToValidateDateBefore("EditView", "now", "date", true , "Deadline has to be in the future. " ,"deadline");';
    $sqsJavascript .= '</script>';
    //1.7.8 setup of currency variables for javascript
    $currencyScript = configureCurrencyVariables($focus);
    //2.2RC get contract currency
    if (isset($focus->currency_id) && $focus->currency_id != '') {
        $currentCurrency = new Currency();
        $currentCurrency->retrieve($focus->currency_id);
        $currencySymbol = $currentCurrency->symbol;
        $current_ratio = $currentCurrency->conversion_rate;
        $current_id = $currentCurrency->id;
    } else {
        $currencySymbol = $locale->getPrecedentPreference('default_currency_symbol');
        $current_ratio = 1;
        $current_id = '-99';
    }
    //	$default_currency = new Currency();
    //	$default_currency->retrieve('-99');
    //	$currencySymbol = $default_currency->symbol;
    //$currencySymbol = $locale->getPrecedentPreference('default_currency_symbol');
    //	require_once('include/oqc/common/common.php');
    require_once 'include/oqc/common/Configuration.php';
    $conf = Configuration::getInstance();
    $hideRecurringContainer = $conf->get('hideRecurringTable');
    //$GLOBALS['log']->error('OQC: Legacy Vat value is '.$vat);
    $sep = get_number_seperators();
    $vat_default = floatval(str_replace($sep[1], '.', $app_list_strings['oqc_vat_list']['default'])) / 100;
    //$GLOBALS['log']->error('OQC: Default Vat value is '.$vat_default);
    $smarty->assign('hideContainer', $hideRecurringContainer);
    $smarty->assign('thousandsSeparator', $sep[0]);
    $smarty->assign('decimalSeparator', $sep[1]);
    $smarty->assign('dropdownLabelsUnitJSON', $json->encode($app_list_strings['unit_list']));
    $smarty->assign('dropdownLabelsRecurrenceJSON', $json->encode($app_list_strings['zeitbezug_list']));
    $smarty->assign('dropdownLabelsDiscountTypeJSON', $json->encode($app_list_strings['discount_select_list']));
    $smarty->assign('dropdownLabelsVatJSON', $json->encode($app_list_strings['oqc_vat_list']));
    $smarty->assign('dateFormat', $locale->getPrecedentPreference('default_date_format'));
    $smarty->assign('currencyJavascript', $currencyScript);
    $smarty->assign('currencySymbol', $currencySymbol);
    $smarty->assign('current_rate', $current_ratio);
    $smarty->assign('current_id', $current_id);
    $smarty->assign('languageStrings', $languageStrings);
    $smarty->assign('languageStringsJSON', $languageStringsJSON);
    $smarty->assign('sqsJavascript', $sqsJavascript);
    $smarty->assign('now', date($timedate->get_date_format()));
    $smarty->assign('contractId', $focus->id);
    $smarty->assign('initialFilter', '&is_option=0');
    $smarty->assign('encoded_request_data', $encoded_request_data);
    $smarty->assign('vat_default', $vat_default);
    // default VAT value -1.7.8 just for information
    $smarty->assign('StartDate', $focus->startdate);
    $smarty->assign('EndDate', $focus->enddate);
    // new for yui
    $smarty->assign('id', $focus->id);
    $smarty->assign('moduleName', $focus->object_name);
    return $smarty->fetch('include/oqc/Services/' . $view . '.html');
}
        $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;
        }
    }
    //now create select option html without the newsletter/email, or blank ('') options
Exemple #28
0
 public function testStoreQuerySaveAndPopulate()
 {
     global $current_user, $timedate;
     $storeQuery = new StoreQuery();
     //Simulate a search request here
     $_REQUEST = array('module' => 'Opportunities', 'action' => 'index', 'searchFormTab' => 'advanced_search', 'query' => true, 'name_advanced' => '', 'account_name_advanced' => '', 'amount_advanced_range_choice' => '=', 'range_amount_advanced' => '', 'start_range_amount_advanced' => '$9,500.00', 'end_range_amount_advanced' => '$45,900.00', 'date_closed_advanced_range_choice' => '=', 'range_date_closed_advanced' => '', 'start_range_date_closed_advanced' => '', 'end_range_date_closed_advanced' => '', 'next_step_advanced' => '', 'update_fields_team_name_advanced_collection' => '', 'team_name_advanced_new_on_update' => false, 'team_name_advanced_allow_update' => '', 'team_name_advanced_allowed_to_check' => false, 'team_name_advanced_collection_0' => '', 'id_team_name_advanced_collection_0' => '', 'team_name_advanced_type' => 'any', 'favorites_only_advanced' => 0, 'showSSDIV' => 'no', 'saved_search_name' => '', 'search_module' => '', 'saved_search_action' => '', 'displayColumns' => 'NAME|ACCOUNT_NAME|SALES_STAGE|AMOUNT_USDOLLAR|DATE_CLOSED|ASSIGNED_USER_NAME|DATE_ENTERED', 'hideTabs' => 'OPPORTUNITY_TYPE|LEAD_SOURCE|NEXT_STEP|PROBABILITY|CREATED_BY_NAME|TEAM_NAME|MODIFIED_BY_NAME', 'orderBy' => 'NAME', 'sortOrder' => 'ASC', 'button' => 'Search', 'saved_search_select' => '_none', 'sugar_user_theme' => 'Sugar', 'ModuleBuilder' => 'helpHidden=true', 'Contacts_divs' => 'quotes_v=#', 'sugar_theme_gm_current' => 'All', 'globalLinksOpen' => 'true', 'SQLiteManager_currentLangue' => '2', 'PHPSESSID' => 'b8e4b4b955ef3c4b29291779751b5fca');
     $storeQuery->saveFromRequest('Opportunities');
     $storedSearch = StoreQuery::getStoredQueryForUser('Opportunities');
     $this->assertEquals($storedSearch['start_range_amount_advanced'], 9500.0, 'Assert that start range amount $9,500.00 was saved unformatted as 9500.00');
     $this->assertEquals($storedSearch['end_range_amount_advanced'], 45900.0, 'Assert that end range amount $45,900.00 was saved unformatted as 45900.00');
     //Test that value is converted to user's numer formatting
     unset($_REQUEST['start_range_amount_advanced']);
     unset($_REQUEST['end_range_amount_advanced']);
     $storeQuery->loadQuery('Opportunities');
     $storeQuery->populateRequest();
     $this->assertTrue(isset($_REQUEST['start_range_amount_advanced']), 'Assert that the start_range_amount_advanced field was correctly populated');
     $this->assertEquals('$9,500.00', $_REQUEST['start_range_amount_advanced'], 'Assert that start_range_amount_advanced value was converted to $9,500.00');
     $this->assertTrue(isset($_REQUEST['end_range_amount_advanced']), 'Assert that the end_range_amount_advanced field was correctly populated');
     $this->assertEquals('$45,900.00', $_REQUEST['end_range_amount_advanced'], 'Assert that end_range_amount_advanced value was converted to $45,900.00');
     //Now say the user changes his number preferences and switches back to this StoredQuery
     $current_user->setPreference('num_grp_sep', '.');
     $current_user->setPreference('dec_sep', ',');
     $current_user->save();
     //Force reset on dec_sep and num_grp_sep because the dec_sep and num_grp_sep values are stored as static variables
     get_number_seperators(true);
     //Now when we reload this store query, the $_REQUEST array should be populated with new user date preference
     unset($_REQUEST['start_range_amount_advanced']);
     unset($_REQUEST['end_range_amount_advanced']);
     $storeQuery->loadQuery('Opportunities');
     $storeQuery->populateRequest();
     $this->assertTrue(isset($_REQUEST['start_range_amount_advanced']), 'Assert that the start_range_amount_advanced field was correctly populated');
     $this->assertEquals('$9.500,00', $_REQUEST['start_range_amount_advanced'], 'Assert that start_range_amount_advanced value was converted to $9.500,00');
     $this->assertTrue(isset($_REQUEST['end_range_amount_advanced']), 'Assert that the end_range_amount_advanced field was correctly populated');
     $this->assertEquals('$45.900,00', $_REQUEST['end_range_amount_advanced'], 'Assert that end_range_amount_advanced value was converted to $45.900,00');
     //Okay so now what happens if they don't specify currency or separator or decimal values?
     $_REQUEST['start_range_amount_advanced'] = 9500;
     $_REQUEST['end_range_amount_advanced'] = 45900;
     $storeQuery->saveFromRequest('Opportunities');
     $storeQuery->loadQuery('Opportunities');
     $storeQuery->populateRequest();
     $this->assertTrue(isset($_REQUEST['start_range_amount_advanced']), 'Assert that the start_range_amount_advanced field was correctly populated');
     $this->assertEquals(9500, $_REQUEST['start_range_amount_advanced'], 'Assert that start_range_amount_advanced value remained as is (9500)');
     $this->assertTrue(isset($_REQUEST['end_range_amount_advanced']), 'Assert that the end_range_amount_advanced field was correctly populated');
     $this->assertEquals(45900, $_REQUEST['end_range_amount_advanced'], 'Assert that end_range_amount_advanced value remained as is (45900)');
 }
Exemple #29
0
 function formatNumber($number, $decimals = null, $decimal_point = null, $thousands_sep = null)
 {
     global $locale;
     if (is_null($decimals)) {
         $decimals = $locale->getPrecision();
     }
     $seps = get_number_seperators();
     $thousands_sep = $seps[0];
     $decimal_point = $seps[1];
     return number_format($number, $decimals, $decimal_point, $thousands_sep);
 }
function getProductsHtml($focus, $name, $value, $view)
{
    if ('EditView' != $view && 'DetailView' != $view) {
        return "";
        // skip the rest of the method if another view calls this method
    }
    global $app_list_strings;
    global $app_strings;
    $smarty = new Sugar_Smarty();
    // setup the popup link
    $popup_request_data = array('call_back_function' => 'OqcProducts.handlePopUpClosed', 'formName' => 'EditView', 'field_to_name_array' => array("price" => "price", "is_recurring" => "is_recurring", "unit" => "unit", "name" => "name", "id" => "productId", "oqc_vat" => "oqc_vat", "cancellationperiod" => "cancellationperiod", "monthsguaranteed" => "monthsguaranteed", "currency_id" => "currency_id"), 'passthru_data' => array('unit_hours' => $app_list_strings['unit_list']['hours'], 'unit_pieces' => $app_list_strings['unit_list']['pieces'], 'zeitbezug_once' => $app_list_strings['zeitbezug_list']['once'], 'zeitbezug_monthly' => $app_list_strings['zeitbezug_list']['monthly'], 'zeitbezug_annually' => $app_list_strings['zeitbezug_list']['annually']));
    $json = getJSONobj();
    $encoded_request_data = $json->encode($popup_request_data);
    $languageStrings = $app_list_strings["oqc"]["Services"];
    //YUI error messages
    $languageStrings['LBL_NO_RECORDS_MESSAGE'] = $app_strings['LBL_NO_RECORDS_MESSAGE'];
    $languageStrings['LBL_DATA_ERROR_MESSAGE'] = $app_strings['LBL_DATA_ERROR_MESSAGE'];
    $languageStrings['LBL_LOADING_MESSAGE'] = $app_strings['LBL_LOADING_MESSAGE'];
    $languageStringsJSON = $json->encode($languageStrings);
    global $timedate;
    global $locale;
    $sqsJavascript = '<script type="text/javascript" src="include/oqc/QuickSearch/oqcQS.js"></script>';
    $sqsJavascript .= '<script type="text/javascript" language="javascript">';
    $sqsJavascript .= 'addToValidateDateBefore("EditView", "now", "date", true , "Deadline has to be in the future. " ,"deadline");';
    $sqsJavascript .= '</script>';
    //2.2RC get product currency
    if (isset($focus->currency_id) && $focus->currency_id != '') {
        $currentCurrency = new Currency();
        $currentCurrency->retrieve($focus->currency_id);
        $currencySymbol = $currentCurrency->symbol;
        $current_ratio = $currentCurrency->conversion_rate;
        $current_id = $currentCurrency->id;
    } else {
        $currencySymbol = $locale->getPrecedentPreference('default_currency_symbol');
        $current_ratio = 1;
        $current_id = '-99';
    }
    $currencyScript = configureCurrencyVariables();
    $sep = get_number_seperators();
    $smarty->assign('thousandsSeparator', $sep[0]);
    $smarty->assign('decimalSeparator', $sep[1]);
    $smarty->assign('dropdownLabelsUnitJSON', $json->encode($app_list_strings['unit_list']));
    $smarty->assign('dropdownLabelsRecurrenceJSON', $json->encode($app_list_strings['zeitbezug_list']));
    $smarty->assign('dateFormat', $locale->getPrecedentPreference('default_date_format'));
    $smarty->assign('currencySymbol', $currencySymbol);
    $smarty->assign('current_rate', $current_ratio);
    $smarty->assign('current_id', $current_id);
    $smarty->assign('currencyJavascript', $currencyScript);
    $smarty->assign('languageStrings', $languageStrings);
    $smarty->assign('languageStringsJSON', $languageStringsJSON);
    $smarty->assign('dropdownLabelsVatJSON', $json->encode($app_list_strings['oqc_vat_list']));
    //1.7.8
    $smarty->assign('sqsJavascript', $sqsJavascript);
    $smarty->assign('now', date($timedate->get_date_format()));
    $smarty->assign('contractId', $focus->id);
    $smarty->assign('initialFilter', "&not_this_product_id={$focus->id}");
    // see view.popup.php of oqc_Product :)
    $smarty->assign('encoded_request_data', $encoded_request_data);
    $smarty->assign('isPacket', $focus->isPacket());
    // new for yui
    $smarty->assign('id', $focus->id);
    $smarty->assign('moduleName', $focus->object_name);
    return $smarty->fetch('include/oqc/Products/Products.' . $view . '.html');
}