📄 view.step4.php
字号:
<?phpif(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');/********************************************************************************* * SugarCRM is a customer relationship management program developed by * SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation with the addition of the following permission added * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. * * 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 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. * * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************//********************************************************************************* * Description: view handler for step 4 of the import process * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. ********************************************************************************/ require_once('include/MVC/View/SugarView.php');require_once('modules/Import/Forms.php');require_once('modules/Import/ImportMap.php');require_once('modules/Import/ImportFile.php');require_once('modules/Import/ImportFileSplitter.php');require_once('modules/Import/ImportCacheFiles.php');require_once('modules/Import/ImportFieldSanitize.php');require_once('modules/Import/ImportDuplicateCheck.php');require_once('modules/Trackers/TrackerManager.php');require_once('include/utils.php'); class ImportViewStep4 extends SugarView { /** * Constructor */ public function __construct() { parent::SugarView(); } /** * display the form */ public function display() { global $sugar_config; if (isset($sugar_config['import_max_execution_time'])) { ini_set("max_execution_time", $sugar_config['import_max_execution_time']); } else { ini_set("max_execution_time", 3600); } // stop the tracker TrackerManager::getInstance()->pause(); // use our own error handler set_error_handler('handleImportErrors',E_ALL); global $mod_strings, $app_strings, $current_user, $import_bean_map; global $current_language, $timedate, $rowValue; $app_list_strings = return_app_list_strings_language($current_language); $update_only = ( isset($_REQUEST['type']) && $_REQUEST['type'] == 'update' ); $firstrow = unserialize(base64_decode($_REQUEST['firstrow'])); // All the Look Up Caches are initialized here $enum_lookup_cache=array(); // Let's try and load the import bean $focus = loadImportBean($_REQUEST['import_module']); if ( !$focus ) { trigger_error($mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'],E_USER_ERROR); } // setup the importable fields array. $importable_fields = $focus->get_importable_fields(); // loop through all request variables $importColumns = array(); foreach ($_REQUEST as $name => $value) { // only look for var names that start with "fieldNum" if (strncasecmp($name, "colnum_", 7) != 0) { continue; } // pull out the column position for this field name $pos = substr($name, 7); if ( isset($importable_fields[$value]) ) { // now mark that we've seen this field $importColumns[$pos] = $value; } } // set the default locale settings $ifs = new ImportFieldSanitize(); $ifs->dateformat = $_REQUEST['importlocale_dateformat']; $ifs->timeformat = $_REQUEST['importlocale_timeformat']; $ifs->timezone = $_REQUEST['importlocale_timezone']; require_once('modules/Currencies/Currency.php'); $currency = new Currency(); $currency->retrieve($_REQUEST['importlocale_currency']); $ifs->currency_symbol = $currency->symbol; $ifs->default_currency_significant_digits = $_REQUEST['importlocale_default_currency_significant_digits']; $ifs->num_grp_sep = $_REQUEST['importlocale_num_grp_sep']; $ifs->dec_sep = $_REQUEST['importlocale_dec_sep']; $ifs->default_locale_name_format = $_REQUEST['importlocale_default_locale_name_format']; // Check to be sure we are getting an import file that is in the right place if ( realpath(dirname($_REQUEST['tmp_file']).'/') != realpath($sugar_config['upload_dir']) ) trigger_error($mod_strings['LBL_CANNOT_OPEN'],E_USER_ERROR); // Open the import file $importFile = new ImportFile( $_REQUEST['tmp_file'], $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure']) ); if ( !$importFile->fileExists() ) { trigger_error($mod_strings['LBL_CANNOT_OPEN'],E_USER_ERROR); } $fieldDefs = $focus->getFieldDefinitions(); unset($focus); while ( $row = $importFile->getNextRow() ) { $focus = loadImportBean($_REQUEST['import_module']); $focus->save_from_post = false; $do_save = true; for ( $fieldNum = 0; $fieldNum < $_REQUEST['columncount']; $fieldNum++ ) { // loop if this column isn't set if ( !isset($importColumns[$fieldNum]) ) { continue; } // get this field's properties $field = $importColumns[$fieldNum]; $fieldDef = $focus->getFieldDefinition($field); $fieldTranslated = translate((isset($fieldDef['vname'])?$fieldDef['vname']:$fieldDef['name']), $_REQUEST['module'])." (".$fieldDef['name'].")"; // translate strings global $locale; if(empty($locale)) { require_once('include/Localization/Localization.php'); $locale = new Localization(); } if ( isset($row[$fieldNum]) ) $rowValue = $locale->translateCharset( strip_tags(trim($row[$fieldNum])), $_REQUEST['importlocale_charset'], $sugar_config['default_charset'] ); else $rowValue = ''; // If there is an default value then use it instead if ( !empty($_REQUEST[$field]) && empty($rowValue) ) { $rowValue = $_REQUEST[$field]; // translate default values to the date/time format for the import file if ( $fieldDef['type'] == 'date' && $ifs->dateformat != $timedate->get_date_format() ) $rowValue = $timedate->swap_formats( $rowValue, $ifs->dateformat, $timedate->get_date_format()); if ( $fieldDef['type'] == 'time' && $ifs->timeformat != $timedate->get_time_format() ) $rowValue = $timedate->swap_formats( $rowValue, $ifs->timeformat, $timedate->get_time_format()); if ( $fieldDef['type'] == 'datetime' && $ifs->dateformat.' '.$ifs->timeformat != $timedate->get_date_time_format() ) $rowValue = $timedate->swap_formats( $rowValue, $ifs->dateformat.' '.$ifs->timeformat, $timedate->get_date_time_format()); if ( in_array($fieldDef['type'],array('currency','float','int','num')) && $ifs->num_grp_sep != $current_user->getPreference('num_grp_sep') ) $rowValue = str_replace($current_user->getPreference('num_grp_sep'), $ifs->num_grp_sep,$rowValue); if ( in_array($fieldDef['type'],array('currency','float')) && $ifs->dec_sep != $current_user->getPreference('dec_sep') ) $rowValue = str_replace($current_user->getPreference('dec_sep'), $ifs->dec_sep,$rowValue); $currency->retrieve('-99'); $user_currency_symbol = $currency->symbol; if ( $fieldDef['type'] == 'currency' && $ifs->currency_symbol != $user_currency_symbol ) $rowValue = str_replace($user_currency_symbol, $ifs->currency_symbol,$rowValue); } // loop if this value has not been set
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -