예제 #1
0
    $ss->assign("HIDE_FREQUENCY_IF_NEWSLETTER", "Select");
    $ss->assign("FREQUENCY_LABEL", $mod_strings['LBL_CAMPAIGN_FREQUENCY']);
    if (!isset($focus->frequency) && !isset($focus->id)) {
        $ss->assign("FREQ_OPTIONS", get_select_options_with_id($app_list_strings['newsletter_frequency_dom'], 'Monthly'));
    } else {
        $ss->assign("FREQ_OPTIONS", get_select_options_with_id($app_list_strings['newsletter_frequency_dom'], $focus->frequency));
    }
} else {
    $ss->assign("HIDE_FREQUENCY_IF_NEWSLETTER", "input type='hidden'");
    $ss->assign("FREQUENCY_LABEL", ' ');
}
global $current_user;
require_once 'modules/Currencies/ListCurrency.php';
$currency = new ListCurrency();
if (isset($focus->currency_id) && !empty($focus->currency_id)) {
    $selectCurrency = $currency->getSelectOptions($focus->currency_id);
    $ss->assign("CURRENCY", $selectCurrency);
} else {
    if ($current_user->getPreference('currency') && !isset($focus->id)) {
        $selectCurrency = $currency->getSelectOptions($current_user->getPreference('currency'));
        $ss->assign("CURRENCY", $selectCurrency);
    } else {
        $selectCurrency = $currency->getSelectOptions();
        $ss->assign("CURRENCY", $selectCurrency);
    }
}
global $current_user;
if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
    $record = '';
    if (!empty($_REQUEST['record'])) {
        $record = $_REQUEST['record'];
예제 #2
0
        $gmtOffset = '+' . $gmtOffset;
    }
    $timezoneOptions .= "<option value='{$key}'" . $selected . ">" . str_replace(array('_', 'North'), array(' ', 'N.'), $key) . " (GMT" . $gmtOffset . ") " . $dst . "</option>";
}
$xtpl->assign('TIMEZONEOPTIONS', $timezoneOptions);
// Numbers and Currency display
require_once 'modules/Currencies/ListCurrency.php';
$currency = new ListCurrency();
// 10/13/2006 Collin - Changed to use Localization.getConfigPreference
// This was the problem- Previously, the "-99" currency id always assumed
// to be defaulted to US Dollars.  However, if someone set their install to use
// Euro or other type of currency then this setting would not apply as the
// default because it was being overridden by US Dollars.
$cur_id = $locale->getPrecedentPreference('currency');
if ($cur_id) {
    $selectCurrency = $currency->getSelectOptions($cur_id);
    $xtpl->assign("CURRENCY", $selectCurrency);
} else {
    $selectCurrency = $currency->getSelectOptions();
    $xtpl->assign("CURRENCY", $selectCurrency);
}
$currenciesVars = "";
$i = 0;
foreach ($locale->currencies as $id => $arrVal) {
    $currenciesVars .= "currencies[{$i}] = '{$arrVal['symbol']}';\n";
    $i++;
}
$currencySymbolsJs = <<<eoq
var currencies = new Object;
{$currenciesVars}
function setSymbolValue(id) {
예제 #3
0
    /**
     * @see SugarView::display()
     */
    public function display()
    {
        global $mod_strings, $app_strings, $current_user, $sugar_config, $app_list_strings, $locale;
        $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
        $has_header = isset($_REQUEST['has_header']) ? 1 : 0;
        $sugar_config['import_max_records_per_file'] = empty($sugar_config['import_max_records_per_file']) ? 1000 : $sugar_config['import_max_records_per_file'];
        // Clear out this user's last import
        $seedUsersLastImport = new UsersLastImport();
        $seedUsersLastImport->mark_deleted_by_user_id($current_user->id);
        ImportCacheFiles::clearCacheFiles();
        // attempt to lookup a preexisting field map
        // use the custom one if specfied to do so in step 1
        $field_map = array();
        $default_values = array();
        $ignored_fields = array();
        if (!empty($_REQUEST['source_id'])) {
            $mapping_file = new ImportMap();
            $mapping_file->retrieve($_REQUEST['source_id'], false);
            $_REQUEST['source'] = $mapping_file->source;
            $has_header = $mapping_file->has_header;
            if (isset($mapping_file->delimiter)) {
                $_REQUEST['custom_delimiter'] = $mapping_file->delimiter;
            }
            if (isset($mapping_file->enclosure)) {
                $_REQUEST['custom_enclosure'] = htmlentities($mapping_file->enclosure);
            }
            $field_map = $mapping_file->getMapping();
            $default_values = $mapping_file->getDefaultValues();
            $this->ss->assign("MAPNAME", $mapping_file->name);
            $this->ss->assign("CHECKMAP", 'checked="checked" value="on"');
        } else {
            // Try to see if we have a custom mapping we can use
            // based upon the where the records are coming from
            // and what module we are importing into
            $classname = 'ImportMap' . ucfirst($_REQUEST['source']);
            if (file_exists("modules/Import/{$classname}.php")) {
                require_once "modules/Import/{$classname}.php";
            } elseif (file_exists("custom/modules/Import/{$classname}.php")) {
                require_once "custom/modules/Import/{$classname}.php";
            } else {
                require_once "custom/modules/Import/ImportMapOther.php";
                $classname = 'ImportMapOther';
                $_REQUEST['source'] = 'other';
            }
            if (class_exists($classname)) {
                $mapping_file = new $classname();
                if (isset($mapping_file->delimiter)) {
                    $_REQUEST['custom_delimiter'] = $mapping_file->delimiter;
                }
                if (isset($mapping_file->enclosure)) {
                    $_REQUEST['custom_enclosure'] = htmlentities($mapping_file->enclosure);
                }
                $ignored_fields = $mapping_file->getIgnoredFields($_REQUEST['import_module']);
                $field_map = $mapping_file->getMapping($_REQUEST['import_module']);
            }
        }
        $this->ss->assign("CUSTOM_DELIMITER", !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : ",");
        $this->ss->assign("CUSTOM_ENCLOSURE", !empty($_REQUEST['custom_enclosure']) ? $_REQUEST['custom_enclosure'] : "");
        // handle uploaded file
        $uploadFile = new UploadFile('userfile');
        if (isset($_FILES['userfile']) && $uploadFile->confirm_upload()) {
            $uploadFile->final_move('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
            $uploadFileName = $uploadFile->get_upload_path('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
        } else {
            $this->_showImportError($mod_strings['LBL_IMPORT_MODULE_ERROR_NO_UPLOAD'], $_REQUEST['import_module'], 'Step2');
            return;
        }
        // split file into parts
        $splitter = new ImportFileSplitter($uploadFileName, $sugar_config['import_max_records_per_file']);
        $splitter->splitSourceFile($_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES), $has_header);
        // Now parse the file and look for errors
        $importFile = new ImportFile($uploadFileName, $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
        if (!$importFile->fileExists()) {
            $this->_showImportError($mod_strings['LBL_CANNOT_OPEN'], $_REQUEST['import_module'], 'Step2');
            return;
        }
        // retrieve first 3 rows
        $rows = array();
        $system_charset = $locale->default_export_charset;
        $user_charset = $locale->getExportCharset();
        $other_charsets = 'UTF-8, UTF-7, ASCII, CP1252, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP';
        $detectable_charsets = "UTF-8, {$user_charset}, {$system_charset}, {$other_charsets}";
        // Bug 26824 - mb_detect_encoding() thinks CP1252 is IS0-8859-1, so use that instead in the encoding list passed to the function
        $detectable_charsets = str_replace('CP1252', 'ISO-8859-1', $detectable_charsets);
        $charset_for_import = $user_charset;
        //We will set the default import charset option by user's preference.
        $able_to_detect = function_exists('mb_detect_encoding');
        for ($i = 0; $i < 3; $i++) {
            $rows[$i] = $importFile->getNextRow();
            if (!empty($rows[$i]) && $able_to_detect) {
                foreach ($rows[$i] as &$temp_value) {
                    $current_charset = mb_detect_encoding($temp_value, $detectable_charsets);
                    if (!empty($current_charset) && $current_charset != "UTF-8") {
                        $temp_value = $locale->translateCharset($temp_value, $current_charset);
                        // we will use utf-8 for displaying the data on the page.
                        $charset_for_import = $current_charset;
                        //set the default import charset option according to the current_charset.
                        //If it is not utf-8, tt may be overwritten by the later one. So the uploaded file should not contain two types of charset($user_charset, $system_charset), and I think this situation will not occur.
                    }
                }
            }
        }
        $ret_field_count = $importFile->getFieldCount();
        // Bug 14689 - Parse the first data row to make sure it has non-empty data in it
        $isempty = true;
        if ($rows[(int) $has_header] != false) {
            foreach ($rows[(int) $has_header] as $value) {
                if (strlen(trim($value)) > 0) {
                    $isempty = false;
                    break;
                }
            }
        }
        if ($isempty || $rows[(int) $has_header] == false) {
            $this->_showImportError($mod_strings['LBL_NO_LINES'], $_REQUEST['import_module'], 'Step2');
            return;
        }
        // save first row to send to step 4
        $this->ss->assign("FIRSTROW", base64_encode(serialize($rows[0])));
        // Now build template
        $this->ss->assign("TMP_FILE", $uploadFileName);
        $this->ss->assign("FILECOUNT", $splitter->getFileCount());
        $this->ss->assign("RECORDCOUNT", $splitter->getRecordCount());
        $this->ss->assign("RECORDTHRESHOLD", $sugar_config['import_max_records_per_file']);
        $this->ss->assign("SOURCE", $_REQUEST['source']);
        $this->ss->assign("TYPE", $_REQUEST['type']);
        $this->ss->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('basic_search', 'align="absmiddle" alt="' . $app_strings['LNK_DELETE'] . '" border="0"'));
        $this->ss->assign("PUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('advanced_search', 'align="absmiddle" alt="' . $mod_strings['LBL_PUBLISH'] . '" border="0"'));
        $this->ss->assign("MODULE_TITLE", $this->getModuleTitle());
        $this->ss->assign("STEP4_TITLE", strip_tags(str_replace("\n", "", getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_STEP_4_TITLE']), false))));
        $this->ss->assign("HEADER", $app_strings['LBL_IMPORT'] . " " . $mod_strings['LBL_MODULE_NAME']);
        // we export it as email_address, but import as email1
        $field_map['email_address'] = 'email1';
        // build each row; row count is determined by the the number of fields in the import file
        $columns = array();
        $mappedFields = array();
        for ($field_count = 0; $field_count < $ret_field_count; $field_count++) {
            // See if we have any field map matches
            $defaultValue = "";
            // Bug 31260 - If the data rows have more columns than the header row, then just add a new header column
            if (!isset($rows[0][$field_count])) {
                $rows[0][$field_count] = '';
            }
            // See if we can match the import row to a field in the list of fields to import
            $firstrow_name = trim(str_replace(":", "", $rows[0][$field_count]));
            if ($has_header && isset($field_map[$firstrow_name])) {
                $defaultValue = $field_map[$firstrow_name];
            } elseif (isset($field_map[$field_count])) {
                $defaultValue = $field_map[$field_count];
            } elseif (empty($_REQUEST['source_id'])) {
                $defaultValue = trim($rows[0][$field_count]);
            }
            // build string of options
            $fields = $this->bean->get_importable_fields();
            $options = array();
            $defaultField = '';
            foreach ($fields as $fieldname => $properties) {
                // get field name
                if (!empty($properties['vname'])) {
                    $displayname = str_replace(":", "", translate($properties['vname'], $this->bean->module_dir));
                } else {
                    $displayname = str_replace(":", "", translate($properties['name'], $this->bean->module_dir));
                }
                // see if this is required
                $req_mark = "";
                $req_class = "";
                if (array_key_exists($fieldname, $this->bean->get_import_required_fields())) {
                    $req_mark = ' ' . $app_strings['LBL_REQUIRED_SYMBOL'];
                    $req_class = ' class="required" ';
                }
                // see if we have a match
                $selected = '';
                if (!empty($defaultValue) && !in_array($fieldname, $mappedFields) && !in_array($fieldname, $ignored_fields)) {
                    if (strtolower($fieldname) == strtolower($defaultValue) || strtolower($fieldname) == str_replace(" ", "_", strtolower($defaultValue)) || strtolower($displayname) == strtolower($defaultValue) || strtolower($displayname) == str_replace(" ", "_", strtolower($defaultValue))) {
                        $selected = ' selected="selected" ';
                        $defaultField = $fieldname;
                        $mappedFields[] = $fieldname;
                    }
                }
                // get field type information
                $fieldtype = '';
                if (isset($properties['type']) && isset($mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])])) {
                    $fieldtype = ' [' . $mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])] . '] ';
                }
                if (isset($properties['comment'])) {
                    $fieldtype .= ' - ' . $properties['comment'];
                }
                $options[$displayname . $fieldname] = '<option value="' . $fieldname . '" title="' . $displayname . htmlentities($fieldtype) . '"' . $selected . $req_class . '>' . $displayname . $req_mark . '</option>\\n';
            }
            // get default field value
            $defaultFieldHTML = '';
            if (!empty($defaultField)) {
                $defaultFieldHTML = getControl($_REQUEST['import_module'], $defaultField, $fields[$defaultField], isset($default_values[$defaultField]) ? $default_values[$defaultField] : '');
            }
            if (isset($default_values[$defaultField])) {
                unset($default_values[$defaultField]);
            }
            // Bug 27046 - Sort the column name picker alphabetically
            ksort($options);
            $columns[] = array('field_choices' => implode('', $options), 'default_field' => $defaultFieldHTML, 'cell1' => str_replace("&quot;", '', htmlspecialchars($rows[0][$field_count])), 'cell2' => str_replace("&quot;", '', htmlspecialchars($rows[1][$field_count])), 'cell3' => str_replace("&quot;", '', htmlspecialchars($rows[2][$field_count])), 'show_remove' => false);
        }
        // add in extra defaulted fields if they are in the mapping record
        if (count($default_values) > 0) {
            foreach ($default_values as $field_name => $default_value) {
                // build string of options
                $fields = $this->bean->get_importable_fields();
                $options = array();
                $defaultField = '';
                foreach ($fields as $fieldname => $properties) {
                    // get field name
                    if (!empty($properties['vname'])) {
                        $displayname = str_replace(":", "", translate($properties['vname'], $this->bean->module_dir));
                    } else {
                        $displayname = str_replace(":", "", translate($properties['name'], $this->bean->module_dir));
                    }
                    // see if this is required
                    $req_mark = "";
                    $req_class = "";
                    if (array_key_exists($fieldname, $this->bean->get_import_required_fields())) {
                        $req_mark = ' ' . $app_strings['LBL_REQUIRED_SYMBOL'];
                        $req_class = ' class="required" ';
                    }
                    // see if we have a match
                    $selected = '';
                    if (strtolower($fieldname) == strtolower($field_name) && !in_array($fieldname, $mappedFields) && !in_array($fieldname, $ignored_fields)) {
                        $selected = ' selected="selected" ';
                        $defaultField = $fieldname;
                        $mappedFields[] = $fieldname;
                    }
                    // get field type information
                    $fieldtype = '';
                    if (isset($properties['type']) && isset($mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])])) {
                        $fieldtype = ' [' . $mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])] . '] ';
                    }
                    if (isset($properties['comment'])) {
                        $fieldtype .= ' - ' . $properties['comment'];
                    }
                    $options[$displayname . $fieldname] = '<option value="' . $fieldname . '" title="' . $displayname . $fieldtype . '"' . $selected . $req_class . '>' . $displayname . $req_mark . '</option>\\n';
                }
                // get default field value
                $defaultFieldHTML = '';
                if (!empty($defaultField)) {
                    $defaultFieldHTML = getControl($_REQUEST['import_module'], $defaultField, $fields[$defaultField], $default_value);
                }
                // Bug 27046 - Sort the column name picker alphabetically
                ksort($options);
                $columns[] = array('field_choices' => implode('', $options), 'default_field' => $defaultFieldHTML, 'show_remove' => true);
                $ret_field_count++;
            }
        }
        $this->ss->assign("COLUMNCOUNT", $ret_field_count);
        $this->ss->assign("rows", $columns);
        // get list of valid date/time formats
        $timeFormat = $current_user->getUserDateTimePreferences();
        $timeOptions = get_select_options_with_id($sugar_config['time_formats'], $timeFormat['time']);
        $dateOptions = get_select_options_with_id($sugar_config['date_formats'], $timeFormat['date']);
        $this->ss->assign('TIMEOPTIONS', $timeOptions);
        $this->ss->assign('DATEOPTIONS', $dateOptions);
        $this->ss->assign('datetimeformat', $GLOBALS['timedate']->get_cal_date_time_format());
        // get list of valid timezones
        $userTZ = $current_user->getPreference('timezone');
        if (empty($userTZ)) {
            $userTZ = TimeDate::userTimezone();
        }
        $this->ss->assign('TIMEZONE_CURRENT', $userTZ);
        $this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList());
        // get currency preference
        require_once 'modules/Currencies/ListCurrency.php';
        $currency = new ListCurrency();
        $cur_id = $locale->getPrecedentPreference('currency', $current_user);
        if ($cur_id) {
            $selectCurrency = $currency->getSelectOptions($cur_id);
            $this->ss->assign("CURRENCY", $selectCurrency);
        } else {
            $selectCurrency = $currency->getSelectOptions();
            $this->ss->assign("CURRENCY", $selectCurrency);
        }
        $currenciesVars = "";
        $i = 0;
        foreach ($locale->currencies as $id => $arrVal) {
            $currenciesVars .= "currencies[{$i}] = '{$arrVal['symbol']}';\n";
            $i++;
        }
        $currencySymbolsJs = <<<eoq
