예제 #1
0
 /** 
  * display the form
  */
 public function display()
 {
     global $mod_strings, $current_user, $current_language;
     $this->ss->assign("MOD", $mod_strings);
     $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
     // lookup this module's $mod_strings to get the correct module name
     $old_mod_strings = $mod_strings;
     $module_mod_strings = return_module_language($current_language, $_REQUEST['import_module']);
     $this->ss->assign("MODULENAME", $module_mod_strings['LBL_MODULE_NAME']);
     // reset old ones afterwards
     $mod_strings = $old_mod_strings;
     $last_import = new UsersLastImport();
     $this->ss->assign('UNDO_SUCCESS', $last_import->undo($_REQUEST['import_module']));
     $this->ss->assign("JAVASCRIPT", $this->_getJS());
     $this->ss->display('modules/Import/tpls/undo.tpl');
 }
 function add_member_of_name()
 {
     // global is defined in UsersLastImport.php
     global $imported_ids;
     global $current_user;
     if ((!isset($this->account_name) || $this->account_name == '') && (!isset($this->parent_id) || $this->parent_id == '')) {
         return;
     }
     $arr = array();
     // check if it already exists
     $focus = new Account();
     $query = '';
     // if user is defining the account id to be associated with this contact..
     if (isset($this->parent_id) && $this->parent_id != '') {
         $this->parent_id = convert_id($this->parent_id);
         $query = "select * from {$focus->table_name} WHERE id='" . PearDatabase::quote($this->parent_id) . "'";
     } else {
         $query = "select * from {$focus->table_name} WHERE name='" . PearDatabase::quote($this->account_name) . "'";
     }
     $GLOBALS['log']->info($query);
     $result = $this->db->query($query) or sugar_die("Error selecting sugarbean: ");
     $row = $this->db->fetchByAssoc($result, -1, false);
     // we found a row with that id
     if (isset($row['id']) && $row['id'] != -1) {
         // if it exists but was deleted, just remove it entirely
         if (isset($row['deleted']) && $row['deleted'] == 1) {
             $query2 = "delete from {$focus->table_name} WHERE id='" . PearDatabase::quote($row['id']) . "'";
             $GLOBALS['log']->info($query2);
             $result2 = $this->db->query($query2) or sugar_die("Error deleting existing sugarbean: ");
         } else {
             $focus->id = $row['id'];
         }
     }
     // if we didnt find the account, so create it
     if (!isset($focus->id) || $focus->id == '') {
         $focus->name = $this->account_name;
         if (isset($this->parent_id)) {
             $focus->parent_id = $this->parent_id;
         } else {
             $focus->parent_id = $current_user->id;
         }
         if (isset($this->modified_date)) {
             $focus->modified_date = $this->modified_date;
         }
         // if we are providing the account id:
         if (isset($this->parent_id) && $this->parent_id != '') {
             $focus->new_with_id = true;
             $focus->id = $this->account_id;
         }
         $focus->save();
         // avoid duplicate mappings:
         if (!isset($imported_ids[$focus->id])) {
             // save the new account as a users_last_import
             $last_import = new UsersLastImport();
             $last_import->assigned_user_id = $current_user->id;
             $last_import->bean_type = "Accounts";
             $last_import->bean_id = $focus->id;
             $last_import->save();
             $imported_ids[$focus->id] = 1;
         }
     }
     // now just link the account
     $this->parent_id = $focus->id;
 }
예제 #3
0
    $_REQUEST['module'] = 'Home';
}
if (!isset($_REQUEST['return_id'])) {
    $_REQUEST['return_id'] = '';
}
if (!isset($_REQUEST['return_module'])) {
    $_REQUEST['return_module'] = '';
}
if (!isset($_REQUEST['return_action'])) {
    $_REQUEST['return_action'] = '';
}
$parenttab = getParenttab();
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$log->info("Import Undo");
$last_import = new UsersLastImport();
$ret_value = $last_import->undo($current_user->id);
// vtlib customization: Invoke undo import function of the module.
$module = $_REQUEST['module'];
$undo_focus = CRMEntity::getInstance($module);
if (method_exists($undo_focus, 'undo_import')) {
    $ret_value += $undo_focus->undo_import($module, $current_user->id);
}
// END
?>

<br>


<table align="center" cellpadding="5" cellspacing="0" width="95%" class="mailClient importLeadUI small">
        <tr>
 /**
  * This function handles the import for uitype 10 fieldtype
  * @param string $module - the current module name
  * @param string fieldname - the related to field name
  */
 function add_related_to($module, $fieldname)
 {
     global $adb, $imported_ids, $current_user;
     $related_to = $this->column_fields[$fieldname];
     if (empty($related_to)) {
         return false;
     }
     //check if the field has module information; if not get the first module
     if (!strpos($related_to, "::::")) {
         $module = getFirstModule($module, $fieldname);
         $value = $related_to;
     } else {
         //check the module of the field
         $arr = array();
         $arr = explode("::::", $related_to);
         $module = $arr[0];
         $value = $arr[1];
     }
     $focus1 = CRMEntity::getInstance($module);
     $entityNameArr = getEntityField($module);
     $entityName = $entityNameArr['fieldname'];
     $query = "SELECT vtiger_crmentity.deleted, {$focus1->table_name}.*\n\t\t\t\t\tFROM {$focus1->table_name}\n\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid={$focus1->table_name}.{$focus1->table_index}\n\t\t\t\t\t\twhere {$entityName}=? and vtiger_crmentity.deleted=0";
     $result = $adb->pquery($query, array($value));
     if (!isset($this->checkFlagArr[$module])) {
         $this->checkFlagArr[$module] = isPermitted($module, 'EditView', '') == 'yes';
     }
     if ($adb->num_rows($result) > 0) {
         //record found
         $focus1->id = $adb->query_result($result, 0, $focus1->table_index);
     } elseif ($this->checkFlagArr[$module]) {
         //record not found; create it
         $focus1->column_fields[$focus1->list_link_field] = $value;
         $focus1->column_fields['assigned_user_id'] = $current_user->id;
         $focus1->column_fields['modified_user_id'] = $current_user->id;
         $focus1->save($module);
         $last_import = new UsersLastImport();
         $last_import->assigned_user_id = $current_user->id;
         $last_import->bean_type = $module;
         $last_import->bean_id = $focus1->id;
         $last_import->save();
     } else {
         //record not found and cannot create
         $this->column_fields[$fieldname] = "";
         return false;
     }
     if (!empty($focus1->id)) {
         $this->column_fields[$fieldname] = $focus1->id;
         return true;
     } else {
         $this->column_fields[$fieldname] = "";
         return false;
     }
 }
예제 #5
0
 /**	function used to create or map with existing account if the contact has mapped with an account during import
  */
 function add_create_account()
 {
     global $adb;
     // global is defined in UsersLastImport.php
     global $imported_ids;
     global $current_user;
     $acc_name = $this->column_fields['account_id'];
     $adb->println("contact add_create acc=" . $acc_name);
     if (!isset($acc_name) || $acc_name == '') {
         return;
     }
     $arr = array();
     // check if it already exists
     $focus = new Accounts();
     $query = '';
     // if user is defining the vtiger_account id to be associated with this contact..
     //Modified to remove the spaces at first and last in vtiger_account name -- after 4.2 patch 2
     $acc_name = trim($acc_name);
     //Modified the query to get the available account only ie., which is not deleted
     $query = "select vtiger_crmentity.deleted, vtiger_account.* from vtiger_account, vtiger_crmentity WHERE accountname=? and vtiger_crmentity.crmid =vtiger_account.accountid and vtiger_crmentity.deleted=0";
     $result = $adb->pquery($query, array($acc_name));
     $row = $this->db->fetchByAssoc($result, -1, false);
     $adb->println("fetched account");
     $adb->println($row);
     // we found a row with that id
     if (isset($row['accountid']) && $row['accountid'] != -1) {
         $focus->id = $row['accountid'];
         $adb->println("Account row exists - using same id=" . $focus->id);
     }
     // if we didnt find the vtiger_account, so create it
     if (!isset($focus->id) || $focus->id == '') {
         $adb->println("Createing new vtiger_account");
         $focus->column_fields['accountname'] = $acc_name;
         $focus->column_fields['assigned_user_id'] = $current_user->id;
         $focus->column_fields['modified_user_id'] = $current_user->id;
         //$focus->saveentity("Accounts");
         $focus->save("Accounts");
         $acc_id = $focus->id;
         $adb->println("New Account created id=" . $focus->id);
         // avoid duplicate mappings:
         if (!isset($imported_ids[$acc_id])) {
             $adb->println("inserting vtiger_users last import for vtiger_accounts");
             // save the new vtiger_account as a vtiger_users_last_import
             $last_import = new UsersLastImport();
             $last_import->assigned_user_id = $current_user->id;
             $last_import->bean_type = "Accounts";
             $last_import->bean_id = $focus->id;
             $last_import->save();
             $imported_ids[$acc_id] = 1;
         }
     }
     $adb->println("prev contact accid=" . $this->column_fields["account_id"]);
     // now just link the vtiger_account
     $this->column_fields["account_id"] = $focus->id;
     $adb->println("curr contact accid=" . $this->column_fields["account_id"]);
 }
