[Vtigercrm-commits] [vtiger-commits] r9639 - in /vtigercrm/branches/5.0.2: Smarty/templates/ImportStep2.tpl modules/Import/ImportAjax.php modules/Import/ImportMap.php modules/Import/ImportStep2.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon Oct 16 14:47:07 EDT 2006


Author: richie
Date: Mon Oct 16 12:47:00 2006
New Revision: 9639

Log:
* Modified to provide the Delete mapping link and when we save new mapping if there is any mapping with the same name exist then we should overwrite the existing one with the new one

Modified:
    vtigercrm/branches/5.0.2/Smarty/templates/ImportStep2.tpl
    vtigercrm/branches/5.0.2/modules/Import/ImportAjax.php
    vtigercrm/branches/5.0.2/modules/Import/ImportMap.php
    vtigercrm/branches/5.0.2/modules/Import/ImportStep2.php

Modified: vtigercrm/branches/5.0.2/Smarty/templates/ImportStep2.tpl
==============================================================================
--- vtigercrm/branches/5.0.2/Smarty/templates/ImportStep2.tpl (original)
+++ vtigercrm/branches/5.0.2/Smarty/templates/ImportStep2.tpl Mon Oct 16 12:47:00 2006
@@ -18,6 +18,13 @@
 function getImportSavedMap(impoptions)
 {ldelim}
 	var mapping = impoptions.options[impoptions.options.selectedIndex].value;
+
+	//added to show the delete link
+	if(mapping != -1)
+		document.getElementById("delete_mapping").style.visibility = "visible";
+	else
+		document.getElementById("delete_mapping").style.visibility = "hidden";
+
 	new Ajax.Request(
 		'index.php',
 		{ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
@@ -28,6 +35,27 @@
 				{rdelim}
 			{rdelim}
 		);
+{rdelim}
+function deleteMapping()
+{ldelim}
+	var options_collection = document.getElementById("saved_source").options;
+	var mapid = options_collection[options_collection.selectedIndex].value;
+
+	new Ajax.Request(
+		'index.php',
+		{ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+			method: 'post',
+			postBody: 'module=Import&mapping='+mapid+'&action=ImportAjax&delete_map='+mapid,
+			onComplete: function(response) {ldelim}
+					$("importmapform").innerHTML = response.responseText;
+				{rdelim}
+			{rdelim}
+		);
+
+	//we have emptied the map name from the select list
+	document.getElementById("saved_source").options[options_collection.selectedIndex] = null;
+	document.getElementById("delete_mapping").style.visibility = "hidden";
+	alert("This map has been deleted. You cannot use this map again");
 {rdelim}
 
 </script>

Modified: vtigercrm/branches/5.0.2/modules/Import/ImportAjax.php
==============================================================================
--- vtigercrm/branches/5.0.2/modules/Import/ImportAjax.php (original)
+++ vtigercrm/branches/5.0.2/modules/Import/ImportAjax.php Mon Oct 16 12:47:00 2006
@@ -12,6 +12,14 @@
 require_once('Smarty_setup.php');
 include('modules/Import/ImportMap.php');
 include('modules/Import/Forms.php');
+
+//This is to delete the map
+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']);
 

Modified: vtigercrm/branches/5.0.2/modules/Import/ImportMap.php
==============================================================================
--- vtigercrm/branches/5.0.2/modules/Import/ImportMap.php (original)
+++ vtigercrm/branches/5.0.2/modules/Import/ImportMap.php Mon Oct 16 12:47:00 2006
@@ -99,6 +99,14 @@
 		$this->content = "".$this->db->getEmptyBlob()."";
                 $this->has_header = $has_header;
                 $this->deleted = 0;
+
+		//check whether this map name is already exist, if yes then overwrite the existing one, else create new
+	        $res = $this->db->query("select id from vtiger_import_maps where name='".trim($name)."'");
+		if($this->db->num_rows($res) > 0)
+		{
+			$this->id = $this->db->query_result($res,0,'id');
+		}
+
                 $returnid = $this->save();
 
 		$this->db->updateBlob($this->table_name,"content","name='".$name."' and module='".$module."'",$content);
@@ -180,7 +188,7 @@
 	 */
 	function getSavedMappingsList($module)
 	{
-		$query = "SELECT * FROM $this->table_name where module='".$module."'";
+		$query = "SELECT * FROM $this->table_name where module='".$module."' and deleted=0";
 		$result = $this->db->query($query,true," Error: ");
 		$map_lists = array();
 
@@ -197,7 +205,7 @@
 	 */
 	function getSavedMappingContent($mapid)
 	{
-		$query = "SELECT * FROM $this->table_name where id='".$mapid."'";
+		$query = "SELECT * FROM $this->table_name where id='".$mapid."' and deleted=0";
 		$result = $this->db->query($query,true," Error: ");
 		$mapping_arr = array();
 

Modified: vtigercrm/branches/5.0.2/modules/Import/ImportStep2.php
==============================================================================
--- vtigercrm/branches/5.0.2/modules/Import/ImportStep2.php (original)
+++ vtigercrm/branches/5.0.2/modules/Import/ImportStep2.php Mon Oct 16 12:47:00 2006
@@ -183,6 +183,8 @@
 	}
 }
 $map_list_combo .= '</select>';
+//This link is Delete link for the selected mapping
+$map_list_combo .= "&nbsp;&nbsp;&nbsp;<span id='delete_mapping' style='visibility:hidden;'><a href='javascript:; deleteMapping();'>Del</a></span>";
 $smarty->assign("SAVED_MAP_LISTS",$map_list_combo);
 
 





More information about the vtigercrm-commits mailing list