[Vtigercrm-commits] [vtiger-commits] r4572 - in /vtigercrm/trunk: include/utils/ modules/Emails/ modules/HelpDesk/ modules/Import/ modules/Migration/

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Tue Mar 28 02:44:58 EST 2006


Author: saraj
Date: Tue Mar 28 00:44:43 2006
New Revision: 4572

Log:
* Modified for junk code removal

Modified:
    vtigercrm/trunk/include/utils/export.php
    vtigercrm/trunk/modules/Emails/Email.php
    vtigercrm/trunk/modules/HelpDesk/HelpDesk.php
    vtigercrm/trunk/modules/Import/ImportAccount.php
    vtigercrm/trunk/modules/Import/ImportContact.php
    vtigercrm/trunk/modules/Import/ImportMap.php
    vtigercrm/trunk/modules/Import/ImportOpportunity.php
    vtigercrm/trunk/modules/Import/ImportSteplast.php
    vtigercrm/trunk/modules/Import/UsersLastImport.php
    vtigercrm/trunk/modules/Migration/Migration.php

Modified: vtigercrm/trunk/include/utils/export.php
==============================================================================
--- vtigercrm/trunk/include/utils/export.php (original)
+++ vtigercrm/trunk/include/utils/export.php Tue Mar 28 00:44:43 2006
@@ -41,92 +41,21 @@
         $result = $current_user->retrieve($_SESSION['authenticated_user_id']);
         if($result == null)
         {
-                session_destroy();
-            header("Location: index.php?action=Login&module=Users");
+		session_destroy();
+		header("Location: index.php?action=Login&module=Users");
         }
 
 }
 if ($allow_exports=='none' || ( $allow_exports=='admin' && ! is_admin($current_user) ) )
 {
-die("you can't export!");
+	die("you can't export!");
 }
 
-
-
-$contact_fields = array(
-"id"=>"Contact ID"
-,"lead_source"=>"Lead Source"
-,"date_entered"=>"Date Entered"
-,"date_modified"=>"Date Modified"
-,"first_name"=>"First Name"
-,"last_name"=>"Last Name"
-,"salutation"=>"Salutation"
-,"birthdate"=>"Lead Source"
-,"do_not_call"=>"Do Not Call"
-,"email_opt_out"=>"Email Opt Out"
-,"title"=>"Title"
-,"department"=>"Department"
-,"birthdate"=>"Birthdate"
-,"do_not_call"=>"Do Not Call"
-,"phone_home"=>"Phone (Home)"
-,"phone_mobile"=>"Phone (Mobile)"
-,"phone_work"=>"Phone (Work)"
-,"phone_other"=>"Phone (Other)"
-,"phone_fax"=>"Fax"
-,"email1"=>"Email"
-,"email2"=>"Email (Other)"
-,"yahoo_id"=>"Yahoo! ID"
-,"assistant"=>"Assistant"
-,"assistant_phone"=>"Assistant Phone"
-,"primary_address_street"=>"Primary Address Street"
-,"primary_address_city"=>"Primary Address City"
-,"primary_address_state"=>"Primary Address State"
-,"primary_address_postalcode"=>"Primary Address Postalcode"
-,"primary_address_country"=>"Primary Address Country"
-,"alt_address_street"=>"Other Address Street"
-,"alt_address_city"=>"Other Address City"
-,"alt_address_state"=>"Other Address State"
-,"alt_address_postalcode"=>"Other Address Postalcode"
-,"alt_address_country"=>"Other Address Country"
-,"description"=>"Description"
-);
-
-/*$account_fields = array(
-"id"=>"Account ID",
-"name"=>"Account Name",
-"website"=>"Website",
-"industry"=>"Industry",
-"account_type"=>"Type",
-"ticker_symbol"=>"Ticker Symbol",
-"employees"=>"Employees",
-"ownership"=>"Ownership",
-"phone_office"=>"Phone",
-"phone_fax"=>"Fax",
-"phone_alternate"=>"Other Phone",
-"email1"=>"Email",
-"email2"=>"Other Email",
-"rating"=>"Rating",
-"sic_code"=>"SIC Code",
-"annual_revenue"=>"Annual Revenue",
-"billing_address_street"=>"Billing Address Street",
-"billing_address_city"=>"Billing Address City",
-"billing_address_state"=>"Billing Address State",
-"billing_address_postalcode"=>"Billing Address Postalcode",
-"billing_address_country"=>"Billing Address Country",
-"shipping_address_street"=>"Shipping Address Street",
-"shipping_address_city"=>"Shipping Address City",
-"shipping_address_state"=>"Shipping Address State",
-"shipping_address_postalcode"=>"Shipping Address Postalcode",
-"shipping_address_country"=>"Shipping Address Country",
-"description"=>"Description"
-);
-
-*/
-
 //Function added to convert line breaks to space in description during export 
-function br2nl_vt($str) {
-   $str = preg_replace("/(\r\n)/", " ", $str);
-   return $str;
+function br2nl_vt($str) 
+{
+	$str = preg_replace("/(\r\n)/", " ", $str);
+	return $str;
 }
 
 function export_all($type)
@@ -140,7 +69,7 @@
 	if ($type == "Contacts")
 	{
 		$focus = new Contact;
-			}
+	}
 	else if ($type == "Accounts")
 	{
 		$focus = new Account;
@@ -168,7 +97,6 @@
 	{
 		$focus = new Lead;
 	}
-
 	else if ($type == "Emails")
 	{
 		$focus = new Email;
@@ -190,22 +118,10 @@
 		$where = $_SESSION['export_where'];
 	}
 
-/*
-	if ( isset( $_SESSION['order_by'] ))
-	{
-		$order_by = $_SESSION['order_by'];
-	} 
-	else
-	{
-		$order_by = "";
-	}
-	*/
 	$order_by = "";
 
-             $query = $focus->create_export_query($order_by,$where);
+	$query = $focus->create_export_query($order_by,$where);
 
-	//print $query;
-//exit;
 
 	$result = $adb->query($query,true,"Error exporting $type: "."<BR>$query");
 
@@ -222,7 +138,6 @@
 	{
 		$new_arr = array();
 
-		//foreach (array_values($val) as $value)
 		foreach ($val as $key => $value)
 		{
 			if($key=="description")
@@ -248,7 +163,7 @@
 header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
 header( "Cache-Control: post-check=0, pre-check=0", false );
 header("Content-Length: ".strlen($content));
-	print $content;
+print $content;
+
 exit;
 ?>
-        

Modified: vtigercrm/trunk/modules/Emails/Email.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/Email.php (original)
+++ vtigercrm/trunk/modules/Emails/Email.php Tue Mar 28 00:44:43 2006
@@ -45,7 +45,6 @@
 	var $date_start;
 	var $time_start;
   	var $module_id="emailid";
-	var $default_email_name_values = array('Assemble catalogs', 'Make travel arrangements', 'Send a letter', 'Send contract', 'Send fax', 'Send a follow-up letter', 'Send literature', 'Send proposal', 'Send quote');
 
 	var $table_name = "activity";
 	var $tab_name = Array('crmentity','activity','seactivityrel','cntactivityrel');
@@ -53,24 +52,20 @@
 
 	// This is the list of fields that are in the lists.
         var $list_fields = Array(
-       'Subject'=>Array('activity'=>'subject'),
-       'Related to'=>Array('seactivityrel'=>'activityid'),
-       'Date Sent'=>Array('activity'=>'date_start'),
-       'Assigned To'=>Array('crmentity','smownerid')
-       );
+				       'Subject'=>Array('activity'=>'subject'),
+				       'Related to'=>Array('seactivityrel'=>'activityid'),
+				       'Date Sent'=>Array('activity'=>'date_start'),
+				       'Assigned To'=>Array('crmentity','smownerid')
+			        );
 
        var $list_fields_name = Array(
-       'Subject'=>'subject',
-       'Related to'=>'activityid',
-       'Date Sent'=>'date_start',
-       'Assigned To'=>'assigned_user_id');
+				       'Subject'=>'subject',
+				       'Related to'=>'activityid',
+				       'Date Sent'=>'date_start',
+				       'Assigned To'=>'assigned_user_id'
+				    );
 
        var $list_link_field= 'subject';
-
-
-	var $rel_users_table = "salesmanactivityrel";
-	var $rel_contacts_table = "cntactivityrel";
-	var $rel_serel_table = "seactivityrel";
 
 	var $object_name = "Email";
 
@@ -82,9 +77,6 @@
 	var $default_order_by = 'subject';
 	var $default_sort_order = 'ASC';
 
-	function create_tables () {
-
-        }
 	function Email() {
 		$this->log = LoggerManager::getLogger('email');
 		$this->db = new PearDatabase();
@@ -106,12 +98,7 @@
 
 		$focus = new Contact();
 
-		$button .= '<input title="Bulk Mail" accessyKey="F" class="button" onclick="this.form.action.value=\'sendmail\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Emails\';this.form.return_module.value=\'Emails\';" type="submit" name="button" value="'.$mod_strings['LBL_BULK_MAILS'].'">&nbsp;';
-
-		if(isPermitted("Contacts",3,"") == 'yes')
-		{
-			$button .= '<input title="Change" accessKey="" tabindex="2" type="button" class="button" value="'.$app_strings['LBL_SELECT_CONTACT_BUTTON_LABEL'].'" name="Button" LANGUAGE=javascript onclick=\'return window.open("index.php?module=Contacts&return_module=Emails&action=Popup&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
-		}
+		$button = '';
 		$returnset = '&return_module=Emails&return_action=DetailView&return_id='.$id;
 
 		$query = 'select contactdetails.accountid, contactdetails.contactid, contactdetails.firstname,contactdetails.lastname, contactdetails.department, contactdetails.title, contactdetails.email, contactdetails.phone, contactdetails.emailoptout, crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime from contactdetails inner join cntactivityrel on cntactivityrel.contactid=contactdetails.contactid inner join crmentity on crmentity.crmid = contactdetails.contactid left join contactgrouprelation on contactdetails.contactid=contactgrouprelation.contactid left join groups on groups.groupname=contactgrouprelation.groupname where cntactivityrel.activityid='.PearDatabase::quote($id).' and crmentity.deleted=0';
@@ -136,7 +123,7 @@
 		$result=$adb->query($query);   
 
 		$noofrows = $adb->num_rows($result);
-		$header[] = $app_strings['LBL_LIST_NAME'];
+		$header [] = $app_strings['LBL_LIST_NAME'];
 
 		$header []= $app_strings['LBL_LIST_USER_NAME'];
 
@@ -172,7 +159,7 @@
 
 			//Adding Security Check for User
 
-			$entries_list[] = entries;
+			$entries_list[] = $entries;
 		}
 
 		if($entries_list != '')
@@ -198,7 +185,6 @@
 			left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid
 			inner join users on crm2.smcreatorid= users.id
 		where crmentity.crmid=".PearDatabase::quote($id);
-		//where crmentity.crmid=".$id;
 		$query .= ' union all ';
 		$query .= "select attachments.description title ,'Attachments'  ActivityType,
 			attachments.name filename, attachments.type FileType,crm2.modifiedtime lastmodified,
@@ -225,32 +211,33 @@
                 return $query;
         }
         
