[Vtigercrm-commits] [vtiger-commits] r10870 - in /vtigercrm/branches/5.0.3/modules/Import: ImportAccount.php ImportContact.php ImportOpportunity.php ImportProduct.php UsersLastImport.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Fri May 11 14:35:28 EDT 2007


Author: richie
Date: Fri May 11 12:35:18 2007
New Revision: 10870

Log:
* Fixed the issue in mapping the entity relationship ie., Member Of in Accounts, Reports To in Contacts, Campaign Source in Potentials and Vendor Name in Products. instead of saving the related id name tried to store so that entries not saved, Fixed #3694

Modified:
    vtigercrm/branches/5.0.3/modules/Import/ImportAccount.php
    vtigercrm/branches/5.0.3/modules/Import/ImportContact.php
    vtigercrm/branches/5.0.3/modules/Import/ImportOpportunity.php
    vtigercrm/branches/5.0.3/modules/Import/ImportProduct.php
    vtigercrm/branches/5.0.3/modules/Import/UsersLastImport.php

Modified: vtigercrm/branches/5.0.3/modules/Import/ImportAccount.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Import/ImportAccount.php (original)
+++ vtigercrm/branches/5.0.3/modules/Import/ImportAccount.php Fri May 11 12:35:18 2007
@@ -44,6 +44,7 @@
 	
 	// This is the list of the functions to run when importing
 	var $special_functions =  array(
+						"map_member_of",
 						//"add_billing_address_streets"
 						//,"add_shipping_address_streets"
 						//,"fix_website"
@@ -176,6 +177,36 @@
 		$this->db->println($this->importable_fields);
 	}
 
+	/**     function used to map with existing Mamber Of(Account) if the account is map with an member of during import
+         */
+	function map_member_of()
+	{
+		global $adb;
+
+		$account_name = $this->column_fields['account_id'];
+		$adb->println("Entering map_member_of account_id=".$account_name);
+
+		if ((! isset($account_name) || $account_name == '') )
+		{
+			$adb->println("Exit map_member_of. Account Name(Member Of) not set for this entity.");
+			return; 
+		}
+
+		$account_name = trim(addslashes($account_name));
+
+		//Query to get the available Account which is not deleted
+		$query = "select accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid WHERE vtiger_account.accountname='{$account_name}' and vtiger_crmentity.deleted=0";
+
+		$account_id = $adb->query_result($adb->query($query),0,'accountid');
+
+		if($account_id == '' || !isset($account_id))
+			$account_id = 0;
+
+		$this->column_fields['account_id'] = $account_id;
+
+		$adb->println("Exit map_member_of. Fetched Account for '".$account_name."' and the account_id = $account_id");
+        }
+
 }
 
 

Modified: vtigercrm/branches/5.0.3/modules/Import/ImportContact.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Import/ImportContact.php (original)
+++ vtigercrm/branches/5.0.3/modules/Import/ImportContact.php Fri May 11 12:35:18 2007
@@ -42,7 +42,8 @@
        // This is the list of the functions to run when importing
         var $special_functions =  array(
 						//"get_names_from_full_name"
-						"add_create_account"
+						"add_create_account",
+						"map_reports_to",
 						//,"add_salutation"
 						//,"add_lead_source"
 						//,"add_birthdate"
@@ -230,7 +231,36 @@
 
         }
 
-	
+	/**     function used to map with existing Reports To(Contact) if the contact is map with reports to during import
+         */
+	function map_reports_to()
+	{
+		global $adb;
+
+		$contact_name = $this->column_fields['contact_id'];
+		$adb->println("Entering map_reports_to contact_id=".$contact_name);
+
+		if ((! isset($contact_name) || $contact_name == '') )
+		{
+			$adb->println("Exit map_reports_to. Contact Name(Reports To) not set for this entity.");
+			return; 
+		}
+
+		$contact_name = trim(addslashes($contact_name));
+
+		//Query to get the available Contact (Reports To) which is not deleted
+		$query = "select contactid from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid WHERE concat(vtiger_contactdetails.lastname,' ',vtiger_contactdetails.firstname) = '{$contact_name}' and vtiger_crmentity.deleted=0";
+
+		$contact_id = $adb->query_result($adb->query($query),0,'contactid');
+
+		if($contact_id == '' || !isset($contact_id))
+			$contact_id = 0;
+
+		$this->column_fields['contact_id'] = $contact_id;
+
+		$adb->println("Exit map_reports_to. Fetched Contact (Reports To) for '".$contact_name."' and the contactid = $contact_id");
+        }
+
 
 	// This is the list of vtiger_fields that can be imported
 	// some of these don't map directly to columns in the db

Modified: vtigercrm/branches/5.0.3/modules/Import/ImportOpportunity.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Import/ImportOpportunity.php (original)
+++ vtigercrm/branches/5.0.3/modules/Import/ImportOpportunity.php Fri May 11 12:35:18 2007
@@ -53,6 +53,7 @@
 	// This is the list of the functions to run when importing
 	var $special_functions =  array(
 						"add_create_account",
+						"map_campaign_source",
 						//"add_lead_source",
 						//"add_opportunity_type",
 				        	//"add_date_closed"
@@ -190,6 +191,37 @@
 		$adb->println("curr contact accid=".$this->column_fields["account_id"]);
 
         }	