var currencies = new Object;
{$currenciesVars}
function setSymbolValue(id) {
    document.getElementById('symbol').value = currencies[id];
}
eoq;
        $this->ss->assign('currencySymbolJs', $currencySymbolsJs);
        // fill significant digits dropdown
        $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
        $sigDigits = '';
        for ($i = 0; $i <= 6; $i++) {
            if ($significantDigits == $i) {
                $sigDigits .= '<option value="' . $i . '" selected="true">' . $i . '</option>';
            } else {
                $sigDigits .= '<option value="' . $i . '">' . $i . '</option>';
            }
        }
        $this->ss->assign('sigDigits', $sigDigits);
        $num_grp_sep = $current_user->getPreference('num_grp_sep');
        $dec_sep = $current_user->getPreference('dec_sep');
        $this->ss->assign("NUM_GRP_SEP", empty($num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $num_grp_sep);
        $this->ss->assign("DEC_SEP", empty($dec_sep) ? $sugar_config['default_decimal_seperator'] : $dec_sep);
        $this->ss->assign('getNumberJs', $locale->getNumberJs());
        // Name display format
        $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($current_user));
        $this->ss->assign('getNameJs', $locale->getNameJs());
        // Charset
        $charsetOptions = get_select_options_with_id($locale->getCharsetSelect(), $charset_for_import);
        //wdong,  bug 25927, here we should use the charset testing results from above.
        $this->ss->assign('CHARSETOPTIONS', $charsetOptions);
        // handle building index selector
        global $dictionary, $current_language;
        require_once "include/templates/TemplateGroupChooser.php";
        $chooser_array = array();
        $chooser_array[0] = array();
        $idc = new ImportDuplicateCheck($this->bean);
        $chooser_array[1] = $idc->getDuplicateCheckIndexes();
        $chooser = new TemplateGroupChooser();
        $chooser->args['id'] = 'selected_indices';
        $chooser->args['values_array'] = $chooser_array;
        $chooser->args['left_name'] = 'choose_index';
        $chooser->args['right_name'] = 'ignore_index';
        $chooser->args['left_label'] = $mod_strings['LBL_INDEX_USED'];
        $chooser->args['right_label'] = $mod_strings['LBL_INDEX_NOT_USED'];
        $this->ss->assign("TAB_CHOOSER", $chooser->display());
        // show notes
        if ($this->bean instanceof Person) {
            $module_key = "LBL_CONTACTS_NOTE_";
        } elseif ($this->bean instanceof Company) {
            $module_key = "LBL_ACCOUNTS_NOTE_";
        } else {
            $module_key = "LBL_" . strtoupper($_REQUEST['import_module']) . "_NOTE_";
        }
        $notetext = '';
        for ($i = 1; isset($mod_strings[$module_key . $i]); $i++) {
            $notetext .= '<li>' . $mod_strings[$module_key . $i] . '</li>';
        }
        $this->ss->assign("NOTETEXT", $notetext);
        $this->ss->assign("HAS_HEADER", $has_header ? 'on' : 'off');
        // get list of required fields
        $required = array();
        foreach (array_keys($this->bean->get_import_required_fields()) as $name) {
            $properties = $this->bean->getFieldDefinition($name);
            if (!empty($properties['vname'])) {
                $required[$name] = str_replace(":", "", translate($properties['vname'], $this->bean->module_dir));
            } else {
                $required[$name] = str_replace(":", "", translate($properties['name'], $this->bean->module_dir));
            }
        }
        // include anything needed for quicksearch to work
        require_once "include/TemplateHandler/TemplateHandler.php";
        $quicksearch_js = TemplateHandler::createQuickSearchCode($fields, $fields, 'importstep3');
        $this->ss->assign("JAVASCRIPT", $quicksearch_js . "\n" . $this->_getJS($required));
        $this->ss->assign('required_fields', implode(', ', $required));
        $this->ss->display('modules/Import/tpls/step3.tpl');
    }
