[Vtigercrm-commits] [vtiger-commits] r10646 - in /vtigercrm/branches/5.0.3: Smarty/templates/ImportStep2.tpl include/language/en_us.lang.php modules/Import/ImportAjax.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Wed Apr 11 11:24:28 EDT 2007
Author: saraj
Date: Wed Apr 11 09:24:19 2007
New Revision: 10646
Log:
* Validation has been added to check, whether the map name is already exist or not, Fixed #3356
Modified:
vtigercrm/branches/5.0.3/Smarty/templates/ImportStep2.tpl
vtigercrm/branches/5.0.3/include/language/en_us.lang.php
vtigercrm/branches/5.0.3/modules/Import/ImportAjax.php
Modified: vtigercrm/branches/5.0.3/Smarty/templates/ImportStep2.tpl
==============================================================================
--- vtigercrm/branches/5.0.3/Smarty/templates/ImportStep2.tpl (original)
+++ vtigercrm/branches/5.0.3/Smarty/templates/ImportStep2.tpl Wed Apr 11 09:24:19 2007
@@ -57,7 +57,42 @@
document.getElementById("delete_mapping").style.visibility = "hidden";
alert("{$APP.MAP_DELETED_INFO}");
{rdelim}
-
+{literal}
+function check_submit()
+{
+ if(validate_import_map())
+ {
+ if(document.getElementById("save_map").checked)
+ {
+ var name=document.getElementById("save_map_as").value
+ $("status").style.display="block";
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody: 'module=Import&name='+name+'&ajax_action=check_dup_map_name&action=ImportAjax',
+ onComplete: function(response) {
+
+ if(response.responseText == 'true')
+ document.Import.submit();
+{/literal} else
+ if(confirm("{$APP.MAP_NAME_EXISTS}"))
+{literal} document.Import.submit();
+ $("status").style.display="none";
+
+ }
+ }
+ );
+
+
+ }
+ else
+ document.Import.submit();
+ }
+}
+
+
+{/literal}
</script>
<!-- header - level 2 tabs -->
{include file='Buttons_List1.tpl'}
@@ -173,7 +208,7 @@
<td align="right" style="padding-right:40px;" class="reportCreateBottom" >
<input type="submit" name="button" value=" ‹ {$MOD.LBL_BACK} " class="crmbutton small cancel" onclick="this.form.action.value='Import';this.form.step.value='1'; return true;" />
- <input type="submit" name="button" value=" {$MOD.LBL_IMPORT_NOW} › " class="crmbutton small save" onclick="this.form.action.value='Import';this.form.step.value='3'; return validate_import_map();" />
+ <input type="button" name="button" value=" {$MOD.LBL_IMPORT_NOW} › " class="crmbutton small save" onclick="this.form.action.value='Import';this.form.step.value='3'; check_submit();" />
</td>
</tr>
</table>
Modified: vtigercrm/branches/5.0.3/include/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.0.3/include/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.0.3/include/language/en_us.lang.php Wed Apr 11 09:24:19 2007
@@ -850,6 +850,7 @@
//Added for the link Read License in footer
'LNK_READ_LICENSE'=>'Read License',
'ACTIVITIES' => 'Activities',
+'MAP_NAME_EXISTS'=>'This map name already exists. \n Do you want to overwrite it?',
);
$app_list_strings = array (
Modified: vtigercrm/branches/5.0.3/modules/Import/ImportAjax.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Import/ImportAjax.php (original)
+++ vtigercrm/branches/5.0.3/modules/Import/ImportAjax.php Wed Apr 11 09:24:19 2007
@@ -14,53 +14,69 @@
include('modules/Import/Forms.php');
//This is to delete the map
-if($_REQUEST['delete_map'] != '')
+
+if($_REQUEST['ajax_action'] == 'check_dup_map_name')
{
- $query = "update vtiger_import_maps set deleted=1 where id = ".$_REQUEST['mapping'];
- $adb->query($query);
+ $map_name=$_REQUEST['name'];
+ global $adb;
+ $query="select * from vtiger_import_maps where deleted=0 and name='".$map_name."'";
+ $Result = $adb->query($query);
+ $noofrows = $adb->num_rows($Result);
+ if($noofrows > 0)
+ echo "false"; //Map name already exists
+ else
+ echo "true";
+}
+else
+{
+
+ if($_REQUEST['delete_map'] != '')
+ {
+ $query = "update vtiger_import_maps set deleted=1 where id = ".$_REQUEST['mapping'];
+ $adb->query($query);
+ }
+
+ $mapping_file = new ImportMap();
+ $mapping_arr = $mapping_file->getSavedMappingContent($_REQUEST['mapping']);
+
+ $importable_fields = $_SESSION['import_module_object_column_fields'];
+ $field_count = $_SESSION['import_module_field_count'];
+ $required_fields = $_SESSION['import_module_object_required_fields'];
+ $translated_column_fields = $_SESSION['import_module_translated_column_fields'];
+
+ $tablename = '';
+ $has_header = $_SESSION['import_has_header'];
+ $firstrow = $_SESSION['import_firstrow'];
+ $field_map = &$mapping_arr;//$_SESSION['import_field_map'];
+ $smarty_array1 = array();
+
+ for($i=0;$i<$field_count;$i++)
+ {
+ $suggest = '';
+ if ($has_header && isset( $field_map[$firstrow[$i]] ) )
+ {
+ $suggest = $field_map[$firstrow[$i]];
+ }
+ else if (isset($field_map[$i]))
+ {
+ $suggest = $field_map[$i];
+ }
+
+ $smarty_array1[$i+1] = getFieldSelect( $importable_fields,
+ $i,
+ $required_fields,
+ $suggest,
+ $translated_column_fields,
+ $tablename
+ );
+ }
+
+ $smarty = new vtigerCRM_Smarty;
+ $smarty->assign("FIRSTROW",$firstrow);
+ $smarty->assign("SELECTFIELD",$smarty_array1);
+
+ $smarty->display('ImportMap.tpl');
+
}
-$mapping_file = new ImportMap();
-$mapping_arr = $mapping_file->getSavedMappingContent($_REQUEST['mapping']);
-
-$importable_fields = $_SESSION['import_module_object_column_fields'];
-$field_count = $_SESSION['import_module_field_count'];
-$required_fields = $_SESSION['import_module_object_required_fields'];
-$translated_column_fields = $_SESSION['import_module_translated_column_fields'];
-
-$tablename = '';
-$has_header = $_SESSION['import_has_header'];
-$firstrow = $_SESSION['import_firstrow'];
-$field_map = &$mapping_arr;//$_SESSION['import_field_map'];
-$smarty_array1 = array();
-
-for($i=0;$i<$field_count;$i++)
-{
- $suggest = '';
- if ($has_header && isset( $field_map[$firstrow[$i]] ) )
- {
- $suggest = $field_map[$firstrow[$i]];
- }
- else if (isset($field_map[$i]))
- {
- $suggest = $field_map[$i];
- }
-
- $smarty_array1[$i+1] = getFieldSelect( $importable_fields,
- $i,
- $required_fields,
- $suggest,
- $translated_column_fields,
- $tablename
- );
-}
-
-$smarty = new vtigerCRM_Smarty;
-$smarty->assign("FIRSTROW",$firstrow);
-$smarty->assign("SELECTFIELD",$smarty_array1);
-
-$smarty->display('ImportMap.tpl');
-
-
-
?>
More information about the vtigercrm-commits
mailing list