예제 #6
0
파일: ImportStep3.php 프로젝트: hardikk/HNH
if (isset($datarows) && is_array($datarows)) {
    //This file will be included only once at the first time. Will not be included when we redirect from ImportSave
    include "modules/Import/picklist_addition.php";
}
$saved_ids = array();
$firstrow = 0;
if (!isset($datarows)) {
    $error = $mod_strings['LBL_FILE_ALREADY_BEEN_OR'];
    $datarows = array();
}
if ($has_header == 1) {
    $firstrow = array_shift($datarows);
}
//Mark the last imported records as deleted which are imported by the current user in vtiger_users_last_import vtiger_table
if (!isset($_REQUEST['startval'])) {
    $seedUsersLastImport = new UsersLastImport();
    $seedUsersLastImport->mark_deleted_by_user_id($current_user->id);
}
$skip_required_count = 0;
p("processing started ret_field_count=" . $ret_field_count);
$adb->println($datarows);
$error = '';
$focus = new $current_bean_type();
$focus->initRequiredFields($module);
// SAVE MAPPING IF REQUESTED
if (isset($_REQUEST['save_map']) && $_REQUEST['save_map'] == 'on' && isset($_REQUEST['save_map_as']) && $_REQUEST['save_map_as'] != '') {
    p("save map");
    $serialized_mapping = '';
    if ($has_header) {
        foreach ($col_pos_to_field as $pos => $field_name) {
            if (isset($firstrow[$pos]) && isset($field_name)) {
예제 #7
0
    /**
     * @see SugarView::display()
     */
    public function display()
    {
        global $mod_strings, $app_strings, $current_user, $sugar_config, $app_list_strings, $locale;
        $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
        $has_header = isset($_REQUEST['has_header']) ? 1 : 0;
        $sugar_config['import_max_records_per_file'] = empty($sugar_config['import_max_records_per_file']) ? 1000 : $sugar_config['import_max_records_per_file'];
        // Clear out this user's last import
        $seedUsersLastImport = new UsersLastImport();
        $seedUsersLastImport->mark_deleted_by_user_id($current_user->id);
        ImportCacheFiles::clearCacheFiles();
        // attempt to lookup a preexisting field map
        // use the custom one if specfied to do so in step 1
        $field_map = array();
        $default_values = array();
        $ignored_fields = array();
        if (!empty($_REQUEST['source_id'])) {
            $mapping_file = new ImportMap();
            $mapping_file->retrieve($_REQUEST['source_id'], false);
            $_REQUEST['source'] = $mapping_file->source;
            $has_header = $mapping_file->has_header;
            if (isset($mapping_file->delimiter)) {
                $_REQUEST['custom_delimiter'] = $mapping_file->delimiter;
            }
            if (isset($mapping_file->enclosure)) {
                $_REQUEST['custom_enclosure'] = htmlentities($mapping_file->enclosure);
            }
            $field_map = $mapping_file->getMapping();
            $default_values = $mapping_file->getDefaultValues();
            $this->ss->assign("MAPNAME", $mapping_file->name);
            $this->ss->assign("CHECKMAP", 'checked="checked" value="on"');
        } else {
            // Try to see if we have a custom mapping we can use
            // based upon the where the records are coming from
            // and what module we are importing into
            $classname = 'ImportMap' . ucfirst($_REQUEST['source']);
            if (file_exists("modules/Import/{$classname}.php")) {
                require_once "modules/Import/{$classname}.php";
            } elseif (file_exists("custom/modules/Import/{$classname}.php")) {
                require_once "custom/modules/Import/{$classname}.php";
            } else {
                require_once "custom/modules/Import/ImportMapOther.php";
                $classname = 'ImportMapOther';
                $_REQUEST['source'] = 'other';
            }
            if (class_exists($classname)) {
                $mapping_file = new $classname();
                if (isset($mapping_file->delimiter)) {
                    $_REQUEST['custom_delimiter'] = $mapping_file->delimiter;
                }
                if (isset($mapping_file->enclosure)) {
                    $_REQUEST['custom_enclosure'] = htmlentities($mapping_file->enclosure);
                }
                $ignored_fields = $mapping_file->getIgnoredFields($_REQUEST['import_module']);
                $field_map = $mapping_file->getMapping($_REQUEST['import_module']);
            }
        }
        $this->ss->assign("CUSTOM_DELIMITER", !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : ",");
        $this->ss->assign("CUSTOM_ENCLOSURE", !empty($_REQUEST['custom_enclosure']) ? $_REQUEST['custom_enclosure'] : "");
        // handle uploaded file
        $uploadFile = new UploadFile('userfile');
        if (isset($_FILES['userfile']) && $uploadFile->confirm_upload()) {
            $uploadFile->final_move('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
            $uploadFileName = $uploadFile->get_upload_path('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
        } else {
            $this->_showImportError($mod_strings['LBL_IMPORT_MODULE_ERROR_NO_UPLOAD'], $_REQUEST['import_module'], 'Step2');
            return;
        }
        // split file into parts
        $splitter = new ImportFileSplitter($uploadFileName, $sugar_config['import_max_records_per_file']);
        $splitter->splitSourceFile($_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES), $has_header);
        // Now parse the file and look for errors
        $importFile = new ImportFile($uploadFileName, $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
        if (!$importFile->fileExists()) {
            $this->_showImportError($mod_strings['LBL_CANNOT_OPEN'], $_REQUEST['import_module'], 'Step2');
            return;
        }
        // retrieve first 3 rows
        $rows = array();
        $system_charset = $locale->default_export_charset;
        $user_charset = $locale->getExportCharset();
        $other_charsets = 'UTF-8, UTF-7, ASCII, CP1252, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP';
        $detectable_charsets = "UTF-8, {$user_charset}, {$system_charset}, {$other_charsets}";
        // Bug 26824 - mb_detect_encoding() thinks CP1252 is IS0-8859-1, so use that instead in the encoding list passed to the function
        $detectable_charsets = str_replace('CP1252', 'ISO-8859-1', $detectable_charsets);
        $charset_for_import = $user_charset;
        //We will set the default import charset option by user's preference.
        $able_to_detect = function_exists('mb_detect_encoding');
        for ($i = 0; $i < 3; $i++) {
            $rows[$i] = $importFile->getNextRow();
            if (!empty($rows[$i]) && $able_to_detect) {
                foreach ($rows[$i] as &$temp_value) {
                    $current_charset = mb_detect_encoding($temp_value, $detectable_charsets);
                    if (!empty($current_charset) && $current_charset != "UTF-8") {
                        $temp_value = $locale->translateCharset($temp_value, $current_charset);
                        // we will use utf-8 for displaying the data on the page.
                        $charset_for_import = $current_charset;
                        //set the default import charset option according to the current_charset.
                        //If it is not utf-8, tt may be overwritten by the later one. So the uploaded file should not contain two types of charset($user_charset, $system_charset), and I think this situation will not occur.
                    }
                }
            }
        }
        $ret_field_count = $importFile->getFieldCount();
        // Bug 14689 - Parse the first data row to make sure it has non-empty data in it
        $isempty = true;
        if ($rows[(int) $has_header] != false) {
            foreach ($rows[(int) $has_header] as $value) {
                if (strlen(trim($value)) > 0) {
                    $isempty = false;
                    break;
                }
            }
        }
        if ($isempty || $rows[(int) $has_header] == false) {
            $this->_showImportError($mod_strings['LBL_NO_LINES'], $_REQUEST['import_module'], 'Step2');
            return;
        }
        // save first row to send to step 4
        $this->ss->assign("FIRSTROW", base64_encode(serialize($rows[0])));
        // Now build template
        $this->ss->assign("TMP_FILE", $uploadFileName);
        $this->ss->assign("FILECOUNT", $splitter->getFileCount());
        $this->ss->assign("RECORDCOUNT", $splitter->getRecordCount());
        $this->ss->assign("RECORDTHRESHOLD", $sugar_config['import_max_records_per_file']);
        $this->ss->assign("SOURCE", $_REQUEST['source']);
        $this->ss->assign("TYPE", $_REQUEST['type']);
        $this->ss->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('basic_search', 'align="absmiddle" alt="' . $app_strings['LNK_DELETE'] . '" border="0"'));
        $this->ss->assign("PUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('advanced_search', 'align="absmiddle" alt="' . $mod_strings['LBL_PUBLISH'] . '" border="0"'));
        $this->ss->assign("MODULE_TITLE", $this->getModuleTitle());
        $this->ss->assign("STEP4_TITLE", strip_tags(str_replace("\n", "", getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_STEP_4_TITLE']), false))));
        $this->ss->assign("HEADER", $app_strings['LBL_IMPORT'] . " " . $mod_strings['LBL_MODULE_NAME']);
        // we export it as email_address, but import as email1
        $field_map['email_address'] = 'email1';
        // build each row; row count is determined by the the number of fields in the import file
        $columns = array();
        $mappedFields = array();
        for ($field_count = 0; $field_count < $ret_field_count; $field_count++) {
            // See if we have any field map matches
            $defaultValue = "";
            // Bug 31260 - If the data rows have more columns than the header row, then just add a new header column
            if (!isset($rows[0][$field_count])) {
                $rows[0][$field_count] = '';
            }
            // See if we can match the import row to a field in the list of fields to import
            $firstrow_name = trim(str_replace(":", "", $rows[0][$field_count]));
            if ($has_header && isset($field_map[$firstrow_name])) {
                $defaultValue = $field_map[$firstrow_name];
            } elseif (isset($field_map[$field_count])) {
                $defaultValue = $field_map[$field_count];
            } elseif (empty($_REQUEST['source_id'])) {
                $defaultValue = trim($rows[0][$field_count]);
            }
            // build string of options
            $fields = $this->bean->get_importable_fields();
            $options = array();
            $defaultField = '';
            foreach ($fields as $fieldname => $properties) {
                // get field name
                if (!empty($properties['vname'])) {
                    $displayname = str_replace(":", "", translate($properties['vname'], $this->bean->module_dir));
                } else {
                    $displayname = str_replace(":", "", translate($properties['name'], $this->bean->module_dir));
                }
                // see if this is required
                $req_mark = "";
                $req_class = "";
                if (array_key_exists($fieldname, $this->bean->get_import_required_fields())) {
                    $req_mark = ' ' . $app_strings['LBL_REQUIRED_SYMBOL'];
                    $req_class = ' class="required" ';
                }
                // see if we have a match
                $selected = '';
                if (!empty($defaultValue) && !in_array($fieldname, $mappedFields) && !in_array($fieldname, $ignored_fields)) {
                    if (strtolower($fieldname) == strtolower($defaultValue) || strtolower($fieldname) == str_replace(" ", "_", strtolower($defaultValue)) || strtolower($displayname) == strtolower($defaultValue) || strtolower($displayname) == str_replace(" ", "_", strtolower($defaultValue))) {
                        $selected = ' selected="selected" ';
                        $defaultField = $fieldname;
                        $mappedFields[] = $fieldname;
                    }
                }
                // get field type information
                $fieldtype = '';
                if (isset($properties['type']) && isset($mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])])) {
                    $fieldtype = ' [' . $mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])] . '] ';
                }
                if (isset($properties['comment'])) {
                    $fieldtype .= ' - ' . $properties['comment'];
                }
                $options[$displayname . $fieldname] = '<option value="' . $fieldname . '" title="' . $displayname . htmlentities($fieldtype) . '"' . $selected . $req_class . '>' . $displayname . $req_mark . '</option>\\n';
            }
            // get default field value
            $defaultFieldHTML = '';
            if (!empty($defaultField)) {
                $defaultFieldHTML = getControl($_REQUEST['import_module'], $defaultField, $fields[$defaultField], isset($default_values[$defaultField]) ? $default_values[$defaultField] : '');
            }
            if (isset($default_values[$defaultField])) {
                unset($default_values[$defaultField]);
            }
            // Bug 27046 - Sort the column name picker alphabetically
            ksort($options);
            $columns[] = array('field_choices' => implode('', $options), 'default_field' => $defaultFieldHTML, 'cell1' => str_replace("&quot;", '', htmlspecialchars($rows[0][$field_count])), 'cell2' => str_replace("&quot;", '', htmlspecialchars($rows[1][$field_count])), 'cell3' => str_replace("&quot;", '', htmlspecialchars($rows[2][$field_count])), 'show_remove' => false);
        }
        // add in extra defaulted fields if they are in the mapping record
        if (count($default_values) > 0) {
            foreach ($default_values as $field_name => $default_value) {
                // build string of options
                $fields = $this->bean->get_importable_fields();
                $options = array();
                $defaultField = '';
                foreach ($fields as $fieldname => $properties) {
                    // get field name
                    if (!empty($properties['vname'])) {
                        $displayname = str_replace(":", "", translate($properties['vname'], $this->bean->module_dir));
                    } else {
                        $displayname = str_replace(":", "", translate($properties['name'], $this->bean->module_dir));
                    }
                    // see if this is required
                    $req_mark = "";
                    $req_class = "";
                    if (array_key_exists($fieldname, $this->bean->get_import_required_fields())) {
                        $req_mark = ' ' . $app_strings['LBL_REQUIRED_SYMBOL'];
                        $req_class = ' class="required" ';
                    }
                    // see if we have a match
                    $selected = '';
                    if (strtolower($fieldname) == strtolower($field_name) && !in_array($fieldname, $mappedFields) && !in_array($fieldname, $ignored_fields)) {
                        $selected = ' selected="selected" ';
                        $defaultField = $fieldname;
                        $mappedFields[] = $fieldname;
                    }
                    // get field type information
                    $fieldtype = '';
                    if (isset($properties['type']) && isset($mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])])) {
                        $fieldtype = ' [' . $mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])] . '] ';
                    }
                    if (isset($properties['comment'])) {
                        $fieldtype .= ' - ' . $properties['comment'];
                    }
                    $options[$displayname . $fieldname] = '<option value="' . $fieldname . '" title="' . $displayname . $fieldtype . '"' . $selected . $req_class . '>' . $displayname . $req_mark . '</option>\\n';
                }
                // get default field value
                $defaultFieldHTML = '';
                if (!empty($defaultField)) {
                    $defaultFieldHTML = getControl($_REQUEST['import_module'], $defaultField, $fields[$defaultField], $default_value);
                }
                // Bug 27046 - Sort the column name picker alphabetically
                ksort($options);
                $columns[] = array('field_choices' => implode('', $options), 'default_field' => $defaultFieldHTML, 'show_remove' => true);
                $ret_field_count++;
            }
        }
        $this->ss->assign("COLUMNCOUNT", $ret_field_count);
        $this->ss->assign("rows", $columns);
        // get list of valid date/time formats
        $timeFormat = $current_user->getUserDateTimePreferences();
        $timeOptions = get_select_options_with_id($sugar_config['time_formats'], $timeFormat['time']);
        $dateOptions = get_select_options_with_id($sugar_config['date_formats'], $timeFormat['date']);
        $this->ss->assign('TIMEOPTIONS', $timeOptions);
        $this->ss->assign('DATEOPTIONS', $dateOptions);
        $this->ss->assign('datetimeformat', $GLOBALS['timedate']->get_cal_date_time_format());
        // get list of valid timezones
        $userTZ = $current_user->getPreference('timezone');
        if (empty($userTZ)) {
            $userTZ = TimeDate::userTimezone();
        }
        $this->ss->assign('TIMEZONE_CURRENT', $userTZ);
        $this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList());
        // get currency preference
        require_once 'modules/Currencies/ListCurrency.php';
        $currency = new ListCurrency();
        $cur_id = $locale->getPrecedentPreference('currency', $current_user);
        if ($cur_id) {
            $selectCurrency = $currency->getSelectOptions($cur_id);
            $this->ss->assign("CURRENCY", $selectCurrency);
        } else {
            $selectCurrency = $currency->getSelectOptions();
            $this->ss->assign("CURRENCY", $selectCurrency);
        }
        $currenciesVars = "";
        $i = 0;
        foreach ($locale->currencies as $id => $arrVal) {
            $currenciesVars .= "currencies[{$i}] = '{$arrVal['symbol']}';\n";
            $i++;
        }
        $currencySymbolsJs = <<<eoq