-     /**
-     * Used to releate email and contacts -- Outlook Plugin
-     */  
-     function set_emails_contact_invitee_relationship($email_id, $contact_id)
-     {
-          $query = "insert into $this->rel_contacts_table (contactid,activityid) values('$contact_id','$email_id')";
-          $this->db->query($query,true,"Error setting email to contact relationship: "."<BR>$query");
-     }
+	/**
+	* Used to releate email and contacts -- Outlook Plugin
+	*/  
+	function set_emails_contact_invitee_relationship($email_id, $contact_id)
+	{
+		$query = "insert into $this->rel_contacts_table (contactid,activityid) values('$contact_id','$email_id')";
+		$this->db->query($query,true,"Error setting email to contact relationship: "."<BR>$query");
+	}
      
-     /**
-     * Used to releate email and salesentity -- Outlook Plugin
-     */
-     function set_emails_se_invitee_relationship($email_id, $contact_id)
-     {
-          $query = "insert into $this->rel_serel_table (crmid,activityid) values('$contact_id','$email_id')";
-          $this->db->query($query,true,"Error setting email to contact relationship: "."<BR>$query");
-     }
+	/**
+	* Used to releate email and salesentity -- Outlook Plugin
+	*/
+	function set_emails_se_invitee_relationship($email_id, $contact_id)
+	{
+		$query = "insert into $this->rel_serel_table (crmid,activityid) values('$contact_id','$email_id')";
+		$this->db->query($query,true,"Error setting email to contact relationship: "."<BR>$query");
+	}
      
-     /**
-     * Used to releate email and Users -- Outlook Plugin
-     */    
-     function set_emails_user_invitee_relationship($email_id, $user_id)
-     {
-          $query = "insert into $this->rel_users_table (smid,activityid) values ('$user_id', '$email_id')";
-          $this->db->query($query,true,"Error setting email to user relationship: "."<BR>$query");
-     }        
+	/**
+	* Used to releate email and Users -- Outlook Plugin
+	*/    
+	function set_emails_user_invitee_relationship($email_id, $user_id)
+	{
+		$query = "insert into $this->rel_users_table (smid,activityid) values ('$user_id', '$email_id')";
+		$this->db->query($query,true,"Error setting email to user relationship: "."<BR>$query");
+	}        
+
 
 }
 ?>

Modified: vtigercrm/trunk/modules/HelpDesk/HelpDesk.php
==============================================================================
Binary files - no diff available.

Modified: vtigercrm/trunk/modules/Import/ImportAccount.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportAccount.php (original)
+++ vtigercrm/trunk/modules/Import/ImportAccount.php Tue Mar 28 00:44:43 2006
@@ -24,8 +24,6 @@
 require_once('data/SugarBean.php');
 require_once('modules/Contacts/Contact.php');
 require_once('modules/Potentials/Opportunity.php');
-//require_once('modules/Cases/Case.php');
-//require_once('modules/Calls/Call.php');
 require_once('modules/Notes/Note.php');
 require_once('modules/Emails/Email.php');
 require_once('modules/Accounts/Account.php');
@@ -35,15 +33,10 @@
 class ImportAccount extends Account {
 	 var $db;
 
-// Get _dom arrays from Database
-//$comboFieldNames = Array('accounttype'=>'account_type_dom'
-//                      ,'industry'=>'industry_dom');
-//$comboFieldArray = getComboArray($comboFieldNames);
-
-
-	// these are fields that may be set on import
-	// but are to be processed and incorporated
-	// into fields of the parent class
+	// Get _dom arrays from Database
+	//$comboFieldNames = Array('accounttype'=>'account_type_dom'
+	//                      ,'industry'=>'industry_dom');
+	//$comboFieldArray = getComboArray($comboFieldNames);
 
 
 	// This is the list of fields that are required.
@@ -51,10 +44,10 @@
 	
 	// This is the list of the functions to run when importing
 	var $special_functions =  array(
-	//"add_billing_address_streets"
-	//,"add_shipping_address_streets"
-	//,"fix_website"
-	 );
+						//"add_billing_address_streets"
+						//,"add_shipping_address_streets"
+						//,"fix_website"
+				       );
 
 
 	function fix_website()

Modified: vtigercrm/trunk/modules/Import/ImportContact.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportContact.php (original)
+++ vtigercrm/trunk/modules/Import/ImportContact.php Tue Mar 28 00:44:43 2006
@@ -18,19 +18,6 @@
  ********************************************************************************/
 include_once('config.php');
 require_once('include/logging.php');
-/*
-require_once('database/DatabaseConnection.php');
-require_once('data/SugarBean.php');
-require_once('include/utils/utils.php');
-require_once('modules/Potentials/Opportunity.php');
-require_once('modules/Cases/Case.php');
-require_once('modules/Tasks/Task.php');
-require_once('modules/Notes/Note.php');
-require_once('modules/Meetings/Meeting.php');
-require_once('modules/Calls/Call.php');
-require_once('modules/Emails/Email.php');
-require_once('modules/Accounts/Account.php');
-*/
 require_once('modules/Contacts/Contact.php');
 require_once('modules/Import/UsersLastImport.php');
 require_once('include/database/PearDatabase.php');
