ss->assign("IMPORT_MODULE", $_REQUEST['import_module']); $this->ss->assign("TYPE", $_REQUEST['type']); $this->ss->assign("HEADER", $app_strings['LBL_IMPORT']." ". $mod_strings['LBL_MODULE_NAME']); $this->ss->assign("MODULE_TITLE", $this->getModuleTitle(false)); // lookup this module's $mod_strings to get the correct module name $module_mod_strings = return_module_language($current_language, $_REQUEST['import_module']); $this->ss->assign("MODULENAME",$module_mod_strings['LBL_MODULE_NAME']); // read status file to get totals for records imported, errors, and duplicates $count = 0; $errorCount = 0; $dupeCount = 0; $createdCount = 0; $updatedCount = 0; $fp = sugar_fopen(ImportCacheFiles::getStatusFileName(),'r'); while (( $row = fgetcsv($fp, 8192) ) !== FALSE) { $count += (int) $row[0]; $errorCount += (int) $row[1]; $dupeCount += (int) $row[2]; $createdCount += (int) $row[3]; $updatedCount += (int) $row[4]; } fclose($fp); $this->ss->assign("showUndoButton",FALSE); if($createdCount > 0) { $this->ss->assign("showUndoButton",TRUE); } if ($errorCount > 0 && ($createdCount <= 0 && $updatedCount <= 0)) $activeTab = 2; else if($dupeCount > 0 && ($createdCount <= 0 && $updatedCount <= 0)) $activeTab = 1; else $activeTab = 0; $this->ss->assign("JAVASCRIPT", $this->_getJS($activeTab)); $this->ss->assign("errorCount",$errorCount); $this->ss->assign("dupeCount",$dupeCount); $this->ss->assign("createdCount",$createdCount); $this->ss->assign("updatedCount",$updatedCount); $this->ss->assign("errorFile",ImportCacheFiles::getErrorFileName()); $this->ss->assign("errorrecordsFile",ImportCacheFiles::getErrorRecordsWithoutErrorFileName()); $this->ss->assign("dupeFile",ImportCacheFiles::getDuplicateFileName()); if ( $this->bean->object_name == "Prospect" ) { $this->ss->assign("PROSPECTLISTBUTTON", $this->_addToProspectListButton()); } else { $this->ss->assign("PROSPECTLISTBUTTON",""); } $resultsTable = ""; foreach ( UsersLastImport::getBeansByImport($_REQUEST['import_module']) as $beanname ) { // load bean if ( !( $this->bean instanceof $beanname ) ) { $this->bean = new $beanname; } $resultsTable .= $this->getListViewResults(); } if(empty($resultsTable)) { $resultsTable = $this->getListViewResults(); } $this->ss->assign("RESULTS_TABLE", $resultsTable); $this->ss->assign("ERROR_TABLE", $this->getListViewTableFromFile(ImportCacheFiles::getErrorRecordsFileName(), 'errors') ); $this->ss->assign("DUP_TABLE", $this->getListViewTableFromFile(ImportCacheFiles::getDuplicateFileDisplayName(), 'dup')); $content = $this->ss->fetch('modules/Import/tpls/last.tpl'); $this->ss->assign("CONTENT",$content); $this->ss->display('modules/Import/tpls/wizardWrapper.tpl'); } protected function getListViewResults() { global $mod_strings, $current_language; // build listview to show imported records $lvf = new ListViewFacade($this->bean, $this->bean->module_dir, 0); $params = array(); if(!empty($_REQUEST['orderBy'])) { $params['orderBy'] = $_REQUEST['orderBy']; $params['overrideOrder'] = true; if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder']; } $beanname = ($this->bean->object_name == 'Case' ? 'aCase' : $this->bean->object_name); // add users_last_import joins so we only show records done in this import $params['custom_from'] = ', users_last_import'; $params['custom_where'] = " AND users_last_import.assigned_user_id = '{$GLOBALS['current_user']->id}' AND users_last_import.bean_type = '{$beanname}' AND users_last_import.bean_id = {$this->bean->table_name}.id AND users_last_import.deleted = 0 AND {$this->bean->table_name}.deleted = 0"; $where = " {$this->bean->table_name}.id IN ( SELECT users_last_import.bean_id FROM users_last_import WHERE users_last_import.assigned_user_id = '{$GLOBALS['current_user']->id}' AND users_last_import.bean_type = '{$beanname}' AND users_last_import.deleted = 0 )"; $lvf->lv->mergeduplicates = false; $lvf->lv->showMassupdateFields = false; if ( $lvf->type == 2 ) $lvf->template = 'include/ListView/ListViewNoMassUpdate.tpl'; $module_mod_strings = return_module_language($current_language, $this->bean->module_dir); $lvf->setup('', $where, $params, $module_mod_strings, 0, -1, '', strtoupper($beanname), array(), 'id'); global $app_list_strings; return $lvf->display($app_list_strings['moduleList'][$this->bean->module_dir], 'main', TRUE); } protected function getListViewTableFromFile($fileName, $tableName) { $has_header = $_REQUEST['has_header'] == 'on' ? TRUE : FALSE; $if = new ImportFile($fileName, ",", '"', FALSE, FALSE); $if->setHeaderRow($has_header); $lv = new ImportListView($if,array('offset'=> 0), $tableName); return $lv->display(TRUE); } /** * Returns JS used in this view */ private function _getJS($activeTab) { return << 'set_return_and_save_background', 'form_name' => 'DetailView', 'field_to_name_array' => array( 'id' => 'subpanel_id', ), 'passthru_data' => array( 'child_field' => 'notused', 'return_url' => 'notused', 'link_field_name' => 'notused', 'module_name' => 'notused', 'refresh_page'=>'1', 'return_type'=>'addtoprospectlist', 'parent_module'=>'ProspectLists', 'parent_type'=>'ProspectList', 'child_id'=>'id', 'link_attribute'=>'prospects', 'link_type'=>'default', //polymorphic or default ) ); $popup_request_data['passthru_data']['query'] = urlencode($query); $json = getJSONobj(); $encoded_popup_request_data = $json->encode($popup_request_data); return << EOHTML; } } ?>