예제 #1
0
 /**
  * Writes the row out to the ImportCacheFiles::getDuplicateFileName() file
  */
 public function markRowAsDuplicate($field_names = array())
 {
     $fp = sugar_fopen(ImportCacheFiles::getDuplicateFileName(), 'a');
     fputcsv($fp, $this->_currentRow);
     fclose($fp);
     //if available, grab the column number based on passed in field_name
     if (!empty($field_names)) {
         $colkey = '';
         $colnums = array();
         //REQUEST should have the field names in order as they appear in the row to be written, get the key values
         //of passed in fields into an array
         foreach ($field_names as $fv) {
             $fv = trim($fv);
             if (empty($fv) || $fv == 'delete') {
                 continue;
             }
             $new_keys = array_keys($_REQUEST, $fv);
             $colnums = array_merge($colnums, $new_keys);
         }
         //if values were found, process for number position
         if (!empty($colnums)) {
             //foreach column, strip the 'colnum_' prefix to the get the column key value
             foreach ($colnums as $column_key) {
                 if (strpos($column_key, 'colnum_') === 0) {
                     $colkey = substr($column_key, 7);
                 }
                 //if we have the column key, then lets add a span tag with styling reference to the original value
                 if (!empty($colkey)) {
                     $hilited_val = $this->_currentRow[$colkey];
                     $this->_currentRow[$colkey] = '<span class=warn>' . $hilited_val . '</span>';
                 }
             }
         }
     }
     //add the row (with or without stylings) to the list view, this will get displayed to the user as a list of duplicates
     $fdp = sugar_fopen(ImportCacheFiles::getDuplicateFileDisplayName(), 'a');
     fputcsv($fdp, $this->_currentRow);
     fclose($fdp);
     //increment dupecount
     $this->_dupeCount++;
 }
예제 #2
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $app_strings, $current_user, $sugar_config, $current_language;
     $this->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::convertFileNameToUrl(ImportCacheFiles::getErrorFileName()));
     $this->ss->assign("errorrecordsFile", ImportCacheFiles::convertFileNameToUrl(ImportCacheFiles::getErrorRecordsWithoutErrorFileName()));
     $this->ss->assign("dupeFile", ImportCacheFiles::convertFileNameToUrl(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');
 }