@@ -54,16 +41,16 @@
 
        // This is the list of the functions to run when importing
         var $special_functions =  array(
-		//"get_names_from_full_name"
-		"add_create_account"
-		//,"add_salutation"
-		//,"add_lead_source"
-		//,"add_birthdate"
-		//,"add_do_not_call"
-		//,"add_email_opt_out"
-		//,"add_primary_address_streets"
-		//,"add_alt_address_streets"
-		);
+						//"get_names_from_full_name"
+						"add_create_account"
+						//,"add_salutation"
+						//,"add_lead_source"
+						//,"add_birthdate"
+						//,"add_do_not_call"
+						//,"add_email_opt_out"
+						//,"add_primary_address_streets"
+						//,"add_alt_address_streets"
+					);
 
 	function add_salutation()
 	{
@@ -83,7 +70,6 @@
 		}
 
 	}
-
 
 	function add_birthdate()
 	{
@@ -161,98 +147,6 @@
                 $this->last_name = join(' ',$name_arr);
 
         }
-
-       /* function add_create_account()
-        {
-		global $adb;
-		// global is defined in UsersLastImport.php
-		global $imported_ids;
-                global $current_user;
-
-		if ( (! isset($this->account_name) || $this->account_name == '') &&
-			(! isset($this->account_id) || $this->account_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->account_id) && $this->account_id != '')
-		{
-                	$query = "select * from {$focus->table_name} WHERE id='{$this->account_id}'";
-		}	
-		// else user is defining the account name to be associated with this contact..
-		else 
-		{
-                	$query = "select * from {$focus->table_name} WHERE name='{$this->account_name}'";
-		}
-
-                $this->log->info($query);
-
-                $result = $adb->query($query)
-                       or die("Error selecting sugarbean: ".mysql_error());
-
-                $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='". $row['id']."'";
-
-                                $this->log->info($query2);
-
-                                $result2 = $adb->query($query2)
-                                        or die("Error deleting existing sugarbean: ".mysql_error());
-
-                        }
-			// else just use this id to link the contact to the account
-                        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;
-                        $focus->assigned_user_id = $current_user->id;
-                        $focus->modified_user_id = $current_user->id;
-
-			if ( isset($this->account_id)  &&
-                                $this->account_id != '')
-                        {
-				$focus->new_with_id = true;
-                                $focus->id = $this->account_id;
-                        }
-
-                        $focus->save();
-			// avoid duplicate mappings:
-			if (! isset( $imported_ids[$this->account_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[$this->account_id] = 1;
-			}
-                }
-
-		// now just link the account
-                $this->account_id = $focus->id;
-
-        }*/
 
 	function add_create_account()
         {
@@ -277,29 +171,13 @@
 		$query = '';
 
 		// if user is defining the account id to be associated with this contact..
-		/*if ( isset($this->account_id) && $this->account_id != '')
-		{
-                	$query = "select * from {$focus->table_name} WHERE id='{$this->account_id}'";
-		}	
-		// else user is defining the account name to be associated with this contact..
-		else 
-		{
-                	$query = "select * from {$focus->table_name} WHERE name='{$this->account_name}'";
-		}*/
-		
-		//$query = "select * from {$focus->table_name} WHERE accountname='{$acc_name}' left join crmentity on crmentity.crmid =account.accountid";
 
 		//Modified to remove the spaces at first and last in account name -- after 4.2 patch 2
-		$adb->println("Account name in csv file related to contact - to be search =>'".$acc_name."'");
 		$acc_name = trim(addslashes($acc_name));
-		$adb->println("Account name going to search in database after addslashes, trim =>'".$acc_name."'");
 
 		$query = "select crmentity.deleted, account.* from account,crmentity WHERE accountname='{$acc_name}' and crmentity.crmid =account.accountid";
 
-                $this->log->info($query);
-
-                $result = $adb->query($query)
-                       or die("Error selecting sugarbean: ".mysql_error());
+                $result = $adb->query($query)	or die("Error selecting sugarbean: ".mysql_error());
 
                 $row = $this->db->fetchByAssoc($result, -1, false);
 
@@ -317,8 +195,7 @@
 
                                 $this->log->info($query2);
 
-                                $result2 = $adb->query($query2)
-                                        or die("Error deleting existing sugarbean: ".mysql_error());
+                                $result2 = $adb->query($query2)	or die("Error deleting existing sugarbean: ".mysql_error());
 
                         }
 			// else just use this id to link the contact to the account
@@ -343,14 +220,6 @@
 
 			$adb->println("New Account created id=".$focus->id);
 
-			/*if ( isset($this->account_id)  &&
-                                $this->account_id != '')
-                        {
-				$focus->new_with_id = true;
-                                $focus->id = $this->account_id;
-                        }
-
-                        $focus->save();*/
 			// avoid duplicate mappings:
 			if (! isset( $imported_ids[$acc_id]) )
 			{
@@ -377,7 +246,7 @@
 	// This is the list of fields that can be imported
 	// some of these don't map directly to columns in the db
 
-//we need to add two or more arrays as the columns are distributed across the tables now
+	//we need to add two or more arrays as the columns are distributed across the tables now
 	/*var $importable_fields =  array(
 		"contactid"=>1,
 		"firstname"=>1,

Modified: vtigercrm/trunk/modules/Import/ImportMap.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportMap.php (original)
+++ vtigercrm/trunk/modules/Import/ImportMap.php Tue Mar 28 00:44:43 2006
@@ -72,69 +72,25 @@
 		return "Object:ImportMap id=$this->id name=$this->name module=$this->module content=$this->content";
 	}
 
-	function create_tables () 
-	{
-		/*
-		$query = 'CREATE TABLE '.$this->table_name.' ( ';
-		$query .='id char(36) NOT NULL';
-		$query .=', name char(36) NOT NULL';
-		$query .=', module char(36) NOT NULL';
-		$query .=', content blob';
-                $query .=', has_header bool NOT NULL default 1';
-                $query .=', deleted bool NOT NULL default 0';
-                $query .=', date_entered datetime NOT NULL';
-                $query .=', date_modified datetime NOT NULL';
-                $query .=', assigned_user_id char(36)';
-                $query .=', is_published char(3) NOT NULL default \'no\'';
-		$query .=', PRIMARY KEY ( ID ) )';
-
-		
-		
-		
-		$this->db->query($query,true,"Error creating table: ".$this->table_name. ":" );
-
-
-		//TODO Clint 4/27 - add exception handling logic here if the table can't be created.
-	
-		// Create the indexes
-                $this->create_index("create index idx_cont_owner_id_module_and_name on ".$this->table_name." (assigned_user_id, module, name, deleted)");*/
-	}
-
-	function drop_tables () 
-	{
-		/*
-		$query = 'DROP TABLE IF EXISTS '.$this->table_name;
-
-		
-			
-		$this->db->query($query);
-
-		//TODO Clint 4/27 - add exception handling logic here if the table can't be dropped.
-		*/
-
-	}
-	
         function save_map( $owner_id, $name, $module, $has_header,$content )
         {
-		$query_arr = array(
-			'assigned_user_id'=>$owner_id,'name'=>$name);
+		$query_arr = array('assigned_user_id'=>$owner_id,'name'=>$name);
 
 		$this->retrieve_by_string_fields($query_arr, false);
 
                 $result = 1;
                 $this->assigned_user_id = $owner_id;
-		//$this->new_with_id=$this->db->getUniqueID("import_maps");
+
                 $this->name = $name;
                 $this->module = $module;
-                //$this->content = $content;
+
 		$this->content = "".$this->db->getEmptyBlob()."";
                 $this->has_header = $has_header;
                 $this->deleted = 0;
                 $returnid = $this->save();
-		//$this->db->println("save_map=".$this->new_with_id);
+
 		$this->db->updateBlob($this->table_name,"content","name='".$name."' and module='".$module."'",$content);
-		//$this->db->updateBlob($this->table_name,"content","id=".$this->new_with_id,$content);
-		
+
                 return $result;
         }
 