예제 #4
0
    private function setCurrencyOptions($field_map = array())
    {
        global $locale, $current_user;
        $cur_id = isset($field_map['importlocale_currency']) ? $field_map['importlocale_currency'] : $locale->getPrecedentPreference('currency', $current_user);
        // get currency preference
        require_once 'modules/Currencies/ListCurrency.php';
        $currency = new ListCurrency();
        if ($cur_id) {
            $selectCurrency = $currency->getSelectOptions($cur_id);
        } else {
            $selectCurrency = $currency->getSelectOptions();
        }
        $this->ss->assign("CURRENCY", $selectCurrency);
        $currenciesVars = "";
        $i = 0;
        foreach ($locale->currencies as $id => $arrVal) {
            $currenciesVars .= "currencies[{$i}] = '{$arrVal['symbol']}';\n";
            $i++;
        }
        $currencySymbolsJs = <<<eoq
var currencies = new Object;
{$currenciesVars}
function setSymbolValue(id) {
    document.getElementById('symbol').value = currencies[id];
}
eoq;
        return $currencySymbolsJs;
    }
예제 #5
0
 protected function setupAdvancedTabLocaleSettings()
 {
     global $locale, $sugar_config, $app_list_strings;
     ///////////////////////////////////////////////////////////////////////////////
     ////	LOCALE SETTINGS
     ////	Date/time format
     $dformat = $locale->getPrecedentPreference($this->bean->id ? 'datef' : 'default_date_format', $this->bean);
     $tformat = $locale->getPrecedentPreference($this->bean->id ? 'timef' : 'default_time_format', $this->bean);
     $nformat = $locale->getPrecedentPreference('default_locale_name_format', $this->bean);
     if (!array_key_exists($nformat, $sugar_config['name_formats'])) {
         $nformat = $sugar_config['default_locale_name_format'];
     }
     $timeOptions = get_select_options_with_id($sugar_config['time_formats'], $tformat);
     $dateOptions = get_select_options_with_id($sugar_config['date_formats'], $dformat);
     $nameOptions = get_select_options_with_id($locale->getUsableLocaleNameOptions($sugar_config['name_formats']), $nformat);
     $this->ss->assign('TIMEOPTIONS', $timeOptions);
     $this->ss->assign('DATEOPTIONS', $dateOptions);
     $this->ss->assign('NAMEOPTIONS', $nameOptions);
     $this->ss->assign('DATEFORMAT', $sugar_config['date_formats'][$dformat]);
     $this->ss->assign('TIMEFORMAT', $sugar_config['time_formats'][$tformat]);
     $this->ss->assign('NAMEFORMAT', $sugar_config['name_formats'][$nformat]);
     //// Timezone
     if (empty($this->bean->id)) {
         // remove default timezone for new users(set later)
         $this->bean->user_preferences['timezone'] = '';
     }
     $userTZ = $this->bean->getPreference('timezone');
     if (empty($userTZ) && !$this->bean->is_group && !$this->bean->portal_only) {
         $userTZ = TimeDate::guessTimezone();
         $this->bean->setPreference('timezone', $userTZ);
     }
     if (!$this->bean->getPreference('ut')) {
         $this->ss->assign('PROMPTTZ', ' checked');
     }
     $this->ss->assign('TIMEZONE_CURRENT', $userTZ);
     $this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList());
     $this->ss->assign("TIMEZONE", TimeDate::tzName($userTZ));
     // FG - Bug 4236 - Managed First Day of Week
     $fdowDays = array();
     foreach ($app_list_strings['dom_cal_day_long'] as $d) {
         if ($d != "") {
             $fdowDays[] = $d;
         }
     }
     $this->ss->assign("FDOWOPTIONS", $fdowDays);
     $currentFDOW = $this->bean->get_first_day_of_week();
     if (!isset($currentFDOW)) {
         $currentFDOW = 0;
     }
     $this->ss->assign("FDOWCURRENT", $currentFDOW);
     $this->ss->assign("FDOWDISPLAY", $fdowDays[$currentFDOW]);
     //// Numbers and Currency display
     require_once 'modules/Currencies/ListCurrency.php';
     $currency = new ListCurrency();
     // 10/13/2006 Collin - Changed to use Localization.getConfigPreference
     // This was the problem- Previously, the "-99" currency id always assumed
     // to be defaulted to US Dollars.  However, if someone set their install to use
     // Euro or other type of currency then this setting would not apply as the
     // default because it was being overridden by US Dollars.
     $cur_id = $locale->getPrecedentPreference('currency', $this->bean);
     if ($cur_id) {
         $selectCurrency = $currency->getSelectOptions($cur_id);
         $this->ss->assign("CURRENCY", $selectCurrency);
     } else {
         $selectCurrency = $currency->getSelectOptions();
         $this->ss->assign("CURRENCY", $selectCurrency);
     }
     // convert base currency values to user preferred
     $this->ss->assign("currency_show_preferred", $locale->getPrecedentPreference('currency_show_preferred', $this->bean));
     $currencyList = array();
     foreach ($locale->currencies as $id => $val) {
         $currencyList[$id] = $val['symbol'];
     }
     $currencySymbolJSON = json_encode($currencyList);
     $this->ss->assign('currencySymbolJSON', $currencySymbolJSON);
     $currencyDisplay = BeanFactory::getBean('Currencies');
     if (isset($cur_id)) {
         $currencyDisplay->retrieve($cur_id);
         $this->ss->assign('CURRENCY_DISPLAY', $currencyDisplay->iso4217 . ' ' . $currencyDisplay->symbol);
     } else {
         $this->ss->assign("CURRENCY_DISPLAY", $currencyDisplay->getDefaultISO4217() . ' ' . $currencyDisplay->getDefaultCurrencySymbol());
     }
     // fill significant digits dropdown
     $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $this->bean);
     $sigDigits = '';
     for ($i = 0; $i <= 6; $i++) {
         if ($significantDigits == $i) {
             $sigDigits .= "<option value=\"{$i}\" selected=\"true\">{$i}</option>";
         } else {
             $sigDigits .= "<option value=\"{$i}\">{$i}</option>";
         }
     }
     $this->ss->assign('sigDigits', $sigDigits);
     $this->ss->assign('CURRENCY_SIG_DIGITS', $significantDigits);
     $num_grp_sep = $this->bean->getPreference('num_grp_sep');
     $dec_sep = $this->bean->getPreference('dec_sep');
     $this->ss->assign("NUM_GRP_SEP", empty($num_grp_sep) ? $GLOBALS['sugar_config']['default_number_grouping_seperator'] : $num_grp_sep);
     $this->ss->assign("DEC_SEP", empty($dec_sep) ? $GLOBALS['sugar_config']['default_decimal_seperator'] : $dec_sep);
     $this->ss->assign('getNumberJs', $locale->getNumberJs());
     //// Name display format
     $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($this->bean));
     $this->ss->assign('getNameJs', $locale->getNameJs());
     $this->ss->assign('NAME_FORMAT', $this->bean->getLocaleFormatDesc());
     ////	END LOCALE SETTINGS
 }
