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()
94 global $mod_strings, $app_list_strings;
96 $iconPath = $this->getModuleTitleIconPath($this->module);
97 $returnArray = array();
98 if (!empty($iconPath) && !$browserTitle) {
99 $returnArray[] = "<a href='index.php?module={$_REQUEST['import_module']}&action=index'><img src='{$iconPath}' alt='{$app_list_strings['moduleList'][$_REQUEST['import_module']]}' title='{$app_list_strings['moduleList'][$_REQUEST['import_module']]}' align='absmiddle'></a>";
102 $returnArray[] = $app_list_strings['moduleList'][$_REQUEST['import_module']];
104 $returnArray[] = "<a href='index.php?module=Import&action=Step1&import_module={$_REQUEST['import_module']}'>".$mod_strings['LBL_MODULE_NAME']."</a>";
105 $returnArray[] = $mod_strings['LBL_STEP_2_TITLE'];
111 * @see SugarView::display()
113 public function display()
115 global $mod_strings, $app_list_strings, $app_strings, $current_user, $import_bean_map;
116 global $import_mod_strings;
118 $this->ss->assign("MODULE_TITLE", $this->getModuleTitle());
119 $this->ss->assign("IMP", $import_mod_strings);
120 $this->ss->assign("TYPE",( !empty($_REQUEST['type']) ? $_REQUEST['type'] : "import" ));
121 $this->ss->assign("CUSTOM_DELIMITER",
122 ( !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : "," ));
123 $this->ss->assign("CUSTOM_ENCLOSURE",htmlentities(
124 ( !empty($_REQUEST['custom_enclosure']) && $_REQUEST['custom_enclosure'] != 'other'
125 ? $_REQUEST['custom_enclosure'] :
126 ( !empty($_REQUEST['custom_enclosure_other'])
127 ? $_REQUEST['custom_enclosure_other'] : "" ) )));
129 $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
130 $this->ss->assign("HEADER", $app_strings['LBL_IMPORT']." ". $mod_strings['LBL_MODULE_NAME']);
131 $this->ss->assign("JAVASCRIPT", $this->_getJS());
133 // special for importing from Outlook
134 if ($_REQUEST['source'] == "outlook") {
135 $this->ss->assign("SOURCE", $_REQUEST['source']);
136 $this->ss->assign("SOURCE_NAME","Outlook ");
137 $this->ss->assign("HAS_HEADER_CHECKED"," CHECKED");
139 // see if the source starts with 'custom'
140 // if so, pull off the id, load that map, and get the name
141 elseif ( strncasecmp("custom:",$_REQUEST['source'],7) == 0) {
142 $id = substr($_REQUEST['source'],7);
143 $import_map_seed = new ImportMap();
144 $import_map_seed->retrieve($id, false);
146 $this->ss->assign("SOURCE_ID", $import_map_seed->id);
147 $this->ss->assign("SOURCE_NAME", $import_map_seed->name);
148 $this->ss->assign("SOURCE", $import_map_seed->source);
149 if (isset($import_map_seed->delimiter))
150 $this->ss->assign("CUSTOM_DELIMITER", $import_map_seed->delimiter);
151 if (isset($import_map_seed->enclosure))
152 $this->ss->assign("CUSTOM_ENCLOSURE", htmlentities($import_map_seed->enclosure));
153 if ($import_map_seed->has_header)
154 $this->ss->assign("HAS_HEADER_CHECKED"," CHECKED");
157 $classname = 'ImportMap' . ucfirst($_REQUEST['source']);
158 if ( file_exists("modules/Import/{$classname}.php") )
159 require_once("modules/Import/{$classname}.php");
160 elseif ( file_exists("custom/modules/Import/{$classname}.php") )
161 require_once("custom/modules/Import/{$classname}.php");
163 require_once("custom/modules/Import/ImportMapOther.php");
164 $classname = 'ImportMapOther';
165 $_REQUEST['source'] = 'other';
167 if ( class_exists($classname) ) {
168 $import_map_seed = new $classname;
169 if (isset($import_map_seed->delimiter))
170 $this->ss->assign("CUSTOM_DELIMITER", $import_map_seed->delimiter);
171 if (isset($import_map_seed->enclosure))
172 $this->ss->assign("CUSTOM_ENCLOSURE", htmlentities($import_map_seed->enclosure));
173 if ($import_map_seed->has_header)
174 $this->ss->assign("HAS_HEADER_CHECKED"," CHECKED");
175 $this->ss->assign("SOURCE", $_REQUEST['source']);
179 // add instructions for anything other than custom_delimited
180 if ($_REQUEST['source'] != 'other')
182 $instructions = array();
184 switch($_REQUEST['source']) {
189 $lang_key = "OUTLOOK";
198 $lang_key = "CUSTOM";
203 $lang_key = "CUSTOM_MAPPING_".strtoupper($import_map_seed->name);
206 if ( $lang_key != '' ) {
207 for ($i = 1; isset($mod_strings["LBL_{$lang_key}_NUM_$i"]);$i++) {
208 $instructions[] = array(
209 "STEP_NUM" => $mod_strings["LBL_NUM_$i"],
210 "INSTRUCTION_STEP" => $mod_strings["LBL_{$lang_key}_NUM_$i"],
213 $this->ss->assign("INSTRUCTIONS_TITLE",$mod_strings["LBL_IMPORT_{$lang_key}_TITLE"]);
214 $this->ss->assign("instructions",$instructions);
218 $this->ss->display('modules/Import/tpls/step2.tpl');
222 * Returns JS used in this view
224 private function _getJS()
228 return <<<EOJAVASCRIPT
229 <script type="text/javascript">
231 document.getElementById('goback').onclick = function(){
232 document.getElementById('importstep2').action.value = 'Step1';
236 document.getElementById('gonext').onclick = function(){
237 document.getElementById('importstep2').action.value = 'Step3';
240 // be sure we specify a file to upload
241 if (document.getElementById('importstep2').userfile.value == "") {
242 add_error_style(document.getElementById('importstep2').name,'userfile',"{$mod_strings['ERR_MISSING_REQUIRED_FIELDS']} {$mod_strings['ERR_SELECT_FILE']}");