2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
38 /*********************************************************************************
40 * Description: view handler for step 2 of the import process
41 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42 * All Rights Reserved.
43 ********************************************************************************/
45 require_once('include/MVC/View/SugarView.php');
48 class ImportViewStep2 extends SugarView
51 * @see SugarView::getMenu()
53 public function getMenu(
57 global $mod_strings, $current_language;
60 $module = $_REQUEST['import_module'];
62 $old_mod_strings = $mod_strings;
63 $mod_strings = return_module_language($current_language, $module);
64 $returnMenu = parent::getMenu($module);
65 $mod_strings = $old_mod_strings;
71 * @see SugarView::_getModuleTab()
73 protected function _getModuleTab()
75 global $app_list_strings, $moduleTabMap;
77 // Need to figure out what tab this module belongs to, most modules have their own tabs, but there are exceptions.
78 if ( !empty($_REQUEST['module_tab']) )
79 return $_REQUEST['module_tab'];
80 elseif ( isset($moduleTabMap[$_REQUEST['import_module']]) )
81 return $moduleTabMap[$_REQUEST['import_module']];
82 // Default anonymous pages to be under Home
83 elseif ( !isset($app_list_strings['moduleList'][$_REQUEST['import_module']]) )
86 return $_REQUEST['import_module'];
90 * @see SugarView::_getModuleTitleParams()
92 protected function _getModuleTitleParams()
97 "<a href='index.php?module={$_REQUEST['import_module']}&action=index'><img src='".SugarThemeRegistry::current()->getImageURL('icon_'.$_REQUEST['import_module'].'_32.png')."' alt='".$_REQUEST['import_module']."' title='".$_REQUEST['import_module']."' align='absmiddle'></a>",
98 "<a href='index.php?module=Import&action=Step1&import_module={$_REQUEST['import_module']}'>".$mod_strings['LBL_MODULE_NAME']."</a>",
99 $mod_strings['LBL_STEP_2_TITLE'],
104 * @see SugarView::display()
106 public function display()
108 global $mod_strings, $app_list_strings, $app_strings, $current_user, $import_bean_map;
109 global $import_mod_strings;
111 $this->ss->assign("MODULE_TITLE", $this->getModuleTitle());
112 $this->ss->assign("MOD", $mod_strings);
113 $this->ss->assign("APP", $app_strings);
114 $this->ss->assign("IMP", $import_mod_strings);
115 $this->ss->assign("TYPE",( !empty($_REQUEST['type']) ? $_REQUEST['type'] : "import" ));
116 $this->ss->assign("CUSTOM_DELIMITER",
117 ( !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : "," ));
118 $this->ss->assign("CUSTOM_ENCLOSURE",htmlentities(
119 ( !empty($_REQUEST['custom_enclosure']) && $_REQUEST['custom_enclosure'] != 'other'
120 ? $_REQUEST['custom_enclosure'] :
121 ( !empty($_REQUEST['custom_enclosure_other'])
122 ? $_REQUEST['custom_enclosure_other'] : "" ) )));
124 $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
125 $this->ss->assign("HEADER", $app_strings['LBL_IMPORT']." ". $mod_strings['LBL_MODULE_NAME']);
126 $this->ss->assign("JAVASCRIPT", $this->_getJS());
129 $focus = loadImportBean($_REQUEST['import_module']);
131 showImportError($mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'],$_REQUEST['import_module']);
135 // special for importing from Outlook
136 if ($_REQUEST['source'] == "outlook") {
137 $this->ss->assign("SOURCE", $_REQUEST['source']);
138 $this->ss->assign("SOURCE_NAME","Outlook ");
139 $this->ss->assign("HAS_HEADER_CHECKED"," CHECKED");
141 // see if the source starts with 'custom'
142 // if so, pull off the id, load that map, and get the name
143 elseif ( strncasecmp("custom:",$_REQUEST['source'],7) == 0) {
144 $id = substr($_REQUEST['source'],7);
145 $import_map_seed = new ImportMap();
146 $import_map_seed->retrieve($id, false);
148 $this->ss->assign("SOURCE_ID", $import_map_seed->id);
149 $this->ss->assign("SOURCE_NAME", $import_map_seed->name);
150 $this->ss->assign("SOURCE", $import_map_seed->source);
151 if (isset($import_map_seed->delimiter))
152 $this->ss->assign("CUSTOM_DELIMITER", $import_map_seed->delimiter);
153 if (isset($import_map_seed->enclosure))
154 $this->ss->assign("CUSTOM_ENCLOSURE", htmlentities($import_map_seed->enclosure));
155 if ($import_map_seed->has_header)
156 $this->ss->assign("HAS_HEADER_CHECKED"," CHECKED");
159 $classname = 'ImportMap' . ucfirst($_REQUEST['source']);
160 require("modules/Import/{$classname}.php");
161 $import_map_seed = new $classname;
162 if (isset($import_map_seed->delimiter))
163 $this->ss->assign("CUSTOM_DELIMITER", $import_map_seed->delimiter);
164 if (isset($import_map_seed->enclosure))
165 $this->ss->assign("CUSTOM_ENCLOSURE", htmlentities($import_map_seed->enclosure));
166 if ($import_map_seed->has_header)
167 $this->ss->assign("HAS_HEADER_CHECKED"," CHECKED");
168 $this->ss->assign("SOURCE", $_REQUEST['source']);
171 // add instructions for anything other than custom_delimited
172 if ($_REQUEST['source'] != 'other')
174 $instructions = array();
176 switch($_REQUEST['source']) {
181 $lang_key = "OUTLOOK";
190 $lang_key = "CUSTOM";
193 if ( $lang_key != '' ) {
194 for ($i = 1; isset($mod_strings["LBL_{$lang_key}_NUM_$i"]);$i++) {
195 $instructions[] = array(
196 "STEP_NUM" => $mod_strings["LBL_NUM_$i"],
197 "INSTRUCTION_STEP" => $mod_strings["LBL_{$lang_key}_NUM_$i"],
200 $this->ss->assign("INSTRUCTIONS_TITLE",$mod_strings["LBL_IMPORT_{$lang_key}_TITLE"]);
201 $this->ss->assign("instructions",$instructions);
205 $this->ss->display('modules/Import/tpls/step2.tpl');
209 * Returns JS used in this view
211 private function _getJS()
215 return <<<EOJAVASCRIPT
216 <script type="text/javascript">
218 document.getElementById('goback').onclick = function(){
219 document.getElementById('importstep2').action.value = 'Step1';
223 document.getElementById('gonext').onclick = function(){
224 document.getElementById('importstep2').action.value = 'Step3';
227 // be sure we specify a file to upload
228 if (document.getElementById('importstep2').userfile.value == "") {
229 add_error_style(document.getElementById('importstep2').name,'userfile',"{$mod_strings['ERR_MISSING_REQUIRED_FIELDS']} {$mod_strings['ERR_SELECT_FILE']}");