예제 #6
0
    /**
     * @see SugarView::display()
     */
    public function display()
    {
        global $mod_strings, $current_user, $locale, $sugar_config, $app_list_strings, $sugar_version;
        $themeObject = SugarThemeRegistry::current();
        $css = $themeObject->getCSS();
        $this->ss->assign('SUGAR_CSS', $css);
        $favicon = $themeObject->getImageURL('sugar_icon.ico', false);
        $this->ss->assign('FAVICON_URL', getJSPath($favicon));
        $this->ss->assign('CSS', '<link rel="stylesheet" type="text/css" href="' . SugarThemeRegistry::current()->getCSSURL('wizard.css') . '" />');
        $this->ss->assign('JAVASCRIPT', user_get_validate_record_js() . user_get_chooser_js() . user_get_confsettings_js());
        $this->ss->assign('PRINT_URL', 'index.php?' . $GLOBALS['request_string']);
        $this->ss->assign('SKIP_WELCOME', isset($_REQUEST['skipwelcome']) && $_REQUEST['skipwelcome'] == 1);
        $this->ss->assign('ID', $current_user->id);
        $this->ss->assign('USER_NAME', $current_user->user_name);
        $this->ss->assign('FIRST_NAME', $current_user->first_name);
        $this->ss->assign('SUGAR_VERSION', $sugar_version);
        $this->ss->assign('LAST_NAME', $current_user->last_name);
        $this->ss->assign('TITLE', $current_user->title);
        $this->ss->assign('DEPARTMENT', $current_user->department);
        $this->ss->assign('REPORTS_TO_ID', $current_user->reports_to_id);
        $this->ss->assign('REPORTS_TO_NAME', $current_user->reports_to_name);
        $this->ss->assign('PHONE_HOME', $current_user->phone_home);
        $this->ss->assign('PHONE_MOBILE', $current_user->phone_mobile);
        $this->ss->assign('PHONE_WORK', $current_user->phone_work);
        $this->ss->assign('PHONE_OTHER', $current_user->phone_other);
        $this->ss->assign('PHONE_FAX', $current_user->phone_fax);
        $this->ss->assign('EMAIL1', $current_user->email1);
        $this->ss->assign('EMAIL2', $current_user->email2);
        $this->ss->assign('ADDRESS_STREET', $current_user->address_street);
        $this->ss->assign('ADDRESS_CITY', $current_user->address_city);
        $this->ss->assign('ADDRESS_STATE', $current_user->address_state);
        $this->ss->assign('ADDRESS_POSTALCODE', $current_user->address_postalcode);
        $this->ss->assign('ADDRESS_COUNTRY', $current_user->address_country);
        $configurator = new Configurator();
        if ($configurator->config['passwordsetting']['SystemGeneratedPasswordON'] || $configurator->config['passwordsetting']['forgotpasswordON']) {
            $this->ss->assign('REQUIRED_EMAIL_ADDRESS', '1');
        } else {
            $this->ss->assign('REQUIRED_EMAIL_ADDRESS', '0');
        }
        // get javascript
        ob_start();
        $this->options['show_javascript'] = true;
        $this->renderJavascript();
        $this->options['show_javascript'] = false;
        $this->ss->assign("SUGAR_JS", ob_get_contents() . $themeObject->getJS());
        ob_end_clean();
        $messenger_type = '<select tabindex="5" name="messenger_type">';
        $messenger_type .= get_select_options_with_id($app_list_strings['messenger_type_dom'], $current_user->messenger_type);
        $messenger_type .= '</select>';
        $this->ss->assign('MESSENGER_TYPE_OPTIONS', $messenger_type);
        $this->ss->assign('MESSENGER_ID', $current_user->messenger_id);
        // set default settings
        $use_real_names = $current_user->getPreference('use_real_names');
        if (empty($use_real_names)) {
            $current_user->setPreference('use_real_names', 'on');
        }
        $current_user->setPreference('reminder_time', 1800);
        $current_user->setPreference('email_reminder_time', 3600);
        $current_user->setPreference('mailmerge_on', 'on');
        //// Timezone
        if (empty($current_user->id)) {
            // remove default timezone for new users(set later)
            $current_user->user_preferences['timezone'] = '';
        }
        $userTZ = $current_user->getPreference('timezone');
        if (empty($userTZ) && !$current_user->is_group && !$current_user->portal_only) {
            $userTZ = TimeDate::guessTimezone();
            $current_user->setPreference('timezone', $userTZ);
        }
        if (!$current_user->getPreference('ut')) {
            $this->ss->assign('PROMPTTZ', ' checked');
        }
        $this->ss->assign('TIMEZONE_CURRENT', $userTZ);
        $this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList());
        //// Numbers and Currency display
        require_once 'modules/Currencies/ListCurrency.php';
        $currency = new ListCurrency();
        // 10/13/2006 Collin - Changed to use Localization.getConfigPreference
        // This was the problem- Previously, the "-99" currency id always assumed
        // to be defaulted to US Dollars.  However, if someone set their install to use
        // Euro or other type of currency then this setting would not apply as the
        // default because it was being overridden by US Dollars.
        $cur_id = $locale->getPrecedentPreference('currency', $current_user);
        if ($cur_id) {
            $selectCurrency = $currency->getSelectOptions($cur_id);
            $this->ss->assign("CURRENCY", $selectCurrency);
        } else {
            $selectCurrency = $currency->getSelectOptions();
            $this->ss->assign("CURRENCY", $selectCurrency);
        }
        $currenciesArray = $locale->currencies;
        $currenciesVars = $this->correctCurrenciesSymbolsSort($currenciesArray);
        $currencySymbolsJs = <<<eoq