var currencies = new Object;
{$currenciesVars}
function setSymbolValue(id) {
    document.getElementById('symbol').value = currencies[id];
}
eoq;
        $this->ss->assign('currencySymbolJs', $currencySymbolsJs);
        // fill significant digits dropdown
        $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
        $sigDigits = '';
        for ($i = 0; $i <= 6; $i++) {
            if ($significantDigits == $i) {
                $sigDigits .= '<option value="' . $i . '" selected="true">' . $i . '</option>';
            } else {
                $sigDigits .= '<option value="' . $i . '">' . $i . '</option>';
            }
        }
        $this->ss->assign('sigDigits', $sigDigits);
        $num_grp_sep = $current_user->getPreference('num_grp_sep');
        $dec_sep = $current_user->getPreference('dec_sep');
        $this->ss->assign("NUM_GRP_SEP", empty($num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $num_grp_sep);
        $this->ss->assign("DEC_SEP", empty($dec_sep) ? $sugar_config['default_decimal_seperator'] : $dec_sep);
        $this->ss->assign('getNumberJs', $locale->getNumberJs());
        // Name display format
        $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($current_user));
        $this->ss->assign('getNameJs', $locale->getNameJs());
        // Charset
        $charsetOptions = get_select_options_with_id($locale->getCharsetSelect(), $charset_for_import);
        //wdong,  bug 25927, here we should use the charset testing results from above.
        $this->ss->assign('CHARSETOPTIONS', $charsetOptions);
        // handle building index selector
        global $dictionary, $current_language;
        require_once "include/templates/TemplateGroupChooser.php";
        $chooser_array = array();
        $chooser_array[0] = array();
        $idc = new ImportDuplicateCheck($this->bean);
        $chooser_array[1] = $idc->getDuplicateCheckIndexes();
        $chooser = new TemplateGroupChooser();
        $chooser->args['id'] = 'selected_indices';
        $chooser->args['values_array'] = $chooser_array;
        $chooser->args['left_name'] = 'choose_index';
        $chooser->args['right_name'] = 'ignore_index';
        $chooser->args['left_label'] = $mod_strings['LBL_INDEX_USED'];
        $chooser->args['right_label'] = $mod_strings['LBL_INDEX_NOT_USED'];
        $this->ss->assign("TAB_CHOOSER", $chooser->display());
        // show notes
        if ($this->bean instanceof Person) {
            $module_key = "LBL_CONTACTS_NOTE_";
        } elseif ($this->bean instanceof Company) {
            $module_key = "LBL_ACCOUNTS_NOTE_";
        } else {
            $module_key = "LBL_" . strtoupper($_REQUEST['import_module']) . "_NOTE_";
        }
        $notetext = '';
        for ($i = 1; isset($mod_strings[$module_key . $i]); $i++) {
            $notetext .= '<li>' . $mod_strings[$module_key . $i] . '</li>';
        }
        $this->ss->assign("NOTETEXT", $notetext);
        $this->ss->assign("HAS_HEADER", $has_header ? 'on' : 'off');
        // get list of required fields
        $required = array();
        foreach (array_keys($this->bean->get_import_required_fields()) as $name) {
            $properties = $this->bean->getFieldDefinition($name);
            if (!empty($properties['vname'])) {
                $required[$name] = str_replace(":", "", translate($properties['vname'], $this->bean->module_dir));
            } else {
                $required[$name] = str_replace(":", "", translate($properties['name'], $this->bean->module_dir));
            }
        }
        // include anything needed for quicksearch to work
        require_once "include/TemplateHandler/TemplateHandler.php";
        $quicksearch_js = TemplateHandler::createQuickSearchCode($fields, $fields, 'importstep3');
        $this->ss->assign("JAVASCRIPT", $quicksearch_js . "\n" . $this->_getJS($required));
        $this->ss->assign('required_fields', implode(', ', $required));
        $this->ss->display('modules/Import/tpls/step3.tpl');
    }