Modified: vtigercrm/trunk/modules/Import/ImportOpportunity.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportOpportunity.php (original)
+++ vtigercrm/trunk/modules/Import/ImportOpportunity.php Tue Mar 28 00:44:43 2006
@@ -24,8 +24,6 @@
 require_once('data/SugarBean.php');
 require_once('modules/Contacts/Contact.php');
 require_once('modules/Potentials/Opportunity.php');
-//require_once('modules/Cases/Case.php');
-//require_once('modules/Calls/Call.php');
 require_once('modules/Notes/Note.php');
 require_once('modules/Emails/Email.php');
 require_once('modules/Accounts/Account.php');
@@ -41,28 +39,25 @@
 class ImportOpportunity extends Potential {
 	 var $db;
 
-	// these are fields that may be set on import
-	// but are to be processed and incorporated
-	// into fields of the parent class
-
-
 	// This is the list of fields that are required.
-	/*var $required_fields =  array(
-				"potentialname"=>1,
-				"account_id"=>1,
-				"closingdate"=>1,
-				"sales_stage"=>1,
-				"amount"=>1
-);*/
-	
+	/*
+	var $required_fields =  array(
+					"potentialname"=>1,
+					"account_id"=>1,
+					"closingdate"=>1,
+					"sales_stage"=>1,
+					"amount"=>1
+				     );
+	*/
+
 	// This is the list of the functions to run when importing
 	var $special_functions =  array(
-		"add_create_account",
-		//"add_lead_source",
-		//"add_opportunity_type",
-        	//"add_date_closed"
-        	//"add_sales_stage"
-	 );
+						"add_create_account",
+						//"add_lead_source",
+						//"add_opportunity_type",
+				        	//"add_date_closed"
+				        	//"add_sales_stage"
+				       );
 
         function add_lead_source()
         {
@@ -116,100 +111,7 @@
 	//exactly the same function from ImportAccount.php
 	// lets put this in one place.. 
 
-        /*function add_create_account()
-        {
-		global $adb;
-                // global is defined in UsersLastImport.php
-                global $imported_ids;
-                global $current_user;
-
-                if ( (! isset($this->account_name) || $this->account_name == '') &&
-                        (! isset($this->account_id) || $this->account_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->account_id) && $this->account_id != '')
-                {
-                        $query = "select * from {$focus->table_name} WHERE id='{$this->account_id}'"
-;
-                }
-                // else user is defining the account name to be associated with this contact..
-                else
-                {
-                        $query = "select * from {$focus->table_name} WHERE name='{$this->account_name}'";
-                }
-
-                $this->log->info($query);
-
-                $result = $adb->query($query)
-                       or die("Error selecting sugarbean: ".mysql_error());
-
-                $row = $this->db->fetchByAssoc($result, -1, false);
-                // if 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='". $row['id']."'";
-
-                                $this->log->info($query2);
-
-                                $result2 = $adb->query($query2)
-                                        or die("Error deleting existing sugarbean: ".mysql_error());
-
-                        }
-                        // else just use this id to link the contact to the account
-                        else
-                        {
-                                $focus->id = $row['id'];
-                        }
-                }
-
-                // we didnt find the account, so create it
-                if (! isset($focus->id) || $focus->id == '')
-                {
-                        $focus->name = $this->account_name;
-                        $focus->assigned_user_id = $current_user->id;
-                        $focus->modified_user_id = $current_user->id;
-
-                        if ( isset($this->account_id)  &&
-                                $this->account_id != '')
-                        {
-                                $focus->new_with_id = true;
-                                $focus->id = $this->account_id;
-                        }
-
-                        $focus->save();
-                        // avoid duplicate mappings:
-                        if (! isset( $imported_ids[$this->account_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[$this->account_id] = 1;
-                        }
-                }
-
-                $this->account_id = $focus->id;
-
-	}
-	*/
-
-
-function add_create_account()
+	function add_create_account()
         {
 		global $adb;
 		// global is defined in UsersLastImport.php
@@ -232,24 +134,12 @@
 		$query = '';
 
 		// if user is defining the account id to be associated with this contact..
-		/*if ( isset($this->account_id) && $this->account_id != '')
-		{
-                	$query = "select * from {$focus->table_name} WHERE id='{$this->account_id}'";
-		}	
-		// else user is defining the account name to be associated with this contact..
-		else 
-		{
-                	$query = "select * from {$focus->table_name} WHERE name='{$this->account_name}'";
-		}*/
-		
-		//$query = "select * from {$focus->table_name} WHERE accountname='{$acc_name}' left join crmentity on crmentity.crmid =account.accountid";
-		$acc_name = addslashes($acc_name);
+		$acc_name = trim(addslashes($acc_name));
 		$query = "select crmentity.deleted, account.* from account,crmentity WHERE accountname='{$acc_name}' and crmentity.crmid =account.accountid";
 
                 $this->log->info($query);
 
-                $result = $adb->query($query)
-                       or die("Error selecting sugarbean: ".mysql_error());
+                $result = $adb->query($query)	or die("Error selecting sugarbean: ".mysql_error());
 
                 $row = $this->db->fetchByAssoc($result, -1, false);
 
@@ -267,8 +157,7 @@
 
                                 $this->log->info($query2);
 
-                                $result2 = $adb->query($query2)
-                                        or die("Error deleting existing sugarbean: ".mysql_error());
+                                $result2 = $adb->query($query2)	or die("Error deleting existing sugarbean: ".mysql_error());
 
                         }
 			// else just use this id to link the contact to the account
@@ -287,20 +176,11 @@
                         $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);
 
-			/*if ( isset($this->account_id)  &&
-                                $this->account_id != '')
-                        {
-				$focus->new_with_id = true;
-                                $focus->id = $this->account_id;
-                        }
-
-                        $focus->save();*/
 			// avoid duplicate mappings:
 			if (! isset( $imported_ids[$acc_id]) )
 			{
@@ -321,7 +201,6 @@
 		$adb->println("curr contact accid=".$this->column_fields["account_id"]);
 
         }	
-
 
 
 	function fix_website()

Modified: vtigercrm/trunk/modules/Import/ImportSteplast.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportSteplast.php (original)
+++ vtigercrm/trunk/modules/Import/ImportSteplast.php Tue Mar 28 00:44:43 2006
@@ -61,23 +61,22 @@
 
 if ( isset($_REQUEST['message']))
 {
-?>
-
-<br>
-
-<table width="100%" border=1>
-<tr>
-<td>
-<br>
-<?php 
-
-echo $_REQUEST['message']; ?>
-<br>
-<br>
-</td>
-</tr>
-</table>
-<?php 
+	?>
+	<br>
+
+	<table width="100%" border=1>
+	   <tr>
+		<td>
+		   <br>
+		   <?php 
+			echo $_REQUEST['message']; 
+		   ?>
+		   <br>
+		   <br>
+		</td>
+	   </tr>
+	</table>
+	<?php 
 }
 ?>
 <br>
@@ -89,29 +88,31 @@
 <input type="hidden" name="return_id" value="<?php echo $_REQUEST['return_id']; ?>">
 <input type="hidden" name="return_action" value="<?php echo $_REQUEST['return_action']; ?>">
 
-<table width="100%" cellpadding="2" cellspacing="0" border="0"><tr>
-        <td align="right"><input title="<?php echo $mod_strings['LBL_UNDO_LAST_IMPORT']; ?>" accessKey="" class="button" type="submit" name="button" value="  <?php echo $mod_strings['LBL_UNDO_LAST_IMPORT'] ?>  "></td>
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+   <tr>
+	<td align="right"><input title="<?php echo $mod_strings['LBL_UNDO_LAST_IMPORT']; ?>" accessKey="" class="button" type="submit" name="button" value="  <?php echo $mod_strings['LBL_UNDO_LAST_IMPORT'] ?>  "></td>
         <td></td>
-</tr>
+   </tr>
 </table>
 </form>
+
 <table width="100%" cellpadding="2" cellspacing="0" border="0">