+
+	/**     function used to map with existing Campaign Source if the potential is map with an campaign during import
+         */
+	function map_campaign_source()
+	{
+		global $adb;
+
+		$campaign_name = $this->column_fields['campaignid'];
+		$adb->println("Entering map_campaign_source campaignid=".$campaign_name);
+
+		if ((! isset($campaign_name) || $campaign_name == '') )
+		{
+			$adb->println("Exit map_campaign_source. Campaign Name not set for this entity.");
+			return; 
+		}
+
+		$campaign_name = trim(addslashes($campaign_name));
+
+		//Query to get the available campaign which is not deleted
+		$query = "select campaignid from vtiger_campaign inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_campaign.campaignid WHERE vtiger_campaign.campaignname='{$campaign_name}' and vtiger_crmentity.deleted=0";
+
+		$campaignid = $adb->query_result($adb->query($query),0,'campaignid');
+
+		if($campaignid == '' || !isset($campaignid))
+			$campaignid = 0;
+
+		$this->column_fields['campaignid'] = $campaignid;
+
+		$adb->println("Exit map_campaign_source. Fetched Campaign for '".$campaign_name."' and the campaignid = $campaignid");
+        }
+
 
 	/*
 	function fix_website()

Modified: vtigercrm/branches/5.0.3/modules/Import/ImportProduct.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Import/ImportProduct.php (original)
+++ vtigercrm/branches/5.0.3/modules/Import/ImportProduct.php Fri May 11 12:35:18 2007
@@ -40,7 +40,10 @@
 	 var $db;
 
 	// This is the list of the functions to run when importing
-	var $special_functions =  array("assign_user");
+	var $special_functions =  array(
+					"assign_user",
+					"map_vendor_name",
+				       );
 
 	var $importable_fields = Array();
 
@@ -95,5 +98,36 @@
 		$this->db->println($this->importable_fields);
 	}
 
+	/**     function used to map with existing Vendor if the product is map with an vendor during import
+         */
+	function map_vendor_name()
+	{
+		global $adb;
+
+		$vendor_name = $this->column_fields['vendor_id'];
+		$adb->println("Entering map_vendor_name vendor_id=".$vendor_name);
+
+		if ((! isset($vendor_name) || $vendor_name == '') )
+		{
+			$adb->println("Exit map_vendor_name. Vendor Name not set for this entity.");
+			return; 
+		}
+
+		$vendor_name = trim(addslashes($vendor_name));
+
+		//Query to get the available Vendor which is not deleted
+		$query = "select vendorid from vtiger_vendor inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_vendor.vendorid WHERE vtiger_vendor.vendorname='{$vendor_name}' and vtiger_crmentity.deleted=0";
+
+		$vendor_id = $adb->query_result($adb->query($query),0,'vendorid');
+
+		if($vendor_id == '' || !isset($vendor_id))
+			$vendor_id = 0;
+
+		$this->column_fields['vendor_id'] = $vendor_id;
+
+		$adb->println("Exit map_vendor_name. Fetched Vendor for '".$vendor_name."' and the vendorid = $vendor_id");
+        }
+
+
 }
 ?>

Modified: vtigercrm/branches/5.0.3/modules/Import/UsersLastImport.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Import/UsersLastImport.php (original)
+++ vtigercrm/branches/5.0.3/modules/Import/UsersLastImport.php Fri May 11 12:35:18 2007
@@ -133,7 +133,7 @@
 		
 			$query = "SELECT distinct
                                 vtiger_account.accountid vtiger_account_id,
-                                vtiger_account.accountname vtiger_account_name,
+                                vtiger_account.accountname accountname,
                                 vtiger_users.user_name user_name,
 			vtiger_crmentity.crmid, smownerid,
 			vtiger_potential.*
@@ -162,15 +162,36 @@
 				left join vtiger_users_last_import on vtiger_users_last_import.bean_id=vtiger_crmentity.crmid			       	
 				left join vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id
 				WHERE 
-			vtiger_users_last_import.assigned_user_id=
+				vtiger_users_last_import.assigned_user_id=
 					'{$current_user->id}'
 				AND vtiger_users_last_import.bean_type='Leads'
 				AND vtiger_users_last_import.deleted=0
 				AND vtiger_crmentity.deleted=0
 				AND vtiger_users.status='Active'";
 		}
-
-		
+		else if($this->bean_type == 'Products')
+		{
+			$query = "SELECT vtiger_crmentity.crmid, vtiger_products.*, vtiger_productcf.*
+				FROM vtiger_products
+				INNER JOIN vtiger_crmentity
+					ON vtiger_crmentity.crmid = vtiger_products.productid
+				INNER JOIN vtiger_productcf
+					ON vtiger_products.productid = vtiger_productcf.productid
+				LEFT JOIN vtiger_vendor
+					ON vtiger_vendor.vendorid = vtiger_products.vendor_id
+				LEFT JOIN vtiger_users_last_import 
+					ON vtiger_users_last_import.bean_id=vtiger_crmentity.crmid
+				LEFT JOIN vtiger_users
+					ON vtiger_users.id = vtiger_products.handler
+				WHERE 
+				vtiger_users_last_import.assigned_user_id= '{$current_user->id}'
+				AND vtiger_users_last_import.bean_type='Products'
+				AND vtiger_users_last_import.deleted=0
+				AND vtiger_crmentity.deleted = 0 
+				AND vtiger_users.status='Active'";
+
+		}
+
 		return $query;
 
 	}





More information about the vtigercrm-commits mailing list