更新到 5.2 后第一次 SVN 提交。
yuchenghu@hawebs.net git-svn-id: https://svn.code.sf.net/p/hawebs/svn@540 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
@@ -97,11 +97,6 @@ function InsertImportRecords($rows,$rows1,$focus,$ret_field_count,$col_pos_to_fi
|
||||
{
|
||||
$focus->column_fields[$field]=$pick_orginal_val;
|
||||
}
|
||||
elseif (substr(trim($field), 0, 3) == "CF_")
|
||||
{
|
||||
p("setting custfld".$field."=".$row[$field_count]);
|
||||
$resCustFldArray[$field] = $row[$field_count];
|
||||
}
|
||||
//MWC
|
||||
elseif ( $field == "assignedto" || $field == "assigned_user_id" )
|
||||
{
|
||||
@@ -221,81 +216,15 @@ function InsertImportRecords($rows,$rows1,$focus,$ret_field_count,$col_pos_to_fi
|
||||
if($process_fields == 'false'){
|
||||
$focus->process_special_fields();
|
||||
}
|
||||
|
||||
$focus->save($module);
|
||||
$focus->saveentity($module);
|
||||
//$focus->saveentity($module);
|
||||
$return_id = $focus->id;
|
||||
|
||||
if(count($resCustFldArray)>0){
|
||||
if($_REQUEST['module'] == 'Contacts'){
|
||||
$_REQUEST['module']='contactdetails';
|
||||
}
|
||||
$dbquery="select * from vtiger_field where vtiger_tablename=? and vtiger_field.presence in (0,2)";
|
||||
$custresult = $adb->pquery($dbquery, array($_REQUEST['module']));
|
||||
if($adb->num_rows($custresult) != 0)
|
||||
{
|
||||
if (! isset( $_REQUEST['module'] ) || $_REQUEST['module'] == 'Contacts')
|
||||
{
|
||||
$columns = 'contactid';
|
||||
$custTabName = 'contactscf';
|
||||
}
|
||||
else if ( $_REQUEST['module'] == 'Accounts')
|
||||
{
|
||||
$columns = 'accountid';
|
||||
$custTabName = 'accountscf';
|
||||
}
|
||||
else if ( $_REQUEST['module'] == 'Potentials')
|
||||
{
|
||||
$columns = 'potentialid';
|
||||
$custTabName = 'potentialscf';
|
||||
}
|
||||
else if ( $_REQUEST['module'] == 'Leads')
|
||||
{
|
||||
$columns = 'leadidid';
|
||||
$custTabName = 'leadscf';
|
||||
}
|
||||
else if ( $_REQUEST['module'] == 'Products')
|
||||
{
|
||||
$columns = 'productid';
|
||||
$custTabName = 'productcf';
|
||||
}
|
||||
else if ( $_REQUEST['module'] == 'Helpdesk')
|
||||
{
|
||||
$columns = 'ticketid';
|
||||
$custTabName = 'ticketcf';
|
||||
}
|
||||
else if ( $_REQUEST['module'] == 'Vendors')
|
||||
{
|
||||
$columns = 'vendorid';
|
||||
$custTabName = 'vendorcf';
|
||||
}
|
||||
$noofrows = $adb->num_rows($custresult);
|
||||
$params = array($focus->id);
|
||||
|
||||
for($j=0; $j<$noofrows; $j++)
|
||||
{
|
||||
$colName=$adb->query_result($custresult,$j,"columnname");
|
||||
if(array_key_exists($colName, $resCustFldArray))
|
||||
{
|
||||
$value_colName = $resCustFldArray[$colName];
|
||||
|
||||
$columns .= ', '.$colName;
|
||||
array_push($params, $value_colName);
|
||||
}
|
||||
}
|
||||
|
||||
$insert_custfld_query = 'insert into '.$custTabName.' ('.$columns.') values('. generateQuestionMarks($params) .')';
|
||||
$adb->pquery($insert_custfld_query, $params);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$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();
|
||||
array_push($saved_ids,$focus->id);
|
||||
$count++;
|
||||
}
|
||||
$ii++;
|
||||
@@ -309,6 +238,7 @@ function InsertImportRecords($rows,$rows1,$focus,$ret_field_count,$col_pos_to_fi
|
||||
$START = $start + $recordcount;
|
||||
$RECORDCOUNT = $recordcount;
|
||||
$dup_check_type = $_REQUEST['dup_type'];
|
||||
$auto_dup_type = $_REQUEST['auto_type'];
|
||||
|
||||
if($end >= $totalnoofrows) {
|
||||
$module = 'Import';//$_REQUEST['module'];
|
||||
@@ -319,7 +249,6 @@ function InsertImportRecords($rows,$rows1,$focus,$ret_field_count,$col_pos_to_fi
|
||||
$skip_required_count = 0;
|
||||
}
|
||||
if($dup_check_type == "auto") {
|
||||
$auto_dup_type = $_REQUEST['auto_type'];
|
||||
if($auto_dup_type == "ignore") {
|
||||
$dup_info = $mod_strings['Duplicate_Records_Skipped_Info'].$dup_count;
|
||||
$imported_records -= $dup_count;
|
||||
@@ -334,7 +263,7 @@ function InsertImportRecords($rows,$rows1,$focus,$ret_field_count,$col_pos_to_fi
|
||||
|
||||
if($imported_records < 0) $imported_records = 0;
|
||||
|
||||
$message= urlencode("<b>".$mod_strings['LBL_SUCCESS']."</b>"."<br><br>" .$mod_strings['LBL_SUCCESS_1']." $imported_records" ."<br><br>" .$mod_strings['LBL_SKIPPED_1']." $skip_required_count <br><br>".$dup_info );
|
||||
$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';
|
||||
@@ -345,7 +274,7 @@ function InsertImportRecords($rows,$rows1,$focus,$ret_field_count,$col_pos_to_fi
|
||||
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?>";
|
||||
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>
|
||||
|
||||
@@ -476,6 +405,23 @@ function overwrite_duplicate_records($module,$focus)
|
||||
global $dup_ow_count;
|
||||
global $process_fields;
|
||||
|
||||
//Fix for 6187 : overwriting records during duplicate merge to handle uitype 10
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$where_clause = "";
|
||||
$where = get_where_clause($module,$focus->column_fields);
|
||||
$sec_parameter = getSecParameterforMerge($module);
|
||||
@@ -569,4 +515,34 @@ function overwrite_duplicate_records($module,$focus)
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
//picklist function is added to avoid duplicate picklist entries
|
||||
function getPicklist($field,$value)
|
||||
{
|
||||
global $table_picklist,$converted_table_picklist_values;
|
||||
|
||||
//for the first run these will be defined and for the subsequent redirections
|
||||
//pick up from session.
|
||||
if(is_array($table_picklist)){
|
||||
$_SESSION['import_table_picklist'] = $table_picklist;
|
||||
}else{
|
||||
$table_picklist = $_SESSION['import_table_picklist'];
|
||||
}
|
||||
if(is_array($converted_table_picklist_values)){
|
||||
$_SESSION['import_converted_picklist_values'] = $converted_table_picklist_values;
|
||||
}else{
|
||||
$converted_table_picklist_values = $_SESSION['import_converted_picklist_values'];
|
||||
}
|
||||
|
||||
$orginal_val = $table_picklist[$field];
|
||||
$converted_val = $converted_table_picklist_values[$field];
|
||||
$temp_val = strtolower($value);
|
||||
if(is_array($converted_val) && in_array($temp_val,$converted_val)) {
|
||||
$existkey = array_search($temp_val,$converted_val);
|
||||
$correct_val=$orginal_val[$existkey];
|
||||
return $correct_val;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -42,7 +42,7 @@ require_once('include/utils/CommonUtils.php');
|
||||
@session_unregister('startval');
|
||||
@session_unregister('return_field_count');
|
||||
$_SESSION['totalrows'] = '';
|
||||
$_SESSION['recordcount'] = 500;
|
||||
$_SESSION['recordcount'] = 250;
|
||||
$_SESSION['startval'] = 0;
|
||||
|
||||
global $mod_strings;
|
||||
|
||||
@@ -35,11 +35,6 @@ require_once('include/ListView/ListView.php');
|
||||
require_once('include/database/PearDatabase.php');
|
||||
require_once('modules/Import/ImportSave.php');
|
||||
|
||||
global $php_max_execution_time;
|
||||
set_time_limit($php_max_execution_time);
|
||||
ini_set("display_errors",'0');
|
||||
|
||||
|
||||
function p($str){
|
||||
global $adb;
|
||||
$adb->println("IMP :".$str);
|
||||
@@ -275,6 +270,16 @@ if($_REQUEST['noofrows'] != ''){
|
||||
$totalnoofrows = count($datarows);
|
||||
}
|
||||
|
||||
if($_REQUEST['recordcount'] != ''){
|
||||
$RECORDCOUNT = vtlib_purify($_REQUEST['recordcount']);
|
||||
}else{
|
||||
$RECORDCOUNT = vtlib_purify($_SESSION['recordcount']);
|
||||
}
|
||||
|
||||
if(($START+$RECORDCOUNT) > $totalnoofrows){
|
||||
$RECORDCOUNT = $totalnoofrows - $START;
|
||||
}
|
||||
|
||||
$loopcount = ($totalnoofrows/$RECORDCOUNT)+1;
|
||||
|
||||
if($_REQUEST['startval'] != ''){
|
||||
@@ -283,16 +288,6 @@ if($_REQUEST['startval'] != ''){
|
||||
$START = vtlib_purify($_SESSION['startval']);
|
||||
}
|
||||
|
||||
if($_REQUEST['recordcount'] != ''){
|
||||
$RECORDCOUNT = vtlib_purify($_REQUEST['recordcount']);
|
||||
}else{
|
||||
$RECORDCOUNT = vtlib_purify($_SESSION['recordcount']);
|
||||
}
|
||||
|
||||
if(($START+$RECORDCOUNT) > $totalnoofrows){
|
||||
$RECORDCOUNT = $totalnoofrows - $START;
|
||||
}
|
||||
|
||||
$focus->initImportableFields($module);
|
||||
if($totalnoofrows > $RECORDCOUNT && $START < $totalnoofrows){
|
||||
$rows1 = Array();
|
||||
@@ -314,4 +309,4 @@ if($totalnoofrows > $RECORDCOUNT && $START < $totalnoofrows){
|
||||
|
||||
//Display the imported records message
|
||||
echo "<div align='center' width='100%'><font color='green'><b>".$_SESSION['import_display_message']."</b></font></div>";
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -182,7 +182,7 @@ if( $_REQUEST['dup_type'] == 'manual')
|
||||
$smarty->assign("FIELD_NAMES",$fld_name);
|
||||
$smarty->assign("CATEGORY",$parenttab);
|
||||
$smarty->assign("ALL_VALUES",$fld_values);
|
||||
$smarty->assign("MOD", return_module_language($current_language,'Contacts'));
|
||||
$smarty->assign("MOD", return_module_language($current_language,$req_module));
|
||||
$smarty->assign("IMAGE_PATH",$image_path);
|
||||
$smarty->assign("APP", $app_strings);
|
||||
$smarty->assign("CMOD", $mod_strings);
|
||||
@@ -297,9 +297,10 @@ else
|
||||
$smarty->assign("LISTENTITY", $listview_entries);
|
||||
|
||||
$smarty->display("ListViewEntries.tpl");
|
||||
echo "<BR>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($_SESSION['import_table_picklist']);
|
||||
unset($_SESSION['import_converted_picklist_values+95']);
|
||||
?>
|
||||
@@ -271,6 +271,7 @@ class UsersLastImport extends SugarBean
|
||||
$count += $this->undo_leads($user_id);
|
||||
$count += $this->undo_products($user_id);
|
||||
$count += $this->undo_HelpDesk($user_id);
|
||||
$count += $this->undo_activities($user_id);
|
||||
$count += $this->undo_Vendors($user_id);
|
||||
return $count;
|
||||
}
|
||||
@@ -447,7 +448,28 @@ class UsersLastImport extends SugarBean
|
||||
return $count;
|
||||
}
|
||||
|
||||
/** function used to delete (update deleted=1 in crmentity table) the last imported products of the current user
|
||||
* @param int $user_id - user id, whose last imported products want to be deleted
|
||||
* @return int $count - return the number of deleted products
|
||||
*/
|
||||
function undo_activities($user_id)
|
||||
{
|
||||
$count = 0;
|
||||
$query1 = "select bean_id from vtiger_users_last_import where assigned_user_id=? AND bean_type='Calendar' AND deleted=0";
|
||||
$this->log->info($query1);
|
||||
$result1 = $this->db->pquery($query1, array($user_id)) or die("Error getting last import for undo: ".mysql_error());
|
||||
|
||||
while ( $row1 = $this->db->fetchByAssoc($result1))
|
||||
{
|
||||
$query2 = "update vtiger_crmentity set deleted=1 where crmid=?";
|
||||
$this->log->info($query2);
|
||||
$result2 = $this->db->pquery($query2, array($row1['bean_id'])) or die("Error undoing last import: ".mysql_error());
|
||||
|
||||
$count++;
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -55,8 +55,18 @@ function parse_import($file_name,$delimiter,$max_lines,$has_header)
|
||||
}
|
||||
$this_field_count = count($fields);
|
||||
|
||||
if ( $this_field_count > $field_count)
|
||||
{
|
||||
//Added to handle the case where the last value in a row is "" and
|
||||
//the field value in the next row is "" then for some reason these rows
|
||||
//are getting parsed as same row, this does not happen if the line seperator is
|
||||
// linux line endings.
|
||||
$matches = array();
|
||||
preg_match("/^''\s*''$/",$fields[$field_count - 1],$matches);
|
||||
if(($this_field_count + 1)/2 == $field_count && count($matches) > 0){
|
||||
$chunks = array_chunk($fields,$field_count);
|
||||
$fields = $chunks[0];
|
||||
array_push($rows,$chunks[1]);
|
||||
$line_count++;
|
||||
}else{
|
||||
$field_count = $this_field_count;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ for($i=0;$i<$no_of_picklists;$i++)
|
||||
}
|
||||
}
|
||||
|
||||
$csv_picklist_values = array();
|
||||
//Collect all picklist values from csv file
|
||||
foreach($field_to_pos as $fieldname => $ind)
|
||||
{
|
||||
@@ -84,21 +85,5 @@ foreach($csv_picklist_values as $fieldname => $temp_array)
|
||||
}
|
||||
|
||||
}
|
||||
function getPicklist($field,$value)
|
||||
{
|
||||
global $table_picklist,$converted_table_picklist_values;
|
||||
$orginal_val = $table_picklist[$field];
|
||||
$converted_val = $converted_table_picklist_values[$field];
|
||||
$temp_val = strtolower($value);
|
||||
|
||||
if(in_array($temp_val,$converted_val))
|
||||
{
|
||||
$existkey = array_search($temp_val,$converted_val);
|
||||
$correct_val=$orginal_val[$existkey];
|
||||
return $correct_val;
|
||||
}else
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user