var currencies = new Object;
{$currenciesVars}
function setSymbolValue(id) {
\tdocument.getElementById('symbol').value = currencies[id];
}
eoq;
        $this->ss->assign('currencySymbolJs', $currencySymbolsJs);
        // fill significant digits dropdown
        $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
        $sigDigits = '';
        for ($i = 0; $i <= 6; $i++) {
            if ($significantDigits == $i) {
                $sigDigits .= "<option value=\"{$i}\" selected=\"true\">{$i}</option>";
            } else {
                $sigDigits .= "<option value=\"{$i}\">{$i}</option>";
            }
        }
        $this->ss->assign('sigDigits', $sigDigits);
        $num_grp_sep = $current_user->getPreference('num_grp_sep');
        $dec_sep = $current_user->getPreference('dec_sep');
        $this->ss->assign("NUM_GRP_SEP", empty($num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $num_grp_sep);
        $this->ss->assign("DEC_SEP", empty($dec_sep) ? $sugar_config['default_decimal_seperator'] : $dec_sep);
        $this->ss->assign('getNumberJs', $locale->getNumberJs());
        //// Name display format
        $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($current_user));
        $this->ss->assign('getNameJs', $locale->getNameJs());
        $this->ss->assign('TIMEOPTIONS', get_select_options_with_id($sugar_config['time_formats'], $current_user->_userPreferenceFocus->getDefaultPreference('default_time_format')));
        $this->ss->assign('DATEOPTIONS', get_select_options_with_id($sugar_config['date_formats'], $current_user->_userPreferenceFocus->getDefaultPreference('default_date_format')));
        $this->ss->assign("MAIL_SENDTYPE", get_select_options_with_id($app_list_strings['notifymail_sendtype'], $current_user->getPreference('mail_sendtype')));
        $this->ss->assign("NEW_EMAIL", $current_user->emailAddress->getEmailAddressWidgetEditView($current_user->id, $current_user->module_dir));
        $this->ss->assign('EMAIL_LINK_TYPE', get_select_options_with_id($app_list_strings['dom_email_link_type'], $current_user->getPreference('email_link_type')));
        $selectedLocaleNameFormat = $current_user->_userPreferenceFocus->getDefaultPreference('default_locale_name_format');
        if (array_key_exists($selectedLocaleNameFormat, $sugar_config['name_formats'])) {
            $selectedLocaleNameFormat = $sugar_config['default_locale_name_format'];
        }
        $this->ss->assign('NAMEOPTIONS', get_select_options_with_id($locale->getUsableLocaleNameOptions($sugar_config['name_formats']), $selectedLocaleNameFormat));
        // email smtp
        $systemOutboundEmail = new OutboundEmail();
        $systemOutboundEmail = $systemOutboundEmail->getSystemMailerSettings();
        $mail_smtpserver = $systemOutboundEmail->mail_smtpserver;
        $mail_smtptype = $systemOutboundEmail->mail_smtptype;
        $mail_smtpport = $systemOutboundEmail->mail_smtpport;
        $mail_smtpssl = $systemOutboundEmail->mail_smtpssl;
        $mail_smtpdisplay = $systemOutboundEmail->mail_smtpdisplay;
        $mail_smtpuser = "";
        $mail_smtppass = "";
        $hide_if_can_use_default = true;
        $mail_smtpauth_req = true;
        if (!empty($mail_smtpserver) && !empty($mail_smtptype)) {
            if (!$systemOutboundEmail->isAllowUserAccessToSystemDefaultOutbound()) {
                $mail_smtpauth_req = $systemOutboundEmail->mail_smtpauth_req;
                $userOverrideOE = $systemOutboundEmail->getUsersMailerForSystemOverride($current_user->id);
                if ($userOverrideOE != null) {
                    $mail_smtpuser = $userOverrideOE->mail_smtpuser;
                    $mail_smtppass = $userOverrideOE->mail_smtppass;
                }
                if (!$mail_smtpauth_req && (empty($systemOutboundEmail->mail_smtpserver) || empty($systemOutboundEmail->mail_smtpuser) || empty($systemOutboundEmail->mail_smtppass))) {
                    $hide_if_can_use_default = true;
                } else {
                    $hide_if_can_use_default = false;
                }
            }
        }
        $isAdmin = is_admin($current_user);
        $this->ss->assign('IS_ADMIN', $isAdmin);
        $this->ss->assign("mail_smtpdisplay", $mail_smtpdisplay);
        $this->ss->assign("mail_smtpuser", $mail_smtpuser);
        $this->ss->assign("mail_smtppass", $mail_smtppass);
        $this->ss->assign('mail_smtpserver', $mail_smtpserver);
        $this->ss->assign("mail_smtpauth_req", $mail_smtpauth_req);
        $this->ss->assign('MAIL_SMTPPORT', $mail_smtpport);
        $this->ss->assign('MAIL_SMTPSSL', $mail_smtpssl);
        $this->ss->assign('HIDE_IF_CAN_USE_DEFAULT_OUTBOUND', $hide_if_can_use_default);
        $this->ss->assign('langHeader', get_language_header());
        $this->ss->display($this->getCustomFilePathIfExists('modules/Users/tpls/wizard.tpl'));
    }