예제 #8
0
 /**
  * Add this row to the UsersLastImport table
  *
  * @param string $import_module name of the module we are doing the import into
  * @param string $module        name of the bean we are creating for this import
  * @param string $id            id of the recorded created in the $module
  */
 public static function writeRowToLastImport($import_module, $module, $id)
 {
     // cache $last_import instance
     static $last_import;
     if (!$last_import instanceof UsersLastImport) {
         $last_import = new UsersLastImport();
     }
     $last_import->id = null;
     $last_import->deleted = null;
     $last_import->assigned_user_id = $GLOBALS['current_user']->id;
     $last_import->import_module = $import_module;
     if ($module == 'Case') {
         $module = 'aCase';
     }
     $last_import->bean_type = $module;
     $last_import->bean_id = $id;
     return $last_import->save();
 }
예제 #9
0
    }
} else {
    echo "<br><br>";
    $currentModule = "Import";
    global $limit;
    global $list_max_entries_per_page;
    $implict_account = false;
    $import_modules_array = array("Leads" => "Leads", "Accounts" => "Accounts", "Contacts" => "Contacts", "Potentials" => "Potentials", "Products" => "Products", "HelpDesk" => "ImportTicket", "Vendors" => "ImportVendors");
    // vtlib customization: Hook provide to include custom modules
    $module = $_REQUEST['modulename'];
    checkFileAccess("modules/{$module}/{$module}.php");
    require_once "modules/{$module}/{$module}.php";
    $import_modules_array[$module] = $module;
    // END
    foreach ($import_modules_array as $module_name => $object_name) {
        $seedUsersLastImport = new UsersLastImport();
        $seedUsersLastImport->bean_type = $module_name;
        $list_query = $seedUsersLastImport->create_list_query($o, $w);
        $current_module_strings = return_module_language($current_language, $module_name);
        $object = new $object_name();
        $seedUsersLastImport->list_fields = $object->list_fields;
        $list_result = $adb->query($list_query);
        //Retreiving the no of rows
        $noofrows = $adb->num_rows($list_result);
        if ($noofrows >= 1) {
            if ($module_name != 'Accounts') {
                $implict_account = true;
            }
            if ($module_name == 'Accounts' && $implict_account == true) {
                $display_header_msg = "Newly created Accounts";
            } else {
예제 #10
0
 /**
  * If a bean save is not done for some reason, this method will undo any of the beans that were created
  *
  * @param array $ids ids of user_last_import records created
  */
 protected function _undoCreatedBeans(array $ids)
 {
     $focus = new UsersLastImport();
     foreach ($ids as $id) {
         $focus->undoById($id);
     }
 }
예제 #11
0
/**	function used to save the records into database
 *	@param array $rows - array of total rows of the csv file
 *	@param array $rows1 - rows to be saved
 *	@param object $focus - object of the corresponding import module
 *	@param int $ret_field_count - total number of fields(columns) available in the csv file
 *	@param int $col_pos_to_field - field position in the mapped array
 *	@param int $start - starting row count value to import
 *	@param int $recordcount - count of records to be import ie., number of records to import
 *	@param string $module - import module
 *	@param int $totalnoofrows - total number of rows available
 *	@param int $skip_required_count - number of records skipped
 This function will redirect to the ImportStep3 if the available records is greater than the record count (ie., number of records import in a single loop) otherwise (total records less than 500) then it will be redirected to import step last
 */
function InsertImportRecords($rows, $rows1, $focus, $ret_field_count, $col_pos_to_field, $start, $recordcount, $module, $totalnoofrows, $skip_required_count)
{
    global $current_user;
    global $adb;
    global $mod_strings;
    global $dup_ow_count;
    global $process_fields;
    // MWC ** Getting vtiger_users
    $users_groups_list = array();
    $dup_count = 0;
    $count = 0;
    $dup_ow_count = 0;
    $process_fields = 'false';
    if ($start == 0) {
        $_SESSION['totalrows'] = $rows;
        $_SESSION['return_field_count'] = $ret_field_count;
        $_SESSION['column_position_to_field'] = $col_pos_to_field;
    }
    $ii = $start;
    // go thru each row, process and save()
    foreach ($rows1 as $row) {
        $adb->println("Going to Save the row " . $ii . " =====> ");
        $adb->println($row);
        global $mod_strings;
        $do_save = 1;
        //MWC
        $my_userid = $current_user->id;
        //If we want to set default values for some fields for each entity then we have to set here
        if ($module == 'Products' || $module == 'Services') {
            //discontinued is not null. if we unmap active, NULL will be inserted and query will fail
            $focus->column_fields['discontinued'] = 'on';
        }
        for ($field_count = 0; $field_count < $ret_field_count; $field_count++) {
            p("col_pos[" . $field_count . "]=" . $col_pos_to_field[$field_count]);
            if (isset($col_pos_to_field[$field_count])) {
                p("set =" . $field_count);
                if (!isset($row[$field_count])) {
                    continue;
                }
                p("setting");
                // TODO: add check for user input
                // addslashes, striptags, etc..
                $field = $col_pos_to_field[$field_count];
                //picklist function is added to avoid duplicate picklist entries
                $pick_orginal_val = getPicklist($field, $row[$field_count]);
                if ($pick_orginal_val != null) {
                    $focus->column_fields[$field] = $pick_orginal_val;
                } elseif ($field == "assignedto" || $field == "assigned_user_id") {
                    //Here we are assigning the user id in column fields, so in function assign_user (ImportLead.php and ImportProduct.php files) we should use the id instead of user name when query the user
                    //or we can use $focus->column_fields['smownerid'] = $users_groups_list[$row[$field_count]];
                    $row[$field_count] = trim($row[$field_count]);
                    if (empty($users_groups_list[$row[$field_count]])) {
                        $id = getUserId_Ol($row[$field_count]);
                        if (empty($id)) {
                            $id = getGrpId($row[$field_count]);
                        }
                        $users_groups_list[trim($row[$field_count])] = $id;
                    }
                    $focus->column_fields[$field] = $users_groups_list[$row[$field_count]];
                    p("setting my_userid={$my_userid} for user="******"Setting " . $field . "=" . $row[$field_count]);
                }
            }
        }
        if ($focus->column_fields['notify_owner'] == '') {
            $focus->column_fields['notify_owner'] = '0';
        }
        if ($focus->column_fields['reference'] == '') {
            $focus->column_fields['reference'] = '0';
        }
        if ($focus->column_fields['emailoptout'] == '') {
            $focus->column_fields['emailoptout'] = '0';
        }
        if ($focus->column_fields['donotcall'] == '') {
            $focus->column_fields['donotcall'] = '0';
        }
        if ($focus->column_fields['discontinued'] == '') {
            $focus->column_fields['discontinued'] = '0';
        }
        if ($focus->column_fields['active'] == '') {
            $focus->column_fields['active'] = '0';
        }
        p("setting done");
        p("do save before req vtiger_fields=" . $do_save);
        $adb->println($focus->required_fields);
        foreach ($focus->required_fields as $field => $notused) {
            $fv = trim($focus->column_fields[$field]);
            if (!isset($fv) || $fv == '') {
                // Leads Import does not allow an empty lastname because the link is created on the lastname
                // Without lastname the Lead could not be opened.
                // But what if the import file has only company and telefone information?
                // It would be stupid to skip all the companies which don't have a contact person yet!
                // So we set lastname ="?????" and the user can later enter a name.
                // So the lastname is still mandatory but may be empty.
                if ($field == 'lastname' && $module == 'Leads') {
                    $focus->column_fields[$field] = '?????';
                } else {
                    p("fv " . $field . " not set");
                    $do_save = 0;
                    $skip_required_count++;
                    break;
                }
            }
        }
        if (!isset($focus->column_fields["assigned_user_id"]) || $focus->column_fields["assigned_user_id"] === '' || $focus->column_fields["assigned_user_id"] === NULL) {
            $focus->column_fields["assigned_user_id"] = $my_userid;
        }
        //added for duplicate handling
        if (is_record_exist($module, $focus, $col_pos_to_field)) {
            if ($do_save != 0) {
                $do_save = 0;
                $dup_count++;
            }
        }
        p("do save=" . $do_save);
        if ($do_save) {
            p("saving..");
            if (!isset($focus->column_fields["assigned_user_id"]) || $focus->column_fields["assigned_user_id"] == '') {
                //$focus->column_fields["assigned_user_id"] = $current_user->id;
                //MWC
                $focus->column_fields["assigned_user_id"] = $my_userid;
            }
            //handle uitype 10
            foreach ($focus->importable_fields as $fieldname => $uitype) {
                $uitype = $focus->importable_fields[$fieldname];
                if ($uitype == 10) {
                    //added to handle security permissions for related modules :: for e.g. Accounts/Contacts in Potentials
                    if (method_exists($focus, "add_related_to")) {
                        if (!$focus->add_related_to($module, $fieldname)) {
                            if (array_key_exists($fieldname, $focus->required_fields)) {
                                $do_save = 0;
                                $skip_required_count++;
                                continue 2;
                            }
                        }
                    }
                }
            }
            // now do any special processing for ex., map account with contact and potential
            if ($process_fields == 'false') {
                $focus->process_special_fields();
            }
            $focus->saveentity($module);
            //$focus->saveentity($module);
            $return_id = $focus->id;
            $last_import = new UsersLastImport();
            $last_import->assigned_user_id = $current_user->id;
            $last_import->bean_type = $_REQUEST['module'];
            $last_import->bean_id = $focus->id;
            $last_import->save();
            $count++;
        }
        $ii++;
    }
    $_REQUEST['count'] = $ii;
    if (isset($_REQUEST['module'])) {
        $modulename = vtlib_purify($_REQUEST['module']);
    }
    $end = $start + $recordcount;
    $START = $start + $recordcount;
    $RECORDCOUNT = $recordcount;
    $dup_check_type = $_REQUEST['dup_type'];
    $auto_dup_type = $_REQUEST['auto_type'];
    if ($end >= $totalnoofrows) {
        $module = 'Import';
        //$_REQUEST['module'];
        $action = 'ImportSteplast';
        //exit;
        $imported_records = $totalnoofrows - $skip_required_count;
        if ($imported_records == $totalnoofrows) {
            $skip_required_count = 0;
        }
        if ($dup_check_type == "auto") {
            if ($auto_dup_type == "ignore") {
                $dup_info = $mod_strings['Duplicate_Records_Skipped_Info'] . $dup_count;
                $imported_records -= $dup_count;
            } else {
                if ($auto_dup_type == "overwrite") {
                    $dup_info = $mod_strings['Duplicate_Records_Overwrite_Info'] . $dup_ow_count;
                    $imported_records -= $dup_ow_count;
                }
            }
        } else {
            $dup_info = "";
        }
        if ($imported_records < 0) {
            $imported_records = 0;
        }
        $message = urlencode("<b>" . $mod_strings['LBL_SUCCESS'] . "</b>" . "<br><br>" . $mod_strings['LBL_SUCCESS_1'] . "  {$imported_records} " . $mod_strings['of'] . ' ' . $totalnoofrows . "<br><br>" . $mod_strings['LBL_SKIPPED_1'] . "  {$skip_required_count} <br><br>" . $dup_info);
    } else {
        $module = 'Import';
        $action = 'ImportStep3';
    }
    ?>

<script>
setTimeout("b()",1000);
function b()
{
	document.location.href="index.php?action=<?php 
    echo $action;
    ?>
&module=<?php 
    echo $module;
    ?>
&modulename=<?php 
    echo $modulename;
    ?>
&startval=<?php 
    echo $end;
    ?>
&recordcount=<?php 
    echo $RECORDCOUNT;
    ?>
&noofrows=<?php 
    echo $totalnoofrows;
    ?>
&message=<?php 
    echo $message;
    ?>
&skipped_record_count=<?php 
    echo $skip_required_count;
    ?>
&parenttab=<?php 
    echo vtlib_purify($_SESSION['import_parenttab']);
    ?>
&dup_type=<?php 
    echo $dup_check_type;
    ?>
&auto_type=<?php 
    echo $auto_dup_type;
    ?>
";
}
</script>

<?php 
    $_SESSION['import_display_message'] = '<br>' . $start . ' ' . $mod_strings['to'] . ' ' . $end . ' ' . $mod_strings['of'] . ' ' . $totalnoofrows . ' ' . $mod_strings['are_imported_succesfully'];
    //return $_SESSION['import_display_message'];
}
예제 #12
0
 public function testGetBeansByImport()
 {
     foreach (UsersLastImport::getBeansByImport('Notes') as $objectName) {
         $this->assertEquals($objectName, 'Note');
     }
 }
예제 #13
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');
 }
예제 #14
0
 /** 
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $app_strings, $current_user, $sugar_config, $current_language;
     $this->ss->assign("MOD", $mod_strings);
     $this->ss->assign("APP", $app_strings);
     $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());
     // lookup this module's $mod_strings to get the correct module name
     $language = isset($current_language) ? $current_language : $sugar_config['default_language'];
     $module_mod_strings = return_module_language($current_language, $_REQUEST['import_module']);
     $this->ss->assign("MODULENAME", $module_mod_strings['LBL_MODULE_NAME']);
     $this->ss->assign("JAVASCRIPT", $this->_getJS());
     // 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("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::getErrorRecordsFileName());
     $this->ss->assign("dupeFile", ImportCacheFiles::getDuplicateFileName());
     // load bean
     $focus = loadImportBean($_REQUEST['import_module']);
     if (!$focus) {
         showImportError($mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'], $_REQUEST['import_module']);
         return;
     }
     if ($focus->object_name == "Prospect") {
         $this->ss->assign("PROSPECTLISTBUTTON", $this->_addToProspectListButton());
     } else {
         $this->ss->assign("PROSPECTLISTBUTTON", "");
     }
     $this->ss->display('modules/Import/tpls/last.tpl');
     foreach (UsersLastImport::getBeansByImport($_REQUEST['import_module']) as $beanname) {
         // load bean
         if (!$focus instanceof $beanname) {
             require_once $GLOBALS['beanFiles'][$beanname];
             $focus = new $beanname();
         }
         // build listview to show imported records
         require_once 'include/ListView/ListViewFacade.php';
         $lvf = new ListViewFacade($focus, $focus->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 = $focus->object_name == 'Case' ? 'aCase' : $focus->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}' \n                AND users_last_import.bean_type = '{$beanname}' \n                AND users_last_import.bean_id = {$focus->table_name}.id \n                AND users_last_import.deleted = 0 \n                AND {$focus->table_name}.deleted = 0";
         $where = " {$focus->table_name}.id IN ( \n                        SELECT users_last_import.bean_id\n                            FROM users_last_import\n                            WHERE users_last_import.assigned_user_id = '{$GLOBALS['current_user']->id}' \n                                AND users_last_import.bean_type = '{$beanname}' \n                                AND users_last_import.deleted = 0 )";
         $lbl_last_imported = $mod_strings['LBL_LAST_IMPORTED'];
         $lvf->lv->mergeduplicates = false;
         $module_mod_strings = return_module_language($current_language, $focus->module_dir);
         $lvf->setup('', $where, $params, $module_mod_strings, 0, -1, '', strtoupper($beanname), array(), 'id');
         $lvf->display($lbl_last_imported . ": " . $module_mod_strings['LBL_MODULE_NAME']);
     }
 }
예제 #15
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $app_strings, $current_user;
     global $sugar_config, $locale;
     $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
     $this->ss->assign("TYPE", !empty($_REQUEST['type']) ? $_REQUEST['type'] : "import");
     $this->ss->assign("SOURCE_ID", $_REQUEST['source_id']);
     $this->instruction = 'LBL_SELECT_PROPERTY_INSTRUCTION';
     $this->ss->assign('INSTRUCTION', $this->getInstruction());
     $this->ss->assign("MODULE_TITLE", $this->getModuleTitle(false), ENT_NOQUOTES);
     $this->ss->assign("CURRENT_STEP", $this->currentStep);
     $sugar_config['import_max_records_per_file'] = empty($sugar_config['import_max_records_per_file']) ? 1000 : $sugar_config['import_max_records_per_file'];
     $importSource = isset($_REQUEST['source']) ? $_REQUEST['source'] : 'csv';
     // Clear out this user's last import
     $seedUsersLastImport = new UsersLastImport();
     $seedUsersLastImport->mark_deleted_by_user_id($current_user->id);
     ImportCacheFiles::clearCacheFiles();
     // handle uploaded file
     $uploadFile = new UploadFile('userfile');
     if (isset($_FILES['userfile']) && $uploadFile->confirm_upload()) {
         $uploadFile->final_move('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
         $uploadFileName = $uploadFile->get_upload_path('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
     } elseif (!empty($_REQUEST['tmp_file'])) {
         $uploadFileName = "upload://" . basename($_REQUEST['tmp_file']);
     } else {
         $this->_showImportError($mod_strings['LBL_IMPORT_MODULE_ERROR_NO_UPLOAD'], $_REQUEST['import_module'], 'Step2', true, null, true);
         return;
     }
     //check the file size, we dont want to process an empty file
     if (isset($_FILES['userfile']['size']) && $_FILES['userfile']['size'] == 0) {
         //this file is empty, throw error message
         $this->_showImportError($mod_strings['LBL_NO_LINES'], $_REQUEST['import_module'], 'Step2', false, null, true);
         return;
     }
     $mimeTypeOk = true;
     //check to see if the file mime type is not a form of text or application octed streramand fire error if not
     if (isset($_FILES['userfile']['type']) && strpos($_FILES['userfile']['type'], 'octet-stream') === false && strpos($_FILES['userfile']['type'], 'text') === false && strpos($_FILES['userfile']['type'], 'application/vnd.ms-excel') === false) {
         //this file does not have a known text or application type of mime type, issue the warning
         $error_msgs[] = $mod_strings['LBL_MIME_TYPE_ERROR_1'];
         $error_msgs[] = $mod_strings['LBL_MIME_TYPE_ERROR_2'];
         $this->_showImportError($error_msgs, $_REQUEST['import_module'], 'Step2', true, $mod_strings['LBL_OK']);
         $mimeTypeOk = false;
     }
     $this->ss->assign("FILE_NAME", $uploadFileName);
     // Now parse the file and look for errors
     $importFile = new ImportFile($uploadFileName, $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES), FALSE);
     if ($this->shouldAutoDetectProperties($importSource)) {
         $GLOBALS['log']->debug("Auto detecing csv properties...");
         $autoDetectOk = $importFile->autoDetectCSVProperties();
         $importFileMap = array();
         $this->ss->assign("SOURCE", 'csv');
         if ($autoDetectOk === FALSE) {
             //show error only if previous mime type check has passed
             if ($mimeTypeOk) {
                 $this->ss->assign("AUTO_DETECT_ERROR", $mod_strings['LBL_AUTO_DETECT_ERROR']);
             }
         } else {
             $dateFormat = $importFile->getDateFormat();
             $timeFormat = $importFile->getTimeFormat();
             if ($dateFormat) {
                 $importFileMap['importlocale_dateformat'] = $dateFormat;
             }
             if ($timeFormat) {
                 $importFileMap['importlocale_timeformat'] = $timeFormat;
             }
         }
     } else {
         $impotMapSeed = $this->getImportMap($importSource);
         $importFile->setImportFileMap($impotMapSeed);
         $importFileMap = $impotMapSeed->getMapping($_REQUEST['import_module']);
     }
     $delimeter = $importFile->getFieldDelimeter();
     $enclosure = $importFile->getFieldEnclosure();
     $hasHeader = $importFile->hasHeaderRow();
     $encodeOutput = TRUE;
     //Handle users navigating back through the wizard.
     if (!empty($_REQUEST['previous_action']) && $_REQUEST['previous_action'] == 'Confirm') {
         $encodeOutput = FALSE;
         $importFileMap = $this->overloadImportFileMapFromRequest($importFileMap);
         $delimeter = !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : $delimeter;
         $enclosure = isset($_REQUEST['custom_enclosure']) ? $_REQUEST['custom_enclosure'] : $enclosure;
         $enclosure = html_entity_decode($enclosure, ENT_QUOTES);
         $hasHeader = !empty($_REQUEST['has_header']) ? $_REQUEST['has_header'] : $hasHeader;
         if ($hasHeader == 'on') {
             $hasHeader = true;
         } else {
             if ($hasHeader == 'off') {
                 $hasHeader = false;
             }
         }
     }
     $this->ss->assign("IMPORT_ENCLOSURE_OPTIONS", $this->getEnclosureOptions($enclosure));
     $this->ss->assign("IMPORT_DELIMETER_OPTIONS", $this->getDelimeterOptions($delimeter));
     $this->ss->assign("CUSTOM_DELIMITER", $delimeter);
     $this->ss->assign("CUSTOM_ENCLOSURE", htmlentities($enclosure, ENT_QUOTES));
     $hasHeaderFlag = $hasHeader ? " CHECKED" : "";
     $this->ss->assign("HAS_HEADER_CHECKED", $hasHeaderFlag);
     if (!$importFile->fileExists()) {
         $this->_showImportError($mod_strings['LBL_CANNOT_OPEN'], $_REQUEST['import_module'], 'Step2', false, null, true);
         return;
     }
     //Check if we will exceed the maximum number of records allowed per import.
     $maxRecordsExceeded = FALSE;
     $maxRecordsWarningMessg = "";
     $lineCount = $importFile->getNumberOfLinesInfile();
     $maxLineCount = isset($sugar_config['import_max_records_total_limit']) ? $sugar_config['import_max_records_total_limit'] : 5000;
     if (!empty($maxLineCount) && $lineCount > $maxLineCount) {
         $maxRecordsExceeded = TRUE;
         $maxRecordsWarningMessg = string_format($mod_strings['LBL_IMPORT_ERROR_MAX_REC_LIMIT_REACHED'], array($lineCount, $maxLineCount));
     }
     //Retrieve a sample set of data
     $rows = $this->getSampleSet($importFile);
     $this->ss->assign('column_count', $this->getMaxColumnsInSampleSet($rows));
     $this->ss->assign('HAS_HEADER', $importFile->hasHeaderRow(FALSE));
     $this->ss->assign('getNumberJs', $locale->getNumberJs());
     $this->setImportFileCharacterSet($importFile, $importFileMap);
     $this->setDateTimeProperties($importFileMap);
     $this->setCurrencyOptions($importFileMap);
     $this->setNumberFormatOptions($importFileMap);
     $this->setNameFormatProperties($importFileMap);
     $importMappingJS = $this->getImportMappingJS();
     $this->ss->assign("SAMPLE_ROWS", $rows);
     $JS = $this->_getJS($maxRecordsExceeded, $maxRecordsWarningMessg, $importMappingJS, $importFileMap);
     $this->ss->assign("JAVASCRIPT", $JS);
     $content = $this->ss->fetch('modules/Import/tpls/confirm.tpl');
     $this->ss->assign("CONTENT", $content);
     $this->ss->display('modules/Import/tpls/wizardWrapper.tpl');
 }
예제 #16
0
/**	function used to save the records into database
 *	@param array $rows - array of total rows of the csv file
 *	@param array $rows1 - rows to be saved
 *	@param object $focus - object of the corresponding import module
 *	@param int $ret_field_count - total number of fields(columns) available in the csv file
 *	@param int $col_pos_to_field - field position in the mapped array
 *	@param int $start - starting row count value to import
 *	@param int $recordcount - count of records to be import ie., number of records to import
 *	@param string $module - import module
 *	@param int $totalnoofrows - total number of rows available
 *	@param int $skip_required_count - number of records skipped
 This function will redirect to the ImportStep3 if the available records is greater than the record count (ie., number of records import in a single loop) otherwise (total records less than 500) then it will be redirected to import step last
 */
function InsertImportRecords($rows, $rows1, $focus, $ret_field_count, $col_pos_to_field, $start, $recordcount, $module, $totalnoofrows, $skip_required_count)
{
    global $current_user;
    global $adb;
    global $mod_strings;
    global $dup_ow_count;
    global $process_fields;
    $acc_config = Accounting::loadConfigParams();
    // MWC ** Getting vtiger_users
    $temp = get_user_array(FALSE);
    foreach ($temp as $key => $data) {
        $users_groups_list[$data] = $key;
    }
    $temp = get_group_array(FALSE);
    foreach ($temp as $key => $data) {
        $users_groups_list[$data] = $key;
    }
    p(print_r(users_groups_list, 1));
    $adb->println("Users List : ");
    $adb->println($users_groups_list);
    $dup_count = 0;
    $count = 0;
    $dup_ow_count = 0;
    $process_fields = 'false';
    if ($start == 0) {
        $_SESSION['totalrows'] = $rows;
        $_SESSION['return_field_count'] = $ret_field_count;
        $_SESSION['column_position_to_field'] = $col_pos_to_field;
    }
    $ii = $start;
    // go thru each row, process and save()
    $lastacc = "";
    $bMultiple = false;
    $rows2 = array();
    $payments = array();
    $sub = 0;
    $ref_idx = "";
    foreach ($col_pos_to_field as $idx => $fld) {
        if ($fld == "accounting_id") {
            $ref_idx = $idx;
            break;
        }
    }
    $ref_idx = 0;
    foreach ($rows1 as $row) {
        if (array_key_exists($row[0], $payments) == false) {
            $bMultiple = false;
        } else {
            $bMultiple = true;
        }
        /*
        		if ($row[0] == $lastacc) {
        			$bMultiple = true;
        		} else {
        			$bMultiple = false;
        		}
        
        		$lastacc = $row[0];
        */
        if ($bMultiple == false) {
            array_push($rows2, $row);
            $payments[$row[0]] = array();
        } else {
            $sub++;
        }
        $idx = 1;
        $paid = $row[$ret_field_count - $idx++];
        if ($acc_config["associnvoice"] == "true") {
            $associnv = $row[$ret_field_count - $idx++];
        }
        $paymentmethod = $row[$ret_field_count - $idx++];
        if ($acc_config["showvat"] == "true") {
            $tax = $row[$ret_field_count - $idx++];
        }
        $amount = $row[$ret_field_count - $idx++];
        $paymentdate = $row[$ret_field_count - $idx++];
        $paymentduedate = $row[$ret_field_count - $idx++];
        $ref = $row[$ret_field_count - $idx++];
        $invid = '';
        $assocmodule = '';
        $assocdisplay = '';
        if ($associnv != "") {
            //check the module of the field
            $arr = array();
            $arr = explode("::::", $associnv);
            $assocmodule = $arr[0];
            $assocdisplay = $arr[1];
            $focus1 = CRMEntity::getInstance($assocmodule);
            $entityNameArr = getEntityField($assocmodule);
            $entityName = $entityNameArr['fieldname'];
            $query = "SELECT vtiger_crmentity.deleted, {$focus1->table_name}.*\n\t\t\t\t\t\tFROM {$focus1->table_name}\n\t\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid={$focus1->table_name}.{$focus1->table_index}\n\t\t\t\t\t\t\twhere {$entityName}=? and vtiger_crmentity.deleted=0";
            $result = $adb->pquery($query, array($assocdisplay));
            $invid = $adb->query_result($result, 0, $focus1->table_index);
        }
        $payment = array('ref' => $ref, 'paymentduedate' => $paymentduedate, 'paymentdate' => $paymentdate, 'amount' => $amount, 'paymenttax' => $tax, 'paymentmethod' => $paymentmethod, 'associnv' => $invid, 'associnv_display' => $assocdisplay, 'paymentassoc_mod' => $assocmodule, 'paid' => $paid);
        array_push($payments[$row[0]], $payment);
    }
    $totalnoofrows -= $sub;
    $rows1 = $rows2;
    $recordcount = count($rows1);
    foreach ($rows1 as $row) {
        $adb->println("Going to Save the row " . $ii . " =====> ");
        $adb->println($row);
        global $mod_strings;
        $do_save = 1;
        //MWC
        $my_userid = $current_user->id;
        //If we want to set default values for some fields for each entity then we have to set here
        if ($module == 'Products' || $module == 'Services') {
            //discontinued is not null. if we unmap active, NULL will be inserted and query will fail
            $focus->column_fields['discontinued'] = 'on';
        }
        for ($field_count = 0; $field_count < $ret_field_count; $field_count++) {
            p("col_pos[" . $field_count . "]=" . $col_pos_to_field[$field_count]);
            if (isset($col_pos_to_field[$field_count])) {
                p("set =" . $field_count);
                if (!isset($row[$field_count])) {
                    continue;
                }
                p("setting");
                // TODO: add check for user input
                // addslashes, striptags, etc..
                $field = $col_pos_to_field[$field_count];
                //picklist function is added to avoid duplicate picklist entries
                $pick_orginal_val = getPicklist($field, $row[$field_count]);
                if ($pick_orginal_val != null) {
                    $focus->column_fields[$field] = $pick_orginal_val;
                } elseif ($field == "assignedto" || $field == "assigned_user_id") {
                    //Here we are assigning the user id in column fields, so in function assign_user (ImportLead.php and ImportProduct.php files) we should use the id instead of user name when query the user
                    //or we can use $focus->column_fields['smownerid'] = $users_groups_list[$row[$field_count]];
                    $imported_user = $current_user->id;
                    $q = "SELECT groupid FROM vtiger_groups WHERE groupname=?";
                    $res = $adb->pquery($q, array(trim($row[$field_count])));
                    if ($adb->num_rows($res) > 0) {
                        $imported_user = $adb->query_result($res, 0, "groupid");
                    } else {
                        $q = "SELECT id FROM vtiger_users WHERE user_name=?";
                        $res = $adb->pquery($q, array(trim($row[$field_count])));
                        if ($adb->num_rows($res) == 0) {
                            $imported_user = $adb->query_result($res, 0, "id");
                        }
                    }
                    $focus->column_fields[$field] = $imported_user;
                    p("setting my_userid={$my_userid} for user="******"Setting " . $field . "=" . $row[$field_count]);
                }
            }
        }
        if ($focus->column_fields['notify_owner'] == '') {
            $focus->column_fields['notify_owner'] = '0';
        }
        if ($focus->column_fields['reference'] == '') {
            $focus->column_fields['reference'] = '0';
        }
        if ($focus->column_fields['emailoptout'] == '') {
            $focus->column_fields['emailoptout'] = '0';
        }
        if ($focus->column_fields['donotcall'] == '') {
            $focus->column_fields['donotcall'] = '0';
        }
        if ($focus->column_fields['discontinued'] == '') {
            $focus->column_fields['discontinued'] = '0';
        }
        if ($focus->column_fields['active'] == '') {
            $focus->column_fields['active'] = '0';
        }
        p("setting done");
        p("do save before req vtiger_fields=" . $do_save);
        $adb->println($focus->required_fields);
        foreach ($focus->required_fields as $field => $notused) {
            $fv = trim($focus->column_fields[$field]);
            if (!isset($fv) || $fv == '') {
                // Leads Import does not allow an empty lastname because the link is created on the lastname
                // Without lastname the Lead could not be opened.
                // But what if the import file has only company and telefone information?
                // It would be stupid to skip all the companies which don't have a contact person yet!
                // So we set lastname ="?????" and the user can later enter a name.
                // So the lastname is still mandatory but may be empty.
                if ($field == 'lastname' && $module == 'Leads') {
                    $focus->column_fields[$field] = '?????';
                } else {
                    p("fv " . $field . " not set");
                    $do_save = 0;
                    $skip_required_count++;
                    break;
                }
            }
        }
        if (!isset($focus->column_fields["assigned_user_id"]) || $focus->column_fields["assigned_user_id"] === '' || $focus->column_fields["assigned_user_id"] === NULL) {
            $focus->column_fields["assigned_user_id"] = $my_userid;
        }
        //added for duplicate handling
        if (is_record_exist($module, $focus)) {
            if ($do_save != 0) {
                $do_save = 0;
                $dup_count++;
            }
        }
        p("do save=" . $do_save);
        if ($do_save) {
            p("saving..");
            if (!isset($focus->column_fields["assigned_user_id"]) || $focus->column_fields["assigned_user_id"] == '') {
                //$focus->column_fields["assigned_user_id"] = $current_user->id;
                //MWC
                $focus->column_fields["assigned_user_id"] = $my_userid;
            }
            //handle uitype 10
            foreach ($focus->importable_fields as $fieldname => $uitype) {
                $uitype = $focus->importable_fields[$fieldname];
                if ($uitype == 10) {
                    //added to handle security permissions for related modules :: for e.g. Accounts/Contacts in Potentials
                    if (method_exists($focus, "add_related_to")) {
                        if (!$focus->add_related_to($module, $fieldname)) {
                            if (array_key_exists($fieldname, $focus->required_fields)) {
                                $do_save = 0;
                                $skip_required_count++;
                                continue 2;
                            }
                        }
                    }
                }
            }
            // now do any special processing for ex., map account with contact and potential
            if ($process_fields == 'false') {
                $focus->process_special_fields();
            }
            $focus->saveentity($module);
            //$focus->saveentity($module);
            $return_id = $focus->id;
            // $focus->column_fields['accounting_id']
            $sql = "INSERT INTO vtiger_accounting_payments (idtransaction, amount," . ($acc_config["showvat"] == "true" ? "tax," : "") . " paymentduedate, paymentdate, paid, ref," . ($acc_config["associnvoice"] == "true" ? "associnv,assoc_display,assoc_mod," : "") . " paymentmethod) VALUES (" . ($acc_config["showvat"] == "true" ? "?," : "") . ($acc_config["associnvoice"] == "true" ? "?,?,?," : "") . "?, ?, ?, ?, ?, ?, ?)";
            foreach ($payments[$row[0]] as $payment) {
                if ($acc_config["associnvoice"] == "true" && $acc_config["showvat"] == "true") {
                    $data_arr = array($return_id, $payment['amount'], $payment['paymenttax'], $payment['paymentduedate'], $payment['paymentdate'], $payment['paid'], $payment['ref'], $payment['associnv'], $payment['associnv_display'], $payment['paymentassoc_mod'], $payment['paymentmethod']);
                } else {
                    if ($acc_config["associnvoice"] == "true" && $acc_config["showvat"] == "false") {
                        $data_arr = array($return_id, $payment['amount'], $payment['paymentduedate'], $payment['paymentdate'], $payment['paid'], $payment['ref'], $payment['associnv'], $payment['associnv_display'], $payment['paymentassoc_mod'], $payment['paymentmethod']);
                    } else {
                        if ($acc_config["associnvoice"] == "false" && $acc_config["showvat"] == "true") {
                            $data_arr = array($return_id, $payment['amount'], $payment['paymenttax'], $payment['paymentduedate'], $payment['paymentdate'], $payment['paid'], $payment['ref'], $payment['paymentmethod']);
                        } else {
                            if ($acc_config["associnvoice"] == "false" && $acc_config["showvat"] == "false") {
                                $data_arr = array($return_id, $payment['amount'], $payment['paymentduedate'], $payment['paymentdate'], $payment['paid'], $payment['ref'], $payment['paymentmethod']);
                            }
                        }
                    }
                }
                foreach ($data_arr as &$param) {
                    if (!isset($param)) {
                        $param = "";
                    }
                }
                $res = $adb->pquery($sql, $data_arr);
            }
            $last_import = new UsersLastImport();
            $last_import->assigned_user_id = $current_user->id;
            $last_import->bean_type = $_REQUEST['module'];
            $last_import->bean_id = $focus->id;
            $last_import->save();
            $count++;
        }
        $ii++;
    }
    $_REQUEST['count'] = $ii;
    if (isset($_REQUEST['module'])) {
        $modulename = vtlib_purify($_REQUEST['module']);
    }
    $end = $start + $recordcount;
    $START = $start + $recordcount;
    $RECORDCOUNT = $recordcount;
    $dup_check_type = $_REQUEST['dup_type'];
    $auto_dup_type = $_REQUEST['auto_type'];
    if ($end >= $totalnoofrows) {
        $module = 'Import';
        //$_REQUEST['module'];
        $action = 'ImportSteplast';
        //exit;
        $imported_records = $totalnoofrows - $skip_required_count;
        if ($imported_records == $totalnoofrows) {
            $skip_required_count = 0;
        }
        if ($dup_check_type == "auto") {
            if ($auto_dup_type == "ignore") {
                $dup_info = $mod_strings['Duplicate_Records_Skipped_Info'] . $dup_count;
                $imported_records -= $dup_count;
            } else {
                if ($auto_dup_type == "overwrite") {
                    $dup_info = $mod_strings['Duplicate_Records_Overwrite_Info'] . $dup_ow_count;
                    $imported_records -= $dup_ow_count;
                }
            }
        } else {
            $dup_info = "";
        }
        if ($imported_records < 0) {
            $imported_records = 0;
        }
        $message = urlencode("<b>" . $mod_strings['LBL_SUCCESS'] . "</b>" . "<br><br>" . $mod_strings['LBL_SUCCESS_1'] . "  {$imported_records} " . $mod_strings['of'] . ' ' . $totalnoofrows . "<br><br>" . $mod_strings['LBL_SKIPPED_1'] . "  {$skip_required_count} <br><br>" . $dup_info);
    } else {
        $module = 'Import';
        $action = 'ImportStep3';
    }
    ?>

<script>
setTimeout("b()",1000);
function b()
{
	document.location.href="index.php?action=<?php 
    echo $action;
    ?>
&module=<?php 
    echo $module;
    ?>
&modulename=<?php 
    echo $modulename;
    ?>
&startval=<?php 
    echo $end;
    ?>
&recordcount=<?php 
    echo $RECORDCOUNT;
    ?>
&noofrows=<?php 
    echo $totalnoofrows;
    ?>
&message=<?php 
    echo $message;
    ?>
&skipped_record_count=<?php 
    echo $skip_required_count;
    ?>
&parenttab=<?php 
    echo vtlib_purify($_SESSION['import_parenttab']);
    ?>
&dup_type=<?php 
    echo $dup_check_type;
    ?>
&auto_type=<?php 
    echo $auto_dup_type;
    ?>
";
}
</script>

<?php 
    $_SESSION['import_display_message'] = '<br>' . $start . ' ' . $mod_strings['to'] . ' ' . $end . ' ' . $mod_strings['of'] . ' ' . $totalnoofrows . ' ' . $mod_strings['are_imported_succesfully'];
    //return $_SESSION['import_display_message'];
}