- <form enctype="multipart/form-data" name="Import" method="POST" action="index.php">
-                        <input type="hidden" name="module" value="<?php echo $_REQUEST['modulename']; ?>">
-                        <input type="hidden" name="action" value="Import">
-                        <input type="hidden" name="step" value="1">
-                        <input type="hidden" name="return_id" value="<?php echo $_REQUEST['return_id']; ?>">
-                        <input type="hidden" name="return_module" value="<?php echo $_REQUEST['return_module']; ?>">
-                        <input type="hidden" name="return_action" value="<?php echo (($_REQUEST['return_action'] != '')?$_REQUEST['return_action']:'index'); ?>">
-        <tr>
-        <td align="right">
-<input title="<?php echo $mod_strings['LBL_IMPORT_MORE'] ?>" accessKey="" class="button" type="submit" name="button" value="  <?php echo $mod_strings['LBL_IMPORT_MORE'] ?>  "  onclick="return true;">
-<input title="<?php echo $mod_strings['LBL_FINISHED'] ?>" accessKey="" class="button" type="submit" name="button" value="  <?php echo $mod_strings['LBL_FINISHED'] ?>  "  onclick="this.form.action.value=this.form.return_action.value;this.form.return_module.value=this.form.return_module.value;return true;"></td>
+	<form enctype="multipart/form-data" name="Import" method="POST" action="index.php">
+		<input type="hidden" name="module" value="<?php echo $_REQUEST['modulename']; ?>">
+                <input type="hidden" name="action" value="Import">
+                <input type="hidden" name="step" value="1">
+                <input type="hidden" name="return_id" value="<?php echo $_REQUEST['return_id']; ?>">
+                <input type="hidden" name="return_module" value="<?php echo $_REQUEST['return_module']; ?>">
+                <input type="hidden" name="return_action" value="<?php echo (($_REQUEST['return_action'] != '')?$_REQUEST['return_action']:'index'); ?>">
+   <tr>
+	<td align="right">
+		<input title="<?php echo $mod_strings['LBL_IMPORT_MORE'] ?>" accessKey="" class="button" type="submit" name="button" value="  <?php echo $mod_strings['LBL_IMPORT_MORE'] ?>  "  onclick="return true;">
+		<input title="<?php echo $mod_strings['LBL_FINISHED'] ?>" accessKey="" class="button" type="submit" name="button" value="  <?php echo $mod_strings['LBL_FINISHED'] ?>  "  onclick="this.form.action.value=this.form.return_action.value;this.form.return_module.value=this.form.return_module.value;return true;">
+	</td>
         <td></td>
-</tr>
+   </tr>
 </table>
-
-        </form>
+</form>
 
 <?php
 
@@ -123,18 +124,13 @@
 $implict_account = false;
 $newForm = null;
 
+//To display the list of Contacts imported
 $seedUsersLastImport = new UsersLastImport();
 $seedUsersLastImport->bean_type = "Contacts";
 $contact_query = $seedUsersLastImport->create_list_query($o,$w);
 $current_module_strings = return_module_language($current_language, 'Contacts');
 
-/*$seedUsersLastImport->list_fields = Array('id', 'first_name', 'last_name', 'account_name', 'account_id', 'title', 'yahoo_id', 'email1', 'phone_work', 'assigned_user_name', 'assigned_user_id');
-
-$where = "users_last_import.assigned_user_id='{$current_user->id}' AND users_last_import.bean_type='Contacts' and users_last_import.bean_id=contactdetails.contactid AND users_last_import.deleted=0";
-*/
-
 $contact = new Contact();
-//$seedUsersLastImport->list_fields = $contact->column_fields;
 $seedUsersLastImport->list_fields = $contact->list_fields;
 
 $list_result = $adb->query($contact_query);