예제 #7
0
function getCurrencyDropDown($focus, $field = 'currency_id', $value = '', $view = 'DetailView')
{
    $view = ucfirst($view);
    if ($view == 'EditView' || $view == 'MassUpdate' || $view == 'QuickCreate' || $view == 'ConvertLead') {
        if (isset($_REQUEST[$field]) && !empty($_REQUEST[$field])) {
            $value = $_REQUEST[$field];
        } elseif (empty($focus->id)) {
            $value = $GLOBALS['current_user']->getPreference('currency');
            if (empty($value)) {
                // -99 is the system default currency
                $value = -99;
            }
        }
        require_once 'modules/Currencies/ListCurrency.php';
        $currency_fields = array();
        //Bug 18276 - Fix for php 5.1.6
        $defs = $focus->field_defs;
        //
        foreach ($defs as $name => $key) {
            if ($key['type'] == 'currency') {
                $currency_fields[] = $name;
            }
        }
        $currency = new ListCurrency();
        $selectCurrency = $currency->getSelectOptions($value);
        $currency->setCurrencyFields($currency_fields);
        $html = '<select name="';
        // If it's a lead conversion (ConvertLead view), add the module_name before the $field
        if ($view == "ConvertLead") {
            $html .= $focus->module_name;
        }
        $html .= $field . '" id="' . $field . '_select" ';
        if ($view != 'MassUpdate') {
            $html .= 'onchange="CurrencyConvertAll(this.form);"';
        }
        $html .= '>' . $selectCurrency . '</select>';
        if ($view != 'MassUpdate') {
            $html .= $currency->getJavascript();
        }
        return $html;
    } else {
        $currency = new Currency();
        $currency->retrieve($value);
        return $currency->name;
    }
}
예제 #8
0
        }
    }
    $lc->lookupCurrencies();
    if (isset($focus->id)) {
        $focus_id = $focus->id;
    } else {
        $focus_id = '';
    }
    $merge_button = '';
    $pretable = '';
    if (isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'merge' || isset($isMerge) && !$isMerge) {
        $merge_button = '<form name= "MERGE" method="POST" action="index.php"><input type="hidden" name="module" value="Currencies"><input type="hidden" name="record" value="' . $focus_id . '"><input type="hidden" name="action" value="index"><input type="hidden" name="merge" value="true"><input title="' . $mod_strings['LBL_MERGE'] . '"  class="button"  type="submit" name="button" value="' . $mod_strings['LBL_MERGE'] . '" ></form>';
    }
    if (isset($isMerge) && $isMerge) {
        $currencyList = new ListCurrency();
        $listoptions = $currencyList->getSelectOptions();
        $pretable = <<<EOQ
\t\t<form name= "MERGE" method="POST" action="index.php">
\t\t\t<input type="hidden" name="module" value="Currencies">
\t\t\t
\t\t\t<input type="hidden" name="action" value="index">
\t\t<table width="100%" cellspacing="0" cellpadding="0" border="0" class="edit view">
\t\t\t<tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
\t\t\t<td>{$mod_strings['LBL_MERGE_TXT']}</td><td width='20%'><select name='mergeTo'>{$listoptions}</select></td>
\t\t\t</tr>
\t\t\t<tr><td></td><td><input title="{$mod_strings['LBL_MERGE']}" class="button" type="submit" name="domerge" value="{$mod_strings['LBL_MERGE']}" >
\t\t<input title="{$app_strings['LBL_CANCEL_BUTTON_TITLE']}" accessKey="{$app_strings['LBL_CANCEL_BUTTON_KEY']}" class="button"  type="submit" name="button" value="{$app_strings['LBL_CANCEL_BUTTON_LABEL']}" > </td></tr>
\t\t\t</table></td></tr></table><br>
EOQ;
    }
    $edit_botton = '<form name="EditView" method="POST" action="index.php" >';
예제 #9
0
function getCurrencyDropDown($focus, $field = 'currency_id', $value = '', $view = 'DetailView')
{
    if ($view == 'EditView' || $view == 'MassUpdate' || $view == 'QuickCreate') {
        require_once 'modules/Currencies/ListCurrency.php';
        $currency_fields = array();
        //Bug 18276 - Fix for php 5.1.6
        $defs = $focus->field_defs;
        //
        foreach ($defs as $name => $key) {
            if ($key['type'] == 'currency') {
                $currency_fields[] = $name;
            }
        }
        $currency = new ListCurrency();
        if (!empty($value)) {
            $selectCurrency = $currency->getSelectOptions($value);
        } else {
            if ($GLOBALS['current_user']->getPreference('currency') && empty($focus->id)) {
                $selectCurrency = $currency->getSelectOptions($GLOBALS['current_user']->getPreference('currency'));
            } else {
                $selectCurrency = $currency->getSelectOptions();
            }
        }
        $currency->setCurrencyFields($currency_fields);
        $html = '<select name="' . $field . '" ';
        if ($view != 'MassUpdate') {
            $html .= 'onchange="CurrencyConvertAll();"';
        }
        $html .= '>' . $selectCurrency . '</select>';
        if ($view != 'MassUpdate') {
            $html .= $currency->getJavascript();
        }
        return $html;
    } else {
        $currency = new Currency();
        $currency->retrieve($value);
        return $currency->name;
    }
}
예제 #10
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>';
 }