@@ -143,6 +139,7 @@
 
 if($noofrows>1) 
 {
+	//Change this XTemplate to Smarty
 	$implict_account=true;
 	echo get_form_header('Last Imported Contacts','', false);
 	$xtpl=new XTemplate ('modules/Contacts/ListView.html');
@@ -150,7 +147,6 @@
 	$xtpl->assign("APP", $app_strings);
 	$xtpl->assign("IMAGE_PATH",$image_path);
 
-
 	//Retreiving the start value from request
 	if(isset($_REQUEST['start']) && $_REQUEST['start'] != '')
 	{
@@ -166,8 +162,8 @@
 	$navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
 	$adb->println("IMPLST Naviga");
 	$adb->println($navigation_array);
+
 	//Retreive the List View Table Header
-
 	$listview_header = getListViewHeader($contact,"Contacts");
 	$xtpl->assign("LISTHEADER", $listview_header);
 	
@@ -219,24 +215,15 @@
 
 	$xtpl->out("main");
 
-	#$ListView = new ListView();
-	#$ListView->initNewXTemplate( 'modules/Contacts/ListView.html',$current_module_strings);
-	#$ListView->setHeaderTitle("Last Imported Contacts" );
-	#$ListView->setQuery($where, "", "","CONTACT");
-	#$ListView->processListView($seedUsersLastImport, "main", "CONTACT");
-
-
 	echo "<BR>";
 }
 
 
-//opps list
+//To display the list of Potentials imported
 $newForm = null;
 $seedUsersLastImport = new UsersLastImport();
 $seedUsersLastImport->bean_type = "Potentials";
 
-#$seedUsersLastImport->list_fields = Array('id', 'name','account_id','account_name','amount','date_closed','assigned_user_name', 'assigned_user_id');
-
 $current_module_strings = return_module_language($current_language, 'Potentials');
 $potential_query = $seedUsersLastImport->create_list_query($o,$w);
 
@@ -250,6 +237,7 @@
 
 if($noofrows>1)
 {
+	//Change this XTemplate to Smarty
 	$implict_account=true;
 	echo get_form_header('Last Imported Potentials','', false);
 	$xtpl=new XTemplate ('modules/Potentials/ListView.html');
@@ -257,7 +245,6 @@
 	$xtpl->assign("APP", $app_strings);
 	$xtpl->assign("IMAGE_PATH",$image_path);
 
-
 	//Retreiving the start value from request
 	if(isset($_REQUEST['start']) && $_REQUEST['start'] != '')
 	{
@@ -271,7 +258,6 @@
 	$navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
 	
 	//Retreive the List View Table Header
-
 	$listview_header = getListViewHeader($potential,"Potentials");
 	$xtpl->assign("LISTHEADER", $listview_header);
 
@@ -317,27 +303,17 @@
 	$xtpl->assign("Prev", $prevoutput);
 	
 	$xtpl->parse("main");
-
 	$xtpl->out("main");
 
-	//$where = "users_last_import.assigned_user_id='{$current_user->id}' AND users_last_import.bean_type='Potentials' and users_last_import.bean_id=potential.potentialid AND users_last_import.deleted=0";
-
-	#$ListView = new ListView();
-	#$ListView->initNewXTemplate( 'modules/Potentials/ListView.html',$current_module_strings);
-	#$ListView->setHeaderTitle("Last Imported Potentials" );
-	#$ListView->setQuery($where, "", "","POTENTIAL");
-	#$ListView->processListView($seedUsersLastImport, "main", "POTENTIAL");
 	echo "<BR>";
 }
 
 
-//leads list
+//To display the list of Leads imported
 $newForm = null;
 $seedUsersLastImport = new UsersLastImport();
 $seedUsersLastImport->bean_type = "Leads";
 
-#$seedUsersLastImport->list_fields = Array('id', 'name','account_id','account_name','amount','date_closed','assigned_user_name', 'assigned_user_id');
-
 $current_module_strings = return_module_language($current_language, 'Potentials');
 $lead_query = $seedUsersLastImport->create_list_query($o,$w);
 
@@ -351,6 +327,7 @@
 
 if($noofrows>1)
 {
+	//Change this XTemplate to Smarty
 	$implict_account=true;
 	echo get_form_header('Last Imported Leads','', false);
 	$xtpl=new XTemplate ('modules/Leads/ListView.html');
@@ -371,7 +348,6 @@
 	$navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
 	
 	//Retreive the List View Table Header
-
 	$listview_header = getListViewHeader($lead,"Leads");
 	$xtpl->assign("LISTHEADER", $listview_header);
 
@@ -417,26 +393,16 @@
 	$xtpl->assign("Prev", $prevoutput);
 
 	$xtpl->parse("main");
-
 	$xtpl->out("main");
 
-	//$where = "users_last_import.assigned_user_id='{$current_user->id}' AND users_last_import.bean_type='Potentials' and users_last_import.bean_id=potential.potentialid AND users_last_import.deleted=0";
-
-	#$ListView = new ListView();
-	#$ListView->initNewXTemplate( 'modules/Potentials/ListView.html',$current_module_strings);
-	#$ListView->setHeaderTitle("Last Imported Potentials" );
-	#$ListView->setQuery($where, "", "","POTENTIAL");
-	#$ListView->processListView($seedUsersLastImport, "main", "POTENTIAL");
 	echo "<BR>";
 }
 
-
+//To display the list of Accounts imported
 $newForm = null;
 $seedUsersLastImport = new UsersLastImport();
 $seedUsersLastImport->bean_type = "Accounts";
 $account_query = $seedUsersLastImport->create_list_query($o,$w);
-//$seedUsersLastImport->list_fields = Array('id', 'name', 'website', 'phone_office', 'billing_address_city', 'assigned_user_name', 'assigned_user_id');
-//$seedUsersLastImport->list_fields = Array('accountid', 'accountname', 'website', 'phone', 'email1', 'assigned_user_name', 'fax');
 
 $current_module_strings = return_module_language($current_language, 'Accounts');
 
@@ -449,6 +415,7 @@
 
 if($noofrows>1)
 {
+	//Change this XTemplate to Smarty
 	if($implict_account==true)
 		echo get_form_header('Newly created Accounts','', false);
 	else
@@ -457,7 +424,6 @@
 	$xtpl->assign("MOD", $mod_strings);
 	$xtpl->assign("APP", $app_strings);
 	$xtpl->assign("IMAGE_PATH",$image_path);
-	
 
 	//Retreiving the start value from request
 	if(isset($_REQUEST['start']) && $_REQUEST['start'] != '')
@@ -472,9 +438,7 @@
 	$navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
 
 	//Retreive the List View Table Header
-
 	$listview_header = getListViewHeader($account,"Accounts");
-	//$xtpl->assign("LISTHEADER", $listview_header);
 	
 	$listview_entries = getListViewEntries($account,"Accounts",$list_result,$navigation_array);
 	$xtpl->assign("LISTHEADER", $listview_header);
@@ -521,14 +485,6 @@
 
 	$xtpl->out("main");
 
-	//$where = "users_last_import.assigned_user_id='{$current_user->id}' AND users_last_import.bean_type='Accounts' and users_last_import.bean_id=account.accountid AND users_last_import.deleted=0";
-
-	#$ListView = new ListView();
-	#$ListView->initNewXTemplate( 'modules/Accounts/ListView.html',$current_module_strings);
-	#$ListView->setHeaderTitle("Last Imported Accounts" );
-	#$ListView->setQuery($where, "", "name");
-	#$ListView->setQuery($where, "", "","ACCOUNT");
-	#$ListView->processListView($seedUsersLastImport, "main", "ACCOUNT");
 }
 
 ?>

Modified: vtigercrm/trunk/modules/Import/UsersLastImport.php
==============================================================================
--- vtigercrm/trunk/modules/Import/UsersLastImport.php (original)
+++ vtigercrm/trunk/modules/Import/UsersLastImport.php Tue Mar 28 00:44:43 2006
@@ -40,12 +40,13 @@
 
 	var $table_name = "users_last_import";
 	var $object_name = "UsersLastImport";
-	var $column_fields = Array("id"
-		,"assigned_user_id"
-		,"bean_type"
-		,"bean_id"
-		,"deleted"
-		);
+	var $column_fields = Array(
+					"id"
+					,"assigned_user_id"
+					,"bean_type"
+					,"bean_id"
+					,"deleted"
+				  );
 
 	var $new_schema = true;
 
@@ -65,21 +66,10 @@
 		
 	}
 
-	function create_tables () 
-	{ 
-	}
-
-        function drop_tables () 
-	{ 
-	}
-
-
 	function mark_deleted_by_user_id($user_id)
         {
-
                 $query = "UPDATE $this->table_name set deleted=1 where assigned_user_id='$user_id'";
                 $this->db->query($query,true,"Error marking last imported accounts deleted: ");
-
         }
 
 
@@ -92,48 +82,6 @@
 
 		if ($this->bean_type == 'Contacts')
 		{
-			/*$query = "SELECT distinct
-				account.accountname as account_name,
-				account.accountid  as account_id,
-				contactdetails.contactid,
-				crmentity.smownerid,
-				contactdetails.yahooid,
-				contactdetails.firstname,
-				contactdetails.lastname,
-				contactdetails.phone,
-				contactdetails.title,
-				contactdetails.email,
-                                users.user_name as assigned_user_name
-				FROM contactdetails, users_last_import 
-				LEFT JOIN users ON contactdetails.contactid=users.id 
-				LEFT JOIN account  ON account.accountid=contactdetails.accountid 
-				inner join crmentity on crmentity.crmid=contactdetails.contactid  
-				WHERE users_last_import.assigned_user_id= '{$current_user->id}'  
-				AND users_last_import.bean_type='Contacts' 
-				AND users_last_import.bean_id=contactdetails.contactid  
-				AND users_last_import.deleted=0  AND crmentity.deleted=0";
-				*/
-				/*$query = "SELECT distinct crmid,
-				account.accountname as account_name,
-				contactdetails.contactid,
-				contactdetails.accountid,				
-				contactdetails.yahooid,
-				contactdetails.firstname,
-				contactdetails.lastname,
-				contactdetails.phone,
-				contactdetails.title,
-				contactdetails.email,
-				users.id as assigned_user_id,
-				smownerid,
-                                users.user_name as assigned_user_name
-				FROM contactdetails, users_last_import 
-				LEFT JOIN users ON contactdetails.contactid=users.id 
-				LEFT JOIN account  ON account.accountid=contactdetails.accountid 
-				inner join crmentity on crmentity.crmid=contactdetails.contactid  
-				WHERE users_last_import.assigned_user_id= '{$current_user->id}'  
-				AND users_last_import.bean_type='Contacts' 
-				AND users_last_import.bean_id=contactdetails.contactid  
-				AND users_last_import.deleted=0  AND crmentity.deleted=0";*/
 				$query = "SELECT distinct crmid,
 				account.accountname as account_name,
 				contactdetails.contactid,
@@ -159,19 +107,6 @@
 		} 
 		else if ($this->bean_type == 'Accounts')
 		{
-			/*$query = "SELECT distinct account.*,
-                                users.user_name assigned_user_name
-				FROM accounts, users_last_import
-                                LEFT JOIN users
-                                ON accounts.assigned_user_id=users.id
-				WHERE 
-				users_last_import.assigned_user_id=
-					'{$current_user->id}'
-				AND users_last_import.bean_type='Accounts'
-				AND users_last_import.bean_id=accounts.id
-				AND users_last_import.deleted=0
-				AND accounts.deleted=0
-				AND users.status='ACTIVE'";*/
 				$query = "SELECT distinct account.*, accountbillads.city,
                                 users.user_name assigned_user_name,
 				crmid, smownerid 
@@ -191,29 +126,6 @@
 		else if ($this->bean_type == 'Potentials')
 		{
 		
-			/*$query = "SELECT distinct
-                                accounts.id account_id,
-                                accounts.name account_name,
-                                users.user_name assigned_user_name,
-                                opportunities.*
-                                FROM opportunities, users_last_import
-                                LEFT JOIN users
-                                ON opportunities.assigned_user_id=users.id
-                                LEFT JOIN accounts_opportunities
-                                ON opportunities.id=accounts_opportunities.opportunity_id
-                                LEFT JOIN accounts
-                                ON accounts_opportunities.account_id=accounts.id 
-                        	WHERE 
-				users_last_import.assigned_user_id=
-					'{$current_user->id}'
-				AND users_last_import.bean_type='Potentials'
-				AND users_last_import.bean_id=opportunities.id
-				AND users_last_import.deleted=0
-				AND accounts_opportunities.deleted=0 
-				AND accounts.deleted=0 
-				AND opportunities.deleted=0 
-				AND users.status='ACTIVE'";*/
-
 			$query = "SELECT distinct
                                 account.accountid account_id,
                                 account.accountname account_name,
@@ -254,109 +166,10 @@
 		}
 
 		
-
-		/*if(! empty($order_by))
-		{
-			$query .= " ORDER BY $order_by";
-		}*/
-
 		return $query;
 
 	}
 
-	
-
-	
-/*	function create_list_query(&$order_by, &$where)
-	{
-
-		echo 'the bean type is  >>>>>>>>>>>>>>>>>>>>>>>>>>>>  ' .$this->bean_type;
-		global $current_user;
-		$query = '';
-
-		if ($this->bean_type == 'Contacts')
-		{
-			$query = "SELECT distinct
-				account.accountname as account_name,
-				account.accountid  as account_id,
-				contactdetails.contactid,
-				crmentity.smownerid,				
-				contactdetails.firstname,
-				contactdetails.lastname,
-				contactdetails.phone,
-				contactdetails.title,
-				contactdetails.email,
-                                users.user_name as assigned_user_name
-				FROM contactdetails, users_last_import inner join crmentity on crmentity.crmid=contactdetails.contactid
-				LEFT JOIN users ON crmentity.smownerid=users.id 
-				LEFT JOIN account  ON account.accountid=contactdetails.accountid 
-				WHERE users_last_import.assigned_user_id= '{$current_user->id}'  
-				AND users_last_import.bean_type='Contacts' 
-				AND users_last_import.bean_id=contactdetails.contactid  
-				AND users_last_import.deleted=0  AND crmentity.deleted=0 AND users.status='ACTIVE'";
-
-				echo 'Contacts >>>>>>>>>>>>>>>>   '.$query;
-		} 
-		else if ($this->bean_type == 'Accounts')
-		{
-			/*$query = "SELECT distinct account.*,
-                                users.user_name assigned_user_name
-				FROM account, users_last_import
-                                LEFT JOIN users
-                                ON account.assigned_user_id=users.id
-				WHERE 
-				users_last_import.assigned_user_id=
-					'{$current_user->id}'
-				AND users_last_import.bean_type='Accounts'
-				AND users_last_import.bean_id=accounts.id
-				AND users_last_import.deleted=0
-				AND accounts.deleted=0
-				AND users.status='ACTIVE'";
-
-				$query = "SELECT distinct account.*,
-                                users.user_name assigned_user_name
-				FROM account, users_last_import inner join crmentity on crmentity.crmid=account.accountid left join users
-                                ON crmentity.smownerid=users.id
-				WHERE 
-				users_last_import.assigned_user_id=
-					'{$current_user->id}'
-				AND users_last_import.bean_type='Accounts'
-				AND users_last_import.bean_id=crmentity.crmid
-				AND users_last_import.deleted=0
-				AND crmentity.deleted=0
-				AND users.status='ACTIVE'";
-				echo '<br>Accounts >>>>>>>>>>>>>>>>   '.$query;
-		} 
-		else if ($this->bean_type == 'Potentials')
-		{
-		
-			$query = "SELECT distinct
-                                account.accountid account_id,
-                                account.accountname account_name,
-                                users.user_name assigned_user_name
-                                FROM potential, users_last_import inner join  crmentity on crmentity.crmid=potential.potentialdid left join users
-				ON crmentity.smownerid=users.id                                
-                        	WHERE 
-				users_last_import.assigned_user_id=
-					'{$current_user->id}'
-				AND users_last_import.bean_type='Potentials'
-				AND users_last_import.bean_id=crmentity.crmid
-				AND users_last_import.deleted=0
-				AND crmentity.deleted=0 
-				AND users.status='ACTIVE'";
-
-	
-				echo '<br>Potentials >>>>>>>>>>>>>>>>   '.$query;
-		}
-
-		if(! empty($order_by))
-		{
-			$query .= " ORDER BY $order_by";
-		}
-
-		return $query;
-
-	}*/
 	
 	function list_view_parse_additional_sections(&$list_form)
 	{
@@ -391,42 +204,22 @@
 	function undo_contacts($user_id)
 	{
 		$count = 0;
-		$query1 = "select bean_id from users_last_import where assigned_user_id='$user_id' 
-		AND bean_type='Contacts' AND deleted=0";
-
-		$this->log->info($query1); 
-
-		$result1 = $this->db->query($query1) 
-			or die("Error getting last import for undo: ".mysql_error()); 
-
-		while ( $row1 = $this->db->fetchByAssoc($result1))
-		{
-			$query2 = "update crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
-
-			$this->log->info($query2); 
-
-			$result2 = $this->db->query($query2) 
-				or die("Error undoing last import: ".mysql_error()); 
+		$query1 = "select bean_id from users_last_import where assigned_user_id='$user_id' AND bean_type='Contacts' AND deleted=0";
+
+		$this->log->info($query1); 
+
+		$result1 = $this->db->query($query1) or die("Error getting last import for undo: ".mysql_error()); 
+
+		while ( $row1 = $this->db->fetchByAssoc($result1))
+		{
+			$query2 = "update crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
+
+			$this->log->info($query2); 
+
+			$result2 = $this->db->query($query2) or die("Error undoing last import: ".mysql_error()); 
 
 			$count++;
 			
-			/*$query2 = "update crmentity set crmentity.deleted=1 inner join contactdetails on contactdetails.contactid=crmentity.crmid where contactdetails.contactid='{$row1['bean_id']}'";
-
-			$this->log->info($query2); 
-
-			$result2 = $this->db->query($query2) 
-				or die("Error undoing last import: ".mysql_error()); 
-
-			$count = $this->db->getAffectedRowCount($result2);*/
-
-	//TODO WELL BEFORE RELEASE RICHIE
-			//$query4 = "update contpotentialrel";
-
-			//$this->log->info($query4); 
-
-		//	$result4 = $this->db->query($query4) 
-		//		or die("Error undoing last import: ".mysql_error()); 
-
 		}
 		return $count;
 	}
@@ -434,42 +227,22 @@
 	function undo_leads($user_id)
 	{
 		$count = 0;
-		$query1 = "select bean_id from users_last_import where assigned_user_id='$user_id' 
-		AND bean_type='Leads' AND deleted=0";
-
-		$this->log->info($query1); 
-
-		$result1 = $this->db->query($query1) 
-			or die("Error getting last import for undo: ".mysql_error()); 
-
-		while ( $row1 = $this->db->fetchByAssoc($result1))
-		{
-			$query2 = "update crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
-
-			$this->log->info($query2); 
-
-			$result2 = $this->db->query($query2) 
-				or die("Error undoing last import: ".mysql_error()); 
+		$query1 = "select bean_id from users_last_import where assigned_user_id='$user_id' AND bean_type='Leads' AND deleted=0";
+
+		$this->log->info($query1); 
+
+		$result1 = $this->db->query($query1) or die("Error getting last import for undo: ".mysql_error()); 
+
+		while ( $row1 = $this->db->fetchByAssoc($result1))
+		{
+			$query2 = "update crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
+
+			$this->log->info($query2); 
+
+			$result2 = $this->db->query($query2) or die("Error undoing last import: ".mysql_error()); 
 
 			$count++;
 			
-			/*$query2 = "update crmentity set crmentity.deleted=1 inner join contactdetails on contactdetails.contactid=crmentity.crmid where contactdetails.contactid='{$row1['bean_id']}'";
-
-			$this->log->info($query2); 
-
-			$result2 = $this->db->query($query2) 
-				or die("Error undoing last import: ".mysql_error()); 
-
-			$count = $this->db->getAffectedRowCount($result2);*/
-
-	//TODO WELL BEFORE RELEASE RICHIE
-			//$query4 = "update contpotentialrel";
-
-			//$this->log->info($query4); 
-
-		//	$result4 = $this->db->query($query4) 
-		//		or die("Error undoing last import: ".mysql_error()); 
-
 		}
 		return $count;
 	}
@@ -478,57 +251,21 @@
 	{
 		// this should just be a loop foreach module type
 		$count = 0;
-		$query1 = "select bean_id from users_last_import 
-		where assigned_user_id='$user_id' 
-		AND bean_type='Accounts' AND deleted=0";
-
-		$this->log->info($query1); 
-
-		$result1 = $this->db->query($query1) 
-			or die("Error getting last import for undo: ".mysql_error()); 
-
-		while ( $row1 = $this->db->fetchByAssoc($result1))
-		{
-
-			$query2 = "update crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
-
-			$this->log->info($query2); 
-
-			$result2 = $this->db->query($query2) 
-				or die("Error undoing last import: ".mysql_error()); 
-
-			$count++;
-			//$count = $this->db->getAffectedRowCount($result2);
-			
-			
-			/*$query2 = "update accounts set accounts.deleted=1 
-					where accounts.id='{$row1['bean_id']}'";
-
-			$this->log->info($query2); 
-
-			$result2 = $this->db->query($query2) 
-				or die("Error undoing last import: ".mysql_error()); 
-
-			$count = $this->db->getAffectedRowCount($result2);
-
-			$query3 = "update accounts_contacts set accounts_contacts.deleted=1 
-					where accounts_contacts.account_id='{$row1['bean_id']}'
-					AND accounts_contacts.deleted=0";
-
-			$this->log->info($query3); 
-
-			$result3 = $this->db->query($query3) 
-				or die("Error undoing last import: ".mysql_error()); 
-
-			$query4 = "update accounts_opportunities set accounts_opportunities.deleted=1 
-					where accounts_opportunities.account_id='{$row1['bean_id']}'
-					AND accounts_opportunities.deleted=0";
-
-			$this->log->info($query4); 
-
-			$result4 = $this->db->query($query4) 
-				or die("Error undoing last import: ".mysql_error()); 
-				*/
+		$query1 = "select bean_id from users_last_import where assigned_user_id='$user_id' AND bean_type='Accounts' AND deleted=0";
+
+		$this->log->info($query1); 
+
+		$result1 = $this->db->query($query1) or die("Error getting last import for undo: ".mysql_error()); 
+
+		while ( $row1 = $this->db->fetchByAssoc($result1))
+		{
+			$query2 = "update crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
+
+			$this->log->info($query2); 
+
+			$result2 = $this->db->query($query2) or die("Error undoing last import: ".mysql_error()); 
+
+			$count++;
 
 		}
 		return $count;
@@ -538,54 +275,21 @@
 	{
 		// this should just be a loop foreach module type
 		$count = 0;
-		$query1 = "select bean_id from users_last_import 
-		where assigned_user_id='$user_id' 
-		AND bean_type='Potentials' AND deleted=0";
-
-		$this->log->info($query1); 
-
-		$result1 = $this->db->query($query1) 
-			or die("Error getting last import for undo: ".mysql_error()); 
-
-		while ( $row1 = $this->db->fetchByAssoc($result1))
-		{
-			$query2 = "update crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
-
-			$this->log->info($query2); 
-
-			$result2 = $this->db->query($query2) 
-				or die("Error undoing last import: ".mysql_error()); 
-
-			$count++;
-			
-			/*$query2 = "update opportunities set opportunities.deleted=1 
-					where opportunities.id='{$row1['bean_id']}'";
-
-			$this->log->info($query2); 
-
-			$result2 = $this->db->query($query2) 
-				or die("Error undoing last import: ".mysql_error()); 
-
-			$count = $this->db->getAffectedRowCount($result2);
-
-			$query3 = "update opportunities_contacts set opportunities_contacts.deleted=1 
-					where opportunities_contacts.opportunity_id='{$row1['bean_id']}'
-					AND opportunities_contacts.deleted=0";
-
-			$this->log->info($query3); 
-
-			$result3 = $this->db->query($query3) 
-				or die("Error undoing last import: ".mysql_error()); 
-
-
-			$query4 = "update accounts_opportunities set accounts_opportunities.deleted=1 
-					where accounts_opportunities.opportunity_id='{$row1['bean_id']}'
-					AND accounts_opportunities.deleted=0";
-
-			$this->log->info($query4); 
-
-			$result4 = $this->db->query($query4) 
-				or die("Error undoing last import: ".mysql_error()); */
+		$query1 = "select bean_id from users_last_import where assigned_user_id='$user_id' AND bean_type='Potentials' AND deleted=0";
+
+		$this->log->info($query1); 
+
+		$result1 = $this->db->query($query1) or die("Error getting last import for undo: ".mysql_error()); 
+
+		while ( $row1 = $this->db->fetchByAssoc($result1))
+		{
+			$query2 = "update crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
+
+			$this->log->info($query2); 
+
+			$result2 = $this->db->query($query2) or die("Error undoing last import: ".mysql_error()); 
+
+			$count++;
 
 		}
 		return $count;
@@ -594,22 +298,19 @@
 	function undo_products($user_id)
 	{
 		$count = 0;
-		$query1 = "select bean_id from users_last_import where assigned_user_id='$user_id' 
-		AND bean_type='Products' AND deleted=0";
-
-		$this->log->info($query1); 
-
-		$result1 = $this->db->query($query1) 
-			or die("Error getting last import for undo: ".mysql_error()); 
-
-		while ( $row1 = $this->db->fetchByAssoc($result1))
-		{
-			$query2 = "update crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
-
-			$this->log->info($query2); 
-
-			$result2 = $this->db->query($query2) 
-				or die("Error undoing last import: ".mysql_error()); 
+		$query1 = "select bean_id from users_last_import where assigned_user_id='$user_id' AND bean_type='Products' AND deleted=0";
+
+		$this->log->info($query1); 
+
+		$result1 = $this->db->query($query1) or die("Error getting last import for undo: ".mysql_error()); 
+
+		while ( $row1 = $this->db->fetchByAssoc($result1))
+		{
+			$query2 = "update crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
+
+			$this->log->info($query2); 
+
+			$result2 = $this->db->query($query2) or die("Error undoing last import: ".mysql_error()); 
 
 			$count++;
 		}

Modified: vtigercrm/trunk/modules/Migration/Migration.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/Migration.php (original)
+++ vtigercrm/trunk/modules/Migration/Migration.php Tue Mar 28 00:44:43 2006
@@ -100,22 +100,6 @@
 		echo '<br> Current Database has been created.';
 	}
 
-	function dropAllData($conn)
-	{
-		$tables_list = $conn->get_tables();
-                foreach($tables_list as $key)
-                {
-                        //if the table name has _seq, the let it pass
-                        if(strpos($key,"_seq"))
-                        {
-                                $conn->println('<br> skipping table '.$key .' for truncation ');
-                                continue;
-                        }
-                        $sql = "delete from ".$key;
-                        $conn->query($sql);
-                }
-	}
-
 	function applyDumpData($host_name,$mysql_port,$mysql_username,$mysql_password,$dbname,$dumpfile)
 	{
 		if($mysql_password != '')
@@ -149,7 +133,7 @@
 
 		//To handle the file includes for each and every version
 		//Here we have to decide which files should be included, where the files will be added newly for every public release
-		//Mickie -- Handle Here
+		//Handle Here -- Mickie
 		include("ModifyDatabase/42P2_to_50Alpha.php");
 
 		$conn->println("Mickie ---- Ends\n\n\n");
@@ -202,9 +186,6 @@
 			$this->conn->println("Going to Create the current Database");
 			$this->createDatabase($conn,$new_dbname);
 
-			//Drop all the values from the tables
-			//$this->dropAllData($conn);
-
 			//Apply the dump of the old database to the current database
 			$this->conn->println("Going to apply the old database dump to the new database.");
 			$this->applyDumpData($new_host_name,$new_mysql_port,$new_mysql_username,$new_mysql_password,$new_dbname,$dump_file);





More information about the vtigercrm-commits mailing list