예제 #11
0
$row_count = $focus->getQuotaRowCount($focus->create_new_list_query("", $where));
if (!empty($_REQUEST['timeperiod_id'])) {
    /* if the user is not a manager, get the user's self quota
     * and use a strip down version of ListView to process the
     * quota object
     */
    if (!$focus->isManager($current_user->id)) {
        $ListView->processListView($focus, "", "");
    } else {
        /* if records are available for the direct reports, 
         * get the group quota and process the ListView
         */
        if ($row_count > 0) {
            $groupQuota = $focus->getGroupQuota($_REQUEST['timeperiod_id']);
            $ListView->xTemplateAssign("GROUP_QUOTA", outputGroupQuota($focus->getGroupQuota($_REQUEST['timeperiod_id'], false)));
            $currency->getSelectOptions();
            $ListView->xTemplateAssign("JAVASCRIPT2", $currency->getJavascript());
            $ListView->processListViewTwo($focus, "main", "QUOTA");
        } else {
            $ListView->xTemplateAssign("NOQUOTA", $mod_strings['LBL_NO_QUOTAS_TIMEPERIOD']);
            $ListView->processListViewTwo($focus, "main", "");
        }
        ///////////////////////////////////////////////////////////////////////////////
        ////	QUOTAS MODULE EDIT VIEW
        $GLOBALS['log']->info("Quota edit view");
        $committed = '';
        $disabled = '';
        if ($focus->currency_id == NULL) {
            $selectCurrency = $currency->getSelectOptions();
        } else {
            $selectCurrency = $currency->getSelectOptions($focus->currency_id);