[Vtigercrm-commits] [vtiger-commits] r7003 - in /vtigercrm/trunk: ./ cron/ data/ include/ include/Ajax/ include/ListView/ include/freetag/ include/utils/ install/ modules/Accounts/ modules/Accounts/language/ modules/Activities/ modules/Activities/language/ modules/Calendar/ modules/Calendar/language/ modules/Campaigns/ modules/Contacts/ modules/Contacts/language/ modules/CustomView/ modules/CustomView/language/ modules/Dashboard/ modules/Dashboard/language/ modules/Emails/ modules/Emails/language/ modules/Faq/ modules/Faq/language/ modules/HelpDesk/ modules/HelpDesk/language/ modules/Home/ modules/Import/ modules/Import/language/ modules/Invoice/ modules/Invoice/language/ modules/Invoice/pdf_templates/ modules/Leads/ modules/Leads/language/ modules/Migration/ modules/Migration/ModifyDatabase/ modules/Notes/ modules/Notes/language/ modules/Portal/ modules/Potentials/ modules/Potentials/language/ modules/PriceBooks/ modules/Products/ modules/Products/language/ modules/PurchaseOrder/ modules/PurchaseOrder/language/ modules/PurchaseOrder/pdf_templates/ modules/Quotes/ modules/Quotes/language/ modules/Quotes/pdf_templates/ modules/Reports/ modules/Reports/language/ modules/Rss/ modules/SalesOrder/ modules/SalesOrder/language/ modules/SalesOrder/pdf_templates/ modules/Settings/ modules/Settings/language/ modules/Users/ modules/Users/language/ modules/Utilities/ modules/Vendors/ modules/Webmails/ modules/Webmails/images/ modules/Webmails/language/ soap/

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon Jun 12 16:30:35 EDT 2006


Author: don
Date: Mon Jun 12 14:26:25 2006
New Revision: 7003

Log:
added the prefix vtiger_ in all table names

Modified:
    vtigercrm/trunk/cron/intimateTaskStatus.php
    vtigercrm/trunk/data/CRMEntity.php
    vtigercrm/trunk/data/SugarBean.php
    vtigercrm/trunk/data/Tracker.php
    vtigercrm/trunk/include/Ajax/TagCloud.php
    vtigercrm/trunk/include/ComboUtil.php
    vtigercrm/trunk/include/CustomFieldUtil.php
    vtigercrm/trunk/include/FormValidationUtil.php
    vtigercrm/trunk/include/ListView/ListView.php
    vtigercrm/trunk/include/PopulateComboValues.php
    vtigercrm/trunk/include/RelatedListView.php
    vtigercrm/trunk/include/freetag/freetag.class.php
    vtigercrm/trunk/include/utils/CommonUtils.php
    vtigercrm/trunk/include/utils/DeleteUtils.php
    vtigercrm/trunk/include/utils/DetailViewUtils.php
    vtigercrm/trunk/include/utils/EditViewUtils.php
    vtigercrm/trunk/include/utils/GetGroupUsers.php
    vtigercrm/trunk/include/utils/GetParentGroups.php
    vtigercrm/trunk/include/utils/GetUserGroups.php
    vtigercrm/trunk/include/utils/InventoryUtils.php
    vtigercrm/trunk/include/utils/ListViewUtils.php
    vtigercrm/trunk/include/utils/SearchUtils.php
    vtigercrm/trunk/include/utils/UserInfoUtil.php
    vtigercrm/trunk/include/utils/export.php
    vtigercrm/trunk/include/utils/utils.php
    vtigercrm/trunk/index.php
    vtigercrm/trunk/install/0welcome.php
    vtigercrm/trunk/install/1checkSystem.php
    vtigercrm/trunk/install/2setConfig.php
    vtigercrm/trunk/install/3confirmConfig.php
    vtigercrm/trunk/install/4createConfigFile.php
    vtigercrm/trunk/install/5createTables.inc.php
    vtigercrm/trunk/install/5createTables.php
    vtigercrm/trunk/install/populateSeedData.php
    vtigercrm/trunk/modules/Accounts/Account.php
    vtigercrm/trunk/modules/Accounts/Forms.php
    vtigercrm/trunk/modules/Accounts/ListViewTop.php
    vtigercrm/trunk/modules/Accounts/Merge.php
    vtigercrm/trunk/modules/Accounts/Popup_picker.php
    vtigercrm/trunk/modules/Accounts/Save.php
    vtigercrm/trunk/modules/Accounts/language/en_us.lang.php
    vtigercrm/trunk/modules/Activities/Activity.php
    vtigercrm/trunk/modules/Activities/EditView.php
    vtigercrm/trunk/modules/Activities/Event.php
    vtigercrm/trunk/modules/Activities/Forms.php
    vtigercrm/trunk/modules/Activities/GroupAllocationView.php
    vtigercrm/trunk/modules/Activities/ListView.php
    vtigercrm/trunk/modules/Activities/OpenListView.php
    vtigercrm/trunk/modules/Activities/RenderRelatedListUI.php
    vtigercrm/trunk/modules/Activities/Save.php
    vtigercrm/trunk/modules/Activities/language/en_us.lang.php
    vtigercrm/trunk/modules/Activities/updateRelations.php
    vtigercrm/trunk/modules/Calendar/Appointment.php
    vtigercrm/trunk/modules/Calendar/CalendarCommon.php
    vtigercrm/trunk/modules/Calendar/addEventUI.php
    vtigercrm/trunk/modules/Calendar/calendarLayout.php
    vtigercrm/trunk/modules/Calendar/disable_sharing.php
    vtigercrm/trunk/modules/Calendar/language/en_us.lang.php
    vtigercrm/trunk/modules/Calendar/updateCalendarSharing.php
    vtigercrm/trunk/modules/Campaigns/Campaign.php
    vtigercrm/trunk/modules/Campaigns/ListView.php
    vtigercrm/trunk/modules/Contacts/CallRelatedList.php
    vtigercrm/trunk/modules/Contacts/Contact.php
    vtigercrm/trunk/modules/Contacts/EditView.php
    vtigercrm/trunk/modules/Contacts/Forms.php
    vtigercrm/trunk/modules/Contacts/ListView.php
    vtigercrm/trunk/modules/Contacts/Merge.php
    vtigercrm/trunk/modules/Contacts/Save.php
    vtigercrm/trunk/modules/Contacts/chat.php
    vtigercrm/trunk/modules/Contacts/language/en_us.lang.php
    vtigercrm/trunk/modules/CustomView/CustomView.php
    vtigercrm/trunk/modules/CustomView/Delete.php
    vtigercrm/trunk/modules/CustomView/Forms.php
    vtigercrm/trunk/modules/CustomView/ListViewTop.php
    vtigercrm/trunk/modules/CustomView/PopulateCustomView.php
    vtigercrm/trunk/modules/CustomView/Save.php
    vtigercrm/trunk/modules/CustomView/SaveAction.php
    vtigercrm/trunk/modules/CustomView/SendMailAction.php
    vtigercrm/trunk/modules/CustomView/language/en_us.lang.php
    vtigercrm/trunk/modules/Dashboard/Chart_lead_source_by_outcome.php
    vtigercrm/trunk/modules/Dashboard/Chart_my_pipeline_by_sales_stage.php
    vtigercrm/trunk/modules/Dashboard/Chart_outcome_by_month.php
    vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_lead_source.php
    vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_sales_stage.php
    vtigercrm/trunk/modules/Dashboard/Entity_charts.php
    vtigercrm/trunk/modules/Dashboard/Forms.php
    vtigercrm/trunk/modules/Dashboard/ReportsCharts.php
    vtigercrm/trunk/modules/Dashboard/display_charts.php
    vtigercrm/trunk/modules/Dashboard/language/en_us.lang.php
    vtigercrm/trunk/modules/Emails/Choose.php
    vtigercrm/trunk/modules/Emails/ChooseEmail.php
    vtigercrm/trunk/modules/Emails/DetailView.php
    vtigercrm/trunk/modules/Emails/EditView.php
    vtigercrm/trunk/modules/Emails/Email.php
    vtigercrm/trunk/modules/Emails/Forms.php
    vtigercrm/trunk/modules/Emails/ListView.php
    vtigercrm/trunk/modules/Emails/Save.php
    vtigercrm/trunk/modules/Emails/class.phpmailer.php
    vtigercrm/trunk/modules/Emails/class.smtp.php
    vtigercrm/trunk/modules/Emails/language/en_us.lang.php
    vtigercrm/trunk/modules/Emails/mail.php
    vtigercrm/trunk/modules/Emails/mailSelect.php
    vtigercrm/trunk/modules/Emails/mailbox.php
    vtigercrm/trunk/modules/Emails/mailsend.php
    vtigercrm/trunk/modules/Emails/sendmail.php
    vtigercrm/trunk/modules/Emails/updateRelations.php
    vtigercrm/trunk/modules/Emails/webmailsend.php
    vtigercrm/trunk/modules/Faq/Faq.php
    vtigercrm/trunk/modules/Faq/language/en_us.lang.php
    vtigercrm/trunk/modules/HelpDesk/Convert.php
    vtigercrm/trunk/modules/HelpDesk/ConvertAsFAQ.php
    vtigercrm/trunk/modules/HelpDesk/ConvertToEntities.php
    vtigercrm/trunk/modules/HelpDesk/Forms.php
    vtigercrm/trunk/modules/HelpDesk/HelpDesk.php
    vtigercrm/trunk/modules/HelpDesk/ListTickets.php
    vtigercrm/trunk/modules/HelpDesk/ListView.php
    vtigercrm/trunk/modules/HelpDesk/Merge.php
    vtigercrm/trunk/modules/HelpDesk/Save.php
    vtigercrm/trunk/modules/HelpDesk/TicketStatisticsUtil.php
    vtigercrm/trunk/modules/HelpDesk/language/en_us.lang.php
    vtigercrm/trunk/modules/Home/Forms.php
    vtigercrm/trunk/modules/Home/LastViewed.php
    vtigercrm/trunk/modules/Home/UnifiedSearch.php
    vtigercrm/trunk/modules/Home/home_rss.php
    vtigercrm/trunk/modules/Home/index.php
    vtigercrm/trunk/modules/Import/Forms.php
    vtigercrm/trunk/modules/Import/ImportAccount.php
    vtigercrm/trunk/modules/Import/ImportContact.php
    vtigercrm/trunk/modules/Import/ImportLead.php
    vtigercrm/trunk/modules/Import/ImportMap.php
    vtigercrm/trunk/modules/Import/ImportOpportunity.php
    vtigercrm/trunk/modules/Import/ImportProduct.php
    vtigercrm/trunk/modules/Import/ImportSave.php
    vtigercrm/trunk/modules/Import/ImportStep2.php
    vtigercrm/trunk/modules/Import/ImportStep3.php
    vtigercrm/trunk/modules/Import/UsersLastImport.php
    vtigercrm/trunk/modules/Import/index.php
    vtigercrm/trunk/modules/Import/language/en_us.lang.php
    vtigercrm/trunk/modules/Import/parse_utils.php
    vtigercrm/trunk/modules/Invoice/CreatePDF.php
    vtigercrm/trunk/modules/Invoice/EditView.php
    vtigercrm/trunk/modules/Invoice/Invoice.php
    vtigercrm/trunk/modules/Invoice/ListTopInvoice.php
    vtigercrm/trunk/modules/Invoice/Save.php
    vtigercrm/trunk/modules/Invoice/language/en_us.lang.php
    vtigercrm/trunk/modules/Invoice/pdf_templates/header.php
    vtigercrm/trunk/modules/Leads/CallRelatedList.php
    vtigercrm/trunk/modules/Leads/ConvertLead.php
    vtigercrm/trunk/modules/Leads/Forms.php
    vtigercrm/trunk/modules/Leads/Lead.php
    vtigercrm/trunk/modules/Leads/LeadConvertToEntities.php
    vtigercrm/trunk/modules/Leads/ListViewTop.php
    vtigercrm/trunk/modules/Leads/Merge.php
    vtigercrm/trunk/modules/Leads/Save.php
    vtigercrm/trunk/modules/Leads/language/en_us.lang.php
    vtigercrm/trunk/modules/Migration/Migration.php
    vtigercrm/trunk/modules/Migration/MigrationCheck.php
    vtigercrm/trunk/modules/Migration/ModifyDatabase/42P2_to_50Alpha.php
    vtigercrm/trunk/modules/Migration/ModifyDatabase/MigrationInfo.php
    vtigercrm/trunk/modules/Migration/updateCurrency.php
    vtigercrm/trunk/modules/Notes/EditView.php
    vtigercrm/trunk/modules/Notes/Forms.php
    vtigercrm/trunk/modules/Notes/Note.php
    vtigercrm/trunk/modules/Notes/Save.php
    vtigercrm/trunk/modules/Notes/language/en_us.lang.php
    vtigercrm/trunk/modules/Portal/ListView.php
    vtigercrm/trunk/modules/Portal/Popup.php
    vtigercrm/trunk/modules/Portal/Portal.php
    vtigercrm/trunk/modules/Potentials/Charts.php
    vtigercrm/trunk/modules/Potentials/EditView.php
    vtigercrm/trunk/modules/Potentials/Forms.php
    vtigercrm/trunk/modules/Potentials/ListView.php
    vtigercrm/trunk/modules/Potentials/ListViewTop.php
    vtigercrm/trunk/modules/Potentials/Opportunity.php
    vtigercrm/trunk/modules/Potentials/Save.php
    vtigercrm/trunk/modules/Potentials/language/en_us.lang.php
    vtigercrm/trunk/modules/Potentials/updateRelations.php
    vtigercrm/trunk/modules/PriceBooks/PriceBook.php
    vtigercrm/trunk/modules/Products/AddProductToPriceBooks.php
    vtigercrm/trunk/modules/Products/AddProductsToPriceBook.php
    vtigercrm/trunk/modules/Products/DeletePriceBookProductRel.php
    vtigercrm/trunk/modules/Products/EditView.php
    vtigercrm/trunk/modules/Products/Forms.php
    vtigercrm/trunk/modules/Products/Product.php
    vtigercrm/trunk/modules/Products/Save.php
    vtigercrm/trunk/modules/Products/UpdateListPrice.php
    vtigercrm/trunk/modules/Products/addPbProductRelToDB.php
    vtigercrm/trunk/modules/Products/language/en_us.lang.php
    vtigercrm/trunk/modules/Products/updateRelations.php
    vtigercrm/trunk/modules/PurchaseOrder/CreatePDF.php
    vtigercrm/trunk/modules/PurchaseOrder/EditView.php
    vtigercrm/trunk/modules/PurchaseOrder/PurchaseOrder.php
    vtigercrm/trunk/modules/PurchaseOrder/Save.php
    vtigercrm/trunk/modules/PurchaseOrder/language/en_us.lang.php
    vtigercrm/trunk/modules/PurchaseOrder/pdf_templates/header.php
    vtigercrm/trunk/modules/Quotes/CreatePDF.php
    vtigercrm/trunk/modules/Quotes/EditView.php
    vtigercrm/trunk/modules/Quotes/ListTopQuotes.php
    vtigercrm/trunk/modules/Quotes/Quote.php
    vtigercrm/trunk/modules/Quotes/Save.php
    vtigercrm/trunk/modules/Quotes/language/en_us.lang.php
    vtigercrm/trunk/modules/Quotes/pdf_templates/header.php
    vtigercrm/trunk/modules/Reports/ChangeFolder.php
    vtigercrm/trunk/modules/Reports/Delete.php
    vtigercrm/trunk/modules/Reports/DeleteReportFolder.php
    vtigercrm/trunk/modules/Reports/PopulateReports.php
    vtigercrm/trunk/modules/Reports/ReportColumns.php
    vtigercrm/trunk/modules/Reports/ReportRun.php
    vtigercrm/trunk/modules/Reports/Reports.php
    vtigercrm/trunk/modules/Reports/Save.php
    vtigercrm/trunk/modules/Reports/SaveAndRun.php
    vtigercrm/trunk/modules/Reports/SaveReportFolder.php
    vtigercrm/trunk/modules/Reports/language/en_us.lang.php
    vtigercrm/trunk/modules/Rss/ListView.php
    vtigercrm/trunk/modules/Rss/Popup.php
    vtigercrm/trunk/modules/Rss/Rss.php
    vtigercrm/trunk/modules/Rss/Star.php
    vtigercrm/trunk/modules/SalesOrder/CreateSOPDF.php
    vtigercrm/trunk/modules/SalesOrder/EditView.php
    vtigercrm/trunk/modules/SalesOrder/ListTopSalesOrder.php
    vtigercrm/trunk/modules/SalesOrder/SalesOrder.php
    vtigercrm/trunk/modules/SalesOrder/Save.php
    vtigercrm/trunk/modules/SalesOrder/language/en_us.lang.php
    vtigercrm/trunk/modules/SalesOrder/pdf_templates/header.php
    vtigercrm/trunk/modules/Settings/AddCustomFieldToDB.php
    vtigercrm/trunk/modules/Settings/AddMailAccount.php
    vtigercrm/trunk/modules/Settings/BackupServerConfig.php
    vtigercrm/trunk/modules/Settings/CurrencyDelete.php
    vtigercrm/trunk/modules/Settings/CurrencyDeleteStep1.php
    vtigercrm/trunk/modules/Settings/CurrencyEditView.php
    vtigercrm/trunk/modules/Settings/CurrencyListView.php
    vtigercrm/trunk/modules/Settings/DeleteCustomField.php
    vtigercrm/trunk/modules/Settings/DeleteLeadCustomFieldMapping.php
    vtigercrm/trunk/modules/Settings/DeleteMailAccount.php
    vtigercrm/trunk/modules/Settings/EditCompanyDetails.php
    vtigercrm/trunk/modules/Settings/EditFieldBlock.php
    vtigercrm/trunk/modules/Settings/EmailConfig.php
    vtigercrm/trunk/modules/Settings/Forms.php
    vtigercrm/trunk/modules/Settings/LeadCustomFieldMapping.php
    vtigercrm/trunk/modules/Settings/ListLeadCustomFieldMapping.php
    vtigercrm/trunk/modules/Settings/ListModuleOwners.php
    vtigercrm/trunk/modules/Settings/OrganizationConfig.php
    vtigercrm/trunk/modules/Settings/PickList.php
    vtigercrm/trunk/modules/Settings/Save.php
    vtigercrm/trunk/modules/Settings/SaveCompany.php
    vtigercrm/trunk/modules/Settings/SaveConvertLead.php
    vtigercrm/trunk/modules/Settings/SaveCurrencyInfo.php
    vtigercrm/trunk/modules/Settings/SaveMailAccount.php
    vtigercrm/trunk/modules/Settings/SettingsSubMenu.php
    vtigercrm/trunk/modules/Settings/TaxConfig.php
    vtigercrm/trunk/modules/Settings/add2db.php
    vtigercrm/trunk/modules/Settings/downloadfile.php
    vtigercrm/trunk/modules/Settings/language/en_us.lang.php
    vtigercrm/trunk/modules/Users/Announcements.php
    vtigercrm/trunk/modules/Users/Authenticate.php
    vtigercrm/trunk/modules/Users/ChangePassword.php
    vtigercrm/trunk/modules/Users/CreateProfile.php
    vtigercrm/trunk/modules/Users/CreateProfile1.php
    vtigercrm/trunk/modules/Users/CreateUserPrivilegeFile.php
    vtigercrm/trunk/modules/Users/DefaultDataPopulator.php
    vtigercrm/trunk/modules/Users/Delete.php
    vtigercrm/trunk/modules/Users/DeleteGroup.php
    vtigercrm/trunk/modules/Users/DeleteUser.php
    vtigercrm/trunk/modules/Users/DetailView.php
    vtigercrm/trunk/modules/Users/EditHomeOrder.php
    vtigercrm/trunk/modules/Users/EditInventoryNotification.php
    vtigercrm/trunk/modules/Users/EditNotification.php
    vtigercrm/trunk/modules/Users/EditView.php
    vtigercrm/trunk/modules/Users/Forms.php
    vtigercrm/trunk/modules/Users/ListProfiles.php
    vtigercrm/trunk/modules/Users/Listhistory.php
    vtigercrm/trunk/modules/Users/Login.php
    vtigercrm/trunk/modules/Users/LoginHistory.php
    vtigercrm/trunk/modules/Users/Logout.php
    vtigercrm/trunk/modules/Users/OrgSharingDetailView.php
    vtigercrm/trunk/modules/Users/OrganizationTermsandConditions.php
    vtigercrm/trunk/modules/Users/ProfileDeleteStep1.php
    vtigercrm/trunk/modules/Users/RoleDetailView.php
    vtigercrm/trunk/modules/Users/RoleDragDrop.php
    vtigercrm/trunk/modules/Users/RolePopup.php
    vtigercrm/trunk/modules/Users/Save.php
    vtigercrm/trunk/modules/Users/SaveGroup.php
    vtigercrm/trunk/modules/Users/SaveInventoryNotification.php
    vtigercrm/trunk/modules/Users/SaveNotification.php
    vtigercrm/trunk/modules/Users/SaveOrgSharing.php
    vtigercrm/trunk/modules/Users/SaveProfile.php
    vtigercrm/trunk/modules/Users/SaveRole.php
    vtigercrm/trunk/modules/Users/TabCustomise.php
    vtigercrm/trunk/modules/Users/UpdateDefaultFieldLevelAccess.php
    vtigercrm/trunk/modules/Users/UpdateProfileChanges.php
    vtigercrm/trunk/modules/Users/UpdateTab.php
    vtigercrm/trunk/modules/Users/User.php
    vtigercrm/trunk/modules/Users/UserDeleteStep1.php
    vtigercrm/trunk/modules/Users/UsersAjax.php
    vtigercrm/trunk/modules/Users/add2db.php
    vtigercrm/trunk/modules/Users/binaryfilelist.php
    vtigercrm/trunk/modules/Users/createrole.php
    vtigercrm/trunk/modules/Users/deleteemailtemplate.php
    vtigercrm/trunk/modules/Users/deletewordtemplate.php
    vtigercrm/trunk/modules/Users/detailviewemailtemplate.php
    vtigercrm/trunk/modules/Users/downloadfile.php
    vtigercrm/trunk/modules/Users/editemailtemplate.php
    vtigercrm/trunk/modules/Users/language/en_us.lang.php
    vtigercrm/trunk/modules/Users/listemailtemplates.php
    vtigercrm/trunk/modules/Users/listinventorynotifications.php
    vtigercrm/trunk/modules/Users/listnotificationschedulers.php
    vtigercrm/trunk/modules/Users/listroles.php
    vtigercrm/trunk/modules/Users/listwordtemplates.php
    vtigercrm/trunk/modules/Users/lookupemailtemplates.php
    vtigercrm/trunk/modules/Users/massChangeStatus.php
    vtigercrm/trunk/modules/Users/massdelete.php
    vtigercrm/trunk/modules/Users/populatetemplate.php
    vtigercrm/trunk/modules/Users/profilePrivileges.php
    vtigercrm/trunk/modules/Users/saveemailtemplate.php
    vtigercrm/trunk/modules/Users/savetermsandconditions.php
    vtigercrm/trunk/modules/Users/updateLeadDBStatus.php
    vtigercrm/trunk/modules/Users/updateNotificationSchedulers.php
    vtigercrm/trunk/modules/Utilities/Merge.php
    vtigercrm/trunk/modules/Vendors/Vendor.php
    vtigercrm/trunk/modules/Vendors/updateRelations.php
    vtigercrm/trunk/modules/Webmails/CallRelatedList.php
    vtigercrm/trunk/modules/Webmails/ListView.php
    vtigercrm/trunk/modules/Webmails/Save.php
    vtigercrm/trunk/modules/Webmails/Webmail.php
    vtigercrm/trunk/modules/Webmails/dlAttachments.php
    vtigercrm/trunk/modules/Webmails/images/index.php
    vtigercrm/trunk/modules/Webmails/language/en_us.lang.php
    vtigercrm/trunk/soap/contactserialize.php
    vtigercrm/trunk/soap/customerportal.php
    vtigercrm/trunk/soap/vtigerolservice.php
    vtigercrm/trunk/soap/webforms.php

Modified: vtigercrm/trunk/cron/intimateTaskStatus.php
==============================================================================
--- vtigercrm/trunk/cron/intimateTaskStatus.php (original)
+++ vtigercrm/trunk/cron/intimateTaskStatus.php Mon Jun 12 14:26:25 2006
@@ -16,20 +16,20 @@
 $selecteddb = $dbconfig['db_name'];
 mysql_select_db($selecteddb,$db);
 
-$emailresult = mysql_query("SELECT email1 from users",$db);
+$emailresult = mysql_query("SELECT email1 from vtiger_users",$db);
 $emailid = mysql_fetch_row($emailresult);
 $emailaddress = $emailid[0];
-$mailserveresult = mysql_query("SELECT server,server_username,server_password FROM systems",$db);
+$mailserveresult = mysql_query("SELECT server,server_username,server_password FROM vtiger_systems",$db);
 $mailrow = mysql_fetch_row($mailserveresult);
 $mailserver = $mailrow[0];
 
 $mailuname = $mailrow[1];
 $mailpwd = $mailrow[1];
 
-//query the notificationscheduler table and get data for those notifications which are active
+//query the vtiger_notificationscheduler vtiger_table and get data for those notifications which are active
 
 
-$sql = "select active from notificationscheduler where schedulednotificationid=1";
+$sql = "select active from vtiger_notificationscheduler where schedulednotificationid=1";
 $result = mysql_query($sql);
 
 $activevalue = mysql_fetch_row($result);
@@ -39,7 +39,7 @@
 
 //get all those activities where the status is not completed even after the passing of 24 hours
 $today = date("Ymd"); 
-$result = mysql_query("select (activity.date_start +1) from activity where activity.status !='Completed' and ".$today." > (activity.date_start+1)",$db);
+$result = mysql_query("select (vtiger_activity.date_start +1) from vtiger_activity where vtiger_activity.status !='Completed' and ".$today." > (vtiger_activity.date_start+1)",$db);
 while ($myrow = mysql_fetch_row($result))
 {
   $status=$myrow[0];
@@ -51,13 +51,13 @@
 }
 
 //Big Deal Alert
-$sql = "select active from notificationscheduler where schedulednotificationid=2";
+$sql = "select active from vtiger_notificationscheduler where schedulednotificationid=2";
 $result = mysql_query($sql);
 
 $activevalue = mysql_fetch_row($result);
 if($activevalue[0] == 1)
 {
-$result = mysql_query("SELECT sales_stage,amount FROM potential",$db);
+$result = mysql_query("SELECT sales_stage,amount FROM vtiger_potential",$db);
 while ($myrow = mysql_fetch_row($result))
 {
   $amount=$myrow[1];
@@ -72,13 +72,13 @@
 }
 
 //Pending tickets
-$sql = "select active from notificationscheduler where schedulednotificationid=3";
+$sql = "select active from vtiger_notificationscheduler where schedulednotificationid=3";
 $result = mysql_query($sql);
 
 $activevalue = mysql_fetch_row($result);
 if($activevalue[0] == 1)
 {
-$result = mysql_query("SELECT status,ticketid FROM troubletickets",$db);
+$result = mysql_query("SELECT status,ticketid FROM vtiger_troubletickets",$db);
 while ($myrow = mysql_fetch_row($result))
 {
   $status=$myrow[0];
@@ -94,15 +94,15 @@
 
 }
 
-//Too many tickets related to a particular account/company causing concern
-$sql = "select active from notificationscheduler where schedulednotificationid=4";
+//Too many tickets related to a particular vtiger_account/company causing concern
+$sql = "select active from vtiger_notificationscheduler where schedulednotificationid=4";
 $result = mysql_query($sql);
 
 $activevalue = mysql_fetch_row($result);
 if($activevalue[0] == 1)
 {
 
-$result = mysql_query("SELECT status,troubletickets.ticketid FROM troubletickets where status!='Completed'",$db);
+$result = mysql_query("SELECT status,vtiger_troubletickets.ticketid FROM vtiger_troubletickets where status!='Completed'",$db);
 while ($myrow = mysql_fetch_row($result))
 {
   $status=$myrow[0];
@@ -114,13 +114,13 @@
 }
 
 //Support Starting
-$sql = "select active from notificationscheduler where schedulednotificationid=5";
+$sql = "select active from vtiger_notificationscheduler where schedulednotificationid=5";
 $result = mysql_query($sql);
 
 $activevalue = mysql_fetch_row($result);
 if($activevalue[0] == 1)
 {
-$result = mysql_query("SELECT start_date FROM products",$db);
+$result = mysql_query("SELECT start_date FROM vtiger_products",$db);
 while ($myrow = mysql_fetch_row($result))
 {
   $status=$myrow[0];
@@ -130,14 +130,14 @@
 }
 
 //Support ending
-$sql = "select active from notificationscheduler where schedulednotificationid=6";
+$sql = "select active from vtiger_notificationscheduler where schedulednotificationid=6";
 $result = mysql_query($sql);
 
 $activevalue = mysql_fetch_row($result);
 if($activevalue[0] == 1)
 {
 
-$result = mysql_query("SELECT expiry_date from products",$db);
+$result = mysql_query("SELECT expiry_date from vtiger_products",$db);
 while ($myrow = mysql_fetch_row($result))
 {
   $status=$myrow[0];

Modified: vtigercrm/trunk/data/CRMEntity.php
==============================================================================
--- vtigercrm/trunk/data/CRMEntity.php (original)
+++ vtigercrm/trunk/data/CRMEntity.php Mon Jun 12 14:26:25 2006
@@ -31,9 +31,9 @@
   /**
    * This method implements a generic insert and update logic for any SugarBean
    * This method only works for subclasses that implement the same variable names.
-   * This method uses the presence of an id field that is not null to signify and update.
-   * The id field should not be set otherwise.
-   * todo - Add support for field type validation and encoding of parameters.
+   * This method uses the presence of an id vtiger_field that is not null to signify and update.
+   * The id vtiger_field should not be set otherwise.
+   * todo - Add support for vtiger_field type validation and encoding of parameters.
    * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
    * All Rights Reserved.
    * Contributor(s): ______________________________________..
@@ -68,19 +68,19 @@
 
 	foreach($this->tab_name as $table_name)
 	{
-		if($table_name == "crmentity")
+		if($table_name == "vtiger_crmentity")
 		{
 			$this->insertIntoCrmEntity($module);
 		}
-		elseif($table_name == "salesmanactivityrel")
+		elseif($table_name == "vtiger_salesmanactivityrel")
 		{
 			$this->insertIntoSmActivityRel($module);
 		}
 		//added by raju
-		elseif($table_name=="seactivityrel" )
+		elseif($table_name=="vtiger_seactivityrel" )
 		{
 			if($module=="Emails" && $_REQUEST['smodule']!='webmails')
-			//modified by Richie as raju's implementation broke the feature for addition of webmail to crmentity.need to be more careful in future while integrating code
+			//modified by Richie as raju's implementation broke the feature for addition of webmail to vtiger_crmentity.need to be more careful in future while integrating code
 			//if($_REQUEST['smodule']!='webmails' && $_REQUEST['smodule'] != '')
 			{
 				if($_REQUEST['currentid']!='')
@@ -95,9 +95,9 @@
 				if($_REQUEST['module'] != 'Emails' && $_REQUEST['module'] != 'Webmails')
 				{
 					if(!$parentid) {
-						$parentid = $adb->getUniqueID('seactivityrel');
+						$parentid = $adb->getUniqueID('vtiger_seactivityrel');
 					}
-					$mysql='insert into seactivityrel values('.$parentid.','.$actid.')';
+					$mysql='insert into vtiger_seactivityrel values('.$parentid.','.$actid.')';
 					$adb->query($mysql);
 				}
 				else
@@ -107,11 +107,11 @@
 					{
 						$realid=explode("@",$myids[$i]);
 						$mycrmid=$realid[0];
-						//added to handle the relationship of emails with users
+						//added to handle the relationship of emails with vtiger_users
 						if($realid[1] == -1)
-							$mysql='insert into salesmanactivityrel values('.$mycrmid.','.$actid.')';
+							$mysql='insert into vtiger_salesmanactivityrel values('.$mycrmid.','.$actid.')';
 						else	
-							$mysql='insert into seactivityrel values('.$mycrmid.','.$actid.')';
+							$mysql='insert into vtiger_seactivityrel values('.$mycrmid.','.$actid.')';
 						$adb->query($mysql);
 					}
 				}
@@ -128,7 +128,7 @@
 				}
 			}			
 		}
-		elseif($table_name == "seticketsrel" || $table_name ==  "seproductsrel" || $table_name ==  "senotesrel")
+		elseif($table_name == "vtiger_seticketsrel" || $table_name ==  "vtiger_seproductsrel" || $table_name ==  "vtiger_senotesrel")
 		{
 			if(isset($this->column_fields['parent_id']) && $this->column_fields['parent_id'] != '')//raju - mass mailing ends
 			{
@@ -139,7 +139,7 @@
 				$this->deleteRelation($table_name);
 			}
 		}
-		elseif($table_name ==  "cntactivityrel")
+		elseif($table_name ==  "vtiger_cntactivityrel")
 		{
 			if(isset($this->column_fields['contact_id']) && $this->column_fields['contact_id'] != '')
 			{
@@ -151,22 +151,22 @@
 			}
 
 		}
-		elseif($table_name ==  "ticketcomments")
+		elseif($table_name ==  "vtiger_ticketcomments")
 		{
                 	$this->insertIntoTicketCommentTable($table_name, $module);
 		}
-		elseif($table_name ==  "faqcomments")
+		elseif($table_name ==  "vtiger_faqcomments")
 		{
                 	$this->insertIntoFAQCommentTable($table_name, $module);
 		}
-		elseif($table_name == "activity_reminder")
+		elseif($table_name == "vtiger_activity_reminder")
 		{
 			if($recur_type == "--None--")
 			{
 				$this->insertIntoReminderTable($table_name,$module,"");
 			}
 		}
-		elseif($table_name == "recurringevents") // Code included by Jaguar -  starts
+		elseif($table_name == "vtiger_recurringevents") // Code included by Jaguar -  starts
 		{
 			$recur_type = trim($_REQUEST['recurringtype']);
 			if($recur_type != "--None--"  && $recur_type != '')
@@ -175,7 +175,7 @@
 			}		
 		}// Code included by Jaguar - Ends
 		// Code included by Minnie  -  starts	
-		elseif($table_name == "invitees") 
+		elseif($table_name == "vtiger_invitees") 
 		{
 			if($invitees_array != '')
 			{
@@ -183,11 +183,11 @@
 			}
 		}
 		// Code included by Minnie  -  Ends
-		elseif($table_name == 'producttaxrel')
+		elseif($table_name == 'vtiger_producttaxrel')
 		{
 			$this->insertTaxInformation($table_name, $module);
 		}
-		elseif($table_name == 'attachments')
+		elseif($table_name == 'vtiger_attachments')
 		{
 			$this->insertIntoAttachment($this->id,$module);
 		}
@@ -226,7 +226,7 @@
 			$data = base64_encode(fread(fopen($filedata, "r"), $filesize));
 		}
 		
-		$current_id = $adb->getUniqueID("crmentity");
+		$current_id = $adb->getUniqueID("vtiger_crmentity");
 
 		if($module=='Emails') 
 		{ 
@@ -241,22 +241,22 @@
 		$sql="update ".$tablename." set filename='".$filename."' where ".$idname."=".$id;
 		$adb->query($sql);
 
-		$sql1 = "insert into crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(".$current_id.",".$current_user->id.",".$ownerid.",'".$module." Attachment','"."',".$adb->formatString("crmentity","createdtime",$date_var).",".$adb->formatString("crmentity","modifiedtime",$date_var).")";
+		$sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(".$current_id.",".$current_user->id.",".$ownerid.",'".$module." Attachment','"."',".$adb->formatString("vtiger_crmentity","createdtime",$date_var).",".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var).")";
 		$adb->query($sql1);
 
-		$sql2="insert into attachments(attachmentsid, name, description, type) values(".$current_id.",'".$filename."','"."','".$filetype."')";
+		$sql2="insert into vtiger_attachments(attachmentsid, name, description, type) values(".$current_id.",'".$filename."','"."','".$filetype."')";
 		$result=$adb->query($sql2);
 
 		//TODO -- instead of put contents in db now we should store the file in harddisk
 
-		$sql3='insert into seattachmentsrel values('.$id.','.$current_id.')';
+		$sql3='insert into vtiger_seattachmentsrel values('.$id.','.$current_id.')';
 		$adb->query($sql3);
 	}
 
 
 	/**
-	 *      This function is used to add the attachments. This will call the function uploadAndSaveFile which will upload the attachment into the server and save that attachment information in the database.
-	 *      @param int $id  - entity id to which the files to be uploaded
+	 *      This function is used to add the vtiger_attachments. This will call the function uploadAndSaveFile which will upload the attachment into the server and save that attachment information in the database.
+	 *      @param int $id  - entity id to which the vtiger_files to be uploaded
 	 *      @param string $module  - the current module name
 	*/
 	function insertIntoAttachment($id,$module)
@@ -272,17 +272,17 @@
 			}
 		}
 
-		//Remove the deleted attachments from db - Products
+		//Remove the deleted vtiger_attachments from db - Products
 		if($module == 'Products' && $_REQUEST['del_file_list'] != '')
 		{
 			$del_file_list = explode("###",trim($_REQUEST['del_file_list'],"###"));
 			foreach($del_file_list as $del_file_name)
 			{
-				$attach_res = $adb->query("select attachments.attachmentsid from attachments inner join seattachmentsrel on attachments.attachmentsid=seattachmentsrel.attachmentsid where crmid=$id and name=\"$del_file_name\"");
+				$attach_res = $adb->query("select vtiger_attachments.attachmentsid from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where crmid=$id and name=\"$del_file_name\"");
 				$attachments_id = $adb->query_result($attach_res,0,'attachmentsid');
 				
-				$del_res1 = $adb->query("delete from attachments where attachmentsid=$attachments_id");
-				$del_res2 = $adb->query("delete from seattachmentsrel where attachmentsid=$attachments_id");
+				$del_res1 = $adb->query("delete from vtiger_attachments where attachmentsid=$attachments_id");
+				$del_res2 = $adb->query("delete from vtiger_seattachmentsrel where attachmentsid=$attachments_id");
 			}
 		}
 
@@ -344,35 +344,35 @@
 
 		if($save_file == 'true')
 		{
-			$current_id = $adb->getUniqueID("crmentity");
-
-			//This is only to update the attached filename in the notes table for the Notes module
+			$current_id = $adb->getUniqueID("vtiger_crmentity");
+
+			//This is only to update the attached filename in the vtiger_notes vtiger_table for the Notes module
 			if($module=='Notes')
 			{
-				$sql="update notes set filename='".$filename."' where notesid = ".$id;
+				$sql="update vtiger_notes set filename='".$filename."' where notesid = ".$id;
 				$adb->query($sql);
 			}
 
-			$sql1 = "insert into crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(".$current_id.",".$current_user->id.",".$ownerid.",'".$module." Attachment','".$this->column_fields['description']."',".$adb->formatString("crmentity","createdtime",$date_var).",".$adb->formatString("crmentity","modifiedtime",$date_var).")";
+			$sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(".$current_id.",".$current_user->id.",".$ownerid.",'".$module." Attachment','".$this->column_fields['description']."',".$adb->formatString("vtiger_crmentity","createdtime",$date_var).",".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var).")";
 			$adb->query($sql1);
 
-			$sql2="insert into attachments(attachmentsid, name, description, type, path) values(".$current_id.",'".$filename."','".$this->column_fields['description']."','".$filetype."','".$upload_file_path."')";
+			$sql2="insert into vtiger_attachments(attachmentsid, name, description, type, path) values(".$current_id.",'".$filename."','".$this->column_fields['description']."','".$filetype."','".$upload_file_path."')";
 			$result=$adb->query($sql2);
 
 			if($_REQUEST['mode'] == 'edit')
 			{
 				if($id != '' && $_REQUEST['fileid'] != '')
 				{
-					$delquery = 'delete from seattachmentsrel where crmid = '.$id.' and attachmentsid = '.$_REQUEST['fileid'];
+					$delquery = 'delete from vtiger_seattachmentsrel where crmid = '.$id.' and attachmentsid = '.$_REQUEST['fileid'];
 					$adb->query($delquery);
 				}
 			}
 			if($module == 'Notes')
 			{
-				$query = "delete from seattachmentsrel where crmid = ".$id;
+				$query = "delete from vtiger_seattachmentsrel where crmid = ".$id;
 				$adb->query($query);
 			}
-			$sql3='insert into seattachmentsrel values('.$id.','.$current_id.')';
+			$sql3='insert into vtiger_seattachmentsrel values('.$id.','.$current_id.')';
 			$adb->query($sql3);
 		}
 		else
@@ -413,31 +413,31 @@
 	}
 	if($this->mode == 'edit')
 	{
-		$description_val = from_html($adb->formatString("crmentity","description",$this->column_fields['description']),($insertion_mode == 'edit')?true:false);
-		$sql = "update crmentity set smownerid=".$ownerid.",modifiedby=".$current_user->id.",description=".$description_val.", modifiedtime=".$adb->formatString("crmentity","modifiedtime",$date_var)." where crmid=".$this->id;
+		$description_val = from_html($adb->formatString("vtiger_crmentity","description",$this->column_fields['description']),($insertion_mode == 'edit')?true:false);
+		$sql = "update vtiger_crmentity set smownerid=".$ownerid.",modifiedby=".$current_user->id.",description=".$description_val.", modifiedtime=".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var)." where crmid=".$this->id;
 
 		$adb->query($sql);
-		$sql1 ="delete from ownernotify where crmid=".$this->id;
+		$sql1 ="delete from vtiger_ownernotify where crmid=".$this->id;
 		$adb->query($sql1);
 		if($ownerid != $current_user->id)
 		{
-			$sql1 = "insert into ownernotify values(".$this->id.",".$ownerid.",null)";
+			$sql1 = "insert into vtiger_ownernotify values(".$this->id.",".$ownerid.",null)";
 			$adb->query($sql1);
 		}
 	}
 	else
 	{
 		//if this is the create mode and the group allocation is chosen, then do the following
-		$current_id = $adb->getUniqueID("crmentity");
+		$current_id = $adb->getUniqueID("vtiger_crmentity");
 		$_REQUEST['currentid']=$current_id;
 
-		$description_val = from_html($adb->formatString("crmentity","description",$this->column_fields['description']),($insertion_mode == 'edit')?true:false);
-		$sql = "insert into crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values('".$current_id."','".$current_user->id."','".$ownerid."','".$module."',".$description_val.",".$adb->formatDate($date_var).",".$adb->formatDate($date_var).")";
+		$description_val = from_html($adb->formatString("vtiger_crmentity","description",$this->column_fields['description']),($insertion_mode == 'edit')?true:false);
+		$sql = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values('".$current_id."','".$current_user->id."','".$ownerid."','".$module."',".$description_val.",".$adb->formatDate($date_var).",".$adb->formatDate($date_var).")";
 		$adb->query($sql);
 		$this->id = $current_id;
 	}
 
-	//$sql = "insert into crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(".$current_id.",".$current_user->id.",".$ownerid.",'".$module."','".$this->column_fields['description']."',".$adb->formatString("crmentity","createdtime",$date_var).",".$adb->formatString("crmentity","modifiedtime",$date_var).")";
+	//$sql = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(".$current_id.",".$current_user->id.",".$ownerid.",'".$module."','".$this->column_fields['description']."',".$adb->formatString("crmentity","createdtime",$date_var).",".$adb->formatString("crmentity","modifiedtime",$date_var).")";
 	//$adb->query($sql);
 	//echo $sql;
 	//$this->id = $current_id;
@@ -452,11 +452,11 @@
     if($this->mode == 'edit')
     {
 
-      $sql = "delete from salesmanactivityrel where activityid=".$this->id." and smid = ".$this->column_fields['assigned_user_id']."";
+      $sql = "delete from vtiger_salesmanactivityrel where activityid=".$this->id." and smid = ".$this->column_fields['assigned_user_id']."";
       $adb->query($sql);
 
     }
-	$sql_qry = "insert into salesmanactivityrel (smid,activityid) values(".$this->column_fields['assigned_user_id'].",".$this->id.")";
+	$sql_qry = "insert into vtiger_salesmanactivityrel (smid,activityid) values(".$this->column_fields['assigned_user_id'].",".$this->id.")";
     $adb->query($sql_qry);
 
   }
@@ -467,8 +467,8 @@
     global $current_user;
     $ticketid = $id;
     //Updating History
-    $tktresult = $adb->query("select * from troubletickets where ticketid='".$ticketid."'");
-    $crmresult = $adb->query("select * from crmentity where crmid='".$ticketid."'");
+    $tktresult = $adb->query("select * from vtiger_troubletickets where ticketid='".$ticketid."'");
+    $crmresult = $adb->query("select * from vtiger_crmentity where crmid='".$ticketid."'");
     $updatelog = $adb->query_result($tktresult,0,"update_log");
     $old_user_id = $adb->query_result($crmresult,0,"smownerid");
     $old_status = $adb->query_result($tktresult,0,"status");
@@ -518,11 +518,11 @@
   function insertIntoEntityTable($table_name, $module)
   {
 	  global $log;	
-	   $log->info("function insertIntoCrmEntity ".$module.' table name ' .$table_name);
+	   $log->info("function insertIntoCrmEntity ".$module.' vtiger_table name ' .$table_name);
 	  global $adb;
 	  $insertion_mode = $this->mode;
 
-	  //Checkin whether an entry is already is present in the table to update
+	  //Checkin whether an entry is already is present in the vtiger_table to update
 	  if($insertion_mode == 'edit')
 	  {
 		  $check_query = "select * from ".$table_name." where ".$this->tab_name_index[$table_name]."=".$this->id;
@@ -547,7 +547,7 @@
 	  }
 
 	  $tabid= getTabid($module);	
-	  $sql = "select * from field where tabid=".$tabid." and tablename='".$table_name."' and displaytype in (1,3)"; 
+	  $sql = "select * from vtiger_field where tabid=".$tabid." and tablename='".$table_name."' and displaytype in (1,3)"; 
 	  $result = $adb->query($sql);
 	  $noofrows = $adb->num_rows($result);
 	  for($i=0; $i<$noofrows; $i++)
@@ -616,18 +616,18 @@
 		  if($insertion_mode == 'edit')
 		  {
 			  //code by richie starts
-			  if(($table_name == "troubletickets") && ($columname == "update_log"))
+			  if(($table_name == "vtiger_troubletickets") && ($columname == "update_log"))
 			  {
 				  $fldvalue = $this->constructUpdateLog($this->id);
 				  $fldvalue = from_html($adb->formatString($table_name,$columname,$fldvalue),($insertion_mode == 'edit')?true:false);
 			  }
 			  //code by richie ends
 
-			  if($table_name == 'notes' && $columname == 'filename' && $_FILES['filename']['name'] == '')
+			  if($table_name == 'vtiger_notes' && $columname == 'filename' && $_FILES['filename']['name'] == '')
 			  {
 				  $fldvalue = $this->getOldFileName($this->id);
 			  }
-			  if($table_name == 'products' && $columname == 'imagename')
+			  if($table_name == 'vtiger_products' && $columname == 'imagename')
 			  {
 			/*	  //Product Image Handling done
 				  if($_FILES['imagename']['name'] != '')
@@ -653,7 +653,7 @@
 		      */		  
 
 			  }
-			  if($table_name != 'ticketcomments')
+			  if($table_name != 'vtiger_ticketcomments')
 			  {
 				  if($i == 0)
 				  {
@@ -668,7 +668,7 @@
 		  else
 		  {
 			  //code by richie starts
-			  if(($table_name == "troubletickets") && ($columname == "update_log"))
+			  if(($table_name == "vtiger_troubletickets") && ($columname == "update_log"))
 			  {
 				  global $current_user;
 				  $fldvalue = date("l dS F Y h:i:s A").' by '.$current_user->user_name;
@@ -692,7 +692,7 @@
 				  $fldvalue = from_html($adb->formatString($table_name,$columname,$fldvalue),($insertion_mode == 'edit')?true:false);
 				  //echo ' updatevalue is ............. ' .$fldvalue;
 			  }
-			  elseif($table_name == 'products' && $columname == 'imagename')
+			  elseif($table_name == 'vtiger_products' && $columname == 'imagename')
 			  {
 				  //Product Image Handling done
 			/*	  if($_FILES['imagename']['name'] != '')
@@ -733,15 +733,15 @@
 	  {
 		  if($_REQUEST['module'] == 'Potentials')
 		  {
-			  $dbquery = 'select sales_stage from potential where potentialid = '.$this->id;
+			  $dbquery = 'select vtiger_sales_stage from vtiger_potential where potentialid = '.$this->id;
 			  $sales_stage = $adb->query_result($adb->query($dbquery),0,'sales_stage');
 			  if($sales_stage != $_REQUEST['sales_stage'])
 			  {
 				  $date_var = date('YmdHis');
-				  //$sql = "insert into potstagehistory values('',".$this->id.",".$_REQUEST['amount'].",'".$_REQUEST['sales_stage']."',".$_REQUEST['probability'].",".$_REQUEST['expectedrevenue'].",".$adb->formatString("potstagehistory","closedate",$_REQUEST['closingdate']).",".$adb->formatString("potstagehistory","lastmodified",$date_var).")";
+				  //$sql = "insert into vtiger_potstagehistory values('',".$this->id.",".$_REQUEST['amount'].",'".$_REQUEST['sales_stage']."',".$_REQUEST['probability'].",".$_REQUEST['expectedrevenue'].",".$adb->formatString("potstagehistory","closedate",$_REQUEST['closingdate']).",".$adb->formatString("potstagehistory","lastmodified",$date_var).")";
 				  //Changed to insert the close date based on user date format - after 4.2 patch2
 				  $closingdate = getDBInsertDateValue($_REQUEST['closingdate']);
-				  $sql = "insert into potstagehistory values('',".$this->id.",'".$_REQUEST['amount']."','".$sales_stage."','".$_REQUEST['probability']."',0,".$adb->formatString("potstagehistory","closedate",$closingdate).",".$adb->formatString("potstagehistory","lastmodified",$date_var).")";
+				  $sql = "insert into vtiger_potstagehistory values('',".$this->id.",'".$_REQUEST['amount']."','".$sales_stage."','".$_REQUEST['probability']."',0,".$adb->formatString("vtiger_potstagehistory","closedate",$closingdate).",".$adb->formatString("vtiger_potstagehistory","lastmodified",$date_var).")";
 				  $adb->query($sql);
 			  }
 		  }
@@ -758,49 +758,49 @@
 		  {
 			  $groupname = $_REQUEST['assigned_group_name'];
 			  //echo 'about to update lead group relation';
-			  if($module == 'Leads' && $table_name == 'leaddetails')
+			  if($module == 'Leads' && $table_name == 'vtiger_leaddetails')
 			  {
 				  updateLeadGroupRelation($this->id,$groupname);
 			  }
-                          elseif($module == 'Accounts' && $table_name == 'account')
+                          elseif($module == 'Accounts' && $table_name == 'vtiger_account')
 			  {
 				  updateAccountGroupRelation($this->id,$groupname);
 			  }
-			  elseif($module == 'Contacts' && $table_name == 'contactdetails')
+			  elseif($module == 'Contacts' && $table_name == 'vtiger_contactdetails')
 			  {
 				  updateContactGroupRelation($this->id,$groupname);
 			  }
-			  elseif($module == 'Potentials' && $table_name == 'potential')
+			  elseif($module == 'Potentials' && $table_name == 'vtiger_potential')
 			  {
 				  updatePotentialGroupRelation($this->id,$groupname);
 			  }
-			  elseif($module == 'Quotes' && $table_name == 'quotes')
+			  elseif($module == 'Quotes' && $table_name == 'vtiger_quotes')
 			  {
 				  updateQuoteGroupRelation($this->id,$groupname);
 			  }
-			  elseif($module == 'SalesOrder' && $table_name == 'salesorder')
+			  elseif($module == 'SalesOrder' && $table_name == 'vtiger_salesorder')
 			  {
 				  updateSoGroupRelation($this->id,$groupname);
 			  }
-			  elseif($module == 'Invoice' && $table_name == 'invoice')
+			  elseif($module == 'Invoice' && $table_name == 'vtiger_invoice')
 			  {
 				  updateInvoiceGroupRelation($this->id,$groupname);
 			  }
-			  elseif($module == 'PurchaseOrder' && $table_name == 'purchaseorder')
+			  elseif($module == 'PurchaseOrder' && $table_name == 'vtiger_purchaseorder')
 			  {
 				  updatePoGroupRelation($this->id,$groupname);
 			  }
-			  elseif($module == 'HelpDesk' && $table_name == 'troubletickets')
+			  elseif($module == 'HelpDesk' && $table_name == 'vtiger_troubletickets')
 			  {
 				  updateTicketGroupRelation($this->id,$groupname);
 			  }
-			  elseif($module == 'Campaigns' && $table_name == 'campaign')
+			  elseif($module == 'Campaigns' && $table_name == 'vtiger_campaign')
 			  {
 				  updateCampaignGroupRelation($this->id,$groupname);
 			  }
 			  elseif($module =='Activities' || $module =='Events' || $module == 'Emails')
 			  {
-				 if($table_name == 'activity')
+				 if($table_name == 'vtiger_activity')
 				 {
 				   updateActivityGroupRelation($this->id,$groupname);
 				 }
@@ -811,49 +811,49 @@
 		  else
 		  {
 			  //echo 'about to update lead group relation again!';
-			  if($module == 'Leads' && $table_name == 'leaddetails')
+			  if($module == 'Leads' && $table_name == 'vtiger_leaddetails')
 			  {
 				  updateLeadGroupRelation($this->id,'');
 			  }
-			  elseif($module == 'Accounts' && $table_name == 'account')
+			  elseif($module == 'Accounts' && $table_name == 'vtiger_account')
 			  {
 				  updateAccountGroupRelation($this->id,'');
 			  }
-			  elseif($module == 'Contacts' && $table_name == 'contactdetails')
+			  elseif($module == 'Contacts' && $table_name == 'vtiger_contactdetails')
 			  {
 				  updateContactGroupRelation($this->id,'');
 			  }
-			  elseif($module == 'Potentials' && $table_name == 'potential')
+			  elseif($module == 'Potentials' && $table_name == 'vtiger_potential')
 			  {
 				  updatePotentialGroupRelation($this->id,'');
 			  }
-			  elseif($module == 'Quotes' && $table_name == 'quotes')
+			  elseif($module == 'Quotes' && $table_name == 'vtiger_quotes')
 			  {
 				  updateQuoteGroupRelation($this->id,'');
 			  }
-			  elseif($module == 'SalesOrder' && $table_name == 'salesorder')
+			  elseif($module == 'SalesOrder' && $table_name == 'vtiger_salesorder')
 			  {
 				  updateSoGroupRelation($this->id,'');
 			  }
-			  elseif($module == 'Invoice' && $table_name == 'invoice')
+			  elseif($module == 'Invoice' && $table_name == 'vtiger_invoice')
 			  {
 				  updateInvoiceGroupRelation($this->id,'');
 			  }
-			  elseif($module == 'PurchaseOrder' && $table_name == 'purchaseorder')
+			  elseif($module == 'PurchaseOrder' && $table_name == 'vtiger_purchaseorder')
 			  {
 				  updatePoGroupRelation($this->id,'');
 			  }
-			  elseif($module == 'HelpDesk' && $table_name == 'troubletickets')
+			  elseif($module == 'HelpDesk' && $table_name == 'vtiger_troubletickets')
 			  {
 				  updateTicketGroupRelation($this->id,'');
 			  }
-			  elseif($module == 'Campaigns' && $table_name == 'campaign')
+			  elseif($module == 'Campaigns' && $table_name == 'vtiger_campaign')
 			  {
 				  updateCampaignGroupRelation($this->id,$groupname);
 			  }
 			  elseif($module =='Activities' || $module =='Events' || $module == 'Emails')
 			  {
-				  if($table_name == 'activity')
+				  if($table_name == 'vtiger_activity')
                                   {
 			             updateActivityGroupRelation($this->id,$groupname);
 				  }
@@ -868,47 +868,47 @@
 		  $sql1 = "insert into ".$table_name." (".$column.") values(".$value.")";
 		  $adb->query($sql1); 
 		  $groupname = $_REQUEST['assigned_group_name'];
-		  if($_REQUEST['assigntype'] == 'T' && $table_name == 'leaddetails')
+		  if($_REQUEST['assigntype'] == 'T' && $table_name == 'vitger_leaddetails')
 		  {
 			  insert2LeadGroupRelation($this->id,$groupname);
 		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'account')
+		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vitger_account')
 		  {
 			  insert2AccountGroupRelation($this->id,$groupname);
 		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'contactdetails')
+		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vitger_contactdetails')
 		  {
 			  insert2ContactGroupRelation($this->id,$groupname);
 		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'potential')
+		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vitger_potential')
 		  {
 			  insert2PotentialGroupRelation($this->id,$groupname);
 		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'quotes')
+		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vitger_quotes')
 		  {
 			  insert2QuoteGroupRelation($this->id,$groupname);
 		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'salesorder')
+		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vitger_salesorder')
 		  {
 			  insert2SoGroupRelation($this->id,$groupname);
 		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'invoice')
+		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vitger_invoice')
 		  {
 			  insert2InvoiceGroupRelation($this->id,$groupname);
 		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'purchaseorder')
+		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vitger_purchaseorder')
 		  {
 			  insert2PoGroupRelation($this->id,$groupname);
 		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'activity') 
+		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vitger_activity') 
 		  {
 			  insert2ActivityGroupRelation($this->id,$groupname);
 		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'troubletickets') 
+		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vitger_troubletickets') 
 		  {
 			  insert2TicketGroupRelation($this->id,$groupname);
 		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'campaign')
+		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vitger_campaign')
 		  {
 			  insert2CampaignGroupRelation($this->id,$groupname);
 		  }
@@ -935,14 +935,14 @@
 	   global $log;
 $log->info("in getOldFileName  ".$notesid);
 	global $adb;
-	$query1 = "select * from seattachmentsrel where crmid=".$notesid;
+	$query1 = "select * from vtiger_seattachmentsrel where crmid=".$notesid;
 	$result = $adb->query($query1);
 	$noofrows = $adb->num_rows($result);
 	if($noofrows != 0)
 		$attachmentid = $adb->query_result($result,0,'attachmentsid');
 	if($attachmentid != '')
 	{
-		$query2 = "select * from attachments where attachmentsid=".$attachmentid;
+		$query2 = "select * from vtiger_attachments where attachmentsid=".$attachmentid;
 		$filename = $adb->query_result($adb->query($query2),0,'name');
 	}
 	return "'".$filename."'";
@@ -963,7 +963,7 @@
 	if($_REQUEST['comments'] != '')
 	{
 		$comment = addslashes($_REQUEST['comments']);
-		$sql = "insert into ticketcomments values('',".$this->id.",'".$comment."','".$current_user->id."','".$ownertype."','".$current_time."')";
+		$sql = "insert into vtiger_ticketcomments values('',".$this->id.",'".$comment."','".$current_user->id."','".$ownertype."','".$current_time."')";
 	        $adb->query($sql);
 	}
 }
@@ -978,7 +978,7 @@
 	if($_REQUEST['comments'] != '')
 	{
 		$comment = addslashes($_REQUEST['comments']);
-		$sql = "insert into faqcomments values('',".$this->id.",'".$comment."','".$current_time."')";
+		$sql = "insert into vtiger_faqcomments values('',".$this->id.",'".$comment."','".$current_time."')";
 		$adb->query($sql);
 	}
 }
@@ -1028,7 +1028,7 @@
 	{
 		if($inviteeid != '')
 		{
-			$query="insert into invitees values(".$this->id.",".$inviteeid.")";
+			$query="insert into vtiger_invitees values(".$this->id.",".$inviteeid.")";
 			$adb->query($query);
 		}
 	}
@@ -1059,7 +1059,7 @@
 	{
 		$activity_id=$this->id;
 
-		$sql='select min(recurringdate) AS min_date,max(recurringdate) AS max_date, recurringtype, activityid from recurringevents where activityid='. $activity_id.' group by activityid, recurringtype';
+		$sql='select min(recurringdate) AS min_date,max(recurringdate) AS max_date, recurringtype, activityid from vtiger_recurringevents where activityid='. $activity_id.' group by activityid, recurringtype';
 		
 		$result = $adb->query($sql);
 		$noofrows = $adb->num_rows($result);
@@ -1073,15 +1073,15 @@
 		{
 			if($_REQUEST['set_reminder'] == 'Yes')
 			{
-				$sql = 'delete from activity_reminder where activity_id='.$activity_id;
+				$sql = 'delete from vtiger_activity_reminder where activity_id='.$activity_id;
 				$adb->query($sql);
-				$sql = 'delete  from recurringevents where activityid='.$activity_id;
+				$sql = 'delete  from vtiger_recurringevents where activityid='.$activity_id;
 				$adb->query($sql);
 				$flag="true";
 			}
 			elseif($_REQUEST['set_reminder'] == 'No')
 			{
-				$sql = 'delete  from activity_reminder where activity_id='.$activity_id;
+				$sql = 'delete  from vtiger_activity_reminder where activity_id='.$activity_id;
 				$adb->query($sql);
 				$flag="false";
 			}
@@ -1090,9 +1090,9 @@
 		}
 		else
 		{
-			$sql = 'delete from activity_reminder where activity_id='.$activity_id;
+			$sql = 'delete from vtiger_activity_reminder where activity_id='.$activity_id;
 			$adb->query($sql);
-			$sql = 'delete  from recurringevents where activityid='.$activity_id;
+			$sql = 'delete  from vtiger_recurringevents where activityid='.$activity_id;
 			$adb->query($sql);
 		}
 	}
@@ -1128,7 +1128,7 @@
 				$tdate=$date_array[$k];
 				if($tdate <= $end_date)
 				{
-					$max_recurid_qry = 'select max(recurringid) AS recurid from recurringevents;';
+					$max_recurid_qry = 'select max(recurringid) AS recurid from vtiger_recurringevents;';
 					$result = $adb->query($max_recurid_qry);
 					$noofrows = $adb->num_rows($result);
 					for($i=0; $i<$noofrows; $i++)
@@ -1136,7 +1136,7 @@
 						$recur_id = $adb->query_result($result,$i,"recurid");
 					}
 					$current_id =$recur_id+1;
-					$recurring_insert = "insert into recurringevents values ('".$current_id."','".$this->id."','".$tdate."','".$type."')";
+					$recurring_insert = "insert into vtiger_recurringevents values ('".$current_id."','".$this->id."','".$tdate."','".$type."')";
 					$adb->query($recurring_insert);
 					if($_REQUEST['set_reminder'] == 'Yes')
 					{
@@ -1184,7 +1184,7 @@
     $detailview_query .= " where ".$table_list[0].".".$table_index[0]." = ".$record;
     $result = $adb->query($detailview_query);*/
     $tabid = getTabid($module);
-    $sql1 =  "select * from field where tabid=".$tabid;
+    $sql1 =  "select * from vtiger_field where tabid=".$tabid;
     $result1 = $adb->query($sql1);
     $noofrows = $adb->num_rows($result1);
     for($i=0; $i<$noofrows; $i++)
@@ -1316,7 +1316,7 @@
 	*/
 	function mark_deleted($id)
 	{
-		$query = "UPDATE crmentity set deleted=1 where crmid='$id'";
+		$query = "UPDATE vtiger_crmentity set deleted=1 where crmid='$id'";
 		$this->db->query($query, true,"Error marking record deleted: ");
 
 
@@ -1349,9 +1349,9 @@
 
 	// this method is called during an import before inserting a bean
 	// define an associative array called $special_fields
-	// the keys are user defined, and don't directly map to the bean's fields
+	// the keys are user defined, and don't directly map to the bean's vtiger_fields
 	// the value is the method name within that bean that will do extra
-	// processing for that field. example: 'full_name'=>'get_names_from_full_name'
+	// processing for that vtiger_field. example: 'full_name'=>'get_names_from_full_name'
 
 	function process_special_fields() 
 	{ 
@@ -1365,7 +1365,7 @@
 	}
 
 	/**
-         * Function to check if the custom field table exists
+         * Function to check if the custom vtiger_field vtiger_table exists
          * return true or false
          */
         function checkIfCustomTableExists($tablename)
@@ -1385,14 +1385,14 @@
         }
 
 	/**
-	 * function to construct the query to fetch the custom fields
-	 * return the query to fetch the custom fields
+	 * function to construct the query to fetch the custom vtiger_fields
+	 * return the query to fetch the custom vtiger_fields
          */
         function constructCustomQueryAddendum($tablename,$module)
         {
                 global $adb;
 		$tabid=getTabid($module);		
-                $sql1 = "select columnname,fieldlabel from field where generatedtype=2 and tabid=".$tabid;
+                $sql1 = "select columnname,fieldlabel from vtiger_field where generatedtype=2 and tabid=".$tabid;
                 $result = $adb->query($sql1);
                 $numRows = $adb->num_rows($result);
                 $sql3 = "select ";
@@ -1420,8 +1420,8 @@
         }
 
 
-	/**	function to save the product tax information in producttarel table
-	 *	@param string $tablename - tablename to save the product tax relationship (producttaxrel)
+	/**	function to save the product tax information in producttarel vtiger_table
+	 *	@param string $tablename - vtiger_tablename to save the product tax relationship (producttaxrel)
 	 *	@param string $module	 - current module name
 	 *	$return void
 	*/
@@ -1439,7 +1439,7 @@
 			foreach($tax_array as $tax_type)
 			{
 				$taxid = getTaxId($tax_type);
-				$sql = "delete from producttaxrel where productid=$this->id and taxid=$taxid";
+				$sql = "delete from vtiger_producttaxrel where productid=$this->id and taxid=$taxid";
 				$adb->query($sql);
 			}
 		}
@@ -1452,7 +1452,7 @@
 
 			$log->debug("Going to save the Product - VAT tax relationship");
 
-			$sql = "insert into producttaxrel values($this->id,$taxid,$tax_per)";
+			$sql = "insert into vtiger_producttaxrel values($this->id,$taxid,$tax_per)";
 			$adb->query($sql);
 		}
 		//Save the Product - Sales tax relationship if Sales tax check box is enabled
@@ -1465,7 +1465,7 @@
 
 			$log->debug("Going to save the Product - Sales tax relationship");
 
-			$sql = "insert into producttaxrel values($this->id,$taxid,$tax_per)";
+			$sql = "insert into vtiger_producttaxrel values($this->id,$taxid,$tax_per)";
 			$adb->query($sql);
 		}
 		//Save the Product - Service tax relationship if Service tax check box is enabled
@@ -1478,7 +1478,7 @@
 
 			$log->debug("Going to save the Product - Service tax relationship");
 
-			$sql = "insert into producttaxrel values($this->id,$taxid,$tax_per)";
+			$sql = "insert into vtiger_producttaxrel values($this->id,$taxid,$tax_per)";
 			$adb->query($sql);
 		}
 

Modified: vtigercrm/trunk/data/SugarBean.php
==============================================================================
--- vtigercrm/trunk/data/SugarBean.php (original)
+++ vtigercrm/trunk/data/SugarBean.php Mon Jun 12 14:26:25 2006
@@ -32,9 +32,9 @@
     /**
      * This method implements a generic insert and update logic for any SugarBean
      * This method only works for subclasses that implement the same variable names.
-     * This method uses the presence of an id field that is not null to signify and update.
-     * The id field should not be set otherwise.
-     * todo - Add support for field type validation and encoding of parameters.
+     * This method uses the presence of an id vtiger_field that is not null to signify and update.
+     * The id vtiger_field should not be set otherwise.
+     * todo - Add support for vtiger_field type validation and encoding of parameters.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
@@ -89,7 +89,7 @@
 		$updKeyValues='';
 		foreach($this->column_fields as $field)
 		{
-			// Do not write out the id field on the update statement.
+			// Do not write out the id vtiger_field on the update statement.
 			// We are not allowed to change ids.
 			if($isUpdate && ('id' == $field))
 				continue;
@@ -158,7 +158,7 @@
     
     /**
      * This function retrieves a record of the appropriate type from the DB.
-     * It fills in all of the fields from the DB into the object it was called on.
+     * It fills in all of the vtiger_fields from the DB into the object it was called on.
      * param $id - If ID is specified, it overrides the current value of $this->id.  If not specified the current value of $this->id will be used.
      * returns this - The object that it was called apon or null if exactly 1 record was not found.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
@@ -172,7 +172,7 @@
 		if($id == '') {
 			return null;
 		}
-// GS porting crmentity
+// GS porting vtiger_crmentity
 $query = "SELECT * FROM $this->table_name WHERE $this->module_id = '$id'";
 //		$query = "SELECT * FROM $this->table_name WHERE ID = '$id'";
 		$this->log->debug("Retrieve $this->object_name: ".$query);
@@ -334,7 +334,7 @@
 	 */
 	function track_view($user_id, $current_module,$id='')
 	{
-		$this->log->debug("About to call tracker (user_id, module_name, item_id)($user_id, $current_module, $this->id)");
+		$this->log->debug("About to call vtiger_tracker (user_id, module_name, item_id)($user_id, $current_module, $this->id)");
 
 		$tracker = new Tracker();
 		$tracker->track_view($user_id, $current_module, $id, '');
@@ -433,9 +433,9 @@
 
 	// this method is called during an import before inserting a bean
 	// define an associative array called $special_fields
-	// the keys are user defined, and don't directly map to the bean's fields
+	// the keys are user defined, and don't directly map to the bean's vtiger_fields
 	// the value is the method name within that bean that will do extra
-	// processing for that field. example: 'full_name'=>'get_names_from_full_name'
+	// processing for that vtiger_field. example: 'full_name'=>'get_names_from_full_name'
 
 	function process_special_fields() 
 	{ 

Modified: vtigercrm/trunk/data/Tracker.php
==============================================================================
--- vtigercrm/trunk/data/Tracker.php (original)
+++ vtigercrm/trunk/data/Tracker.php Mon Jun 12 14:26:25 2006
@@ -34,9 +34,9 @@
 class Tracker {
     var $log;
     var $db;
-    var $table_name = "tracker";
-
-    // Tracker table
+    var $table_name = "vtiger_tracker";
+
+    // Tracker vtiger_table
     var $column_fields = Array(
         "id",
         "user_id",
@@ -54,7 +54,7 @@
     }
 
     /**
-     * Add this new item to the tracker table.  If there are too many items (global config for now)
+     * Add this new item to the vtiger_tracker vtiger_table.  If there are too many items (global config for now)
      * then remove the oldest item.  If there is more than one extra item, log an error.
      * If the new item is the same as the most recent item then do not change the list
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
@@ -75,7 +75,7 @@
          //get the first name and last name from the respective modules
           if($current_module =='Leads')
           {
-            $query = 'select firstname,lastname from leaddetails where leadid=' .$item_id;
+            $query = 'select firstname,lastname from vtiger_leaddetails where leadid=' .$item_id;
             $result = $this->db->query($query);
             $firstname = $adb->query_result($result,0,'firstname');
             $lastname =  $adb->query_result($result,0,'lastname');
@@ -83,7 +83,7 @@
           }
           elseif ($current_module =='Accounts')
           {
-            $query = 'select accountname from account where accountid=' .$item_id;
+            $query = 'select accountname from vtiger_account where accountid=' .$item_id;
             $result = $this->db->query($query);
             $accountname = $adb->query_result($result,0,'accountname');
             $item_summary = $accountname;
@@ -91,7 +91,7 @@
           }
           elseif($current_module =='Contacts')
           {
-            $query = 'select firstname,lastname from contactdetails where contactid=' .$item_id;
+            $query = 'select firstname,lastname from vtiger_contactdetails where contactid=' .$item_id;
             $result = $this->db->query($query);
             $firstname = $adb->query_result($result,0,'firstname');
             $lastname =  $adb->query_result($result,0,'lastname');
@@ -100,14 +100,14 @@
           }
           elseif($current_module =='Potentials')
           {
-            $query = 'select potentialname from potential where potentialid=' .$item_id;
+            $query = 'select potentialname from vtiger_potential where potentialid=' .$item_id;
             $result = $this->db->query($query);
             $potentialname =  $adb->query_result($result,0,'potentialname');
             $item_summary = $potentialname;
           }
           elseif($current_module =='Notes')
           {
-            $query = 'select title from notes where notesid=' .$item_id;
+            $query = 'select title from vtiger_notes where notesid=' .$item_id;
             $result = $this->db->query($query);
             $title = $adb->query_result($result,0,'title');
             $item_summary = $title;
@@ -115,7 +115,7 @@
           }
           elseif($current_module =='HelpDesk')
           {
-            $query = 'select title from troubletickets where ticketid=' .$item_id;
+            $query = 'select title from vtiger_troubletickets where ticketid=' .$item_id;
             $result = $this->db->query($query);
             $title = $adb->query_result($result,0,'title');
             $item_summary = $title;
@@ -123,7 +123,7 @@
           elseif($current_module =='Activities')
           {
             //$query = 'select name from calls where callid=' .$item_id;
-	    $query = 'select subject from activity where activityid=' .$item_id;
+	    $query = 'select subject from vtiger_activity where activityid=' .$item_id;
             $result = $this->db->query($query);
             $name = $adb->query_result($result,0,'subject');
             $item_summary = $name;
@@ -131,21 +131,21 @@
           elseif($current_module =='Emails')
           {
             //$query = 'select name from emails where emailid=' .$item_id;
-	    $query = 'select subject from activity where activityid=' .$item_id;
+	    $query = 'select subject from vtiger_activity where activityid=' .$item_id;
             $result = $this->db->query($query);
             $name = $adb->query_result($result,0,'subject');
             $item_summary = $name;
           }
           elseif($current_module =='Products')
           {
-            $query = 'select productname from products where productid=' .$item_id;
+            $query = 'select productname from vtiger_products where productid=' .$item_id;
             $result = $this->db->query($query);
             $productname = $adb->query_result($result,0,'productname');
             $item_summary = $productname;
           }
           elseif($current_module =='Users')
           {
-            $query = 'select first_name,last_name from users where id=' .$item_id;
+            $query = 'select first_name,last_name from vtiger_users where id=' .$item_id;
             $result = $this->db->query($query);
             $firstname = $adb->query_result($result,0,'first_name');
             $lastname = $adb->query_result($result,0,'last_name');
@@ -153,49 +153,49 @@
           }
 	  elseif($current_module =='Invoice')
           {
-            $query = 'select subject from invoice where invoiceid=' .$item_id;
+            $query = 'select subject from vtiger_invoice where invoiceid=' .$item_id;
             $result = $this->db->query($query);
             $invoice = $adb->query_result($result,0,'subject');
             $item_summary = $invoice;
           }
           elseif($current_module =='Quotes')
           {
-            $query = 'select subject from quotes where quoteid=' .$item_id;
+            $query = 'select subject from vtiger_quotes where quoteid=' .$item_id;
             $result = $this->db->query($query);
             $quote = $adb->query_result($result,0,'subject');
             $item_summary = $quote;
           }
 	  elseif($current_module =='PurchaseOrder')
           {
-            $query = 'select subject from purchaseorder where purchaseorderid=' .$item_id;
+            $query = 'select subject from vtiger_purchaseorder where purchaseorderid=' .$item_id;
             $result = $this->db->query($query);
             $po = $adb->query_result($result,0,'subject');
             $item_summary = $po;
           }
 	  elseif($current_module =='SalesOrder')
           {
-            $query = 'select subject from salesorder where salesorderid=' .$item_id;
+            $query = 'select subject from vtiger_salesorder where salesorderid=' .$item_id;
             $result = $this->db->query($query);
             $so = $adb->query_result($result,0,'subject');
             $item_summary = $so;
           }
 	  elseif($current_module =='Vendor')
           {
-            $query = 'select vendorname from vendor where vendorid=' .$item_id;
+            $query = 'select vtiger_vendorname from vtiger_vendor where vendorid=' .$item_id;
             $result = $this->db->query($query);
             $vendor = $adb->query_result($result,0,'vendorname');
             $item_summary = $vendor;
           }
 	  elseif($current_module =='PriceBook')
           {
-            $query = 'select bookname from pricebook where pricebookid=' .$item_id;
+            $query = 'select bookname from vtiger_pricebook where pricebookid=' .$item_id;
             $result = $this->db->query($query);
             $pb = $adb->query_result($result,0,'bookname');
             $item_summary = $pb;
           }	
 
 	 
-	 #if condition added to skip faq in last viewed history
+	 #if condition added to skip vtiger_faq in last viewed history
 	  if ($current_module != 'Faq')
 	  {		
           $query = "INSERT into $this->table_name (user_id, module_name, item_id, item_summary) values ('$user_id', '$current_module', '$esc_item_id', ".$this->db->formatString($this->table_name,'item_summary',$item_summary).")";
@@ -212,7 +212,7 @@
     /**
      * param $user_id - The id of the user to retrive the history for
      * param $module_name - Filter the history to only return records from the specified module.  If not specified all records are returned
-     * return - return the array of result set rows from the query.  All of the table fields are included
+     * return - return the array of result set rows from the query.  All of the vtiger_table vtiger_fields are included
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
@@ -224,7 +224,7 @@
     	}
 
 //        $query = "SELECT * from $this->table_name WHERE user_id='$user_id' ORDER BY id DESC";
-	$query = "SELECT * from $this->table_name inner join crmentity on crmentity.crmid=tracker.item_id WHERE user_id='$user_id' and crmentity.deleted=0 ORDER BY id DESC";
+	$query = "SELECT * from $this->table_name inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_tracker.item_id WHERE user_id='$user_id' and vtiger_crmentity.deleted=0 ORDER BY id DESC";
         $this->log->debug("About to retrieve list: $query");
         $result = $this->db->query($query, true);
         $list = Array();

Modified: vtigercrm/trunk/include/Ajax/TagCloud.php
==============================================================================
--- vtigercrm/trunk/include/Ajax/TagCloud.php (original)
+++ vtigercrm/trunk/include/Ajax/TagCloud.php Mon Jun 12 14:26:25 2006
@@ -34,7 +34,7 @@
 	$module = $_REQUEST["module"];
 	$useid = $current_user->id;
 	global $adb;
-	$query="select * from freetagged_objects where module = '".$module ."'";
+	$query="select * from vtiger_freetagged_objects where module = '".$module ."'";
 	$result=$adb->query($query);
 	if($adb->num_rows($result) > 0)
 	{

Modified: vtigercrm/trunk/include/ComboUtil.php
==============================================================================
--- vtigercrm/trunk/include/ComboUtil.php (original)
+++ vtigercrm/trunk/include/ComboUtil.php Mon Jun 12 14:26:25 2006
@@ -20,7 +20,7 @@
 	{
 		$fldArrName= $arrayName;
 		$arrayName = Array();
-		$result = $adb->query("select * from ".$tableName." where presence=1 order by sortorderid");
+		$result = $adb->query("select * from vtiger_".$tableName." where presence=1 order by sortorderid");
 		while($row = $adb->fetch_array($result))
 		{
 			$val = $row[$tableName];

Modified: vtigercrm/trunk/include/CustomFieldUtil.php
==============================================================================
--- vtigercrm/trunk/include/CustomFieldUtil.php (original)
+++ vtigercrm/trunk/include/CustomFieldUtil.php Mon Jun 12 14:26:25 2006
@@ -13,9 +13,9 @@
 require_once('include/utils/utils.php');
 
 /**
- * Function to get field typename
+ * Function to get vtiger_field typename
  * @param $uitype :: uitype -- Type integer
- * returns the field type name -- Type string
+ * returns the vtiger_field type name -- Type string
  */
 function getCustomFieldTypeName($uitype)
 {
@@ -82,8 +82,8 @@
 }
 
 /**
- * Function to get custom fields
- * @param $module :: table name -- Type string
+ * Function to get custom vtiger_fields
+ * @param $module :: vtiger_table name -- Type string
  * returns customfields in key-value pair array format
  */
 function getCustomFieldArray($module)
@@ -91,7 +91,7 @@
 	global $log;
 	$log->debug("Entering getCustomFieldArray(".$module.") method ...");
 	global $adb;
-	$custquery = "select * from field where tablename='".$module."'";
+	$custquery = "select * from vtiger_field where vtiger_tablename='".$module."'";
 	$custresult = $adb->query($custquery);
 	$custFldArray = Array();
 	$noofrows = $adb->num_rows($custresult);
@@ -106,9 +106,9 @@
 }
 
 /**
- * Function to get columnname and fieldlabel from field table
+ * Function to get columnname and vtiger_fieldlabel from vtiger_field vtiger_table
  * @param $module :: module name -- Type string
- * @param $trans_array :: translated column fields -- Type array
+ * @param $trans_array :: translated column vtiger_fields -- Type array
  * returns trans_array in key-value pair array format
  */
 function getCustomFieldTrans($module, $trans_array)
@@ -117,7 +117,7 @@
 	$log->debug("Entering getCustomFieldTrans(".$module.",". $trans_array.") method ...");
 	global $adb;
 	$tab_id = getTabid($module);	
-	$custquery = "select columnname,fieldlabel from field where generatedtype=2 and tabid=".$tab_id;
+	$custquery = "select columnname,fieldlabel from vtiger_field where generatedtype=2 and vtiger_tabid=".$tab_id;
 	$custresult = $adb->query($custquery);
 	$custFldArray = Array();
 	$noofrows = $adb->num_rows($custresult);
@@ -132,10 +132,10 @@
 
 
 /**
- * Function to get customfield record from field table
+ * Function to get customfield record from vtiger_field vtiger_table
  * @param $tab :: Tab ID -- Type integer
- * @param $datatype :: field name -- Type string
- * @param $id :: field Id -- Type integer
+ * @param $datatype :: vtiger_field name -- Type string
+ * @param $id :: vtiger_field Id -- Type integer
  * returns the data result in string format
  */
 function getCustomFieldData($tab,$id,$datatype)
@@ -143,7 +143,7 @@
 	global $log;
 	$log->debug("Entering getCustomFieldData(".$tab.",".$id.",".$datatype.") method ...");
 	global $adb;
-	$query = "select * from field where tabid=".$tab." and fieldid=".$id;
+	$query = "select * from vtiger_field where vtiger_tabid=".$tab." and vtiger_fieldid=".$id;
 	$result = $adb->query($query);
 	$return_data=$adb->fetch_array($result);
 	$log->debug("Exiting getCustomFieldData method ...");
@@ -153,9 +153,9 @@
 
 /**
  * Function to get customfield type,length value,decimal value and picklist value
- * @param $label :: field typename -- Type string
+ * @param $label :: vtiger_field typename -- Type string
  * @param $typeofdata :: datatype -- Type string
- * returns the field type,length,decimal
+ * returns the vtiger_field type,length,decimal
  * and picklist value in ';' separated array format
  */
 function getFldTypeandLengthValue($label,$typeofdata)

Modified: vtigercrm/trunk/include/FormValidationUtil.php
==============================================================================
--- vtigercrm/trunk/include/FormValidationUtil.php (original)
+++ vtigercrm/trunk/include/FormValidationUtil.php Mon Jun 12 14:26:25 2006
@@ -32,22 +32,22 @@
   	{
 		if($numValues > 1 && $i != $numValues-1)
     		{
-			$sql .= "select fieldlabel,fieldname,typeofdata from field where tablename='".$tablearray[$i] ."'and tabid=10 and displaytype <> 2 union ";
+			$sql .= "select fieldlabel,fieldname,typeofdata from vtiger_field where tablename='".$tablearray[$i] ."'and tabid=10 and displaytype <> 2 union ";
      		}
    		else
     		{
-   			$sql  .= "select fieldlabel,fieldname,typeofdata from field where tablename='".$tablearray[$i] ."' and tabid=10 and displaytype <> 2 ";
+   			$sql  .= "select fieldlabel,fieldname,typeofdata from vtiger_field where tablename='".$tablearray[$i] ."' and tabid=10 and displaytype <> 2 ";
     		}
   	}
   	else
   	{
     		if($numValues > 1 && $i != $numValues-1)
     		{
-      			$sql .= "select fieldlabel,fieldname,typeofdata from field where tablename='".$tablearray[$i] ."'".$tab_con." and displaytype in (1,3) union ";
+      			$sql .= "select fieldlabel,fieldname,typeofdata from vtiger_field where tablename='".$tablearray[$i] ."'".$tab_con." and displaytype in (1,3) union ";
     		}
     		else
     		{
-      			$sql  .= "select fieldlabel,fieldname,typeofdata from field where tablename='".$tablearray[$i] ."'".$tab_con." and displaytype in (1,3)";
+      			$sql  .= "select fieldlabel,fieldname,typeofdata from vtiger_field where tablename='".$tablearray[$i] ."'".$tab_con." and displaytype in (1,3)";
     		}
   	}
   }

Modified: vtigercrm/trunk/include/ListView/ListView.php
==============================================================================
--- vtigercrm/trunk/include/ListView/ListView.php (original)
+++ vtigercrm/trunk/include/ListView/ListView.php Mon Jun 12 14:26:25 2006
@@ -75,7 +75,7 @@
 	$this->header_title = $value;	
 	$log->debug("Exiting setHeaderTitle method ...");
 }
-/**sets the header text this is text thats appended to the header table and is usually used for the creation of buttons
+/**sets the header text this is text thats appended to the header vtiger_table and is usually used for the creation of buttons
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________.

Modified: vtigercrm/trunk/include/PopulateComboValues.php
==============================================================================
--- vtigercrm/trunk/include/PopulateComboValues.php (original)
+++ vtigercrm/trunk/include/PopulateComboValues.php Mon Jun 12 14:26:25 2006
@@ -24,7 +24,7 @@
 
 
 	/** 
-	 * To populate the default combo values for the combo tables
+	 * To populate the default combo values for the combo vtiger_tables
 	 */
 	function insertComboValues($values, $tableName)
 	{
@@ -37,11 +37,11 @@
 			$id = $adb->getUniqueID($tableName);
 			if($val != '')
 			{
-				$adb->query("insert into ".$tableName. " values(".$id.",'".$val."',".$i.",1)");
+				$adb->query("insert into vtiger_".$tableName. " values(".$id.",'".$val."',".$i.",1)");
 			}
 			else
 			{
-				$adb->query("insert into ".$tableName. " values(".$id.",'--None--',".$i.",1)");
+				$adb->query("insert into vtiger_".$tableName. " values(".$id.",'--None--',".$i.",1)");
 			}
 			$i++;
 		}
@@ -50,7 +50,7 @@
 
 
 	/** 
-	 * To populate the combo tables at startup time
+	 * To populate the combo vtiger_tables at startup time
 	 */
 
 	function create_tables () 

Modified: vtigercrm/trunk/include/RelatedListView.php
==============================================================================
--- vtigercrm/trunk/include/RelatedListView.php (original)
+++ vtigercrm/trunk/include/RelatedListView.php Mon Jun 12 14:26:25 2006
@@ -379,7 +379,7 @@
 
 // begin: Armando Lüscher 14.07.2005 -> §scrollableTables
 // Desc: 'X'
-//			 Insert new table with 1 cell where all entries are in a new table.
+//			 Insert new vtiger_table with 1 cell where all entries are in a new vtiger_table.
 //			 This cell will be scrollable when too many entries exist
 		$list .= ($noofrows>15) ? '<tr><td colspan="'.$colspan.'"><div style="overflow:auto;height:315px;width:100%;"><table cellspacing="0" cellpadding="0" border="0" width="100%">':'';
 // end: Armando Lüscher 14.07.2005 -> §scrollableTables
@@ -512,7 +512,7 @@
 		}
 
 // begin: Armando Lüscher 14.07.2005 -> §scrollableTables
-// Desc: Close table from 
+// Desc: Close vtiger_table from 
 		$list .= ($noofrows>15) ? '</table></div></td></tr>':'';
 // end: Armando Lüscher 14.07.2005 -> §scrollableTables
 
@@ -590,7 +590,7 @@
 
 // begin: Armando Lüscher 14.07.2005 -> §scrollableTables
 // Desc: 'X'
-//			 Insert new table with 1 cell where all entries are in a new table.
+//			 Insert new vtiger_table with 1 cell where all entries are in a new vtiger_table.
 //			 This cell will be scrollable when too many entries exist
 		$list_body .= ($num_rows>15) ? '<tr><td colspan="12"><div style="overflow:auto;height:315px;width:100%;"><table cellspacing="0" cellpadding="0" border="0" width="100%">':'';
 // end: Armando Lüscher 14.07.2005 -> §scrollableTablEs

Modified: vtigercrm/trunk/include/freetag/freetag.class.php
==============================================================================
--- vtigercrm/trunk/include/freetag/freetag.class.php (original)
+++ vtigercrm/trunk/include/freetag/freetag.class.php Mon Jun 12 14:26:25 2006
@@ -50,9 +50,9 @@
 	var $_debug = FALSE;
 	/**
 	 * @access private
-	 * @param string The prefix of freetag database tables.
-	 */
-	var $_table_prefix = '';
+	 * @param string The prefix of freetag database vtiger_tables.
+	 */
+	var $_table_prefix = 'vtiger_';
 	/**
 	 * @access private
 	 * @param string The regex-style set of characters that are valid for normalized tags.
@@ -65,7 +65,7 @@
 	var $_normalize_tags = 1;
 	/**
 	 * @access private
-	 * @param string Whether to prevent multiple users from tagging the same object. By default, set to block (ala Upcoming.org)
+	 * @param string Whether to prevent multiple vtiger_users from tagging the same object. By default, set to block (ala Upcoming.org)
 	 */
 	var $_block_multiuser_tag_on_object =0;
 	/**
@@ -97,10 +97,10 @@
 	 * - db_pass: Database password
 	 * - db_host: Database hostname [default: localhost]
 	 * - db_name: Database name
-	 * - table_prefix: If you wish to create multiple Freetag databases on the same database, you can put a prefix in front of the table names and pass separate prefixes to the constructor. [default: '']
+	 * - vtiger_table_prefix: If you wish to create multiple Freetag databases on the same database, you can put a prefix in front of the vtiger_table names and pass separate prefixes to the constructor. [default: '']
 	 * - normalize_tags: Whether to normalize (lowercase and filter for valid characters) on tags at all. [default: 1]
 	 * - normalized_valid_chars: Pass a regex-style set of valid characters that you want your tags normalized against. [default: 'a-zA-Z0-9' for alphanumeric]
-	 * - block_multiuser_tag_on_object: Set to 0 in order to allow individual users to all tag the same object with the same tag. Default is 1 to only allow one occurence of a tag per object. [default: 1]
+	 * - block_multiuser_tag_on_object: Set to 0 in order to allow individual vtiger_users to all tag the same object with the same tag. Default is 1 to only allow one occurence of a tag per object. [default: 1]
 	 * - MAX_TAG_LENGTH: maximum length of normalized tags in chars. [default: 30]
 	 * - ADODB_DIR: directory in which adodb is installed. Change if you don't want to use the bundled version. [default: adodb/]
 	 * - PCONNECT: Whether to use ADODB persistent connections. [default: FALSE]
@@ -240,7 +240,7 @@
 	 * get_objects_with_tag_combo
 	 *
 	 * Returns an array of object ID's that have all the tags passed in the
-	 * tagArray parameter. Use this to provide tag combo services to your users.
+	 * tagArray parameter. Use this to provide tag combo services to your vtiger_users.
 	 *
 	 * @param array - Pass an array of normalized form tags along to the function.
 	 * @param int (Optional) - The numerical offset to begin display at. Defaults to 0.
@@ -347,7 +347,7 @@
 	 * You can use this function to show the tags on an object. Since it supports both user-specific
 	 * and general modes with the $tagger_id parameter, you can use it twice on a page to make it work
 	 * similar to upcoming.org and flickr, where the page displays your own tags differently than
-	 * other users' tags.
+	 * other vtiger_users' tags.
 	 *
 	 * @param int The unique ID of the object in question.
 	 * @param int The offset of tags to return.
@@ -428,7 +428,7 @@
 		$prefix = $this->_table_prefix;
 
 		// First, check for duplicate of the normalized form of the tag on this object.
-		// Dynamically switch between allowing duplication between users on the constructor param 'block_multiuser_tag_on_object'.
+		// Dynamically switch between allowing duplication between vtiger_users on the constructor param 'block_multiuser_tag_on_object'.
 		// If it's set not to block multiuser tags, then modify the existence
 		// check to look for a tag by this particular user. Otherwise, the following
 		// query will reveal whether that tag exists on that object for ANY user.
@@ -514,7 +514,7 @@
 	 *
 	 * @param int The unique ID of the person who tagged the object with this tag.
 	 * @param int The ID of the object in question.
-	 * @param string The raw string form of the tag to delete. See above for notes.
+	 * @param string The raw string form of the tag to delete. See above for vtiger_notes.
 	 *
 	 * @return string Returns the tag in normalized form.
 	 */ 
@@ -682,7 +682,7 @@
 	 *
 	 * @param int The unique ID of the person who tagged the object with this tag.
 	 * @param int The ID of the object in question.
-	 * @param string The raw string form of the tag to delete. See above for notes.
+	 * @param string The raw string form of the tag to delete. See above for vtiger_notes.
 	 * @param int Whether to skip the update portion for objects that haven't been tagged. (Default: 1)
 	 *
 	 * @return string Returns the tag in normalized form.
@@ -1015,7 +1015,7 @@
 	 *
 	 * Finds tags that are "similar" or related to the given tag.
 	 * It does this by looking at the other tags on objects tagged with the tag specified.
-	 * Confusing? Think of it like e-commerce's "Other users who bought this also bought," 
+	 * Confusing? Think of it like e-commerce's "Other vtiger_users who bought this also bought," 
 	 * as that's exactly how this works.
 	 *
 	 * Returns an empty array if no tag is passed, or if no related tags are found.

Modified: vtigercrm/trunk/include/utils/CommonUtils.php
==============================================================================
--- vtigercrm/trunk/include/utils/CommonUtils.php (original)
+++ vtigercrm/trunk/include/utils/CommonUtils.php Mon Jun 12 14:26:25 2006
@@ -119,7 +119,7 @@
 	foreach ($key_list as $option_key=>$option_value) {
 		$selected_string = '';
 		// the system is evaluating $selected_key == 0 || '' to true.  Be very careful when changing this.  Test all cases.
-		// The reported bug was only happening with one of the users in the drop down.  It was being replaced by none.
+		// The vtiger_reported bug was only happening with one of the vtiger_users in the drop down.  It was being replaced by none.
 		if (($option_key != '' && $selected_key == $option_key) || ($selected_key == '' && $option_key == '') || (in_array($option_key, $selected_key)))
 		{
 			$selected_string = 'selected ';
@@ -221,22 +221,22 @@
 
 /** To get the Currency of the specified user
   * @param $id -- The user Id:: Type integer
-  * @returns  currencyid :: Type integer
+  * @returns  vtiger_currencyid :: Type integer
  */
 function fetchCurrency($id)
 {
 	global $log;
 	$log->debug("Entering fetchCurrency(".$id.") method ...");
         global $adb;
-        $sql = "select currency_id from users where id=" .$id;
+        $sql = "select currency_id from vtiger_users where id=" .$id;
         $result = $adb->query($sql);
         $currencyid=  $adb->query_result($result,0,"currency_id");
 	$log->debug("Exiting fetchCurrency method ...");
         return $currencyid;
 }
 
-/** Function to get the Currency name from the currency_info
-  * @param $currencyid -- currencyid:: Type integer
+/** Function to get the Currency name from the vtiger_currency_info
+  * @param $currencyid -- vtiger_currencyid:: Type integer
   * @returns $currencyname -- Currency Name:: Type varchar
   *
  */
@@ -255,7 +255,7 @@
 
 
 /**
- * Function to fetch the list of groups from group table 
+ * Function to fetch the list of vtiger_groups from group vtiger_table 
  * Takes no value as input 
  * returns the query result set object
  */
@@ -265,7 +265,7 @@
 	global $log;
 	$log->debug("Entering get_group_options() method ...");
 	global $adb,$noof_group_rows;;
-	$sql = "select groupname from groups";
+	$sql = "select groupname from vtiger_groups";
 	$result = $adb->query($sql);
 	$noof_group_rows=$adb->num_rows($result);
 	$log->debug("Exiting get_group_options method ...");
@@ -293,7 +293,7 @@
 
         $log->info("module  is ".$module);
         global $adb;
-	$sql = "select tabid from tab where name='".$module."'";
+	$sql = "select tabid from vtiger_tab where name='".$module."'";
 	$result = $adb->query($sql);
 	$tabid=  $adb->query_result($result,0,"tabid");
 	}
@@ -314,7 +314,7 @@
 	$log->debug("Entering getSalesEntityType(".$crmid.") method ...");
 	$log->info("in getSalesEntityType ".$crmid);
 	global $adb;
-	$sql = "select * from crmentity where crmid=".$crmid;
+	$sql = "select * from vtiger_crmentity where crmid=".$crmid;
         $result = $adb->query($sql);
 	$parent_module = $adb->query_result($result,0,"setype");
 	$log->debug("Exiting getSalesEntityType method ...");
@@ -322,9 +322,9 @@
 }
 
 /**
- * Function to get the AccountName when a account id is given 
- * Takes the input as $acount_id - account id
- * returns the account name in string format.
+ * Function to get the AccountName when a vtiger_account id is given 
+ * Takes the input as $acount_id - vtiger_account id
+ * returns the vtiger_account name in string format.
  */
 
 function getAccountName($account_id)
@@ -336,7 +336,7 @@
 	global $adb;
 	if($account_id != '')
 	{
-		$sql = "select accountname from account where accountid=".$account_id;
+		$sql = "select accountname from vtiger_account where accountid=".$account_id;
         	$result = $adb->query($sql);
 		$accountname = $adb->query_result($result,0,"accountname");
 	}
@@ -358,7 +358,7 @@
 	$log->info("in getproductname ".$product_id);
 
 	global $adb;
-	$sql = "select productname from products where productid=".$product_id;
+	$sql = "select productname from vtiger_products where productid=".$product_id;
         $result = $adb->query($sql);
 	$productname = $adb->query_result($result,0,"productname");
 	$log->debug("Exiting getProductName method ...");
@@ -366,9 +366,9 @@
 }
 
 /**
- * Function to get the Potentail Name when a potential id is given 
- * Takes the input as $potential_id - potential id
- * returns the potential name in string format.
+ * Function to get the Potentail Name when a vtiger_potential id is given 
+ * Takes the input as $potential_id - vtiger_potential id
+ * returns the vtiger_potential name in string format.
  */
 
 function getPotentialName($potential_id)
@@ -381,7 +381,7 @@
 	$potentialname = '';
 	if($potential_id != '')
 	{
-		$sql = "select potentialname from potential where potentialid=".$potential_id;
+		$sql = "select potentialname from vtiger_potential where potentialid=".$potential_id;
         	$result = $adb->query($sql);
 		$potentialname = $adb->query_result($result,0,"potentialname");
 	}
@@ -402,7 +402,7 @@
 	$log->info("in getContactName ".$contact_id);
 
         global $adb;
-        $sql = "select * from contactdetails where contactid=".$contact_id;
+        $sql = "select * from vtiger_contactdetails where contactid=".$contact_id;
         $result = $adb->query($sql);
         $firstname = $adb->query_result($result,0,"firstname");
         $lastname = $adb->query_result($result,0,"lastname");
@@ -412,8 +412,8 @@
 }
 
 /**
- * Function to get the Vendor Name when a vendor id is given 
- * Takes the input as $vendor_id - vendor id
+ * Function to get the Vendor Name when a vtiger_vendor id is given 
+ * Takes the input as $vendor_id - vtiger_vendor id
  * returns the Vendor Name in string format.
  */
 
@@ -423,7 +423,7 @@
 	$log->debug("Entering getVendorName(".$vendor_id.") method ...");
 	$log->info("in getVendorName ".$vendor_id);
         global $adb;
-        $sql = "select * from vendor where vendorid=".$vendor_id;
+        $sql = "select * from vtiger_vendor where vendorid=".$vendor_id;
         $result = $adb->query($sql);
         $vendor_name = $adb->query_result($result,0,"vendorname");
 	$log->debug("Exiting getVendorName method ...");
@@ -431,7 +431,7 @@
 }
 
 /**
- * Function to get the Quote Name when a vendor id is given 
+ * Function to get the Quote Name when a vtiger_vendor id is given 
  * Takes the input as $quote_id - quote id
  * returns the Quote Name in string format.
  */
@@ -442,7 +442,7 @@
 	$log->debug("Entering getQuoteName(".$quote_id.") method ...");
 	$log->info("in getQuoteName ".$quote_id);
         global $adb;
-        $sql = "select * from quotes where quoteid=".$quote_id;
+        $sql = "select * from vtiger_quotes where quoteid=".$quote_id;
         $result = $adb->query($sql);
         $quote_name = $adb->query_result($result,0,"subject");
 	$log->debug("Exiting getQuoteName method ...");
@@ -450,8 +450,8 @@
 }
 
 /**
- * Function to get the PriceBook Name when a pricebook id is given 
- * Takes the input as $pricebook_id - pricebook id
+ * Function to get the PriceBook Name when a vtiger_pricebook id is given 
+ * Takes the input as $pricebook_id - vtiger_pricebook id
  * returns the PriceBook Name in string format.
  */
 
@@ -461,7 +461,7 @@
 	$log->debug("Entering getPriceBookName(".$pricebookid.") method ...");
 	$log->info("in getPriceBookName ".$pricebookid);
         global $adb;
-        $sql = "select * from pricebook where pricebookid=".$pricebookid;
+        $sql = "select * from vtiger_pricebook where pricebookid=".$pricebookid;
         $result = $adb->query($sql);
         $pricebook_name = $adb->query_result($result,0,"bookname");
 	$log->debug("Exiting getPriceBookName method ...");
@@ -478,15 +478,15 @@
 	$log->debug("Entering getPoName(".$po_id.") method ...");
         $log->info("in getPoName ".$po_id);
         global $adb;
-        $sql = "select * from purchaseorder where purchaseorderid=".$po_id;
+        $sql = "select * from vtiger_purchaseorder where purchaseorderid=".$po_id;
         $result = $adb->query($sql);
         $po_name = $adb->query_result($result,0,"subject");
 	$log->debug("Exiting getPoName method ...");
         return $po_name;
 }
 /**
- * Function to get the Sales Order Name when a salesorder id is given 
- * Takes the input as $salesorder_id - salesorder id
+ * Function to get the Sales Order Name when a vtiger_salesorder id is given 
+ * Takes the input as $salesorder_id - vtiger_salesorder id
  * returns the Salesorder Name in string format.
  */
 
@@ -496,7 +496,7 @@
 	$log->debug("Entering getSoName(".$so_id.") method ...");
 	$log->info("in getSoName ".$so_id);
 	global $adb;
-        $sql = "select * from salesorder where salesorderid=".$so_id;
+        $sql = "select * from vtiger_salesorder where salesorderid=".$so_id;
         $result = $adb->query($sql);
         $so_name = $adb->query_result($result,0,"subject");
 	$log->debug("Exiting getSoName method ...");
@@ -518,47 +518,47 @@
         global $adb;
         if($module == 'Leads')
         {
-               $sql = "select leadgrouprelation.groupname,groups.groupid from leadgrouprelation inner join groups on groups.groupname=leadgrouprelation.groupname where leadgrouprelation.leadid=".$id;
+               $sql = "select vtiger_leadgrouprelation.groupname,vtiger_groups.groupid from vtiger_leadgrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_leadgrouprelation.groupname where vtiger_leadgrouprelation.leadid=".$id;
         }
         elseif($module == 'Accounts')
         {
-               $sql = "select accountgrouprelation.groupname,groups.groupid from accountgrouprelation inner join groups on groups.groupname=accountgrouprelation.groupname where accountgrouprelation.accountid=".$id;
+               $sql = "select vtiger_accountgrouprelation.groupname,vtiger_groups.groupid from vtiger_accountgrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_accountgrouprelation.groupname where vtiger_accountgrouprelation.accountid=".$id;
         }
         elseif($module == 'Contacts')
         {
-               $sql = "select contactgrouprelation.groupname,groups.groupid from contactgrouprelation inner join groups on groups.groupname=contactgrouprelation.groupname where contactgrouprelation.contactid=".$id;
+               $sql = "select vtiger_contactgrouprelation.groupname,vtiger_groups.groupid from vtiger_contactgrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname where vtiger_contactgrouprelation.contactid=".$id;
         }
 	elseif($module == 'Potentials')
         {
-               $sql = "select potentialgrouprelation.groupname,groups.groupid from potentialgrouprelation inner join groups on groups.groupname=potentialgrouprelation.groupname where potentialgrouprelation.potentialid=".$id;
+               $sql = "select vtiger_potentialgrouprelation.groupname,vtiger_groups.groupid from vtiger_potentialgrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_potentialgrouprelation.groupname where vtiger_potentialgrouprelation.potentialid=".$id;
         }
 	elseif($module == 'Quotes')
         {
-               $sql = "select quotegrouprelation.groupname,groups.groupid from quotegrouprelation inner join groups on groups.groupname=quotegrouprelation.groupname where quotegrouprelation.quoteid=".$id;
+               $sql = "select vtiger_quotegrouprelation.groupname,vtiger_groups.groupid from vtiger_quotegrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_quotegrouprelation.groupname where vtiger_quotegrouprelation.quoteid=".$id;
         }
 	elseif($module == 'SalesOrder')
         {
-               $sql = "select sogrouprelation.groupname,groups.groupid from sogrouprelation inner join groups on groups.groupname=sogrouprelation.groupname where sogrouprelation.salesorderid=".$id;
+               $sql = "select vtiger_sogrouprelation.groupname,vtiger_groups.groupid from vtiger_sogrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where vtiger_sogrouprelation.salesorderid=".$id;
         }
 	elseif($module == 'Invoice')
         {
-               $sql = "select invoicegrouprelation.groupname,groups.groupid from invoicegrouprelation inner join groups on groups.groupname=invoicegrouprelation.groupname where invoicegrouprelation.invoiceid=".$id;
+               $sql = "select vtiger_invoicegrouprelation.groupname,vtiger_groups.groupid from vtiger_invoicegrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_invoicegrouprelation.groupname where vtiger_invoicegrouprelation.invoiceid=".$id;
         }
 	elseif($module == 'PurchaseOrder')
         {
-               $sql = "select pogrouprelation.groupname,groups.groupid from pogrouprelation inner join groups on groups.groupname=pogrouprelation.groupname where pogrouprelation.purchaseorderid=".$id;
+               $sql = "select vtiger_pogrouprelation.groupname,vtiger_groups.groupid from vtiger_pogrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_pogrouprelation.groupname where vtiger_pogrouprelation.purchaseorderid=".$id;
         }
         elseif($module == 'HelpDesk')
         {
-               $sql = "select ticketgrouprelation.groupname,groups.groupid from ticketgrouprelation inner join groups on groups.groupname=ticketgrouprelation.groupname where ticketgrouprelation.ticketid=".$id;
+               $sql = "select vtiger_ticketgrouprelation.groupname,vtiger_groups.groupid from vtiger_ticketgrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_ticketgrouprelation.groupname where vtiger_ticketgrouprelation.ticketid=".$id;
         }
 	elseif($module == 'Campaigns')
 	{
-	       $sql = "select campaigngrouprelation.groupname,groups.groupid from campaigngrouprelation inner join groups on groups.groupname=campaigngrouprelation.groupname where campaigngrouprelation.campaignid=".$id;
+	       $sql = "select vtiger_campaigngrouprelation.groupname,vtiger_groups.groupid from vtiger_campaigngrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_campaigngrouprelation.groupname where vtiger_campaigngrouprelation.campaignid=".$id;
         }
         elseif($module == 'Activities' || $module == 'Emails' || $module == 'Events')
         {
-               $sql = "select activitygrouprelation.groupname,groups.groupid from activitygrouprelation inner join groups on groups.groupname=activitygrouprelation.groupname where activitygrouprelation.activityid=".$id;
+               $sql = "select vtiger_activitygrouprelation.groupname,vtiger_groups.groupid from vtiger_activitygrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_activitygrouprelation.activityid=".$id;
 	}
 	$result = $adb->query($sql);
         $group_info[] = $adb->query_result($result,0,"groupname");
@@ -584,7 +584,7 @@
 	global $adb;
 	if($userid != '')
 	{
-		$sql = "select user_name from users where id=".$userid;
+		$sql = "select user_name from vtiger_users where id=".$userid;
 		$result = $adb->query($sql);
 		$user_name = $adb->query_result($result,0,"user_name");
 	}
@@ -594,7 +594,7 @@
 
 /**
  * Creates and returns database query. To be used for search and other text links.   This method expects the module object.
- * param $focus - the module object contains the column fields
+ * param $focus - the module object contains the column vtiger_fields
  */
    
 function getURLstring($focus)
@@ -708,7 +708,7 @@
 	return $display_date;
 }
 
-/** This function returns the default currency information.
+/** This function returns the default vtiger_currency information.
   * Takes no param, return type array.
     */
     
@@ -718,7 +718,7 @@
 	global $adb;
 	$log->debug("Entering getDisplayCurrency() method ...");
         $curr_array = Array();
-        $sql1 = "select * from currency_info where currency_status='Active'";
+        $sql1 = "select * from vtiger_currency_info where currency_status='Active'";
         $result = $adb->query($sql1);
         $num_rows=$adb->num_rows($result);
         for($i=0; $i<$num_rows;$i++)
@@ -755,9 +755,9 @@
         return $amount * $crate;
 }
 
-/** This function returns the conversion rate and currency symbol
+/** This function returns the conversion rate and vtiger_currency symbol
   * in array format for a given id.
-  * param $id - currency id.
+  * param $id - vtiger_currency id.
   */
       
 function getCurrencySymbolandCRate($id)
@@ -765,7 +765,7 @@
 	global $log;
 	$log->debug("Entering getCurrencySymbolandCRate(".$id.") method ...");
         global $adb;
-        $sql1 = "select conversion_rate,currency_symbol from currency_info where id=".$id;
+        $sql1 = "select conversion_rate,currency_symbol from vtiger_currency_info where id=".$id;
         $result = $adb->query($sql1);
 	$rate_symbol['rate'] = $adb->query_result($result,0,"conversion_rate");
 	$rate_symbol['symbol'] = $adb->query_result($result,0,"currency_symbol");
@@ -782,7 +782,7 @@
 	global $log;
 	$log->debug("Entering getTermsandConditions() method ...");
         global $adb;
-        $sql1 = "select * from inventory_tandc";
+        $sql1 = "select * from vtiger_inventory_tandc";
         $result = $adb->query($sql1);
         $tandc = $adb->query_result($result,0,"tandc");
 	$log->debug("Exiting getTermsandConditions method ...");
@@ -791,10 +791,10 @@
 
 /**
  * Create select options in a dropdown list.  To be used inside
-  *  a reminder select statement in a activity form. 
+  *  a reminder select statement in a vtiger_activity form. 
    * param $start - start value
    * param $end - end value
-   * param $fldname - field name 
+   * param $fldname - vtiger_field name 
    * param $selvalue - selected value 
    */
     
@@ -821,7 +821,7 @@
 
 /** This function returns the List price of a given product in a given price book.
   * param $productid - product id.
-  * param $pbid - pricebook id.
+  * param $pbid - vtiger_pricebook id.
   */
   
 function getListPrice($productid,$pbid)
@@ -831,7 +831,7 @@
         $log->info("in getListPrice productid ".$productid);
 
 	global $adb;
-	$query = "select listprice from pricebookproductrel where pricebookid=".$pbid." and productid=".$productid;
+	$query = "select listprice from vtiger_pricebookproductrel where pricebookid=".$pbid." and productid=".$productid;
 	$result = $adb->query($query);
 	$lp = $adb->query_result($result,0,'listprice');
 	$log->debug("Exiting getListPrice method ...");
@@ -889,8 +889,8 @@
    return($ret);
 }
 /**
- * This function returns the blocks and its related information for given module.
- * Input Parameter are $module - module name, $disp_view = display view (edit,detail or create),$mode - edit, $col_fields - * column fields/
+ * This function returns the vtiger_blocks and its related information for given module.
+ * Input Parameter are $module - module name, $disp_view = display view (edit,detail or create),$mode - edit, $col_fields - * column vtiger_fields/
  * This function returns an array
  */
 
@@ -903,7 +903,7 @@
         $tabid = getTabid($module);
         $block_detail = Array();
         $getBlockinfo = "";
-        $query="select blockid,blocklabel,show_title from blocks where tabid=$tabid and $disp_view=0 and visible = 0 order by sequence";
+        $query="select blockid,blocklabel,show_title from vtiger_blocks where tabid=$tabid and $disp_view=0 and visible = 0 order by sequence";
 
         $result = $adb->query($query);
         $noofrows = $adb->num_rows($result);
@@ -918,18 +918,18 @@
 		$block_label[$blockid] = $adb->query_result($result,$i,"blocklabel");
 	}
 	$blockid_list .= ')';
-	//retreive the profileList from database
+	//retreive the vtiger_profileList from database
 	require('user_privileges/user_privileges_'.$current_user->id.'.php');
 	if($disp_view == "detail_view")
 	{
 		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
 		{
-			$sql = "select field.* from field where field.tabid=".$tabid." and field.block in $blockid_list and field.displaytype in (1,2) order by block,sequence";
+			$sql = "select vtiger_field.* from vtiger_field where vtiger_field.tabid=".$tabid." and vtiger_field.block in $blockid_list and vtiger_field.displaytype in (1,2) order by block,sequence";
 		}
 		else
 		{
 			$profileList = getCurrentUserProfileList();
-			$sql = "select field.* from field inner join profile2field on profile2field.fieldid=field.fieldid inner join def_org_field on def_org_field.fieldid=field.fieldid where field.tabid=".$tabid." and field.block in ".$blockid_list." and field.displaytype in (1,2) and profile2field.visible=0 and def_org_field.visible=0 and profile2field.profileid in ".$profileList." group by field.fieldid order by block,sequence";
+			$sql = "select vtiger_field.* from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=".$tabid." and vtiger_field.block in ".$blockid_list." and vtiger_field.displaytype in (1,2) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList." group by vtiger_field.fieldid order by block,sequence";
 		}
 		$result = $adb->query($sql);
 		$getBlockInfo=getDetailBlockInformation($module,$result,$col_fields,$tabid,$block_label);
@@ -940,24 +940,24 @@
 		{
 			if($is_admin==true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2]== 0)
 			{
-				$sql = "select field.* from field where field.tabid=".$tabid." and field.block in ".$blockid_list ." and field.displaytype=1 and info_type = '".$info_type."' order by block,sequence";
+				$sql = "select vtiger_field.* from vtiger_field where vtiger_field.tabid=".$tabid." and vtiger_field.block in ".$blockid_list ." and vtiger_field.displaytype=1 and info_type = '".$info_type."' order by block,sequence";
 			}
 			else
 			{
 				$profileList = getCurrentUserProfileList();
-				$sql = "select field.* from field inner join profile2field on profile2field.fieldid=field.fieldid inner join def_org_field on def_org_field.fieldid=field.fieldid  where field.tabid=".$tabid." and field.block in ".$blockid_list." and field.displaytype=1 and info_type = '".$info_type."' and profile2field.visible=0 and def_org_field.visible=0 and profile2field.profileid in ".$profileList.=" group by field.fieldid order by block,sequence";
+				$sql = "select vtiger_field.* from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid  where vtiger_field.tabid=".$tabid." and vtiger_field.block in ".$blockid_list." and vtiger_field.displaytype=1 and info_type = '".$info_type."' and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList.=" group by vtiger_field.fieldid order by block,sequence";
 			}
 		}
 		else
 		{
 			if($is_admin==true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
 			{
-				$sql = "select field.* from field where field.tabid=".$tabid." and field.block in ".$blockid_list." and field.displaytype=1 order by block,sequence";
+				$sql = "select vtiger_field.* from vtiger_field where vtiger_field.tabid=".$tabid." and vtiger_field.block in ".$blockid_list." and vtiger_field.displaytype=1 order by block,sequence";
 			}
 			else
 			{
 				$profileList = getCurrentUserProfileList();
-				$sql = "select field.* from field inner join profile2field on profile2field.fieldid=field.fieldid inner join def_org_field on def_org_field.fieldid=field.fieldid  where field.tabid=".$tabid." and field.block in ".$blockid_list." and field.displaytype=1 and profile2field.visible=0 and def_org_field.visible=0 and profile2field.profileid in ".$profileList.=" group by field.fieldid order by block,sequence";
+				$sql = "select vtiger_field.* from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid  where vtiger_field.tabid=".$tabid." and vtiger_field.block in ".$blockid_list." and vtiger_field.displaytype=1 and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList.=" group by vtiger_field.fieldid order by block,sequence";
 			}
 		}
 		$result = $adb->query($sql);
@@ -995,7 +995,7 @@
 	$log->debug("Entering getBlockId(".$tabid.",".$label.") method ...");
         global $adb;
         $blockid = '';
-        $query = "select blockid from blocks where tabid=$tabid and blocklabel = '$label'";
+        $query = "select blockid from vtiger_blocks where tabid=$tabid and blocklabel = '$label'";
         $result = $adb->query($query);
         $noofrows = $adb->num_rows($result);
         if($noofrows == 1)
@@ -1007,8 +1007,8 @@
 }
 
 /**
- * This function is used to get the Parent and Child tab relation array.
- * Takes no parameter and get the data from parent_tabdata.php and tabdata.php
+ * This function is used to get the Parent and Child vtiger_tab relation array.
+ * Takes no parameter and get the data from parent_tabdata.php and vtiger_tabdata.php
  * This returns array type value
  */
 
@@ -1059,8 +1059,8 @@
 }
 
 /**
- * This function is used to get the Parent Tab name for a given parent tab id.
- * Takes the input parameter as $parenttabid - Parent tab id
+ * This function is used to get the Parent Tab name for a given parent vtiger_tab id.
+ * Takes the input parameter as $parenttabid - Parent vtiger_tab id
  * This returns value string type 
  */
 
@@ -1076,7 +1076,7 @@
 	}
 	else
 	{
-		$sql = "select parenttab_label from parenttab where parenttabid=".$parenttabid;
+		$sql = "select parenttab_label from vtiger_parenttab where parenttabid=".$parenttabid;
 		$result = $adb->query($sql);
 		$parent_tabname=  $adb->query_result($result,0,"parenttab_label");
 	}
@@ -1113,7 +1113,7 @@
 	}
 	else
 	{
-		$sql = "select parenttab.* from parenttab inner join parenttabrel on parenttabrel.parenttabid=parenttab.parenttabid inner join tab on tab.tabid=parenttabrel.tabid where tab.name='".$module."'";
+		$sql = "select vtiger_parenttab.* from vtiger_parenttab inner join vtiger_parenttabrel on vtiger_parenttabrel.parenttabid=vtiger_parenttab.parenttabid inner join vtiger_tab on vtiger_tab.tabid=vtiger_parenttabrel.tabid where vtiger_tab.name='".$module."'";
 		$result = $adb->query($sql);
 		$tab =  $adb->query_result($result,0,"parenttab_label");
 		$log->debug("Exiting getParentTabFromModule method ...");
@@ -1123,7 +1123,7 @@
 
 /**
  * This function is used to get the Parent Tab name for a given module.
- * Takes no parameter but gets the parenttab value from form request
+ * Takes no parameter but gets the vtiger_parenttab value from form request
  * This returns value string type 
  */
 
@@ -1146,7 +1146,7 @@
 /**
  * This function is used to get the days in between the current time and the modified time of an entity .
  * Takes the input parameter as $id - crmid  it will calculate the number of days in between the
- * the current time and the modified time from the crmentity table and return the result as a string.
+ * the current time and the modified time from the vtiger_crmentity vtiger_table and return the result as a string.
  * The return format is updated <No of Days> day ago <(date when updated)>
  */
 
@@ -1157,7 +1157,7 @@
 
     global $adb;
     global $app_strings;
-    $query='select modifiedtime from crmentity where crmid ='.$id ;
+    $query='select modifiedtime from vtiger_crmentity where crmid ='.$id ;
     $result = $adb->query($query);
     $modifiedtime = $adb->query_result($result,0,'modifiedtime');
     $values=explode(' ',$modifiedtime);
@@ -1194,7 +1194,7 @@
 	$script_images=array();
 	$script = '<script>var ProductImages = new Array(';
    	$i=0;
-	$query='select imagename from products where productid='.$id;
+	$query='select imagename from vtiger_products where productid='.$id;
 	$result = $adb->query($query);
 	$imagename=$adb->query_result($result,0,'imagename');
 	$image_lists=explode('###',$imagename);
@@ -1381,7 +1381,7 @@
 
 /**
  * This function is used get the User Count.
- * It returns the array which has the total users ,admin users,and the non admin users 
+ * It returns the array which has the total vtiger_users ,admin vtiger_users,and the non admin vtiger_users 
  */
 
 function UserCount()
@@ -1389,9 +1389,9 @@
 	global $log;
 	$log->debug("Entering UserCount() method ...");
 	global $adb;
-	$result=$adb->query("select * from users where deleted =0;");
+	$result=$adb->query("select * from vtiger_users where deleted =0;");
 	$user_count=$adb->num_rows($result);
-	$result=$adb->query("select * from users where deleted =0 AND is_admin != 'on';");
+	$result=$adb->query("select * from vtiger_users where deleted =0 AND is_admin != 'on';");
 	$nonadmin_count = $adb->num_rows($result);
 	$admin_count = $user_count-$nonadmin_count;
 	$count=array('user'=>$user_count,'admin'=>$admin_count,'nonadmin'=>$nonadmin_count);
@@ -1435,7 +1435,7 @@
 		$log->debug("Entering DefHomeView() method ...");
 		global $adb;
 		global $current_user;
-		$query="select defhomeview from users where id = ".$current_user->id;
+		$query="select defhomeview from vtiger_users where id = ".$current_user->id;
 		$result=$adb->query($query);
 		$defaultview=$adb->query_result($result,0,'defhomeview');
 		$log->debug("Exiting DefHomeView method ...");
@@ -1472,7 +1472,7 @@
 }
 
  /**
- * Function to write the tabid and name to a flat file tabdata.txt so that the data
+ * Function to write the tabid and name to a flat file vtiger_tabdata.txt so that the data
  * is obtained from the file instead of repeated queries
  * returns null
  */
@@ -1481,9 +1481,9 @@
 {
 	global $log;
 	$log->debug("Entering create_tab_data_file() method ...");
-        $log->info("creating tabdata file");
+        $log->info("creating vtiger_tabdata file");
         global $adb;
-        $sql = "select * from tab";
+        $sql = "select * from vtiger_tab";
         $result = $adb->query($sql);
         $num_rows=$adb->num_rows($result);
         $result_array=Array();
@@ -1540,7 +1540,7 @@
 
 
  /**
- * Function to write the parenttabid and name to a flat file parent_tabdata.txt so that the data
+ * Function to write the vtiger_parenttabid and name to a flat file parent_tabdata.txt so that the data
  * is obtained from the file instead of repeated queries
  * returns null
  */
@@ -1551,7 +1551,7 @@
 	$log->debug("Entering create_parenttab_data_file() method ...");
 	$log->info("creating parent_tabdata file");
 	global $adb;
-	$sql = "select parenttabid,parenttab_label from parenttab order by sequence";
+	$sql = "select parenttabid,parenttab_label from vtiger_parenttab order by sequence";
 	$result = $adb->query($sql);
 	$num_rows=$adb->num_rows($result);
 	$result_array=Array();
@@ -1591,7 +1591,7 @@
 			foreach($result_array as $parid=>$parvalue)
 			{
 				$childArray=Array();
-				$sql = "select * from parenttabrel where parenttabid=".$parid." order by sequence";
+				$sql = "select * from vtiger_parenttabrel where parenttabid=".$parid." order by sequence";
 				$result = $adb->query($sql);
 				$num_rows=$adb->num_rows($result);
 				$result_array=Array();
@@ -1654,7 +1654,7 @@
 			 'Contacts'=>'LNK_NEW_CONTACT',
 			 'Vendors'=>'LNK_NEW_VENDOR'); 	
 
-$qc_query = "select distinct tab.tablabel,tab.name from field inner join tab on tab.tabid = field.tabid where quickcreate=0 order by tab.tablabel";
+$qc_query = "select distinct vtiger_tab.tablabel,vtiger_tab.name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where quickcreate=0 order by vtiger_tab.tablabel";
 $result = $adb->query($qc_query);
 $noofrows = $adb->num_rows($result);
 $return_qcmodule = Array();
@@ -1680,7 +1680,7 @@
 }
 																					   
 /**
- * This function is used to get the Quick create form field parameters for a given module.
+ * This function is used to get the Quick create form vtiger_field parameters for a given module.
  * Param $module - module name 
  * returns the value in array format
  */
@@ -1700,12 +1700,12 @@
 require('user_privileges/user_privileges_'.$current_user->id.'.php');
            if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
            {
-                 $quickcreate_query = "select * from field where quickcreate=0 and tabid = ".$tabid." order by quickcreatesequence";
+                 $quickcreate_query = "select * from vtiger_field where quickcreate=0 and tabid = ".$tabid." order by quickcreatesequence";
            }
            else
            {
                  $profileList = getCurrentUserProfileList();
-                 $quickcreate_query = "select field.* from field inner join profile2field on profile2field.fieldid=field.fieldid inner join def_org_field on def_org_field.fieldid=field.fieldid where field.tabid=".$tabid." and quickcreate=0 and profile2field.visible=0 and def_org_field.visible=0  and profile2field.profileid in ".$profileList." order by quickcreatesequence";
+                 $quickcreate_query = "select vtiger_field.* from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=".$tabid." and quickcreate=0 and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0  and vtiger_profile2field.profileid in ".$profileList." order by quickcreatesequence";
            }
 																					     
 $category = getParentTab();
@@ -1830,7 +1830,7 @@
 	global $log;
 	$log->debug("Entering getUserslist() method ...");
 	global $adb;
-	$result=$adb->query("select * from users");
+	$result=$adb->query("select * from vtiger_users");
 	for($i=0;$i<$adb->num_rows($result);$i++)
 	{
 	       $useridlist[$i]=$adb->query_result($result,$i,'id');
@@ -1883,7 +1883,7 @@
 		
 	switch ($module)
 	{
-		case "Accounts" : $query = "select accountname from account where accountid in (".$list.")";
+		case "Accounts" : $query = "select accountname from vtiger_account where accountid in (".$list.")";
 				  $result = $adb->query($query);
 				  $numrows = $adb->num_rows($result);
 				  $account_name = array();	
@@ -1895,7 +1895,7 @@
 					return $account_name;
 					break;
 
-		  case "Leads" :  $query = "select concat(firstname,' ',lastname) as leadname from leaddetails where leadid in (".$list.")";
+		  case "Leads" :  $query = "select concat(firstname,' ',lastname) as leadname from vtiger_leaddetails where leadid in (".$list.")";
 				  $result = $adb->query($query);
 				  $numrows = $adb->num_rows($result);
 				  $lead_name = array();
@@ -1908,7 +1908,7 @@
 					return $lead_name;
 					break;
 		
-	       case "Contacts" : $query = "select concat(firstname,' ',lastname) as contactname from contactdetails where contactid in (".$list.")"; 
+	       case "Contacts" : $query = "select concat(firstname,' ',lastname) as contactname from vtiger_contactdetails where contactid in (".$list.")"; 
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $contact_name = array();
@@ -1921,7 +1921,7 @@
 					return $contact_name;
 					break;
 
-	    case "Potentials"  : $query = "select potentialname from potential where potentialid in (".$list.")";
+	    case "Potentials"  : $query = "select potentialname from vtiger_potential where potentialid in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $potential_name = array();
@@ -1934,7 +1934,7 @@
 					return $potential_name;
 					break;
 
-	        case "Quotes"  : $query = "select subject from quotes where quoteid in (".$list.")";
+	        case "Quotes"  : $query = "select subject from vtiger_quotes where quoteid in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $quote_subject = array();		    	
@@ -1947,7 +1947,7 @@
 					return $quote_subject;
 					break;	
 
-	    case "SalesOrder"  : $query = "select subject from salesorder where salesorderid in (".$list.")";
+	    case "SalesOrder"  : $query = "select subject from vtiger_salesorder where salesorderid in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $so_subject = array();		    	
@@ -1960,7 +1960,7 @@
 					return $so_subject;
 					break;
 	
-	       case "Invoice"  : $query = "select subject from invoice where invoiceid in (".$list.")";
+	       case "Invoice"  : $query = "select subject from vtiger_invoice where invoiceid in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $inv_subject = array();		    	
@@ -1973,7 +1973,7 @@
 					return $inv_subject;
 					break;
 		
-	      case "Products"  : $query = "select productname from products where productid in (".$list.")";
+	      case "Products"  : $query = "select productname from vtiger_products where productid in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $product_name = array();		    	
@@ -1986,7 +1986,7 @@
 					return $product_name;
 					break;
 
-	   case "PriceBooks"  :  $query = "select bookname from pricebook where pricebookid in (".$list.")";
+	   case "PriceBooks"  :  $query = "select bookname from vtiger_pricebook where pricebookid in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $pbook_name = array();		    	
@@ -1999,7 +1999,7 @@
 					return $pbook_name;
 					break;
 
-	        case "Notes"  :  $query = "select title from notes where notesid in (".$list.")";
+	        case "Notes"  :  $query = "select title from vtiger_notes where notesid in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $notes_title = array();		    	
@@ -2012,7 +2012,7 @@
 					return $notes_title;
 					break;
 		
-	  case "Activities"  :  $query = "select subject from activity where activityid in (".$list.")";
+	  case "Activities"  :  $query = "select subject from vtiger_activity where activityid in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $activity_subject = array();		    	
@@ -2025,7 +2025,7 @@
 					return $activity_subject;
 					break;
 
-	    case "Campaigns"  :  $query = "select campaignname from campaign where campaignid in (".$list.")";
+	    case "Campaigns"  :  $query = "select campaignname from vtiger_campaign where campaignid in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $campaign_name = array();		    	
@@ -2038,7 +2038,7 @@
 					return $campaign_name;
 					break;
 
-	          case "Faq"  :  $query = "select question from faq where id in (".$list.")";
+	          case "Faq"  :  $query = "select question from vtiger_faq where id in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $faq_name = array();		    	
@@ -2051,7 +2051,7 @@
 					return $faq_name;
 					break;
 		
-	      case "Vendors"  :  $query = "select vendorname from vendor where vendorid in (".$list.")";
+	      case "Vendors"  :  $query = "select vendorname from vtiger_vendor where vendorid in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $vendor_name = array();		    	
@@ -2064,7 +2064,7 @@
 					return $vendor_name;
 					break;
 
-	case "PurchaseOrder"  :  $query = "select subject from purchaseorder where purchaseorderid in (".$list.")";
+	case "PurchaseOrder"  :  $query = "select subject from vtiger_purchaseorder where purchaseorderid in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $po_name = array();		    	
@@ -2077,7 +2077,7 @@
 					return $po_name;
 					break;
 
-	     case "HelpDesk"  :  $query = "select title from troubletickets where ticketid in (".$list.")";
+	     case "HelpDesk"  :  $query = "select title from vtiger_troubletickets where ticketid in (".$list.")";
 				 $result = $adb->query($query);
 				 $numrows = $adb->num_rows($result);
 				 $ticket_name = array();		    	
@@ -2099,7 +2099,7 @@
         global $adb;
 	global $current_user;
         $resultant_array = Array();
-        $query = 'select name,tablabel,parenttab_label,tab.tabid from parenttabrel inner join tab on parenttabrel.tabid = tab.tabid inner join parenttab on parenttabrel.parenttabid = parenttab.parenttabid order by parenttab.sequence';
+        $query = 'select name,tablabel,parenttab_label,vtiger_tab.tabid from vtiger_parenttabrel inner join vtiger_tab on vtiger_parenttabrel.tabid = vtiger_tab.tabid inner join vtiger_parenttab on vtiger_parenttabrel.parenttabid = vtiger_parenttab.parenttabid order by vtiger_parenttab.sequence';
         $result = $adb->query($query);
 	require('user_privileges/user_privileges_'.$current_user->id.'.php');
         for($i=0;$i<$adb->num_rows($result);$i++)
@@ -2179,7 +2179,7 @@
 }
 
 /**
- * 	This function is used to get the Path in where we store the files based on the module.
+ * 	This function is used to get the Path in where we store the vtiger_files based on the module.
  *	@param string $module   - module name
  * 	return string $storage_path - path inwhere the file will be uploaded (also where it was stored) will be return based on the module
 */
@@ -2205,7 +2205,7 @@
 
 /**
  * 	This function is used to check whether the attached file is a image file or not
- *	@param string $file_details  - files array which contains all the uploaded file details
+ *	@param string $file_details  - vtiger_files array which contains all the uploaded file details
  * 	return string $save_image - true or false. if the image can be uploaded then true will return otherwise false.
 */
 function validateImageFile($file_details)
@@ -2243,7 +2243,7 @@
         global $adb,$log;
         $log->debug("Entering into getTemplateDetails($templateid) method ...");
         $returndata =  Array();
-        $result = $adb->query("select * from emailtemplates where templateid=$templateid");
+        $result = $adb->query("select * from vtiger_emailtemplates where templateid=$templateid");
         $returndata[] = $templateid;
         $returndata[] = $adb->query_result($result,0,'body');
         $returndata[] = $adb->query_result($result,0,'subject');
@@ -2278,7 +2278,7 @@
 			if(is_array($fields["accounts"]))
 			{
 				$columnfields = implode(',',$fields["accounts"]);
-				$query = 'select '.$columnfields.' from account where accountid ='.$id;
+				$query = 'select '.$columnfields.' from vtiger_account where accountid ='.$id;
 				$result = $adb->query($query);
 				foreach($fields["accounts"] as $columnname)			
 				{

Modified: vtigercrm/trunk/include/utils/DeleteUtils.php
==============================================================================
--- vtigercrm/trunk/include/utils/DeleteUtils.php (original)
+++ vtigercrm/trunk/include/utils/DeleteUtils.php Mon Jun 12 14:26:25 2006
@@ -24,73 +24,73 @@
 	case Accounts:
 		if($return_id!='')
 		{
-			$sql ='delete from seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
+			$sql ='delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
 			$adb->query($sql);
 		}
 	break;
 	case Activities:
 		if($return_module == 'Contacts')
 		{
-			$sql = 'delete from cntactivityrel where contactid = '.$return_id.' and activityid = '.$record;
+			$sql = 'delete from vtiger_cntactivityrel where contactid = '.$return_id.' and activityid = '.$record;
 			$adb->query($sql);
 		}
 		else
 		{
-			$sql= 'delete from seactivityrel where activityid='.$record;
+			$sql= 'delete from vtiger_seactivityrel where activityid='.$record;
 			$adb->query($sql);
 		}
 
 		if($return_module == 'HelpDesk')
 		{
-			$sql = 'delete from seticketsrel where ticketid = '.$return_id.' and crmid = '.$record;
-			$adb->query($sql);
-		}
-		$sql = 'delete from activity_reminder where activity_id='.$record;
+			$sql = 'delete from vtiger_seticketsrel where ticketid = '.$return_id.' and crmid = '.$record;
+			$adb->query($sql);
+		}
+		$sql = 'delete from vtiger_activity_reminder where activity_id='.$record;
  		$adb->query($sql);
 
- 		$sql = 'delete  from recurringevents where activityid='.$record;
+ 		$sql = 'delete  from vtiger_recurringevents where activityid='.$record;
  		$adb->query($sql);
 	break;
 	case Contacts:
 		if($return_module == 'Accounts')
 		{
-			$sql = 'update crmentity set deleted = 1 where crmid = '.$record;
+			$sql = 'update vtiger_crmentity set deleted = 1 where crmid = '.$record;
 			$adb->query($sql);
 		}
 		if($return_module == 'Potentials' && $record != '' && $return_id != '')
 		{
-			$sql = 'delete from contpotentialrel where contactid='.$record.' and potentialid='.$return_id;
+			$sql = 'delete from vtiger_contpotentialrel where contactid='.$record.' and potentialid='.$return_id;
 			$adb->query($sql);
 		}
 		if($record != '' && $return_id != '')
 		{
-			$sql = 'delete from seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
-			$adb->query($sql);
-			$sql_recentviewed ='delete from tracker where user_id = '.$current_user->id.' and item_id = '.$record;
+			$sql = 'delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
+			$adb->query($sql);
+			$sql_recentviewed ='delete from vtiger_tracker where user_id = '.$current_user->id.' and item_id = '.$record;
 			$adb->query($sql_recentviewed);
 		}
 		if($return_module == 'Products')
 		{
-			$sql = 'delete from vendorcontactrel where contactid='.$record.' and vendorid='.$return_id;
+			$sql = 'delete from vtiger_vendorcontactrel where contactid='.$record.' and vendorid='.$return_id;
 			$adb->query($sql);
 		}
 	break;
 	case Emails:
-		$sql='delete from seactivityrel where activityid='.$adb->quote($record);
+		$sql='delete from vtiger_seactivityrel where activityid='.$adb->quote($record);
 		$adb->query($sql);
 	break;
 	case HelpDesk:
 		if($return_module == 'Contacts' || $return_module == 'Accounts')
 		{
-			$sql = "update troubletickets set parent_id='' where ticketid=".$record;
-			$adb->query($sql);
-			$se_sql= 'delete from seticketsrel where ticketid='.$record;
+			$sql = "update vtiger_troubletickets set parent_id='' where ticketid=".$record;
+			$adb->query($sql);
+			$se_sql= 'delete from vtiger_seticketsrel where ticketid='.$record;
 			$adb->query($se_sql);
 
 		}
 		if($return_module == 'Products')
 		{
-			$sql = "update troubletickets set product_id='' where ticketid=".$record;
+			$sql = "update vtiger_troubletickets set product_id='' where ticketid=".$record;
 			$adb->query($sql);
 		}
 	break;
@@ -101,13 +101,13 @@
 		}
 		elseif($return_module=="SalesOrder")
 		{
-			$relation_query = "UPDATE invoice set salesorderid='' where invoiceid=".$record;
+			$relation_query = "UPDATE vtiger_invoice set salesorderid='' where invoiceid=".$record;
 			$adb->query($relation_query);
 		}
 		elseif($return_module=="Products")
 		{
-			//Removing the relation from the quotes product rel
-			$inv_query = "select * from invoiceproductrel where productid=".$return_id;
+			//Removing the relation from the vtiger_quotes product rel
+			$inv_query = "select * from vtiger_invoiceproductrel where productid=".$return_id;
 			$result = $adb->query($inv_query);
 			$num_rows = $adb->num_rows($result);
 			for($i=0; $i< $num_rows; $i++)
@@ -120,48 +120,48 @@
 				//Get the current sub total from Quotes and update it with the new subtotal
 				updateSubTotal("Invoices","invoice","subtotal","total","invoiceid",$invoice_id,$prod_total);
 			}
-			//delete the relation from quotes product rel
-			$del_query = "delete from invoiceproductrel where productid=".$return_id." and invoiceid=".$record;
+			//delete the relation from vtiger_quotes product rel
+			$del_query = "delete from vtiger_invoiceproductrel where productid=".$return_id." and invoiceid=".$record;
 			$adb->query($del_query);
 		}
 	break;
 	case Leads:
-		$sql = 'delete from seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
+		$sql = 'delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
 		$adb->query($sql);
 	break;
 	case Notes:
 		if($return_module== 'Contacts')
 		{
-			$sql = 'update notes set contact_id = 0 where notesid = '.$record;
-			$adb->query($sql);
-		}
-		$sql = 'delete from senotesrel where notesid = '.$record. ' and crmid = '.$return_id;
+			$sql = 'update vtiger_notes set contact_id = 0 where notesid = '.$record;
+			$adb->query($sql);
+		}
+		$sql = 'delete from vtiger_senotesrel where notesid = '.$record. ' and crmid = '.$return_id;
 		$adb->query($sql);
 
 	break;
 	case Potentials:
 		if($return_module == 'Accounts')
 		{
-			$sql = 'update crmentity set deleted = 1 where crmid = '.$record;
-			$adb->query($sql);
-		}
-		$sql ='delete from seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
+			$sql = 'update vtiger_crmentity set deleted = 1 where crmid = '.$record;
+			$adb->query($sql);
+		}
+		$sql ='delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
 		$adb->query($sql);
 	break;
 	case Products:
 		if($record != '' && $return_id != '')
 		{
 			if($return_module == 'Activities')
-				$sql = 'delete from seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
+				$sql = 'delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
 
 			if($return_module == 'Potentials' || $return_module == 'Accounts' || $return_module == 'Leads')
-				$sql = 'delete from seproductsrel where crmid = '.$return_id.' and productid = '.$record;
+				$sql = 'delete from vtiger_seproductsrel where crmid = '.$return_id.' and productid = '.$record;
 
 			$adb->query($sql);
 		}
 		if($return_module == "Contacts")
 		{
-			$sql = "UPDATE products set contactid = '' where productid = ".$record;
+			$sql = "UPDATE vtiger_products set contactid = '' where productid = ".$record;
 			$adb->query($sql);
 		}
 	break;
@@ -173,13 +173,13 @@
 		}
 		elseif($return_module == "Vendors")
 		{
-			$sql_req ='DELETE from purchaseorder where purchaseorderid= '.$record;
+			$sql_req ='DELETE from vtiger_purchaseorder where purchaseorderid= '.$record;
 			$adb->query($sql_req);
 		}
 		elseif($return_module == "Products")
 		{
 			//Removing the relation from the po product rel
-			$po_query = "select * from poproductrel where productid=".$return_id;
+			$po_query = "select * from vtiger_poproductrel where productid=".$return_id;
 			$result = $adb->query($po_query);
 			$num_rows = $adb->num_rows($result);
 			for($i=0; $i< $num_rows; $i++)
@@ -192,13 +192,13 @@
 				updateSubTotal("PurchaseOrder","purchaseorder","subtotal","total","purchaseorderid",$po_id,$prod_total);
 			}
 			//delete the relation from po product rel
-			$del_query = "delete from poproductrel where productid=".$return_id." and purchaseorderid=".$record;
+			$del_query = "delete from vtiger_poproductrel where productid=".$return_id." and purchaseorderid=".$record;
 			$adb->query($del_query);
 
 		}
 		elseif($return_module == "Contacts")
 		{
-			$sql_req ='UPDATE purchaseorder set contactid="" where purchaseorderid = '.$record;
+			$sql_req ='UPDATE vtiger_purchaseorder set contactid="" where purchaseorderid = '.$record;
 			$adb->query($sql_req);
 		}
 	break;
@@ -209,18 +209,18 @@
 		}
 		elseif($return_module == "Potentials")
 		{
-			$relation_query = "UPDATE quotes set potentialid='' where quoteid=".$record;
+			$relation_query = "UPDATE vtiger_quotes set potentialid='' where quoteid=".$record;
 			$adb->query($relation_query);
 		}
 		elseif($return_module == "Contacts")
 		{
-			$relation_query = "UPDATE quotes set contactid='' where quoteid=".$record;
+			$relation_query = "UPDATE vtiger_quotes set contactid='' where quoteid=".$record;
 			$adb->query($relation_query);
 		}
 		elseif($return_module == "Products")
 		{
-			//Removing the relation from the quotes product rel
-			$qt_query = "select * from quotesproductrel where productid=".$return_id;
+			//Removing the relation from the vtiger_quotes product rel
+			$qt_query = "select * from vtiger_quotesproductrel where productid=".$return_id;
 			$result = $adb->query($qt_query);
 			$num_rows = $adb->num_rows($result);
 			for($i=0; $i< $num_rows; $i++)
@@ -233,8 +233,8 @@
 				//Get the current sub total from Quotes and update it with the new subtotal
 				updateSubTotal("Quotes","quotes","subtotal","total","quoteid",$quote_id,$prod_total);
 			}
-			//delete the relation from quotes product rel
-			$del_query = "delete from quotesproductrel where productid=".$return_id." and quoteid=".$record;
+			//delete the relation from vtiger_quotes product rel
+			$del_query = "delete from vtiger_quotesproductrel where productid=".$return_id." and quoteid=".$record;
 			$adb->query($del_query);
 
 		}
@@ -245,23 +245,23 @@
 		}
 		elseif($return_module == "Quotes")
 		{
-			$relation_query = "UPDATE salesorder set quoteid='' where salesorderid=".$record;
+			$relation_query = "UPDATE vtiger_salesorder set quoteid='' where salesorderid=".$record;
 			$adb->query($relation_query);
 		}
 		elseif($return_module == "Potentials")
 		{
-			$relation_query = "UPDATE salesorder set potentialid='' where salesorderid=".$record;
+			$relation_query = "UPDATE vtiger_salesorder set potentialid='' where salesorderid=".$record;
 			$adb->query($relation_query);
 		}
 		elseif($return_module == "Contacts")
 		{
-			$relation_query = "UPDATE salesorder set contactid='' where salesorderid=".$record;
+			$relation_query = "UPDATE vtiger_salesorder set contactid='' where salesorderid=".$record;
 			$adb->query($relation_query);
 		}
 		elseif($return_module == "Products")
 		{
 			//Removing the relation from the so product rel
-			$so_query = "select * from soproductrel where productid=".$return_id;
+			$so_query = "select * from vtiger_soproductrel where productid=".$return_id;
 			$result = $adb->query($so_query);
 			$num_rows = $adb->num_rows($result);
 			for($i=0; $i< $num_rows; $i++)
@@ -275,17 +275,17 @@
 				updateSubTotal("SalesOrder","salesorder","subtotal","total","salesorderid",$so_id,$prod_total);
 			}
 			//delete the relation from so product rel
-			$del_query = "delete from soproductrel where productid=".$return_id." and salesorderid=".$record;
+			$del_query = "delete from vtiger_soproductrel where productid=".$return_id." and salesorderid=".$record;
 			$adb->query($del_query);
 
 		}
 	break;
 		case Rss:
-			$del_query = "delete from rss where rssid=".$record;
+			$del_query = "delete from vtiger_rss where rssid=".$record;
 			$adb->query($del_query);
 	break;
 		case Portal:
-			$del_query = "delete from portal where portalid=".$record;
+			$del_query = "delete from vtiger_portal where portalid=".$record;
 			$adb->query($del_query);
 	break;
 	endswitch;
@@ -300,7 +300,7 @@
 	}
 	if($module != 'Faq')
 	{	
-		$sql_recentviewed ='delete from tracker where user_id = '.$current_user->id.' and item_id = '.$record;
+		$sql_recentviewed ='delete from vtiger_tracker where user_id = '.$current_user->id.' and item_id = '.$record;
         	$adb->query($sql_recentviewed);
 	}
 	$log->debug("Entering DeleteEntity method ...");

Modified: vtigercrm/trunk/include/utils/DetailViewUtils.php
==============================================================================
--- vtigercrm/trunk/include/utils/DetailViewUtils.php (original)
+++ vtigercrm/trunk/include/utils/DetailViewUtils.php Mon Jun 12 14:26:25 2006
@@ -25,13 +25,13 @@
 require_once('include/utils/CommonUtils.php'); //new
 
 
-/** This function returns the detail view form field and and its properties in array format.
-  * Param $uitype - UI type of the field
-  * Param $fieldname - Form field name
-  * Param $fieldlabel - Form field label name
-  * Param $col_fields - array contains the fieldname and values
+/** This function returns the detail view form vtiger_field and and its properties in array format.
+  * Param $uitype - UI type of the vtiger_field
+  * Param $fieldname - Form vtiger_field name
+  * Param $fieldlabel - Form vtiger_field label name
+  * Param $col_fields - array contains the vtiger_fieldname and values
   * Param $generatedtype - Field generated type (default is 1)
-  * Param $tabid - tab id to which the Field belongs to (default is "")
+  * Param $tabid - vtiger_tab id to which the Field belongs to (default is "")
   * Return type is an array
   */
 
@@ -67,7 +67,7 @@
 	     $label_fld[] = $mod_strings[$fieldlabel];
 	     $label_fld[] = $col_fields[$fieldname];
 	     
-		$pick_query="select * from ".$fieldname;
+		$pick_query="select * from vtiger_".$fieldname;
 		$pickListResult = $adb->query($pick_query);
 		$noofpickrows = $adb->num_rows($pickListResult);
 
@@ -260,7 +260,7 @@
         {
 		if($tabid == 4)
            {
-                   $query="select contactdetails.imagename from contactdetails where contactid=".$col_fields['record_id'];
+                   $query="select vtiger_contactdetails.imagename from vtiger_contactdetails where contactid=".$col_fields['record_id'];
                    $result = $adb->query($query);
                    $imagename=$adb->query_result($result,0,'imagename');
                    if($imagename != '')
@@ -333,10 +333,10 @@
         {
                 global $adb;
 
-                $attachmentid=$adb->query_result($adb->query("select * from seattachmentsrel where crmid = ".$col_fields['record_id']),0,'attachmentsid');
+                $attachmentid=$adb->query_result($adb->query("select * from vtiger_seattachmentsrel where crmid = ".$col_fields['record_id']),0,'attachmentsid');
 		if($col_fields[$fieldname] == '' && $attachmentid != '')
 		{
-				$attachquery = "select * from attachments where attachmentsid=".$attachmentid;
+				$attachquery = "select * from vtiger_attachments where attachmentsid=".$attachmentid;
         		        $col_fields[$fieldname] = $adb->query_result($adb->query($attachquery),0,'name');
 		}
 
@@ -356,7 +356,7 @@
 		if($tabid==14)
 		{
 			$images=array();
-			$query = 'select productname,attachments.path,attachments.name from products left join seattachmentsrel on seattachmentsrel.crmid=products.productid inner join attachments on attachments.attachmentsid=seattachmentsrel.attachmentsid where productid='.$col_fields['record_id'];
+			$query = 'select productname,vtiger_attachments.path,vtiger_attachments.name from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where productid='.$col_fields['record_id'];
 			$result_image = $adb->query($query);
 			for($image_iter=0;$image_iter < $adb->num_rows($result_image);$image_iter++)	
 			{
@@ -405,7 +405,7 @@
 			if($parent_module == "Leads")
 			{
 				$label_fld[] =$app_strings['LBL_LEAD_NAME'];
-				$sql = "select * from leaddetails where leadid=".$value;
+				$sql = "select * from vtiger_leaddetails where leadid=".$value;
 				$result = $adb->query($sql);
 				$first_name = $adb->query_result($result,0,"firstname");
 				$last_name = $adb->query_result($result,0,"lastname");
@@ -415,7 +415,7 @@
 			elseif($parent_module == "Accounts")
 			{
 				$label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
-				$sql = "select * from  account where accountid=".$value;
+				$sql = "select * from  vtiger_account where accountid=".$value;
 				$result = $adb->query($sql);
 				$account_name = $adb->query_result($result,0,"accountname");
 
@@ -424,7 +424,7 @@
 			elseif($parent_module == "Potentials")
 			{
 				$label_fld[] =$app_strings['LBL_POTENTIAL_NAME'];
-				$sql = "select * from  potential where potentialid=".$value;
+				$sql = "select * from  vtiger_potential where potentialid=".$value;
 				$result = $adb->query($sql);
 				$potentialname = $adb->query_result($result,0,"potentialname");
 
@@ -433,7 +433,7 @@
 			elseif($parent_module == "Products")
 			{
 				$label_fld[] =$app_strings['LBL_PRODUCT_NAME'];
-				$sql = "select * from  products where productid=".$value;
+				$sql = "select * from  vtiger_products where productid=".$value;
 				$result = $adb->query($sql);
 				$productname= $adb->query_result($result,0,"productname");
 
@@ -442,7 +442,7 @@
 			elseif($parent_module == "PurchaseOrder")
 			{
 				$label_fld[] =$app_strings['LBL_PORDER_NAME'];
-				$sql = "select * from  purchaseorder where purchaseorderid=".$value;
+				$sql = "select * from  vtiger_purchaseorder where purchaseorderid=".$value;
 				$result = $adb->query($sql);
 				$pordername= $adb->query_result($result,0,"subject");
 
@@ -451,7 +451,7 @@
 			elseif($parent_module == "SalesOrder")
 			{
 				$label_fld[] = $app_strings['LBL_SORDER_NAME'];
-				$sql = "select * from  salesorder where salesorderid=".$value;
+				$sql = "select * from  vtiger_salesorder where salesorderid=".$value;
 				$result = $adb->query($sql);
 				$sordername= $adb->query_result($result,0,"subject");
 
@@ -460,7 +460,7 @@
 			elseif($parent_module == "Invoice")
 			{
 				$label_fld[] = $app_strings['LBL_INVOICE_NAME'];
-				$sql = "select * from  invoice where invoiceid=".$value;
+				$sql = "select * from  vtiger_invoice where invoiceid=".$value;
 				$result = $adb->query($sql);
 				$invoicename= $adb->query_result($result,0,"subject");
 
@@ -484,7 +484,7 @@
 			if($parent_module == "Leads")
 			{
 				$label_fld[] =$app_strings['LBL_LEAD_NAME'];
-				$sql = "select * from leaddetails where leadid=".$value;
+				$sql = "select * from vtiger_leaddetails where leadid=".$value;
 				$result = $adb->query($sql);
 				$first_name = $adb->query_result($result,0,"firstname");
 				$last_name = $adb->query_result($result,0,"lastname");
@@ -494,7 +494,7 @@
 			elseif($parent_module == "Accounts")
 			{
 				$label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
-				$sql = "select * from  account where accountid=".$value;
+				$sql = "select * from  vtiger_account where accountid=".$value;
 				$result = $adb->query($sql);
 				$account_name = $adb->query_result($result,0,"accountname");
 
@@ -503,7 +503,7 @@
 			elseif($parent_module == "Potentials")
 			{
 				$label_fld[] =$app_strings['LBL_POTENTIAL_NAME'];
-				$sql = "select * from  potential where potentialid=".$value;
+				$sql = "select * from  vtiger_potential where potentialid=".$value;
 				$result = $adb->query($sql);
 				$potentialname = $adb->query_result($result,0,"potentialname");
 
@@ -512,7 +512,7 @@
 			elseif($parent_module == "Quotes")
                         {
 				$label_fld[] =$app_strings['LBL_QUOTE_NAME'];
-                                $sql = "select * from  quotes where quoteid=".$value;
+                                $sql = "select * from  vtiger_quotes where quoteid=".$value;
                                 $result = $adb->query($sql);
                                 $quotename = $adb->query_result($result,0,"subject");
 
@@ -521,7 +521,7 @@
 			elseif($parent_module == "PurchaseOrder")
                         {
 				$label_fld[] = $app_strings['LBL_PORDER_NAME'];
-                                $sql = "select * from  purchaseorder where purchaseorderid=".$value;
+                                $sql = "select * from  vtiger_purchaseorder where purchaseorderid=".$value;
                                 $result = $adb->query($sql);
                                 $pordername = $adb->query_result($result,0,"subject");
 
@@ -530,7 +530,7 @@
                         elseif($parent_module == "SalesOrder")
                         {
 				$label_fld[] = $app_strings['LBL_SORDER_NAME'];
-                                $sql = "select * from  salesorder where salesorderid=".$value;
+                                $sql = "select * from  vtiger_salesorder where salesorderid=".$value;
                                 $result = $adb->query($sql);
                                 $sordername = $adb->query_result($result,0,"subject");
 
@@ -539,7 +539,7 @@
 			elseif($parent_module == "Invoice")
                         {
 				$label_fld[] = $app_strings['LBL_INVOICE_NAME'];
-                                $sql = "select * from  invoice where invoiceid=".$value;
+                                $sql = "select * from  vtiger_invoice where invoiceid=".$value;
                                 $result = $adb->query($sql);
                                 $invoicename = $adb->query_result($result,0,"subject");
 
@@ -562,7 +562,7 @@
 			if($parent_module == "Leads")
 			{
 				$label_fld[] = $app_strings['LBL_LEAD_NAME'];
-				$sql = "select * from leaddetails where leadid=".$value;
+				$sql = "select * from vtiger_leaddetails where leadid=".$value;
 				$result = $adb->query($sql);
 				$first_name = $adb->query_result($result,0,"firstname");
 				$last_name = $adb->query_result($result,0,"lastname");
@@ -572,7 +572,7 @@
 			elseif($parent_module == "Contacts")
 			{
 				$label_fld[] = $app_strings['LBL_CONTACT_NAME'];
-				$sql = "select * from  contactdetails where contactid=".$value;
+				$sql = "select * from  vtiger_contactdetails where contactid=".$value;
 				$result = $adb->query($sql);
 				$first_name = $adb->query_result($result,0,"firstname");
                                 $last_name = $adb->query_result($result,0,"lastname");
@@ -596,7 +596,7 @@
 			$parent_name='';
 			$parent_id='';
 			$myemailid= $_REQUEST['record'];
-			$mysql = "select crmid from seactivityrel where activityid=".$myemailid;
+			$mysql = "select crmid from vtiger_seactivityrel where activityid=".$myemailid;
 			$myresult = $adb->query($mysql);
 			$mycount=$adb->num_rows($myresult);
 			if ($mycount>1){
@@ -609,7 +609,7 @@
 				if($parent_module == "Leads")
 				{
 					$label_fld[] = $app_strings['LBL_LEAD_NAME'];
-					$sql = "select * from leaddetails where leadid=".$value;
+					$sql = "select * from vtiger_leaddetails where leadid=".$value;
 					$result = $adb->query($sql);
 					$first_name = $adb->query_result($result,0,"firstname");
 					$last_name = $adb->query_result($result,0,"lastname");
@@ -618,7 +618,7 @@
 				elseif($parent_module == "Contacts")
 				{
 					$label_fld[] = $app_strings['LBL_CONTACT_NAME'];
-					$sql = "select * from  contactdetails where contactid=".$value;
+					$sql = "select * from  vtiger_contactdetails where contactid=".$value;
 					$result = $adb->query($sql);
 					$first_name = $adb->query_result($result,0,"firstname");
 					$last_name = $adb->query_result($result,0,"lastname");
@@ -627,7 +627,7 @@
 				elseif($parent_module == "Accounts")
 				{
 					$label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
-					$sql = "select * from  account where accountid=".$value;
+					$sql = "select * from  vtiger_account where accountid=".$value;
 					$result = $adb->query($sql);
 					$accountname = $adb->query_result($result,0,"accountname");
 					$label_fld[] = '<a href="index.php?module='.$parent_module.'&action=DetailView&record='.$value.'">'.$accountname.'</a>';
@@ -651,7 +651,7 @@
 			if($parent_module == "Contacts")
 			{
 				$label_fld[] = $app_strings['LBL_CONTACT_NAME'];
-				$sql = "select * from  contactdetails where contactid=".$value;
+				$sql = "select * from  vtiger_contactdetails where contactid=".$value;
 				$result = $adb->query($sql);
 				$first_name = $adb->query_result($result,0,"firstname");
                                 $last_name = $adb->query_result($result,0,"lastname");
@@ -661,7 +661,7 @@
 			elseif($parent_module == "Accounts")
 			{
 				$label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
-				$sql = "select * from account where accountid=".$value;
+				$sql = "select * from vtiger_account where accountid=".$value;
 				$result = $adb->query($sql);
 				$account_name = $adb->query_result($result,0,"accountname");
 
@@ -833,7 +833,7 @@
 	return $label_fld;
 }
 
-/** This function returns a HTML output of associated products for a given entity (Quotes,Invoice,Sales order or Purchase order)
+/** This function returns a HTML output of associated vtiger_products for a given entity (Quotes,Invoice,Sales order or Purchase order)
   * Param $module - module name
   * Param $focus - module object
   * Return type string
@@ -870,19 +870,19 @@
 
 	if($module == 'Quotes')
 	{
-		$query="select products.productname,products.unit_price,products.qtyinstock,quotesproductrel.* from quotesproductrel inner join products on products.productid=quotesproductrel.productid where quoteid=".$focus->id;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_quotesproductrel.* from vtiger_quotesproductrel inner join vtiger_products on vtiger_products.productid=vtiger_quotesproductrel.productid where quoteid=".$focus->id;
 	}
 	elseif($module == 'PurchaseOrder')
 	{
-		$query="select products.productname,products.unit_price,products.qtyinstock,poproductrel.* from poproductrel inner join products on products.productid=poproductrel.productid where purchaseorderid=".$focus->id;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_poproductrel.* from vtiger_poproductrel inner join vtiger_products on vtiger_products.productid=vtiger_poproductrel.productid where purchaseorderid=".$focus->id;
 	}
 	elseif($module == 'SalesOrder')
 	{
-		$query="select products.productname,products.unit_price,products.qtyinstock,soproductrel.* from soproductrel inner join products on products.productid=soproductrel.productid where salesorderid=".$focus->id;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_soproductrel.* from vtiger_soproductrel inner join vtiger_products on vtiger_products.productid=vtiger_soproductrel.productid where salesorderid=".$focus->id;
 	}
 	elseif($module == 'Invoice')
 	{
-		$query="select products.productname,products.unit_price,products.qtyinstock,invoiceproductrel.* from invoiceproductrel inner join products on products.productid=invoiceproductrel.productid where invoiceid=".$focus->id;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_invoiceproductrel.* from vtiger_invoiceproductrel inner join vtiger_products on vtiger_products.productid=vtiger_invoiceproductrel.productid where invoiceid=".$focus->id;
 	}
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
@@ -954,7 +954,7 @@
 
 }
 
-/** This function returns the related tab details for a given entity or a module.
+/** This function returns the related vtiger_tab details for a given entity or a module.
 * Param $module - module name
 * Param $focus - module object
 * Return type is an array
@@ -970,7 +970,7 @@
 	
 	$cur_tab_id = getTabid($module);
 
-	$sql1 = "select * from relatedlists where tabid=".$cur_tab_id;
+	$sql1 = "select * from vtiger_relatedlists where tabid=".$cur_tab_id;
 	$result = $adb->query($sql1);
 	$num_row = $adb->num_rows($result);
 	for($i=0; $i<$num_row; $i++)
@@ -1001,8 +1001,8 @@
 /** This function returns the detailed block information of a record in a module.
 * Param $module - module name
 * Param $block - block id
-* Param $col_fields - column fields array for the module 
-* Param $tabid - tab id
+* Param $col_fields - column vtiger_fields array for the module 
+* Param $tabid - vtiger_tab id
 * Return type is an array
 */
 

Modified: vtigercrm/trunk/include/utils/EditViewUtils.php
==============================================================================
--- vtigercrm/trunk/include/utils/EditViewUtils.php (original)
+++ vtigercrm/trunk/include/utils/EditViewUtils.php Mon Jun 12 14:26:25 2006
@@ -24,12 +24,12 @@
 require_once('include/ComboUtil.php'); //new
 require_once('include/utils/CommonUtils.php'); //new
 
-/** This function returns the field details for a given fieldname.
-  * Param $uitype - UI type of the field
-  * Param $fieldname - Form field name
-  * Param $fieldlabel - Form field label name
-  * Param $maxlength - maximum length of the field
-  * Param $col_fields - array contains the fieldname and values
+/** This function returns the vtiger_field details for a given vtiger_fieldname.
+  * Param $uitype - UI type of the vtiger_field
+  * Param $fieldname - Form vtiger_field name
+  * Param $fieldlabel - Form vtiger_field label name
+  * Param $maxlength - maximum length of the vtiger_field
+  * Param $col_fields - array contains the vtiger_fieldname and values
   * Param $generatedtype - Field generated type (default is 1)
   * Param $module_name - module name
   * Return type is an array
@@ -110,7 +110,7 @@
 	elseif($uitype == 15 || $uitype == 16)
 	{
 		$editview_label[]=$mod_strings[$fieldlabel];
-		$pick_query="select * from ".$fieldname;
+		$pick_query="select * from vtiger_".$fieldname;
 		$pickListResult = $adb->query($pick_query);
 		$noofpickrows = $adb->num_rows($pickListResult);
 
@@ -340,7 +340,7 @@
 	{
 		$options =Array();
 		$editview_label[]=$mod_strings[$fieldlabel];
-		$pick_query="select * from groups";
+		$pick_query="select * from vtiger_groups";
 		$pickListResult = $adb->query($pick_query);
 		$noofpickrows = $adb->num_rows($pickListResult);
 		for($j = 0; $j < $noofpickrows; $j++)
@@ -364,7 +364,7 @@
 	{
 		$editview_label[]=$mod_strings[$fieldlabel];
 		$options = Array();
-		$pick_query="select * from salutationtype order by sortorderid";
+		$pick_query="select * from vtiger_salutationtype order by sortorderid";
 		$pickListResult = $adb->query($pick_query);
 		$noofpickrows = $adb->num_rows($pickListResult);
 		$salt_value = $col_fields["salutationtype"];
@@ -409,7 +409,7 @@
 		if($value=='')
 			$value=1;
 		$options = Array();
-		$pick_query="select * from duration_minutes order by sortorderid";
+		$pick_query="select * from vtiger_duration_minutes order by sortorderid";
 		$pickListResult = $adb->query($pick_query);
 		$noofpickrows = $adb->num_rows($pickListResult);
 		$salt_value = $col_fields["duration_minutes"];
@@ -481,10 +481,10 @@
 		}
 		if($col_fields['record_id'] != '')
 		{
-			$attachmentid=$adb->query_result($adb->query("select * from seattachmentsrel where crmid = ".$col_fields['record_id']),0,'attachmentsid');
+			$attachmentid=$adb->query_result($adb->query("select * from vtiger_seattachmentsrel where crmid = ".$col_fields['record_id']),0,'attachmentsid');
 			if($col_fields[$fieldname] == '' && $attachmentid != '')
 			{
-				$attachquery = "select * from attachments where attachmentsid=".$attachmentid;
+				$attachquery = "select * from vtiger_attachments where attachmentsid=".$attachmentid;
 				$value = $adb->query_result($adb->query($attachquery),0,'name');
 			}
 		}
@@ -500,11 +500,11 @@
 		//This query is for Products only
 		if($module_name == 'Products')
 		{
-			$query = 'select attachments.path,attachments.name from products left join seattachmentsrel on seattachmentsrel.crmid=products.productid inner join attachments on attachments.attachmentsid=seattachmentsrel.attachmentsid where productid='.$col_fields['record_id'];
+			$query = 'select vtiger_attachments.path,vtiger_attachments.name from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where productid='.$col_fields['record_id'];
 		}
 		else
 		{
-			$query = "select attachments.path, attachments.name from contactdetails left join seattachmentsrel on seattachmentsrel.crmid=contactdetails.contactid inner join attachments on attachments.attachmentsid=seattachmentsrel.attachmentsid where contactdetails.imagename=attachments.name and contactid=".$col_fields['record_id'];
+			$query = "select vtiger_attachments.path, vtiger_attachments.name from vtiger_contactdetails left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_contactdetails.contactid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where vtiger_contactdetails.imagename=vtiger_attachments.name and contactid=".$col_fields['record_id'];
 		}
 		$result_image = $adb->query($query);
 		for($image_iter=0;$image_iter < $adb->num_rows($result_image);$image_iter++)	
@@ -530,7 +530,7 @@
 			$parent_module = getSalesEntityType($value);
 			if($parent_module == "Leads")
 			{
-				$sql = "select * from leaddetails where leadid=".$value;
+				$sql = "select * from vtiger_leaddetails where leadid=".$value;
 				$result = $adb->query($sql);
 				$first_name = $adb->query_result($result,0,"firstname");
 				$last_name = $adb->query_result($result,0,"lastname");
@@ -540,7 +540,7 @@
 			}
 			elseif($parent_module == "Accounts")
 			{
-				$sql = "select * from  account where accountid=".$value;
+				$sql = "select * from  vtiger_account where accountid=".$value;
 				$result = $adb->query($sql);
 				$parent_name = $adb->query_result($result,0,"accountname");
 				$account_selected = "selected";
@@ -548,7 +548,7 @@
 			}
 			elseif($parent_module == "Potentials")
 			{
-				$sql = "select * from  potential where potentialid=".$value;
+				$sql = "select * from  vtiger_potential where potentialid=".$value;
 				$result = $adb->query($sql);
 				$parent_name = $adb->query_result($result,0,"potentialname");
 				$potential_selected = "selected";
@@ -556,7 +556,7 @@
 			}
 			elseif($parent_module == "Products")
 			{
-				$sql = "select * from  products where productid=".$value;
+				$sql = "select * from  vtiger_products where productid=".$value;
 				$result = $adb->query($sql);
 				$parent_name= $adb->query_result($result,0,"productname");
 				$product_selected = "selected";
@@ -564,7 +564,7 @@
 			}
 			elseif($parent_module == "PurchaseOrder")
 			{
-				$sql = "select * from  purchaseorder where purchaseorderid=".$value;
+				$sql = "select * from  vtiger_purchaseorder where purchaseorderid=".$value;
 				$result = $adb->query($sql);
 				$parent_name= $adb->query_result($result,0,"subject");
 				$porder_selected = "selected";
@@ -572,7 +572,7 @@
 			}
 			elseif($parent_module == "SalesOrder")
 			{
-				$sql = "select * from  salesorder where salesorderid=".$value;
+				$sql = "select * from  vtiger_salesorder where salesorderid=".$value;
 				$result = $adb->query($sql);
 				$parent_name= $adb->query_result($result,0,"subject");
 				$sorder_selected = "selected";
@@ -580,7 +580,7 @@
 			}
 			elseif($parent_module == "Invoice")
 			{
-				$sql = "select * from  invoice where invoiceid=".$value;
+				$sql = "select * from  vtiger_invoice where invoiceid=".$value;
 				$result = $adb->query($sql);
 				$parent_name= $adb->query_result($result,0,"subject");
 				$invoice_selected = "selected";
@@ -614,7 +614,7 @@
 	{
 		if(isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '')
 			$value = $_REQUEST['parent_id'];
-		// Check for activity type if task orders to be added in select option
+		// Check for vtiger_activity type if task orders to be added in select option
 		$act_mode = $_REQUEST['activity_mode'];
 
 		if($value != '')
@@ -622,7 +622,7 @@
 			$parent_module = getSalesEntityType($value);
 			if($parent_module == "Leads")
 			{
-				$sql = "select * from leaddetails where leadid=".$value;
+				$sql = "select * from vtiger_leaddetails where leadid=".$value;
 				$result = $adb->query($sql);
 				$first_name = $adb->query_result($result,0,"firstname");
 				$last_name = $adb->query_result($result,0,"lastname");
@@ -632,7 +632,7 @@
 			}
 			elseif($parent_module == "Accounts")
 			{
-				$sql = "select * from  account where accountid=".$value;
+				$sql = "select * from  vtiger_account where accountid=".$value;
 				$result = $adb->query($sql);
 				$parent_name = $adb->query_result($result,0,"accountname");
 				$account_selected = "selected";
@@ -640,7 +640,7 @@
 			}
 			elseif($parent_module == "Potentials")
 			{
-				$sql = "select * from  potential where potentialid=".$value;
+				$sql = "select * from  vtiger_potential where potentialid=".$value;
 				$result = $adb->query($sql);
 				$parent_name = $adb->query_result($result,0,"potentialname");
 				$potential_selected = "selected";
@@ -648,7 +648,7 @@
 			}
 			elseif($parent_module == "Quotes")
 			{
-				$sql = "select * from  quotes where quoteid=".$value;
+				$sql = "select * from  vtiger_quotes where quoteid=".$value;
 				$result = $adb->query($sql);
 				$parent_name = $adb->query_result($result,0,"subject");
 				$quote_selected = "selected";
@@ -658,21 +658,21 @@
 			{
 				if($parent_module == "PurchaseOrder")
 				{
-					$sql = "select * from purchaseorder where purchaseorderid=".$value;
+					$sql = "select * from vtiger_purchaseorder where purchaseorderid=".$value;
 					$result = $adb->query($sql);
 					$parent_name = $adb->query_result($result,0,"subject");
 					$purchase_selected = "selected";
 				}
 				if($parent_module == "SalesOrder")
 				{
-					$sql = "select * from salesorder where salesorderid=".$value;
+					$sql = "select * from vtiger_salesorder where salesorderid=".$value;
 					$result = $adb->query($sql);
 					$parent_name = $adb->query_result($result,0,"subject");
 					$sales_selected = "selected";
 				}
 				if($parent_module == "Invoice")
 				{
-					$sql = "select * from invoice where invoiceid=".$value;
+					$sql = "select * from vtiger_invoice where invoiceid=".$value;
 					$result = $adb->query($sql);
 					$parent_name = $adb->query_result($result,0,"subject");
 					$invoice_selected = "selected";
@@ -762,7 +762,7 @@
 					$lead_selected = 'selected';
 				}
 				for ($j=1;$j<$nemail;$j++){
-					$querystr='select columnname from field where fieldid='.$realid[$j].';';
+					$querystr='select columnname from vtiger_field where fieldid='.$realid[$j].';';
 					$result=$adb->query($querystr);
 					$temp=$adb->query_result($result,0,'columnname');
 					$temp1=br2nl($myfocus->column_fields[$temp]);
@@ -793,7 +793,7 @@
 			$parent_name='';
 			$parent_id='';
 			$myemailid= $_REQUEST['record'];
-			$mysql = "select crmid from seactivityrel where activityid=".$myemailid;
+			$mysql = "select crmid from vtiger_seactivityrel where activityid=".$myemailid;
 			$myresult = $adb->query($mysql);
 			$mycount=$adb->num_rows($myresult);
 			if($mycount >0)
@@ -804,7 +804,7 @@
 					$parent_module = getSalesEntityType($mycrmid);
 					if($parent_module == "Leads")
 					{
-						$sql = "select firstname,lastname,email from leaddetails where leadid=".$mycrmid;
+						$sql = "select firstname,lastname,email from vtiger_leaddetails where leadid=".$mycrmid;
 						$result = $adb->query($sql);
 						$first_name = $adb->query_result($result,0,"firstname");
 						$last_name = $adb->query_result($result,0,"lastname");
@@ -815,7 +815,7 @@
 					}
 					elseif($parent_module == "Contacts")
 					{
-						$sql = "select * from  contactdetails where contactid=".$mycrmid;
+						$sql = "select * from  vtiger_contactdetails where contactid=".$mycrmid;
 						$result = $adb->query($sql);
 						$first_name = $adb->query_result($result,0,"firstname");
 						$last_name = $adb->query_result($result,0,"lastname");
@@ -826,7 +826,7 @@
 					}
 					elseif($parent_module == "Accounts")
 					{
-						$sql = "select * from  account where accountid=".$mycrmid;
+						$sql = "select * from  vtiger_account where accountid=".$mycrmid;
 						$result = $adb->query($sql);
 						$account_name = $adb->query_result($result,0,"accountname");
 						$myemail=$adb->query_result($result,0,"email1");
@@ -835,7 +835,7 @@
 						$account_selected = 'selected';
 					}elseif($parent_module == "Users")
 					{
-						$sql = "select user_name,email1 from users where id=".$mycrmid;
+						$sql = "select user_name,email1 from vtiger_users where id=".$mycrmid;
 						$result = $adb->query($sql);
 						$account_name = $adb->query_result($result,0,"user_name");
 						$myemail=$adb->query_result($result,0,"email1");
@@ -872,7 +872,7 @@
 			$parent_module = getSalesEntityType($value);
 			if($parent_module == "Contacts")
 			{
-				$sql = "select * from  contactdetails where contactid=".$value;
+				$sql = "select * from  vtiger_contactdetails where contactid=".$value;
 				$result = $adb->query($sql);
 				$first_name = $adb->query_result($result,0,"firstname");
 				$last_name = $adb->query_result($result,0,"lastname");
@@ -882,7 +882,7 @@
 			}
 			elseif($parent_module == "Accounts")
 			{
-				$sql = "select * from  account where accountid=".$value;
+				$sql = "select * from  vtiger_account where accountid=".$value;
 				$result = $adb->query($sql);
 				$parent_name = $adb->query_result($result,0,"accountname");
 				$account_selected = "selected";
@@ -1039,7 +1039,7 @@
 	return $final_arr;
 }
 
-/** This function returns the invoice object populated with the details from sales order object.
+/** This function returns the vtiger_invoice object populated with the details from sales order object.
 * Param $focus - Invoice object
 * Param $so_focus - Sales order focus
 * Param $soid - sales order id
@@ -1081,7 +1081,7 @@
 
 }
 
-/** This function returns the invoice object populated with the details from quote object.
+/** This function returns the vtiger_invoice object populated with the details from quote object.
 * Param $focus - Invoice object
 * Param $quote_focus - Quote order focus
 * Param $quoteid - quote id
@@ -1156,7 +1156,7 @@
 
 }
 
-/** This function returns the detailed list of products associated to a given entity or a record.
+/** This function returns the detailed list of vtiger_products associated to a given entity or a record.
 * Param $module - module name
 * Param $focus - module object
 * Param $seid - sales entity id
@@ -1176,27 +1176,27 @@
 	$product_Detail = Array();
 	if($module == 'Quotes')
 	{
-		$query="select products.productname,products.unit_price,products.qtyinstock,quotesproductrel.* from quotesproductrel inner join products on products.productid=quotesproductrel.productid where quoteid=".$focus->id;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_quotesproductrel.* from vtiger_quotesproductrel inner join vtiger_products on vtiger_products.productid=vtiger_quotesproductrel.productid where quoteid=".$focus->id;
 	}
 	elseif($module == 'PurchaseOrder')
 	{
-		$query="select products.productname,products.unit_price,products.qtyinstock,poproductrel.* from poproductrel inner join products on products.productid=poproductrel.productid where purchaseorderid=".$focus->id;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_poproductrel.* from vtiger_poproductrel inner join vtiger_products on vtiger_products.productid=vtiger_poproductrel.productid where purchaseorderid=".$focus->id;
 	}
 	elseif($module == 'SalesOrder')
 	{
-		$query="select products.productname,products.unit_price,products.qtyinstock,soproductrel.* from soproductrel inner join products on products.productid=soproductrel.productid where salesorderid=".$focus->id;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_soproductrel.* from vtiger_soproductrel inner join vtiger_products on vtiger_products.productid=vtiger_soproductrel.productid where salesorderid=".$focus->id;
 	}
 	elseif($module == 'Invoice')
 	{
-		$query="select products.productname,products.unit_price,products.qtyinstock,invoiceproductrel.* from invoiceproductrel inner join products on products.productid=invoiceproductrel.productid where invoiceid=".$focus->id;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_invoiceproductrel.* from vtiger_invoiceproductrel inner join vtiger_products on vtiger_products.productid=vtiger_invoiceproductrel.productid where invoiceid=".$focus->id;
 	}
 	elseif($module == 'Potentials')
 	{
-		$query="select products.productname,products.unit_price,products.qtyinstock,seproductsrel.* from products inner join seproductsrel on seproductsrel.productid=products.productid where crmid=".$seid;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_seproductsrel.* from vtiger_products inner join vtiger_seproductsrel on vtiger_seproductsrel.productid=vtiger_products.productid where crmid=".$seid;
 	}
 	elseif($module == 'Products')
 	{
-		$query="select products.productid,products.productname,products.unit_price,products.qtyinstock,crmentity.* from products inner join crmentity on crmentity.crmid=products.productid where crmentity.deleted=0 and productid=".$seid;
+		$query="select vtiger_products.productid,vtiger_products.productname,vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_crmentity.* from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid where vtiger_crmentity.deleted=0 and productid=".$seid;
 	}
 
 	$result = $adb->query($query);
@@ -1260,7 +1260,7 @@
 
 }
 
-/** This function returns the no of products associated to the given entity or a record.
+/** This function returns the no of vtiger_products associated to the given entity or a record.
 * Param $module - module name
 * Param $focus - module object
 * Param $seid - sales entity id
@@ -1275,27 +1275,27 @@
 	$output = '';
 	if($module == 'Quotes')
 	{
-		$query="select products.productname,products.unit_price,quotesproductrel.* from quotesproductrel inner join products on products.productid=quotesproductrel.productid where quoteid=".$focus->id;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_quotesproductrel.* from vtiger_quotesproductrel inner join vtiger_products on vtiger_products.productid=vtiger_quotesproductrel.productid where quoteid=".$focus->id;
 	}
 	elseif($module == 'PurchaseOrder')
 	{
-		$query="select products.productname,products.unit_price,poproductrel.* from poproductrel inner join products on products.productid=poproductrel.productid where purchaseorderid=".$focus->id;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_poproductrel.* from vtiger_poproductrel inner join vtiger_products on vtiger_products.productid=vtiger_poproductrel.productid where purchaseorderid=".$focus->id;
 	}
 	elseif($module == 'SalesOrder')
 	{
-		$query="select products.productname,products.unit_price,soproductrel.* from soproductrel inner join products on products.productid=soproductrel.productid where salesorderid=".$focus->id;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_soproductrel.* from vtiger_soproductrel inner join vtiger_products on vtiger_products.productid=vtiger_soproductrel.productid where salesorderid=".$focus->id;
 	}
 	elseif($module == 'Invoice')
 	{
-		$query="select products.productname,products.unit_price,invoiceproductrel.* from invoiceproductrel inner join products on products.productid=invoiceproductrel.productid where invoiceid=".$focus->id;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_invoiceproductrel.* from vtiger_invoiceproductrel inner join vtiger_products on vtiger_products.productid=vtiger_invoiceproductrel.productid where invoiceid=".$focus->id;
 	}
 	elseif($module == 'Potentials')
 	{
-		$query="select products.productname,products.unit_price,seproductsrel.* from products inner join seproductsrel on seproductsrel.productid=products.productid where crmid=".$seid;
+		$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_seproductsrel.* from vtiger_products inner join vtiger_seproductsrel on vtiger_seproductsrel.productid=vtiger_products.productid where crmid=".$seid;
 	}	
 	elseif($module == 'Products')
 	{
-		$query="select products.productname,products.unit_price, crmentity.* from products inner join crmentity on crmentity.crmid=products.productid where crmentity.deleted=0 and productid=".$seid;
+		$query="select vtiger_products.productname,vtiger_products.unit_price, vtiger_crmentity.* from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid where vtiger_crmentity.deleted=0 and productid=".$seid;
 	}
 
 
@@ -1309,8 +1309,8 @@
 * Param $module - module name
 * Param $block - block name
 * Param $mode - view type (detail/edit/create)
-* Param $col_fields - fields array
-* Param $tabid - tab id
+* Param $col_fields - vtiger_fields array
+* Param $tabid - vtiger_tab id
 * Param $info_type - information type (basic/advance) default ""
 * Return type is an object array
 */
@@ -1402,8 +1402,8 @@
 	
 }
 
-/** This function returns the data type of the fields, with field label, which is used for javascript validation.
-* Param $validationData - array of fieldnames with datatype
+/** This function returns the data type of the vtiger_fields, with vtiger_field label, which is used for javascript validation.
+* Param $validationData - array of vtiger_fieldnames with datatype
 * Return type array 
 */
 

Modified: vtigercrm/trunk/include/utils/GetGroupUsers.php
==============================================================================
--- vtigercrm/trunk/include/utils/GetGroupUsers.php (original)
+++ vtigercrm/trunk/include/utils/GetGroupUsers.php Mon Jun 12 14:26:25 2006
@@ -10,7 +10,7 @@
  ********************************************************************************/
 
 
-/** Class to retreive all the users present in a group 
+/** Class to retreive all the vtiger_users present in a group 
  *
  */
 require_once('include/utils/UserInfoUtil.php');
@@ -21,17 +21,17 @@
 	var $group_users=array();
 	var $group_subgroups=array();
 
-	/** to get all the users and groups of the specified group
+	/** to get all the vtiger_users and vtiger_groups of the specified group
 	 * @params $groupId --> Group Id :: Type Integer
-         * @returns the users present in the group in the variable $parent_groups of the class
-         * @returns the sub groups present in the group in the variable $group_subgroups of the class
+         * @returns the vtiger_users present in the group in the variable $parent_groups of the class
+         * @returns the sub vtiger_groups present in the group in the variable $group_subgroups of the class
          */
 	function getAllUsersInGroup($groupid)
 	{
 		global $adb,$log;
 		$log->debug("Entering getAllUsersInGroup(".$groupid.") method...");
 		//Retreiving from the user2grouptable
-		$query="select * from users2group where groupid=".$groupid;
+		$query="select * from vtiger_users2group where groupid=".$groupid;
 		$result = $adb->query($query);
 		$num_rows=$adb->num_rows($result);
 		for($i=0;$i<$num_rows;$i++)
@@ -45,8 +45,8 @@
 		}
 		
 
-		//Retreiving from the group2role
-		$query="select * from group2role where groupid=".$groupid;
+		//Retreiving from the vtiger_group2role
+		$query="select * from vtiger_group2role where groupid=".$groupid;
                 $result = $adb->query($query);
                 $num_rows=$adb->num_rows($result);
                 for($i=0;$i<$num_rows;$i++)
@@ -66,8 +66,8 @@
 			
                 }
 
-		//Retreiving from the group2rs
-		$query="select * from group2rs where groupid=".$groupid;
+		//Retreiving from the vtiger_group2rs
+		$query="select * from vtiger_group2rs where groupid=".$groupid;
                 $result = $adb->query($query);
                 $num_rows=$adb->num_rows($result);
                 for($i=0;$i<$num_rows;$i++)
@@ -86,7 +86,7 @@
  
                 }
 		//Retreving from group2group
-		$query="select * from group2grouprel where groupid=".$groupid;
+		$query="select * from vtiger_group2grouprel where groupid=".$groupid;
                 $result = $adb->query($query);
                 $num_rows=$adb->num_rows($result);
                 for($i=0;$i<$num_rows;$i++)

Modified: vtigercrm/trunk/include/utils/GetParentGroups.php
==============================================================================
--- vtigercrm/trunk/include/utils/GetParentGroups.php (original)
+++ vtigercrm/trunk/include/utils/GetParentGroups.php Mon Jun 12 14:26:25 2006
@@ -16,7 +16,7 @@
 
 	var $parent_groups=Array();
 
-	/** to get all the parent groups of the specified group
+	/** to get all the parent vtiger_groups of the specified group
 	 * @params $groupId --> Group Id :: Type Integer
          * @returns updates the parent group in the varibale $parent_groups of the class
          */
@@ -24,7 +24,7 @@
 	{
 		global $adb,$log;
 		$log->debug("Entering getAllParentGroups(".$groupid.") method...");
-		$query="select groupid from group2grouprel where containsgroupid=".$groupId;
+		$query="select groupid from vtiger_group2grouprel where containsgroupid=".$groupId;
 		$adb->query($query);
 		$result=$adb->query($query);
 		$num_rows=$adb->num_rows($result);

Modified: vtigercrm/trunk/include/utils/GetUserGroups.php
==============================================================================
--- vtigercrm/trunk/include/utils/GetUserGroups.php (original)
+++ vtigercrm/trunk/include/utils/GetUserGroups.php Mon Jun 12 14:26:25 2006
@@ -20,7 +20,7 @@
 	var $user_groups=Array();
 	//var $userRole='';
 
-	/** to get all the parent groups of the specified group
+	/** to get all the parent vtiger_groups of the specified group
 	 * @params $groupId --> Group Id :: Type Integer
          * @returns updates the parent group in the varibale $parent_groups of the class
          */
@@ -29,7 +29,7 @@
 		global $adb,$log;
 		$log->debug("Entering getAllUserGroups(".$userid.") method...");
 		//Retreiving from the user2grouptable
-		$query="select * from users2group where userid=".$userid;
+		$query="select * from vtiger_users2group where userid=".$userid;
 		$result = $adb->query($query);
 		$num_rows=$adb->num_rows($result);
 		for($i=0;$i<$num_rows;$i++)
@@ -44,8 +44,8 @@
 
 		//Setting the User Role
 		$userRole = fetchUserRole($userid);
-		//Retreiving from the user2role
-		$query="select * from group2role where roleid='".$userRole."'";
+		//Retreiving from the vtiger_user2role
+		$query="select * from vtiger_group2role where roleid='".$userRole."'";
                 $result = $adb->query($query);
                 $num_rows=$adb->num_rows($result);
                 for($i=0;$i<$num_rows;$i++)
@@ -66,7 +66,7 @@
 			$parentRolelist .= "'".$par_rol_id."',";		
 		}
 		$parentRolelist .= "'".$userRole."')";
-		$query="select * from group2rs where roleandsubid in".$parentRolelist;
+		$query="select * from vtiger_group2rs where roleandsubid in".$parentRolelist;
                 $result = $adb->query($query);
                 $num_rows=$adb->num_rows($result);
                 for($i=0;$i<$num_rows;$i++)

Modified: vtigercrm/trunk/include/utils/InventoryUtils.php
==============================================================================
--- vtigercrm/trunk/include/utils/InventoryUtils.php (original)
+++ vtigercrm/trunk/include/utils/InventoryUtils.php Mon Jun 12 14:26:25 2006
@@ -11,8 +11,8 @@
 
 /**
  * This function returns the Product detail block values in array format.
- * Input Parameter are $module - module name, $focus - module object, $num_of_products - no.of products associated with it  * $associated_prod = associated product details
- * column fields/
+ * Input Parameter are $module - module name, $focus - module object, $num_of_products - no.of vtiger_products associated with it  * $associated_prod = associated product details
+ * column vtiger_fields/
  */
 
 function getProductDetailsBlockInfo($mode,$module,$focus='',$num_of_products='',$associated_prod='')
@@ -58,7 +58,7 @@
  * Param $productid - product id
  * Param $qty - product quantity in no's
  * Param $mode - mode type
- * Param $ext_prod_arr - existing products 
+ * Param $ext_prod_arr - existing vtiger_products 
  * Param $module - module name
  * return type void
  */
@@ -175,7 +175,7 @@
 		{
 			$notificationname = 'InvoiceNotification';
 		}
-		$query = "select * from inventorynotification where notificationname='".$notification_table."'";
+		$query = "select * from vtiger_inventorynotification where notificationname='".$notification_table."'";
 		$result = $adb->query($query);
 
 		$subject = $adb->query_result($result,0,'notificationsubject');
@@ -210,7 +210,7 @@
 	global $log;
 	$log->debug("Entering getPrdQtyInStck(".$product_id.") method ...");
 	global $adb;
-	$query1 = "SELECT qtyinstock FROM products WHERE productid = ".$product_id;
+	$query1 = "SELECT qtyinstock FROM vtiger_products WHERE productid = ".$product_id;
 	$result=$adb->query($query1);
 	$qtyinstck= $adb->query_result($result,0,"qtyinstock");
 	$log->debug("Exiting getPrdQtyInStck method ...");
@@ -227,7 +227,7 @@
 	global $log;
 	$log->debug("Entering getPrdReOrderLevel(".$product_id.") method ...");
 	global $adb;
-	$query1 = "SELECT reorderlevel FROM products WHERE productid = ".$product_id;
+	$query1 = "SELECT reorderlevel FROM vtiger_products WHERE productid = ".$product_id;
 	$result=$adb->query($query1);
 	$reorderlevel= $adb->query_result($result,0,"reorderlevel");
 	$log->debug("Exiting getPrdReOrderLevel method ...");
@@ -244,7 +244,7 @@
 	global $log;
 	$log->debug("Entering getPrdHandler(".$product_id.") method ...");
 	global $adb;
-	$query1 = "SELECT handler FROM products WHERE productid = ".$product_id;
+	$query1 = "SELECT handler FROM vtiger_products WHERE productid = ".$product_id;
 	$result=$adb->query($query1);
 	$handler= $adb->query_result($result,0,"handler");
 	$log->debug("Exiting getPrdHandler method ...");
@@ -253,14 +253,14 @@
 
 /**	function to get the taxid
  *	@param string $type - tax type (VAT or Sales or Service)
- *	return int   $taxid - taxid corresponding to the Tax type from inventorytaxinfo table
+ *	return int   $taxid - taxid corresponding to the Tax type from vtiger_inventorytaxinfo vtiger_table
  */
 function getTaxId($type)
 {
 	global $adb, $log;
 	$log->debug("Entering into getTaxId($type) function.");
 
-	$res = $adb->query("SELECT taxid FROM inventorytaxinfo WHERE taxname='$type'");
+	$res = $adb->query("SELECT taxid FROM vtiger_inventorytaxinfo WHERE taxname='$type'");
 	$taxid = $adb->query_result($res,0,'taxid');
 
 	$log->debug("Exiting from getTaxId($type) function. return value=$taxid");
@@ -269,7 +269,7 @@
 
 /**	function to get the taxpercentage
  *	@param string $type       - tax type (VAT or Sales or Service)
- *	return int $taxpercentage - taxpercentage corresponding to the Tax type from inventorytaxinfo table
+ *	return int $taxpercentage - taxpercentage corresponding to the Tax type from vtiger_inventorytaxinfo vtiger_table
  */
 function getTaxPercentage($type)
 {
@@ -278,7 +278,7 @@
 
 	$taxpercentage = '';
 
-	$res = $adb->query("SELECT percentage FROM inventorytaxinfo WHERE taxname = '$type'");
+	$res = $adb->query("SELECT percentage FROM vtiger_inventorytaxinfo WHERE taxname = '$type'");
 	$taxpercentage = $adb->query_result($res,0,'percentage');
 
 	$log->debug("Exiting from getTaxPercentage($type) function. return value=$taxpercentage");
@@ -289,7 +289,7 @@
  *	@param string $type       - tax type (VAT or Sales or Service)
  *	@param id  $productid     - productid to which we want the tax percentage
  *	@param id  $default       - if 'default' then first look for product's tax percentage and product's tax is empty then it will return the default configured tax percentage, else it will return the product's tax (not look for default value)
- *	return int $taxpercentage - taxpercentage corresponding to the Tax type from inventorytaxinfo table
+ *	return int $taxpercentage - taxpercentage corresponding to the Tax type from vtiger_inventorytaxinfo vtiger_table
  */
 function getProductTaxPercentage($type,$productid,$default='')
 {
@@ -299,11 +299,11 @@
 	$taxpercentage = '';
 
 	$res = $adb->query("SELECT taxpercentage
-			FROM inventorytaxinfo
-			INNER JOIN producttaxrel
-				ON inventorytaxinfo.taxid = producttaxrel.taxid
-			WHERE producttaxrel.productid = $productid
-			AND inventorytaxinfo.taxname = '$type'");
+			FROM vtiger_inventorytaxinfo
+			INNER JOIN vtiger_producttaxrel
+				ON vtiger_inventorytaxinfo.taxid = vtiger_producttaxrel.taxid
+			WHERE vtiger_producttaxrel.productid = $productid
+			AND vtiger_inventorytaxinfo.taxname = '$type'");
 	$taxpercentage = $adb->query_result($res,0,'taxpercentage');
 
 	//This is to retrive the default configured value if the taxpercentage related to product is empty

Modified: vtigercrm/trunk/include/utils/ListViewUtils.php
==============================================================================
--- vtigercrm/trunk/include/utils/ListViewUtils.php (original)
+++ vtigercrm/trunk/include/utils/ListViewUtils.php Mon Jun 12 14:26:25 2006
@@ -49,10 +49,10 @@
 	$image_path=$theme_path."images/";
 	$list_header = Array();
 
-	//Get the tabid of the module
+	//Get the vtiger_tabid of the module
 	$tabid = getTabid($module);
 	global $current_user;
-	//added for customview 27/5
+	//added for vtiger_customview 27/5
 	if($oCv)
 	{
 		if(isset($oCv->list_fields))
@@ -86,17 +86,17 @@
 	if($is_admin==false)
 	{
 		$profileList = getCurrentUserProfileList();
-		$query  = "SELECT DISTINCT field.fieldname
-			FROM field
-			INNER JOIN profile2field
-				ON profile2field.fieldid = field.fieldid
-			INNER JOIN def_org_field
-				ON def_org_field.fieldid = field.fieldid
-			WHERE field.tabid = ".$tabid."
-			AND profile2field.visible = 0
-			AND def_org_field.visible = 0
-			AND profile2field.profileid IN ".$profileList."
-			AND field.fieldname IN ".$field_list;
+		$query  = "SELECT DISTINCT vtiger_field.fieldname
+			FROM vtiger_field
+			INNER JOIN vtiger_profile2field
+				ON vtiger_profile2field.fieldid = vtiger_field.fieldid
+			INNER JOIN vtiger_def_org_field
+				ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
+			WHERE vtiger_field.tabid = ".$tabid."
+			AND vtiger_profile2field.visible = 0
+			AND vtiger_def_org_field.visible = 0
+			AND vtiger_profile2field.profileid IN ".$profileList."
+			AND vtiger_field.fieldname IN ".$field_list;
 		$result = $adb->query($query);
 		$field=Array();
 		for($k=0;$k < $adb->num_rows($result);$k++)
@@ -106,10 +106,10 @@
 	}
 	//end
 
-	//modified for customview 27/5 - $app_strings change to $mod_strings
+	//modified for vtiger_customview 27/5 - $app_strings change to $mod_strings
 	foreach($focus->list_fields as $name=>$tableinfo)
 	{
-		//added for customview 27/5
+		//added for vtiger_customview 27/5
 		if($oCv)
 		{
 			if(isset($oCv->list_fields_name))
@@ -128,7 +128,7 @@
 		{
 			if(isset($focus->sortby_fields) && $focus->sortby_fields !='')
 			{
-				//Added on 14-12-2005 to avoid if and else check for every list field for arrow image and change order
+				//Added on 14-12-2005 to avoid if and else check for every list vtiger_field for arrow image and change order
 				$change_sorder = array('ASC'=>'DESC','DESC'=>'ASC');
 				$arrow_gif = array('ASC'=>'arrow_down.gif','DESC'=>'arrow_up.gif');
 
@@ -166,7 +166,7 @@
 							{
 								$lbl_name = $mod_strings[$name];
 							}
-							//added to display currency symbol in listview header
+							//added to display vtiger_currency symbol in listview header
 							if($lbl_name =='Amount')
 							{
 								$currencyid=fetchCurrency($current_user->id);
@@ -194,7 +194,7 @@
 
 				}
 			}
-																	//added to display currency symbol in related listview header
+																	//added to display vtiger_currency symbol in related listview header
 																	if($name =='Amount' && $relatedlist !='' )
 		{
 			$currencyid=fetchCurrency($current_user->id);
@@ -256,17 +256,17 @@
 	if($is_admin==false)
 	{
 		$profileList = getCurrentUserProfileList();
-		$query  = "SELECT DISTINCT field.fieldname
-			FROM field
-			INNER JOIN profile2field
-				ON profile2field.fieldid = field.fieldid
-			INNER JOIN def_org_field
-				ON def_org_field.fieldid = field.fieldid
-			WHERE field.tabid = ".$tabid."
-			AND profile2field.visible=0
-			AND def_org_field.visible=0
-			AND profile2field.profileid IN ".$profileList."
-			AND field.fieldname IN ".$field_list;
+		$query  = "SELECT DISTINCT vtiger_field.fieldname
+			FROM vtiger_field
+			INNER JOIN vtiger_profile2field
+				ON vtiger_profile2field.fieldid = vtiger_field.fieldid
+			INNER JOIN vtiger_def_org_field
+				ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
+			WHERE vtiger_field.tabid = ".$tabid."
+			AND vtiger_profile2field.visible=0
+			AND vtiger_def_org_field.visible=0
+			AND vtiger_profile2field.profileid IN ".$profileList."
+			AND vtiger_field.fieldname IN ".$field_list;
 		$result = $adb->query($query);
 		$field=Array();
 		for($k=0;$k < $adb->num_rows($result);$k++)
@@ -287,17 +287,17 @@
 		if($is_admin==false)
 		{
                 	$profileList = getCurrentUserProfileList();
-                	$query = "SELECT profile2field.*
-				FROM field
-				INNER JOIN profile2field
-					ON profile2field.fieldid = field.fieldid
-				INNER JOIN def_org_field
-					ON def_org_field.fieldid = field.fieldid
-				WHERE field.tabid = ".$tabid."
-				AND profile2field.visible = 0
-				AND def_org_field.visible = 0
-				AND profile2field.profileid IN ".$profileList."
-				AND field.fieldname = '".$fieldname."'";
+                	$query = "SELECT vtiger_profile2field.*
+				FROM vtiger_field
+				INNER JOIN vtiger_profile2field
+					ON vtiger_profile2field.fieldid = vtiger_field.fieldid
+				INNER JOIN vtiger_def_org_field
+					ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
+				WHERE vtiger_field.tabid = ".$tabid."
+				AND vtiger_profile2field.visible = 0
+				AND vtiger_def_org_field.visible = 0
+				AND vtiger_profile2field.profileid IN ".$profileList."
+				AND vtiger_field.fieldname = '".$fieldname."'";
 
                 	$result = $adb->query($query);
                 }
@@ -431,11 +431,11 @@
 *Param $returnset - list query parameters in url string
 *Param $edit_action - Edit action value
 *Param $del_action - delete action value
-*Param $oCv - customview object
+*Param $oCv - vtiger_customview object
 *Returns an array type
 */
 
-//parameter added for customview $oCv 27/5
+//parameter added for vtiger_customview $oCv 27/5
 function getListViewEntries($focus, $module,$list_result,$navigation_array,$relatedlist='',$returnset='',$edit_action='EditView',$del_action='Delete',$oCv='')
 {
 	global $log;
@@ -449,10 +449,10 @@
 	$evt_status;
 	$theme_path="themes/".$theme."/";
 	$image_path=$theme_path."images/";
-	//getting the fieldtable entries from database
+	//getting the vtiger_fieldtable entries from database
 	$tabid = getTabid($module);
 
-	//added for customview 27/5
+	//added for vtiger_customview 27/5
 	if($oCv)
 	{
 		if(isset($oCv->list_fields))
@@ -485,17 +485,17 @@
 	if($is_admin==false)
 	{
 		$profileList = getCurrentUserProfileList();
-		$query  = "SELECT DISTINCT field.fieldname
-			FROM field
-			INNER JOIN profile2field
-				ON profile2field.fieldid = field.fieldid
-			INNER JOIN def_org_field
-				ON def_org_field.fieldid = field.fieldid
-			WHERE field.tabid = ".$tabid."
-			AND profile2field.visible = 0
-			AND def_org_field.visible = 0
-			AND profile2field.profileid IN ".$profileList."
-			AND field.fieldname IN ".$field_list;
+		$query  = "SELECT DISTINCT vtiger_field.fieldname
+			FROM vtiger_field
+			INNER JOIN vtiger_profile2field
+				ON vtiger_profile2field.fieldid = vtiger_field.fieldid
+			INNER JOIN vtiger_def_org_field
+				ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
+			WHERE vtiger_field.tabid = ".$tabid."
+			AND vtiger_profile2field.visible = 0
+			AND vtiger_def_org_field.visible = 0
+			AND vtiger_profile2field.profileid IN ".$profileList."
+			AND vtiger_field.fieldname IN ".$field_list;
 		$result = $adb->query($query);
 		$field=Array();
 		for($k=0;$k < $adb->num_rows($result);$k++)
@@ -507,7 +507,7 @@
 	$ui_col_array=Array();
 
 	$query = "SELECT uitype, columnname, fieldname
-		FROM field
+		FROM vtiger_field
 		WHERE tabid = ".$tabid."
 		AND fieldname IN".$field_list;
 	$result = $adb->query($query);
@@ -555,7 +555,7 @@
 		{
 			$fieldname = $focus->list_fields_name[$name];
 
-			//added for customview 27/5
+			//added for vtiger_customview 27/5
 			if($oCv)
 			{
 				if(isset($oCv->list_fields_name))
@@ -655,7 +655,7 @@
 					}
 					elseif($name=='Account Name')
 					{
-						//modified for customview 27/5
+						//modified for vtiger_customview 27/5
 						if($module == 'Accounts')
 						{
 							$account_id = $adb->query_result($list_result,$i-1,"crmid");
@@ -754,7 +754,7 @@
 *Param $returnset - list query parameters in url string
 *Param $edit_action - Edit action value
 *Param $del_action - delete action value
-*Param $oCv - customview object
+*Param $oCv - vtiger_customview object
 *Returns an array type
 */
 
@@ -770,7 +770,7 @@
 	$image_path=$theme_path."images/";
 	$list_block = Array();
 
-	//getting the fieldtable entries from database
+	//getting the vtiger_fieldtable entries from database
 	$tabid = getTabid($module);
 	require('user_privileges/user_privileges_'.$current_user->id.'.php');
 	
@@ -791,17 +791,17 @@
 	if($is_admin==false)
 	{
 		$profileList = getCurrentUserProfileList();
-		$query  = "SELECT DISTINCT field.fieldname
-			FROM field
-			INNER JOIN profile2field
-				ON profile2field.fieldid = field.fieldid
-			INNER JOIN def_org_field
-				ON def_org_field.fieldid = field.fieldid
-			WHERE field.tabid = ".$tabid."
-			AND profile2field.visible = 0
-			AND def_org_field.visible = 0
-			AND profile2field.profileid IN ".$profileList."
-			AND field.fieldname IN ".$field_list;
+		$query  = "SELECT DISTINCT vtiger_field.fieldname
+			FROM vtiger_field
+			INNER JOIN vtiger_profile2field
+				ON vtiger_profile2field.fieldid = vtiger_field.fieldid
+			INNER JOIN vtiger_def_org_field
+				ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
+			WHERE vtiger_field.tabid = ".$tabid."
+			AND vtiger_profile2field.visible = 0
+			AND vtiger_def_org_field.visible = 0
+			AND vtiger_profile2field.profileid IN ".$profileList."
+			AND vtiger_field.fieldname IN ".$field_list;
 		$result = $adb->query($query);
 		$field=Array();
 		for($k=0;$k < $adb->num_rows($result);$k++)
@@ -813,7 +813,7 @@
 	$ui_col_array=Array();
 
 	$query = "SELECT uitype, columnname, fieldname
-		FROM field
+		FROM vtiger_field
 		WHERE tabid=".$tabid."
 		AND fieldname IN ".$field_list;
 	$result = $adb->query($query);
@@ -844,17 +844,17 @@
 				if($is_admin==false)
 				{
 					$profileList = getCurrentUserProfileList();
-					$query = "SELECT profile2field.*
-						FROM field
-						INNER JOIN profile2field
-						ON profile2field.fieldid = field.fieldid
-						INNER JOIN def_org_field
-						ON def_org_field.fieldid = field.fieldid
-						WHERE field.tabid = ".$tabid."
-						AND profile2field.visible = 0
-						AND def_org_field.visible = 0
-						AND profile2field.profileid IN ".$profileList."
-						AND field.fieldname = '".$fieldname."'";
+					$query = "SELECT vtiger_profile2field.*
+						FROM vtiger_field
+						INNER JOIN vtiger_profile2field
+						ON vtiger_profile2field.fieldid = vtiger_field.fieldid
+						INNER JOIN vtiger_def_org_field
+						ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
+						WHERE vtiger_field.tabid = ".$tabid."
+						AND vtiger_profile2field.visible = 0
+						AND vtiger_def_org_field.visible = 0
+						AND vtiger_profile2field.profileid IN ".$profileList."
+						AND vtiger_field.fieldname = '".$fieldname."'";
 
 					$result = $adb->query($query);
 				}
@@ -927,10 +927,10 @@
 }
 
 
-/**This function generates the value for a given field namee 
-*Param $field_result - field result in array
+/**This function generates the value for a given vtiger_field namee 
+*Param $field_result - vtiger_field result in array
 *Param $list_result - resultset of a listview query
-*Param $fieldname - field name
+*Param $fieldname - vtiger_field name
 *Param $focus - module object
 *Param $module - module name
 *Param $entity_id - entity id
@@ -993,7 +993,7 @@
 	elseif($uitype == 71 || $uitype == 72)
 	{
 		if($temp_val != '' && $temp_val != 0)
-		{       //changes made to remove currency symbol infront of each potential amount
+		{       //changes made to remove vtiger_currency symbol infront of each vtiger_potential amount
                         $value = $temp_val;
 		}
 		else
@@ -1029,7 +1029,7 @@
 		global $adb;
 		if($temp_val != '')
                 {
-			$sql="SELECT * FROM contactdetails WHERE contactid=".$temp_val;		
+			$sql="SELECT * FROM vtiger_contactdetails WHERE contactid=".$temp_val;		
 			$result=$adb->query($sql);
 			$firstname=$adb->query_result($result,0,"firstname");
 			$lastname=$adb->query_result($result,0,"lastname");
@@ -1057,7 +1057,7 @@
 	{
 			global $adb;
 
-	$attachmentid=$adb->query_result($adb->query("SELECT * FROM seattachmentsrel WHERE crmid = ".$entity_id),0,'attachmentsid');
+	$attachmentid=$adb->query_result($adb->query("SELECT * FROM vtiger_seattachmentsrel WHERE crmid = ".$entity_id),0,'attachmentsid');
 	$value = '<a href = "index.php?module=uploads&action=downloadfile&return_module='.$module.'&fileid='.$attachmentid.'&filename='.$temp_val.'">'.$temp_val.'</a>';
 
 	}
@@ -1349,9 +1349,9 @@
 						if($emailaddress == '')
 							$emailaddress=$adb->query_result($list_result,$list_result_count,"email2");
 
-						$querystr="SELECT fieldid,fieldlabel,columnname FROM field WHERE tabid=".getTabid($module)." and uitype=13;";
+						$querystr="SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=".getTabid($module)." and uitype=13;";
 						$queryres = $adb->query($querystr);
-						//Change this index 0 - to get the fieldid based on email1 or email2
+						//Change this index 0 - to get the vtiger_fieldid based on email1 or email2
 						$fieldid = $adb->query_result($queryres,0,'fieldid');
 
 						$value = '<a href="a" LANGUAGE=javascript onclick=\'return set_return_emails('.$entity_id.','.$fieldid.',"'.$name.'","'.$emailaddress.'"); \'>'.$name.'</a>';
@@ -1365,9 +1365,9 @@
 						if($emailaddress == '')
 							$emailaddress=$adb->query_result($list_result,$list_result_count,"yahooid");
 
-						$querystr="SELECT fieldid,fieldlabel,columnname FROM field WHERE tabid=".getTabid($module)." and uitype=13;";
+						$querystr="SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=".getTabid($module)." and uitype=13;";
 						$queryres = $adb->query($querystr);
-						//Change this index 0 - to get the fieldid based on email or yahooid
+						//Change this index 0 - to get the vtiger_fieldid based on email or yahooid
 						$fieldid = $adb->query_result($queryres,0,'fieldid');
 
 						//$value = '<a href="javascript: submitform('.$entity_id.');">'.$name.'</a>';
@@ -1403,7 +1403,7 @@
 				{
 					if($module == "Contacts")
                                         {
-                                                 $query="SELECT contactdetails.imagename FROM contactdetails WHERE lastname='".$temp_val."'";
+                                                 $query="SELECT vtiger_contactdetails.imagename FROM vtiger_contactdetails WHERE lastname='".$temp_val."'";
                                                 //echo $query;
                                                  $result = $adb->query($query);
                                                  $imagename=$adb->query_result($result,0,'imagename');
@@ -1462,7 +1462,7 @@
 		}
 	}
 	
-	// Mike Crowe Mod --------------------------------------------------------Make right justified and currency value
+	// Mike Crowe Mod --------------------------------------------------------Make right justified and vtiger_currency value
 	if ( in_array($uitype,array(71,72,7,9,90)) )
 	{
 		$value = '<span align="right">'.$value.'</div>';
@@ -1484,29 +1484,29 @@
 	$tab_id = getTabid($module);	
 	if($module == "HelpDesk")
 	{
-		$query = "SELECT crmentity.crmid, crmentity.smownerid,
-				troubletickets.title, troubletickets.status,
-				troubletickets.priority, troubletickets.parent_id,
-				contactdetails.contactid, contactdetails.firstname,
-				contactdetails.lastname, account.accountid,
-				account.accountname, ticketcf.*
-			FROM troubletickets
-			INNER JOIN ticketcf
-				ON ticketcf.ticketid = troubletickets.ticketid
-			INNER JOIN crmentity
-				ON crmentity.crmid = troubletickets.ticketid
-			LEFT JOIN ticketgrouprelation
-				ON troubletickets.ticketid = ticketgrouprelation.ticketid
-			LEFT JOIN groups
-				ON groups.groupname = ticketgrouprelation.groupname
-			LEFT JOIN contactdetails
-				ON troubletickets.parent_id = contactdetails.contactid
-			LEFT JOIN account
-				ON account.accountid = troubletickets.parent_id
-			LEFT JOIN users
-				ON crmentity.smownerid = users.id
-				AND troubletickets.ticketid = ticketcf.ticketid
-			WHERE crmentity.deleted = 0 ";
+		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
+			vtiger_troubletickets.title, vtiger_troubletickets.status,
+			vtiger_troubletickets.priority, vtiger_troubletickets.parent_id,
+			vtiger_contactdetails.contactid, vtiger_contactdetails.firstname,
+			vtiger_contactdetails.lastname, vtiger_account.accountid,
+			vtiger_account.accountname, vtiger_ticketcf.*
+			FROM vtiger_troubletickets
+			INNER JOIN vtiger_ticketcf
+				ON vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid
+			LEFT JOIN vtiger_ticketgrouprelation
+				ON vtiger_troubletickets.ticketid = vtiger_ticketgrouprelation.ticketid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_troubletickets.parent_id = vtiger_contactdetails.contactid
+			LEFT JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_troubletickets.parent_id
+			LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id
+				AND vtiger_troubletickets.ticketid = vtiger_ticketcf.ticketid
+			WHERE vtiger_crmentity.deleted = 0 ";
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
 				$sec_parameter=getListViewSecurityParameter($module);
@@ -1518,60 +1518,60 @@
 	if($module == "Accounts")
 	{
 		//Query modified to sort by assigned to
-		$query = "SELECT crmentity.crmid, crmentity.smownerid,
-				account.accountname, account.email1,
-				account.email2, account.website, account.phone,
-				accountbillads.city,
-				accountscf.*
-			FROM account
-			INNER JOIN crmentity
-				ON crmentity.crmid = account.accountid
-			INNER JOIN accountbillads
-				ON account.accountid = accountbillads.accountaddressid
-			INNER JOIN accountshipads
-				ON account.accountid = accountshipads.accountaddressid
-			INNER JOIN accountscf
-				ON account.accountid = accountscf.accountid
-			LEFT JOIN accountgrouprelation
-				ON accountscf.accountid = accountgrouprelation.accountid
-			LEFT JOIN groups
-				ON groups.groupname = accountgrouprelation.groupname
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			WHERE crmentity.deleted = 0 ";
+		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
+			vtiger_account.accountname, vtiger_account.email1,
+			vtiger_account.email2, vtiger_account.website, vtiger_account.phone,
+			vtiger_accountbillads.city,
+			vtiger_accountscf.*
+			FROM vtiger_account
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_account.accountid
+			INNER JOIN vtiger_accountbillads
+				ON vtiger_account.accountid = vtiger_accountbillads.accountaddressid
+			INNER JOIN vtiger_accountshipads
+				ON vtiger_account.accountid = vtiger_accountshipads.accountaddressid
+			INNER JOIN vtiger_accountscf
+				ON vtiger_account.accountid = vtiger_accountscf.accountid
+			LEFT JOIN vtiger_accountgrouprelation
+				ON vtiger_accountscf.accountid = vtiger_accountgrouprelation.accountid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_accountgrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			WHERE vtiger_crmentity.deleted = 0 ";
 
 	if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
                 {
-                    $query .= "AND (crmentity.smownerid IN (".$current_user->id.")
-		   		 OR crmentity.smownerid IN (
-					 SELECT user2role.userid
-					 FROM user2role
-					 INNER JOIN users
-						 ON users.id = user2role.userid
-					 INNER JOIN role
-						 ON role.roleid = user2role.roleid
-					 WHERE role.parentrole LIKE '".$current_user_parent_role_seq."::%')
-					 OR crmentity.smownerid IN (
+                    $query .= "AND (vtiger_crmentity.smownerid IN (".$current_user->id.")
+		   		 OR vtiger_crmentity.smownerid IN (
+					 SELECT vtiger_user2role.userid
+					 FROM vtiger_user2role
+					 INNER JOIN vtiger_users
+						 ON vtiger_users.id = vtiger_user2role.userid
+					 INNER JOIN vtiger_role
+						 ON vtiger_role.roleid = vtiger_user2role.roleid
+					 WHERE vtiger_role.parentrole LIKE '".$current_user_parent_role_seq."::%')
+					 OR vtiger_crmentity.smownerid IN (
 						 SELECT shareduserid
-						 FROM tmp_read_user_sharing_per
+						 FROM vtiger_tmp_read_user_sharing_per
 						 WHERE userid=".$current_user->id."
 						 AND tabid=".$tab_id.")
-					 OR (crmentity.smownerid in (0)
+					 OR (vtiger_crmentity.smownerid in (0)
 					 AND (";
 
                         if(sizeof($current_user_groups) > 0)
                         {
                               $query .= "accountgrouprelation.groupname IN (
 				      		SELECT groupname
-						FROM groups
+						FROM vtiger_groups
 						WHERE groupid IN ".getCurrentUserGroupList().")
 					OR ";
                         }
                          $query .= "accountgrouprelation.groupname IN (
-				 	SELECT groups.groupname
-					FROM tmp_read_group_sharing_per
-					INNER JOIN groups
-						ON groups.groupid = tmp_read_group_sharing_per.sharedgroupid
+				 	SELECT vtiger_groups.groupname
+					FROM vtiger_tmp_read_group_sharing_per
+					INNER JOIN vtiger_groups
+						ON vtiger_groups.groupid = vtiger_tmp_read_group_sharing_per.sharedgroupid
 					WHERE userid=".$current_user->id."
 					AND tabid=".$tab_id.")))) ";
                 }
@@ -1580,27 +1580,27 @@
 	if ($module == "Potentials")
 	{
 		//Query modified to sort by assigned to
-		$query = "SELECT crmentity.crmid, crmentity.smownerid,
-				account.accountname,
-				potential.accountid, potential.potentialname,
-				potential.sales_stage, potential.amount,
-				potential.currency, potential.closingdate,
-				potential.typeofrevenue,
-				potentialscf.*
-			FROM potential
-			INNER JOIN crmentity
-				ON crmentity.crmid = potential.potentialid
-			INNER JOIN account
-				ON potential.accountid = account.accountid
-			INNER JOIN potentialscf
-				ON potentialscf.potentialid = potential.potentialid
-			LEFT JOIN potentialgrouprelation
-				ON potential.potentialid = potentialgrouprelation.potentialid
-			LEFT JOIN groups
-				ON groups.groupname = potentialgrouprelation.groupname
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			WHERE crmentity.deleted = 0 ".$where; 
+		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
+			vtiger_account.accountname,
+			vtiger_potential.accountid, vtiger_potential.potentialname,
+			vtiger_potential.sales_stage, vtiger_potential.amount,
+			vtiger_potential.currency, vtiger_potential.closingdate,
+			vtiger_potential.typeofrevenue,
+			vtiger_potentialscf.*
+			FROM vtiger_potential
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_potential.potentialid
+			INNER JOIN vtiger_account
+				ON vtiger_potential.accountid = vtiger_account.accountid
+			INNER JOIN vtiger_potentialscf
+				ON vtiger_potentialscf.potentialid = vtiger_potential.potentialid
+			LEFT JOIN vtiger_potentialgrouprelation
+				ON vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			WHERE vtiger_crmentity.deleted = 0 ".$where; 
 
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
@@ -1612,28 +1612,28 @@
 	}
 	if($module == "Leads")
 	{
-		$query = "SELECT crmentity.crmid, crmentity.smownerid,
-				leaddetails.firstname, leaddetails.lastname,
-				leaddetails.company, leadaddress.phone,
-				leadsubdetails.website, leaddetails.email,
-				leadscf.*
-			FROM leaddetails
-			INNER JOIN crmentity
-				ON crmentity.crmid = leaddetails.leadid
-			INNER JOIN leadsubdetails
-				ON leadsubdetails.leadsubscriptionid = leaddetails.leadid
-			INNER JOIN leadaddress
-				ON leadaddress.leadaddressid = leadsubdetails.leadsubscriptionid
-			INNER JOIN leadscf
-				ON leaddetails.leadid = leadscf.leadid
-			LEFT JOIN leadgrouprelation
-				ON leadscf.leadid = leadgrouprelation.leadid
-			LEFT JOIN groups
-				ON groups.groupname = leadgrouprelation.groupname
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			WHERE crmentity.deleted = 0
-			AND leaddetails.converted = 0 ";
+		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
+			vtiger_leaddetails.firstname, vtiger_leaddetails.lastname,
+			vtiger_leaddetails.company, vtiger_leadaddress.phone,
+			vtiger_leadsubdetails.website, vtiger_leaddetails.email,
+			vtiger_leadscf.*
+			FROM vtiger_leaddetails
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_leaddetails.leadid
+			INNER JOIN vtiger_leadsubdetails
+				ON vtiger_leadsubdetails.leadsubscriptionid = vtiger_leaddetails.leadid
+			INNER JOIN vtiger_leadaddress
+				ON vtiger_leadaddress.leadaddressid = vtiger_leadsubdetails.leadsubscriptionid
+			INNER JOIN vtiger_leadscf
+				ON vtiger_leaddetails.leadid = vtiger_leadscf.leadid
+			LEFT JOIN vtiger_leadgrouprelation
+				ON vtiger_leadscf.leadid = vtiger_leadgrouprelation.leadid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_leadgrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_leaddetails.converted = 0 ";
                if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
                 {
 			$sec_parameter=getListViewSecurityParameter($module);
@@ -1642,75 +1642,75 @@
 	}
 	if($module == "Products")
 	{
-		$query = "SELECT crmentity.crmid, products.*, productcf.*
-			FROM products
-			INNER JOIN crmentity
-				ON crmentity.crmid = products.productid
-			LEFT JOIN productcf
-				ON products.productid = productcf.productid
-			LEFT JOIN seproductsrel
-				ON seproductsrel.productid = products.productid
-			WHERE crmentity.deleted = 0
-			AND ((seproductsrel.crmid IS NULL
-					AND (products.contactid = 0
-						OR products.contactid IS NULL))
-				OR seproductsrel.crmid IN (".getReadEntityIds('Leads').")
-				OR seproductsrel.crmid IN (".getReadEntityIds('Accounts').")
-				OR seproductsrel.crmid IN (".getReadEntityIds('Potentials').")
-				OR products.contactid IN (".getReadEntityIds('Contacts').")) ";
+		$query = "SELECT vtiger_crmentity.crmid, vtiger_products.*, vtiger_productcf.*
+			FROM vtiger_products
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_products.productid
+			LEFT JOIN vtiger_productcf
+				ON vtiger_products.productid = vtiger_productcf.productid
+			LEFT JOIN vtiger_seproductsrel
+				ON vtiger_seproductsrel.productid = vtiger_products.productid
+			WHERE vtiger_crmentity.deleted = 0
+			AND ((vtiger_seproductsrel.crmid IS NULL
+					AND (vtiger_products.contactid = 0
+						OR vtiger_products.contactid IS NULL))
+				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Leads').")
+				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Accounts').")
+				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Potentials').")
+				OR vtiger_products.contactid IN (".getReadEntityIds('Contacts').")) ";
 	}
         if($module == "Notes")
         {
-		$query = "SELECT crmentity.crmid, crmentity.modifiedtime,
-				notes.title, notes.contact_id, notes.filename,
-				senotesrel.crmid AS relatedto,
-				contactdetails.firstname, contactdetails.lastname,
-				notes.*
-			FROM notes
-			INNER JOIN crmentity
-				ON crmentity.crmid = notes.notesid
-			LEFT JOIN senotesrel
-				ON senotesrel.notesid = notes.notesid
-			LEFT JOIN contactdetails
-				ON contactdetails.contactid = notes.contact_id
-			WHERE crmentity.deleted = 0
-			AND ((senotesrel.crmid IS NULL
-					AND (notes.contact_id = 0
-						OR notes.contact_id IS NULL))
-				OR senotesrel.crmid IN (".getReadEntityIds('Leads').")
-				OR senotesrel.crmid IN (".getReadEntityIds('Accounts').")
-				OR senotesrel.crmid IN (".getReadEntityIds('Potentials').")
-				OR senotesrel.crmid IN (".getReadEntityIds('Products').")
-				OR senotesrel.crmid IN (".getReadEntityIds('Invoice').")
-				OR senotesrel.crmid IN (".getReadEntityIds('PurchaseOrder').")
-				OR senotesrel.crmid IN (".getReadEntityIds('SalesOrder').")
-				OR notes.contact_id IN (".getReadEntityIds('Contacts').")) ";
+		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.modifiedtime,
+			vtiger_notes.title, vtiger_notes.contact_id, vtiger_notes.filename,
+			vtiger_senotesrel.crmid AS relatedto,
+			vtiger_contactdetails.firstname, vtiger_contactdetails.lastname,
+			vtiger_notes.*
+			FROM vtiger_notes
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_notes.notesid
+			LEFT JOIN vtiger_senotesrel
+				ON vtiger_senotesrel.notesid = vtiger_notes.notesid
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_contactdetails.contactid = vtiger_notes.contact_id
+			WHERE vtiger_crmentity.deleted = 0
+			AND ((vtiger_senotesrel.crmid IS NULL
+					AND (vtiger_notes.contact_id = 0
+						OR vtiger_notes.contact_id IS NULL))
+				OR vtiger_senotesrel.crmid IN (".getReadEntityIds('Leads').")
+				OR vtiger_senotesrel.crmid IN (".getReadEntityIds('Accounts').")
+				OR vtiger_senotesrel.crmid IN (".getReadEntityIds('Potentials').")
+				OR vtiger_senotesrel.crmid IN (".getReadEntityIds('Products').")
+				OR vtiger_senotesrel.crmid IN (".getReadEntityIds('Invoice').")
+				OR vtiger_senotesrel.crmid IN (".getReadEntityIds('PurchaseOrder').")
+				OR vtiger_senotesrel.crmid IN (".getReadEntityIds('SalesOrder').")
+				OR vtiger_notes.contact_id IN (".getReadEntityIds('Contacts').")) ";
         }
 	if($module == "Contacts")
         {
 		//Query modified to sort by assigned to
-		$query = "SELECT contactdetails.firstname, contactdetails.lastname,
-				contactdetails.title, contactdetails.accountid,
-				contactdetails.email, contactdetails.phone,
-				crmentity.smownerid, crmentity.crmid
-			FROM contactdetails
-			INNER JOIN crmentity
-				ON crmentity.crmid = contactdetails.contactid
-			INNER JOIN contactaddress
-				ON contactdetails.contactid = contactaddress.contactaddressid
-			INNER JOIN contactsubdetails
-				ON contactaddress.contactaddressid = contactsubdetails.contactsubscriptionid
-			INNER JOIN contactscf
-				ON contactdetails.contactid = contactscf.contactid
-			LEFT JOIN account
-				ON account.accountid = contactdetails.accountid
-			LEFT JOIN contactgrouprelation
-				ON contactscf.contactid = contactgrouprelation.contactid
-			LEFT JOIN groups
-				ON groups.groupname = contactgrouprelation.groupname
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			WHERE crmentity.deleted = 0 ".$where;
+		$query = "SELECT vtiger_contactdetails.firstname, vtiger_contactdetails.lastname,
+			vtiger_contactdetails.title, vtiger_contactdetails.accountid,
+			vtiger_contactdetails.email, vtiger_contactdetails.phone,
+			vtiger_crmentity.smownerid, vtiger_crmentity.crmid
+			FROM vtiger_contactdetails
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
+			INNER JOIN vtiger_contactaddress
+				ON vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid
+			INNER JOIN vtiger_contactsubdetails
+				ON vtiger_contactaddress.contactaddressid = vtiger_contactsubdetails.contactsubscriptionid
+			INNER JOIN vtiger_contactscf
+				ON vtiger_contactdetails.contactid = vtiger_contactscf.contactid
+			LEFT JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_contactdetails.accountid
+			LEFT JOIN vtiger_contactgrouprelation
+				ON vtiger_contactscf.contactid = vtiger_contactgrouprelation.contactid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			WHERE vtiger_crmentity.deleted = 0 ".$where;
 
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
@@ -1720,73 +1720,73 @@
         }
 	if($module == "Activities")
         {
-		$query = "SELECT crmentity.crmid, crmentity.smownerid, crmentity.setype,
-				activity.*,
-				contactdetails.lastname, contactdetails.firstname,
-				contactdetails.contactid,
-				account.accountid, account.accountname,
-				recurringevents.recurringtype
-			FROM activity
-			INNER JOIN crmentity
-				ON crmentity.crmid = activity.activityid
-			LEFT JOIN cntactivityrel
-				ON cntactivityrel.activityid = activity.activityid
-			LEFT JOIN contactdetails
-				ON contactdetails.contactid = cntactivityrel.contactid
-			LEFT JOIN seactivityrel
-				ON seactivityrel.activityid = activity.activityid
-			LEFT JOIN activitygrouprelation
-				ON activitygrouprelation.activityid = crmentity.crmid
-			LEFT JOIN groups
-				ON groups.groupname = activitygrouprelation.groupname
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			LEFT OUTER JOIN account
-				ON account.accountid = contactdetails.accountid
-			LEFT OUTER JOIN recurringevents
-				ON recurringevents.activityid = activity.activityid
-			WHERE crmentity.deleted = 0
-			AND (activity.activitytype = 'Meeting'
-				OR activity.activitytype = 'Call'
-				OR activity.activitytype = 'Task') ".$where;
+		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.setype,
+			vtiger_activity.*,
+			vtiger_contactdetails.lastname, vtiger_contactdetails.firstname,
+			vtiger_contactdetails.contactid,
+			vtiger_account.accountid, vtiger_account.accountname,
+			vtiger_recurringevents.recurringtype
+			FROM vtiger_activity
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_activity.activityid
+			LEFT JOIN vtiger_cntactivityrel
+				ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
+			LEFT JOIN vtiger_seactivityrel
+				ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_activitygrouprelation
+				ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT OUTER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_contactdetails.accountid
+			LEFT OUTER JOIN vtiger_recurringevents
+				ON vtiger_recurringevents.activityid = vtiger_activity.activityid
+			WHERE vtiger_crmentity.deleted = 0
+			AND (vtiger_activity.activitytype = 'Meeting'
+				OR vtiger_activity.activitytype = 'Call'
+				OR vtiger_activity.activitytype = 'Task') ".$where;
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
 			$sec_parameter=getListViewSecurityParameter($module);
 			$query .= $sec_parameter;		
 
 		}
-		//$query .=" group by activity.activityid ";
+		//$query .=" group by vtiger_activity.activityid ";
 		//included by Jaguar
         }
 	if($module == "Emails")
         {
-		$query = "SELECT DISTINCT crmentity.crmid, crmentity.smownerid,
-				activity.activityid, activity.subject,
-				activity.date_start,
-				contactdetails.lastname, contactdetails.firstname,
-				contactdetails.contactid
-			FROM activity
-			INNER JOIN crmentity
-				ON crmentity.crmid = activity.activityid
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			LEFT JOIN seactivityrel
-				ON seactivityrel.activityid = activity.activityid
-			LEFT JOIN contactdetails
-				ON contactdetails.contactid = seactivityrel.crmid
-			LEFT JOIN cntactivityrel
-				ON cntactivityrel.activityid = activity.activityid
-				AND cntactivityrel.contactid = cntactivityrel.contactid
-			LEFT JOIN activitygrouprelation
-				ON activitygrouprelation.activityid = crmentity.crmid
-			LEFT JOIN groups
-				ON groups.groupname = activitygrouprelation.groupname
-			LEFT JOIN salesmanactivityrel
-				ON salesmanactivityrel.activityid = activity.activityid
-			LEFT JOIN emaildetails
-				ON emaildetails.emailid = activity.activityid
-			WHERE activity.activitytype = 'Emails'
-			AND crmentity.deleted = 0 ";
+		$query = "SELECT DISTINCT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
+			vtiger_activity.activityid, vtiger_activity.subject,
+			vtiger_activity.date_start,
+			vtiger_contactdetails.lastname, vtiger_contactdetails.firstname,
+			vtiger_contactdetails.contactid
+			FROM vtiger_activity
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_activity.activityid
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_seactivityrel
+				ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_contactdetails.contactid = vtiger_seactivityrel.crmid
+			LEFT JOIN vtiger_cntactivityrel
+				ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid
+				AND vtiger_cntactivityrel.contactid = vtiger_cntactivityrel.contactid
+			LEFT JOIN vtiger_activitygrouprelation
+				ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
+			LEFT JOIN vtiger_salesmanactivityrel
+				ON vtiger_salesmanactivityrel.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_emaildetails
+				ON vtiger_emaildetails.emailid = vtiger_activity.activityid
+			WHERE vtiger_activity.activitytype = 'Emails'
+			AND vtiger_crmentity.deleted = 0 ";
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
 			$sec_parameter=getListViewSecurityParameter($module);
@@ -1796,61 +1796,61 @@
 
 	if($module == "Faq")
 	{
-		$query = "SELECT crmentity.crmid, crmentity.createdtime, crmentity.modifiedtime,
-				faq.*
-			FROM faq
-			INNER JOIN crmentity
-				ON crmentity.crmid = faq.id
-			LEFT JOIN products
-				ON faq.product_id = products.productid
-			WHERE crmentity.deleted = 0";
+		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.createdtime, vtiger_crmentity.modifiedtime,
+			vtiger_faq.*
+			FROM vtiger_faq
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_faq.id
+			LEFT JOIN vtiger_products
+				ON vtiger_faq.product_id = vtiger_products.productid
+			WHERE vtiger_crmentity.deleted = 0";
 	}
 	
 	if($module == "Vendors")
 	{
-		$query = "SELECT crmentity.crmid, vendor.*
-			FROM vendor
-			INNER JOIN crmentity
-				ON crmentity.crmid = vendor.vendorid
-			WHERE crmentity.deleted = 0";
+		$query = "SELECT vtiger_crmentity.crmid, vtiger_vendor.*
+			FROM vtiger_vendor
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_vendor.vendorid
+			WHERE vtiger_crmentity.deleted = 0";
 	}
 	if($module == "PriceBooks")
 	{
-		$query = "SELECT crmentity.crmid, pricebook.*
-			FROM pricebook
-			INNER JOIN crmentity
-				ON crmentity.crmid = pricebook.pricebookid
-			WHERE crmentity.deleted = 0";
+		$query = "SELECT vtiger_crmentity.crmid, vtiger_pricebook.*
+			FROM vtiger_pricebook
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_pricebook.pricebookid
+			WHERE vtiger_crmentity.deleted = 0";
 	}
 	if($module == "Quotes")
 	{
 		//Query modified to sort by assigned to
-		$query = "SELECT crmentity.*,
-				quotes.*,
-				quotesbillads.*,
-				quotesshipads.*,
-				potential.potentialname,
-				account.accountname
-			FROM quotes
-			INNER JOIN crmentity
-				ON crmentity.crmid = quotes.quoteid
-			INNER JOIN quotesbillads
-				ON quotes.quoteid = quotesbillads.quotebilladdressid
-			INNER JOIN quotesshipads
-				ON quotes.quoteid = quotesshipads.quoteshipaddressid
-			LEFT JOIN quotescf
-				ON quotes.quoteid = quotescf.quoteid
-			LEFT OUTER JOIN account
-				ON account.accountid = quotes.accountid
-			LEFT OUTER JOIN potential
-				ON potential.potentialid = quotes.potentialid
-			LEFT JOIN quotegrouprelation
-				ON quotes.quoteid = quotegrouprelation.quoteid
-			LEFT JOIN groups
-				ON groups.groupname = quotegrouprelation.groupname
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			WHERE crmentity.deleted = 0 ".$where;
+		$query = "SELECT vtiger_crmentity.*,
+			vtiger_quotes.*,
+			vtiger_quotesbillads.*,
+			vtiger_quotesshipads.*,
+			vtiger_potential.potentialname,
+			vtiger_account.accountname
+			FROM vtiger_quotes
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_quotes.quoteid
+			INNER JOIN vtiger_quotesbillads
+				ON vtiger_quotes.quoteid = vtiger_quotesbillads.quotebilladdressid
+			INNER JOIN vtiger_quotesshipads
+				ON vtiger_quotes.quoteid = vtiger_quotesshipads.quoteshipaddressid
+			LEFT JOIN vtiger_quotescf
+				ON vtiger_quotes.quoteid = vtiger_quotescf.quoteid
+			LEFT OUTER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_quotes.accountid
+			LEFT OUTER JOIN vtiger_potential
+				ON vtiger_potential.potentialid = vtiger_quotes.potentialid
+			LEFT JOIN vtiger_quotegrouprelation
+				ON vtiger_quotes.quoteid = vtiger_quotegrouprelation.quoteid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_quotegrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			WHERE vtiger_crmentity.deleted = 0 ".$where;
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
 			$sec_parameter=getListViewSecurityParameter($module);
@@ -1860,29 +1860,29 @@
 	if($module == "PurchaseOrder")
         {
 		//Query modified to sort by assigned to
-                $query = "SELECT crmentity.*,
-				purchaseorder.*,
-				pobillads.*,
-				poshipads.*,
-				vendor.vendorname
-			FROM purchaseorder
-			INNER JOIN crmentity
-				ON crmentity.crmid = purchaseorder.purchaseorderid
-			LEFT OUTER JOIN vendor
-				ON purchaseorder.vendorid = vendor.vendorid
-			INNER JOIN pobillads
-				ON purchaseorder.purchaseorderid = pobillads.pobilladdressid
-			INNER JOIN poshipads
-				ON purchaseorder.purchaseorderid = poshipads.poshipaddressid
-			LEFT JOIN purchaseordercf
-				ON purchaseordercf.purchaseorderid = purchaseorder.purchaseorderid
-			LEFT JOIN pogrouprelation
-				ON purchaseorder.purchaseorderid = pogrouprelation.purchaseorderid
-			LEFT JOIN groups
-				ON groups.groupname = pogrouprelation.groupname
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			WHERE crmentity.deleted = 0 ";
+                $query = "SELECT vtiger_crmentity.*,
+			vtiger_purchaseorder.*,
+			vtiger_pobillads.*,
+			vtiger_poshipads.*,
+			vtiger_vendor.vendorname
+			FROM vtiger_purchaseorder
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_purchaseorder.purchaseorderid
+			LEFT OUTER JOIN vtiger_vendor
+				ON vtiger_purchaseorder.vendorid = vtiger_vendor.vendorid
+			INNER JOIN vtiger_pobillads
+				ON vtiger_purchaseorder.purchaseorderid = vtiger_pobillads.pobilladdressid
+			INNER JOIN vtiger_poshipads
+				ON vtiger_purchaseorder.purchaseorderid = vtiger_poshipads.poshipaddressid
+			LEFT JOIN vtiger_purchaseordercf
+				ON vtiger_purchaseordercf.purchaseorderid = vtiger_purchaseorder.purchaseorderid
+			LEFT JOIN vtiger_pogrouprelation
+				ON vtiger_purchaseorder.purchaseorderid = vtiger_pogrouprelation.purchaseorderid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_pogrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			WHERE vtiger_crmentity.deleted = 0 ";
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
 			$sec_parameter=getListViewSecurityParameter($module);
@@ -1892,32 +1892,32 @@
         if($module == "SalesOrder")
         {
 		//Query modified to sort by assigned to
-                $query = "SELECT crmentity.*,
-				salesorder.*,
-				sobillads.*,
-				soshipads.*,
-				quotes.subject AS quotename,
-				account.accountname
-			FROM salesorder
-			INNER JOIN crmentity
-				ON crmentity.crmid = salesorder.salesorderid
-			INNER JOIN sobillads
-				ON salesorder.salesorderid = sobillads.sobilladdressid
-			INNER JOIN soshipads
-				ON salesorder.salesorderid = soshipads.soshipaddressid
-			LEFT JOIN salesordercf
-				ON salesordercf.salesorderid = salesorder.salesorderid
-			LEFT OUTER JOIN quotes
-				ON quotes.quoteid = salesorder.quoteid
-			LEFT OUTER JOIN account
-				ON account.accountid = salesorder.accountid
-			LEFT JOIN sogrouprelation
-				ON salesorder.salesorderid = sogrouprelation.salesorderid
-			LEFT JOIN groups
-				ON groups.groupname = sogrouprelation.groupname
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			WHERE crmentity.deleted = 0 ".$where;
+                $query = "SELECT vtiger_crmentity.*,
+			vtiger_salesorder.*,
+			vtiger_sobillads.*,
+			vtiger_soshipads.*,
+			vtiger_quotes.subject AS quotename,
+			vtiger_account.accountname
+			FROM vtiger_salesorder
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_salesorder.salesorderid
+			INNER JOIN vtiger_sobillads
+				ON vtiger_salesorder.salesorderid = vtiger_sobillads.sobilladdressid
+			INNER JOIN vtiger_soshipads
+				ON vtiger_salesorder.salesorderid = vtiger_soshipads.soshipaddressid
+			LEFT JOIN vtiger_salesordercf
+				ON vtiger_salesordercf.salesorderid = vtiger_salesorder.salesorderid
+			LEFT OUTER JOIN vtiger_quotes
+				ON vtiger_quotes.quoteid = vtiger_salesorder.quoteid
+			LEFT OUTER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_salesorder.accountid
+			LEFT JOIN vtiger_sogrouprelation
+				ON vtiger_salesorder.salesorderid = vtiger_sogrouprelation.salesorderid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_sogrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			WHERE vtiger_crmentity.deleted = 0 ".$where;
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
 			$sec_parameter=getListViewSecurityParameter($module);
@@ -1928,29 +1928,29 @@
 	{
 		//Query modified to sort by assigned to
 		//query modified -Code contribute by Geoff(http://forums.vtiger.com/viewtopic.php?t=3376)
-		$query = "SELECT crmentity.*,
-				invoice.*,
-				invoicebillads.*,
-				invoiceshipads.*,
-				salesorder.subject AS salessubject
-			FROM invoice
-			INNER JOIN crmentity
-				ON crmentity.crmid = invoice.invoiceid
-			INNER JOIN invoicebillads
-				ON invoice.invoiceid = invoicebillads.invoicebilladdressid
-			INNER JOIN invoiceshipads
-				ON invoice.invoiceid = invoiceshipads.invoiceshipaddressid
-			LEFT OUTER JOIN salesorder
-				ON salesorder.salesorderid = invoice.salesorderid
-			INNER JOIN invoicecf
-				ON invoice.invoiceid = invoicecf.invoiceid
-			LEFT JOIN invoicegrouprelation
-				ON invoice.invoiceid = invoicegrouprelation.invoiceid
-			LEFT JOIN groups
-				ON groups.groupname = invoicegrouprelation.groupname
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			WHERE crmentity.deleted = 0 ".$where;
+		$query = "SELECT vtiger_crmentity.*,
+			vtiger_invoice.*,
+			vtiger_invoicebillads.*,
+			vtiger_invoiceshipads.*,
+			vtiger_salesorder.subject AS salessubject
+			FROM vtiger_invoice
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_invoice.invoiceid
+			INNER JOIN vtiger_invoicebillads
+				ON vtiger_invoice.invoiceid = vtiger_invoicebillads.invoicebilladdressid
+			INNER JOIN vtiger_invoiceshipads
+				ON vtiger_invoice.invoiceid = vtiger_invoiceshipads.invoiceshipaddressid
+			LEFT OUTER JOIN vtiger_salesorder
+				ON vtiger_salesorder.salesorderid = vtiger_invoice.salesorderid
+			INNER JOIN vtiger_invoicecf
+				ON vtiger_invoice.invoiceid = vtiger_invoicecf.invoiceid
+			LEFT JOIN vtiger_invoicegrouprelation
+				ON vtiger_invoice.invoiceid = vtiger_invoicegrouprelation.invoiceid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_invoicegrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			WHERE vtiger_crmentity.deleted = 0 ".$where;
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
 			$sec_parameter=getListViewSecurityParameter($module);
@@ -1961,18 +1961,18 @@
 	{
 		//Query modified to sort by assigned to
 		//query modified -Code contribute by Geoff(http://forums.vtiger.com/viewtopic.php?t=3376)
-		$query = "SELECT crmentity.*,
-				campaign.*
-			FROM campaign
-			INNER JOIN crmentity
-				ON crmentity.crmid = campaign.campaignid
-			LEFT JOIN campaigngrouprelation
-				ON campaign.campaignid = campaigngrouprelation.campaignid
-			LEFT JOIN groups
-				ON groups.groupname = campaigngrouprelation.groupname
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			WHERE crmentity.deleted = 0 ".$where;
+		$query = "SELECT vtiger_crmentity.*,
+			vtiger_campaign.*
+			FROM vtiger_campaign
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_campaign.campaignid
+			LEFT JOIN vtiger_campaigngrouprelation
+				ON vtiger_campaign.campaignid = vtiger_campaigngrouprelation.campaignid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_campaigngrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			WHERE vtiger_crmentity.deleted = 0 ".$where;
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
 			$sec_parameter=getListViewSecurityParameter($module);
@@ -1997,16 +1997,16 @@
 
 	if($module == "Leads")
 	{
-		$query = "SELECT crmentity.crmid
-			FROM leaddetails
-			INNER JOIN crmentity
-				ON crmentity.crmid = leaddetails.leadid
-			LEFT JOIN leadgrouprelation
-				ON leaddetails.leadid = leadgrouprelation.leadid
-			LEFT JOIN groups
-                                ON groups.groupname = leadgrouprelation.groupname
-			WHERE crmentity.deleted = 0
-			AND leaddetails.converted = 0 ";
+		$query = "SELECT vtiger_crmentity.crmid
+			FROM vtiger_leaddetails
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_leaddetails.leadid
+			LEFT JOIN vtiger_leadgrouprelation
+				ON vtiger_leaddetails.leadid = vtiger_leadgrouprelation.leadid
+			LEFT JOIN vtiger_groups
+                                ON vtiger_groups.groupname = vtiger_leadgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_leaddetails.converted = 0 ";
                if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
                 {
 			$sec_parameter=getListViewSecurityParameter($module);
@@ -2019,15 +2019,15 @@
 	if($module == "Accounts")
 	{
 		//Query modified to sort by assigned to
-		$query = "SELECT crmentity.crmid
-			FROM account
-			INNER JOIN crmentity
-				ON crmentity.crmid = account.accountid
-			LEFT JOIN accountgrouprelation
-				ON account.accountid = accountgrouprelation.accountid
-			LEFT JOIN groups
-                                ON groups.groupname = accountgrouprelation.groupname
-			WHERE crmentity.deleted = 0 ";
+		$query = "SELECT vtiger_crmentity.crmid
+			FROM vtiger_account
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_account.accountid
+			LEFT JOIN vtiger_accountgrouprelation
+				ON vtiger_account.accountid = vtiger_accountgrouprelation.accountid
+			LEFT JOIN vtiger_groups
+                                ON vtiger_groups.groupname = vtiger_accountgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 ";
 
 	if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
                 {
@@ -2041,15 +2041,15 @@
 	if ($module == "Potentials")
 	{
 		//Query modified to sort by assigned to
-		$query = "SELECT crmentity.crmid
-			FROM potential
-			INNER JOIN crmentity
-				ON crmentity.crmid = potential.potentialid
-			LEFT JOIN potentialgrouprelation
-				ON potential.potentialid = potentialgrouprelation.potentialid
-			LEFT JOIN groups
-                                ON groups.groupname = potentialgrouprelation.groupname
-			WHERE crmentity.deleted = 0 "; 
+		$query = "SELECT vtiger_crmentity.crmid
+			FROM vtiger_potential
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_potential.potentialid
+			LEFT JOIN vtiger_potentialgrouprelation
+				ON vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid
+			LEFT JOIN vtiger_groups
+                                ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 "; 
 
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
@@ -2065,15 +2065,15 @@
 		//Query modified to sort by assigned to
 
 		
-		$query = "SELECT crmentity.crmid
-			FROM contactdetails
-			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 crmentity.deleted = 0 ";
+		$query = "SELECT vtiger_crmentity.crmid
+			FROM vtiger_contactdetails
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
+			LEFT JOIN vtiger_contactgrouprelation
+				ON vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
+			LEFT JOIN vtiger_groups
+                                ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 ";
 
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
@@ -2083,34 +2083,34 @@
         }
 	if($module == "Products")
 	{
-		$query = "SELECT DISTINCT crmentity.crmid
-			FROM products
-			INNER JOIN crmentity
-				ON crmentity.crmid = products.productid
-			LEFT JOIN seproductsrel
-				ON seproductsrel.productid = products.productid
-			WHERE crmentity.deleted = 0
-			AND ((seproductsrel.crmid IS NULL
-					OR products.contactid = 0
-					OR products.contactid IS NULL)
-				OR seproductsrel.crmid IN (".getReadEntityIds('Leads').")
-				OR seproductsrel.crmid IN (".getReadEntityIds('Accounts').")
-				OR seproductsrel.crmid IN (".getReadEntityIds('Potentials').")
-				OR products.contactid IN (".getReadEntityIds('Contacts').")) ";
+		$query = "SELECT DISTINCT vtiger_crmentity.crmid
+			FROM vtiger_products
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_products.productid
+			LEFT JOIN vtiger_seproductsrel
+				ON vtiger_seproductsrel.productid = vtiger_products.productid
+			WHERE vtiger_crmentity.deleted = 0
+			AND ((vtiger_seproductsrel.crmid IS NULL
+					OR vtiger_products.contactid = 0
+					OR vtiger_products.contactid IS NULL)
+				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Leads').")
+				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Accounts').")
+				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Potentials').")
+				OR vtiger_products.contactid IN (".getReadEntityIds('Contacts').")) ";
 	}
 
 	if($module == "PurchaseOrder")
         {
 		//Query modified to sort by assigned to
-                $query = "SELECT crmentity.crmid
-			FROM purchaseorder
-			INNER JOIN crmentity
-				ON crmentity.crmid = purchaseorder.purchaseorderid
-			LEFT JOIN pogrouprelation
-				ON purchaseorder.purchaseorderid = pogrouprelation.purchaseorderid
-			LEFT JOIN groups
-                                ON groups.groupname = pogrouprelation.groupname
-			WHERE crmentity.deleted = 0 ";
+                $query = "SELECT vtiger_crmentity.crmid
+			FROM vtiger_purchaseorder
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_purchaseorder.purchaseorderid
+			LEFT JOIN vtiger_pogrouprelation
+				ON vtiger_purchaseorder.purchaseorderid = vtiger_pogrouprelation.purchaseorderid
+			LEFT JOIN vtiger_groups
+                                ON vtiger_groups.groupname = vtiger_pogrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 ";
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
 			$sec_parameter=getListViewSecurityParameter($module);
@@ -2120,15 +2120,15 @@
         if($module == "SalesOrder")
         {
 		//Query modified to sort by assigned to
-                $query = "SELECT crmentity.crmid
-			FROM salesorder
-			INNER JOIN crmentity
-				ON crmentity.crmid = salesorder.salesorderid
-			LEFT JOIN sogrouprelation
-				ON salesorder.salesorderid = sogrouprelation.salesorderid
-			LEFT JOIN groups
-                                ON groups.groupname = sogrouprelation.groupname
-			WHERE crmentity.deleted = 0 ".$where;
+                $query = "SELECT vtiger_crmentity.crmid
+			FROM vtiger_salesorder
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_salesorder.salesorderid
+			LEFT JOIN vtiger_sogrouprelation
+				ON vtiger_salesorder.salesorderid = vtiger_sogrouprelation.salesorderid
+			LEFT JOIN vtiger_groups
+                                ON vtiger_groups.groupname = vtiger_sogrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 ".$where;
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
 			$sec_parameter=getListViewSecurityParameter($module);
@@ -2137,15 +2137,15 @@
         }
 	if($module == "Invoice")
 	{
-		$query = "SELECT crmentity.crmid
-			FROM invoice
-			INNER JOIN crmentity
-				ON crmentity.crmid = invoice.invoiceid
-			LEFT JOIN invoicegrouprelation
-				ON invoice.invoiceid = invoicegrouprelation.invoiceid
-			LEFT JOIN groups
-				ON groups.groupname = invoicegrouprelation.groupname
-			WHERE crmentity.deleted = 0 ".$where;
+		$query = "SELECT vtiger_crmentity.crmid
+			FROM vtiger_invoice
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_invoice.invoiceid
+			LEFT JOIN vtiger_invoicegrouprelation
+				ON vtiger_invoice.invoiceid = vtiger_invoicegrouprelation.invoiceid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_invoicegrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 ".$where;
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
 			$sec_parameter=getListViewSecurityParameter($module);
@@ -2159,7 +2159,7 @@
 }
 
 
-//parameter $viewid added for customview 27/5
+//parameter $viewid added for vtiger_customview 27/5
 function AlphabeticalSearch($module,$action,$fieldname,$query,$type,$popuptype='',$recordid='',$return_module='',$append_url='',$viewid='',$groupid='')
 {
 	global $log;
@@ -2208,43 +2208,43 @@
 		$parent_name=$app_strings['LBL_MULTIPLE'];
         }
         //Raju -- Ends
-			$parent_query = "SELECT accountname FROM account WHERE accountid=".$seid;
+			$parent_query = "SELECT accountname FROM vtiger_account WHERE accountid=".$seid;
 			$parent_result = $adb->query($parent_query);
 			$parent_name = $adb->query_result($parent_result,0,"accountname");
 		}
 		if($parent_module == 'Leads')
 		{
-			$parent_query = "SELECT firstname,lastname FROM leaddetails WHERE leadid=".$seid;
+			$parent_query = "SELECT firstname,lastname FROM vtiger_leaddetails WHERE leadid=".$seid;
 			$parent_result = $adb->query($parent_query);
 			$parent_name = $adb->query_result($parent_result,0,"lastname")." ".$adb->query_result($parent_result,0,"firstname");
 		}
 		if($parent_module == 'Potentials')
 		{
-			$parent_query = "SELECT potentialname FROM potential WHERE potentialid=".$seid;
+			$parent_query = "SELECT potentialname FROM vtiger_potential WHERE potentialid=".$seid;
 			$parent_result = $adb->query($parent_query);
 			$parent_name = $adb->query_result($parent_result,0,"potentialname");
 		}
 		if($parent_module == 'Products')
 		{
-			$parent_query = "SELECT productname FROM products WHERE productid=".$seid;
+			$parent_query = "SELECT productname FROM vtiger_products WHERE productid=".$seid;
 			$parent_result = $adb->query($parent_query);
 			$parent_name = $adb->query_result($parent_result,0,"productname");
 		}
 		if($parent_module == 'PurchaseOrder')
 		{
-			$parent_query = "SELECT subject FROM purchaseorder WHERE purchaseorderid=".$seid;
+			$parent_query = "SELECT subject FROM vtiger_purchaseorder WHERE purchaseorderid=".$seid;
 			$parent_result = $adb->query($parent_query);
 			$parent_name = $adb->query_result($parent_result,0,"subject");
 		}
 		if($parent_module == 'SalesOrder')
 		{
-			$parent_query = "SELECT subject FROM salesorder WHERE salesorderid=".$seid;
+			$parent_query = "SELECT subject FROM vtiger_salesorder WHERE salesorderid=".$seid;
 			$parent_result = $adb->query($parent_query);
 			$parent_name = $adb->query_result($parent_result,0,"subject");
 		}
 		if($parent_module == 'Invoice')
 		{
-			$parent_query = "SELECT subject FROM invoice WHERE invoiceid=".$seid;
+			$parent_query = "SELECT subject FROM vtiger_invoice WHERE invoiceid=".$seid;
 			$parent_result = $adb->query($parent_query);
 			$parent_name = $adb->query_result($parent_result,0,"subject");
 		}
@@ -2261,7 +2261,7 @@
 }
 
 
-//used in home page listTop files
+//used in home page listTop vtiger_files
 function getRelatedTo($module,$list_result,$rset)
 {
 	global $log;
@@ -2273,36 +2273,36 @@
         {
                 $notesid = $adb->query_result($list_result,$rset,"notesid");
                 $action = "DetailView";
-                $evt_query="SELECT senotesrel.crmid, crmentity.setype
-			FROM senotesrel
-			INNER JOIN crmentity
-				ON  senotesrel.crmid = crmentity.crmid
-			WHERE senotesrel.notesid ='".$notesid."'";
+                $evt_query="SELECT vtiger_senotesrel.crmid, vtiger_crmentity.setype
+			FROM vtiger_senotesrel
+			INNER JOIN vtiger_crmentity
+				ON  vtiger_senotesrel.crmid = vtiger_crmentity.crmid
+			WHERE vtiger_senotesrel.notesid ='".$notesid."'";
 	}else if($module == "Products")
 	{
 		$productid = $adb->query_result($list_result,$rset,"productid");
                 $action = "DetailView";
-                $evt_query="SELECT seproductsrel.crmid, crmentity.setype
-			FROM seproductsrel
-			INNER JOIN crmentity
-				ON seproductsrel.crmid = crmentity.crmid
-			WHERE seproductsrel.productid ='".$productid."'";
+                $evt_query="SELECT vtiger_seproductsrel.crmid, vtiger_crmentity.setype
+			FROM vtiger_seproductsrel
+			INNER JOIN vtiger_crmentity
+				ON vtiger_seproductsrel.crmid = vtiger_crmentity.crmid
+			WHERE vtiger_seproductsrel.productid ='".$productid."'";
 
 	}else
 	{
 		$activity_id = $adb->query_result($list_result,$rset,"activityid");
 		$action = "DetailView";
-		$evt_query="SELECT seactivityrel.crmid, crmentity.setype
-			FROM seactivityrel
-			INNER JOIN crmentity
-				ON  seactivityrel.crmid = crmentity.crmid
-			WHERE seactivityrel.activityid='".$activity_id."'";
+		$evt_query="SELECT vtiger_seactivityrel.crmid, vtiger_crmentity.setype
+			FROM vtiger_seactivityrel
+			INNER JOIN vtiger_crmentity
+				ON  vtiger_seactivityrel.crmid = vtiger_crmentity.crmid
+			WHERE vtiger_seactivityrel.activityid='".$activity_id."'";
 
 		if($module == 'HelpDesk')
 		{
 			$activity_id = $adb->query_result($list_result,$rset,"parent_id");
 			if($activity_id != '')
-				$evt_query = "SELECT * FROM crmentity WHERE crmid=".$activity_id;
+				$evt_query = "SELECT * FROM vtiger_crmentity WHERE crmid=".$activity_id;
 		}
 	}
 	//added by raju to change the related to in emails inot multiple if email is for more than one contact
@@ -2326,55 +2326,55 @@
 	$action = "DetailView";
         if($parent_module == 'Accounts')
         {
-                $parent_query = "SELECT accountname FROM account WHERE accountid=".$parent_id;
+                $parent_query = "SELECT accountname FROM vtiger_account WHERE accountid=".$parent_id;
                 $parent_result = $adb->query($parent_query);
                 $parent_name = $adb->query_result($parent_result,0,"accountname");
         }
         if($parent_module == 'Leads')
         {
-                $parent_query = "SELECT firstname,lastname FROM leaddetails WHERE leadid=".$parent_id;
+                $parent_query = "SELECT firstname,lastname FROM vtiger_leaddetails WHERE leadid=".$parent_id;
                 $parent_result = $adb->query($parent_query);
                 $parent_name = $adb->query_result($parent_result,0,"lastname")." ".$adb->query_result($parent_result,0,"firstname");
         }
         if($parent_module == 'Potentials')
         {
-                $parent_query = "SELECT potentialname FROM potential WHERE potentialid=".$parent_id;
+                $parent_query = "SELECT potentialname FROM vtiger_potential WHERE potentialid=".$parent_id;
                 $parent_result = $adb->query($parent_query);
                 $parent_name = $adb->query_result($parent_result,0,"potentialname");
         }
         if($parent_module == 'Products')
         {
-                $parent_query = "SELECT productname FROM products WHERE productid=".$parent_id;
+                $parent_query = "SELECT productname FROM vtiger_products WHERE productid=".$parent_id;
                 $parent_result = $adb->query($parent_query);
                 $parent_name = $adb->query_result($parent_result,0,"productname");
         }
 	if($parent_module == 'Quotes')
         {
-                $parent_query = "SELECT subject FROM quotes WHERE quoteid=".$parent_id;
+                $parent_query = "SELECT subject FROM vtiger_quotes WHERE quoteid=".$parent_id;
                 $parent_result = $adb->query($parent_query);
                 $parent_name = $adb->query_result($parent_result,0,"subject");
         }
 	if($parent_module == 'PurchaseOrder')
         {
-                $parent_query = "SELECT subject FROM purchaseorder WHERE purchaseorderid=".$parent_id;
+                $parent_query = "SELECT subject FROM vtiger_purchaseorder WHERE purchaseorderid=".$parent_id;
                 $parent_result = $adb->query($parent_query);
                 $parent_name = $adb->query_result($parent_result,0,"subject");
         }
 	if($parent_module == 'Invoice')
         {
-                $parent_query = "SELECT subject FROM invoice WHERE invoiceid=".$parent_id;
+                $parent_query = "SELECT subject FROM vtiger_invoice WHERE invoiceid=".$parent_id;
                 $parent_result = $adb->query($parent_query);
                 $parent_name = $adb->query_result($parent_result,0,"subject");
         }
         if($parent_module == 'SalesOrder')
         {
-                $parent_query = "SELECT subject FROM salesorder WHERE salesorderid=".$parent_id;
+                $parent_query = "SELECT subject FROM vtiger_salesorder WHERE salesorderid=".$parent_id;
                 $parent_result = $adb->query($parent_query);
                 $parent_name = $adb->query_result($parent_result,0,"subject");
         }
 	if($parent_module == 'Contacts' && ($module == 'Emails' || $module == 'HelpDesk'))
         {
-                $parent_query = "SELECT firstname,lastname FROM contactdetails WHERE contactid=".$parent_id;
+                $parent_query = "SELECT firstname,lastname FROM vtiger_contactdetails WHERE contactid=".$parent_id;
                 $parent_result = $adb->query($parent_query);
                 $parent_name = $adb->query_result($parent_result,0,"lastname")." ".$adb->query_result($parent_result,0,"firstname");
         }
@@ -2460,11 +2460,11 @@
 
 	if($currentmodule=="Contacts" && $returnmodule == "Potentials")
 	{
-		$query = "SELECT contactid FROM contpotentialrel WHERE potentialid = ".$recordid;
+		$query = "SELECT contactid FROM vtiger_contpotentialrel WHERE potentialid = ".$recordid;
 	}
 	elseif($currentmodule=="Contacts" && $returnmodule == "Vendors")
 	{
-		$query = "SELECT contactid FROM vendorcontactrel WHERE vendorid = ".$recordid;
+		$query = "SELECT contactid FROM vtiger_vendorcontactrel WHERE vendorid = ".$recordid;
 	}
 
 	if($query !='')
@@ -2477,7 +2477,7 @@
 				$skip_id[]=$adb->query_result($result,$k,"contactid");
 			}
 			$skipids = constructList($skip_id,'INTEGER');
-			$where_relquery = "and contactdetails.contactid not in ".$skipids;
+			$where_relquery = "and vtiger_contactdetails.contactid not in ".$skipids;
 		}
 	}
 	$log->debug("Exiting getRelCheckquery method ...");

Modified: vtigercrm/trunk/include/utils/SearchUtils.php
==============================================================================
--- vtigercrm/trunk/include/utils/SearchUtils.php (original)
+++ vtigercrm/trunk/include/utils/SearchUtils.php Mon Jun 12 14:26:25 2006
@@ -16,7 +16,7 @@
 require_once('include/utils/CommonUtils.php'); //new
 	
 $column_array=array('accountid','contact_id');
-$table_col_array=array('account.accountname','contactdetails.firstname,contactdetails.lastname');
+$table_col_array=array('vtiger_account.accountname','vtiger_contactdetails.firstname,vtiger_contactdetails.lastname');
 
 /**This function is used to get the list view header values in a list view during search
 *Param $focus - module object
@@ -44,10 +44,10 @@
         $image_path=$theme_path."images/";
         $search_header = Array();
 
-        //Get the tabid of the module
+        //Get the vtiger_tabid of the module
         //require_once('include/utils/UserInfoUtil.php')
         $tabid = getTabid($module);
-        //added for customview 27/5
+        //added for vtiger_customview 27/5
         if($oCv)
         {
                 if(isset($oCv->list_fields))
@@ -55,7 +55,7 @@
                         $focus->list_fields = $oCv->list_fields;
                 }
         }
-	//Added to reduce the no. of queries logging for non-admin users -- by Minnie-start
+	//Added to reduce the no. of queries logging for non-admin vtiger_users -- by Minnie-start
 	$field_list ='(';
 	$j=0;
 	require('user_privileges/user_privileges_'.$current_user->id.'.php');
@@ -77,12 +77,12 @@
 		$j++;
 	}
 	$field_list .=')';
-	//Getting the Entries from Profile2 field table
+	//Getting the Entries from Profile2 vtiger_field vtiger_table
 	if($is_admin == false)
 	{
 		$profileList = getCurrentUserProfileList();
-		//changed to get field.fieldname
-		$query  = "select profile2field.*,field.fieldname from field inner join profile2field on profile2field.fieldid=field.fieldid inner join def_org_field on def_org_field.fieldid=field.fieldid where field.tabid=".$tabid." and profile2field.visible=0 and def_org_field.visible=0  and profile2field.profileid in ".$profileList." and field.fieldname in ".$field_list." group by field.fieldid";
+		//changed to get vtiger_field.fieldname
+		$query  = "select vtiger_profile2field.*,vtiger_field.fieldname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=".$tabid." and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0  and vtiger_profile2field.profileid in ".$profileList." and vtiger_field.fieldname in ".$field_list." group by vtiger_field.fieldid";
 		$result = $adb->query($query);
 		$field=Array();
 		for($k=0;$k < $adb->num_rows($result);$k++)
@@ -91,11 +91,11 @@
 		}
 	}
 
-        //modified for customview 27/5 - $app_strings change to $mod_strings
+        //modified for vtiger_customview 27/5 - $app_strings change to $mod_strings
         foreach($focus->list_fields as $name=>$tableinfo)
         {
-                //$fieldname = $focus->list_fields_name[$name];  //commented for customview 27/5
-                //added for customview 27/5
+                //$fieldname = $focus->list_fields_name[$name];  //commented for vtiger_customview 27/5
+                //added for vtiger_customview 27/5
                 if($oCv)
                 {
                         if(isset($oCv->list_fields_name))
@@ -122,7 +122,7 @@
 		{
                         if(isset($focus->sortby_fields) && $focus->sortby_fields !='')
                         {
-                                //Added on 14-12-2005 to avoid if and else check for every list field for arrow image and change order
+                                //Added on 14-12-2005 to avoid if and else check for every list vtiger_field for arrow image and change order
 
                                 foreach($focus->list_fields[$name] as $tab=>$col)
                                 {
@@ -228,7 +228,7 @@
 }
 
 /**This function is used to get user_id's for a given user_name during search
-*Param $table_name - tablename
+*Param $table_name - vtiger_tablename
 *Param $column_name - columnname
 *Param $search_string - searchstring value (username)
 *Returns the where conditions for list query in string format
@@ -240,7 +240,7 @@
 	global $log;
         $log->debug("Entering get_usersid(".$table_name.",".$column_name.",".$search_string.") method ...");
 	global $adb;
-	$user_qry="select distinct(users.id)from users inner join crmentity on crmentity.smownerid=users.id where users.user_name like '%".$search_string."%' ";
+	$user_qry="select distinct(vtiger_users.id)from vtiger_users inner join vtiger_crmentity on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_users.user_name like '%".$search_string."%' ";
 	$user_result=$adb->query($user_qry);
 	$noofuser_rows=$adb->num_rows($user_result);
 	$x=$noofuser_rows-1;
@@ -256,7 +256,7 @@
 				$where .= " or ";
 			}
 		}
-		$where.=" or groups.groupname like '%".$search_string."%')";
+		$where.=" or vtiger_groups.groupname like '%".$search_string."%')";
 	}
 	else
 	{
@@ -267,7 +267,7 @@
 	return $where;	
 }
 
-/**This function is used to get where conditions for a given accountid or contactid during search for their respective names
+/**This function is used to get where conditions for a given vtiger_accountid or contactid during search for their respective names
 *Param $column_name - columnname
 *Param $search_string - searchstring value (username)
 *Returns the where conditions for list query in string format
@@ -331,7 +331,7 @@
 		$where="$table_name.$column_name like '%".$search_string."%'";	
 	}else
 	{	
-		$qry="select field.columnname,tablename from tab inner join field on field.tabid=tab.tabid where name='".$module."' and fieldname='".$search_field."'";
+		$qry="select vtiger_field.columnname,tablename from vtiger_tab inner join vtiger_field on vtiger_field.tabid=vtiger_tab.tabid where name='".$module."' and fieldname='".$search_field."'";
 		$result = $adb->query($qry);
 		$noofrows = $adb->num_rows($result);
 		if($noofrows!=0)
@@ -345,7 +345,7 @@
 			}
 			elseif($table_name == "activity" && $column_name == "status")
 			{
-				$where="$table_name.$column_name like '%".$search_string."%' or activity.eventstatus like '%".$search_string."%'";
+				$where="$table_name.$column_name like '%".$search_string."%' or vtiger_activity.eventstatus like '%".$search_string."%'";
 			}
 			else if(in_array($column_name,$column_array))
 			{
@@ -378,18 +378,18 @@
 
 	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
 	{
-		$sql = "select * from field ";
-		$sql.= " where field.tabid=".$tabid." and";
-		$sql.= " field.displaytype in (1,2)";
+		$sql = "select * from vtiger_field ";
+		$sql.= " where vtiger_field.tabid=".$tabid." and";
+		$sql.= " vtiger_field.displaytype in (1,2)";
 		$sql.= " order by block,sequence";
 	}
 	else
 	{
 		$profileList = getCurrentUserProfileList();
-		$sql = "select * from field inner join profile2field on profile2field.fieldid=field.fieldid inner join def_org_field on def_org_field.fieldid=field.fieldid ";
-		$sql.= " where field.tabid=".$tabid." and";
-		$sql.= " field.displaytype in (1,2) and profile2field.visible=0";
-		$sql.= " and def_org_field.visible=0  and profile2field.profileid in ".$profileList." order by block,sequence";
+		$sql = "select * from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid ";
+		$sql.= " where vtiger_field.tabid=".$tabid." and";
+		$sql.= " vtiger_field.displaytype in (1,2) and vtiger_profile2field.visible=0";
+		$sql.= " and vtiger_def_org_field.visible=0  and vtiger_profile2field.profileid in ".$profileList." order by block,sequence";
 	}
 
 
@@ -410,10 +410,10 @@
 		{
 			$module_columnlist['crmentity:crmid::HelpDesk_Ticket ID:I'] = 'Ticket ID';
 		}
-		//Added to include activity type in activity customview list
+		//Added to include vtiger_activity type in vtiger_activity vtiger_customview list
 		if($module == 'Activities' && $block == 19)
 		{
-			$module_columnlist['activity:activitytype:activitytype:Activities_Activity Type:C'] = 'Activity Type';
+			$module_columnlist['vtiger_activity:activitytype:activitytype:Activities_Activity Type:C'] = 'Activity Type';
 		}
 		if($fieldlabel == "Related To")
 		{
@@ -423,7 +423,7 @@
 		{
 			$fieldlabel = "Start Date";
 			if($module == 'Activities' && $block == 19)
-				$module_columnlist['activity:time_start::Activities_Start Time:I'] = 'Start Time';
+				$module_columnlist['vtiger_activity:time_start::Activities_Start Time:I'] = 'Start Time';
 
 		}
 		$fieldlabel1 = str_replace(" ","_",$fieldlabel);
@@ -456,7 +456,7 @@
 /**This function is returns the where conditions for each search criteria option in Advance Search
 *Param $criteria - search criteria option
 *Param $searchstring - search string
-*Param $searchfield - fieldname to be search for 
+*Param $searchfield - vtiger_fieldname to be search for 
 *Returns the search criteria option (where condition) to be added in list query
 */
 
@@ -608,13 +608,13 @@
 
 	if(isset($date_closed_start) && $date_closed_start != "" && isset($date_closed_end) && $date_closed_end != "")
 	{
-		array_push($where_clauses, "potential.closingdate >= ".$adb->quote($date_closed_start)." and potential.closingdate <= ".$adb->quote($date_closed_end));
+		array_push($where_clauses, "potential.closingdate >= ".$adb->quote($date_closed_start)." and vtiger_potential.closingdate <= ".$adb->quote($date_closed_end));
 		$url_string .= "&closingdate_start=".$date_closed_start."&closingdate_end=".$date_closed_end;
 	}
 	
 	if(isset($sales_stage) && $sales_stage!=''){
 		if($sales_stage=='Other')
-		array_push($where_clauses, "(potential.sales_stage <> 'Closed Won' and potential.sales_stage <> 'Closed Lost')");
+		array_push($where_clauses, "(vtiger_potential.sales_stage <> 'Closed Won' and vtiger_potential.sales_stage <> 'Closed Lost')");
 		else
 		array_push($where_clauses, "potential.sales_stage = ".$adb->quote($sales_stage));
 		$url_string .= "&sales_stage=".$sales_stage;

Modified: vtigercrm/trunk/include/utils/UserInfoUtil.php
==============================================================================
--- vtigercrm/trunk/include/utils/UserInfoUtil.php (original)
+++ vtigercrm/trunk/include/utils/UserInfoUtil.php Mon Jun 12 14:26:25 2006
@@ -26,8 +26,8 @@
 	global $log;
 	$log->debug("Entering getMailServerInfo(".$user.") method ...");
 	global $adb;
-	//$sql= "select rolename from user2role where userid='" .$userid ."'";
-   $sql = "select * from mail_accounts where status=1 and user_id=".$user->id;
+	//$sql= "select vtiger_rolename from vtiger_user2role where userid='" .$userid ."'";
+   $sql = "select * from vtiger_mail_accounts where status=1 and user_id=".$user->id;
         $result = $adb->query($sql);
 	$log->debug("Exiting getMailServerInfo method ...");
 	return $result;
@@ -35,15 +35,15 @@
 
 /** To get the Role of the specified user
   * @param $userid -- The user Id:: Type integer
-  * @returns  roleid :: Type String
+  * @returns  vtiger_roleid :: Type String
  */
 function fetchUserRole($userid)
 {
 	global $log;
 	$log->debug("Entering fetchUserRole(".$userid.") method ...");
 	global $adb;
-	//$sql= "select rolename from user2role where userid='" .$userid ."'";
-	$sql = "select roleid from user2role where userid='" .$userid ."'";
+	//$sql= "select vtiger_rolename from vtiger_user2role where userid='" .$userid ."'";
+	$sql = "select roleid from vtiger_user2role where userid='" .$userid ."'";
         $result = $adb->query($sql);
 	$roleid=  $adb->query_result($result,0,"roleid");
 	$log->debug("Exiting fetchUserRole method ...");
@@ -59,12 +59,12 @@
 	global $log;
 	$log->debug("Entering fetchUserProfileId(".$userid.") method ...");
 	global $adb;
-	$sql = "select roleid from user2role where userid=" .$userid;
+	$sql = "select roleid from vtiger_user2role where userid=" .$userid;
         $result = $adb->query($sql);
 	$roleid=  $adb->query_result($result,0,"roleid");
 
 
-	$sql1 = "select profileid from role2profile where roleid='" .$roleid."'";
+	$sql1 = "select profileid from vtiger_role2profile where roleid='" .$roleid."'";
         $result1 = $adb->query($sql1);
 	$profileid=  $adb->query_result($result1,0,"profileid");
 	$log->debug("Exiting fetchUserProfileId method ...");
@@ -101,7 +101,7 @@
 
         $persistPermArray = Array();
         $profiles = Array();
-        $sql = "select distinct profileid from profile2tab";
+        $sql = "select distinct profileid from vtiger_profile2tab";
         $result = $adb->query($sql);
         $num_rows = $adb->num_rows($result);
         for ( $i=0; $i < $num_rows; $i++ )
@@ -110,7 +110,7 @@
         $persistPermArray = Array();
         foreach ( $profiles as $profileid )
         {
-                $sql = "select * from profile2tab where profileid=" .$profileid ;
+                $sql = "select * from vtiger_profile2tab where profileid=" .$profileid ;
                 $result = $adb->query($sql);
                 if($MAX_TAB_PER !='')
                 {
@@ -127,7 +127,7 @@
 	$log->debug("Exiting loadAllPerms method ...");
 }
 
-/** Function to get all the tab permission for the specified profile
+/** Function to get all the vtiger_tab permission for the specified vtiger_profile
   * @param $profileid -- Profile Id:: Type integer
   * @returns  TabPermission Array in the following format:
   * $tabPermission = Array($tabid1=>permission,
@@ -152,7 +152,7 @@
         }
         else
         {
-                $sql = "select * from profile2tab where profileid=" .$profileid ;
+                $sql = "select * from vtiger_profile2tab where profileid=" .$profileid ;
                 $result = $adb->query($sql);
                 $tab_perr_array = Array();
                 if($MAX_TAB_PER !='')
@@ -173,7 +173,7 @@
 
 }
 
-/** Function to get all the tab permission for the specified profile other than tabid 15
+/** Function to get all the vtiger_tab permission for the specified vtiger_profile other than tabid 15
   * @param $profileid -- Profile Id:: Type integer
   * @returns  TabPermission Array in the following format:
   * $tabPermission = Array($tabid1=>permission,
@@ -201,7 +201,7 @@
         }
         else
         {
-                $sql = "select * from profile2tab where profileid=" .$profileid;
+                $sql = "select * from vtiger_profile2tab where profileid=" .$profileid;
                 $result = $adb->query($sql);
                 $tab_perr_array = Array();
                 $num_rows = $adb->num_rows($result);
@@ -220,7 +220,7 @@
 
 }
 
-/** Function to get all the tab standard action permission for the specified profile
+/** Function to get all the vtiger_tab standard action permission for the specified vtiger_profile
   * @param $profileid -- Profile Id:: Type integer
   * @returns  Tab Action Permission Array in the following format:
   * $tabPermission = Array($tabid1=>Array(actionid1=>permission, actionid2=>permission,...,actionidn=>permission), 
@@ -236,7 +236,7 @@
 	global $adb;
 	$check = Array();
 	$temp_tabid = Array();	
-	$sql1 = "select * from profile2standardpermissions where profileid=".$profileid." and tabid not in(16) order by(tabid)";
+	$sql1 = "select * from vtiger_profile2standardpermissions where profileid=".$profileid." and tabid not in(16) order by(tabid)";
 	//echo $sql1.'<BR>';
 	$result1 = $adb->query($sql1);
         $num_rows1 = $adb->num_rows($result1);
@@ -258,7 +258,7 @@
 	return $check;
 }
 
-/** Function to get all the tab utility action permission for the specified profile
+/** Function to get all the vtiger_tab utility action permission for the specified vtiger_profile
   * @param $profileid -- Profile Id:: Type integer
   * @returns  Tab Utility Action Permission Array in the following format:
   * $tabPermission = Array($tabid1=>Array(actionid1=>permission, actionid2=>permission,...,actionidn=>permission), 
@@ -276,7 +276,7 @@
 	global $adb;
 	$check = Array();
 	$temp_tabid = Array();	
-	$sql1 = "select * from profile2utility where profileid=".$profileid." order by(tabid)";
+	$sql1 = "select * from vtiger_profile2utility where profileid=".$profileid." order by(tabid)";
 	//echo $sql1.'<BR>';
 	$result1 = $adb->query($sql1);
         $num_rows1 = $adb->num_rows($result1);
@@ -317,7 +317,7 @@
 	$log->debug("Entering getDefaultSharingEditAction() method ...");
 	global $adb;
 	//retreiving the standard permissions	
-	$sql= "select * from def_org_share where editstatus=0";
+	$sql= "select * from vtiger_def_org_share where editstatus=0";
 	$result = $adb->query($sql);
 	$permissionRow=$adb->fetch_array($result);
 	do
@@ -348,7 +348,7 @@
 	$log->debug("Entering getDefaultSharingAction() method ...");
 	global $adb;
 	//retreivin the standard permissions	
-	$sql= "select * from def_org_share where editstatus in(0,1)";
+	$sql= "select * from vtiger_def_org_share where editstatus in(0,1)";
 	$result = $adb->query($sql);
 	$permissionRow=$adb->fetch_array($result);
 	do
@@ -381,7 +381,7 @@
 	global $adb;
 	$copy=Array();
 	//retreiving the standard permissions	
-	$sql= "select * from def_org_share";
+	$sql= "select * from vtiger_def_org_share";
 	$result = $adb->query($sql);
 	$num_rows=$adb->num_rows($result);
 
@@ -407,7 +407,7 @@
   global $log;
   $log->debug("Entering setPermittedTabs2Session(".$profileid.") method ...");
   global $adb;
-  $sql = "select tabid from profile2tab where profileid=" .$profileid ." and permissions =0" ;
+  $sql = "select tabid from vtiger_profile2tab where profileid=" .$profileid ." and permissions =0" ;
   $result = $adb->query($sql);
   
   $tabPermission=$adb->fetch_array($result);
@@ -436,7 +436,7 @@
   $log->debug("Entering setPermittedActions2Session(".$profileid.") method ...");
   global $adb;
   $check = Array(); 	
-  $sql1 = "select tabid from profile2tab where profileid=" .$profileid ." and permissions =0" ;
+  $sql1 = "select tabid from vtiger_profile2tab where profileid=" .$profileid ." and permissions =0" ;
   $result1 = $adb->query($sql1);
   $num_rows1 = $adb->num_rows($result1);
   for($i=0; $i<$num_rows1; $i++)
@@ -448,7 +448,7 @@
 	//echo '<BR>';
 
 	//Inserting the Standard Actions into the Array	
-	$sql= "select * from profile2standardpermissions where profileid =".$profileid." and tabid=".$tab_id;
+	$sql= "select * from vtiger_profile2standardpermissions where profileid =".$profileid." and tabid=".$tab_id;
 	$result = $adb->query($sql);
 	$num_rows = $adb->num_rows($result);
 	for($j=0; $j<$num_rows; $j++)
@@ -463,7 +463,7 @@
 	}
 	
 	//Inserting the utility Actions into the Array
-	$sql2= "select * from profile2utility where profileid =".$profileid." and tabid=".$tab_id;
+	$sql2= "select * from vtiger_profile2utility where profileid =".$profileid." and tabid=".$tab_id;
 	$result2 = $adb->query($sql2);
 	$num_rows2 = $adb->num_rows($result2);
 	for($k=0; $k<$num_rows2; $k++)
@@ -496,8 +496,8 @@
 	$log->debug("Entering setPermittedDefaultSharingAction2Session(".$profileid.") method ...");
 	global $adb;
 	//retreiving the standard permissions	
-	//$sql= "select default_org_sharingrule.* from default_org_sharingrule inner join profile2tab on profile2tab.tabid = default_org_sharingrule.tabid where profile2tab.permissions =0 and profile2tab.profileid=".$profileid;
-	$sql = "select * from def_org_share";
+	//$sql= "select default_org_sharingrule.* from default_org_sharingrule inner join vtiger_profile2tab on vtiger_profile2tab.tabid = default_org_sharingrule.tabid where vtiger_profile2tab.permissions =0 and vtiger_profile2tab.profileid=".$profileid;
+	$sql = "select * from vtiger_def_org_share";
 	$result = $adb->query($sql);
 	$permissionRow=$adb->fetch_array($result);
 	do
@@ -514,10 +514,10 @@
 }
 
 
-/** Function to create the role
+/** Function to create the vtiger_role
   * @param $roleName -- Role Name:: Type varchar
   * @param $parentRoleId -- Parent Role Id:: Type varchar
-  * @param $roleProfileArray -- Profile to be associated with this role:: Type Array
+  * @param $roleProfileArray -- Profile to be associated with this vtiger_role:: Type Array
   * @returns  the Rold Id :: Type varchar
   *
  */
@@ -536,11 +536,11 @@
         $nowParentRoleHr=$parentRoleHr.'::'.$roleId;
         $nowRoleDepth=$parentRoleDepth + 1;
 
-	//Inserting role into db
-	$query="insert into role values('".$roleId."','".$roleName."','".$nowParentRoleHr."',".$nowRoleDepth.")";
+	//Inserting vtiger_role into db
+	$query="insert into vtiger_role values('".$roleId."','".$roleName."','".$nowParentRoleHr."',".$nowRoleDepth.")";
 	$adb->query($query);
 
-	//Inserting into role2profile table
+	//Inserting into vtiger_role2profile vtiger_table
 	foreach($roleProfileArray as $profileId)
         {
                 if($profileId != '')
@@ -554,10 +554,10 @@
 
 }
 
-/** Function to update the role
+/** Function to update the vtiger_role
   * @param $roleName -- Role Name:: Type varchar
   * @param $roleId -- Role Id:: Type varchar
-  * @param $roleProfileArray -- Profile to be associated with this role:: Type Array
+  * @param $roleProfileArray -- Profile to be associated with this vtiger_role:: Type Array
   *
  */
 function updateRole($roleId,$roleName,$roleProfileArray)
@@ -565,10 +565,10 @@
 	global $log;
 	$log->debug("Entering updateRole(".$roleId.",".$roleName.",".$roleProfileArray.") method ...");
 	global $adb;
-	$sql1 = "update role set rolename='".$roleName."' where roleid='".$roleId."'";
+	$sql1 = "update vtiger_role set rolename='".$roleName."' where roleid='".$roleId."'";
         $adb->query($sql1);
 	//Updating the Role2Profile relation
-	$sql2 = "delete from role2profile where roleId='".$roleId."'";
+	$sql2 = "delete from vtiger_role2profile where roleId='".$roleId."'";
 	$adb->query($sql2);
 
 	foreach($roleProfileArray as $profileId)
@@ -582,7 +582,7 @@
 	
 }
 
-/** Function to add the role to profile relation
+/** Function to add the vtiger_role to vtiger_profile relation
   * @param $profileId -- Profile Id:: Type integer
   * @param $roleId -- Role Id:: Type varchar
   *
@@ -592,7 +592,7 @@
 	global $log;
 	$log->debug("Entering insertRole2ProfileRelation(".$roleId.",".$profileId.") method ...");
 	global $adb;
-	$query="insert into role2profile values('".$roleId."',".$profileId.")";
+	$query="insert into vtiger_role2profile values('".$roleId."',".$profileId.")";
 	$adb->query($query);	
 	$log->debug("Exiting insertRole2ProfileRelation method ...");
 	
@@ -609,7 +609,7 @@
 	global $log;
 	$log->debug("Entering createNewGroup(".$groupName.",".$groupDescription.") method ...");
 	global $adb;
-	$sql = "insert into groups(name,description) values('" .$groupName ."','". $groupDescription ."')";
+	$sql = "insert into vtiger_groups(name,description) values('" .$groupName ."','". $groupDescription ."')";
 	$result = $adb->query($sql); 
 	$log->debug("Exiting createNewGroup method ...");
 	header("Location: index.php?module=Users&action=listgroups");
@@ -627,7 +627,7 @@
 	global $log;
 	$log->debug("Entering fetchTabId(".$moduleName.") method ...");
 	global $adb;
-	$sql = "select id from tabu where name ='" .$moduleName ."'";
+	$sql = "select id from vtiger_tab where name ='" .$moduleName ."'";
 	$result = $adb->query($sql); 
 	$tabid =  $adb->query_result($result,0,"id");
 	$log->debug("Exiting fetchTabId method ...");
@@ -645,12 +645,12 @@
 	global $log;
 	$log->debug("Entering populatePermissions4NewRole(".$parentroleName.",".$roleName.") method ...");
   global $adb;
-  //fetch the permissions for the parent role
+  //fetch the permissions for the parent vtiger_role
   $referenceValues = fetchTabReferenceEntityValues($parentroleName);
 
   while($permissionRow = $adb->fetch_array($referenceValues))
   {
-    $sql_insert="insert into role2tab(rolename,tabid,module_permission,description) values('" .$roleName ."'," .$permissionRow['tabid'] ."," .$permissionRow['module_permission'] .", '')";
+    $sql_insert="insert into vtiger_role2tab(rolename,tabid,module_permission,description) values('" .$roleName ."'," .$permissionRow['tabid'] ."," .$permissionRow['module_permission'] .", '')";
 
     //echo $sql_insert;
     $adb->query($sql_insert);
@@ -659,7 +659,7 @@
   $actionreferenceValues = fetchActionReferenceEntityValues($parentroleName);
   while($permissionRow = $adb->fetch_array($actionreferenceValues))
   {
-    $sql_insert="insert into role2action(rolename,tabid,actionname,action_permission,description) values('" .$roleName ."'," .$permissionRow['tabid'] .",'" .$permissionRow['actionname'] ."'," .$permissionRow['action_permission'] .", '')";
+    $sql_insert="insert into vtiger_role2action(rolename,tabid,actionname,action_permission,description) values('" .$roleName ."'," .$permissionRow['tabid'] .",'" .$permissionRow['actionname'] ."'," .$permissionRow['action_permission'] .", '')";
     //echo $sql_insert;
     $adb->query($sql_insert);
   }
@@ -677,7 +677,7 @@
 	global $log;
 	$log->debug("Entering fetchTabReferenceEntityValues(".$parentrolename.") method ...");
   global $adb;
-  $sql = "select tabid,module_permission,description from role2tab where rolename='" .$parentrolename ."'"; 
+  $sql = "select tabid,module_permission,description from vtiger_role2tab where rolename='" .$parentrolename ."'"; 
   //echo $sql;
   $result=$adb->query($sql);
 $log->debug("Exiting fetchTabReferenceEntityValues method ...");
@@ -696,13 +696,13 @@
 	global $log;
 $log->debug("Entering fetchActionReferenceEntityValues(".$parentrolename.") method ...");
   global $adb;
-  $sql = "select tabid,actionname,action_permission,description from role2action where rolename='" .$parentrolename ."'"; 
+  $sql = "select tabid,actionname,action_permission,description from vtiger_role2action where rolename='" .$parentrolename ."'"; 
     $result=$adb->query($sql);
 $log->debug("Exiting fetchActionReferenceEntityValues method ...");
   return $result;
 }
 
-/** Function to get the roleid from rolename
+/** Function to get the vtiger_roleid from vtiger_rolename
   * @param $rolename -- Role Name:: Type varchar
   * @returns Role Id:: Type varchar
   *
@@ -713,14 +713,14 @@
 $log->debug("Entering fetchRoleId(".$rolename.") method ...");
 
   global $adb;
-  $sqlfetchroleid = "select roleid from role where rolename='".$rolename ."'";
+  $sqlfetchroleid = "select roleid from vtiger_role where rolename='".$rolename ."'";
   $resultroleid = $adb->query($sqlfetchroleid);
   $role_id = $adb->query_result($resultroleid,0,"roleid");
 $log->debug("Exiting fetchRoleId method ...");
   return $role_id;
 }
 
-/** Function to update user to role mapping based on the userid
+/** Function to update user to vtiger_role mapping based on the userid
   * @param $roleid -- Role Id:: Type varchar
   * @param $userid User Id:: Type integer
   *
@@ -731,14 +731,14 @@
 $log->debug("Entering updateUser2RoleMapping(".$roleid.",".$userid.") method ...");
   global $adb;
   //Check if row already exists
-  $sqlcheck = "select * from user2role where userid=".$userid;
+  $sqlcheck = "select * from vtiger_user2role where userid=".$userid;
   $resultcheck = $adb->query($sqlcheck);
   if($adb->num_rows($resultcheck) == 1)
   {
-  	$sqldelete = "delete from user2role where userid=".$userid;
+  	$sqldelete = "delete from vtiger_user2role where userid=".$userid;
   	$result_delete = $adb->query($sqldelete);
   }	
-  $sql = "insert into user2role(userid,roleid) values(" .$userid .",'" .$roleid ."')";
+  $sql = "insert into vtiger_user2role(userid,roleid) values(" .$userid .",'" .$roleid ."')";
   $result = $adb->query($sql);
 	$log->debug("Exiting updateUser2RoleMapping method ...");
 
@@ -755,14 +755,14 @@
 global $log;
 $log->debug("Entering updateUsers2GroupMapping(".$groupname.",".$userid.") method ...");
   global $adb;
-  $sqldelete = "delete from users2group where userid = '" .$userid ."'";
+  $sqldelete = "delete from vtiger_users2group where userid = '" .$userid ."'";
   $result_delete = $adb->query($sqldelete);
-  $sql = "insert into users2group(groupname,userid) values('" .$groupname ."','" .$userid ."')";
+  $sql = "insert into vtiger_users2group(groupname,userid) values('" .$groupname ."','" .$userid ."')";
   $result = $adb->query($sql);
   $log->debug("Exiting updateUsers2GroupMapping method ...");
 }
 
-/** Function to add user to role mapping 
+/** Function to add user to vtiger_role mapping 
   * @param $roleid -- Role Id:: Type varchar
   * @param $userid User Id:: Type integer
   *
@@ -773,7 +773,7 @@
 $log->debug("Entering insertUser2RoleMapping(".$roleid.",".$userid.") method ...");
 
   global $adb;	
-  $sql = "insert into user2role(userid,roleid) values('" .$userid ."','" .$roleid ."')";
+  $sql = "insert into vtiger_user2role(userid,roleid) values('" .$userid ."','" .$roleid ."')";
  $adb->query($sql); 
 $log->debug("Exiting insertUser2RoleMapping method ...");
 
@@ -789,7 +789,7 @@
 global $log;
 $log->debug("Entering insertUsers2GroupMapping(".$groupname.",".$userid.") method ...");
   global $adb;
-  $sql = "insert into users2group(groupname,userid) values('" .$groupname ."','" .$userid ."')";
+  $sql = "insert into vtiger_users2group(groupname,userid) values('" .$groupname ."','" .$userid ."')";
   $adb->query($sql);
 $log->debug("Exiting insertUsers2GroupMapping method ...");
 }
@@ -804,7 +804,7 @@
 global $log;
 $log->debug("Entering fetchWordTemplateList(".$module.") method ...");
   global $adb;
-  $sql_word = "select templateid, filename from wordtemplates where module ='".$module."'" ; 
+  $sql_word = "select templateid, filename from vtiger_wordtemplates where module ='".$module."'" ; 
   $result=$adb->query($sql_word);
 $log->debug("Exiting fetchWordTemplateList method ...");
   return $result;
@@ -822,7 +822,7 @@
 global $log;
 $log->debug("Entering fetchEmailTemplateInfo(".$templateName.") method ...");
 	global $adb;
-        $sql= "select * from emailtemplates where templatename='" .$templateName ."'";
+        $sql= "select * from vtiger_emailtemplates where templatename='" .$templateName ."'";
         $result = $adb->query($sql);
 $log->debug("Exiting fetchEmailTemplateInfo method ...");
         return $result;
@@ -888,7 +888,7 @@
 	global $log;
 	$log->debug("Entering insert2LeadGroupRelation(".$leadid.",".$groupname.") method ...");
 global $adb;
-  $sql = "insert into leadgrouprelation values (" .$leadid .",'".$groupname."')";
+  $sql = "insert into vtiger_leadgrouprelation values (" .$leadid .",'".$groupname."')";
   $adb->query($sql);
 	$log->debug("Exiting insert2LeadGroupRelation method ...");
 
@@ -904,9 +904,9 @@
 global $log;
 $log->debug("Entering updateLeadGroupRelation(".$leadid.",".$groupname.") method ...");
  global $adb;
-  $sqldelete = "delete from leadgrouprelation where leadid=".$leadid;
+  $sqldelete = "delete from vtiger_leadgrouprelation where leadid=".$leadid;
   $adb->query($sqldelete);
-  $sql = "insert into leadgrouprelation values (".$leadid .",'" .$groupname ."')";  
+  $sql = "insert into vtiger_leadgrouprelation values (".$leadid .",'" .$groupname ."')";  
   $adb->query($sql);
   $log->debug("Exiting updateLeadGroupRelation method ...");
 
@@ -922,7 +922,7 @@
 global $log;
 $log->debug("Entering insert2AccountGroupRelation(".$accountid.",".$groupname.") method ...");
 global $adb;
-  $sql = "insert into accountgrouprelation values (" .$accountid .",'".$groupname."')";
+  $sql = "insert into vtiger_accountgrouprelation values (" .$accountid .",'".$groupname."')";
   $adb->query($sql);
 $log->debug("Exiting insert2AccountGroupRelation method ...");
 
@@ -939,9 +939,9 @@
 global $log;
 $log->debug("Entering updateAccountGroupRelation(".$accountid.",".$groupname.") method ...");
  global $adb;
-  $sqldelete = "delete from accountgrouprelation where accountid=".$accountid;
+  $sqldelete = "delete from vtiger_accountgrouprelation where accountid=".$accountid;
   $adb->query($sqldelete);
-  $sql = "insert into accountgrouprelation values (".$accountid .",'" .$groupname ."')";
+  $sql = "insert into vtiger_accountgrouprelation values (".$accountid .",'" .$groupname ."')";
   $adb->query($sql);
 $log->debug("Exiting updateAccountGroupRelation method ...");
 
@@ -957,7 +957,7 @@
 global $log;
 $log->debug("Entering insert2ContactGroupRelation(".$contactid.",".$groupname.") method ...");
 global $adb;
-  $sql = "insert into contactgrouprelation values (" .$contactid .",'".$groupname."')";
+  $sql = "insert into vtiger_contactgrouprelation values (" .$contactid .",'".$groupname."')";
   $adb->query($sql);
 $log->debug("Exiting insert2ContactGroupRelation method ...");
 
@@ -974,9 +974,9 @@
 global $log;
 $log->debug("Entering updateContactGroupRelation(".$contactid.",".$groupname.") method ...");
  global $adb;
-  $sqldelete = "delete from contactgrouprelation where contactid=".$contactid;
+  $sqldelete = "delete from vtiger_contactgrouprelation where contactid=".$contactid;
   $adb->query($sqldelete);
-  $sql = "insert into contactgrouprelation values (".$contactid .",'" .$groupname ."')";
+  $sql = "insert into vtiger_contactgrouprelation values (".$contactid .",'" .$groupname ."')";
   $adb->query($sql);
 $log->debug("Exiting updateContactGroupRelation method ...");
 
@@ -991,7 +991,7 @@
 global $log;
 $log->debug("Entering insert2PotentialGroupRelation(".$potentialid.",".$groupname.") method ...");
 global $adb;
-  $sql = "insert into potentialgrouprelation values (" .$potentialid .",'".$groupname."')";
+  $sql = "insert into vtiger_potentialgrouprelation values (" .$potentialid .",'".$groupname."')";
   $adb->query($sql);
   $log->debug("Exiting insert2PotentialGroupRelation method ...");
 
@@ -1008,9 +1008,9 @@
 global $log;
 $log->debug("Entering updatePotentialGroupRelation(".$potentialid.",".$groupname.") method ...");
  global $adb;
-  $sqldelete = "delete from potentialgrouprelation where potentialid=".$potentialid;
+  $sqldelete = "delete from vtiger_potentialgrouprelation where potentialid=".$potentialid;
   $adb->query($sqldelete);
-  $sql = "insert into potentialgrouprelation values (".$potentialid .",'" .$groupname ."')";
+  $sql = "insert into vtiger_potentialgrouprelation values (".$potentialid .",'" .$groupname ."')";
   $adb->query($sql);
   $log->debug("Exiting updatePotentialGroupRelation method ...");
 
@@ -1026,7 +1026,7 @@
 global $log;
 $log->debug("Entering insert2QuoteGroupRelation(".$quoteid.",".$groupname.") method ...");
 global $adb;
-  $sql = "insert into quotegrouprelation values (" .$quoteid .",'".$groupname."')";
+  $sql = "insert into vtiger_quotegrouprelation values (" .$quoteid .",'".$groupname."')";
   $adb->query($sql);
 $log->debug("Exiting insert2QuoteGroupRelation method ...");
 
@@ -1043,9 +1043,9 @@
 global $log;
 $log->debug("Entering updateQuoteGroupRelation(".$quoteid.",".$groupname.") method ...");
  global $adb;
-  $sqldelete = "delete from quotegrouprelation where quoteid=".$quoteid;
+  $sqldelete = "delete from vtiger_quotegrouprelation where quoteid=".$quoteid;
   $adb->query($sqldelete);
-  $sql = "insert into quotegrouprelation values (".$quoteid .",'" .$groupname ."')";
+  $sql = "insert into vtiger_quotegrouprelation values (".$quoteid .",'" .$groupname ."')";
   $adb->query($sql);
 $log->debug("Exiting updateQuoteGroupRelation method ...");
 
@@ -1060,7 +1060,7 @@
 global $log;
 $log->debug("Entering insert2SoGroupRelation(".$salesorderid.",".$groupname.") method ...");
 global $adb;
-  $sql = "insert into sogrouprelation values (" .$salesorderid .",'".$groupname."')";
+  $sql = "insert into vtiger_sogrouprelation values (" .$salesorderid .",'".$groupname."')";
   $adb->query($sql);
 $log->debug("Exiting insert2SoGroupRelation method ...");
 
@@ -1077,9 +1077,9 @@
 global $log;
 $log->debug("Entering updateSoGroupRelation(".$salesorderid.",".$groupname.") method ...");
  global $adb;
-  $sqldelete = "delete from sogrouprelation where salesorderid=".$salesorderid;
+  $sqldelete = "delete from vtiger_sogrouprelation where salesorderid=".$salesorderid;
   $adb->query($sqldelete);
-  $sql = "insert into sogrouprelation values (".$salesorderid .",'" .$groupname ."')";
+  $sql = "insert into vtiger_sogrouprelation values (".$salesorderid .",'" .$groupname ."')";
   $adb->query($sql);
 $log->debug("Exiting updateSoGroupRelation method ...");
 
@@ -1095,7 +1095,7 @@
 global $log;
 $log->debug("Entering insert2InvoiceGroupRelation(".$invoiceid.",".$groupname.") method ...");
 global $adb;
-  $sql = "insert into invoicegrouprelation values (" .$invoiceid .",'".$groupname."')";
+  $sql = "insert into vtiger_invoicegrouprelation values (" .$invoiceid .",'".$groupname."')";
   $adb->query($sql);
 $log->debug("Exiting insert2InvoiceGroupRelation method ...");
 
@@ -1112,9 +1112,9 @@
 global $log;
 $log->debug("Entering updateInvoiceGroupRelation(".$invoiceid.",".$groupname.") method ...");
  global $adb;
-  $sqldelete = "delete from invoicegrouprelation where invoiceid=".$invoiceid;
+  $sqldelete = "delete from vtiger_invoicegrouprelation where invoiceid=".$invoiceid;
   $adb->query($sqldelete);
-  $sql = "insert into invoicegrouprelation values (".$invoiceid .",'" .$groupname ."')";
+  $sql = "insert into vtiger_invoicegrouprelation values (".$invoiceid .",'" .$groupname ."')";
   $adb->query($sql);
 $log->debug("Exiting updateInvoiceGroupRelation method ...");
 
@@ -1130,7 +1130,7 @@
 global $log;
 $log->debug("Entering insert2PoGroupRelation(".$poid.",".$groupname.") method ...");
 global $adb;
-  $sql = "insert into pogrouprelation values (" .$poid .",'".$groupname."')";
+  $sql = "insert into vtiger_pogrouprelation values (" .$poid .",'".$groupname."')";
   $adb->query($sql);
 $log->debug("Exiting insert2PoGroupRelation method ...");
 
@@ -1147,9 +1147,9 @@
 global $log;
 $log->debug("Entering updatePoGroupRelation(".$poid.",".$groupname.") method ...");
  global $adb;
-  $sqldelete = "delete from pogrouprelation where purchaseorderid=".$poid;
+  $sqldelete = "delete from vtiger_pogrouprelation where purchaseorderid=".$poid;
   $adb->query($sqldelete);
-  $sql = "insert into pogrouprelation values (".$poid .",'" .$groupname ."')";
+  $sql = "insert into vtiger_pogrouprelation values (".$poid .",'" .$groupname ."')";
   $adb->query($sql);
 $log->debug("Exiting updatePoGroupRelation method ...");
 
@@ -1166,16 +1166,16 @@
 global $log;
 $log->debug("Entering updateTicketGroupRelation(".$ticketid.",".$groupname.") method ...");
  global $adb;
-  $sqldelete = "delete from ticketgrouprelation where ticketid=".$ticketid;
+  $sqldelete = "delete from vtiger_ticketgrouprelation where ticketid=".$ticketid;
   $adb->query($sqldelete);
-  $sql = "insert into ticketgrouprelation values (".$ticketid .",'" .$groupname ."')";  
+  $sql = "insert into vtiger_ticketgrouprelation values (".$ticketid .",'" .$groupname ."')";  
   $adb->query($sql);
 $log->debug("Exiting updateTicketGroupRelation method ...");
 
 }
 
 
-/** Function to insert activity group relation 
+/** Function to insert vtiger_activity group relation 
   * @param $activityid -- Activity Id:: Type integer
   * @param $groupname -- Group Name:: Type varchar
   *
@@ -1185,7 +1185,7 @@
 global $log;
 $log->debug("Entering insert2ActivityGroupRelation(".$activityid.",".$groupname.") method ...");
 global $adb;
-  $sql = "insert into activitygrouprelation values (" .$activityid .",'".$groupname."')";
+  $sql = "insert into vtiger_activitygrouprelation values (" .$activityid .",'".$groupname."')";
   $adb->query($sql);
 $log->debug("Exiting insert2ActivityGroupRelation method ...");
 
@@ -1202,13 +1202,13 @@
 global $log;
 $log->debug("Entering insert2TicketGroupRelation(".$ticketid.",".$groupname.") method ...");
 global $adb;
-  $sql = "insert into ticketgrouprelation values (" .$ticketid .",'".$groupname."')";
+  $sql = "insert into vtiger_ticketgrouprelation values (" .$ticketid .",'".$groupname."')";
   $adb->query($sql);
 $log->debug("Exiting insert2TicketGroupRelation method ...");
 
 }
 
-/** Function to update activity group relation 
+/** Function to update vtiger_activity group relation 
   * @param $activityid -- Activity Id:: Type integer
   * @param $groupname -- Group Name:: Type varchar
   *
@@ -1218,10 +1218,10 @@
 global $log;
 $log->debug("Entering updateActivityGroupRelation(".$activityid.",".$groupname.") method ...");
 	global $adb;
-  $sqldelete = "delete from activitygrouprelation where activityid=".$activityid;
+  $sqldelete = "delete from vtiger_activitygrouprelation where activityid=".$activityid;
   if($groupname != '' && $groupname != 'null') {
 	  $adb->query($sqldelete);
-	  $sql = "insert into activitygrouprelation values (".$activityid .",'" .$groupname ."')";  
+	  $sql = "insert into vtiger_activitygrouprelation values (".$activityid .",'" .$groupname ."')";  
 	  $adb->query($sql);
   }
   $log->debug("Exiting updateActivityGroupRelation method ...");
@@ -1244,7 +1244,7 @@
         {
                 $tabid = 5;
         }
-        $query = "select * from profile2field where profileid =".$profileid." and tabid=".$tabid;
+        $query = "select * from vtiger_profile2field where profileid =".$profileid." and tabid=".$tabid;
         //echo $query;
         $result = $adb->query($query);
 	$log->debug("Exiting getFieldList method ...");
@@ -1266,7 +1266,7 @@
         {
                 $tabid = 5;
         }
-        $query = "select * from profile2field where profileid =".$profileid." and tabid=".$tabid;
+        $query = "select * from vtiger_profile2field where profileid =".$profileid." and tabid=".$tabid;
         //echo $query;
         $result = $adb->query($query);
 	$fldVisbArray = Array();
@@ -1296,7 +1296,7 @@
         {
                 $tabid = 5;
         }
-        $query = "select * from profile2field where profileid =".$profileid." and tabid=".$tabid;
+        $query = "select * from vtiger_profile2field where profileid =".$profileid." and tabid=".$tabid;
         //echo $query;
         $result = $adb->query($query);
 	$fldReadOnlyArray = Array();
@@ -1312,7 +1312,7 @@
 }
 
 
-/** Function to get the role name from the roleid 
+/** Function to get the vtiger_role name from the vtiger_roleid 
   * @param $roleid -- Role Id:: Type varchar
   * @returns $rolename -- Role Name:: Type varchar
   *
@@ -1322,14 +1322,14 @@
 	global $log;
 	$log->debug("Entering getRoleName(".$roleid.") method ...");
 	global $adb;
-	$sql1 = "select * from role where roleid='".$roleid."'";
+	$sql1 = "select * from vtiger_role where roleid='".$roleid."'";
 	$result = $adb->query($sql1);
 	$rolename = $adb->query_result($result,0,"rolename");
 	$log->debug("Exiting getRoleName method ...");
 	return $rolename;	
 }
 
-/** Function to get the profile name from the profileid 
+/** Function to get the vtiger_profile name from the vtiger_profileid 
   * @param $profileid -- Profile Id:: Type integer
   * @returns $rolename -- Role Name:: Type varchar
   *
@@ -1339,7 +1339,7 @@
 	global $log;
 	$log->debug("Entering getProfileName(".$profileid.") method ...");
 	global $adb;
-	$sql1 = "select * from profile where profileid=".$profileid;
+	$sql1 = "select * from vtiger_profile where profileid=".$profileid;
 	$result = $adb->query($sql1);
 	$profilename = $adb->query_result($result,0,"profilename");
 	$log->debug("Exiting getProfileName method ...");
@@ -1398,7 +1398,7 @@
 	//Retreiving the Tabid and Action Id	
 	$tabid = getTabid($module);
 	$actionid=getActionid($actionname);
-	//If no actionid, then allow action is tab permission is available	
+	//If no actionid, then allow action is vtiger_tab permission is available	
 	if($actionid == '')
 	{
 		if($profileTabsPermission[$tabid] ==0)
@@ -1437,7 +1437,7 @@
 
 		}
 	}
-	//Checking for tab permission
+	//Checking for vtiger_tab permission
 	if($profileTabsPermission[$tabid] !=0)
 	{
 		$permission = "no";
@@ -1906,7 +1906,7 @@
 		$defSharingPermissionData = getDefaultSharingAction();
 		$others_permission_id = $defSharingPermissionData[$tabid];
 
-		//Checking whether this tab is allowed
+		//Checking whether this vtiger_tab is allowed
 		if($tab_per_Data[$tabid] == 0)
 		{
 			$permission = 'yes';
@@ -1996,7 +1996,7 @@
 	global $log;
 	$log->debug("Entering setGlobalProfilePermission2Session(".$profileid.") method ...");
   global $adb;
-  $sql = "select * from profile2globalpermissions where profileid=".$profileid ;
+  $sql = "select * from vtiger_profile2globalpermissions where profileid=".$profileid ;
   $result = $adb->query($sql);
   $num_rows = $adb->num_rows($result);
 
@@ -2014,7 +2014,7 @@
 
 
 
-/** Function to get the Profile Global Information for the specified profileid  
+/** Function to get the Profile Global Information for the specified vtiger_profileid  
   * @param $profileid -- Profile Id:: Type integer
   * @returns Profile Gloabal Permission Array in the following format:
   * $profileGloblaPermisson=Array($viewall_actionid=>permission, $editall_actionid=>permission)
@@ -2024,7 +2024,7 @@
 global $log;
 $log->debug("Entering getProfileGlobalPermission(".$profileid.") method ...");
   global $adb;
-  $sql = "select * from profile2globalpermissions where profileid=".$profileid ;
+  $sql = "select * from vtiger_profile2globalpermissions where profileid=".$profileid ;
   $result = $adb->query($sql);
   $num_rows = $adb->num_rows($result);
 
@@ -2040,7 +2040,7 @@
   
 }
 
-/** Function to get the Profile Tab Permissions for the specified profileid  
+/** Function to get the Profile Tab Permissions for the specified vtiger_profileid  
   * @param $profileid -- Profile Id:: Type integer
   * @returns Profile Tabs Permission Array in the following format:
   * $profileTabPermisson=Array($tabid1=>permission, $tabid2=>permission,........., $tabidn=>permission)
@@ -2050,7 +2050,7 @@
 global $log;
 $log->debug("Entering getProfileTabsPermission(".$profileid.") method ...");
   global $adb;
-  $sql = "select * from profile2tab where profileid=".$profileid ;
+  $sql = "select * from vtiger_profile2tab where profileid=".$profileid ;
   $result = $adb->query($sql);
   $num_rows = $adb->num_rows($result);
 
@@ -2067,7 +2067,7 @@
 }
 
 
-/** Function to get the Profile Action Permissions for the specified profileid  
+/** Function to get the Profile Action Permissions for the specified vtiger_profileid  
   * @param $profileid -- Profile Id:: Type integer
   * @returns Profile Tabs Action Permission Array in the following format:
   *    $tabActionPermission = Array($tabid1=>Array(actionid1=>permission, actionid2=>permission,...,actionidn=>permission),
@@ -2082,7 +2082,7 @@
 	global $adb;
 	$check = Array();
 	$temp_tabid = Array();	
-	$sql1 = "select * from profile2standardpermissions where profileid=".$profileid;
+	$sql1 = "select * from vtiger_profile2standardpermissions where profileid=".$profileid;
 	//echo $sql1.'<BR>';
 	$result1 = $adb->query($sql1);
         $num_rows1 = $adb->num_rows($result1);
@@ -2110,7 +2110,7 @@
 
 
 
-/** Function to get the Standard and Utility Profile Action Permissions for the specified profileid  
+/** Function to get the Standard and Utility Profile Action Permissions for the specified vtiger_profileid  
   * @param $profileid -- Profile Id:: Type integer
   * @returns Profile Tabs Action Permission Array in the following format:
   *    $tabActionPermission = Array($tabid1=>Array(actionid1=>permission, actionid2=>permission,...,actionidn=>permission),
@@ -2139,7 +2139,7 @@
 }
 
 
-/** Function to create profile 
+/** Function to create vtiger_profile 
   * @param $profilename -- Profile Name:: Type varchar
   * @param $parentProfileId -- Profile Id:: Type integer
  */
@@ -2149,40 +2149,40 @@
 $log->debug("Entering createProfile(".$profilename.",".$parentProfileId.",".$description.") method ...");
 	global $adb;
 	//Inserting values into Profile Table
-	$sql1 = "insert into profile values('','".$profilename."','".$description."')";
+	$sql1 = "insert into vtiger_profile values('','".$profilename."','".$description."')";
 	$adb->query($sql1);
 
-	//Retreiving the profileid
-	$sql2 = "select max(profileid) as current_id from profile";
+	//Retreiving the vtiger_profileid
+	$sql2 = "select max(profileid) as current_id from vtiger_profile";
 	$result2 = $adb->query($sql2);
 	$current_profile_id = $adb->query_result($result2,0,'current_id');
 
-	//Inserting values into profile2globalpermissions
-	$sql3 = "select * from profile2globalpermissions where profileid=".$parentProfileId;
+	//Inserting values into vtiger_profile2globalpermissions
+	$sql3 = "select * from vtiger_profile2globalpermissions where profileid=".$parentProfileId;
 	$result3= $adb->query($sql3);
 	$p2tab_rows = $adb->num_rows($result3);
 	for($i=0; $i<$p2tab_rows; $i++)
 	{
 		$act_id=$adb->query_result($result3,$i,'globalactionid');
 		$permissions=$adb->query_result($result3,$i,'globalactionpermission');
-		$sql4="insert into profile2globalpermissions values(".$current_profile_id.", ".$act_id.", ".$permissions.")";
+		$sql4="insert into vtiger_profile2globalpermissions values(".$current_profile_id.", ".$act_id.", ".$permissions.")";
 		$adb->query($sql4);	
 	}
 
-	//Inserting values into Profile2tab table
-	$sql3 = "select * from profile2tab where profileid=".$parentProfileId;
+	//Inserting values into Profile2tab vtiger_table
+	$sql3 = "select * from vtiger_profile2tab where profileid=".$parentProfileId;
 	$result3= $adb->query($sql3);
 	$p2tab_rows = $adb->num_rows($result3);
 	for($i=0; $i<$p2tab_rows; $i++)
 	{
 		$tab_id=$adb->query_result($result3,$i,'tabid');
 		$permissions=$adb->query_result($result3,$i,'permissions');
-		$sql4="insert into profile2tab values(".$current_profile_id.", ".$tab_id.", ".$permissions.")";
+		$sql4="insert into vtiger_profile2tab values(".$current_profile_id.", ".$tab_id.", ".$permissions.")";
 		$adb->query($sql4);	
 	}
 
-	//Inserting values into Profile2standard table
-	$sql6 = "select * from profile2standardpermissions where profileid=".$parentProfileId;
+	//Inserting values into Profile2standard vtiger_table
+	$sql6 = "select * from vtiger_profile2standardpermissions where profileid=".$parentProfileId;
 	$result6= $adb->query($sql6);
 	$p2per_rows = $adb->num_rows($result6);
 	for($i=0; $i<$p2per_rows; $i++)
@@ -2190,12 +2190,12 @@
 		$tab_id=$adb->query_result($result6,$i,'tabid');
 		$action_id=$adb->query_result($result6,$i,'operation');	
 		$permissions=$adb->query_result($result6,$i,'permissions');
-		$sql7="insert into profile2standardpermissions values(".$current_profile_id.", ".$tab_id.", ".$action_id.", ".$permissions.")";
+		$sql7="insert into vtiger_profile2standardpermissions values(".$current_profile_id.", ".$tab_id.", ".$action_id.", ".$permissions.")";
 		$adb->query($sql7);	
 	}
 
-	//Inserting values into Profile2Utility table
-	$sql8 = "select * from profile2utility where profileid=".$parentProfileId;
+	//Inserting values into Profile2Utility vtiger_table
+	$sql8 = "select * from vtiger_profile2utility where profileid=".$parentProfileId;
 	$result8= $adb->query($sql8);
 	$p2util_rows = $adb->num_rows($result8);
 	for($i=0; $i<$p2util_rows; $i++)
@@ -2203,12 +2203,12 @@
 		$tab_id=$adb->query_result($result8,$i,'tabid');
 		$action_id=$adb->query_result($result8,$i,'activityid');	
 		$permissions=$adb->query_result($result8,$i,'permission');
-		$sql9="insert into profile2utility values(".$current_profile_id.", ".$tab_id.", ".$action_id.", ".$permissions.")";
+		$sql9="insert into vtiger_profile2utility values(".$current_profile_id.", ".$tab_id.", ".$action_id.", ".$permissions.")";
 		$adb->query($sql9);	
 	}
 
-	//Inserting values into Profile2field table
-	$sql10 = "select * from profile2field where profileid=".$parentProfileId;
+	//Inserting values into Profile2field vtiger_table
+	$sql10 = "select * from vtiger_profile2field where profileid=".$parentProfileId;
 	$result10= $adb->query($sql10);
 	$p2field_rows = $adb->num_rows($result10);
 	for($i=0; $i<$p2field_rows; $i++)
@@ -2217,14 +2217,14 @@
 		$fieldid=$adb->query_result($result10,$i,'fieldid');	
 		$permissions=$adb->query_result($result10,$i,'visible');
 		$readonly=$adb->query_result($result10,$i,'readonly');
-		$sql11="insert into profile2field values(".$current_profile_id.", ".$tab_id.", ".$fieldid.", ".$permissions." ,".$readonly.")";
+		$sql11="insert into vtiger_profile2field values(".$current_profile_id.", ".$tab_id.", ".$fieldid.", ".$permissions." ,".$readonly.")";
 		$adb->query($sql11);	
 	}
 	$log->debug("Exiting createProfile method ...");
 }
 
-/** Function to delete profile 
-  * @param $transfer_profileid -- Profile Id to which the existing role2profile relationships are to be transferred :: Type varchar
+/** Function to delete vtiger_profile 
+  * @param $transfer_profileid -- Profile Id to which the existing vtiger_role2profile relationships are to be transferred :: Type varchar
   * @param $prof_id -- Profile Id to be deleted:: Type integer
  */
 function deleteProfile($prof_id,$transfer_profileid='')
@@ -2232,48 +2232,48 @@
 	global $log;
 $log->debug("Entering deleteProfile(".$prof_id.",".$transfer_profileid.") method ...");
 	global $adb;
-	//delete from profile2global permissions
-	$sql4 = "delete from profile2globalpermissions where profileid=".$prof_id;
+	//delete from vtiger_profile2global permissions
+	$sql4 = "delete from vtiger_profile2globalpermissions where profileid=".$prof_id;
 	$adb->query($sql4);
 
-	//deleting from profile 2 tab;
-	$sql4 = "delete from profile2tab where profileid=".$prof_id;
+	//deleting from vtiger_profile 2 vtiger_tab;
+	$sql4 = "delete from vtiger_profile2tab where profileid=".$prof_id;
 	$adb->query($sql4);
 
-	//deleting from profile2standardpermissions table
-	$sql5 = "delete from profile2standardpermissions where profileid=".$prof_id;
+	//deleting from vtiger_profile2standardpermissions vtiger_table
+	$sql5 = "delete from vtiger_profile2standardpermissions where profileid=".$prof_id;
 	$adb->query($sql5);
 
-	//deleting from profile2field
-	$sql6 ="delete from profile2field where profileid=".$prof_id;
+	//deleting from vtiger_profile2field
+	$sql6 ="delete from vtiger_profile2field where profileid=".$prof_id;
 	$adb->query($sql6);
 
-	//deleting from profile2utility
-	$sql7 ="delete from profile2utility where profileid=".$prof_id;
+	//deleting from vtiger_profile2utility
+	$sql7 ="delete from vtiger_profile2utility where profileid=".$prof_id;
 	$adb->query($sql7);
 
-	//updating role2profile
+	//updating vtiger_role2profile
         if(isset($transfer_profileid) && $transfer_profileid != '')
         {
 
-                $sql8 = "select roleid from role2profile where profileid=".$prof_id;
+                $sql8 = "select roleid from vtiger_role2profile where profileid=".$prof_id;
                 $result=$adb->query($sql8);
                 $num_rows=$adb->num_rows($result);
 
                 for($i=0;$i<$num_rows;$i++)
                 {
                         $roleid=$adb->query_result($result,$i,'roleid');
-                        $sql = "select profileid from role2profile where roleid='".$roleid."'";
+                        $sql = "select profileid from vtiger_role2profile where roleid='".$roleid."'";
                         $profresult=$adb->query($sql);
                         $num=$adb->num_rows($profresult);
                         if($num>1)
                         {
-                                $sql10="delete from role2profile where roleid='".$roleid."' and profileid=".$prof_id;
+                                $sql10="delete from vtiger_role2profile where roleid='".$roleid."' and profileid=".$prof_id;
                                 $adb->query($sql10);
                         }
                         else
                         {
-                                $sql8 = "update role2profile set profileid=".$transfer_profileid." where profileid=".$prof_id." and roleid='".$roleid."'";
+                                $sql8 = "update vtiger_role2profile set profileid=".$transfer_profileid." where profileid=".$prof_id." and roleid='".$roleid."'";
                                 $adb->query($sql8);
                         }
 
@@ -2281,15 +2281,15 @@
                 }
         }
 
-	//delete from profile table;
-	$sql9 = "delete from profile where profileid=".$prof_id;
+	//delete from vtiger_profile vtiger_table;
+	$sql9 = "delete from vtiger_profile where profileid=".$prof_id;
 	$adb->query($sql9);
 	$log->debug("Exiting deleteProfile method ...");	
 
 }
 
-/** Function to get all  the role information 
-  * @returns $allRoleDetailArray-- Array will contain the details of all the roles. RoleId will be the key:: Type array
+/** Function to get all  the vtiger_role information 
+  * @returns $allRoleDetailArray-- Array will contain the details of all the vtiger_roles. RoleId will be the key:: Type array
  */
 function getAllRoleDetails()
 {
@@ -2297,7 +2297,7 @@
 $log->debug("Entering getAllRoleDetails() method ...");
 	global $adb;
 	$role_det = Array();
-	$query = "select * from role";
+	$query = "select * from vtiger_role";
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0; $i<$num_rows;$i++)
@@ -2311,7 +2311,7 @@
 		$sub_role='';
 		
 		//getting the immediate subordinates
-		$query1="select * from role where parentrole like '".$parentrole."::%' and depth=".$sub_roledepth;
+		$query1="select * from vtiger_role where parentrole like '".$parentrole."::%' and depth=".$sub_roledepth;
 		$res1 = $adb->query($query1);
 		$num_roles = $adb->num_rows($res1);
 		if($num_roles > 0)
@@ -2341,15 +2341,15 @@
 }
 
 
-/** Function to get all  the profile information 
-  * @returns $allProfileInfoArray-- Array will contain the details of all the profiles. Profile ID will be the key:: Type array
+/** Function to get all  the vtiger_profile information 
+  * @returns $allProfileInfoArray-- Array will contain the details of all the vtiger_profiles. Profile ID will be the key:: Type array
  */
 function getAllProfileInfo()
 {
 	global $log;
 	$log->debug("Entering getAllProfileInfo() method ...");
 	global $adb;
-	$query="select * from profile";
+	$query="select * from vtiger_profile";
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$prof_details=Array();
@@ -2364,7 +2364,7 @@
 	return $prof_details;	
 }
 
-/** Function to get the role information of the specified role
+/** Function to get the vtiger_role information of the specified vtiger_role
   * @param $roleid -- RoleId :: Type varchar 
   * @returns $roleInfoArray-- RoleInfoArray in the following format:
   *       $roleInfo=Array($roleId=>Array($rolename,$parentrole,$roledepth,$immediateParent));
@@ -2374,7 +2374,7 @@
 	global $log;
 	$log->debug("Entering getRoleInformation(".$roleid.") method ...");
 	global $adb;
-	$query = "select * from role where roleid='".$roleid."'";
+	$query = "select * from vtiger_role where roleid='".$roleid."'";
 	$result = $adb->query($query);
 	$rolename=$adb->query_result($result,0,'rolename');
 	$parentrole=$adb->query_result($result,0,'parentrole');
@@ -2393,7 +2393,7 @@
 }
 
 
-/** Function to get the role related profiles
+/** Function to get the vtiger_role related vtiger_profiles
   * @param $roleid -- RoleId :: Type varchar 
   * @returns $roleProfiles-- Role Related Profile Array in the following format:
   *       $roleProfiles=Array($profileId1=>$profileName,$profileId2=>$profileName,........,$profileIdn=>$profileName));
@@ -2403,7 +2403,7 @@
 	global $log;
 	$log->debug("Entering getRoleRelatedProfiles(".$roleId.") method ...");
 	global $adb;
-	$query = "select role2profile.*,profile.profilename from role2profile inner join profile on profile.profileid=role2profile.profileid where roleid='".$roleId."'";
+	$query = "select vtiger_role2profile.*,vtiger_profile.profilename from vtiger_role2profile inner join vtiger_profile on vtiger_profile.profileid=vtiger_role2profile.profileid where roleid='".$roleId."'";
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$roleRelatedProfiles=Array();
@@ -2416,7 +2416,7 @@
 }
 
 
-/** Function to get the role related users
+/** Function to get the vtiger_role related vtiger_users
   * @param $roleid -- RoleId :: Type varchar 
   * @returns $roleUsers-- Role Related User Array in the following format:
   *       $roleUsers=Array($userId1=>$userName,$userId2=>$userName,........,$userIdn=>$userName));
@@ -2426,7 +2426,7 @@
 	global $log;
 	$log->debug("Entering getRoleUsers(".$roleId.") method ...");
 	global $adb;
-	$query = "select user2role.*,users.user_name from user2role inner join users on users.id=user2role.userid where roleid='".$roleId."'";
+	$query = "select vtiger_user2role.*,vtiger_users.user_name from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid where roleid='".$roleId."'";
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$roleRelatedUsers=Array();
@@ -2441,7 +2441,7 @@
 }
 
 
-/** Function to get the role related user ids
+/** Function to get the vtiger_role related user ids
   * @param $roleid -- RoleId :: Type varchar 
   * @returns $roleUserIds-- Role Related User Array in the following format:
   *       $roleUserIds=Array($userId1,$userId2,........,$userIdn);
@@ -2452,7 +2452,7 @@
 	global $log;
 	$log->debug("Entering getRoleUserIds(".$roleId.") method ...");
 	global $adb;
-	$query = "select user2role.*,users.user_name from user2role inner join users on users.id=user2role.userid where roleid='".$roleId."'";
+	$query = "select vtiger_user2role.*,vtiger_users.user_name from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid where roleid='".$roleId."'";
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$roleRelatedUsers=Array();
@@ -2466,7 +2466,7 @@
 
 }
 
-/** Function to get the role and subordinate users
+/** Function to get the vtiger_role and subordinate vtiger_users
   * @param $roleid -- RoleId :: Type varchar 
   * @returns $roleSubUsers-- Role and Subordinates Related Users Array in the following format:
   *       $roleSubUsers=Array($userId1=>$userName,$userId2=>$userName,........,$userIdn=>$userName));
@@ -2478,7 +2478,7 @@
 	global $adb;
 	$roleInfoArr=getRoleInformation($roleId);
 	$parentRole=$roleInfoArr[$roleId][1];
-	$query = "select user2role.*,users.user_name from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$parentRole."%'";
+	$query = "select vtiger_user2role.*,vtiger_users.user_name from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$parentRole."%'";
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$roleRelatedUsers=Array();
@@ -2493,7 +2493,7 @@
 }
 
 
-/** Function to get the role and subordinate user ids
+/** Function to get the vtiger_role and subordinate user ids
   * @param $roleid -- RoleId :: Type varchar 
   * @returns $roleSubUserIds-- Role and Subordinates Related Users Array in the following format:
   *       $roleSubUserIds=Array($userId1,$userId2,........,$userIdn);
@@ -2505,7 +2505,7 @@
 	global $adb;
 	$roleInfoArr=getRoleInformation($roleId);
 	$parentRole=$roleInfoArr[$roleId][1];
-	$query = "select user2role.*,users.user_name from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$parentRole."%'";
+	$query = "select vtiger_user2role.*,vtiger_users.user_name from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$parentRole."%'";
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$roleRelatedUsers=Array();
@@ -2519,7 +2519,7 @@
 
 }
 
-/** Function to get the role and subordinate Information for the specified roleId
+/** Function to get the vtiger_role and subordinate Information for the specified vtiger_roleId
   * @param $roleid -- RoleId :: Type varchar 
   * @returns $roleSubInfo-- Role and Subordinates Information array in the following format:
   *       $roleSubInfo=Array($roleId1=>Array($rolename,$parentrole,$roledepth,$immediateParent), $roleId2=>Array($rolename,$parentrole,$roledepth,$immediateParent),.....);
@@ -2533,7 +2533,7 @@
 	$roleInfo=$roleDetails[$roleId];
 	$roleParentSeq=$roleInfo[1];
 	
-	$query="select * from role where parentrole like '".$roleParentSeq."%' order by parentrole asc";
+	$query="select * from vtiger_role where parentrole like '".$roleParentSeq."%' order by parentrole asc";
 	$result=$adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$roleInfo=Array();
@@ -2556,7 +2556,7 @@
 }
 
 
-/** Function to get the role and subordinate role ids
+/** Function to get the vtiger_role and subordinate vtiger_role ids
   * @param $roleid -- RoleId :: Type varchar 
   * @returns $roleSubRoleIds-- Role and Subordinates RoleIds in an Array in the following format:
   *       $roleSubRoleIds=Array($roleId1,$roleId2,........,$roleIdn);
@@ -2570,7 +2570,7 @@
 	$roleInfo=$roleDetails[$roleId];
 	$roleParentSeq=$roleInfo[1];
 	
-	$query="select * from role where parentrole like '".$roleParentSeq."%' order by parentrole asc";
+	$query="select * from vtiger_role where parentrole like '".$roleParentSeq."%' order by parentrole asc";
 	$result=$adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$roleInfo=Array();
@@ -2585,9 +2585,9 @@
 
 }
 
-/** Function to get delete the spcified role 
+/** Function to get delete the spcified vtiger_role 
   * @param $roleid -- RoleId :: Type varchar 
-  * @param $transferRoleId -- RoleId to which users of the role that is being deleted are transferred:: Type varchar 
+  * @param $transferRoleId -- RoleId to which vtiger_users of the vtiger_role that is being deleted are transferred:: Type varchar 
  */
 function deleteRole($roleId,$transferRoleId)
 {
@@ -2598,26 +2598,26 @@
         foreach($roleInfo as $roleid=>$roleDetArr)
         {
 
-                $sql1 = "update user2role set roleid='".$transferRoleId."' where roleid='".$roleid."'";
+                $sql1 = "update vtiger_user2role set roleid='".$transferRoleId."' where roleid='".$roleid."'";
                 $adb->query($sql1);
 
-                //Deleteing from role2profile table
-                $sql2 = "delete from role2profile where roleid='".$roleid."'";
+                //Deleteing from vtiger_role2profile vtiger_table
+                $sql2 = "delete from vtiger_role2profile where roleid='".$roleid."'";
                 $adb->query($sql2);
 
-                //delete handling for groups
-                $sql10 = "delete from group2role where roleid='".$roleid."'";
+                //delete handling for vtiger_groups
+                $sql10 = "delete from vtiger_group2role where roleid='".$roleid."'";
                 $adb->query($sql10);
 
-                $sql11 = "delete from group2rs where roleandsubid='".$roleid."'";
+                $sql11 = "delete from vtiger_group2rs where roleandsubid='".$roleid."'";
                 $adb->query($sql11);
 
 
                 //delete handling for sharing rules
                 deleteRoleRelatedSharingRules($roleid);
 
-                //delete from role table;
-                $sql9 = "delete from role where roleid='".$roleid."'";
+                //delete from vtiger_role vtiger_table;
+                $sql9 = "delete from vtiger_role where roleid='".$roleid."'";
                 $adb->query($sql9);
                 //echo $sql1.'            '.$sql2.'           '.$sql9;
 
@@ -2628,7 +2628,7 @@
 
 }
 
-/** Function to delete the role related sharing rules
+/** Function to delete the vtiger_role related sharing rules
   * @param $roleid -- RoleId :: Type varchar
  */
 function deleteRoleRelatedSharingRules($roleId)
@@ -2636,14 +2636,14 @@
 	global $log;
 	$log->debug("Entering deleteRoleRelatedSharingRules(".$roleId.") method ...");
         global $adb;
-        $dataShareTableColArr=Array('datashare_grp2role'=>'to_roleid',
-                                    'datashare_grp2rs'=>'to_roleandsubid',
-                                    'datashare_role2group'=>'share_roleid',
-                                    'datashare_role2role'=>'share_roleid::to_roleid',
-                                    'datashare_role2rs'=>'share_roleid::to_roleandsubid',
-                                    'datashare_rs2grp'=>'share_roleandsubid',
-                                    'datashare_rs2role'=>'share_roleandsubid::to_roleid',
-                                    'datashare_rs2rs'=>'share_roleandsubid::to_roleandsubid');
+        $dataShareTableColArr=Array('vtiger_datashare_grp2role'=>'to_roleid',
+                                    'vtiger_datashare_grp2rs'=>'to_roleandsubid',
+                                    'vtiger_datashare_role2group'=>'share_roleid',
+                                    'vtiger_datashare_role2role'=>'share_roleid::to_roleid',
+                                    'vtiger_datashare_role2rs'=>'share_roleid::to_roleandsubid',
+                                    'vtiger_datashare_rs2grp'=>'share_roleandsubid',
+                                    'vtiger_datashare_rs2role'=>'share_roleandsubid::to_roleid',
+                                    'vtiger_datashare_rs2rs'=>'share_roleandsubid::to_roleandsubid');
 
         foreach($dataShareTableColArr as $tablename=>$colname)
         {
@@ -2676,11 +2676,11 @@
 	$log->debug("Entering deleteGroupRelatedSharingRules(".$grpId.") method ...");
 
         global $adb;
-        $dataShareTableColArr=Array('datashare_grp2grp'=>'share_groupid::to_groupid',
-                                    'datashare_grp2role'=>'share_groupid',
-                                    'datashare_grp2rs'=>'share_groupid',
-                                    'datashare_role2group'=>'to_groupid',
-                                    'datashare_rs2grp'=>'to_groupid');
+        $dataShareTableColArr=Array('vtiger_datashare_grp2grp'=>'share_groupid::to_groupid',
+                                    'vtiger_datashare_grp2role'=>'share_groupid',
+                                    'vtiger_datashare_grp2rs'=>'share_groupid',
+                                    'vtiger_datashare_role2group'=>'to_groupid',
+                                    'vtiger_datashare_rs2grp'=>'to_groupid');
 
 
         foreach($dataShareTableColArr as $tablename=>$colname)
@@ -2706,7 +2706,7 @@
 }
 
 
-/** Function to get userid and username of all users 
+/** Function to get userid and username of all vtiger_users 
   * @returns $userArray -- User Array in the following format:
   * $userArray=Array($userid1=>$username, $userid2=>$username,............,$useridn=>$username); 
  */
@@ -2715,7 +2715,7 @@
 	global $log;
 	$log->debug("Entering getAllUserName() method ...");
 	global $adb;
-	$query="select * from users where deleted=0";
+	$query="select * from vtiger_users where deleted=0";
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$user_details=Array();
@@ -2732,7 +2732,7 @@
 }
 
 
-/** Function to get groupid and groupname of all groups 
+/** Function to get groupid and groupname of all vtiger_groups 
   * @returns $grpArray -- Group Array in the following format:
   * $grpArray=Array($grpid1=>$grpname, $grpid2=>$grpname,............,$grpidn=>$grpname); 
  */
@@ -2741,7 +2741,7 @@
 	global $log;
 	$log->debug("Entering getAllGroupName() method ...");
 	global $adb;
-	$query="select * from groups";
+	$query="select * from vtiger_groups";
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$group_details=Array();
@@ -2757,7 +2757,7 @@
 
 }
 
-/** Function to get group information of all groups 
+/** Function to get group information of all vtiger_groups 
   * @returns $grpInfoArray -- Group Informaton array in the following format: 
   * $grpInfoArray=Array($grpid1=>Array($grpname,description) $grpid2=>Array($grpname,description),............,$grpidn=>Array($grpname,description)); 
  */
@@ -2766,7 +2766,7 @@
 	global $log;
 	$log->debug("Entering getAllGroupInfo() method ...");
 	global $adb;
-	$query="select * from groups";
+	$query="select * from vtiger_groups";
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$group_details=Array();
@@ -2798,8 +2798,8 @@
 	$log->debug("Entering createGroup(".$groupName.",".$groupMemberArray.",".$description.") method ...");
 	global $adb;
 	$groupId=$adb->getUniqueId("groups");
-	//Insert into group table
-	$query = "insert into groups values(".$groupId.",'".$groupName."','".$description."')";
+	//Insert into group vtiger_table
+	$query = "insert into vtiger_groups values(".$groupId.",'".$groupName."','".$description."')";
 	$adb->query($query);
 
 	//Insert Group to Group Relation
@@ -2844,13 +2844,13 @@
 	global $log;
 	$log->debug("Entering insertGroupToGroupRelation(".$groupId.",".$containsGroupId.") method ...");
 	global $adb;
-	$query="insert into group2grouprel values(".$groupId.",".$containsGroupId.")";
+	$query="insert into vtiger_group2grouprel values(".$groupId.",".$containsGroupId.")";
 	$adb->query($query);
 	$log->debug("Exiting insertGroupToGroupRelation method ...");
 }
 
 
-/** Function to insert group to role relation 
+/** Function to insert group to vtiger_role relation 
   * @param $groupId -- Group Id :: Type integer 
   * @param $roleId -- Role Id :: Type varchar 
  */
@@ -2859,13 +2859,13 @@
 	 global $log;
 	$log->debug("Entering insertGroupToRoleRelation(".$groupId.",".$roleId.") method ...");
 	global $adb;
-	$query="insert into group2role values(".$groupId.",'".$roleId."')";
+	$query="insert into vtiger_group2role values(".$groupId.",'".$roleId."')";
 	$adb->query($query);
 	$log->debug("Exiting insertGroupToRoleRelation method ...");
 }
 
 
-/** Function to insert group to role&subordinate relation 
+/** Function to insert group to vtiger_role&subordinate relation 
   * @param $groupId -- Group Id :: Type integer 
   * @param $rsId -- Role Sub Id :: Type varchar 
  */
@@ -2874,7 +2874,7 @@
 	global $log;
 	$log->debug("Entering insertGroupToRsRelation(".$groupId.",".$rsId.") method ...");
 	global $adb;
-	$query="insert into group2rs values(".$groupId.",'".$rsId."')";
+	$query="insert into vtiger_group2rs values(".$groupId.",'".$rsId."')";
 	$adb->query($query);
 	$log->debug("Exiting insertGroupToRsRelation method ...");
 }
@@ -2888,7 +2888,7 @@
 	global $log;
 	$log->debug("Entering insertGroupToUserRelation(".$groupId.",".$userId.") method ...");
 	global $adb;
-	$query="insert into users2group values(".$groupId.",".$userId.")";
+	$query="insert into vtiger_users2group values(".$groupId.",".$userId.")";
 	$adb->query($query);
 	$log->debug("Exiting insertGroupToUserRelation method ...");
 }
@@ -2907,7 +2907,7 @@
 	$groupDetailArr=Array();
 	$groupMemberArr=Array();
 	//Retreving the group Info
-	$query="select * from groups where groupid=".$groupId;
+	$query="select * from vtiger_groups where groupid=".$groupId;
 	$result = $adb->query($query);
 	$groupName=$adb->query_result($result,0,'groupname');
 	$description=$adb->query_result($result,0,'description');
@@ -2936,7 +2936,7 @@
 
 	global $adb;
 	//Retreving the group Info
-	$query="select * from groups where groupid=".$groupId;
+	$query="select * from vtiger_groups where groupid=".$groupId;
 	$result = $adb->query($query);
 	$groupName=$adb->query_result($result,0,'groupname');
 	$log->debug("Exiting fetchGroupName method ...");
@@ -2971,7 +2971,7 @@
 	return($groupMemberArr);
 }
 
-/** Function to get the group related roles of the specified group 
+/** Function to get the group related vtiger_roles of the specified group 
   * @param $groupId -- Group Id :: Type integer 
   * @returns Group Related Role Array in the follwing format:
   *  $groupRoles=Array(roleid1,roleid2,roleid3,.....,roleidn);
@@ -2982,7 +2982,7 @@
 	$log->debug("Entering getGroupRelatedRoles(".$groupId.") method ...");
 	global $adb;
 	$roleGroupArr=Array();
-	$query="select * from group2role where groupid=".$groupId;
+	$query="select * from vtiger_group2role where groupid=".$groupId;
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0;$i<$num_rows;$i++)
@@ -2996,7 +2996,7 @@
 }
 
 
-/** Function to get the group related roles and subordinates of the specified group 
+/** Function to get the group related vtiger_roles and subordinates of the specified group 
   * @param $groupId -- Group Id :: Type integer 
   * @returns Group Related Roles & Subordinate Array in the follwing format:
   *  $groupRoleSubordinates=Array(roleid1,roleid2,roleid3,.....,roleidn);
@@ -3007,7 +3007,7 @@
 	$log->debug("Entering getGroupRelatedRoleSubordinates(".$groupId.") method ...");
 	global $adb;
 	$rsGroupArr=Array();
-	$query="select * from group2rs where groupid=".$groupId;
+	$query="select * from vtiger_group2rs where groupid=".$groupId;
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0;$i<$num_rows;$i++)
@@ -3020,7 +3020,7 @@
 }
 
 
-/** Function to get the group related groups  
+/** Function to get the group related vtiger_groups  
   * @param $groupId -- Group Id :: Type integer 
   * @returns Group Related Groups Array in the follwing format:
   *  $groupGroups=Array(grpid1,grpid2,grpid3,.....,grpidn);
@@ -3031,7 +3031,7 @@
 	$log->debug("Entering getGroupRelatedGroups(".$groupId.") method ...");
 	global $adb;
 	$groupGroupArr=Array();
-	$query="select * from group2grouprel where groupid=".$groupId;
+	$query="select * from vtiger_group2grouprel where groupid=".$groupId;
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0;$i<$num_rows;$i++)
@@ -3044,7 +3044,7 @@
 			
 }
 
-/** Function to get the group related users  
+/** Function to get the group related vtiger_users  
   * @param $userId -- User Id :: Type integer 
   * @returns Group Related Users Array in the follwing format:
   *  $groupUsers=Array(userid1,userid2,userid3,.....,useridn);
@@ -3055,7 +3055,7 @@
 	$log->debug("Entering getGroupRelatedUsers(".$groupId.") method ...");
 	global $adb;
 	$userGroupArr=Array();
-	$query="select * from users2group where groupid=".$groupId;
+	$query="select * from vtiger_users2group where groupid=".$groupId;
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0;$i<$num_rows;$i++)
@@ -3079,7 +3079,7 @@
 	global $log;
 	$log->debug("Entering updateGroup(".$groupId.",".$groupName.",".$groupMemberArray.",".$description.") method ...");
 	global $adb;
-	$query="update groups set groupname='".$groupName."',description='".$description."' where groupid=".$groupId;
+	$query="update vtiger_groups set groupname='".$groupName."',description='".$description."' where groupid=".$groupId;
 	$adb->query($query);
 
 	//Deleting the Group Member Relation
@@ -3129,7 +3129,7 @@
 	$log->debug("Entering deleteGroup(".$groupId.") method ...");	
 	global $adb;
 	deleteGroupRelatedSharingRules($groupId);		
-	$query="delete from groups where groupid=".$groupId;
+	$query="delete from vtiger_groups where groupid=".$groupId;
 	$adb->query($query);
 
 	deleteGroupRelatedGroups($groupId);
@@ -3148,13 +3148,13 @@
 	global $log;
 	$log->debug("Entering deleteGroupRelatedGroups(".$groupId.") method ...");
 	global $adb;
-	$query="delete from group2grouprel where groupid=".$groupId;
+	$query="delete from vtiger_group2grouprel where groupid=".$groupId;
 	$adb->query($query);
 	$log->debug("Exiting deleteGroupRelatedGroups method ...");
 }
 
 
-/** Function to delete group to role relation of the  specified group  
+/** Function to delete group to vtiger_role relation of the  specified group  
   * @param $groupId -- Group Id :: Type integer 
  */
 function deleteGroupRelatedRoles($groupId)
@@ -3162,13 +3162,13 @@
 	global $log;
 	$log->debug("Entering deleteGroupRelatedRoles(".$groupId.") method ...");
 	global $adb;
-	$query="delete from group2role where groupid=".$groupId;
+	$query="delete from vtiger_group2role where groupid=".$groupId;
 	$adb->query($query);
 	$log->debug("Exiting deleteGroupRelatedRoles method ...");
 }
 
 
-/** Function to delete group to role and subordinates relation of the  specified group  
+/** Function to delete group to vtiger_role and subordinates relation of the  specified group  
   * @param $groupId -- Group Id :: Type integer 
  */
 function deleteGroupRelatedRolesAndSubordinates($groupId)
@@ -3176,7 +3176,7 @@
 	global $log;
 	$log->debug("Entering deleteGroupRelatedRolesAndSubordinates(".$groupId.") method ...");
 	global $adb;
-	$query="delete from group2rs where groupid=".$groupId;
+	$query="delete from vtiger_group2rs where groupid=".$groupId;
 	$adb->query($query);
 	$log->debug("Exiting deleteGroupRelatedRolesAndSubordinates method ...");
 }
@@ -3190,7 +3190,7 @@
 	global $log;
 	$log->debug("Entering deleteGroupRelatedUsers(".$groupId.") method ...");
 	global $adb;
-	$query="delete from users2group where groupid=".$groupId;
+	$query="delete from vtiger_users2group where groupid=".$groupId;
 	$adb->query($query);
 	$log->debug("Exiting deleteGroupRelatedUsers method ...");
 }
@@ -3204,7 +3204,7 @@
 	global $log;
 	$log->debug("Entering getDefOrgShareActionName(".$share_action_id.") method ...");
 	global $adb;
-	$query="select * from org_share_action_mapping where share_action_id=".$share_action_id;
+	$query="select * from vtiger_org_share_action_mapping where share_action_id=".$share_action_id;
 	$result=$adb->query($query);
 	$share_action_name=$adb->query_result($result,0,"share_action_name");
 	$log->debug("Exiting getDefOrgShareActionName method ...");
@@ -3228,7 +3228,7 @@
 	$log->debug("Entering getModuleSharingActionArray(".$tabid.") method ...");
 	global $adb;
 	$share_action_arr=Array();
-	$query = "select org_share_action_mapping.share_action_name,org_share_action2tab.share_action_id from org_share_action2tab inner join org_share_action_mapping on org_share_action2tab.share_action_id=org_share_action_mapping.share_action_id where org_share_action2tab.tabid=".$tabid;
+	$query = "select vtiger_org_share_action_mapping.share_action_name,vtiger_org_share_action2tab.share_action_id from vtiger_org_share_action2tab inner join vtiger_org_share_action_mapping on vtiger_org_share_action2tab.share_action_id=vtiger_org_share_action_mapping.share_action_id where vtiger_org_share_action2tab.tabid=".$tabid;
 	$result=$adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0; $i<$num_rows; $i++)
@@ -3245,8 +3245,8 @@
 /** This function adds a organisation level sharing rule for the specified Module
   * It takes the following input parameters:
   * 	$tabid -- Module tabid - Datatype::Integer
-  * 	$shareEntityType -- The Entity Type may be groups,roles,rs and users - Datatype::String
-  * 	$toEntityType -- The Entity Type may be groups,roles,rs and users - Datatype::String
+  * 	$shareEntityType -- The Entity Type may be vtiger_groups,roles,rs and vtiger_users - Datatype::String
+  * 	$toEntityType -- The Entity Type may be vtiger_groups,roles,rs and vtiger_users - Datatype::String
   * 	$shareEntityId -- The id of the group,role,rs,user to be shared 
   * 	$toEntityId -- The id of the group,role,rs,user to which the specified entity is to be shared
   * 	$sharePermisson -- This can have the following values:
@@ -3266,57 +3266,57 @@
 	if($shareEntityType == 'groups' && $toEntityType == 'groups')
 	{
 		$type_string='GRP::GRP';
-		$query = "insert into datashare_grp2grp values(".$shareid.", ".$shareEntityId.", ".$toEntityId.", ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_grp2grp values(".$shareid.", ".$shareEntityId.", ".$toEntityId.", ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'groups' && $toEntityType == 'roles')
 	{
 		
 		$type_string='GRP::ROLE';
-		$query = "insert into datashare_grp2role values(".$shareid.", ".$shareEntityId.", '".$toEntityId."', ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_grp2role values(".$shareid.", ".$shareEntityId.", '".$toEntityId."', ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'groups' && $toEntityType == 'rs')
 	{
 		
 		$type_string='GRP::RS';
-		$query = "insert into datashare_grp2rs values(".$shareid.", ".$shareEntityId.", '".$toEntityId."', ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_grp2rs values(".$shareid.", ".$shareEntityId.", '".$toEntityId."', ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'roles' && $toEntityType == 'groups')
 	{
 		
 		$type_string='ROLE::GRP';
-		$query = "insert into datashare_role2group values(".$shareid.", '".$shareEntityId."', ".$toEntityId.", ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_role2group values(".$shareid.", '".$shareEntityId."', ".$toEntityId.", ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'roles' && $toEntityType == 'roles')
 	{
 		
 		$type_string='ROLE::ROLE';
-		$query = "insert into datashare_role2role values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_role2role values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'roles' && $toEntityType == 'rs')
 	{
 		
 		$type_string='ROLE::RS';
-		$query = "insert into datashare_role2rs values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_role2rs values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'rs' && $toEntityType == 'groups')
 	{
 		
 		$type_string='RS::GRP';
-		$query = "insert into datashare_rs2grp values(".$shareid.", '".$shareEntityId."', ".$toEntityId.", ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_rs2grp values(".$shareid.", '".$shareEntityId."', ".$toEntityId.", ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'rs' && $toEntityType == 'roles')
 	{
 		
 		$type_string='RS::ROLE';
-		$query = "insert into datashare_rs2role values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_rs2role values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'rs' && $toEntityType == 'rs')
 	{
 		
 		$type_string='RS::RS';
-		$query = "insert into datashare_rs2rs values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
-	}
-	$query1 = "insert into datashare_module_rel values(".$shareid.",".$tabid.",'".$type_string."')";
+		$query = "insert into vtiger_datashare_rs2rs values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
+	}
+	$query1 = "insert into vtiger_datashare_module_rel values(".$shareid.",".$tabid.",'".$type_string."')";
 	$adb->query($query1);		
 	$adb->query($query);	
 	$log->debug("Exiting addSharingRule method ...");
@@ -3329,8 +3329,8 @@
   * It takes the following input parameters:
   *     $shareid -- Id of the Sharing Rule to be updated
   * 	$tabid -- Module tabid - Datatype::Integer
-  * 	$shareEntityType -- The Entity Type may be groups,roles,rs and users - Datatype::String
-  * 	$toEntityType -- The Entity Type may be groups,roles,rs and users - Datatype::String
+  * 	$shareEntityType -- The Entity Type may be vtiger_groups,roles,rs and vtiger_users - Datatype::String
+  * 	$toEntityType -- The Entity Type may be vtiger_groups,roles,rs and vtiger_users - Datatype::String
   * 	$shareEntityId -- The id of the group,role,rs,user to be shared 
   * 	$toEntityId -- The id of the group,role,rs,user to which the specified entity is to be shared
   * 	$sharePermisson -- This can have the following values:
@@ -3344,7 +3344,7 @@
 	$log->debug("Entering updateSharingRule(".$shareid.",".$tabid.",".$shareEntityType.",".$toEntityType.",".$shareEntityId.",".$toEntityId.",".$sharePermission.") method ...");
 	
 	global $adb;
-	$query2="select * from datashare_module_rel where shareid=".$shareid;
+	$query2="select * from vtiger_datashare_module_rel where shareid=".$shareid;
 	$res=$adb->query($query2);
 	$typestr=$adb->query_result($res,0,'relationtype');
 	$tabname=getDSTableNameForType($typestr);
@@ -3355,58 +3355,58 @@
 	if($shareEntityType == 'groups' && $toEntityType == 'groups')
 	{
 		$type_string='GRP::GRP';
-		$query = "insert into datashare_grp2grp values(".$shareid.", ".$shareEntityId.", ".$toEntityId.", ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_grp2grp values(".$shareid.", ".$shareEntityId.", ".$toEntityId.", ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'groups' && $toEntityType == 'roles')
 	{
 		
 		$type_string='GRP::ROLE';
-		$query = "insert into datashare_grp2role values(".$shareid.", ".$shareEntityId.", '".$toEntityId."', ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_grp2role values(".$shareid.", ".$shareEntityId.", '".$toEntityId."', ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'groups' && $toEntityType == 'rs')
 	{
 		
 		$type_string='GRP::RS';
-		$query = "insert into datashare_grp2rs values(".$shareid.", ".$shareEntityId.", '".$toEntityId."', ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_grp2rs values(".$shareid.", ".$shareEntityId.", '".$toEntityId."', ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'roles' && $toEntityType == 'groups')
 	{
 		
 		$type_string='ROLE::GRP';
-		$query = "insert into datashare_role2group values(".$shareid.", '".$shareEntityId."', ".$toEntityId.", ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_role2group values(".$shareid.", '".$shareEntityId."', ".$toEntityId.", ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'roles' && $toEntityType == 'roles')
 	{
 		
 		$type_string='ROLE::ROLE';
-		$query = "insert into datashare_role2role values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_role2role values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'roles' && $toEntityType == 'rs')
 	{
 		
 		$type_string='ROLE::RS';
-		$query = "insert into datashare_role2rs values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_role2rs values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'rs' && $toEntityType == 'groups')
 	{
 		
 		$type_string='RS::GRP';
-		$query = "insert into datashare_rs2grp values(".$shareid.", '".$shareEntityId."', ".$toEntityId.", ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_rs2grp values(".$shareid.", '".$shareEntityId."', ".$toEntityId.", ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'rs' && $toEntityType == 'roles')
 	{
 		
 		$type_string='RS::ROLE';
-		$query = "insert into datashare_rs2role values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
+		$query = "insert into vtiger_datashare_rs2role values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
 	}
 	elseif($shareEntityType == 'rs' && $toEntityType == 'rs')
 	{
 		
 		$type_string='RS::RS';
-		$query = "insert into datashare_rs2rs values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
-	}
-	
-	$query1 = "update datashare_module_rel set relationtype='".$type_string."' where shareid=".$shareid;
+		$query = "insert into vtiger_datashare_rs2rs values(".$shareid.", '".$shareEntityId."', '".$toEntityId."', ".$sharePermission.")";
+	}
+	
+	$query1 = "update vtiger_datashare_module_rel set relationtype='".$type_string."' where shareid=".$shareid;
 	$adb->query($query1);		
 	$adb->query($query);	
 	$log->debug("Exiting updateSharingRule method ...");
@@ -3424,17 +3424,17 @@
 	global $log;
 	$log->debug("Entering deleteSharingRule(".$shareid.") method ...");
 	global $adb;
-	$query2="select * from datashare_module_rel where shareid=".$shareid;
+	$query2="select * from vtiger_datashare_module_rel where shareid=".$shareid;
 	$res=$adb->query($query2);
 	$typestr=$adb->query_result($res,0,'relationtype');
 	$tabname=getDSTableNameForType($typestr);
 	$query3="delete from ".$tabname." where shareid=".$shareid;
 	$adb->query($query3);
-	$query4="delete from datashare_module_rel where shareid=".$shareid;
+	$query4="delete from vtiger_datashare_module_rel where shareid=".$shareid;
 	$adb->query($query4);
 
 	//deleting the releated module sharing permission
-	$query5="delete from datashare_relatedmodule_permission where shareid=".$shareid;
+	$query5="delete from vtiger_datashare_relatedmodule_permission where shareid=".$shareid;
 	$adb->query($query5);
 	$log->debug("Exiting deleteSharingRule method ...");
 	
@@ -3456,15 +3456,15 @@
 {
 	global $log;
 	$log->debug("Entering getDataShareTableandColumnArray() method ...");
-	$dataShareTableColArr=Array('datashare_grp2grp'=>'share_groupid::to_groupid',
-				    'datashare_grp2role'=>'share_groupid::to_roleid',
-				    'datashare_grp2rs'=>'share_groupid::to_roleandsubid',
-				    'datashare_role2group'=>'share_roleid::to_groupid',
-				    'datashare_role2role'=>'share_roleid::to_roleid',
-				    'datashare_role2rs'=>'share_roleid::to_roleandsubid',
-				    'datashare_rs2grp'=>'share_roleandsubid::to_groupid',
-				    'datashare_rs2role'=>'share_roleandsubid::to_roleid',
-				    'datashare_rs2rs'=>'share_roleandsubid::to_roleandsubid');
+	$dataShareTableColArr=Array('vtiger_datashare_grp2grp'=>'share_groupid::to_groupid',
+				    'vtiger_datashare_grp2role'=>'share_groupid::to_roleid',
+				    'vtiger_datashare_grp2rs'=>'share_groupid::to_roleandsubid',
+				    'vtiger_datashare_role2group'=>'share_roleid::to_groupid',
+				    'vtiger_datashare_role2role'=>'share_roleid::to_roleid',
+				    'vtiger_datashare_role2rs'=>'share_roleid::to_roleandsubid',
+				    'vtiger_datashare_rs2grp'=>'share_roleandsubid::to_groupid',
+				    'vtiger_datashare_rs2role'=>'share_roleandsubid::to_roleid',
+				    'vtiger_datashare_rs2rs'=>'share_roleandsubid::to_roleandsubid');
 	$log->debug("Exiting getDataShareTableandColumnArray method ...");
 	return $dataShareTableColArr;	
 					
@@ -3507,15 +3507,15 @@
 {
 	global $log;
 	$log->debug("Entering getDataShareTableName() method ...");
-	$dataShareTableColArr=Array('GRP::GRP'=>'datashare_grp2grp',
-				    'GRP::ROLE'=>'datashare_grp2role',
-				    'GRP::RS'=>'datashare_grp2rs',
-				    'ROLE::GRP'=>'datashare_role2group',
-				    'ROLE::ROLE'=>'datashare_role2role',
-				    'ROLE::RS'=>'datashare_role2rs',
-				    'RS::GRP'=>'datashare_rs2grp',
-				    'RS::ROLE'=>'datashare_rs2role',
-				    'RS::RS'=>'datashare_rs2rs');
+	$dataShareTableColArr=Array('GRP::GRP'=>'vtiger_datashare_grp2grp',
+				    'GRP::ROLE'=>'vtiger_datashare_grp2role',
+				    'GRP::RS'=>'vtiger_datashare_grp2rs',
+				    'ROLE::GRP'=>'vtiger_datashare_role2group',
+				    'ROLE::ROLE'=>'vtiger_datashare_role2role',
+				    'ROLE::RS'=>'vtiger_datashare_role2rs',
+				    'RS::GRP'=>'vtiger_datashare_rs2grp',
+				    'RS::ROLE'=>'vtiger_datashare_rs2role',
+				    'RS::RS'=>'vtiger_datashare_rs2rs');
 	$log->debug("Exiting getDataShareTableName method ...");
 	return $dataShareTableColArr;	
 					
@@ -3539,7 +3539,7 @@
 
 /** Function to get the Entity type from the specified DataShare Table Column Name
  *  @param $colname -- Datashare Table Column Name :: Type Varchar
- *  @returns The entity type. The entity type may be groups or roles or rs -- Type Varchar
+ *  @returns The entity type. The entity type may be vtiger_groups or vtiger_roles or rs -- Type Varchar
  */
 function getEntityTypeFromCol($colName)
 {
@@ -3566,7 +3566,7 @@
 
 /** Function to get the Entity Display Link
  *  @param $entityid -- Entity Id 
- *  @params $entityType --  The entity type may be groups or roles or rs -- Type Varchar
+ *  @params $entityType --  The entity type may be vtiger_groups or vtiger_roles or rs -- Type Varchar
  *  @returns the Entity Display link  
  */
 function getEntityDisplayLink($entityType,$entityid)
@@ -3605,7 +3605,7 @@
 	$log->debug("Entering getSharingRuleInfo(".$shareId.") method ...");
 	global $adb;
 	$shareRuleInfoArr=Array();
-	$query="select * from datashare_module_rel where shareid=".$shareId;
+	$query="select * from vtiger_datashare_module_rel where shareid=".$shareId;
 	$result=$adb->query($query);
 	//Retreving the Sharing Tabid
 	$tabid=$adb->query_result($result,0,'tabid');
@@ -3658,7 +3658,7 @@
 	$log->debug("Entering getRelatedSharingModules(".$tabid.") method ...");
 	global $adb;
 	$relatedSharingModuleArray=Array();
-	$query="select * from datashare_relatedmodules where tabid=".$tabid;
+	$query="select * from vtiger_datashare_relatedmodules where tabid=".$tabid;
 	$result=$adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0;$i<$num_rows;$i++)
@@ -3690,7 +3690,7 @@
 	$log->debug("Entering addRelatedModuleSharingPermission(".$shareid.",".$tabid.",".$relatedtabid.",".$sharePermission.") method ...");
 	global $adb;
 	$relatedModuleSharingId=getRelatedModuleSharingId($tabid,$relatedtabid);	
-	$query="insert into datashare_relatedmodule_permission values(".$shareid.", ".$relatedModuleSharingId.", ".$sharePermission.")" ;
+	$query="insert into vtiger_datashare_relatedmodule_permission values(".$shareid.", ".$relatedModuleSharingId.", ".$sharePermission.")" ;
 	$result=$adb->query($query);
 	$log->debug("Exiting addRelatedModuleSharingPermission method ...");
 }
@@ -3711,7 +3711,7 @@
 	$log->debug("Entering updateRelatedModuleSharingPermission(".$shareid.",".$tabid.",".$relatedtabid.",".$sharePermission.") method ...");
 	global $adb;
 	$relatedModuleSharingId=getRelatedModuleSharingId($tabid,$relatedtabid);
-	$query="update datashare_relatedmodule_permission set permission=".$sharePermission." where shareid=".$shareid." and datashare_relatedmodule_id=".$relatedModuleSharingId;		
+	$query="update vtiger_datashare_relatedmodule_permission set permission=".$sharePermission." where shareid=".$shareid." and datashare_relatedmodule_id=".$relatedModuleSharingId;		
 	$result=$adb->query($query);
 	$log->debug("Exiting updateRelatedModuleSharingPermission method ...");
 }
@@ -3728,7 +3728,7 @@
 	global $log;
 	$log->debug("Entering getRelatedModuleSharingId(".$tabid.",".$related_tabid.") method ...");
 	global $adb;
-	$query="select datashare_relatedmodule_id from datashare_relatedmodules where tabid=".$tabid." and relatedto_tabid=".$related_tabid ;
+	$query="select datashare_relatedmodule_id from vtiger_datashare_relatedmodules where tabid=".$tabid." and relatedto_tabid=".$related_tabid ;
 	$result=$adb->query($query);
 	$relatedModuleSharingId=$adb->query_result($result,0,'datashare_relatedmodule_id');
 	$log->debug("Exiting getRelatedModuleSharingId method ...");
@@ -3752,7 +3752,7 @@
 	$log->debug("Entering getRelatedModuleSharingPermission(".$shareid.") method ...");
 	global $adb;
 	$relatedSharingModulePermissionArray=Array();
-	$query="select datashare_relatedmodules.*,datashare_relatedmodule_permission.permission from datashare_relatedmodules inner join datashare_relatedmodule_permission on datashare_relatedmodule_permission.datashare_relatedmodule_id=datashare_relatedmodules.datashare_relatedmodule_id where datashare_relatedmodule_permission.shareid=".$shareid;
+	$query="select vtiger_datashare_relatedmodules.*,vtiger_datashare_relatedmodule_permission.permission from vtiger_datashare_relatedmodules inner join vtiger_datashare_relatedmodule_permission on vtiger_datashare_relatedmodule_permission.datashare_relatedmodule_id=vtiger_datashare_relatedmodules.datashare_relatedmodule_id where vtiger_datashare_relatedmodule_permission.shareid=".$shareid;
 	$result=$adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0;$i<$num_rows;$i++)
@@ -3769,10 +3769,10 @@
 }
 
 
-/** This function is to retreive the profiles associated with the  the specified user 
+/** This function is to retreive the vtiger_profiles associated with the  the specified user 
   * It takes the following input parameters:
   *     $userid -- The User Id:: Type Integer
-  *This function will return the profiles associated to the specified users in an Array in the following format:
+  *This function will return the vtiger_profiles associated to the specified vtiger_users in an Array in the following format:
   *     $userProfileArray=(profileid1,profileid2,profileid3,...,profileidn);
   */
 function getUserProfile($userId)
@@ -3782,7 +3782,7 @@
 	global $adb;
 	$roleId=fetchUserRole($userId);
 	$profArr=Array();	
-	$sql1 = "select profileid from role2profile where roleid='" .$roleId."'";
+	$sql1 = "select profileid from vtiger_role2profile where roleid='" .$roleId."'";
         $result1 = $adb->query($sql1);
 	$num_rows=$adb->num_rows($result1);
 	for($i=0;$i<$num_rows;$i++)
@@ -3796,7 +3796,7 @@
 	
 }
 
-/** To retreive the global permission of the specifed user from the various profiles associated with the user  
+/** To retreive the global permission of the specifed user from the various vtiger_profiles associated with the user  
   * @param $userid -- The User Id:: Type Integer
   * @returns  user global permission  array in the following format:
   *     $gloabalPerrArray=(view all action id=>permission,
@@ -3842,7 +3842,7 @@
 
 }
 
-/** To retreive the tab permissions of the specifed user from the various profiles associated with the user  
+/** To retreive the vtiger_tab permissions of the specifed user from the various vtiger_profiles associated with the user  
   * @param $userid -- The User Id:: Type Integer
   * @returns  user global permission  array in the following format:
   *     $tabPerrArray=(tabid1=>permission,
@@ -3887,7 +3887,7 @@
 
 }
 
-/** To retreive the tab acion permissions of the specifed user from the various profiles associated with the user  
+/** To retreive the vtiger_tab acion permissions of the specifed user from the various vtiger_profiles associated with the user  
   * @param $userid -- The User Id:: Type Integer
   * @returns  user global permission  array in the following format:
   *     $actionPerrArray=(tabid1=>permission,
@@ -3935,9 +3935,9 @@
 
 }
 
-/** To retreive the parent role of the specified role 
+/** To retreive the parent vtiger_role of the specified vtiger_role 
   * @param $roleid -- The Role Id:: Type varchar
-  * @returns  parent role array in the following format:
+  * @returns  parent vtiger_role array in the following format:
   *     $parentRoleArray=(roleid1,roleid2,.......,roleidn);
  */
 function getParentRole($roleId)
@@ -3960,9 +3960,9 @@
 	
 }
 
-/** To retreive the subordinate roles of the specified parent role  
+/** To retreive the subordinate vtiger_roles of the specified parent vtiger_role  
   * @param $roleid -- The Role Id:: Type varchar
-  * @returns  subordinate role array in the following format:
+  * @returns  subordinate vtiger_role array in the following format:
   *     $subordinateRoleArray=(roleid1,roleid2,.......,roleidn);
  */
 function getRoleSubordinates($roleId)
@@ -3974,7 +3974,7 @@
 	$roleInfo=$roleDetails[$roleId];
 	$roleParentSeq=$roleInfo[1];
 	
-	$query="select * from role where parentrole like '".$roleParentSeq."::%' order by parentrole asc";
+	$query="select * from vtiger_role where parentrole like '".$roleParentSeq."::%' order by parentrole asc";
 	$result=$adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$roleSubordinates=Array();
@@ -3990,14 +3990,14 @@
 
 }
 
-/** To retreive the subordinate roles and users of the specified parent role  
+/** To retreive the subordinate vtiger_roles and vtiger_users of the specified parent vtiger_role  
   * @param $roleid -- The Role Id:: Type varchar
-  * @returns  subordinate role array in the following format:
+  * @returns  subordinate vtiger_role array in the following format:
   *     $subordinateRoleUserArray=(roleid1=>Array(userid1,userid2,userid3),
-                               roleid2=>Array(userid1,userid2,userid3)
+                               vtiger_roleid2=>Array(userid1,userid2,userid3)
 				                |
 						|
-			       roleidn=>Array(userid1,userid2,userid3));
+			       vtiger_roleidn=>Array(userid1,userid2,userid3));
  */
 function getSubordinateRoleAndUsers($roleId)
 {
@@ -4102,7 +4102,7 @@
 	global $current_user;
 	$user_array=Array();
 	$tabid=getTabid($module);
-	$query = "select shareduserid from tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid;
+	$query = "select shareduserid from vtiger_tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid;
 	$result=$adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0;$i<$num_rows;$i++)
@@ -4123,7 +4123,7 @@
 	global $current_user;
 	$grp_array=Array();
 	$tabid=getTabid($module);
-	$query = "select sharedgroupid from tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid;
+	$query = "select sharedgroupid from vtiger_tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid;
 	$result=$adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0;$i<$num_rows;$i++)
@@ -4144,7 +4144,7 @@
 	global $current_user;
 	$grp_array=Array();
 	$tabid=getTabid($module);
-	$query = "select sharedgroupid from tmp_write_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid;
+	$query = "select sharedgroupid from vtiger_tmp_write_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid;
 	$result=$adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0;$i<$num_rows;$i++)
@@ -4205,172 +4205,172 @@
 
 	if($module == 'Leads')
 	{
-		$sec_query .= "and (crmentity.smownerid in($current_user->id) or crmentity.smownerid in(select user2role.userid from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%') or crmentity.smownerid in(select shareduserid from tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or (crmentity.smownerid in (0) and (";
+		$sec_query .= "and (vtiger_crmentity.smownerid in($current_user->id) or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%') or vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or (vtiger_crmentity.smownerid in (0) and (";
 
                         if(sizeof($current_user_groups) > 0)
                         {
                               $sec_query .= "groups.groupid in".getCurrentUserGroupList()." or ";
                         }
-                         $sec_query .= "groups.groupid in(select tmp_read_group_sharing_per.sharedgroupid from tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";	
+                         $sec_query .= "groups.groupid in(select vtiger_tmp_read_group_sharing_per.sharedgroupid from vtiger_tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";	
 	}
 	elseif($module == 'Accounts')
 	{
-		$sec_query .= "and (crmentity.smownerid in($current_user->id) or crmentity.smownerid in(select user2role.userid from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%') or crmentity.smownerid in(select shareduserid from tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or (crmentity.smownerid in (0) and (";
+		$sec_query .= "and (vtiger_crmentity.smownerid in($current_user->id) or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%') or vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or (vtiger_crmentity.smownerid in (0) and (";
 
                 if(sizeof($current_user_groups) > 0)
                 {
                 	$sec_query .= "groups.groupid in".getCurrentUserGroupList()." or ";
                 }
-		$sec_query .= "groups.groupid in(select tmp_read_group_sharing_per.sharedgroupid from tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
+		$sec_query .= "groups.groupid in(select vtiger_tmp_read_group_sharing_per.sharedgroupid from vtiger_tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
 	
 	}
 	elseif($module == 'Contacts')
 	{
-		$sec_query .= "and (crmentity.smownerid in($current_user->id) or crmentity.smownerid in(select user2role.userid from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%') or crmentity.smownerid in(select shareduserid from tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or (crmentity.smownerid in (0) and (";
+		$sec_query .= "and (vtiger_crmentity.smownerid in($current_user->id) or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%') or vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or (vtiger_crmentity.smownerid in (0) and (";
 
                 if(sizeof($current_user_groups) > 0)
                 {
                 	$sec_query .= "groups.groupid in".getCurrentUserGroupList()." or ";
                 }
-		$sec_query .= "groups.groupid in(select tmp_read_group_sharing_per.sharedgroupid from tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
+		$sec_query .= "groups.groupid in(select vtiger_tmp_read_group_sharing_per.sharedgroupid from vtiger_tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
 	
 	}
 	elseif($module == 'Potentials')
 	{
-		$sec_query .= "and (crmentity.smownerid in($current_user->id) or crmentity.smownerid in(select user2role.userid from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%') or crmentity.smownerid in(select shareduserid from tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or potential.accountid in (select crmid from crmentity where setype='accounts' and crmentity.smownerid in(select shareduserid from tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or potential.accountid in (select crmid from crmentity left join accountgrouprelation on accountgrouprelation.accountid=crmentity.crmid inner join groups on groups.groupname=accountgrouprelation.groupname where setype='Accounts' and crmentity.smownerid=0 and groups.groupid in(select tmp_read_group_rel_sharing_per.sharedgroupid from tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or (crmentity.smownerid in (0) and (";
+		$sec_query .= "and (vtiger_crmentity.smownerid in($current_user->id) or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%') or vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or vtiger_potential.accountid in (select crmid from vtiger_crmentity where setype='accounts' and vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or vtiger_potential.accountid in (select crmid from vtiger_crmentity left join vtiger_accountgrouprelation on vtiger_accountgrouprelation.accountid=vtiger_crmentity.crmid inner join vtiger_groups on vtiger_groups.groupname=vtiger_accountgrouprelation.groupname where setype='Accounts' and vtiger_crmentity.smownerid=0 and vtiger_groups.groupid in(select vtiger_tmp_read_group_rel_sharing_per.sharedgroupid from vtiger_tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or (vtiger_crmentity.smownerid in (0) and (";
 
                 if(sizeof($current_user_groups) > 0)
                 {
                 	$sec_query .= "groups.groupid in".getCurrentUserGroupList()." or ";
                 }
-		$sec_query .= "groups.groupid in(select tmp_read_group_sharing_per.sharedgroupid from tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
+		$sec_query .= "groups.groupid in(select vtiger_tmp_read_group_sharing_per.sharedgroupid from vtiger_tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
 	
 	}
 	elseif($module == 'HelpDesk')
 	{
-		$sec_query .= "and (crmentity.smownerid in($current_user->id) or crmentity.smownerid in(select user2role.userid from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%') or crmentity.smownerid in(select shareduserid from tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or troubletickets.parent_id in (select crmid from crmentity where setype='Accounts' and crmentity.smownerid in(select shareduserid from tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or troubletickets.parent_id in (select crmid from crmentity left join accountgrouprelation on accountgrouprelation.accountid=crmentity.crmid inner join groups on groups.groupname=accountgrouprelation.groupname where setype='Accounts' and crmentity.smownerid=0 and groups.groupid in(select tmp_read_group_rel_sharing_per.sharedgroupid from tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or (crmentity.smownerid in (0) and (";
+		$sec_query .= "and (vtiger_crmentity.smownerid in($current_user->id) or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%') or vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or vtiger_troubletickets.parent_id in (select crmid from vtiger_crmentity where setype='Accounts' and vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or vtiger_troubletickets.parent_id in (select crmid from vtiger_crmentity left join vtiger_accountgrouprelation on vtiger_accountgrouprelation.accountid=vtiger_crmentity.crmid inner join vtiger_groups on vtiger_groups.groupname=vtiger_accountgrouprelation.groupname where setype='Accounts' and vtiger_crmentity.smownerid=0 and vtiger_groups.groupid in(select vtiger_tmp_read_group_rel_sharing_per.sharedgroupid from vtiger_tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or (vtiger_crmentity.smownerid in (0) and (";
 
                 if(sizeof($current_user_groups) > 0)
                 {
                 	$sec_query .= "groups.groupid in".getCurrentUserGroupList()." or ";
                 }
-		$sec_query .= "groups.groupid in(select tmp_read_group_sharing_per.sharedgroupid from tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
+		$sec_query .= "groups.groupid in(select vtiger_tmp_read_group_sharing_per.sharedgroupid from vtiger_tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
 	
 	}
 	elseif($module == 'Emails')
 	{
 		echo '<BR>now<BR>'; 
-		$sec_query .= "and (crmentity.smownerid in($current_user->id) or crmentity.smownerid in(select user2role.userid from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%') or crmentity.smownerid in(select shareduserid from tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")";
-
-		//Adding crterial for account related emails sharing
-		 $sec_query .= "or seactivityrel.crmid in (select crmid from crmentity where setype='Accounts' and crmentity.smownerid in(select shareduserid from tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or seactivityrel.crmid in (select crmid from crmentity left join accountgrouprelation on accountgrouprelation.accountid=crmentity.crmid inner join groups on groups.groupname=accountgrouprelation.groupname where setype='Accounts' and crmentity.smownerid=0 and groups.groupid in(select tmp_read_group_rel_sharing_per.sharedgroupid from tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid."))";
+		$sec_query .= "and (vtiger_crmentity.smownerid in($current_user->id) or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%') or vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")";
+
+		//Adding crterial for vtiger_account related emails sharing
+		 $sec_query .= "or vtiger_seactivityrel.crmid in (select crmid from vtiger_crmentity where setype='Accounts' and vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or vtiger_seactivityrel.crmid in (select crmid from vtiger_crmentity left join vtiger_accountgrouprelation on vtiger_accountgrouprelation.accountid=vtiger_crmentity.crmid inner join vtiger_groups on vtiger_groups.groupname=vtiger_accountgrouprelation.groupname where setype='Accounts' and vtiger_crmentity.smownerid=0 and vtiger_groups.groupid in(select vtiger_tmp_read_group_rel_sharing_per.sharedgroupid from vtiger_tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid."))";
 		//Adding crterial for lead related emails sharing
-		 $sec_query .= " or seactivityrel.crmid in (select crmid from crmentity where setype='Leads' and crmentity.smownerid in(select shareduserid from tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Leads')." and relatedtabid=".$tabid.")) or seactivityrel.crmid in (select crmid from crmentity left join leadgrouprelation on leadgrouprelation.leadid=crmentity.crmid inner join groups on groups.groupname=leadgrouprelation.groupname where setype='Leads' and crmentity.smownerid=0 and groups.groupid in(select tmp_read_group_rel_sharing_per.sharedgroupid from tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Leads')." and relatedtabid=".$tabid."))";
+		 $sec_query .= " or vtiger_seactivityrel.crmid in (select crmid from vtiger_crmentity where setype='Leads' and vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Leads')." and relatedtabid=".$tabid.")) or vtiger_seactivityrel.crmid in (select crmid from vtiger_crmentity left join vtiger_leadgrouprelation on vtiger_leadgrouprelation.leadid=vtiger_crmentity.crmid inner join vtiger_groups on vtiger_groups.groupname=vtiger_leadgrouprelation.groupname where setype='Leads' and vtiger_crmentity.smownerid=0 and vtiger_groups.groupid in(select vtiger_tmp_read_group_rel_sharing_per.sharedgroupid from vtiger_tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Leads')." and relatedtabid=".$tabid."))";
 	
 
 		//Adding crteria for group sharing
-		 $sec_query .= " or (crmentity.smownerid in (0) and (";
+		 $sec_query .= " or (vtiger_crmentity.smownerid in (0) and (";
 
                 if(sizeof($current_user_groups) > 0)
                 {
                 	$sec_query .= "groups.groupid in".getCurrentUserGroupList()." or ";
                 }
-		$sec_query .= "groups.groupid in(select tmp_read_group_sharing_per.sharedgroupid from tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";
+		$sec_query .= "groups.groupid in(select vtiger_tmp_read_group_sharing_per.sharedgroupid from vtiger_tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";
 	
 	}
 	elseif($module == 'Activities')
 	{
-		$sec_query .= "and (crmentity.smownerid in($current_user->id) or crmentity.smownerid in(select user2role.userid from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%')";
+		$sec_query .= "and (vtiger_crmentity.smownerid in($current_user->id) or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%')";
 
 		if(sizeof($current_user_groups) > 0)
 		{
-			$sec_query .= " or (crmentity.smownerid in (0) and (groups.groupid in".getCurrentUserGroupList()."))";
+			$sec_query .= " or (vtiger_crmentity.smownerid in (0) and (vtiger_groups.groupid in".getCurrentUserGroupList()."))";
 		}
 		$sec_query .= ")";	
 	}
 	elseif($module == 'Quotes')
 	{
-		$sec_query .= "and (crmentity.smownerid in($current_user->id) or crmentity.smownerid in(select user2role.userid from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%') or crmentity.smownerid in(select shareduserid from tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")";
-
-		//Adding crterial for account related quotes sharing
-		 $sec_query .= "or quotes.accountid in (select crmid from crmentity where setype='Accounts' and crmentity.smownerid in(select shareduserid from tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or quotes.accountid in (select crmid from crmentity left join accountgrouprelation on accountgrouprelation.accountid=crmentity.crmid inner join groups on groups.groupname=accountgrouprelation.groupname where setype='Accounts' and crmentity.smownerid=0 and groups.groupid in(select tmp_read_group_rel_sharing_per.sharedgroupid from tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid."))";
-		//Adding crterial for potential related quotes sharing
-		 $sec_query .= " or quotes.potentialid in (select crmid from crmentity where setype='Potentials' and crmentity.smownerid in(select shareduserid from tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Potentials')." and relatedtabid=".$tabid.")) or quotes.potentialid in (select crmid from crmentity left join potentialgrouprelation on potentialgrouprelation.potentialid=crmentity.crmid inner join groups on groups.groupname=potentialgrouprelation.groupname where setype='Potentials' and crmentity.smownerid=0 and groups.groupid in(select tmp_read_group_rel_sharing_per.sharedgroupid from tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Potentials')." and relatedtabid=".$tabid."))";
+		$sec_query .= "and (vtiger_crmentity.smownerid in($current_user->id) or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%') or vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")";
+
+		//Adding crterial for vtiger_account related vtiger_quotes sharing
+		 $sec_query .= "or vtiger_quotes.accountid in (select crmid from vtiger_crmentity where setype='Accounts' and vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or vtiger_quotes.accountid in (select crmid from vtiger_crmentity left join vtiger_accountgrouprelation on vtiger_accountgrouprelation.accountid=vtiger_crmentity.crmid inner join vtiger_groups on vtiger_groups.groupname=vtiger_accountgrouprelation.groupname where setype='Accounts' and vtiger_crmentity.smownerid=0 and vtiger_groups.groupid in(select vtiger_tmp_read_group_rel_sharing_per.sharedgroupid from vtiger_tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid."))";
+		//Adding crterial for vtiger_potential related vtiger_quotes sharing
+		 $sec_query .= " or vtiger_quotes.potentialid in (select crmid from vtiger_crmentity where setype='Potentials' and vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Potentials')." and relatedtabid=".$tabid.")) or vtiger_quotes.potentialid in (select crmid from vtiger_crmentity left join vtiger_potentialgrouprelation on vtiger_potentialgrouprelation.potentialid=vtiger_crmentity.crmid inner join vtiger_groups on vtiger_groups.groupname=vtiger_potentialgrouprelation.groupname where setype='Potentials' and vtiger_crmentity.smownerid=0 and vtiger_groups.groupid in(select vtiger_tmp_read_group_rel_sharing_per.sharedgroupid from vtiger_tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Potentials')." and relatedtabid=".$tabid."))";
 	
 
 		//Adding crteria for group sharing
-		 $sec_query .= " or (crmentity.smownerid in (0) and (";
+		 $sec_query .= " or (vtiger_crmentity.smownerid in (0) and (";
 
                 if(sizeof($current_user_groups) > 0)
                 {
                 	$sec_query .= "groups.groupid in".getCurrentUserGroupList()." or ";
                 }
-		$sec_query .= "groups.groupid in(select tmp_read_group_sharing_per.sharedgroupid from tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
+		$sec_query .= "groups.groupid in(select vtiger_tmp_read_group_sharing_per.sharedgroupid from vtiger_tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
 	
 	}	
 	elseif($module == 'PurchaseOrder')
 	{
-		$sec_query .= "and (crmentity.smownerid in($current_user->id) or crmentity.smownerid in(select user2role.userid from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%') or crmentity.smownerid in(select shareduserid from tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or (crmentity.smownerid in (0) and (";
+		$sec_query .= "and (vtiger_crmentity.smownerid in($current_user->id) or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%') or vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or (vtiger_crmentity.smownerid in (0) and (";
 
                 if(sizeof($current_user_groups) > 0)
                 {
                 	$sec_query .= "groups.groupid in".getCurrentUserGroupList()." or ";
                 }
-		$sec_query .= "groups.groupid in(select tmp_read_group_sharing_per.sharedgroupid from tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
+		$sec_query .= "groups.groupid in(select vtiger_tmp_read_group_sharing_per.sharedgroupid from vtiger_tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
 	
 	}
 	elseif($module == 'SalesOrder')
 	{
-		$sec_query .= "and (crmentity.smownerid in($current_user->id) or crmentity.smownerid in(select user2role.userid from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%') or crmentity.smownerid in(select shareduserid from tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")";
-
-		//Adding crterial for account related so sharing
-		 $sec_query .= "or salesorder.accountid in (select crmid from crmentity where setype='Accounts' and crmentity.smownerid in(select shareduserid from tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or salesorder.accountid in (select crmid from crmentity left join accountgrouprelation on accountgrouprelation.accountid=crmentity.crmid inner join groups on groups.groupname=accountgrouprelation.groupname where setype='Accounts' and crmentity.smownerid=0 and groups.groupid in(select tmp_read_group_rel_sharing_per.sharedgroupid from tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid."))";
-		//Adding crterial for potential related so sharing
-		 $sec_query .= " or salesorder.potentialid in (select crmid from crmentity where setype='Potentials' and crmentity.smownerid in(select shareduserid from tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Potentials')." and relatedtabid=".$tabid.")) or salesorder.potentialid in (select crmid from crmentity left join potentialgrouprelation on potentialgrouprelation.potentialid=crmentity.crmid inner join groups on groups.groupname=potentialgrouprelation.groupname where setype='Potentials' and crmentity.smownerid=0 and groups.groupid in(select tmp_read_group_rel_sharing_per.sharedgroupid from tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Potentials')." and relatedtabid=".$tabid."))";
-		//Adding crterial for quotes related so sharing
-		 $sec_query .= " or salesorder.quoteid in (select crmid from crmentity where setype='Quotes' and crmentity.smownerid in(select shareduserid from tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Quotes')." and relatedtabid=".$tabid.")) or salesorder.quoteid in (select crmid from crmentity left join quotegrouprelation on quotegrouprelation.quoteid=crmentity.crmid inner join groups on groups.groupname=quotegrouprelation.groupname where setype='Quotes' and crmentity.smownerid=0 and groups.groupid in(select tmp_read_group_rel_sharing_per.sharedgroupid from tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Quotes')." and relatedtabid=".$tabid."))";
+		$sec_query .= "and (vtiger_crmentity.smownerid in($current_user->id) or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%') or vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")";
+
+		//Adding crterial for vtiger_account related so sharing
+		 $sec_query .= "or vtiger_salesorder.accountid in (select crmid from vtiger_crmentity where setype='Accounts' and vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or vtiger_salesorder.accountid in (select crmid from vtiger_crmentity left join vtiger_accountgrouprelation on vtiger_accountgrouprelation.accountid=vtiger_crmentity.crmid inner join vtiger_groups on vtiger_groups.groupname=vtiger_accountgrouprelation.groupname where setype='Accounts' and vtiger_crmentity.smownerid=0 and vtiger_groups.groupid in(select vtiger_tmp_read_group_rel_sharing_per.sharedgroupid from vtiger_tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid."))";
+		//Adding crterial for vtiger_potential related so sharing
+		 $sec_query .= " or vtiger_salesorder.potentialid in (select crmid from vtiger_crmentity where setype='Potentials' and vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Potentials')." and relatedtabid=".$tabid.")) or vtiger_salesorder.potentialid in (select crmid from vtiger_crmentity left join vtiger_potentialgrouprelation on vtiger_potentialgrouprelation.potentialid=vtiger_crmentity.crmid inner join vtiger_groups on vtiger_groups.groupname=vtiger_potentialgrouprelation.groupname where setype='Potentials' and vtiger_crmentity.smownerid=0 and vtiger_groups.groupid in(select vtiger_tmp_read_group_rel_sharing_per.sharedgroupid from vtiger_tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Potentials')." and relatedtabid=".$tabid."))";
+		//Adding crterial for vtiger_quotes related so sharing
+		 $sec_query .= " or vtiger_salesorder.quoteid in (select crmid from vtiger_crmentity where setype='Quotes' and vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Quotes')." and relatedtabid=".$tabid.")) or vtiger_salesorder.quoteid in (select crmid from vtiger_crmentity left join vtiger_quotegrouprelation on vtiger_quotegrouprelation.quoteid=vtiger_crmentity.crmid inner join vtiger_groups on vtiger_groups.groupname=vtiger_quotegrouprelation.groupname where setype='Quotes' and vtiger_crmentity.smownerid=0 and vtiger_groups.groupid in(select vtiger_tmp_read_group_rel_sharing_per.sharedgroupid from vtiger_tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Quotes')." and relatedtabid=".$tabid."))";
 	
 
 		//Adding crteria for group sharing
-		 $sec_query .= " or (crmentity.smownerid in (0) and (";
+		 $sec_query .= " or (vtiger_crmentity.smownerid in (0) and (";
 
                 if(sizeof($current_user_groups) > 0)
                 {
                 	$sec_query .= "groups.groupid in".getCurrentUserGroupList()." or ";
                 }
-		$sec_query .= "groups.groupid in(select tmp_read_group_sharing_per.sharedgroupid from tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
+		$sec_query .= "groups.groupid in(select vtiger_tmp_read_group_sharing_per.sharedgroupid from vtiger_tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
 	
 	}
 	elseif($module == 'Invoice')
 	{
-		$sec_query .= "and (crmentity.smownerid in($current_user->id) or crmentity.smownerid in(select user2role.userid from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%') or crmentity.smownerid in(select shareduserid from tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")";
-
-		//Adding crterial for account related invoice sharing
-		 $sec_query .= "or invoice.accountid in (select crmid from crmentity where setype='Accounts' and crmentity.smownerid in(select shareduserid from tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or invoice.accountid in (select crmid from crmentity left join accountgrouprelation on accountgrouprelation.accountid=crmentity.crmid inner join groups on groups.groupname=accountgrouprelation.groupname where setype='Accounts' and crmentity.smownerid=0 and groups.groupid in(select tmp_read_group_rel_sharing_per.sharedgroupid from tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid."))";
-		//Adding crterial for salesorder related invoice sharing
-		 $sec_query .= " or invoice.salesorderid in (select crmid from crmentity where setype='SalesOrder' and crmentity.smownerid in(select shareduserid from tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('SalesOrder')." and relatedtabid=".$tabid.")) or invoice.salesorderid in(select crmid from crmentity left join sogrouprelation on sogrouprelation.salesorderid=crmentity.crmid inner join groups on groups.groupname=sogrouprelation.groupname where setype='SalesOrder' and crmentity.smownerid=0 and groups.groupid in(select tmp_read_group_rel_sharing_per.sharedgroupid from tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('SalesOrder')." and relatedtabid=".$tabid."))";
+		$sec_query .= "and (vtiger_crmentity.smownerid in($current_user->id) or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%') or vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")";
+
+		//Adding crterial for vtiger_account related vtiger_invoice sharing
+		 $sec_query .= "or vtiger_invoice.accountid in (select crmid from vtiger_crmentity where setype='Accounts' and vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid.")) or vtiger_invoice.accountid in (select crmid from vtiger_crmentity left join vtiger_accountgrouprelation on vtiger_accountgrouprelation.accountid=vtiger_crmentity.crmid inner join vtiger_groups on vtiger_groups.groupname=vtiger_accountgrouprelation.groupname where setype='Accounts' and vtiger_crmentity.smownerid=0 and vtiger_groups.groupid in(select vtiger_tmp_read_group_rel_sharing_per.sharedgroupid from vtiger_tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('Accounts')." and relatedtabid=".$tabid."))";
+		//Adding crterial for vtiger_salesorder related vtiger_invoice sharing
+		 $sec_query .= " or vtiger_invoice.salesorderid in (select crmid from vtiger_crmentity where setype='SalesOrder' and vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('SalesOrder')." and relatedtabid=".$tabid.")) or vtiger_invoice.salesorderid in(select crmid from vtiger_crmentity left join vtiger_sogrouprelation on vtiger_sogrouprelation.salesorderid=vtiger_crmentity.crmid inner join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where setype='SalesOrder' and vtiger_crmentity.smownerid=0 and vtiger_groups.groupid in(select vtiger_tmp_read_group_rel_sharing_per.sharedgroupid from vtiger_tmp_read_group_rel_sharing_per where userid=".$current_user->id." and tabid=".getTabid('SalesOrder')." and relatedtabid=".$tabid."))";
 	
 
 		//Adding crteria for group sharing
-		 $sec_query .= " or (crmentity.smownerid in (0) and (";
+		 $sec_query .= " or (vtiger_crmentity.smownerid in (0) and (";
 
                 if(sizeof($current_user_groups) > 0)
                 {
                 	$sec_query .= "groups.groupid in".getCurrentUserGroupList()." or ";
                 }
-		$sec_query .= "groups.groupid in(select tmp_read_group_sharing_per.sharedgroupid from tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
+		$sec_query .= "groups.groupid in(select vtiger_tmp_read_group_sharing_per.sharedgroupid from vtiger_tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";			
 	
 	}
 	elseif($module == 'Campaigns')
 	{
 
-		$sec_query .= " and (crmentity.smownerid in($current_user->id) or crmentity.smownerid in(select user2role.userid from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%') or crmentity.smownerid in(select shareduserid from tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or (crmentity.smownerid in (0) and (";
+		$sec_query .= " and (vtiger_crmentity.smownerid in($current_user->id) or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%') or vtiger_crmentity.smownerid in(select shareduserid from vtiger_tmp_read_user_sharing_per where userid=".$current_user->id." and tabid=".$tabid.") or (vtiger_crmentity.smownerid in (0) and (";
 
 		if(sizeof($current_user_groups) > 0)
 		{
 			$sec_query .= "groups.groupid in".getCurrentUserGroupList()." or ";
 		}
-		$sec_query .= "groups.groupid in(select tmp_read_group_sharing_per.sharedgroupid from tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";
+		$sec_query .= "groups.groupid in(select vtiger_tmp_read_group_sharing_per.sharedgroupid from vtiger_tmp_read_group_sharing_per where userid=".$current_user->id." and tabid=".$tabid.")))) ";
 
 			
 	}	
@@ -4378,20 +4378,20 @@
 	{
 
 		//Current User	
-		$sec_query = " and (crmentity.smownerid=".$current_user->id;
+		$sec_query = " and (vtiger_crmentity.smownerid=".$current_user->id;
 
 		//Subordinate User
 		$subUsersList=getSubordinateUsersList();
 		if($subUsersList != '')
 		{
-			$sec_query .= " or crmentity.smownerid in".$subUsersList;
+			$sec_query .= " or vtiger_crmentity.smownerid in".$subUsersList;
 		}
 
 		//Shared User
 		$sharedUsersList=getReadSharingUsersList($module);
 		if($sharedUsersList != '')
 		{
-			$sec_query .= " or crmentity.smownerid in".$sharedUsersList;
+			$sec_query .= " or vtiger_crmentity.smownerid in".$sharedUsersList;
 		}
 
 
@@ -4401,14 +4401,14 @@
 			$userGroupsList=getCurrentUserGroupList();
 			if($userGroupsList != '')
 			{
-				$sec_query .= " or (crmentity.smownerid in(0) and groups.groupid in".$userGroupsList.")";
+				$sec_query .= " or (vtiger_crmentity.smownerid in(0) and vtiger_groups.groupid in".$userGroupsList.")";
 			}
 
 			//Shared User Groups
 			$sharedGroupsList=getReadSharingGroupsList($module);
 			if($sharedGroupsList != '')
 			{
-				$sec_query .= " or (crmentity.smownerid in(0) and groups.groupid in".$sharedGroupsList.")";
+				$sec_query .= " or (vtiger_crmentity.smownerid in(0) and vtiger_groups.groupid in".$sharedGroupsList.")";
 			}	
 
 
@@ -4427,7 +4427,7 @@
 	global $adb,$noof_group_rows;
 	$current_user_group_list=getCurrentUserGroupList();
 	$sharing_write_group_list=getWriteSharingGroupsList($module);
-	$query ="select groupname from groups";
+	$query ="select groupname from vtiger_groups";
 	if($current_user_group_list != '' && $sharing_write_group_list != '')
 	{
 		$query .= " where (groupid in".$current_user_group_list." or groupid in".$sharing_write_group_list.")";
@@ -4456,13 +4456,13 @@
 	$log->debug("Entering getGrpId(".$groupname.") method ...");
 	global $adb;
 	
-	$result = $adb->query("select groupid from groups where groupname='".$groupname."'");
+	$result = $adb->query("select groupid from vtiger_groups where groupname='".$groupname."'");
 	$groupid = $adb->query_result($result,0,'groupid');
 	$log->debug("Exiting getGrpId method ...");
 	return $groupid;
 }
 
-/** Function to check permission to access a field for a given user
+/** Function to check permission to access a vtiger_field for a given user
   * @param $fld_module -- Module :: Type String
   * @param $userid -- User Id :: Type integer
   * @param $fieldname -- Field Name :: Type varchar
@@ -4487,13 +4487,13 @@
 	}
 	else
 	{
-		//get profile list using userid
+		//get vtiger_profile list using userid
 		$profilelist = getCurrentUserProfileList();
 
 		//get tabid
 		$tabid = getTabid($fld_module);
 
-		$query="select profile2field.* from field inner join profile2field on profile2field.fieldid=field.fieldid inner join def_org_field on def_org_field.fieldid=field.fieldid where field.tabid=".$tabid." and profile2field.visible=0 and def_org_field.visible=0  and profile2field.profileid in".$profilelist." and field.fieldname='".$fieldname."' group by field.fieldid";
+		$query="select vtiger_profile2field.* from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=".$tabid." and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0  and vtiger_profile2field.profileid in".$profilelist." and vtiger_field.fieldname='".$fieldname."' group by vtiger_field.fieldid";
 		$result = $adb->query($query);
 
 		$log->debug("Exiting getFieldVisibilityPermission method ...");
@@ -4501,8 +4501,8 @@
 	}
 }
 
-/** Function to get the field access module array 
-  * @returns The field Access module Array :: Type Array
+/** Function to get the vtiger_field access module array 
+  * @returns The vtiger_field Access module Array :: Type Array
   *
  */
 function getFieldModuleAccessArray()
@@ -4576,8 +4576,8 @@
 
 
 
-/** Function to recalculate the Sharing Rules for all the users 
-  * This function will recalculate all the sharing rules for all the users in the Organization and will write them in flat files 
+/** Function to recalculate the Sharing Rules for all the vtiger_users 
+  * This function will recalculate all the sharing rules for all the vtiger_users in the Organization and will write them in flat vtiger_files 
   *
  */
 function RecalculateSharingRules()
@@ -4586,7 +4586,7 @@
 	$log->debug("Entering RecalculateSharingRules() method ...");
 	global $adb;
 	require_once('modules/Users/CreateUserPrivilegeFile.php');
-	$query="select id from users where deleted=0";
+	$query="select id from vtiger_users where deleted=0";
 	$result=$adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0;$i<$num_rows;$i++)
@@ -4599,9 +4599,9 @@
 				
 }
 
-//Code added by Minnie for campaigngroup relation -- start
-
-/** Function to add campaign group relation
+//Code added by Minnie for vtiger_campaigngroup relation -- start
+
+/** Function to add vtiger_campaign group relation
   * @param $campaignid -- Campaign Id:: Type integer
   * @param $groupname -- Group Name:: Type varchar
   *
@@ -4611,13 +4611,13 @@
 	global $log;
 	$log->debug("Entering insert2CampaignGroupRelation(".$campaignid.",".$groupname.") method ...");
 	global $adb;
-	$sql = "insert into campaigngrouprelation values (" .$campaignid .",'".$groupname."')";
+	$sql = "insert into vtiger_campaigngrouprelation values (" .$campaignid .",'".$groupname."')";
 	$adb->query($sql);
 	$log->debug("Exiting insert2CampaignGroupRelation method ...");
 
 }
 
-/** Function to update campaign group relation
+/** Function to update vtiger_campaign group relation
   * @param $campaignid -- Campaign Id:: Type integer
   * @param $groupname -- Group Name:: Type varchar
   *
@@ -4627,10 +4627,10 @@
 	global $log;
 	$log->debug("Entering updateCampaignGroupRelation(".$campaignid.",".$groupname.") method ...");
 	global $adb;
-	$sqldelete = "delete from campaigngrouprelation where campaignid=".$campaignid;
+	$sqldelete = "delete from vtiger_campaigngrouprelation where campaignid=".$campaignid;
 	$adb->query($sqldelete);
 	if($groupname) {
-		$sql = "insert into campaigngrouprelation values (".$campaignid .",'" .$groupname ."')";
+		$sql = "insert into vtiger_campaigngrouprelation values (".$campaignid .",'" .$groupname ."')";
 		$adb->query($sql);
 	}
 	$log->debug("Exiting updateCampaignGroupRelation method ...");

Modified: vtigercrm/trunk/include/utils/export.php
==============================================================================
--- vtigercrm/trunk/include/utils/export.php (original)
+++ vtigercrm/trunk/include/utils/export.php Mon Jun 12 14:26:25 2006
@@ -100,7 +100,7 @@
 	else if ($type == "Accounts")
 	{
 		$focus = new Account;
-		$exp_query="SELECT columnname, fieldlabel FROM field where tabid=6";
+		$exp_query="SELECT columnname, fieldlabel FROM vtiger_field where tabid=6";
 		$account_result=$adb->query($exp_query);
 		if($adb->num_rows($account_result)!=0)
 		{

Modified: vtigercrm/trunk/include/utils/utils.php
==============================================================================
--- vtigercrm/trunk/include/utils/utils.php (original)
+++ vtigercrm/trunk/include/utils/utils.php Mon Jun 12 14:26:25 2006
@@ -133,21 +133,21 @@
 		require_once('include/database/PearDatabase.php');
 		$db = new PearDatabase();
 		$temp_result = Array();
-		// Including deleted users for now.
+		// Including deleted vtiger_users for now.
 		if (empty($status)) {
-				$query = "SELECT id, user_name from users";
+				$query = "SELECT id, user_name from vtiger_users";
 		}
 		else {
 				if($private == 'private')
 				{
 					$log->debug("Sharing is Private. Only the current user should be listed");
-					$query = "select id as id,user_name as user_name from users where id=".$current_user->id." and status='Active' union select user2role.userid as id,users.user_name as user_name from user2role inner join users on users.id=user2role.userid inner join role on role.roleid=user2role.roleid where role.parentrole like '".$current_user_parent_role_seq."::%' and status='Active' union select shareduserid as id,users.user_name as user_name from tmp_read_user_sharing_per inner join users on users.id=tmp_read_user_sharing_per.shareduserid where status='Active' and tmp_read_user_sharing_per.userid=".$current_user->id." and tmp_read_user_sharing_per.tabid=".getTabid($module);	
+					$query = "select id as id,user_name as user_name from vtiger_users where id=".$current_user->id." and status='Active' union select vtiger_user2role.userid as id,vtiger_users.user_name as user_name from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%' and status='Active' union select shareduserid as id,vtiger_users.user_name as user_name from vtiger_tmp_read_user_sharing_per inner join vtiger_users on vtiger_users.id=vtiger_tmp_read_user_sharing_per.shareduserid where status='Active' and vtiger_tmp_read_user_sharing_per.userid=".$current_user->id." and vtiger_tmp_read_user_sharing_per.tabid=".getTabid($module);	
 						
 				}
 				else
 				{
-					$log->debug("Sharing is Public. All users should be listed");
-					$query = "SELECT id, user_name from users WHERE status='$status'";
+					$log->debug("Sharing is Public. All vtiger_users should be listed");
+					$query = "SELECT id, user_name from vtiger_users WHERE status='$status'";
 				}
 		}
 		if (!empty($assigned_user)) {
@@ -675,8 +675,8 @@
 }
 
 /**
- * Create javascript to set the cursor focus to specific field in a form
- * when the screen is rendered.  The field name is currently hardcoded into the
+ * Create javascript to set the cursor focus to specific vtiger_field in a form
+ * when the screen is rendered.  The vtiger_field name is currently hardcoded into the
  * the function.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
@@ -685,7 +685,7 @@
 function get_set_focus_js () {
 global $log;
 $log->debug("Entering set_focus() method ...");
-//TODO Clint 5/20 - Make this function more generic so that it can take in the target form and field names as variables
+//TODO Clint 5/20 - Make this function more generic so that it can take in the target form and vtiger_field names as variables
 $the_script = <<<EOQ
 <script type="text/javascript" language="JavaScript">
 <!-- Begin
@@ -693,12 +693,12 @@
 	if (document.forms.length > 0) {
 		for (i = 0; i < document.forms.length; i++) {
 			for (j = 0; j < document.forms[i].elements.length; j++) {
-				var field = document.forms[i].elements[j];
-				if ((field.type == "text" || field.type == "textarea" || field.type == "password") &&
-						!field.disabled && (field.name == "first_name" || field.name == "name")) {
-					field.focus();
-                    if (field.type == "text") {
-                        field.select();
+				var vtiger_field = document.forms[i].elements[j];
+				if ((vtiger_field.type == "text" || vtiger_field.type == "textarea" || vtiger_field.type == "password") &&
+						!field.disabled && (vtiger_field.name == "first_name" || vtiger_field.name == "name")) {
+				vtiger_field.focus();
+                    if (vtiger_field.type == "text") {
+                        vtiger_field.select();
                     }
 					break;
 	    		}
@@ -800,16 +800,16 @@
   if($module == 'Leads')
   {
 
-   $sql="select (case when (user_name is null) then  (leadgrouprelation.groupname) else (user_name) end) as name from leads left join users on users.id= assigned_user_id left join leadgrouprelation on leadgrouprelation.leadid=leads.id where leads.deleted=0 and leads.id='". $id ."'";
+   $sql="select (case when (user_name is null) then  (vtiger_leadgrouprelation.groupname) else (user_name) end) as name from leads left join vtiger_users on vtiger_users.id= assigned_user_id left join vtiger_leadgrouprelation on vtiger_leadgrouprelation.leadid=leads.id where leads.deleted=0 and leads.id='". $id ."'";
    
   }
   else if($module == 'Tasks')
   {
-       $sql="select (case when (user_name is null) then  (taskgrouprelation.groupname) else (user_name) end) as name from tasks left join users on users.id= assigned_user_id left join taskgrouprelation on taskgrouprelation.taskid=tasks.id where tasks.deleted=0 and tasks.id='". $id ."'";
+       $sql="select (case when (user_name is null) then  (taskgrouprelation.groupname) else (user_name) end) as name from tasks left join vtiger_users on vtiger_users.id= assigned_user_id left join taskgrouprelation on taskgrouprelation.taskid=tasks.id where tasks.deleted=0 and tasks.id='". $id ."'";
   }
   else if($module == 'Calls')
   {
-       $sql="select (case when (user_name is null) then  (callgrouprelation.groupname) else (user_name) end) as name from calls left join users on users.id= assigned_user_id left join callgrouprelation on callgrouprelation.callid=calls.id where calls.deleted=0 and calls.id='". $id ."'";
+       $sql="select (case when (user_name is null) then  (callgrouprelation.groupname) else (user_name) end) as name from calls left join vtiger_users on vtiger_users.id= assigned_user_id left join callgrouprelation on callgrouprelation.callid=calls.id where calls.deleted=0 and calls.id='". $id ."'";
   }
 
 	$result = $adb->query($sql);
@@ -824,7 +824,7 @@
 	$log->debug("Entering getTabname(".$tabid.") method ...");
         $log->info("tab id is ".$tabid);
         global $adb;
-	$sql = "select tablabel from tab where tabid='".$tabid."'";
+	$sql = "select tablabel from vtiger_tab where tabid='".$tabid."'";
 	$result = $adb->query($sql);
 	$tabname=  $adb->query_result($result,0,"tablabel");
 	$log->debug("Exiting getTabname method ...");
@@ -846,7 +846,7 @@
 	global $log;
         $log->info("tab id is ".$tabid);
         global $adb;
-        $sql = "select name from tab where tabid='".$tabid."'";
+        $sql = "select name from vtiger_tab where tabid='".$tabid."'";
         $result = $adb->query($sql);
         $tabname=  $adb->query_result($result,0,"name");
 	}
@@ -863,7 +863,7 @@
 	global $adb;
 	$column_fld = Array();
         $tabid = getTabid($module);
-	$sql = "select * from field where tabid=".$tabid;
+	$sql = "select * from vtiger_field where tabid=".$tabid;
         $result = $adb->query($sql);
         $noofrows = $adb->num_rows($result);
 	for($i=0; $i<$noofrows; $i++)
@@ -884,7 +884,7 @@
         global $adb;
         if($userid != '')
         {
-                $sql = "select email1 from users where id=".$userid;
+                $sql = "select email1 from vtiger_users where id=".$userid;
                 $result = $adb->query($sql);
                 $email = $adb->query_result($result,0,"email1");
         }
@@ -899,7 +899,7 @@
 	$log->info("in getUserId_Ol ".$username);
 
 	global $adb;
-	$sql = "select id from users where user_name='".$username."'";
+	$sql = "select id from vtiger_users where user_name='".$username."'";
 	$result = $adb->query($sql);
 	$num_rows = $adb->num_rows($result);
 	if($num_rows > 0)
@@ -923,7 +923,7 @@
 	$log->info("get Actionid ".$action);
 
 	$actionid = '';
-	$query="select * from actionmapping where actionname='".$action."'";
+	$query="select * from vtiger_actionmapping where actionname='".$action."'";
         $result =$adb->query($query);
         $actionid=$adb->query_result($result,0,'actionid');
 	$log->info("action id selected is ".$actionid );
@@ -940,7 +940,7 @@
 	global $adb;
 
 	$actionname='';
-	$query="select * from actionmapping where actionid=".$actionid ." and securitycheck=0";
+	$query="select * from vtiger_actionmapping where actionid=".$actionid ." and securitycheck=0";
 	$result =$adb->query($query);
 	$actionname=$adb->query_result($result,0,"actionname");
 	$log->debug("Exiting getActionname method ...");
@@ -955,7 +955,7 @@
         $log->info("in getUserId ".$record);
 
 	global $adb;
-        $user_id=$adb->query_result($adb->query("select * from crmentity where crmid = ".$record),0,'smownerid');
+        $user_id=$adb->query_result($adb->query("select * from vtiger_crmentity where crmid = ".$record),0,'smownerid');
 	$log->debug("Exiting getUserId method ...");
 	return $user_id;	
 }
@@ -967,7 +967,7 @@
 
 	global $adb;
 	$ownerArr=Array();
-	$query="select * from crmentity where crmid = ".$record;
+	$query="select * from vtiger_crmentity where crmid = ".$record;
 	$result=$adb->query($query);
 	$user_id=$adb->query_result($result,0,'smownerid');
 	if($user_id != 0)
@@ -980,48 +980,48 @@
 		$module=$adb->query_result($result,0,'setype');
 		if($module == 'Leads')
 		{
-			$query1="select groups.groupid from leadgrouprelation inner join groups on groups.groupname = leadgrouprelation.groupname where leadid=".$record;
+			$query1="select vtiger_groups.groupid from vtiger_leadgrouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_leadgrouprelation.groupname where leadid=".$record;
 		}
 		elseif($module == 'Activities' || $module == 'Emails')
 		{
 
-			$query1="select groups.groupid from activitygrouprelation inner join groups on groups.groupname = activitygrouprelation.groupname where activityid=".$record;
+			$query1="select vtiger_groups.groupid from vtiger_activitygrouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_activitygrouprelation.groupname where activityid=".$record;
 		}
 		elseif($module == 'HelpDesk')
 		{
-			$query1="select groups.groupid from ticketgrouprelation inner join groups on groups.groupname = ticketgrouprelation.groupname where ticketid=".$record;
+			$query1="select vtiger_groups.groupid from vtiger_ticketgrouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname where ticketid=".$record;
 		}
 		elseif($module == 'Accounts')
 		{
-			$query1="select groups.groupid from accountgrouprelation inner join groups on groups.groupname = accountgrouprelation.groupname where accountid=".$record;
+			$query1="select vtiger_groups.groupid from vtiger_accountgrouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_accountgrouprelation.groupname where accountid=".$record;
 		}
 		elseif($module == 'Contacts')
 		{
-			$query1="select groups.groupid from contactgrouprelation inner join groups on groups.groupname = contactgrouprelation.groupname where contactid=".$record;
+			$query1="select vtiger_groups.groupid from vtiger_contactgrouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_contactgrouprelation.groupname where contactid=".$record;
 		}
 		elseif($module == 'Potentials')
 		{
-			$query1="select groups.groupid from potentialgrouprelation inner join groups on groups.groupname = potentialgrouprelation.groupname where potentialid=".$record;
+			$query1="select vtiger_groups.groupid from vtiger_potentialgrouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname where potentialid=".$record;
 		}
 		elseif($module == 'Quotes')
 		{
-			$query1="select groups.groupid from quotegrouprelation inner join groups on groups.groupname = quotegrouprelation.groupname where quoteid=".$record;
+			$query1="select vtiger_groups.groupid from vtiger_quotegrouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_quotegrouprelation.groupname where quoteid=".$record;
 		}
 		elseif($module == 'PurchaseOrder')
 		{
-			$query1="select groups.groupid from pogrouprelation inner join groups on groups.groupname = pogrouprelation.groupname where purchaseorderid=".$record;
+			$query1="select vtiger_groups.groupid from vtiger_pogrouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_pogrouprelation.groupname where purchaseorderid=".$record;
 		}
 		elseif($module == 'SalesOrder')
 		{
-			$query1="select groups.groupid from sogrouprelation inner join groups on groups.groupname = sogrouprelation.groupname where salesorderid=".$record;
+			$query1="select vtiger_groups.groupid from vtiger_sogrouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_sogrouprelation.groupname where salesorderid=".$record;
 		}
 		elseif($module == 'Invoice')
 		{
-			$query1="select groups.groupid from invoicegrouprelation inner join groups on groups.groupname = invoicegrouprelation.groupname where invoiceid=".$record;
+			$query1="select vtiger_groups.groupid from vtiger_invoicegrouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_invoicegrouprelation.groupname where invoiceid=".$record;
 		}
 		elseif($module == 'Campaigns')
 		{
-			$query1="select groups.groupid from campaigngrouprelation inner join groups on groups.groupname = campaigngrouprelation.groupname where campaignid=".$record;
+			$query1="select vtiger_groups.groupid from vtiger_campaigngrouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_campaigngrouprelation.groupname where campaignid=".$record;
 		}
 
 		$result1=$adb->query($query1);
@@ -1043,13 +1043,13 @@
 
 	global $adb;
 	$adb->database->SetFetchMode(ADODB_FETCH_ASSOC); 
-	$fld_result = $adb->query("select * from field where generatedtype=1 and displaytype in (1,2)");
+	$fld_result = $adb->query("select * from vtiger_field where generatedtype=1 and displaytype in (1,2)");
         $num_rows = $adb->num_rows($fld_result);
         for($i=0; $i<$num_rows; $i++)
         {
                  $tab_id = $adb->query_result($fld_result,$i,'tabid');
                  $field_id = $adb->query_result($fld_result,$i,'fieldid');
-                 $adb->query("insert into profile2field values (".$profileid.",".$tab_id.",".$field_id.",0,1)");
+                 $adb->query("insert into vtiger_profile2field values (".$profileid.",".$tab_id.",".$field_id.",0,1)");
 	}
 	$log->debug("Exiting insertProfile2field method ...");
 }
@@ -1060,13 +1060,13 @@
 	$log->debug("Entering insert_def_org_field() method ...");
 	global $adb;
 	$adb->database->SetFetchMode(ADODB_FETCH_ASSOC); 
-	$fld_result = $adb->query("select * from field where generatedtype=1 and displaytype in (1,2)");
+	$fld_result = $adb->query("select * from vtiger_field where generatedtype=1 and displaytype in (1,2)");
         $num_rows = $adb->num_rows($fld_result);
         for($i=0; $i<$num_rows; $i++)
         {
                  $tab_id = $adb->query_result($fld_result,$i,'tabid');
                  $field_id = $adb->query_result($fld_result,$i,'fieldid');
-                 $adb->query("insert into def_org_field values (".$tab_id.",".$field_id.",0,1)");
+                 $adb->query("insert into vtiger_def_org_field values (".$tab_id.",".$field_id.",0,1)");
 	}
 	$log->debug("Exiting insert_def_org_field() method ...");
 }
@@ -1075,12 +1075,12 @@
 {
 	global $log;
 	$log->debug("Entering getProfile2FieldList(".$fld_module.",". $profileid.") method ...");
-        $log->info("in getProfile2FieldList ".$fld_module. ' profile id is  '.$profileid);
+        $log->info("in getProfile2FieldList ".$fld_module. ' vtiger_profile id is  '.$profileid);
 
 	global $adb;
 	$tabid = getTabid($fld_module);
 	
-	$query = "select profile2field.visible,field.* from profile2field inner join field on field.fieldid=profile2field.fieldid where profile2field.profileid=".$profileid." and profile2field.tabid=".$tabid;
+	$query = "select vtiger_profile2field.visible,vtiger_field.* from vtiger_profile2field inner join vtiger_field on vtiger_field.fieldid=vtiger_profile2field.fieldid where vtiger_profile2field.profileid=".$profileid." and vtiger_profile2field.tabid=".$tabid;
 	$result = $adb->query($query);
 	$log->debug("Exiting getProfile2FieldList method ...");
 	return $result;
@@ -1092,12 +1092,12 @@
 {
 	global $log;
 	$log->debug("Entering getProfile2FieldPermissionList(".$fld_module.",". $profileid.") method ...");
-        $log->info("in getProfile2FieldList ".$fld_module. ' profile id is  '.$profileid);
+        $log->info("in getProfile2FieldList ".$fld_module. ' vtiger_profile id is  '.$profileid);
 
 	global $adb;
 	$tabid = getTabid($fld_module);
 	
-	$query = "select profile2field.visible,field.* from profile2field inner join field on field.fieldid=profile2field.fieldid where profile2field.profileid=".$profileid." and profile2field.tabid=".$tabid;
+	$query = "select vtiger_profile2field.visible,vtiger_field.* from vtiger_profile2field inner join vtiger_field on vtiger_field.fieldid=vtiger_profile2field.fieldid where vtiger_profile2field.profileid=".$profileid." and vtiger_profile2field.tabid=".$tabid;
 	$result = $adb->query($query);
 	$return_data=array();
     for($i=0; $i<$adb->num_rows($result); $i++)
@@ -1112,7 +1112,7 @@
 {
 	global $log;
      $log->debug("Entering getProfile2AllFieldList(".$mod_array.",".$profileid.") method ...");
-     $log->info("in getProfile2AllFieldList profile id is " .$profileid);
+     $log->info("in getProfile2AllFieldList vtiger_profile id is " .$profileid);
 
 	global $adb;
 	$profilelist=array();
@@ -1136,7 +1136,7 @@
 	global $adb;
 	$tabid = getTabid($fld_module);
 	
-	$query = "select def_org_field.visible,field.* from def_org_field inner join field on field.fieldid=def_org_field.fieldid where def_org_field.tabid=".$tabid;
+	$query = "select vtiger_def_org_field.visible,vtiger_field.* from vtiger_def_org_field inner join vtiger_field on vtiger_field.fieldid=vtiger_def_org_field.fieldid where vtiger_def_org_field.tabid=".$tabid;
 	$result = $adb->query($query);
 	$log->debug("Exiting getDefOrgFieldList method ...");
 	return $result;
@@ -1163,16 +1163,16 @@
  {
 	global $log;
 	$log->debug("Entering ChangeStatus(".$status.",".$activityid.",".$activity_mode."='') method ...");
-        $log->info("in ChangeStatus ".$status. ' activityid is  '.$activityid);
+        $log->info("in ChangeStatus ".$status. ' vtiger_activityid is  '.$activityid);
 
         global $adb;
         if ($activity_mode == 'Task')
         {
-                $query = "Update activity set status='".$status."' where activityid = ".$activityid;
+                $query = "Update vtiger_activity set status='".$status."' where activityid = ".$activityid;
         }
         elseif ($activity_mode == 'Events')
         {
-                $query = "Update activity set eventstatus='".$status."' where activityid = ".$activityid;
+                $query = "Update vtiger_activity set eventstatus='".$status."' where activityid = ".$activityid;
         }
 	if($query) {
         	$adb->query($query);
@@ -1221,7 +1221,7 @@
         $log->info("in getUnitPrice productid ".$productid);
 
         global $adb;
-        $query = "select unit_price from products where productid=".$productid;
+        $query = "select unit_price from vtiger_products where productid=".$productid;
         $result = $adb->query($query);
         $up = $adb->query_result($result,0,'unit_price');
 	$log->debug("Exiting getUnitPrice method ...");
@@ -1284,7 +1284,7 @@
 	$log->debug("Entering getProductImageName(".$id.",".$deleted_array."='') method ...");
 	global $adb;
 	$image_array=array();	
-	$query = "select imagename from products where productid=".$id;
+	$query = "select imagename from vtiger_products where productid=".$id;
 	$result = $adb->query($query);
 	$image_name = $adb->query_result($result,0,"imagename");
 	$image_array=explode("###",$image_name);
@@ -1308,7 +1308,7 @@
 	global $log;
 	$log->debug("Entering getContactImageName(".$id.") method ...");
         global $adb;
-        $query = "select imagename from contactdetails where contactid=".$id;
+        $query = "select imagename from vtiger_contactdetails where contactid=".$id;
         $result = $adb->query($query);
         $image_name = $adb->query_result($result,0,"imagename");
         $log->debug("Inside getContactImageName. The image_name is ".$image_name);
@@ -1342,11 +1342,11 @@
 	global $adb;
 	if($return_module == "Potentials")
 	{
-		$query ="select products.productname,products.unit_price,products.qtyinstock,seproductsrel.* from products inner join seproductsrel on seproductsrel.productid=products.productid where crmid=".$id;
+		$query ="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_seproductsrel.* from vtiger_products inner join vtiger_seproductsrel on vtiger_seproductsrel.productid=vtiger_products.productid where crmid=".$id;
 	}
 	elseif($return_module == "Products")
 	{
-		$query="select products.productid,products.productname,products.unit_price,products.qtyinstock,crmentity.* from products inner join crmentity on crmentity.crmid=products.productid where crmentity.deleted=0 and productid=".$id;
+		$query="select vtiger_products.productid,vtiger_products.productname,vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_crmentity.* from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid where vtiger_crmentity.deleted=0 and productid=".$id;
 	}
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
@@ -1371,7 +1371,7 @@
 	global $log;
 	$log->debug("Entering updateProductQty(".$product_id.",". $upd_qty.") method ...");
 	global $adb;
-	$query= "update products set qtyinstock=".$upd_qty." where productid=".$product_id;
+	$query= "update vtiger_products set qtyinstock=".$upd_qty." where productid=".$product_id;
         $adb->query($query);
 	$log->debug("Exiting updateProductQty method ...");
 
@@ -1382,7 +1382,7 @@
 	global $log;
 	$log->debug("Entering get_account_info(".$parent_id.") method ...");
         global $adb;
-        $query = "select accountid from potential where potentialid=".$parent_id;
+        $query = "select accountid from vtiger_potential where potentialid=".$parent_id;
         $result = $adb->query($query);
         $accountid=$adb->query_result($result,0,'accountid');
 	$log->debug("Exiting get_account_info method ...");
@@ -1768,7 +1768,7 @@
         if($focus->column_fields['email'] == '' && $focus->column_fields['yahooid'] != '')
                 $fieldname = 'yahooid';
 
-        $res = $adb->query("select * from field where tabid = ".getTabid($module)." and fieldname='".$fieldname."'");
+        $res = $adb->query("select * from vtiger_field where tabid = ".getTabid($module)." and fieldname='".$fieldname."'");
         $fieldid = $adb->query_result($res,0,'fieldid');
 
         $hidden .= '<input type="hidden" name="emailids" value="'.$id.'@'.$fieldid.'|">';
@@ -1791,7 +1791,7 @@
         $log->info("in getPoName ".$po_id);
 
         global $adb;
-        $sql = "select postatus from purchaseorder where purchaseorderid=".$po_id;
+        $sql = "select postatus from vtiger_purchaseorder where purchaseorderid=".$po_id;
         $result = $adb->query($sql);
         $po_status = $adb->query_result($result,0,"postatus");
 	$log->debug("Exiting getPoStatus method ...");
@@ -1810,7 +1810,7 @@
 	global $adb;
 	$qtyInStck=getProductQtyInStock($productId);
 	$updQty=$qtyInStck + $qty;
-	$sql = "UPDATE products set qtyinstock=$updQty where productid=".$productId;
+	$sql = "UPDATE vtiger_products set qtyinstock=$updQty where productid=".$productId;
 	$adb->query($sql);
 	$log->debug("Exiting addToProductStock method ...");
 	
@@ -1824,7 +1824,7 @@
 	global $log;
 	$log->debug("Entering getProductQtyInStock(".$product_id.") method ...");
         global $adb;
-        $query1 = "select qtyinstock from products where productid=".$product_id;
+        $query1 = "select qtyinstock from vtiger_products where productid=".$product_id;
         $result=$adb->query($query1);
         $qtyinstck= $adb->query_result($result,0,"qtyinstock");
 	$log->debug("Exiting getProductQtyInStock method ...");
@@ -1861,10 +1861,10 @@
 
 
 
-/**     Function to get the table name from 'field' table for the input field based on the module
+/**     Function to get the vtiger_table name from 'field' vtiger_table for the input vtiger_field based on the module
  *      @param  : string $module - current module value
- *      @param  : string $fieldname - fieldname to which we want the tablename
- *      @return : string $tablename - tablename in which $fieldname is a column, which is retrieved from 'field' table per $module basis
+ *      @param  : string $fieldname - vtiger_fieldname to which we want the vtiger_tablename
+ *      @return : string $tablename - vtiger_tablename in which $fieldname is a column, which is retrieved from 'field' vtiger_table per $module basis
  */
 function getTableNameForField($module,$fieldname)
 {
@@ -1873,7 +1873,7 @@
 	global $adb;
 	$tabid = getTabid($module);
 
-	$sql = "select tablename from field where tabid=".$tabid." and fieldname like '%".$fieldname."%'";
+	$sql = "select tablename from vtiger_field where tabid=".$tabid." and fieldname like '%".$fieldname."%'";
 	$res = $adb->query($sql);
 
 	$tablename = '';
@@ -1908,7 +1908,7 @@
 	global $log;
 	$log->debug("Entering getPotentialsRelatedAccounts(".$record_id.") method ...");
 	global $adb;
-	$query="select accountid from potential where potentialid=".$record_id;
+	$query="select accountid from vtiger_potential where potentialid=".$record_id;
 	$result=$adb->query($query);
 	$accountid=$adb->query_result($result,0,'accountid');
 	$log->debug("Exiting getPotentialsRelatedAccounts method ...");
@@ -1920,7 +1920,7 @@
 	global $log;
 	$log->debug("Entering getEmailsRelatedAccounts(".$record_id.") method ...");
 	global $adb;
-	$query = "select seactivityrel.crmid from seactivityrel inner join crmentity on crmentity.crmid=seactivityrel.crmid where crmentity.setype='Accounts' and activityid=".$record_id;
+	$query = "select vtiger_seactivityrel.crmid from vtiger_seactivityrel inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_seactivityrel.crmid where vtiger_crmentity.setype='Accounts' and activityid=".$record_id;
 	$result = $adb->query($query);
 	$accountid=$adb->query_result($result,0,'crmid');
 	$log->debug("Exiting getEmailsRelatedAccounts method ...");
@@ -1932,7 +1932,7 @@
 	global $log;
 	$log->debug("Entering getEmailsRelatedLeads(".$record_id.") method ...");
 	global $adb;
-	$query = "select seactivityrel.crmid from seactivityrel inner join crmentity on crmentity.crmid=seactivityrel.crmid where crmentity.setype='Leads' and activityid=".$record_id;
+	$query = "select vtiger_seactivityrel.crmid from vtiger_seactivityrel inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_seactivityrel.crmid where vtiger_crmentity.setype='Leads' and activityid=".$record_id;
 	$result = $adb->query($query);
 	$leadid=$adb->query_result($result,0,'crmid');
 	$log->debug("Exiting getEmailsRelatedLeads method ...");
@@ -1944,7 +1944,7 @@
 	global $log;
 	$log->debug("Entering getHelpDeskRelatedAccounts(".$record_id.") method ...");
 	global $adb;
-        $query="select parent_id from troubletickets inner join crmentity on crmentity.crmid=troubletickets.parent_id where ticketid=".$record_id." and crmentity.setype='Accounts'";
+        $query="select parent_id from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.parent_id where ticketid=".$record_id." and vtiger_crmentity.setype='Accounts'";
         $result=$adb->query($query);
         $accountid=$adb->query_result($result,0,'parent_id');
 	$log->debug("Exiting getHelpDeskRelatedAccounts method ...");
@@ -1957,7 +1957,7 @@
 	global $log;
 	$log->debug("Entering getQuotesRelatedAccounts(".$record_id.") method ...");
 	global $adb;
-        $query="select accountid from quotes where quoteid=".$record_id;
+        $query="select accountid from vtiger_quotes where quoteid=".$record_id;
         $result=$adb->query($query);
         $accountid=$adb->query_result($result,0,'accountid');
 	$log->debug("Exiting getQuotesRelatedAccounts method ...");
@@ -1970,7 +1970,7 @@
 	global $log;
 	$log->debug("Entering getQuotesRelatedPotentials(".$record_id.") method ...");
 	global $adb;
-        $query="select potentialid from quotes where quoteid=".$record_id;
+        $query="select potentialid from vtiger_quotes where quoteid=".$record_id;
         $result=$adb->query($query);
         $potid=$adb->query_result($result,0,'potentialid');
 	$log->debug("Exiting getQuotesRelatedPotentials method ...");
@@ -1982,7 +1982,7 @@
 	global $log;
 	$log->debug("Entering getSalesOrderRelatedAccounts(".$record_id.") method ...");
 	global $adb;
-        $query="select accountid from salesorder where salesorder=".$record_id;
+        $query="select accountid from vtiger_salesorder where salesorder=".$record_id;
         $result=$adb->query($query);
         $accountid=$adb->query_result($result,0,'accountid');
 	$log->debug("Exiting getSalesOrderRelatedAccounts method ...");
@@ -1995,7 +1995,7 @@
 	global $log;
 	$log->debug("Entering getSalesOrderRelatedPotentials(".$record_id.") method ...");
 	global $adb;
-        $query="select potentialid from salesorder where salesorder=".$record_id;
+        $query="select potentialid from vtiger_salesorder where salesorder=".$record_id;
         $result=$adb->query($query);
         $potid=$adb->query_result($result,0,'potentialid');
 	$log->debug("Exiting getSalesOrderRelatedPotentials method ...");
@@ -2007,7 +2007,7 @@
 	global $log;
 	$log->debug("Entering getSalesOrderRelatedQuotes(".$record_id.") method ...");
 	global $adb;
-        $query="select quoteid from salesorder where salesorder=".$record_id;
+        $query="select quoteid from vtiger_salesorder where salesorder=".$record_id;
         $result=$adb->query($query);
         $qtid=$adb->query_result($result,0,'quoteid');
 	$log->debug("Exiting getSalesOrderRelatedQuotes method ...");
@@ -2019,7 +2019,7 @@
 	global $log;
 	$log->debug("Entering getInvoiceRelatedAccounts(".$record_id.") method ...");
 	global $adb;
-        $query="select accountid from invoice where invoiceid=".$record_id;
+        $query="select accountid from vtiger_invoice where invoiceid=".$record_id;
         $result=$adb->query($query);
         $accountid=$adb->query_result($result,0,'accountid');
 	$log->debug("Exiting getInvoiceRelatedAccounts method ...");
@@ -2031,7 +2031,7 @@
 	global $log;
 	$log->debug("Entering getInvoiceRelatedSalesOrder(".$record_id.") method ...");
 	global $adb;
-        $query="select salesorderid from invoice where invoiceid=".$record_id;
+        $query="select salesorderid from vtiger_invoice where invoiceid=".$record_id;
         $result=$adb->query($query);
         $soid=$adb->query_result($result,0,'salesorderid');
 	$log->debug("Exiting getInvoiceRelatedSalesOrder method ...");
@@ -2147,7 +2147,7 @@
 }//function ends
 
 
-/**   Function to get the Graph and table format for a particular date
+/**   Function to get the Graph and vtiger_table format for a particular date
         based upon the period
         * Portions created by vtiger are Copyright (C) vtiger.
         * All Rights Reserved.
@@ -2158,7 +2158,7 @@
 	global $log;
 	$log->debug("Entering Graph_n_table_format(".$period_type.",".$date_value.") method ...");
         $date_val=explode("-",$date_value);
-        if($period_type=="month")   //to get the table format dates
+        if($period_type=="month")   //to get the vtiger_table format dates
         {
                 $table_format=date("j",mktime(0,0,0,date($date_val[1]),(date($date_val[2])),date($date_val[0])));
                 $graph_format=date("D",mktime(0,0,0,date($date_val[1]),(date($date_val[2])),date($date_val[0])));
@@ -2185,7 +2185,7 @@
 	$log->debug("Entering getImageCount(".$id.") method ...");
 	global $adb;
 	$image_lists=array();
-	$query="select imagename from products where productid=".$id;
+	$query="select imagename from vtiger_products where productid=".$id;
 	$result=$adb->query($query);
 	$imagename=$adb->query_result($result,0,'imagename');
 	$image_lists=explode("###",$imagename);
@@ -2198,7 +2198,7 @@
 	global $log;
 	$log->debug("Entering getUserImageName(".$id.") method ...");
 	global $adb;
-	$query = "select imagename from users where id=".$id;
+	$query = "select imagename from vtiger_users where id=".$id;
 	$result = $adb->query($query);
 	$image_name = $adb->query_result($result,0,"imagename");
 	$log->debug("Inside getUserImageName. The image_name is ".$image_name);
@@ -2213,7 +2213,7 @@
 	global $log;
 	$log->debug("Entering getUserImageNames() method ...");
 	global $adb;
-	$query = "select imagename from users where deleted=0";
+	$query = "select imagename from vtiger_users where deleted=0";
 	$result = $adb->query($query);
 	$image_name=array();
 	for($i=0;$i<$adb->num_rows($result);$i++)
@@ -2250,6 +2250,6 @@
 
 function useInternalMailer() {
 	global $current_user,$adb;
-	return $adb->query_result($adb->query("select int_mailer from mail_accounts where user_id='".$current_user->id."'"),0,"int_mailer");
+	return $adb->query_result($adb->query("select int_mailer from vtiger_mail_accounts where user_id='".$current_user->id."'"),0,"int_mailer");
 }
 ?>

Modified: vtigercrm/trunk/index.php
==============================================================================
--- vtigercrm/trunk/index.php (original)
+++ vtigercrm/trunk/index.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 /*********************************************************************************
  * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/index.php,v 1.93 2005/04/21 16:17:25 ray Exp $
  * Description: Main file and starting point for the application.  Calls the 
- * theme header and footer files defined for the user as well as the module as 
+ * theme header and footer vtiger_files defined for the user as well as the module as 
  * defined by the input parameters.
  ********************************************************************************/
 
@@ -105,7 +105,7 @@
 if (isset($_REQUEST['PHPSESSID'])) $log->debug("****Starting for session ".$_REQUEST['PHPSESSID']);
 else $log->debug("****Starting for new session");
 
-// We use the REQUEST_URI later to construct dynamic URLs.  IIS does not pass this field
+// We use the REQUEST_URI later to construct dynamic URLs.  IIS does not pass this vtiger_field
 // to prevent an error, if it is not set, we will assign it to ''
 if(!isset($_SERVER['REQUEST_URI']))
 {
@@ -271,7 +271,7 @@
 			ereg("^Webmails",$module) ))
 	{
 		$skipHeaders=true;
-		//skip headers for all these invocations as they are mostly popups
+		//skip vtiger_headers for all these invocations as they are mostly popups
 		if(ereg("^Popup", $action) ||
 			ereg("^ChangePassword", $action) ||
 			ereg("^Export", $action) ||
@@ -319,7 +319,7 @@
 }
 else {
     // use $default_module and $default_action as set in config.php
-    // Redirect to the correct module with the correct action.  We need the URI to include these fields.
+    // Redirect to the correct module with the correct action.  We need the URI to include these vtiger_fields.
   
 
         header("Location: index.php?action=$default_action&module=$default_module");
@@ -501,9 +501,9 @@
         setcookie('ck_login_language_vtiger', $_SESSION['authenticated_user_language']);
 }
 
-//skip headers for popups, deleting, saving, importing and other actions
+//skip vtiger_headers for popups, deleting, saving, importing and other actions
 if(!$skipHeaders) {
-	$log->debug("including headers");
+	$log->debug("including vtiger_headers");
 	if($use_current_login)
 	{
 		if(isset($_REQUEST['category']) && $_REQUEST['category'] !='')
@@ -522,7 +522,7 @@
 	if(isset($_SESSION['administrator_error']))
 	{
 		// only print DB errors once otherwise they will still look broken after they are fixed.
-		// Only print the errors for admin users.
+		// Only print the errors for admin vtiger_users.
 		if(is_admin($current_user)) 
 			echo $_SESSION['administrator_error'];
 		unset($_SESSION['administrator_error']);
@@ -531,7 +531,7 @@
 	echo "<!-- startscrmprint -->";
 }
 else {
-		$log->debug("skipping headers");
+		$log->debug("skipping vtiger_headers");
 }
 
 

Modified: vtigercrm/trunk/install/0welcome.php
==============================================================================
--- vtigercrm/trunk/install/0welcome.php (original)
+++ vtigercrm/trunk/install/0welcome.php Mon Jun 12 14:26:25 2006
@@ -54,7 +54,7 @@
 <body leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
 
 
-<!-- Master table -->
+<!-- Master vtiger_table -->
 <table border=0 cellspacing=0 cellpadding=0 width=100%>
 <tr>
 <td width="10%" valign="top"></td>
@@ -95,7 +95,7 @@
 <p><b><i>Again, thanks for taking out the time to try vtiger! We want you to know that we really appreciate it.</i></b>
 
 <p><b>Installation Instructions:-</b></p>
-<p>This Configuration Wizard will create vtiger CRM 5.0 Beta databases and tables and configuration files you need to start. The entire process should take about four minutes. Click the Start button when you are ready. 
+<p>This Configuration Wizard will create vtiger CRM 5.0 Beta databases and vtiger_tables and configuration vtiger_files you need to start. The entire process should take about four minutes. Click the Start button when you are ready. 
 <br><br>
 <p><span style="color:#555555">- vtiger CRM 5.0 Beta is tested on mySQL 4.1.X, mySQL 5.0.19, PHP 5.0.19 and Apache 2.0.40.</p> 
 <p align="center"><font color='red'><b>vtiger CRM 5 Beta will not work on mysql 4.0.x versions</b></font></center><center><font color='blue'><b>vtiger crm can run on a system which has xampp/lampp/wampp already installed in it provided it meets the above mentioned requirements</b></font></center>
@@ -183,7 +183,7 @@
 			form for making modifications,<br>
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; including but not limited to software
 			source code, documentation<br>
-			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; source, and configuration files.<br>
+			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; source, and configuration vtiger_files.<br>
 			<br>
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Object" form shall mean any form
 			resulting from mechanical<br>
@@ -233,8 +233,8 @@
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; to the Licensor or its representatives,
 			including but not limited to<br>
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; communication on electronic mailing
-			lists, source code control systems,<br>
-			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and issue tracking systems that are
+			lists, source code control vtiger_systems,<br>
+			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and issue tracking vtiger_systems that are
 			managed by, or on behalf of, the<br>
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Licensor for the purpose of discussing
 			and improving the Work, but<br>
@@ -306,10 +306,10 @@
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Derivative Works
 			a copy of this License; and<br>
 			<br>
-			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (b) You must cause any modified files to
+			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (b) You must cause any modified vtiger_files to
 			carry prominent notices<br>
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stating that You
-			changed the files; and<br>
+			changed the vtiger_files; and<br>
 			<br>
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (c) You must retain, in the Source form
 			of any Derivative Works<br>
@@ -460,7 +460,7 @@
 			<br>
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; To apply the Apache License to your
 			work, attach the following<br>
-			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boilerplate notice, with the fields
+			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boilerplate notice, with the vtiger_fields
 			enclosed by brackets "[]"<br>
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; replaced with your own identifying
 			information. (Don't include<br>
@@ -547,7 +547,7 @@
 			&nbsp;*<br>
 			&nbsp;* 2. The origin of this software must not be misrepresented,
 			either by<br>
-			&nbsp;* explicit claim or by omission.&nbsp; Since few users ever read
+			&nbsp;* explicit claim or by omission.&nbsp; Since few vtiger_users ever read
 			sources, credits<br>
 			&nbsp;* must appear in the documentation.<br>
 			&nbsp;*<br>
@@ -865,7 +865,7 @@
 			acknowledgments normally appear.<br>
 			&nbsp;*<br>
 			&nbsp;* 4. The names "Apache" and "Apache Software Foundation" must<br>
-			&nbsp;*&nbsp;&nbsp;&nbsp; not be used to endorse or promote products
+			&nbsp;*&nbsp;&nbsp;&nbsp; not be used to endorse or promote vtiger_products
 			derived from this<br>
 			&nbsp;*&nbsp;&nbsp;&nbsp; software without prior written permission.
 			For written<br>
@@ -1018,7 +1018,7 @@
 			<br>
 			&nbsp;&nbsp; somewhere reasonably visible in your documentation and in
 			any relevant<br>
-			&nbsp;&nbsp; files or online help data or similar. A reference to the
+			&nbsp;&nbsp; vtiger_files or online help data or similar. A reference to the
 			ftp site for<br>
 			&nbsp;&nbsp; the source, that is, to<br>
 			<br>
@@ -1092,7 +1092,7 @@
 			and Clark Cooper<br>
 			<br>
 			Permission is hereby granted, free of charge, to any person obtaining<br>
-			a copy of this software and associated documentation files (the<br>
+			a copy of this software and associated documentation vtiger_files (the<br>
 			"Software"), to deal in the Software without restriction, including<br>
 			without limitation the rights to use, copy, modify, merge, publish,<br>
 			distribute, sublicense, and/or sell copies of the Software, and to<br>
@@ -1189,16 +1189,16 @@
 			<br>
 			IMPORTANT:<br>
 			<br>
-			Send bug (error) reports, questions and comments to the mailing list<br>
+			Send bug (error) vtiger_reports, questions and comments to the mailing list<br>
 			at mysql at lists.mysql.com<br>
 			<br>
-			Please use the 'mysqlbug' script when posting bug reports or questions<br>
+			Please use the 'mysqlbug' script when posting bug vtiger_reports or questions<br>
 			about MySQL. mysqlbug will gather some information about your system<br>
 			and start your editor with a form in which you can describe your<br>
-			problem. Bug reports might be silently ignored by the MySQL<br>
-			maintainers if there is not a good reason included in the report as to<br>
-			why mysqlbug has not been used. A report that says 'MySQL does not<br>
-			work for me. Why?' is not considered a valid bug report.<br>
+			problem. Bug vtiger_reports might be silently ignored by the MySQL<br>
+			maintainers if there is not a good reason included in the vtiger_report as to<br>
+			why mysqlbug has not been used. A vtiger_report that says 'MySQL does not<br>
+			work for me. Why?' is not considered a valid bug vtiger_report.<br>
 			<br>
 			The mysqlbug script can be found in the 'scripts' directory of the<br>
 			distribution, that is '&lt;where-you-installed-mysql&gt;/scripts'.<br>
@@ -1228,7 +1228,7 @@
 			provided with the<br>
 			&nbsp;&nbsp;&nbsp;&nbsp; distribution.<br>
 			&nbsp;<br>
-			&nbsp; 3. The name "PHP" must not be used to endorse or promote products<br>
+			&nbsp; 3. The name "PHP" must not be used to endorse or promote vtiger_products<br>
 			&nbsp;&nbsp;&nbsp;&nbsp; derived from this software without prior
 			written permission. For<br>
 			&nbsp;&nbsp;&nbsp;&nbsp; written permission, please contact
@@ -1343,7 +1343,7 @@
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.9. ''Modifications'' means any
 			addition to or deletion from the substance or structure of either the
 			Original Code or any previous Modifications. When Covered Code is
-			released as a series of files, a Modification is:<br>
+			released as a series of vtiger_files, a Modification is:<br>
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A.
 			Any addition to or deletion from the contents of a file containing
 			Original Code or previous Modifications.<br>
@@ -1367,7 +1367,7 @@
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.11. ''Source Code'' means the
 			preferred form of the Covered Code for making modifications to it,
 			including all modules it contains, plus any associated interface
-			definition files, scripts used to control compilation and installation
+			definition vtiger_files, scripts used to control compilation and installation
 			of an Executable, or source code differential comparisons against
 			either the Original Code or another well known, available Covered Code
 			of the Contributor's choice. The Source Code can be in a compressed or
@@ -1686,7 +1686,7 @@
 			such claim is resolved (such as by license or settlement) prior to the
 			initiation of patent infringement litigation, then the reasonable value
 			of the licenses granted by such Participant under Sections 2.1 or 2.2
-			shall be taken into account in determining the amount or value of any
+			shall be taken into vtiger_account in determining the amount or value of any
 			payment or license.<br>
 			<br>
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8.4.&nbsp; In the event of termination
@@ -1783,7 +1783,7 @@
 			Contributor(s): ______________________________________.<br>
 			<br>
 			[NOTE: The text of this Exhibit A may differ slightly from the text of
-			the notices in the Source Code files of the Original Code. You should
+			the notices in the Source Code vtiger_files of the Original Code. You should
 			use the text of this Exhibit A rather than the text found in the
 			Original Code Source Code for Your Modifications.]<br>
 			<br>
@@ -1834,7 +1834,7 @@
 			intended to<br>
 			guarantee your freedom to share and change free software--to make sure
 			the<br>
-			software is free for all its users.<br>
+			software is free for all its vtiger_users.<br>
 			<br>
 			This license, the Lesser General Public License, applies to some
 			specially<br>
@@ -1871,7 +1871,7 @@
 			must<br>
 			make sure that they, too, receive or can get the source code. If you
 			link<br>
-			other code with the library, you must provide complete object files to
+			other code with the library, you must provide complete object vtiger_files to
 			the<br>
 			recipients, so that they can relink them with the library after making
 			changes<br>
@@ -1946,7 +1946,7 @@
 			<br>
 			In other cases, permission to use a particular library in non-free
 			programs<br>
-			enables a greater number of people to use a large body of free
+			enables a greater number of people to use a vtiger_large body of free
 			software. For<br>
 			example, permission to use the GNU C Library in non-free programs
 			enables many<br>
@@ -2046,23 +2046,23 @@
 			&nbsp;&nbsp;&nbsp; a) The modified work must itself be a software
 			library.<br>
 			<br>
-			&nbsp;&nbsp;&nbsp; b) You must cause the files modified to carry
+			&nbsp;&nbsp;&nbsp; b) You must cause the vtiger_files modified to carry
 			prominent notices stating<br>
-			that you changed the files and the date of any change.<br>
+			that you changed the vtiger_files and the date of any change.<br>
 			<br>
 			&nbsp;&nbsp;&nbsp; c) You must cause the whole of the work to be
 			licensed at no charge to all<br>
 			third parties under the terms of this License.<br>
 			<br>
 			&nbsp;&nbsp;&nbsp; d) If a facility in the modified Library refers to a
-			function or a table<br>
+			function or a vtiger_table<br>
 			of data to be supplied by an application program that uses the
 			facility, other<br>
 			than as an argument passed when the facility is invoked, then you must
 			make a<br>
 			good faith effort to ensure that, in the event an application does not
 			supply<br>
-			such function or table, the facility still operates, and performs
+			such function or vtiger_table, the facility still operates, and performs
 			whatever<br>
 			part of its purpose remains meaningful.<br>
 			<br>
@@ -2233,7 +2233,7 @@
 			executable<br>
 			containing the modified Library. (It is understood that the user who
 			changes<br>
-			the contents of definitions files in the Library will not necessarily
+			the contents of definitions vtiger_files in the Library will not necessarily
 			be able<br>
 			to recompile the application to use the modified definitions.)<br>
 			<br>
@@ -2526,19 +2526,19 @@
 			Acknowledgements:<br>
 			<br>
 			We have used the following software:<br>
-			<br>1. ExcelReader package to read the xls files. We have taken the utility from the following Web site : <br>
+			<br>1. ExcelReader package to read the xls vtiger_files. We have taken the utility from the following Web site : <br>
 			http://freshmeat.net/projects/phpexcelreader/<br>
 			The product is available as GNU General Public License (GPL).<br>
-			2. E-mail Client to handle attachments with PHP. We have taken the ideas from the article by Kevin Steffer available at the<br>
+			2. E-mail Client to handle vtiger_attachments with PHP. We have taken the ideas from the article by Kevin Steffer available at the<br>
   http://www.linuxscope.net/articles/mailAttachmentsPHP.html<br>
-			3. FPDF package to create PDF reports and documents. We have downloaded package from http://www.fpdf.org<br>
+			3. FPDF package to create PDF vtiger_reports and documents. We have downloaded package from http://www.fpdf.org<br>
 			4. Prototype (Object-Oriented JavaScript framework) package to ease development of dynamic web applications. We have downloaded package from http://prototype.conio.net<br>
 			5. class_http to cache scraped content. We have downloaded package from http://www.troywolf.com/articles/php/class_http/ <br>
-			6.Carousel Slideshow package to display large images as thumbnails. We have downloaded package from http://www.dynamicdrive.com/dynamicindex14/carousel2.htm<br>
-			7. Ajax Popup Chat for enabling instant messaging for vtiger CRM users. We have downloaded package from http://www.os-solution.com/demo/ajaxcsspopupchat/index.php<br>
+			6.Carousel Slideshow package to display vtiger_large images as thumbnails. We have downloaded package from http://www.dynamicdrive.com/dynamicindex14/carousel2.htm<br>
+			7. Ajax Popup Chat for enabling instant messaging for vtiger CRM vtiger_users. We have downloaded package from http://www.os-solution.com/demo/ajaxcsspopupchat/index.php<br>
 			8. Image Crossfade Redux for enabling fade effect to images. We have downloaded package from http://slayeroffice.com/code/imageCrossFade/xfade2.html<br>
 			9. Calculator for enabling calculations in vtiger CRM. We have downloaded package from http://www.hmhd.com/steve<br>
-We are grateful to the creators of the respective products for providing such a beautiful utilities.<br>
+We are grateful to the creators of the respective vtiger_products for providing such a beautiful utilities.<br>
 			
 			&nbsp;<br>
 			<br>
@@ -2587,7 +2587,7 @@
 <td width="10%" valign="top"></td>
 </tr>
 </table>
-<!-- Master table closes -->
+<!-- Master vtiger_table closes -->
 
 </body>
 </html>

Modified: vtigercrm/trunk/install/1checkSystem.php
==============================================================================
--- vtigercrm/trunk/install/1checkSystem.php (original)
+++ vtigercrm/trunk/install/1checkSystem.php Mon Jun 12 14:26:25 2006
@@ -156,7 +156,7 @@
 </head>
 <body leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
 
-<!-- Master table -->
+<!-- Master vtiger_table -->
 <table border=0 cellspacing=0 cellpadding=0 width=100%>
 <tr>
 	<td align=center>
@@ -250,7 +250,7 @@
         </tr>
 		<tr bgcolor="#fafafa">
 		    <td valign=top ><strong>Uploads Directory</strong><br> (storage/)</td>
-            <td valign=top bgcolor="white"><?php echo (is_writable('./storage/'))?"<strong><font color=\"#0066CC\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems with the file attachments feature. Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File attachments issue</a> for more details </font>"; ?></td>
+            <td valign=top bgcolor="white"><?php echo (is_writable('./storage/'))?"<strong><font color=\"#0066CC\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems with the file vtiger_attachments feature. Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File vtiger_attachments issue</a> for more details </font>"; ?></td>
         </tr>
 		<tr bgcolor="#fafafa">
 		    <td valign=top ><strong>Install Directory</strong><br> (install/)</td>
@@ -262,19 +262,19 @@
         </tr>
 	<tr bgcolor="#fafafa">
 		<td valign=top ><strong>Product Image Directory</strong><br> (test/product/)</td>
-		<td valign=top bgcolor="white"><?php echo (is_writable('./test/product/'))?"<strong><font color=\"#0066CC\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems while attaching image for Products.Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File attachments issue</a> for more details </font>"; ?></td>
+		<td valign=top bgcolor="white"><?php echo (is_writable('./test/product/'))?"<strong><font color=\"#0066CC\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems while attaching image for Products.Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File vtiger_attachments issue</a> for more details </font>"; ?></td>
 	</tr>
 	<tr bgcolor="#fafafa">
 		<td valign=top ><strong>User Image Directory</strong><br> (test/user/)</td>
-		<td valign=top bgcolor="white"><?php echo (is_writable('./test/user/'))?"<strong><font color=\"#0066CC\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems while attaching image for Users. Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File attachments issue</a> for more details </font>"; ?></td>
+		<td valign=top bgcolor="white"><?php echo (is_writable('./test/user/'))?"<strong><font color=\"#0066CC\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems while attaching image for Users. Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File vtiger_attachments issue</a> for more details </font>"; ?></td>
 	</tr>
 	<tr bgcolor="#fafafa">
 		<td valign=top ><strong>Contact Image Directory</strong><br> (test/contact/)</td>
-		<td valign=top bgcolor="white"><?php echo (is_writable('./test/contact/'))?"<strong><font color=\"#0066CC\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems while attaching image for Contacts. Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File attachments issue</a> for more details </font>"; ?></td>
+		<td valign=top bgcolor="white"><?php echo (is_writable('./test/contact/'))?"<strong><font color=\"#0066CC\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems while attaching image for Contacts. Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File vtiger_attachments issue</a> for more details </font>"; ?></td>
 	</tr>
 		<tr bgcolor="#fafafa">
 		    <td valign=top ><strong>Logo Directory</strong><br> (test/logo/)</td>
-            <td valign=top bgcolor="white"><?php echo (is_writable('./test/logo/'))?"<strong><font color=\"#0066CC\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems with the company logo in the pdf generation. Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File attachments issue</a> for more details </font>"; ?></td>
+            <td valign=top bgcolor="white"><?php echo (is_writable('./test/logo/'))?"<strong><font color=\"#0066CC\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems with the company logo in the pdf generation. Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File vtiger_attachments issue</a> for more details </font>"; ?></td>
         </tr>
 
 		<tr bgcolor="#fafafa">
@@ -359,7 +359,7 @@
 </td>
 </tr>
 </table>
-<!-- Master table closes -->
+<!-- Master vtiger_table closes -->
 
 <br><br><br>
 <!--

Modified: vtigercrm/trunk/install/2setConfig.php
==============================================================================
--- vtigercrm/trunk/install/2setConfig.php (original)
+++ vtigercrm/trunk/install/2setConfig.php Mon Jun 12 14:26:25 2006
@@ -234,7 +234,7 @@
 
 	// Here we decide whether to submit the form.
 	if (isError == true) {
-		alert("Missing required fields: " + errorMessage);
+		alert("Missing required vtiger_fields: " + errorMessage);
 		return false;
 	}
 
@@ -244,7 +244,7 @@
 </script>
 
 
-<!-- Master table -->
+<!-- Master vtiger_table -->
 <table border=0 cellspacing=0 cellpadding=0 width=100%>
 <tr>
 	<td align=center>
@@ -291,7 +291,7 @@
 
 					  If you do not have root access to your database (for example you are installing in a virtual
 					  hosting environment), you will need to have your database created for you before you proceed.
-					  However, this installer will still be able to create the necessary database tables. <br><br>
+					  However, this installer will still be able to create the necessary database vtiger_tables. <br><br>
 			
 					  If you unsure of your database host, username or password, we suggest that you use the default
 					  values below. <br><br>
@@ -433,7 +433,7 @@
 </td>
 </tr>
 </table>
-<!-- Master table closes -->
+<!-- Master vtiger_table closes -->
 
 <br><br><br>
 

Modified: vtigercrm/trunk/install/3confirmConfig.php
==============================================================================
--- vtigercrm/trunk/install/3confirmConfig.php (original)
+++ vtigercrm/trunk/install/3confirmConfig.php Mon Jun 12 14:26:25 2006
@@ -131,7 +131,7 @@
 	</head>
 	<body leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
 
-		<!-- Master table -->
+		<!-- Master vtiger_table -->
 		<table border=0 cellspacing=0 cellpadding=0 width=100%>
 			<tr>
 				<td align=center>
@@ -299,6 +299,6 @@
 				</td>
 			</tr>
 		</table>
-	<!-- Master table closes -->
+	<!-- Master vtiger_table closes -->
 	</body>
 </html>

Modified: vtigercrm/trunk/install/4createConfigFile.php
==============================================================================
--- vtigercrm/trunk/install/4createConfigFile.php (original)
+++ vtigercrm/trunk/install/4createConfigFile.php Mon Jun 12 14:26:25 2006
@@ -121,7 +121,7 @@
 
 <body leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
 
-<!-- Master table -->
+<!-- Master vtiger_table -->
 <table border=0 cellspacing=0 cellpadding=0 width=100%>
 <tr>
 	<td align=center>
@@ -290,7 +290,7 @@
 </td>
 </tr>
 </table>
-<!-- Master table closes -->
+<!-- Master vtiger_table closes -->
 
 </body>
 

Modified: vtigercrm/trunk/install/5createTables.inc.php
==============================================================================
--- vtigercrm/trunk/install/5createTables.inc.php (original)
+++ vtigercrm/trunk/install/5createTables.inc.php Mon Jun 12 14:26:25 2006
@@ -90,10 +90,10 @@
         $user->save();
 
         // we need to change the admin user to a fixed id of 1.
-        //$query = "update users set id='1' where user_name='$user->user_name'";
+        //$query = "update vtiger_users set id='1' where user_name='$user->user_name'";
         //$result = $db->query($query, true, "Error updating admin user ID: ");
 
-        $log->info("Created ".$user->table_name." table. for user $user->id");
+        $log->info("Created ".$user->table_name." vtiger_table. for user $user->id");
 
 	/*
         if($create_default_user) {
@@ -115,16 +115,16 @@
         }
 	*/
 
-	// insert values into user2role table
-	$role_query = "select roleid from role where rolename='administrator'";
+	// insert values into vtiger_user2role vtiger_table
+	$role_query = "select roleid from vtiger_role where rolename='administrator'";
 	$db->database->SetFetchMode(ADODB_FETCH_ASSOC);
 	$role_result = $db->query($role_query);
 	$role_id = $db->query_result($role_result,0,"roleid");
 
-	$sql_stmt1 = "insert into user2role values(".$user->id.",'".$role_id."')";
+	$sql_stmt1 = "insert into vtiger_user2role values(".$user->id.",'".$role_id."')";
 	$db->query($sql_stmt1) or die($app_strings['ERR_CREATING_TABLE'].mysql_error());
 
-	//Creating the flat files
+	//Creating the flat vtiger_files
 	createUserPrivilegesfile($user->id);
         createUserSharingPrivilegesfile($user->id);
 
@@ -152,15 +152,15 @@
         $user->email = $std_email;
         $user->save();
 
-	$role_query = "select roleid from role where rolename='standard_user'";
+	$role_query = "select roleid from vtiger_role where rolename='standard_user'";
 	$db->database->SetFetchMode(ADODB_FETCH_ASSOC);
 	$role_result = $db->query($role_query);
 	$role_id = $db->query_result($role_result,0,"roleid");
 
-	$sql_stmt2 = "insert into user2role values(".$user->id.",'".$role_id."')";
+	$sql_stmt2 = "insert into vtiger_user2role values(".$user->id.",'".$role_id."')";
 	$db->query($sql_stmt2) or die($app_strings['ERR_CREATING_TABLE'].mysql_error());
 
-	//Creating the flat files
+	//Creating the flat vtiger_files
 	createUserPrivilegesfile($user->id);
         createUserSharingPrivilegesfile($user->id);
 
@@ -169,8 +169,8 @@
 //$startTime = microtime();
 $modules = array("DefaultDataPopulator");
 $focus=0;				
-// tables creation
-eecho("Creating Core tables: ");
+// vtiger_tables creation
+eecho("Creating Core vtiger_tables: ");
 $success = $db->createTables("schema/DatabaseSchema.xml");
 
 // TODO HTML
@@ -188,34 +188,34 @@
 }
 			
 
-// populate users table
+// populate vtiger_users vtiger_table
 //$uid = $db->getUniqueID("users");
-//$sql_stmt1 = "insert into users(id,user_name,user_password,last_name,email1,date_format) values(".$uid.",'standarduser','stX/AHHNK/Gkw','standarduser','standarduser at standard.user.com','yyyy-mm-dd')";
+//$sql_stmt1 = "insert into vtiger_users(id,user_name,user_password,last_name,email1,date_format) values(".$uid.",'standarduser','stX/AHHNK/Gkw','standarduser','standarduser at standard.user.com','yyyy-mm-dd')";
 //$db->query($sql_stmt1) or die($app_strings['ERR_CREATING_TABLE'].mysql_error());
 
 
-// create and populate combo tables
+// create and populate combo vtiger_tables
 require_once('include/PopulateComboValues.php');
 $combo = new PopulateComboValues();
 $combo->create_tables();
 
 create_default_users();
 
-// default report population
+// default vtiger_report population
 require_once('modules/Reports/PopulateReports.php');
 
-// default customview population
+// default vtiger_customview population
 require_once('modules/CustomView/PopulateCustomView.php');
 
-//Writing tab data in flat file
+//Writing vtiger_tab data in flat file
 create_tab_data_file();
 create_parenttab_data_file();
 
 // ensure required sequences are created (adodb creates them as needed, but if
 // creation occurs within a transaction we get problems
-$db->getUniqueID("crmentity");
-$db->getUniqueID("seactivityrel");
-$db->getUniqueID("freetags");
+$db->getUniqueID("vtiger_crmentity");
+$db->getUniqueID("vtiger_seactivityrel");
+$db->getUniqueID("vtiger_freetags");
 
 // populate the db with seed data
 if ($db_populate) {

Modified: vtigercrm/trunk/install/5createTables.php
==============================================================================
--- vtigercrm/trunk/install/5createTables.php (original)
+++ vtigercrm/trunk/install/5createTables.php Mon Jun 12 14:26:25 2006
@@ -193,7 +193,7 @@
 </td>
 </tr>
 </table>
-<!-- master table closes -->
+<!-- master vtiger_table closes -->
 
 
 </body></html>

Modified: vtigercrm/trunk/install/populateSeedData.php
==============================================================================
--- vtigercrm/trunk/install/populateSeedData.php (original)
+++ vtigercrm/trunk/install/populateSeedData.php Mon Jun 12 14:26:25 2006
@@ -145,7 +145,7 @@
 	
 	$account_name = $company_name_array[$i];
 
-	// Create new accounts.
+	// Create new vtiger_accounts.
 	$account = new Account();
 	$account->column_fields["accountname"] = $account_name;
 	$account->column_fields["phone"] = create_phone_number();
@@ -182,11 +182,11 @@
 	if ($i > 3)
 	{
 		$freetag = $adb->getUniqueId('freetags');
-		$query = "insert into freetags values ($freetag, '$cloudtag[1]', '$cloudtag[1]')";
+		$query = "insert into vtiger_freetags values ($freetag, '$cloudtag[1]', '$cloudtag[1]')";
 		$res = $adb->query($query);
 
 		$date = date('YmdHis'); 
-		$query_tag = "insert into freetagged_objects values ($freetag, 1,".$account->id.", $date, 'Accounts')";
+		$query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$account->id.", $date, 'Accounts')";
 		$result = $adb->query($query_tag);
 	}
 
@@ -227,7 +227,7 @@
 	
 	$opportunity_ids[] = $opp->id;
 
-//	$adb->println("PSD Potential [".$opp->id."] - account[".$account->id."]");
+//	$adb->println("PSD Potential [".$opp->id."] - vtiger_account[".$account->id."]");
 	
 }
 
@@ -285,11 +285,11 @@
 	if ($i > 8)
 	{
 		$freetag = $adb->getUniqueId('freetags');
-		$query = "insert into freetags values ($freetag, '$cloudtag[2]', '$cloudtag[2]')";
+		$query = "insert into vtiger_freetags values ($freetag, '$cloudtag[2]', '$cloudtag[2]')";
 		$res1 = $adb->query($query);
 
 		$date = date('YmdHis'); 
-		$query_tag = "insert into freetagged_objects values ($freetag, 1,".$contact->id.", $date, 'Contacts')";
+		$query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$contact->id.", $date, 'Contacts')";
 		$result1 = $adb->query($query_tag);
 	}
 	// This assumes that there will be one opportunity per company in the seed data.
@@ -297,10 +297,10 @@
 	//$query = "insert into opportunities_contacts set id='".create_guid()."', contact_id='$contact->id', contact_role='".$app_list_strings['opportunity_relationship_type_default_key']."', opportunity_id='".$opportunity_ids[$opportunity_key]."'";
 	//$db->query($query, true, "unable to create seed links between opportunities and contacts");
 
-	$query = "insert into contpotentialrel ( contactid, potentialid ) values (".$contact->id.",".$opportunity_ids[$opportunity_key].")";
+	$query = "insert into vtiger_contpotentialrel ( contactid, vtiger_potentialid ) values (".$contact->id.",".$opportunity_ids[$opportunity_key].")";
 	$db->query($query);
 
-//	$adb->println("PSD Contact [".$contact->id."] - account[".$account_ids[$account_key]."] - potential[".$opportunity_ids[$opportunity_key]."]");
+//	$adb->println("PSD Contact [".$contact->id."] - vtiger_account[".$account_ids[$account_key]."] - vtiger_potential[".$opportunity_ids[$opportunity_key]."]");
 
 	//Create new tasks
 	/*$task = new Task();
@@ -396,7 +396,7 @@
 
 }
 
-// Temp fix since user is not logged in while populating data updating creatorid in crmentity - GS
+// Temp fix since user is not logged in while populating data updating creatorid in vtiger_crmentity - GS
 
 
 //Populating Vendor Data
@@ -544,7 +544,7 @@
 http://support.microsoft.com/default.aspx?scid=kb%3BEN-US%3B263074
 
 If you want to continue working with vtiger Outlook Plug-in, select the Allow access for check box and select the time from drop-down box.",
-	" Since, vtigerCRM & all plugins are open source, it is not signed up with third party vendors and IE will ask to download even though the plugin are not signed.
+	" Since, vtigerCRM & all plugins are open source, it is not signed up with third party vtiger_vendors and IE will ask to download even though the plugin are not signed.
 
 This message if produced by Microsoft Windows XP. I English Windows XP with the SP2 and the last updates. I told IE to accept installation of the ActiveX, but after it, this message has appeared. Provably there is a place where to tall to WinXP to not validate if the code is signed... but I don\'t know where.
 
@@ -600,7 +600,7 @@
 	$quote_ids[] = $quote->id;
 
 	$product_key = array_rand($product_ids); 
-	$query = "insert into quotesproductrel ( quoteid, productid, quantity, listprice ) values (".$quote->id.",".$product_ids[$product_key].",10,2999.000 )";
+	$query = "insert into vtiger_quotesproductrel ( quoteid, productid, quantity, listprice ) values (".$quote->id.",".$product_ids[$product_key].",10,2999.000 )";
 	$db->query($query);
 }
 
@@ -633,7 +633,7 @@
 	$salesorder_ids[] = $so->id;
 	
 	$product_key = array_rand($product_ids);
-        $query = "insert into soproductrel ( salesorderid, productid, quantity, listprice ) values (".$so->id.",".$product_ids[$product_key].",12,499.000 )";
+        $query = "insert into vtiger_soproductrel ( vtiger_salesorderid, productid, quantity, listprice ) values (".$so->id.",".$product_ids[$product_key].",12,499.000 )";
         $db->query($query);
 
 }
@@ -668,7 +668,7 @@
 	$purchaseorder_ids[] = $po->id;
 
 	$product_key = array_rand($product_ids);
-        $query = "insert into poproductrel ( purchaseorderid, productid, quantity, listprice ) values (".$po->id.",".$product_ids[$product_key].",15,1299.000 )";
+        $query = "insert into vtiger_poproductrel ( vtiger_purchaseorderid, productid, quantity, listprice ) values (".$po->id.",".$product_ids[$product_key].",15,1299.000 )";
         $db->query($query);
 
 }
@@ -701,16 +701,16 @@
 	if ($i > 3)
 	{
 		$freetag = $adb->getUniqueId('freetags');
-		$query = "insert into freetags values ($freetag, '$cloudtag[0]', '$cloudtag[0]')";
+		$query = "insert into vtiger_freetags values ($freetag, '$cloudtag[0]', '$cloudtag[0]')";
 		$res_inv = $adb->query($query);
 
 		$date = date('YmdHis'); 
-		$query_tag = "insert into freetagged_objects values ($freetag, 1,".$invoice->id.", $date, 'Invoice')";
+		$query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$invoice->id.", $date, 'Invoice')";
 		$result_inv = $adb->query($query_tag);
 	}
 
 	$product_key = array_rand($product_ids);
-        $query = "insert into invoiceproductrel ( invoiceid, productid, quantity, listprice ) values (".$invoice->id.",".$product_ids[$product_key].",18,269.000 )";
+        $query = "insert into vtiger_invoiceproductrel ( vtiger_invoiceid, productid, quantity, listprice ) values (".$invoice->id.",".$product_ids[$product_key].",18,269.000 )";
         $db->query($query);
 	
 }
@@ -781,7 +781,7 @@
 	$notes_ids[] = $notes ->id;
 	
 	$product_key = array_rand($product_ids);
-        $query = "insert into senotesrel (crmid, notesid) values (".$product_ids[$product_key].", ".$notes->id.")";
+        $query = "insert into vtiger_senotesrel (crmid, vtiger_notesid) values (".$product_ids[$product_key].", ".$notes->id.")";
 	$db->query($query);
 		
 }
@@ -823,11 +823,11 @@
 	if ($i > 3)
 	{
 		$freetag = $adb->getUniqueId('freetags');
-		$query = "insert into freetags values ($freetag, '$cloudtag[3]', '$cloudtag[3]')";
+		$query = "insert into vtiger_freetags values ($freetag, '$cloudtag[3]', '$cloudtag[3]')";
 		$res_tkt = $adb->query($query);
 
 		$date = date('YmdHis'); 
-		$query_tag = "insert into freetagged_objects values ($freetag, 1,".$helpdesk->id.", $date, 'HelpDesk')";
+		$query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$helpdesk->id.", $date, 'HelpDesk')";
 		$result_tkt = $adb->query($query_tag);
 	}
 
@@ -915,7 +915,7 @@
 }
 
 
-$adb->query("update crmentity set smcreatorid=".$assigned_user_id);
+$adb->query("update vtiger_crmentity set smcreatorid=".$assigned_user_id);
 
 $expected_revenue = Array("250000","750000","500000");
 $budget_cost = Array("25000","50000","90000");

Modified: vtigercrm/trunk/modules/Accounts/Account.php
==============================================================================
--- vtigercrm/trunk/modules/Accounts/Account.php (original)
+++ vtigercrm/trunk/modules/Accounts/Account.php Mon Jun 12 14:26:25 2006
@@ -33,23 +33,23 @@
 require_once('modules/Emails/Email.php');
 require_once('include/utils/utils.php');
 
-// Account is used to store account information.
+// Account is used to store vtiger_account information.
 class Account extends CRMEntity {
 	var $log;
 	var $db;
 
 	var $table_name = "account";
-	var $tab_name = Array('crmentity','account','accountbillads','accountshipads','accountscf');
-	var $tab_name_index = Array('crmentity'=>'crmid','account'=>'accountid','accountbillads'=>'accountaddressid','accountshipads'=>'accountaddressid','accountscf'=>'accountid');
-
-	var $entity_table = "crmentity";
-
-	var $billadr_table = "accountbillads";
+	var $tab_name = Array('vtiger_crmentity','vtiger_account','vtiger_accountbillads','vtiger_accountshipads','vtiger_accountscf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_account'=>'accountid','vtiger_accountbillads'=>'accountaddressid','vtiger_accountshipads'=>'accountaddressid','vtiger_accountscf'=>'accountid');
+
+	var $entity_table = "vtiger_crmentity";
+
+	var $billadr_table = "vtiger_accountbillads";
 
 	var $object_name = "Accounts";
 	// Mike Crowe Mod --------------------------------------------------------added for general search
-	var $base_table_name = "account";
-	var $cf_table_name = "accountscf";
+	var $base_table_name = "vtiger_account";
+	var $cf_table_name = "vtiger_accountscf";
 
 	var $new_schema = true;
 
@@ -60,13 +60,13 @@
 	var $sortby_fields = Array('accountname','city','website','phone','smownerid');		
 
 
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
-			'Account Name'=>Array('account'=>'accountname'),
-			'City'=>Array('accountbillads'=>'city'), 
-			'Website'=>Array('account'=>'website'),
-			'Phone'=>Array('account'=> 'phone'),
-			'Assigned To'=>Array('crmentity'=>'smownerid')
+			'Account Name'=>Array('vtiger_account'=>'accountname'),
+			'City'=>Array('vtiger_accountbillads'=>'city'), 
+			'Website'=>Array('vtiger_account'=>'website'),
+			'Phone'=>Array('vtiger_account'=> 'phone'),
+			'Assigned To'=>Array('vtiger_crmentity'=>'smownerid')
 			);
 
 	var $list_fields_name = Array(
@@ -79,8 +79,8 @@
 	var $list_link_field= 'accountname';
 
 	var $search_fields = Array(
-			'Account Name'=>Array('account'=>'accountname'),
-			'City'=>Array('accountbillads'=>'city'), 
+			'Account Name'=>Array('vtiger_account'=>'accountname'),
+			'City'=>Array('vtiger_accountbillads'=>'city'), 
 			);
 
 	var $search_fields_name = Array(
@@ -88,7 +88,7 @@
 			'City'=>'bill_city',
 			);
 
-	// This is the list of fields that are required.
+	// This is the list of vtiger_fields that are required.
 	var $required_fields =  array("accountname"=>1);
 
 	//Added these variables which are used as default order by and sortorder in ListView
@@ -149,21 +149,21 @@
 		$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
 
 		//SQL
-		$query = "SELECT contactdetails.*,
-				crmentity.crmid,
-                        	crmentity.smownerid,
-				users.user_name
-			FROM contactdetails
-			INNER JOIN crmentity
-				ON crmentity.crmid = contactdetails.contactid
-			LEFT JOIN contactgrouprelation
-				ON contactdetails.contactid = contactgrouprelation.contactid
-			LEFT JOIN groups
-				ON groups.groupname = contactgrouprelation.groupname
-			LEFT JOIN users
-				ON crmentity.smownerid = users.id
-			WHERE crmentity.deleted = 0
-			AND contactdetails.accountid = ".$id;
+		$query = "SELECT vtiger_contactdetails.*,
+			vtiger_crmentity.crmid,
+                        vtiger_crmentity.smownerid,
+			vtiger_users.user_name
+			FROM vtiger_contactdetails
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
+			LEFT JOIN vtiger_contactgrouprelation
+				ON vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_contactdetails.accountid = ".$id;
 		$log->debug("Exiting get_contacts method ...");
 		return GetRelatedList('Accounts','Contacts',$focus,$query,$button,$returnset);
 	}
@@ -188,23 +188,23 @@
 		}
 		$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT potential.potentialid, potential.accountid,
-				potential.potentialname, potential.sales_stage,
-				potential.potentialtype, potential.amount,
-				potential.closingdate, potential.potentialtype,
-				users.user_name,
-				crmentity.crmid, crmentity.smownerid
-			FROM potential
-			INNER JOIN crmentity
-				ON crmentity.crmid = potential.potentialid
-			LEFT JOIN users
-				ON crmentity.smownerid = users.id
-			LEFT JOIN potentialgrouprelation
-				ON potential.potentialid = potentialgrouprelation.potentialid
-			LEFT JOIN groups
-				ON groups.groupname = potentialgrouprelation.groupname
-			WHERE crmentity.deleted = 0
-			AND potential.accountid = ".$id;
+		$query = "SELECT vtiger_potential.potentialid, vtiger_potential.accountid,
+			vtiger_potential.potentialname, vtiger_potential.sales_stage,
+			vtiger_potential.potentialtype, vtiger_potential.amount,
+			vtiger_potential.closingdate, vtiger_potential.potentialtype,
+			vtiger_users.user_name,
+			vtiger_crmentity.crmid, vtiger_crmentity.smownerid
+			FROM vtiger_potential
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_potential.potentialid
+			LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id
+			LEFT JOIN vtiger_potentialgrouprelation
+				ON vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_potential.accountid = ".$id;
 		$log->debug("Exiting get_opportunities method ...");
 
 		return GetRelatedList('Accounts','Potentials',$focus,$query,$button,$returnset);
@@ -231,42 +231,42 @@
 		}
 		$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT activity.*,
-				seactivityrel.*,
-				contactdetails.contactid, contactdetails.lastname,
-				contactdetails.firstname,
-				crmentity.crmid, crmentity.smownerid,
-				crmentity.modifiedtime,
-				users.user_name,
-				recurringevents.recurringtype
-			FROM activity
-			INNER JOIN seactivityrel
-				ON seactivityrel.activityid = activity.activityid
-			INNER JOIN crmentity
-				ON crmentity.crmid = activity.activityid
-			LEFT JOIN cntactivityrel
-				ON cntactivityrel.activityid = activity.activityid
-			LEFT JOIN contactdetails
-				ON contactdetails.contactid = cntactivityrel.contactid
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			LEFT OUTER JOIN recurringevents
-				ON recurringevents.activityid = activity.activityid
-			LEFT JOIN activitygrouprelation
-				ON activitygrouprelation.activityid = crmentity.crmid
-			LEFT JOIN groups
-				ON groups.groupname = activitygrouprelation.groupname
-			WHERE seactivityrel.crmid = ".$id."
+		$query = "SELECT vtiger_activity.*,
+			vtiger_seactivityrel.*,
+			vtiger_contactdetails.contactid, vtiger_contactdetails.lastname,
+			vtiger_contactdetails.firstname,
+			vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
+			vtiger_crmentity.modifiedtime,
+			vtiger_users.user_name,
+			vtiger_recurringevents.recurringtype
+			FROM vtiger_activity
+			INNER JOIN vtiger_seactivityrel
+				ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_activity.activityid
+			LEFT JOIN vtiger_cntactivityrel
+				ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT OUTER JOIN vtiger_recurringevents
+				ON vtiger_recurringevents.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_activitygrouprelation
+				ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
+			WHERE vtiger_seactivityrel.crmid = ".$id."
 			AND (activitytype='Task'
-				OR activitytype='Call'
-				OR activitytype='Meeting')
-			AND crmentity.deleted = 0
-			AND ((activity.status IS NOT NULL
-					AND activity.status != 'Completed')
-				AND (activity.status IS NOT NULL
-					AND activity.status != 'Deferred')
-				OR (activity.eventstatus !=''
-					AND  activity.eventstatus != 'Held'))";
+				OR vtiger_activitytype='Call'
+				OR vtiger_activitytype='Meeting')
+			AND vtiger_crmentity.deleted = 0
+			AND ((vtiger_activity.status IS NOT NULL
+					AND vtiger_activity.status != 'Completed')
+				AND (vtiger_activity.status IS NOT NULL
+					AND vtiger_activity.status != 'Deferred')
+				OR (vtiger_activity.eventstatus !=''
+					AND  vtiger_activity.eventstatus != 'Held'))";
 		$log->debug("Exiting get_activities method ...");
 		return GetRelatedList('Accounts','Activities',$focus,$query,$button,$returnset);
 
@@ -276,37 +276,37 @@
 	{
 		global $log;
                 $log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT activity.activityid, activity.subject,
-				activity.status, activity.eventstatus,
-				activity.activitytype,
-				contactdetails.contactid, contactdetails.firstname,
-				contactdetails.lastname,
-				crmentity.modifiedtime, crmentity.createdtime,
-				crmentity.description,
-				users.user_name
-			FROM activity
-			INNER JOIN seactivityrel
-				ON seactivityrel.activityid = activity.activityid
-			INNER JOIN crmentity
-				ON crmentity.crmid = activity.activityid
-			LEFT JOIN cntactivityrel
-				ON cntactivityrel.activityid = activity.activityid 
-			LEFT JOIN contactdetails
-				ON contactdetails.contactid = cntactivityrel.contactid
-			LEFT JOIN activitygrouprelation
-				ON activitygrouprelation.activityid = activity.activityid
-			LEFT JOIN groups
-				ON groups.groupname = activitygrouprelation.groupname
-			INNER JOIN users
-				ON crmentity.smcreatorid = users.id
-			WHERE (activity.activitytype = 'Meeting'
-				OR activity.activitytype = 'Call'
-				OR activity.activitytype = 'Task')
-			AND (activity.status = 'Completed'
-				OR activity.status = 'Deferred'
-				OR (activity.eventstatus = 'Held'
-					AND activity.eventstatus != ''))
-			AND seactivityrel.crmid = ".$id;
+		$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject,
+			vtiger_activity.status, vtiger_activity.eventstatus,
+			vtiger_activity.activitytype,
+			vtiger_contactdetails.contactid, vtiger_contactdetails.firstname,
+			vtiger_contactdetails.lastname,
+			vtiger_crmentity.modifiedtime, vtiger_crmentity.createdtime,
+			vtiger_crmentity.description,
+			vtiger_users.user_name
+			FROM vtiger_activity
+			INNER JOIN vtiger_seactivityrel
+				ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_activity.activityid
+			LEFT JOIN vtiger_cntactivityrel
+				ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid 
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
+			LEFT JOIN vtiger_activitygrouprelation
+				ON vtiger_activitygrouprelation.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
+			INNER JOIN vtiger_users
+				ON vtiger_crmentity.smcreatorid = vtiger_users.id
+			WHERE (vtiger_activity.activitytype = 'Meeting'
+				OR vtiger_activity.activitytype = 'Call'
+				OR vtiger_activity.activitytype = 'Task')
+			AND (vtiger_activity.status = 'Completed'
+				OR vtiger_activity.status = 'Deferred'
+				OR (vtiger_activity.eventstatus = 'Held'
+					AND vtiger_activity.eventstatus != ''))
+			AND vtiger_seactivityrel.crmid = ".$id;
 		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
 		$log->debug("Exiting get_history method ...");
 		return getHistory('Accounts',$query,$id);
@@ -317,49 +317,49 @@
 		 global $log;
                  $log->debug("Entering get_attachments(".$id.") method ...");
 		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crm2.createdtime, notes.notecontent description, users.user_name
-		// Inserted inner join users on crm2.smcreatorid= users.id
-		$query = "SELECT notes.title, notes.notecontent AS description,
-				notes.filename, notes.notesid AS crmid,
+		// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		$query = "SELECT vtiger_notes.title, vtiger_notes.notecontent AS description,
+			vtiger_notes.filename, vtiger_notes.notesid AS crmid,
 				'Notes      ' AS ActivityType,
-				attachments.type AS FileType,
+			vtiger_attachments.type AS FileType,
 				crm2.modifiedtime AS lastmodified, crm2.createdtime,
-				seattachmentsrel.attachmentsid,
-				users.user_name
-			FROM notes
-			INNER JOIN senotesrel
-				ON senotesrel.notesid = notes.notesid
-			INNER JOIN crmentity
-				ON crmentity.crmid = senotesrel.crmid
-			INNER JOIN crmentity crm2
-				ON crm2.crmid = notes.notesid
+			vtiger_seattachmentsrel.attachmentsid,
+			vtiger_users.user_name
+			FROM vtiger_notes
+			INNER JOIN vtiger_senotesrel
+				ON vtiger_senotesrel.notesid = vtiger_notes.notesid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_senotesrel.crmid
+			INNER JOIN vtiger_crmentity crm2
+				ON crm2.crmid = vtiger_notes.notesid
 				AND crm2.deleted = 0
-			LEFT JOIN seattachmentsrel
-				ON seattachmentsrel.crmid = notes.notesid
-			LEFT JOIN attachments
-				ON seattachmentsrel.attachmentsid = attachments.attachmentsid
-			INNER JOIN users
-				ON crm2.smcreatorid = users.id
-			WHERE crmentity.crmid = ".$id."
+			LEFT JOIN vtiger_seattachmentsrel
+				ON vtiger_seattachmentsrel.crmid = vtiger_notes.notesid
+			LEFT JOIN vtiger_attachments
+				ON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			INNER JOIN vtiger_users
+				ON crm2.smcreatorid = vtiger_users.id
+			WHERE vtiger_crmentity.crmid = ".$id."
 		 UNION ALL
-			SELECT attachments.description AS title, attachments.description,
-				attachments.name AS filename,
-				seattachmentsrel.attachmentsid AS crmid,
+			SELECT vtiger_attachments.description AS title, vtiger_attachments.description,
+			vtiger_attachments.name AS filename,
+			vtiger_seattachmentsrel.attachmentsid AS crmid,
 				'Attachments' AS ActivityType,
-				attachments.type AS FileType,
+			vtiger_attachments.type AS FileType,
 				crm2.modifiedtime AS lastmodified, crm2.createdtime,
-				attachments.attachmentsid,
-				users.user_name
-			FROM attachments
-			INNER JOIN seattachmentsrel
-				ON seattachmentsrel.attachmentsid = attachments.attachmentsid
-			INNER JOIN crmentity
-				ON crmentity.crmid = seattachmentsrel.crmid
-			INNER JOIN crmentity crm2
-				ON crm2.crmid = attachments.attachmentsid
-			INNER JOIN users
-				ON crm2.smcreatorid = users.id
-			WHERE crmentity.crmid = ".$id."
+			vtiger_attachments.attachmentsid,
+			vtiger_users.user_name
+			FROM vtiger_attachments
+			INNER JOIN vtiger_seattachmentsrel
+				ON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_seattachmentsrel.crmid
+			INNER JOIN vtiger_crmentity crm2
+				ON crm2.crmid = vtiger_attachments.attachmentsid
+			INNER JOIN vtiger_users
+				ON crm2.smcreatorid = vtiger_users.id
+			WHERE vtiger_crmentity.crmid = ".$id."
 			ORDER BY createdtime DESC";
 		$log->debug("Exiting get_attachments method ...");
 		return getAttachmentsAndNotes('Accounts',$query,$id);
@@ -381,27 +381,27 @@
 		$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
 
 
-		$query = "SELECT users.user_name,
-				groups.groupname,
-				crmentity.*,
-				quotes.*,
-				potential.potentialname,
-				account.accountname
-			FROM quotes
-			INNER JOIN crmentity
-				ON crmentity.crmid = quotes.quoteid
-			LEFT OUTER JOIN account
-				ON account.accountid = quotes.accountid
-			LEFT OUTER JOIN potential
-				ON potential.potentialid = quotes.potentialid
-			LEFT JOIN quotegrouprelation
-				ON quotes.quoteid = quotegrouprelation.quoteid
-			LEFT JOIN groups
-				ON groups.groupname = quotegrouprelation.groupname
-			LEFT JOIN users
-				ON crmentity.smownerid = users.id
-			WHERE crmentity.deleted = 0
-			AND account.accountid = ".$id;
+		$query = "SELECT vtiger_users.user_name,
+			vtiger_groups.groupname,
+			vtiger_crmentity.*,
+			vtiger_quotes.*,
+			vtiger_potential.potentialname,
+			vtiger_account.accountname
+			FROM vtiger_quotes
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_quotes.quoteid
+			LEFT OUTER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_quotes.accountid
+			LEFT OUTER JOIN vtiger_potential
+				ON vtiger_potential.potentialid = vtiger_quotes.potentialid
+			LEFT JOIN vtiger_quotegrouprelation
+				ON vtiger_quotes.quoteid = vtiger_quotegrouprelation.quoteid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_quotegrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_account.accountid = ".$id;
 		$log->debug("Exiting get_quotes method ...");
 		return GetRelatedList('Accounts','Quotes',$focus,$query,$button,$returnset);
 	}
@@ -421,27 +421,27 @@
 		}
 		$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT users.user_name,
-				groups.groupname,
-				crmentity.*,
-				invoice.*,
-				account.accountname,
-				salesorder.subject AS salessubject
-			FROM invoice
-			INNER JOIN crmentity
-				ON crmentity.crmid = invoice.invoiceid
-			LEFT OUTER JOIN account
-				ON account.accountid = invoice.accountid
-			LEFT OUTER JOIN salesorder
-				ON salesorder.salesorderid = invoice.salesorderid
-			LEFT JOIN invoicegrouprelation
-				ON invoice.invoiceid = invoicegrouprelation.invoiceid
-			LEFT JOIN groups
-				ON groups.groupname = invoicegrouprelation.groupname
-			LEFT JOIN users
-				ON crmentity.smownerid = users.id
-			WHERE crmentity.deleted = 0
-			AND account.accountid = ".$id;
+		$query = "SELECT vtiger_users.user_name,
+			vtiger_groups.groupname,
+			vtiger_crmentity.*,
+			vtiger_invoice.*,
+			vtiger_account.accountname,
+			vtiger_salesorder.subject AS salessubject
+			FROM vtiger_invoice
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_invoice.invoiceid
+			LEFT OUTER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_invoice.accountid
+			LEFT OUTER JOIN vtiger_salesorder
+				ON vtiger_salesorder.salesorderid = vtiger_invoice.salesorderid
+			LEFT JOIN vtiger_invoicegrouprelation
+				ON vtiger_invoice.invoiceid = vtiger_invoicegrouprelation.invoiceid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_invoicegrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_account.accountid = ".$id;
 		$log->debug("Exiting get_invoices method ...");
 		return GetRelatedList('Accounts','Invoice',$focus,$query,$button,$returnset);
 	}
@@ -462,27 +462,27 @@
 
 		$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT crmentity.*,
-				salesorder.*,
-				quotes.subject AS quotename,
-				account.accountname,
-				users.user_name,
-				groups.groupname
-			FROM salesorder
-			INNER JOIN crmentity
-				ON crmentity.crmid = salesorder.salesorderid
-			LEFT OUTER JOIN quotes
-				ON quotes.quoteid = salesorder.quoteid
-			LEFT OUTER JOIN account
-				ON account.accountid = salesorder.accountid
-			LEFT JOIN sogrouprelation
-				ON salesorder.salesorderid = sogrouprelation.salesorderid
-			LEFT JOIN groups
-				ON groups.groupname = sogrouprelation.groupname
-			LEFT JOIN users
-				ON crmentity.smownerid = users.id
-			WHERE crmentity.deleted = 0
-			AND salesorder.accountid = ".$id;
+		$query = "SELECT vtiger_crmentity.*,
+			vtiger_salesorder.*,
+			vtiger_quotes.subject AS quotename,
+			vtiger_account.accountname,
+			vtiger_users.user_name,
+			vtiger_groups.groupname
+			FROM vtiger_salesorder
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_salesorder.salesorderid
+			LEFT OUTER JOIN vtiger_quotes
+				ON vtiger_quotes.quoteid = vtiger_salesorder.quoteid
+			LEFT OUTER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_salesorder.accountid
+			LEFT JOIN vtiger_sogrouprelation
+				ON vtiger_salesorder.salesorderid = vtiger_sogrouprelation.salesorderid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_sogrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_salesorder.accountid = ".$id;
 		$log->debug("Exiting get_salesorder method ...");		
 		return GetRelatedList('Accounts','SalesOrder',$focus,$query,$button,$returnset);
 	}
@@ -498,23 +498,23 @@
 		$button .= '<td valign="bottom" align="right"><input title="New TICKET" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'HelpDesk\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_TICKET'].'">&nbsp;</td>';
 		$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT users.user_name, users.id,
-				troubletickets.title, troubletickets.ticketid AS crmid,
-				troubletickets.status, troubletickets.priority,
-				troubletickets.parent_id,
-				crmentity.smownerid, crmentity.modifiedtime
-			FROM troubletickets
-			INNER JOIN crmentity
-				ON crmentity.crmid = troubletickets.ticketid
-			LEFT JOIN account
-				ON account.accountid = troubletickets.parent_id
-			LEFT JOIN users
-				ON users.id=crmentity.smownerid
-			LEFT JOIN ticketgrouprelation
-				ON troubletickets.ticketid = ticketgrouprelation.ticketid
-			LEFT JOIN groups
-				ON groups.groupname = ticketgrouprelation.groupname
-			WHERE account.accountid = ".$id ;
+		$query = "SELECT vtiger_users.user_name, vtiger_users.id,
+			vtiger_troubletickets.title, vtiger_troubletickets.ticketid AS crmid,
+			vtiger_troubletickets.status, vtiger_troubletickets.priority,
+			vtiger_troubletickets.parent_id,
+			vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime
+			FROM vtiger_troubletickets
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid
+			LEFT JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_troubletickets.parent_id
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id=vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_ticketgrouprelation
+				ON vtiger_troubletickets.ticketid = vtiger_ticketgrouprelation.ticketid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname
+			WHERE vtiger_account.accountid = ".$id ;
 		//Appending the security parameter
 		global $current_user;
 		require('user_privileges/user_privileges_'.$current_user->id.'.php');
@@ -527,25 +527,25 @@
 
 		}
 		$query .= " UNION ALL
-			SELECT users.user_name, users.id,
-				troubletickets.title, troubletickets.ticketid AS crmid,
-				troubletickets.status, troubletickets.priority,
-				troubletickets.parent_id,
-				crmentity.smownerid, crmentity.modifiedtime
-			FROM troubletickets
-			INNER JOIN crmentity
-				ON crmentity.crmid = troubletickets.ticketid
-			LEFT JOIN contactdetails
-				ON contactdetails.contactid = troubletickets.parent_id
-			LEFT JOIN account
-				ON account.accountid = contactdetails.accountid
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			LEFT JOIN ticketgrouprelation
-				ON troubletickets.ticketid = ticketgrouprelation.ticketid
-			LEFT JOIN groups
-				ON groups.groupname = ticketgrouprelation.groupname
-			WHERE account.accountid = ".$id;
+			SELECT vtiger_users.user_name, vtiger_users.id,
+			vtiger_troubletickets.title, vtiger_troubletickets.ticketid AS crmid,
+			vtiger_troubletickets.status, vtiger_troubletickets.priority,
+			vtiger_troubletickets.parent_id,
+			vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime
+			FROM vtiger_troubletickets
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_contactdetails.contactid = vtiger_troubletickets.parent_id
+			LEFT JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_contactdetails.accountid
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_ticketgrouprelation
+				ON vtiger_troubletickets.ticketid = vtiger_ticketgrouprelation.ticketid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname
+			WHERE vtiger_account.accountid = ".$id;
 		$log->debug("Exiting get_tickets method ...");
 		return GetRelatedList('Accounts','HelpDesk',$focus,$query,$button,$returnset);
 	}
@@ -569,19 +569,19 @@
 		}
 		$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT products.productid, products.productname,
-				products.productcode, products.commissionrate,
-				products.qty_per_unit, products.unit_price,
-				crmentity.crmid, crmentity.smownerid
-			FROM products
-			INNER JOIN seproductsrel
-				ON products.productid = seproductsrel.productid
-			INNER JOIN crmentity
-				ON crmentity.crmid = products.productid
-			INNER JOIN account
-				ON account.accountid = seproductsrel.crmid
-			WHERE account.accountid = ".$id."
-			AND crmentity.deleted = 0";
+		$query = "SELECT vtiger_products.productid, vtiger_products.productname,
+			vtiger_products.productcode, vtiger_products.commissionrate,
+			vtiger_products.qty_per_unit, vtiger_products.unit_price,
+			vtiger_crmentity.crmid, vtiger_crmentity.smownerid
+			FROM vtiger_products
+			INNER JOIN vtiger_seproductsrel
+				ON vtiger_products.productid = vtiger_seproductsrel.productid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_products.productid
+			INNER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_seproductsrel.crmid
+			WHERE vtiger_account.accountid = ".$id."
+			AND vtiger_crmentity.deleted = 0";
 		$log->debug("Exiting get_products method ...");
 		return GetRelatedList('Accounts','Products',$focus,$query,$button,$returnset);
 	}
@@ -595,62 +595,62 @@
 		{
 
 			$query = $this->constructCustomQueryAddendum('accountscf','Accounts') . "
-					account.*,
+				vtiger_account.*,
 					".$this->entity_table.".*,
-					accountbillads.city AS billing_city,
-					accountbillads.country AS billing_country,
-					accountbillads.code AS billing_code,
-					accountbillads.state AS billing_state,
-					accountbillads.street AS billing_street,
-					accountshipads.city AS shipping_city,
-					accountshipads.country AS shipping_country,
-					accountshipads.code AS shipping_code,
-					accountshipads.state AS shipping_state,
-					accountshipads.street AS shipping_street,
-					users.user_name,
-					users.status AS user_status
+				vtiger_accountbillads.city AS billing_city,
+				vtiger_accountbillads.country AS billing_country,
+				vtiger_accountbillads.code AS billing_code,
+				vtiger_accountbillads.state AS billing_state,
+				vtiger_accountbillads.street AS billing_street,
+				vtiger_accountshipads.city AS shipping_city,
+				vtiger_accountshipads.country AS shipping_country,
+				vtiger_accountshipads.code AS shipping_code,
+				vtiger_accountshipads.state AS shipping_state,
+				vtiger_accountshipads.street AS shipping_street,
+				vtiger_users.user_name,
+				vtiger_users.status AS user_status
 				FROM ".$this->entity_table."
-				INNER JOIN account
-					ON crmentity.crmid = account.accountid
-				LEFT JOIN accountbillads
-					ON account.accountid = accountbillads.accountaddressid
-				LEFT JOIN accountshipads
-					ON account.accountid = accountshipads.accountaddressid
-				LEFT JOIN accountscf 
-					ON accountscf.accountid = account.accountid
-				LEFT JOIN users
-					ON crmentity.smownerid = users.id ";
+				INNER JOIN vtiger_account
+					ON vtiger_crmentity.crmid = vtiger_account.accountid
+				LEFT JOIN vtiger_accountbillads
+					ON vtiger_account.accountid = vtiger_accountbillads.accountaddressid
+				LEFT JOIN vtiger_accountshipads
+					ON vtiger_account.accountid = vtiger_accountshipads.accountaddressid
+				LEFT JOIN vtiger_accountscf 
+					ON vtiger_accountscf.accountid = vtiger_account.accountid
+				LEFT JOIN vtiger_users
+					ON vtiger_crmentity.smownerid = vtiger_users.id ";
 
 		}
 		else
 		{
-			$query = "SELECT account.*,
+			$query = "SELECT vtiger_account.*,
 					".$this->entity_table.".*,
-					accountbillads.city AS billing_city,
-					accountbillads.country AS billing_country,
-					accountbillads.code AS billing_code,
-					accountbillads.state AS billing_state,
-					accountbillads.street AS billing_street,
-					accountshipads.city AS shipping_city,
-					accountshipads.country AS shipping_country,
-					accountshipads.code AS shipping_code,
-					accountshipads.state AS shipping_state,
-					accountshipads.street AS shipping_street,
-					users.user_name,
-					users.status AS user_status
+				vtiger_accountbillads.city AS billing_city,
+				vtiger_accountbillads.country AS billing_country,
+				vtiger_accountbillads.code AS billing_code,
+				vtiger_accountbillads.state AS billing_state,
+				vtiger_accountbillads.street AS billing_street,
+				vtiger_accountshipads.city AS shipping_city,
+				vtiger_accountshipads.country AS shipping_country,
+				vtiger_accountshipads.code AS shipping_code,
+				vtiger_accountshipads.state AS shipping_state,
+				vtiger_accountshipads.street AS shipping_street,
+				vtiger_users.user_name,
+				vtiger_users.status AS user_status
 				FROM ".$this->entity_table."
-				INNER JOIN account
-					ON crmentity.crmid = account.accountid
-				LEFT JOIN accountbillads
-					ON account.accountid = accountbillads.accountaddressid
-				LEFT JOIN accountshipads
-					ON account.accountid = accountshipads.accountaddressid
-				LEFT JOIN users
-					ON crmentity.smownerid = users.id ";
-		}
-
-		$where_auto = " users.status = 'Active'
-			AND crmentity.deleted = 0 ";
+				INNER JOIN vtiger_account
+					ON vtiger_crmentity.crmid = vtiger_account.accountid
+				LEFT JOIN vtiger_accountbillads
+					ON vtiger_account.accountid = vtiger_accountbillads.accountaddressid
+				LEFT JOIN vtiger_accountshipads
+					ON vtiger_account.accountid = vtiger_accountshipads.accountaddressid
+				LEFT JOIN vtiger_users
+					ON vtiger_crmentity.smownerid = vtiger_users.id ";
+		}
+
+		$where_auto = " vtiger_users.status = 'Active'
+			AND vtiger_crmentity.deleted = 0 ";
 
 		if($where != "")
 			$query .= "WHERE ($where) AND ".$where_auto;
@@ -669,7 +669,7 @@
 	{
 		global $log;
                 $log->debug("Entering getColumnNames_Acnt() method ...");
-		$sql1 = "SELECT fieldlabel FROM field WHERE tabid = 6";
+		$sql1 = "SELECT vtiger_fieldlabel FROM vtiger_field WHERE vtiger_tabid = 6";
 		$result = $this->db->query($sql1);
 		$numRows = $this->db->num_rows($result);
 		for($i=0; $i < $numRows;$i++)

Modified: vtigercrm/trunk/modules/Accounts/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Accounts/Forms.php (original)
+++ vtigercrm/trunk/modules/Accounts/Forms.php Mon Jun 12 14:26:25 2006
@@ -27,7 +27,7 @@
 require_once('include/utils/utils.php'); //new
 
 /**
- * Create HTML form to enter a new record with the minimum necessary fields.
+ * Create HTML form to enter a new record with the minimum necessary vtiger_fields.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
@@ -52,7 +52,7 @@
 $qcreate_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
 
 
-$qcreate_get_field="select * from field where tabid=6 and quickcreate=0 order by quickcreatesequence";
+$qcreate_get_field="select * from vtiger_field where vtiger_tabid=6 and quickcreate=0 order by quickcreatesequence";
 $qcreate_get_result=$adb->query($qcreate_get_field);
 $qcreate_get_noofrows=$adb->num_rows($qcreate_get_result);
 
@@ -138,9 +138,9 @@
 $qcreate_form.='</form>';
 $qcreate_form.='<script type="text/javascript">
 		
-	var fieldname = new Array('.$fieldName.')
-	var fieldlabel = new Array('.$fieldLabel.')
-	var fielddatatype = new Array('.$fldDataType.')
+	var vtiger_fieldname = new Array('.$fieldName.')
+	var vtiger_fieldlabel = new Array('.$fieldLabel.')
+	var vtiger_fielddatatype = new Array('.$fldDataType.')
 
 		</script>';
 

Modified: vtigercrm/trunk/modules/Accounts/ListViewTop.php
==============================================================================
--- vtigercrm/trunk/modules/Accounts/ListViewTop.php (original)
+++ vtigercrm/trunk/modules/Accounts/ListViewTop.php Mon Jun 12 14:26:25 2006
@@ -21,7 +21,7 @@
  ********************************************************************************/
 function getTopAccounts()
 {
-	$log = LoggerManager::getLogger('top accounts_list');
+	$log = LoggerManager::getLogger('top vtiger_accounts_list');
 	$log->debug("Entering getTopAccounts() method ...");
 	require_once("data/Tracker.php");
 	require_once('modules/Potentials/Opportunity.php');
@@ -33,7 +33,7 @@
 	global $current_user;
 	$current_module_strings = return_module_language($current_language, "Accounts");
 
-	$list_query = "select account.accountid, account.accountname, account.tickersymbol, sum(potential.amount) as amount from potential inner join crmentity on (potential.potentialid=crmentity.crmid) inner join account on (potential.accountid=account.accountid) where crmentity.deleted=0 AND crmentity.smownerid='".$current_user->id."' and potential.sales_stage <> '".$app_strings['LBL_CLOSE_WON']."' and potential.sales_stage <> '".$app_strings['LBL_CLOSE_LOST']."' group by account.accountid, account.accountname, account.tickersymbol order by amount desc;";
+	$list_query = "select vtiger_account.accountid, vtiger_account.accountname, vtiger_account.tickersymbol, sum(vtiger_potential.amount) as amount from vtiger_potential inner join vtiger_crmentity on (vtiger_potential.potentialid=vtiger_crmentity.crmid) inner join vtiger_account on (vtiger_potential.accountid=vtiger_account.accountid) where vtiger_crmentity.deleted=0 AND vtiger_crmentity.smownerid='".$current_user->id."' and vtiger_potential.sales_stage <> '".$app_strings['LBL_CLOSE_WON']."' and vtiger_potential.sales_stage <> '".$app_strings['LBL_CLOSE_LOST']."' group by vtiger_account.accountid, vtiger_account.accountname, vtiger_account.tickersymbol order by amount desc;";
 	$list_result=$adb->query($list_query);
 	$open_accounts_list = array();
 	$noofrows = min($adb->num_rows($list_result),7);

Modified: vtigercrm/trunk/modules/Accounts/Merge.php
==============================================================================
--- vtigercrm/trunk/modules/Accounts/Merge.php (original)
+++ vtigercrm/trunk/modules/Accounts/Merge.php Mon Jun 12 14:26:25 2006
@@ -39,7 +39,7 @@
 }
 //get the particular file from db and store it in the local hard disk.
 //store the path to the location where the file is stored and pass it  as parameter to the method 
-$sql = "select filename,data,filesize from wordtemplates where templateid=".$templateid;
+$sql = "select filename,data,filesize from vtiger_wordtemplates where templateid=".$templateid;
 
 $result = $adb->query($sql);
 $temparray = $adb->fetch_array($result);
@@ -75,8 +75,8 @@
 
 //echo $mass_merge;
 //die;
-//for setting accountid=0 for the contacts which are deleted
-$ct_query = "select crmid from crmentity where setype='Contacts' and deleted=1";
+//for setting vtiger_accountid=0 for the contacts which are deleted
+$ct_query = "select crmid from vtiger_crmentity where setype='Contacts' and deleted=1";
 $result = $adb->query($ct_query);
 
 while($row = $adb->fetch_array($result))
@@ -87,13 +87,13 @@
 if(count($deleted_id) > 0)
 {
 	$deleted_id = implode(",",$deleted_id);
-	$update_query = "update contactdetails set accountid = 0 where contactid in (".$deleted_id.")";
+	$update_query = "update vtiger_contactdetails set vtiger_accountid = 0 where contactid in (".$deleted_id.")";
 	$result = $adb->query($update_query);
 }
-//End setting accountid=0 for the contacts which are deleted
+//End setting vtiger_accountid=0 for the contacts which are deleted
 
 //<<<<<<<<<<<<<<<<header for csv and select columns for query>>>>>>>>>>>>>>>>>>>>>>>>
-$query1="select tab.name,field.tablename,field.columnname,field.fieldlabel from field inner join tab on tab.tabid = field.tabid where field.tabid in (4,6) and field.block <> 6 and field.block <> 75 order by field.tablename";
+$query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (4,6) and vtiger_field.block <> 6 and vtiger_field.block <> 75 order by vtiger_field.tablename";
 
 $result = $adb->query($query1);
 $y=$adb->num_rows($result);
@@ -116,7 +116,7 @@
   {
       if($modulename == "Accounts")
       {
-  			$querycolumns[$x] = "concat(users.last_name,' ',users.first_name) as userjoinname,users.first_name,users.last_name,users.user_name,users.yahoo_id,users.title,users.phone_work,users.department,users.phone_mobile,users.phone_other,users.phone_fax,users.email1,users.phone_home,users.email2,users.address_street,users.address_city,users.address_state,users.address_postalcode,users.address_country";
+  			$querycolumns[$x] = "concat(vtiger_users.last_name,' ',vtiger_users.first_name) as userjoinname,vtiger_users.first_name,vtiger_users.last_name,vtiger_users.user_name,vtiger_users.yahoo_id,vtiger_users.title,vtiger_users.phone_work,vtiger_users.department,vtiger_users.phone_mobile,vtiger_users.phone_other,vtiger_users.phone_fax,vtiger_users.email1,vtiger_users.phone_home,vtiger_users.email2,vtiger_users.address_street,vtiger_users.address_city,vtiger_users.address_state,vtiger_users.address_postalcode,vtiger_users.address_country";
       }
   		if($modulename == "Contacts")
       {
@@ -159,22 +159,22 @@
 {
 	$selectcolumns = implode($querycolumns,",");
 
-$query = "select  ".$selectcolumns." from account 
-				inner join crmentity on crmentity.crmid=account.accountid 
-				inner join accountbillads on account.accountid=accountbillads.accountaddressid 
-				inner join accountshipads on account.accountid=accountshipads.accountaddressid 
-				inner join accountscf on account.accountid = accountscf.accountid 
-				left join account as accountAccount on accountAccount.accountid = account.parentid
-				left join users on users.id = crmentity.smownerid
-				left join contactdetails on contactdetails.accountid=account.accountid
-				left join crmentity as crmentityContacts on crmentityContacts.crmid = contactdetails.contactid 
-				left join contactaddress on contactdetails.contactid = contactaddress.contactaddressid 
-				left join contactsubdetails on contactdetails.contactid = contactsubdetails.contactsubscriptionid 
-				left join contactscf on contactdetails.contactid = contactscf.contactid 
-				left join contactdetails as contactdetailsContacts on contactdetailsContacts.contactid = contactdetails.reportsto
-				left join account as accountContacts on accountContacts.accountid = contactdetails.accountid 
-				left join users as usersContacts on usersContacts.id = crmentityContacts.smownerid
-				where crmentity.deleted=0 and (crmentityContacts.deleted=0 || crmentityContacts.deleted is null) and account.accountid in(".$mass_merge.")";
+$query = "select  ".$selectcolumns." from vtiger_account 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid 
+				inner join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid 
+				inner join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid 
+				inner join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid 
+				left join vtiger_account as vtiger_accountAccount on vtiger_accountAccount.accountid = vtiger_account.parentid
+				left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid
+				left join vtiger_contactdetails on vtiger_contactdetails.accountid=vtiger_account.accountid
+				left join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid 
+				left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid 
+				left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid 
+				left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid 
+				left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
+				left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid 
+				left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid
+				where vtiger_crmentity.deleted=0 and (crmentityContacts.deleted=0 || vtiger_crmentityContacts.deleted is null) and vtiger_account.accountid in(".$mass_merge.")";
 //echo $query;
 //die;	
 $result = $adb->query($query);
@@ -209,7 +209,7 @@
 $csvdata = implode($mergevalue,"###");
 }else
 {
-	die("No fields to do Merge");
+	die("No vtiger_fields to do Merge");
 }
 
 $handle = fopen($wordtemplatedownloadpath."datasrc.csv","wb");

Modified: vtigercrm/trunk/modules/Accounts/Popup_picker.php
==============================================================================
--- vtigercrm/trunk/modules/Accounts/Popup_picker.php (original)
+++ vtigercrm/trunk/modules/Accounts/Popup_picker.php Mon Jun 12 14:26:25 2006
@@ -99,9 +99,9 @@
 if($_REQUEST['form'] == 'TasksEditView')
 {
 	$the_javascript  = "<script type='text/javascript' language='JavaScript'>\n";
-	$the_javascript .= "function set_return(account_id, account_name) {\n";
-	$the_javascript .= "	window.opener.document.EditView.parent_name.value = account_name;\n";
-	$the_javascript .= "	window.opener.document.EditView.parent_id.value = account_id;\n";
+	$the_javascript .= "function set_return(account_id, vtiger_account_name) {\n";
+	$the_javascript .= "	window.opener.document.EditView.parent_name.value = vtiger_account_name;\n";
+	$the_javascript .= "	window.opener.document.EditView.parent_id.value = vtiger_account_id;\n";
 	$the_javascript .= "}\n";
 	$the_javascript .= "</script>\n";
 	$button  = "<table cellspacing='0' cellpadding='1' border='0'><form border='0' action='index.php' method='post' name='form' id='form'>\n";
@@ -113,9 +113,9 @@
 elseif($_REQUEST['form'] == 'HelpDeskEditView')
 {
 	$the_javascript  = "<script type='text/javascript' language='JavaScript'>\n";
-	$the_javascript .= "function set_return(account_id, account_name) {\n";
-	$the_javascript .= "	window.opener.document.EditView.parent_name.value = account_name;\n";
-	$the_javascript .= "	window.opener.document.EditView.parent_id.value = account_id;\n";
+	$the_javascript .= "function set_return(account_id, vtiger_account_name) {\n";
+	$the_javascript .= "	window.opener.document.EditView.parent_name.value = vtiger_account_name;\n";
+	$the_javascript .= "	window.opener.document.EditView.parent_id.value = vtiger_account_id;\n";
 	$the_javascript .= "}\n";
 	$the_javascript .= "</script>\n";
 	$button  = "<table cellspacing='0' cellpadding='1' border='0'><form border='0' action='index.php' method='post' name='form' id='form'>\n";
@@ -127,8 +127,8 @@
 elseif(isset($_REQUEST['form_submit']) && $_REQUEST['form'] == 'AccountDetailView' && $_REQUEST['form_submit'] == 'true')
 {
 	$the_javascript  = "<script type='text/javascript' language='JavaScript'>\n";
-	$the_javascript .= "function set_return(account_id, account_name) {\n";
-	$the_javascript .= "	window.opener.document.DetailView.member_id.value = account_id; \n";
+	$the_javascript .= "function set_return(account_id, vtiger_account_name) {\n";
+	$the_javascript .= "	window.opener.document.DetailView.member_id.value = vtiger_account_id; \n";
 	$the_javascript .= "	window.opener.document.DetailView.return_module.value = window.opener.document.DetailView.module.value; \n";
 	$the_javascript .= "	window.opener.document.DetailView.return_action.value = 'DetailView'; \n";
 	$the_javascript .= "	window.opener.document.DetailView.return_id.value = window.opener.document.DetailView.record.value; \n";
@@ -144,9 +144,9 @@
 elseif ($_REQUEST['form'] == 'EditView') 
 {
 	$the_javascript  = "<script type='text/javascript' language='JavaScript'>\n";
-	$the_javascript .= "function set_return(account_id, account_name) {\n";
-	$the_javascript .= "	window.opener.document.EditView.account_name.value = account_name;\n";
-	$the_javascript .= "	window.opener.document.EditView.account_id.value = account_id;\n";
+	$the_javascript .= "function set_return(account_id, vtiger_account_name) {\n";
+	$the_javascript .= "	window.opener.document.EditView.account_name.value = vtiger_account_name;\n";
+	$the_javascript .= "	window.opener.document.EditView.account_id.value = vtiger_account_id;\n";
 	$the_javascript .= "}\n";
 	$the_javascript .= "</script>\n";
 	$button  = "<table cellspacing='0' cellpadding='1' border='0'><form border='0' action='index.php' method='post' name='form' id='form'>\n";

Modified: vtigercrm/trunk/modules/Accounts/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Accounts/Save.php (original)
+++ vtigercrm/trunk/modules/Accounts/Save.php Mon Jun 12 14:26:25 2006
@@ -98,13 +98,13 @@
 if($_REQUEST['return_viewname'] == '') $return_viewname='0';
 if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
 
-//Send notification mail to the assigned to owner about the account creation
+//Send notification mail to the assigned to owner about the vtiger_account creation
 if($focus->column_fields['notify_owner'] == 1 || $focus->column_fields['notify_owner'] == 'on')
 	$status = sendNotificationToOwner('Accounts',&$focus);
 
 header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&viewname=$return_viewname");
 
-//Code to save the custom field info into database
+//Code to save the custom vtiger_field info into database
 function save_customfields($entity_id)
 {
 	global $log;
@@ -114,12 +114,12 @@
 	$dbquery = "SELECT * FROM customfields WHERE module = 'Accounts'";
         /*
 	$result = mysql_query($dbquery);
-	$custquery = "SELECT * FROM accountcf WHERE accountid = '".$entity_id."'";
+	$custquery = "SELECT * FROM vtiger_accountcf WHERE vtiger_accountid = '".$entity_id."'";
         $cust_result = mysql_query($custquery);
 	if(mysql_num_rows($result) != 0)
         */
 	$result = $adb->query($dbquery);
-	$custquery = "SELECT * FROM accountcf WHERE accountid = '".$entity_id."'";
+	$custquery = "SELECT * FROM vtiger_accountcf WHERE vtiger_accountid = '".$entity_id."'";
         $cust_result = $adb->query($custquery);
 	if($adb->num_rows($result) != 0)
 	{
@@ -185,19 +185,19 @@
                   if(isset($_REQUEST['record']) && $_REQUEST['record'] != '' && $adb->num_rows($cust_result) !=0)
 		{
 			//Update Block
-                        $query = "UPDATE accountcf SET ".$update." WHERE accountid='".$entity_id."'"; 
+                        $query = "UPDATE vtiger_accountcf SET ".$update." WHERE vtiger_accountid='".$entity_id."'"; 
 			$adb->query($query);
 		}
 		else
 		{
 			//Insert Block
-			$query = "INSERT INTO accountcf (".$columns.") VALUES(".$values.")";
+			$query = "INSERT INTO vtiger_accountcf (".$columns.") VALUES(".$values.")";
                         $adb->query($query);
 		}
 		
 	}
 	$log->debug("Exiting save_customfields method ...");
-	// commented by srini - PATCH for saving accounts
+	// commented by srini - PATCH for saving vtiger_accounts
 	/*else
 	{
           //if(isset($_REQUEST['record']) && $_REQUEST['record'] != '' && mysql_num_rows($cust_result) !=0)
@@ -208,7 +208,7 @@
 		else
 		{
 			//Insert Block
-			$query = "INSERT INTO accountcf (".$columns.") VALUES(".$values.")";
+			$query = "INSERT INTO vtiger_accountcf (".$columns.") VALUES(".$values.")";
                         $adb->query($query);
 			//mysql_query($query);
 		}

Modified: vtigercrm/trunk/modules/Accounts/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Accounts/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Accounts/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -81,10 +81,10 @@
 'NTC_COPY_SHIPPING_ADDRESS'=>'Copy shipping address to billing address',
 'NTC_REMOVE_MEMBER_ORG_CONFIRMATION'=>'Are you sure you want to remove this record as a member organization?',
 'LBL_DUPLICATE'=>'Potential Duplicate Accounts',
-'MSG_DUPLICATE' => 'Creating this account may potentialy create a duplicate account. You may either select an account from the list below or you may click on Create New Account to continue creating a new account with the previously entered data.',
+'MSG_DUPLICATE' => 'Creating this vtiger_account may vtiger_potentialy create a duplicate vtiger_account. You may either select an vtiger_account from the list below or you may click on Create New Account to continue creating a new vtiger_account with the previously entered data.',
 
 'LBL_INVITEE'=>'Contacts',
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
 
 'LBL_SELECT_ACCOUNT'=>'Select Account',
 'LBL_GENERAL_INFORMATION'=>'General Information',
@@ -104,7 +104,7 @@
 'LBL_NEW_CONTACT'=>'New Contact',
 'LBL_CONTACT_TITLE'=>'Contacts',
 
-//Added fields after RC1 - Release
+//Added vtiger_fields after RC1 - Release
 'LBL_ALL'=>'All',
 'LBL_PROSPECT'=>'Prospect',
 'LBL_INVESTOR'=>'Investor',

Modified: vtigercrm/trunk/modules/Activities/Activity.php
==============================================================================
--- vtigercrm/trunk/modules/Activities/Activity.php (original)
+++ vtigercrm/trunk/modules/Activities/Activity.php Mon Jun 12 14:26:25 2006
@@ -32,7 +32,7 @@
 	var $log;
 	var $db;
 
-	// Stored fields
+	// Stored vtiger_fields
   	var $eventid;
 	var $description;
 	var $firstname;
@@ -48,7 +48,7 @@
 
 	var $table_name = "activity";
 	#var $object_name = "activity";	
-		// Mike Crowe Mod --------------------------------------------------------Renamed to match tab
+		// Mike Crowe Mod --------------------------------------------------------Renamed to match vtiger_tab
 	var $object_name = "Activities";
 	// Mike Crowe Mod --------------------------------------------------------added for general search
     var $base_table_name = "activity";
@@ -58,17 +58,17 @@
 	
 	var $reminder_table = "activity_reminder";
 	
-	var $tab_name = Array('crmentity','activity','seactivityrel','cntactivityrel','salesmanactivityrel','activity_reminder','recurringevents','invitees');
-
-	var $tab_name_index = Array('crmentity'=>'crmid','activity'=>'activityid','seactivityrel'=>'activityid','cntactivityrel'=>'activityid','salesmanactivityrel'=>'activityid','activity_reminder'=>'activity_id','recurringevents'=>'activityid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_activity','vtiger_seactivityrel','vtiger_cntactivityrel','vtiger_salesmanactivityrel','vtiger_activity_reminder','vtiger_recurringevents','vtiger_invitees');
+
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_activity'=>'activityid','vtiger_seactivityrel'=>'activityid','vtiger_cntactivityrel'=>'activityid','vtiger_salesmanactivityrel'=>'activityid','vtiger_activity_reminder'=>'activity_id','vtiger_recurringevents'=>'activityid');
 
 	var $column_fields = Array();
 	var $sortby_fields = Array('subject','due_date','date_start','smownerid','activitytype');	//Sorting is added for due date and start date	
 
-	// This is used to retrieve related fields from form posts.
+	// This is used to retrieve related vtiger_fields from form posts.
 	var $additional_column_fields = Array('assigned_user_name', 'assigned_user_id', 'contactname', 'contact_phone', 'contact_email', 'parent_name');
 
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
        'Close'=>Array('activity'=>'status'),
        'Type'=>Array('activity'=>'activitytype'),
@@ -164,12 +164,12 @@
 
 			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=Activities&action=Popup&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
+				$button .= '<input title="Change" accessKey="" vtiger_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=Activities&action=Popup&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
 			}
 			$returnset = '&return_module=Activities&return_action=DetailView&activity_mode=Events&return_id='.$id;
 
 
-			$query = 'select contactdetails.accountid, contactdetails.contactid, contactdetails.firstname,contactdetails.lastname, contactdetails.department, contactdetails.title, contactdetails.email, contactdetails.phone, crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime from contactdetails inner join seactivityrel on seactivityrel.crmid=contactdetails.contactid inner join crmentity on crmentity.crmid = contactdetails.contactid where seactivityrel.activityid='.$id.' and crmentity.deleted=0';
+			$query = 'select vtiger_contactdetails.accountid, vtiger_contactdetails.contactid, vtiger_contactdetails.firstname,vtiger_contactdetails.lastname, vtiger_contactdetails.department, vtiger_contactdetails.title, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_contactdetails inner join vtiger_seactivityrel on vtiger_seactivityrel.crmid=vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_seactivityrel.activityid='.$id.' and vtiger_crmentity.deleted=0';
 			$log->debug("Exiting get_contacts method ...");
 			return GetRelatedList('Activities','Contacts',$focus,$query,$button,$returnset);
         }
@@ -178,7 +178,7 @@
 	{
 			global $adb,$log;
 			$log->debug("Entering get_users(".$id.") method ...");
-			$query = 'SELECT users.id, users.first_name,users.last_name, users.user_name, users.email1, users.email2, users.yahoo_id, users.phone_home, users.phone_work, users.phone_mobile, users.phone_other, users.phone_fax,activity.date_start,activity.due_date,activity.time_start,activity.duration_hours,activity.duration_minutes from users inner join salesmanactivityrel on salesmanactivityrel.smid=users.id  inner join activity on activity.activityid=salesmanactivityrel.activityid where activity.activityid='.$id;
+			$query = 'SELECT vtiger_users.id, vtiger_users.first_name,vtiger_users.last_name, vtiger_users.user_name, vtiger_users.email1, vtiger_users.email2, vtiger_users.yahoo_id, vtiger_users.phone_home, vtiger_users.phone_work, vtiger_users.phone_mobile, vtiger_users.phone_other, vtiger_users.phone_fax,vtiger_activity.date_start,vtiger_activity.due_date,vtiger_activity.time_start,vtiger_activity.duration_hours,vtiger_activity.duration_minutes from vtiger_users inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.smid=vtiger_users.id  inner join vtiger_activity on vtiger_activity.activityid=vtiger_salesmanactivityrel.activityid where vtiger_activity.activityid='.$id;
 			$activity_id=$id;
 
 			global $mod_strings;
@@ -229,12 +229,12 @@
 				}
 
 			// To display the dates for the Group calendar starts -Jaguar
-			$recur_dates_qry='select distinct(recurringdate) from recurringevents where activityid='.$activity_id;
+			$recur_dates_qry='select distinct(recurringdate) from vtiger_recurringevents where vtiger_activityid='.$activity_id;
 			$recur_result=$adb->query($recur_dates_qry);
 			$noofrows_recur = $adb->num_rows($recur_result);
 			if($noofrows_recur==0)
 			{
-				$recur_dates_qry='select activity.date_start,recurringevents.* from activity left outer join recurringevents on activity.activityid=recurringevents.activityid where recurringevents.activityid is NULL and activity.activityid='.$activity_id;
+				$recur_dates_qry='select vtiger_activity.date_start,vtiger_recurringevents.* from vtiger_activity left outer join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid where vtiger_recurringevents.activityid is NULL and vtiger_activity.activityid='.$activity_id;
 				$recur_result=$adb->query($recur_dates_qry);
 				$noofrows_recur = $adb->num_rows($recur_result);
 
@@ -251,7 +251,7 @@
 				$activity_start_time=time_to_number($act_time_start);	
 				$activity_end_time=get_duration($act_time_start,$act_hour_dur,$act_mins_dur);	
 
-				$activity_owner_qry='select users.user_name,users.id AS userid from users,crmentity where users.id=crmentity.smownerid and crmentity.crmid='.$id;
+				$activity_owner_qry='select vtiger_users.user_name,vtiger_users.id AS userid from vtiger_users,crmentity where vtiger_users.id=vtiger_crmentity.smownerid and vtiger_crmentity.crmid='.$id;
 				$result_owner=$adb->query($activity_owner_qry);
 
 				while($row_owner = $adb->fetch_array($result_owner))
@@ -259,7 +259,7 @@
 					$owner=$row_owner['userid'];
 				}
 
-				$recur_dates_qry='select recurringdate from recurringevents where activityid ='.$activity_id;
+				$recur_dates_qry='select recurringdate from vtiger_recurringevents where vtiger_activityid ='.$activity_id;
 				$recur_result=$adb->query($recur_dates_qry);
 				$noofrows_recur = $adb->num_rows($recur_result);
 				$userid=$row['id'];
@@ -298,7 +298,7 @@
   	{
 	 global $log;
          $log->debug("Entering get_full_list(".$criteria.") method ...");
-    $query = "select crmentity.crmid,crmentity.smownerid,crmentity.setype, activity.*, contactdetails.lastname, contactdetails.firstname, contactdetails.contactid from activity inner join crmentity on crmentity.crmid=activity.activityid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid= cntactivityrel.contactid left join seactivityrel on seactivityrel.activityid = activity.activityid WHERE crmentity.deleted=0 ".$criteria;
+    $query = "select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_activity.*, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 ".$criteria;
     $result =& $this->db->query($query);
 	echo $query;
     $this->log->debug("process_full_list_query: result is ".$result);
@@ -338,7 +338,7 @@
 	{
 		global $log;
 	        $log->debug("Entering getCount_Meeting(".$user_name.") method ...");
-      $query = "select count(*) from activity inner join crmentity on crmentity.crmid=activity.activityid inner join salesmanactivityrel on salesmanactivityrel.activityid=activity.activityid inner join users on users.id=salesmanactivityrel.smid where user_name='" .$user_name ."' and crmentity.deleted=0 and activity.activitytype='Meeting'";
+      $query = "select count(*) from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Meeting'";
 
       $result = $this->db->query($query,true,"Error retrieving contacts count");
       $rows_found =  $this->db->getRowCount($result);
@@ -351,7 +351,7 @@
     {   
 	    global $log;
             $log->debug("Entering get_calendars(".$user_name.",".$from_index.",".$offset.") method ...");
-		$query = "select activity.location as location,activity.duration_hours as duehours, activity.duration_minutes as dueminutes,activity.time_start as time_start, activity.subject as name,crmentity.modifiedtime as date_modified, activity.date_start start_date,activity.activityid as id,activity.status as status, crmentity.description as description, activity.priority as priority, activity.due_date as date_due ,contactdetails.firstname cfn, contactdetails.lastname cln from activity inner join salesmanactivityrel on salesmanactivityrel.activityid=activity.activityid inner join users on users.id=salesmanactivityrel.smid left join cntactivityrel on cntactivityrel.activityid=activity.activityid left join contactdetails on contactdetails.contactid=cntactivityrel.contactid inner join crmentity on crmentity.crmid=activity.activityid where user_name='" .$user_name ."' and crmentity.deleted=0 and activity.activitytype='Meeting' limit " .$from_index ."," .$offset;
+		$query = "select vtiger_activity.location as location,vtiger_activity.duration_hours as duehours, vtiger_activity.duration_minutes as dueminutes,vtiger_activity.time_start as time_start, vtiger_activity.subject as name,vtiger_crmentity.modifiedtime as date_modified, vtiger_activity.date_start start_date,vtiger_activity.activityid as id,vtiger_activity.status as status, vtiger_crmentity.description as description, vtiger_activity.priority as vtiger_priority, vtiger_activity.due_date as date_due ,vtiger_contactdetails.firstname cfn, vtiger_contactdetails.lastname cln from vtiger_activity inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Meeting' limit " .$from_index ."," .$offset;
 	$log->debug("Exiting get_calendars method ...");
 	    return $this->process_list_query1($query);   
     }       
@@ -361,7 +361,7 @@
     {
 	    global $log;
             $log->debug("Entering getCount(".$user_name.") method ...");
-        $query = "select count(*) from activity inner join crmentity on crmentity.crmid=activity.activityid inner join salesmanactivityrel on salesmanactivityrel.activityid=activity.activityid inner join users on users.id=salesmanactivityrel.smid where user_name='" .$user_name ."' and crmentity.deleted=0 and activity.activitytype='Task'";
+        $query = "select count(*) from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Task'";
 
         $result = $this->db->query($query,true,"Error retrieving contacts count");
         $rows_found =  $this->db->getRowCount($result);
@@ -375,7 +375,7 @@
     {   
 	global $log;
         $log->debug("Entering get_tasks(".$user_name.",".$from_index.",".$offset.") method ...");
-	 $query = "select activity.subject as name,crmentity.modifiedtime as date_modified, activity.date_start start_date,activity.activityid as id,activity.status as status, crmentity.description as description, activity.priority as priority, activity.due_date as date_due ,contactdetails.firstname cfn, contactdetails.lastname cln from activity inner join salesmanactivityrel on salesmanactivityrel.activityid=activity.activityid inner join users on users.id=salesmanactivityrel.smid left join cntactivityrel on cntactivityrel.activityid=activity.activityid left join contactdetails on contactdetails.contactid=cntactivityrel.contactid inner join crmentity on crmentity.crmid=activity.activityid where user_name='" .$user_name ."' and crmentity.deleted=0 and activity.activitytype='Task' limit " .$from_index ."," .$offset;
+	 $query = "select vtiger_activity.subject as name,vtiger_crmentity.modifiedtime as date_modified, vtiger_activity.date_start start_date,vtiger_activity.activityid as id,vtiger_activity.status as status, vtiger_crmentity.description as description, vtiger_activity.priority as vtiger_priority, vtiger_activity.due_date as date_due ,vtiger_contactdetails.firstname cfn, vtiger_contactdetails.lastname cln from vtiger_activity inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Task' limit " .$from_index ."," .$offset;
 	 $log->debug("Exiting get_tasks method ...");
     return $this->process_list_query1($query);
     
@@ -424,12 +424,12 @@
         return $response;
     }
 		
-	function activity_reminder($activity_id,$reminder_time,$reminder_sent=0,$recurid,$remindermode='')
+	function vtiger_activity_reminder($activity_id,$reminder_time,$reminder_sent=0,$recurid,$remindermode='')
 	{
 		global $log;
-		$log->debug("Entering activity_reminder(".$activity_id.",".$reminder_time.",".$reminder_sent.",".$recurid.",".$remindermode.") method ...");
-		//Check for activityid already present in the reminder_table
-		$query_exist = "SELECT activity_id FROM ".$this->reminder_table." WHERE activity_id = ".$activity_id;
+		$log->debug("Entering vtiger_activity_reminder(".$activity_id.",".$reminder_time.",".$reminder_sent.",".$recurid.",".$remindermode.") method ...");
+		//Check for vtiger_activityid already present in the reminder_table
+		$query_exist = "SELECT vtiger_activity_id FROM ".$this->reminder_table." WHERE vtiger_activity_id = ".$activity_id;
 		$result_exist = $this->db->query($query_exist);
 
 		if($remindermode == 'edit')
@@ -438,7 +438,7 @@
 			{
 				$query = "UPDATE ".$this->reminder_table." SET";
 				$query .=" reminder_sent = ".$reminder_sent.",";
-				$query .=" reminder_time = ".$reminder_time." WHERE activity_id =".$activity_id; 
+				$query .=" reminder_time = ".$reminder_time." WHERE vtiger_activity_id =".$activity_id; 
 			}
 			else
 			{
@@ -447,14 +447,14 @@
 		}
 		elseif(($remindermode == 'delete') && ($this->db->num_rows($result_exist) == 1))
 		{
-			$query = "DELETE FROM ".$this->reminder_table." WHERE activity_id = ".$activity_id;
+			$query = "DELETE FROM ".$this->reminder_table." WHERE vtiger_activity_id = ".$activity_id;
 		}
 		else
 		{
 			$query = "INSERT INTO ".$this->reminder_table." VALUES (".$activity_id.",".$reminder_time.",0,'".$recurid."')";
 		}
-      		$this->db->query($query,true,"Error in processing table $this->reminder_table");
-		$log->debug("Exiting activity_reminder method ...");
+      		$this->db->query($query,true,"Error in processing vtiger_table $this->reminder_table");
+		$log->debug("Exiting vtiger_activity_reminder method ...");
 	}
 
 //Used for vtigerCRM Outlook Add-In
@@ -462,15 +462,15 @@
 {
 	global $log;
         $log->debug("Entering get_tasksforol(".$username.") method ...");
-	$query = "select activity.subject,activity.date_start startdate,
-			 activity.activityid as taskid,activity.status,
-			 crmentity.description,activity.priority as priority,activity.due_date as duedate,
-			 contactdetails.firstname, contactdetails.lastname 
-			 from activity inner join crmentity on crmentity.crmid=activity.activityid 
-			 inner join users on users.id = crmentity.smownerid 
-			 left join cntactivityrel on cntactivityrel.activityid=activity.activityid 
-			 left join contactdetails on contactdetails.contactid=cntactivityrel.contactid 
-			 where users.user_name='".$username."' and crmentity.deleted=0 and activity.activitytype='Task'";
+	$query = "select vtiger_activity.subject,vtiger_activity.date_start startdate,
+			 vtiger_activity.activityid as taskid,vtiger_activity.status,
+			 vtiger_crmentity.description,vtiger_activity.priority as vtiger_priority,vtiger_activity.due_date as duedate,
+			 vtiger_contactdetails.firstname, vtiger_contactdetails.lastname 
+			 from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid 
+			 inner join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid 
+			 left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid 
+			 left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid 
+			 where vtiger_users.user_name='".$username."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Task'";
 	$log->debug("Exiting get_tasksforol method ...");		 
 	return $query;
 }
@@ -479,17 +479,17 @@
 {
 	global $log;
         $log->debug("Entering get_calendarsforol(".$user_name.") method ...");
-	  $query = "select activity.location, activity.duration_hours as duehours, 
-				activity.duration_minutes as dueminutes,activity.time_start as startime, 
-				activity.subject,activity.date_start as startdate,activity.activityid as clndrid,
-				crmentity.description,activity.due_date as duedate ,
-				contactdetails.firstname, contactdetails.lastname from activity 
-				inner join salesmanactivityrel on salesmanactivityrel.activityid=activity.activityid 
-				inner join users on users.id=salesmanactivityrel.smid 
-				left join cntactivityrel on cntactivityrel.activityid=activity.activityid 
-				left join contactdetails on contactdetails.contactid=cntactivityrel.contactid 
-				inner join crmentity on crmentity.crmid=activity.activityid 
-				where users.user_name='".$user_name."' and crmentity.deleted=0 and activity.activitytype='Meeting'";
+	  $query = "select vtiger_activity.location, vtiger_activity.duration_hours as duehours, 
+			vtiger_activity.duration_minutes as dueminutes,vtiger_activity.time_start as startime, 
+			vtiger_activity.subject,vtiger_activity.date_start as startdate,vtiger_activity.activityid as clndrid,
+			vtiger_crmentity.description,vtiger_activity.due_date as duedate ,
+			vtiger_contactdetails.firstname, vtiger_contactdetails.lastname from vtiger_activity 
+				inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid 
+				inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid 
+				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid 
+				left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid 
+				where vtiger_users.user_name='".$user_name."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Meeting'";
 	$log->debug("Exiting get_calendarsforol method ...");
 	return $query;
 }

Modified: vtigercrm/trunk/modules/Activities/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Activities/EditView.php (original)
+++ vtigercrm/trunk/modules/Activities/EditView.php Mon Jun 12 14:26:25 2006
@@ -31,7 +31,7 @@
 require_once('include/FormValidationUtil.php');
 global $app_strings;
 global $mod_strings;
-// Unimplemented until jscalendar language files are fixed
+// Unimplemented until jscalendar language vtiger_files are fixed
 $activity_lbl='';
 $activity_mode = $_REQUEST['activity_mode'];
 if($activity_mode == 'Task')
@@ -98,7 +98,7 @@
 $category = getParentTab();
 $smarty->assign("CATEGORY",$category);
 
-// Unimplemented until jscalendar language files are fixed
+// Unimplemented until jscalendar language vtiger_files are fixed
 $smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
 $smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
 

Modified: vtigercrm/trunk/modules/Activities/Event.php
==============================================================================
--- vtigercrm/trunk/modules/Activities/Event.php (original)
+++ vtigercrm/trunk/modules/Activities/Event.php Mon Jun 12 14:26:25 2006
@@ -30,7 +30,7 @@
 	var $log;
 	var $db;
 
-	// Stored fields
+	// Stored vtiger_fields
   	var $eventid;
 	var $description;
 	var $status;
@@ -51,10 +51,10 @@
 
 	var $column_fields = Array();
 
-	// This is used to retrieve related fields from form posts.
+	// This is used to retrieve related vtiger_fields from form posts.
 	var $additional_column_fields = Array('assigned_user_name', 'assigned_user_id', 'contactname', 'contact_phone', 'contact_email', 'parent_name');
 
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
        'Close'=>Array('event'=>'status'),
        'Subject'=>Array('activity'=>'subject'),
@@ -88,7 +88,7 @@
     {
 	global $log;
 	$log->debug("Entering getCount(".$user_name.") method ...");
-        $query = "select count(*) from tasks inner join users on users.id=tasks.assigned_user_id where user_name='" .$user_name ."' and tasks.deleted=0";
+        $query = "select count(*) from tasks inner join vtiger_users on vtiger_users.id=tasks.assigned_user_id where user_name='" .$user_name ."' and tasks.deleted=0";
 
 //       echo "\n Query is " .$query ."\n";
         $result = $this->db->query($query,true,"Error retrieving contacts count");

Modified: vtigercrm/trunk/modules/Activities/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Activities/Forms.php (original)
+++ vtigercrm/trunk/modules/Activities/Forms.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 /*********************************************************************************
  * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Activities/Forms.php,v 1.7 2005/04/19 16:49:29 ray Exp $
  * Description:  Contains a variety of utility functions used to display UI
- * components such as form headers and footers.  Intended to be modified on a per
+ * components such as form vtiger_headers and footers.  Intended to be modified on a per
  * theme basis.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
@@ -60,23 +60,23 @@
  */
 // Declaring valid date character, minimum year and maximum year
 
-var fieldname,fieldlabel,fielddatatype;	
+var vtiger_fieldname,fieldlabel,fielddatatype;	
 function verify_data(form,fname,flabel,fdatatype) 
 {
 	var form_name=form.name;
 	if(form_name=='ActivitySave')
         {
                form.due_date.value=form.date_start.value;
-	       fieldname =fname.split(",");
-	       fieldlabel = flabel.split(",");
-               fielddatatype = fdatatype.split(",");
+	       vtiger_fieldname =fname.split(",");
+	       vtiger_fieldlabel = flabel.split(",");
+               vtiger_fielddatatype = fdatatype.split(",");
         }
         else
         {
               form.due_date.value=form.date_start.value;
-	      fieldname = fname.split(",");
-              fieldlabel = flabel.split(",");
-              fielddatatype = fdatatype.split(",");
+	      vtiger_fieldname = fname.split(",");
+              vtiger_fieldlabel = flabel.split(",");
+              vtiger_fielddatatype = fdatatype.split(",");
         
         }
 
@@ -93,7 +93,7 @@
 
 /* Commented for RC
 /**
- * Create HTML form to enter a new record with the minimum necessary fields.
+ * Create HTML form to enter a new record with the minimum necessary vtiger_fields.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
@@ -106,13 +106,13 @@
 global $theme;
 global $adb;//for dynamic quickcreateform construction
 
-// Unimplemented until jscalendar language files are fixed
+// Unimplemented until jscalendar language vtiger_files are fixed
 // global $current_language;
 // global $default_language;
 // global $cal_codes;
 
 $user_id = $current_user->id;
-// Unimplemented until jscalendar language files are fixed
+// Unimplemented until jscalendar language vtiger_files are fixed
 // $cal_lang = (empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language];
 $cal_lang = "en";
 $cal_dateformat = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
@@ -126,7 +126,7 @@
 $fieldLabel_task = '';
 $fldDataType_task = '';
 
-$qcreate_get_field="select * from field where tabid=9 and quickcreate=0 order by quickcreatesequence";
+$qcreate_get_field="select * from vtiger_field where vtiger_tabid=9 and quickcreate=0 order by quickcreatesequence";
 $qcreate_get_result=$adb->query($qcreate_get_field);
 $qcreate_get_noofrows=$adb->num_rows($qcreate_get_result);
 $fieldName_array_task = Array();//for validation
@@ -239,7 +239,7 @@
 $fieldLabel = '';
 $fldDataType = '';
 
-$qcreate_get_field="select * from field where tabid=16 and quickcreate=0 order by quickcreatesequence";
+$qcreate_get_field="select * from vtiger_field where vtiger_tabid=16 and quickcreate=0 order by quickcreatesequence";
 $qcreate_get_result=$adb->query($qcreate_get_field);
 $qcreate_get_noofrows=$adb->num_rows($qcreate_get_result);
 

Modified: vtigercrm/trunk/modules/Activities/GroupAllocationView.php
==============================================================================
--- vtigercrm/trunk/modules/Activities/GroupAllocationView.php (original)
+++ vtigercrm/trunk/modules/Activities/GroupAllocationView.php Mon Jun 12 14:26:25 2006
@@ -52,7 +52,7 @@
 if(isset($_REQUEST['query']))
 {
 
-  $query = "select leads.last_name,leadgrouprelation.groupname from leads inner join leadgrouprelation on leads.id=leadgrouprelation.leadid where leadgrouprelation.deleted=0  and leads.deleted=0";
+  $query = "select leads.last_name,vtiger_leadgrouprelation.groupname from leads inner join vtiger_leadgrouprelation on leads.id=vtiger_leadgrouprelation.leadid where vtiger_leadgrouprelation.deleted=0  and leads.deleted=0";
   $log->info("Here is the where clause for the list view: $query");
 
 }

Modified: vtigercrm/trunk/modules/Activities/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Activities/ListView.php (original)
+++ vtigercrm/trunk/modules/Activities/ListView.php Mon Jun 12 14:26:25 2006
@@ -125,7 +125,7 @@
 	$list_query .= " AND " .$where;
 }
 
-$list_query .= ' group by activity.activityid';
+$list_query .= ' group by vtiger_activity.activityid';
 
 if(isset($order_by) && $order_by != '')
 {
@@ -177,7 +177,7 @@
 if($viewid !='')
 $url_string .="&viewname=".$viewid;
 
-//Cambiado code to add close button in custom field
+//Cambiado code to add close button in custom vtiger_field
 if (($viewid!=0)&&($viewid!="")){
   if (!isset($oCustomView->list_fields['Close'])) $oCustomView->list_fields['Close']=array ( 'activity' => 'status' );
   if (!isset($oCustomView->list_fields_name['Close'])) $oCustomView->list_fields_name['Close']='status';

Modified: vtigercrm/trunk/modules/Activities/OpenListView.php
==============================================================================
--- vtigercrm/trunk/modules/Activities/OpenListView.php (original)
+++ vtigercrm/trunk/modules/Activities/OpenListView.php Mon Jun 12 14:26:25 2006
@@ -45,7 +45,7 @@
 	//code added to customize upcomming and pending activities
 	if($_REQUEST['activity_view']=='')
 	{	
-		$query = "select activity_view from users where id ='$current_user->id'";
+		$query = "select activity_view from vtiger_users where id ='$current_user->id'";
 		$result=$adb->query($query);
 		$activity_view=$adb->query_result($result,0,'activity_view');
 	}
@@ -78,12 +78,12 @@
 	if($mode != 1)
 	{
 		//for upcoming avtivities
-		$list_query = " select crmentity.crmid,crmentity.smownerid,crmentity.setype, activity.*, contactdetails.lastname, contactdetails.firstname, contactdetails.contactid, account.accountid, account.accountname, recurringevents.recurringtype,recurringevents.recurringdate from activity inner join crmentity on crmentity.crmid=activity.activityid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid= cntactivityrel.contactid left join seactivityrel on seactivityrel.activityid = activity.activityid left outer join account on account.accountid = contactdetails.accountid left outer join recurringevents on recurringevents.activityid=activity.activityid inner join salesmanactivityrel on salesmanactivityrel.activityid=activity.activityid WHERE crmentity.deleted=0 and (activity.activitytype = 'Meeting' or activity.activitytype='Call' or activity.activitytype='Task') AND ( activity.status is NULL OR activity.status != 'Completed' ) and ( activity.status is NULL OR activity.status != 'Deferred') and  (  activity.eventstatus is NULL OR  activity.eventstatus != 'Held') and (activity.eventstatus is NULL OR  activity.eventstatus != 'Not Held' ) AND (((date_start > '$today' AND date_start < '$later'))  OR (recurringevents.recurringdate between '$today' and '$later') ) AND crmentity.smownerid !=0 AND salesmanactivityrel.smid ='$current_user->id'";
+		$list_query = " select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_activity.*, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_account.accountid, vtiger_account.accountname, vtiger_recurringevents.recurringtype,vtiger_recurringevents.recurringdate from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid left outer join vtiger_account on vtiger_account.accountid = vtiger_contactdetails.accountid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task') AND ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Completed' ) and ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Deferred') and  (  vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus != 'Held') and (vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus != 'Not Held' ) AND (((date_start > '$today' AND date_start < '$later'))  OR (vtiger_recurringevents.recurringdate between '$today' and '$later') ) AND vtiger_crmentity.smownerid !=0 AND vtiger_salesmanactivityrel.smid ='$current_user->id'";
 	}	
 	else
 	{
 		//for pending activities for the last 10 days
-		$list_query = " select crmentity.crmid,crmentity.smownerid,crmentity.setype, activity.*, contactdetails.lastname, contactdetails.firstname, contactdetails.contactid, account.accountid, account.accountname, recurringevents.recurringtype,recurringevents.recurringdate from activity inner join crmentity on crmentity.crmid=activity.activityid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid= cntactivityrel.contactid left join seactivityrel on seactivityrel.activityid = activity.activityid left outer join account on account.accountid = contactdetails.accountid left outer join recurringevents on recurringevents.activityid=activity.activityid inner join salesmanactivityrel on salesmanactivityrel.activityid=activity.activityid WHERE crmentity.deleted=0 and (activity.activitytype = 'Meeting' or activity.activitytype='Call' or activity.activitytype='Task') AND ( activity.status is NULL OR activity.status != 'Completed' ) and ( activity.status is NULL OR activity.status != 'Deferred') and (  activity.eventstatus is NULL OR  activity.eventstatus != 'Held') and (activity.eventstatus is NULL OR  activity.eventstatus != 'Not Held' ) AND (due_date > '$last_tendays' AND due_date <= '$today') OR (recurringevents.recurringdate > '$last_tendays' AND recurringevents.recurringdate <= '$today') AND crmentity.smownerid !=0 AND salesmanactivityrel.smid ='$current_user->id'";
+		$list_query = " select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_activity.*, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_account.accountid, vtiger_account.accountname, vtiger_recurringevents.recurringtype,vtiger_recurringevents.recurringdate from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid left outer join vtiger_account on vtiger_account.accountid = vtiger_contactdetails.accountid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task') AND ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Completed' ) and ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Deferred') and (  vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus != 'Held') and (vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus != 'Not Held' ) AND (due_date > '$last_tendays' AND due_date <= '$today') OR (vtiger_recurringevents.recurringdate > '$last_tendays' AND vtiger_recurringevents.recurringdate <= '$today') AND vtiger_crmentity.smownerid !=0 AND vtiger_salesmanactivityrel.smid ='$current_user->id'";
 	}
 	$res = $adb->query($list_query);
 	$noofrecords = $adb->num_rows($res);
@@ -110,7 +110,7 @@
 					'recurringdate' => getDisplayDate($adb->query_result($list_result,$i,'recurringdate')),
 					'parent'=> $parent_name,
 					// Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
-					'priority' => $adb->query_result($list_result,$i,'priority'), // Armando Lüscher 04.07.2005 -> §priority -> Desc: Get priority from db
+					'priority' => $adb->query_result($list_result,$i,'priority'), // Armando Lüscher 04.07.2005 -> §priority -> Desc: Get vtiger_priority from db
 					);
 		}
 	$later_day = getDisplayDate(date("Y-m-d", strtotime("$later -1 day ")));
@@ -149,7 +149,7 @@
 			$event['date_start']=$event['recurringdate'];
 			// Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
 		// begin: Armando Lüscher 04.07.2005 -> §priority
-		// Desc: Set priority colors
+		// Desc: Set vtiger_priority colors
 		$font_color_high = "color:#00DD00;";
 		$font_color_medium = "color:#DD00DD;";
 

Modified: vtigercrm/trunk/modules/Activities/RenderRelatedListUI.php
==============================================================================
--- vtigercrm/trunk/modules/Activities/RenderRelatedListUI.php (original)
+++ vtigercrm/trunk/modules/Activities/RenderRelatedListUI.php Mon Jun 12 14:26:25 2006
@@ -64,11 +64,11 @@
 		if( $owner != $userid)
 		{
 			
-			$usr_query="select activityid,activity.date_start,activity.due_date, activity.time_start,activity.duration_hours,activity.duration_minutes,crmentity.smownerid from activity,crmentity where crmentity.crmid=activity.activityid and ('".$avail_date."' like date_start) and crmentity.smownerid=".$userid." and activity.activityid !=".$activity_id."  and crmentity.deleted=0";
+			$usr_query="select vtiger_activityid,vtiger_activity.date_start,vtiger_activity.due_date, vtiger_activity.time_start,vtiger_activity.duration_hours,vtiger_activity.duration_minutes,vtiger_crmentity.smownerid from vtiger_activity,crmentity where vtiger_crmentity.crmid=vtiger_activity.activityid and ('".$avail_date."' like date_start) and vtiger_crmentity.smownerid=".$userid." and vtiger_activity.activityid !=".$activity_id."  and vtiger_crmentity.deleted=0";
 		}
 		else
 		{
-			$usr_query="select activityid,activity.date_start,activity.due_date, activity.time_start,activity.duration_hours,activity.duration_minutes,crmentity.smownerid from activity,crmentity where crmentity.crmid=activity.activityid and ('".$avail_date."' like date_start) and crmentity.smownerid=".$userid." and activity.activityid !=".$activity_id." and crmentity.deleted=0";
+			$usr_query="select vtiger_activityid,vtiger_activity.date_start,vtiger_activity.due_date, vtiger_activity.time_start,vtiger_activity.duration_hours,vtiger_activity.duration_minutes,vtiger_crmentity.smownerid from vtiger_activity,crmentity where vtiger_crmentity.crmid=vtiger_activity.activityid and ('".$avail_date."' like date_start) and vtiger_crmentity.smownerid=".$userid." and vtiger_activity.activityid !=".$activity_id." and vtiger_crmentity.deleted=0";
 		}
 		$result_cal=$adb->query($usr_query);   
 		$noofrows_cal = $adb->num_rows($result_cal);
@@ -98,7 +98,7 @@
 		}
 		if($avail_flag!="true")
 		{
-			$recur_query="SELECT activity.activityid, activity.time_start, activity.duration_hours, activity.duration_minutes , crmentity.smownerid, recurringevents.recurringid, recurringevents.recurringdate as date_start from activity inner join crmentity on activity.activityid = crmentity.crmid inner join recurringevents on activity.activityid=recurringevents.activityid where ('".$avail_date."' like recurringevents.recurringdate) and crmentity.smownerid=".$userid." and activity.activityid !=".$activity_id." and crmentity.deleted=0";
+			$recur_query="SELECT vtiger_activity.activityid, vtiger_activity.time_start, vtiger_activity.duration_hours, vtiger_activity.duration_minutes , vtiger_crmentity.smownerid, vtiger_recurringevents.recurringid, vtiger_recurringevents.recurringdate as date_start from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid inner join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid where ('".$avail_date."' like vtiger_recurringevents.recurringdate) and vtiger_crmentity.smownerid=".$userid." and vtiger_activity.activityid !=".$activity_id." and vtiger_crmentity.deleted=0";
 			
 			$result_cal=$adb->query($recur_query);   
 			$noofrows_cal = $adb->num_rows($result_cal);

Modified: vtigercrm/trunk/modules/Activities/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Activities/Save.php (original)
+++ vtigercrm/trunk/modules/Activities/Save.php Mon Jun 12 14:26:25 2006
@@ -106,7 +106,7 @@
 		$crmid = $_REQUEST['product_id'];
 	if($crmid != $_REQUEST['parent_id'])
 	{
-		$sql = "insert into seactivityrel (activityid, crmid) values('".$focus->id."','".$crmid."')";
+		$sql = "insert into vtiger_seactivityrel (activityid, crmid) values('".$focus->id."','".$crmid."')";
 		$adb->query($sql);
 	}
 }
@@ -114,7 +114,7 @@
 $activemode = "";
 if($activity_mode != '') $activemode = "&activity_mode=".$activity_mode;
 
-//Added code to send mail to the assigned to user about the details of the activity if sendnotification = on and assigned to user
+//Added code to send mail to the assigned to user about the details of the vtiger_activity if sendnotification = on and assigned to user
 if($_REQUEST['sendnotification'] == 'on' && $_REQUEST['assigntype'] == 'U')
 {
 	global $current_user;
@@ -128,7 +128,7 @@
         $mail_status  = send_mail('Activities',$to_email,$current_user->user_name,'',$subject,$description);
 }
 
-//code added to send mail to the invitees
+//code added to send mail to the vtiger_invitees
 if(isset($_REQUEST['inviteesid']) && $_REQUEST['inviteesid']!='')
 {
 	global $current_user;
@@ -163,7 +163,7 @@
 	$page.='&allflag=Normal';
 header("Location: index.php?action=$return_action&module=$return_module$view$hour$day$month$year&record=$return_id$activemode&viewname=$return_viewname$page");
 
-//Function to get the activity details for mail body
+//Function to get the vtiger_activity details for mail body
 function getActivityDetails($description)
 {
 	global $log;
@@ -175,7 +175,7 @@
 	$status = (($_REQUEST['activity_mode']=='Task')?($_REQUEST['taskstatus']):($_REQUEST['eventstatus']));
 
 	$list = 'Dear '.$name.',';
-	$list .= '<br><br> There is an activity('.$_REQUEST['activity_mode'].')'.$reply.'. The details are :';
+	$list .= '<br><br> There is an vtiger_activity('.$_REQUEST['activity_mode'].')'.$reply.'. The details are :';
 	$list .= '<br>Subject : '.$_REQUEST['subject'];
 	$list .= '<br>Status : '.$status;
 	$list .= '<br>Priority : '.$_REQUEST['taskpriority'];

Modified: vtigercrm/trunk/modules/Activities/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Activities/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Activities/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -65,14 +65,14 @@
 'LBL_LIST_LAST_MODIFIED'=>'Last Modified',
 'LBL_LIST_RECURRING_TYPE'=>'Recurring Type',
 
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
 'NTC_NONE_SCHEDULED'=>'None scheduled.',
 
-// Added fields for Attachments in Activities/SubPanelView.php
+// Added vtiger_fields for Attachments in Activities/SubPanelView.php
 'LBL_ATTACHMENTS'=>'Attachments',
 'LBL_NEW_ATTACHMENT'=>'New Attachment',
 
-//Added fields after RC1 - Release
+//Added vtiger_fields after RC1 - Release
 'LBL_ALL'=>'All',
 'LBL_CALL'=>'Call',
 'LBL_MEETING'=>'Meeting',

Modified: vtigercrm/trunk/modules/Activities/updateRelations.php
==============================================================================
--- vtigercrm/trunk/modules/Activities/updateRelations.php (original)
+++ vtigercrm/trunk/modules/Activities/updateRelations.php Mon Jun 12 14:26:25 2006
@@ -22,7 +22,7 @@
 		if($id != '')
 		{
 			$record = $_REQUEST['parentid'];
-			$sql = "insert into seactivityrel values (".$id.",".$_REQUEST["parentid"].")";
+			$sql = "insert into vtiger_seactivityrel values (".$id.",".$_REQUEST["parentid"].")";
 			$adb->query($sql);
 		}
 	}
@@ -32,7 +32,7 @@
 elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
 {
 	$record = $_REQUEST["parid"];
-	$sql = "insert into seactivityrel values (". $_REQUEST["entityid"] .",".$_REQUEST["parid"] .")";
+	$sql = "insert into vtiger_seactivityrel values (". $_REQUEST["entityid"] .",".$_REQUEST["parid"] .")";
 	$adb->query($sql);
 	header("Location: index.php?action=CallRelatedList&module=Activities&activity_mode=Events&record=".$record);
 }
@@ -40,11 +40,11 @@
 
 
  
-//This if for adding the users 
+//This if for adding the vtiger_users 
 if(isset($_REQUEST['user_id']) && $_REQUEST['user_id'] != '')
 {
 	$record = $_REQUEST['record'];
-	$sql = "insert into salesmanactivityrel values (". $_REQUEST["user_id"] .",".$_REQUEST["record"] .")";
+	$sql = "insert into vtiger_salesmanactivityrel values (". $_REQUEST["user_id"] .",".$_REQUEST["record"] .")";
 	$adb->query($sql);
 	header("Location: index.php?action=CallRelatedList&module=Activities&activity_mode=Events&record=".$record);
 

Modified: vtigercrm/trunk/modules/Calendar/Appointment.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/Appointment.php (original)
+++ vtigercrm/trunk/modules/Calendar/Appointment.php Mon Jun 12 14:26:25 2006
@@ -57,20 +57,20 @@
 		$shared_ids = getSharedCalendarId($current_user->id);		
 		if(empty($shared_ids))
 			$shared_ids = $current_user->id;
-                $q= "select activity.*, crmentity.*, account.accountname,account.accountid,activitygrouprelation.groupname FROM activity inner join crmentity on activity.activityid = crmentity.crmid left join recurringevents on activity.activityid=recurringevents.activityid left outer join activitygrouprelation on activitygrouprelation.activityid=activity.activityid left join cntactivityrel on activity.activityid = cntactivityrel.activityid left join contactdetails on cntactivityrel.contactid = contactdetails.contactid left join account  on contactdetails.accountid = account.accountid inner join salesmanactivityrel on salesmanactivityrel.activityid=activity.activityid WHERE activity.activitytype in ('Call','Meeting') AND ";
+                $q= "select vtiger_activity.*, vtiger_crmentity.*, vtiger_account.accountname,vtiger_account.accountid,vtiger_activitygrouprelation.groupname FROM vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid left join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left outer join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_activity.activityid = vtiger_cntactivityrel.activityid left join vtiger_contactdetails on vtiger_cntactivityrel.contactid = vtiger_contactdetails.contactid left join vtiger_account  on vtiger_contactdetails.accountid = vtiger_account.accountid inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid WHERE vtiger_activity.activitytype in ('Call','Meeting') AND ";
 
                 if(!is_admin($current_user))
                 {
                         $q .= " ( ";
                 }
 
-                $q.=" ((activity.date_start < '". $to_datetime->get_formatted_date() ."' AND activity.date_start >= '". $from_datetime->get_formatted_date()."')";
-                if(!is_admin($current_user))
-                {
-                        $q .= "  ) AND ((crmentity.smownerid ='".$current_user->id."' and salesmanactivityrel.smid = '".$current_user->id."') or (crmentity.smownerid in (".$shared_ids.") and salesmanactivityrel.smid in (".$shared_ids.")))";
-                }
-                $q .= " AND crmentity.deleted = 0) AND recurringevents.activityid is NULL ";
-                $q .= " ORDER by activity.date_start,activity.time_start";
+                $q.=" ((vtiger_activity.date_start < '". $to_datetime->get_formatted_date() ."' AND vtiger_activity.date_start >= '". $from_datetime->get_formatted_date()."')";
+                if(!is_admin($current_user))
+                {
+                        $q .= "  ) AND ((vtiger_crmentity.smownerid ='".$current_user->id."' and vtiger_salesmanactivityrel.smid = '".$current_user->id."') or (vtiger_crmentity.smownerid in (".$shared_ids.") and vtiger_salesmanactivityrel.smid in (".$shared_ids.")))";
+                }
+                $q .= " AND vtiger_crmentity.deleted = 0) AND vtiger_recurringevents.activityid is NULL ";
+                $q .= " ORDER by vtiger_activity.date_start,vtiger_activity.time_start";
 		$r = $adb->query($q);
                 $n = $adb->getRowCount($r);
                 $a = 0;
@@ -85,9 +85,9 @@
                         unset($obj);
                 }
 		//Get Recurring events
-		$q = "SELECT activity.activityid, activity.subject, activity.activitytype, crmentity.description, activity.time_start, activity.duration_hours, activity.duration_minutes, activity.priority, activity.location,activity.eventstatus, crmentity.*, recurringevents.recurringid, recurringevents.recurringdate as date_start ,recurringevents.recurringtype,account.accountname,account.accountid,activitygrouprelation.groupname from activity inner join crmentity on activity.activityid = crmentity.crmid inner join recurringevents on activity.activityid=recurringevents.activityid left outer join activitygrouprelation on activitygrouprelation.activityid=activity.activityid left join cntactivityrel on activity.activityid = cntactivityrel.activityid left join contactdetails on cntactivityrel.contactid = contactdetails.contactid left join account  on contactdetails.accountid = account.accountid inner join salesmanactivityrel on salesmanactivityrel.activityid=activity.activityid";
-
-                $q.=" where ( activity.activitytype in ('Call','Meeting') AND ";
+		$q = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.activitytype, vtiger_crmentity.description, vtiger_activity.time_start, vtiger_activity.duration_hours, vtiger_activity.duration_minutes, vtiger_activity.priority, vtiger_activity.location,vtiger_activity.eventstatus, vtiger_crmentity.*, vtiger_recurringevents.recurringid, vtiger_recurringevents.recurringdate as date_start ,vtiger_recurringevents.recurringtype,vtiger_account.accountname,vtiger_account.accountid,vtiger_activitygrouprelation.groupname from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid inner join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left outer join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_activity.activityid = vtiger_cntactivityrel.activityid left join vtiger_contactdetails on vtiger_cntactivityrel.contactid = vtiger_contactdetails.contactid left join vtiger_account  on vtiger_contactdetails.accountid = vtiger_account.accountid inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid";
+
+                $q.=" where ( vtiger_activity.activitytype in ('Call','Meeting') AND ";
                 if(!is_admin($current_user))
                 {
                         $q .= " ( ";
@@ -95,10 +95,10 @@
                 $q .= "  (recurringdate < '".$to_datetime->get_formatted_date()."' AND recurringdate >= '".$from_datetime->get_formatted_date(). "') ";
                 if(!is_admin($current_user))
                 {
-			$q .= " ) AND ((crmentity.smownerid ='".$current_user->id."' and salesmanactivityrel.smid = '".$current_user->id."' ) or (crmentity.smownerid in (".$shared_ids.") and salesmanactivityrel.smid in (".$shared_ids.")))";
-                }
-
-                $q .= " AND crmentity.deleted = 0 )" ;
+			$q .= " ) AND ((vtiger_crmentity.smownerid ='".$current_user->id."' and vtiger_salesmanactivityrel.smid = '".$current_user->id."' ) or (vtiger_crmentity.smownerid in (".$shared_ids.") and vtiger_salesmanactivityrel.smid in (".$shared_ids.")))";
+                }
+
+                $q .= " AND vtiger_crmentity.deleted = 0 )" ;
                 $q .= " ORDER by recurringid";
                 $r = $adb->query($q);
                 $n = $adb->getRowCount($r);
@@ -120,7 +120,7 @@
 
 
 	/** To read and set the events value in Appointment Obj
-          * @param $act_array -- The activity array :: Type Array
+          * @param $act_array -- The vtiger_activity array :: Type Array
           * @param $view -- The calendar view :: Type String
          */
 	function readResult($act_array, $view)
@@ -199,7 +199,7 @@
 			$this->assignedto ="user";
 			$this->ownerid = $act_array["smownerid"];
 			$this->owner   = getUserName($act_array["smownerid"]);
-                        $query="SELECT cal_color FROM users where id = ".$this->ownerid;
+                        $query="SELECT cal_color FROM vtiger_users where id = ".$this->ownerid;
                         $result=$adb->query($query);
                         if($adb->getRowCount($result)!=0)
 			{
@@ -241,8 +241,8 @@
 }
 
 /** To two array values
-  * @param $a -- The activity array :: Type Array
-  * @param $b -- The activity array :: Type Array
+  * @param $a -- The vtiger_activity array :: Type Array
+  * @param $b -- The vtiger_activity array :: Type Array
   * @returns value 0 or 1 or -1 depends on comparision result
  */
 function compare($a,$b)

Modified: vtigercrm/trunk/modules/Calendar/CalendarCommon.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/CalendarCommon.php (original)
+++ vtigercrm/trunk/modules/Calendar/CalendarCommon.php Mon Jun 12 14:26:25 2006
@@ -19,13 +19,13 @@
 /**
  * To get the lists of sharedids 
  * @param $id -- The user id :: Type integer
- * @returns $sharedids -- The shared users id :: Type Array
+ * @returns $sharedids -- The shared vtiger_users id :: Type Array
  */
 function getSharedUserId($id)
 {
         global $adb;
 	$sharedid = Array();
-        $query = "SELECT * from sharedcalendar where userid=".$id;
+        $query = "SELECT * from vtiger_sharedcalendar where userid=".$id;
         $result = $adb->query($query);
         $rows = $adb->num_rows($result);
         for($j=0;$j<$rows;$j++)
@@ -36,14 +36,14 @@
 }
 
 /**
- * To get the lists of users id who shared their calendar with specified user
+ * To get the lists of vtiger_users id who shared their calendar with specified user
  * @param $sharedid -- The shared user id :: Type integer
- * @returns $shared_ids -- a comma seperated users id  :: Type string
+ * @returns $shared_ids -- a comma seperated vtiger_users id  :: Type string
  */
 function getSharedCalendarId($sharedid)
 {
 	global $adb;
-	$query = "SELECT * from sharedcalendar where sharedid=".$sharedid;
+	$query = "SELECT * from vtiger_sharedcalendar where sharedid=".$sharedid;
 	$result = $adb->query($query);
 	if($adb->num_rows($result)!=0)
 	{
@@ -55,7 +55,7 @@
 }
 
 /**
- * To get userid and username of all users except the current user
+ * To get userid and username of all vtiger_users except the current user
  * @param $id -- The user id :: Type integer
  * @returns $user_details -- Array in the following format:
  * $user_details=Array($userid1=>$username, $userid2=>$username,............,$useridn=>$username);
@@ -63,7 +63,7 @@
 function getOtherUserName($id)
 {
 	global $adb;
-	$query="select * from users where deleted=0 and status='Active' and id!=".$id;
+	$query="select * from vtiger_users where deleted=0 and status='Active' and id!=".$id;
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	$user_details=Array();

Modified: vtigercrm/trunk/modules/Calendar/addEventUI.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/addEventUI.php (original)
+++ vtigercrm/trunk/modules/Calendar/addEventUI.php Mon Jun 12 14:26:25 2006
@@ -616,9 +616,9 @@
                 </table>
 </form>
 <script>
-	var fieldname = new Array('task_subject','task_date_start','task_time_start','taskstatus');
-        var fieldlabel = new Array('Subject','Date','Time','Status');
-        var fielddatatype = new Array('V~M','D~M~time_start','T~O','V~O');
+	var vtiger_fieldname = new Array('task_subject','task_date_start','task_time_start','taskstatus');
+        var vtiger_fieldlabel = new Array('Subject','Date','Time','Status');
+        var vtiger_fielddatatype = new Array('V~M','D~M~time_start','T~O','V~O');
 </script>	
 
 </div>

Modified: vtigercrm/trunk/modules/Calendar/calendarLayout.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/calendarLayout.php (original)
+++ vtigercrm/trunk/modules/Calendar/calendarLayout.php Mon Jun 12 14:26:25 2006
@@ -997,30 +997,30 @@
 	$shared_ids = getSharedCalendarId($current_user->id);
 	if(empty($shared_ids))
 		$shared_ids = $current_user->id;
-	$query = "SELECT cntactivityrel.contactid, activity.*
-		FROM activity
-		INNER JOIN crmentity
-			ON crmentity.crmid = activity.activityid
-		LEFT JOIN cntactivityrel
-			ON cntactivityrel.activityid = activity.activityid
-		LEFT OUTER JOIN recurringevents
-			ON recurringevents.activityid = activity.activityid
-		WHERE crmentity.deleted = 0
-			AND (activity.activitytype = 'Meeting' OR activity.activitytype = 'Call')
-			AND (activity.date_start BETWEEN '".$start_date."' AND '".$end_date."'
-				OR recurringevents.recurringdate BETWEEN '".$start_date."' AND '".$end_date."')";
+	$query = "SELECT vtiger_cntactivityrel.contactid, vtiger_activity.*
+		FROM vtiger_activity
+		INNER JOIN vtiger_crmentity
+			ON vtiger_crmentity.crmid = vtiger_activity.activityid
+		LEFT JOIN vtiger_cntactivityrel
+			ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid
+		LEFT OUTER JOIN vtiger_recurringevents
+			ON vtiger_recurringevents.activityid = vtiger_activity.activityid
+		WHERE vtiger_crmentity.deleted = 0
+			AND (vtiger_activity.activitytype = 'Meeting' OR vtiger_activity.activitytype = 'Call')
+			AND (vtiger_activity.date_start BETWEEN '".$start_date."' AND '".$end_date."'
+				OR vtiger_recurringevents.recurringdate BETWEEN '".$start_date."' AND '".$end_date."')";
 	if($info != '')
 	{
-		$pending_query = $query." AND (activity.eventstatus = 'Planned')
-			AND crmentity.smownerid = ".$current_user->id."
-		ORDER BY activity.date_start,activity.time_start ASC";
+		$pending_query = $query." AND (vtiger_activity.eventstatus = 'Planned')
+			AND vtiger_crmentity.smownerid = ".$current_user->id."
+		ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC";
 		$res = $adb->query($pending_query);
 		$pending_rows = $adb->num_rows($res);
 	}
 	if(!is_admin($current_user))
-		$query .= " AND crmentity.smownerid in (".$shared_ids.")";
+		$query .= " AND vtiger_crmentity.smownerid in (".$shared_ids.")";
 		
-	$query .= "ORDER BY activity.date_start,activity.time_start ASC";
+	$query .= "ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC";
 
 	$result = $adb->query($query);
 	$rows = $adb->num_rows($result);
@@ -1083,27 +1083,27 @@
 	$shared_ids = getSharedCalendarId($current_user->id);
 	if(empty($shared_ids))
 		$shared_ids = $current_user->id;
-        $query = "SELECT cntactivityrel.contactid, activity.*
-                FROM activity
-                INNER JOIN crmentity
-                        ON crmentity.crmid = activity.activityid
-                LEFT JOIN cntactivityrel
-                        ON cntactivityrel.activityid = activity.activityid
-                WHERE crmentity.deleted = 0
-                        AND activity.activitytype = 'Task'
-                        AND (activity.date_start BETWEEN '".$start_date."' AND '".$end_date."')";
+        $query = "SELECT vtiger_cntactivityrel.contactid, vtiger_activity.*
+                FROM vtiger_activity
+                INNER JOIN vtiger_crmentity
+                        ON vtiger_crmentity.crmid = vtiger_activity.activityid
+                LEFT JOIN vtiger_cntactivityrel
+                        ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid
+                WHERE vtiger_crmentity.deleted = 0
+                        AND vtiger_activity.activitytype = 'Task'
+                        AND (vtiger_activity.date_start BETWEEN '".$start_date."' AND '".$end_date."')";
         if($info != '')
         {
-                $pending_query = $query." AND (activity.status != 'Completed')
-                        AND crmentity.smownerid = ".$current_user->id."
-                ORDER BY activity.date_start,activity.time_start ASC";
+                $pending_query = $query." AND (vtiger_activity.status != 'Completed')
+                        AND vtiger_crmentity.smownerid = ".$current_user->id."
+                ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC";
                 $res = $adb->query($pending_query);
                 $pending_rows = $adb->num_rows($res);
         }
 	
 	if(!is_admin($current_user))
-                $query .= " AND crmentity.smownerid in (".$shared_ids.")";
-        $query .= " ORDER BY activity.date_start,activity.time_start ASC";
+                $query .= " AND vtiger_crmentity.smownerid in (".$shared_ids.")";
+        $query .= " ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC";
 
         $result = $adb->query($query);
         $rows = $adb->num_rows($result);

Modified: vtigercrm/trunk/modules/Calendar/disable_sharing.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/disable_sharing.php (original)
+++ vtigercrm/trunk/modules/Calendar/disable_sharing.php Mon Jun 12 14:26:25 2006
@@ -16,7 +16,7 @@
 $storearray = explode(";",$idlist);
 foreach($storearray as $id)
 {
-        $sql="delete from sharedcalendar where sharedid='" .$id ."'";
+        $sql="delete from vtiger_sharedcalendar where sharedid='" .$id ."'";
         $result = $adb->query($sql);
 }
 header("Location:index.php?module=".$returnmodule."&action=".$returnaction);

Modified: vtigercrm/trunk/modules/Calendar/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Calendar/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -108,7 +108,7 @@
 
 'LBL_APP_IGNORE_TIME2' => '(i.e. the appointment takes place<br />at no particular time on these day(s) )',
 
-'LBL_APP_ERR001' =>'Invalid Date in field %s!',
+'LBL_APP_ERR001' =>'Invalid Date in vtiger_field %s!',
 'LBL_APP_ERR002' =>'start after end !',
 'LBL_APP_ERR003' =>'Missing Contact !',
 'LBL_APP_ERR004' =>'Missing Subject !',
@@ -208,10 +208,10 @@
 'LBL_EVERYMON'=>'Every Month',
 'LBL_REPEATEVENT'=>'Repeat Event',
 
-'LBL_INVITE_INST1'=>'To invite, select the users from the "Available Users" list and click the "Add" button.',
-'LBL_INVITE_INST2'=>'To remove, select the users in the "Selected Users" list and the click "Remove" button.',
-'LBL_SELUSR_INFO'=>' Selected users will receive an email about the Event.',
-'LBL_CALSHAREMESSAGE'=>'Share my calendar with the following selected users',
+'LBL_INVITE_INST1'=>'To invite, select the vtiger_users from the "Available Users" list and click the "Add" button.',
+'LBL_INVITE_INST2'=>'To remove, select the vtiger_users in the "Selected Users" list and the click "Remove" button.',
+'LBL_SELUSR_INFO'=>' Selected vtiger_users will receive an email about the Event.',
+'LBL_CALSHAREMESSAGE'=>'Share my calendar with the following selected vtiger_users',
 'LBL_CALSHARE'=>'Calendar Sharing',
 'LBL_SEL_USERS'=>'Selected Users',
 'LBL_AVL_USERS'=>'Available Users',

Modified: vtigercrm/trunk/modules/Calendar/updateCalendarSharing.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/updateCalendarSharing.php (original)
+++ vtigercrm/trunk/modules/Calendar/updateCalendarSharing.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 	$hour_format = $_REQUEST['hour_format'];
 else
 	$hour_format = 'am/pm';
-$delquery = "delete from sharedcalendar where userid=".$_REQUEST["current_userid"];
+$delquery = "delete from vtiger_sharedcalendar where userid=".$_REQUEST["current_userid"];
 $adb->query($delquery);
 $sharedid = $_REQUEST['user'];
 if(isset($sharedid) && $sharedid != null)
@@ -24,18 +24,18 @@
         {
                 if($sid != '')
                 {
-			$sql = "insert into sharedcalendar values (".$_REQUEST["current_userid"].",".$sid.")";
+			$sql = "insert into vtiger_sharedcalendar values (".$_REQUEST["current_userid"].",".$sid.")";
 		        $adb->query($sql);
                 }
         }
 }
 if(isset($_REQUEST['start_hour']) && $_REQUEST['start_hour'] != '')
 {
-	$sql = "update users set start_hour='".$_REQUEST['start_hour']."' where id=".$current_user->id;
+	$sql = "update vtiger_users set start_hour='".$_REQUEST['start_hour']."' where id=".$current_user->id;
         $adb->query($sql);
 }
 
-$sql = "update users set hour_format='".$hour_format."' where id=".$current_user->id;
+$sql = "update vtiger_users set hour_format='".$hour_format."' where id=".$current_user->id;
 $adb->query($sql);
 header("Location: index.php?action=index&module=Calendar&parenttab=My Home Page");
 

Modified: vtigercrm/trunk/modules/Campaigns/Campaign.php
==============================================================================
--- vtigercrm/trunk/modules/Campaigns/Campaign.php (original)
+++ vtigercrm/trunk/modules/Campaigns/Campaign.php Mon Jun 12 14:26:25 2006
@@ -25,12 +25,12 @@
 	var $log;
 	var $db;
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $mode;
 
-	var $tab_name = Array('crmentity','campaign','campaignscf');
-	var $tab_name_index = Array('crmentity'=>'crmid','campaign'=>'campaignid','campaignscf'=>'campaignid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_campaign','vtiger_campaignscf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_campaign'=>'campaignid','vtiger_campaignscf'=>'campaignid');
 	var $column_fields = Array();
 
 	var $sortby_fields = Array('campaignname','smownerid','expectedcost');
@@ -69,7 +69,7 @@
                 $button = '';
                 $returnset = '&return_module=Campaigns&return_action=DetailView&return_id='.$id;
 
-		$query = 'SELECT contactdetails.*, crmentity.crmid, users.user_name, groups.groupname, crmentity.smownerid from contactdetails inner join crmentity on crmentity.crmid = contactdetails.contactid left join users on crmentity.smownerid = users.id left join contactgrouprelation on contactdetails.contactid=contactgrouprelation.contactid left join groups on groups.groupname=contactgrouprelation.groupname  where crmentity.deleted=0 and contactdetails.campaignid = '.$id;
+		$query = 'SELECT vtiger_contactdetails.*, vtiger_crmentity.crmid, vtiger_users.user_name, vtiger_groups.groupname, vtiger_crmentity.smownerid from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_users on vtiger_crmentity.smownerid = vtiger_users.id left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname  where vtiger_crmentity.deleted=0 and vtiger_contactdetails.campaignid = '.$id;
 		$log->debug("Exiting get_contacts method ...");
                 return GetRelatedList('Campaigns','Contacts',$focus,$query,$button,$returnset);
         }
@@ -84,7 +84,7 @@
                 $button = '';
                 $returnset = '&return_module=Campaigns&return_action=DetailView&return_id='.$id;
 
-		$query = 'SELECT leaddetails.*, crmentity.crmid, users.user_name, groups.groupname, crmentity.smownerid from leaddetails inner join crmentity on crmentity.crmid = leaddetails.leadid left join users on crmentity.smownerid = users.id left join leadgrouprelation on leaddetails.leadid=leadgrouprelation.leadid left join groups on groups.groupname=leadgrouprelation.groupname where crmentity.deleted=0 and leaddetails.campaignid = '.$id;
+		$query = 'SELECT vtiger_leaddetails.*, vtiger_crmentity.crmid, vtiger_users.user_name, vtiger_groups.groupname, vtiger_crmentity.smownerid from vtiger_leaddetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_leaddetails.leadid left join vtiger_users on vtiger_crmentity.smownerid = vtiger_users.id left join vtiger_leadgrouprelation on vtiger_leaddetails.leadid=vtiger_leadgrouprelation.leadid left join vtiger_groups on vtiger_groups.groupname=vtiger_leadgrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_leaddetails.campaignid = '.$id;
 		$log->debug("Exiting get_leads method ...");
                 return GetRelatedList('Campaigns','Leads',$focus,$query,$button,$returnset);
         }

Modified: vtigercrm/trunk/modules/Campaigns/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Campaigns/ListView.php (original)
+++ vtigercrm/trunk/modules/Campaigns/ListView.php Mon Jun 12 14:26:25 2006
@@ -136,7 +136,7 @@
 {
 	if($order_by == 'smownerid')
 	{
-		$list_query .= ' ORDER BY users.user_name '.$sorder;
+		$list_query .= ' ORDER BY vtiger_users.user_name '.$sorder;
 	}
 	else
 	{
@@ -148,7 +148,7 @@
 }
 else
 {
-	$list_query .= ' order by campaign.campaignid DESC';
+	$list_query .= ' order by vtiger_campaign.campaignid DESC';
 }
 
 $list_result = $adb->query($list_query);

Modified: vtigercrm/trunk/modules/Contacts/CallRelatedList.php
==============================================================================
--- vtigercrm/trunk/modules/Contacts/CallRelatedList.php (original)
+++ vtigercrm/trunk/modules/Contacts/CallRelatedList.php Mon Jun 12 14:26:25 2006
@@ -29,11 +29,11 @@
 }
 
 global $adb;
-$sql = $adb->query('select accountid from contactdetails where contactid='.$focus->id);
+$sql = $adb->query('select vtiger_accountid from vtiger_contactdetails where contactid='.$focus->id);
 $accountid = $adb->query_result($sql,0,'accountid');
 if($accountid == 0) $accountid='';
 
-$sql1 = $adb->query('select campaignid from contactdetails where contactid='.$focus->id);
+$sql1 = $adb->query('select vtiger_campaignid from vtiger_contactdetails where contactid='.$focus->id);
 $campaignid = $adb->query_result($sql1,0,'campaignid');
 if($campaignid == 0) $campaignid='';
 

Modified: vtigercrm/trunk/modules/Contacts/Contact.php
==============================================================================
--- vtigercrm/trunk/modules/Contacts/Contact.php (original)
+++ vtigercrm/trunk/modules/Contacts/Contact.php Mon Jun 12 14:26:25 2006
@@ -38,8 +38,8 @@
 	var $db;
 
 	var $table_name = "contactdetails";
-	var $tab_name = Array('crmentity','contactdetails','contactaddress','contactsubdetails','contactscf','customerdetails','attachments');
-	var $tab_name_index = Array('crmentity'=>'crmid','contactdetails'=>'contactid','contactaddress'=>'contactaddressid','contactsubdetails'=>'contactsubscriptionid','contactscf'=>'contactid','customerdetails'=>'customerid','attachments'=>'attachmentsid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_contactdetails','vtiger_contactaddress','vtiger_contactsubdetails','vtiger_contactscf','vtiger_customerdetails','vtiger_attachments');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_contactdetails'=>'contactid','vtiger_contactaddress'=>'contactaddressid','vtiger_contactsubdetails'=>'contactsubscriptionid','vtiger_contactscf'=>'contactid','vtiger_customerdetails'=>'customerid','vtiger_attachments'=>'attachmentsid');
 
 	var $module_id = "contactid";
 	var $object_name = "Contact";
@@ -52,7 +52,7 @@
 
 	var $list_link_field= 'lastname';
 
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
 	'Last Name' => Array('contactdetails'=>'lastname'),
 	'First Name' => Array('contactdetails'=>'firstname'),
@@ -116,7 +116,7 @@
 	'Title' => 'title'
 	);
 
-	// This is the list of fields that are required
+	// This is the list of vtiger_fields that are required
 	var $required_fields =  array("lastname"=>1);
 
 	//Added these variables which are used as default order by and sortorder in ListView
@@ -159,7 +159,7 @@
     {
 	global $log;
 	$log->debug("Entering getCount(".$user_name.") method ...");
-        $query = "select count(*) from contactdetails  inner join crmentity on crmentity.crmid=contactdetails.contactid inner join users on users.id=crmentity.smownerid where user_name='" .$user_name ."' and crmentity.deleted=0";
+        $query = "select count(*) from vtiger_contactdetails  inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0";
 
         $result = $this->db->query($query,true,"Error retrieving contacts count");
         $rows_found =  $this->db->getRowCount($result);
@@ -174,7 +174,7 @@
     {   
 	global $log;
 	$log->debug("Entering get_contacts1(".$user_name.",".$email_address.") method ...");
-      $query = "select users.user_name, contactdetails.lastname last_name,contactdetails.firstname first_name,contactdetails.contactid as id, contactdetails.salutation as salutation, contactdetails.email as email1,contactdetails.title as title,contactdetails.mobile as phone_mobile,account.accountname as account_name,account.accountid as account_id   from contactdetails inner join crmentity on crmentity.crmid=contactdetails.contactid inner join users on users.id=crmentity.smownerid  left join account on account.accountid=contactdetails.accountid left join contactaddress on contactaddress.contactaddressid=contactdetails.contactid  left join contactgrouprelation on contactdetails.contactid=contactgrouprelation.contactid where user_name='" .$user_name ."' and crmentity.deleted=0  and contactdetails.email like '%" .$email_address ."%' limit 50";
+      $query = "select vtiger_users.user_name, vtiger_contactdetails.lastname last_name,vtiger_contactdetails.firstname first_name,vtiger_contactdetails.contactid as id, vtiger_contactdetails.salutation as salutation, vtiger_contactdetails.email as email1,vtiger_contactdetails.title as title,vtiger_contactdetails.mobile as phone_mobile,vtiger_account.accountname as vtiger_account_name,vtiger_account.accountid as vtiger_account_id   from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid  left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid  left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0  and vtiger_contactdetails.email like '%" .$email_address ."%' limit 50";
     
 	$log->debug("Exiting get_contacts1 method ...");
       return $this->process_list_query1($query);
@@ -184,7 +184,7 @@
     {   
 	global $log;
 	$log->debug("Entering get_contacts(".$user_name.",".$from_index.",".$offset.") method ...");
-      $query = "select users.user_name,groups.groupname,contactdetails.department department, contactdetails.phone office_phone, contactdetails.fax fax, contactsubdetails.assistant assistant_name, contactsubdetails.otherphone other_phone, contactsubdetails.homephone home_phone,contactsubdetails.birthday birthdate, contactdetails.lastname last_name,contactdetails.firstname first_name,contactdetails.contactid as id, contactdetails.salutation as salutation, contactdetails.email as email1,contactdetails.title as title,contactdetails.mobile as phone_mobile,account.accountname as account_name,account.accountid as account_id, contactaddress.mailingcity as primary_address_city,contactaddress.mailingstreet as primary_address_street, contactaddress.mailingcountry as primary_address_country,contactaddress.mailingstate as primary_address_state, contactaddress.mailingzip as primary_address_postalcode,   contactaddress.othercity as alt_address_city,contactaddress.otherstreet as alt_address_street, contactaddress.othercountry as alt_address_country,contactaddress.otherstate as alt_address_state, contactaddress.otherzip as alt_address_postalcode  from contactdetails inner join crmentity on crmentity.crmid=contactdetails.contactid inner join users on users.id=crmentity.smownerid left join account on account.accountid=contactdetails.accountid left join contactaddress on contactaddress.contactaddressid=contactdetails.contactid left join contactsubdetails on contactsubdetails.contactsubscriptionid = contactdetails.contactid left join contactgrouprelation on contactdetails.contactid=contactgrouprelation.contactid left join groups on groups.groupname=contactgrouprelation.groupname left join users on crmentity.smownerid=users.id where user_name='" .$user_name ."' and crmentity.deleted=0 limit " .$from_index ."," .$offset;
+      $query = "select vtiger_users.user_name,vtiger_groups.groupname,vtiger_contactdetails.department department, vtiger_contactdetails.phone office_phone, vtiger_contactdetails.fax fax, vtiger_contactsubdetails.assistant assistant_name, vtiger_contactsubdetails.otherphone other_phone, vtiger_contactsubdetails.homephone home_phone,vtiger_contactsubdetails.birthday birthdate, vtiger_contactdetails.lastname last_name,vtiger_contactdetails.firstname first_name,vtiger_contactdetails.contactid as id, vtiger_contactdetails.salutation as salutation, vtiger_contactdetails.email as email1,vtiger_contactdetails.title as title,vtiger_contactdetails.mobile as phone_mobile,vtiger_account.accountname as vtiger_account_name,vtiger_account.accountid as vtiger_account_id, vtiger_contactaddress.mailingcity as primary_address_city,vtiger_contactaddress.mailingstreet as primary_address_street, vtiger_contactaddress.mailingcountry as primary_address_country,vtiger_contactaddress.mailingstate as primary_address_state, vtiger_contactaddress.mailingzip as primary_address_postalcode,   vtiger_contactaddress.othercity as alt_address_city,vtiger_contactaddress.otherstreet as alt_address_street, vtiger_contactaddress.othercountry as alt_address_country,vtiger_contactaddress.otherstate as alt_address_state, vtiger_contactaddress.otherzip as alt_address_postalcode  from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid left join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 limit " .$from_index ."," .$offset;
       
 	$log->debug("Exiting get_contacts method ...");
       return $this->process_list_query1($query);
@@ -218,8 +218,8 @@
                     }   
 	     }	
     
-// TODO OPTIMIZE THE QUERY ACCOUNT NAME AND ID are set separetly for every contactdetails and hence 
-// account query goes for ecery single account row
+// TODO OPTIMIZE THE QUERY ACCOUNT NAME AND ID are set separetly for every vtiger_contactdetails and hence 
+// vtiger_account query goes for ecery single vtiger_account row
 
                     $list[] = $contact;
                 }
@@ -261,7 +261,7 @@
 		$log->info("Potential Related List for Contact Displayed");
 
 		// First, get the list of IDs.
-		$query = 'select users.user_name,groups.groupname,contactdetails.accountid, contactdetails.contactid , potential.potentialid, potential.potentialname, potential.potentialtype, potential.sales_stage, potential.amount, potential.closingdate, crmentity.crmid, crmentity.smownerid from contactdetails inner join potential on contactdetails.accountid = potential.accountid inner join crmentity on crmentity.crmid = potential.potentialid left join potentialgrouprelation on potential.potentialid=potentialgrouprelation.potentialid left join groups on groups.groupname=potentialgrouprelation.groupname left join users on users.id=crmentity.smownerid where contactdetails.contactid = '.$id.' and crmentity.deleted=0';
+		$query = 'select vtiger_users.user_name,vtiger_groups.groupname,vtiger_contactdetails.accountid, vtiger_contactdetails.contactid , vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_potential.potentialtype, vtiger_potential.sales_stage, vtiger_potential.amount, vtiger_potential.closingdate, vtiger_crmentity.crmid, vtiger_crmentity.smownerid from vtiger_contactdetails inner join vtiger_potential on vtiger_contactdetails.accountid = vtiger_potential.accountid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid left join vtiger_potentialgrouprelation on vtiger_potential.potentialid=vtiger_potentialgrouprelation.potentialid left join vtiger_groups on vtiger_groups.groupname=vtiger_potentialgrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_contactdetails.contactid = '.$id.' and vtiger_crmentity.deleted=0';
 		if($this->column_fields['account_id'] != 0)
 		$log->debug("Exiting get_opportunities method ...");
 		return GetRelatedList('Contacts','Potentials',$focus,$query,$button,$returnset);
@@ -292,7 +292,7 @@
 
 		$log->info("Activity Related List for Contact Displayed");
 
-		$query = "SELECT users.user_name,contactdetails.lastname, contactdetails.firstname,  activity.activityid , activity.subject, activity.activitytype, activity.date_start, activity.due_date, cntactivityrel.contactid, crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime, recurringevents.recurringtype  from contactdetails inner join cntactivityrel on cntactivityrel.contactid = contactdetails.contactid inner join activity on cntactivityrel.activityid=activity.activityid inner join crmentity on crmentity.crmid = cntactivityrel.activityid left join users on users.id=crmentity.smownerid left outer join recurringevents on recurringevents.activityid=activity.activityid left join activitygrouprelation on activitygrouprelation.activityid=crmentity.crmid left join groups on groups.groupname=activitygrouprelation.groupname  where contactdetails.contactid=".$id." and crmentity.deleted = 0 and (activity.activitytype = 'Meeting' or activity.activitytype='Call' or activity.activitytype='Task') AND ( activity.status is NULL OR activity.status != 'Completed' ) and ( activity.eventstatus is NULL OR activity.eventstatus != 'Held') ";  //recurring type is added in Query -Jaguar
+		$query = "SELECT vtiger_users.user_name,vtiger_contactdetails.lastname, vtiger_contactdetails.firstname,  vtiger_activity.activityid , vtiger_activity.subject, vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date, vtiger_cntactivityrel.contactid, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_recurringevents.recurringtype  from vtiger_contactdetails inner join vtiger_cntactivityrel on vtiger_cntactivityrel.contactid = vtiger_contactdetails.contactid inner join vtiger_activity on vtiger_cntactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_cntactivityrel.activityid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname  where vtiger_contactdetails.contactid=".$id." and vtiger_crmentity.deleted = 0 and (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task') AND ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Completed' ) and ( vtiger_activity.eventstatus is NULL OR vtiger_activity.eventstatus != 'Held') ";  //recurring type is added in Query -Jaguar
 		$log->debug("Exiting get_activities method ...");
 		return GetRelatedList('Contacts','Activities',$focus,$query,$button,$returnset);
 
@@ -302,21 +302,21 @@
 	{
 		global $log;
 		$log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT activity.activityid, activity.subject, activity.status, activity.eventstatus,
-			activity.activitytype, contactdetails.contactid, contactdetails.firstname,
-			contactdetails.lastname, crmentity.modifiedtime,
-			crmentity.createdtime, crmentity.description, users.user_name
-				from activity
-				inner join cntactivityrel on cntactivityrel.activityid= activity.activityid
-				inner join contactdetails on contactdetails.contactid= cntactivityrel.contactid
-				inner join crmentity on crmentity.crmid=activity.activityid
-				left join seactivityrel on seactivityrel.activityid=activity.activityid
-				left join activitygrouprelation on activitygrouprelation.activityid=activity.activityid
-                                left join groups on groups.groupname=activitygrouprelation.groupname
-				inner join users on crmentity.smcreatorid= users.id
-				where (activity.activitytype = 'Meeting' or activity.activitytype='Call' or activity.activitytype='Task')
-				and (activity.status = 'Completed' or activity.status = 'Deferred' or (activity.eventstatus = 'Held' and activity.eventstatus != ''))
-				and cntactivityrel.contactid=".$id;
+		$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status, vtiger_activity.eventstatus,
+		vtiger_activity.activitytype, vtiger_contactdetails.contactid, vtiger_contactdetails.firstname,
+		vtiger_contactdetails.lastname, vtiger_crmentity.modifiedtime,
+		vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
+				from vtiger_activity
+				inner join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
+				inner join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+				left join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
+				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
+				where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
+				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
+				and vtiger_cntactivityrel.contactid=".$id;
 		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
 		$log->debug("Entering get_history method ...");
 		return getHistory('Contacts',$query,$id);
@@ -332,7 +332,7 @@
 		$button = '<td valign="bottom" align="right"><input title="New Ticket" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'HelpDesk\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_TICKET'].'">&nbsp;</td>';
 		$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
 
-		$query = "select users.user_name,crmentity.crmid, troubletickets.title, contactdetails.contactid, troubletickets.parent_id, contactdetails.firstname, contactdetails.lastname, troubletickets.status, troubletickets.priority, crmentity.smownerid from troubletickets inner join crmentity on crmentity.crmid=troubletickets.ticketid left join contactdetails on contactdetails.contactid=troubletickets.parent_id left join users on users.id=crmentity.smownerid left join ticketgrouprelation on troubletickets.ticketid=ticketgrouprelation.ticketid left join groups on groups.groupname=ticketgrouprelation.groupname where crmentity.deleted=0 and contactdetails.contactid=".$id;
+		$query = "select vtiger_users.user_name,vtiger_crmentity.crmid, vtiger_troubletickets.title, vtiger_contactdetails.contactid, vtiger_troubletickets.parent_id, vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_troubletickets.status, vtiger_troubletickets.priority, vtiger_crmentity.smownerid from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_troubletickets.parent_id left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_ticketgrouprelation on vtiger_troubletickets.ticketid=vtiger_ticketgrouprelation.ticketid left join vtiger_groups on vtiger_groups.groupname=vtiger_ticketgrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_contactdetails.contactid=".$id;
 		$log->info("Ticket Related List for Contact Displayed");
 		$log->debug("Exiting get_tickets method ...");
 		return GetRelatedList('Contacts','HelpDesk',$focus,$query,$button,$returnset);
@@ -342,28 +342,28 @@
 	{
 		global $log;
 		$log->debug("Entering get_attachments(".$id.") method ...");
-		$query = "select notes.title,'Notes      ' AS ActivityType,
-			notes.filename, attachments.type AS FileType,crm2.modifiedtime AS lastmodified,
-			seattachmentsrel.attachmentsid AS attachmentsid, notes.notesid AS crmid,
-			crm2.createdtime, notes.notecontent AS description, users.user_name
-		from notes
-			inner join crmentity on crmentity.crmid= notes.contact_id
-			inner join crmentity crm2 on crm2.crmid=notes.notesid and crm2.deleted=0
-			left join seattachmentsrel on seattachmentsrel.crmid =notes.notesid
-			left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid
-			inner join users on crm2.smcreatorid= users.id
-		where crmentity.crmid=".$id;
+		$query = "select vtiger_notes.title,'Notes      ' AS ActivityType,
+		vtiger_notes.filename, vtiger_attachments.type AS FileType,crm2.modifiedtime AS lastmodified,
+		vtiger_seattachmentsrel.attachmentsid AS vtiger_attachmentsid, vtiger_notes.notesid AS crmid,
+			crm2.createdtime, vtiger_notes.notecontent AS description, vtiger_users.user_name
+		from vtiger_notes
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_notes.contact_id
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+			left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id;
 		$query .= " union all ";
-		$query .= "select attachments.description AS title,'Attachments' AS ActivityType,
-			attachments.name AS filename, attachments.type AS FileType,crm2.modifiedtime AS lastmodified,
-			attachments.attachmentsid AS attachmentsid, seattachmentsrel.attachmentsid AS crmid,
-			crm2.createdtime, attachments.description, users.user_name
-		from attachments
-			inner join seattachmentsrel on seattachmentsrel.attachmentsid= attachments.attachmentsid
-			inner join crmentity on crmentity.crmid= seattachmentsrel.crmid
-			inner join crmentity crm2 on crm2.crmid=attachments.attachmentsid
-			inner join users on crm2.smcreatorid= users.id
-		where crmentity.crmid=".$id."
+		$query .= "select vtiger_attachments.description AS title,'Attachments' AS ActivityType,
+		vtiger_attachments.name AS filename, vtiger_attachments.type AS FileType,crm2.modifiedtime AS lastmodified,
+		vtiger_attachments.attachmentsid AS vtiger_attachmentsid, vtiger_seattachmentsrel.attachmentsid AS crmid,
+			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		from vtiger_attachments
+			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id."
 		order by createdtime desc";
 	  	$log->info("Notes&Attachmenmts for Contact Displayed");
 		$log->debug("Exiting get_attachments method ...");
@@ -384,7 +384,7 @@
 		$button .= '<input title="'.$app_strings['LBL_NEW_QUOTE_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_QUOTE_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Quotes\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_QUOTE_BUTTON'].'">&nbsp;</td>';
 		}
 		$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
-		$query = "select users.user_name,crmentity.*, quotes.*,potential.potentialname,contactdetails.lastname from quotes inner join crmentity on crmentity.crmid=quotes.quoteid left outer join contactdetails on contactdetails.contactid=quotes.contactid left outer join potential on potential.potentialid=quotes.potentialid  left join users on users.id=crmentity.smownerid left join quotegrouprelation on quotes.quoteid=quotegrouprelation.quoteid left join groups on groups.groupname=quotegrouprelation.groupname where crmentity.deleted=0 and contactdetails.contactid=".$id;
+		$query = "select vtiger_users.user_name,vtiger_crmentity.*, vtiger_quotes.*,vtiger_potential.potentialname,vtiger_contactdetails.lastname from vtiger_quotes inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid left outer join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_quotes.contactid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_quotes.potentialid  left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_quotegrouprelation on vtiger_quotes.quoteid=vtiger_quotegrouprelation.quoteid left join vtiger_groups on vtiger_groups.groupname=vtiger_quotegrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_contactdetails.contactid=".$id;
 		$log->debug("Exiting get_quotes method ...");
 		return GetRelatedList('Contacts','Quotes',$focus,$query,$button,$returnset);
 	  }
@@ -405,7 +405,7 @@
 		 }
 		 $returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
 
-		 $query = "select users.user_name,crmentity.*, salesorder.*, quotes.subject as quotename, account.accountname, contactdetails.lastname from salesorder inner join crmentity on crmentity.crmid=salesorder.salesorderid left join users on users.id=crmentity.smownerid left outer join quotes on quotes.quoteid=salesorder.quoteid left outer join account on account.accountid=salesorder.accountid left outer join contactdetails on contactdetails.contactid=salesorder.contactid left join sogrouprelation on salesorder.salesorderid=sogrouprelation.salesorderid left join groups on groups.groupname=sogrouprelation.groupname where crmentity.deleted=0 and salesorder.contactid = ".$id;
+		 $query = "select vtiger_users.user_name,vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename, vtiger_account.accountname, vtiger_contactdetails.lastname from vtiger_salesorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid left outer join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_salesorder.contactid left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_salesorder.contactid = ".$id;
 		$log->debug("Exiting get_salesorder method ...");
 		 return GetRelatedList('Contacts','SalesOrder',$focus,$query,$button,$returnset);
 	 }
@@ -426,7 +426,7 @@
 		 }
 		 $returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
 
-		 $query = 'select products.productid, products.productname, products.productcode, products.commissionrate, products.qty_per_unit, products.unit_price, crmentity.crmid, crmentity.smownerid,contactdetails.lastname from products inner join crmentity on crmentity.crmid = products.productid left outer join contactdetails on contactdetails.contactid = products.contactid where contactdetails.contactid = '.$id.' and crmentity.deleted = 0';
+		 $query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_contactdetails.lastname from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid left outer join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_products.contactid where vtiger_contactdetails.contactid = '.$id.' and vtiger_crmentity.deleted = 0';
 		$log->debug("Exiting get_products method ...");
 		 return GetRelatedList('Contacts','Products',$focus,$query,$button,$returnset);
 	 }
@@ -448,7 +448,7 @@
 		 }
 		 $returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
 
-		 $query = "select users.user_name,crmentity.*, purchaseorder.*,vendor.vendorname,contactdetails.lastname from purchaseorder inner join crmentity on crmentity.crmid=purchaseorder.purchaseorderid left outer join vendor on purchaseorder.vendorid=vendor.vendorid left outer join contactdetails on contactdetails.contactid=purchaseorder.contactid left join users on users.id=crmentity.smownerid left join pogrouprelation on purchaseorder.purchaseorderid=pogrouprelation.purchaseorderid left join groups on groups.groupname=pogrouprelation.groupname where crmentity.deleted=0 and purchaseorder.contactid=".$id;
+		 $query = "select vtiger_users.user_name,vtiger_crmentity.*, vtiger_purchaseorder.*,vtiger_vendor.vendorname,vtiger_contactdetails.lastname from vtiger_purchaseorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_purchaseorder.purchaseorderid left outer join vtiger_vendor on vtiger_purchaseorder.vendorid=vtiger_vendor.vendorid left outer join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_purchaseorder.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_pogrouprelation on vtiger_purchaseorder.purchaseorderid=vtiger_pogrouprelation.purchaseorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_pogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_purchaseorder.contactid=".$id;
 		$log->debug("Exiting get_purchase_orders method ...");
 		 return GetRelatedList('Contacts','PurchaseOrder',$focus,$query,$button,$returnset);
 	 }
@@ -476,7 +476,7 @@
 
 		$log->info("Email Related List for Contact Displayed");
 
-		$query = "select activity.activityid, activity.activityid, activity.subject, activity.activitytype, users.user_name, crmentity.modifiedtime, crmentity.crmid, crmentity.smownerid, activity.date_start from activity, seactivityrel, contactdetails, users, crmentity left join activitygrouprelation on activitygrouprelation.activityid=crmentity.crmid left join groups on groups.groupname=activitygrouprelation.groupname where seactivityrel.activityid = activity.activityid and contactdetails.contactid = seactivityrel.crmid and users.id=crmentity.smownerid and crmentity.crmid = activity.activityid  and contactdetails.contactid = ".$id." and activity.activitytype='Emails' and crmentity.deleted = 0";
+		$query = "select vtiger_activity.activityid, vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.activitytype, vtiger_users.user_name, vtiger_crmentity.modifiedtime, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_activity.date_start from vtiger_activity, vtiger_seactivityrel, vtiger_contactdetails, vtiger_users, vtiger_crmentity left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.activityid = vtiger_activity.activityid and vtiger_contactdetails.contactid = vtiger_seactivityrel.crmid and vtiger_users.id=vtiger_crmentity.smownerid and vtiger_crmentity.crmid = vtiger_activity.activityid  and vtiger_contactdetails.contactid = ".$id." and vtiger_activity.activitytype='Emails' and vtiger_crmentity.deleted = 0";
 		$log->debug("Exiting get_emails method ...");
 		return GetRelatedList('Contacts','Emails',$focus,$query,$button,$returnset);
 	}
@@ -492,30 +492,30 @@
 		if($this->checkIfCustomTableExists('contactscf'))
 		{
 			$query =  $this->constructCustomQueryAddendum('contactscf','Contacts') ."
-                                contactdetails.*, contactaddress.*,
-                                account.accountname account_name,
-                                users.user_name assigned_user_name
-                                FROM contactdetails
-				inner join crmentity on crmentity.crmid=contactdetails.contactid
-                                LEFT JOIN users ON crmentity.smownerid=users.id
-                                LEFT JOIN account on contactdetails.accountid=account.accountid
-				left join contactaddress on contactaddress.contactaddressid=contactdetails.contactid
-			        left join contactscf on contactscf.contactid=contactdetails.contactid
-				where crmentity.deleted=0 and users.status='Active' ";
+                                vtiger_contactdetails.*, vtiger_contactaddress.*,
+                                vtiger_account.accountname vtiger_account_name,
+                                vtiger_users.user_name assigned_user_name
+                                FROM vtiger_contactdetails
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid
+                                LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id
+                                LEFT JOIN vtiger_account on vtiger_contactdetails.accountid=vtiger_account.accountid
+				left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid
+			        left join vtiger_contactscf on vtiger_contactscf.contactid=vtiger_contactdetails.contactid
+				where vtiger_crmentity.deleted=0 and vtiger_users.status='Active' ";
 		}
 		else
 		{
                   	 $query = "SELECT
-                                contactdetails.*, contactaddress.*,
-                                account.accountname account_name,
-                                users.user_name assigned_user_name
-                                FROM contactdetails
-                                inner join crmentity on crmentity.crmid=contactdetails.contactid
-                                LEFT JOIN users ON crmentity.smownerid=users.id
-                                LEFT JOIN account on contactdetails.accountid=account.accountid
-				left join contactaddress on contactaddress.contactaddressid=contactdetails.contactid
-			        left join contactscf on contactscf.contactid=contactdetails.contactid
-				where crmentity.deleted=0 and users.status='Active' ";
+                                vtiger_contactdetails.*, vtiger_contactaddress.*,
+                                vtiger_account.accountname vtiger_account_name,
+                                vtiger_users.user_name assigned_user_name
+                                FROM vtiger_contactdetails
+                                inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid
+                                LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id
+                                LEFT JOIN vtiger_account on vtiger_contactdetails.accountid=vtiger_account.accountid
+				left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid
+			        left join vtiger_contactscf on vtiger_contactscf.contactid=vtiger_contactdetails.contactid
+				where vtiger_crmentity.deleted=0 and vtiger_users.status='Active' ";
 		}
                  $log->info("Export Query Constructed Successfully");
 		$log->debug("Exiting create_export_query method ...");
@@ -528,7 +528,7 @@
 {
 	global $log;
 	$log->debug("Entering getColumnNames() method ...");
-	$sql1 = "select fieldlabel from field where tabid=4 and block <> 6 and block <> 75";
+	$sql1 = "select vtiger_fieldlabel from vtiger_field where vtiger_tabid=4 and block <> 6 and block <> 75";
 	$result = $this->db->query($sql1);
 	$numRows = $this->db->num_rows($result);
 	for($i=0; $i < $numRows;$i++)
@@ -548,16 +548,16 @@
 {
 	global $log;
 	$log->debug("Entering get_searchbyemailid(".$username.",".$emailaddress.") method ...");
-	$query = "select contactdetails.lastname as last_name,contactdetails.firstname as first_name,
-						contactdetails.contactid as id, contactdetails.salutation as salutation, 
-						contactdetails.email as email1,contactdetails.title as title,
-						contactdetails.mobile as phone_mobile,account.accountname as account_name,
-						account.accountid as account_id  from contactdetails 
-						inner join crmentity on crmentity.crmid=contactdetails.contactid 
-						inner join users on users.id=crmentity.smownerid  
-						left join account on account.accountid=contactdetails.accountid 
-						left join contactaddress on contactaddress.contactaddressid=contactdetails.contactid 
-						where user_name='" .$username ."' and crmentity.deleted=0  and contactdetails.email like '%".$emailaddress."%'";
+	$query = "select vtiger_contactdetails.lastname as last_name,vtiger_contactdetails.firstname as first_name,
+					vtiger_contactdetails.contactid as id, vtiger_contactdetails.salutation as salutation, 
+					vtiger_contactdetails.email as email1,vtiger_contactdetails.title as title,
+					vtiger_contactdetails.mobile as phone_mobile,vtiger_account.accountname as vtiger_account_name,
+					vtiger_account.accountid as vtiger_account_id  from vtiger_contactdetails 
+						inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid 
+						inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid  
+						left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid 
+						left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid 
+						where user_name='" .$username ."' and vtiger_crmentity.deleted=0  and vtiger_contactdetails.email like '%".$emailaddress."%'";
 						
 	$log->debug("Exiting get_searchbyemailid method ...");
 	return $this->process_list_query1($query);
@@ -567,27 +567,27 @@
 {
 	global $log;
 	$log->debug("Entering get_contactsforol(".$user_name.") method ...");
-	$query = "select contactdetails.department department, contactdetails.phone, 
-						contactdetails.fax, contactsubdetails.assistant assistant_name,
-						contactsubdetails.assistantphone,  
-						contactsubdetails.otherphone, contactsubdetails.homephone,
-						contactsubdetails.birthday birthdate, contactdetails.lastname last_name,
-						contactdetails.firstname first_name,contactdetails.contactid as id, 
-						contactdetails.salutation, contactdetails.email,
-						contactdetails.title,contactdetails.mobile,
-						account.accountname as account_name,account.accountid as account_id, 
-						contactaddress.mailingcity, contactaddress.mailingstreet, 
-						contactaddress.mailingcountry, contactaddress.mailingstate, 
-						contactaddress.mailingzip, contactaddress.othercity,
-						contactaddress.otherstreet, contactaddress.othercountry,
-						contactaddress.otherstate, contactaddress.otherzip   
-						from contactdetails 
-						inner join crmentity on crmentity.crmid=contactdetails.contactid 
-						inner join users on users.id=crmentity.smownerid 
-						left join account on account.accountid=contactdetails.accountid 
-						left join contactaddress on contactaddress.contactaddressid=contactdetails.contactid 
-						left join contactsubdetails on contactsubdetails.contactsubscriptionid = contactdetails.contactid 
-						where users.user_name='" .$user_name ."' and crmentity.deleted=0";
+	$query = "select vtiger_contactdetails.department department, vtiger_contactdetails.phone, 
+					vtiger_contactdetails.fax, vtiger_contactsubdetails.assistant assistant_name,
+					vtiger_contactsubdetails.assistantphone,  
+					vtiger_contactsubdetails.otherphone, vtiger_contactsubdetails.homephone,
+					vtiger_contactsubdetails.birthday birthdate, vtiger_contactdetails.lastname last_name,
+					vtiger_contactdetails.firstname first_name,vtiger_contactdetails.contactid as id, 
+					vtiger_contactdetails.salutation, vtiger_contactdetails.email,
+					vtiger_contactdetails.title,vtiger_contactdetails.mobile,
+					vtiger_account.accountname as vtiger_account_name,vtiger_account.accountid as vtiger_account_id, 
+					vtiger_contactaddress.mailingcity, vtiger_contactaddress.mailingstreet, 
+					vtiger_contactaddress.mailingcountry, vtiger_contactaddress.mailingstate, 
+					vtiger_contactaddress.mailingzip, vtiger_contactaddress.othercity,
+					vtiger_contactaddress.otherstreet, vtiger_contactaddress.othercountry,
+					vtiger_contactaddress.otherstate, vtiger_contactaddress.otherzip   
+						from vtiger_contactdetails 
+						inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid 
+						inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid 
+						left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid 
+						left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid 
+						left join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid 
+						where vtiger_users.user_name='" .$user_name ."' and vtiger_crmentity.deleted=0";
 						
 	$log->debug("Exiting get_contactsforol method ...");
 	return $query;

Modified: vtigercrm/trunk/modules/Contacts/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Contacts/EditView.php (original)
+++ vtigercrm/trunk/modules/Contacts/EditView.php Mon Jun 12 14:26:25 2006
@@ -105,7 +105,7 @@
 
 $smarty->assign("OP_MODE",$disp_view);
 
-//needed when creating a new contact with a default account value passed in
+//needed when creating a new contact with a default vtiger_account value passed in
 if (isset($_REQUEST['account_name']) && is_null($focus->account_name)) {
 	$focus->account_name = $_REQUEST['account_name'];
 	
@@ -147,7 +147,7 @@
 if(isset($_REQUEST['activity_mode']) && $_REQUEST['activity_mode'] !='')
         $smarty->assign("ACTIVITYMODE",$_REQUEST['activity_mode']);
 
-// Unimplemented until jscalendar language files are fixed
+// Unimplemented until jscalendar language vtiger_files are fixed
 $smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
 $smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
 

Modified: vtigercrm/trunk/modules/Contacts/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Contacts/Forms.php (original)
+++ vtigercrm/trunk/modules/Contacts/Forms.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 /*********************************************************************************
  * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Contacts/Forms.php,v 1.7 2005/03/04 15:18:47 jack Exp $
  * Description:  Contains a variety of utility functions used to display UI
- * components such as form headers and footers.  Intended to be modified on a per
+ * components such as form vtiger_headers and footers.  Intended to be modified on a per
  * theme basis.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
@@ -79,7 +79,7 @@
 }
 
 /**
- * Create HTML form to enter a new record with the minimum necessary fields.
+ * Create HTML form to enter a new record with the minimum necessary vtiger_fields.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
@@ -107,7 +107,7 @@
 $qcreate_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
 
 
-$qcreate_get_field="select * from field where tabid=4 and quickcreate=0 order by quickcreatesequence";
+$qcreate_get_field="select * from vtiger_field where vtiger_tabid=4 and quickcreate=0 order by quickcreatesequence";
 $qcreate_get_result=$adb->query($qcreate_get_field);
 $qcreate_get_noofrows=$adb->num_rows($qcreate_get_result);
 
@@ -196,9 +196,9 @@
 $qcreate_form.='</form>';
 $qcreate_form.='<script type="text/javascript">
 		
-	var fieldname = new Array('.$fieldName.')
-	var fieldlabel = new Array('.$fieldLabel.')
-	var fielddatatype = new Array('.$fldDataType.')
+	var vtiger_fieldname = new Array('.$fieldName.')
+	var vtiger_fieldlabel = new Array('.$fieldLabel.')
+	var vtiger_fielddatatype = new Array('.$fldDataType.')
 
 		</script>';
 

Modified: vtigercrm/trunk/modules/Contacts/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Contacts/ListView.php (original)
+++ vtigercrm/trunk/modules/Contacts/ListView.php Mon Jun 12 14:26:25 2006
@@ -79,7 +79,7 @@
 	$smarty->assign("SEARCH_URL",$url_string);
 				
 //Added for Custom Field Search
-/*$sql="select * from field where tablename='contactscf' order by fieldlabel";
+/*$sql="select * from vtiger_field where vtiger_tablename='contactscf' order by vtiger_fieldlabel";
 $result=$adb->query($sql);
 for($i=0;$i<$adb->num_rows($result);$i++)
 {
@@ -91,11 +91,11 @@
         if(isset($customfield[$i]) && $customfield[$i] != '')
         {
 		if($uitype[$i] == 56)
-			$str = " contactscf.".$column[$i]." = 1";
+			$str = " vtiger_contactscf.".$column[$i]." = 1";
 		elseif($uitype[$i] == 15)//Added to handle the picklist customfield - after 4.2 patch2 
-			$str = " contactscf.".$column[$i]." = '".$customfield[$i]."'";
+			$str = " vtiger_contactscf.".$column[$i]." = '".$customfield[$i]."'";
 		else
-	        	$str = " contactscf.".$column[$i]." like '$customfield[$i]%'";
+	        	$str = " vtiger_contactscf.".$column[$i]." like '$customfield[$i]%'";
                 array_push($where_clauses, $str);
 		$url_string .="&".$column[$i]."=".$customfield[$i];
         }

Modified: vtigercrm/trunk/modules/Contacts/Merge.php
==============================================================================
--- vtigercrm/trunk/modules/Contacts/Merge.php (original)
+++ vtigercrm/trunk/modules/Contacts/Merge.php Mon Jun 12 14:26:25 2006
@@ -42,7 +42,7 @@
 }
 //get the particular file from db and store it in the local hard disk.
 //store the path to the location where the file is stored and pass it  as parameter to the method 
-$sql = "select filename,data,filesize from wordtemplates where templateid=".$templateid;
+$sql = "select filename,data,filesize from vtiger_wordtemplates where templateid=".$templateid;
 
 $result = $adb->query($sql);
 $temparray = $adb->fetch_array($result);
@@ -77,7 +77,7 @@
 }
 
 //<<<<<<<<<<<<<<<<header for csv and select columns for query>>>>>>>>>>>>>>>>>>>>>>>>
-$query1="select tab.name,field.tablename,field.columnname,field.fieldlabel from field inner join tab on tab.tabid = field.tabid where field.tabid in (4,6) and field.block <> 6 and field.block <> 75 order by field.tablename";
+$query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (4,6) and vtiger_field.block <> 6 and vtiger_field.block <> 75 order by vtiger_field.tablename";
 
 $result = $adb->query($query1);
 $y=$adb->num_rows($result);
@@ -104,7 +104,7 @@
     }
 		if($modulename == "Contacts")
     {
-    	$querycolumns[$x]="concat(users.last_name,' ',users.first_name) as usercname,users.first_name,users.last_name,users.user_name,users.yahoo_id,users.title,users.phone_work,users.department,users.phone_mobile,users.phone_other,users.phone_fax,users.email1,users.phone_home,users.email2,users.address_street,users.address_city,users.address_state,users.address_postalcode,users.address_country";
+    	$querycolumns[$x]="concat(vtiger_users.last_name,' ',vtiger_users.first_name) as usercname,vtiger_users.first_name,vtiger_users.last_name,vtiger_users.user_name,vtiger_users.yahoo_id,vtiger_users.title,vtiger_users.phone_work,vtiger_users.department,vtiger_users.phone_mobile,vtiger_users.phone_other,vtiger_users.phone_fax,vtiger_users.email1,vtiger_users.phone_home,vtiger_users.email2,vtiger_users.address_street,vtiger_users.address_city,vtiger_users.address_state,vtiger_users.address_postalcode,vtiger_users.address_country";
     }
   }
 	if($columnname == "parentid")
@@ -146,22 +146,22 @@
 	$selectcolumns = implode($querycolumns,",");
 	
 
-$query = "select ".$selectcolumns." from contactdetails
-				inner join crmentity on crmentity.crmid = contactdetails.contactid 
-				inner join contactaddress on contactdetails.contactid = contactaddress.contactaddressid 
-				inner join contactsubdetails on contactdetails.contactid = contactsubdetails.contactsubscriptionid 
-				inner join contactscf on contactdetails.contactid = contactscf.contactid 
-				left join contactdetails as contactdetailsContacts on contactdetailsContacts.contactid = contactdetails.reportsto
-				left join account as accountContacts on accountContacts.accountid = contactdetails.accountid 
-				left join users on users.id = crmentity.smownerid
-				left join account on account.accountid = contactdetails.accountid
-				left join crmentity as crmentityAccounts on crmentityAccounts.crmid=account.accountid
-				left join accountbillads on account.accountid=accountbillads.accountaddressid
-				left join accountshipads on account.accountid=accountshipads.accountaddressid
-				left join accountscf on account.accountid = accountscf.accountid
-				left join account as accountAccounts on accountAccounts.accountid = account.parentid
-				left join users as usersAccounts on usersAccounts.id = crmentityAccounts.smownerid 
-				where crmentity.deleted=0 and (crmentityAccounts.deleted <> 1) and contactdetails.contactid in(".$mass_merge.")";
+$query = "select ".$selectcolumns." from vtiger_contactdetails
+				inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid 
+				inner join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid 
+				inner join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid 
+				inner join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid 
+				left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
+				left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid 
+				left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid
+				left join vtiger_account on vtiger_account.accountid = vtiger_contactdetails.accountid
+				left join vtiger_crmentity as vtiger_crmentityAccounts on vtiger_crmentityAccounts.crmid=vtiger_account.accountid
+				left join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid
+				left join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid
+				left join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid
+				left join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid
+				left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentityAccounts.smownerid 
+				where vtiger_crmentity.deleted=0 and (crmentityAccounts.deleted <> 1) and vtiger_contactdetails.contactid in(".$mass_merge.")";
 				
 
 $result = $adb->query($query);
@@ -197,7 +197,7 @@
 $csvdata = implode($mergevalue,"###");
 }else
 {
-	die("No fields to do Merge");
+	die("No vtiger_fields to do Merge");
 }	
 
 $handle = fopen($wordtemplatedownloadpath."datasrc.csv","wb");

Modified: vtigercrm/trunk/modules/Contacts/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Contacts/Save.php (original)
+++ vtigercrm/trunk/modules/Contacts/Save.php Mon Jun 12 14:26:25 2006
@@ -84,7 +84,7 @@
         {
                 if(isset($_REQUEST[$fieldname]))
                 {
-			$log->debug("Assigning the previous values given for the contact to respective fields ");
+			$log->debug("Assigning the previous values given for the contact to respective vtiger_fields ");
                         $field_values_passed.="&";
                         $value = $_REQUEST[$fieldname];
                         $focus->column_fields[$fieldname] = $value;
@@ -113,7 +113,7 @@
 if($saveimage=="true")
 {
         $focus->column_fields['imagename']=$image_name_val;
-        $log->debug("Assign the Image name to the field name ");
+        $log->debug("Assign the Image name to the vtiger_field name ");
 }
 //Saving the contact
 if($image_error=="false")
@@ -134,7 +134,7 @@
 	//BEGIN -- Code for Create Customer Portal Users password and Send Mail 
 	if($_REQUEST['portal'] == '' && $_REQUEST['mode'] == 'edit')
 	{
-		$sql = "update portalinfo set user_name='".$_REQUEST['email']."',isactive=0 where id=".$_REQUEST['record'];
+		$sql = "update vtiger_portalinfo set user_name='".$_REQUEST['email']."',isactive=0 where id=".$_REQUEST['record'];
 		$adb->query($sql);
 	}
 	elseif($_REQUEST['portal'] != '' && $_REQUEST['email'] != '')// && $_REQUEST['mode'] != 'edit')
@@ -145,7 +145,7 @@
 		if($_REQUEST['mode'] != 'edit')
 			$insert = 'true';
 
-		$sql = "select id,user_name,user_password,isactive from portalinfo";
+		$sql = "select id,user_name,user_password,isactive from vtiger_portalinfo";
 		$result = $adb->query($sql);
 
 		for($i=0;$i<$adb->num_rows($result);$i++)
@@ -159,7 +159,7 @@
 					$flag = 'true';
 				else
 				{
-					$sql = "update portalinfo set user_name='".$username."', isactive=1 where id=".$id;
+					$sql = "update vtiger_portalinfo set user_name='".$username."', isactive=1 where id=".$id;
 					$adb->query($sql);
 					$update = 'true';
 					$flag = 'true';
@@ -175,7 +175,7 @@
 		if($insert == 'true')
 		{
 			$password = makeRandomPassword();
-			$sql = "insert into portalinfo (id,user_name,user_password,type,isactive) values(".$focus->id.",'".$username."','".$password."','C',1)";
+			$sql = "insert into vtiger_portalinfo (id,user_name,user_password,type,isactive) values(".$focus->id.",'".$username."','".$password."','C',1)";
 			$adb->query($sql);
 		}
 

Modified: vtigercrm/trunk/modules/Contacts/chat.php
==============================================================================
--- vtigercrm/trunk/modules/Contacts/chat.php (original)
+++ vtigercrm/trunk/modules/Contacts/chat.php Mon Jun 12 14:26:25 2006
@@ -32,7 +32,7 @@
  * Constants for the chat
  */
 $chat_conf = array();
-$chat_conf['alive_time'] = "30"; // time users should report to be online, in seconds.
+$chat_conf['alive_time'] = "30"; // time vtiger_users should vtiger_report to be online, in seconds.
 $chat_conf['msg_limit'] = "10"; // maximum msg's to send in one request.
 
 /*************************************************************/
@@ -68,7 +68,7 @@
     // las message id received by user
     if(!isset($_SESSION["mlid"]))
       {
-	$res = $adb->query("SELECT max(id) AS id FROM chat_msg");
+	$res = $adb->query("SELECT max(id) AS id FROM vtiger_chat_msg");
 	$line = $adb->fetch_array($res);
 	if(intval($line['id']) == 0)
 	  $_SESSION["mlid"] = 0;
@@ -89,7 +89,7 @@
       }
     else
       {
-	      $res = $adb->query("UPDATE chat_users SET ping = ".$adb->database->sysTimeStamp." WHERE session = '".session_id()."'");
+	      $res = $adb->query("UPDATE vtiger_chat_users SET ping = ".$adb->database->sysTimeStamp." WHERE session = '".session_id()."'");
 	if($adb->getAffectedRowCount($res) == 0)
 	  {
 	    $this->setUserNick();
@@ -164,7 +164,7 @@
   {
 	global $current_user;	
 	global $adb;
-    $res = $adb->query("SELECT id FROM chat_users WHERE session = '".session_id()."'");
+    $res = $adb->query("SELECT id FROM vtiger_chat_users WHERE session = '".session_id()."'");
     if($adb->num_rows($res) > 0)
       {
 	$line = $adb->fetch_array($res);
@@ -174,7 +174,7 @@
     
     $_SESSION['chat_user'] = $adb->getUniqueID('chat_users');
     
-    $res = $adb->query("INSERT INTO chat_users (id, nick, session, ping, ip)
+    $res = $adb->query("INSERT INTO vtiger_chat_users (id, nick, session, ping, ip)
    			 VALUES ('".$_SESSION['chat_user']."',
 			 	'".$current_user->user_name."',
 				 '".session_id()."',
@@ -186,7 +186,7 @@
   }
   
   /**
-   * generate the available users list
+   * generate the available vtiger_users list
    */
   function getUserList()
   {
@@ -194,9 +194,9 @@
     global $chat_conf;
     $tmp = '';
     $delete_from = time() - $chat_conf['alive_time'];
-    $res = $adb->query("DELETE FROM chat_users
+    $res = $adb->query("DELETE FROM vtiger_chat_users
     			WHERE ping > ".$adb->formatDate($delete_from));
-    $res = $adb->query("SELECT id, nick FROM chat_users");
+    $res = $adb->query("SELECT id, nick FROM vtiger_chat_users");
     if($adb->num_rows($res)==0)
       {
 	$this->json = '';
@@ -232,10 +232,10 @@
     $res = $adb->limitQuery("SELECT ms.id AS mid, ms.chat_from AS mfrom,
    				 ms.chat_to AS mto,pv.id AS id,
 				 us.nick AS nfrom, ms.msg AS msg
-			FROM chat_users us
-			INNER JOIN chat_msg ms
+			FROM vtiger_chat_users us
+			INNER JOIN vtiger_chat_msg ms
 				ON us.id = ms.chat_from
-			INNER JOIN chat_pvchat pv
+			INNER JOIN vtiger_chat_pvchat pv
 				ON pv.msg = ms.id
 			WHERE ms.id > '".($_SESSION['mlid'])."'
 			AND (ms.chat_from = '".$_SESSION['chat_user']."'
@@ -277,10 +277,10 @@
     $res = $adb->limitQuery("SELECT ms.id AS mid, ms.chat_from AS mfrom,
     				ms.chat_to AS mto, p.id AS id,
 				us.nick AS nfrom, ms.msg AS msg
-			FROM chat_users us
-			INNER JOIN chat_msg ms
+			FROM vtiger_chat_users us
+			INNER JOIN vtiger_chat_msg ms
 				ON us.id = ms.chat_from
-			INNER JOIN chat_pchat p
+			INNER JOIN vtiger_chat_pchat p
 				ON p.msg = ms.id
 			WHERE ms.id > '".($_SESSION['mlid'])."'
 			AND ms.chat_to = 0
@@ -319,10 +319,10 @@
 	    if(isset($words[1]) && strlen($words[1]) > 3)
 	      {
 		$res = $adb->query("SELECT nick
-				FROM chat_users
+				FROM vtiger_chat_users
 				WHERE id= '".$_SESSION['chat_user']."'");
 		$line = $adb->fetch_array($res);
-		$res = $adb->query("UPDATE chat_users
+		$res = $adb->query("UPDATE vtiger_chat_users
 				SET nick = ".$adb->quote($words[1])."
 				WHERE id = '".$_SESSION['chat_user']."'");
 		$msg = '\sys <span class="sysb">'.$line['nick'].'</span> changed nick to <span class="sysb">'.$words[1].'</span>';
@@ -347,7 +347,7 @@
     if(strlen($msg) == 0) return;
     
     $id = $adb->getUniqueID('chat_msg');
-    $res = $adb->query("INSERT INTO chat_msg (id, chat_from, chat_to, born, msg)
+    $res = $adb->query("INSERT INTO vtiger_chat_msg (id, chat_from, chat_to, born, msg)
     			VALUES (".$id.", '".$_SESSION['chat_user']."', '".$to."', ".$adb->database->sysTimeStamp.", '".$msg."')");
     
     $chat = "p";
@@ -363,7 +363,7 @@
   function pvClose($to)
   {
 	global $adb;
-    $res = $adb->query("DELETE FROM chat_msg
+    $res = $adb->query("DELETE FROM vtiger_chat_msg
    			 WHERE (chat_from = '".$to."'
 				 AND chat_to = '".$_SESSION['chat_user']."')
 			 OR (chat_from = '".$_SESSION['chat_user']."'

Modified: vtigercrm/trunk/modules/Contacts/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Contacts/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Contacts/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -52,8 +52,8 @@
 	
 'LBL_EXISTING_CONTACT' => 'Used an existing contact',
 'LBL_CREATED_CONTACT' => 'Created a new contact',
-'LBL_EXISTING_ACCOUNT' => 'Used an existing account',
-'LBL_CREATED_ACCOUNT' => 'Created a new account',
+'LBL_EXISTING_ACCOUNT' => 'Used an existing vtiger_account',
+'LBL_CREATED_ACCOUNT' => 'Created a new vtiger_account',
 'LBL_CREATED_CALL' => 'Created a new call',
 'LBL_CREATED_MEETING' => 'Created a new meeting',
 'LBL_ADDMORE_BUSINESSCARD' =>'Add another business card',
@@ -102,13 +102,13 @@
 'LBL_CONTACT_ROLE'=>'Role:',
 'LBL_OPP_NAME'=>'Opportunity Name:',
 'LBL_DUPLICATE'=>'Potential Duplicate Contacts',
-'MSG_DUPLICATE' => 'Creating this contact may potentialy create a duplicate contact. You may either select a contact from the list below or you may click on Create New Contact to continue creating a new contact with the previously entered data.',
+'MSG_DUPLICATE' => 'Creating this contact may vtiger_potentialy create a duplicate contact. You may either select a contact from the list below or you may click on Create New Contact to continue creating a new contact with the previously entered data.',
 
 'LNK_NEW_APPOINTMENT' => 'New Appointment',
 'LBL_ADD_BUSINESSCARD' => 'Add Business Card',
 'NTC_DELETE_CONFIRMATION'=>'Are you sure you want to delete this record?',
 'NTC_REMOVE_CONFIRMATION'=>'Are you sure you want to remove this contact from this case?',
-'NTC_REMOVE_DIRECT_REPORT_CONFIRMATION'=>'Are you sure you want to remove this record as a direct report?',
+'NTC_REMOVE_DIRECT_REPORT_CONFIRMATION'=>'Are you sure you want to remove this record as a direct vtiger_report?',
 'ERR_DELETE_RECORD'=>"en_us A record number must be specified to delete the contact.",
 'NTC_COPY_PRIMARY_ADDRESS'=>'Copy primary address to alternate address',
 'NTC_COPY_ALTERNATE_ADDRESS'=>'Copy alternate address to primary address',
@@ -176,7 +176,7 @@
 'Contact Image'=>'Contact Image',
 'Description'=>'Description',
 
-// Added fields for Add Business Card
+// Added vtiger_fields for Add Business Card
 'LBL_NEW_CONTACT'=>'New Contact',
 'LBL_NEW_ACCOUNT'=>'New Account',
 'LBL_NOTE_SUBJECT'=>'Note Subject:',
@@ -187,7 +187,7 @@
 'LBL_START_DATE'=>'Start Date:',
 'LBL_START_TIME'=>'Start Time:',
 
-//Added field after 4_0_1
+//Added vtiger_field after 4_0_1
 'Portal User'=>'Portal User',
 'LBL_CUSTOMER_PORTAL_INFORMATION'=>'Customer Portal Information',
 'Support Start Date'=>'Support Start Date',
@@ -195,7 +195,7 @@
 //Added for 4.2 Release -- CustomView
 'Name'=>'Name',
 'LBL_ALL'=>'All',
-'LBL_MAXIMUM_LIMIT_ERROR'=>'Sorry, the uploaded file exceeds the maximum filesize limit. Please try a file smaller than 800000 bytes',
+'LBL_MAXIMUM_LIMIT_ERROR'=>'Sorry, the uploaded file exceeds the maximum vtiger_filesize limit. Please try a file smaller than 800000 bytes',
 'LBL_UPLOAD_ERROR'=>'Problems in file upload. Please try again!',
 'LBL_IMAGE_ERROR'=>'The given file is not of type image(.gif/.jpg/.png)',
 'LBL_INVALID_IMAGE'=>'Invalid file OR File has no data',

Modified: vtigercrm/trunk/modules/CustomView/CustomView.php
==============================================================================
--- vtigercrm/trunk/modules/CustomView/CustomView.php (original)
+++ vtigercrm/trunk/modules/CustomView/CustomView.php Mon Jun 12 14:26:25 2006
@@ -94,7 +94,7 @@
 				$viewid = $this->setdefaultviewid;
 			}else
 			{
-				$query="select cvid from customview where viewname='All' and entitytype='".$module."'";
+				$query="select cvid from vtiger_customview where viewname='All' and entitytype='".$module."'";
 				$cvresult=$adb->query($query);
 				$viewid = $adb->query_result($cvresult,0,'cvid');;
 			}
@@ -133,14 +133,14 @@
 		return $groupid;
 	}
 
-	// to get the available customviews for a module
+	// to get the available vtiger_customviews for a module
 	// return type array
 	function getCustomViewByCvid($cvid)
 	{
 		global $adb;
 		$tabid = getTabid($this->customviewmodule);
-		$ssql = "select customview.* from customview inner join tab on tab.name = customview.entitytype";
-		$ssql .= " where customview.cvid=".$cvid;		
+		$ssql = "select vtiger_customview.* from vtiger_customview inner join vtiger_tab on vtiger_tab.name = vtiger_customview.entitytype";
+		$ssql .= " where vtiger_customview.cvid=".$cvid;		
 
 		$result = $adb->query($ssql);
 
@@ -157,8 +157,8 @@
 		global $adb;
 		global $app_strings;
 		$tabid = getTabid($this->customviewmodule);
-		$ssql = "select customview.* from customview inner join tab on tab.name = customview.entitytype";
-		$ssql .= " where tab.tabid=".$tabid;
+		$ssql = "select vtiger_customview.* from vtiger_customview inner join vtiger_tab on vtiger_tab.name = vtiger_customview.entitytype";
+		$ssql .= " where vtiger_tab.tabid=".$tabid;
 		$result = $adb->query($ssql);
 		while($cvrow=$adb->fetch_array($result))
 		{
@@ -188,18 +188,18 @@
 
 		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
 		{
-			$sql = "select * from field ";
-			$sql.= " where field.tabid=".$tabid." and field.block in (".$block.") and";
-			$sql.= " field.displaytype in (1,2)";
+			$sql = "select * from vtiger_field ";
+			$sql.= " where vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$block.") and";
+			$sql.= " vtiger_field.displaytype in (1,2)";
 			$sql.= " order by sequence";
 		}
 		else
 		{
 			$profileList = getCurrentUserProfileList();
-			$sql = "select * from field inner join profile2field on profile2field.fieldid=field.fieldid inner join def_org_field on def_org_field.fieldid=field.fieldid ";
-			$sql.= " where field.tabid=".$tabid." and field.block in (".$block.") and";
-			$sql.= " field.displaytype in (1,2) and profile2field.visible=0";
-			$sql.= " and def_org_field.visible=0  and profile2field.profileid in ".$profileList." order by sequence";
+			$sql = "select * from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid ";
+			$sql.= " where vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$block.") and";
+			$sql.= " vtiger_field.displaytype in (1,2) and vtiger_profile2field.visible=0";
+			$sql.= " and vtiger_def_org_field.visible=0  and vtiger_profile2field.profileid in ".$profileList." order by sequence";
 		}	
 
 
@@ -211,7 +211,7 @@
 		{
 			$module_columnlist['crmentity:crmid::HelpDesk_Ticket ID:I'] = 'Ticket ID';
 		}
-		//Added to include activity type in activity customview list
+		//Added to include vtiger_activity type in vtiger_activity vtiger_customview list
 		if($module == 'Activities' && $block == 19)
 		{
 			$module_columnlist['activity:activitytype:activitytype:Activities_Activity Type:C'] = 'Activity Type';
@@ -266,9 +266,9 @@
 	{
 		global $adb;
 		
-		$sSQL = "select cvcolumnlist.* from cvcolumnlist";
-		$sSQL .= " inner join customview on customview.cvid = cvcolumnlist.cvid";
-		$sSQL .= " where customview.cvid =".$cvid." order by cvcolumnlist.columnindex";
+		$sSQL = "select vtiger_cvcolumnlist.* from vtiger_cvcolumnlist";
+		$sSQL .= " inner join vtiger_customview on vtiger_customview.cvid = vtiger_cvcolumnlist.cvid";
+		$sSQL .= " where vtiger_customview.cvid =".$cvid." order by vtiger_cvcolumnlist.columnindex";
 		$result = $adb->query($sSQL);
 		
 		while($columnrow = $adb->fetch_array($result))
@@ -297,18 +297,18 @@
 
 		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
 		{
-			$sql = "select * from field inner join tab on tab.tabid = field.tabid ";
-			$sql.= " where field.tabid=".$tabid." and field.block in (".$blockids.")
-                        and (field.uitype =5 or field.displaytype=2) ";
-			$sql.= " order by field.sequence";
+			$sql = "select * from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid ";
+			$sql.= " where vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$blockids.")
+                        and (vtiger_field.uitype =5 or vtiger_field.displaytype=2) ";
+			$sql.= " order by vtiger_field.sequence";
 		}
 		else
 		{
 			$profileList = getCurrentUserProfileList();
-			$sql = "select * from field inner join tab on tab.tabid = field.tabid inner join  profile2field on profile2field.fieldid=field.fieldid inner join def_org_field on def_org_field.fieldid=field.fieldid ";
-			$sql.= " where field.tabid=".$tabid." and field.block in (".$blockids.") and (field.uitype =5 or field.displaytype=2)";
-			$sql.= " and profile2field.visible=0";
-			$sql.= " and def_org_field.visible=0  and profile2field.profileid in ".$profileList." order by field.sequence";
+			$sql = "select * from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid inner join  vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid ";
+			$sql.= " where vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$blockids.") and (vtiger_field.uitype =5 or vtiger_field.displaytype=2)";
+			$sql.= " and vtiger_profile2field.visible=0";
+			$sql.= " and vtiger_def_org_field.visible=0  and vtiger_profile2field.profileid in ".$profileList." order by vtiger_field.sequence";
 		}			
 
 
@@ -609,8 +609,8 @@
 	{
 		global $adb;
 
-		$sSQL = "select cvstdfilter.* from cvstdfilter inner join customview on customview.cvid = cvstdfilter.cvid";
-		$sSQL .= " where cvstdfilter.cvid=".$cvid;
+		$sSQL = "select vtiger_cvstdfilter.* from vtiger_cvstdfilter inner join vtiger_customview on vtiger_customview.cvid = vtiger_cvstdfilter.cvid";
+		$sSQL .= " where vtiger_cvstdfilter.cvid=".$cvid;
 
 		$result = $adb->query($sSQL);
 		$stdfilterrow = $adb->fetch_array($result);
@@ -644,8 +644,8 @@
 		global $adb;
 		global $modules;
 
-		$sSQL = "select cvadvfilter.* from cvadvfilter inner join customview on cvadvfilter.cvid = customview.cvid";
-		$sSQL .= " where cvadvfilter.cvid=".$cvid;
+		$sSQL = "select vtiger_cvadvfilter.* from vtiger_cvadvfilter inner join vtiger_customview on vtiger_cvadvfilter.cvid = vtiger_customview.cvid";
+		$sSQL .= " where vtiger_cvadvfilter.cvid=".$cvid;
 		$result = $adb->query($sSQL);
 
 		while($advfilterrow = $adb->fetch_array($result))
@@ -678,7 +678,7 @@
 					{
 						if($list[1] == "status")
 						{
-							$sqllist_column = "case when (activity.status not like '') then activity.status else activity.eventstatus end as activitystatus";
+							$sqllist_column = "case when (vtiger_activity.status not like '') then vtiger_activity.status else vtiger_activity.eventstatus end as vtiger_activitystatus";
 						}
 					}
 					$sqllist[] = $sqllist_column;
@@ -756,10 +756,10 @@
 							$advfiltersql[] = " (".$advorsqls.") ";
 						}else
 						{
-							//Added for getting activity Status -Jaguar
+							//Added for getting vtiger_activity Status -Jaguar
 							if($this->customviewmodule == "Activities" && $columns[1] == "status")
 							{
-								$advfiltersql[] = "case when (activity.status not like '') then activity.status else activity.eventstatus end".$this->getAdvComparator($advfltrow["comparator"],trim($advfltrow["value"]));
+								$advfiltersql[] = "case when (vtiger_activity.status not like '') then vtiger_activity.status else vtiger_activity.eventstatus end".$this->getAdvComparator($advfltrow["comparator"],trim($advfltrow["value"]));
 							}
 							else
 							{
@@ -833,7 +833,7 @@
                 global $log;
                 $log->info("in getSalesEntityId ".$setype);
 		global $adb;
-		$sql = "select crmid from crmentity where setype='".$setype."' and deleted = 0";
+		$sql = "select crmid from vtiger_crmentity where setype='".$setype."' and deleted = 0";
 		$result = $adb->query($sql);
 		while($row = $adb->fetch_array($result))
 		{
@@ -856,7 +856,7 @@
 		global $adb;
 		if($so_name != '')
 		{
-			$sql = "select salesorderid from salesorder where subject='".$so_name."'";
+			$sql = "select vtiger_salesorderid from vtiger_salesorder where subject='".$so_name."'";
 			$result = $adb->query($sql);
 			$so_id = $adb->query_result($result,0,"salesorderid");
 		}
@@ -870,7 +870,7 @@
 		global $adb;
 		if($product_name != '')
 		{
-			$sql = "select productid from products where productname='".$product_name."'";
+			$sql = "select productid from vtiger_products where productname='".$product_name."'";
 			$result = $adb->query($sql);
 			$productid = $adb->query_result($result,0,"productid");
 		}
@@ -884,7 +884,7 @@
 		global $adb;
 		if($quote_name != '')
 		{
-			$sql = "select quoteid from quotes where subject='".$quote_name."'";
+			$sql = "select quoteid from vtiger_quotes where subject='".$quote_name."'";
 			$result = $adb->query($sql);
 			$quote_id = $adb->query_result($result,0,"quoteid");
 		}
@@ -898,7 +898,7 @@
 		global $adb;
 		if($pot_name != '')
 		{
-			$sql = "select potentialid from potential where potentialname='".$pot_name."'";
+			$sql = "select vtiger_potentialid from vtiger_potential where vtiger_potentialname='".$pot_name."'";
 			$result = $adb->query($sql);
 			$potentialid = $adb->query_result($result,0,"potentialid");
 		}
@@ -911,7 +911,7 @@
 		global $adb;
 		if($vendor_name != '')
 		{
-			$sql = "select vendorid from vendor where vendorname='".$vendor_name."'";
+			$sql = "select vtiger_vendorid from vtiger_vendor where vtiger_vendorname='".$vendor_name."'";
 			$result = $adb->query($sql);
 			$vendor_id = $adb->query_result($result,0,"vendorid");
 		}
@@ -925,7 +925,7 @@
 		global $adb;
 		if($contact_name != '')
 		{
-			$sql = "select contactid from contactdetails where lastname='".$contact_name."'";
+			$sql = "select contactid from vtiger_contactdetails where lastname='".$contact_name."'";
 			$result = $adb->query($sql);
 			$contact_id = $adb->query_result($result,0,"contactid");
 		}
@@ -939,7 +939,7 @@
 		global $adb;
 		if($account_name != '')
 		{
-			$sql = "select accountid from account where accountname='".$account_name."'";
+			$sql = "select vtiger_accountid from vtiger_account where vtiger_accountname='".$account_name."'";
 			$result = $adb->query($sql);
 			$accountid = $adb->query_result($result,0,"accountid");
 		}		
@@ -1235,26 +1235,26 @@
 			$listviewquery = substr($listquery, strpos($listquery,'FROM'),strlen($listquery));
 			if($module == "Activities" || $module == "Emails")
 			{
-				$query = "select groups.groupname ,users.user_name,".$this->getCvColumnListSQL($viewid)." ,crmentity.crmid,activity.* ".$listviewquery;
+				$query = "select vtiger_groups.groupname ,vtiger_users.user_name,".$this->getCvColumnListSQL($viewid)." ,vtiger_crmentity.crmid,vtiger_activity.* ".$listviewquery;
 			}else if($module == "Notes")
 			{
-				$query = "select ".$this->getCvColumnListSQL($viewid)." ,crmentity.crmid,notes.* ".$listviewquery;
+				$query = "select ".$this->getCvColumnListSQL($viewid)." ,vtiger_crmentity.crmid,vtiger_notes.* ".$listviewquery;
 			}
 			else if($module == "Products")
 			{
-				$query = "select ".$this->getCvColumnListSQL($viewid)." ,crmentity.crmid,products.* ".$listviewquery;
+				$query = "select ".$this->getCvColumnListSQL($viewid)." ,vtiger_crmentity.crmid,vtiger_products.* ".$listviewquery;
 			}
 			else if($module == "Vendors")
 			{
-				$query = "select ".$this->getCvColumnListSQL($viewid)." ,crmentity.crmid ".$listviewquery;
+				$query = "select ".$this->getCvColumnListSQL($viewid)." ,vtiger_crmentity.crmid ".$listviewquery;
 			}
 			else if($module == "PriceBooks")
 			{
-				$query = "select ".$this->getCvColumnListSQL($viewid)." ,crmentity.crmid ".$listviewquery;
+				$query = "select ".$this->getCvColumnListSQL($viewid)." ,vtiger_crmentity.crmid ".$listviewquery;
 			}
 			else
 			{
-				$query = "select groups.groupname ,users.user_name,".$this->getCvColumnListSQL($viewid)." ,crmentity.crmid ".$listviewquery;
+				$query = "select vtiger_groups.groupname ,vtiger_users.user_name,".$this->getCvColumnListSQL($viewid)." ,vtiger_crmentity.crmid ".$listviewquery;
 			}
 			$stdfiltersql = $this->getCVStdFilterSQL($viewid);
 			$advfiltersql = $this->getCVAdvFilterSQL($viewid);
@@ -1299,8 +1299,8 @@
 	{
 		global $adb;
 
-		$sSQL = "select customaction.* from customaction inner join customview on customaction.cvid = customview.cvid";
-		$sSQL .= " where customaction.cvid=".$cvid;
+		$sSQL = "select vtiger_customaction.* from vtiger_customaction inner join vtiger_customview on vtiger_customaction.cvid = vtiger_customview.cvid";
+		$sSQL .= " where vtiger_customaction.cvid=".$cvid;
 		$result = $adb->query($sSQL);
 
 		while($carow = $adb->fetch_array($result))

Modified: vtigercrm/trunk/modules/CustomView/Delete.php
==============================================================================
--- vtigercrm/trunk/modules/CustomView/Delete.php (original)
+++ vtigercrm/trunk/modules/CustomView/Delete.php Mon Jun 12 14:26:25 2006
@@ -19,7 +19,7 @@
 
 if(isset($cvid) && $cvid != '')
 {
-	$deletesql = "delete from customview where cvid =".$cvid;
+	$deletesql = "delete from vtiger_customview where cvid =".$cvid;
 	$deleteresult = $adb->query($deletesql);
 	$_SESSION['lvs'][$module]["viewname"] = '';
 }

Modified: vtigercrm/trunk/modules/CustomView/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/CustomView/Forms.php (original)
+++ vtigercrm/trunk/modules/CustomView/Forms.php Mon Jun 12 14:26:25 2006
@@ -50,7 +50,7 @@
 			}
 			if ( hash[ form.elements[i].value ] == 1)
 			{
-				// got same field more than once
+				// got same vtiger_field more than once
 				isError = true;
 			}
 			hash[form.elements[i].value] = 1;
@@ -69,7 +69,7 @@
 		return false;
 	}
 
-	for(var field_name in required)
+	for(var vtiger_field_name in required)
 	{
 		// contacts hack to bypass errors if full_name is set
 		if (field_name == 'last_name' && 
@@ -77,7 +77,7 @@
 		{
 			continue;
 		}
-		if ( hash[ field_name ] != 1 )
+		if ( hash[ vtiger_field_name ] != 1 )
 		{
 				isError = true;
 				errorMessage += "$err_required " + required[field_name];

Modified: vtigercrm/trunk/modules/CustomView/ListViewTop.php
==============================================================================
--- vtigercrm/trunk/modules/CustomView/ListViewTop.php (original)
+++ vtigercrm/trunk/modules/CustomView/ListViewTop.php Mon Jun 12 14:26:25 2006
@@ -92,8 +92,8 @@
 function getMetricList()
 {
 	global $adb;
-	$ssql = "select customview.* from customview inner join tab on tab.name = customview.entitytype";
-	$ssql .= " where customview.setmetrics = 1 order by customview.entitytype";
+	$ssql = "select vtiger_customview.* from vtiger_customview inner join vtiger_tab on vtiger_tab.name = vtiger_customview.entitytype";
+	$ssql .= " where vtiger_customview.setmetrics = 1 order by vtiger_customview.entitytype";
 	$result = $adb->query($ssql);
 	while($cvrow=$adb->fetch_array($result))
 	{

Modified: vtigercrm/trunk/modules/CustomView/PopulateCustomView.php
==============================================================================
--- vtigercrm/trunk/modules/CustomView/PopulateCustomView.php (original)
+++ vtigercrm/trunk/modules/CustomView/PopulateCustomView.php Mon Jun 12 14:26:25 2006
@@ -133,199 +133,199 @@
 		    );
 
 
-$cvcolumns = Array(Array('leaddetails:lastname:lastname:Leads_Last_Name:V',
-                         'leaddetails:firstname:firstname:Leads_First_Name:V',
-                         'leaddetails:company:company:Leads_Company:V',
-			 'leadaddress:phone:phone:Leads_Phone:V',
-                         'leadsubdetails:website:website:Leads_Website:V',
-                         'leaddetails:email:email:Leads_Email:E',
-			 'crmentity:smownerid:assigned_user_id:Leads_Assigned_To:V'),
-
-	           Array('leaddetails:firstname:firstname:Leads_First_Name:V',
-                         'leaddetails:lastname:lastname:Leads_Last_Name:V',
-                         'leaddetails:company:company:Leads_Company:V',
-                         'leaddetails:leadsource:leadsource:Leads_Lead_Source:V',
-                         'leadsubdetails:website:website:Leads_Website:V',
-                         'leaddetails:email:email:Leads_Email:E'),
-
-		   Array('leaddetails:firstname:firstname:Leads_First_Name:V',
-                         'leaddetails:lastname:lastname:Leads_Last_Name:V',
-                         'leaddetails:company:company:Leads_Company:V',
-                         'leaddetails:leadsource:leadsource:Leads_Lead_Source:V',
-                         'leadsubdetails:website:website:Leads_Website:V',
-                         'leaddetails:email:email:Leads_Email:E'),
+$cvcolumns = Array(Array('vtiger_leaddetails:lastname:lastname:Leads_Last_Name:V',
+                         'vtiger_leaddetails:firstname:firstname:Leads_First_Name:V',
+                         'vtiger_leaddetails:company:company:Leads_Company:V',
+			 'vtiger_leadaddress:phone:phone:Leads_Phone:V',
+                         'vtiger_leadsubdetails:website:website:Leads_Website:V',
+                         'vtiger_leaddetails:email:email:Leads_Email:E',
+			 'vtiger_crmentity:smownerid:assigned_user_id:Leads_Assigned_To:V'),
+
+	           Array('vtiger_leaddetails:firstname:firstname:Leads_First_Name:V',
+                         'vtiger_leaddetails:lastname:lastname:Leads_Last_Name:V',
+                         'vtiger_leaddetails:company:company:Leads_Company:V',
+                         'vtiger_leaddetails:leadsource:leadsource:Leads_Lead_Source:V',
+                         'vtiger_leadsubdetails:website:website:Leads_Website:V',
+                         'vtiger_leaddetails:email:email:Leads_Email:E'),
+
+		   Array('vtiger_leaddetails:firstname:firstname:Leads_First_Name:V',
+                         'vtiger_leaddetails:lastname:lastname:Leads_Last_Name:V',
+                         'vtiger_leaddetails:company:company:Leads_Company:V',
+                         'vtiger_leaddetails:leadsource:leadsource:Leads_Lead_Source:V',
+                         'vtiger_leadsubdetails:website:website:Leads_Website:V',
+                         'vtiger_leaddetails:email:email:Leads_Email:E'),
 	
-		   Array('account:accountname:accountname:Accounts_Account_Name:V',
-                         'accountbillads:city:bill_city:Accounts_City:V',
-                         'account:website:website:Accounts_Website:V',
-                         'account:phone:phone:Accounts_Phone:V',
-                         'crmentity:smownerid:assigned_user_id:Accounts_Assigned_To:V'),
-
-		   Array('account:accountname:accountname:Accounts_Account_Name:V',
-			 'account:phone:phone:Accounts_Phone:V',
-			 'account:website:website:Accounts_Website:V',
-			 'account:rating:rating:Accounts_Rating:V',
-			 'crmentity:smownerid:assigned_user_id:Accounts_Assigned_To:V'),
-
-		   Array('account:accountname:accountname:Accounts_Account_Name:V',
-                         'account:phone:phone:Accounts_Phone:V',
-                         'account:website:website:Accounts_Website:V',
-                         'accountbillads:city:bill_city:Accounts_City:V',
-                         'crmentity:smownerid:assigned_user_id:Accounts_Assigned_To:V'),
-
-		   Array('contactdetails:firstname:firstname:Contacts_First_Name:V',
-                         'contactdetails:lastname:lastname:Contacts_Last_Name:V',
-                         'contactdetails:title:title:Contacts_Title:V',
-                         'contactdetails:accountid:account_id:Contacts_Account_Name:I',
-                         'contactdetails:email:email:Contacts_Email:E',
-                         'contactdetails:phone:phone:Contacts_Office_Phone:V',
-			 'crmentity:smownerid:assigned_user_id:Contacts_Assigned_To:V'),
-
-		   Array('contactdetails:firstname:firstname:Contacts_First_Name:V',
-                         'contactdetails:lastname:lastname:Contacts_Last_Name:V',
-                         'contactaddress:mailingstreet:mailingstreet:Contacts_Mailing_Street:V',
-                         'contactaddress:mailingcity:mailingcity:Contacts_City:V',
-                         'contactaddress:mailingstate:mailingstate:Contacts_State:V',
-			 'contactaddress:mailingzip:mailingzip:Contacts_Zip:V',
-			 'contactaddress:mailingcountry:mailingcountry:Contacts_Country:V'),
+		   Array('vtiger_account:accountname:accountname:Accounts_Account_Name:V',
+                         'vtiger_accountbillads:city:bill_city:Accounts_City:V',
+                         'vtiger_account:website:website:Accounts_Website:V',
+                         'vtiger_account:phone:phone:Accounts_Phone:V',
+                         'vtiger_crmentity:smownerid:assigned_user_id:Accounts_Assigned_To:V'),
+
+		   Array('vtiger_account:accountname:accountname:Accounts_Account_Name:V',
+			 'vtiger_account:phone:phone:Accounts_Phone:V',
+			 'vtiger_account:website:website:Accounts_Website:V',
+			 'vtiger_account:rating:rating:Accounts_Rating:V',
+			 'vtiger_crmentity:smownerid:assigned_user_id:Accounts_Assigned_To:V'),
+
+		   Array('vtiger_account:accountname:accountname:Accounts_Account_Name:V',
+                         'vtiger_account:phone:phone:Accounts_Phone:V',
+                         'vtiger_account:website:website:Accounts_Website:V',
+                         'vtiger_accountbillads:city:bill_city:Accounts_City:V',
+                         'vtiger_crmentity:smownerid:assigned_user_id:Accounts_Assigned_To:V'),
+
+		   Array('vtiger_contactdetails:firstname:firstname:Contacts_First_Name:V',
+                         'vtiger_contactdetails:lastname:lastname:Contacts_Last_Name:V',
+                         'vtiger_contactdetails:title:title:Contacts_Title:V',
+                         'vtiger_contactdetails:accountid:account_id:Contacts_Account_Name:I',
+                         'vtiger_contactdetails:email:email:Contacts_Email:E',
+                         'vtiger_contactdetails:phone:phone:Contacts_Office_Phone:V',
+			 'vtiger_crmentity:smownerid:assigned_user_id:Contacts_Assigned_To:V'),
+
+		   Array('vtiger_contactdetails:firstname:firstname:Contacts_First_Name:V',
+                         'vtiger_contactdetails:lastname:lastname:Contacts_Last_Name:V',
+                         'vtiger_contactaddress:mailingstreet:mailingstreet:Contacts_Mailing_Street:V',
+                         'vtiger_contactaddress:mailingcity:mailingcity:Contacts_City:V',
+                         'vtiger_contactaddress:mailingstate:mailingstate:Contacts_State:V',
+			 'vtiger_contactaddress:mailingzip:mailingzip:Contacts_Zip:V',
+			 'vtiger_contactaddress:mailingcountry:mailingcountry:Contacts_Country:V'),
 		   
-		   Array('contactdetails:firstname:firstname:Contacts_First_Name:V',
-                         'contactdetails:lastname:lastname:Contacts_Last_Name:V',
-                         'contactdetails:title:title:Contacts_Title:V',
-                         'contactdetails:accountid:account_id:Contacts_Account_Name:I',
-                         'contactdetails:email:email:Contacts_Email:E',
-			 'contactsubdetails:otherphone:otherphone:Contacts_Phone:V',
-			 'crmentity:smownerid:assigned_user_id:Contacts_Assigned_To:V'),
+		   Array('vtiger_contactdetails:firstname:firstname:Contacts_First_Name:V',
+                         'vtiger_contactdetails:lastname:lastname:Contacts_Last_Name:V',
+                         'vtiger_contactdetails:title:title:Contacts_Title:V',
+                         'vtiger_contactdetails:accountid:account_id:Contacts_Account_Name:I',
+                         'vtiger_contactdetails:email:email:Contacts_Email:E',
+			 'vtiger_contactsubdetails:otherphone:otherphone:Contacts_Phone:V',
+			 'vtiger_crmentity:smownerid:assigned_user_id:Contacts_Assigned_To:V'),
 		  
-		   Array('potential:potentialname:potentialname:Potentials_Potential_Name:V',
-                         'potential:accountid:account_id:Potentials_Account_Name:V',
-                         'potential:sales_stage:sales_stage:Potentials_Sales_Stage:V',
-                         'potential:leadsource:leadsource:Potentials_Lead_Source:V',
-                         'potential:closingdate:closingdate:Potentials_Expected_Close_Date:D',
-                         'crmentity:smownerid:assigned_user_id:Potentials_Assigned_To:V'),
-
-                   Array('potential:potentialname:potentialname:Potentials_Potential_Name:V',
-                         'potential:accountid:account_id:Potentials_Account_Name:V',
-                         'potential:amount:amount:Potentials_Amount:N',
-                         'potential:closingdate:closingdate:Potentials_Expected_Close_Date:D',
-                         'crmentity:smownerid:assigned_user_id:Potentials_Assigned_To:V'),
-
-		   Array('potential:potentialname:potentialname:Potentials_Potential_Name:V',
-                         'potential:accountid:account_id:Potentials_Account_Name:V',
-                         'potential:amount:amount:Potentials_Amount:N',
-                         'potential:leadsource:leadsource:Potentials_Lead_Source:V',
-                         'potential:closingdate:closingdate:Potentials_Expected_Close_Date:D',
-                         'crmentity:smownerid:assigned_user_id:Potentials_Assigned_To:V'),
-
-		   Array('crmentity:crmid::HelpDesk_Ticket_ID:I',
-			 'troubletickets:title:ticket_title:HelpDesk_Title:V',
-                         'troubletickets:parent_id:parent_id:HelpDesk_Related_to:I',
-                         'troubletickets:status:ticketstatus:HelpDesk_Status:V',
-                         'troubletickets:priority:ticketpriorities:HelpDesk_Priority:V',
-                         'crmentity:smownerid:assigned_user_id:HelpDesk_Assigned_To:V'),
-
-		   Array('troubletickets:title:ticket_title:HelpDesk_Title:V',
-                         'troubletickets:parent_id:parent_id:HelpDesk_Related_to:I',
-                         'troubletickets:priority:ticketpriorities:HelpDesk_Priority:V',
-                         'troubletickets:product_id:product_id:HelpDesk_Product_Name:I',
-                         'crmentity:smownerid:assigned_user_id:HelpDesk_Assigned_To:V'),
-
-		   Array('troubletickets:title:ticket_title:HelpDesk_Title:V',
-                         'troubletickets:parent_id:parent_id:HelpDesk_Related_to:I',
-                         'troubletickets:status:ticketstatus:HelpDesk_Status:V',
-                         'troubletickets:product_id:product_id:HelpDesk_Product_Name:I',
-                         'crmentity:smownerid:assigned_user_id:HelpDesk_Assigned_To:V'),
-
-		   Array('crmentity:crmid::Quotes_Quote_ID:I',
-			 'quotes:subject:subject:Quotes_Subject:V',
-                         'quotes:quotestage:quotestage:Quotes_Quote_Stage:V',
-                         'quotes:potentialid:potential_id:Quotes_Potential_Name:I',
-                         'quotes:accountid:account_id:Quotes_Account_Name:I',
-                         'quotes:total:hdnGrandTotal:Quotes_Total:I',
-			 'crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V'),
-
-		   Array('quotes:subject:subject:Quotes_Subject:V',
-                         'quotes:quotestage:quotestage:Quotes_Quote_Stage:V',
-                         'quotes:potentialid:potential_id:Quotes_Potential_Name:I',
-                         'quotes:accountid:account_id:Quotes_Account_Name:I',
-                         'quotes:validtill:validtill:Quotes_Valid_Till:D',
-			 'crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V'),
-
-		   Array('quotes:subject:subject:Quotes_Subject:V',
-                         'quotes:potentialid:potential_id:Quotes_Potential_Name:I',
-                         'quotes:accountid:account_id:Quotes_Account_Name:I',
-                         'quotes:validtill:validtill:Quotes_Valid_Till:D',
-                         'crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V'),
+		   Array('vtiger_potential:potentialname:potentialname:Potentials_Potential_Name:V',
+                         'vtiger_potential:accountid:account_id:Potentials_Account_Name:V',
+                         'vtiger_potential:sales_stage:sales_stage:Potentials_Sales_Stage:V',
+                         'vtiger_potential:leadsource:leadsource:Potentials_Lead_Source:V',
+                         'vtiger_potential:closingdate:closingdate:Potentials_Expected_Close_Date:D',
+                         'vtiger_crmentity:smownerid:assigned_user_id:Potentials_Assigned_To:V'),
+
+                   Array('vtiger_potential:potentialname:potentialname:Potentials_Potential_Name:V',
+                         'vtiger_potential:accountid:account_id:Potentials_Account_Name:V',
+                         'vtiger_potential:amount:amount:Potentials_Amount:N',
+                         'vtiger_potential:closingdate:closingdate:Potentials_Expected_Close_Date:D',
+                         'vtiger_crmentity:smownerid:assigned_user_id:Potentials_Assigned_To:V'),
+
+		   Array('vtiger_potential:potentialname:potentialname:Potentials_Potential_Name:V',
+                         'vtiger_potential:accountid:account_id:Potentials_Account_Name:V',
+                         'vtiger_potential:amount:amount:Potentials_Amount:N',
+                         'vtiger_potential:leadsource:leadsource:Potentials_Lead_Source:V',
+                         'vtiger_potential:closingdate:closingdate:Potentials_Expected_Close_Date:D',
+                         'vtiger_crmentity:smownerid:assigned_user_id:Potentials_Assigned_To:V'),
+
+		   Array('vtiger_crmentity:crmid::HelpDesk_Ticket_ID:I',
+			 'vtiger_troubletickets:title:ticket_title:HelpDesk_Title:V',
+                         'vtiger_troubletickets:parent_id:parent_id:HelpDesk_Related_to:I',
+                         'vtiger_troubletickets:status:ticketstatus:HelpDesk_Status:V',
+                         'vtiger_troubletickets:priority:ticketpriorities:HelpDesk_Priority:V',
+                         'vtiger_crmentity:smownerid:assigned_user_id:HelpDesk_Assigned_To:V'),
+
+		   Array('vtiger_troubletickets:title:ticket_title:HelpDesk_Title:V',
+                         'vtiger_troubletickets:parent_id:parent_id:HelpDesk_Related_to:I',
+                         'vtiger_troubletickets:priority:ticketpriorities:HelpDesk_Priority:V',
+                         'vtiger_troubletickets:product_id:product_id:HelpDesk_Product_Name:I',
+                         'vtiger_crmentity:smownerid:assigned_user_id:HelpDesk_Assigned_To:V'),
+
+		   Array('vtiger_troubletickets:title:ticket_title:HelpDesk_Title:V',
+                         'vtiger_troubletickets:parent_id:parent_id:HelpDesk_Related_to:I',
+                         'vtiger_troubletickets:status:ticketstatus:HelpDesk_Status:V',
+                         'vtiger_troubletickets:product_id:product_id:HelpDesk_Product_Name:I',
+                         'vtiger_crmentity:smownerid:assigned_user_id:HelpDesk_Assigned_To:V'),
+
+		   Array('vtiger_crmentity:crmid::Quotes_Quote_ID:I',
+			 'vtiger_quotes:subject:subject:Quotes_Subject:V',
+                         'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V',
+                         'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:I',
+                         'vtiger_quotes:accountid:account_id:Quotes_Account_Name:I',
+                         'vtiger_quotes:total:hdnGrandTotal:Quotes_Total:I',
+			 'vtiger_crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V'),
+
+		   Array('vtiger_quotes:subject:subject:Quotes_Subject:V',
+                         'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V',
+                         'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:I',
+                         'vtiger_quotes:accountid:account_id:Quotes_Account_Name:I',
+                         'vtiger_quotes:validtill:validtill:Quotes_Valid_Till:D',
+			 'vtiger_crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V'),
+
+		   Array('vtiger_quotes:subject:subject:Quotes_Subject:V',
+                         'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:I',
+                         'vtiger_quotes:accountid:account_id:Quotes_Account_Name:I',
+                         'vtiger_quotes:validtill:validtill:Quotes_Valid_Till:D',
+                         'vtiger_crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V'),
 			
-		   Array('activity:status:taskstatus:Activities_Status:V',
-                         'activity:activitytype:activitytype:Activities_Type:V',
-                         'activity:subject:subject:Activities_Subject:V',
-                         'cntactivityrel:contactid:contact_id:Activities_Contact_Name:I',
-                         'seactivityrel:crmid:parent_id:Activities_Related_to:V',
-                         'activity:date_start:date_start:Activities_Start_Date:D',
-                         'activity:due_date:due_date:Activities_End_Date:D',
-                         'crmentity:smownerid:assigned_user_id:Activities_Assigned_To:V'),
-
-		   Array('activity:subject:subject:Emails_Subject:V',
-				'crmentity:smownerid:assigned_user_id:Emails_Sender:V',
-                 'activity:date_start:date_start:Emails_Date_Sent:D'),
+		   Array('vtiger_activity:status:taskstatus:Activities_Status:V',
+                         'vtiger_activity:activitytype:activitytype:Activities_Type:V',
+                         'vtiger_activity:subject:subject:Activities_Subject:V',
+                         'vtiger_cntactivityrel:contactid:contact_id:Activities_Contact_Name:I',
+                         'vtiger_seactivityrel:crmid:parent_id:Activities_Related_to:V',
+                         'vtiger_activity:date_start:date_start:Activities_Start_Date:D',
+                         'vtiger_activity:due_date:due_date:Activities_End_Date:D',
+                         'vtiger_crmentity:smownerid:assigned_user_id:Activities_Assigned_To:V'),
+
+		   Array('vtiger_activity:subject:subject:Emails_Subject:V',
+				'vtiger_crmentity:smownerid:assigned_user_id:Emails_Sender:V',
+                 'vtiger_activity:date_start:date_start:Emails_Date_Sent:D'),
 		
-		   Array('crmentity:crmid::Invoice_Invoice_Id:I',
-                         'invoice:subject:subject:Invoice_Subject:V',
-                         'invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I',
-                         'invoice:invoicestatus:invoicestatus:Invoice_Status:V',
-                         'invoice:total:hdnGrandTotal:Invoice_Total:I',
-                         'crmentity:smownerid:assigned_user_id:Invoice_Assigned_To:V'),
+		   Array('vtiger_crmentity:crmid::Invoice_Invoice_Id:I',
+                         'vtiger_invoice:subject:subject:Invoice_Subject:V',
+                         'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I',
+                         'vtiger_invoice:invoicestatus:invoicestatus:Invoice_Status:V',
+                         'vtiger_invoice:total:hdnGrandTotal:Invoice_Total:I',
+                         'vtiger_crmentity:smownerid:assigned_user_id:Invoice_Assigned_To:V'),
 		
-		  Array('notes:title:title:Notes_Title:V',
-                        'notes:contact_id:contact_id:Notes_Contact_Name:I',
-                        'senotesrel:crmid:parent_id:Notes_Related_to:I',
-                        'notes:filename:filename:Notes_File:V',
-                        'crmentity:modifiedtime:modifiedtime:Notes_Modified_Time:V'),
+		  Array('vtiger_notes:title:title:Notes_Title:V',
+                        'vtiger_notes:contact_id:contact_id:Notes_Contact_Name:I',
+                        'vtiger_senotesrel:crmid:parent_id:Notes_Related_to:I',
+                        'vtiger_notes:filename:filename:Notes_File:V',
+                        'vtiger_crmentity:modifiedtime:modifiedtime:Notes_Modified_Time:V'),
 		
-		  Array('pricebook:bookname:bookname:PriceBooks_Price_Book_Name:V',
-                        'pricebook:active:active:PriceBooks_Active:V'),
+		  Array('vtiger_pricebook:bookname:bookname:PriceBooks_Price_Book_Name:V',
+                        'vtiger_pricebook:active:active:PriceBooks_Active:V'),
 		  
-		  Array('products:productname:productname:Products_Product_Name:V',
-                        'products:productcode:productcode:Products_Product_Code:V',
-                        'products:commissionrate:commissionrate:Products_Commission_Rate:V',
-                        'products:qty_per_unit:qty_per_unit:Products_Qty/Unit:V',
-                        'products:unit_price:unit_price:Products_Unit_Price:V'),
+		  Array('vtiger_products:productname:productname:Products_Product_Name:V',
+                        'vtiger_products:productcode:productcode:Products_Product_Code:V',
+                        'vtiger_products:commissionrate:commissionrate:Products_Commission_Rate:V',
+                        'vtiger_products:qty_per_unit:qty_per_unit:Products_Qty/Unit:V',
+                        'vtiger_products:unit_price:unit_price:Products_Unit_Price:V'),
 		  
-		  Array('crmentity:crmid::PurchaseOrder_Order_Id:I',
-                        'purchaseorder:subject:subject:PurchaseOrder_Subject:V',
-                        'purchaseorder:vendorid:vendor_id:PurchaseOrder_Vendor_Name:I',
-                        'purchaseorder:tracking_no:tracking_no:PurchaseOrder_Tracking_Number:V',
-                        'crmentity:smownerid:assigned_user_id:PurchaseOrder_Assigned_To:V'),
+		  Array('vtiger_crmentity:crmid::PurchaseOrder_Order_Id:I',
+                        'vtiger_purchaseorder:subject:subject:PurchaseOrder_Subject:V',
+                        'vtiger_purchaseorder:vendorid:vendor_id:PurchaseOrder_Vendor_Name:I',
+                        'vtiger_purchaseorder:tracking_no:tracking_no:PurchaseOrder_Tracking_Number:V',
+                        'vtiger_crmentity:smownerid:assigned_user_id:PurchaseOrder_Assigned_To:V'),
 		  
-	          Array('crmentity:crmid::SalesOrder_Order_Id:I',
-                        'salesorder:subject:subject:SalesOrder_Subject:V',
-                        'account:accountid:account_id:SalesOrder_Account_Name:V',
-                        'quotes:quoteid:quote_id:SalesOrder_Quote_Name:I',
-                        'salesorder:total:hdnGrandTotal:SalesOrder_Total:V',
-                        'crmentity:smownerid:assigned_user_id:SalesOrder_Assigned_To:V'),
-
-	          Array('vendor:vendorname:vendorname:Vendors_Vendor_Name:V',
-			'vendor:phone:phone:Vendors_Phone:V',
-			'vendor:email:email:Vendors_Email:E',
-                        'vendor:category:category:Vendors_Category:V'),
-
-
-
-
-		 Array('faq:id::Faq_FAQ_Id:I',
-		       'faq:question:question:Faq_Question:V',
-		       'faq:category:faqcategories:Faq_Category:V',
-		       'faq:product_id:product_id:Faq_Product_Name:I',
-		       'crmentity:createdtime:createdtime:Faq_Created_Time:D',
-                       'crmentity:modifiedtime:modifiedtime:Faq_Modified_Time:D'),
+	          Array('vtiger_crmentity:crmid::SalesOrder_Order_Id:I',
+                        'vtiger_salesorder:subject:subject:SalesOrder_Subject:V',
+                        'vtiger_account:accountid:account_id:SalesOrder_Account_Name:V',
+                        'vtiger_quotes:quoteid:quote_id:SalesOrder_Quote_Name:I',
+                        'vtiger_salesorder:total:hdnGrandTotal:SalesOrder_Total:V',
+                        'vtiger_crmentity:smownerid:assigned_user_id:SalesOrder_Assigned_To:V'),
+
+	          Array('vtiger_vendor:vendorname:vendorname:Vendors_Vendor_Name:V',
+			'vtiger_vendor:phone:phone:Vendors_Phone:V',
+			'vtiger_vendor:email:email:Vendors_Email:E',
+                        'vtiger_vendor:category:category:Vendors_Category:V'),
+
+
+
+
+		 Array('vtiger_faq:id::Faq_FAQ_Id:I',
+		       'vtiger_faq:question:question:Faq_Question:V',
+		       'vtiger_faq:category:faqcategories:Faq_Category:V',
+		       'vtiger_faq:product_id:product_id:Faq_Product_Name:I',
+		       'vtiger_crmentity:createdtime:createdtime:Faq_Created_Time:D',
+                       'vtiger_crmentity:modifiedtime:modifiedtime:Faq_Modified_Time:D'),
 		      //this sequence has to be maintained 
-		 Array('campaign:campaignname:campaignname:Campaigns_Campaign_Name:V',
-		       'campaign:campaigntype:campaigntype:Campaigns_Campaign_Type:N',
-		       'campaign:campaignstatus:campaignstatus:Campaigns_Campaign_Status:N',
-		       'campaign:expectedrevenue:expectedrevenue:Campaigns_Expected_Revenue:V',
-		       'campaign:closingdate:closingdate:Campaigns_Expected_Close_Date:D',
-		       'crmentity:smownerid:assigned_user_id:Campaigns_Assigned_To:V'),
+		 Array('vtiger_campaign:campaignname:campaignname:Campaigns_Campaign_Name:V',
+		       'vtiger_campaign:campaigntype:campaigntype:Campaigns_Campaign_Type:N',
+		       'vtiger_campaign:campaignstatus:campaignstatus:Campaigns_Campaign_Status:N',
+		       'vtiger_campaign:expectedrevenue:expectedrevenue:Campaigns_Expected_Revenue:V',
+		       'vtiger_campaign:closingdate:closingdate:Campaigns_Expected_Close_Date:D',
+		       'vtiger_crmentity:smownerid:assigned_user_id:Campaigns_Assigned_To:V'),
 
 
 		 Array('subject:subject:subject:Subject:V',
@@ -336,17 +336,17 @@
 
 
 
-$cvstdfilters = Array(Array('columnname'=>'crmentity:modifiedtime:modifiedtime:Leads_Modified_Time',
+$cvstdfilters = Array(Array('columnname'=>'vtiger_crmentity:modifiedtime:modifiedtime:Leads_Modified_Time',
                             'datefilter'=>'thismonth',
                             'startdate'=>'2005-06-01',
                             'enddate'=>'2005-06-30'),
 
-		      Array('columnname'=>'crmentity:createdtime:createdtime:Accounts_Created_Time',
+		      Array('columnname'=>'vtiger_crmentity:createdtime:createdtime:Accounts_Created_Time',
                             'datefilter'=>'thisweek',
                             'startdate'=>'2005-06-19',
                             'enddate'=>'2005-06-25'),
 
-		      Array('columnname'=>'contactsubdetails:birthday:birthday:Contacts_Birthdate',
+		      Array('columnname'=>'vtiger_contactsubdetails:birthday:birthday:Contacts_Birthdate',
                             'datefilter'=>'today',
                             'startdate'=>'2005-06-25',
                             'enddate'=>'2005-06-25')
@@ -354,53 +354,53 @@
 
 $cvadvfilters = Array(
                 	Array(
-               			 Array('columnname'=>'leaddetails:leadstatus:leadstatus:Leads_Lead_Status:V',
+               			 Array('columnname'=>'vtiger_leaddetails:leadstatus:leadstatus:Leads_Lead_Status:V',
 		                      'comparator'=>'e',
         		              'value'=>'Hot'
                      			)
                      	 ),
 		      		Array(
-                          Array('columnname'=>'account:account_type:accounttype:Accounts_Type:V',
+                          Array('columnname'=>'vtiger_account:account_type:accounttype:Accounts_Type:V',
                                 'comparator'=>'e',
                                  'value'=>'Prospect'
                                  )
                            ),
 				     Array(
-                            Array('columnname'=>'potential:sales_stage:sales_stage:Potentials_Sales_Stage:V',
+                            Array('columnname'=>'vtiger_potential:sales_stage:sales_stage:Potentials_Sales_Stage:V',
                                   'comparator'=>'e',
                                   'value'=>'Closed Won'
                                  )
                            ),
 				     Array(
-                            Array('columnname'=>'potential:sales_stage:sales_stage:Potentials_Sales_Stage:V',
+                            Array('columnname'=>'vtiger_potential:sales_stage:sales_stage:Potentials_Sales_Stage:V',
                                   'comparator'=>'e',
                                   'value'=>'Prospecting'
                                  )
                            ),
 				     Array(
-                            Array('columnname'=>'troubletickets:status:ticketstatus:HelpDesk_Status:V',
+                            Array('columnname'=>'vtiger_troubletickets:status:ticketstatus:HelpDesk_Status:V',
                                   'comparator'=>'n',
                                   'value'=>'Closed'
                                  )
                            ),
 				     Array(
-                            Array('columnname'=>'troubletickets:priority:ticketpriorities:HelpDesk_Priority:V',
+                            Array('columnname'=>'vtiger_troubletickets:priority:ticketpriorities:HelpDesk_Priority:V',
                                   'comparator'=>'e',
                                   'value'=>'High'
                                  )
                            ),
 				     Array(
-	                        Array('columnname'=>'quotes:quotestage:quotestage:Quotes_Quote_Stage:V',
+	                        Array('columnname'=>'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V',
                                   'comparator'=>'n',
                                   'value'=>'Accepted'
                                  ),
-						    Array('columnname'=>'quotes:quotestage:quotestage:Quotes_Quote_Stage:V',
+						    Array('columnname'=>'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V',
                                   'comparator'=>'n',
                                   'value'=>'Rejected'
                                  )
                            ),
 				     Array(
-                            Array('columnname'=>'quotes:quotestage:quotestage:Quotes_Quote_Stage:V',
+                            Array('columnname'=>'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V',
                                   'comparator'=>'e',
                                   'value'=>'Rejected'
                                  )
@@ -432,7 +432,7 @@
 	if($genCVid != "")
 	{
 
-		$customviewsql = "insert into customview(cvid,viewname,setdefault,setmetrics,entitytype)";
+		$customviewsql = "insert into vtiger_customview(cvid,viewname,setdefault,setmetrics,entitytype)";
 		$customviewsql .= " values(".$genCVid.",'".$viewname."',".$setdefault.",".$setmetrics.",'".$cvmodule."')";
 		$customviewresult = $adb->query($customviewsql);
 	}
@@ -446,7 +446,7 @@
 	{
 		for($i=0;$i<count($columnslist);$i++)
 		{
-			$columnsql = "insert into cvcolumnlist (cvid,columnindex,columnname)";
+			$columnsql = "insert into vtiger_cvcolumnlist (cvid,columnindex,columnname)";
 			$columnsql .= " values (".$CVid.",".$i.",'".$columnslist[$i]."')";
 			$columnresult = $adb->query($columnsql);
 		}
@@ -458,7 +458,7 @@
 	global $adb;
 	if($CVid != "")
 	{
-		$stdfiltersql = "insert into cvstdfilter(cvid,columnname,stdfilter,startdate,enddate)";
+		$stdfiltersql = "insert into vtiger_cvstdfilter(cvid,columnname,stdfilter,startdate,enddate)";
 		$stdfiltersql .= " values (".$CVid.",'".$filtercolumn."',";
 		$stdfiltersql .= "'".$filtercriteria."',";
 		$stdfiltersql .= "'".$startdate."',";
@@ -474,7 +474,7 @@
 	{
 		foreach($filters as $i=>$filter)
 		{
-			$advfiltersql = "insert into cvadvfilter(cvid,columnindex,columnname,comparator,value)";
+			$advfiltersql = "insert into vtiger_cvadvfilter(cvid,columnindex,columnname,comparator,value)";
 			$advfiltersql .= " values (".$CVid.",".$i.",'".$filter['columnname']."',";
 			$advfiltersql .= "'".$filter['comparator']."',";
 			$advfiltersql .= "'".$filter['value']."')";

Modified: vtigercrm/trunk/modules/CustomView/Save.php
==============================================================================
--- vtigercrm/trunk/modules/CustomView/Save.php (original)
+++ vtigercrm/trunk/modules/CustomView/Save.php Mon Jun 12 14:26:25 2006
@@ -95,32 +95,32 @@
 
 			if($setdefault == 1)
 			{
-				$updatedefaultsql = "UPDATE customview SET setdefault = 0 WHERE entitytype = ".$adb->quote($cvmodule);
+				$updatedefaultsql = "UPDATE vtiger_customview SET setdefault = 0 WHERE entitytype = ".$adb->quote($cvmodule);
 				$updatedefaultresult = $adb->query($updatedefaultsql);
 			}
 			$log->info("CustomView :: Save :: setdefault upated successfully");
 
-			$customviewsql = "INSERT INTO customview(cvid, viewname,
+			$customviewsql = "INSERT INTO vtiger_customview(cvid, viewname,
 						setdefault, setmetrics,
 						entitytype)
 					VALUES (".$genCVid.",".$adb->quote($viewname).",
 						".$setdefault.",".$setmetrics.",
 						".$adb->quote($cvmodule).")";
 			$customviewresult = $adb->query($customviewsql);
-			$log->info("CustomView :: Save :: customview created successfully");
+			$log->info("CustomView :: Save :: vtiger_customview created successfully");
 			if($customviewresult)
 			{
 				if(isset($columnslist))
 				{
 					for($i=0;$i<count($columnslist);$i++)
 					{
-						$columnsql = "INSERT INTO cvcolumnlist (cvid, columnindex, columnname)
+						$columnsql = "INSERT INTO vtiger_cvcolumnlist (cvid, columnindex, columnname)
 							VALUES (".$genCVid.", ".$i.", ".$adb->quote($columnslist[$i]).")";
 						$columnresult = $adb->query($columnsql);
 					}
-					$log->info("CustomView :: Save :: cvcolumnlist created successfully");
-
-					$stdfiltersql = "INSERT INTO cvstdfilter
+					$log->info("CustomView :: Save :: vtiger_cvcolumnlist created successfully");
+
+					$stdfiltersql = "INSERT INTO vtiger_cvstdfilter
 								(cvid,
 								columnname,
 								stdfilter,
@@ -134,10 +134,10 @@
 								".$adb->formatDate($std_filter_list["startdate"]).",
 								".$adb->formatDate($std_filter_list["enddate"]).")";
 					$stdfilterresult = $adb->query($stdfiltersql);
-					$log->info("CustomView :: Save :: cvstdfilter created successfully");
+					$log->info("CustomView :: Save :: vtiger_cvstdfilter created successfully");
 					for($i=0;$i<count($adv_filter_col);$i++)
 					{
-						$advfiltersql = "INSERT INTO cvadvfilter
+						$advfiltersql = "INSERT INTO vtiger_cvadvfilter
 								(cvid,
 								columnindex,
 								columnname,
@@ -151,7 +151,7 @@
 								".$adb->quote($adv_filter_value[$i]).")";
 						$advfilterresult = $adb->query($advfiltersql);
 					}
-					$log->info("CustomView :: Save :: cvadvfilter created successfully");
+					$log->info("CustomView :: Save :: vtiger_cvadvfilter created successfully");
 				}
 			}
 			$cvid = $genCVid;
@@ -161,26 +161,26 @@
 
 		if($setdefault == 1)
 		{
-			$updatedefaultsql = "UPDATE customview SET setdefault = 0 WHERE entitytype = ".$adb->quote($cvmodule);
+			$updatedefaultsql = "UPDATE vtiger_customview SET setdefault = 0 WHERE entitytype = ".$adb->quote($cvmodule);
 			$updatedefaultresult = $adb->query($updatedefaultsql);
 		}
 		$log->info("CustomView :: Save :: setdefault upated successfully".$genCVid);
-		$updatecvsql = "UPDATE customview
+		$updatecvsql = "UPDATE vtiger_customview
 				SET viewname = ".$adb->quote($viewname).",
 					setdefault = ".$setdefault.",
 					setmetrics = ".$setmetrics."
 				WHERE cvid = ".$cvid;
 		$updatecvresult = $adb->query($updatecvsql);
-		$log->info("CustomView :: Save :: customview upated successfully".$genCVid);
-		$deletesql = "DELETE FROM cvcolumnlist WHERE cvid = ".$cvid;
+		$log->info("CustomView :: Save :: vtiger_customview upated successfully".$genCVid);
+		$deletesql = "DELETE FROM vtiger_cvcolumnlist WHERE cvid = ".$cvid;
 		$deleteresult = $adb->query($deletesql);
 
-		$deletesql = "DELETE FROM cvstdfilter WHERE cvid = ".$cvid;
+		$deletesql = "DELETE FROM vtiger_cvstdfilter WHERE cvid = ".$cvid;
 		$deleteresult = $adb->query($deletesql);
 
-		$deletesql = "DELETE FROM cvadvfilter WHERE cvid = ".$cvid;
+		$deletesql = "DELETE FROM vtiger_cvadvfilter WHERE cvid = ".$cvid;
 		$deleteresult = $adb->query($deletesql);
-		$log->info("CustomView :: Save :: cvcolumnlist,cvstdfilter,cvadvfilter deleted successfully before update".$genCVid);
+		$log->info("CustomView :: Save :: vtiger_cvcolumnlist,cvstdfilter,cvadvfilter deleted successfully before update".$genCVid);
 
 		$genCVid = $cvid;
 		if($updatecvresult)
@@ -189,12 +189,12 @@
 			{
 				for($i=0;$i<count($columnslist);$i++)
 				{
-					$columnsql = "INSERT INTO cvcolumnlist (cvid, columnindex, columnname)
+					$columnsql = "INSERT INTO vtiger_cvcolumnlist (cvid, columnindex, columnname)
 						VALUES (".$genCVid.", ".$i.", ".$adb->quote($columnslist[$i]).")";
 					$columnresult = $adb->query($columnsql);
 				}
-				$log->info("CustomView :: Save :: cvcolumnlist update successfully".$genCVid);
-				$stdfiltersql = "INSERT INTO cvstdfilter
+				$log->info("CustomView :: Save :: vtiger_cvcolumnlist update successfully".$genCVid);
+				$stdfiltersql = "INSERT INTO vtiger_cvstdfilter
 							(cvid,
 							columnname,
 							stdfilter,
@@ -207,10 +207,10 @@
 							".$adb->formatDate($std_filter_list["startdate"]).",
 							".$adb->formatDate($std_filter_list["enddate"]).")";
 				$stdfilterresult = $adb->query($stdfiltersql);
-				$log->info("CustomView :: Save :: cvstdfilter update successfully".$genCVid);
+				$log->info("CustomView :: Save :: vtiger_cvstdfilter update successfully".$genCVid);
 				for($i=0;$i<count($adv_filter_col);$i++)
 				{
-					$advfiltersql = "INSERT INTO cvadvfilter
+					$advfiltersql = "INSERT INTO vtiger_cvadvfilter
 								(cvid,
 								columnindex,
 								columnname,
@@ -224,7 +224,7 @@
 								".$adb->quote($adv_filter_value[$i]).")";
 					$advfilterresult = $adb->query($advfiltersql);
 				}
-				$log->info("CustomView :: Save :: cvadvfilter update successfully".$genCVid);
+				$log->info("CustomView :: Save :: vtiger_cvadvfilter update successfully".$genCVid);
 			}
 		}
 	}

Modified: vtigercrm/trunk/modules/CustomView/SaveAction.php
==============================================================================
--- vtigercrm/trunk/modules/CustomView/SaveAction.php (original)
+++ vtigercrm/trunk/modules/CustomView/SaveAction.php Mon Jun 12 14:26:25 2006
@@ -22,7 +22,7 @@
 {
 	if($mode == "new")
 	{
-		$customactionsql = "insert into customaction(cvid,subject,module,content)";
+		$customactionsql = "insert into vtiger_customaction(cvid,subject,module,content)";
 		$customactionsql .= " values(".$cvid.",'".$subject."','".$cvmodule."','".$body."')";
 		$customactionresult = $adb->query($customactionsql);
 		if($customactionresult == false)
@@ -37,7 +37,7 @@
 
 	}elseif($mode == "edit")
 	{
-		$updatecasql = "update customaction set subject='".$subject."',content='".$body."' where cvid=".$cvid;
+		$updatecasql = "update vtiger_customaction set subject='".$subject."',content='".$body."' where cvid=".$cvid;
 		$updatecaresult = $adb->query($updatecasql);
 		if($updatecaresult == false)
 		{

Modified: vtigercrm/trunk/modules/CustomView/SendMailAction.php
==============================================================================
--- vtigercrm/trunk/modules/CustomView/SendMailAction.php (original)
+++ vtigercrm/trunk/modules/CustomView/SendMailAction.php Mon Jun 12 14:26:25 2006
@@ -38,7 +38,7 @@
 			if($id == '') continue;
 			if($camodule == "Contacts")
 			{
-				$sql="select * from contactdetails inner join crmentity on crmentity.crmid = contactdetails.contactid where crmentity.deleted =0 and contactdetails.contactid='" .$id ."'";
+				$sql="select * from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid='" .$id ."'";
 				$result = $adb->query($sql);
 				$camodulerow = $adb->fetch_array($result);
 				if(isset($camodulerow))
@@ -65,7 +65,7 @@
 
 			}elseif($camodule == "Leads")
 			{
-				$sql="select * from leaddetails inner join crmentity on crmentity.crmid = leaddetails.leadid where crmentity.deleted =0 and leaddetails.leadid='" .$id ."'";
+				$sql="select * from vtiger_leaddetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_leaddetails.leadid where vtiger_crmentity.deleted =0 and vtiger_leaddetails.leadid='" .$id ."'";
 				$result = $adb->query($sql);
 				$camodulerow = $adb->fetch_array($result);
 				if(isset($camodulerow))
@@ -88,7 +88,7 @@
 				}
 			}elseif($camodule == "Accounts")
 			{
-				$sql="select * from account inner join crmentity on crmentity.crmid = account.accountid where crmentity.deleted =0 and account.accountid='" .$id ."'";
+				$sql="select * from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_account.accountid where vtiger_crmentity.deleted =0 and vtiger_account.accountid='" .$id ."'";
 				$result = $adb->query($sql);
 				$camodulerow = $adb->fetch_array($result);
 				if(isset($camodulerow))
@@ -128,7 +128,7 @@
 	if($current_user_id != '')
 	{
 		global $adb;
-		$sql = "select * from users where id= ".$current_user_id;
+		$sql = "select * from vtiger_users where id= ".$current_user_id;
 		$result = $adb->query($sql);
 		$from = $adb->query_result($result,0,'email1');
 		$initialfrom = $adb->query_result($result,0,'user_name');
@@ -136,7 +136,7 @@
 	if($mail_server=='')
 	{
 		global $adb;
-		$mailserverresult=$adb->query("select * from systems where server_type='email'");
+		$mailserverresult=$adb->query("select * from vtiger_systems where server_type='email'");
 		$mail_server = $adb->query_result($mailserverresult,0,'server');
 		$mail_server_username = $adb->query_result($mailserverresult,0,'server_username');
 		$mail_server_password = $adb->query_result($mailserverresult,0,'server_password');

Modified: vtigercrm/trunk/modules/CustomView/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/CustomView/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/CustomView/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -86,7 +86,7 @@
 'less_or_equal'=>'less or equal', 
 'greater_or_equal'=>'greater or equal', 
  
-//Strings added to translate field label groups 
+//Strings added to translate vtiger_field label vtiger_groups 
 'Address'=>'Address', 
 'Information'=>'Information', 
 'Description'=>'Description', 
@@ -96,7 +96,7 @@
 '- Task Information'=>'- Task Information', 
 '- Task Description'=>'- Task Description', 
  
-//Strings added for helpdesk module fields 
+//Strings added for helpdesk module vtiger_fields 
 'Title'=>'Title', 
 'Assigned To'=>'Assigned To', 
 'Related to'=>'Related to', 
@@ -109,7 +109,7 @@
 'Modified Time'=>'Modified Time', 
 'Attachment'=>'Attachment', 
  
-//Strings added for Leads module fields 
+//Strings added for Leads module vtiger_fields 
 'First Name'=>'First Name', 
 'Phone'=>'Phone', 
 'Last Name'=>'Last Name', 
@@ -128,7 +128,7 @@
 'Country'=>'Country', 
 'State'=>'State', 
  
-//Strings added for Accounts module fields 
+//Strings added for Accounts module vtiger_fields 
 'Account Name'=>'Account Name', 
 'Ticker Symbol'=>'Ticker Symbol', 
 'Other Phone'=>'Other Phone', 
@@ -153,7 +153,7 @@
 'Billing Country'=>'Billing Country', 
  
  
-//Strings added for Contacts module fields 
+//Strings added for Contacts module vtiger_fields 
  
 'Office Phone'=>'Office Phone', 
 'Home Phone'=>'Home Phone', 
@@ -175,7 +175,7 @@
 'Other Country'=>'Other Country', 
  
  
-//Strings added for Potential module fields 
+//Strings added for Potential module vtiger_fields 
  
 'Potential Name'=>'Potential Name', 
 'Amount'=>'Amount', 
@@ -185,7 +185,7 @@
 'Probability'=>'Probability', 
  
  
-//Strings added for Quotes module fields 
+//Strings added for Quotes module vtiger_fields 
 'Subject'=>'Subject', 
 'Quote Stage'=>'Quote Stage', 
 'Valid Till'=>'Valid Till', 
@@ -195,7 +195,7 @@
 'Shipping'=>'Shipping', 
 'Inventory Manager'=>'Inventory Manager', 
  
-//Strings added for Sales Orders module fields 
+//Strings added for Sales Orders module vtiger_fields 
 'Customer No'=>'Customer No', 
 'Quote Name'=>'Quote Name', 
 'Purchase Order'=>'Purchase Order', 
@@ -204,11 +204,11 @@
 'Sales Commission'=>'Sales Commission', 
 'Excise Duty'=>'Excise Duty', 
  
-//Strings added for Invoices module fields 
+//Strings added for Invoices module vtiger_fields 
 'Sales Order'=>'Sales Order', 
 'Invoice Date'=>'Invoice Date', 
  
-//Strings added for Product module fields 
+//Strings added for Product module vtiger_fields 
 'Product Code'=>'Product Code', 
 'Product Active'=>'Product Active', 
 'Product Category'=>'Product Category', 
@@ -224,16 +224,16 @@
 'Product Sheet'=>'Product Sheet', 
 'GL Account'=>'GL Account', 
  
-//Strings added for Price book module fields 
+//Strings added for Price book module vtiger_fields 
 'Price Book Name'=>'Price Book Name', 
 'Active'=>'Active', 
  
-//Strings added for tasks & events module fields 
+//Strings added for tasks & events module vtiger_fields 
 'Start Date & Time'=>'Start Date & Time', 
  
 //error message 
-'Missing required fields'=>'Missing required fields', 
-//Strings added for campaigns 
+'Missing required vtiger_fields'=>'Missing required vtiger_fields', 
+//Strings added for vtiger_campaigns 
 'Campaign Name'=>'Campaign Name', 
 'Campaign Type'=>'Campaign Type', 
 'Product'=>'Product', 
@@ -255,10 +255,10 @@
  
  
  
-//Added for customview.tpl 
+//Added for vtiger_customview.tpl 
  
 'LBL_Select_a_Column'=>'Select a Column', 
-'Missing_required_fields'=>'Missing required fields', 
+'Missing_required_fields'=>'Missing required vtiger_fields', 
 'Details'=>'Details', 
 'New_Custom_View'=>'New Custom view', 
 'LBL_AF_HDR5'=>'Simple Time Filter allows you to select date based on  

Modified: vtigercrm/trunk/modules/Dashboard/Chart_lead_source_by_outcome.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/Chart_lead_source_by_outcome.php (original)
+++ vtigercrm/trunk/modules/Dashboard/Chart_lead_source_by_outcome.php Mon Jun 12 14:26:25 2006
@@ -89,7 +89,7 @@
 	$ids = array_keys($ids);
 }
 
-//create unique prefix based on selected users for image files
+//create unique prefix based on selected vtiger_users for image vtiger_files
 $id_hash = '';
 if (isset($ids)) {
 	sort($ids);

Modified: vtigercrm/trunk/modules/Dashboard/Chart_my_pipeline_by_sales_stage.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/Chart_my_pipeline_by_sales_stage.php (original)
+++ vtigercrm/trunk/modules/Dashboard/Chart_my_pipeline_by_sales_stage.php Mon Jun 12 14:26:25 2006
@@ -106,7 +106,7 @@
 $log->debug($datax);
 
 $ids = array($current_user->id);
-//create unique prefix based on selected users for image files
+//create unique prefix based on selected vtiger_users for image vtiger_files
 $id_hash = '';
 if (isset($ids)) {
 	sort($ids);

Modified: vtigercrm/trunk/modules/Dashboard/Chart_outcome_by_month.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/Chart_outcome_by_month.php (original)
+++ vtigercrm/trunk/modules/Dashboard/Chart_outcome_by_month.php Mon Jun 12 14:26:25 2006
@@ -90,7 +90,7 @@
 	$ids = array_keys($ids);
 }
 
-//create unique prefix based on selected users for image files
+//create unique prefix based on selected vtiger_users for image vtiger_files
 $id_hash = '';
 if (isset($ids)) {
 	sort($ids);

Modified: vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_lead_source.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_lead_source.php (original)
+++ vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_lead_source.php Mon Jun 12 14:26:25 2006
@@ -89,7 +89,7 @@
 	$ids = array_keys($ids);
 }
 
-//create unique prefix based on selected users for image files
+//create unique prefix based on selected vtiger_users for image vtiger_files
 $id_hash = '';
 if (isset($ids)) {
 	sort($ids);

Modified: vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_sales_stage.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_sales_stage.php (original)
+++ vtigercrm/trunk/modules/Dashboard/Chart_pipeline_by_sales_stage.php Mon Jun 12 14:26:25 2006
@@ -124,7 +124,7 @@
 	$ids = array_keys($ids);
 }
 
-//create unique prefix based on selected users for image files
+//create unique prefix based on selected vtiger_users for image vtiger_files
 $id_hash = '';
 if (isset($ids)) {
 	sort($ids);

Modified: vtigercrm/trunk/modules/Dashboard/Entity_charts.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/Entity_charts.php (original)
+++ vtigercrm/trunk/modules/Dashboard/Entity_charts.php Mon Jun 12 14:26:25 2006
@@ -15,9 +15,9 @@
 require_once('include/database/PearDatabase.php');
 require_once('include/utils/CommonUtils.php');
 
-//To get the account names
-
-/* Function to get the Account name for a given account id
+//To get the vtiger_account names
+
+/* Function to get the Account name for a given vtiger_account id
  * Portions created by vtiger are Copyright (C) vtiger.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
@@ -27,7 +27,7 @@
 {
 	global $adb;
 
-	$acc_qry="select accountname from account where accountid =".$acc_id;
+	$acc_qry="select vtiger_accountname from vtiger_account where vtiger_accountid =".$acc_id;
 	$acc_result=$adb->query($acc_qry);
 	$no_acc_rows=$adb->num_rows($acc_result);
 
@@ -57,7 +57,7 @@
 	global $adb;
 	global $days,$date_array,$period_type;
 
-	//$where= " and crmentity.smownerid=".$user_id." and crmentity.createdtime between '".$date_start."' and '".$end_date."'" ;
+	//$where= " and vtiger_crmentity.smownerid=".$user_id." and vtiger_crmentity.createdtime between '".$date_start."' and '".$end_date."'" ;
 	$query.=$where;
 	if($added_qry!="")
 		$query.=$added_qry;
@@ -117,7 +117,7 @@
 			$mod_cnt_table="<table border=0 cellspacing=1 cellpadding=3><tr>
 				<th>  Status </th>";
 
-			//Assigning the Header values to the table and giving the dates as graphformat 
+			//Assigning the Header values to the vtiger_table and giving the dates as graphformat 
 			for($i=0; $i<$days; $i++)
 			{
 				$tdate=$date_array[$i];
@@ -235,7 +235,7 @@
 					$test_target_val.="K".$link_val;
 			}
 			$mod_cnt_table .="</tr><tr><td class=\"$class\">Total</td>";
-			//For all Days getting the table 
+			//For all Days getting the vtiger_table 
 			for($k=0; $k<$days;$k++)
 			{
 				$tdate=$date_array[$k];

Modified: vtigercrm/trunk/modules/Dashboard/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/Forms.php (original)
+++ vtigercrm/trunk/modules/Dashboard/Forms.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 /*********************************************************************************
  * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Dashboard/Forms.php,v 1.2 2004/10/06 09:02:05 jack Exp $
  * Description:  Contains a variety of utility functions used to display UI 
- * components such as form headers and footers.  Intended to be modified on a per 
+ * components such as form vtiger_headers and footers.  Intended to be modified on a per 
  * theme basis.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.

Modified: vtigercrm/trunk/modules/Dashboard/ReportsCharts.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/ReportsCharts.php (original)
+++ vtigercrm/trunk/modules/Dashboard/ReportsCharts.php Mon Jun 12 14:26:25 2006
@@ -186,7 +186,7 @@
 	{
 		//Getting the cached image
 		$imgMap_fp = fopen($cache_file_name.'.map', "rb");
-		$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
+		$imgMap = fread($imgMap_fp, vtiger_filesize($cache_file_name.'.map'));
 		fclose($imgMap_fp);
 		$base_name_cache_file=basename($cache_file_name);
 		$ccc="cache/images/".$base_name_cache_file;

Modified: vtigercrm/trunk/modules/Dashboard/display_charts.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/display_charts.php (original)
+++ vtigercrm/trunk/modules/Dashboard/display_charts.php Mon Jun 12 14:26:25 2006
@@ -35,35 +35,35 @@
 $user_id=$current_user->id;
 
 // Query for Leads
-$leads_query="select crmentity.crmid,crmentity.createdtime, leaddetails.*, crmentity.smownerid, leadscf.* from leaddetails inner join crmentity on crmentity.crmid=leaddetails.leadid inner join leadsubdetails on leadsubdetails.leadsubscriptionid=leaddetails.leadid inner join leadaddress on leadaddress.leadaddressid=leadsubdetails.leadsubscriptionid inner join leadscf on leaddetails.leadid = leadscf.leadid left join leadgrouprelation on leadscf.leadid=leadgrouprelation.leadid left join groups on groups.groupname=leadgrouprelation.groupname where crmentity.deleted=0 and leaddetails.converted=0 ";
+$leads_query="select vtiger_crmentity.crmid,vtiger_crmentity.createdtime, vtiger_leaddetails.*, vtiger_crmentity.smownerid, vtiger_leadscf.* from vtiger_leaddetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid inner join vtiger_leadsubdetails on vtiger_leadsubdetails.leadsubscriptionid=vtiger_leaddetails.leadid inner join vtiger_leadaddress on vtiger_leadaddress.leadaddressid=vtiger_leadsubdetails.leadsubscriptionid inner join vtiger_leadscf on vtiger_leaddetails.leadid = vtiger_leadscf.leadid left join vtiger_leadgrouprelation on vtiger_leadscf.leadid=vtiger_leadgrouprelation.leadid left join vtiger_groups on vtiger_groups.groupname=vtiger_leadgrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_leaddetails.converted=0 ";
 
 
 //Query for Accounts
-$account_query="select crmentity.*, account.*, accountscf.* from account inner join crmentity on crmentity.crmid=account.accountid inner join accountbillads on account.accountid=accountbillads.accountaddressid inner join accountshipads on account.accountid=accountshipads.accountaddressid inner join accountscf on account.accountid = accountscf.accountid left join accountgrouprelation on accountscf.accountid=accountgrouprelation.accountid left join groups on groups.groupname=accountgrouprelation.groupname left join users on users.id=crmentity.smownerid where crmentity.deleted=0 ";
+$account_query="select vtiger_crmentity.*, vtiger_account.*, vtiger_accountscf.* from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid inner join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid inner join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid inner join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid left join vtiger_accountgrouprelation on vtiger_accountscf.accountid=vtiger_accountgrouprelation.accountid left join vtiger_groups on vtiger_groups.groupname=vtiger_accountgrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 ";
 
 
 //Query For Products
-$products_query="select distinct(crmentity.crmid),crmentity.createdtime,products.*, productcf.* from products inner join crmentity on crmentity.crmid=products.productid left join productcf on products.productid = productcf.productid left join seproductsrel on seproductsrel.productid = products.productid where crmentity.deleted=0 ";
+$products_query="select distinct(vtiger_crmentity.crmid),vtiger_crmentity.createdtime,vtiger_products.*, vtiger_productcf.* from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid left join vtiger_productcf on vtiger_products.productid = vtiger_productcf.productid left join vtiger_seproductsrel on vtiger_seproductsrel.productid = vtiger_products.productid where vtiger_crmentity.deleted=0 ";
 
 //Query for Potential
-$potential_query= "select  crmentity.*,account.accountname, potential.*, potentialscf.* from potential inner join crmentity on crmentity.crmid=potential.potentialid inner join account on potential.accountid = account.accountid inner join potentialscf on potentialscf.potentialid = potential.potentialid left join potentialgrouprelation on potential.potentialid=potentialgrouprelation.potentialid left join groups on groups.groupname=potentialgrouprelation.groupname left join users on users.id=crmentity.smownerid where crmentity.deleted=0 ";
+$potential_query= "select  vtiger_crmentity.*,vtiger_account.accountname, vtiger_potential.*, vtiger_potentialscf.* from vtiger_potential inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid inner join vtiger_account on vtiger_potential.accountid = vtiger_account.accountid inner join vtiger_potentialscf on vtiger_potentialscf.potentialid = vtiger_potential.potentialid left join vtiger_potentialgrouprelation on vtiger_potential.potentialid=vtiger_potentialgrouprelation.potentialid left join vtiger_groups on vtiger_groups.groupname=vtiger_potentialgrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 ";
 
 //Query for Sales Order
-$so_query="select crmentity.*,salesorder.*,account.accountid,quotes.quoteid from salesorder inner join crmentity on crmentity.crmid=salesorder.salesorderid inner join sobillads on salesorder.salesorderid=sobillads.sobilladdressid inner join soshipads on salesorder.salesorderid=soshipads.soshipaddressid left join salesordercf on salesordercf.salesorderid = salesorder.salesorderid left outer join quotes on quotes.quoteid=salesorder.quoteid left outer join account on account.accountid=salesorder.accountid left join sogrouprelation on salesorder.salesorderid=sogrouprelation.salesorderid left join groups on groups.groupname=sogrouprelation.groupname left join users on users.id=crmentity.smownerid where crmentity.deleted=0 ";
+$so_query="select vtiger_crmentity.*,vtiger_salesorder.*,vtiger_account.accountid,vtiger_quotes.quoteid from vtiger_salesorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid inner join vtiger_sobillads on vtiger_salesorder.salesorderid=vtiger_sobillads.sobilladdressid inner join vtiger_soshipads on vtiger_salesorder.salesorderid=vtiger_soshipads.soshipaddressid left join vtiger_salesordercf on vtiger_salesordercf.salesorderid = vtiger_salesorder.salesorderid left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 ";
 
 
 //Query for Purchase Order
 
-$po_query="select crmentity.*,purchaseorder.* from purchaseorder inner join crmentity on crmentity.crmid=purchaseorder.purchaseorderid left outer join vendor on purchaseorder.vendorid=vendor.vendorid inner join pobillads on purchaseorder.purchaseorderid=pobillads.pobilladdressid inner join poshipads on purchaseorder.purchaseorderid=poshipads.poshipaddressid left join purchaseordercf on purchaseordercf.purchaseorderid = purchaseorder.purchaseorderid left join pogrouprelation on purchaseorder.purchaseorderid=pogrouprelation.purchaseorderid left join groups on groups.groupname=pogrouprelation.groupname left join users on users.id=crmentity.smownerid where crmentity.deleted=0 ";
+$po_query="select vtiger_crmentity.*,vtiger_purchaseorder.* from vtiger_purchaseorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_purchaseorder.purchaseorderid left outer join vtiger_vendor on vtiger_purchaseorder.vendorid=vtiger_vendor.vendorid inner join vtiger_pobillads on vtiger_purchaseorder.purchaseorderid=vtiger_pobillads.pobilladdressid inner join vtiger_poshipads on vtiger_purchaseorder.purchaseorderid=vtiger_poshipads.poshipaddressid left join vtiger_purchaseordercf on vtiger_purchaseordercf.purchaseorderid = vtiger_purchaseorder.purchaseorderid left join vtiger_pogrouprelation on vtiger_purchaseorder.purchaseorderid=vtiger_pogrouprelation.purchaseorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_pogrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 ";
 
 // Query for Quotes
-$quotes_query="select crmentity.*,quotes.* from quotes inner join crmentity on crmentity.crmid=quotes.quoteid inner join quotesbillads on quotes.quoteid=quotesbillads.quotebilladdressid inner join quotesshipads on quotes.quoteid=quotesshipads.quoteshipaddressid left join quotescf on quotes.quoteid = quotescf.quoteid left outer join account on account.accountid=quotes.accountid left outer join potential on potential.potentialid=quotes.potentialid left join quotegrouprelation on quotes.quoteid=quotegrouprelation.quoteid left join groups on groups.groupname=quotegrouprelation.groupname left join users on users.id=crmentity.smownerid where crmentity.deleted=0 ";
+$quotes_query="select vtiger_crmentity.*,vtiger_quotes.* from vtiger_quotes inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid inner join vtiger_quotesbillads on vtiger_quotes.quoteid=vtiger_quotesbillads.quotebilladdressid inner join vtiger_quotesshipads on vtiger_quotes.quoteid=vtiger_quotesshipads.quoteshipaddressid left join vtiger_quotescf on vtiger_quotes.quoteid = vtiger_quotescf.quoteid left outer join vtiger_account on vtiger_account.accountid=vtiger_quotes.accountid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_quotes.potentialid left join vtiger_quotegrouprelation on vtiger_quotes.quoteid=vtiger_quotegrouprelation.quoteid left join vtiger_groups on vtiger_groups.groupname=vtiger_quotegrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 ";
 
 //Query for Invoice
-$invoice_query="select crmentity.*,invoice.* from invoice inner join crmentity on crmentity.crmid=invoice.invoiceid inner join invoicebillads on invoice.invoiceid=invoicebillads.invoicebilladdressid inner join invoiceshipads on invoice.invoiceid=invoiceshipads.invoiceshipaddressid left outer join salesorder on salesorder.salesorderid=invoice.salesorderid inner join invoicecf on invoice.invoiceid = invoicecf.invoiceid left join invoicegrouprelation on invoice.invoiceid=invoicegrouprelation.invoiceid left join groups on groups.groupname=invoicegrouprelation.groupname left join users on users.id=crmentity.smownerid where crmentity.deleted=0 ";
+$invoice_query="select vtiger_crmentity.*,vtiger_invoice.* from vtiger_invoice inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_invoice.invoiceid inner join vtiger_invoicebillads on vtiger_invoice.invoiceid=vtiger_invoicebillads.invoicebilladdressid inner join vtiger_invoiceshipads on vtiger_invoice.invoiceid=vtiger_invoiceshipads.invoiceshipaddressid left outer join vtiger_salesorder on vtiger_salesorder.salesorderid=vtiger_invoice.salesorderid inner join vtiger_invoicecf on vtiger_invoice.invoiceid = vtiger_invoicecf.invoiceid left join vtiger_invoicegrouprelation on vtiger_invoice.invoiceid=vtiger_invoicegrouprelation.invoiceid left join vtiger_groups on vtiger_groups.groupname=vtiger_invoicegrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 ";
 
 //Query for tickets
-$helpdesk_query=" select troubletickets.status AS ticketstatus, troubletickets.*,crmentity.* from troubletickets inner join ticketcf on ticketcf.ticketid = troubletickets.ticketid inner join crmentity on crmentity.crmid=troubletickets.ticketid left join ticketgrouprelation on troubletickets.ticketid=ticketgrouprelation.ticketid left join groups on groups.groupname=ticketgrouprelation.groupname left join contactdetails on troubletickets.parent_id=contactdetails.contactid left join account on account.accountid=troubletickets.parent_id left join users on crmentity.smownerid=users.id and troubletickets.ticketid = ticketcf.ticketid where crmentity.deleted=0";
+$helpdesk_query=" select vtiger_troubletickets.status AS vtiger_ticketstatus, vtiger_troubletickets.*,vtiger_crmentity.* from vtiger_troubletickets inner join vtiger_ticketcf on vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid left join vtiger_ticketgrouprelation on vtiger_troubletickets.ticketid=vtiger_ticketgrouprelation.ticketid left join vtiger_groups on vtiger_groups.groupname=vtiger_ticketgrouprelation.groupname left join vtiger_contactdetails on vtiger_troubletickets.parent_id=vtiger_contactdetails.contactid left join vtiger_account on vtiger_account.accountid=vtiger_troubletickets.parent_id left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id and vtiger_troubletickets.ticketid = vtiger_ticketcf.ticketid where vtiger_crmentity.deleted=0";
 
  /**  This function returns  the values for the graph, for any type of graph needed	 
         * Portions created by vtiger are Copyright (C) vtiger.
@@ -257,7 +257,7 @@
 	{
 		//Getting the cached image
 		$imgMap_fp = fopen($cache_file_name.'.map', "rb");
-		$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
+		$imgMap = fread($imgMap_fp, vtiger_filesize($cache_file_name.'.map'));
 		fclose($imgMap_fp);
 		$base_name_cache_file=basename($cache_file_name);
 		$ccc="cache/images/".$base_name_cache_file;
@@ -408,7 +408,7 @@
                             $graph_by="leadsource";
                             $graph_title=$mod_strings['salesbyleadsource'];
                             $module="Potentials";
-                            $where=" and potential.sales_stage like '%Closed Won%' ";
+                            $where=" and vtiger_potential.sales_stage like '%Closed Won%' ";
                             $query=$potential_query;
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
@@ -418,7 +418,7 @@
                     	$graph_by="accountid";
                          $graph_title=$mod_strings['salesbyaccount'];
                          $module="Potentials";
-                         $where=" and potential.sales_stage like '%Closed Won%' ";
+                         $where=" and vtiger_potential.sales_stage like '%Closed Won%' ";
                          $query=$potential_query;
                          echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }

Modified: vtigercrm/trunk/modules/Dashboard/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Dashboard/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -22,13 +22,13 @@
  
 $mod_strings = Array(
 'LBL_SALES_STAGE_FORM_TITLE'=>'Pipeline By Sales Stage',
-'LBL_SALES_STAGE_FORM_DESC'=>'Shows cumulative opportunity amounts by selected sales stages for selected users where the expected closed date is within the specificed date range.',
+'LBL_SALES_STAGE_FORM_DESC'=>'Shows cumulative opportunity amounts by selected sales stages for selected vtiger_users where the expected closed date is within the specificed date range.',
 'LBL_MONTH_BY_OUTCOME'=>'Pipeline By Month By Outcome',
-'LBL_MONTH_BY_OUTCOME_DESC'=>'Shows cumulative opportunity amounts by month by outcome for selected users where the expected closed date is within the specificed date range.  Outcome is based on whether the sales stage is Closed Won, Closed Lost or any other value.',
+'LBL_MONTH_BY_OUTCOME_DESC'=>'Shows cumulative opportunity amounts by month by outcome for selected vtiger_users where the expected closed date is within the specificed date range.  Outcome is based on whether the sales stage is Closed Won, Closed Lost or any other value.',
 'LBL_LEAD_SOURCE_FORM_TITLE'=>'All Opportunities By Lead Source',
-'LBL_LEAD_SOURCE_FORM_DESC'=>'Shows cumulative opportunity amounts by selected lead source for selected users.',
+'LBL_LEAD_SOURCE_FORM_DESC'=>'Shows cumulative opportunity amounts by selected lead source for selected vtiger_users.',
 'LBL_LEAD_SOURCE_BY_OUTCOME'=>'All Opportunities By Lead Source By Outcome',
-'LBL_LEAD_SOURCE_BY_OUTCOME_DESC'=>'Shows cumulative opportunity amounts by selected lead source by outcome for selected users where the expected closed date is within the specificed date range.  Outcome is based on whether the sales stage is Closed Won, Closed Lost or any other value.',
+'LBL_LEAD_SOURCE_BY_OUTCOME_DESC'=>'Shows cumulative opportunity amounts by selected lead source by outcome for selected vtiger_users where the expected closed date is within the specificed date range.  Outcome is based on whether the sales stage is Closed Won, Closed Lost or any other value.',
 'LBL_PIPELINE_FORM_TITLE_DESC'=>'Shows cumulative amounts by selected sales stages for your opportunities where the expected closed date is within the specificed date range.',
 'LBL_DATE_RANGE'=>'Date range is',
 'LBL_DATE_RANGE_TO'=>'to',
@@ -51,8 +51,8 @@
 'LBL_DATE_START'=>'Begin Date:',
 'LBL_DATE_END'=>'End Date:',
 //Added for 5.0 
-'LBL_NO_PERMISSION'=>'Your profile doesn\'t allow you view the Graph for this module',
-'LBL_NO_PERMISSION_FIELD'=>'Your profile doesn\'t allow you view the Graph for this module or for the Field',
+'LBL_NO_PERMISSION'=>'Your vtiger_profile doesn\'t allow you view the Graph for this module',
+'LBL_NO_PERMISSION_FIELD'=>'Your vtiger_profile doesn\'t allow you view the Graph for this module or for the Field',
 
 "leadsource" => "Leads By Source",
 "leadstatus" => "Leads By Status",

Modified: vtigercrm/trunk/modules/Emails/Choose.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/Choose.php (original)
+++ vtigercrm/trunk/modules/Emails/Choose.php Mon Jun 12 14:26:25 2006
@@ -16,15 +16,15 @@
 
 if ($pmodule=='Accounts')
 {
-	$querystr="select fieldid,fieldlabel,columnname,tablename from field where tabid=6 and uitype=13;"; 
+	$querystr="select vtiger_fieldid,fieldlabel,columnname,tablename from vtiger_field where vtiger_tabid=6 and uitype=13;"; 
 }
 elseif ($pmodule=='Contacts')
 {
-	$querystr="select fieldid,fieldlabel,columnname from field where tabid=4 and uitype=13;";
+	$querystr="select vtiger_fieldid,fieldlabel,columnname from vtiger_field where vtiger_tabid=4 and uitype=13;";
 }
 elseif ($pmodule=='Leads')
 {
-	$querystr="select fieldid,fieldlabel,columnname from field where tabid=7 and uitype=13;";
+	$querystr="select vtiger_fieldid,fieldlabel,columnname from vtiger_field where vtiger_tabid=7 and uitype=13;";
 }
 
 $result=$adb->query($querystr);

Modified: vtigercrm/trunk/modules/Emails/ChooseEmail.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/ChooseEmail.php (original)
+++ vtigercrm/trunk/modules/Emails/ChooseEmail.php Mon Jun 12 14:26:25 2006
@@ -14,15 +14,15 @@
 
 if ($pmodule=='Accounts')
 {
-	$querystr="select fieldid,fieldlabel,columnname,tablename from field where tabid=6 and uitype=13;"; 
+	$querystr="select vtiger_fieldid,fieldlabel,columnname,tablename from vtiger_field where vtiger_tabid=6 and uitype=13;"; 
 }
 elseif ($pmodule=='Contacts')
 {
-	$querystr="select fieldid,fieldlabel,columnname from field where tabid=4 and uitype=13;";
+	$querystr="select vtiger_fieldid,fieldlabel,columnname from vtiger_field where vtiger_tabid=4 and uitype=13;";
 }
 elseif ($pmodule=='Leads')
 {
-	$querystr="select fieldid,fieldlabel,columnname from field where tabid=7 and uitype=13;";
+	$querystr="select vtiger_fieldid,fieldlabel,columnname from vtiger_field where vtiger_tabid=7 and uitype=13;";
 }
 $result=$adb->query($querystr);
 $numrows = $adb->num_rows($result);

Modified: vtigercrm/trunk/modules/Emails/DetailView.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/DetailView.php (original)
+++ vtigercrm/trunk/modules/Emails/DetailView.php Mon Jun 12 14:26:25 2006
@@ -42,7 +42,7 @@
 	$focus->retrieve_entity_info($_REQUEST['record'],"Emails");
 	$log->info("Entity info successfully retrieved for DetailView.");
 	$focus->id = $_REQUEST['record'];
-	$query = 'select email_flag,from_email,to_email,cc_email,bcc_email from emaildetails where emailid ='.$focus->id;
+	$query = 'select email_flag,from_email,to_email,cc_email,bcc_email from vtiger_emaildetails where emailid ='.$focus->id;
 	$result = $adb->query($query);
     	$smarty->assign('FROM_MAIL',$adb->query_result($result,0,'from_email'));	
 	$to_email = ereg_replace('###',', ',$adb->query_result($result,0,'to_email'));

Modified: vtigercrm/trunk/modules/Emails/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/EditView.php (original)
+++ vtigercrm/trunk/modules/Emails/EditView.php Mon Jun 12 14:26:25 2006
@@ -61,7 +61,7 @@
 		$focus->mode = '';
 	}else
 	{
-		$query = 'select idlists,from_email,to_email,cc_email,bcc_email from emaildetails where emailid ='.$focus->id;
+		$query = 'select idlists,from_email,to_email,cc_email,bcc_email from vtiger_emaildetails where emailid ='.$focus->id;
 		$result = $adb->query($query);
 		$smarty->assign('FROM_MAIL',$adb->query_result($result,0,'from_email'));	
 		$to_email = ereg_replace('###',',',$adb->query_result($result,0,'to_email'));
@@ -88,15 +88,15 @@
 	$rec_id = $_REQUEST["rec_id"];
 
 	if($rec_type == "record_id") {
-		$rs = $adb->query("select setype from crmentity where crmid='".$rec_id."'");
+		$rs = $adb->query("select setype from vtiger_crmentity where crmid='".$rec_id."'");
 		$type = $adb->query_result($rs,0,'setype');
 
 		if($type == "Leads") 
-			$q = "select email as email1 from leaddetails where leadid='".$rec_id."'";
+			$q = "select email as email1 from vtiger_leaddetails where leadid='".$rec_id."'";
 		elseif ($type == "Contacts")
-			$q = "select email as email1 from contactdetails where contactid='".$rec_id."'";
+			$q = "select email as email1 from vtiger_contactdetails where contactid='".$rec_id."'";
 		elseif ($type == "Accounts")
-			$q = "select email1,email2 from account where accountid='".$rec_id."'";
+			$q = "select email1,email2 from vtiger_account where vtiger_accountid='".$rec_id."'";
 
 		$email1 = $adb->query_result($adb->query($q),0,"email1");
 	} elseif ($rec_type == "email_addy") {
@@ -217,7 +217,7 @@
         $smarty->assign("MODE", $focus->mode);
 }
 
-// Unimplemented until jscalendar language files are fixed
+// Unimplemented until jscalendar language vtiger_files are fixed
 
 $smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
 $smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
@@ -252,7 +252,7 @@
 
 if(isset($focus->parent_type) && $focus->parent_type != "") 
 {
-	$change_parent_button = "<input title='".$app_strings['LBL_CHANGE_BUTTON_TITLE']."' tabindex='2' accessKey='".$app_strings['LBL_CHANGE_BUTTON_KEY']."' type='button' class='button' value='".$app_strings['LBL_CHANGE_BUTTON_LABEL']."' name='button' LANGUAGE=javascript onclick='return window.open(\"index.php?module=\"+ document.EditView.parent_type.value + \"&action=Popup&html=Popup_picker&form=TasksEditView\",\"test\",\"width=600,height=400,resizable=1,scrollbars=1\");'>";
+	$change_parent_button = "<input title='".$app_strings['LBL_CHANGE_BUTTON_TITLE']."' vtiger_tabindex='2' accessKey='".$app_strings['LBL_CHANGE_BUTTON_KEY']."' type='button' class='button' value='".$app_strings['LBL_CHANGE_BUTTON_LABEL']."' name='button' LANGUAGE=javascript onclick='return window.open(\"index.php?module=\"+ document.EditView.parent_type.value + \"&action=Popup&html=Popup_picker&form=TasksEditView\",\"test\",\"width=600,height=400,resizable=1,scrollbars=1\");'>";
 	$smarty->assign("CHANGE_PARENT_BUTTON", $change_parent_button);
 }
 

Modified: vtigercrm/trunk/modules/Emails/Email.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/Email.php (original)
+++ vtigercrm/trunk/modules/Emails/Email.php Mon Jun 12 14:26:25 2006
@@ -35,7 +35,7 @@
 	var $log;
 	var $db;
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $mode;
 
@@ -46,15 +46,15 @@
 	var $time_start;
   	var $module_id="emailid";
 
-	var $rel_users_table = "salesmanactivityrel";
-	var $rel_contacts_table = "cntactivityrel";
-	var $rel_serel_table = "seactivityrel";
+	var $rel_users_table = "vtiger_salesmanactivityrel";
+	var $rel_contacts_table = "vtiger_cntactivityrel";
+	var $rel_serel_table = "vtiger_seactivityrel";
 
 	var $table_name = "activity";
-	var $tab_name = Array('crmentity','activity','seactivityrel','cntactivityrel','attachments');
-        var $tab_name_index = Array('crmentity'=>'crmid','activity'=>'activityid','seactivityrel'=>'activityid','cntactivityrel'=>'activityid','attachments'=>'attachmentsid');
-
-	// This is the list of fields that are in the lists.
+	var $tab_name = Array('vtiger_crmentity','vtiger_activity','vtiger_seactivityrel','vtiger_cntactivityrel','vtiger_attachments');
+        var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_activity'=>'activityid','vtiger_seactivityrel'=>'activityid','vtiger_cntactivityrel'=>'activityid','vtiger_attachments'=>'attachmentsid');
+
+	// This is the list of vtiger_fields that are in the lists.
         var $list_fields = Array(
 				       'Subject'=>Array('activity'=>'subject'),
 				       'Related to'=>Array('seactivityrel'=>'activityid'),
@@ -109,7 +109,7 @@
 		$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='.$adb->quote($id).' and crmentity.deleted=0';
+		$query = 'select vtiger_contactdetails.accountid, vtiger_contactdetails.contactid, vtiger_contactdetails.firstname,vtiger_contactdetails.lastname, vtiger_contactdetails.department, vtiger_contactdetails.title, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_contactdetails.emailoptout, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_contactdetails inner join vtiger_cntactivityrel on vtiger_cntactivityrel.contactid=vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname where vtiger_cntactivityrel.activityid='.$adb->quote($id).' and vtiger_crmentity.deleted=0';
 		$log->info("Contact Related List for Email is Displayed");
 		$log->debug("Exiting get_contacts method ...");
 		return GetRelatedList('Emails','Contacts',$focus,$query,$button,$returnset);
@@ -154,7 +154,7 @@
 	}	
 	// Mike Crowe Mod --------------------------------------------------------
 
-	/** Returns a list of the associated users
+	/** Returns a list of the associated vtiger_users
 	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
 	 * All Rights Reserved..
 	 * Contributor(s): ______________________________________..
@@ -169,7 +169,7 @@
 
 		$id = $_REQUEST['record'];
 
-		$query = 'SELECT users.id, users.first_name,users.last_name, users.user_name, users.email1, users.email2, users.yahoo_id, users.phone_home, users.phone_work, users.phone_mobile, users.phone_other, users.phone_fax from users inner join salesmanactivityrel on salesmanactivityrel.smid=users.id and salesmanactivityrel.activityid='.$adb->quote($id);
+		$query = 'SELECT vtiger_users.id, vtiger_users.first_name,vtiger_users.last_name, vtiger_users.user_name, vtiger_users.email1, vtiger_users.email2, vtiger_users.yahoo_id, vtiger_users.phone_home, vtiger_users.phone_work, vtiger_users.phone_mobile, vtiger_users.phone_other, vtiger_users.phone_fax from vtiger_users inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.smid=vtiger_users.id and vtiger_salesmanactivityrel.activityid='.$adb->quote($id);
 		$result=$adb->query($query);   
 
 		$noofrows = $adb->num_rows($result);
@@ -219,35 +219,35 @@
 	}
 
 	/**
-	  * Returns a list of the associated attachments and notes of the Email
+	  * Returns a list of the associated vtiger_attachments and vtiger_notes of the Email
 	  */
 	function get_attachments($id)
 	{
 		global $log;
 		$log->debug("Entering get_attachments(".$id.") method ...");
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename,
-			attachments.type  FileType,crm2.modifiedtime lastmodified,
-			seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid,
-			crm2.createdtime, notes.notecontent description, users.user_name
-		from notes
-			inner join senotesrel on senotesrel.notesid= notes.notesid
-			inner join crmentity on crmentity.crmid= senotesrel.crmid
-			inner join crmentity crm2 on crm2.crmid=notes.notesid and crm2.deleted=0
-			left join seattachmentsrel  on seattachmentsrel.crmid =notes.notesid
-			left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid
-			inner join users on crm2.smcreatorid= users.id
-		where crmentity.crmid=".$adb->quote($id);
+		$query = "select vtiger_notes.title,'Notes      '  ActivityType, vtiger_notes.filename,
+		vtiger_attachments.type  FileType,crm2.modifiedtime lastmodified,
+		vtiger_seattachmentsrel.attachmentsid vtiger_attachmentsid, vtiger_notes.notesid crmid,
+			crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		from vtiger_notes
+			inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+			left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$adb->quote($id);
 		$query .= ' union all ';
-		$query .= "select attachments.description title ,'Attachments'  ActivityType,
-			attachments.name filename, attachments.type FileType,crm2.modifiedtime lastmodified,
-			attachments.attachmentsid  attachmentsid,	seattachmentsrel.attachmentsid crmid,
-			crm2.createdtime, attachments.description, users.user_name
-		from attachments
-			inner join seattachmentsrel on seattachmentsrel.attachmentsid= attachments.attachmentsid
-			inner join crmentity on crmentity.crmid= seattachmentsrel.crmid
-			inner join crmentity crm2 on crm2.crmid=attachments.attachmentsid
-			inner join users on crm2.smcreatorid= users.id
-		where crmentity.crmid=".$adb->quote($id);
+		$query .= "select vtiger_attachments.description title ,'Attachments'  ActivityType,
+		vtiger_attachments.name filename, vtiger_attachments.type FileType,crm2.modifiedtime lastmodified,
+		vtiger_attachments.attachmentsid  vtiger_attachmentsid,vtiger_seattachmentsrel.attachmentsid crmid,
+			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		from vtiger_attachments
+			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$adb->quote($id);
 		
 		$log->info("Notes&Attachments Related List for Email is Displayed");
 		$log->debug("Exiting get_attachments method ...");
@@ -261,7 +261,7 @@
 	{
 		global $log;
 		$log->debug("Entering create_export_query(".$order_by.",".$where.") method ...");
-		$query = 'SELECT activity.activityid, activity.subject, activity.activitytype, attachments.name as filename, crmentity.description as email_content FROM activity inner join crmentity on crmentity.crmid=activity.activityid left join seattachmentsrel on activity.activityid=seattachmentsrel.crmid left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid where activity.activitytype="Emails" and crmentity.deleted=0';
+		$query = 'SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.activitytype, vtiger_attachments.name as filename, vtiger_crmentity.description as email_content FROM vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_seattachmentsrel on vtiger_activity.activityid=vtiger_seattachmentsrel.crmid left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid where vtiger_activity.activitytype="Emails" and vtiger_crmentity.deleted=0';
 
 		$log->debug("Exiting create_export_query method ...");
                 return $query;
@@ -312,7 +312,7 @@
 function get_to_emailids($module)
 {
 	global $adb;
-	$query = 'select columnname,fieldid from field where fieldid in('.ereg_replace(':',',',$_REQUEST["field_lists"]).')';
+	$query = 'select columnname,fieldid from vtiger_field where vtiger_fieldid in('.ereg_replace(':',',',$_REQUEST["field_lists"]).')';
     $result = $adb->query($query);
 	$columns = Array();
 	$idlists = '';
@@ -327,13 +327,13 @@
 	switch($module)
 	{
 		case 'Leads':
-			$query = 'select crmid,concat(lastname," ",firstname) as entityname,'.$columnlists.' from leaddetails inner join crmentity on crmentity.crmid=leaddetails.leadid left join leadscf on leadscf.leadid = leaddetails.leadid where crmentity.deleted=0 and crmentity.crmid in ('.$crmids.')';
+			$query = 'select crmid,concat(lastname," ",firstname) as entityname,'.$columnlists.' from vtiger_leaddetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid left join vtiger_leadscf on vtiger_leadscf.leadid = vtiger_leaddetails.leadid where vtiger_crmentity.deleted=0 and vtiger_crmentity.crmid in ('.$crmids.')';
 			break;
 		case 'Contacts':
-			$query = 'select crmid,concat(lastname," ",firstname) as entityname,'.$columnlists.' from contactdetails inner join crmentity on crmentity.crmid=contactdetails.contactid left join contactscf on contactscf.contactid = contactdetails.contactid where crmentity.deleted=0 and crmentity.crmid in ('.$crmids.')';
+			$query = 'select crmid,concat(lastname," ",firstname) as entityname,'.$columnlists.' from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid left join vtiger_contactscf on vtiger_contactscf.contactid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted=0 and vtiger_crmentity.crmid in ('.$crmids.')';
 			break;
 		case 'Accounts':
-			$query = 'select crmid,accountname as entityname,'.$columnlists.' from account inner join crmentity on crmentity.crmid=account.accountid left join accountscf on accountscf.accountid = account.accountid where crmentity.deleted=0 and crmentity.crmid in ('.$crmids.')';
+			$query = 'select crmid,accountname as entityname,'.$columnlists.' from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid left join vtiger_accountscf on vtiger_accountscf.accountid = vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_crmentity.crmid in ('.$crmids.')';
 			break;
 	}	
 	$result = $adb->query($query);

Modified: vtigercrm/trunk/modules/Emails/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/Forms.php (original)
+++ vtigercrm/trunk/modules/Emails/Forms.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 /*********************************************************************************
  * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Emails/Forms.php,v 1.4 2005/04/19 16:48:31 ray Exp $
  * Description:  Contains a variety of utility functions used to display UI
- * components such as form headers and footers.  Intended to be modified on a per
+ * components such as form vtiger_headers and footers.  Intended to be modified on a per
  * theme basis.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
@@ -211,7 +211,7 @@
 }
 
 /**
- * Create HTML form to enter a new record with the minimum necessary fields.
+ * Create HTML form to enter a new record with the minimum necessary vtiger_fields.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
@@ -226,7 +226,7 @@
 	global $adb;//for dynamic quickcreateform construction
 
 
-	// Unimplemented until jscalendar language files are fixed
+	// Unimplemented until jscalendar language vtiger_files are fixed
 	// global $current_language;
 	// global $default_language;
 	// global $cal_codes;
@@ -244,7 +244,7 @@
 	$default_date_start = date('Y-m-d');
 	$default_time_start = date('H:i');
 	$user_id = $current_user->id;
-	// Unimplemented until jscalendar language files are fixed
+	// Unimplemented until jscalendar language vtiger_files are fixed
 	// $cal_lang = (empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language];
 	$cal_lang = "en";
 	$cal_dateformat = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
@@ -252,7 +252,7 @@
 	$qcreate_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
 
 
-	$qcreate_get_field="select * from field where tabid=10 and quickcreate=0 order by quickcreatesequence";
+	$qcreate_get_field="select * from vtiger_field where vtiger_tabid=10 and quickcreate=0 order by quickcreatesequence";
 	$qcreate_get_result=$adb->query($qcreate_get_field);
 	$qcreate_get_noofrows=$adb->num_rows($qcreate_get_result);
 
@@ -345,9 +345,9 @@
 inputField : "QCK_date_start", ifFormat : "'.$cal_dateformat.'", showsTime : false, button : "jscal_trigger", singleClick : true, step : 1
 });
 
-		var fieldname = new Array('.$fieldName.')
-		var fieldlabel = new Array('.$fieldLabel.')
-		var fielddatatype = new Array('.$fldDataType.')
+		var vtiger_fieldname = new Array('.$fieldName.')
+		var vtiger_fieldlabel = new Array('.$fieldLabel.')
+		var vtiger_fielddatatype = new Array('.$fldDataType.')
 
 	</script>';
 

Modified: vtigercrm/trunk/modules/Emails/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/ListView.php (original)
+++ vtigercrm/trunk/modules/Emails/ListView.php Mon Jun 12 14:26:25 2006
@@ -88,14 +88,14 @@
 $display_title = $mod_strings['LBL_LIST_FORM_TITLE'];
 if($email_title)$display_title = $email_title;
 
-//to get the search field if exists
+//to get the search vtiger_field if exists
 if(isset($_REQUEST['search']) && $_REQUEST['search'] != '' && $_REQUEST['search_text'] != '')
 {
 	$url_string .= "&search=".$_REQUEST['search']."&search_field=".$_REQUEST['search_field']."&search_text=".$_REQUEST['search_text'];
 	if($_REQUEST['search_field'] != 'join')
 		$where = $_REQUEST['search_field']." like '%".$_REQUEST['search_text']."%'";	
 	else
-		$where = "(subject like '%".$_REQUEST['search_text']."%' OR users.user_name like '%".$_REQUEST['search_text']."%')";	
+		$where = "(subject like '%".$_REQUEST['search_text']."%' OR vtiger_users.user_name like '%".$_REQUEST['search_text']."%')";	
 }
 
 
@@ -118,23 +118,23 @@
 }
 if($_REQUEST['folderid'] =='2')
 {
-	$list_query .= "AND seactivityrel.crmid in (select contactid from contactdetails) AND emaildetails.email_flag !='WEBMAIL'";
+	$list_query .= "AND vtiger_seactivityrel.crmid in (select contactid from vtiger_contactdetails) AND vtiger_emaildetails.email_flag !='WEBMAIL'";
 }
 if($_REQUEST['folderid'] =='3')
 {
-	$list_query .= "AND seactivityrel.crmid in (select accountid from account)";	
+	$list_query .= "AND vtiger_seactivityrel.crmid in (select vtiger_accountid from vtiger_account)";	
 }
 if($_REQUEST['folderid'] =='4')
 {
-	$list_query .= "AND seactivityrel.crmid in (select leadid from leaddetails)";	
+	$list_query .= "AND vtiger_seactivityrel.crmid in (select leadid from vtiger_leaddetails)";	
 }
 if($_REQUEST['folderid'] =='5')
 {
-	$list_query .= "AND salesmanactivityrel.smid in (select id from users)";	
+	$list_query .= "AND vtiger_salesmanactivityrel.smid in (select id from vtiger_users)";	
 }
 if($_REQUEST['folderid'] =='6')
 {
-	$list_query .= "AND emaildetails.email_flag ='WEBMAIL'";	
+	$list_query .= "AND vtiger_emaildetails.email_flag ='WEBMAIL'";	
 }
 if(isset($order_by) && $order_by != '')
 {

Modified: vtigercrm/trunk/modules/Emails/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/Save.php (original)
+++ vtigercrm/trunk/modules/Emails/Save.php Mon Jun 12 14:26:25 2006
@@ -21,11 +21,11 @@
  * Contributor(s): ______________________________________..
  ********************************************************************************/
 
-//Added on 09-11-2005 to avoid loading the webmail files in Email process
+//Added on 09-11-2005 to avoid loading the webmail vtiger_files in Email process
 if($_REQUEST['smodule'] != '')
 {
 	define('SM_PATH','modules/squirrelmail-1.4.4/');
-	/* SquirrelMail required files. */
+	/* SquirrelMail required vtiger_files. */
 	require_once(SM_PATH . 'functions/strings.php');
 	require_once(SM_PATH . 'functions/imap_general.php');
 	require_once(SM_PATH . 'functions/imap_messages.php');
@@ -130,7 +130,7 @@
 	global $log;
 	$log->debug("Entering checkIfContactExists(".$mailid.") method ...");
 	global $adb;
-	$sql = "select contactid from contactdetails inner join crmentity on crmentity.crmid=contactdetails.contactid where crmentity.deleted=0 and email= ".$adb->quote($mailid);
+	$sql = "select contactid from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid where vtiger_crmentity.deleted=0 and email= ".$adb->quote($mailid);
 	$result = $adb->query($sql);
 	$numRows = $adb->num_rows($result);
 	if($numRows > 0)
@@ -153,10 +153,10 @@
 $focus->column_fields["date_start"]= date('Y-m-d');
 $focus->save("Emails");
 
-//saving the email details in emaildetails table
+//saving the email details in vtiger_emaildetails vtiger_table
 $return_id = $focus->id;
 $email_id = $return_id;
-$query = 'select emailid from emaildetails where emailid ='.$email_id;
+$query = 'select emailid from vtiger_emaildetails where emailid ='.$email_id;
 $result = $adb->query($query);
 if(isset($_REQUEST["hidden_toid"]) && $_REQUEST["hidden_toid"]!='')
 	$all_to_ids = ereg_replace(",","###",$_REQUEST["hidden_toid"]);
@@ -167,10 +167,10 @@
 $all_bcc_ids = ereg_replace(",","###",$_REQUEST["bccmail"]);
 if($adb->num_rows($result) > 0)
 {
-	$query = 'update emaildetails set to_email="'.$all_to_ids.'",cc_email="'.$all_cc_ids.'",bcc_email="'.$all_bcc_ids.'",idlists="'.$_REQUEST["parent_id"].'",email_flag="SAVED" where emailid = '.$email_id;
+	$query = 'update vtiger_emaildetails set to_email="'.$all_to_ids.'",cc_email="'.$all_cc_ids.'",bcc_email="'.$all_bcc_ids.'",idlists="'.$_REQUEST["parent_id"].'",email_flag="SAVED" where emailid = '.$email_id;
 }else
 {
-	$query = 'insert into emaildetails values ('.$email_id.',"","'.$all_to_ids.'","'.$all_cc_ids.'","'.$all_bcc_ids.'","","'.$_REQUEST["parent_id"].'","SAVED")';
+	$query = 'insert into vtiger_emaildetails values ('.$email_id.',"","'.$all_to_ids.'","'.$all_cc_ids.'","'.$all_bcc_ids.'","","'.$_REQUEST["parent_id"].'","SAVED")';
 }
 $adb->query($query);
 

Modified: vtigercrm/trunk/modules/Emails/class.phpmailer.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/class.phpmailer.php (original)
+++ vtigercrm/trunk/modules/Emails/class.phpmailer.php Mon Jun 12 14:26:25 2006
@@ -24,7 +24,7 @@
     /////////////////////////////////////////////////
 
     /**
-     * Email priority (1 = High, 3 = Normal, 5 = low).
+     * Email vtiger_priority (1 = High, 3 = Normal, 5 = low).
      * @var int
      */
     var $Priority          = 3;
@@ -134,7 +134,7 @@
     var $ConfirmReadingTo  = "";
 
     /**
-     *  Sets the hostname to use in Message-Id and Received headers
+     *  Sets the hostname to use in Message-Id and Received vtiger_headers
      *  and as default HELO string. If empty, the value returned
      *  by SERVER_NAME is used or 'localhost.localdomain'.
      *  @var string
@@ -613,7 +613,7 @@
     /////////////////////////////////////////////////
 
     /**
-     * Creates recipient headers.  
+     * Creates recipient vtiger_headers.  
      * @access private
      * @return string
      */
@@ -805,7 +805,7 @@
                        "<" . trim($this->ConfirmReadingTo) . ">");
         }
 
-        // Add custom headers
+        // Add custom vtiger_headers
         for($index = 0; $index < count($this->CustomHeader); $index++)
         {
             $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), 
@@ -984,7 +984,7 @@
     /////////////////////////////////////////////////
 
     /**
-     * Adds an attachment from a path on the filesystem.
+     * Adds an attachment from a path on the vtiger_filesystem.
      * Returns false if the file could not be found
      * or accessed.
      * @param string $path Path to the attachment.
@@ -1019,7 +1019,7 @@
     }
 
     /**
-     * Attaches all fs, string, and binary attachments to the message.
+     * Attaches all fs, string, and binary vtiger_attachments to the message.
      * Returns an empty string on failure.
      * @access private
      * @return string
@@ -1028,7 +1028,7 @@
         // Return text of body
         $mime = array();
 
-        // Add all attachments
+        // Add all vtiger_attachments
         for($i = 0; $i < count($this->attachment); $i++)
         {
             // Check for string attachment
@@ -1089,7 +1089,7 @@
         }
         $magic_quotes = get_magic_quotes_runtime();
         set_magic_quotes_runtime(0);
-        $file_buffer = fread($fd, filesize($path));
+        $file_buffer = fread($fd, vtiger_filesize($path));
         $file_buffer = $this->EncodeString($file_buffer, $encoding);
         fclose($fd);
         set_magic_quotes_runtime($magic_quotes);
@@ -1195,7 +1195,7 @@
         // Replace every high ascii, control and = characters
         $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
                   "'='.sprintf('%02X', ord('\\1'))", $encoded);
-        // Replace every spaces and tabs when it's the last character on a line
+        // Replace every spaces and vtiger_tabs when it's the last character on a line
         $encoded = preg_replace("/([\011\040])".$this->LE."/e",
                   "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);
 
@@ -1365,8 +1365,8 @@
     }
 
     /**
-     * Clears all previously set filesystem, string, and binary
-     * attachments.  Returns void.
+     * Clears all previously set vtiger_filesystem, string, and binary
+     * vtiger_attachments.  Returns void.
      * @return void
      */
     function ClearAttachments() {
@@ -1374,7 +1374,7 @@
     }
 
     /**
-     * Clears all custom headers.  Returns void.
+     * Clears all custom vtiger_headers.  Returns void.
      * @return void
      */
     function ClearCustomHeaders() {

Modified: vtigercrm/trunk/modules/Emails/class.smtp.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/class.smtp.php (original)
+++ vtigercrm/trunk/modules/Emails/class.smtp.php Mon Jun 12 14:26:25 2006
@@ -126,7 +126,7 @@
         if(substr(PHP_OS, 0, 3) != "WIN")
            socket_set_timeout($this->smtp_conn, $tval, 0);
 
-        # get any announcement stuff
+        # get any vtiger_announcement stuff
         $announce = $this->get_lines();
 
         # set the timeout  of any socket functions at 1/10 of a second
@@ -252,8 +252,8 @@
     /**
      * Issues a data command and sends the msg_data to the server
      * finializing the mail transaction. $msg_data is the message
-     * that is to be send with the headers. Each header needs to be
-     * on a single line followed by a <CRLF> with the message headers
+     * that is to be send with the vtiger_headers. Each header needs to be
+     * on a single line followed by a <CRLF> with the message vtiger_headers
      * and the message body being seperated by and additional <CRLF>.
      *
      * Implements rfc 821: DATA <CRLF>
@@ -313,13 +313,13 @@
         $msg_data = str_replace("\r","\n",$msg_data);
         $lines = explode("\n",$msg_data);
 
-        # we need to find a good way to determine is headers are
+        # we need to find a good way to determine is vtiger_headers are
         # in the msg_data or if it is a straight msg body
-        # currently I'm assuming rfc 822 definitions of msg headers
-        # and if the first field of the first line (':' sperated)
+        # currently I'm assuming rfc 822 definitions of msg vtiger_headers
+        # and if the first vtiger_field of the first line (':' sperated)
         # does not contain a space then it _should_ be a header
         # and we can process all lines before a blank "" line as
-        # headers.
+        # vtiger_headers.
         $field = substr($lines[0],0,strpos($lines[0],":"));
         $in_headers = false;
         if(!empty($field) && !strstr($field," ")) {
@@ -345,9 +345,9 @@
 
                 $lines_out[] = substr($line,0,$pos);
                 $line = substr($line,$pos + 1);
-                # if we are processing headers we need to
+                # if we are processing vtiger_headers we need to
                 # add a LWSP-char to the front of the new line
-                # rfc 822 on long msg headers
+                # rfc 822 on long msg vtiger_headers
                 if($in_headers) {
                     $line = "\t" . $line;
                 }
@@ -805,7 +805,7 @@
      * $from. Returns true if successful or false otherwise. If True
      * the mail transaction is started and then one or more Recipient
      * commands may be called followed by a Data command. This command
-     * will send the message to the users terminal if they are logged
+     * will send the message to the vtiger_users terminal if they are logged
      * in.
      *
      * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
@@ -853,7 +853,7 @@
      * $from. Returns true if successful or false otherwise. If True
      * the mail transaction is started and then one or more Recipient
      * commands may be called followed by a Data command. This command
-     * will send the message to the users terminal if they are logged
+     * will send the message to the vtiger_users terminal if they are logged
      * in and send them an email.
      *
      * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
@@ -901,7 +901,7 @@
      * $from. Returns true if successful or false otherwise. If True
      * the mail transaction is started and then one or more Recipient
      * commands may be called followed by a Data command. This command
-     * will send the message to the users terminal if they are logged
+     * will send the message to the vtiger_users terminal if they are logged
      * in or mail it to them if they are not.
      *
      * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>

Modified: vtigercrm/trunk/modules/Emails/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Emails/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -33,7 +33,7 @@
 'LBL_LIST_DATE'=>'Date Sent',
 'LBL_LIST_TIME'=>'Time Sent',
 
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
 'LBL_DATE_SENT'=>'Date Sent:',
 'LBL_SUBJECT'=>'Subject :',
 'LBL_BODY'=>'Body:',
@@ -99,7 +99,7 @@
 'LBL_NEW_ACCOUNT'=>'New Account',
 'LBL_ACCOUNT_TITLE'=>'Accounts',
 
-// Added fields after vtiger4 - Beta
+// Added vtiger_fields after vtiger4 - Beta
 'LBL_USER_TITLE'=>'Users',
 'LBL_NEW_USER'=>'New User',
 

Modified: vtigercrm/trunk/modules/Emails/mail.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/mail.php (original)
+++ vtigercrm/trunk/modules/Emails/mail.php Mon Jun 12 14:26:25 2006
@@ -16,13 +16,13 @@
   *   $module 		-- current module 
   *   $to_email 	-- to email address 
   *   $from_name	-- currently loggedin user name
-  *   $from_email	-- currently loggedin users's email id. you can give as '' if you are not in HelpDesk module
+  *   $from_email	-- currently loggedin vtiger_users's email id. you can give as '' if you are not in HelpDesk module
   *   $subject		-- subject of the email you want to send
   *   $contents		-- body of the email you want to send
   *   $cc		-- add email ids with comma seperated. - optional 
   *   $bcc		-- add email ids with comma seperated. - optional.
-  *   $attachment	-- whether we want to attach the currently selected file or all files.[values = current,all] - optional
-  *   $emailid		-- id of the email object which will be used to get the attachments
+  *   $attachment	-- whether we want to attach the currently selected file or all vtiger_files.[values = current,all] - optional
+  *   $emailid		-- id of the email object which will be used to get the vtiger_attachments
   */
 function send_mail($module,$to_email,$from_name,$from_email,$subject,$contents,$cc='',$bcc='',$attachment='',$emailid='')
 {
@@ -35,7 +35,7 @@
 
 	$adb->println("To id => '".$to_email."'\nSubject ==>'".$subject."'\nContents ==> '".$contents."'");
 
-	//Get the email id of assigned_to user -- pass the value and name, name must be "user_name" or "id"(field names of users table)
+	//Get the email id of assigned_to user -- pass the value and name, name must be "user_name" or "id"(field names of vtiger_users vtiger_table)
 	//$to_email = getUserEmailId('id',$assigned_user_id);
 
 	//if module is HelpDesk then from_email will come based on support email id 
@@ -65,7 +65,7 @@
 }
 
 /**	Function to get the user Email id based on column name and column value
-  *	$name -- column name of the users table 
+  *	$name -- column name of the vtiger_users vtiger_table 
   *	$val  -- column value 
   */
 function getUserEmailId($name,$val)
@@ -74,9 +74,9 @@
 	$adb->println("Inside the function getUserEmailId. --- ".$name." = '".$val."'");
 	if($val != '')
 	{
-		//$sql = "select email1, email2, yahoo_id from users where ".$name." = '".$val."'";
+		//$sql = "select email1, email2, yahoo_id from vtiger_users where ".$name." = '".$val."'";
 		//done to resolve the PHP5 specific behaviour
-		$sql = "select email1, email2, yahoo_id from users where ".$name." = ".$adb->quote($val);
+		$sql = "select email1, email2, yahoo_id from vtiger_users where ".$name." = ".$adb->quote($val);
 		$res = $adb->query($sql);
 		$email = $adb->query_result($res,0,'email1');
 		if($email == '')
@@ -106,7 +106,7 @@
 	global $adb;
 	$adb->println("Inside the function addSignature");
 
-	$sign = $adb->query_result($adb->query("select signature from users where user_name=".$adb->quote($fromname)),0,"signature");
+	$sign = $adb->query_result($adb->query("select signature from vtiger_users where user_name=".$adb->quote($fromname)),0,"signature");
 	if($sign != '')
 	{
 		$contents .= '<br><br><font color=darkgrey>'.$sign.'</font>';
@@ -127,9 +127,9 @@
   *	$from_name	-- from name which will be displayed in the mail
   *	$to_email 	-- to email address  -- This can be an email in a single string, a comma separated
   *			   list of emails or an array of email addresses
-  *	$attachment	-- whether we want to attach the currently selected file or all files.
+  *	$attachment	-- whether we want to attach the currently selected file or all vtiger_files.
   				[values = current,all] - optional
-  *	$emailid	-- id of the email object which will be used to get the attachments - optional
+  *	$emailid	-- id of the email object which will be used to get the vtiger_attachments - optional
   */
 function setMailerProperties($mail,$subject,$contents,$from_email,$from_name,$to_email,$attachment='',$emailid='')
 {
@@ -147,7 +147,7 @@
 
 	//Handle the from name and email for HelpDesk
 	$mail->From = $from_email;
-	$rs = $adb->query("select first_name,last_name from users where user_name='".$from_name."'");
+	$rs = $adb->query("select first_name,last_name from vtiger_users where user_name='".$from_name."'");
 	if($adb->num_rows($rs) > 0)
 		$from_name = $adb->query_result($rs,0,"first_name")." ".$adb->query_result($rs,0,"last_name");
 
@@ -176,7 +176,7 @@
 		addAttachment(&$mail,$_FILES['filename']['name'],$emailid);
 	}
 
-	//This will add all the files which are related to this record or email
+	//This will add all the vtiger_files which are related to this record or email
 	if($attachment == 'all')
 	{
 		addAllAttachments(&$mail,$emailid);
@@ -197,7 +197,7 @@
 	global $adb;
 	$adb->println("Inside the function setMailServerProperties");
 
-	$res = $adb->query("select * from systems where server_type='email'");
+	$res = $adb->query("select * from vtiger_systems where server_type='email'");
 	$server = $adb->query_result($res,0,'server');
         $username = $adb->query_result($res,0,'server_username');
         $password = $adb->query_result($res,0,'server_password');
@@ -231,17 +231,17 @@
         }
 }
 
-/**     Function to add all the files as attachment with the mail object
+/**     Function to add all the vtiger_files as attachment with the mail object
   *     $mail -- reference of the mail object
-  *     $record -- email id ie., record id which is used to get the all attachments from database
+  *     $record -- email id ie., record id which is used to get the all vtiger_attachments from database
   */
 function addAllAttachments($mail,$record)
 {
 	global $adb, $root_directory;
         $adb->println("Inside the function addAllAttachments");
 
-	//Retrieve the files from database where avoid the file which has been currently selected
-	$sql = "select attachments.* from attachments inner join seattachmentsrel on attachments.attachmentsid = seattachmentsrel.attachmentsid inner join crmentity on crmentity.crmid = attachments.attachmentsid where crmentity.deleted=0 and seattachmentsrel.crmid=".$record;
+	//Retrieve the vtiger_files from database where avoid the file which has been currently selected
+	$sql = "select vtiger_attachments.* from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_attachments.attachmentsid = vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid where vtiger_crmentity.deleted=0 and vtiger_seattachmentsrel.crmid=".$record;
 	$res = $adb->query($sql);
 	$count = $adb->num_rows($res);
 
@@ -316,7 +316,7 @@
 
 /**	Function to get the Parent email id from HelpDesk to send the details about the ticket via email
   *	$returnmodule -- Parent module value. Contact or Account for send email about the ticket details
-  *	$parentid -- id of the parent ie., contact or account
+  *	$parentid -- id of the parent ie., contact or vtiger_account
   */
 function getParentMailId($parentmodule,$parentid)
 {
@@ -325,14 +325,14 @@
 
         if($parentmodule == 'Contacts')
         {
-                $tablename = 'contactdetails';
+                $tablename = 'vtiger_contactdetails';
                 $idname = 'contactid';
 		$first_email = 'email';
 		$second_email = 'yahooid';
         }
         if($parentmodule == 'Accounts')
         {
-                $tablename = 'account';
+                $tablename = 'vtiger_account';
                 $idname = 'accountid';
 		$first_email = 'email1';
 		$second_email = 'email2';
@@ -451,7 +451,7 @@
 			}
 			elseif($status_str[1] == '0')
 			{
-				$adb->println("first elseif part - status will be 0 which is the case of assigned to users's email is empty.");
+				$adb->println("first elseif part - status will be 0 which is the case of assigned to vtiger_users's email is empty.");
 				$errorstr .= '<br><b><font color=red> Mail could not be sent to the assigned to user. Please check the assigned to user email id...</font></b>';
 				//Added to display the message about the CC && BCC mail sending status
 				if($status_str[0] == 'cc_success')

Modified: vtigercrm/trunk/modules/Emails/mailSelect.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/mailSelect.php (original)
+++ vtigercrm/trunk/modules/Emails/mailSelect.php Mon Jun 12 14:26:25 2006
@@ -24,15 +24,15 @@
 $smarty = new vtigerCRM_Smarty;
 if ($pmodule=='Accounts')
 {
-	$querystr="select fieldid,fieldlabel,columnname,tablename from field where tabid=6 and uitype=13;"; 
+	$querystr="select vtiger_fieldid,fieldlabel,columnname,tablename from vtiger_field where vtiger_tabid=6 and uitype=13;"; 
 }
 elseif ($pmodule=='Contacts')
 {
-	$querystr="select fieldid,fieldlabel,columnname from field where tabid=4 and uitype=13;";
+	$querystr="select vtiger_fieldid,fieldlabel,columnname from vtiger_field where vtiger_tabid=4 and uitype=13;";
 }
 elseif ($pmodule=='Leads')
 {
-	$querystr="select fieldid,fieldlabel,columnname from field where tabid=7 and uitype=13;";
+	$querystr="select vtiger_fieldid,fieldlabel,columnname from vtiger_field where vtiger_tabid=7 and uitype=13;";
 }
 $result=$adb->query($querystr);
 $numrows = $adb->num_rows($result);

Modified: vtigercrm/trunk/modules/Emails/mailbox.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/mailbox.php (original)
+++ vtigercrm/trunk/modules/Emails/mailbox.php Mon Jun 12 14:26:25 2006
@@ -73,7 +73,7 @@
 	      
 	   function handleFile(nr) {
 	   	if (b != "ie") {
- 	      		alert("This feature is currently only available for Microsoft Internet Explorer 5.5+ users\n\nWait for an update!");
+ 	      		alert("This feature is currently only available for Microsoft Internet Explorer 5.5+ vtiger_users\n\nWait for an update!");
 	   	} else {
 	   		check = confirm("Do you want to download the file ?");
 			if (check) {

Modified: vtigercrm/trunk/modules/Emails/mailsend.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/mailsend.php (original)
+++ vtigercrm/trunk/modules/Emails/mailsend.php Mon Jun 12 14:26:25 2006
@@ -35,7 +35,7 @@
 	$grp_obj = new GetGroupUsers();
 	$grp_obj->getAllUsersInGroup(getGrpId($_REQUEST['assigned_group_name']));
 	$users_list = constructList($grp_obj->group_users,'INTEGER');
-	$sql = "select first_name, last_name, email1, email2, yahoo_id from users where id in ".$users_list;
+	$sql = "select first_name, last_name, email1, email2, yahoo_id from vtiger_users where id in ".$users_list;
 	$res = $adb->query($sql);
 	$user_email = '';
 	while ($user_info = $adb->fetch_array($res))
@@ -73,7 +73,7 @@
 {
 	$mail_status = send_mail('Emails',$to_email,$current_user->user_name,'',$_REQUEST['subject'],$_REQUEST['description'],$cc,$bcc,'all',$focus->id);
 	
-	$query = 'update emaildetails set email_flag ="SENT" where emailid='.$focus->id;
+	$query = 'update vtiger_emaildetails set email_flag ="SENT" where emailid='.$focus->id;
 	$adb->query($query);
 	//set the errorheader1 to 1 if the mail has not been sent to the assigned to user
 	if($mail_status != 1)//when mail send fails
@@ -105,8 +105,8 @@
 	$mycrmid=$realid[0];
 	if($realid[1] == -1)
 	{
-		//handle the mail send to users
-		$emailadd = $adb->query_result($adb->query("select email1 from users where id=$mycrmid"),0,'email1');
+		//handle the mail send to vtiger_users
+		$emailadd = $adb->query_result($adb->query("select email1 from vtiger_users where id=$mycrmid"),0,'email1');
 		$pmodule = 'Users';
 		$description = getMergedDescription($focus->column_fields['description'],$mycrmid,$pmodule);
 		$mail_status = send_mail('Emails',$emailadd,$current_user->user_name,'',$focus->column_fields['subject'],$description,'','','all',$focus->id);
@@ -115,12 +115,12 @@
 	}
 	else
 	{
-		//Send mail to account or lead or contact based on their ids
+		//Send mail to vtiger_account or lead or contact based on their ids
 		$pmodule=getSalesEntityType($mycrmid);
 		for ($j=1;$j<$nemail;$j++)
 		{
 			$temp=$realid[$j];
-			$myquery='Select columnname from field where fieldid='.$adb->quote($temp);
+			$myquery='Select columnname from vtiger_field where vtiger_fieldid='.$adb->quote($temp);
 			$fresult=$adb->query($myquery);			
 			if ($pmodule=='Contacts')
 			{
@@ -180,7 +180,7 @@
 {
 	global $adb;
 	$date_var = date('Ymd');
-	$query = 'update activity set date_start ='.$date_var.' where activityid = '.$returnid;
+	$query = 'update vtiger_activity set date_start ='.$date_var.' where vtiger_activityid = '.$returnid;
 	$adb->query($query);
 }
 //The following function call is used to parse and form a encoded error message and then pass to result page

Modified: vtigercrm/trunk/modules/Emails/sendmail.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/sendmail.php (original)
+++ vtigercrm/trunk/modules/Emails/sendmail.php Mon Jun 12 14:26:25 2006
@@ -38,12 +38,12 @@
 	
 	$noofrows = $adb->num_rows($result);
 
-	$dbQuery = 'select attachments.*, activity.subject, crmentity.description  from activity inner join crmentity on crmentity.crmid = activity.activityid left join seattachmentsrel on seattachmentsrel.crmid = activity.activityid left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid where crmentity.crmid = '.$adb->quote($_REQUEST['return_id']);
+	$dbQuery = 'select vtiger_attachments.*, vtiger_activity.subject, vtiger_crmentity.description  from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_activity.activityid left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid = vtiger_activity.activityid left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid where vtiger_crmentity.crmid = '.$adb->quote($_REQUEST['return_id']);
 
         $result1 = $adb->query($dbQuery) or die("Couldn't get file list");
 	$temparray = $adb->fetch_array($result1);
 
-	$notequery = 'select  attachments.*, notes.notesid, notes.filename,notes.notecontent  from notes inner join senotesrel on senotesrel.notesid= notes.notesid inner join crmentity on crmentity.crmid= senotesrel.crmid left join seattachmentsrel  on seattachmentsrel.crmid =notes.notesid left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid where crmentity.crmid='.$adb->quote($_REQUEST['return_id']);
+	$notequery = 'select  vtiger_attachments.*, vtiger_notes.notesid, vtiger_notes.filename,vtiger_notes.notecontent  from vtiger_notes inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid where vtiger_crmentity.crmid='.$adb->quote($_REQUEST['return_id']);
 	$result2 = $adb->query($notequery) or die("Couldn't get file list");
 
 	$mail = new PHPMailer();
@@ -52,7 +52,7 @@
 
 	$DESCRIPTION = $adb->query_result($result1,0,"description");
 	$DESCRIPTION .= '<br><br>';
-	$DESCRIPTION .= '<font color=darkgrey>'.nl2br($adb->query_result($adb->query("select * from users where user_name=".$adb->quote($from)),0,"signature")).'</font>';
+	$DESCRIPTION .= '<font color=darkgrey>'.nl2br($adb->query_result($adb->query("select * from vtiger_users where user_name=".$adb->quote($from)),0,"signature")).'</font>';
 
         $mail->Body    = nl2br($DESCRIPTION);
 	$initialfrom = $from;
@@ -60,7 +60,7 @@
 
 	if($mail_server=='')
 	{
-	        $mailserverresult = $adb->query("select * from systems where server_type = 'email'");
+	        $mailserverresult = $adb->query("select * from vtiger_systems where server_type = 'email'");
         	$mail_server = $adb->query_result($mailserverresult,0,'server');
 		$mail_server_username = $adb->query_result($mailserverresult,0,'server_username');
                 $mail_server_password = $adb->query_result($mailserverresult,0,'server_password');
@@ -73,9 +73,9 @@
 	$mail->SMTPAuth = $smtp_auth;
 	$mail->Username = $mail_server_username;
 	$mail->Password = $mail_server_password;
-	//$mail->From = $adb->query_result($adb->query("select * from users where user_name='".$from."'"),0,"email1");
-
-	$mail->From = $adb->query_result($adb->query("select * from users where user_name=".$adb->quote($from)),0,"email1");
+	//$mail->From = $adb->query_result($adb->query("select * from vtiger_users where user_name='".$from."'"),0,"email1");
+
+	$mail->From = $adb->query_result($adb->query("select * from vtiger_users where user_name=".$adb->quote($from)),0,"email1");
 	$mail->FromName = $initialfrom;
 	$mail->AddReplyTo($from);
 	$mail->WordWrap = 50;
@@ -93,7 +93,7 @@
 		if(!@fwrite($handle,base64_decode($fileContent),$filesize)){}
 		if(!@fclose($handle)){}
 
-		$mail->AddAttachment($root_directory."/test/upload/".$filename);//temparray['filename']) // add attachments
+		$mail->AddAttachment($root_directory."/test/upload/".$filename);//temparray['filename']) // add vtiger_attachments
 		$log->info("File '".$filename."' is attached with the mail.");
 	}
 
@@ -108,7 +108,7 @@
 		if(!@fwrite($handle,base64_decode($fileContent),$filesize)){}
 		if(!@fclose($handle)){}
 
-		$mail->AddAttachment($root_directory."/test/upload/".$filename);//temparray['filename']) // add attachments
+		$mail->AddAttachment($root_directory."/test/upload/".$filename);//temparray['filename']) // add vtiger_attachments
 		$log->info("File '".$filename."' is attached with the mail.");
 	}
 

Modified: vtigercrm/trunk/modules/Emails/updateRelations.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/updateRelations.php (original)
+++ vtigercrm/trunk/modules/Emails/updateRelations.php Mon Jun 12 14:26:25 2006
@@ -24,7 +24,7 @@
 		if($id != '')
 		{
 			$record = $_REQUEST["parentid"];
-			$sql = "insert into seactivityrel values (". $adb->quote($id).",".$adb->quote($_REQUEST["parentid"]) .")";
+			$sql = "insert into vtiger_seactivityrel values (". $adb->quote($id).",".$adb->quote($_REQUEST["parentid"]) .")";
 			$adb->query($sql);
 		}
 	}
@@ -33,8 +33,8 @@
 elseif (isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
 {
 	$record = $_REQUEST["parid"];
-	//$sql = "insert into seactivityrel values (". $_REQUEST["entityid"] .",".$_REQUEST["parid"] .")";
-	$sql = "insert into seactivityrel values (". $adb->quote($_REQUEST["entityid"]).",".$adb->quote($_REQUEST["parid"]) .")";
+	//$sql = "insert into vtiger_seactivityrel values (". $_REQUEST["entityid"] .",".$_REQUEST["parid"] .")";
+	$sql = "insert into vtiger_seactivityrel values (". $adb->quote($_REQUEST["entityid"]).",".$adb->quote($_REQUEST["parid"]) .")";
 	$adb->query($sql);
 	header("Location: index.php?action=CallRelatedList&module=Emails&record=".$record);
 }
@@ -44,8 +44,8 @@
 if(isset($_REQUEST['user_id']) && $_REQUEST['user_id'] != '')
 {
 	$record = $_REQUEST['record'];
-	//$sql = "insert into salesmanactivityrel values (". $_REQUEST["user_id"] .",".$_REQUEST["record"] .")";
-	$sql = "insert into salesmanactivityrel values (".$adb->quote($_REQUEST["user_id"]).",".$adb->quote($_REQUEST["record"]).")";
+	//$sql = "insert into vtiger_salesmanactivityrel values (". $_REQUEST["user_id"] .",".$_REQUEST["record"] .")";
+	$sql = "insert into vtiger_salesmanactivityrel values (".$adb->quote($_REQUEST["user_id"]).",".$adb->quote($_REQUEST["record"]).")";
 	$adb->query($sql);
 	header("Location: index.php?action=CallRelatedList&module=Emails&record=".$record);
 }

Modified: vtigercrm/trunk/modules/Emails/webmailsend.php
==============================================================================
--- vtigercrm/trunk/modules/Emails/webmailsend.php (original)
+++ vtigercrm/trunk/modules/Emails/webmailsend.php Mon Jun 12 14:26:25 2006
@@ -12,7 +12,7 @@
 
 $mail_status = send_mail('Emails',$_REQUEST["parent_name"],$current_user->user_name,'',$_REQUEST['subject'],$_REQUEST['description'],$_REQUEST["ccmail"],$_REQUEST["bccmail"],'all',$focus->id);
 	
-$query = 'update emaildetails set email_flag ="SENT" where emailid='.$focus->id;
+$query = 'update vtiger_emaildetails set email_flag ="SENT" where emailid='.$focus->id;
 $adb->query($query);
 
 //set the errorheader1 to 1 if the mail has not been sent to the assigned to user

Modified: vtigercrm/trunk/modules/Faq/Faq.php
==============================================================================
--- vtigercrm/trunk/modules/Faq/Faq.php (original)
+++ vtigercrm/trunk/modules/Faq/Faq.php Mon Jun 12 14:26:25 2006
@@ -28,25 +28,25 @@
 require_once('data/CRMEntity.php');
 require_once('include/utils/utils.php');
 
-// Faq is used to store faq information.
+// Faq is used to store vtiger_faq information.
 class Faq extends CRMEntity {
 	var $log;
 	var $db;
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $mode;
 	
-	var $tab_name = Array('crmentity','faq','faqcomments');
-	var $tab_name_index = Array('crmentity'=>'crmid','faq'=>'id','faqcomments'=>'faqid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_faq','vtiger_faqcomments');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_faq'=>'id','vtiger_faqcomments'=>'faqid');
 				
-	var $entity_table = "crmentity";
+	var $entity_table = "vtiger_crmentity";
 	
 	var $column_fields = Array();
 		
 	var $sortby_fields = Array('question','category','id');		
 
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
 				'FAQ Id'=>Array('faq'=>'id'),
 				'Question'=>Array('faq'=>'question'),
@@ -100,7 +100,7 @@
 		global $log;
 		$log->debug("Entering getFAQComments(".$faqid.") method ...");
 		global $mod_strings;
-		$sql = "select * from faqcomments where faqid=".$faqid;
+		$sql = "select * from vtiger_faqcomments where faqid=".$faqid;
 		$result = $this->db->query($sql);
 		$noofrows = $this->db->num_rows($result);
 

Modified: vtigercrm/trunk/modules/Faq/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Faq/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Faq/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -78,10 +78,10 @@
 'NTC_COPY_SHIPPING_ADDRESS'=>'Copy shipping address to billing address',
 'NTC_REMOVE_MEMBER_ORG_CONFIRMATION'=>'Are you sure you want to remove this record as a member organization?',
 'LBL_DUPLICATE'=>'Potential Duplicate Faq',
-'MSG_DUPLICATE' => 'Creating this account may potentialy create a duplicate account. You may either select an account from the list below or you may click on Create New Faq to continue creating a new account with the previously entered data.',
+'MSG_DUPLICATE' => 'Creating this vtiger_account may vtiger_potentialy create a duplicate vtiger_account. You may either select an vtiger_account from the list below or you may click on Create New Faq to continue creating a new vtiger_account with the previously entered data.',
 
 'LBL_INVITEE'=>'Contacts',
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
 
 'LBL_SELECT_ACCOUNT'=>'Select Faq',
 'LBL_GENERAL_INFORMATION'=>'General Information',
@@ -110,7 +110,7 @@
 'Created Time'=>'Created Time',
 'Modified Time'=>'Modified Time',
 
-//Added fields after 4.2 alpha
+//Added vtiger_fields after 4.2 alpha
 'LBL_TICKETS'=>'Tickets',
 'LBL_FAQ'=>'FAQ',
 'Product Name'=>'Product Name',

Modified: vtigercrm/trunk/modules/HelpDesk/Convert.php
==============================================================================
--- vtigercrm/trunk/modules/HelpDesk/Convert.php (original)
+++ vtigercrm/trunk/modules/HelpDesk/Convert.php Mon Jun 12 14:26:25 2006
@@ -71,7 +71,7 @@
 $change='';
 if($_REQUEST['change_owner'])
 {
-	$change .= '<input type="hidden" name="change_owner" value="true"/><td width="20%" valign="top" class="dataLabel">'.$mod_strings['LBL_ASSIGNED_TO'].'<select tabindex="5" name="assigned_user_id" {ASSIGNED_USER_OPTIONS}</select> </td>';
+	$change .= '<input type="hidden" name="change_owner" value="true"/><td width="20%" valign="top" class="dataLabel">'.$mod_strings['LBL_ASSIGNED_TO'].'<select vtiger_tabindex="5" name="assigned_user_id" {ASSIGNED_USER_OPTIONS}</select> </td>';
 	$xtpl->assign("ASSIGNED_USER_OPTIONS",getComboValues("user_name","users","user_name","1",'--None--'));
 }
 if($_REQUEST['change_status'])

Modified: vtigercrm/trunk/modules/HelpDesk/ConvertAsFAQ.php
==============================================================================
--- vtigercrm/trunk/modules/HelpDesk/ConvertAsFAQ.php (original)
+++ vtigercrm/trunk/modules/HelpDesk/ConvertAsFAQ.php Mon Jun 12 14:26:25 2006
@@ -13,7 +13,7 @@
 
 $focus = new FAQ();
 
-//Map the fields like ticket column => faq column where ticket column is the troubletikcets field name & faq - column_fields
+//Map the vtiger_fields like ticket column => vtiger_faq column where ticket column is the troubletikcets vtiger_field name & vtiger_faq - column_fields
 $ticket_faq_mapping_fields = Array(
 			'title'=>'question',
 			'product_id'=>'product_id',
@@ -22,7 +22,7 @@
 			//'ticketcategories'=>'faqcategory'
 		   );
 
-$sql = "select ticketid, title, product_id, description, solution,status, category from troubletickets where ticketid=".$_REQUEST['record'];
+$sql = "select ticketid, title, product_id, description, solution,status, category from vtiger_troubletickets where ticketid=".$_REQUEST['record'];
 $res = $adb->query($sql);
 
 //set all the ticket values to FAQ
@@ -45,8 +45,8 @@
 		$answer .= '\r\n\r\nSOLUTION:\r\n'.$solution;
 	}
 
-	//Retrive the ticket comments from the ticketcomments table and added into the faq answer
-	$sql = "select ticketid, comments, createdtime from ticketcomments where ticketid=".$_REQUEST['record'];
+	//Retrive the ticket comments from the vtiger_ticketcomments vtiger_table and added into the vtiger_faq answer
+	$sql = "select ticketid, comments, createdtime from vtiger_ticketcomments where ticketid=".$_REQUEST['record'];
 	$res = $adb->query($sql);
 	$noofrows = $adb->num_rows($res);
 	$answer .= '\r\n\r\nCOMMENTS:';
@@ -59,7 +59,7 @@
 		}
 	}
 
-	$sql1 = "update faq set answer='".$answer."' where id=".$focus->id;
+	$sql1 = "update vtiger_faq set answer='".$answer."' where id=".$focus->id;
 	$adb->query($sql1);
 }
 

Modified: vtigercrm/trunk/modules/HelpDesk/ConvertToEntities.php
==============================================================================
--- vtigercrm/trunk/modules/HelpDesk/ConvertToEntities.php (original)
+++ vtigercrm/trunk/modules/HelpDesk/ConvertToEntities.php Mon Jun 12 14:26:25 2006
@@ -20,11 +20,11 @@
 $close_date = $_REQUEST["closedate"];
 $current_user_id = $_REQUEST["current_user_id"];
 
-//$id=$adb->query_result($adb->query('select * from users where user_name="'.$_REQUEST['assigned_user_id'].'"'),0,"id");
+//$id=$adb->query_result($adb->query('select * from vtiger_users where user_name="'.$_REQUEST['assigned_user_id'].'"'),0,"id");
 
 $idlist=split(';',$_REQUEST['idlist']);
 
-$query='select * from troubletickets';
+$query='select * from vtiger_troubletickets';
 $rs=$adb->query($query);
 for($i=0;$i<count($idlist);$i++)
 {
@@ -36,11 +36,11 @@
 	}
 	if(isset($_REQUEST['change_owner']))
 	{
-		$resultset=$adb->query('select * from users where user_name="'.$_REQUEST['assigned_user_id'].'"');
+		$resultset=$adb->query('select * from vtiger_users where user_name="'.$_REQUEST['assigned_user_id'].'"');
 		$changevalue=$adb->query_result($resultset,0,"id");
 		$changekey='assigned_user_id';
 	}
-	$sql="update troubletickets set ".$changekey." = '".$changevalue."' where id = '".$id."'";
+	$sql="update vtiger_troubletickets set ".$changekey." = '".$changevalue."' where id = '".$id."'";
 	$adb->query($sql);
 }
 header("Location: index.php?action=index&module=HelpDesk");

Modified: vtigercrm/trunk/modules/HelpDesk/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/HelpDesk/Forms.php (original)
+++ vtigercrm/trunk/modules/HelpDesk/Forms.php Mon Jun 12 14:26:25 2006
@@ -26,7 +26,7 @@
 
 
 /**
- * Create HTML form to enter a new record with the minimum necessary fields.
+ * Create HTML form to enter a new record with the minimum necessary vtiger_fields.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
@@ -59,7 +59,7 @@
 	$qcreate_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
 
 
-	$qcreate_get_field="select * from field where tabid=13 and quickcreate=0 order by quickcreatesequence";
+	$qcreate_get_field="select * from vtiger_field where vtiger_tabid=13 and quickcreate=0 order by quickcreatesequence";
 	$qcreate_get_result=$adb->query($qcreate_get_field);
 	$qcreate_get_noofrows=$adb->num_rows($qcreate_get_result);
 
@@ -141,9 +141,9 @@
 	$qcreate_form.='</form>';
 	$qcreate_form.='<script type="text/javascript">
 
-				var fieldname = new Array('.$fieldName.')
-				var fieldlabel = new Array('.$fieldLabel.')
-				var fielddatatype = new Array('.$fldDataType.')
+				var vtiger_fieldname = new Array('.$fieldName.')
+				var vtiger_fieldlabel = new Array('.$fieldLabel.')
+				var vtiger_fielddatatype = new Array('.$fldDataType.')
 
 			</script>';
 

Modified: vtigercrm/trunk/modules/HelpDesk/HelpDesk.php
==============================================================================
--- vtigercrm/trunk/modules/HelpDesk/HelpDesk.php (original)
+++ vtigercrm/trunk/modules/HelpDesk/HelpDesk.php Mon Jun 12 14:26:25 2006
@@ -25,12 +25,12 @@
 	var $db;
 
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $mode;
 
-	var $tab_name = Array('crmentity','troubletickets','seticketsrel','ticketcf','ticketcomments','attachments');
-	var $tab_name_index = Array('crmentity'=>'crmid','troubletickets'=>'ticketid','seticketsrel'=>'ticketid','ticketcf'=>'ticketid','ticketcomments'=>'ticketid','attachments'=>'attachmentsid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_troubletickets','vtiger_seticketsrel','vtiger_ticketcf','vtiger_ticketcomments','vtiger_attachments');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_troubletickets'=>'ticketid','vtiger_seticketsrel'=>'ticketid','vtiger_ticketcf'=>'ticketid','vtiger_ticketcomments'=>'ticketid','vtiger_attachments'=>'attachmentsid');
 	var $column_fields = Array();
 
 	var $sortby_fields = Array('title','status','priority','crmid','firstname','smownerid');
@@ -104,7 +104,7 @@
 
 		$returnset = '&return_module=HelpDesk&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT activity.*, crmentity.crmid, contactdetails.contactid, contactdetails.lastname, contactdetails.firstname, recurringevents.recurringtype, crmentity.smownerid, crmentity.modifiedtime, users.user_name from activity inner join seactivityrel on seactivityrel.activityid=activity.activityid inner join crmentity on crmentity.crmid=activity.activityid left outer join recurringevents on recurringevents.activityid=activity.activityid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid= cntactivityrel.contactid left join users on users.id=crmentity.smownerid left join activitygrouprelation on activitygrouprelation.activityid=crmentity.crmid left join groups on groups.groupname=activitygrouprelation.groupname where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting')";
+		$query = "SELECT vtiger_activity.*, vtiger_crmentity.crmid, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_recurringevents.recurringtype, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or vtiger_activitytype='Call' or vtiger_activitytype='Meeting')";
 		$log->debug("Exiting get_activities method ...");
 		
 		return GetRelatedList('HelpDesk','Activities',$focus,$query,$button,$returnset);
@@ -123,7 +123,7 @@
 		global $log, $adb;
 		$log->debug("Entering into get_ticket_history($ticketid) method ...");
 
-		$query="select title,update_log from troubletickets where ticketid=".$ticketid;
+		$query="select title,update_log from vtiger_troubletickets where ticketid=".$ticketid;
 		$result=$adb->query($query);
 		$update_log = $adb->query_result($result,0,"update_log");
 
@@ -138,7 +138,7 @@
 		return $return_value;
 	}
 
-	/**	Function to form the query to get the list of attachments and notes
+	/**	Function to form the query to get the list of vtiger_attachments and vtiger_notes
 	 *	@param  int $id - ticket id
 	 *	@return void
 	 *	 but this function will call the function renderRelatedAttachments with parameters query and ticket id
@@ -147,31 +147,31 @@
 	{
 		global $log;
 		$log->debug("Entering get_attachments(".$id.") method ...");
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename,
-			attachments.type  FileType,crm2.modifiedtime lastmodified,
-			seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid,
-			crm2.createdtime, notes.notecontent description, users.user_name
-		from notes
-			inner join senotesrel on senotesrel.notesid= notes.notesid
-			inner join crmentity on crmentity.crmid= senotesrel.crmid
-			inner join crmentity crm2 on crm2.crmid=notes.notesid and crm2.deleted=0
-			left join seattachmentsrel  on seattachmentsrel.crmid =notes.notesid
-			left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid
-			inner join users on crm2.smcreatorid= users.id
-		where crmentity.crmid=".$id;
+		$query = "select vtiger_notes.title,'Notes      '  ActivityType, vtiger_notes.filename,
+		vtiger_attachments.type  FileType,crm2.modifiedtime lastmodified,
+		vtiger_seattachmentsrel.attachmentsid vtiger_attachmentsid, vtiger_notes.notesid crmid,
+			crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		from vtiger_notes
+			inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+			left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id;
 
 		$query .= ' union all ';
 
-		$query .= "select attachments.description title ,'Attachments'  ActivityType,
-			attachments.name filename, attachments.type FileType,crm2.modifiedtime lastmodified,
-			attachments.attachmentsid attachmentsid, seattachmentsrel.attachmentsid crmid,
-			crm2.createdtime, attachments.description, users.user_name
-		from attachments
-			inner join seattachmentsrel on seattachmentsrel.attachmentsid= attachments.attachmentsid
-			inner join crmentity on crmentity.crmid= seattachmentsrel.crmid
-			inner join crmentity crm2 on crm2.crmid=attachments.attachmentsid
-			left join users on crm2.smcreatorid= users.id
-		where crmentity.crmid=".$id;	
+		$query .= "select vtiger_attachments.description title ,'Attachments'  ActivityType,
+		vtiger_attachments.name filename, vtiger_attachments.type FileType,crm2.modifiedtime lastmodified,
+		vtiger_attachments.attachmentsid vtiger_attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
+			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		from vtiger_attachments
+			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+			left join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id;	
 		$log->debug("Exiting get_attachments method ...");
 		return getAttachmentsAndNotes('HelpDesk',$query,$id);
 	}
@@ -189,7 +189,7 @@
 	{
 		global $log;
 		$log->debug("Entering get_ticket_comments_list(".$ticketid.") method ...");
-		 $sql = "select * from ticketcomments where ticketid=".$ticketid." order by createdtime DESC";
+		 $sql = "select * from vtiger_ticketcomments where ticketid=".$ticketid." order by createdtime DESC";
 		 $result = $this->db->query($sql);
 		 $noofrows = $this->db->num_rows($result);
 		 for($i=0;$i<$noofrows;$i++)
@@ -200,7 +200,7 @@
 				 $name = getUserName($ownerid);
 			 elseif($ownertype == 'customer')
 			 {
-				 $sql1 = 'select * from portalinfo where id='.$ownerid;
+				 $sql1 = 'select * from vtiger_portalinfo where id='.$ownerid;
 				 $name = $this->db->query_result($this->db->query($sql1),0,'user_name');
 			 }
 
@@ -224,7 +224,7 @@
 
 		$this->db->println("where ==> ".$where);
 
-		$query = "select crmentity.crmid, troubletickets.*, crmentity.smownerid, crmentity.createdtime, crmentity.modifiedtime, contactdetails.firstname, contactdetails.lastname, products.productid, products.productname, ticketcf.* from troubletickets inner join ticketcf on ticketcf.ticketid = troubletickets.ticketid inner join crmentity on crmentity.crmid=troubletickets.ticketid left join contactdetails on troubletickets.parent_id=contactdetails.contactid left join products on products.productid = troubletickets.product_id left join users on crmentity.smownerid=users.id  where crmentity.deleted=0 and contactdetails.email='".$user_name."' and troubletickets.parent_id = '".$id."'";
+		$query = "select vtiger_crmentity.crmid, vtiger_troubletickets.*, vtiger_crmentity.smownerid, vtiger_crmentity.createdtime, vtiger_crmentity.modifiedtime, vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_products.productid, vtiger_products.productname, vtiger_ticketcf.* from vtiger_troubletickets inner join vtiger_ticketcf on vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid left join vtiger_contactdetails on vtiger_troubletickets.parent_id=vtiger_contactdetails.contactid left join vtiger_products on vtiger_products.productid = vtiger_troubletickets.product_id left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id  where vtiger_crmentity.deleted=0 and vtiger_contactdetails.email='".$user_name."' and vtiger_troubletickets.parent_id = '".$id."'";
 
 		if(trim($where) != '')
 		{
@@ -260,10 +260,10 @@
 				$where_conditions = " and ( ".$where_conditions." ) ";
 
 			$query .= $where_conditions;
-			$this->db->println("where condition for customer portal tickets search : ".$where_conditions);
+			$this->db->println("where condition for customer vtiger_portal tickets search : ".$where_conditions);
 		}
 
-		$query .= " order by crmentity.crmid desc";
+		$query .= " order by vtiger_crmentity.crmid desc";
 		$log->debug("Exiting get_user_tickets_list method ...");
 		return $this->process_list_query($query);
 	}
@@ -317,14 +317,14 @@
 	        return $response;
 	}
 
-	/**	Function to get the HelpDesk field labels in caps letters without space
+	/**	Function to get the HelpDesk vtiger_field labels in caps letters without space
 	 *	return array $mergeflds - array(	key => val	)    where   key=0,1,2..n & val = ASSIGNEDTO,RELATEDTO, .,etc
 	**/
 	function getColumnNames_Hd()
 	{
 		global $log;
 		$log->debug("Entering getColumnNames_Hd() method ...");
-		$sql1 = "select fieldlabel from field where tabid=13 and block <> 6 ";
+		$sql1 = "select vtiger_fieldlabel from vtiger_field where vtiger_tabid=13 and block <> 6 ";
 		$result = $this->db->query($sql1);
 		$numRows = $this->db->num_rows($result);
 		for($i=0; $i < $numRows;$i++)
@@ -348,7 +348,7 @@
 		$log->debug("Entering getCommentInformation(".$ticketid.") method ...");
 		global $adb;
 		global $mod_strings;
-		$sql = "select * from ticketcomments where ticketid=".$ticketid;
+		$sql = "select * from vtiger_ticketcomments where ticketid=".$ticketid;
 		$result = $adb->query($sql);
 		$noofrows = $adb->num_rows($result);
 
@@ -389,7 +389,7 @@
 		return $list;
 	}
 
-	/**     Function to get the Customer Name who has made comment to the ticket from the portal
+	/**     Function to get the Customer Name who has made comment to the ticket from the vtiger_portal
 	 *      @param  int    $id   - Ticket id
 	 *      @return string $customername - The contact name
 	**/
@@ -398,7 +398,7 @@
 		global $log;
 		$log->debug("Entering getCustomerName(".$id.") method ...");
         	global $adb;
-	        $sql = "select * from portalinfo inner join troubletickets on troubletickets.parent_id = portalinfo.id where troubletickets.ticketid=".$id;
+	        $sql = "select * from vtiger_portalinfo inner join vtiger_troubletickets on vtiger_troubletickets.parent_id = vtiger_portalinfo.id where vtiger_troubletickets.ticketid=".$id;
         	$result = $adb->query($sql);
 	        $customername = $adb->query_result($result,0,'user_name');
 		$log->debug("Exiting getCustomerName method ...");

Modified: vtigercrm/trunk/modules/HelpDesk/ListTickets.php
==============================================================================
--- vtigercrm/trunk/modules/HelpDesk/ListTickets.php (original)
+++ vtigercrm/trunk/modules/HelpDesk/ListTickets.php Mon Jun 12 14:26:25 2006
@@ -24,18 +24,18 @@
 	$theme_path="themes/".$theme."/";
 	$image_path=$theme_path."images/";
 
-	$search_query="select troubletickets.ticketid, parent_id, priority, troubletickets.status, category, troubletickets.title, troubletickets.description, update_log, version_id,
-	crmentity.createdtime, crmentity.modifiedtime, 
-	contactdetails.firstname, contactdetails.lastname, 
-	account.accountid, account.accountname, 
-	users.user_name from 
-	troubletickets 
-	inner join crmentity on crmentity.crmid = troubletickets.ticketid 
-	inner join users on users.id = crmentity.smownerid 
-	left join contactdetails on troubletickets.parent_id = contactdetails.contactid 
-	left join account on account.accountid = troubletickets.parent_id 
-	left join seticketsrel on seticketsrel.ticketid = troubletickets.ticketid 
-	where crmentity.smownerid = ".$current_user->id." and crmentity.deleted = 0 and troubletickets.status <> 'Closed'  ORDER BY createdtime DESC";
+	$search_query="select vtiger_troubletickets.ticketid, parent_id, priority, vtiger_troubletickets.status, category, vtiger_troubletickets.title, vtiger_troubletickets.description, update_log, version_id,
+vtiger_crmentity.createdtime, vtiger_crmentity.modifiedtime, 
+vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, 
+vtiger_account.accountid, vtiger_account.accountname, 
+vtiger_users.user_name from 
+	vtiger_troubletickets 
+	inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_troubletickets.ticketid 
+	inner join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid 
+	left join vtiger_contactdetails on vtiger_troubletickets.parent_id = vtiger_contactdetails.contactid 
+	left join vtiger_account on vtiger_account.accountid = vtiger_troubletickets.parent_id 
+	left join vtiger_seticketsrel on vtiger_seticketsrel.ticketid = vtiger_troubletickets.ticketid 
+	where vtiger_crmentity.smownerid = ".$current_user->id." and vtiger_crmentity.deleted = 0 and vtiger_troubletickets.status <> 'Closed'  ORDER BY createdtime DESC";
 
 	$resultcount = $adb->num_rows($adb->query($search_query));
 	if($resultcount > 0)
@@ -96,19 +96,19 @@
 	$log->debug("Entering getParentLink(".$parent_id.") method ...");
 	global $adb;
 
-	$sql = "select setype from crmentity where crmid=".$parent_id;
+	$sql = "select setype from vtiger_crmentity where crmid=".$parent_id;
 	$parent_module = $adb->query_result($adb->query($sql),0,'setype');
 
 	if($parent_module == 'Contacts')
 	{
-		$sql = "select firstname,lastname from contactdetails where contactid=".$parent_id;
+		$sql = "select firstname,lastname from vtiger_contactdetails where contactid=".$parent_id;
 		$parentname = $adb->query_result($adb->query($sql),0,'firstname');
 		$parentname .= ' '.$adb->query_result($adb->query($sql),0,'lastname');
 	        $parent_name = '<a href="index.php?action=DetailView&module='.$parent_module.'&record='.$parent_id.'">'.$parentname.'</a>';
 	}
 	if($parent_module == 'Accounts')
 	{
-		$sql = "select accountname from account where accountid=".$parent_id;
+		$sql = "select vtiger_accountname from vtiger_account where vtiger_accountid=".$parent_id;
 		$parentname = $adb->query_result($adb->query($sql),0,'accountname');
 	        $parent_name = '<a href="index.php?action=DetailView&module='.$parent_module.'&record='.$parent_id.'">'.$parentname.'</a>';
 	}

Modified: vtigercrm/trunk/modules/HelpDesk/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/HelpDesk/ListView.php (original)
+++ vtigercrm/trunk/modules/HelpDesk/ListView.php Mon Jun 12 14:26:25 2006
@@ -134,7 +134,7 @@
 {
 	if($order_by == 'smownerid')
 	{
-		$list_query .= ' ORDER BY users.user_name '.$sorder;
+		$list_query .= ' ORDER BY vtiger_users.user_name '.$sorder;
 	}
 	else
 	{
@@ -146,7 +146,7 @@
 }
 else
 {
-	$list_query .= ' order by troubletickets.ticketid DESC';
+	$list_query .= ' order by vtiger_troubletickets.ticketid DESC';
 }
 
 

Modified: vtigercrm/trunk/modules/HelpDesk/Merge.php
==============================================================================
--- vtigercrm/trunk/modules/HelpDesk/Merge.php (original)
+++ vtigercrm/trunk/modules/HelpDesk/Merge.php Mon Jun 12 14:26:25 2006
@@ -35,7 +35,7 @@
 }
 //get the particular file from db and store it in the local hard disk.
 //store the path to the location where the file is stored and pass it  as parameter to the method 
-$sql = "select filename,data,filesize from wordtemplates where templateid=".$templateid;
+$sql = "select filename,data,filesize from vtiger_wordtemplates where templateid=".$templateid;
 
 $result = $adb->query($sql);
 $temparray = $adb->fetch_array($result);
@@ -71,7 +71,7 @@
 }
 
 //<<<<<<<<<<<<<<<<header for csv and select columns for query>>>>>>>>>>>>>>>>>>>>>>>>
-$query1="select tab.name,field.tablename,field.columnname,field.fieldlabel from field inner join tab on tab.tabid = field.tabid where field.tabid in (13,4,6) and field.uitype <> 61 and (field.tablename <>'CustomerDetails' and block <> 6 and block <> 75) and block <> 30 order by field.tablename";
+$query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (13,4,6) and vtiger_field.uitype <> 61 and (vtiger_field.tablename <>'CustomerDetails' and block <> 6 and block <> 75) and block <> 30 order by vtiger_field.tablename";
 
 $result = $adb->query($query1);
 $y=$adb->num_rows($result);
@@ -86,7 +86,7 @@
 
 	if($columnname == "parent_id")
 	{
-		$column_name = "case crmentityRelHelpDesk.setype when 'Accounts' then accountRelHelpDesk.accountname when 'Contacts' then concat(contactdetailsRelHelpDesk.firstname,' ',contactdetailsRelHelpDesk.lastname) End";
+		$column_name = "case vtiger_crmentityRelHelpDesk.setype when 'Accounts' then vtiger_accountRelHelpDesk.accountname when 'Contacts' then concat(contactdetailsRelHelpDesk.firstname,' ',contactdetailsRelHelpDesk.lastname) End";
 	}
 	if($columnname == "product_id")
 	{
@@ -119,7 +119,7 @@
 		}
 		if($modulename == "HelpDesk")
 		{
-			$column_name = "concat(users.last_name,' ',users.first_name) as userhelpname,users.first_name,users.last_name,users.user_name,users.yahoo_id,users.title,users.phone_work,users.department,users.phone_mobile,users.phone_other,users.phone_fax,users.email1,users.phone_home,users.email2,users.address_street,users.address_city,users.address_state,users.address_postalcode,users.address_country";
+			$column_name = "concat(vtiger_users.last_name,' ',vtiger_users.first_name) as userhelpname,vtiger_users.first_name,vtiger_users.last_name,vtiger_users.user_name,vtiger_users.yahoo_id,vtiger_users.title,vtiger_users.phone_work,vtiger_users.department,vtiger_users.phone_mobile,vtiger_users.phone_other,vtiger_users.phone_fax,vtiger_users.email1,vtiger_users.phone_home,vtiger_users.email2,vtiger_users.address_street,vtiger_users.address_city,vtiger_users.address_state,vtiger_users.address_postalcode,vtiger_users.address_country";
 		}
 	}
 	if($columnname == "parentid")
@@ -162,31 +162,31 @@
 {
 	$selectcolumns = implode($querycolumns,",");
 
-	$query ="select ".$selectcolumns." from troubletickets
-			inner join crmentity on crmentity.crmid=troubletickets.ticketid
-			inner join ticketcf on ticketcf.ticketid = troubletickets.ticketid
-			left join crmentity as crmentityRelHelpDesk on crmentityRelHelpDesk.crmid = troubletickets.parent_id
-			left join account as accountRelHelpDesk on accountRelHelpDesk.accountid=crmentityRelHelpDesk.crmid
-			left join contactdetails as contactdetailsRelHelpDesk on contactdetailsRelHelpDesk.contactid= crmentityRelHelpDesk.crmid
-			left join products as productsRel on productsRel.productid = troubletickets.product_id
-			left join users on crmentity.smownerid=users.id
-			left join account on account.accountid = troubletickets.parent_id               
-			left join crmentity as crmentityAccounts on crmentityAccounts.crmid = account.accountid 
-			left join accountbillads on accountbillads.accountaddressid = account.accountid
-			left join accountshipads on accountshipads.accountaddressid = account.accountid
-			left join accountscf on accountbillads.accountaddressid = accountscf.accountid 
-			left join account as accountAccount on accountAccount.accountid = troubletickets.parent_id
-			left join users as usersAccounts on usersAccounts.id = crmentityAccounts.smownerid
-			left join contactdetails on contactdetails.contactid = troubletickets.parent_id               
-			left join crmentity as crmentityContacts on crmentityContacts.crmid = contactdetails.contactid 
-			left join contactaddress on contactdetails.contactid = contactaddress.contactaddressid 
-			left join contactsubdetails on contactdetails.contactid = contactsubdetails.contactsubscriptionid 
-			left join contactscf on contactdetails.contactid = contactscf.contactid 
-			left join contactdetails as contactdetailsContacts on contactdetailsContacts.contactid = contactdetails.reportsto
-			left join account as accountContacts on accountContacts.accountid = contactdetails.accountid 
-			left join users as usersContacts on usersContacts.id = crmentityContacts.smownerid
-			where crmentity.deleted=0 and ((crmentityContacts.deleted=0 || crmentityContacts.deleted is null)||(crmentityAccounts.deleted=0 || crmentityAccounts.deleted is null)) 
-			and troubletickets.ticketid in (".$mass_merge.")";
+	$query ="select ".$selectcolumns." from vtiger_troubletickets
+			inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid
+			inner join vtiger_ticketcf on vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid
+			left join vtiger_crmentity as vtiger_crmentityRelHelpDesk on vtiger_crmentityRelHelpDesk.crmid = vtiger_troubletickets.parent_id
+			left join vtiger_account as vtiger_accountRelHelpDesk on vtiger_accountRelHelpDesk.accountid=crmentityRelHelpDesk.crmid
+			left join vtiger_contactdetails as vtiger_contactdetailsRelHelpDesk on vtiger_contactdetailsRelHelpDesk.contactid= vtiger_crmentityRelHelpDesk.crmid
+			left join vtiger_products as vtiger_productsRel on vtiger_productsRel.productid = vtiger_troubletickets.product_id
+			left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id
+			left join vtiger_account on vtiger_account.accountid = vtiger_troubletickets.parent_id               
+			left join vtiger_crmentity as vtiger_crmentityAccounts on vtiger_crmentityAccounts.crmid = vtiger_account.accountid 
+			left join vtiger_accountbillads on vtiger_accountbillads.accountaddressid = vtiger_account.accountid
+			left join vtiger_accountshipads on vtiger_accountshipads.accountaddressid = vtiger_account.accountid
+			left join vtiger_accountscf on vtiger_accountbillads.accountaddressid = vtiger_accountscf.accountid 
+			left join vtiger_account as vtiger_accountAccount on vtiger_accountAccount.accountid = vtiger_troubletickets.parent_id
+			left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentityAccounts.smownerid
+			left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_troubletickets.parent_id               
+			left join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid 
+			left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid 
+			left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid 
+			left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid 
+			left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
+			left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid 
+			left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid
+			where vtiger_crmentity.deleted=0 and ((crmentityContacts.deleted=0 || vtiger_crmentityContacts.deleted is null)||(crmentityAccounts.deleted=0 || vtiger_crmentityAccounts.deleted is null)) 
+			and vtiger_troubletickets.ticketid in (".$mass_merge.")";
 
 	$result = $adb->query($query);
 
@@ -196,7 +196,7 @@
 		for($x=0; $x<$y; $x++)
 		{
 			$value = $columnValues[$x];
-			//<<<<<<<<<<<<<<<for blank fields>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+			//<<<<<<<<<<<<<<<for blank vtiger_fields>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 			if($value == "0")
 			{
 				$value = "";
@@ -221,7 +221,7 @@
 }
 else
 {
-	die("No fields to do Merge");
+	die("No vtiger_fields to do Merge");
 }	
 
 $handle = fopen($wordtemplatedownloadpath."datasrc.csv","wb");

Modified: vtigercrm/trunk/modules/HelpDesk/Save.php
==============================================================================
--- vtigercrm/trunk/modules/HelpDesk/Save.php (original)
+++ vtigercrm/trunk/modules/HelpDesk/Save.php Mon Jun 12 14:26:25 2006
@@ -48,13 +48,13 @@
 
 $emailoptout = 0;
 
-//To get the emailoptout field value and then decide whether send mail about the tickets or not
+//To get the emailoptout vtiger_field value and then decide whether send mail about the tickets or not
 if($focus->column_fields['parent_id'] != '')
 {
 	$parent_module = getSalesEntityType($focus->column_fields['parent_id']);
 	if($parent_module == 'Contacts')
 	{
-		$result = $adb->query("select * from contactdetails where contactid=".$focus->column_fields['parent_id']);
+		$result = $adb->query("select * from vtiger_contactdetails where contactid=".$focus->column_fields['parent_id']);
 		$emailoptout = $adb->query_result($result,0,'emailoptout');
 		$contactname = $adb->query_result($result,0,'firstname').' '.$adb->query_result($result,0,'lastname');
 		$parentname = $contactname;
@@ -62,16 +62,16 @@
 	}
 	if($parent_module == 'Accounts')
 	{
-		$result = $adb->query("select * from account where accountid=".$focus->column_fields['parent_id']);
+		$result = $adb->query("select * from vtiger_account where vtiger_accountid=".$focus->column_fields['parent_id']);
 		$emailoptout = $adb->query_result($result,0,'emailoptout');
 		$parentname = $adb->query_result($result,0,'accountname');
 	}
 }
 
-//Get the status of the portal user. if the customer is active then send the portal link in the mail
+//Get the status of the vtiger_portal user. if the customer is active then send the vtiger_portal link in the mail
 if($contact_mailid != '')
 {
-	$sql = "select * from portalinfo where user_name='".$contact_mailid."'";
+	$sql = "select * from vtiger_portalinfo where user_name='".$contact_mailid."'";
 	$isactive = $adb->query_result($adb->query($sql),0,'isactive');
 }
 if($isactive == 1)
@@ -103,7 +103,7 @@
 
 if($_REQUEST['product_id'] != '' && $focus->id != '' && $_REQUEST['mode'] != 'edit')
 {
-        $sql = 'insert into seticketsrel values('.$_REQUEST['product_id'].' , '.$focus->id.')';
+        $sql = 'insert into vtiger_seticketsrel values('.$_REQUEST['product_id'].' , '.$focus->id.')';
         $adb->query($sql);
 
 	if($_REQUEST['return_module'] == 'Products')
@@ -122,7 +122,7 @@
 {
 	$mail_status_str = "'".$to_email."'=0&&&";
 }
-//added condition to check the emailoptout(this is for contacts and accounts.)
+//added condition to check the emailoptout(this is for contacts and vtiger_accounts.)
 if($emailoptout == 0)
 {
 	//send mail to parent
@@ -159,7 +159,7 @@
 	global $adb;
 
 	$commentlist = '';
-	$sql = "select * from ticketcomments where ticketid=".$ticketid;
+	$sql = "select * from vtiger_ticketcomments where ticketid=".$ticketid;
 	$result = $adb->query($sql);
 	for($i=0;$i<$adb->num_rows($result);$i++)
 	{

Modified: vtigercrm/trunk/modules/HelpDesk/TicketStatisticsUtil.php
==============================================================================
--- vtigercrm/trunk/modules/HelpDesk/TicketStatisticsUtil.php (original)
+++ vtigercrm/trunk/modules/HelpDesk/TicketStatisticsUtil.php Mon Jun 12 14:26:25 2006
@@ -19,7 +19,7 @@
 	global $log;
 	$log->debug("Entering getTotalNoofTickets() method ...");
 	global $adb;
-	$query = "select count(*) as totalticketcount from troubletickets inner join crmentity on crmentity.crmid=troubletickets.ticketid where crmentity.deleted=0";
+	$query = "select count(*) as totalticketcount from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid where vtiger_crmentity.deleted=0";
 	$result = $adb->query($query);
 	$totTickets = $adb->query_result($result,0,"totalticketcount");
 	$log->debug("Exiting getTotalNoofTickets method ...");
@@ -34,7 +34,7 @@
 	global $log;
 	$log->debug("Entering getTotalNoofOpenTickets() method ...");
 	global $adb;
-	$query = "select count(*) as totalopenticketcount from troubletickets inner join crmentity on crmentity.crmid=troubletickets.ticketid where crmentity.deleted=0 and troubletickets.status !='Closed'";
+	$query = "select count(*) as totalopenticketcount from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid where vtiger_crmentity.deleted=0 and vtiger_troubletickets.status !='Closed'";
 	$result = $adb->query($query);
 	$totOpenTickets = $adb->query_result($result,0,"totalopenticketcount");
 	$log->debug("Exiting getTotalNoofOpenTickets method ...");
@@ -49,7 +49,7 @@
 	global $log;
 	$log->debug("Entering getTotalNoofClosedTickets() method ...");
 	global $adb;
-	$query = "select count(*) as totalclosedticketcount from troubletickets inner join crmentity on crmentity.crmid=troubletickets.ticketid where crmentity.deleted=0 and troubletickets.status ='Closed'";
+	$query = "select count(*) as totalclosedticketcount from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid where vtiger_crmentity.deleted=0 and vtiger_troubletickets.status ='Closed'";
 	$result = $adb->query($query);
 	$totClosedTickets = $adb->query_result($result,0,"totalclosedticketcount");
 	$log->debug("Exiting getTotalNoofClosedTickets method ...");
@@ -170,7 +170,7 @@
 	
 }
 
-/**     Function to display the statistics based on the Users ie., will display all the users and the no. of tickets per user
+/**     Function to display the statistics based on the Users ie., will display all the vtiger_users and the no. of tickets per user
  *      @param  string $image_path - image path of the bar per theme basis
  *      @param  int $singleUnit - the single bar length value which is calculated as 80/total no. of tickets
  *      @return void.
@@ -218,8 +218,8 @@
 	
 }
 
-/**     Function to retrieve all values from the table which is passed as the parameter
- *      @param  string $tableName - table name in which we want to get the result
+/**     Function to retrieve all values from the vtiger_table which is passed as the parameter
+ *      @param  string $tableName - vtiger_table name in which we want to get the result
  *      @return result $result - the result of the query "select * from $tableName" will be return
 **/
 function getFromDB($tableName)
@@ -235,8 +235,8 @@
 
 /**     Function to get the number of tickets based on the User or Priority or Category which is passed as a parameter
  *      @param  string $mode - the status of the ticket ie., Open or Closed. if Total then all tickets count will be retrieved
- *      @param  string $priority_val - the value based on which we get tickets ie., id of the user or ticketcategories or ticketpriorities
- *      @param  int $critColName - smownerid or category or priority which is the fieldname of the table in which we check $priority_val
+ *      @param  string $priority_val - the value based on which we get tickets ie., id of the user or vtiger_ticketcategories or vtiger_ticketpriorities
+ *      @param  int $critColName - smownerid or category or vtiger_priority which is the vtiger_fieldname of the vtiger_table in which we check $priority_val
  *      @return void.
 **/
 function getTicketCount($mode, $priority_val, $critColName)
@@ -254,16 +254,16 @@
 	global $adb;
 	if($mode == 'Open')
 	{
-		$query = "select count(*) as count from troubletickets inner join crmentity on crmentity.crmid=troubletickets.ticketid where crmentity.deleted=0  and ".$table_name.".".$critColName."='".$priority_val."' and troubletickets.status !='Closed'";
+		$query = "select count(*) as count from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid where vtiger_crmentity.deleted=0  and ".$table_name.".".$critColName."='".$priority_val."' and vtiger_troubletickets.status !='Closed'";
 		
 	}
 	elseif($mode == 'Closed')
 	{
-		$query = "select count(*) as count from troubletickets inner join crmentity on crmentity.crmid=troubletickets.ticketid where crmentity.deleted=0 and ".$table_name.".".$critColName."='".$priority_val."' and troubletickets.status ='Closed'";
+		$query = "select count(*) as count from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid where vtiger_crmentity.deleted=0 and ".$table_name.".".$critColName."='".$priority_val."' and vtiger_troubletickets.status ='Closed'";
 	}
 	elseif($mode == 'Total')
 	{
-		$query = "select count(*) as count from troubletickets inner join crmentity on crmentity.crmid=troubletickets.ticketid where crmentity.deleted=0 and ".$table_name.".".$critColName."='".$priority_val."' and deleted='0'";
+		$query = "select count(*) as count from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid where vtiger_crmentity.deleted=0 and ".$table_name.".".$critColName."='".$priority_val."' and deleted='0'";
 	}
 	$result = $adb->query($query);
 	$nooftickets = $adb->query_result($result,0,"count");

Modified: vtigercrm/trunk/modules/HelpDesk/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/HelpDesk/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/HelpDesk/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -64,12 +64,12 @@
 'LBL_AUTHOR'=>'Author',
 'LBL_QUESTION'=>'Question',
 
-//Added fields for File Attachment and Mail send in Tickets
+//Added vtiger_fields for File Attachment and Mail send in Tickets
 'LBL_ATTACHMENTS'=>'Attachments',
 'LBL_NEW_ATTACHMENT'=>'New Attachment',
 'LBL_SEND_MAIL'=>'Send Mail',
 
-//Added fields for search option  in TicketsList -- 4Beta
+//Added vtiger_fields for search option  in TicketsList -- 4Beta
 'LBL_CREATED_DATE'=>'Created Date',
 'LBL_IS'=>'is',
 'LBL_IS_NOT'=>'is not',
@@ -96,21 +96,21 @@
 'LBL_TICKET_CATEGORY'=>'Category',
 'LBL_TICKET_PRIORITY'=>'Priority',
 
-//Added fields after 4 -- Beta
+//Added vtiger_fields after 4 -- Beta
 'LBL_NEW_TICKET'=>'New Ticket',
 'LBL_TICKET_INFORMATION'=>'Ticket Information',
 
 'LBL_LIST_FORM_TITLE'=>'Tickets List',
 'LBL_SEARCH_FORM_TITLE'=>'Ticket Search',
 
-//Added fields after RC1 - Release
+//Added vtiger_fields after RC1 - Release
 'LBL_CHOOSE_A_VIEW'=>'Choose a View...',
 'LBL_ALL'=>'All',
 'LBL_LOW'=>'Low',
 'LBL_MEDIUM'=>'Medium',
 'LBL_HIGH'=>'High',
 'LBL_CRITICAL'=>'Critical',
-//Added fields for 4GA
+//Added vtiger_fields for 4GA
 'Assigned To'=>'Assigned To',
 'Contact Name'=>'Contact Name',
 'Priority'=>'Priority',
@@ -132,7 +132,7 @@
 'LBL_PRIORITIES'=>'Priorities',
 'LBL_SUPPORTERS'=>'Supporters',
 
-//Added fields after 4_0_1
+//Added vtiger_fields after 4_0_1
 'LBL_TICKET_RESOLUTION'=>'Solution Information',
 'Solution'=>'Solution',
 'Add Comment'=>'Add Comment',

Modified: vtigercrm/trunk/modules/Home/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Home/Forms.php (original)
+++ vtigercrm/trunk/modules/Home/Forms.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 /*********************************************************************************
  * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Home/Forms.php,v 1.3 2005/03/04 15:18:47 jack Exp $
  * Description:  Contains a variety of utility functions used to display UI
- * components such as form headers and footers.  Intended to be modified on a per
+ * components such as form vtiger_headers and footers.  Intended to be modified on a per
  * theme basis.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.

Modified: vtigercrm/trunk/modules/Home/LastViewed.php
==============================================================================
--- vtigercrm/trunk/modules/Home/LastViewed.php (original)
+++ vtigercrm/trunk/modules/Home/LastViewed.php Mon Jun 12 14:26:25 2006
@@ -24,7 +24,7 @@
 $theme_path="themes/".$theme."/";
 $image_path=$theme_path."images/";
 
-// Create the head of the table.
+// Create the head of the vtiger_table.
 ?>
 		<table cellpadding="2" cellspacing="0" border="0">
 		<tbody>

Modified: vtigercrm/trunk/modules/Home/UnifiedSearch.php
==============================================================================
--- vtigercrm/trunk/modules/Home/UnifiedSearch.php (original)
+++ vtigercrm/trunk/modules/Home/UnifiedSearch.php Mon Jun 12 14:26:25 2006
@@ -91,11 +91,11 @@
 
 	
 		$listquery = getListQuery($module);
-		//Avoided the modules Faq and PriceBooks. we should remove this if when change the customview function
+		//Avoided the modules Faq and PriceBooks. we should remove this if when change the vtiger_customview function
 		$oCustomView = '';
 		if($module != 'Faq' && $module != 'PriceBooks')
 		{
-			//Added to get the default 'All' customview query
+			//Added to get the default 'All' vtiger_customview query
 			$oCustomView = new CustomView($module);
 			$viewid = $oCustomView->getViewId($module);
 
@@ -163,17 +163,17 @@
 	echo "<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>".$mod_strings['ERR_ONE_CHAR']."</em>";
 }
 
-/**	Function to get the where condition for a module based on the field table entries
+/**	Function to get the where condition for a module based on the vtiger_field vtiger_table entries
   *	@param  string $listquery  -- ListView query for the module 
   *	@param  string $module     -- module name
   *	@param  string $search_val -- entered search string value
-  *	@return string $where      -- where condition for the module based on field table entries
+  *	@return string $where      -- where condition for the module based on vtiger_field vtiger_table entries
   */
 function getUnifiedWhere($listquery,$module,$search_val)
 {
 	global $adb;
 
-	$query = "SELECT * FROM field WHERE tabid = ".getTabid($module);
+	$query = "SELECT * FROM vtiger_field WHERE vtiger_tabid = ".getTabid($module);
 	$result = $adb->query($query);
 	$noofrows = $adb->num_rows($result);
 
@@ -183,7 +183,7 @@
 		$columnname = $adb->query_result($result,$i,'columnname');
 		$tablename = $adb->query_result($result,$i,'tablename');
 
-		//Before form the where condition, check whether the table for the field has been added in the listview query
+		//Before form the where condition, check whether the vtiger_table for the vtiger_field has been added in the listview query
 		if(strstr($listquery,$tablename))
 		{
 			if($where != '')
@@ -198,7 +198,7 @@
 /**	Function to get the Tags where condition
   *	@param  string $search_val -- entered search string value
   *	@param  string $current_user_id     -- current user id
-  *	@return string $where      -- where condition with the list of crmids, will like crmentity.crmid in (1,3,4,etc.,)
+  *	@return string $where      -- where condition with the list of crmids, will like vtiger_crmentity.crmid in (1,3,4,etc.,)
   */
 function getTagWhere($search_val,$current_user_id)
 {
@@ -211,7 +211,7 @@
 	$where = '';
 	if(count($crmid_array) > 0)
 	{
-		$where = " crmentity.crmid IN (";
+		$where = " vtiger_crmentity.crmid IN (";
 		foreach($crmid_array as $index => $crmid)
 		{
 			$where .= $crmid.',';

Modified: vtigercrm/trunk/modules/Home/home_rss.php
==============================================================================
--- vtigercrm/trunk/modules/Home/home_rss.php (original)
+++ vtigercrm/trunk/modules/Home/home_rss.php Mon Jun 12 14:26:25 2006
@@ -40,7 +40,7 @@
 
 //retrieving notifications******************************
 //<<<<<<<<<<<<<<<< start of owner notify>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-$query = "select crmentity.setype,crmentity.crmid,crmentity.smcreatorid,crmentity.modifiedtime from crmentity inner join ownernotify on crmentity.crmid=ownernotify.crmid";
+$query = "select vtiger_crmentity.setype,vtiger_crmentity.crmid,vtiger_crmentity.smcreatorid,vtiger_crmentity.modifiedtime from vtiger_crmentity inner join vtiger_ownernotify on vtiger_crmentity.crmid=vtiger_ownernotify.crmid";
 
 $result = $adb->query($query);
 for($i=0;$i<$adb->num_rows($result);$i++)
@@ -48,77 +48,77 @@
 	    $mod_notify[$i] = $adb->fetch_array($result);
 		if($mod_notify[$i]['setype']=='Accounts')
 		{
-			$tempquery='select accountname from account where accountid='.$mod_notify[$i]['crmid'];
+			$tempquery='select vtiger_accountname from vtiger_account where vtiger_accountid='.$mod_notify[$i]['crmid'];
 			$tempresult=$adb->query($tempquery);
 			$account_name=$adb->fetch_array($tempresult);
 			$notify_values[$i]=$account_name['accountname'];	
 		}else if($mod_notify[$i]['setype']=='Potentials')
 		{
-			$tempquery='select potentialname from potential where potentialid='.$mod_notify[$i]['crmid'];
+			$tempquery='select vtiger_potentialname from vtiger_potential where vtiger_potentialid='.$mod_notify[$i]['crmid'];
 			$tempresult=$adb->query($tempquery);
 			$potential_name=$adb->fetch_array($tempresult);
 			$notify_values[$i]=$potential_name['potentialname'];
 		}else if($mod_notify[$i]['setype']=='Contacts')
 		{	
-			$tempquery='select lastname from contactdetails where contactid='.$mod_notify[$i]['crmid'];
+			$tempquery='select lastname from vtiger_contactdetails where contactid='.$mod_notify[$i]['crmid'];
 			$tempresult=$adb->query($tempquery);
 			$contact_name=$adb->fetch_array($tempresult);
 			$notify_values[$i]=$contact_name['lastname'];
 
 		}else if($mod_notify[$i]['setype']=='Leads')
 		{
-			$tempquery='select lastname from leaddetails where leadid='.$mod_notify[$i]['crmid'];
+			$tempquery='select lastname from vtiger_leaddetails where leadid='.$mod_notify[$i]['crmid'];
 			$tempresult=$adb->query($tempquery);
 			$lead_name=$adb->fetch_array($tempresult);
 			$notify_values[$i]=$lead_name['lastname'];
 		}else if($mod_notify[$i]['setype']=='SalesOrder')
 		{
-			$tempquery='select subject from salesorder where salesorderid='.$mod_notify[$i]['crmid'];
+			$tempquery='select subject from vtiger_salesorder where vtiger_salesorderid='.$mod_notify[$i]['crmid'];
 			$tempresult=$adb->query($tempquery);
 			$sales_subject=$adb->fetch_array($tempresult);
 			$notify_values[$i]=$sales_subject['subject'];
 
 		}else if($mod_notify[$i]['setype']=='Orders')
 		{
-			$tempquery='select subject from purchaseorder where purchaseorderid='.$mod_notify[$i]['crmid'];
+			$tempquery='select subject from vtiger_purchaseorder where vtiger_purchaseorderid='.$mod_notify[$i]['crmid'];
 			$tempresult=$adb->query($tempquery);
 			$purchase_subject=$adb->fetch_array($tempresult);
 			$notify_values[$i]=$purchase_subject['subject'];
 
 		}else if($mod_notify[$i]['setype']=='Products')
 		{
-			$tempquery='select productname from products where productid='.$mod_notify[$i]['crmid'];
+			$tempquery='select productname from vtiger_products where productid='.$mod_notify[$i]['crmid'];
 			$tempresult=$adb->query($tempquery);
 			$product_name=$adb->fetch_array($tempresult);
 			$notify_values[$i]=$product_name['productname'];
 		}else if($mod_notify[$i]['setype']=='Emails')
 		{
-			$tempquery='select subject from activity where activityid='.$mod_notify[$i]['crmid'];
+			$tempquery='select subject from vtiger_activity where vtiger_activityid='.$mod_notify[$i]['crmid'];
 			$tempresult=$adb->query($tempquery);
 			$email_subject=$adb->fetch_array($tempresult);
 			$notify_values[$i]=$email_subject['subject'];
 
 		}else if($mod_notify[$i]['setype']=='HelpDesk')
 		{
-			$tempquery='select title from troubletickets where ticketid='.$mod_notify[$i]['crmid'];
+			$tempquery='select title from vtiger_troubletickets where ticketid='.$mod_notify[$i]['crmid'];
 			$tempresult=$adb->query($tempquery);
 			$HelpDesk_title=$adb->fetch_array($tempresult);
 			$notify_values[$i]=$HelpDesk_title['title'];
 		}else if($mod_notify[$i]['setype']=='Activities')
 		{
-			$tempquery='select subject from activity where activityid='.$mod_notify[$i]['crmid'];
+			$tempquery='select subject from vtiger_activity where vtiger_activityid='.$mod_notify[$i]['crmid'];
 			$tempresult=$adb->query($tempquery);
 			$Activity_subject=$adb->fetch_array($tempresult);
 			$notify_values[$i]=$Activity_subject['subject'];
 		}else if($mod_notify[$i]['setype']=='Quotes')
 		{
-			$tempquery='select subject from quotes where quoteid='.$mod_notify[$i]['crmid'];
+			$tempquery='select subject from vtiger_quotes where quoteid='.$mod_notify[$i]['crmid'];
 			$tempresult=$adb->query($tempquery);
 			$quote_subject=$adb->fetch_array($tempresult);
 			$notify_values[$i]=$quote_subject['subject'];
 		}else if($mod_notify[$i]['setype']=='Invoice')
 		{
-			$tempquery='select subject from invoice where invoiceid='.$mod_notify[$i]['crmid'];
+			$tempquery='select subject from vtiger_invoice where vtiger_invoiceid='.$mod_notify[$i]['crmid'];
 			$tempresult=$adb->query($tempquery);
 			$invoice_subject=$adb->fetch_array($tempresult);
 			$notify_values[$i]=$invoice_subject['subject'];

Modified: vtigercrm/trunk/modules/Home/index.php
==============================================================================
--- vtigercrm/trunk/modules/Home/index.php (original)
+++ vtigercrm/trunk/modules/Home/index.php Mon Jun 12 14:26:25 2006
@@ -44,7 +44,7 @@
 global $adb;
 global $current_user;
 
-$query = "SELECT users.homeorder FROM users WHERE id=".$current_user->id;
+$query = "SELECT vtiger_users.homeorder FROM vtiger_users WHERE id=".$current_user->id;
 $result =& $adb->query($query, true,"Error getting home order");
 $row = $adb->fetchByAssoc($result);
 
@@ -140,14 +140,14 @@
 function getActivityType($id)
 {
 	global $adb;
-	$quer = "select activitytype from activity where activityid=".$id;
+	$quer = "select vtiger_activitytype from vtiger_activity where vtiger_activityid=".$id;
 	$res = $adb->query($quer);
 	$acti_type = $adb->query_result($res,0,"activitytype");
 	return $acti_type;
 
 }
 
-$query="select tagcloud from users where id=".$current_user->id;
+$query="select tagcloud from vtiger_users where id=".$current_user->id;
 $result=$adb->query($query);
 $tagcloud_js=$adb->query_result($result,0,'tagcloud');
 $smarty->assign("TAGCLOUD_JS",$tagcloud_js);
@@ -176,13 +176,13 @@
 	global $app_strings;
 	$i=0;
 	$userid= $current_user->id;
-	$query="select * from loginhistory inner join users on loginhistory.user_name=users.user_name where users.id=".$userid;
+	$query="select * from vtiger_loginhistory inner join vtiger_users on vtiger_loginhistory.user_name=vtiger_users.user_name where vtiger_users.id=".$userid;
 	$result=$adb->query($query);
 	$count=$adb->num_rows($result);
 	$logout_time=$adb->query_result($result,$count-2,'logout_time');
 	if($logout_time !='' && $logout_time != '0000-00-00 00:00:00' && $count >= 2)
 	{
-		$query ="select * from crmentity where modifiedtime > '".$logout_time."'and smownerid =".$userid;
+		$query ="select * from vtiger_crmentity where modifiedtime > '".$logout_time."'and smownerid =".$userid;
 		$result=$adb->query($query);
 		$entry_list=array();
 		for(;$i < $adb->num_rows($result);$i++)
@@ -210,15 +210,15 @@
 	$groupids = fetchUserGroupids($userid);
 	if($groupids !='')
 	{
-		//code modified to list the groups associates to a user om 21-11-05
+		//code modified to list the vtiger_groups associates to a user om 21-11-05
 		//Get the leads assigned to group
-		$query = "select leaddetails.leadid as id,leaddetails.lastname as name,leadgrouprelation.groupname as groupname, 'Leads     ' as Type from leaddetails inner join leadgrouprelation on leaddetails.leadid=leadgrouprelation.leadid inner join crmentity on crmentity.crmid = leaddetails.leadid inner join groups on leadgrouprelation.groupname=groups.groupname where  crmentity.deleted=0  and leadgrouprelation.groupname is not null and groups.groupid in (".$groupids.")";
+		$query = "select vtiger_leaddetails.leadid as id,vtiger_leaddetails.lastname as name,vtiger_leadgrouprelation.groupname as groupname, 'Leads     ' as Type from vtiger_leaddetails inner join vtiger_leadgrouprelation on vtiger_leaddetails.leadid=vtiger_leadgrouprelation.leadid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_leaddetails.leadid inner join vtiger_groups on vtiger_leadgrouprelation.groupname=vtiger_groups.groupname where  vtiger_crmentity.deleted=0  and vtiger_leadgrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
 		$query .= " union all ";
 		//Get the activities assigned to group
-		$query .= "select activity.activityid id,activity.subject,activitygrouprelation.groupname,'Activities' as Type from activity inner join activitygrouprelation on activitygrouprelation.activityid=activity.activityid inner join crmentity on crmentity.crmid = activity.activityid inner join groups on activitygrouprelation.groupname=groups.groupname where  crmentity.deleted=0 and ((activity.eventstatus !='held'and (activity.status is null or activity.status ='')) or (activity.status !='completed' and (activity.eventstatus is null or activity.eventstatus=''))) and activitygrouprelation.groupname is not null and groups.groupid in (".$groupids.")";
+		$query .= "select vtiger_activity.activityid id,vtiger_activity.subject,vtiger_activitygrouprelation.groupname,'Activities' as Type from vtiger_activity inner join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_activity.activityid inner join vtiger_groups on vtiger_activitygrouprelation.groupname=vtiger_groups.groupname where  vtiger_crmentity.deleted=0 and ((vtiger_activity.eventstatus !='held'and (vtiger_activity.status is null or vtiger_activity.status ='')) or (vtiger_activity.status !='completed' and (vtiger_activity.eventstatus is null or vtiger_activity.eventstatus=''))) and vtiger_activitygrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
 		$query .= " union all ";
 		//Get the tickets assigned to group (status not Closed -- hardcoded value)
-		$query .= "select troubletickets.ticketid,troubletickets.title,ticketgrouprelation.groupname,'Tickets   ' as Type from troubletickets inner join ticketgrouprelation on ticketgrouprelation.ticketid=troubletickets.ticketid inner join crmentity on crmentity.crmid = troubletickets.ticketid inner join groups on ticketgrouprelation.groupname=groups.groupname where crmentity.deleted=0 and troubletickets.status != 'Closed' and ticketgrouprelation.groupname is not null and groups.groupid in (".$groupids.")";
+		$query .= "select vtiger_troubletickets.ticketid,vtiger_troubletickets.title,vtiger_ticketgrouprelation.groupname,'Tickets   ' as Type from vtiger_troubletickets inner join vtiger_ticketgrouprelation on vtiger_ticketgrouprelation.ticketid=vtiger_troubletickets.ticketid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_troubletickets.ticketid inner join vtiger_groups on vtiger_ticketgrouprelation.groupname=vtiger_groups.groupname where vtiger_crmentity.deleted=0 and vtiger_troubletickets.status != 'Closed' and vtiger_ticketgrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
 
 
 		$log->info("Here is the where clause for the list view: $query");

Modified: vtigercrm/trunk/modules/Import/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Import/Forms.php (original)
+++ vtigercrm/trunk/modules/Import/Forms.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 /*********************************************************************************
  * $Header$
  * Description:  Contains a variety of utility functions used to display UI 
- * components such as form headers and footers.  Intended to be modified on a per 
+ * components such as form vtiger_headers and footers.  Intended to be modified on a per 
  * theme basis.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
@@ -64,7 +64,7 @@
 			}
 			if ( hash[ form.elements[i].value ] == 1)
 			{
-				// got same field more than once
+				// got same vtiger_field more than once
 				isError = true;
 			}
 			hash[form.elements[i].value] = 1;
@@ -83,7 +83,7 @@
 		return false;
 	}
 
-	for(var field_name in required)
+	for(var vtiger_field_name in required)
 	{
 		// contacts hack to bypass errors if full_name is set
 		if (field_name == 'last_name' && 
@@ -91,7 +91,7 @@
 		{
 			continue;
 		}
-		if ( hash[ field_name ] != 1 )
+		if ( hash[ vtiger_field_name ] != 1 )
 		{
 				isError = true;
 				errorMessage += "$err_required " + required[field_name];
@@ -177,11 +177,11 @@
 function getFieldSelect(&$column_fields,$colnum,&$required_fields,$suggest_field,$translated_fields,$module)
 {
 /*
-echo '<br> column fields : ';print_r($column_fields);
+echo '<br> column vtiger_fields : ';print_r($column_fields);
 echo '<br> column  : '.$colnum;
-echo '<br> required fields : ';print_r($required_fields);
-echo '<br> suggest fields : '.$suggest_field;
-echo '<br> translated fields : ';print_r($translated_fields);
+echo '<br> required vtiger_fields : ';print_r($required_fields);
+echo '<br> suggest vtiger_fields : '.$suggest_field;
+echo '<br> translated vtiger_fields : ';print_r($translated_fields);
 */	global $mod_strings;
 	global $app_strings;
 	global $outlook_contacts_field_map;
@@ -238,7 +238,7 @@
 	{
 	$module ='contactdetails';
 	}	
-	$custquery = "select * from field where tablename='".$module."'";
+	$custquery = "select * from vtiger_field where vtiger_tablename='".$module."'";
 	$cust_result = $adb->query($custquery);
 	while($row = $adb->fetch_array($cust_result))
 	{

Modified: vtigercrm/trunk/modules/Import/ImportAccount.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportAccount.php (original)
+++ vtigercrm/trunk/modules/Import/ImportAccount.php Mon Jun 12 14:26:25 2006
@@ -29,7 +29,7 @@
 require_once('modules/Accounts/Account.php');
 require_once('include/ComboUtil.php');
 
-// Account is used to store account information.
+// Account is used to store vtiger_account information.
 class ImportAccount extends Account {
 	 var $db;
 
@@ -39,7 +39,7 @@
 	//$comboFieldArray = getComboArray($comboFieldNames);
 
 
-	// This is the list of fields that are required.
+	// This is the list of vtiger_fields that are required.
 	var $required_fields =  array("accountname"=>1);
 	
 	// This is the list of the functions to run when importing
@@ -120,7 +120,7 @@
 	}
 
 
-	// This is the list of fields that are importable.
+	// This is the list of vtiger_fields that are importable.
 	// some if these do not map directly to database columns
 	/*var $importable_fields = Array(
 		"id"=>1

Modified: vtigercrm/trunk/modules/Import/ImportContact.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportContact.php (original)
+++ vtigercrm/trunk/modules/Import/ImportContact.php Mon Jun 12 14:26:25 2006
@@ -29,9 +29,9 @@
 
 // Contact is used to store customer information.
 class ImportContact extends Contact {
-	// these are fields that may be set on import
+	// these are vtiger_fields that may be set on import
 	// but are to be processed and incorporated
-	// into fields of the parent class
+	// into vtiger_fields of the parent class
 	var $db;
 	var $full_name;
 	var $primary_address_street_2;
@@ -170,18 +170,18 @@
 
 		$query = '';
 
-		// if user is defining the account id to be associated with this contact..
-
-		//Modified to remove the spaces at first and last in account name -- after 4.2 patch 2
+		// if user is defining the vtiger_account id to be associated with this contact..
+
+		//Modified to remove the spaces at first and last in vtiger_account name -- after 4.2 patch 2
 		$acc_name = trim(addslashes($acc_name));
 
-		$query = "select crmentity.deleted, account.* from account,crmentity WHERE accountname='{$acc_name}' and crmentity.crmid =account.accountid";
+		$query = "select vtiger_crmentity.deleted, vtiger_account.* from vtiger_account,crmentity WHERE vtiger_accountname='{$acc_name}' and vtiger_crmentity.crmid =vtiger_account.accountid";
 
                 $result = $adb->query($query)	or die("Error selecting sugarbean: ".mysql_error());
 
                 $row = $this->db->fetchByAssoc($result, -1, false);
 
-		$adb->println("fetched account");
+		$adb->println("fetched vtiger_account");
 		$adb->println($row);
 
 		// we found a row with that id
@@ -191,14 +191,14 @@
                         if ( isset($row['deleted']) && $row['deleted'] == 1)
                         {
 				$adb->println("row exists - deleting");
-                                $query2 = "delete from crmentity WHERE crmid='". $row['accountid']."'";
+                                $query2 = "delete from vtiger_crmentity WHERE crmid='". $row['accountid']."'";
 
                                 $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 just use this id to link the contact to the vtiger_account
                         else
                         {				
                                 $focus->id = $row['accountid'];
@@ -206,10 +206,10 @@
                         }
                 }
 
-		// if we didnt find the account, so create it
+		// if we didnt find the vtiger_account, so create it
                 if (! isset($focus->id) || $focus->id == '')
                 {
-			$adb->println("Createing new account");
+			$adb->println("Createing new vtiger_account");
                         $focus->column_fields['accountname'] = $acc_name;
                         $focus->column_fields['assigned_user_id'] = $current_user->id;
                         $focus->column_fields['modified_user_id'] = $current_user->id;
@@ -223,8 +223,8 @@
 			// avoid duplicate mappings:
 			if (! isset( $imported_ids[$acc_id]) )
 			{
-				$adb->println("inserting users last import for accounts");
-				// save the new account as a users_last_import
+				$adb->println("inserting vtiger_users last import for vtiger_accounts");
+				// save the new vtiger_account as a vtiger_users_last_import
                 		$last_import = new UsersLastImport();
                 		$last_import->assigned_user_id = $current_user->id;
                 		$last_import->bean_type = "Accounts";
@@ -235,7 +235,7 @@
                 }
 
 		$adb->println("prev contact accid=".$this->column_fields["account_id"]);
-		// now just link the account
+		// now just link the vtiger_account
                 $this->column_fields["account_id"] = $focus->id;
 		$adb->println("curr contact accid=".$this->column_fields["account_id"]);
 
@@ -243,10 +243,10 @@
 
 	
 
-	// This is the list of fields that can be imported
+	// This is the list of vtiger_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 vtiger_tables now
 	/*var $importable_fields =  array(
 		"contactid"=>1,
 		"firstname"=>1,

Modified: vtigercrm/trunk/modules/Import/ImportLead.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportLead.php (original)
+++ vtigercrm/trunk/modules/Import/ImportLead.php Mon Jun 12 14:26:25 2006
@@ -53,7 +53,7 @@
 		{
 			$this->db->println("searching and assigning ".$ass_user);
 
-			$result = $this->db->query("select id from users where user_name = '".$ass_user."'");
+			$result = $this->db->query("select id from vtiger_users where user_name = '".$ass_user."'");
 			if($this->db->num_rows($result)!=1)
 			{
 				$this->db->println("not exact records setting current userid");

Modified: vtigercrm/trunk/modules/Import/ImportMap.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportMap.php (original)
+++ vtigercrm/trunk/modules/Import/ImportMap.php Mon Jun 12 14:26:25 2006
@@ -29,7 +29,7 @@
 	var $log;
 	var $db;
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $name;
 	var $module;

Modified: vtigercrm/trunk/modules/Import/ImportOpportunity.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportOpportunity.php (original)
+++ vtigercrm/trunk/modules/Import/ImportOpportunity.php Mon Jun 12 14:26:25 2006
@@ -35,11 +35,11 @@
                       ,'sales_stage'=>'sales_stage_dom');
 $comboFieldArray = getComboArray($comboFieldNames);
 
-// Account is used to store account information.
+// Account is used to store vtiger_account information.
 class ImportOpportunity extends Potential {
 	 var $db;
 
-	// This is the list of fields that are required.
+	// This is the list of vtiger_fields that are required.
 	/*
 	var $required_fields =  array(
 					"potentialname"=>1,
@@ -133,9 +133,9 @@
 
 		$query = '';
 
-		// if user is defining the account id to be associated with this contact..
+		// if user is defining the vtiger_account id to be associated with this contact..
 		$acc_name = trim(addslashes($acc_name));
-		$query = "select crmentity.deleted, account.* from account,crmentity WHERE accountname='{$acc_name}' and crmentity.crmid =account.accountid";
+		$query = "select vtiger_crmentity.deleted, vtiger_account.* from vtiger_account,crmentity WHERE vtiger_accountname='{$acc_name}' and vtiger_crmentity.crmid =vtiger_account.accountid";
 
                 $this->log->info($query);
 
@@ -143,7 +143,7 @@
 
                 $row = $this->db->fetchByAssoc($result, -1, false);
 
-		$adb->println("fetched account");
+		$adb->println("fetched vtiger_account");
 		$adb->println($row);
 
 		// we found a row with that id
@@ -153,14 +153,14 @@
                         if ( isset($row['deleted']) && $row['deleted'] == 1)
                         {
 				$adb->println("row exists - deleting");
-                                $query2 = "delete from crmentity WHERE crmid='". $row['accountid']."'";
+                                $query2 = "delete from vtiger_crmentity WHERE crmid='". $row['accountid']."'";
 
                                 $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 just use this id to link the contact to the vtiger_account
                         else
                         {				
                                 $focus->id = $row['accountid'];
@@ -168,10 +168,10 @@
                         }
                 }
 
-		// if we didnt find the account, so create it
+		// if we didnt find the vtiger_account, so create it
                 if (! isset($focus->id) || $focus->id == '')
                 {
-			$adb->println("Createing new account");
+			$adb->println("Createing new vtiger_account");
                         $focus->column_fields['accountname'] = $acc_name;
                         $focus->column_fields['assigned_user_id'] = $current_user->id;
                         $focus->column_fields['modified_user_id'] = $current_user->id;
@@ -184,8 +184,8 @@
 			// avoid duplicate mappings:
 			if (! isset( $imported_ids[$acc_id]) )
 			{
-				$adb->println("inserting users last import for accounts");
-				// save the new account as a users_last_import
+				$adb->println("inserting vtiger_users last import for vtiger_accounts");
+				// save the new vtiger_account as a vtiger_users_last_import
                 		$last_import = new UsersLastImport();
                 		$last_import->assigned_user_id = $current_user->id;
                 		$last_import->bean_type = "Accounts";
@@ -196,7 +196,7 @@
                 }
 
 		$adb->println("prev contact accid=".$this->column_fields["account_id"]);
-		// now just link the account
+		// now just link the vtiger_account
                 $this->column_fields["account_id"] = $focus->id;
 		$adb->println("curr contact accid=".$this->column_fields["account_id"]);
 
@@ -213,7 +213,7 @@
 	}
 
 	
-	// This is the list of fields that are importable.
+	// This is the list of vtiger_fields that are importable.
 	// some if these do not map directly to database columns
 	/*var $importable_fields = Array(
 		"id"=>1

Modified: vtigercrm/trunk/modules/Import/ImportProduct.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportProduct.php (original)
+++ vtigercrm/trunk/modules/Import/ImportProduct.php Mon Jun 12 14:26:25 2006
@@ -54,7 +54,7 @@
 		{
 			$this->db->println("searching and assigning ".$ass_user);
 
-			$result = $this->db->query("select id from users where user_name = '".$ass_user."'");
+			$result = $this->db->query("select id from vtiger_users where user_name = '".$ass_user."'");
 			if($this->db->num_rows($result)!=1)
 			{
 				$this->db->println("not exact records setting current userid");

Modified: vtigercrm/trunk/modules/Import/ImportSave.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportSave.php (original)
+++ vtigercrm/trunk/modules/Import/ImportSave.php Mon Jun 12 14:26:25 2006
@@ -17,7 +17,7 @@
 	global $current_user;
 	global $adb;
 
-// MWC ** Getting users
+// MWC ** Getting vtiger_users
 $temp = get_user_array(FALSE);
 foreach ( $temp as $key=>$data)
 	$my_users[$data] = $key;
@@ -84,7 +84,7 @@
 
 	p("setting done");
 	
-	p("do save before req fields=".$do_save);
+	p("do save before req vtiger_fields=".$do_save);
 
 	$adb->println($focus->required_fields);
 
@@ -128,7 +128,7 @@
 			{
 				$_REQUEST['module']='contactdetails';
 			}
-			$dbquery="select * from field where tablename='".$_REQUEST['module']."'";
+			$dbquery="select * from vtiger_field where vtiger_tablename='".$_REQUEST['module']."'";
 			$custresult = $adb->query($dbquery);
 			if($adb->num_rows($custresult) != 0)
 			{

Modified: vtigercrm/trunk/modules/Import/ImportStep2.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportStep2.php (original)
+++ vtigercrm/trunk/modules/Import/ImportStep2.php Mon Jun 12 14:26:25 2006
@@ -226,7 +226,7 @@
 
 $translated_column_fields = $mod_list_strings[$list_string_key];
 
-// adding custom fields translations
+// adding custom vtiger_fields translations
 getCustomFieldTrans($_REQUEST['module'],&$translated_column_fields);
 
 $cnt=1;
@@ -355,7 +355,7 @@
 {
 	var tagName;
 	var count = 0;
-	var field_count = "<?php echo $field_count; ?>";
+	var vtiger_field_count = "<?php echo $field_count; ?>";
 	var required_fields = new Array();
 	var required_fields_name = new Array();
 	var seq_string = '';
@@ -384,7 +384,7 @@
 			}
 			else
 			{
-				//if a field mapped more than once, alert the user and return
+				//if a vtiger_field mapped more than once, alert the user and return
 				alert("'"+tagName.options[tagName.selectedIndex].text+"' is mapped more than once. Please check the mapping.");
 				return false;
 			}
@@ -392,12 +392,12 @@
 
 	}
 
-	//check whether the mandatory fields have been mapped.
+	//check whether the mandatory vtiger_fields have been mapped.
 	for(inner_loop = 0; inner_loop<required_fields.length;inner_loop++)
 	{
 		if(seq_string.indexOf(required_fields[inner_loop]) == -1)
 		{
-			alert('Please map the mandatory field "'+required_fields_name[inner_loop]+'"');
+			alert('Please map the mandatory vtiger_field "'+required_fields_name[inner_loop]+'"');
 			return false;
 		}
 	}

Modified: vtigercrm/trunk/modules/Import/ImportStep3.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportStep3.php (original)
+++ vtigercrm/trunk/modules/Import/ImportStep3.php Mon Jun 12 14:26:25 2006
@@ -112,13 +112,13 @@
 
 $focus = new $current_bean_type();
 
-//Constructing the custom field Array
+//Constructing the custom vtiger_field Array
 require_once('include/CustomFieldUtil.php');
 $custFldArray = getCustomFieldArray($_REQUEST['module']);
 p("IMP 3: custFldArray");
 p($custFldArray);
 
-//Initializing  an empty Array to store the custom field Column Name and Value
+//Initializing  an empty Array to store the custom vtiger_field Column Name and Value
 $resCustFldArray = Array();
 
 p("Getting from request");
@@ -137,13 +137,13 @@
 		continue;
 	}
 
-	// this value is a user defined field name
+	// this value is a user defined vtiger_field name
 	$user_field = $value;
 
-	// pull out the column position for this field name
+	// pull out the column position for this vtiger_field name
 	$pos = substr($name,6);
 
-	// make sure we haven't seen this field defined yet
+	// make sure we haven't seen this vtiger_field defined yet
 	if ( isset( $field_to_pos[$user_field]) )
 	{
 		show_error_import($mod_strings['LBL_ERROR_MULTIPLE']);
@@ -153,12 +153,12 @@
 
 	p("user_field=".$user_field." if=".$focus->importable_fields[$user_field]);
 	
-	// match up the "official" field to the user 
+	// match up the "official" vtiger_field to the user 
 	// defined one, and map to columm position: 
 	if ( isset( $focus->importable_fields[$user_field] ) || isset( $custFldArray[$user_field] ))
 	{
 		p("user_field SET=".$user_field);
-		// now mark that we've seen this field
+		// now mark that we've seen this vtiger_field
 		$field_to_pos[$user_field] = $pos;
 		$col_pos_to_field[$pos] = $user_field;
 	}
@@ -207,7 +207,7 @@
 	$firstrow = array_shift($datarows);
 }
 
-//Mark the last imported records as deleted which are imported by the current user in users_last_import table
+//Mark the last imported records as deleted which are imported by the current user in vtiger_users_last_import vtiger_table
 if(!isset($_REQUEST['startval']))
 {
 	$seedUsersLastImport = new UsersLastImport();

Modified: vtigercrm/trunk/modules/Import/UsersLastImport.php
==============================================================================
--- vtigercrm/trunk/modules/Import/UsersLastImport.php (original)
+++ vtigercrm/trunk/modules/Import/UsersLastImport.php Mon Jun 12 14:26:25 2006
@@ -32,7 +32,7 @@
 	var $log;
 	var $db;
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $assigned_user_id;
 	var $bean_type;
@@ -64,7 +64,7 @@
 	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: ");
+                $this->db->query($query,true,"Error marking last imported vtiger_accounts deleted: ");
         }
 
 
@@ -78,86 +78,86 @@
 		if ($this->bean_type == 'Contacts')
 		{
 				$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,
+			vtiger_account.accountname as vtiger_account_name,
+			vtiger_contactdetails.contactid,
+			vtiger_contactdetails.accountid,				
+			vtiger_contactdetails.yahooid,
+			vtiger_contactdetails.firstname,
+			vtiger_contactdetails.lastname,
+			vtiger_contactdetails.phone,
+			vtiger_contactdetails.title,
+			vtiger_contactdetails.email,
+			vtiger_users.id as assigned_user_id,
 				smownerid,
-                                users.user_name as assigned_user_name
-				FROM contactdetails
-				left join users_last_import on users_last_import.bean_id=contactdetails.contactid
-				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.deleted=0  AND crmentity.deleted=0";
+                                vtiger_users.user_name as assigned_user_name
+				FROM vtiger_contactdetails
+				left join vtiger_users_last_import on vtiger_users_last_import.bean_id=vtiger_contactdetails.contactid
+				LEFT JOIN vtiger_users ON vtiger_contactdetails.contactid=vtiger_users.id 
+				LEFT JOIN vtiger_account  ON vtiger_account.accountid=vtiger_contactdetails.accountid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid  
+				WHERE vtiger_users_last_import.assigned_user_id= '{$current_user->id}'  
+				AND vtiger_users_last_import.bean_type='Contacts' 
+				AND vtiger_users_last_import.deleted=0  AND vtiger_crmentity.deleted=0";
 			
 		} 
 		else if ($this->bean_type == 'Accounts')
 		{
-				$query = "SELECT distinct account.*, accountbillads.city,
-                                users.user_name assigned_user_name,
+				$query = "SELECT distinct vtiger_account.*, vtiger_accountbillads.city,
+                                vtiger_users.user_name assigned_user_name,
 				crmid, smownerid 
-				FROM account
-				inner join crmentity on crmentity.crmid=account.accountid
-				inner join accountbillads on crmentity.crmid=accountbillads.accountaddressid
-				left join users_last_import on users_last_import.bean_id=crmentity.crmid
-			       	left join users ON crmentity.smownerid=users.id
+				FROM vtiger_account
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid
+				inner join vtiger_accountbillads on vtiger_crmentity.crmid=vtiger_accountbillads.accountaddressid
+				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 
-				users_last_import.assigned_user_id=
+			vtiger_users_last_import.assigned_user_id=
 					'{$current_user->id}'
-				AND users_last_import.bean_type='Accounts'
-				AND users_last_import.deleted=0
-				AND crmentity.deleted=0
-				AND users.status='Active'";
+				AND vtiger_users_last_import.bean_type='Accounts'
+				AND vtiger_users_last_import.deleted=0
+				AND vtiger_crmentity.deleted=0
+				AND vtiger_users.status='Active'";
 		} 
 		else if ($this->bean_type == 'Potentials')
 		{
 		
 			$query = "SELECT distinct
-                                account.accountid account_id,
-                                account.accountname account_name,
-                                users.user_name assigned_user_name,
-				crmentity.crmid, smownerid,
-				potential.*
-                               FROM potential 
-			       inner join account on account.accountid=potential.accountid 
-			       inner join  crmentity on crmentity.crmid=potential.potentialid 
-			       left join users ON crmentity.smownerid=users.id 
-			       left join users_last_import on users_last_import.assigned_user_id=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'";
+                                vtiger_account.accountid vtiger_account_id,
+                                vtiger_account.accountname vtiger_account_name,
+                                vtiger_users.user_name assigned_user_name,
+			vtiger_crmentity.crmid, smownerid,
+			vtiger_potential.*
+                               FROM vtiger_potential 
+			       inner join vtiger_account on vtiger_account.accountid=vtiger_potential.accountid 
+			       inner join  vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid 
+			       left join vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id 
+			       left join vtiger_users_last_import on vtiger_users_last_import.assigned_user_id=vtiger_users.id 
+			       where vtiger_users_last_import.assigned_user_id='{$current_user->id}'
+				AND vtiger_users_last_import.bean_type='Potentials'
+				AND vtiger_users_last_import.bean_id=vtiger_crmentity.crmid
+				AND vtiger_users_last_import.deleted=0
+				AND vtiger_crmentity.deleted=0 
+				AND vtiger_users.status='Active'";
 
 		}
 		else if($this->bean_type == 'Leads')
 		{
-			$query = "SELECT distinct leaddetails.*, crmentity.crmid, leadaddress.phone,leadsubdetails.website,
-                                users.user_name assigned_user_name,
+			$query = "SELECT distinct vtiger_leaddetails.*, vtiger_crmentity.crmid, vtiger_leadaddress.phone,vtiger_leadsubdetails.website,
+                                vtiger_users.user_name assigned_user_name,
 				smownerid 
-				FROM leaddetails 
-				inner join crmentity on crmentity.crmid=leaddetails.leadid 
-				inner join leadaddress on crmentity.crmid=leadaddress.leadaddressid 
-				inner join leadsubdetails on crmentity.crmid=leadsubdetails.leadsubscriptionid 
-				left join users_last_import on users_last_import.bean_id=crmentity.crmid			       	
-				left join users ON crmentity.smownerid=users.id
+				FROM vtiger_leaddetails 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid 
+				inner join vtiger_leadaddress on vtiger_crmentity.crmid=vtiger_leadaddress.leadaddressid 
+				inner join vtiger_leadsubdetails on vtiger_crmentity.crmid=vtiger_leadsubdetails.leadsubscriptionid 
+				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 
-				users_last_import.assigned_user_id=
+			vtiger_users_last_import.assigned_user_id=
 					'{$current_user->id}'
-				AND users_last_import.bean_type='Leads'
-				AND users_last_import.deleted=0
-				AND crmentity.deleted=0
-				AND users.status='Active'";
+				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'";
 		}
 
 		
@@ -199,15 +199,15 @@
 	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']}'";
+		$query1 = "select bean_id from vtiger_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 vtiger_crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
 
 			$this->log->info($query2); 
 
@@ -222,15 +222,15 @@
 	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']}'";
+		$query1 = "select bean_id from vtiger_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 vtiger_crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
 
 			$this->log->info($query2); 
 
@@ -246,15 +246,15 @@
 	{
 		// 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']}'";
+		$query1 = "select bean_id from vtiger_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 vtiger_crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
 
 			$this->log->info($query2); 
 
@@ -270,15 +270,15 @@
 	{
 		// 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']}'";
+		$query1 = "select bean_id from vtiger_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 vtiger_crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
 
 			$this->log->info($query2); 
 
@@ -293,15 +293,15 @@
 	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']}'";
+		$query1 = "select bean_id from vtiger_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 vtiger_crmentity set deleted=1 where crmid='{$row1['bean_id']}'";
 
 			$this->log->info($query2); 
 

Modified: vtigercrm/trunk/modules/Import/index.php
==============================================================================
--- vtigercrm/trunk/modules/Import/index.php (original)
+++ vtigercrm/trunk/modules/Import/index.php Mon Jun 12 14:26:25 2006
@@ -177,7 +177,7 @@
 
 
 /*
-ommited fields to map:
+ommited vtiger_fields to map:
 "Account Number"=>"",
 "Account Site"=>"",
 "Last Activity"=>"",

Modified: vtigercrm/trunk/modules/Import/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Import/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Import/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -25,18 +25,18 @@
 'LBL_IMPORT_MODULE_NO_DIRECTORY'=>'The directory ',
 'LBL_IMPORT_MODULE_NO_DIRECTORY_END'=>' does not exist or is not writable',
 'LBL_IMPORT_MODULE_ERROR_NO_UPLOAD'=>'File was not uploaded successfully, try again',
-'LBL_IMPORT_MODULE_ERROR_LARGE_FILE'=>'File is too large. Max:',
+'LBL_IMPORT_MODULE_ERROR_LARGE_FILE'=>'File is too vtiger_large. Max:',
 'LBL_IMPORT_MODULE_ERROR_LARGE_FILE_END'=>'Bytes. Change $upload_maxsize in config.php',
 'LBL_MODULE_NAME'=>'Import',
 'LBL_TRY_AGAIN'=>'Try Again',
 'LBL_ERROR'=>'Error:',
-'ERR_MULTIPLE'=>'Multiple columns have been defined with the same field name.',
-'ERR_MISSING_REQUIRED_FIELDS'=>'Missing required fields:',
+'ERR_MULTIPLE'=>'Multiple columns have been defined with the same vtiger_field name.',
+'ERR_MISSING_REQUIRED_FIELDS'=>'Missing required vtiger_fields:',
 'ERR_SELECT_FULL_NAME'=>'You cannot select Full Name when First Name and Last Name are selected.',
 'ERR_SELECT_FILE'=>'Select a file to upload.',
 'LBL_SELECT_FILE'=>'Select file:',
 'LBL_CUSTOM'=>'Custom',
-'LBL_DONT_MAP'=>'-- Do not map this field --',
+'LBL_DONT_MAP'=>'-- Do not map this vtiger_field --',
 'LBL_STEP_1_TITLE'=>'Step 1 of 4: Select Data Source',
 'LBL_WHAT_IS'=>'Please select a data source from the following:',
 'LBL_MICROSOFT_OUTLOOK'=>'Microsoft Outlook',
@@ -80,21 +80,21 @@
 'LBL_ACT_NUM_4'=>'Choose a filename and location for the exported data and click <b>Next</b>',
 'LBL_ACT_NUM_5'=>'Select <b>Contacts records only</b>',
 'LBL_ACT_NUM_6'=>'Click the <b>Options...</b> button',
-'LBL_ACT_NUM_7'=>'Select <b>Comma</b> as the field separator character',
-'LBL_ACT_NUM_8'=>'Check the <b>Yes, export field names</b> checkbox and click <b>OK</b>',
+'LBL_ACT_NUM_7'=>'Select <b>Comma</b> as the vtiger_field separator character',
+'LBL_ACT_NUM_8'=>'Check the <b>Yes, export vtiger_field names</b> checkbox and click <b>OK</b>',
 'LBL_ACT_NUM_9'=>'Click <b>Next</b>',
 'LBL_ACT_NUM_10'=>'Select <b>All Records</b> and then Click <b>Finish</b>',
 
 'LBL_IMPORT_SF_TITLE'=>'Salesforce.com can export data in the <b>Comma Separated Values</b> format which can be used to import data into the system. To export your data from Salesforce.com, follow the steps below:',
 'LBL_SF_NUM_1'=>'Open your browser, go to http://www.salesforce.com, and login with your email address and password',
-'LBL_SF_NUM_2'=>'Click on the <b>Reports</b> tab on the top menu',
+'LBL_SF_NUM_2'=>'Click on the <b>Reports</b> vtiger_tab on the top menu',
 'LBL_SF_NUM_3'=>'To export Accounts:</b> Click on the <b>Active Accounts</b> link<br><b>To export Contacts:</b> Click on the <b>Mailing List</b> link',
-'LBL_SF_NUM_4'=>'On <b>Step 1: Select your report type</b>, select <b>Tabular Report</b>click <b>Next</b>',
-'LBL_SF_NUM_5'=>'On <b>Step 2: Select the report columns</b>, choose the columns you want to export and click <b>Next</b>',
+'LBL_SF_NUM_4'=>'On <b>Step 1: Select your vtiger_report type</b>, select <b>Tabular Report</b>click <b>Next</b>',
+'LBL_SF_NUM_5'=>'On <b>Step 2: Select the vtiger_report columns</b>, choose the columns you want to export and click <b>Next</b>',
 'LBL_SF_NUM_6'=>'On <b>Step 3: Select the information to summarize</b>, just click <b>Next</b>',
-'LBL_SF_NUM_7'=>'On <b>Step 4: Order the report columns</b>, just click <b>Next</b>',
-'LBL_SF_NUM_8'=>'On <b>Step 5: Select your report criteria</b>, under <b>Start Date</b>, choose a date far enough in the past to include all your Accounts. You can also export a subset of Accounts using more advanced criteria. When you are done, click <b>Run Report</b>',
-'LBL_SF_NUM_9'=>'A report will be generated, and the page should display <b>Report Generation Status: Complete.</b> Now click <b>Export to Excel</b>',
+'LBL_SF_NUM_7'=>'On <b>Step 4: Order the vtiger_report columns</b>, just click <b>Next</b>',
+'LBL_SF_NUM_8'=>'On <b>Step 5: Select your vtiger_report criteria</b>, under <b>Start Date</b>, choose a date far enough in the past to include all your Accounts. You can also export a subset of Accounts using more advanced criteria. When you are done, click <b>Run Report</b>',
+'LBL_SF_NUM_9'=>'A vtiger_report will be generated, and the page should display <b>Report Generation Status: Complete.</b> Now click <b>Export to Excel</b>',
 'LBL_SF_NUM_10'=>'On <b>Export Report:</b>, for <b>Export File Format:</b>, choose <b>Comma Delimited .csv</b>. Click <b>Export</b>.',
 'LBL_SF_NUM_11'=>'A dialog will pop up for you to save the export file to your computer.',
 'LBL_IMPORT_CUSTOM_TITLE'=>'Many applications will allow you to export data into a <b>Comma Delimited text file (.csv)</b>. Generally most applications follow these general steps:',
@@ -105,9 +105,9 @@
 'LBL_STEP_3_TITLE'=>'Step 3 of 4: Confirm Fields and Import',
 'LBL_STEP_1'=>'Step 1 of 3 : ',
 'LBL_STEP_1_TITLE'=>'Select the .CSV File',
-'LBL_STEP_1_TEXT'=> ' vtiger CRM supports importing records from .csv (<b> Comma Separated Values</b> ) files. To start import, browse to locate the .CSV file and click on the Next button to Continue.',
-
-'LBL_SELECT_FIELDS_TO_MAP'=>'In the list below, select the fields in your import file that should be imported into each field in the system. When you are finished, click <b>Import Now</b>',
+'LBL_STEP_1_TEXT'=> ' vtiger CRM supports importing records from .csv (<b> Comma Separated Values</b> ) vtiger_files. To start import, browse to locate the .CSV file and click on the Next button to Continue.',
+
+'LBL_SELECT_FIELDS_TO_MAP'=>'In the list below, select the vtiger_fields in your import file that should be imported into each vtiger_field in the system. When you are finished, click <b>Import Now</b>',
 
 'LBL_DATABASE_FIELD'=>'Database Field',
 'LBL_HEADER_ROW'=>'Header Row',
@@ -119,15 +119,15 @@
 'LBL_CONTACTS_NOTE_4'=>'Fields ending in Address Street 2 and Address Street 3 are concatenated together with the main Address Street Field when inserted into the database.',
 'LBL_ACCOUNTS_NOTE_1'=>'Account Name must be mapped.',
 'LBL_ACCOUNTS_NOTE_2'=>'Fields ending in Address Street 2 and Address Street 3 are concatenated together with the main Address Street Field when inserted into the database.',
-'LBL_POTENTIALS_NOTE_1'=>'Potential Name, Account Name, Date Closed, and Sales Stage are required fields.',
-'LBL_OPPORTUNITIES_NOTE_1'=>'Opportunity Name, Account Name, Date Closed, and Sales Stage are required fields.',
+'LBL_POTENTIALS_NOTE_1'=>'Potential Name, Account Name, Date Closed, and Sales Stage are required vtiger_fields.',
+'LBL_OPPORTUNITIES_NOTE_1'=>'Opportunity Name, Account Name, Date Closed, and Sales Stage are required vtiger_fields.',
 'LBL_LEADS_NOTE_1'=>'Last Name must be mapped.',
 'LBL_LEADS_NOTE_2'=>'Company Name must be mapped.',
 'LBL_IMPORT_NOW'=>'Import Now',
 'LBL_'=>'',
 'LBL_'=>'',
 'LBL_CANNOT_OPEN'=>'Cannot open the imported file for reading',
-'LBL_NOT_SAME_NUMBER'=>'There were not the same number of fields per line in your file',
+'LBL_NOT_SAME_NUMBER'=>'There were not the same number of vtiger_fields per line in your file',
 'LBL_NO_LINES'=>'There were no lines in your import file',
 'LBL_FILE_ALREADY_BEEN_OR'=>'The import file has already been processed or does not exist',
 'LBL_SUCCESS'=>'Success! ',
@@ -135,7 +135,7 @@
 'LBL_LAST_IMPORT_UNDONE'=>'Your Last Import Was Undone',
 'LBL_NO_IMPORT_TO_UNDO'=>'There was no import to undo.',
 'LBL_FAIL'=>'Fail:',
-'LBL_RECORDS_SKIPPED'=>'records skipped because they were missing one or more required fields',
+'LBL_RECORDS_SKIPPED'=>'records skipped because they were missing one or more required vtiger_fields',
 'LBL_IDS_EXISTED_OR_LONGER'=>'records skipped because the id\'s either existed or where longer than 36 characters',
 'LBL_RESULTS'=>'Results',
 'LBL_IMPORT_MORE'=>'Import More',
@@ -143,7 +143,7 @@
 'LBL_UNDO_LAST_IMPORT'=>'Undo Last Import',
 
 'LBL_SUCCESS_1' => 'No. of Records Successfully Imported : ',
-'LBL_SKIPPED_1' => 'No. of Records Skipped as they were missing one or more required fields : ',
+'LBL_SKIPPED_1' => 'No. of Records Skipped as they were missing one or more required vtiger_fields : ',
 
 //Added for patch2 - Products Import Notes
 'LBL_PRODUCTS_NOTE_1'=>'Product Name must be mapped',
@@ -153,13 +153,13 @@
 'LBL_FILE_LOCATION'=>'File Location :',
 'LBL_STEP_2_3'=>'Step 2 of 3 :',
 'LBL_LIST_MAPPING'=>'List & Mapping',
-'LBL_STEP_2_MSG'=>'The following tables shows the imported',
+'LBL_STEP_2_MSG'=>'The following vtiger_tables shows the imported',
 'LBL_STEP_2_MSG1'=>'and other details.',
-'LBL_STEP_2_TXT'=>'To map the fields, Select the corresponding in combo boxes for each',
+'LBL_STEP_2_TXT'=>'To map the vtiger_fields, Select the corresponding in combo boxes for each',
 'LBL_USE_SAVED_MAPPING'=>'Use Saved Mapping :',
 'LBL_MAPPING'=>'Mapping',
 'LBL_HEADERS'=>'Headers :',
-'LBL_ERROR_MULTIPLE'=>'Same fields may be mapped twice. Please check the mapped fields.',
+'LBL_ERROR_MULTIPLE'=>'Same vtiger_fields may be mapped twice. Please check the mapped vtiger_fields.',
 
 );
 

Modified: vtigercrm/trunk/modules/Import/parse_utils.php
==============================================================================
--- vtigercrm/trunk/modules/Import/parse_utils.php (original)
+++ vtigercrm/trunk/modules/Import/parse_utils.php Mon Jun 12 14:26:25 2006
@@ -14,9 +14,9 @@
  ********************************************************************************/
 
 // takes a string and parses it into one record per line,
-// one field per delimiter, to a maximum number of lines
-// some files have a header, some dont.
-// keeps track of which fields are used
+// one vtiger_field per delimiter, to a maximum number of lines
+// some vtiger_files have a header, some dont.
+// keeps track of which vtiger_fields are used
 
 function parse_import($file_name,$delimiter,$max_lines,$has_header)
 {

Modified: vtigercrm/trunk/modules/Invoice/CreatePDF.php
==============================================================================
--- vtigercrm/trunk/modules/Invoice/CreatePDF.php (original)
+++ vtigercrm/trunk/modules/Invoice/CreatePDF.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 require_once('include/database/PearDatabase.php');
 
 global $adb,$app_strings,$products_per_page;
-$sql="select currency_symbol from currency_info";
+$sql="select vtiger_currency_symbol from vtiger_currency_info";
 $result = $adb->query($sql);
 $currency_symbol = $adb->query_result($result,0,'currency_symbol');
 
@@ -25,7 +25,7 @@
 
 $id = $_REQUEST['record'];
 
-//retreiving the invoice info
+//retreiving the vtiger_invoice info
 $focus = new Invoice();
 $focus->retrieve_entity_info($_REQUEST['record'],"Invoice");
 $account_name = getAccountName($focus->column_fields[account_id]);
@@ -60,7 +60,7 @@
 $status = $focus->column_fields["invoicestatus"];
 
 // Company information
-$add_query = "select * from organizationdetails";
+$add_query = "select * from vtiger_organizationdetails";
 $result = $adb->query($add_query);
 $num_rows = $adb->num_rows($result);
 
@@ -85,7 +85,7 @@
 $price_total = $currency_symbol.number_format(StripLastZero($focus->column_fields["hdnGrandTotal"]),2,'.',',');
 
 //getting the Product Data
-$query="select products.productname,products.unit_price,products.product_description,invoiceproductrel.* from invoiceproductrel inner join products on products.productid=invoiceproductrel.productid where invoiceid=".$id;
+$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.product_description,vtiger_invoiceproductrel.* from vtiger_invoiceproductrel inner join vtiger_products on vtiger_products.productid=vtiger_invoiceproductrel.productid where vtiger_invoiceid=".$id;
 
 global $result;
 $result = $adb->query($query);

Modified: vtigercrm/trunk/modules/Invoice/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Invoice/EditView.php (original)
+++ vtigercrm/trunk/modules/Invoice/EditView.php Mon Jun 12 14:26:25 2006
@@ -47,7 +47,7 @@
 	$quote_focus->retrieve_entity_info($quoteid,"Quotes");
 	$focus = getConvertQuoteToInvoice($focus,$quote_focus,$quoteid);
 
-	//Added to display the Quote's associated products -- when we create invoice from Quotes DetailView 
+	//Added to display the Quote's associated vtiger_products -- when we create vtiger_invoice from Quotes DetailView 
 	$associated_prod = getAssociatedProducts("Quotes",$quote_focus);
 	$txtTax = (($quote_focus->column_fields['txtTax'] != '')?$quote_focus->column_fields['txtTax']:'0.000');
 	$txtAdj = (($quote_focus->column_fields['txtAdjustment'] != '')?$quote_focus->column_fields['txtAdjustment']:'0.000');
@@ -68,7 +68,7 @@
         $so_focus->retrieve_entity_info($soid,"SalesOrder");
         $focus = getConvertSoToInvoice($focus,$so_focus,$soid);
 
-	//Added to display the SalesOrder's associated products -- when we create invoice from SO DetailView
+	//Added to display the SalesOrder's associated vtiger_products -- when we create vtiger_invoice from SO DetailView
 	$associated_prod = getAssociatedProducts("SalesOrder",$so_focus);
 	$txtTax = (($so_focus->column_fields['txtTax'] != '')?$so_focus->column_fields['txtTax']:'0.000');
 	$txtAdj = (($so_focus->column_fields['txtAdjustment'] != '')?$so_focus->column_fields['txtAdjustment']:'0.000');
@@ -98,7 +98,7 @@
                 }
 
         }
-	//Handling for dateformat in invoicedate field
+	//Handling for dateformat in vtiger_invoicedate vtiger_field
         if($focus->column_fields['invoicedate'] != '')
         {
               $curr_due_date = $focus->column_fields['invoicedate'];
@@ -137,7 +137,7 @@
 			}
 
 		}
-		//Handling for dateformat in invoicedate field
+		//Handling for dateformat in vtiger_invoicedate vtiger_field
                 if($focus->column_fields['invoicedate'] != '')
                 {
                         $curr_due_date = $focus->column_fields['invoicedate'];

Modified: vtigercrm/trunk/modules/Invoice/Invoice.php
==============================================================================
--- vtigercrm/trunk/modules/Invoice/Invoice.php (original)
+++ vtigercrm/trunk/modules/Invoice/Invoice.php Mon Jun 12 14:26:25 2006
@@ -28,25 +28,25 @@
 require_once('data/CRMEntity.php');
 require_once('include/utils/utils.php');
 
-// Account is used to store account information.
+// Account is used to store vtiger_account information.
 class Invoice extends CRMEntity {
 	var $log;
 	var $db;
 
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $mode;
 	
 		
-	var $table_name = "invoice";
-	var $tab_name = Array('crmentity','invoice','invoicebillads','invoiceshipads','invoicecf');
-	var $tab_name_index = Array('crmentity'=>'crmid','invoice'=>'invoiceid','invoicebillads'=>'invoicebilladdressid','invoiceshipads'=>'invoiceshipaddressid','invoicecf'=>'invoiceid');
+	var $table_name = "vtiger_invoice";
+	var $tab_name = Array('vtiger_crmentity','vtiger_invoice','vtiger_invoicebillads','vtiger_invoiceshipads','vtiger_invoicecf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_invoice'=>'invoiceid','vtiger_invoicebillads'=>'invoicebilladdressid','vtiger_invoiceshipads'=>'invoiceshipaddressid','vtiger_invoicecf'=>'invoiceid');
 				
 	
-	var $entity_table = "crmentity";
-	
-	var $billadr_table = "invoicebillads";
+	var $entity_table = "vtiger_crmentity";
+	
+	var $billadr_table = "vtiger_invoicebillads";
 
 	var $object_name = "Invoice";
 
@@ -58,10 +58,10 @@
 
 	var $sortby_fields = Array('subject','crmid','invoicestatus','smownerid');		
 
-	// This is used to retrieve related fields from form posts.
+	// This is used to retrieve related vtiger_fields from form posts.
 	var $additional_column_fields = Array('assigned_user_name', 'smownerid', 'opportunity_id', 'case_id', 'contact_id', 'task_id', 'note_id', 'meeting_id', 'call_id', 'email_id', 'parent_name', 'member_id' );
 
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
 				'Invoice Id'=>Array('crmentity'=>'crmid'),
 				'Subject'=>Array('invoice'=>'subject'),
@@ -95,7 +95,7 @@
 				        'Subject'=>'subject',
 				      );
 
-	// This is the list of fields that are required.
+	// This is the list of vtiger_fields that are required.
 	var $required_fields =  array("accountname"=>1);
 
 	//Added these variables which are used as default order by and sortorder in ListView
@@ -129,7 +129,7 @@
 
 		$returnset = '&return_module=Invoice&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT contactdetails.lastname, contactdetails.firstname, contactdetails.contactid, activity.*,seactivityrel.*,crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime, users.user_name from activity inner join seactivityrel on seactivityrel.activityid=activity.activityid inner join crmentity on crmentity.crmid=activity.activityid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid = cntactivityrel.contactid left join users on users.id=crmentity.smownerid left join activitygrouprelation on activitygrouprelation.activityid=crmentity.crmid left join groups on groups.groupname=activitygrouprelation.groupname where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and (activity.status is not NULL && activity.status != 'Completed') and (activity.status is not NULL && activity.status != 'Deferred') or (activity.eventstatus != '' &&  activity.eventstatus = 'Planned')";
+		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or vtiger_activitytype='Call' or vtiger_activitytype='Meeting') and vtiger_crmentity.deleted=0 and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Deferred') or (vtiger_activity.eventstatus != '' &&  vtiger_activity.eventstatus = 'Planned')";
 		$log->debug("Exiting get_activities method ...");
 		return  GetRelatedList('Invoice','Activities',$focus,$query,$button,$returnset);
 	}
@@ -137,20 +137,20 @@
 	{
 		global $log;
 		$log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT contactdetails.lastname, contactdetails.firstname, contactdetails.contactid,
-				activity.*,seactivityrel.*,crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime,
-				crmentity.createdtime, crmentity.description, users.user_name
-			from activity
-				inner join seactivityrel on seactivityrel.activityid=activity.activityid
-				inner join crmentity on crmentity.crmid=activity.activityid
-				left join cntactivityrel on cntactivityrel.activityid= activity.activityid
-				left join contactdetails on contactdetails.contactid = cntactivityrel.contactid
-				inner join users on crmentity.smcreatorid= users.id
-				left join activitygrouprelation on activitygrouprelation.activityid=activity.activityid
-                                left join groups on groups.groupname=activitygrouprelation.groupname	
-			where (activity.activitytype = 'Meeting' or activity.activitytype='Call' or activity.activitytype='Task')
-				and (activity.status = 'Completed' or activity.status = 'Deferred' or (activity.eventstatus != 'Planned' and activity.eventstatus != ''))
-				and seactivityrel.crmid=".$id;
+		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,
+			vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,
+			vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
+			from vtiger_activity
+				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
+				left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
+				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
+				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname	
+			where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
+				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus != 'Planned' and vtiger_activity.eventstatus != ''))
+				and vtiger_seactivityrel.crmid=".$id;
 		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
 
 		$log->debug("Exiting get_history method ...");
@@ -161,35 +161,35 @@
 		global $log;
 		$log->debug("Entering get_attachments(".$id.") method ...");
 		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crm2.createdtime, notes.notecontent description, users.user_name
-		// Inserted inner join users on crm2.smcreatorid= users.id
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename,
-			attachments.type  FileType,crm2.modifiedtime lastmodified,
-			seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid,
-			crm2.createdtime, notes.notecontent description, users.user_name
-		from notes
-			inner join senotesrel on senotesrel.notesid= notes.notesid
-			inner join crmentity on crmentity.crmid= senotesrel.crmid
-			inner join crmentity crm2 on crm2.crmid=notes.notesid and crm2.deleted=0
-			left join seattachmentsrel  on seattachmentsrel.crmid =notes.notesid
-			left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid
-			inner join users on crm2.smcreatorid= users.id
-		where crmentity.crmid=".$id;
+		// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		$query = "select vtiger_notes.title,'Notes      '  ActivityType, vtiger_notes.filename,
+		vtiger_attachments.type  FileType,crm2.modifiedtime lastmodified,
+		vtiger_seattachmentsrel.attachmentsid vtiger_attachmentsid, vtiger_notes.notesid crmid,
+			crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		from vtiger_notes
+			inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+			left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id;
 		$query .= ' union all ';
 		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crm2.createdtime, attachments.description, users.user_name
-		// Inserted inner join users on crm2.smcreatorid= users.id
+		// Desc: Inserted crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
 		// Inserted order by createdtime desc
-		$query .= "select attachments.description  title ,'Attachments'  ActivityType,
-			attachments.name filename, attachments.type FileType, crm2.modifiedtime lastmodified,
-			attachments.attachmentsid attachmentsid, seattachmentsrel.attachmentsid crmid,
-			crm2.createdtime, attachments.description, users.user_name
-		from attachments
-			inner join seattachmentsrel on seattachmentsrel.attachmentsid= attachments.attachmentsid
-			inner join crmentity on crmentity.crmid= seattachmentsrel.crmid
-			inner join crmentity crm2 on crm2.crmid=attachments.attachmentsid
-			inner join users on crm2.smcreatorid= users.id
-		where crmentity.crmid=".$id;
+		$query .= "select vtiger_attachments.description  title ,'Attachments'  ActivityType,
+		vtiger_attachments.name filename, vtiger_attachments.type FileType, crm2.modifiedtime lastmodified,
+		vtiger_attachments.attachmentsid vtiger_attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
+			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		from vtiger_attachments
+			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id;
 		$log->debug("Exiting get_attachments method ...");
 		return getAttachmentsAndNotes('Invoice',$query,$id);
 	}

Modified: vtigercrm/trunk/modules/Invoice/ListTopInvoice.php
==============================================================================
--- vtigercrm/trunk/modules/Invoice/ListTopInvoice.php (original)
+++ vtigercrm/trunk/modules/Invoice/ListTopInvoice.php Mon Jun 12 14:26:25 2006
@@ -52,7 +52,7 @@
 	$date_var = date('Y-m-d');
 
 	//Changed for Patch 2 by Don
-	$where = ' and crmentity.smownerid='.$current_user->id.' and  invoice.invoicestatus != \'Paid\' ORDER BY total DESC';
+	$where = ' and vtiger_crmentity.smownerid='.$current_user->id.' and  vtiger_invoice.invoicestatus != \'Paid\' ORDER BY total DESC';
 	$query = getListQuery("Invoice",$where);
 
 	//<<<<<<<<customview>>>>>>>>>

Modified: vtigercrm/trunk/modules/Invoice/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Invoice/Save.php (original)
+++ vtigercrm/trunk/modules/Invoice/Save.php Mon Jun 12 14:26:25 2006
@@ -34,11 +34,11 @@
 
 $focus->save("Invoice");
 
-//Checking if salesorderid is present and updating the quote status
+//Checking if vtiger_salesorderid is present and updating the quote status
 if($focus->column_fields["salesorder_id"] != '')
 {
         $so_id = $focus->column_fields["salesorder_id"];
-        $query1 = "update salesorder set sostatus='Approved' where salesorderid=".$so_id;
+        $query1 = "update vtiger_salesorder set vtiger_sostatus='Approved' where vtiger_salesorderid=".$so_id;
         $adb->query($query1);
 }
 
@@ -46,7 +46,7 @@
 $ext_prod_arr = Array();
 if($focus->mode == 'edit')
 {
-	$query2  = "select * from invoiceproductrel where invoiceid=".$focus->id;
+	$query2  = "select * from vtiger_invoiceproductrel where vtiger_invoiceid=".$focus->id;
 	$result2 = $adb->query($query2);
 	$num_rows = $adb->num_rows($result2);
 	for($i=0; $i<$num_rows;$i++)
@@ -56,7 +56,7 @@
 		$ext_prod_arr[$pro_id] = $pro_qty;	
 	}	
 
-        $query1 = "delete from invoiceproductrel where invoiceid=".$focus->id;
+        $query1 = "delete from vtiger_invoiceproductrel where vtiger_invoiceid=".$focus->id;
         $adb->query($query1);
 
 }
@@ -84,7 +84,7 @@
         if($prod_status != 'D')
         {
 
-                $query ="insert into invoiceproductrel values($focus->id, $prod_id, $qty, $listprice, $vat, $sales, $service)";
+                $query ="insert into vtiger_invoiceproductrel values($focus->id, $prod_id, $qty, $listprice, $vat, $sales, $service)";
                 $adb->query($query);
 		//Updating the Quantity in Stock in the Product Table
 		updateStk($prod_id,$qty,$focus->mode,$ext_prod_arr,'Invoice');

Modified: vtigercrm/trunk/modules/Invoice/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Invoice/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Invoice/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -83,10 +83,10 @@
 'NTC_COPY_SHIPPING_ADDRESS'=>'Copy shipping address to billing address',
 'NTC_REMOVE_MEMBER_ORG_CONFIRMATION'=>'Are you sure you want to remove this record as a member organization?',
 'LBL_DUPLICATE'=>'Potential Duplicate Accounts',
-'MSG_DUPLICATE' => 'Creating this account may potentialy create a duplicate account. You may either select an account from the list below or you may click on Create New Account to continue creating a new account with the previously entered data.',
+'MSG_DUPLICATE' => 'Creating this vtiger_account may vtiger_potentialy create a duplicate vtiger_account. You may either select an vtiger_account from the list below or you may click on Create New Account to continue creating a new vtiger_account with the previously entered data.',
 
 'LBL_INVITEE'=>'Contacts',
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
 
 'LBL_SELECT_ACCOUNT'=>'Select Account',
 'LBL_GENERAL_INFORMATION'=>'General Information',
@@ -106,7 +106,7 @@
 'LBL_NEW_CONTACT'=>'New Contact',
 'LBL_CONTACT_TITLE'=>'Contacts',
 
-//Added fields after RC1 - Release
+//Added vtiger_fields after RC1 - Release
 'LBL_ALL'=>'All',
 'LBL_PROSPECT'=>'Prospect',
 'LBL_INVESTOR'=>'Investor',
@@ -120,7 +120,7 @@
 'Quote Name'=>'Quote Name',
 'Vendor Name'=>'Vendor Name',
 'Invoice Terms'=>'Invoice Terms',
-'Contact Name'=>'Contact Name',//to include contact name field in Invoice
+'Contact Name'=>'Contact Name',//to include contact name vtiger_field in Invoice
 'Invoice Date'=>'Invoice Date',
 'Sub Total'=>'Sub Total',
 'Due Date'=>'Due Date',

Modified: vtigercrm/trunk/modules/Invoice/pdf_templates/header.php
==============================================================================
--- vtigercrm/trunk/modules/Invoice/pdf_templates/header.php (original)
+++ vtigercrm/trunk/modules/Invoice/pdf_templates/header.php Mon Jun 12 14:26:25 2006
@@ -67,7 +67,7 @@
 $dueBlock=array("80","65");
 $pdf->addRecBlock($valid_till, "Due Date",$dueBlock);
 
-// invoice number block
+// vtiger_invoice number block
 $invBlock=array("145","65");
 $pdf->addRecBlock($id, "Invoice Number",$invBlock);
 

Modified: vtigercrm/trunk/modules/Leads/CallRelatedList.php
==============================================================================
--- vtigercrm/trunk/modules/Leads/CallRelatedList.php (original)
+++ vtigercrm/trunk/modules/Leads/CallRelatedList.php Mon Jun 12 14:26:25 2006
@@ -47,7 +47,7 @@
        unset($_SESSION['rlvs']);
  }
 	
-$sql1 = $adb->query('select campaignid from leaddetails where leadid='.$focus->id);
+$sql1 = $adb->query('select vtiger_campaignid from vtiger_leaddetails where leadid='.$focus->id);
 $campaignid = $adb->query_result($sql1,0,'campaignid');
 if($campaignid == 0) $campaignid='';
 $smarty->assign("campaignid",$campaignid);

Modified: vtigercrm/trunk/modules/Leads/ConvertLead.php
==============================================================================
--- vtigercrm/trunk/modules/Leads/ConvertLead.php (original)
+++ vtigercrm/trunk/modules/Leads/ConvertLead.php Mon Jun 12 14:26:25 2006
@@ -27,7 +27,7 @@
 }
 
 //Retreive lead details from database
-$sql = "SELECT firstname, lastname, company, smownerid from leaddetails inner join crmentity on crmentity.crmid=leaddetails.leadid where leaddetails.leadid =".$id;
+$sql = "SELECT firstname, lastname, company, smownerid from vtiger_leaddetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid where vtiger_leaddetails.leadid =".$id;
 $result = $adb->query($sql);
 $row = $adb->fetch_array($result);
 
@@ -38,7 +38,7 @@
 $company = $row["company"];
 $log->debug(" the company is  ".$company);
 $potentialname = $row["company"] ."-";
-$log->debug(" the potentialname is ".$potentialname);
+$log->debug(" the vtiger_potentialname is ".$potentialname);
 $userid = $row["smownerid"];
 $log->debug(" the userid is ".$userid);
 
@@ -48,7 +48,7 @@
 
 $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
 
-$sales_stage_query="select * from sales_stage";
+$sales_stage_query="select * from vtiger_sales_stage";
 $sales_stage_result = $adb->query($sales_stage_query);
 $noofsalesRows = $adb->num_rows($sales_stage_result);
 $sales_stage_fld = '';
@@ -114,13 +114,13 @@
 						<tr>
 							<td align="right" class="dvtCellLabel" width="50%"><font color="red">*</font>'.$mod_strings['LBL_POTENTIAL_NAME'].'</td>
 							<td class="dvtCellInfo" width="50%">
-							<input name="potential_name" value="'.$potentialname.'" tabindex="3">
+							<input name="potential_name" value="'.$potentialname.'" vtiger_tabindex="3">
                                                         </td>
 						</tr>
 						<tr>
 							<td align="right" class="dvtCellLabel"><font color="red">*</font>'.$mod_strings['LBL_POTENTIAL_CLOSE_DATE'].'</td>
 							<td class="dvtCellInfo">
-								<input name="closedate" class="dvtCellInfo" id="jscal_field" type="text" tabindex="4" size="10" maxlength="10" value="'.$focus->closedate.'">
+								<input name="closedate" class="dvtCellInfo" id="jscal_field" type="text" vtiger_tabindex="4" size="10" maxlength="10" value="'.$focus->closedate.'">
 								<font size=1><em old="(yyyy-mm-dd)">('.$current_user->date_format.')</em></font>
 							</td>
 						</tr>

Modified: vtigercrm/trunk/modules/Leads/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Leads/Forms.php (original)
+++ vtigercrm/trunk/modules/Leads/Forms.php Mon Jun 12 14:26:25 2006
@@ -66,7 +66,7 @@
 }
 
 /**
- * Create HTML form to enter a new record with the minimum necessary fields.
+ * Create HTML form to enter a new record with the minimum necessary vtiger_fields.
  */
 
  
@@ -95,7 +95,7 @@
 
 $qcreate_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
 
-$qcreate_get_field="select * from field where tabid=7 and quickcreate=0 order by quickcreatesequence";
+$qcreate_get_field="select * from vtiger_field where vtiger_tabid=7 and quickcreate=0 order by quickcreatesequence";
 $qcreate_get_result=$adb->query($qcreate_get_field);
 $qcreate_get_noofrows=$adb->num_rows($qcreate_get_result);
 
@@ -179,9 +179,9 @@
 $qcreate_form.='</form>';
 $qcreate_form.='<script type="text/javascript">
 		
-	var fieldname = new Array('.$fieldName.')
-	var fieldlabel = new Array('.$fieldLabel.')
-	var fielddatatype = new Array('.$fldDataType.')
+	var vtiger_fieldname = new Array('.$fieldName.')
+	var vtiger_fieldlabel = new Array('.$fieldLabel.')
+	var vtiger_fielddatatype = new Array('.$fldDataType.')
 
 		</script>';
 

Modified: vtigercrm/trunk/modules/Leads/Lead.php
==============================================================================
--- vtigercrm/trunk/modules/Leads/Lead.php (original)
+++ vtigercrm/trunk/modules/Leads/Lead.php Mon Jun 12 14:26:25 2006
@@ -30,12 +30,12 @@
 
 	var $module_id = "leadid";
 
-	var $tab_name = Array('crmentity','leaddetails','leadsubdetails','leadaddress','leadscf');
-	var $tab_name_index = Array('crmentity'=>'crmid','leaddetails'=>'leadid','leadsubdetails'=>'leadsubscriptionid','leadaddress'=>'leadaddressid','leadscf'=>'leadid');
-
-
-	var $entity_table = "crmentity";
-	var $table_name = "leaddetails";
+	var $tab_name = Array('vtiger_crmentity','vtiger_leaddetails','vtiger_leadsubdetails','vtiger_leadaddress','vtiger_leadscf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_leaddetails'=>'leadid','vtiger_leadsubdetails'=>'leadsubscriptionid','vtiger_leadaddress'=>'leadaddressid','vtiger_leadscf'=>'leadid');
+
+
+	var $entity_table = "vtiger_crmentity";
+	var $table_name = "vtiger_leaddetails";
 
 	var $object_name = "Lead";
 
@@ -53,10 +53,10 @@
 	,'rating'=>'rating_dom'
 	,'licencekey'=>'licensekey_dom');
 
-	// This is used to retrieve related fields from form posts.
+	// This is used to retrieve related vtiger_fields from form posts.
 	var $additional_column_fields = Array('smcreatorid', 'smownerid', 'contactid','potentialid' ,'crmid');
 
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
 		'Last Name'=>Array('leaddetails'=>'lastname'),
 		'First Name'=>Array('leaddetails'=>'firstname'),
@@ -138,36 +138,36 @@
 		{
 
 			$query = $this->constructCustomQueryAddendum('leadscf','Leads') . " 
-				leaddetails.*, ".$this->entity_table.".*, leadsubdetails.*,leadaddress.city city, leadaddress.state state,leadaddress.code code,leadaddress.country country, leadaddress.phone phone, users.user_name, users.status user_status
+			vtiger_leaddetails.*, ".$this->entity_table.".*, vtiger_leadsubdetails.*,vtiger_leadaddress.city city, vtiger_leadaddress.state state,vtiger_leadaddress.code code,vtiger_leadaddress.country country, vtiger_leadaddress.phone phone, vtiger_users.user_name, vtiger_users.status user_status
 				FROM ".$this->entity_table."
-				INNER JOIN leaddetails
-				ON crmentity.crmid=leaddetails.leadid
-				LEFT JOIN leadaddress 
-				ON leaddetails.leadid=leadaddress.leadaddressid
-				LEFT JOIN leadsubdetails
-				ON leaddetails.leadid=leadsubdetails.leadsubscriptionid
-				LEFT JOIN leadscf 
-				ON leadscf.leadid=leaddetails.leadid
-				LEFT JOIN users
-				ON crmentity.smownerid = users.id ";
+				INNER JOIN vtiger_leaddetails
+				ON vtiger_crmentity.crmid=vtiger_leaddetails.leadid
+				LEFT JOIN vtiger_leadaddress 
+				ON vtiger_leaddetails.leadid=vtiger_leadaddress.leadaddressid
+				LEFT JOIN vtiger_leadsubdetails
+				ON vtiger_leaddetails.leadid=vtiger_leadsubdetails.leadsubscriptionid
+				LEFT JOIN vtiger_leadscf 
+				ON vtiger_leadscf.leadid=vtiger_leaddetails.leadid
+				LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id ";
 
 		}
 		else
 		{
 			$query = "SELECT 
-				leaddetails.*, ".$this->entity_table.".*, leadsubdetails.*,leadaddress.*,users.user_name, users.status user_status FROM ".$this->entity_table."
-				INNER JOIN leaddetails
-				ON crmentity.crmid=leaddetails.leadid
-				LEFT JOIN leadsubdetails
-				ON leaddetails.leadid = leadsubdetails.leadsubscriptionid
-				LEFT JOIN leadaddress
-				ON leaddetails.leadid=leadaddress.leadaddressid
-				LEFT JOIN users
-				ON crmentity.smownerid = users.id ";
+			vtiger_leaddetails.*, ".$this->entity_table.".*, vtiger_leadsubdetails.*,vtiger_leadaddress.*,vtiger_users.user_name, vtiger_users.status user_status FROM ".$this->entity_table."
+				INNER JOIN vtiger_leaddetails
+				ON vtiger_crmentity.crmid=vtiger_leaddetails.leadid
+				LEFT JOIN vtiger_leadsubdetails
+				ON vtiger_leaddetails.leadid = vtiger_leadsubdetails.leadsubscriptionid
+				LEFT JOIN vtiger_leadaddress
+				ON vtiger_leaddetails.leadid=vtiger_leadaddress.leadaddressid
+				LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id ";
 		}
 
-		$where_auto = " users.status='Active'
-			AND crmentity.deleted=0 AND leaddetails.converted =0";
+		$where_auto = " vtiger_users.status='Active'
+			AND vtiger_crmentity.deleted=0 AND vtiger_leaddetails.converted =0";
 
 		if($where != "")
 			$query .= "where ($where) AND ".$where_auto;
@@ -203,7 +203,7 @@
 
 
 	// First, get the list of IDs.
-	$query = "SELECT contactdetails.lastname, contactdetails.firstname, contactdetails.contactid, activity.*,seactivityrel.*,crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime, users.user_name,recurringevents.recurringtype from activity inner join seactivityrel on seactivityrel.activityid=activity.activityid inner join crmentity on crmentity.crmid=activity.activityid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid = cntactivityrel.contactid left join users on users.id=crmentity.smownerid left outer join recurringevents on recurringevents.activityid=activity.activityid left join activitygrouprelation on activitygrouprelation.activityid=crmentity.crmid left join groups on groups.groupname=activitygrouprelation.groupname where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and (activity.status is not NULL && activity.status != 'Completed') and (activity.status is not NULL && activity.status != 'Deferred') or (activity.eventstatus !='' && activity.eventstatus != 'Held')";
+	$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name,vtiger_recurringevents.recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or vtiger_activitytype='Call' or vtiger_activitytype='Meeting') and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Deferred') or (vtiger_activity.eventstatus !='' && vtiger_activity.eventstatus != 'Held')";
 	$log->debug("Exiting get_activities method ...");
 	return  GetRelatedList('Leads','Activities',$focus,$query,$button,$returnset);
 }
@@ -228,7 +228,7 @@
 	}
 	$returnset = '&return_module=Leads&return_action=DetailView&return_id='.$id;
 
-	$query ="select activity.activityid, activity.subject, activity.semodule, activity.activitytype, activity.date_start, activity.status, activity.priority, crmentity.crmid,crmentity.smownerid,crmentity.modifiedtime, users.user_name from activity inner join seactivityrel on seactivityrel.activityid=activity.activityid inner join crmentity on crmentity.crmid=activity.activityid inner join users on  users.id=crmentity.smownerid where activity.activitytype='Emails' and crmentity.deleted=0 and seactivityrel.crmid=".$id;
+	$query ="select vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.semodule, vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.status, vtiger_activity.priority, vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.modifiedtime, vtiger_users.user_name from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_users on  vtiger_users.id=vtiger_crmentity.smownerid where vtiger_activity.activitytype='Emails' and vtiger_crmentity.deleted=0 and vtiger_seactivityrel.crmid=".$id;
 	$log->debug("Exiting get_emails method ...");
 	return GetRelatedList('Leads','Emails',$focus,$query,$button,$returnset);
 }
@@ -237,21 +237,21 @@
 {
 	global $log;
 	$log->debug("Entering get_history(".$id.") method ...");
-	$query = "SELECT activity.activityid, activity.subject, activity.status,
-		activity.eventstatus, activity.activitytype, contactdetails.contactid,
-		contactdetails.firstname, contactdetails.lastname, crmentity.modifiedtime,
-		crmentity.createdtime, crmentity.description, users.user_name,activitygrouprelation.groupname
-			from activity
-			inner join seactivityrel on seactivityrel.activityid=activity.activityid
-			inner join crmentity on crmentity.crmid=activity.activityid
-			left join cntactivityrel on cntactivityrel.activityid= activity.activityid
-			left join contactdetails on contactdetails.contactid= cntactivityrel.contactid
-			left join activitygrouprelation on activitygrouprelation.activityid=activity.activityid
-			left join groups on groups.groupname=activitygrouprelation.groupname 
-			left join users on crmentity.smownerid= users.id
-			where (activity.activitytype = 'Meeting' or activity.activitytype='Call' or activity.activitytype='Task')
-			and (activity.status = 'Completed' or activity.status = 'Deferred' or (activity.eventstatus = 'Held' and activity.eventstatus != ''))
-			and seactivityrel.crmid=".$id;
+	$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status,
+	vtiger_activity.eventstatus, vtiger_activity.activitytype, vtiger_contactdetails.contactid,
+	vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_crmentity.modifiedtime,
+	vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name,vtiger_activitygrouprelation.groupname
+			from vtiger_activity
+			inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+			left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
+			left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid
+			left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+			left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname 
+			left join vtiger_users on vtiger_crmentity.smownerid= vtiger_users.id
+			where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
+			and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
+			and vtiger_seactivityrel.crmid=".$id;
 	//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
 
 	$log->debug("Exiting get_history method ...");
@@ -263,35 +263,35 @@
 	global $log;
 	$log->debug("Entering get_attachments(".$id.") method ...");
 	// Armando Lüscher 18.10.2005 -> §visibleDescription
-	// Desc: Inserted crm2.createdtime, notes.notecontent description, users.user_name
-	// Inserted inner join users on crm2.smcreatorid= users.id
-	$query = "select notes.title,'Notes      ' ActivityType, notes.filename,
-		attachments.type  FileType,crm2.modifiedtime lastmodified,
-		seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid,
-		crm2.createdtime, notes.notecontent description, users.user_name
-			from notes
-			inner join senotesrel on senotesrel.notesid= notes.notesid
-			inner join crmentity on crmentity.crmid= senotesrel.crmid
-			inner join crmentity crm2 on crm2.crmid=notes.notesid and crm2.deleted=0
-			left join seattachmentsrel  on seattachmentsrel.crmid =notes.notesid
-			left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid
-			inner join users on crm2.smcreatorid= users.id
-			where crmentity.crmid=".$id;
+	// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+	// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+	$query = "select vtiger_notes.title,'Notes      ' ActivityType, vtiger_notes.filename,
+	vtiger_attachments.type  FileType,crm2.modifiedtime lastmodified,
+	vtiger_seattachmentsrel.attachmentsid vtiger_attachmentsid, vtiger_notes.notesid crmid,
+		crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+			from vtiger_notes
+			inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+			left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+			where vtiger_crmentity.crmid=".$id;
 	$query .= ' union all ';
 	// Armando Lüscher 18.10.2005 -> §visibleDescription
-	// Desc: Inserted crm2.createdtime, attachments.description, users.user_name
-	// Inserted inner join users on crm2.smcreatorid= users.id
+	// Desc: Inserted crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+	// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
 	// Inserted order by createdtime desc
-	$query .= "select attachments.description title ,'Attachments' ActivityType,
-		attachments.name filename, attachments.type FileType,crm2.modifiedtime lastmodified,
-		attachments.attachmentsid attachmentsid, seattachmentsrel.attachmentsid crmid,
-		crm2.createdtime, attachments.description, users.user_name
-			from attachments
-			inner join seattachmentsrel on seattachmentsrel.attachmentsid= attachments.attachmentsid
-			inner join crmentity on crmentity.crmid= seattachmentsrel.crmid
-			inner join crmentity crm2 on crm2.crmid=attachments.attachmentsid
-			inner join users on crm2.smcreatorid= users.id
-			where crmentity.crmid=".$id."
+	$query .= "select vtiger_attachments.description title ,'Attachments' ActivityType,
+	vtiger_attachments.name filename, vtiger_attachments.type FileType,crm2.modifiedtime lastmodified,
+	vtiger_attachments.attachmentsid vtiger_attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
+		crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+			from vtiger_attachments
+			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+			where vtiger_crmentity.crmid=".$id."
 			order by createdtime desc";
 
 	$log->debug("Exiting get_attachments method ...");
@@ -316,7 +316,7 @@
 	}
 	$returnset = '&return_module=Leads&return_action=DetailView&return_id='.$id;
 
-	$query = 'select products.productid, products.productname, products.productcode, products.commissionrate, products.qty_per_unit, products.unit_price, crmentity.crmid, crmentity.smownerid from products inner join seproductsrel on products.productid = seproductsrel.productid inner join crmentity on crmentity.crmid = products.productid inner join leaddetails on leaddetails.leadid = seproductsrel.crmid  where leaddetails.leadid = '.$id.' and crmentity.deleted = 0';
+	$query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid from vtiger_products inner join vtiger_seproductsrel on vtiger_products.productid = vtiger_seproductsrel.productid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid inner join vtiger_leaddetails on vtiger_leaddetails.leadid = vtiger_seproductsrel.crmid  where vtiger_leaddetails.leadid = '.$id.' and vtiger_crmentity.deleted = 0';
 	$log->debug("Exiting get_products method ...");
 	return  GetRelatedList('Leads','Products',$focus,$query,$button,$returnset);
 }
@@ -335,7 +335,7 @@
 {
 	global $log;
 	$log->debug("Entering getColumnNames_Lead() method ...");
-	$sql1 = "select fieldlabel from field where tabid=7";
+	$sql1 = "select vtiger_fieldlabel from vtiger_field where vtiger_tabid=7";
 	$result = $this->db->query($sql1);
 	$numRows = $this->db->num_rows($result);
 	for($i=0; $i < $numRows;$i++)

Modified: vtigercrm/trunk/modules/Leads/LeadConvertToEntities.php
==============================================================================
--- vtigercrm/trunk/modules/Leads/LeadConvertToEntities.php (original)
+++ vtigercrm/trunk/modules/Leads/LeadConvertToEntities.php Mon Jun 12 14:26:25 2006
@@ -40,7 +40,7 @@
 if($check_unit[1] == "")
         $potential_name = $check_unit[0];
 
-//Retrieve info from all the tables related to leads
+//Retrieve info from all the vtiger_tables related to leads
   $focus = new Lead();
  $focus->retrieve_entity_info($id,"Leads");
 
@@ -54,48 +54,48 @@
 
 $crmid = $adb->getUniqueID("crmentity");
 
-//function for getting the custom values from leads and saving to account/contact/potential custom fields -Jag
+//function for getting the custom values from leads and saving to vtiger_account/contact/potential custom vtiger_fields -Jag
 function getInsertValues($type,$type_id)
 {
 	global $id,$adb,$log;
 	$log->debug("Entering getInsertValues(".$type.",".$type_id.") method ...");
-	$sql_convert_lead="select * from convertleadmapping ";
+	$sql_convert_lead="select * from vtiger_convertleadmapping ";
 	$convert_result = $adb->query($sql_convert_lead);
 	$noofrows = $adb->num_rows($convert_result);
 
 	for($i=0;$i<$noofrows;$i++)
 	{
 		$flag="false";
-	 	$log->info("In convertleadmapping function");
+	 	$log->info("In vtiger_convertleadmapping function");
 		$lead_id=$adb->query_result($convert_result,$i,"leadfid");  
-		//Getting the relatd customfields for Accounts/Contact/potential from convertleadmapping table	
+		//Getting the relatd customfields for Accounts/Contact/potential from vtiger_convertleadmapping vtiger_table	
 		$account_id_val=$adb->query_result($convert_result,$i,"accountfid");
 		$contact_id_val=$adb->query_result($convert_result,$i,"contactfid");
 		$potential_id_val=$adb->query_result($convert_result,$i,"potentialfid");
 		
-		$sql_leads_column="select field.fieldid,field.columnname from field,tab where field.tabid=tab.tabid and generatedtype=2 and tab.name='Leads' and fieldid=".$lead_id; //getting the columnname for the customfield of the lead
-
-		 $log->debug("Lead's custom field coumn name is ".$sql_leads_column);
+		$sql_leads_column="select vtiger_field.fieldid,vtiger_field.columnname from vtiger_field,tab where vtiger_field.tabid=vtiger_tab.tabid and generatedtype=2 and vtiger_tab.name='Leads' and vtiger_fieldid=".$lead_id; //getting the columnname for the customfield of the lead
+
+		 $log->debug("Lead's custom vtiger_field coumn name is ".$sql_leads_column);
 
 		$lead_column_result = $adb->query($sql_leads_column);
 		$leads_no_rows = $adb->num_rows($lead_column_result);
 		if($leads_no_rows>0)
 		{
 			$lead_column_name=$adb->query_result($lead_column_result,0,"columnname");
-			$sql_leads_val="select ".$lead_column_name." from leadscf where leadid=".$id; //custom field value for lead
+			$sql_leads_val="select ".$lead_column_name." from vtiger_leadscf where leadid=".$id; //custom vtiger_field value for lead
 			$lead_val_result = $adb->query($sql_leads_val);
 			$lead_value=$adb->query_result($lead_val_result,0,$lead_column_name);
-			 $log->debug("Lead's custom field value is ".$lead_value);
+			 $log->debug("Lead's custom vtiger_field value is ".$lead_value);
 		}	
-		//Query for getting the column name for Accounts/Contacts/Potentials if custom field for lead is mappped
-		$sql_type="select field.fieldid,field.columnname from field,tab where field.tabid=tab.tabid and generatedtype=2 and tab.name="; 
+		//Query for getting the column name for Accounts/Contacts/Potentials if custom vtiger_field for lead is mappped
+		$sql_type="select vtiger_field.fieldid,vtiger_field.columnname from vtiger_field,tab where vtiger_field.tabid=vtiger_tab.tabid and generatedtype=2 and vtiger_tab.name="; 
 		if($type=="Accounts")
 		{
 			if($account_id_val!="" && $account_id_val!=0)	
 			{
 				$flag="true";
-				 $log->info("Getting the  Accounts custom field column name  ");
-				$sql_type.="'Accounts' and fieldid=".$account_id_val;
+				 $log->info("Getting the  Accounts custom vtiger_field column name  ");
+				$sql_type.="'Accounts' and vtiger_fieldid=".$account_id_val;
 			}
 		}
 		else if($type == "Contacts")
@@ -103,8 +103,8 @@
 			if($contact_id_val!="" && $contact_id_val!=0)	
 			{
 				$flag="true";
-				 $log->info("Getting the  Contacts custom field column name  ");
-				$sql_type.="'Contacts' and fieldid=".$contact_id_val;
+				 $log->info("Getting the  Contacts custom vtiger_field column name  ");
+				$sql_type.="'Contacts' and vtiger_fieldid=".$contact_id_val;
 			}
 		}
 		else if($type == "Potentials")
@@ -112,8 +112,8 @@
 			if($potential_id_val!="" && $potential_id_val!=0)
                         {
 				$flag="true";
-                                  $log->info("Getting the  Potentials custom field column name  ");
-				$sql_type.="'Potentials' and fieldid=".$potential_id_val;
+                                  $log->info("Getting the  Potentials custom vtiger_field column name  ");
+				$sql_type.="'Potentials' and vtiger_fieldid=".$potential_id_val;
                         }
 
 		}
@@ -145,7 +145,7 @@
 	global $adb,$log,$id;
 	$log->debug("Entering getRelatedNotesAttachments(".$id.",".$accountid.") method ...");
 	
-	$sql_lead_notes	="select * from senotesrel where crmid=".$id;
+	$sql_lead_notes	="select * from vtiger_senotesrel where crmid=".$id;
 	$lead_notes_result = $adb->query($sql_lead_notes);
 	$noofrows = $adb->num_rows($lead_notes_result);
 
@@ -154,14 +154,14 @@
 
 		$lead_related_note_id=$adb->query_result($lead_notes_result,$i,"notesid");
 		 $log->debug("Lead related note id ".$lead_related_note_id);
-		$sql_delete_lead_notes="delete from senotesrel where crmid=".$id;
+		$sql_delete_lead_notes="delete from vtiger_senotesrel where crmid=".$id;
 		$adb->query($sql_delete_lead_notes);
 
-		$sql_insert_account_notes="insert into senotesrel(crmid,notesid) values (".$accountid.",".$lead_related_note_id.")";
+		$sql_insert_account_notes="insert into vtiger_senotesrel(crmid,notesid) values (".$accountid.",".$lead_related_note_id.")";
 		$adb->query($sql_insert_account_notes);
 	}
 
-	$sql_lead_attachment="select * from seattachmentsrel where crmid=".$id;
+	$sql_lead_attachment="select * from vtiger_seattachmentsrel where crmid=".$id;
         $lead_attachment_result = $adb->query($sql_lead_attachment);
         $noofrows = $adb->num_rows($lead_attachment_result);
 
@@ -171,10 +171,10 @@
                 $lead_related_attachment_id=$adb->query_result($lead_attachment_result,$i,"attachmentsid");
 		 $log->debug("Lead related attachment id ".$lead_related_attachment_id);
 
-                $sql_delete_lead_attachment="delete from seattachmentsrel where crmid=".$id;
+                $sql_delete_lead_attachment="delete from vtiger_seattachmentsrel where crmid=".$id;
                 $adb->query($sql_delete_lead_attachment);
 
-                $sql_insert_account_attachment="insert into seattachmentsrel(crmid,attachmentsid) values (".$accountid.",".$lead_related_attachment_id.")";                        
+                $sql_insert_account_attachment="insert into vtiger_seattachmentsrel(crmid,attachmentsid) values (".$accountid.",".$lead_related_attachment_id.")";                        
                 $adb->query($sql_insert_account_attachment);
         }
 	$log->debug("Exiting getRelatedNotesAttachments method ...");
@@ -185,61 +185,61 @@
 {
 	global $adb,$log,$id;	
 	$log->debug("Entering getRelatedActivities(".$accountid.",".$contact_id.") method ...");
-	$sql_lead_activity="select * from seactivityrel where crmid=".$id;
+	$sql_lead_activity="select * from vtiger_seactivityrel where crmid=".$id;
 	$lead_activity_result = $adb->query($sql_lead_activity);
         $noofrows = $adb->num_rows($lead_activity_result);
         for($i=0;$i<$noofrows;$i++)
         {
 
                 $lead_related_activity_id=$adb->query_result($lead_activity_result,$i,"activityid");
-		 $log->debug("Lead related activity id ".$lead_related_activity_id);
-
-		$sql_type_email="select setype from crmentity where crmid=".$lead_related_activity_id;
+		 $log->debug("Lead related vtiger_activity id ".$lead_related_activity_id);
+
+		$sql_type_email="select setype from vtiger_crmentity where crmid=".$lead_related_activity_id;
 		$type_email_result = $adb->query($sql_type_email);
                 $type=$adb->query_result($type_email_result,0,"setype");
-		$log->debug("type of activity id ".$type);
-
-                $sql_delete_lead_activity="delete from seactivityrel where crmid=".$id;
+		$log->debug("type of vtiger_activity id ".$type);
+
+                $sql_delete_lead_activity="delete from vtiger_seactivityrel where crmid=".$id;
                 $adb->query($sql_delete_lead_activity);
 
 		if($type != "Emails")
 		{
-                	$sql_insert_account_activity="insert into seactivityrel(crmid,activityid) values (".$accountid.",".$lead_related_activity_id.")";
+                	$sql_insert_account_activity="insert into vtiger_seactivityrel(crmid,activityid) values (".$accountid.",".$lead_related_activity_id.")";
 	                $adb->query($sql_insert_account_activity);
 
-			$sql_insert_account_activity="insert into cntactivityrel(contactid,activityid) values (".$contact_id.",".$lead_related_activity_id.")";
+			$sql_insert_account_activity="insert into vtiger_cntactivityrel(contactid,activityid) values (".$contact_id.",".$lead_related_activity_id.")";
                 	$adb->query($sql_insert_account_activity);
 		}
 		else
 		{
-			 $sql_insert_account_activity="insert into seactivityrel(crmid,activityid) values (".$contact_id.",".$lead_related_activity_id.")";                                                                                     $adb->query($sql_insert_account_activity);
+			 $sql_insert_account_activity="insert into vtiger_seactivityrel(crmid,activityid) values (".$contact_id.",".$lead_related_activity_id.")";                                                                                     $adb->query($sql_insert_account_activity);
 		}
         }
 	$log->debug("Exiting getRelatedActivities method ...");
 	
 }
 
-$sql_crmentity = "insert into crmentity(crmid,smcreatorid,smownerid,setype,presence,createdtime,modifiedtime,deleted,description) values(".$crmid.",".$current_user_id.",".$assigned_user_id.",'Accounts',1,".$date_entered.",".$date_modified.",0,'".$row['description']."')";
+$sql_crmentity = "insert into vtiger_crmentity(crmid,smcreatorid,smownerid,setype,presence,createdtime,modifiedtime,deleted,description) values(".$crmid.",".$current_user_id.",".$assigned_user_id.",'Accounts',1,".$date_entered.",".$date_modified.",0,'".$row['description']."')";
 
 $adb->query($sql_crmentity);
 
 
-$sql_insert_account = "INSERT INTO account (accountid,accountname,industry,annualrevenue,phone,fax,rating,email1,website,employees) VALUES (".$crmid.",'".$accountname ."','".$row["industry"] ."','" .$row["annualrevenue"] ."','" .$row["phone"] ."','".$row["fax"] ."','" .$row["rating"] ."','" .$row["email"] ."','" .$row["website"] ."','" .$row["noofemployees"] ."')";
+$sql_insert_account = "INSERT INTO vtiger_account (accountid,accountname,industry,annualrevenue,phone,fax,rating,email1,website,employees) VALUES (".$crmid.",'".$accountname ."','".$row["industry"] ."','" .$row["annualrevenue"] ."','" .$row["phone"] ."','".$row["fax"] ."','" .$row["rating"] ."','" .$row["email"] ."','" .$row["website"] ."','" .$row["noofemployees"] ."')";
 
 
 $adb->query($sql_insert_account);
 
-$sql_insert_accountbillads = "INSERT INTO accountbillads (accountaddressid,city,code,country,state,street) VALUES (".$crmid.",'".$row["city"] ."','" .$row["code"] ."','" .$row["country"] ."','".$row["state"] ."','" .$row["lane"]."')";
+$sql_insert_accountbillads = "INSERT INTO vtiger_accountbillads (accountaddressid,city,code,country,state,street) VALUES (".$crmid.",'".$row["city"] ."','" .$row["code"] ."','" .$row["country"] ."','".$row["state"] ."','" .$row["lane"]."')";
 
  $adb->query($sql_insert_accountbillads);
 
 
-$sql_insert_accountshipads = "INSERT INTO accountshipads (accountaddressid,city,code,country,state,street) VALUES (".$crmid.",'".$row["city"] ."','" .$row["code"] ."','" .$row["country"] ."','".$row["state"] ."','" .$row["lane"]."')";
+$sql_insert_accountshipads = "INSERT INTO vtiger_accountshipads (accountaddressid,city,code,country,state,street) VALUES (".$crmid.",'".$row["city"] ."','" .$row["code"] ."','" .$row["country"] ."','".$row["state"] ."','" .$row["lane"]."')";
 
 
  $adb->query($sql_insert_accountshipads);
 
-//Getting the custom field values from leads and inserting into Accounts if the field is mapped - Jaguar
+//Getting the custom vtiger_field values from leads and inserting into Accounts if the vtiger_field is mapped - Jaguar
 $insert_value=$crmid;
 $insert_column="accountid";	
 $val= getInsertValues("Accounts",$insert_value);
@@ -250,7 +250,7 @@
 
 $insert_column.=$val[0];
 $insert_value.=$val[1];
-$sql_insert_accountcustomfield = "INSERT INTO accountscf (".$insert_column.") VALUES (".$insert_value.")";
+$sql_insert_accountcustomfield = "INSERT INTO vtiger_accountscf (".$insert_column.") VALUES (".$insert_value.")";
 
 $adb->query($sql_insert_accountcustomfield);
 
@@ -264,7 +264,7 @@
  $date_modified = date('YmdHis');
 
 $crmcontactid = $adb->getUniqueID("crmentity");
-$sql_crmentity1 = "insert into crmentity(crmid,smcreatorid,smownerid,setype,presence,deleted,description,createdtime) values(".$crmcontactid.",".$current_user_id.",".$assigned_user_id.",'Contacts',0,0,'".$row['description']."','".$date_entered."')";
+$sql_crmentity1 = "insert into vtiger_crmentity(crmid,smcreatorid,smownerid,setype,presence,deleted,description,createdtime) values(".$crmcontactid.",".$current_user_id.",".$assigned_user_id.",'Contacts',0,0,'".$row['description']."','".$date_entered."')";
 
 $adb->query($sql_crmentity1);
 
@@ -272,16 +272,16 @@
 $contact_id = $crmcontactid;
 $log->debug("contact id is ".$contact_id);
 
- $sql_insert_contact = "INSERT INTO contactdetails (contactid,accountid,salutation,firstname,lastname,email,phone,mobile,title,fax,yahooid) VALUES (".$contact_id.",".$crmid.",'".$row["salutationtype"] ."','" .$row["firstname"] ."','" .$row["lastname"] ."','" .$row["email"] ."','" .$row["phone"]. "','" .$row["mobile"] ."','" .$row["designation"] ."','".$row["fax"] ."','".$row['yahooid']."')";
+ $sql_insert_contact = "INSERT INTO vtiger_contactdetails (contactid,accountid,salutation,firstname,lastname,email,phone,mobile,title,fax,yahooid) VALUES (".$contact_id.",".$crmid.",'".$row["salutationtype"] ."','" .$row["firstname"] ."','" .$row["lastname"] ."','" .$row["email"] ."','" .$row["phone"]. "','" .$row["mobile"] ."','" .$row["designation"] ."','".$row["fax"] ."','".$row['yahooid']."')";
 
 $adb->query($sql_insert_contact);
 
 
- $sql_insert_contactsubdetails = "INSERT INTO contactsubdetails (contactsubscriptionid,homephone,otherphone,leadsource) VALUES (".$contact_id.",'','','".$row['leadsource']."')";
+ $sql_insert_contactsubdetails = "INSERT INTO vtiger_contactsubdetails (contactsubscriptionid,homephone,otherphone,leadsource) VALUES (".$contact_id.",'','','".$row['leadsource']."')";
 
 $adb->query($sql_insert_contactsubdetails);
 
- $sql_insert_contactaddress = "INSERT INTO contactaddress (contactaddressid,mailingcity,mailingstreet,mailingstate,mailingcountry,mailingzip) VALUES (".$contact_id.",'".$row["city"] ."','" .$row["lane"] ."','".$row['state']."','" .$row["country"] ."','".$row['code']."')";
+ $sql_insert_contactaddress = "INSERT INTO vtiger_contactaddress (contactaddressid,mailingcity,mailingstreet,mailingstate,mailingcountry,mailingzip) VALUES (".$contact_id.",'".$row["city"] ."','" .$row["lane"] ."','".$row['state']."','" .$row["country"] ."','".$row['code']."')";
 
 $adb->query($sql_insert_contactaddress);
 
@@ -298,7 +298,7 @@
 
 $insert_column.=$val[0];
 $insert_value.=$val[1];
-$sql_insert_contactcustomfield = "INSERT INTO contactscf (".$insert_column.") VALUES (".$insert_value.")";
+$sql_insert_contactcustomfield = "INSERT INTO vtiger_contactscf (".$insert_column.") VALUES (".$insert_value.")";
 
 $adb->query($sql_insert_contactcustomfield);
 //
@@ -313,7 +313,7 @@
   
 
   $oppid = $adb->getUniqueID("crmentity");
-  $sql_crmentity = "insert into crmentity(crmid,smcreatorid,smownerid,setype,presence,deleted,createdtime,description) values(".$oppid.",".$current_user_id.",".$assigned_user_id.",'Potentials',0,0,'".$date_entered."','".$row['description']."')";
+  $sql_crmentity = "insert into vtiger_crmentity(crmid,smcreatorid,smownerid,setype,presence,deleted,createdtime,description) values(".$oppid.",".$current_user_id.",".$assigned_user_id.",'Potentials',0,0,'".$date_entered."','".$row['description']."')";
   
   $adb->query($sql_crmentity);
 
@@ -323,7 +323,7 @@
 		$potential_amount=0;
         }
 
-	$sql_insert_opp = "INSERT INTO potential (potentialid,accountid,potentialname,leadsource,closingdate,sales_stage,amount) VALUES (".$oppid.",".$crmid .",'".$potential_name."','".$row['leadsource']."','".$close_date."','".$potential_sales_stage."',".$potential_amount.")";
+	$sql_insert_opp = "INSERT INTO vtiger_potential (potentialid,accountid,potentialname,leadsource,closingdate,sales_stage,amount) VALUES (".$oppid.",".$crmid .",'".$potential_name."','".$row['leadsource']."','".$close_date."','".$potential_sales_stage."',".$potential_amount.")";
 
 	$adb->query($sql_insert_opp);
 
@@ -339,23 +339,23 @@
 	$insert_column.=$val[0];
 	$insert_value.=$val[1];
 
-	$sql_insert_potentialcustomfield = "INSERT INTO potentialscf (".$insert_column.") VALUES (".$insert_value.")";
+	$sql_insert_potentialcustomfield = "INSERT INTO vtiger_potentialscf (".$insert_column.") VALUES (".$insert_value.")";
 //
 
 	$adb->query($sql_insert_potentialcustomfield);
-        $sql_insert2contpotentialrel ="insert into contpotentialrel values(".$contact_id.",".$oppid .")";
+        $sql_insert2contpotentialrel ="insert into vtiger_contpotentialrel values(".$contact_id.",".$oppid .")";
         
         $adb->query($sql_insert2contpotentialrel);
 
 	
 }
 
-//Deleting from the tracker
-$sql_delete_tracker= "DELETE from tracker where item_id='" .$id ."'";
+//Deleting from the vtiger_tracker
+$sql_delete_tracker= "DELETE from vtiger_tracker where item_id='" .$id ."'";
 $adb->query($sql_delete_tracker);
 
 //Updating the deleted status
-$sql_update_converted = "UPDATE leaddetails SET converted = 1 where leadid='" .$id ."'";
+$sql_update_converted = "UPDATE vtiger_leaddetails SET converted = 1 where leadid='" .$id ."'";
 $adb->query($sql_update_converted); 
 
 header("Location: index.php?action=DetailView&module=Accounts&record=$crmid");

Modified: vtigercrm/trunk/modules/Leads/ListViewTop.php
==============================================================================
--- vtigercrm/trunk/modules/Leads/ListViewTop.php (original)
+++ vtigercrm/trunk/modules/Leads/ListViewTop.php Mon Jun 12 14:26:25 2006
@@ -44,7 +44,7 @@
 	require_once($theme_path.'layout_utils.php');
 	if($_REQUEST['lead_view']=='')
 	{	
-		$query = "select lead_view from users where id ='$current_user->id'";
+		$query = "select lead_view from vtiger_users where id ='$current_user->id'";
 		$result=$adb->query($query);
 		$lead_view=$adb->query_result($result,0,'lead_view');
 	}
@@ -66,7 +66,7 @@
 		$start_date = date("Y-m-d", strtotime("-1 week"));
 	}	
 
-	$list_query = 'select leaddetails.*,crmentity.createdtime,crmentity.description from leaddetails inner join crmentity on leaddetails.leadid = crmentity.crmid where crmentity.deleted =0 AND leaddetails.converted =0 AND crmentity.createdtime >='.$start_date.' AND crmentity.smownerid = '.$current_user->id; 
+	$list_query = 'select vtiger_leaddetails.*,vtiger_crmentity.createdtime,vtiger_crmentity.description from vtiger_leaddetails inner join vtiger_crmentity on vtiger_leaddetails.leadid = vtiger_crmentity.crmid where vtiger_crmentity.deleted =0 AND vtiger_leaddetails.converted =0 AND vtiger_crmentity.createdtime >='.$start_date.' AND vtiger_crmentity.smownerid = '.$current_user->id; 
 	
 	$list_result = $adb->query($list_query);
 	$noofrows = $adb->num_rows($list_result);

Modified: vtigercrm/trunk/modules/Leads/Merge.php
==============================================================================
--- vtigercrm/trunk/modules/Leads/Merge.php (original)
+++ vtigercrm/trunk/modules/Leads/Merge.php Mon Jun 12 14:26:25 2006
@@ -38,7 +38,7 @@
 }
 //get the particular file from db and store it in the local hard disk.
 //store the path to the location where the file is stored and pass it  as parameter to the method 
-$sql = "select filename,data,filesize from wordtemplates where templateid=".$templateid;
+$sql = "select filename,data,filesize from vtiger_wordtemplates where templateid=".$templateid;
 
 $result = $adb->query($sql);
 $temparray = $adb->fetch_array($result);
@@ -74,7 +74,7 @@
 }
 
 //<<<<<<<<<<<<<<<<header for csv and select columns for query>>>>>>>>>>>>>>>>>>>>>>>>
-$query1="select tablename,columnname,fieldlabel from field where tabid=7 order by tablename";
+$query1="select vtiger_tablename,columnname,fieldlabel from vtiger_field where vtiger_tabid=7 order by vtiger_tablename";
 $result = $adb->query($query1);
 $y=$adb->num_rows($result);
 	
@@ -85,7 +85,7 @@
 	$querycolumns[$x] = $tablename.".".$columnname;
   if($columnname == "smownerid")
   {
-    $querycolumns[$x] = "concat(users.last_name,' ',users.first_name) as username,users.first_name,users.last_name,users.user_name,users.yahoo_id,users.title,users.phone_work,users.department,users.phone_mobile,users.phone_other,users.phone_fax,users.email1,users.phone_home,users.email2,users.address_street,users.address_city,users.address_state,users.address_postalcode,users.address_country";
+    $querycolumns[$x] = "concat(vtiger_users.last_name,' ',vtiger_users.first_name) as username,vtiger_users.first_name,vtiger_users.last_name,vtiger_users.user_name,vtiger_users.yahoo_id,vtiger_users.title,vtiger_users.phone_work,vtiger_users.department,vtiger_users.phone_mobile,vtiger_users.phone_other,vtiger_users.phone_fax,vtiger_users.email1,vtiger_users.phone_home,vtiger_users.email2,vtiger_users.address_street,vtiger_users.address_city,vtiger_users.address_state,vtiger_users.address_postalcode,vtiger_users.address_country";
   }
   $field_label[$x] = "LEAD_".strtoupper(str_replace(" ","",$adb->query_result($result,$x,"fieldlabel")));
 	if($columnname == "smownerid")
@@ -100,13 +100,13 @@
 {
 	$selectcolumns = implode($querycolumns,",");
 
-$query = "select ".$selectcolumns." from leaddetails 
-  inner join crmentity on crmentity.crmid=leaddetails.leadid 
-  inner join leadsubdetails on leadsubdetails.leadsubscriptionid=leaddetails.leadid 
-  inner join leadaddress on leadaddress.leadaddressid=leadsubdetails.leadsubscriptionid 
-  inner join leadscf on leaddetails.leadid = leadscf.leadid 
-  left join users on users.id = crmentity.smownerid
-  where crmentity.deleted=0 and leaddetails.leadid in (".$mass_merge.")";
+$query = "select ".$selectcolumns." from vtiger_leaddetails 
+  inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid 
+  inner join vtiger_leadsubdetails on vtiger_leadsubdetails.leadsubscriptionid=vtiger_leaddetails.leadid 
+  inner join vtiger_leadaddress on vtiger_leadaddress.leadaddressid=vtiger_leadsubdetails.leadsubscriptionid 
+  inner join vtiger_leadscf on vtiger_leaddetails.leadid = vtiger_leadscf.leadid 
+  left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid
+  where vtiger_crmentity.deleted=0 and vtiger_leaddetails.leadid in (".$mass_merge.")";
 		
 $result = $adb->query($query);
 	
@@ -140,7 +140,7 @@
 $csvdata = implode($mergevalue,"###");
 }else
 {
-	die("No fields to do Merge");
+	die("No vtiger_fields to do Merge");
 }	
 
 $handle = fopen($wordtemplatedownloadpath."datasrc.csv","wb");

Modified: vtigercrm/trunk/modules/Leads/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Leads/Save.php (original)
+++ vtigercrm/trunk/modules/Leads/Save.php Mon Jun 12 14:26:25 2006
@@ -70,11 +70,11 @@
 if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
 header("Location: index.php?action=$return_action&module=$return_module&record=$return_id&viewname=$return_viewname");
 
-//Code to save the custom field info into database
+//Code to save the custom vtiger_field info into database
 function save_customfields($entity_id)
 {
 	$log->debug("Entering save_customfields(".$entity_id.") method ...");
-	 $log->debug("save custom field invoked ".$entity_id);
+	 $log->debug("save custom vtiger_field invoked ".$entity_id);
 	global $adb;
 	$dbquery="select * from customfields where module='Leads'";
 	$result = $adb->query($dbquery);

Modified: vtigercrm/trunk/modules/Leads/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Leads/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Leads/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -76,13 +76,13 @@
 
 'NTC_DELETE_CONFIRMATION'=>'Are you sure you want to delete this record?',
 'NTC_REMOVE_CONFIRMATION'=>'Are you sure you want to remove this contact from this case?',
-'NTC_REMOVE_DIRECT_REPORT_CONFIRMATION'=>'Are you sure you want to remove this record as a direct report?',
+'NTC_REMOVE_DIRECT_REPORT_CONFIRMATION'=>'Are you sure you want to remove this record as a direct vtiger_report?',
 'NTC_REMOVE_OPP_CONFIRMATION'=>'Are you sure you want to remove this contact from this opportunity?',
 'ERR_DELETE_RECORD'=>"en_us A record number must be specified to delete the contact.",
 'NTC_COPY_PRIMARY_ADDRESS'=>'Copy primary address to alternate address',
 'NTC_COPY_ALTERNATE_ADDRESS'=>'Copy alternate address to primary address',
 
-// Added fields in fetchfile.php, import.php -- crm4-Beta
+// Added vtiger_fields in fetchfile.php, import.php -- crm4-Beta
 'LBL_COLON'=>' : ', 
 'LBL_IMPORT_LEADS'=>'Import Leads',
 'LBL_LEADS_FILE_LIST'=>'Leads File List',
@@ -114,7 +114,7 @@
 'LBL_ATTACHMENT_TITLE'=>'Attachments',
 
 
-//Added fields after RC1 - Release 
+//Added vtiger_fields after RC1 - Release 
 'LBL_ALL'=>'All',
 'LBL_CONTACTED'=>'Contacted',
 'LBL_LOST'=>'Lost',

Modified: vtigercrm/trunk/modules/Migration/Migration.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/Migration.php (original)
+++ vtigercrm/trunk/modules/Migration/Migration.php Mon Jun 12 14:26:25 2006
@@ -165,7 +165,7 @@
 	{
 		global $conn;
 
-		$sql = "select tabid from tab where name='".$module."'";
+		$sql = "select vtiger_tabid from vtiger_tab where name='".$module."'";
 		$result = $conn->query($sql);
 		$tabid=  $conn->query_result($result,0,"tabid");
 
@@ -207,7 +207,7 @@
 		$failure_query_array = Array();
 
 		//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
+		//Here we have to decide which vtiger_files should be included, where the vtiger_files will be added newly for every public release
 		//Handle Here -- Mickie
 		include("modules/Migration/ModifyDatabase/MigrationInfo.php");
 
@@ -289,16 +289,16 @@
 			$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);
 
-			//get the number of tables in new database 
+			//get the number of vtiger_tables in new database 
 			$new_tables_count = $this->getTablesCountInNewDatabase();
 
-			//get the number of tables in old database 
+			//get the number of vtiger_tables in old database 
 			$old_tables_count = $this->getTablesCountInOldDatabase();
 
-			//if tables are missing after apply the dump, then alert the user and quit
+			//if vtiger_tables are missing after apply the dump, then alert the user and quit
 			if(($new_tables_count != $old_tables_count && $option == 'dbsource') || ($new_tables_count < 180 && $option == 'dumpsource'))
 			{
-				$this->conn->println("New Database tables not equal to Old Database tables count. Reload the current database again and quit.");
+				$this->conn->println("New Database vtiger_tables not equal to Old Database vtiger_tables count. Reload the current database again and quit.");
 				
 				$continue_process = 0;
 				$msg = "The dump may not be applied correctly. Tables exist in 4.2.3 database : $old_tables_count. Tables exist in current database after apply the dump : $new_tables_count";

Modified: vtigercrm/trunk/modules/Migration/MigrationCheck.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/MigrationCheck.php (original)
+++ vtigercrm/trunk/modules/Migration/MigrationCheck.php Mon Jun 12 14:26:25 2006
@@ -107,7 +107,7 @@
 
 	if($continue2 == 1)
 	{
-		//Check whether the table are exist in the databases or not
+		//Check whether the vtiger_table are exist in the databases or not
 		$old_tables = @mysql_num_rows(mysql_list_tables($old_dbname,$oldconn));
 		//$new_tables = @mysql_num_rows(mysql_list_tables($new_dbname));
 
@@ -289,7 +289,7 @@
 
 	if($continue2 == 1)
 	{
-		//Check whether the table are exist in the databases or not
+		//Check whether the vtiger_table are exist in the databases or not
 		$old_tables = @mysql_num_rows(mysql_list_tables($old_dbname,$oldconn));
 
 		if(!$old_tables)

Modified: vtigercrm/trunk/modules/Migration/ModifyDatabase/42P2_to_50Alpha.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/ModifyDatabase/42P2_to_50Alpha.php (original)
+++ vtigercrm/trunk/modules/Migration/ModifyDatabase/42P2_to_50Alpha.php Mon Jun 12 14:26:25 2006
@@ -22,7 +22,7 @@
 /****************** 5.0(Alpha) dev version 1 Database changes -- Starts*********************/
 
 
-//Added the announcement table creation to avoid the error
+//Added the vtiger_announcement vtiger_table creation to avoid the error
 $ann_query = "CREATE TABLE `announcement` (
 	  `creatorid` int(19) NOT NULL,
 	    `announcement` text,
@@ -33,41 +33,41 @@
 	    ) ENGINE=InnoDB DEFAULT CHARSET=latin1";
 Execute($ann_query);
 
-//Added Primay Keys for the left out tables
+//Added Primay Keys for the left out vtiger_tables
 $alter_array1 = Array(
-		"alter table activity_reminder ADD PRIMARY KEY (activity_id,recurringid)",
-		"alter table activitygrouprelation ADD PRIMARY KEY (activityid)",
-		"alter table cvadvfilter ADD PRIMARY KEY (cvid,columnindex)",
-		"alter table cvcolumnlist ADD PRIMARY KEY (cvid,columnindex)",
-		"alter table cvstdfilter ADD PRIMARY KEY (cvid)",
-		"alter table def_org_field ADD PRIMARY KEY (fieldid)",
-		"alter table leadgrouprelation ADD PRIMARY KEY (leadid)",
-		"alter table leadgrouprelation drop key leadgrouprelation_IDX0",
-		"alter table organizationdetails ADD PRIMARY KEY (organizationame)",
-		"alter table profile2field ADD PRIMARY KEY (profileid,fieldid)",
-		"alter table profile2standardpermissions ADD PRIMARY KEY (profileid,tabid,Operation)",
-		"alter table profile2standardpermissions drop index idx_prof2stad",
-		"alter table profile2utility ADD PRIMARY KEY (profileid,tabid,activityid)",
-		"alter table profile2utility drop index idx_prof2utility",
-		"alter table relcriteria ADD PRIMARY KEY (queryid,columnindex)",
-		"alter table reportdatefilter ADD PRIMARY KEY (datefilterid)",
-		"alter table reportdatefilter DROP INDEX reportdatefilter_IDX0",
-		"alter table reportsortcol ADD PRIMARY KEY (sortcolid,reportid)",
-		"alter table reportsummary ADD PRIMARY KEY (reportsummaryid,summarytype,columnname)",
-		"drop table role2action",
-		"drop table role2tab",
-		"alter table selectcolumn ADD PRIMARY KEY (queryid,columnindex)",
-		"alter table ticketgrouprelation ADD PRIMARY KEY (ticketid)",
-		"alter table ticketstracktime ADD PRIMARY KEY (ticket_id)",
-		"alter table users2group ADD PRIMARY KEY (groupname,userid)",
-		"alter table users2group DROP INDEX idx_users2group",
+		"alter vtiger_table vtiger_activity_reminder ADD PRIMARY KEY (activity_id,recurringid)",
+		"alter vtiger_table vtiger_activitygrouprelation ADD PRIMARY KEY (activityid)",
+		"alter vtiger_table vtiger_cvadvfilter ADD PRIMARY KEY (cvid,columnindex)",
+		"alter vtiger_table vtiger_cvcolumnlist ADD PRIMARY KEY (cvid,columnindex)",
+		"alter vtiger_table vtiger_cvstdfilter ADD PRIMARY KEY (cvid)",
+		"alter vtiger_table vtiger_def_org_field ADD PRIMARY KEY (fieldid)",
+		"alter vtiger_table vtiger_leadgrouprelation ADD PRIMARY KEY (leadid)",
+		"alter vtiger_table vtiger_leadgrouprelation drop key vtiger_leadgrouprelation_IDX0",
+		"alter vtiger_table vtiger_organizationdetails ADD PRIMARY KEY (organizationame)",
+		"alter vtiger_table vtiger_profile2field ADD PRIMARY KEY (profileid,fieldid)",
+		"alter vtiger_table vtiger_profile2standardpermissions ADD PRIMARY KEY (profileid,tabid,Operation)",
+		"alter vtiger_table vtiger_profile2standardpermissions drop index idx_prof2stad",
+		"alter vtiger_table vtiger_profile2utility ADD PRIMARY KEY (profileid,tabid,activityid)",
+		"alter vtiger_table vtiger_profile2utility drop index idx_prof2utility",
+		"alter vtiger_table vtiger_relcriteria ADD PRIMARY KEY (queryid,columnindex)",
+		"alter vtiger_table vtiger_reportdatefilter ADD PRIMARY KEY (datefilterid)",
+		"alter vtiger_table vtiger_reportdatefilter DROP INDEX vtiger_reportdatefilter_IDX0",
+		"alter vtiger_table vtiger_reportsortcol ADD PRIMARY KEY (sortcolid,reportid)",
+		"alter vtiger_table vtiger_reportsummary ADD PRIMARY KEY (reportsummaryid,summarytype,columnname)",
+		"drop vtiger_table vtiger_role2action",
+		"drop vtiger_table vtiger_role2tab",
+		"alter vtiger_table vtiger_selectcolumn ADD PRIMARY KEY (queryid,columnindex)",
+		"alter vtiger_table vtiger_ticketgrouprelation ADD PRIMARY KEY (ticketid)",
+		"alter vtiger_table vtiger_ticketstracktime ADD PRIMARY KEY (ticket_id)",
+		"alter vtiger_table vtiger_users2group ADD PRIMARY KEY (groupname,userid)",
+		"alter vtiger_table vtiger_users2group DROP INDEX idx_users2group",
 		);
 foreach($alter_array1 as $query)
 {
 	Execute($query);
 }
 
-//Tables profile2globalpermissions, actionmapping creation
+//Tables vtiger_profile2globalpermissions, vtiger_actionmapping creation
 
 $create_sql1 ="CREATE TABLE `profile2globalpermissions` (`profileid` int(19) NOT NULL, `globalactionid` int(19) NOT NULL, `globalactionpermission` int(19) default NULL, PRIMARY KEY  (`profileid`,`globalactionid`),  KEY `idx_profile2globalpermissions` (`profileid`,`globalactionid`)) ENGINE=InnoDB DEFAULT CHARSET=latin1";
 
@@ -81,8 +81,8 @@
 	) TYPE=InnoDB";
 Execute($create_sql2);
 
-//For all Profiles, insert the following entries into profile2global permissions table:
-$sql = 'select * from profile';
+//For all Profiles, insert the following entries into vtiger_profile2global permissions vtiger_table:
+$sql = 'select * from vtiger_profile';
 $res = $conn->query($sql);
 $noofprofiles = $conn->num_rows($res);
 
@@ -90,20 +90,20 @@
 {
 	$profile_id = $conn->query_result($res,$i,'profileid');
 
-	$sql1 = "insert into profile2globalpermissions values ($profile_id,1,0)";
-	$sql2 = "insert into profile2globalpermissions values ($profile_id,2,0)";
+	$sql1 = "insert into vtiger_profile2globalpermissions values ($profile_id,1,0)";
+	$sql2 = "insert into vtiger_profile2globalpermissions values ($profile_id,2,0)";
 
 	Execute($sql1);
 	Execute($sql2);
 }
 
 
-//Removing entries for Dashboard and Home module from profile2standardpermissions table
-$del_query1 = "delete from profile2standardpermissions where tabid in(1,3)";
+//Removing entries for Dashboard and Home module from vtiger_profile2standardpermissions vtiger_table
+$del_query1 = "delete from vtiger_profile2standardpermissions where vtiger_tabid in(1,3)";
 Execute($del_query1);
 
-//For all Profile do the following insert into profile2utility table:
-$sql = 'select * from profile';
+//For all Profile do the following insert into vtiger_profile2utility vtiger_table:
+$sql = 'select * from vtiger_profile';
 $res = $conn->query($sql);
 $noofprofiles = $conn->num_rows($res);
 
@@ -112,40 +112,40 @@
 {
 	$profile_id = $conn->query_result($res,$i,'profileid');
 
-	$sql1 = "insert into profile2utility values ($profile_id,4,7,0)";
-	$sql2 = "insert into profile2utility values ($profile_id,7,9,0)";
+	$sql1 = "insert into vtiger_profile2utility values ($profile_id,4,7,0)";
+	$sql2 = "insert into vtiger_profile2utility values ($profile_id,7,9,0)";
 
 	Execute($sql1);
 	Execute($sql2);
 }
 */
 
-//Insert Values into action mapping table:
+//Insert Values into action mapping vtiger_table:
 $actionmapping_array = Array(
-		"insert into actionmapping values(0,'Save',0)",
-		"insert into actionmapping values(1,'EditView',0)",
-		"insert into actionmapping values(2,'Delete',0)",
-		"insert into actionmapping values(3,'index',0)",
-		"insert into actionmapping values(4,'DetailView',0)",
-		"insert into actionmapping values(5,'Import',0)",
-		"insert into actionmapping values(6,'Export',0)",
-		"insert into actionmapping values(8,'Merge',0)",
-		"insert into actionmapping values(1,'VendorEditView',1)",
-		"insert into actionmapping values(4,'VendorDetailView',1)",
-		"insert into actionmapping values(0,'SaveVendor',1)",
-		"insert into actionmapping values(2,'DeleteVendor',1)",
-		"insert into actionmapping values(1,'PriceBookEditView',1)",
-		"insert into actionmapping values(4,'PriceBookDetailView',1)",
-		"insert into actionmapping values(0,'SavePriceBook',1)",
-		"insert into actionmapping values(2,'DeletePriceBook',1)",
-		"insert into actionmapping values(1,'SalesOrderEditView',1)",
-		"insert into actionmapping values(4,'SalesOrderDetailView',1)",
-		"insert into actionmapping values(0,'SaveSalesOrder',1)",
-		"insert into actionmapping values(2,'DeleteSalesOrder',1)",
-		"insert into actionmapping values(9,'ConvertLead',0)",
-		"insert into actionmapping values(1,'DetailViewAjax',1)",
-		"insert into actionmapping values(1,'QuickCreate',1)",
-		"insert into actionmapping values(4,'TagCloud',1)"
+		"insert into vtiger_actionmapping values(0,'Save',0)",
+		"insert into vtiger_actionmapping values(1,'EditView',0)",
+		"insert into vtiger_actionmapping values(2,'Delete',0)",
+		"insert into vtiger_actionmapping values(3,'index',0)",
+		"insert into vtiger_actionmapping values(4,'DetailView',0)",
+		"insert into vtiger_actionmapping values(5,'Import',0)",
+		"insert into vtiger_actionmapping values(6,'Export',0)",
+		"insert into vtiger_actionmapping values(8,'Merge',0)",
+		"insert into vtiger_actionmapping values(1,'VendorEditView',1)",
+		"insert into vtiger_actionmapping values(4,'VendorDetailView',1)",
+		"insert into vtiger_actionmapping values(0,'SaveVendor',1)",
+		"insert into vtiger_actionmapping values(2,'DeleteVendor',1)",
+		"insert into vtiger_actionmapping values(1,'PriceBookEditView',1)",
+		"insert into vtiger_actionmapping values(4,'PriceBookDetailView',1)",
+		"insert into vtiger_actionmapping values(0,'SavePriceBook',1)",
+		"insert into vtiger_actionmapping values(2,'DeletePriceBook',1)",
+		"insert into vtiger_actionmapping values(1,'SalesOrderEditView',1)",
+		"insert into vtiger_actionmapping values(4,'SalesOrderDetailView',1)",
+		"insert into vtiger_actionmapping values(0,'SaveSalesOrder',1)",
+		"insert into vtiger_actionmapping values(2,'DeleteSalesOrder',1)",
+		"insert into vtiger_actionmapping values(9,'ConvertLead',0)",
+		"insert into vtiger_actionmapping values(1,'DetailViewAjax',1)",
+		"insert into vtiger_actionmapping values(1,'QuickCreate',1)",
+		"insert into vtiger_actionmapping values(4,'TagCloud',1)"
 		);
 foreach($actionmapping_array as $query)
 {
@@ -153,10 +153,10 @@
 }
 
 
-//Added two columns in field table to construct the quickcreate form dynamically
+//Added two columns in vtiger_field vtiger_table to construct the quickcreate form dynamically
 $alter_array2 = Array(
-		"ALTER TABLE field ADD column quickcreate int(10) after typeofdata",
-		"ALTER TABLE field ADD column quickcreatesequence int(19) after quickcreate",
+		"ALTER TABLE vtiger_field ADD column quickcreate int(10) after typeofdata",
+		"ALTER TABLE vtiger_field ADD column quickcreatesequence int(19) after quickcreate",
 		);
 foreach($alter_array2 as $query)
 {
@@ -164,50 +164,50 @@
 }
 
 $update_array1 = Array(
-		"UPDATE field SET quickcreate = 1,quickcreatesequence = 0",
-
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 1 WHERE tabid = 2 and fieldlabel = 'Potential Name'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 2 WHERE tabid = 2 and fieldlabel = 'Account Name'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 3 WHERE tabid = 2 and fieldlabel = 'Expected Close Date'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 4 WHERE tabid = 2 and fieldlabel = 'Sales Stage'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 5 WHERE tabid = 2 and fieldlabel = 'Amount'",
-
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 1 WHERE tabid = 4 and fieldlabel = 'First Name'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 2 WHERE tabid = 4 and fieldlabel = 'Last Name'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 3 WHERE tabid = 4 and fieldlabel = 'Account Name'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 4 WHERE tabid = 4 and fieldlabel = 'Office Phone'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 5 WHERE tabid = 4 and fieldlabel = 'Email'",
-
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 1 WHERE tabid = 6 and fieldlabel = 'Account Name'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 2 WHERE tabid = 6 and fieldlabel = 'Phone'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 3 WHERE tabid = 6 and fieldlabel = 'Website'",
-
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 1 WHERE tabid = 7 and fieldlabel = 'First Name'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 2 WHERE tabid = 7 and fieldlabel = 'Last Name'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 3 WHERE tabid = 7 and fieldlabel = 'Company'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 4 WHERE tabid = 7 and fieldlabel = 'Phone'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 5 WHERE tabid = 7 and fieldlabel = 'Email'",
-
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 1 WHERE tabid = 8 and fieldlabel = 'Subject'",
-
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 1 WHERE tabid = 9 and fieldlabel = 'Subject'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 2 WHERE tabid = 9 and fieldlabel = 'Start Date & Time'",
-
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 1 WHERE tabid = 10 and fieldlabel = 'Subject'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 2 WHERE tabid = 10 and fieldlabel = 'Date & Time Sent'",
-
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 1 WHERE tabid = 13 and fieldlabel = 'Title'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 2 WHERE tabid = 13 and fieldlabel = 'Description'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 3 WHERE tabid = 13 and fieldlabel = 'Priority'",
-
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 1 WHERE tabid = 14 and fieldlabel = 'Product Name'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 2 WHERE tabid = 14 and fieldlabel = 'Product Code'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 3 WHERE tabid = 14 and fieldlabel = 'Product Category'",
-
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 1 WHERE tabid = 16 and fieldlabel = 'Subject'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 2 WHERE tabid = 16 and fieldlabel = 'Start Date & Time'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 3 WHERE tabid = 16 and fieldlabel = 'Activity Type'",
-		"UPDATE field SET quickcreate = 0,quickcreatesequence = 4 WHERE tabid = 16 and fieldlabel = 'Duration'",
+		"UPDATE vtiger_field SET quickcreate = 1,quickcreatesequence = 0",
+
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 1 WHERE vtiger_tabid = 2 and vtiger_fieldlabel = 'Potential Name'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 2 WHERE vtiger_tabid = 2 and vtiger_fieldlabel = 'Account Name'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 3 WHERE vtiger_tabid = 2 and vtiger_fieldlabel = 'Expected Close Date'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 4 WHERE vtiger_tabid = 2 and vtiger_fieldlabel = 'Sales Stage'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 5 WHERE vtiger_tabid = 2 and vtiger_fieldlabel = 'Amount'",
+
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 1 WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'First Name'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 2 WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Last Name'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 3 WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Account Name'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 4 WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Office Phone'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 5 WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Email'",
+
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 1 WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Account Name'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 2 WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Phone'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 3 WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Website'",
+
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 1 WHERE vtiger_tabid = 7 and vtiger_fieldlabel = 'First Name'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 2 WHERE vtiger_tabid = 7 and vtiger_fieldlabel = 'Last Name'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 3 WHERE vtiger_tabid = 7 and vtiger_fieldlabel = 'Company'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 4 WHERE vtiger_tabid = 7 and vtiger_fieldlabel = 'Phone'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 5 WHERE vtiger_tabid = 7 and vtiger_fieldlabel = 'Email'",
+
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 1 WHERE vtiger_tabid = 8 and vtiger_fieldlabel = 'Subject'",
+
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 1 WHERE vtiger_tabid = 9 and vtiger_fieldlabel = 'Subject'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 2 WHERE vtiger_tabid = 9 and vtiger_fieldlabel = 'Start Date & Time'",
+
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 1 WHERE vtiger_tabid = 10 and vtiger_fieldlabel = 'Subject'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 2 WHERE vtiger_tabid = 10 and vtiger_fieldlabel = 'Date & Time Sent'",
+
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 1 WHERE vtiger_tabid = 13 and vtiger_fieldlabel = 'Title'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 2 WHERE vtiger_tabid = 13 and vtiger_fieldlabel = 'Description'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 3 WHERE vtiger_tabid = 13 and vtiger_fieldlabel = 'Priority'",
+
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 1 WHERE vtiger_tabid = 14 and vtiger_fieldlabel = 'Product Name'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 2 WHERE vtiger_tabid = 14 and vtiger_fieldlabel = 'Product Code'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 3 WHERE vtiger_tabid = 14 and vtiger_fieldlabel = 'Product Category'",
+
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 1 WHERE vtiger_tabid = 16 and vtiger_fieldlabel = 'Subject'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 2 WHERE vtiger_tabid = 16 and vtiger_fieldlabel = 'Start Date & Time'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 3 WHERE vtiger_tabid = 16 and vtiger_fieldlabel = 'Activity Type'",
+		"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 4 WHERE vtiger_tabid = 16 and vtiger_fieldlabel = 'Duration'",
 		);
 foreach($update_array1 as $query)
 {
@@ -218,33 +218,33 @@
 $alter_query1 = "ALTER TABLE `users` ADD `cal_color` VARCHAR(25) DEFAULT '#E6FAD8' AFTER `user_hash`";
 Execute($alter_query1);
 
-//code contributed by Fredy for color priority
+//code contributed by Fredy for color vtiger_priority
 $newfieldid = $conn->getUniqueID("field");
-$insert_query1 = "insert into field values (16,".$newfieldid.",'priority','activity',1,15,'taskpriority','Priority',1,0,0,100,17,1,1,'V~O',1,'')";
+$insert_query1 = "insert into vtiger_field values (16,".$newfieldid.",'priority','activity',1,15,'taskpriority','Priority',1,0,0,100,17,1,1,'V~O',1,'')";
 Execute($insert_query1);
 
-//Added on 23-12-2005 which is missed from Fredy's contribution for Color priority
+//Added on 23-12-2005 which is missed from Fredy's contribution for Color vtiger_priority
 populateFieldForSecurity('16',$newfieldid);
-$activity_alter_query = "alter table activity add column priority varchar(150) default NULL";
+$activity_alter_query = "alter vtiger_table vtiger_activity add column vtiger_priority varchar(150) default NULL";
 Execute($activity_alter_query);
 
 //Code contributed by Raju for better emailing 
 /*
 $insert_array1 = Array(
-		"insert into field values (10,".$conn->getUniqueID("field").",'crmid','seactivityrel',1,'357','parent_id','Related To',1,0,0,100,1,2,1,'I~O',1,'')",
-		"insert into field values (10,".$conn->getUniqueID("field").",'subject','activity',1,'2','subject','Subject',1,0,0,100,1,3,1,'V~M',0,1)",
-		"insert into field values (10,".$conn->getUniqueID("field").",'filename','emails',1,'61','filename','Attachment',1,0,0,100,1,4,1,'V~O',1,'')",
-		"insert into field values (10,".$conn->getUniqueID("field").",'description','emails',1,'19','description','Description',1,0,0,100,1,5,1,'V~O',1,'')",
+		"insert into vtiger_field values (10,".$conn->getUniqueID("field").",'crmid','seactivityrel',1,'357','parent_id','Related To',1,0,0,100,1,2,1,'I~O',1,'')",
+		"insert into vtiger_field values (10,".$conn->getUniqueID("field").",'subject','activity',1,'2','subject','Subject',1,0,0,100,1,3,1,'V~M',0,1)",
+		"insert into vtiger_field values (10,".$conn->getUniqueID("field").",'filename','emails',1,'61','filename','Attachment',1,0,0,100,1,4,1,'V~O',1,'')",
+		"insert into vtiger_field values (10,".$conn->getUniqueID("field").",'description','emails',1,'19','description','Description',1,0,0,100,1,5,1,'V~O',1,'')",
 		);
 */
 //commented the above array as that queries are wrong queries -- changed on 23-12-2005
 $insert_array1 = array(
-			"update field set uitype='357' where tabid=10 and fieldname='parent_id' and tablename='seactivityrel'",
-			"update field set sequence=1 where tabid=10 and fieldname in ('parent_id','subject','filename','description')",
-			"update field set block=2 where tabid=10 and fieldname='parent_id'",
-			"update field set block=3 where tabid=10 and fieldname='subject'",
-			"update field set block=4 where tabid=10 and fieldname='filename'",
-			"update field set block=5 where tabid=10 and fieldname='description'",
+			"update vtiger_field set uitype='357' where vtiger_tabid=10 and vtiger_fieldname='parent_id' and vtiger_tablename='seactivityrel'",
+			"update vtiger_field set sequence=1 where vtiger_tabid=10 and vtiger_fieldname in ('parent_id','subject','filename','description')",
+			"update vtiger_field set block=2 where vtiger_tabid=10 and vtiger_fieldname='parent_id'",
+			"update vtiger_field set block=3 where vtiger_tabid=10 and vtiger_fieldname='subject'",
+			"update vtiger_field set block=4 where vtiger_tabid=10 and vtiger_fieldname='filename'",
+			"update vtiger_field set block=5 where vtiger_tabid=10 and vtiger_fieldname='description'",
 		      );
 foreach($insert_array1 as $query)
 {
@@ -252,40 +252,40 @@
 }
 
 //code contributed by mike to rearrange the home page
-$alter_query2 = "alter table users add column homeorder varchar(255) default 'ALVT,PLVT,QLTQ,CVLVT,HLT,OLV,GRT,OLTSO,ILTI' after date_format";
+$alter_query2 = "alter vtiger_table vtiger_users add column homeorder varchar(255) default 'ALVT,PLVT,QLTQ,CVLVT,HLT,OLV,GRT,OLTSO,ILTI' after date_format";
 Execute($alter_query2);
 
-//Added one column in invoice table to include 'Contact Name' field in Invoice module
-$alter_query3 = "ALTER TABLE invoice ADD column contactid int(19) after customerno";
+//Added one column in vtiger_invoice vtiger_table to include 'Contact Name' vtiger_field in Invoice module
+$alter_query3 = "ALTER TABLE vtiger_invoice ADD column contactid int(19) after customerno";
 Execute($alter_query3);
 
 $newfieldid = $conn->getUniqueID("field");
-$insert_query2 = "insert into field values (23,".$newfieldid.",'contactid','invoice',1,'57','contact_id','Contact Name',1,0,0,100,4,1,1,'I~O',1,'')";
+$insert_query2 = "insert into vtiger_field values (23,".$newfieldid.",'contactid','invoice',1,'57','contact_id','Contact Name',1,0,0,100,4,1,1,'I~O',1,'')";
 Execute($insert_query2);
-//Added on 23-12-2005 because we must populate field entries in profile2field and def_org_field if we add a field in field table
+//Added on 23-12-2005 because we must populate vtiger_field entries in vtiger_profile2field and vtiger_def_org_field if we add a vtiger_field in vtiger_field vtiger_table
 populateFieldForSecurity('23',$newfieldid);
 
 //changes made to fix the bug in Address Information block of Accounts and Contacs module
 $update_array2 = Array(
-		"UPDATE field SET fieldlabel='Billing City' WHERE tabid=6 and tablename='accountbillads' and fieldname='bill_city'",
-		"UPDATE field SET fieldlabel='Billing State' WHERE tabid=6 and tablename='accountbillads' and fieldname='bill_state'",
-		"UPDATE field SET fieldlabel='Billing Code' WHERE tabid=6 and tablename='accountbillads' and fieldname='bill_code'",
-		"UPDATE field SET fieldlabel='Billing Country' WHERE tabid=6 and tablename='accountbillads' and fieldname='bill_country'",
-
-		"UPDATE field SET fieldlabel='Shipping City' WHERE tabid=6 and tablename='accountshipads' and fieldname='ship_city'",
-		"UPDATE field SET fieldlabel='Shipping Country' WHERE tabid=6 and tablename='accountshipads' and fieldname='ship_country'",
-		"UPDATE field SET fieldlabel='Shipping State' WHERE tabid=6 and tablename='accountshipads' and fieldname='ship_state'",
-		"UPDATE field SET fieldlabel='Shipping Code' WHERE tabid=6 and tablename='accountshipads' and fieldname='ship_code'",
-
-		"UPDATE field SET fieldlabel='Mailing City' WHERE tabid=4 and tablename='contactaddress' and fieldname='mailingcity'",
-		"UPDATE field SET fieldlabel='Mailing State' WHERE tabid=4 and tablename='contactaddress' and fieldname='mailingstate'",
-		"UPDATE field SET fieldlabel='Mailing Zip' WHERE tabid=4 and tablename='contactaddress' and fieldname='mailingzip'",
-		"UPDATE field SET fieldlabel='Mailing Country' WHERE tabid=4 and tablename='contactaddress' and fieldname='mailingcountry'",
-
-		"UPDATE field SET fieldlabel='Other City' WHERE tabid=4 and tablename='contactaddress' and fieldname='othercity'",
-		"UPDATE field SET fieldlabel='Other State' WHERE tabid=4 and tablename='contactaddress' and fieldname='otherstate'",
-		"UPDATE field SET fieldlabel='Other Zip' WHERE tabid=4 and tablename='contactaddress' and fieldname='otherzip'",
-		"UPDATE field SET fieldlabel='Other Country' WHERE tabid=4 and tablename='contactaddress' and fieldname='othercountry'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Billing City' WHERE vtiger_tabid=6 and vtiger_tablename='accountbillads' and vtiger_fieldname='bill_city'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Billing State' WHERE vtiger_tabid=6 and vtiger_tablename='accountbillads' and vtiger_fieldname='bill_state'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Billing Code' WHERE vtiger_tabid=6 and vtiger_tablename='accountbillads' and vtiger_fieldname='bill_code'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Billing Country' WHERE vtiger_tabid=6 and vtiger_tablename='accountbillads' and vtiger_fieldname='bill_country'",
+
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Shipping City' WHERE vtiger_tabid=6 and vtiger_tablename='accountshipads' and vtiger_fieldname='ship_city'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Shipping Country' WHERE vtiger_tabid=6 and vtiger_tablename='accountshipads' and vtiger_fieldname='ship_country'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Shipping State' WHERE vtiger_tabid=6 and vtiger_tablename='accountshipads' and vtiger_fieldname='ship_state'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Shipping Code' WHERE vtiger_tabid=6 and vtiger_tablename='accountshipads' and vtiger_fieldname='ship_code'",
+
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Mailing City' WHERE vtiger_tabid=4 and vtiger_tablename='contactaddress' and vtiger_fieldname='mailingcity'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Mailing State' WHERE vtiger_tabid=4 and vtiger_tablename='contactaddress' and vtiger_fieldname='mailingstate'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Mailing Zip' WHERE vtiger_tabid=4 and vtiger_tablename='contactaddress' and vtiger_fieldname='mailingzip'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Mailing Country' WHERE vtiger_tabid=4 and vtiger_tablename='contactaddress' and vtiger_fieldname='mailingcountry'",
+
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Other City' WHERE vtiger_tabid=4 and vtiger_tablename='contactaddress' and vtiger_fieldname='othercity'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Other State' WHERE vtiger_tabid=4 and vtiger_tablename='contactaddress' and vtiger_fieldname='otherstate'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Other Zip' WHERE vtiger_tabid=4 and vtiger_tablename='contactaddress' and vtiger_fieldname='otherzip'",
+		"UPDATE vtiger_field SET vtiger_fieldlabel='Other Country' WHERE vtiger_tabid=4 and vtiger_tablename='contactaddress' and vtiger_fieldname='othercountry'",
 		);
 foreach($update_array2 as $query)
 {
@@ -293,22 +293,22 @@
 }
 
 
-//Added field emailoptout in account table
+//Added vtiger_field emailoptout in vtiger_account vtiger_table
 $newfieldid = $conn->getUniqueID("field");
-$insert_query3 = "insert into field values (6,".$newfieldid.",'emailoptout','account',1,'56','emailoptout','Email Opt Out',1,0,0,100,17,1,1,'C~O',1,'')";
+$insert_query3 = "insert into vtiger_field values (6,".$newfieldid.",'emailoptout','account',1,'56','emailoptout','Email Opt Out',1,0,0,100,17,1,1,'C~O',1,'')";
 Execute($insert_query3);
 
-//Added on 23-12-2005 because we must populate field entries in profile2field and def_org_field if we add a field in field table
+//Added on 23-12-2005 because we must populate vtiger_field entries in vtiger_profile2field and vtiger_def_org_field if we add a vtiger_field in vtiger_field vtiger_table
 populateFieldForSecurity('6',$newfieldid);
 
 //Added on 22-12-2005
-$alter_query4 = "alter table account add column emailoptout varchar(3) default 0";
+$alter_query4 = "alter vtiger_table vtiger_account add column emailoptout varchar(3) default 0";
 Execute($alter_query4);
 
 $update_array3 = Array(
-		"update field set sequence=18 where tabid=6 and fieldname ='assigned_user_id'",
-		"update field set sequence=19 where tabid=6 and fieldname ='createdtime'",
-		"update field set sequence=19 where tabid=6 and fieldname ='modifiedtime'",
+		"update vtiger_field set sequence=18 where vtiger_tabid=6 and vtiger_fieldname ='assigned_user_id'",
+		"update vtiger_field set sequence=19 where vtiger_tabid=6 and vtiger_fieldname ='createdtime'",
+		"update vtiger_field set sequence=19 where vtiger_tabid=6 and vtiger_fieldname ='modifiedtime'",
 		);
 foreach($update_array3 as $query)
 {
@@ -316,7 +316,7 @@
 }
 
 
-//create table moduleowners to assign the module and corresponding owners
+//create vtiger_table vtiger_moduleowners to assign the module and corresponding owners
 $create_query2 = "CREATE TABLE `moduleowners` (
 	  `tabid` int(19) NOT NULL default '0',
 	    `user_id` varchar(11) NOT NULL,
@@ -335,7 +335,7 @@
 */
 Execute($create_query2);
 
-//Populated the default entries for moduleowners which is created newly
+//Populated the default entries for vtiger_moduleowners which is created newly
 $module_array = Array(
 		'Potentials',
 		'Contacts',
@@ -357,18 +357,18 @@
 		);
 foreach($module_array as $mod)
 {
-	$query = "insert into moduleowners values(".$this->localGetTabID($mod).",1)";
-	Execute($query);
-}
-
-
-//Changes made to include status field in Activity Quickcreate Form
+	$query = "insert into vtiger_moduleowners values(".$this->localGetTabID($mod).",1)";
+	Execute($query);
+}
+
+
+//Changes made to include status vtiger_field in Activity Quickcreate Form
 $update_array4 = Array(
-		"UPDATE field SET quickcreate=0,quickcreatesequence=3 WHERE tabid=16 and fieldname='eventstatus'",
-		"UPDATE field SET quickcreate=0,quickcreatesequence=4 WHERE tabid=16 and fieldname='activitytype'",
-		"UPDATE field SET quickcreate=0,quickcreatesequence=5 WHERE tabid=16 and fieldname='duration_hours'",
-
-		"UPDATE field SET quickcreate=0,quickcreatesequence=3 WHERE tabid=9 and fieldname='taskstatus'",
+		"UPDATE vtiger_field SET quickcreate=0,quickcreatesequence=3 WHERE vtiger_tabid=16 and vtiger_fieldname='eventstatus'",
+		"UPDATE vtiger_field SET quickcreate=0,quickcreatesequence=4 WHERE vtiger_tabid=16 and vtiger_fieldname='activitytype'",
+		"UPDATE vtiger_field SET quickcreate=0,quickcreatesequence=5 WHERE vtiger_tabid=16 and vtiger_fieldname='duration_hours'",
+
+		"UPDATE vtiger_field SET quickcreate=0,quickcreatesequence=3 WHERE vtiger_tabid=9 and vtiger_fieldname='taskstatus'",
 		);
 foreach($update_array4 as $query)
 {
@@ -378,10 +378,10 @@
 
 
 //Table 'inventory_tandc' added newly to include Inventory Terms &Conditions
-$create_query1 = "CREATE TABLE  inventory_tandc(id INT(19),type VARCHAR(30) NOT NULL,tandc LONGTEXT default NULL,PRIMARY KEY(id))";
+$create_query1 = "CREATE TABLE  vtiger_inventory_tandc(id INT(19),type VARCHAR(30) NOT NULL,tandc LONGTEXT default NULL,PRIMARY KEY(id))";
 Execute($create_query1);
 
-$insert_query4 = "insert into inventory_tandc values('".$conn->getUniqueID('inventory_tandc')."','Inventory','  ')";
+$insert_query4 = "insert into vtiger_inventory_tandc values('".$conn->getUniqueID('inventory_tandc')."','Inventory','  ')";
 Execute($insert_query4);
 
 /****************** 5.0(Alpha) dev version 1 Database changes -- Ends*********************/
@@ -397,17 +397,17 @@
 
 /****************** 5.0(Alpha) dev version 2 Database changes -- Starts*********************/
 
-$query1 = "ALTER TABLE leadaddress change lane lane varchar(250)";
+$query1 = "ALTER TABLE vtiger_leadaddress change lane lane varchar(250)";
 Execute($query1);
 
 $rename_table_array1 = Array(
-		"update field set tablename='customerdetails' where tabid=4 and fieldname in ('portal','support_start_date','support_end_date')",
-		"alter table PortalInfo drop foreign key fk_PortalInfo",
-		"rename table PortalInfo to portalinfo",
-		"alter table portalinfo add CONSTRAINT `fk_portalinfo` FOREIGN KEY (`id`) REFERENCES `contactdetails` (`contactid`) ON DELETE CASCADE",
-		"alter table CustomerDetails drop foreign key fk_CustomerDetails",
-		"rename table CustomerDetails to customerdetails",
-		"alter table customerdetails add CONSTRAINT `fk_customerdetails` FOREIGN KEY (`customerid`) REFERENCES `contactdetails` (`contactid`) ON DELETE CASCADE"
+		"update vtiger_field set vtiger_tablename='customerdetails' where vtiger_tabid=4 and vtiger_fieldname in ('portal','support_start_date','support_end_date')",
+		"alter vtiger_table PortalInfo drop foreign key fk_PortalInfo",
+		"rename vtiger_table PortalInfo to vtiger_portalinfo",
+		"alter vtiger_table vtiger_portalinfo add CONSTRAINT `fk_portalinfo` FOREIGN KEY (`id`) REFERENCES `contactdetails` (`contactid`) ON DELETE CASCADE",
+		"alter vtiger_table CustomerDetails drop foreign key fk_CustomerDetails",
+		"rename vtiger_table CustomerDetails to vtiger_customerdetails",
+		"alter vtiger_table vtiger_customerdetails add CONSTRAINT `fk_customerdetails` FOREIGN KEY (`customerid`) REFERENCES `contactdetails` (`contactid`) ON DELETE CASCADE"
 		);
 foreach($rename_table_array1 as $query)
 {
@@ -415,12 +415,12 @@
 }
 
 
-$query2 = "create table ownernotify(crmid int(19),smownerid int(19),flag int(3))";
+$query2 = "create vtiger_table vtiger_ownernotify(crmid int(19),smownerid int(19),flag int(3))";
 Execute($query2);
 
 
-//Form the role_map_array as roleid=>name mapping array
-$sql = "select * from role";
+//Form the vtiger_role_map_array as vtiger_roleid=>name mapping array
+$sql = "select * from vtiger_role";
 $res = $conn->query($sql);
 $role_map_array = Array();
 for($i=0;$i<$conn->num_rows($res);$i++)
@@ -429,10 +429,10 @@
 	$name = $conn->query_result($res,$i,'name');
 	$role_map_array[$roleid] = $name;
 }
-//echo '<pre> List of roles :';print_r($role_map_array);echo '</pre>';
-
-//Before delete the role take a backup array for the table user2role
-$sql = "select * from user2role";
+//echo '<pre> List of vtiger_roles :';print_r($role_map_array);echo '</pre>';
+
+//Before delete the vtiger_role take a backup array for the vtiger_table vtiger_user2role
+$sql = "select * from vtiger_user2role";
 $res = $conn->query($sql);
 $user2role_array = array();
 for($i=0;$i<$conn->num_rows($res);$i++)
@@ -441,23 +441,23 @@
 	$roleid = $conn->query_result($res,$i,'roleid');
 	$user2role_array[$userid] = $roleid;
 }
-//echo '<pre> List of user2role : (userid => roleid)';print_r($user2role_array);echo '</pre>';
-
-//Delete the role entries
-$sql = "truncate role";
+//echo '<pre> List of vtiger_user2role : (userid => vtiger_roleid)';print_r($user2role_array);echo '</pre>';
+
+//Delete the vtiger_role entries
+$sql = "truncate vtiger_role";
 Execute($sql);
 
 
-$query3 = "alter table user2role drop FOREIGN KEY fk_user2role2";
+$query3 = "alter vtiger_table vtiger_user2role drop FOREIGN KEY fk_user2role2";
 Execute($query3);
 
 //4,5 th are the Extra added queries
 $alter_query_array1 = Array(
-		"alter table user2role change roleid roleid varchar(255)",
-		"alter table role2profile change roleid roleid varchar(255)",
-		"alter table role CHANGE roleid roleid varchar(255)",
-		"alter table role2profile drop PRIMARY KEY",
-		"alter table role2profile ADD PRIMARY KEY (roleid,profileid)"
+		"alter vtiger_table vtiger_user2role change vtiger_roleid vtiger_roleid varchar(255)",
+		"alter vtiger_table vtiger_role2profile change vtiger_roleid vtiger_roleid varchar(255)",
+		"alter vtiger_table vtiger_role CHANGE vtiger_roleid vtiger_roleid varchar(255)",
+		"alter vtiger_table vtiger_role2profile drop PRIMARY KEY",
+		"alter vtiger_table vtiger_role2profile ADD PRIMARY KEY (roleid,profileid)"
 		);
 foreach($alter_query_array1 as $query)
 {
@@ -465,14 +465,14 @@
 }
 
 
-$query4 = "ALTER TABLE user2role ADD CONSTRAINT fk_user2role2 FOREIGN KEY (roleid) REFERENCES role(roleid) ON DELETE CASCADE";
+$query4 = "ALTER TABLE vtiger_user2role ADD CONSTRAINT fk_user2role2 FOREIGN KEY (roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE";
 Execute($query4);
 
 $alter_query_array2 = Array(
-		"alter table role CHANGE name rolename varchar(200)",
-		"alter table role DROP description",
-		"alter table role add parentrole varchar(255)",
-		"alter table role add depth int(19)"
+		"alter vtiger_table vtiger_role CHANGE name vtiger_rolename varchar(200)",
+		"alter vtiger_table vtiger_role DROP description",
+		"alter vtiger_table vtiger_role add parentrole varchar(255)",
+		"alter vtiger_table vtiger_role add depth int(19)"
 		);
 foreach($alter_query_array2 as $query)
 {
@@ -481,17 +481,17 @@
 
 
 
-$query5 = "insert into role values('H1','Organisation','H1',0)";
+$query5 = "insert into vtiger_role values('H1','Organisation','H1',0)";
 Execute($query5);
 
 //include("include/utils/UserInfoUtil.php");
-//Create role based on role_map_array values and form the new_role_map_array with old roleid and new roleid
+//Create vtiger_role based on vtiger_role_map_array values and form the new_role_map_array with old vtiger_roleid and new vtiger_roleid
 foreach($role_map_array as $roleid => $rolename)
 {
 	$parentRole = 'H1';
 	if($rolename == 'standard_user')
 	{
-		$rs = $conn->query("select * from role where rolename='administrator'");
+		$rs = $conn->query("select * from vtiger_role where vtiger_rolename='administrator'");
 		$parentRole = $conn->query_result($rs,0,'roleid');
 	}
 	$empty_array = array(""=>"");
@@ -500,42 +500,42 @@
 }
 
 //Before insert the new entry we should remove the old entries -- added on 06-06-06
-$user2role_del = "truncate user2role";
+$user2role_del = "truncate vtiger_user2role";
 Execute($user2role_del);
 
-//First we will insert the old values from user2role_array to user2role table and then update the new role id
+//First we will insert the old values from vtiger_user2role_array to vtiger_user2role vtiger_table and then update the new vtiger_role id
 foreach($user2role_array as $userid => $roleid)
 {
-	$sql = "insert into user2role (userid, roleid) values(".$userid.",'".$new_role_map_array[$roleid]."')";
+	$sql = "insert into vtiger_user2role (userid, vtiger_roleid) values(".$userid.",'".$new_role_map_array[$roleid]."')";
 	Execute($sql);
 }
-//Commented the following loop as we have backup the user2role and insert the entries with the new rold id using new_role_map_array above
-//Update the user2role table with new roleid
+//Commented the following loop as we have backup the vtiger_user2role and insert the entries with the new rold id using new_role_map_array above
+//Update the vtiger_user2role vtiger_table with new vtiger_roleid
 /*
    foreach($new_role_map_array as $old_roleid => $new_roleid)
    {
-   $update_user2role = "update user2role set roleid='".$new_roleid."' where roleid=".$old_roleid;
+   $update_user2role = "update vtiger_user2role set vtiger_roleid='".$new_roleid."' where vtiger_roleid=".$old_roleid;
    Execute($update_user2role);
    }
  */
-//Update the role2profile table with new roleid
+//Update the vtiger_role2profile vtiger_table with new vtiger_roleid
 foreach($new_role_map_array as $old_roleid => $new_roleid)
 {
-	$update_role2profile = "update role2profile set roleid='".$new_roleid."' where roleid=".$old_roleid;
+	$update_role2profile = "update vtiger_role2profile set vtiger_roleid='".$new_roleid."' where vtiger_roleid=".$old_roleid;
 	Execute($update_role2profile);
 }
 
 
 
 //Group Migration:
-//Step 1 :  form and group_map_array as groupname => description from groups table
-//Step 2 :  form an users2group_map_array array as userid => groupname from users2group table
-//Step 3 :  delete all entries from groups table and enter new values from group_map_array
-//Step 4 :  drop the table users2group and create new table
-//Step 5 :  put entries to users2group table based on users2group_map_array. Here get the groupid from groups table based on groupname
+//Step 1 :  form and group_map_array as groupname => description from vtiger_groups vtiger_table
+//Step 2 :  form an vtiger_users2group_map_array array as userid => groupname from vtiger_users2group vtiger_table
+//Step 3 :  delete all entries from vtiger_groups vtiger_table and enter new values from group_map_array
+//Step 4 :  drop the vtiger_table vtiger_users2group and create new vtiger_table
+//Step 5 :  put entries to vtiger_users2group vtiger_table based on vtiger_users2group_map_array. Here get the groupid from vtiger_groups vtiger_table based on groupname
 
 //Step 1 : Form the group_map_array as groupname => description
-$sql = "select * from groups";
+$sql = "select * from vtiger_groups";
 $res = $conn->query($sql);
 $group_map_array = Array();
 for($i=0;$i<$conn->num_rows($res);$i++)
@@ -547,8 +547,8 @@
 //echo '<pre>List of Groups : ';print_r($group_map_array);echo '</pre>';
 
 
-//Step 2 : form an users2group_map_array array as userid => groupname from users2group table
-$sql = "select * from users2group";
+//Step 2 : form an vtiger_users2group_map_array array as userid => groupname from vtiger_users2group vtiger_table
+$sql = "select * from vtiger_users2group";
 $res = $conn->query($sql);
 $users2group_map_array = Array();
 for($i=0;$i<$conn->num_rows($res);$i++)
@@ -557,18 +557,18 @@
 	$userid = $conn->query_result($res,$i,'userid');
 	$users2group_map_array[$userid] = $groupname;
 }
-//echo '<pre>List of users2group : ';print_r($users2group_map_array);echo '</pre>';
-
-//Step 3 : delete all entries from groups table
-$sql = "truncate groups";
+//echo '<pre>List of vtiger_users2group : ';print_r($users2group_map_array);echo '</pre>';
+
+//Step 3 : delete all entries from vtiger_groups vtiger_table
+$sql = "truncate vtiger_groups";
 Execute($sql);
 
 $alter_query_array3 = Array(
-		"alter table users2group drop FOREIGN KEY fk_users2group",
-		"alter table leadgrouprelation drop FOREIGN KEY fk_leadgrouprelation2",
-		"alter table activitygrouprelation drop FOREIGN KEY fk_activitygrouprelation2",
-		"alter table ticketgrouprelation drop FOREIGN KEY fk_ticketgrouprelation2",
-		"alter table groups drop PRIMARY KEY"
+		"alter vtiger_table vtiger_users2group drop FOREIGN KEY fk_users2group",
+		"alter vtiger_table vtiger_leadgrouprelation drop FOREIGN KEY fk_leadgrouprelation2",
+		"alter vtiger_table vtiger_activitygrouprelation drop FOREIGN KEY fk_activitygrouprelation2",
+		"alter vtiger_table vtiger_ticketgrouprelation drop FOREIGN KEY fk_ticketgrouprelation2",
+		"alter vtiger_table vtiger_groups drop PRIMARY KEY"
 		);
 foreach($alter_query_array3 as $query)
 {
@@ -576,12 +576,12 @@
 }
 
 //2 nd query is the Extra added query
-//Adding columns in group table:
+//Adding columns in group vtiger_table:
 $alter_query_array4 = Array(
-		"alter table groups add column groupid int(19) FIRST",
-		"alter table groups change name  groupname varchar(100)",
-		"alter table groups ADD PRIMARY KEY (groupid)",
-		"alter table groups add index (groupname)"
+		"alter vtiger_table vtiger_groups add column groupid int(19) FIRST",
+		"alter vtiger_table vtiger_groups change name  groupname varchar(100)",
+		"alter vtiger_table vtiger_groups ADD PRIMARY KEY (groupid)",
+		"alter vtiger_table vtiger_groups add index (groupname)"
 		);
 foreach($alter_query_array4 as $query)
 {
@@ -589,7 +589,7 @@
 }
 
 
-//Moved the create table queries for group2grouprel, group2role, group2rs from the end of this block
+//Moved the create vtiger_table queries for vtiger_group2grouprel, vtiger_group2role, vtiger_group2rs from the end of this block
 //Added on 06-06-06
 $query8 = "CREATE TABLE `group2grouprel` (
 	  `groupid` int(19) NOT NULL,
@@ -641,7 +641,7 @@
 */
 Execute($query10);
 
-//Insert all the retrieved old values to the new groups table ie., create new groups
+//Insert all the retrieved old values to the new vtiger_groups vtiger_table ie., create new vtiger_groups
 foreach($group_map_array as $groupname => $description)
 {
 	$empty_array = array(
@@ -655,10 +655,10 @@
 }
 
 
-//Copy all mappings in a user2grop table in a array;
-
-//Step 4 : Drop and again create users2group
-$query6 = "drop table users2group";
+//Copy all mappings in a user2grop vtiger_table in a array;
+
+//Step 4 : Drop and again create vtiger_users2group
+$query6 = "drop vtiger_table vtiger_users2group";
 Execute($query6);
 
 //Added on 06-06-06
@@ -679,30 +679,30 @@
 */
 Execute($query7);
 
-//Step 5 : put entries to users2group table based on users2group_map_array. Here get the groupid from groups table based on groupname
+//Step 5 : put entries to vtiger_users2group vtiger_table based on vtiger_users2group_map_array. Here get the groupid from vtiger_groups vtiger_table based on groupname
 foreach($users2group_map_array as $userid => $groupname)
 {
-	//$groupid = $conn->query_result($conn->query("select * from groups where groupname='".$groupname."'"),0,'groupid');
-	$sql = "insert into users2group (groupid,userid) values(".$group_name_id_mapping[$groupname].",".$userid.")";
+	//$groupid = $conn->query_result($conn->query("select * from vtiger_groups where groupname='".$groupname."'"),0,'groupid');
+	$sql = "insert into vtiger_users2group (groupid,userid) values(".$group_name_id_mapping[$groupname].",".$userid.")";
 	Execute($sql);
 }
 
 
 $alter_query_array5 = Array(
-		"alter table leadgrouprelation ADD CONSTRAINT fk_leadgrouprelation2 FOREIGN KEY (groupname) REFERENCES groups(groupname) ON DELETE CASCADE",
-		"ALTER TABLE activitygrouprelation ADD CONSTRAINT fk_activitygrouprelation2 FOREIGN KEY (groupname) REFERENCES groups(groupname) ON DELETE CASCADE",
-		"ALTER TABLE ticketgrouprelation ADD CONSTRAINT fk_ticketgrouprelation2 FOREIGN KEY (groupname) REFERENCES groups(groupname) ON DELETE CASCADE"
+		"alter vtiger_table vtiger_leadgrouprelation ADD CONSTRAINT fk_leadgrouprelation2 FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE",
+		"ALTER TABLE vtiger_activitygrouprelation ADD CONSTRAINT fk_activitygrouprelation2 FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE",
+		"ALTER TABLE vtiger_ticketgrouprelation ADD CONSTRAINT fk_ticketgrouprelation2 FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE"
 		);
 foreach($alter_query_array5 as $query)
 {
 	Execute($query);
 }
-//Moved the create table queries for group2grouprel, group2role, group2rs to before creatinf the Group ie., before call the createGroup
-
-
-/***Added to include decimal places for amount field in potential table  --by Mangai 15-Nov-2005***/
-
-$query11 = "ALTER TABLE potential change amount amount decimal(10,2)";
+//Moved the create vtiger_table queries for vtiger_group2grouprel, vtiger_group2role, vtiger_group2rs to before creatinf the Group ie., before call the createGroup
+
+
+/***Added to include decimal places for amount vtiger_field in vtiger_potential vtiger_table  --by Mangai 15-Nov-2005***/
+
+$query11 = "ALTER TABLE vtiger_potential change amount amount decimal(10,2)";
 Execute($query11);
 
 /****************** 5.0(Alpha) dev version 2 Database changes -- Ends*********************/
@@ -720,10 +720,10 @@
 
 /****************** 5.0(Alpha) dev version 3 Database changes -- Starts*********************/
 
-//Drop the column company_name from vendor table ---- modified by Mickie on 18-11-2005
-$altersql1 = "alter table vendor drop column company_name";
+//Drop the column company_name from vtiger_vendor vtiger_table ---- modified by Mickie on 18-11-2005
+$altersql1 = "alter vtiger_table vtiger_vendor drop column company_name";
 Execute($altersql1);
-//TODO (check): Remove this company_name entry from the field table if it already exists
+//TODO (check): Remove this company_name entry from the vtiger_field vtiger_table if it already exists
 
 //Migration for Default Organisation Share -- Added by Don on 20-11-2005
 
@@ -743,24 +743,24 @@
 Execute($query2);
 
 
-$query3 = "alter table def_org_share add column editstatus int(19)";
+$query3 = "alter vtiger_table vtiger_def_org_share add column editstatus int(19)";
 Execute($query3);
 
-$query4 = "delete from def_org_share where tabid in(8,14,15,18,19)";
+$query4 = "delete from vtiger_def_org_share where vtiger_tabid in(8,14,15,18,19)";
 Execute($query4);
 
 
 
 //Inserting values into org share action mapping
 $insert_query_array1 = Array(
-			"insert into org_share_action_mapping values(0,'Public: Read Only')",
-			"insert into org_share_action_mapping values(1,'Public:Read,Create/Edit')",
-			"insert into org_share_action_mapping values(2,'Public: Read, Create/Edit, Delete')",
-			"insert into org_share_action_mapping values(3,'Private')",
-			"insert into org_share_action_mapping values(4,'Hide Details')",
-			"insert into org_share_action_mapping values(5,'Hide Details and Add Events')",
-			"insert into org_share_action_mapping values(6,'Show Details')",
-			"insert into org_share_action_mapping values(7,'Show Details and Add Events')"
+			"insert into vtiger_org_share_action_mapping values(0,'Public: Read Only')",
+			"insert into vtiger_org_share_action_mapping values(1,'Public:Read,Create/Edit')",
+			"insert into vtiger_org_share_action_mapping values(2,'Public: Read, Create/Edit, Delete')",
+			"insert into vtiger_org_share_action_mapping values(3,'Private')",
+			"insert into vtiger_org_share_action_mapping values(4,'Hide Details')",
+			"insert into vtiger_org_share_action_mapping values(5,'Hide Details and Add Events')",
+			"insert into vtiger_org_share_action_mapping values(6,'Show Details')",
+			"insert into vtiger_org_share_action_mapping values(7,'Show Details and Add Events')"
 			);
 foreach($insert_query_array1 as $query)
 {
@@ -768,15 +768,15 @@
 }
 
 
-//Inserting for all tabs
+//Inserting for all vtiger_tabs
 $def_org_tabid=Array(2,4,6,7,9,10,13,16,20,21,22,23,26);
 foreach($def_org_tabid as $def_tabid)
 {
 	$insert_query_array2 = Array(
-			"insert into org_share_action2tab values(0,".$def_tabid.")",
-			"insert into org_share_action2tab values(1,".$def_tabid.")",
-			"insert into org_share_action2tab values(2,".$def_tabid.")",
-			"insert into org_share_action2tab values(3,".$def_tabid.")"
+			"insert into vtiger_org_share_action2tab values(0,".$def_tabid.")",
+			"insert into vtiger_org_share_action2tab values(1,".$def_tabid.")",
+			"insert into vtiger_org_share_action2tab values(2,".$def_tabid.")",
+			"insert into vtiger_org_share_action2tab values(3,".$def_tabid.")"
 			);
 	foreach($insert_query_array2 as $query)
 	{
@@ -785,10 +785,10 @@
 }
 
 $insert_query_array3 = Array(
-		"insert into org_share_action2tab values(4,17)",
-		"insert into org_share_action2tab values(5,17)",
-		"insert into org_share_action2tab values(6,17)",
-		"insert into org_share_action2tab values(7,17)"
+		"insert into vtiger_org_share_action2tab values(4,17)",
+		"insert into vtiger_org_share_action2tab values(5,17)",
+		"insert into vtiger_org_share_action2tab values(6,17)",
+		"insert into vtiger_org_share_action2tab values(7,17)"
 		);
 foreach($insert_query_array3 as $query)
 {
@@ -796,11 +796,11 @@
 }
 
 $query_array1 = Array(
-		"insert into def_org_share values(9,17,7,0)",
-		"update def_org_share set editstatus=0",
-		"update def_org_share set editstatus=2 where tabid=4",
-		"update def_org_share set editstatus=1 where tabid=9",
-		"update def_org_share set editstatus=2 where tabid=16"
+		"insert into vtiger_def_org_share values(9,17,7,0)",
+		"update vtiger_def_org_share set editstatus=0",
+		"update vtiger_def_org_share set editstatus=2 where vtiger_tabid=4",
+		"update vtiger_def_org_share set editstatus=1 where vtiger_tabid=9",
+		"update vtiger_def_org_share set editstatus=2 where vtiger_tabid=16"
 		);
 foreach($query_array1 as $query)
 {
@@ -814,8 +814,8 @@
 $conn->println("Database Modifications for 5.0(Alpha) Dev 3 ==> 5.0 Alpha starts here.");
 //echo "<br><br><b>Database Modifications for 5.0(Alpha) Dev3 ==> 5.0 Alpha starts here.....</b><br>";
 $alter_query_array6 = Array(
-				"ALTER TABLE users ADD column activity_view VARCHAR(25) DEFAULT 'Today' AFTER homeorder",
-				"ALTER TABLE activity ADD column notime CHAR(3) DEFAULT '0' AFTER location"
+				"ALTER TABLE vtiger_users ADD column vtiger_activity_view VARCHAR(25) DEFAULT 'Today' AFTER homeorder",
+				"ALTER TABLE vtiger_activity ADD column notime CHAR(3) DEFAULT '0' AFTER location"
 			   );
 foreach($alter_query_array6 as $query)
 {
@@ -823,8 +823,8 @@
 }
 
 $insert_field_array1 = Array(
-				"Insert into field values (9,".$conn->getUniqueID("field").",'notime','activity',1,56,'notime','No Time',1,0,0,100,20,1,3,'C~O',1,'')",
-				"Insert into field values (16,".$conn->getUniqueID("field").",'notime','activity',1,56,'notime','No Time',1,0,0,100,18,1,1,'C~O',1,'')"
+				"Insert into vtiger_field values (9,".$conn->getUniqueID("field").",'notime','activity',1,56,'notime','No Time',1,0,0,100,20,1,3,'C~O',1,'')",
+				"Insert into vtiger_field values (16,".$conn->getUniqueID("field").",'notime','activity',1,56,'notime','No Time',1,0,0,100,18,1,1,'C~O',1,'')"
 			    );
 foreach($insert_field_array1 as $query)
 {
@@ -832,20 +832,20 @@
 }
 
 $alter_query_array7 = Array(
-				"alter table vendor add column pobox varchar(30) after state",
-				"alter table leadaddress add column pobox varchar(30) after state",
-				"alter table accountbillads add column pobox varchar(30) after state",
-				"alter table accountshipads add column pobox varchar(30) after state",
-				"alter table contactaddress add column mailingpobox varchar(30) after mailingstate",
-				"alter table contactaddress add column otherpobox varchar(30) after otherstate",
-				"alter table quotesbillads add column bill_pobox varchar(30) after bill_street",
-				"alter table quotesshipads add column ship_pobox varchar(30) after ship_street",
-				"alter table pobillads add column bill_pobox varchar(30) after bill_street",
-				"alter table poshipads add column ship_pobox varchar(30) after ship_street",
-				"alter table sobillads add column bill_pobox varchar(30) after bill_street",
-				"alter table soshipads add column ship_pobox varchar(30) after ship_street",
-				"alter table invoicebillads add column bill_pobox varchar(30) after bill_street",
-				"alter table invoiceshipads add column ship_pobox varchar(30) after ship_street"
+				"alter vtiger_table vtiger_vendor add column pobox varchar(30) after state",
+				"alter vtiger_table vtiger_leadaddress add column pobox varchar(30) after state",
+				"alter vtiger_table vtiger_accountbillads add column pobox varchar(30) after state",
+				"alter vtiger_table vtiger_accountshipads add column pobox varchar(30) after state",
+				"alter vtiger_table vtiger_contactaddress add column mailingpobox varchar(30) after mailingstate",
+				"alter vtiger_table vtiger_contactaddress add column otherpobox varchar(30) after otherstate",
+				"alter vtiger_table vtiger_quotesbillads add column bill_pobox varchar(30) after bill_street",
+				"alter vtiger_table vtiger_quotesshipads add column ship_pobox varchar(30) after ship_street",
+				"alter vtiger_table vtiger_pobillads add column bill_pobox varchar(30) after bill_street",
+				"alter vtiger_table vtiger_poshipads add column ship_pobox varchar(30) after ship_street",
+				"alter vtiger_table vtiger_sobillads add column bill_pobox varchar(30) after bill_street",
+				"alter vtiger_table vtiger_soshipads add column ship_pobox varchar(30) after ship_street",
+				"alter vtiger_table vtiger_invoicebillads add column bill_pobox varchar(30) after bill_street",
+				"alter vtiger_table vtiger_invoiceshipads add column ship_pobox varchar(30) after ship_street"
 			   );
 foreach($alter_query_array7 as $query)
 {
@@ -853,27 +853,27 @@
 }
 
 $insert_field_array2 = Array(
-				"insert into field values (23,".$conn->getUniqueID("field").",'bill_pobox','invoicebillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,2,1,'V~O',1,'')",
-				"insert into field values (23,".$conn->getUniqueID("field").",'ship_pobox','invoiceshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,2,1,'V~O',1,'')",
+				"insert into vtiger_field values (23,".$conn->getUniqueID("field").",'bill_pobox','invoicebillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,2,1,'V~O',1,'')",
+				"insert into vtiger_field values (23,".$conn->getUniqueID("field").",'ship_pobox','invoiceshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,2,1,'V~O',1,'')",
 				
-				"insert into field values (6,".$conn->getUniqueID("field").",'pobox','accountbillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,2,1,'V~O',1,'')",
-				"insert into field values (6,".$conn->getUniqueID("field").",'pobox','accountshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,2,1,'V~O',1,'')",
+				"insert into vtiger_field values (6,".$conn->getUniqueID("field").",'pobox','accountbillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,2,1,'V~O',1,'')",
+				"insert into vtiger_field values (6,".$conn->getUniqueID("field").",'pobox','accountshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,2,1,'V~O',1,'')",
 				
-				"insert into field values (7,".$conn->getUniqueID("field").",'pobox','leadaddress',1,'1','pobox','Po Box',1,0,0,100,2,2,1,'V~O',1,'')",
-
-				"insert into field values (4,".$conn->getUniqueID("field").",'mailingpobox','contactaddress',1,'1','mailingpobox','Mailing Po Box',1,0,0,100,3,2,1,'V~O',1,'')",
-				"insert into field values (4,".$conn->getUniqueID("field").",'otherpobox','contactaddress',1,'1','otherpobox','Other Po Box',1,0,0,100,4,2,1,'V~O',1,'')",
-
-				"insert into field values (18,".$conn->getUniqueID("field").",'pobox','vendor',1,'1','pobox','Po Box',1,0,0,100,2,2,1,'V~O',1,'')",
-
-				"insert into field values (20,".$conn->getUniqueID("field").",'bill_pobox','quotesbillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,2,1,'V~O',1,'')",
-				"insert into field values (20,".$conn->getUniqueID("field").",'ship_pobox','quotesshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,2,1,'V~O',1,'')",
-
-				"insert into field values (21,".$conn->getUniqueID("field").",'bill_pobox','pobillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,2,1,'V~O',1,'')",
-				"insert into field values (21,".$conn->getUniqueID("field").",'ship_pobox','poshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,2,1,'V~O',1,'')",
-
-				"insert into field values (22,".$conn->getUniqueID("field").",'bill_pobox','sobillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,2,1,'V~O',1,'')",
-				"insert into field values (22,".$conn->getUniqueID("field").",'ship_pobox','soshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,2,1,'V~O',1,'')"
+				"insert into vtiger_field values (7,".$conn->getUniqueID("field").",'pobox','leadaddress',1,'1','pobox','Po Box',1,0,0,100,2,2,1,'V~O',1,'')",
+
+				"insert into vtiger_field values (4,".$conn->getUniqueID("field").",'mailingpobox','contactaddress',1,'1','mailingpobox','Mailing Po Box',1,0,0,100,3,2,1,'V~O',1,'')",
+				"insert into vtiger_field values (4,".$conn->getUniqueID("field").",'otherpobox','contactaddress',1,'1','otherpobox','Other Po Box',1,0,0,100,4,2,1,'V~O',1,'')",
+
+				"insert into vtiger_field values (18,".$conn->getUniqueID("field").",'pobox','vendor',1,'1','pobox','Po Box',1,0,0,100,2,2,1,'V~O',1,'')",
+
+				"insert into vtiger_field values (20,".$conn->getUniqueID("field").",'bill_pobox','quotesbillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,2,1,'V~O',1,'')",
+				"insert into vtiger_field values (20,".$conn->getUniqueID("field").",'ship_pobox','quotesshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,2,1,'V~O',1,'')",
+
+				"insert into vtiger_field values (21,".$conn->getUniqueID("field").",'bill_pobox','pobillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,2,1,'V~O',1,'')",
+				"insert into vtiger_field values (21,".$conn->getUniqueID("field").",'ship_pobox','poshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,2,1,'V~O',1,'')",
+
+				"insert into vtiger_field values (22,".$conn->getUniqueID("field").",'bill_pobox','sobillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,2,1,'V~O',1,'')",
+				"insert into vtiger_field values (22,".$conn->getUniqueID("field").",'ship_pobox','soshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,2,1,'V~O',1,'')"
 			    );
 foreach($insert_field_array2 as $query)
 {
@@ -892,7 +892,7 @@
 	$n = $n+5;
 	for($i = 0;$i < 5;$i++)
 	{
-		$query1 = "update field set sequence=".$sequence[$j]." where tablename='".$tablename[$n+$i]."' && fieldname='".$fieldname[$j]."'";
+		$query1 = "update vtiger_field set sequence=".$sequence[$j]." where vtiger_tablename='".$tablename[$n+$i]."' && vtiger_fieldname='".$fieldname[$j]."'";
 		Execute($query1);
 	}
 }
@@ -902,7 +902,7 @@
 $sequence = array(3,4,5,6);
 for($i = 0;$i < 4;$i++)
 {
-	$query2 = "update field set sequence=".$sequence[$i]." where tablename='".$tablename."' && fieldname='".$fieldname[$i]."'";
+	$query2 = "update vtiger_field set sequence=".$sequence[$i]." where vtiger_tablename='".$tablename."' && vtiger_fieldname='".$fieldname[$i]."'";
 	Execute($query2);
 }
 
@@ -912,7 +912,7 @@
 
 for($i = 0;$i < 4;$i++)
 {
-	$query3 = "update field set sequence=".$sequence[$i]." where tablename='".$tablename."' && fieldname='".$fieldname[$i]."'";
+	$query3 = "update vtiger_field set sequence=".$sequence[$i]." where vtiger_tablename='".$tablename."' && vtiger_fieldname='".$fieldname[$i]."'";
 	Execute($query3);
 }
 
@@ -922,43 +922,43 @@
 
 for($i = 0;$i < 8;$i++)
 {
-	$query = "update field set sequence=".$sequence[$i]." where tablename='".$tablename."' && fieldname='".$fieldname[$i]."'";
+	$query = "update vtiger_field set sequence=".$sequence[$i]." where vtiger_tablename='".$tablename."' && vtiger_fieldname='".$fieldname[$i]."'";
 	Execute($query);
 }
 
 $query_array1 = Array(
-			"update field set tablename='crmentity' where tabid=10 and fieldname='description'",
-			"update field set tablename='attachments' where tabid=10 and fieldname='filename'",
-			"drop table emails",
-
-			"alter table activity drop column description",
-			"update field set tablename='crmentity' where tabid in (9,16) and fieldname='description'",
-
-			"update tab set name='PurchaseOrder',tablabel='PurchaseOrder' where tabid=21",
-			"update tab set presence=0 where tabid=22 and name='SalesOrder'",
-
-			"delete from actionmapping where actionname='SalesOrderDetailView'",
-			"delete from actionmapping where actionname='SalesOrderEditView'",
-			"delete from actionmapping where actionname='SaveSalesOrder'",
-			"delete from actionmapping where actionname='DeleteSalesOrder'",
-
-			"insert into field values (13,".$conn->getUniqueID("field").",'filename','attachments',1,'61','filename','Attachment',1,0,0,100,12,2,1,'V~O',0,1)",
-
-			"alter table troubletickets add column filename varchar(50) default NULL after title"
+			"update vtiger_field set vtiger_tablename='crmentity' where vtiger_tabid=10 and vtiger_fieldname='description'",
+			"update vtiger_field set vtiger_tablename='attachments' where vtiger_tabid=10 and vtiger_fieldname='filename'",
+			"drop vtiger_table emails",
+
+			"alter vtiger_table vtiger_activity drop column description",
+			"update vtiger_field set vtiger_tablename='crmentity' where vtiger_tabid in (9,16) and vtiger_fieldname='description'",
+
+			"update vtiger_tab set name='PurchaseOrder',tablabel='PurchaseOrder' where vtiger_tabid=21",
+			"update vtiger_tab set presence=0 where vtiger_tabid=22 and name='SalesOrder'",
+
+			"delete from vtiger_actionmapping where actionname='SalesOrderDetailView'",
+			"delete from vtiger_actionmapping where actionname='SalesOrderEditView'",
+			"delete from vtiger_actionmapping where actionname='SaveSalesOrder'",
+			"delete from vtiger_actionmapping where actionname='DeleteSalesOrder'",
+
+			"insert into vtiger_field values (13,".$conn->getUniqueID("field").",'filename','attachments',1,'61','filename','Attachment',1,0,0,100,12,2,1,'V~O',0,1)",
+
+			"alter vtiger_table vtiger_troubletickets add column filename varchar(50) default NULL after title"
 		     );
 foreach($query_array1 as $query)
 {
 	Execute($query);
 }
 
-$create_query3 = "create table parenttab(parenttabid int(19) not null, parenttab_label varchar(100) not null, sequence int(10) not null, visible int(2) not null default '0', Primary Key(parenttabid))";
+$create_query3 = "create vtiger_table vtiger_parenttab(parenttabid int(19) not null, vtiger_parenttab_label varchar(100) not null, sequence int(10) not null, visible int(2) not null default '0', Primary Key(parenttabid))";
 Execute($create_query3);
-$create_query4 = "create table parenttabrel(parenttabid int(3) not null, tabid int(3) not null,sequence int(3) not null)";
+$create_query4 = "create vtiger_table vtiger_parenttabrel(parenttabid int(3) not null, vtiger_tabid int(3) not null,sequence int(3) not null)";
 Execute($create_query4);
 
 $insert_query_array4 = Array(
-				"insert into parenttab values(1,'My Home Page',1,0),(2,'Marketing',2,0),(3,'Sales',3,0),(4,'Support',4,0),(5,'Analytics',5,0),(6,'Inventory',6,0), (7,'Tools',7,0),(8,'Settings',8,0)",
-				"insert into parenttabrel values(1,9,2),(1,17,3),(1,10,4),(1,3,1),(3,7,1),(3,6,2),(3,4,3),(3,2,4),(3,20,5),(3,22,6),(3,23,7),(3,14,8),(3,19,9),(3,8,10),(4,13,1),(4,15,2),(4,6,3),(4,4,4),(4,14,5),(4,8,6),(5,1,1),(5,25,2),(6,14,1), (6,18,2), (6,19,3), (6,21,4), (6,22,5), (6,20,6), (6,23,7), (7,24,1), (7,27,2), (7,8,3), (2,26,1), (2,6,2), (2,4,3) "
+				"insert into vtiger_parenttab values(1,'My Home Page',1,0),(2,'Marketing',2,0),(3,'Sales',3,0),(4,'Support',4,0),(5,'Analytics',5,0),(6,'Inventory',6,0), (7,'Tools',7,0),(8,'Settings',8,0)",
+				"insert into vtiger_parenttabrel values(1,9,2),(1,17,3),(1,10,4),(1,3,1),(3,7,1),(3,6,2),(3,4,3),(3,2,4),(3,20,5),(3,22,6),(3,23,7),(3,14,8),(3,19,9),(3,8,10),(4,13,1),(4,15,2),(4,6,3),(4,4,4),(4,14,5),(4,8,6),(5,1,1),(5,25,2),(6,14,1), (6,18,2), (6,19,3), (6,21,4), (6,22,5), (6,20,6), (6,23,7), (7,24,1), (7,27,2), (7,8,3), (2,26,1), (2,6,2), (2,4,3) "
 			    );
 foreach($insert_query_array4 as $query)
 {
@@ -966,100 +966,100 @@
 }
 
 
-$create_query5 = "CREATE TABLE blocks ( blockid int(19) NOT NULL, tabid int(19) NOT NULL, blocklabel varchar(100) NOT NULL, sequence int(19) NOT NULL, show_title int(2) NOT NULL, visible int(2) NOT NULL DEFAULT 0, create_view int(2) NOT NULL DEFAULT 0, edit_view int(2) NOT NULL DEFAULT 0, detail_view int(2) NOT NULL DEFAULT 0, PRIMARY KEY (blockid))";
+$create_query5 = "CREATE TABLE vtiger_blocks ( blockid int(19) NOT NULL, vtiger_tabid int(19) NOT NULL, blocklabel varchar(100) NOT NULL, sequence int(19) NOT NULL, show_title int(2) NOT NULL, visible int(2) NOT NULL DEFAULT 0, create_view int(2) NOT NULL DEFAULT 0, edit_view int(2) NOT NULL DEFAULT 0, detail_view int(2) NOT NULL DEFAULT 0, PRIMARY KEY (blockid))";
 Execute($create_query5);
 
 $update_query_array1 = Array(
-				"update field set block=2 where tabid=2 and block=5",
-				"update field set block=3 where tabid=2 and block=2",
-
-				//"update field set block=4 where tabid=4 and block=1",
-				"update field set block=5 where tabid=4 and block=5",
-				"update field set block=6 where tabid=4 and block=4",//Modified on 24-04-06
-				"update field set block=4 where tabid=4 and block=1",
-				"update field set block=7 where tabid=4 and block=2",
-				"update field set block=8 where tabid=4 and block=3",
-
-				"update field set block=9 where tabid=6 and block=1",
-				"update field set block=10 where tabid=6 and block=5",
-				"update field set block=11 where tabid=6 and block=2",
-				"update field set block=12 where tabid=6 and block=3",
-
-				"update field set block=13 where tabid=7 and block=1",
-				"update field set block=14 where tabid=7 and block=5",
-				"update field set block=15 where tabid=7 and block=2",
-				"update field set block=16 where tabid=7 and block=3",
-
-				"update field set block=17 where tabid=8 and block=1",
-				"update field set block=17 where tabid=8 and block=2",
-				"update field set block=18 where tabid=8 and block=3",
-
-				"update field set block=19 where tabid=9 and block=1",
-				"update field set block=19 where tabid=9 and block=7",
-				"update field set block=20 where tabid=9 and block=2",
-
-				"update field set block=21 where tabid=10 and block=1",
-				"update field set block=22 where tabid=10 and block=2",
-				"update field set block=23 where tabid=10 and block=3",
-				"update field set block=23 where tabid=10 and block=4",
-				"update field set block=24 where tabid=10 and block=5",
-
-				"update field set block=25 where tabid=13 and block=1",
-				"update field set block=26 where tabid=13 and block=2",
-				"update field set block=27 where tabid=13 and block=5",
-				"update field set block=28 where tabid=13 and block=3",
-				"update field set block=29 where tabid=13 and block=4",
-				"update field set block=30 where tabid=13 and block=6",
-
-				"update field set block=31 where tabid=14 and block=1",
-				"update field set block=32 where tabid=14 and block=2",
-				"update field set block=33 where tabid=14 and block=3",
-				"update field set block=34 where tabid=14 and block=5",
-				"update field set block=35 where tabid=14 and block=6",
-				"update field set block=36 where tabid=14 and block=4",
-
-				"update field set block=37 where tabid=15 and block=1",
-				"update field set block=38 where tabid=15 and block=2",
-				"update field set block=39 where tabid=15 and block=3",
-				"update field set block=40 where tabid=15 and block=4",
-
-				"update field set block=41 where tabid=16 and block=1",
-				"update field set block=42 where tabid=16 and block=7",
-				"update field set block=43 where tabid=16 and block=2",
-
-				"update field set block=44 where tabid=18 and block=1",
-				"update field set block=45 where tabid=18 and block=5",
-				"update field set block=36 where tabid=18 and block=2",
-				"update field set block=47 where tabid=18 and block=3",
-
-				"update field set block=48 where tabid=19 and block=1",
-				"update field set block=49 where tabid=19 and block=5",
-				"update field set block=50 where tabid=19 and block=2",
-
-				"update field set block=51 where tabid=20 and block=1",
-				"update field set block=52 where tabid=20 and block=5",
-				"update field set block=53 where tabid=20 and block=2",
-				"update field set block=55 where tabid=20 and block=6",
-				"update field set block=56 where tabid=20 and block=3",
-
-				"update field set block=57 where tabid=21 and block=1",
-				"update field set block=58 where tabid=21 and block=5",
-				"update field set block=59 where tabid=21 and block=2",
-				"update field set block=61 where tabid=21 and block=6",
-				"update field set block=62 where tabid=21 and block=3",
-
-				"update field set block=63 where tabid=22 and block=1",
-				"update field set block=64 where tabid=22 and block=5",
-				"update field set block=65 where tabid=22 and block=2",
-				"update field set block=67 where tabid=22 and block=6",
-				"update field set block=68 where tabid=22 and block=3",
-
-
-				"update field set block=69 where tabid=23 and block=1",
-				"update field set block=70 where tabid=23 and block=5",
-				"update field set block=71 where tabid=23 and block=2",
-				"update field set block=73 where tabid=23 and block=6",
-				"update field set block=74 where tabid=23 and block=3",
+				"update vtiger_field set block=2 where vtiger_tabid=2 and block=5",
+				"update vtiger_field set block=3 where vtiger_tabid=2 and block=2",
+
+				//"update vtiger_field set block=4 where vtiger_tabid=4 and block=1",
+				"update vtiger_field set block=5 where vtiger_tabid=4 and block=5",
+				"update vtiger_field set block=6 where vtiger_tabid=4 and block=4",//Modified on 24-04-06
+				"update vtiger_field set block=4 where vtiger_tabid=4 and block=1",
+				"update vtiger_field set block=7 where vtiger_tabid=4 and block=2",
+				"update vtiger_field set block=8 where vtiger_tabid=4 and block=3",
+
+				"update vtiger_field set block=9 where vtiger_tabid=6 and block=1",
+				"update vtiger_field set block=10 where vtiger_tabid=6 and block=5",
+				"update vtiger_field set block=11 where vtiger_tabid=6 and block=2",
+				"update vtiger_field set block=12 where vtiger_tabid=6 and block=3",
+
+				"update vtiger_field set block=13 where vtiger_tabid=7 and block=1",
+				"update vtiger_field set block=14 where vtiger_tabid=7 and block=5",
+				"update vtiger_field set block=15 where vtiger_tabid=7 and block=2",
+				"update vtiger_field set block=16 where vtiger_tabid=7 and block=3",
+
+				"update vtiger_field set block=17 where vtiger_tabid=8 and block=1",
+				"update vtiger_field set block=17 where vtiger_tabid=8 and block=2",
+				"update vtiger_field set block=18 where vtiger_tabid=8 and block=3",
+
+				"update vtiger_field set block=19 where vtiger_tabid=9 and block=1",
+				"update vtiger_field set block=19 where vtiger_tabid=9 and block=7",
+				"update vtiger_field set block=20 where vtiger_tabid=9 and block=2",
+
+				"update vtiger_field set block=21 where vtiger_tabid=10 and block=1",
+				"update vtiger_field set block=22 where vtiger_tabid=10 and block=2",
+				"update vtiger_field set block=23 where vtiger_tabid=10 and block=3",
+				"update vtiger_field set block=23 where vtiger_tabid=10 and block=4",
+				"update vtiger_field set block=24 where vtiger_tabid=10 and block=5",
+
+				"update vtiger_field set block=25 where vtiger_tabid=13 and block=1",
+				"update vtiger_field set block=26 where vtiger_tabid=13 and block=2",
+				"update vtiger_field set block=27 where vtiger_tabid=13 and block=5",
+				"update vtiger_field set block=28 where vtiger_tabid=13 and block=3",
+				"update vtiger_field set block=29 where vtiger_tabid=13 and block=4",
+				"update vtiger_field set block=30 where vtiger_tabid=13 and block=6",
+
+				"update vtiger_field set block=31 where vtiger_tabid=14 and block=1",
+				"update vtiger_field set block=32 where vtiger_tabid=14 and block=2",
+				"update vtiger_field set block=33 where vtiger_tabid=14 and block=3",
+				"update vtiger_field set block=34 where vtiger_tabid=14 and block=5",
+				"update vtiger_field set block=35 where vtiger_tabid=14 and block=6",
+				"update vtiger_field set block=36 where vtiger_tabid=14 and block=4",
+
+				"update vtiger_field set block=37 where vtiger_tabid=15 and block=1",
+				"update vtiger_field set block=38 where vtiger_tabid=15 and block=2",
+				"update vtiger_field set block=39 where vtiger_tabid=15 and block=3",
+				"update vtiger_field set block=40 where vtiger_tabid=15 and block=4",
+
+				"update vtiger_field set block=41 where vtiger_tabid=16 and block=1",
+				"update vtiger_field set block=42 where vtiger_tabid=16 and block=7",
+				"update vtiger_field set block=43 where vtiger_tabid=16 and block=2",
+
+				"update vtiger_field set block=44 where vtiger_tabid=18 and block=1",
+				"update vtiger_field set block=45 where vtiger_tabid=18 and block=5",
+				"update vtiger_field set block=36 where vtiger_tabid=18 and block=2",
+				"update vtiger_field set block=47 where vtiger_tabid=18 and block=3",
+
+				"update vtiger_field set block=48 where vtiger_tabid=19 and block=1",
+				"update vtiger_field set block=49 where vtiger_tabid=19 and block=5",
+				"update vtiger_field set block=50 where vtiger_tabid=19 and block=2",
+
+				"update vtiger_field set block=51 where vtiger_tabid=20 and block=1",
+				"update vtiger_field set block=52 where vtiger_tabid=20 and block=5",
+				"update vtiger_field set block=53 where vtiger_tabid=20 and block=2",
+				"update vtiger_field set block=55 where vtiger_tabid=20 and block=6",
+				"update vtiger_field set block=56 where vtiger_tabid=20 and block=3",
+
+				"update vtiger_field set block=57 where vtiger_tabid=21 and block=1",
+				"update vtiger_field set block=58 where vtiger_tabid=21 and block=5",
+				"update vtiger_field set block=59 where vtiger_tabid=21 and block=2",
+				"update vtiger_field set block=61 where vtiger_tabid=21 and block=6",
+				"update vtiger_field set block=62 where vtiger_tabid=21 and block=3",
+
+				"update vtiger_field set block=63 where vtiger_tabid=22 and block=1",
+				"update vtiger_field set block=64 where vtiger_tabid=22 and block=5",
+				"update vtiger_field set block=65 where vtiger_tabid=22 and block=2",
+				"update vtiger_field set block=67 where vtiger_tabid=22 and block=6",
+				"update vtiger_field set block=68 where vtiger_tabid=22 and block=3",
+
+
+				"update vtiger_field set block=69 where vtiger_tabid=23 and block=1",
+				"update vtiger_field set block=70 where vtiger_tabid=23 and block=5",
+				"update vtiger_field set block=71 where vtiger_tabid=23 and block=2",
+				"update vtiger_field set block=73 where vtiger_tabid=23 and block=6",
+				"update vtiger_field set block=74 where vtiger_tabid=23 and block=3",
 			    );
 foreach($update_query_array1 as $query)
 {
@@ -1067,80 +1067,80 @@
 }
 
 $insert_query_array5 = Array(
-				"insert into blocks values (1,2,'LBL_OPPORTUNITY_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (2,2,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
-				"insert into blocks values (3,2,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)",
-				"insert into blocks values (4,4,'LBL_CONTACT_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (5,4,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
-				"insert into blocks values (6,4,'LBL_CUSTOMER_PORTAL_INFORMATION',3,0,0,0,0,0)",
-				"insert into blocks values (7,4,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0)",
-				"insert into blocks values (8,4,'LBL_DESCRIPTION_INFORMATION',5,0,0,0,0,0)",
-				"insert into blocks values (9,6,'LBL_ACCOUNT_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (10,6,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
-				"insert into blocks values (11,6,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)",
-				"insert into blocks values (12,6,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)",
-				"insert into blocks values (13,7,'LBL_LEAD_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (14,7,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
-				"insert into blocks values (15,7,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)",
-				"insert into blocks values (16,7,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)",
-				"insert into blocks values (17,8,'LBL_NOTE_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (18,8,'',2,1,0,0,0,0)",
-				"insert into blocks values (19,9,'LBL_TASK_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (20,9,'',2,1,0,0,0,0)",
-				"insert into blocks values (21,10,'LBL_EMAIL_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (22,10,'',2,1,0,0,0,0)",
-				"insert into blocks values (23,10,'',3,1,0,0,0,0)",
-				"insert into blocks values (24,10,'',4,1,0,0,0,0)",
-				"insert into blocks values (25,13,'LBL_TICKET_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (26,13,'',2,1,0,0,0,0)",
-				"insert into blocks values (27,13,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0)",
-				"insert into blocks values (28,13,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)",
-				"insert into blocks values (29,13,'LBL_TICKET_RESOLUTION',5,0,0,1,0,0)",
-				"insert into blocks values (30,13,'LBL_COMMENTS',6,0,0,1,0,0)",
-				"insert into blocks values (31,14,'LBL_PRODUCT_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (32,14,'LBL_PRICING_INFORMATION',2,0,0,0,0,0)",
-				"insert into blocks values (33,14,'LBL_STOCK_INFORMATION',3,0,0,0,0,0)",
-				"insert into blocks values (34,14,'LBL_CUSTOM_INFORMATION',4,0,0,0,0,0)",
-				"insert into blocks values (35,14,'LBL_IMAGE_INFORMATION',5,0,0,0,0,0)",
-				"insert into blocks values (36,14,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)",
-				"insert into blocks values (37,15,'LBL_FAQ_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (38,15,'',2,1,0,0,0,0)",
-				"insert into blocks values (39,15,'',3,1,0,0,0,0)",
-				"insert into blocks values (40,15,'LBL_COMMENT_INFORMATION',4,0,0,1,0,0)",
-				"insert into blocks values (41,16,'LBL_EVENT_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (42,16,'',2,1,0,0,0,0)",
-				"insert into blocks values (43,16,'',3,1,0,0,0,0)",
-				"insert into blocks values (44,18,'LBL_VENDOR_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (45,18,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
-				"insert into blocks values (46,18,'LBL_VENDOR_ADDRESS_INFORMATION',3,0,0,0,0,0)",
-				"insert into blocks values (47,18,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)",
-				"insert into blocks values (48,19,'LBL_PRICEBOOK_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (49,19,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
-				"insert into blocks values (50,19,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)",
-				"insert into blocks values (51,20,'LBL_QUOTE_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (52,20,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
-				"insert into blocks values (53,20,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)",
-				"insert into blocks values (54,20,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)",
-				"insert into blocks values (55,20,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)",
-				"insert into blocks values (56,20,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)",
-				"insert into blocks values (57,21,'LBL_PO_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (58,21,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
-				"insert into blocks values (59,21,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)",
-				"insert into blocks values (60,21,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)",
-				"insert into blocks values (61,21,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)",
-				"insert into blocks values (62,21,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)",
-				"insert into blocks values (63,22,'LBL_SO_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (64,22,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
-				"insert into blocks values (65,22,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)",
-				"insert into blocks values (66,22,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)",
-				"insert into blocks values (67,22,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)",
-				"insert into blocks values (68,22,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)",
-				"insert into blocks values (69,23,'LBL_INVOICE_INFORMATION',1,0,0,0,0,0)",
-				"insert into blocks values (70,23,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
-				"insert into blocks values (71,23,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)",
-				"insert into blocks values (72,23,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)",
-				"insert into blocks values (73,23,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)",
-				"insert into blocks values (74,23,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)"
+				"insert into vtiger_blocks values (1,2,'LBL_OPPORTUNITY_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (2,2,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
+				"insert into vtiger_blocks values (3,2,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)",
+				"insert into vtiger_blocks values (4,4,'LBL_CONTACT_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (5,4,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
+				"insert into vtiger_blocks values (6,4,'LBL_CUSTOMER_PORTAL_INFORMATION',3,0,0,0,0,0)",
+				"insert into vtiger_blocks values (7,4,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0)",
+				"insert into vtiger_blocks values (8,4,'LBL_DESCRIPTION_INFORMATION',5,0,0,0,0,0)",
+				"insert into vtiger_blocks values (9,6,'LBL_ACCOUNT_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (10,6,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
+				"insert into vtiger_blocks values (11,6,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)",
+				"insert into vtiger_blocks values (12,6,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)",
+				"insert into vtiger_blocks values (13,7,'LBL_LEAD_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (14,7,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
+				"insert into vtiger_blocks values (15,7,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)",
+				"insert into vtiger_blocks values (16,7,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)",
+				"insert into vtiger_blocks values (17,8,'LBL_NOTE_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (18,8,'',2,1,0,0,0,0)",
+				"insert into vtiger_blocks values (19,9,'LBL_TASK_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (20,9,'',2,1,0,0,0,0)",
+				"insert into vtiger_blocks values (21,10,'LBL_EMAIL_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (22,10,'',2,1,0,0,0,0)",
+				"insert into vtiger_blocks values (23,10,'',3,1,0,0,0,0)",
+				"insert into vtiger_blocks values (24,10,'',4,1,0,0,0,0)",
+				"insert into vtiger_blocks values (25,13,'LBL_TICKET_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (26,13,'',2,1,0,0,0,0)",
+				"insert into vtiger_blocks values (27,13,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0)",
+				"insert into vtiger_blocks values (28,13,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)",
+				"insert into vtiger_blocks values (29,13,'LBL_TICKET_RESOLUTION',5,0,0,1,0,0)",
+				"insert into vtiger_blocks values (30,13,'LBL_COMMENTS',6,0,0,1,0,0)",
+				"insert into vtiger_blocks values (31,14,'LBL_PRODUCT_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (32,14,'LBL_PRICING_INFORMATION',2,0,0,0,0,0)",
+				"insert into vtiger_blocks values (33,14,'LBL_STOCK_INFORMATION',3,0,0,0,0,0)",
+				"insert into vtiger_blocks values (34,14,'LBL_CUSTOM_INFORMATION',4,0,0,0,0,0)",
+				"insert into vtiger_blocks values (35,14,'LBL_IMAGE_INFORMATION',5,0,0,0,0,0)",
+				"insert into vtiger_blocks values (36,14,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)",
+				"insert into vtiger_blocks values (37,15,'LBL_FAQ_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (38,15,'',2,1,0,0,0,0)",
+				"insert into vtiger_blocks values (39,15,'',3,1,0,0,0,0)",
+				"insert into vtiger_blocks values (40,15,'LBL_COMMENT_INFORMATION',4,0,0,1,0,0)",
+				"insert into vtiger_blocks values (41,16,'LBL_EVENT_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (42,16,'',2,1,0,0,0,0)",
+				"insert into vtiger_blocks values (43,16,'',3,1,0,0,0,0)",
+				"insert into vtiger_blocks values (44,18,'LBL_VENDOR_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (45,18,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
+				"insert into vtiger_blocks values (46,18,'LBL_VENDOR_ADDRESS_INFORMATION',3,0,0,0,0,0)",
+				"insert into vtiger_blocks values (47,18,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)",
+				"insert into vtiger_blocks values (48,19,'LBL_PRICEBOOK_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (49,19,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
+				"insert into vtiger_blocks values (50,19,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)",
+				"insert into vtiger_blocks values (51,20,'LBL_QUOTE_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (52,20,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
+				"insert into vtiger_blocks values (53,20,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)",
+				"insert into vtiger_blocks values (54,20,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)",
+				"insert into vtiger_blocks values (55,20,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)",
+				"insert into vtiger_blocks values (56,20,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)",
+				"insert into vtiger_blocks values (57,21,'LBL_PO_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (58,21,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
+				"insert into vtiger_blocks values (59,21,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)",
+				"insert into vtiger_blocks values (60,21,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)",
+				"insert into vtiger_blocks values (61,21,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)",
+				"insert into vtiger_blocks values (62,21,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)",
+				"insert into vtiger_blocks values (63,22,'LBL_SO_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (64,22,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
+				"insert into vtiger_blocks values (65,22,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)",
+				"insert into vtiger_blocks values (66,22,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)",
+				"insert into vtiger_blocks values (67,22,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)",
+				"insert into vtiger_blocks values (68,22,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)",
+				"insert into vtiger_blocks values (69,23,'LBL_INVOICE_INFORMATION',1,0,0,0,0,0)",
+				"insert into vtiger_blocks values (70,23,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)",
+				"insert into vtiger_blocks values (71,23,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)",
+				"insert into vtiger_blocks values (72,23,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)",
+				"insert into vtiger_blocks values (73,23,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)",
+				"insert into vtiger_blocks values (74,23,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)"
 			    );
 foreach($insert_query_array5 as $query)
 {
@@ -1148,117 +1148,117 @@
 }
 
 $update_query_array2 = Array(
-				"update tab set name='Vendors', tablabel='Vendors' where tabid=18",
-				"update tab set name='PriceBooks', tablabel='PriceBooks' where tabid=19",
-				"update tab set presence=0 where tabid in(18,19)",
-				"update relatedlists set label='PriceBooks' where tabid=14 and related_tabid=19"
+				"update vtiger_tab set name='Vendors', vtiger_tablabel='Vendors' where vtiger_tabid=18",
+				"update vtiger_tab set name='PriceBooks', vtiger_tablabel='PriceBooks' where vtiger_tabid=19",
+				"update vtiger_tab set presence=0 where vtiger_tabid in(18,19)",
+				"update vtiger_relatedlists set label='PriceBooks' where vtiger_tabid=14 and related_tabid=19"
 			    );
 foreach($update_query_array2 as $query)
 {
 	Execute($query);
 }
 
-$delete_query1 = "delete from actionmapping where actionname in ('SavePriceBook','SaveVendor','PriceBookEditView','VendorEditView','DeletePriceBook','DeleteVendor','PriceBookDetailView','VendorDetailView')";
+$delete_query1 = "delete from vtiger_actionmapping where actionname in ('SavePriceBook','SaveVendor','PriceBookEditView','VendorEditView','DeletePriceBook','DeleteVendor','PriceBookDetailView','VendorDetailView')";
 Execute($query);
 
 $insert_query_array6 = Array(
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'Leads')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'Accounts')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'Contacts')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'Potentials')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'HelpDesk')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'Quotes')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'Activities')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'Emails')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'Invoice')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'Notes')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'PriceBooks')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'Products')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'PurchaseOrder')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'Leads')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'Accounts')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'Contacts')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'Potentials')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'HelpDesk')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'Quotes')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'Activities')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'Emails')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'Invoice')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'Notes')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'PriceBooks')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'Products')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'PurchaseOrder')",
 				
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'SalesOrder')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'Vendors')",
-			"insert into customview values(".$conn->getUniqueID('customview').",'All',1,0,'Faq')"
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'SalesOrder')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'Vendors')",
+			"insert into vtiger_customview values(".$conn->getUniqueID('customview').",'All',1,0,'Faq')"
 			    );
 foreach($insert_query_array6 as $query)
 {
 	Execute($query);
 }
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='Leads'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='Leads'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array7 = Array(
-			"insert into cvcolumnlist values ($cvid,0,'leaddetails:lastname:lastname:Leads_Last_Name:V')",
-			"insert into cvcolumnlist values ($cvid,1,'leaddetails:firstname:firstname:Leads_First_Name:V')",
-			"insert into cvcolumnlist values ($cvid,2,'leaddetails:company:company:Leads_Company:V')",
-			"insert into cvcolumnlist values ($cvid,3,'leadaddress:phone:phone:Leads_Phone:V')",
-			"insert into cvcolumnlist values ($cvid,4,'leadsubdetails:website:website:Leads_Website:V')",
-			"insert into cvcolumnlist values ($cvid,5,'leaddetails:email:email:Leads_Email:V')",
-			"insert into cvcolumnlist values ($cvid,6,'crmentity:smownerid:assigned_user_id:Leads_Assigned_To:V')"
+			"insert into vtiger_cvcolumnlist values ($cvid,0,'leaddetails:lastname:lastname:Leads_Last_Name:V')",
+			"insert into vtiger_cvcolumnlist values ($cvid,1,'leaddetails:firstname:firstname:Leads_First_Name:V')",
+			"insert into vtiger_cvcolumnlist values ($cvid,2,'leaddetails:company:company:Leads_Company:V')",
+			"insert into vtiger_cvcolumnlist values ($cvid,3,'leadaddress:phone:phone:Leads_Phone:V')",
+			"insert into vtiger_cvcolumnlist values ($cvid,4,'leadsubdetails:website:website:Leads_Website:V')",
+			"insert into vtiger_cvcolumnlist values ($cvid,5,'leaddetails:email:email:Leads_Email:V')",
+			"insert into vtiger_cvcolumnlist values ($cvid,6,'crmentity:smownerid:assigned_user_id:Leads_Assigned_To:V')"
 			    );
 foreach($insert_query_array7 as $query)
 {
 	Execute($query);
 }
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='Accounts'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='Accounts'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array8 = Array(
-		"insert into cvcolumnlist values ($cvid,0,'account:accountname:accountname:Accounts_Account_Name:V')",
-		"insert into cvcolumnlist values ($cvid,1,'accountbillads:city:bill_city:Accounts_City:V')",
-		"insert into cvcolumnlist values ($cvid,2,'account:website:website:Accounts_Website:V')",
-		"insert into cvcolumnlist values ($cvid,3,'account:phone:phone:Accounts_Phone:V')",
-		"insert into cvcolumnlist values ($cvid,4,'crmentity:smownerid:assigned_user_id:Accounts_Assigned_To:V')"
+		"insert into vtiger_cvcolumnlist values ($cvid,0,'account:accountname:accountname:Accounts_Account_Name:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,1,'accountbillads:city:bill_city:Accounts_City:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,2,'account:website:website:Accounts_Website:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,3,'account:phone:phone:Accounts_Phone:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,4,'crmentity:smownerid:assigned_user_id:Accounts_Assigned_To:V')"
 			    );
 foreach($insert_query_array8 as $query)
 {
 	Execute($query);
 }
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='Contacts'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='Contacts'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array9 = Array(
-		"insert into cvcolumnlist values ($cvid,0,'contactdetails:firstname:firstname:Contacts_First_Name:V')",
-		"insert into cvcolumnlist values ($cvid,1,'contactdetails:lastname:lastname:Contacts_Last_Name:V')",
-		"insert into cvcolumnlist values ($cvid,2,'contactdetails:title:title:Contacts_Title:V')",
-		"insert into cvcolumnlist values ($cvid,3,'account:accountname:accountname:Contacts_Account_Name:V')",
-		"insert into cvcolumnlist values ($cvid,4,'contactdetails:email:email:Contacts_Email:V')",
-		"insert into cvcolumnlist values ($cvid,5,'contactdetails:phone:phone:Contacts_Phone_Name:V')",
-		"insert into cvcolumnlist values ($cvid,6,'crmentity:smownerid:assigned_user_id:Contacts_Assigned_To:V')"
+		"insert into vtiger_cvcolumnlist values ($cvid,0,'contactdetails:firstname:firstname:Contacts_First_Name:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,1,'contactdetails:lastname:lastname:Contacts_Last_Name:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,2,'contactdetails:title:title:Contacts_Title:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,3,'account:accountname:accountname:Contacts_Account_Name:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,4,'contactdetails:email:email:Contacts_Email:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,5,'contactdetails:phone:phone:Contacts_Phone_Name:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,6,'crmentity:smownerid:assigned_user_id:Contacts_Assigned_To:V')"
 			    );
 foreach($insert_query_array9 as $query)
 {
 	Execute($query);
 }
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='Potentials'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='Potentials'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array10 = Array(
-	"insert into cvcolumnlist values ($cvid,0,'potential:potentialname:potentialname:Potentials_Potential_Name:V')",
-	"insert into cvcolumnlist values ($cvid,1,'potential:accountid:account_id:Potentials_Account_Name:V')",
-	"insert into cvcolumnlist values ($cvid,2,'potential:amount:amount:Potentials_Amount:N')",
-	"insert into cvcolumnlist values ($cvid,3,'potential:closingdate:closingdate:Potentials_Expected_Close_Date:D')",
-	"insert into cvcolumnlist values ($cvid,4,'crmentity:smownerid:assigned_user_id:Potentials_Assigned_To:V')"
+	"insert into vtiger_cvcolumnlist values ($cvid,0,'potential:potentialname:potentialname:Potentials_Potential_Name:V')",
+	"insert into vtiger_cvcolumnlist values ($cvid,1,'potential:accountid:account_id:Potentials_Account_Name:V')",
+	"insert into vtiger_cvcolumnlist values ($cvid,2,'potential:amount:amount:Potentials_Amount:N')",
+	"insert into vtiger_cvcolumnlist values ($cvid,3,'potential:closingdate:closingdate:Potentials_Expected_Close_Date:D')",
+	"insert into vtiger_cvcolumnlist values ($cvid,4,'crmentity:smownerid:assigned_user_id:Potentials_Assigned_To:V')"
 			     );
 foreach($insert_query_array10 as $query)
 {
 	Execute($query);
 }
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='HelpDesk'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='HelpDesk'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array11 = Array(
-		"insert into cvcolumnlist values ($cvid,0,'crmentity:crmid::HelpDesk_Ticket_ID:I')",
-		"insert into cvcolumnlist values ($cvid,1,'troubletickets:title:ticket_title:HelpDesk_Title:V')",
-		"insert into cvcolumnlist values ($cvid,2,'troubletickets:parent_id:parent_id:HelpDesk_Related_to:I')",
-		"insert into cvcolumnlist values ($cvid,3,'troubletickets:status:ticketstatus:HelpDesk_Status:V')",
-		"insert into cvcolumnlist values ($cvid,4,'troubletickets:priority:ticketpriorities:HelpDesk_Priority:V')",
-		"insert into cvcolumnlist values ($cvid,5,'crmentity:smownerid:assigned_user_id:HelpDesk_Assigned_To:V')"
+		"insert into vtiger_cvcolumnlist values ($cvid,0,'crmentity:crmid::HelpDesk_Ticket_ID:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,1,'troubletickets:title:ticket_title:HelpDesk_Title:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,2,'troubletickets:parent_id:parent_id:HelpDesk_Related_to:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,3,'troubletickets:status:ticketstatus:HelpDesk_Status:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,4,'troubletickets:priority:ticketpriorities:HelpDesk_Priority:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,5,'crmentity:smownerid:assigned_user_id:HelpDesk_Assigned_To:V')"
 			     );
 foreach($insert_query_array11 as $query)
 {
@@ -1266,35 +1266,35 @@
 }
 
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='Quotes'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='Quotes'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array12 = Array(
-		"insert into cvcolumnlist values ($cvid,0,'crmentity:crmid::Quotes_Quote_ID:I')",
-		"insert into cvcolumnlist values ($cvid,1,'quotes:subject:subject:Quotes_Subject:V')",
-		"insert into cvcolumnlist values ($cvid,2,'quotes:quotestage:quotestage:Quotes_Quote_Stage:V')",
-		"insert into cvcolumnlist values ($cvid,3,'quotes:potentialid:potential_id:Quotes_Potential_Name:I')",
-		"insert into cvcolumnlist values ($cvid,4,'quotes:accountid:account_id:Quotes_Account_Name:I')",
-		"insert into cvcolumnlist values ($cvid,5,'quotes:total:hdnGrandTotal:Quotes_Total:I')",
-		"insert into cvcolumnlist values ($cvid,6,'crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V')"
+		"insert into vtiger_cvcolumnlist values ($cvid,0,'crmentity:crmid::Quotes_Quote_ID:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,1,'quotes:subject:subject:Quotes_Subject:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,2,'quotes:quotestage:quotestage:Quotes_Quote_Stage:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,3,'quotes:potentialid:potential_id:Quotes_Potential_Name:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,4,'quotes:accountid:account_id:Quotes_Account_Name:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,5,'quotes:total:hdnGrandTotal:Quotes_Total:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,6,'crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V')"
 			     );
 foreach($insert_query_array12 as $query)
 {
 	Execute($query);
 }
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='Activities'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='Activities'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array13 = Array(
-		"insert into cvcolumnlist values ($cvid,0,'activity:status:taskstatus:Activities_Status:V')",
-		"insert into cvcolumnlist values ($cvid,1,'activity:activitytype:activitytype:Activities_Type:V')",
-		"insert into cvcolumnlist values ($cvid,2,'activity:subject:subject:Activities_Subject:V')",
-		"insert into cvcolumnlist values ($cvid,3,'contactdetails:lastname:lastname:Activities_Contact_Name:V')",
-		"insert into cvcolumnlist values ($cvid,4,'seactivityrel:crmid:parent_id:Activities_Related_To:V')",
-		"insert into cvcolumnlist values ($cvid,5,'activity:date_start:date_start:Activities_Start_Date:D')",
-		"insert into cvcolumnlist values ($cvid,6,'activity:due_date:due_date:Activities_End_Date:D')",
-		"insert into cvcolumnlist values ($cvid,7,'crmentity:smownerid:assigned_user_id:Activities_Assigned_To:V')"
+		"insert into vtiger_cvcolumnlist values ($cvid,0,'activity:status:taskstatus:Activities_Status:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,1,'activity:activitytype:activitytype:Activities_Type:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,2,'activity:subject:subject:Activities_Subject:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,3,'contactdetails:lastname:lastname:Activities_Contact_Name:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,4,'seactivityrel:crmid:parent_id:Activities_Related_To:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,5,'activity:date_start:date_start:Activities_Start_Date:D')",
+		"insert into vtiger_cvcolumnlist values ($cvid,6,'activity:due_date:due_date:Activities_End_Date:D')",
+		"insert into vtiger_cvcolumnlist values ($cvid,7,'crmentity:smownerid:assigned_user_id:Activities_Assigned_To:V')"
 			     );
 foreach($insert_query_array13 as $query)
 {
@@ -1302,30 +1302,30 @@
 }
 
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='Emails'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='Emails'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array14 = Array(
-		"insert into cvcolumnlist values ($cvid,0,'activity:subject:subject:Emails_Subject:V')",
-		"insert into cvcolumnlist values ($cvid,1,'seactivityrel:crmid:parent_id:Emails_Related_To:I')",
-		"insert into cvcolumnlist values ($cvid,2,'activity:date_start:date_start:Emails_Date_Sent:D')",
-		"insert into cvcolumnlist values ($cvid,3,'crmentity:smownerid:assigned_user_id:Emails_Assigned_To:V')"
+		"insert into vtiger_cvcolumnlist values ($cvid,0,'activity:subject:subject:Emails_Subject:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,1,'seactivityrel:crmid:parent_id:Emails_Related_To:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,2,'activity:date_start:date_start:Emails_Date_Sent:D')",
+		"insert into vtiger_cvcolumnlist values ($cvid,3,'crmentity:smownerid:assigned_user_id:Emails_Assigned_To:V')"
 			     );
 foreach($insert_query_array14 as $query)
 {
 	Execute($query);
 }
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='Invoice'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='Invoice'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array15 = Array(
-		"insert into cvcolumnlist values ($cvid,0,'crmentity:crmid::Invoice_Invoice_Id:I')",
-		"insert into cvcolumnlist values ($cvid,1,'invoice:subject:subject:Invoice_Subject:V')",
-		"insert into cvcolumnlist values ($cvid,2,'invoice:salesorderid:salesorder_id:Invoice_Sales_Order:V')",
-		"insert into cvcolumnlist values ($cvid,3,'invoice:invoicestatus:invoicestatus:Invoice_Status:V')",
-		"insert into cvcolumnlist values ($cvid,4,'invoice:total:hdnGrandTotal:Invoice_Total:I')",
-		"insert into cvcolumnlist values ($cvid,5,'crmentity:smownerid:assigned_user_id:Invoice_Assigned_To:V')"
+		"insert into vtiger_cvcolumnlist values ($cvid,0,'crmentity:crmid::Invoice_Invoice_Id:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,1,'invoice:subject:subject:Invoice_Subject:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,2,'invoice:salesorderid:salesorder_id:Invoice_Sales_Order:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,3,'invoice:invoicestatus:invoicestatus:Invoice_Status:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,4,'invoice:total:hdnGrandTotal:Invoice_Total:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,5,'crmentity:smownerid:assigned_user_id:Invoice_Assigned_To:V')"
 			     );
 foreach($insert_query_array15 as $query)
 {
@@ -1333,27 +1333,27 @@
 }
 
 	     
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='Notes'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='Notes'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array16 = Array(
-		"insert into cvcolumnlist values ($cvid,0,'notes:title:title:Notes_Title:V')",
-		"insert into cvcolumnlist values ($cvid,1,'notes:contact_id:contact_id:Notes_Contact_Name:I')",
-		"insert into cvcolumnlist values ($cvid,2,'senotesrel:crmid:crmid:Notes_Related_To:I')",
-		"insert into cvcolumnlist values ($cvid,3,'notes:filename:filename:Notes_File:V')",
-		"insert into cvcolumnlist values ($cvid,4,'crmentity:modifiedtime:modifiedtime:Notes_Modified_Time:V')"
+		"insert into vtiger_cvcolumnlist values ($cvid,0,'notes:title:title:Notes_Title:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,1,'notes:contact_id:contact_id:Notes_Contact_Name:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,2,'senotesrel:crmid:crmid:Notes_Related_To:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,3,'notes:filename:filename:Notes_File:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,4,'crmentity:modifiedtime:modifiedtime:Notes_Modified_Time:V')"
 			     );
 foreach($insert_query_array16 as $query)
 {
 	Execute($query);
 }
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='PriceBooks'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='PriceBooks'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array17 = Array(
-		"insert into cvcolumnlist values ($cvid,1,'pricebook:bookname:bookname:PriceBooks_Price_Book_Name:V')",
-		"insert into cvcolumnlist values ($cvid,2,'pricebook:active:active:PriceBooks_Active:V')"
+		"insert into vtiger_cvcolumnlist values ($cvid,1,'pricebook:bookname:bookname:PriceBooks_Price_Book_Name:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,2,'pricebook:active:active:PriceBooks_Active:V')"
 			     );
 foreach($insert_query_array17 as $query)
 {
@@ -1361,76 +1361,76 @@
 }
 
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='Products'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='Products'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array18 = Array(
-	"insert into cvcolumnlist values ($cvid,0,'products:productname:productname:Products_Product_Name:V')",
-	"insert into cvcolumnlist values ($cvid,1,'products:productcode:productcode:Products_Product_Code:V')",
-	"insert into cvcolumnlist values ($cvid,2,'products:commissionrate:commissionrate:Products_Commission_Rate:V')",
-	"insert into cvcolumnlist values ($cvid,3,'products:qty_per_unit:qty_per_unit:Products_Qty/Unit:V')",
-	"insert into cvcolumnlist values ($cvid,4,'products:unit_price:unit_price:Products_Unit_Price:V')"
+	"insert into vtiger_cvcolumnlist values ($cvid,0,'products:productname:productname:Products_Product_Name:V')",
+	"insert into vtiger_cvcolumnlist values ($cvid,1,'products:productcode:productcode:Products_Product_Code:V')",
+	"insert into vtiger_cvcolumnlist values ($cvid,2,'products:commissionrate:commissionrate:Products_Commission_Rate:V')",
+	"insert into vtiger_cvcolumnlist values ($cvid,3,'products:qty_per_unit:qty_per_unit:Products_Qty/Unit:V')",
+	"insert into vtiger_cvcolumnlist values ($cvid,4,'products:unit_price:unit_price:Products_Unit_Price:V')"
 			     );
 foreach($insert_query_array18 as $query)
 {
 	Execute($query);
 }
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='PurchaseOrder'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='PurchaseOrder'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array19 = Array(
-	"insert into cvcolumnlist values($cvid,0,'crmentity:crmid::PurchaseOrder_Order_Id:I')",
-	"insert into cvcolumnlist values($cvid,1,'purchaseorder:subject:subject:PurchaseOrder_Subject:V')",
-	"insert into cvcolumnlist values($cvid,2,'purchaseorder:vendorid:vendor_id:PurchaseOrder_Vendor_Name:I')",
-	"insert into cvcolumnlist values($cvid,3,'purchaseorder:tracking_no:tracking_no:PurchaseOrder_Tracking_Number:V')",
-	"insert into cvcolumnlist values($cvid,4,'crmentity:smownerid:assigned_user_id:PurchaseOrder_Assigned_To:V')"
+	"insert into vtiger_cvcolumnlist values($cvid,0,'crmentity:crmid::PurchaseOrder_Order_Id:I')",
+	"insert into vtiger_cvcolumnlist values($cvid,1,'purchaseorder:subject:subject:PurchaseOrder_Subject:V')",
+	"insert into vtiger_cvcolumnlist values($cvid,2,'purchaseorder:vendorid:vendor_id:PurchaseOrder_Vendor_Name:I')",
+	"insert into vtiger_cvcolumnlist values($cvid,3,'purchaseorder:tracking_no:tracking_no:PurchaseOrder_Tracking_Number:V')",
+	"insert into vtiger_cvcolumnlist values($cvid,4,'crmentity:smownerid:assigned_user_id:PurchaseOrder_Assigned_To:V')"
 			     );
 foreach($insert_query_array19 as $query)
 {
 	Execute($query);
 }
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='SalesOrder'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='SalesOrder'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array20 = Array(
-		"insert into cvcolumnlist values ($cvid,0,'crmentity:crmid::SalesOrder_Order_Id:I')",
-		"insert into cvcolumnlist values ($cvid,1,'salesorder:subject:subject:SalesOrder_Subject:V')",
-		"insert into cvcolumnlist values ($cvid,2,'account:accountid:account_id:SalesOrder_Account_Name:V')",
-		"insert into cvcolumnlist values ($cvid,3,'quotes:quoteid:quote_id:SalesOrder_Quote_Name:I')",
-		"insert into cvcolumnlist values ($cvid,4,'salesorder:total:hdnGrandTotal:SalesOrder_Total:V')",
-		"insert into cvcolumnlist values ($cvid,5,'crmentity:smownerid:assigned_user_id:SalesOrder_Assigned_To:V')"
+		"insert into vtiger_cvcolumnlist values ($cvid,0,'crmentity:crmid::SalesOrder_Order_Id:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,1,'salesorder:subject:subject:SalesOrder_Subject:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,2,'account:accountid:account_id:SalesOrder_Account_Name:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,3,'quotes:quoteid:quote_id:SalesOrder_Quote_Name:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,4,'salesorder:total:hdnGrandTotal:SalesOrder_Total:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,5,'crmentity:smownerid:assigned_user_id:SalesOrder_Assigned_To:V')"
 			     );
 foreach($insert_query_array20 as $query)
 {
 	Execute($query);
 }
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='Vendors'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='Vendors'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array21 = Array(
-			"insert into cvcolumnlist values ($cvid,0,'vendor:vendorname:vendorname:Vendors_Vendor_Name:V')",
-			"insert into cvcolumnlist values ($cvid,1,'vendor:phone:phone:Vendors_Phone:V')",
-			"insert into cvcolumnlist values ($cvid,2,'vendor:email:email:Vendors_Email:V')",
-			"insert into cvcolumnlist values ($cvid,3,'vendor:category:category:Vendors_Category:V')"
+			"insert into vtiger_cvcolumnlist values ($cvid,0,'vendor:vendorname:vendorname:Vendors_Vendor_Name:V')",
+			"insert into vtiger_cvcolumnlist values ($cvid,1,'vendor:phone:phone:Vendors_Phone:V')",
+			"insert into vtiger_cvcolumnlist values ($cvid,2,'vendor:email:email:Vendors_Email:V')",
+			"insert into vtiger_cvcolumnlist values ($cvid,3,'vendor:category:category:Vendors_Category:V')"
 			     );
 foreach($insert_query_array21 as $query)
 {
 	Execute($query);
 }
 
-$res=$conn->query("select cvid from customview where viewname='All' and entitytype='Faq'");
+$res=$conn->query("select cvid from vtiger_customview where viewname='All' and entitytype='Faq'");
 $cvid = $conn->query_result($res,0,"cvid");
 
 $insert_query_array22 = Array(
-		"insert into cvcolumnlist values ($cvid,0,'faq:id::Faq_FAQ_Id:I')",
-		"insert into cvcolumnlist values ($cvid,1,'faq:question:question:Faq_Question:V')",
-		"insert into cvcolumnlist values ($cvid,2,'faq:category:faqcategories:Faq_Category:V')",
-		"insert into cvcolumnlist values ($cvid,3,'faq:product_id:product_id:Faq_Product_Name:I')",
-		"insert into cvcolumnlist values ($cvid,4,'crmentity:createdtime:createdtime:Faq_Created_Time:D')",
-		"insert into cvcolumnlist values ($cvid,5,'crmentity:modifiedtime:modifiedtime:Faq_Modified_Time:D')"
+		"insert into vtiger_cvcolumnlist values ($cvid,0,'faq:id::Faq_FAQ_Id:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,1,'faq:question:question:Faq_Question:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,2,'faq:category:faqcategories:Faq_Category:V')",
+		"insert into vtiger_cvcolumnlist values ($cvid,3,'faq:product_id:product_id:Faq_Product_Name:I')",
+		"insert into vtiger_cvcolumnlist values ($cvid,4,'crmentity:createdtime:createdtime:Faq_Created_Time:D')",
+		"insert into vtiger_cvcolumnlist values ($cvid,5,'crmentity:modifiedtime:modifiedtime:Faq_Modified_Time:D')"
 			     );
 foreach($insert_query_array22 as $query)
 {
@@ -1439,35 +1439,35 @@
 
 
 $update_query_array3 = Array(
-				"update field set uitype=53 where tabid=2 and columnname='smownerid'",
-				"update field set uitype=53 where tabid=4 and columnname='smownerid'",
-				"update field set uitype=53 where tabid=20 and columnname='smownerid'",
-				"update field set uitype=53 where tabid=22 and columnname='smownerid'",
-				"update field set uitype=53 where tabid=23 and columnname='smownerid'"
+				"update vtiger_field set uitype=53 where vtiger_tabid=2 and columnname='smownerid'",
+				"update vtiger_field set uitype=53 where vtiger_tabid=4 and columnname='smownerid'",
+				"update vtiger_field set uitype=53 where vtiger_tabid=20 and columnname='smownerid'",
+				"update vtiger_field set uitype=53 where vtiger_tabid=22 and columnname='smownerid'",
+				"update vtiger_field set uitype=53 where vtiger_tabid=23 and columnname='smownerid'"
 			    );
 foreach($update_query_array3 as $query)
 {
 	Execute($query);
 }
 
-$create_query6 = "CREATE TABLE accountgrouprelation ( accountid int(19) NOT NULL default '0', groupname varchar(100) default NULL, PRIMARY KEY  (`accountid`))";
+$create_query6 = "CREATE TABLE vtiger_accountgrouprelation ( vtiger_accountid int(19) NOT NULL default '0', groupname varchar(100) default NULL, PRIMARY KEY  (`accountid`))";
 Execute($create_query6);
 
 $alter_query_array8 = Array(
-				"alter table accountgrouprelation ADD CONSTRAINT fk_accountgrouprelation FOREIGN KEY (accountid) REFERENCES account(accountid) ON DELETE CASCADE",
-				"alter table accountgrouprelation ADD CONSTRAINT fk_accountgrouprelation2 FOREIGN KEY (groupname) REFERENCES groups(name) ON DELETE CASCADE"
+				"alter vtiger_table vtiger_accountgrouprelation ADD CONSTRAINT fk_accountgrouprelation FOREIGN KEY (accountid) REFERENCES vtiger_account(accountid) ON DELETE CASCADE",
+				"alter vtiger_table vtiger_accountgrouprelation ADD CONSTRAINT fk_accountgrouprelation2 FOREIGN KEY (groupname) REFERENCES vtiger_groups(name) ON DELETE CASCADE"
 			   );
 foreach($alter_query_array8 as $query)
 {
 	Execute($query);
 }
 
-$create_query7 = "CREATE TABLE contactgrouprelation ( contactid int(19) NOT NULL default '0', groupname varchar(100) default NULL, PRIMARY KEY  (`contactid`))";
+$create_query7 = "CREATE TABLE vtiger_contactgrouprelation ( contactid int(19) NOT NULL default '0', groupname varchar(100) default NULL, PRIMARY KEY  (`contactid`))";
 Execute($create_query7);
 
 $alter_query_array9 = Array(
-				"alter table contactgrouprelation ADD CONSTRAINT fk_contactgrouprelation FOREIGN KEY (contactid) REFERENCES contactdetails(contactid) ON DELETE CASCADE",
-				"alter table contactgrouprelation ADD CONSTRAINT fk_contactgrouprelation2 FOREIGN KEY (groupname) REFERENCES groups(name) ON DELETE CASCADE"
+				"alter vtiger_table vtiger_contactgrouprelation ADD CONSTRAINT fk_contactgrouprelation FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE",
+				"alter vtiger_table vtiger_contactgrouprelation ADD CONSTRAINT fk_contactgrouprelation2 FOREIGN KEY (groupname) REFERENCES vtiger_groups(name) ON DELETE CASCADE"
 			   );
 foreach($alter_query_array9 as $query)
 {
@@ -1475,81 +1475,81 @@
 }
 
 
-$create_query10 = "CREATE TABLE potentialgrouprelation ( potentialid int(19) NOT NULL default '0', groupname varchar(100) default NULL, PRIMARY KEY  (`potentialid`))";
+$create_query10 = "CREATE TABLE vtiger_potentialgrouprelation ( vtiger_potentialid int(19) NOT NULL default '0', groupname varchar(100) default NULL, PRIMARY KEY  (`potentialid`))";
 Execute($create_query10);
 
 $alter_query_array10 = Array(
-				"alter table potentialgrouprelation ADD CONSTRAINT fk_potentialgrouprelation FOREIGN KEY (potentialid) REFERENCES potential(potentialid) ON DELETE CASCADE",
-				"alter table potentialgrouprelation ADD CONSTRAINT fk_potentialgrouprelation2 FOREIGN KEY (groupname) REFERENCES groups(name) ON DELETE CASCADE"
+				"alter vtiger_table vtiger_potentialgrouprelation ADD CONSTRAINT fk_potentialgrouprelation FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE",
+				"alter vtiger_table vtiger_potentialgrouprelation ADD CONSTRAINT fk_potentialgrouprelation2 FOREIGN KEY (groupname) REFERENCES vtiger_groups(name) ON DELETE CASCADE"
 			    );
 foreach($alter_query_array10 as $query)
 {
 	Execute($query);
 }
 
-$create_query11 = "CREATE TABLE quotegrouprelation ( quoteid int(19) NOT NULL default '0', groupname varchar(100) default NULL, PRIMARY KEY  (`quoteid`) )";
+$create_query11 = "CREATE TABLE vtiger_quotegrouprelation ( quoteid int(19) NOT NULL default '0', groupname varchar(100) default NULL, PRIMARY KEY  (`quoteid`) )";
 Execute($create_query11);
 
 $alter_query_array11 = Array(
-				"alter table quotegrouprelation ADD CONSTRAINT fk_quotegrouprelation FOREIGN KEY (quoteid) REFERENCES quotes(quoteid) ON DELETE CASCADE",
-				"alter table quotegrouprelation ADD CONSTRAINT fk_quotegrouprelation2 FOREIGN KEY (groupname) REFERENCES groups(name) ON DELETE CASCADE"
+				"alter vtiger_table vtiger_quotegrouprelation ADD CONSTRAINT fk_quotegrouprelation FOREIGN KEY (quoteid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE",
+				"alter vtiger_table vtiger_quotegrouprelation ADD CONSTRAINT fk_quotegrouprelation2 FOREIGN KEY (groupname) REFERENCES vtiger_groups(name) ON DELETE CASCADE"
 			    );
 foreach($alter_query_array11 as $query)
 {
 	Execute($query);
 }
 
-$create_query12 = "CREATE TABLE sogrouprelation ( salesorderid int(19) NOT NULL default '0', groupname varchar(100) default NULL, PRIMARY KEY  (`salesorderid`) )";
+$create_query12 = "CREATE TABLE vtiger_sogrouprelation ( vtiger_salesorderid int(19) NOT NULL default '0', groupname varchar(100) default NULL, PRIMARY KEY  (`salesorderid`) )";
 Execute($create_query12);
 
 $alter_query_array12 = Array(
-				"alter table sogrouprelation ADD CONSTRAINT fk_sogrouprelation FOREIGN KEY (salesorderid) REFERENCES salesorder(salesorderid) ON DELETE CASCADE",
-				"alter table sogrouprelation ADD CONSTRAINT fk_sogrouprelation2 FOREIGN KEY (groupname) REFERENCES groups(name) ON DELETE CASCADE"
+				"alter vtiger_table vtiger_sogrouprelation ADD CONSTRAINT fk_sogrouprelation FOREIGN KEY (salesorderid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE",
+				"alter vtiger_table vtiger_sogrouprelation ADD CONSTRAINT fk_sogrouprelation2 FOREIGN KEY (groupname) REFERENCES vtiger_groups(name) ON DELETE CASCADE"
 			    );
 foreach($alter_query_array12 as $query)
 {
 	Execute($query);
 }
 
-$create_query13 = "CREATE TABLE invoicegrouprelation ( invoiceid int(19) NOT NULL default '0',  groupname varchar(100) default NULL,  PRIMARY KEY  (`invoiceid`))";
+$create_query13 = "CREATE TABLE vtiger_invoicegrouprelation ( vtiger_invoiceid int(19) NOT NULL default '0',  groupname varchar(100) default NULL,  PRIMARY KEY  (`invoiceid`))";
 Execute($create_query13);
 
 $alter_query_array13 = Array(
-				"alter table invoicegrouprelation ADD CONSTRAINT fk_invoicegrouprelation FOREIGN KEY (invoiceid) REFERENCES invoice(invoiceid) ON DELETE CASCADE",
-				"alter table invoicegrouprelation ADD CONSTRAINT fk_invoicegrouprelation2 FOREIGN KEY (groupname) REFERENCES groups(name) ON DELETE CASCADE"
+				"alter vtiger_table vtiger_invoicegrouprelation ADD CONSTRAINT fk_invoicegrouprelation FOREIGN KEY (invoiceid) REFERENCES vtiger_invoice(invoiceid) ON DELETE CASCADE",
+				"alter vtiger_table vtiger_invoicegrouprelation ADD CONSTRAINT fk_invoicegrouprelation2 FOREIGN KEY (groupname) REFERENCES vtiger_groups(name) ON DELETE CASCADE"
 			    );
 foreach($alter_query_array13 as $query)
 {
 	Execute($query);
 }
 
-$create_query14 = "CREATE TABLE pogrouprelation ( purchaseorderid int(19) NOT NULL default '0', groupname varchar(100) default NULL, PRIMARY KEY  (`purchaseorderid`))";
+$create_query14 = "CREATE TABLE vtiger_pogrouprelation ( vtiger_purchaseorderid int(19) NOT NULL default '0', groupname varchar(100) default NULL, PRIMARY KEY  (`purchaseorderid`))";
 Execute($create_query14);
 
 $alter_query_array14 = Array(
-				"alter table pogrouprelation ADD CONSTRAINT fk_pogrouprelation FOREIGN KEY (purchaseorderid) REFERENCES purchaseorder(purchaseorderid) ON DELETE CASCADE",
-				"alter table pogrouprelation ADD CONSTRAINT fk_productgrouprelation2 FOREIGN KEY (groupname) REFERENCES groups(name) ON DELETE CASCADE"
+				"alter vtiger_table vtiger_pogrouprelation ADD CONSTRAINT fk_pogrouprelation FOREIGN KEY (purchaseorderid) REFERENCES vtiger_purchaseorder(purchaseorderid) ON DELETE CASCADE",
+				"alter vtiger_table vtiger_pogrouprelation ADD CONSTRAINT fk_productgrouprelation2 FOREIGN KEY (groupname) REFERENCES vtiger_groups(name) ON DELETE CASCADE"
 			    );
 foreach($alter_query_array14 as $query)
 {
 	Execute($query);
 }
 
-$alter_query1 = "ALTER TABLE users ADD column lead_view VARCHAR(25) DEFAULT 'Today' AFTER homeorder";
+$alter_query1 = "ALTER TABLE vtiger_users ADD column lead_view VARCHAR(25) DEFAULT 'Today' AFTER homeorder";
 Execute($alter_query1);
 
-$update_query1 = "update users set homeorder = 'ALVT,PLVT,QLTQ,CVLVT,HLT,OLV,GRT,OLTSO,ILTI,MNL'";
+$update_query1 = "update vtiger_users set homeorder = 'ALVT,PLVT,QLTQ,CVLVT,HLT,OLV,GRT,OLTSO,ILTI,MNL'";
 Execute($update_query1);
 
-$alter_query2 = "ALTER TABLE products change column imagename imagename text";
+$alter_query2 = "ALTER TABLE vtiger_products change column imagename imagename text";
 Execute($alter_query2);
 
-$alter_query3 = "alter table systems modify server varchar(50), modify server_username varchar(50), modify server_password varchar(50), add column smtp_auth char(5)";
+$alter_query3 = "alter vtiger_table vtiger_systems modify server varchar(50), modify server_username varchar(50), modify server_password varchar(50), add column smtp_auth char(5)";
 Execute($alter_query3);
 
 $alter_query_array15 = Array( 
-				"alter table users add column imagename varchar(250)",
-				"alter table users add column tagcloud varchar(250)"
+				"alter vtiger_table vtiger_users add column imagename varchar(250)",
+				"alter vtiger_table vtiger_users add column tagcloud varchar(250)"
 			    );
 foreach($alter_query_array15 as $query)
 {
@@ -1557,8 +1557,8 @@
 }
 
 $alter_query_array16 = Array(
-			"alter table systems change column server server varchar(80) default NULL",
-			"alter table systems change column server_username server_username varchar(80) default NULL"
+			"alter vtiger_table vtiger_systems change column server server varchar(80) default NULL",
+			"alter vtiger_table vtiger_systems change column server_username server_username varchar(80) default NULL"
 			    );
 foreach($alter_query_array16 as $query)
 {
@@ -1566,71 +1566,71 @@
 }
 
 
-$create_query15 = "create table portal(portalid int(19), portalname varchar(255) NOT NULL, portalurl varchar(255) NOT NULL,sequence int(3) NOT NULL, PRIMARY KEY (portalid))";
+$create_query15 = "create vtiger_table vtiger_portal(portalid int(19), vtiger_portalname varchar(255) NOT NULL, vtiger_portalurl varchar(255) NOT NULL,sequence int(3) NOT NULL, PRIMARY KEY (portalid))";
 Execute($create_query15);
 
 $alter_query_array = Array( 
-				"alter table attachments drop column attachmentsize",
-				"alter table attachments drop column attachmentcontents"
+				"alter vtiger_table vtiger_attachments drop column vtiger_attachmentsize",
+				"alter vtiger_table vtiger_attachments drop column attachmentcontents"
 			    );
 foreach($alter_query_array as $query)
 {
 	Execute($query);
 }
 
-$alter_query = "ALTER TABLE field ADD column info_type varchar(20) default NULL after quickcreatesequence";
+$alter_query = "ALTER TABLE vtiger_field ADD column info_type varchar(20) default NULL after quickcreatesequence";
 Execute($alter_query);
 
-//$update_query2 = "UPDATE field SET fieldlabel = 'Reference' WHERE tabid = 4 and tablename = 'contactdetails' and fieldname='reference'";
-//changed in 24-04-06 because the reference has not been entered into the field table. 
-$update_query2 = "insert into field values (4,".$conn->getUniqueID("field").",'reference','contactdetails',1,'56','reference','Reference',1,0,0,10,23,4,1,'C~O',1,null,'ADV')";
+//$update_query2 = "UPDATE vtiger_field SET vtiger_fieldlabel = 'Reference' WHERE vtiger_tabid = 4 and vtiger_tablename = 'contactdetails' and vtiger_fieldname='reference'";
+//changed in 24-04-06 because the reference has not been entered into the vtiger_field vtiger_table. 
+$update_query2 = "insert into vtiger_field values (4,".$conn->getUniqueID("field").",'reference','contactdetails',1,'56','reference','Reference',1,0,0,10,23,4,1,'C~O',1,null,'ADV')";
 Execute($update_query2);
 
 $update_query_array4 = Array(
-				"UPDATE field SET info_type = 'BAS'",
-
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 7 and fieldlabel = 'Website'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 7 and fieldlabel = 'Industry'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 7 and fieldlabel = 'Annual Revenue'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 7 and fieldlabel = 'No Of Employees'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 7 and fieldlabel = 'Yahoo Id'",
-
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 6 and fieldlabel = 'Ticker Symbol'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 6 and fieldlabel = 'Other Phone'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 6 and fieldlabel = 'Member Of'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 6 and fieldlabel = 'Employees'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 6 and fieldlabel = 'Other Email'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 6 and fieldlabel = 'Ownership'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 6 and fieldlabel = 'Rating'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 6 and fieldlabel = 'industry'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 6 and fieldlabel = 'SIC Code'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 6 and fieldlabel = 'Type'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 6 and fieldlabel = 'Annual Revenue'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 6 and fieldlabel = 'Email Opt Out'",
-
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Home Phone'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Department'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Birthdate'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Email'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Reports To'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Assistant'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Yahoo Id'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Assistant Phone'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Do Not Call'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Email Opt Out'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Reference'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Portal User'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Support Start Date'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Support End Date'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 4 and fieldlabel = 'Contact Image'",
-
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 14 and fieldlabel = 'Usage Unit'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 14 and fieldlabel = 'Qty/Unit'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 14 and fieldlabel = 'Qty In Stock'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 14 and fieldlabel = 'Reorder Level'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 14 and fieldlabel = 'Handler'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 14 and fieldlabel = 'Qty In Demand'",
-				"UPDATE field SET info_type = 'ADV' WHERE tabid = 14 and fieldlabel = 'Product Image'"
+				"UPDATE vtiger_field SET info_type = 'BAS'",
+
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 7 and vtiger_fieldlabel = 'Website'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 7 and vtiger_fieldlabel = 'Industry'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 7 and vtiger_fieldlabel = 'Annual Revenue'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 7 and vtiger_fieldlabel = 'No Of Employees'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 7 and vtiger_fieldlabel = 'Yahoo Id'",
+
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Ticker Symbol'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Other Phone'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Member Of'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Employees'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Other Email'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Ownership'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Rating'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'industry'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'SIC Code'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Type'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Annual Revenue'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 6 and vtiger_fieldlabel = 'Email Opt Out'",
+
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Home Phone'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Department'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Birthdate'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Email'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Reports To'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Assistant'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Yahoo Id'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Assistant Phone'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Do Not Call'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Email Opt Out'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Reference'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Portal User'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Support Start Date'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Support End Date'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 4 and vtiger_fieldlabel = 'Contact Image'",
+
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 14 and vtiger_fieldlabel = 'Usage Unit'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 14 and vtiger_fieldlabel = 'Qty/Unit'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 14 and vtiger_fieldlabel = 'Qty In Stock'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 14 and vtiger_fieldlabel = 'Reorder Level'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 14 and vtiger_fieldlabel = 'Handler'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 14 and vtiger_fieldlabel = 'Qty In Demand'",
+				"UPDATE vtiger_field SET info_type = 'ADV' WHERE vtiger_tabid = 14 and vtiger_fieldlabel = 'Product Image'"
 			    );
 foreach($update_query_array4 as $query)
 {
@@ -1661,35 +1661,35 @@
 	Execute($query);
 }
 
-$create_query20 = "CREATE TABLE freetags ( id int(19) NOT NULL, tag varchar(50) NOT NULL default '', raw_tag varchar(50) NOT NULL default '', PRIMARY KEY  (id)) TYPE=MyISAM";
+$create_query20 = "CREATE TABLE vtiger_freetags ( id int(19) NOT NULL, tag varchar(50) NOT NULL default '', raw_tag varchar(50) NOT NULL default '', PRIMARY KEY  (id)) TYPE=MyISAM";
 Execute($create_query20);
 
-$create_query21 = "CREATE TABLE freetagged_objects ( tag_id int(19) NOT NULL default '0', tagger_id int(19) NOT NULL default '0', object_id int(19) NOT NULL default '0', tagged_on datetime NOT NULL default '0000-00-00 00:00:00', module varchar(50) NOT NULL default '', PRIMARY KEY  (`tag_id`,`tagger_id`,`object_id`), KEY `tag_id_index` (`tag_id`), KEY `tagger_id_index` (`tagger_id`),  KEY `object_id_index` (`object_id`)
+$create_query21 = "CREATE TABLE vtiger_freetagged_objects ( tag_id int(19) NOT NULL default '0', tagger_id int(19) NOT NULL default '0', object_id int(19) NOT NULL default '0', tagged_on datetime NOT NULL default '0000-00-00 00:00:00', module varchar(50) NOT NULL default '', PRIMARY KEY  (`tag_id`,`tagger_id`,`object_id`), KEY `tag_id_index` (`tag_id`), KEY `tagger_id_index` (`tagger_id`),  KEY `object_id_index` (`object_id`)
 ) TYPE=MyISAM";
 Execute($create_query21);
   
-$alter_query4 = "alter table profile add column description text";
+$alter_query4 = "alter vtiger_table vtiger_profile add column description text";
 Execute($alter_query4);
 
-$alter_query5 = "alter table contactdetails add column imagename varchar(250) after currency";
+$alter_query5 = "alter vtiger_table vtiger_contactdetails add column imagename varchar(250) after vtiger_currency";
 Execute($alter_query5);
 
-$alter_query = "ALTER TABLE contactdetails ADD column reference varchar(3) default NULL after imagename";
+$alter_query = "ALTER TABLE vtiger_contactdetails ADD column reference varchar(3) default NULL after imagename";
 Execute($alter_query);
 
 $insert_query_array23 = Array(
-				"insert into blocks values(75,4,'LBL_IMAGE_INFORMATION',5,0,0,0,0,0)",
-				"insert into field values(4,".$conn->getUniqueID("field").",'imagename','contactdetails',1,'69','imagename','Contact Image',1,0,0,100,1,75,1,'V~O',1,null,'ADV')",
-
-				"Insert into field values(9,".$conn->getUniqueID("field").",'visibility','activity',1,15,'visibility','Visibility',1,0,0,100,17,19,3,'V~O',1,null,'BAS')",
-				"Insert into field values(16,".$conn->getUniqueID("field").",'visibility','activity',1,15,'visibility','Visibility',1,0,0,100,19,41,1,'V~O',1,null,'BAS')"
+				"insert into vtiger_blocks values(75,4,'LBL_IMAGE_INFORMATION',5,0,0,0,0,0)",
+				"insert into vtiger_field values(4,".$conn->getUniqueID("field").",'imagename','contactdetails',1,'69','imagename','Contact Image',1,0,0,100,1,75,1,'V~O',1,null,'ADV')",
+
+				"Insert into vtiger_field values(9,".$conn->getUniqueID("field").",'visibility','activity',1,15,'visibility','Visibility',1,0,0,100,17,19,3,'V~O',1,null,'BAS')",
+				"Insert into vtiger_field values(16,".$conn->getUniqueID("field").",'visibility','activity',1,15,'visibility','Visibility',1,0,0,100,19,41,1,'V~O',1,null,'BAS')"
 			     );
 foreach($insert_query_array23 as $query)
 {
 	Execute($query);
 }
 
-$alter_query6 = "alter table activity add column visibility varchar(50) NOT NULL after notime";
+$alter_query6 = "alter vtiger_table vtiger_activity add column vtiger_visibility varchar(50) NOT NULL after notime";
 Execute($alter_query6);
 
 $create_query22 = "CREATE TABLE `visibility` ( `visibilityid` int(19) NOT NULL auto_increment, `visibility` varchar(200) NOT NULL default '', `sortorderid` int(19) NOT NULL default '0', `presence` int(1) NOT NULL default '1', PRIMARY KEY  (`visibilityid`), UNIQUE KEY `Visibility_VLY` (`visibility`)) ENGINE=InnoDB";
@@ -1699,42 +1699,42 @@
 $create_query23 = "CREATE TABLE `sharedcalendar` ( `userid` int(19) NOT NULL default '0',  `sharedid` int(19) NOT NULL default '0', PRIMARY KEY  (`userid`,`sharedid`)) ENGINE=MyISAM";
 Execute($create_query23);
 
-$insert_query6 = "INSERT INTO tab VALUES(26,'Campaigns',0,23,'Campaigns',null,null,1)";
+$insert_query6 = "INSERT INTO vtiger_tab VALUES(26,'Campaigns',0,23,'Campaigns',null,null,1)";
 Execute($insert_query6);
-$insert_query7 = "INSERT INTO parenttabrel VALUES(2,26,1)";
+$insert_query7 = "INSERT INTO vtiger_parenttabrel VALUES(2,26,1)";
 Execute($insert_query7);
 
-$insert_query8 = "insert into blocks values(76,26,'LBL_CAMPAIGN_INFORMATION',1,0,0,0,0,0)";
+$insert_query8 = "insert into vtiger_blocks values(76,26,'LBL_CAMPAIGN_INFORMATION',1,0,0,0,0,0)";
 Execute($insert_query8);
-$insert_query8 = "insert into blocks values (77,26,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)";
+$insert_query8 = "insert into vtiger_blocks values (77,26,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)";
 Execute($insert_query8);
-$insert_query9 = "insert into blocks values(78,26,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)";
+$insert_query9 = "insert into vtiger_blocks values(78,26,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)";
 Execute($insert_query9);
 
 $insert_query_array24 = Array(
-	"insert into field values (26,".$conn->getUniqueID("field").",'campaignname','campaign',1,'2','campaignname','Campaign Name',1,0,0,100,1,76,1,'V~M',0,1,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'campaigntype','campaign',1,15,'campaigntype','Campaign Type',1,0,0,100,2,76,1,'V~O',0,5,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'product_id','campaign',1,59,'product_id','Product',1,0,0,100,3,76,1,'I~O',0,5,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'campaignstatus','campaign',1,15,'campaignstatus','Campaign Status',1,0,0,100,4,76,1,'V~O',0,5,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'closingdate','campaign',1,'23','closingdate','Expected Close Date',1,0,0,100,5,76,1,'D~M',0,3,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'expectedrevenue','campaign',1,'1','expectedrevenue','Expected Revenue',1,0,0,100,6,76,1,'I~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'budgetcost','campaign',1,'1','budgetcost','Budget Cost',1,0,0,100,7,76,1,'I~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'actualcost','campaign',1,'1','actualcost','Actual Cost',1,0,0,100,8,76,1,'I~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'expectedresponse','campaign',1,'15','expectedresponse','Expected Response',1,0,0,100,9,76,1,'V~O',0,4,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,10,76,1,'V~M',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'numsent','campaign',1,'9','numsent','Num Sent',1,0,0,100,11,76,1,'N~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'sponsor','campaign',1,'1','sponsor','Sponsor',1,0,0,100,12,76,1,'V~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'targetaudience','campaign',1,'1','targetaudience','Target Audience',1,0,0,100,13,76,1,'V~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'targetsize','campaign',1,'1','targetsize','TargetSize',1,0,0,100,14,76,1,'N~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'expectedresponsecount','campaign',1,'1','expectedresponsecount','Expected Response Count',1,0,0,100,17,76,1,'N~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'expectedsalescount','campaign',1,'1','expectedsalescount','Expected Sales Count',1,0,0,100,15,76,1,'N~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'expectedroi','campaign',1,'1','expectedroi','Expected ROI',1,0,0,100,19,76,1,'N~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'actualresponsecount','campaign',1,'1','actualresponsecount','Actual Response Count',1,0,0,100,18,76,1,'N~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'actualsalescount','campaign',1,'1','actualsalescount','Actual Sales Count',1,0,0,100,16,76,1,'N~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'actualroi','campaign',1,'1','actualroi','Actual ROI',1,0,0,100,20,76,1,'N~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,15,76,2,'T~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,16,76,2,'T~O',1,null,'BAS')",
-	"insert into field values (26,".$conn->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,78,1,'V~O',1,null,'BAS')"
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'campaignname','campaign',1,'2','campaignname','Campaign Name',1,0,0,100,1,76,1,'V~M',0,1,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'campaigntype','campaign',1,15,'campaigntype','Campaign Type',1,0,0,100,2,76,1,'V~O',0,5,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'product_id','campaign',1,59,'product_id','Product',1,0,0,100,3,76,1,'I~O',0,5,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'campaignstatus','campaign',1,15,'campaignstatus','Campaign Status',1,0,0,100,4,76,1,'V~O',0,5,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'closingdate','campaign',1,'23','closingdate','Expected Close Date',1,0,0,100,5,76,1,'D~M',0,3,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'expectedrevenue','campaign',1,'1','expectedrevenue','Expected Revenue',1,0,0,100,6,76,1,'I~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'budgetcost','campaign',1,'1','budgetcost','Budget Cost',1,0,0,100,7,76,1,'I~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'actualcost','campaign',1,'1','actualcost','Actual Cost',1,0,0,100,8,76,1,'I~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'expectedresponse','campaign',1,'15','expectedresponse','Expected Response',1,0,0,100,9,76,1,'V~O',0,4,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,10,76,1,'V~M',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'numsent','campaign',1,'9','numsent','Num Sent',1,0,0,100,11,76,1,'N~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'sponsor','campaign',1,'1','sponsor','Sponsor',1,0,0,100,12,76,1,'V~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'targetaudience','campaign',1,'1','targetaudience','Target Audience',1,0,0,100,13,76,1,'V~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'targetsize','campaign',1,'1','targetsize','TargetSize',1,0,0,100,14,76,1,'N~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'expectedresponsecount','campaign',1,'1','expectedresponsecount','Expected Response Count',1,0,0,100,17,76,1,'N~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'expectedsalescount','campaign',1,'1','expectedsalescount','Expected Sales Count',1,0,0,100,15,76,1,'N~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'expectedroi','campaign',1,'1','expectedroi','Expected ROI',1,0,0,100,19,76,1,'N~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'actualresponsecount','campaign',1,'1','actualresponsecount','Actual Response Count',1,0,0,100,18,76,1,'N~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'actualsalescount','campaign',1,'1','actualsalescount','Actual Sales Count',1,0,0,100,16,76,1,'N~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'actualroi','campaign',1,'1','actualroi','Actual ROI',1,0,0,100,20,76,1,'N~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,15,76,2,'T~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,16,76,2,'T~O',1,null,'BAS')",
+	"insert into vtiger_field values (26,".$conn->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,78,1,'V~O',1,null,'BAS')"
 			     );
 foreach($insert_query_array24 as $query)
 {
@@ -1742,8 +1742,8 @@
 }
 
 $insert_query_array25 = Array(
-	"insert into relatedlists values (".$conn->getUniqueID('relatedlists').",".getTabid("Campaigns").",".getTabid("Contacts").",'get_contacts',1,'Contacts',0)",
-	"insert into relatedlists values (".$conn->getUniqueID('relatedlists').",".getTabid("Campaigns").",".getTabid("Leads").",'get_leads',2,'Leads',0)"
+	"insert into vtiger_relatedlists values (".$conn->getUniqueID('relatedlists').",".getTabid("Campaigns").",".getTabid("Contacts").",'get_contacts',1,'Contacts',0)",
+	"insert into vtiger_relatedlists values (".$conn->getUniqueID('relatedlists').",".getTabid("Campaigns").",".getTabid("Leads").",'get_leads',2,'Leads',0)"
 			     );
 foreach($insert_query_array25 as $query)
 {
@@ -1752,8 +1752,8 @@
 
 
 $insert_query_array26 = Array(
-	"insert into field values (7,".$conn->getUniqueID("field").",'campaignid','leaddetails',1,'51','campaignid','Campaign Name',1,0,0,100,6,13,3,'I~O',1,null,'BAS')",
-	"insert into field values (4,".$conn->getUniqueID("field").",'campaignid','contactdetails',1,'51','campaignid','Campaign Name',1,0,0,100,6,4,3,'I~O',1,null,'BAS')"
+	"insert into vtiger_field values (7,".$conn->getUniqueID("field").",'campaignid','leaddetails',1,'51','campaignid','Campaign Name',1,0,0,100,6,13,3,'I~O',1,null,'BAS')",
+	"insert into vtiger_field values (4,".$conn->getUniqueID("field").",'campaignid','contactdetails',1,'51','campaignid','Campaign Name',1,0,0,100,6,4,3,'I~O',1,null,'BAS')"
 			     );
 foreach($insert_query_array26 as $query)
 {
@@ -1858,11 +1858,11 @@
 Execute($create_table_query1);
 
 $alter_query_array18 = Array(
-				"alter table leaddetails add column campaignid int(19) default NULL after leadid",
-				"alter table contactdetails add column  campaignid int(19) default NULL after accountid",
-				//"alter table notes drop PRIMARY KEY contact_id",
-				"alter table notes drop PRIMARY KEY , add primary key(notesid)",
-				"update field set uitype=99 where fieldname='update_log' and tabid=13"
+				"alter vtiger_table vtiger_leaddetails add column vtiger_campaignid int(19) default NULL after leadid",
+				"alter vtiger_table vtiger_contactdetails add column  vtiger_campaignid int(19) default NULL after vtiger_accountid",
+				//"alter vtiger_table vtiger_notes drop PRIMARY KEY contact_id",
+				"alter vtiger_table vtiger_notes drop PRIMARY KEY , add primary key(notesid)",
+				"update vtiger_field set uitype=99 where vtiger_fieldname='update_log' and vtiger_tabid=13"
 			    );
 foreach($alter_query_array18 as $query)
 {
@@ -1871,8 +1871,8 @@
 
 
 
-//echo "<br><br><b>Database Modifications for Indexing and some missded tables starts here.....</b><br>";
-//Added queries which are for indexing and the missing tables - Mickie - on 06-04-2006
+//echo "<br><br><b>Database Modifications for Indexing and some missded vtiger_tables starts here.....</b><br>";
+//Added queries which are for indexing and the missing vtiger_tables - Mickie - on 06-04-2006
 
 $query_array = Array(
 
@@ -2605,7 +2605,7 @@
 "ALTER TABLE `purchaseorder` ADD KEY `PO_Quote_IDX` (`quoteid`)",
 "ALTER TABLE `purchaseorder` ADD KEY `PO_Contact_IDX` (`contactid`)",
 "ALTER TABLE `quotegrouprelation` ADD KEY `quotegrouprelation_IDX1` (`groupname`)",
-"ALTER TABLE `quotes` DROP INDEX quotestage",
+"ALTER TABLE `quotes` DROP INDEX vtiger_quotestage",
 "ALTER TABLE `quotes` ADD INDEX `quotestage` (`quoteid`)",
 "ALTER TABLE `quotes` ADD KEY `potentialid2` (`potentialid`)",
 "ALTER TABLE `quotes` ADD KEY `contactid` (`contactid`)",
@@ -2662,20 +2662,20 @@
 $conn->println("Database Modifications after 5.0(Alpha 5) starts here.");
 
 
-//Added on 22-04-06 - to add the Notify Owner field in Contacts and Accounts
+//Added on 22-04-06 - to add the Notify Owner vtiger_field in Contacts and Accounts
 $notify_owner_array = Array(
-	"update field set sequence=26 where tabid=4 and fieldname='modifiedtime'",
-	"update field set sequence=25 where tabid=4 and fieldname='createdtime'",
+	"update vtiger_field set sequence=26 where vtiger_tabid=4 and vtiger_fieldname='modifiedtime'",
+	"update vtiger_field set sequence=25 where vtiger_tabid=4 and vtiger_fieldname='createdtime'",
 	
-	"insert into field values(4,".$conn->getUniqueID("field").",'notify_owner','contactdetails',1,56,'notify_owner','Notify Owner',1,0,0,10,24,4,1,'C~O',1,NULL,'ADV')",
-	"alter table contactdetails add column notify_owner varchar(3) default 0 after reference",
-
-	"update field set sequence=21 where tabid=6 and fieldname='modifiedtime'",
-	"update field set sequence=20 where tabid=6 and fieldname='createdtime'",
-	"update field set sequence=19 where tabid=6 and fieldname='assigned_user_id'",
+	"insert into vtiger_field values(4,".$conn->getUniqueID("field").",'notify_owner','contactdetails',1,56,'notify_owner','Notify Owner',1,0,0,10,24,4,1,'C~O',1,NULL,'ADV')",
+	"alter vtiger_table vtiger_contactdetails add column notify_owner varchar(3) default 0 after reference",
+
+	"update vtiger_field set sequence=21 where vtiger_tabid=6 and vtiger_fieldname='modifiedtime'",
+	"update vtiger_field set sequence=20 where vtiger_tabid=6 and vtiger_fieldname='createdtime'",
+	"update vtiger_field set sequence=19 where vtiger_tabid=6 and vtiger_fieldname='assigned_user_id'",
 	
-	"insert into field values(6,".$conn->getUniqueID("field").",'notify_owner','account',1,56,'notify_owner','Notify Owner',1,0,0,10,18,9,1,'C~O',1,NULL,'ADV')",
-	"alter table account add column notify_owner varchar(3) default 0 after emailoptout"
+	"insert into vtiger_field values(6,".$conn->getUniqueID("field").",'notify_owner','account',1,56,'notify_owner','Notify Owner',1,0,0,10,18,9,1,'C~O',1,NULL,'ADV')",
+	"alter vtiger_table vtiger_account add column notify_owner varchar(3) default 0 after emailoptout"
 			   );
 foreach($notify_owner_array as $query)
 {
@@ -2683,17 +2683,17 @@
 }
 
 //Added for RSS entries
-$rss_insert_query = "insert into field values (24,".$conn->getUniqueID("field").",'rsscategory','rss',1,'15','rsscategory','rsscategory',1,0,0,255,13,null,1,'V~O',1,null,'BAS')";
+$rss_insert_query = "insert into vtiger_field values (24,".$conn->getUniqueID("field").",'rsscategory','rss',1,'15','rsscategory','rsscategory',1,0,0,255,13,null,1,'V~O',1,null,'BAS')";
 Execute($rss_insert_query);
 
 //Quick Create Feature added for Vendor & PriceBook
 $quickcreate_query = Array(
-	"UPDATE field SET quickcreate = 0,quickcreatesequence = 1 WHERE tabid = 18 and fieldname = 'vendorname'",
-	"UPDATE field SET quickcreate = 0,quickcreatesequence = 2 WHERE tabid = 18 and fieldname = 'phone'",
-	"UPDATE field SET quickcreate = 0,quickcreatesequence = 3 WHERE tabid = 18 and fieldname = 'email'",
-
-	"UPDATE field SET quickcreate = 0,quickcreatesequence = 1 WHERE tabid = 19 and fieldname = 'bookname'",
-	"UPDATE field SET quickcreate = 0,quickcreatesequence = 2 WHERE tabid = 19 and fieldname = 'active'"
+	"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 1 WHERE vtiger_tabid = 18 and vtiger_fieldname = 'vendorname'",
+	"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 2 WHERE vtiger_tabid = 18 and vtiger_fieldname = 'phone'",
+	"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 3 WHERE vtiger_tabid = 18 and vtiger_fieldname = 'email'",
+
+	"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 1 WHERE vtiger_tabid = 19 and vtiger_fieldname = 'bookname'",
+	"UPDATE vtiger_field SET quickcreate = 0,quickcreatesequence = 2 WHERE vtiger_tabid = 19 and vtiger_fieldname = 'active'"
 			  );
 foreach($quickcreate_query as $query)
 {
@@ -2701,24 +2701,24 @@
 }
 
 
-//Added on 24-04-06 to populate customview All for Campaign and webmails modules
+//Added on 24-04-06 to populate vtiger_customview All for Campaign and webmails modules
 $cvid1 = $conn->getUniqueID("customview");
 $cvid2 = $conn->getUniqueID("customview");
 $customview_query_array = Array(
-	"insert into customview(cvid,viewname,setdefault,setmetrics,entitytype) values(".$cvid1.",'All',1,0,'Campaigns')",
-	"insert into cvcolumnlist (cvid,columnindex,columnname) values (".$cvid1.",0,'campaign:campaignname:campaignname:Campaigns_Campaign_Name:V')",
-	"insert into cvcolumnlist (cvid,columnindex,columnname) values (".$cvid1.",1,'campaign:campaigntype:campaigntype:Campaigns_Campaign_Type:N')",
-	"insert into cvcolumnlist (cvid,columnindex,columnname) values (".$cvid1.",2,'campaign:campaignstatus:campaignstatus:Campaigns_Campaign_Status:N')",
-	"insert into cvcolumnlist (cvid,columnindex,columnname) values (".$cvid1.",3,'campaign:expectedrevenue:expectedrevenue:Campaigns_Expected_Revenue:V')",
-	"insert into cvcolumnlist (cvid,columnindex,columnname) values (".$cvid1.",4,'campaign:closingdate:closingdate:Campaigns_Expected_Close_Date:D')",
-	"insert into cvcolumnlist (cvid,columnindex,columnname) values (".$cvid1.",5,'crmentity:smownerid:assigned_user_id:Campaigns_Assigned_To:V')",
-
-
-	"insert into customview(cvid,viewname,setdefault,setmetrics,entitytype) values(".$cvid2.",'All',1,0,'Webmails')",
-	"insert into cvcolumnlist (cvid,columnindex,columnname) values (".$cvid2.",0,'subject:subject:subject:Subject:V')",
-	"insert into cvcolumnlist (cvid,columnindex,columnname) values (".$cvid2.",1,'from:fromname:fromname:From:N')",
-	"insert into cvcolumnlist (cvid,columnindex,columnname) values (".$cvid2.",2,'to:tpname:toname:To:N')",
-	"insert into cvcolumnlist (cvid,columnindex,columnname) values (".$cvid2.",3,'body:body:body:Body:V')"
+	"insert into vtiger_customview(cvid,viewname,setdefault,setmetrics,entitytype) values(".$cvid1.",'All',1,0,'Campaigns')",
+	"insert into vtiger_cvcolumnlist (cvid,columnindex,columnname) values (".$cvid1.",0,'campaign:campaignname:campaignname:Campaigns_Campaign_Name:V')",
+	"insert into vtiger_cvcolumnlist (cvid,columnindex,columnname) values (".$cvid1.",1,'campaign:campaigntype:campaigntype:Campaigns_Campaign_Type:N')",
+	"insert into vtiger_cvcolumnlist (cvid,columnindex,columnname) values (".$cvid1.",2,'campaign:campaignstatus:campaignstatus:Campaigns_Campaign_Status:N')",
+	"insert into vtiger_cvcolumnlist (cvid,columnindex,columnname) values (".$cvid1.",3,'campaign:expectedrevenue:expectedrevenue:Campaigns_Expected_Revenue:V')",
+	"insert into vtiger_cvcolumnlist (cvid,columnindex,columnname) values (".$cvid1.",4,'campaign:closingdate:closingdate:Campaigns_Expected_Close_Date:D')",
+	"insert into vtiger_cvcolumnlist (cvid,columnindex,columnname) values (".$cvid1.",5,'crmentity:smownerid:assigned_user_id:Campaigns_Assigned_To:V')",
+
+
+	"insert into vtiger_customview(cvid,viewname,setdefault,setmetrics,entitytype) values(".$cvid2.",'All',1,0,'Webmails')",
+	"insert into vtiger_cvcolumnlist (cvid,columnindex,columnname) values (".$cvid2.",0,'subject:subject:subject:Subject:V')",
+	"insert into vtiger_cvcolumnlist (cvid,columnindex,columnname) values (".$cvid2.",1,'from:fromname:fromname:From:N')",
+	"insert into vtiger_cvcolumnlist (cvid,columnindex,columnname) values (".$cvid2.",2,'to:tpname:toname:To:N')",
+	"insert into vtiger_cvcolumnlist (cvid,columnindex,columnname) values (".$cvid2.",3,'body:body:body:Body:V')"
 
 			       );
 foreach($customview_query_array as $query)
@@ -2728,25 +2728,25 @@
 
 
 $query_array2 = Array(
-				"INSERT INTO parenttabrel VALUES(2,4,2)",
-				"INSERT INTO parenttabrel VALUES(2,6,3)",
-				"update cvcolumnlist set columnname ='crmentity:smownerid:assigned_user_id:Emails_Sender:V' where cvid=20 and columnindex=3",
-				"update field set sequence = 2 where columnname='filename' and tablename = 'attachments'",
-				"delete from cvcolumnlist where columnname = 'seactivityrel:crmid:parent_id:Emails_Related_To:I'",
-				"update cvcolumnlist set columnindex = 1 where cvid=3 and columnindex=3",
-				"update field set info_type='ADV' where tabid=18 and columnname in ('street','pobox','city','state','postalcode','country','description')",
-				"update field set info_type='ADV' where tabid in (20,21,22,23) and columnname in ('description','terms_conditions')",
-
-				"create table inventorytaxinfo (taxid int(3) NOT NULL auto_increment, taxname varchar(50) default NULL, percentage decimal(7,3) default NULL,  PRIMARY KEY  (taxid), KEY inventorytaxinfo_taxname_idx (taxname))",
-				"create table producttaxrel ( productid int(11) NOT NULL, taxid int(3) NOT NULL, taxpercentage decimal(7,3) default NULL, KEY producttaxrel_productid_idx (productid), KEY producttaxrel_taxid_idx (taxid))",
-
-				"insert into inventorytaxinfo values(".$conn->getUniqueID("inventorytaxinfo").",'VAT','4.5')",
-				"insert into inventorytaxinfo values(".$conn->getUniqueID("inventorytaxinfo").",'Sales','10')",
-				"insert into inventorytaxinfo values(".$conn->getUniqueID("inventorytaxinfo").",'Service','12.5')",
-				"update field set uitype=83, tablename='producttaxrel' where tabid=14 and fieldname='taxclass'",
-				"insert into moduleowners values(".$this->localGetTabID('Campaigns').",1)",
-
-				"alter table attachments add column path varchar(255) default NULL"
+				"INSERT INTO vtiger_parenttabrel VALUES(2,4,2)",
+				"INSERT INTO vtiger_parenttabrel VALUES(2,6,3)",
+				"update vtiger_cvcolumnlist set columnname ='crmentity:smownerid:assigned_user_id:Emails_Sender:V' where cvid=20 and columnindex=3",
+				"update vtiger_field set sequence = 2 where columnname='filename' and vtiger_tablename = 'attachments'",
+				"delete from vtiger_cvcolumnlist where columnname = 'seactivityrel:crmid:parent_id:Emails_Related_To:I'",
+				"update vtiger_cvcolumnlist set columnindex = 1 where cvid=3 and columnindex=3",
+				"update vtiger_field set info_type='ADV' where vtiger_tabid=18 and columnname in ('street','pobox','city','state','postalcode','country','description')",
+				"update vtiger_field set info_type='ADV' where vtiger_tabid in (20,21,22,23) and columnname in ('description','terms_conditions')",
+
+				"create vtiger_table vtiger_inventorytaxinfo (taxid int(3) NOT NULL auto_increment, taxname varchar(50) default NULL, percentage decimal(7,3) default NULL,  PRIMARY KEY  (taxid), KEY vtiger_inventorytaxinfo_taxname_idx (taxname))",
+				"create vtiger_table vtiger_producttaxrel ( productid int(11) NOT NULL, taxid int(3) NOT NULL, taxpercentage decimal(7,3) default NULL, KEY vtiger_producttaxrel_productid_idx (productid), KEY vtiger_producttaxrel_taxid_idx (taxid))",
+
+				"insert into vtiger_inventorytaxinfo values(".$conn->getUniqueID("inventorytaxinfo").",'VAT','4.5')",
+				"insert into vtiger_inventorytaxinfo values(".$conn->getUniqueID("inventorytaxinfo").",'Sales','10')",
+				"insert into vtiger_inventorytaxinfo values(".$conn->getUniqueID("inventorytaxinfo").",'Service','12.5')",
+				"update vtiger_field set uitype=83, vtiger_tablename='producttaxrel' where vtiger_tabid=14 and vtiger_fieldname='taxclass'",
+				"insert into vtiger_moduleowners values(".$this->localGetTabID('Campaigns').",1)",
+
+				"alter vtiger_table vtiger_attachments add column path varchar(255) default NULL"
 			     );
 
 foreach($query_array2 as $query)
@@ -2779,30 +2779,30 @@
 
 }
 
-$update_query3 = "update currency_info set conversion_rate=1, currency_status='Active', defaultid='-11' where id=1";
+$update_query3 = "update vtiger_currency_info set conversion_rate=1, vtiger_currency_status='Active', defaultid='-11' where id=1";
 Execute($update_query3);
 
-$update_query4 = "update relatedlists set label='Purchase Order' where tabid=18 and name='get_purchase_orders'";
+$update_query4 = "update vtiger_relatedlists set label='Purchase Order' where vtiger_tabid=18 and name='get_purchase_orders'";
 Execute($update_query4);
 
 
 
 //Added on 27-05-06
 
-$create_query27 = "CREATE TABLE invitees (activityid int(19) NOT NULL, inviteeid int(19) NOT NULL, PRIMARY KEY (activityid,inviteeid))";
+$create_query27 = "CREATE TABLE vtiger_invitees (activityid int(19) NOT NULL, inviteeid int(19) NOT NULL, PRIMARY KEY (activityid,inviteeid))";
 Execute($create_query27);
 
 $alter_query_array17 = Array(
-				"ALTER TABLE users ADD column hour_format varchar(30) default 'am/pm' AFTER date_format",
-				"ALTER TABLE users ADD column start_hour varchar(30) default '10:00' AFTER hour_format",
-				"ALTER TABLE users ADD column end_hour varchar(30) default '23:00' AFTER start_hour"
+				"ALTER TABLE vtiger_users ADD column hour_format varchar(30) default 'am/pm' AFTER date_format",
+				"ALTER TABLE vtiger_users ADD column start_hour varchar(30) default '10:00' AFTER hour_format",
+				"ALTER TABLE vtiger_users ADD column end_hour varchar(30) default '23:00' AFTER start_hour"
 			    );
 foreach($alter_query_array17 as $query)
 {
 	Execute($query);
 }
 
-$create_query28 = "CREATE TABLE emaildetails (
+$create_query28 = "CREATE TABLE vtiger_emaildetails (
 			emailid int(19) NOT NULL,
 			from_email varchar(50) NOT NULL default '',
 			to_email text,
@@ -2817,12 +2817,12 @@
 
 
 $obj_array = Array('Leads'=>'leaddetails','Contacts'=>'contactdetails');
-$leadfieldid = $conn->query_result($conn->query("select fieldid from field where tabid=7 and fieldname='email'"),0,'fieldid');
-$contactfieldid = $conn->query_result($conn->query("select fieldid from field where tabid=4 and fieldname='email'"),0,'fieldid');
+$leadfieldid = $conn->query_result($conn->query("select vtiger_fieldid from vtiger_field where vtiger_tabid=7 and vtiger_fieldname='email'"),0,'fieldid');
+$contactfieldid = $conn->query_result($conn->query("select vtiger_fieldid from vtiger_field where vtiger_tabid=4 and vtiger_fieldname='email'"),0,'fieldid');
 $fieldid_array = Array("Leads"=>"$leadfieldid","Contacts"=>"$contactfieldid");
 $idname_array = Array("Leads"=>"leadid","Contacts"=>"contactid");
 
-$query = 'select * from seactivityrel where activityid in (select activityid from activity where activitytype="Emails")';
+$query = 'select * from vtiger_seactivityrel where vtiger_activityid in (select vtiger_activityid from vtiger_activity where vtiger_activitytype="Emails")';
 $result = $conn->query($query);
 $numofrows = $conn->num_rows($result);
 
@@ -2833,7 +2833,7 @@
 	$parentid = $conn->query_result($result,$i,'crmid');
 	$emailid = $conn->query_result($result,$i,'activityid');
 
-	$query = 'select setype from crmentity where crmid='.$parentid;
+	$query = 'select setype from vtiger_crmentity where crmid='.$parentid;
 	$result1 = $conn->query($query);
 	$module = $conn->query_result($result1,0,'setype');
 
@@ -2844,8 +2844,8 @@
 		$result2 = $conn->query("select lastname, firstname, email from $obj_array[$module] where $idname_array[$module] = $parentid");
 		$toemail = $conn->query_result($result2,0,'lastname').' '.$conn->query_result($result2,0,'firstname').'<'.$conn->query_result($result2,0,'email').'>###';
 
-		//insert this idlists and toemail values in emaildetails table
-		$sql = "insert into emaildetails values ($emailid,'',\"$toemail\",'','','',\"$idlists\",'SAVE')";
+		//insert this idlists and toemail values in vtiger_emaildetails vtiger_table
+		$sql = "insert into vtiger_emaildetails values ($emailid,'',\"$toemail\",'','','',\"$idlists\",'SAVE')";
 		Execute($sql);
 	}
 	else
@@ -2854,25 +2854,25 @@
 	}
 }
 
-$update_query5 = "update field set quickcreate=1, quickcreatesequence=NULL where tabid in (10,14)";
+$update_query5 = "update vtiger_field set quickcreate=1, quickcreatesequence=NULL where vtiger_tabid in (10,14)";
 Execute($update_query5);
 
 $alter_query_array18 = Array(
-				"alter table soproductrel add column vattax decimal(7,3) default NULL",
-				"alter table soproductrel add column salestax decimal(7,3) default NULL",
-				"alter table soproductrel add column servicetax decimal(7,3) default NULL",
+				"alter vtiger_table vtiger_soproductrel add column vattax decimal(7,3) default NULL",
+				"alter vtiger_table vtiger_soproductrel add column salestax decimal(7,3) default NULL",
+				"alter vtiger_table vtiger_soproductrel add column servicetax decimal(7,3) default NULL",
 				
-				"alter table poproductrel add column vattax decimal(7,3) default NULL",
-				"alter table poproductrel add column salestax decimal(7,3) default NULL",
-				"alter table poproductrel add column servicetax decimal(7,3) default NULL",
+				"alter vtiger_table vtiger_poproductrel add column vattax decimal(7,3) default NULL",
+				"alter vtiger_table vtiger_poproductrel add column salestax decimal(7,3) default NULL",
+				"alter vtiger_table vtiger_poproductrel add column servicetax decimal(7,3) default NULL",
 				
-				"alter table quotesproductrel add column vattax decimal(7,3) default NULL",
-				"alter table quotesproductrel add column salestax decimal(7,3) default NULL",
-				"alter table quotesproductrel add column servicetax decimal(7,3) default NULL",
+				"alter vtiger_table vtiger_quotesproductrel add column vattax decimal(7,3) default NULL",
+				"alter vtiger_table vtiger_quotesproductrel add column salestax decimal(7,3) default NULL",
+				"alter vtiger_table vtiger_quotesproductrel add column servicetax decimal(7,3) default NULL",
 				
-				"alter table invoiceproductrel add column vattax decimal(7,3) default NULL",
-				"alter table invoiceproductrel add column salestax decimal(7,3) default NULL",
-				"alter table invoiceproductrel add column servicetax decimal(7,3) default NULL",
+				"alter vtiger_table vtiger_invoiceproductrel add column vattax decimal(7,3) default NULL",
+				"alter vtiger_table vtiger_invoiceproductrel add column salestax decimal(7,3) default NULL",
+				"alter vtiger_table vtiger_invoiceproductrel add column servicetax decimal(7,3) default NULL",
 			    );
 foreach($alter_query_array18 as $query)
 {
@@ -2881,91 +2881,91 @@
 
 
 
-//Security profile and tab table handling by DON starts
-$sql_sec="select profileid from  profile";
+//Security vtiger_profile and vtiger_tab vtiger_table handling by DON starts
+$sql_sec="select vtiger_profileid from  vtiger_profile";
 $result_sec=$conn->query($sql_sec);
 $num_rows=$conn->num_rows($result_sec);
 for($i=0;$i<$num_row;$i++)
 {
 	$prof_id=$conn->query_result($result_sec,$i,'profileid');
-	$sql1_sec="insert into profile2utility values(".$prof_id.",13,8,0)";
+	$sql1_sec="insert into vtiger_profile2utility values(".$prof_id.",13,8,0)";
 	Execute($sql1_sec);
 
-	$sql2_sec="insert into profile2utility values(".$prof_id.",7,9,0)";
+	$sql2_sec="insert into vtiger_profile2utility values(".$prof_id.",7,9,0)";
 	Execute($sql2_sec);
 
-	$sql3_sec="insert into profile2tab values(".$prof_id.",26,0)";
+	$sql3_sec="insert into vtiger_profile2tab values(".$prof_id.",26,0)";
 	Execute($sql3_sec);
 
-	$sql4_sec="insert into profile2tab values(".$prof_id.",27,0)";
+	$sql4_sec="insert into vtiger_profile2tab values(".$prof_id.",27,0)";
 	Execute($sql4_sec);
 
-	$sql7_sec="insert into profile2standardpermissions values(".$prof_id.",26,0,0)";
+	$sql7_sec="insert into vtiger_profile2standardpermissions values(".$prof_id.",26,0,0)";
 	Execute($sql7_sec);
 
-	$sql8_sec="insert into profile2standardpermissions values(".$prof_id.",26,1,0)";
+	$sql8_sec="insert into vtiger_profile2standardpermissions values(".$prof_id.",26,1,0)";
 	Execute($sql8_sec);
 
-	$sql9_sec="insert into profile2standardpermissions values(".$prof_id.",26,2,0)";
+	$sql9_sec="insert into vtiger_profile2standardpermissions values(".$prof_id.",26,2,0)";
 	Execute($sql9_sec);
 
-	$sql10_sec="insert into profile2standardpermissions values(".$prof_id.",26,3,0)";
+	$sql10_sec="insert into vtiger_profile2standardpermissions values(".$prof_id.",26,3,0)";
 	Execute($sql10_sec);
 
-	$sql11_sec="insert into profile2standardpermissions values(".$prof_id.",26,4,0)";
+	$sql11_sec="insert into vtiger_profile2standardpermissions values(".$prof_id.",26,4,0)";
 	Execute($sql11_sec);	
 
 }
 
-//Inserting into tab tables
-$sec2="INSERT INTO tab VALUES (27,'Portal',0,24,'Portal',null,null,1)";
-$sec3="INSERT INTO tab VALUES (28,'Webmails',0,25,'Webmails',null,null,1)";
-
-//Insert into def_org_share tables
-$sec4="insert into def_org_share values (".$conn->getUniqueID('def_org_share').",26,2,0)";	
+//Inserting into vtiger_tab vtiger_tables
+$sec2="INSERT INTO vtiger_tab VALUES (27,'Portal',0,24,'Portal',null,null,1)";
+$sec3="INSERT INTO vtiger_tab VALUES (28,'Webmails',0,25,'Webmails',null,null,1)";
+
+//Insert into vtiger_def_org_share vtiger_tables
+$sec4="insert into vtiger_def_org_share values (".$conn->getUniqueID('def_org_share').",26,2,0)";	
 
 Execute($sec2);
 Execute($sec3);
 Execute($sec4);
 
-//Inserting into datashare related modules table
-
-Execute("insert into datashare_relatedmodules_seq values(1)");
+//Inserting into datashare related modules vtiger_table
+
+Execute("insert into vtiger_datashare_relatedmodules_seq values(1)");
 	
 //Lead Related Module
-Execute("insert into datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",7,10)");
+Execute("insert into vtiger_datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",7,10)");
 
 //Account Related Module
-Execute("insert into datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",6,2)");
-Execute("insert into datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",6,13)");
-Execute("insert into datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",6,20)");
-Execute("insert into datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",6,22)");
-Execute("insert into datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",6,23)");
-Execute("insert into datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",6,10)");
+Execute("insert into vtiger_datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",6,2)");
+Execute("insert into vtiger_datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",6,13)");
+Execute("insert into vtiger_datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",6,20)");
+Execute("insert into vtiger_datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",6,22)");
+Execute("insert into vtiger_datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",6,23)");
+Execute("insert into vtiger_datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",6,10)");
 
 
 //Potential Related Module
-Execute("insert into datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",2,20)");
-Execute("insert into datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",2,22)");
+Execute("insert into vtiger_datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",2,20)");
+Execute("insert into vtiger_datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",2,22)");
 
 //Quote Related Module
-Execute("insert into datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",20,22)");
+Execute("insert into vtiger_datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",20,22)");
 
 //SO Related Module
-Execute("insert into datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",22,23)");
+Execute("insert into vtiger_datashare_relatedmodules values (".$conn->getUniqueID('datashare_relatedmodules').",22,23)");
 	
 
 //By Don Ends
 
-//Added the tabel mail_accounts which has been added by mmbrich
-$alter_query18 = "alter table mail_accounts add column int_mailer int(1) default '0'";
+//Added the vtiger_tabel vtiger_mail_accounts which has been added by mmbrich
+$alter_query18 = "alter vtiger_table vtiger_mail_accounts add column int_mailer int(1) default '0'";
 Execute($alter_query18);
 
 $update_query_array5 = Array(
-	"update field set info_type='BAS' where tabid=6 and fieldname in ('tickersymbol','account_id')",
-	"update relatedlists set label = 'Activity History' where tabid in (4,6,7,20,21,22,23) and label = 'History'",
-	"update relatedlists set label = 'Products' where tabid=2 and name='get_products' and label='History'",
-	"update relatedlists set label = 'Activity History' where tabid=2 and name='get_history' and label='History'"
+	"update vtiger_field set info_type='BAS' where vtiger_tabid=6 and vtiger_fieldname in ('tickersymbol','account_id')",
+	"update vtiger_relatedlists set label = 'Activity History' where vtiger_tabid in (4,6,7,20,21,22,23) and label = 'History'",
+	"update vtiger_relatedlists set label = 'Products' where vtiger_tabid=2 and name='get_products' and label='History'",
+	"update vtiger_relatedlists set label = 'Activity History' where vtiger_tabid=2 and name='get_history' and label='History'"
 			    );
 foreach($update_query_array5 as $query)
 {
@@ -2973,9 +2973,9 @@
 }
 
 $insert_query_array27 = Array(
-	"insert into relatedlists values(".$conn->getUniqueID('relatedlists').",13,0,'get_ticket_history',3,'Ticket History',0)",
-	"insert into parenttabrel values (2,10,4)",
-	"insert into parenttabrel values (4,10,7)"
+	"insert into vtiger_relatedlists values(".$conn->getUniqueID('relatedlists').",13,0,'get_ticket_history',3,'Ticket History',0)",
+	"insert into vtiger_parenttabrel values (2,10,4)",
+	"insert into vtiger_parenttabrel values (4,10,7)"
 			     );
 foreach($insert_query_array27 as $query)
 {
@@ -2996,14 +2996,14 @@
 		alert("Currency Changes has been made Successfully");
 	}
 
-	if(!confirm("Are you using Dollar $ as Currency? \n Click OK to remain as $, Cancel to change the currency conversion rate."))
+	if(!confirm("Are you using Dollar $ as Currency? \n Click OK to remain as $, Cancel to change the vtiger_currency conversion rate."))
 	{
 		getConversionRate('');
 	}
 
 	function getConversionRate(err)
 	{
-		var crate = prompt(err+"\nPlease enter the conversion rate of your currency");
+		var crate = prompt(err+"\nPlease enter the conversion rate of your vtiger_currency");
 
 		if(crate != 0 && crate > 0)
 		{
@@ -3051,21 +3051,21 @@
 	}
 }
 
-//Added on 23-12-2005 which is used to populate the profile2field and def_org_field table entries for the field per tab
-//if we enter a field in field table then we must populate that field in these table for security access
+//Added on 23-12-2005 which is used to populate the vtiger_profile2field and vtiger_def_org_field vtiger_table entries for the vtiger_field per vtiger_tab
+//if we enter a vtiger_field in vtiger_field vtiger_table then we must populate that vtiger_field in these vtiger_table for security access
 function populateFieldForSecurity($tabid,$fieldid)
 {
 	global $conn;
 
-	$profileresult = $conn->query("select * from profile");
+	$profileresult = $conn->query("select * from vtiger_profile");
 	$countprofiles = $conn->num_rows($profileresult);
 	for ($i=0;$i<$countprofiles;$i++)
 	{
         	$profileid = $conn->query_result($profileresult,$i,'profileid');
-	        $sqlProf2FieldInsert[$i] = 'insert into profile2field values ('.$profileid.','.$tabid.','.$fieldid.',0,1)';
+	        $sqlProf2FieldInsert[$i] = 'insert into vtiger_profile2field values ('.$profileid.','.$tabid.','.$fieldid.',0,1)';
         	Execute($sqlProf2FieldInsert[$i]);
 	}
-	$def_query = "insert into def_org_field values (".$tabid.",".$fieldid.",0,1)";
+	$def_query = "insert into vtiger_def_org_field values (".$tabid.",".$fieldid.",0,1)";
 	Execute($def_query);
 }
 

Modified: vtigercrm/trunk/modules/Migration/ModifyDatabase/MigrationInfo.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/ModifyDatabase/MigrationInfo.php (original)
+++ vtigercrm/trunk/modules/Migration/ModifyDatabase/MigrationInfo.php Mon Jun 12 14:26:25 2006
@@ -191,7 +191,7 @@
 						<b style="color:#006600">Migration Queries Log</b>
 						<div id="successLog" style="border:1px solid #666666;width:90%;position:relative;height:250px;overflow:auto;left:5%;top:10px;">
 							<!-- we should place the All queries executed-->
-							<!-- This table is designed to display all the queries (before this table a div tag is opened. so all these following queries will be put inside the div tab as a table format) -->
+							<!-- This vtiger_table is designed to display all the queries (before this vtiger_table a div tag is opened. so all these following queries will be put inside the div vtiger_tab as a vtiger_table format) -->
 							<style>
 								.MigInfo{
 									border-collapse:collapse;
@@ -238,7 +238,7 @@
 
 						<br /><br />
 
-						<!-- This table is to show the total, success and failed queries -->
+						<!-- This vtiger_table is to show the total, success and failed queries -->
 						<table width="35%" border="0" cellpadding="5" cellspacing="0" align="center" class="small">
 						   <tr>
 							<td width="75%" align="right" nowrap>

Modified: vtigercrm/trunk/modules/Migration/updateCurrency.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/updateCurrency.php (original)
+++ vtigercrm/trunk/modules/Migration/updateCurrency.php Mon Jun 12 14:26:25 2006
@@ -20,10 +20,10 @@
 	$crate = $_REQUEST['crate'];
 	$conn->println('conversion rate = '.$crate);
 	
-	$query = "update currency_info set conversion_rate='".$_REQUEST['crate']."' where id=1";
+	$query = "update vtiger_currency_info set conversion_rate='".$_REQUEST['crate']."' where id=1";
 	$result = $conn->query($query);
 
-	//array should be id || fieldname => tablename
+	//array should be id || vtiger_fieldname => vtiger_tablename
 	$modules_array = Array(
 				"accountid||annualrevenue"	=>	"account",
 				

Modified: vtigercrm/trunk/modules/Notes/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Notes/EditView.php (original)
+++ vtigercrm/trunk/modules/Notes/EditView.php Mon Jun 12 14:26:25 2006
@@ -170,7 +170,7 @@
 }
 
 if (isset($focus->parent_type) && $focus->parent_type != "") {
-        $change_parent_button = "<input title='".$app_strings['LBL_CHANGE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_CHANGE_BUTTON_KEY']."' tabindex='3' type='button' class='button' value='".$app_strings['LBL_CHANGE_BUTTON_LABEL']."' name='button' LANGUAGE=javascript onclick='return window.open(\"index.php?module=\"+ document.EditView.parent_type.value + \"&action=Popup&html=Popup_picker&form=TasksEditView\",\"test\",\"width=600,height=400,resizable=1,scrollbars=1\");'>";
+        $change_parent_button = "<input title='".$app_strings['LBL_CHANGE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_CHANGE_BUTTON_KEY']."' vtiger_tabindex='3' type='button' class='button' value='".$app_strings['LBL_CHANGE_BUTTON_LABEL']."' name='button' LANGUAGE=javascript onclick='return window.open(\"index.php?module=\"+ document.EditView.parent_type.value + \"&action=Popup&html=Popup_picker&form=TasksEditView\",\"test\",\"width=600,height=400,resizable=1,scrollbars=1\");'>";
         $smarty->assign("CHANGE_PARENT_BUTTON", $change_parent_button);
 }
 if ($focus->parent_type == "Account") $smarty->assign("DEFAULT_SEARCH", "&query=true&account_id=$focus->parent_id&account_name=".urlencode($focus->parent_name));

Modified: vtigercrm/trunk/modules/Notes/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Notes/Forms.php (original)
+++ vtigercrm/trunk/modules/Notes/Forms.php Mon Jun 12 14:26:25 2006
@@ -64,7 +64,7 @@
 }
 
 /**
- * Create HTML form to enter a new record with the minimum necessary fields.
+ * Create HTML form to enter a new record with the minimum necessary vtiger_fields.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
@@ -86,7 +86,7 @@
 
 $qcreate_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
 
-$qcreate_get_field="select * from field where tabid=8 and quickcreate=0 order by quickcreatesequence";
+$qcreate_get_field="select * from vtiger_field where vtiger_tabid=8 and quickcreate=0 order by quickcreatesequence";
 $qcreate_get_result=$adb->query($qcreate_get_field);
 $qcreate_get_noofrows=$adb->num_rows($qcreate_get_result);
 $fieldName_array = Array();//for validation 
@@ -167,9 +167,9 @@
 $qcreate_form.='</form>';
 $qcreate_form.='<script type="text/javascript">
 		
-	var fieldname = new Array('.$fieldName.')
-	var fieldlabel = new Array('.$fieldLabel.')
-	var fielddatatype = new Array('.$fldDataType.')
+	var vtiger_fieldname = new Array('.$fieldName.')
+	var vtiger_fieldlabel = new Array('.$fieldLabel.')
+	var vtiger_fielddatatype = new Array('.$fldDataType.')
 
 		</script>';
 

Modified: vtigercrm/trunk/modules/Notes/Note.php
==============================================================================
--- vtigercrm/trunk/modules/Notes/Note.php (original)
+++ vtigercrm/trunk/modules/Notes/Note.php Mon Jun 12 14:26:25 2006
@@ -32,7 +32,7 @@
 	var $log;
 	var $db;
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
         var $mode;
 
@@ -49,11 +49,11 @@
 	var $contact_phone;
 	var $contact_email;
 	var $required_fields =  array("name"=>1);
-	var $default_note_name_dom = array('Meeting notes', 'Reminder');
+	var $default_note_name_dom = array('Meeting vtiger_notes', 'Reminder');
 
 	var $table_name = "notes";
-	var $tab_name = Array('crmentity','notes','senotesrel','attachments');
-	var $tab_name_index = Array('crmentity'=>'crmid','notes'=>'notesid','senotesrel'=>'notesid','attachments'=>'attachmentsid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_notes','vtiger_senotesrel','vtiger_attachments');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_notes'=>'notesid','vtiger_senotesrel'=>'notesid','vtiger_attachments'=>'attachmentsid');
 
   	var $module_id = "notesid";
 	var $object_name = "Note";
@@ -62,10 +62,10 @@
 
         var $sortby_fields = Array('title','modifiedtime');		  
 
-	// This is used to retrieve related fields from form posts.
+	// This is used to retrieve related vtiger_fields from form posts.
 	var $additional_column_fields = Array('', '', '', '');
 
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
 				'Subject'=>Array('notes'=>'title'),
 				'Contact Name'=>Array('notes'=>'contact_id'),
@@ -101,11 +101,11 @@
 		global $log;
 		$log->debug("Entering create_export_query(".$order_by.",". $where.") method ...");
              $query = "SELECT
-                                        notes.*,
-                                        contactdetails.firstname,
-                                        contactdetails.lastname
-                                        FROM notes
-                                        LEFT JOIN contactdetails ON notes.contact_id=contactdetails.contactid inner join crmentity on crmentity.crmid=notes.notesid and crmentity.deleted=0 ";
+                                        vtiger_notes.*,
+                                        vtiger_contactdetails.firstname,
+                                        vtiger_contactdetails.lastname
+                                        FROM vtiger_notes
+                                        LEFT JOIN vtiger_contactdetails ON vtiger_notes.contact_id=vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_notes.notesid and vtiger_crmentity.deleted=0 ";
 		$log->debug("Exiting create_export_query method ...");
                 return $query;
         }

Modified: vtigercrm/trunk/modules/Notes/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Notes/Save.php (original)
+++ vtigercrm/trunk/modules/Notes/Save.php Mon Jun 12 14:26:25 2006
@@ -40,16 +40,16 @@
 
 if (!isset($_REQUEST['date_due_flag'])) $focus->date_due_flag = 'off';
 
-//Added for retrieve the old existing attachments when duplicated without new attachment
+//Added for retrieve the old existing vtiger_attachments when duplicated without new attachment
 if($_FILES['filename']['name'] == '' && $_REQUEST['mode'] != 'edit' && $_REQUEST['old_id'] != '')
 {
-        $sql = "select attachments.attachmentsid from attachments inner join seattachmentsrel on seattachmentsrel.attachmentsid=attachments.attachmentsid where seattachmentsrel.crmid= ".$_REQUEST['old_id'];
+        $sql = "select vtiger_attachments.attachmentsid from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid=vtiger_attachments.attachmentsid where vtiger_seattachmentsrel.crmid= ".$_REQUEST['old_id'];
         $result = $adb->query($sql);
         if($adb->num_rows($result) != 0)
                 $attachmentid = $adb->query_result($result,0,'attachmentsid');
 	        if($attachmentid != '')
 	        {
-	                $attachquery = "select * from attachments where attachmentsid = ".$attachmentid;
+	                $attachquery = "select * from vtiger_attachments where vtiger_attachmentsid = ".$attachmentid;
 	                $result = $adb->query($attachquery);
 	                $filename = $adb->query_result($result,0,'name');
 	                $filetype = $adb->query_result($result,0,'type');
@@ -58,8 +58,8 @@
 	                $_FILES['filename']['name'] = $filename;
 	                $_FILES['filename']['type'] = $filetype;
 
-			//we should read the file and calculate the size, without setting filesize, attachment will not save
-	                $filesize = filesize($filepath.$filename);
+			//we should read the file and calculate the size, without setting vtiger_filesize, attachment will not save
+	                $filesize = vtiger_filesize($filepath.$filename);
 	                $_FILES['filename']['size'] = $filesize;
 	        }
 }
@@ -85,7 +85,7 @@
 		$crmid = $_REQUEST['ticket_id'];
 	if($crmid != $_REQUEST['parent_id'])
 	{
-		$sql = "insert into senotesrel (notesid, crmid) values('".$focus->id."','".$crmid."')";
+		$sql = "insert into vtiger_senotesrel (notesid, crmid) values('".$focus->id."','".$crmid."')";
 		$adb->query($sql);
 	}
 }

Modified: vtigercrm/trunk/modules/Notes/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Notes/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Notes/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -42,7 +42,7 @@
 'LBL_EMAIL_ADDRESS'=>'Email Address:',
 'LBL_COLON'=>':',
 
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
 'LBL_LIST_FILENAME'=>"File",
 
 // Added for Note(3.2-patch 3) 

Modified: vtigercrm/trunk/modules/Portal/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Portal/ListView.php (original)
+++ vtigercrm/trunk/modules/Portal/ListView.php Mon Jun 12 14:26:25 2006
@@ -21,7 +21,7 @@
 $current_module_strings = return_module_language($current_language, 'Portal');
 global $adb;
 	
-$query="select * from portal";
+$query="select * from vtiger_portal";
 $result=$adb->query($query);
 $no_of_portals=$adb->num_rows($result);
 $portal_info=array();

Modified: vtigercrm/trunk/modules/Portal/Popup.php
==============================================================================
--- vtigercrm/trunk/modules/Portal/Popup.php (original)
+++ vtigercrm/trunk/modules/Portal/Popup.php Mon Jun 12 14:26:25 2006
@@ -17,7 +17,7 @@
 if(isset($_REQUEST['record']) && $_REQUEST['record'] !='')
 {
 	$portalid = $_REQUEST['record'];
-	$query="select * from portal where portalid =$portalid";
+	$query="select * from vtiger_portal where vtiger_portalid =$portalid";
 	$result=$adb->query($query);
 	$portalname = $adb->query_result($result,0,'portalname');
         $portalurl = $adb->query_result($result,0,'portalurl');		

Modified: vtigercrm/trunk/modules/Portal/Portal.php
==============================================================================
--- vtigercrm/trunk/modules/Portal/Portal.php (original)
+++ vtigercrm/trunk/modules/Portal/Portal.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 	global $adb;
 	$adb->println("just entered the SavePortal method");
 	$portalid=$adb->getUniqueID('portal');
-	$query="insert into portal values(".$portalid.",'".$portalname."','".$portalurl."',0)";
+	$query="insert into vtiger_portal values(".$portalid.",'".$portalname."','".$portalurl."',0)";
 	$adb->println($query);
 	$result=$adb->query($query);
 	return $portalid;
@@ -25,7 +25,7 @@
 {
 	global $adb;
 	$adb->println("just entered the SavePortal method");
-	$query="update portal set portalname='$portalname' ,portalurl='$portalurl' where portalid=$portalid";
+	$query="update vtiger_portal set portalname='$portalname' ,portalurl='$portalurl' where portalid=$portalid";
 	$adb->println($query);
 	$result=$adb->query($query);
 	return $portalid;

Modified: vtigercrm/trunk/modules/Potentials/Charts.php
==============================================================================
--- vtigercrm/trunk/modules/Potentials/Charts.php (original)
+++ vtigercrm/trunk/modules/Potentials/Charts.php Mon Jun 12 14:26:25 2006
@@ -29,7 +29,7 @@
 
 class jpgraph {
 	/**
-	 * Creates opportunity pipeline image as a horizontal accumlated bar graph for multiple users.
+	 * Creates opportunity pipeline image as a horizontal accumlated bar graph for multiple vtiger_users.
 	 * param $datax- the month data to display in the x-axis
 	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
 	 * All Rights Reserved..
@@ -345,7 +345,7 @@
 		}
 		else {
 			$imgMap_fp = fopen($cache_file_name.'.map', "rb");
-			$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
+			$imgMap = fread($imgMap_fp, vtiger_filesize($cache_file_name.'.map'));
 			fclose($imgMap_fp);
 		}
 		$fileModTime = filemtime($cache_file_name.'.map');
@@ -355,11 +355,11 @@
 	}
 
 	/**
-	 * Creates lead_source_by_outcome pipeline image as a horizontal accumlated bar graph for multiple users.
+	 * Creates lead_source_by_outcome pipeline image as a horizontal accumlated bar graph for multiple vtiger_users.
 	 * param $datay- the lead source data to display in the x-axis
 	 * param $date_start- the begin date of opps to find
 	 * param $date_end- the end date of opps to find
-	 * param $ids - list of assigned users of opps to find
+	 * param $ids - list of assigned vtiger_users of opps to find
 	 * param $cache_file_name - file name to write image to
 	 * param $refresh - boolean whether to rebuild image if exists
 	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
@@ -680,7 +680,7 @@
 		}
 		else {
 			$imgMap_fp = fopen($cache_file_name.'.map', "rb");
-			$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
+			$imgMap = fread($imgMap_fp, vtiger_filesize($cache_file_name.'.map'));
 			fclose($imgMap_fp);
 		}
 		$fileModTime = filemtime($cache_file_name.'.map');
@@ -690,7 +690,7 @@
 	}
 
 	/**
-	 * Creates opportunity pipeline image as a horizontal accumlated bar graph for multiple users.
+	 * Creates opportunity pipeline image as a horizontal accumlated bar graph for multiple vtiger_users.
 	 * param $datax- the sales stage data to display in the x-axis
 	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
 	 * All Rights Reserved..
@@ -1001,7 +1001,7 @@
 		}
 		else {
 			$imgMap_fp = fopen($cache_file_name.'.map', "rb");
-			$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
+			$imgMap = fread($imgMap_fp, vtiger_filesize($cache_file_name.'.map'));
 			fclose($imgMap_fp);
 		}
 		$fileModTime = filemtime($cache_file_name.'.map');
@@ -1103,7 +1103,7 @@
 					}
 					else
 					{
-						// put none in if the field is blank.
+						// put none in if the vtiger_field is blank.
 						array_push($visible_legends, $current_module_strings['NTC_NO_LEGENDS']);
 					}
 					array_push($aTargets, "index.php?module=Potentials&action=ListView&leadsource=".urlencode($lead_source_key)."&query=true&type=dbrd");
@@ -1229,7 +1229,7 @@
 		}
 		else {
 			$imgMap_fp = fopen($cache_file_name.'.map', "rb");
-			$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
+			$imgMap = fread($imgMap_fp, vtiger_filesize($cache_file_name.'.map'));
 			fclose($imgMap_fp);
 		}
 		$fileModTime = filemtime($cache_file_name.'.map');

Modified: vtigercrm/trunk/modules/Potentials/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Potentials/EditView.php (original)
+++ vtigercrm/trunk/modules/Potentials/EditView.php Mon Jun 12 14:26:25 2006
@@ -61,7 +61,7 @@
 $category = getParentTab();
 $smarty->assign("CATEGORY",$category);
 
-//needed when creating a new opportunity with a default account value passed in
+//needed when creating a new opportunity with a default vtiger_account value passed in
 if (isset($_REQUEST['accountname']) && is_null($focus->accountname)) {
 	$focus->accountname = $_REQUEST['accountname'];
 	
@@ -104,7 +104,7 @@
 
 
 
-// Unimplemented until jscalendar language files are fixed
+// Unimplemented until jscalendar language vtiger_files are fixed
 $smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
 $smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
 

Modified: vtigercrm/trunk/modules/Potentials/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Potentials/Forms.php (original)
+++ vtigercrm/trunk/modules/Potentials/Forms.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 /*********************************************************************************
  * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/Forms.php,v 1.11 2005/04/20 20:25:13 ray Exp $
  * Description:  Contains a variety of utility functions used to display UI
- * components such as form headers and footers.  Intended to be modified on a per
+ * components such as form vtiger_headers and footers.  Intended to be modified on a per
  * theme basis.
  ********************************************************************************/
 
@@ -182,7 +182,7 @@
 }
 
 /**
- * Create HTML form to enter a new record with the minimum necessary fields.
+ * Create HTML form to enter a new record with the minimum necessary vtiger_fields.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
@@ -197,7 +197,7 @@
 global $current_user;
 global $adb;//for dynamic quickcreateform construction
 
-// Unimplemented until jscalendar language files are fixed
+// Unimplemented until jscalendar language vtiger_files are fixed
 // global $current_language;
 // global $default_language;
 // global $cal_codes;
@@ -214,7 +214,7 @@
 $lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY'];
 $lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL'];
 $user_id = $current_user->id;
-// Unimplemented until jscalendar language files are fixed
+// Unimplemented until jscalendar language vtiger_files are fixed
 // $cal_lang = (empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language];
 $cal_lang = "en";
 $cal_dateformat = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
@@ -227,7 +227,7 @@
 
 $qcreate_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
 
-$qcreate_get_field="select * from field where tabid=2 and quickcreate=0 order by quickcreatesequence";
+$qcreate_get_field="select * from vtiger_field where vtiger_tabid=2 and quickcreate=0 order by quickcreatesequence";
 $qcreate_get_result=$adb->query($qcreate_get_field);
 $qcreate_get_noofrows=$adb->num_rows($qcreate_get_result);
 
@@ -317,9 +317,9 @@
 		Calendar.setup ({
 			inputField : "QCK_closingdate", ifFormat : "'.$cal_dateformat.'", showsTime : false, button : "jscal_trigger", singleClick : true, step : 1
 		});
-	var fieldname = new Array('.$fieldName.')
-	var fieldlabel = new Array('.$fieldLabel.')
-	var fielddatatype = new Array('.$fldDataType.')
+	var vtiger_fieldname = new Array('.$fieldName.')
+	var vtiger_fieldlabel = new Array('.$fieldLabel.')
+	var vtiger_fielddatatype = new Array('.$fldDataType.')
 
 
 		</script>';

Modified: vtigercrm/trunk/modules/Potentials/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Potentials/ListView.php (original)
+++ vtigercrm/trunk/modules/Potentials/ListView.php Mon Jun 12 14:26:25 2006
@@ -80,7 +80,7 @@
 	$smarty->assign("SEARCH_URL",$url_string);
 				
 	//Added for Custom Field Search
-/*	$sql="select * from field where tablename='potentialscf' order by fieldlabel";
+/*	$sql="select * from vtiger_field where vtiger_tablename='potentialscf' order by vtiger_fieldlabel";
 	$result=$adb->query($sql);
 	for($i=0;$i<$adb->num_rows($result);$i++)
 	{
@@ -92,11 +92,11 @@
 		if(isset($customfield[$i]) && $customfield[$i] != '')
 		{
 			if($uitype[$i] == 56)
-				$str = " potentialscf.".$column[$i]." = 1";
+				$str = " vtiger_potentialscf.".$column[$i]." = 1";
 			elseif($uitype[$i] == 15)//Added to handle the picklist customfield - after 4.2 patch2
-				$str = " potentialscf.".$column[$i]." = '".$customfield[$i]."'";
+				$str = " vtiger_potentialscf.".$column[$i]." = '".$customfield[$i]."'";
 			else
-				$str = " potentialscf.".$column[$i]." like '$customfield[$i]%'";
+				$str = " vtiger_potentialscf.".$column[$i]." like '$customfield[$i]%'";
 			array_push($where_clauses, $str);
 			$url_string .="&".$column[$i]."=".$customfield[$i];
 		}

Modified: vtigercrm/trunk/modules/Potentials/ListViewTop.php
==============================================================================
--- vtigercrm/trunk/modules/Potentials/ListViewTop.php (original)
+++ vtigercrm/trunk/modules/Potentials/ListViewTop.php Mon Jun 12 14:26:25 2006
@@ -38,7 +38,7 @@
 	$title[]='myTopOpenPotentials.gif';
 	$title[]=$current_module_strings['LBL_TOP_OPPORTUNITIES'];
 	$title[]='home_mypot';
-	$where = "AND potential.sales_stage <> '".$app_strings['LBL_CLOSE_WON']."' AND potential.sales_stage <> '".$app_strings['LBL_CLOSE_LOST']."' AND crmentity.smownerid='".$current_user->id."' ORDER BY amount DESC";
+	$where = "AND vtiger_potential.sales_stage <> '".$app_strings['LBL_CLOSE_WON']."' AND vtiger_potential.sales_stage <> '".$app_strings['LBL_CLOSE_LOST']."' AND vtiger_crmentity.smownerid='".$current_user->id."' ORDER BY amount DESC";
 	$header=array();
 	$header[]=$current_module_strings['LBL_LIST_OPPORTUNITY_NAME'];
 	$header[]=$current_module_strings['LBL_LIST_ACCOUNT_NAME'];

Modified: vtigercrm/trunk/modules/Potentials/Opportunity.php
==============================================================================
--- vtigercrm/trunk/modules/Potentials/Opportunity.php (original)
+++ vtigercrm/trunk/modules/Potentials/Opportunity.php Mon Jun 12 14:26:25 2006
@@ -31,7 +31,7 @@
 require_once('modules/Emails/Email.php');
 require_once('include/utils/utils.php');
 
-// potential is used to store customer information.
+// vtiger_potential is used to store customer information.
 class Potential extends CRMEntity {
 	var $log;
 	var $db;
@@ -43,15 +43,15 @@
 	var $module_id = "potentialid";
 	var $object_name = "potential";
 
-	var $tab_name = Array('crmentity','potential','potentialscf');
-	var $tab_name_index = Array('crmentity'=>'crmid','potential'=>'potentialid','potentialscf'=>'potentialid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_potential','vtiger_potentialscf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_potential'=>'potentialid','vtiger_potentialscf'=>'potentialid');
 
 	var $column_fields = Array();
 
 	var $sortby_fields = Array('potentialname','amount','closingdate','smownerid');
 
 
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
 			'Potential'=>Array('potential'=>'potentialname'),
 			'Account Name'=>Array('account'=>'accountname'),	  			
@@ -95,7 +95,7 @@
 	var $default_order_by = 'potentialname';
 	var $default_sort_order = 'ASC';
 
-	function potential() {
+	function Potential() {
 		$this->log = LoggerManager::getLogger('potential');
 		$this->db = new PearDatabase();
 		$this->column_fields = getColumnFields('Potentials');
@@ -107,18 +107,18 @@
 	{
 		global $log;
 		$log->debug("Entering create_list_query(".$order_by.",". $where.") method ...");
-		// Determine if the account name is present in the where clause.
+		// Determine if the vtiger_account name is present in the where clause.
 		$account_required = ereg("accounts\.name", $where);
 
 		if($account_required)
 		{
-			$query = "SELECT potential.potentialid,  potential.potentialname, potential.dateclosed FROM potential, account ";
-			$where_auto = "account.accountid = potential.accountid AND crmentity.deleted=0 ";
+			$query = "SELECT vtiger_potential.potentialid,  vtiger_potential.potentialname, vtiger_potential.dateclosed FROM vtiger_potential, vtiger_account ";
+			$where_auto = "account.accountid = vtiger_potential.accountid AND vtiger_crmentity.deleted=0 ";
 		}
 		else
 		{
-			$query = 'SELECT potentialid, potentialname, smcreatorid, closingdate FROM potential inner join crmentity on crmentity.crmid=potential.potentialid ';
-			$where_auto = 'AND crmentity.deleted=0';
+			$query = 'SELECT potentialid, potentialname, smcreatorid, closingdate FROM vtiger_potential inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid ';
+			$where_auto = 'AND vtiger_crmentity.deleted=0';
 		}
 
 		if($where != "")
@@ -127,9 +127,9 @@
 			$query .= "where ".$where_auto;
 
 		if($order_by != "")
-			$query .= " ORDER BY potential.$order_by";
+			$query .= " ORDER BY vtiger_potential.$order_by";
 		else
-			$query .= " ORDER BY potential.potentialname";
+			$query .= " ORDER BY vtiger_potential.potentialname";
 
 
 
@@ -146,25 +146,25 @@
 		if($this->checkIfCustomTableExists('potentialscf'))
 		{
 			$query = $this->constructCustomQueryAddendum('potentialscf','Potentials') ."
-				potential.*,
-				account.accountname account_name,
-				users.user_name assigned_user_name
-					FROM potential
-					INNER JOIN crmentity
-					ON crmentity.crmid=potential.potentialid
-					LEFT JOIN account on potential.accountid=account.accountid
-					left join potentialscf on potentialscf.potentialid=potential.potentialid
-					left join users on crmentity.smownerid=users.id where crmentity.deleted=0 ";
+			vtiger_potential.*,
+			vtiger_account.accountname vtiger_account_name,
+			vtiger_users.user_name assigned_user_name
+					FROM vtiger_potential
+					INNER JOIN vtiger_crmentity
+					ON vtiger_crmentity.crmid=vtiger_potential.potentialid
+					LEFT JOIN vtiger_account on vtiger_potential.accountid=vtiger_account.accountid
+					left join vtiger_potentialscf on vtiger_potentialscf.potentialid=vtiger_potential.potentialid
+					left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_crmentity.deleted=0 ";
 		}
 		else
 		{
 			$query = "SELECT
-				potential.*,
-				account.accountname account_name,
-				users.user_name assigned_user_name
-					FROM potential inner join crmentity on crmentity.crmid=potential.potentialid                                LEFT JOIN users
-					ON crmentity.smownerid=users.id
-					LEFT JOIN account on potential.accountid=account.accountid  LEFT JOIN potentialscf on potentialscf.potentialid=potential.potentialid where crmentity.deleted=0 ";
+			vtiger_potential.*,
+			vtiger_account.accountname vtiger_account_name,
+			vtiger_users.user_name assigned_user_name
+					FROM vtiger_potential inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid                                LEFT JOIN vtiger_users
+					ON vtiger_crmentity.smownerid=vtiger_users.id
+					LEFT JOIN vtiger_account on vtiger_potential.accountid=vtiger_account.accountid  LEFT JOIN vtiger_potentialscf on vtiger_potentialscf.potentialid=vtiger_potential.potentialid where vtiger_crmentity.deleted=0 ";
 		}	
 
 		$log->debug("Exiting create_export_query method ...");
@@ -192,11 +192,11 @@
 		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&action=Popup&return_module=Potentials&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
+			$button .= '<input title="Change" accessKey="" vtiger_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&action=Popup&return_module=Potentials&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
 		}
 		$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
 
-		$query = 'select contactdetails.accountid, users.user_name,groups.groupname,potential.potentialid, potential.potentialname, contactdetails.contactid, contactdetails.lastname, contactdetails.firstname, contactdetails.title, contactdetails.department, contactdetails.email, contactdetails.phone, crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime from potential inner join contpotentialrel on contpotentialrel.potentialid = potential.potentialid inner join contactdetails on contpotentialrel.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 left join users on crmentity.smownerid=users.id where potential.potentialid = '.$id.' and crmentity.deleted=0';
+		$query = 'select vtiger_contactdetails.accountid, vtiger_users.user_name,vtiger_groups.groupname,vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title, vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_potential inner join vtiger_contpotentialrel on vtiger_contpotentialrel.potentialid = vtiger_potential.potentialid inner join vtiger_contactdetails on vtiger_contpotentialrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_potential.potentialid = '.$id.' and vtiger_crmentity.deleted=0';
 		
 		$log->debug("Exiting get_contacts method ...");
 		return GetRelatedList('Potentials','Contacts',$focus,$query,$button,$returnset);
@@ -225,7 +225,7 @@
 		}
 		$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT activity.*,seactivityrel.*,crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime, users.user_name, recurringevents.recurringtype, contactdetails.contactid, contactdetails.lastname, contactdetails.firstname from activity inner join seactivityrel on seactivityrel.activityid=activity.activityid inner join crmentity on crmentity.crmid=activity.activityid inner join potential on potential.potentialid=seactivityrel.crmid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid= cntactivityrel.contactid left join users on users.id=crmentity.smownerid left join activitygrouprelation on activitygrouprelation.activityid=crmentity.crmid left join groups on groups.groupname=activitygrouprelation.groupname left outer join recurringevents on recurringevents.activityid=activity.activityid where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and (activity.status is not NULL && activity.status != 'Completed') and (activity.status is not NULL && activity.status != 'Deferred') or (activity.eventstatus != '' &&  activity.eventstatus != 'Held')";
+		$query = "SELECT vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name, vtiger_recurringevents.recurringtype, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_potential on vtiger_potential.potentialid=vtiger_seactivityrel.crmid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or vtiger_activitytype='Call' or vtiger_activitytype='Meeting') and vtiger_crmentity.deleted=0 and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Deferred') or (vtiger_activity.eventstatus != '' &&  vtiger_activity.eventstatus != 'Held')";
 		$log->debug("Exiting get_activities method ...");
 		return GetRelatedList('Potentials','Activities',$focus,$query,$button,$returnset);
 
@@ -251,11 +251,11 @@
 		}
 		if(isPermitted("Products",3,"") == 'yes')
 		{
-			$button .= '<input title="Change" accessKey="" tabindex="2" type="button" class="button" value="'.$app_strings['LBL_SELECT_PRODUCT_BUTTON_LABEL'].'" name="Button" LANGUAGE=javascript onclick=\'return window.open("index.php?module=Products&action=Popup&return_module=Potentials&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
+			$button .= '<input title="Change" accessKey="" vtiger_tabindex="2" type="button" class="button" value="'.$app_strings['LBL_SELECT_PRODUCT_BUTTON_LABEL'].'" name="Button" LANGUAGE=javascript onclick=\'return window.open("index.php?module=Products&action=Popup&return_module=Potentials&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
 		}
 		$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
 
-		$query = 'select products.productid, products.productname, products.productcode, products.commissionrate, products.qty_per_unit, products.unit_price, crmentity.crmid, crmentity.smownerid from products inner join seproductsrel on products.productid = seproductsrel.productid inner join crmentity on crmentity.crmid = products.productid inner join potential on potential.potentialid = seproductsrel.crmid  where potential.potentialid = '.$id.' and crmentity.deleted = 0';
+		$query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid from vtiger_products inner join vtiger_seproductsrel on vtiger_products.productid = vtiger_seproductsrel.productid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid inner join vtiger_potential on vtiger_potential.potentialid = vtiger_seproductsrel.crmid  where vtiger_potential.potentialid = '.$id.' and vtiger_crmentity.deleted = 0';
 		$log->debug("Exiting get_products method ...");
 		return GetRelatedList('Potentials','Products',$focus,$query,$button,$returnset);
 	}
@@ -370,7 +370,7 @@
 
 		}
 
-		$query = 'select potstagehistory.*, potential.potentialname from potstagehistory inner join potential on potential.potentialid = potstagehistory.potentialid inner join crmentity on crmentity.crmid = potential.potentialid where crmentity.deleted = 0 and potential.potentialid = '.$id;
+		$query = 'select vtiger_potstagehistory.*, vtiger_potential.potentialname from vtiger_potstagehistory inner join vtiger_potential on vtiger_potential.potentialid = vtiger_potstagehistory.potentialid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid where vtiger_crmentity.deleted = 0 and vtiger_potential.potentialid = '.$id;
 	 $log->debug("Exiting get_stage_history method ...");
 	}
 
@@ -378,21 +378,21 @@
 	{
 		 global $log;
 		$log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT activity.activityid, activity.subject, activity.status,
-			activity.eventstatus, activity.activitytype, contactdetails.contactid,
-			contactdetails.firstname, contactdetails.lastname, crmentity.modifiedtime,
-			crmentity.createdtime, crmentity.description, users.user_name
-				from activity
-				inner join seactivityrel on seactivityrel.activityid=activity.activityid
-				inner join crmentity on crmentity.crmid=activity.activityid
-				left join cntactivityrel on cntactivityrel.activityid= activity.activityid
-				left join contactdetails on contactdetails.contactid= cntactivityrel.contactid
-				left join activitygrouprelation on activitygrouprelation.activityid=activity.activityid
-				left join groups on groups.groupname=activitygrouprelation.groupname
-				inner join users on crmentity.smcreatorid= users.id
-				where (activity.activitytype = 'Meeting' or activity.activitytype='Call' or activity.activitytype='Task')
-				and (activity.status = 'Completed' or activity.status = 'Deferred' or (activity.eventstatus = 'Held' and activity.eventstatus != ''))
-				and seactivityrel.crmid=".$id;
+		$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status,
+		vtiger_activity.eventstatus, vtiger_activity.activitytype, vtiger_contactdetails.contactid,
+		vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_crmentity.modifiedtime,
+		vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
+				from vtiger_activity
+				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
+				left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid
+				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+				left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
+				where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
+				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
+				and vtiger_seactivityrel.crmid=".$id;
 		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
 
 		$log->debug("Exiting get_history method ...");
@@ -404,35 +404,35 @@
 		 global $log;
 		$log->debug("Entering get_attachments(".$id.") method ...");
 		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crm2.createdtime, notes.notecontent description, users.user_name
-		// Inserted inner join users on crm2.smcreatorid= users.id
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename,
-			attachments.type  FileType, crm2.modifiedtime lastmodified,
-			seattachmentsrel.attachmentsid, notes.notesid crmid,
-			crm2.createdtime, notes.notecontent description, users.user_name
-				from notes
-				inner join senotesrel on senotesrel.notesid= notes.notesid
-				inner join crmentity on crmentity.crmid= senotesrel.crmid
-				inner join crmentity crm2 on crm2.crmid=notes.notesid and crm2.deleted=0
-				left join seattachmentsrel  on seattachmentsrel.crmid =notes.notesid
-				left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid
-				inner join users on crm2.smcreatorid= users.id
-				where crmentity.crmid=".$id;
+		// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		$query = "select vtiger_notes.title,'Notes      '  ActivityType, vtiger_notes.filename,
+		vtiger_attachments.type  FileType, crm2.modifiedtime lastmodified,
+		vtiger_seattachmentsrel.attachmentsid, vtiger_notes.notesid crmid,
+			crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+				from vtiger_notes
+				inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
+				inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+				left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+				left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+				inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+				where vtiger_crmentity.crmid=".$id;
 		$query .= ' union all ';
 		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crm2.createdtime, attachments.description, users.user_name
-		// Inserted inner join users on crm2.smcreatorid= users.id
+		// Desc: Inserted crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
 		// Inserted order by createdtime desc
-		$query .= "select attachments.description title ,'Attachments'  ActivityType,
-			attachments.name filename, attachments.type FileType,crm2.modifiedtime lastmodified,
-			attachments.attachmentsid, seattachmentsrel.attachmentsid crmid,
-			crm2.createdtime, attachments.description, users.user_name
-				from attachments
-				inner join seattachmentsrel on seattachmentsrel.attachmentsid= attachments.attachmentsid
-				inner join crmentity on crmentity.crmid= seattachmentsrel.crmid
-				inner join crmentity crm2 on crm2.crmid=attachments.attachmentsid
-				inner join users on crm2.smcreatorid= users.id
-				where crmentity.crmid=".$id."
+		$query .= "select vtiger_attachments.description title ,'Attachments'  ActivityType,
+		vtiger_attachments.name filename, vtiger_attachments.type FileType,crm2.modifiedtime lastmodified,
+		vtiger_attachments.attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
+			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+				from vtiger_attachments
+				inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+				inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+				inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+				where vtiger_crmentity.crmid=".$id."
 				order by createdtime desc";
 
 		$log->debug("Exiting get_attachments method ...");
@@ -457,7 +457,7 @@
 		$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
 
 
-		$query = "select crmentity.*, quotes.*, potential.potentialname, users.user_name from quotes inner join crmentity on crmentity.crmid=quotes.quoteid left outer join potential on potential.potentialid=quotes.potentialid left join quotegrouprelation on quotes.quoteid=quotegrouprelation.quoteid left join groups on groups.groupname=quotegrouprelation.groupname left join users on users.id=crmentity.smownerid where crmentity.deleted=0 and potential.potentialid=".$id;
+		$query = "select vtiger_crmentity.*, vtiger_quotes.*, vtiger_potential.potentialname, vtiger_users.user_name from vtiger_quotes inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_quotes.potentialid left join vtiger_quotegrouprelation on vtiger_quotes.quoteid=vtiger_quotegrouprelation.quoteid left join vtiger_groups on vtiger_groups.groupname=vtiger_quotegrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid=".$id;
 		$log->debug("Exiting get_quotes method ...");
 		return  GetRelatedList('Potentials','Quotes',$focus,$query,$button,$returnset);
 	}
@@ -480,7 +480,7 @@
 		$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
 
 
-		$query = "select crmentity.*, salesorder.*, quotes.subject as quotename, account.accountname, potential.potentialname from salesorder inner join crmentity on crmentity.crmid=salesorder.salesorderid left outer join quotes on quotes.quoteid=salesorder.quoteid left outer join account on account.accountid=salesorder.accountid left outer join potential on potential.potentialid=salesorder.potentialid left join sogrouprelation on salesorder.salesorderid=sogrouprelation.salesorderid left join groups on groups.groupname=sogrouprelation.groupname where crmentity.deleted=0 and potential.potentialid = ".$id;
+		$query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename, vtiger_account.accountname, vtiger_potential.potentialname from vtiger_salesorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_salesorder.potentialid left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid = ".$id;
 		$log->debug("Exiting get_salesorder method ...");
 		return GetRelatedList('Potentials','SalesOrder',$focus,$query,$button,$returnset);
 

Modified: vtigercrm/trunk/modules/Potentials/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Potentials/Save.php (original)
+++ vtigercrm/trunk/modules/Potentials/Save.php Mon Jun 12 14:26:25 2006
@@ -56,7 +56,7 @@
 if($_REQUEST['return_viewname'] == '') $return_viewname='0';
 if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
 
-//Added to send mail to the potential-owner about the Potential
+//Added to send mail to the vtiger_potential-owner about the Potential
 $status = sendNotificationToOwner('Potentials',&$focus);
 
 header("Location: index.php?action=$return_action&module=$return_module&record=$return_id&viewname=$return_viewname");

Modified: vtigercrm/trunk/modules/Potentials/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Potentials/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Potentials/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -85,7 +85,7 @@
 'LBL_NEW_CONTACT'=>'New Contact',
 'LBL_CONTACT_TITLE'=>'Contacts',
 
-//Added fields after RC1 - Release
+//Added vtiger_fields after RC1 - Release
 'LBL_ALL'=>'All',
 'LBL_WON'=>'Won',
 'LBL_LOST'=>'Lost',

Modified: vtigercrm/trunk/modules/Potentials/updateRelations.php
==============================================================================
--- vtigercrm/trunk/modules/Potentials/updateRelations.php (original)
+++ vtigercrm/trunk/modules/Potentials/updateRelations.php Mon Jun 12 14:26:25 2006
@@ -21,9 +21,9 @@
 	{
 		if($id != '')
 		{
-		$sql = "insert into contpotentialrel values (".$id.",".$_REQUEST["parentid"] .")";
+		$sql = "insert into vtiger_contpotentialrel values (".$id.",".$_REQUEST["parentid"] .")";
 		$adb->query($sql);
-		$sql = "insert into seproductsrel values (". $_REQUEST["parentid"] .",".$id.")";
+		$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parentid"] .",".$id.")";
 		$adb->query($sql);
 		}
 	}
@@ -31,9 +31,9 @@
 }
 elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
 {
-		$sql = "insert into contpotentialrel values (". $_REQUEST["entityid"] .",".$_REQUEST["parid"] .")";
+		$sql = "insert into vtiger_contpotentialrel values (". $_REQUEST["entityid"] .",".$_REQUEST["parid"] .")";
 		$adb->query($sql);
-		$sql = "insert into seproductsrel values (". $_REQUEST["parid"] .",".$_REQUEST["entityid"] .")";
+		$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parid"] .",".$_REQUEST["entityid"] .")";
 		$adb->query($sql);
  		header("Location: index.php?action=CallRelatedList&module=Potentials&record=".$_REQUEST["parid"]);
 }

Modified: vtigercrm/trunk/modules/PriceBooks/PriceBook.php
==============================================================================
--- vtigercrm/trunk/modules/PriceBooks/PriceBook.php (original)
+++ vtigercrm/trunk/modules/PriceBooks/PriceBook.php Mon Jun 12 14:26:25 2006
@@ -22,17 +22,17 @@
 	var $db;
 
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $mode;
 
-	var $tab_name = Array('crmentity','pricebook','pricebookcf');
-	var $tab_name_index = Array('crmentity'=>'crmid','pricebook'=>'pricebookid','pricebookcf'=>'pricebookid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_pricebook','vtiger_pricebookcf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_pricebook'=>'pricebookid','vtiger_pricebookcf'=>'pricebookid');
 	var $column_fields = Array();
 
 	var $sortby_fields = Array('bookname');		  
 
-        // This is the list of fields that are in the lists.
+        // This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
                                 'Price Book Name'=>Array('pricebook'=>'bookname'),
                                 'Active'=>Array('pricebook'=>'active')
@@ -78,7 +78,7 @@
 
 		$returnset = '&return_module=PriceBooks&return_action=DetailView&return_id='.$id;
 
-		$query = 'select products.productid, products.productname, products.productcode, products.commissionrate, products.qty_per_unit, products.unit_price, crmentity.crmid, crmentity.smownerid,pricebookproductrel.listprice from products inner join pricebookproductrel on products.productid = pricebookproductrel.productid inner join crmentity on crmentity.crmid = products.productid inner join pricebook on pricebook.pricebookid = pricebookproductrel.pricebookid  where pricebook.pricebookid = '.$id.' and crmentity.deleted = 0'; 
+		$query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_pricebookproductrel.listprice from vtiger_products inner join vtiger_pricebookproductrel on vtiger_products.productid = vtiger_pricebookproductrel.productid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid inner join vtiger_pricebook on vtiger_pricebook.pricebookid = vtiger_pricebookproductrel.pricebookid  where vtiger_pricebook.pricebookid = '.$id.' and vtiger_crmentity.deleted = 0'; 
 		$log->debug("Exiting get_pricebook_products method ...");
 		return getPriceBookRelatedProducts($query,$focus,$returnset);
 	}
@@ -87,11 +87,11 @@
 		global $log;
 		$log->debug("Entering get_pricebook_noproduct(".$id.") method ...");
 		 
-		$query = "select crmentity.crmid, pricebook.* from pricebook inner join crmentity on crmentity.crmid=pricebook.pricebookid where crmentity.deleted=0";                                                                                                  $result = $this->db->query($query);
+		$query = "select vtiger_crmentity.crmid, vtiger_pricebook.* from vtiger_pricebook inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_pricebook.pricebookid where vtiger_crmentity.deleted=0";                                                                                                  $result = $this->db->query($query);
 		$no_count = $this->db->num_rows($result);
 		if($no_count !=0)
 		{
-       	 		$pb_query = 'select crmentity.crmid, pricebook.pricebookid,pricebookproductrel.productid from pricebook inner join crmentity on crmentity.crmid=pricebook.pricebookid inner join pricebookproductrel on pricebookproductrel.pricebookid=pricebook.pricebookid where crmentity.deleted=0 and pricebookproductrel.productid='.$id;
+       	 		$pb_query = 'select vtiger_crmentity.crmid, vtiger_pricebook.pricebookid,vtiger_pricebookproductrel.productid from vtiger_pricebook inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_pricebook.pricebookid inner join vtiger_pricebookproductrel on vtiger_pricebookproductrel.pricebookid=vtiger_pricebook.pricebookid where vtiger_crmentity.deleted=0 and vtiger_pricebookproductrel.productid='.$id;
 			$result_pb = $this->db->query($pb_query);
 			if($no_count == $this->db->num_rows($result_pb))
 			{

Modified: vtigercrm/trunk/modules/Products/AddProductToPriceBooks.php
==============================================================================
--- vtigercrm/trunk/modules/Products/AddProductToPriceBooks.php (original)
+++ vtigercrm/trunk/modules/Products/AddProductToPriceBooks.php Mon Jun 12 14:26:25 2006
@@ -50,16 +50,16 @@
 $list_query = getListQuery("PriceBooks");
 $xtpl->assign("PRICEBOOKLISTHEADER", get_form_header($current_module_strings['LBL_LIST_PRICEBOOK_FORM_TITLE'], $other_text, false ));
 
-$list_query .= ' ORDER BY pricebookid DESC ';
+$list_query .= ' ORDER BY vtiger_pricebookid DESC ';
 
 $list_result = $adb->query($list_query);
 $num_rows = $adb->num_rows($list_result);
 
 $record_string= "Total No of Rows: ".$num_rows;
 
-//Retreiving the array of already releated products;
+//Retreiving the array of already releated vtiger_products;
 
-$sql1="select crmentity.crmid, pricebookproductrel.pricebookid,products.unit_price from pricebookproductrel inner join crmentity on crmentity.crmid=pricebookproductrel.productid inner join products on products.productid=pricebookproductrel.productid where crmentity.deleted=0 and pricebookproductrel.productid=".$productid;
+$sql1="select vtiger_crmentity.crmid, vtiger_pricebookproductrel.pricebookid,vtiger_products.unit_price from vtiger_pricebookproductrel inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_pricebookproductrel.productid inner join vtiger_products on vtiger_products.productid=vtiger_pricebookproductrel.productid where vtiger_crmentity.deleted=0 and vtiger_pricebookproductrel.productid=".$productid;
 $res1 = $adb->query($sql1);
 $num_prod_rows = $adb->num_rows($res1);
 $pbk_array = Array();

Modified: vtigercrm/trunk/modules/Products/AddProductsToPriceBook.php
==============================================================================
--- vtigercrm/trunk/modules/Products/AddProductsToPriceBook.php (original)
+++ vtigercrm/trunk/modules/Products/AddProductsToPriceBook.php Mon Jun 12 14:26:25 2006
@@ -58,7 +58,7 @@
 
 	$where_clauses = Array();
 	//Added for Custom Field Search
-	$sql="select * from field where tablename='productcf' order by fieldlabel";
+	$sql="select * from vtiger_field where vtiger_tablename='productcf' order by vtiger_fieldlabel";
 	$result=$adb->query($sql);
 	for($i=0;$i<$adb->num_rows($result);$i++)
 	{
@@ -71,9 +71,9 @@
 	        if(isset($customfield[$i]) && $customfield[$i] != '')
 	        {
 			if($uitype[$i] == 56)
-                                $str=" productcf.".$column[$i]." = 1";
+                                $str=" vtiger_productcf.".$column[$i]." = 1";
                         else
-			        $str=" productcf.".$column[$i]." like '$customfield[$i]%'";
+			        $str=" vtiger_productcf.".$column[$i]." like '$customfield[$i]%'";
 		        array_push($where_clauses, $str);
 			$url_string .="&".$column[$i]."=".$customfield[$i];
 	        }
@@ -178,9 +178,9 @@
 
 $record_string= "Total No of Rows: ".$num_rows;
 
-//Retreiving the array of already releated products;
-
-$sql1 = "select productid from pricebookproductrel where pricebookid=".$pricebook_id;
+//Retreiving the array of already releated vtiger_products;
+
+$sql1 = "select productid from vtiger_pricebookproductrel where vtiger_pricebookid=".$pricebook_id;
 $res1 = $adb->query($sql1);
 $num_prod_rows = $adb->num_rows($res1);
 $prod_array = Array();
@@ -224,7 +224,7 @@
 for($i=0; $i<$num_rows; $i++)
 {
 	
-	 $log->info("Products :: Showing the List of products to be added in price book");
+	 $log->info("Products :: Showing the List of vtiger_products to be added in price book");
 	$entity_id = $adb->query_result($list_result,$i,"crmid");
 	if(! array_key_exists($entity_id, $prod_array))
 	{

Modified: vtigercrm/trunk/modules/Products/DeletePriceBookProductRel.php
==============================================================================
--- vtigercrm/trunk/modules/Products/DeletePriceBookProductRel.php (original)
+++ vtigercrm/trunk/modules/Products/DeletePriceBookProductRel.php Mon Jun 12 14:26:25 2006
@@ -18,13 +18,13 @@
 if($return_action !='' && $return_action=="DetailView")
 {
 	$log->info("Products :: Deleting Price Book");
-	$query = "delete from pricebookproductrel where pricebookid=".$record." and productid=".$return_id;
+	$query = "delete from vtiger_pricebookproductrel where vtiger_pricebookid=".$record." and productid=".$return_id;
 	$adb->query($query); 
 }
 else
 {
 	$log->info("Products :: Deleting Price Book");
-	$query = "delete from pricebookproductrel where pricebookid=".$return_id." and productid=".$record;
+	$query = "delete from vtiger_pricebookproductrel where vtiger_pricebookid=".$return_id." and productid=".$record;
 	$adb->query($query); 
 }
 

Modified: vtigercrm/trunk/modules/Products/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Products/EditView.php (original)
+++ vtigercrm/trunk/modules/Products/EditView.php Mon Jun 12 14:26:25 2006
@@ -63,7 +63,7 @@
     	$focus->mode = ''; 	
 } 
 
-//needed when creating a new product with a default vendor name to passed 
+//needed when creating a new product with a default vtiger_vendor name to passed 
 if (isset($_REQUEST['name']) && is_null($focus->name)) {
 	$focus->name = $_REQUEST['name'];
 	

Modified: vtigercrm/trunk/modules/Products/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Products/Forms.php (original)
+++ vtigercrm/trunk/modules/Products/Forms.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 /*********************************************************************************
  * $Header: /advent/projects/wesat/vtiger_crm/vtigercrm/modules/Products/Forms.php,v 1.3 2005/03/04 17:06:55 saraj Exp $
  * Description:  Contains a variety of utility functions used to display UI
- * components such as form headers and footers.  Intended to be modified on a per
+ * components such as form vtiger_headers and footers.  Intended to be modified on a per
  * theme basis.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
@@ -23,7 +23,7 @@
  ********************************************************************************/
 
 /**
- * Create HTML form to enter a new record with the minimum necessary fields.
+ * Create HTML form to enter a new record with the minimum necessary vtiger_fields.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
@@ -52,7 +52,7 @@
 $qcreate_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
 
 
-$qcreate_get_field="select * from field where tabid=14 and quickcreate=0 order by quickcreatesequence";
+$qcreate_get_field="select * from vtiger_field where vtiger_tabid=14 and quickcreate=0 order by quickcreatesequence";
 $qcreate_get_result=$adb->query($qcreate_get_field);
 $qcreate_get_noofrows=$adb->num_rows($qcreate_get_result);
 
@@ -140,9 +140,9 @@
 $qcreate_form.='</form>';
 $qcreate_form.='<script type="text/javascript">
 		
-	var fieldname = new Array('.$fieldName.')
-	var fieldlabel = new Array('.$fieldLabel.')
-	var fielddatatype = new Array('.$fldDataType.')
+	var vtiger_fieldname = new Array('.$fieldName.')
+	var vtiger_fieldlabel = new Array('.$fieldLabel.')
+	var vtiger_fielddatatype = new Array('.$fldDataType.')
 
 		</script>';
 

Modified: vtigercrm/trunk/modules/Products/Product.php
==============================================================================
--- vtigercrm/trunk/modules/Products/Product.php (original)
+++ vtigercrm/trunk/modules/Products/Product.php Mon Jun 12 14:26:25 2006
@@ -22,7 +22,7 @@
 	var $db;
 
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $mode;
 
@@ -42,13 +42,13 @@
         );
 
 
-	var $tab_name = Array('crmentity','products','productcf','seproductsrel','producttaxrel','attachments');
-	var $tab_name_index = Array('crmentity'=>'crmid','products'=>'productid','productcf'=>'productid','seproductsrel'=>'productid','producttaxrel'=>'productid','attachments'=>'attachmentsid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_products','vtiger_productcf','vtiger_seproductsrel','vtiger_producttaxrel','vtiger_attachments');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_products'=>'productid','vtiger_productcf'=>'productid','vtiger_seproductsrel'=>'productid','vtiger_producttaxrel'=>'productid','vtiger_attachments'=>'attachmentsid');
 	var $column_fields = Array();
 
 	var $sortby_fields = Array('productname','productcode','commissionrate');		  
 
-        // This is the list of fields that are in the lists.
+        // This is the list of vtiger_fields that are in the lists.
         var $list_fields = Array(
                                 'Product Name'=>Array('products'=>'productname'),
                                 'Product Code'=>Array('products'=>'productcode'),
@@ -100,50 +100,50 @@
 		global $log;
 		$log->debug("Entering get_attachments(".$id.") method ...");
 		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crmentity.createdtime, notes.notecontent description, users.user_name
-		// Inserted inner join users on crmentity.smcreatorid= users.id
-		$query = "SELECT notes.title, 'Notes      ' AS ActivityType,
-				notes.filename, attachments.type  AS FileType,
+		// Desc: Inserted vtiger_crmentity.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
+		$query = "SELECT vtiger_notes.title, 'Notes      ' AS ActivityType,
+			vtiger_notes.filename, vtiger_attachments.type  AS FileType,
 				crm2.modifiedtime AS lastmodified,
-				seattachmentsrel.attachmentsid AS attachmentsid,
-				notes.notesid AS crmid, crmentity.createdtime,
-				notes.notecontent AS description,
-				users.user_name
-			FROM notes
-			INNER JOIN senotesrel
-				ON senotesrel.notesid = notes.notesid
-			INNER JOIN crmentity
-				ON crmentity.crmid = senotesrel.crmid
-			INNER JOIN crmentity AS crm2
-				ON crm2.crmid = notes.notesid
+			vtiger_seattachmentsrel.attachmentsid AS vtiger_attachmentsid,
+			vtiger_notes.notesid AS crmid, vtiger_crmentity.createdtime,
+			vtiger_notes.notecontent AS description,
+			vtiger_users.user_name
+			FROM vtiger_notes
+			INNER JOIN vtiger_senotesrel
+				ON vtiger_senotesrel.notesid = vtiger_notes.notesid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_senotesrel.crmid
+			INNER JOIN vtiger_crmentity AS crm2
+				ON crm2.crmid = vtiger_notes.notesid
 				AND crm2.deleted = 0
-			LEFT JOIN seattachmentsrel
-				ON seattachmentsrel.crmid = notes.notesid
-			LEFT JOIN attachments
-				ON seattachmentsrel.attachmentsid = attachments.attachmentsid
-			INNER JOIN users
-				ON crmentity.smcreatorid = users.id
-			WHERE crmentity.crmid = ".$id."
+			LEFT JOIN vtiger_seattachmentsrel
+				ON vtiger_seattachmentsrel.crmid = vtiger_notes.notesid
+			LEFT JOIN vtiger_attachments
+				ON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			INNER JOIN vtiger_users
+				ON vtiger_crmentity.smcreatorid = vtiger_users.id
+			WHERE vtiger_crmentity.crmid = ".$id."
 		UNION ALL
-			SELECT attachments.description AS title,
+			SELECT vtiger_attachments.description AS title,
 				'Attachments' AS ActivityType,
-				attachments.name AS filename,
-				attachments.type AS FileType,
+			vtiger_attachments.name AS filename,
+			vtiger_attachments.type AS FileType,
 				crm2.modifiedtime AS lastmodified,
-				attachments.attachmentsid AS attachmentsid,
-				seattachmentsrel.attachmentsid AS crmid,
-				crmentity.createdtime,
-				attachments.description, users.user_name
-			FROM attachments
-			INNER JOIN seattachmentsrel
-				ON seattachmentsrel.attachmentsid = attachments.attachmentsid
-			INNER JOIN crmentity
-				ON crmentity.crmid = seattachmentsrel.crmid
-			INNER JOIN crmentity AS crm2
-				ON crm2.crmid = attachments.attachmentsid
-			INNER JOIN users
-				ON crmentity.smcreatorid = users.id
-			WHERE crmentity.crmid = ".$id;	
+			vtiger_attachments.attachmentsid AS vtiger_attachmentsid,
+			vtiger_seattachmentsrel.attachmentsid AS crmid,
+			vtiger_crmentity.createdtime,
+			vtiger_attachments.description, vtiger_users.user_name
+			FROM vtiger_attachments
+			INNER JOIN vtiger_seattachmentsrel
+				ON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_seattachmentsrel.crmid
+			INNER JOIN vtiger_crmentity AS crm2
+				ON crm2.crmid = vtiger_attachments.attachmentsid
+			INNER JOIN vtiger_users
+				ON vtiger_crmentity.smcreatorid = vtiger_users.id
+			WHERE vtiger_crmentity.crmid = ".$id;	
 
 		$log->debug("Exiting get_attachments method ...");
         	return getAttachmentsAndNotes('Products',$query,$id);
@@ -153,19 +153,19 @@
 	{
 		global $log;
 		$log->debug("Entering get_opportunities(".$id.") method ...");
-		$query = "SELECT potential.potentialid, potential.potentialname,
-				potential.potentialtype, products.productid,
-				products.productname, products.qty_per_unit,
-				products.unit_price, products.expiry_date
-			FROM potential
-			INNER JOIN products
-				ON potential.productid = products.productid
-			LEFT JOIN potentialgrouprelation
-				ON potential.potentialid = potentialgrouprelation.potentialid
-			LEFT JOIN groups
-				ON groups.groupname = potentialgrouprelation.groupname
-			WHERE crmentity.deleted = 0
-			AND products.productid = ".$id;
+		$query = "SELECT vtiger_potential.potentialid, vtiger_potential.potentialname,
+			vtiger_potential.potentialtype, vtiger_products.productid,
+			vtiger_products.productname, vtiger_products.qty_per_unit,
+			vtiger_products.unit_price, vtiger_products.expiry_date
+			FROM vtiger_potential
+			INNER JOIN vtiger_products
+				ON vtiger_potential.productid = vtiger_products.productid
+			LEFT JOIN vtiger_potentialgrouprelation
+				ON vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_products.productid = ".$id;
 		$log->debug("Exiting get_opportunities method ...");
           renderRelatedPotentials($query);
         }
@@ -182,26 +182,26 @@
 
 		$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT users.user_name, users.id,
-				products.productid, products.productname,
-				troubletickets.ticketid,
-				troubletickets.parent_id, troubletickets.title,
-				troubletickets.status, troubletickets.priority,
-				crmentity.crmid, crmentity.smownerid,
-				crmentity.modifiedtime
-			FROM troubletickets
-			INNER JOIN crmentity
-				ON crmentity.crmid = troubletickets.ticketid
-			LEFT JOIN products
-				ON products.productid = troubletickets.product_id
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			LEFT JOIN ticketgrouprelation
-				ON troubletickets.ticketid = ticketgrouprelation.ticketid
-			LEFT JOIN groups
-				ON groups.groupname = ticketgrouprelation.groupname
-			WHERE crmentity.deleted = 0
-			AND products.productid = ".$id;
+		$query = "SELECT vtiger_users.user_name, vtiger_users.id,
+			vtiger_products.productid, vtiger_products.productname,
+			vtiger_troubletickets.ticketid,
+			vtiger_troubletickets.parent_id, vtiger_troubletickets.title,
+			vtiger_troubletickets.status, vtiger_troubletickets.priority,
+			vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
+			vtiger_crmentity.modifiedtime
+			FROM vtiger_troubletickets
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid
+			LEFT JOIN vtiger_products
+				ON vtiger_products.productid = vtiger_troubletickets.product_id
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_ticketgrouprelation
+				ON vtiger_troubletickets.ticketid = vtiger_ticketgrouprelation.ticketid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_products.productid = ".$id;
 	$log->debug("Exiting get_tickets method ...");
 		return GetRelatedList('Products','HelpDesk',$focus,$query,$button,$returnset);
 	}
@@ -223,36 +223,36 @@
 		$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
 
 
-		$query = "SELECT contactdetails.lastname,
-				contactdetails.firstname,
-				contactdetails.contactid,
-				activity.*,
-				seactivityrel.*,
-				crmentity.crmid, crmentity.smownerid,
-				crmentity.modifiedtime,
-				users.user_name,
-				recurringevents.recurringtype
-			FROM activity
-			INNER JOIN seactivityrel
-				ON seactivityrel.activityid = activity.activityid
-			INNER JOIN crmentity
-				ON crmentity.crmid=activity.activityid
-			LEFT JOIN cntactivityrel
-				ON cntactivityrel.activityid = activity.activityid
-			LEFT JOIN contactdetails
-				ON contactdetails.contactid = cntactivityrel.contactid
-			LEFT JOIN users
-				ON users.id = crmentity.smownerid
-			LEFT OUTER JOIN recurringevents
-				ON recurringevents.activityid = activity.activityid
-			LEFT JOIN activitygrouprelation
-				ON activitygrouprelation.activityid = crmentity.crmid
-			LEFT JOIN groups
-				ON groups.groupname = activitygrouprelation.groupname
-			WHERE seactivityrel.crmid=".$id."
+		$query = "SELECT vtiger_contactdetails.lastname,
+			vtiger_contactdetails.firstname,
+			vtiger_contactdetails.contactid,
+			vtiger_activity.*,
+			vtiger_seactivityrel.*,
+			vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
+			vtiger_crmentity.modifiedtime,
+			vtiger_users.user_name,
+			vtiger_recurringevents.recurringtype
+			FROM vtiger_activity
+			INNER JOIN vtiger_seactivityrel
+				ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid=vtiger_activity.activityid
+			LEFT JOIN vtiger_cntactivityrel
+				ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT OUTER JOIN vtiger_recurringevents
+				ON vtiger_recurringevents.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_activitygrouprelation
+				ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
+			WHERE vtiger_seactivityrel.crmid=".$id."
 			AND (activitytype = 'Task'
-				OR activitytype = 'Call'
-				OR activitytype = 'Meeting')";
+				OR vtiger_activitytype = 'Call'
+				OR vtiger_activitytype = 'Meeting')";
 		$log->debug("Exiting get_activities method ...");
 		return GetRelatedList('Products','Activities',$focus,$query,$button,$returnset);
 	}
@@ -268,26 +268,26 @@
 		$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
 
 
-		$query = "SELECT crmentity.*,
-				quotes.*,
-				potential.potentialname,
-				account.accountname,
-				quotesproductrel.productid
-			FROM quotes
-			INNER JOIN crmentity
-				ON crmentity.crmid = quotes.quoteid
-			INNER JOIN quotesproductrel
-				ON quotesproductrel.quoteid = quotes.quoteid
-			LEFT OUTER JOIN account
-				ON account.accountid = quotes.accountid
-			LEFT OUTER JOIN potential
-				ON potential.potentialid = quotes.potentialid
-			LEFT JOIN quotegrouprelation
-				ON quotes.quoteid = quotegrouprelation.quoteid
-			LEFT JOIN groups
-				ON groups.groupname = quotegrouprelation.groupname
-			WHERE crmentity.deleted = 0
-			AND quotesproductrel.productid = ".$id;
+		$query = "SELECT vtiger_crmentity.*,
+			vtiger_quotes.*,
+			vtiger_potential.potentialname,
+			vtiger_account.accountname,
+			vtiger_quotesproductrel.productid
+			FROM vtiger_quotes
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_quotes.quoteid
+			INNER JOIN vtiger_quotesproductrel
+				ON vtiger_quotesproductrel.quoteid = vtiger_quotes.quoteid
+			LEFT OUTER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_quotes.accountid
+			LEFT OUTER JOIN vtiger_potential
+				ON vtiger_potential.potentialid = vtiger_quotes.potentialid
+			LEFT JOIN vtiger_quotegrouprelation
+				ON vtiger_quotes.quoteid = vtiger_quotegrouprelation.quoteid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_quotegrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_quotesproductrel.productid = ".$id;
 		$log->debug("Exiting get_quotes method ...");
 		return GetRelatedList('Products','Quotes',$focus,$query,$button,$returnset);
 	}
@@ -303,23 +303,23 @@
 
 		$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT crmentity.*,
-				purchaseorder.*,
-				products.productname,
-				poproductrel.productid
-			FROM purchaseorder
-			INNER JOIN crmentity
-				ON crmentity.crmid = purchaseorder.purchaseorderid
-			INNER JOIN poproductrel
-				ON poproductrel.purchaseorderid = purchaseorder.purchaseorderid
-			INNER JOIN products
-				ON products.productid = poproductrel.productid
-			LEFT JOIN pogrouprelation
-				ON purchaseorder.purchaseorderid = pogrouprelation.purchaseorderid
-			LEFT JOIN groups
-				ON groups.groupname = pogrouprelation.groupname
-			WHERE crmentity.deleted = 0
-			AND products.productid = ".$id;
+		$query = "SELECT vtiger_crmentity.*,
+			vtiger_purchaseorder.*,
+			vtiger_products.productname,
+			vtiger_poproductrel.productid
+			FROM vtiger_purchaseorder
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_purchaseorder.purchaseorderid
+			INNER JOIN vtiger_poproductrel
+				ON vtiger_poproductrel.purchaseorderid = vtiger_purchaseorder.purchaseorderid
+			INNER JOIN vtiger_products
+				ON vtiger_products.productid = vtiger_poproductrel.productid
+			LEFT JOIN vtiger_pogrouprelation
+				ON vtiger_purchaseorder.purchaseorderid = vtiger_pogrouprelation.purchaseorderid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_pogrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_products.productid = ".$id;
 		$log->debug("Exiting get_purchase_orders method ...");
 		return GetRelatedList('Products','PurchaseOrder',$focus,$query,$button,$returnset);
 	}
@@ -334,25 +334,25 @@
 		$button = '';
 		$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT crmentity.*,
-				salesorder.*,
-				products.productname AS productname,
-				account.accountname
-			FROM salesorder
-			INNER JOIN crmentity
-				ON crmentity.crmid = salesorder.salesorderid
-			INNER JOIN soproductrel
-				ON soproductrel.salesorderid = salesorder.salesorderid
-			INNER JOIN products
-				ON products.productid = soproductrel.productid
-			LEFT OUTER JOIN account
-				ON account.accountid = salesorder.accountid
-			LEFT JOIN sogrouprelation
-				ON salesorder.salesorderid = sogrouprelation.salesorderid
-			LEFT JOIN groups
-				ON groups.groupname = sogrouprelation.groupname
-			WHERE crmentity.deleted = 0
-			AND products.productid = ".$id;
+		$query = "SELECT vtiger_crmentity.*,
+			vtiger_salesorder.*,
+			vtiger_products.productname AS productname,
+			vtiger_account.accountname
+			FROM vtiger_salesorder
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_salesorder.salesorderid
+			INNER JOIN vtiger_soproductrel
+				ON vtiger_soproductrel.salesorderid = vtiger_salesorder.salesorderid
+			INNER JOIN vtiger_products
+				ON vtiger_products.productid = vtiger_soproductrel.productid
+			LEFT OUTER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_salesorder.accountid
+			LEFT JOIN vtiger_sogrouprelation
+				ON vtiger_salesorder.salesorderid = vtiger_sogrouprelation.salesorderid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_sogrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_products.productid = ".$id;
 		$log->debug("Exiting get_salesorder method ...");
 		return GetRelatedList('Products','SalesOrder',$focus,$query,$button,$returnset);
 	}
@@ -368,23 +368,23 @@
 		$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
 
 
-		$query = "SELECT crmentity.*,
-				invoice.*,
-				invoiceproductrel.quantity,
-				account.accountname
-			FROM invoice
-			INNER JOIN crmentity
-				ON crmentity.crmid = invoice.invoiceid
-			LEFT OUTER JOIN account
-				ON account.accountid = invoice.accountid
-			INNER JOIN invoiceproductrel
-				ON invoiceproductrel.invoiceid = invoice.invoiceid
-			LEFT JOIN invoicegrouprelation
-				ON invoice.invoiceid = invoicegrouprelation.invoiceid
-			LEFT JOIN groups
-				ON groups.groupname = invoicegrouprelation.groupname
-			WHERE crmentity.deleted = 0
-			AND invoiceproductrel.productid = ".$id;
+		$query = "SELECT vtiger_crmentity.*,
+			vtiger_invoice.*,
+			vtiger_invoiceproductrel.quantity,
+			vtiger_account.accountname
+			FROM vtiger_invoice
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_invoice.invoiceid
+			LEFT OUTER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_invoice.accountid
+			INNER JOIN vtiger_invoiceproductrel
+				ON vtiger_invoiceproductrel.invoiceid = vtiger_invoice.invoiceid
+			LEFT JOIN vtiger_invoicegrouprelation
+				ON vtiger_invoice.invoiceid = vtiger_invoicegrouprelation.invoiceid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_invoicegrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_invoiceproductrel.productid = ".$id;
 		$log->debug("Exiting get_invoices method ...");
 		return GetRelatedList('Products','Invoice',$focus,$query,$button,$returnset);
 	}
@@ -399,16 +399,16 @@
 		$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
 
 
-		$query = "SELECT crmentity.crmid,
-				pricebook.*,
-				pricebookproductrel.productid as prodid
-			FROM pricebook
-			INNER JOIN crmentity
-				ON crmentity.crmid = pricebook.pricebookid
-			INNER JOIN pricebookproductrel
-				ON pricebookproductrel.pricebookid = pricebook.pricebookid
-			WHERE crmentity.deleted = 0
-			AND pricebookproductrel.productid = ".$id; 
+		$query = "SELECT vtiger_crmentity.crmid,
+			vtiger_pricebook.*,
+			vtiger_pricebookproductrel.productid as prodid
+			FROM vtiger_pricebook
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_pricebook.pricebookid
+			INNER JOIN vtiger_pricebookproductrel
+				ON vtiger_pricebookproductrel.pricebookid = vtiger_pricebook.pricebookid
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_pricebookproductrel.productid = ".$id; 
 		$log->debug("Exiting get_product_pricebooks method ...");
 		return GetRelatedList('Products','PriceBooks',$focus,$query,$button,$returnset);
 	}
@@ -417,12 +417,12 @@
 	{
 		global $log;
 		$log->debug("Entering product_novendor() method ...");
-		$query = "SELECT products.productname, crmentity.deleted
-			FROM products
-			INNER JOIN crmentity
-				ON crmentity.crmid = products.productid
-			WHERE crmentity.deleted = 0
-			AND products.vendor_id = ''";
+		$query = "SELECT vtiger_products.productname, vtiger_crmentity.deleted
+			FROM vtiger_products
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_products.productid
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_products.vendor_id = ''";
 		$result=$this->db->query($query);
 		$log->debug("Exiting product_novendor method ...");
 		return $this->db->num_rows($result);
@@ -437,85 +437,85 @@
 		{
 
 		$query = $this->constructCustomQueryAddendum('productcf','Products') ."    
-				products.productid AS productid,
-				products.productname AS productname,
-				products.productcode AS productcode,
-				products.productcategory AS productcategory,
-				products.manufacturer AS manufacturer,
-				products.product_description AS product_description,
-				products.qty_per_unit AS qty_per_unit,
-				products.unit_price AS unit_price,
-				products.weight AS weight,
-				products.pack_size AS pack_size,
-				DATE_FORMAT(products.start_date, '%Y-%M-%D') AS start_date,
-				DATE_FORMAT(products.expiry_date, '%Y-%M-%D') AS expiry_date,
-				products.cost_factor AS cost_factor,
-				products.commissionrate AS commissionrate,
-				products.commissionmethod AS commissionmethod,
-				products.discontinued AS discontinued,
-				products.sales_start_date AS sales_start_date,
-				products.sales_end_date AS sales_end_date,
-				products.usageunit AS usageunit,
-				products.serialno AS serialno,
-				products.currency AS currency,
-				products.reorderlevel AS reorderlevel,
-				products.website AS website,
-				products.taxclass AS taxclass,
-				products.mfr_part_no AS mfr_part_no,
-				products.vendor_part_no AS vendor_part_no,
-				products.qtyinstock AS qtyinstock,
-				products.productsheet AS productsheet,
-				products.qtyindemand AS qtyindemand
+			vtiger_products.productid AS productid,
+			vtiger_products.productname AS productname,
+			vtiger_products.productcode AS productcode,
+			vtiger_products.productcategory AS vtiger_productcategory,
+			vtiger_products.manufacturer AS vtiger_manufacturer,
+			vtiger_products.product_description AS product_description,
+			vtiger_products.qty_per_unit AS qty_per_unit,
+			vtiger_products.unit_price AS unit_price,
+			vtiger_products.weight AS weight,
+			vtiger_products.pack_size AS pack_size,
+				DATE_FORMAT(vtiger_products.start_date, '%Y-%M-%D') AS start_date,
+				DATE_FORMAT(vtiger_products.expiry_date, '%Y-%M-%D') AS expiry_date,
+			vtiger_products.cost_factor AS cost_factor,
+			vtiger_products.commissionrate AS commissionrate,
+			vtiger_products.commissionmethod AS commissionmethod,
+			vtiger_products.discontinued AS discontinued,
+			vtiger_products.sales_start_date AS sales_start_date,
+			vtiger_products.sales_end_date AS sales_end_date,
+			vtiger_products.usageunit AS vtiger_usageunit,
+			vtiger_products.serialno AS serialno,
+			vtiger_products.currency AS vtiger_currency,
+			vtiger_products.reorderlevel AS reorderlevel,
+			vtiger_products.website AS website,
+			vtiger_products.taxclass AS vtiger_taxclass,
+			vtiger_products.mfr_part_no AS mfr_part_no,
+			vtiger_products.vendor_part_no AS vtiger_vendor_part_no,
+			vtiger_products.qtyinstock AS qtyinstock,
+			vtiger_products.productsheet AS vtiger_productsheet,
+			vtiger_products.qtyindemand AS qtyindemand
 			FROM ".$this->entity_table."
-			INNER JOIN products
-				ON crmentity.crmid = products.productid
-			INNER JOIN users
-				ON users.id = crmentity.smownerid 
-			LEFT JOIN productcf
-				ON productcf.productid = products.productid";
+			INNER JOIN vtiger_products
+				ON vtiger_crmentity.crmid = vtiger_products.productid
+			INNER JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid 
+			LEFT JOIN vtiger_productcf
+				ON vtiger_productcf.productid = vtiger_products.productid";
 
 		}
 		else
 		{
-			$query = "SELECT products.productid AS productid,
-				products.productname AS productname,
-				products.productcode AS productcode,
-				products.productcategory AS productcategory,
-				products.manufacturer AS manufacturer,
-				products.product_description AS product_description,
-				products.qty_per_unit AS qty_per_unit,
-				products.unit_price AS unit_price,
-				products.weight AS weight,
-				products.pack_size AS pack_size,
-				DATE_FORMAT(products.start_date, '%Y-%M-%D') AS start_date,
-				DATE_FORMAT(products.expiry_date, '%Y-%M-%D') AS expiry_date,
-				products.cost_factor AS cost_factor,
-				products.commissionrate AS commissionrate,
-				products.commissionmethod AS commissionmethod,
-				products.discontinued AS discontinued,
-				products.sales_start_date AS sales_start_date,
-				products.sales_end_date AS sales_end_date,
-				products.usageunit AS usageunit,
-				products.serialno AS serialno,
-				products.currency AS currency,
-				products.reorderlevel AS reorderlevel,
-				products.website AS website,
-				products.taxclass AS taxclass,
-				products.mfr_part_no AS mfr_part_no,
-				products.vendor_part_no AS vendor_part_no,
-				products.qtyinstock AS qtyinstock,
-				products.productsheet AS productsheet,
-				products.qtyindemand AS qtyindemand
+			$query = "SELECT vtiger_products.productid AS productid,
+			vtiger_products.productname AS productname,
+			vtiger_products.productcode AS productcode,
+			vtiger_products.productcategory AS vtiger_productcategory,
+			vtiger_products.manufacturer AS vtiger_manufacturer,
+			vtiger_products.product_description AS product_description,
+			vtiger_products.qty_per_unit AS qty_per_unit,
+			vtiger_products.unit_price AS unit_price,
+			vtiger_products.weight AS weight,
+			vtiger_products.pack_size AS pack_size,
+				DATE_FORMAT(vtiger_products.start_date, '%Y-%M-%D') AS start_date,
+				DATE_FORMAT(vtiger_products.expiry_date, '%Y-%M-%D') AS expiry_date,
+			vtiger_products.cost_factor AS cost_factor,
+			vtiger_products.commissionrate AS commissionrate,
+			vtiger_products.commissionmethod AS commissionmethod,
+			vtiger_products.discontinued AS discontinued,
+			vtiger_products.sales_start_date AS sales_start_date,
+			vtiger_products.sales_end_date AS sales_end_date,
+			vtiger_products.usageunit AS vtiger_usageunit,
+			vtiger_products.serialno AS serialno,
+			vtiger_products.currency AS vtiger_currency,
+			vtiger_products.reorderlevel AS reorderlevel,
+			vtiger_products.website AS website,
+			vtiger_products.taxclass AS vtiger_taxclass,
+			vtiger_products.mfr_part_no AS mfr_part_no,
+			vtiger_products.vendor_part_no AS vtiger_vendor_part_no,
+			vtiger_products.qtyinstock AS qtyinstock,
+			vtiger_products.productsheet AS vtiger_productsheet,
+			vtiger_products.qtyindemand AS qtyindemand
 			FROM ".$this->table_name ."
-			INNER JOIN crmentity
-				ON crmentity.crmid = products.productid 
-			INNER JOIN users
-				ON users.id=crmentity.smownerid ";
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_products.productid 
+			INNER JOIN vtiger_users
+				ON vtiger_users.id=vtiger_crmentity.smownerid ";
 
 		}
 	
-		  $where_auto = " users.status = 'Active'
-                        AND crmentity.deleted = 0 ";
+		  $where_auto = " vtiger_users.status = 'Active'
+                        AND vtiger_crmentity.deleted = 0 ";
 
 
 

Modified: vtigercrm/trunk/modules/Products/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Products/Save.php (original)
+++ vtigercrm/trunk/modules/Products/Save.php Mon Jun 12 14:26:25 2006
@@ -171,7 +171,7 @@
 	{
 		if(isset($_REQUEST[$fieldname]))
 		{
-			 $log->debug("Assigning the previous values given for the product to respective fields ");
+			 $log->debug("Assigning the previous values given for the product to respective vtiger_fields ");
 			$field_values_passed.="&";
 			$value = $_REQUEST[$fieldname];
 			$focus->column_fields[$fieldname] = $value;
@@ -201,7 +201,7 @@
 {
 	$image_lists_db=implode("###",$image_lists);
 	$focus->column_fields['imagename']=$image_lists_db;
-	$log->debug("Assign the Image name to the field name ");
+	$log->debug("Assign the Image name to the vtiger_field name ");
 }
 //Saving the product
 if($image_error=="false")

Modified: vtigercrm/trunk/modules/Products/UpdateListPrice.php
==============================================================================
--- vtigercrm/trunk/modules/Products/UpdateListPrice.php (original)
+++ vtigercrm/trunk/modules/Products/UpdateListPrice.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 $product_id = $_REQUEST['product_id'];
 $listprice = $_REQUEST['list_price'];
 $return_action = $_REQUEST['return_action'];
-$query = "update pricebookproductrel set listprice=".$listprice." where pricebookid=".$pricebook_id." and productid=".$product_id;
+$query = "update vtiger_pricebookproductrel set listprice=".$listprice." where vtiger_pricebookid=".$pricebook_id." and productid=".$product_id;
 //echo $query;
 $adb->query($query); 
 

Modified: vtigercrm/trunk/modules/Products/addPbProductRelToDB.php
==============================================================================
--- vtigercrm/trunk/modules/Products/addPbProductRelToDB.php (original)
+++ vtigercrm/trunk/modules/Products/addPbProductRelToDB.php Mon Jun 12 14:26:25 2006
@@ -27,9 +27,9 @@
 		if($id != '') {
 			$lp_name = $id.'_listprice';
 			$list_price = $_REQUEST[$lp_name];
-			//Updating the pricebook product rel table
-			 $log->info("Products :: Inserting products to price book");
-			$query= "insert into pricebookproductrel (pricebookid,productid,listprice) values(".$pricebook_id.",".$id.",".$list_price.")";
+			//Updating the vtiger_pricebook product rel vtiger_table
+			 $log->info("Products :: Inserting vtiger_products to price book");
+			$query= "insert into vtiger_pricebookproductrel (pricebookid,productid,listprice) values(".$pricebook_id.",".$id.",".$list_price.")";
 			$adb->query($query);
 		}
 	}
@@ -44,9 +44,9 @@
 		if($id != '') {
 			$lp_name = $id.'_listprice';
 			$list_price = $_REQUEST[$lp_name];
-			//Updating the pricebook product rel table
+			//Updating the vtiger_pricebook product rel vtiger_table
 			 $log->info("Products :: Inserting PriceBooks to Product");
-			$query= "insert into pricebookproductrel (pricebookid,productid,listprice) values(".$id.",".$productid.",".$list_price.")";
+			$query= "insert into vtiger_pricebookproductrel (pricebookid,productid,listprice) values(".$id.",".$productid.",".$list_price.")";
 			$adb->query($query);
 		}
 	}

Modified: vtigercrm/trunk/modules/Products/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Products/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Products/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -85,7 +85,7 @@
 'LBL_NEW_ATTACHMENT'=>'New Attachment',
 'LBL_ATTACHMENT_TITLE'=>'Attachments',
 
-//Added fields after RC1 - Release
+//Added vtiger_fields after RC1 - Release
 'LBL_MANUFACTURER'=>'Manufacturer',
 'LBL_PRODUCTCATEGORY'=>'Product Category',
 'LBL_SUPPORT_START_DATE'=>'Support Start Date',
@@ -167,7 +167,7 @@
 'LBL_ADD_PRODUCTS_PRICEBOOK'=>'Add Products to PriceBook',
 
 //Added for 4.2 patch2 release
-'LBL_MAXIMUM_LIMIT_ERROR'=>'Sorry, the uploaded file exceeds the maximum filesize limit. Please try a file smaller than 800000 bytes',
+'LBL_MAXIMUM_LIMIT_ERROR'=>'Sorry, the uploaded file exceeds the maximum vtiger_filesize limit. Please try a file smaller than 800000 bytes',
 'LBL_UPLOAD_ERROR'=>'Problems in file upload. Please try again!',
 'LBL_IMAGE_ERROR'=>'The given file is not of type image(.gif/.jpg/.png)',
 'LBL_INVALID_IMAGE'=>'Invalid file OR File has no data',

Modified: vtigercrm/trunk/modules/Products/updateRelations.php
==============================================================================
--- vtigercrm/trunk/modules/Products/updateRelations.php (original)
+++ vtigercrm/trunk/modules/Products/updateRelations.php Mon Jun 12 14:26:25 2006
@@ -16,7 +16,7 @@
 {
 	if($_REQUEST['smodule']=='VENDOR')
 	{
-		$sql = "update products set vendor_id=".$_REQUEST['parid']." where productid=".$_REQUEST['entityid'];
+		$sql = "update vtiger_products set vtiger_vendor_id=".$_REQUEST['parid']." where productid=".$_REQUEST['entityid'];
 		$adb->query($sql);
 	}
 }
@@ -24,7 +24,7 @@
 {
 	if($_REQUEST['smodule']=='VENDOR')
 	{
-		$sql = "insert into vendorcontactrel values (".$_REQUEST['parid'].",".$_REQUEST['entityid'].")";
+		$sql = "insert into vtiger_vendorcontactrel values (".$_REQUEST['parid'].",".$_REQUEST['entityid'].")";
 		$adb->query($sql);
 	}
 }

Modified: vtigercrm/trunk/modules/PurchaseOrder/CreatePDF.php
==============================================================================
--- vtigercrm/trunk/modules/PurchaseOrder/CreatePDF.php (original)
+++ vtigercrm/trunk/modules/PurchaseOrder/CreatePDF.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 
 global $adb,$app_strings;
 
-$sql="select currency_symbol from currency_info";
+$sql="select vtiger_currency_symbol from vtiger_currency_info";
 $result = $adb->query($sql);
 $currency_symbol = $adb->query_result($result,0,'currency_symbol');
 
@@ -25,7 +25,7 @@
 $products_per_page="6";
 
 $id = $_REQUEST['record'];
-//retreiving the invoice info
+//retreiving the vtiger_invoice info
 $focus = new Order();
 $focus->retrieve_entity_info($_REQUEST['record'],"PurchaseOrder");
 $vendor_name = getVendorName($focus->column_fields[vendor_id]);
@@ -56,7 +56,7 @@
 $status = $focus->column_fields["postatus"];
 
 // Company information
-$add_query = "select * from organizationdetails";
+$add_query = "select * from vtiger_organizationdetails";
 $result = $adb->query($add_query);
 $num_rows = $adb->num_rows($result);
 
@@ -82,7 +82,7 @@
 $price_total = $currency_symbol.number_format(StripLastZero($focus->column_fields["hdnGrandTotal"]),2,'.',',');
 
 //getting the Product Data
-$query="select products.productname,products.unit_price,products.product_description,poproductrel.* from poproductrel inner join products on products.productid=poproductrel.productid where purchaseorderid=".$id;
+$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.product_description,vtiger_poproductrel.* from vtiger_poproductrel inner join vtiger_products on vtiger_products.productid=vtiger_poproductrel.productid where vtiger_purchaseorderid=".$id;
 
 global $result;
 $result = $adb->query($query);

Modified: vtigercrm/trunk/modules/PurchaseOrder/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/PurchaseOrder/EditView.php (original)
+++ vtigercrm/trunk/modules/PurchaseOrder/EditView.php Mon Jun 12 14:26:25 2006
@@ -55,7 +55,7 @@
         $associated_prod = getAssociatedProducts("Products",$focus,$focus->column_fields['product_id']);
 }
 
-// Get vendor address if vendorid is given
+// Get vtiger_vendor address if vtiger_vendorid is given
 if(isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id']!='' && $_REQUEST['record']==''){
 	require_once('modules/Vendors/Vendor.php');
 	$vend_focus = new Vendor();

Modified: vtigercrm/trunk/modules/PurchaseOrder/PurchaseOrder.php
==============================================================================
--- vtigercrm/trunk/modules/PurchaseOrder/PurchaseOrder.php (original)
+++ vtigercrm/trunk/modules/PurchaseOrder/PurchaseOrder.php Mon Jun 12 14:26:25 2006
@@ -28,25 +28,25 @@
 require_once('data/CRMEntity.php');
 require_once('include/utils/utils.php');
 
-// Account is used to store account information.
+// Account is used to store vtiger_account information.
 class Order extends CRMEntity {
 	var $log;
 	var $db;
 
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $mode;
 	
 		
 	var $table_name = "purchaseorder";
-	var $tab_name = Array('crmentity','purchaseorder','pobillads','poshipads','purchaseordercf');
-	var $tab_name_index = Array('crmentity'=>'crmid','purchaseorder'=>'purchaseorderid','pobillads'=>'pobilladdressid','poshipads'=>'poshipaddressid','purchaseordercf'=>'purchaseorderid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_purchaseorder','vtiger_pobillads','vtiger_poshipads','vtiger_purchaseordercf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_purchaseorder'=>'purchaseorderid','vtiger_pobillads'=>'pobilladdressid','vtiger_poshipads'=>'poshipaddressid','vtiger_purchaseordercf'=>'purchaseorderid');
 				
 	
-	var $entity_table = "crmentity";
-	
-	var $billadr_table = "pobillads";
+	var $entity_table = "vtiger_crmentity";
+	
+	var $billadr_table = "vtiger_pobillads";
 
 	var $object_name = "Order";
 
@@ -58,10 +58,10 @@
 
 	var $sortby_fields = Array('subject','tracking_no','smownerid');		
 
-	// This is used to retrieve related fields from form posts.
+	// This is used to retrieve related vtiger_fields from form posts.
 	var $additional_column_fields = Array('assigned_user_name', 'smownerid', 'opportunity_id', 'case_id', 'contact_id', 'task_id', 'note_id', 'meeting_id', 'call_id', 'email_id', 'parent_name', 'member_id' );
 
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
 				'Order Id'=>Array('crmentity'=>'crmid'),
 				'Subject'=>Array('purchaseorder'=>'subject'),
@@ -93,7 +93,7 @@
 				        'Subject'=>'subject',
 				      );
 
-	// This is the list of fields that are required.
+	// This is the list of vtiger_fields that are required.
 	var $required_fields =  array("accountname"=>1);
 
 	//Added these variables which are used as default order by and sortorder in ListView
@@ -126,7 +126,7 @@
 
 		$returnset = '&return_module=PurchaseOrder&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT contactdetails.lastname, contactdetails.firstname, contactdetails.contactid,activity.*,seactivityrel.*,crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime, users.user_name from activity inner join seactivityrel on seactivityrel.activityid=activity.activityid inner join crmentity on crmentity.crmid=activity.activityid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid = cntactivityrel.contactid left join users on users.id=crmentity.smownerid left join activitygrouprelation on activitygrouprelation.activityid=crmentity.crmid left join groups on groups.groupname=activitygrouprelation.groupname where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and (activity.status is not NULL && activity.status != 'Completed') and (activity.status is not NULL && activity.status != 'Deferred') or (activity.eventstatus != '' &&  activity.eventstatus = 'Planned')";
+		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or vtiger_activitytype='Call' or vtiger_activitytype='Meeting') and vtiger_crmentity.deleted=0 and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Deferred') or (vtiger_activity.eventstatus != '' &&  vtiger_activity.eventstatus = 'Planned')";
 		$log->debug("Exiting get_activities method ...");
 		return GetRelatedList('PurchaseOrder','Activities',$focus,$query,$button,$returnset);
 	}
@@ -139,27 +139,27 @@
 	{
 		global $log;
 		$log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT contactdetails.lastname, contactdetails.firstname, contactdetails.contactid,
-				activity.* ,seactivityrel.*, crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime,
-				crmentity.createdtime, crmentity.description, users.user_name
-			from activity
-				inner join seactivityrel on seactivityrel.activityid=activity.activityid
-				inner join crmentity on crmentity.crmid=activity.activityid
-				left join cntactivityrel on cntactivityrel.activityid= activity.activityid
-				left join contactdetails on contactdetails.contactid = cntactivityrel.contactid
-				inner join users on crmentity.smcreatorid= users.id
-				left join activitygrouprelation on activitygrouprelation.activityid=activity.activityid
-                                left join groups on groups.groupname=activitygrouprelation.groupname
-			where (activity.activitytype = 'Meeting' or activity.activitytype='Call' or activity.activitytype='Task')
-				and (activity.status = 'Completed' or activity.status = 'Deferred' or (activity.eventstatus != 'Planned' and activity.eventstatus != '' ))
-				and seactivityrel.crmid=".$id;
+		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,
+			vtiger_activity.* ,vtiger_seactivityrel.*, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,
+			vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
+			from vtiger_activity
+				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
+				left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
+				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
+				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+			where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
+				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus != 'Planned' and vtiger_activity.eventstatus != '' ))
+				and vtiger_seactivityrel.crmid=".$id;
 		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
 
 		$log->debug("Exiting get_history method ...");
 		return getHistory('PurchaseOrder',$query,$id);
 	}
 
-/** Function to get attachments associated with the id
+/** Function to get vtiger_attachments associated with the id
  *  This function accepts the id as arguments and execute the MySQL query using the id
  *  and sends the query and the id as arguments to renderRelatedAttachments() method.
 */
@@ -168,35 +168,35 @@
 		global $log;
 		$log->debug("Entering get_attachments(".$id.") method ...");
 		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crm2.createdtime, notes.notecontent description, users.user_name
-		// Inserted inner join users on crm2.smcreatorid= users.id
-		$query = "select notes.title, 'Notes      '  ActivityType, notes.filename,
-			attachments.type FileType, crm2.modifiedtime lastmodified,
-			seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid,
-			crm2.createdtime, notes.notecontent description, users.user_name
-		from notes
-			inner join senotesrel on senotesrel.notesid= notes.notesid
-			inner join crmentity on crmentity.crmid= senotesrel.crmid
-			inner join crmentity crm2 on crm2.crmid=notes.notesid and crm2.deleted=0
-			left join seattachmentsrel  on seattachmentsrel.crmid =notes.notesid
-			left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid
-			inner join users on crm2.smcreatorid= users.id
-		where crmentity.crmid=".$id;
+		// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		$query = "select vtiger_notes.title, 'Notes      '  ActivityType, vtiger_notes.filename,
+		vtiger_attachments.type FileType, crm2.modifiedtime lastmodified,
+		vtiger_seattachmentsrel.attachmentsid vtiger_attachmentsid, vtiger_notes.notesid crmid,
+			crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		from vtiger_notes
+			inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+			left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id;
 		$query .= ' union all ';
 		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crm2.createdtime, attachments.description, users.user_name
-		// Inserted inner join users on crm2.smcreatorid= users.id
+		// Desc: Inserted crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
 		// Inserted order by createdtime desc
-		$query .= "select attachments.description  title ,'Attachments'  ActivityType,
-			attachments.name  filename, attachments.type  FileType, crm2.modifiedtime  lastmodified,
-			attachments.attachmentsid  attachmentsid, seattachmentsrel.attachmentsid crmid,
-			crm2.createdtime, attachments.description, users.user_name
-		from attachments
-			inner join seattachmentsrel on seattachmentsrel.attachmentsid= attachments.attachmentsid
-			inner join crmentity on crmentity.crmid= seattachmentsrel.crmid
-			inner join crmentity crm2 on crm2.crmid=attachments.attachmentsid
-			inner join users on crm2.smcreatorid= users.id
-		where crmentity.crmid=".$id."
+		$query .= "select vtiger_attachments.description  title ,'Attachments'  ActivityType,
+		vtiger_attachments.name  filename, vtiger_attachments.type  FileType, crm2.modifiedtime  lastmodified,
+		vtiger_attachments.attachmentsid  vtiger_attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
+			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		from vtiger_attachments
+			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id."
 		order by createdtime desc";
 		$log->debug("Exiting get_attachments method ...");
 		return getAttachmentsAndNotes('PurchaseOrder',$query,$id,$sid='purchaseorderid');

Modified: vtigercrm/trunk/modules/PurchaseOrder/Save.php
==============================================================================
--- vtigercrm/trunk/modules/PurchaseOrder/Save.php (original)
+++ vtigercrm/trunk/modules/PurchaseOrder/Save.php Mon Jun 12 14:26:25 2006
@@ -46,7 +46,7 @@
 $focus->save("PurchaseOrder");
 if($focus->mode == 'edit')
 {
-        $query1 = "delete from poproductrel where purchaseorderid=".$focus->id;
+        $query1 = "delete from vtiger_poproductrel where vtiger_purchaseorderid=".$focus->id;
         $adb->query($query1);
 
 }
@@ -74,7 +74,7 @@
         if($prod_status != 'D')
         {
 
-                $query ="insert into poproductrel values($focus->id, $prod_id, $qty, $listprice, $vat, $sales, $service)";
+                $query ="insert into vtiger_poproductrel values($focus->id, $prod_id, $qty, $listprice, $vat, $sales, $service)";
                 $adb->query($query);
 		if($update_prod_stock == 'true')
                 {

Modified: vtigercrm/trunk/modules/PurchaseOrder/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/PurchaseOrder/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/PurchaseOrder/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -80,10 +80,10 @@
 'NTC_COPY_SHIPPING_ADDRESS'=>'Copy shipping address to billing address',
 'NTC_REMOVE_MEMBER_ORG_CONFIRMATION'=>'Are you sure you want to remove this record as a member organization?',
 'LBL_DUPLICATE'=>'Potential Duplicate Accounts',
-'MSG_DUPLICATE' => 'Creating this account may potentialy create a duplicate account. You may either select an account from the list below or you may click on Create New Account to continue creating a new account with the previously entered data.',
+'MSG_DUPLICATE' => 'Creating this vtiger_account may vtiger_potentialy create a duplicate vtiger_account. You may either select an vtiger_account from the list below or you may click on Create New Account to continue creating a new vtiger_account with the previously entered data.',
 
 'LBL_INVITEE'=>'Contacts',
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
 
 'LBL_SELECT_ACCOUNT'=>'Select Account',
 'LBL_GENERAL_INFORMATION'=>'General Information',
@@ -103,7 +103,7 @@
 'LBL_NEW_CONTACT'=>'New Contact',
 'LBL_CONTACT_TITLE'=>'Contacts',
 
-//Added fields after RC1 - Release
+//Added vtiger_fields after RC1 - Release
 'LBL_ALL'=>'All',
 'LBL_PROSPECT'=>'Prospect',
 'LBL_INVESTOR'=>'Investor',

Modified: vtigercrm/trunk/modules/PurchaseOrder/pdf_templates/header.php
==============================================================================
--- vtigercrm/trunk/modules/PurchaseOrder/pdf_templates/header.php (original)
+++ vtigercrm/trunk/modules/PurchaseOrder/pdf_templates/header.php Mon Jun 12 14:26:25 2006
@@ -67,7 +67,7 @@
 $dueBlock=array("80","65");
 $pdf->addRecBlock($valid_till, "Due Date",$dueBlock);
 
-// invoice number block
+// vtiger_invoice number block
 $invBlock=array("145","65");
 $pdf->addRecBlock($id, "Order Number",$invBlock);
 

Modified: vtigercrm/trunk/modules/Quotes/CreatePDF.php
==============================================================================
--- vtigercrm/trunk/modules/Quotes/CreatePDF.php (original)
+++ vtigercrm/trunk/modules/Quotes/CreatePDF.php Mon Jun 12 14:26:25 2006
@@ -16,7 +16,7 @@
 
 global $adb,$app_strings;
 
-$sql="select currency_symbol from currency_info";
+$sql="select vtiger_currency_symbol from vtiger_currency_info";
 $result = $adb->query($sql);
 $currency_symbol = $adb->query_result($result,0,'currency_symbol');
 
@@ -52,7 +52,7 @@
 $status = $focus->column_fields["quotestage"];
 
 // Company information
-$add_query = "select * from organizationdetails";
+$add_query = "select * from vtiger_organizationdetails";
 $result = $adb->query($add_query);
 $num_rows = $adb->num_rows($result);
 
@@ -78,7 +78,7 @@
 $price_total = $currency_symbol.number_format(StripLastZero($focus->column_fields["hdnGrandTotal"]),2,'.',',');
 
 //getting the Product Data
-$query="select products.productname,products.unit_price,products.product_description,quotesproductrel.* from quotesproductrel inner join products on products.productid=quotesproductrel.productid where quoteid=".$quote_id;
+$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.product_description,vtiger_quotesproductrel.* from vtiger_quotesproductrel inner join vtiger_products on vtiger_products.productid=vtiger_quotesproductrel.productid where quoteid=".$quote_id;
 
 global $result;
 $result = $adb->query($query);

Modified: vtigercrm/trunk/modules/Quotes/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Quotes/EditView.php (original)
+++ vtigercrm/trunk/modules/Quotes/EditView.php Mon Jun 12 14:26:25 2006
@@ -67,7 +67,7 @@
         $associated_prod = getAssociatedProducts("Products",$focus,$focus->column_fields['product_id']);
 }
 
-// Get Account address if account is given
+// Get Account address if vtiger_account is given
 if(isset($_REQUEST['account_id']) && $_REQUEST['account_id']!='' && $_REQUEST['record']==''){
 	require_once('modules/Accounts/Account.php');
 	$acct_focus = new Account();

Modified: vtigercrm/trunk/modules/Quotes/ListTopQuotes.php
==============================================================================
--- vtigercrm/trunk/modules/Quotes/ListTopQuotes.php (original)
+++ vtigercrm/trunk/modules/Quotes/ListTopQuotes.php Mon Jun 12 14:26:25 2006
@@ -56,7 +56,7 @@
 	//<<<<<<<<<customview>>>>>>>>>
 	$date_var = date('Y-m-d');
 
-	$where = ' and crmentity.smownerid='.$current_user->id.' and  quotes.validtill >= \''.$date_var.'\' ORDER BY total DESC';
+	$where = ' and vtiger_crmentity.smownerid='.$current_user->id.' and  vtiger_quotes.validtill >= \''.$date_var.'\' ORDER BY total DESC';
 	$query = getListQuery("Quotes",$where);
 
 	//<<<<<<<<customview>>>>>>>>>

Modified: vtigercrm/trunk/modules/Quotes/Quote.php
==============================================================================
--- vtigercrm/trunk/modules/Quotes/Quote.php (original)
+++ vtigercrm/trunk/modules/Quotes/Quote.php Mon Jun 12 14:26:25 2006
@@ -28,20 +28,20 @@
 require_once('data/CRMEntity.php');
 require_once('include/utils/utils.php');
 require_once('include/RelatedListView.php');
-// Account is used to store account information.
+// Account is used to store vtiger_account information.
 class Quote extends CRMEntity {
 	var $log;
 	var $db;
 
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $mode;
 	
 		
 	var $table_name = "quotes";
-	var $tab_name = Array('crmentity','quotes','quotesbillads','quotesshipads','quotescf');
-	var $tab_name_index = Array('crmentity'=>'crmid','quotes'=>'quoteid','quotesbillads'=>'quotebilladdressid','quotesshipads'=>'quoteshipaddressid','quotescf'=>'quoteid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_quotes','vtiger_quotesbillads','vtiger_quotesshipads','vtiger_quotescf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_quotes'=>'quoteid','vtiger_quotesbillads'=>'quotebilladdressid','vtiger_quotesshipads'=>'quoteshipaddressid','vtiger_quotescf'=>'quoteid');
 				
 	
 	var $entity_table = "crmentity";
@@ -58,10 +58,10 @@
 
 	var $sortby_fields = Array('subject','crmid','smownerid');		
 
-	// This is used to retrieve related fields from form posts.
+	// This is used to retrieve related vtiger_fields from form posts.
 	var $additional_column_fields = Array('assigned_user_name', 'smownerid', 'opportunity_id', 'case_id', 'contact_id', 'task_id', 'note_id', 'meeting_id', 'call_id', 'email_id', 'parent_name', 'member_id' );
 
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
 				'Quote Id'=>Array('crmentity'=>'crmid'),
 				'Subject'=>Array('quotes'=>'subject'),
@@ -101,7 +101,7 @@
 				        'Quote Stage'=>'quotestage',
 				      );
 
-	// This is the list of fields that are required.
+	// This is the list of vtiger_fields that are required.
 	var $required_fields =  array("accountname"=>1);
 
 	//Added these variables which are used as default order by and sortorder in ListView
@@ -125,7 +125,7 @@
 
 		$returnset = '&return_module=Quotes&return_action=DetailView&return_id='.$id;
 
-		$query = "select crmentity.*, salesorder.*, quotes.subject as quotename, account.accountname from salesorder inner join crmentity on crmentity.crmid=salesorder.salesorderid left outer join quotes on quotes.quoteid=salesorder.quoteid left outer join account on account.accountid=salesorder.accountid left join sogrouprelation on salesorder.salesorderid=sogrouprelation.salesorderid left join groups on groups.groupname=sogrouprelation.groupname where crmentity.deleted=0 and salesorder.quoteid = ".$id;
+		$query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename, vtiger_account.accountname from vtiger_salesorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_salesorder.quoteid = ".$id;
 		$log->debug("Exiting get_salesorder method ...");
 		return GetRelatedList('Quotes','SalesOrder',$focus,$query,$button,$returnset);
 	}
@@ -142,7 +142,7 @@
 
 		$returnset = '&return_module=Quotes&return_action=DetailView&return_id='.$id;
 
-		$query = "SELECT contactdetails.contactid, contactdetails.lastname, contactdetails.firstname, activity.*,seactivityrel.*,crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime, users.user_name,recurringevents.recurringtype from activity inner join seactivityrel on seactivityrel.activityid=activity.activityid inner join crmentity on crmentity.crmid=activity.activityid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid = cntactivityrel.contactid left join users on users.id=crmentity.smownerid left outer join recurringevents on recurringevents.activityid=activity.activityid left join activitygrouprelation on activitygrouprelation.activityid=crmentity.crmid left join groups on groups.groupname=activitygrouprelation.groupname where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and (activity.status is not NULL && activity.status != 'Completed') and (activity.status is not NULL && activity.status != 'Deferred') or (activity.eventstatus !='' && activity.eventstatus = 'Planned')";
+		$query = "SELECT vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name,vtiger_recurringevents.recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or vtiger_activitytype='Call' or vtiger_activitytype='Meeting') and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Deferred') or (vtiger_activity.eventstatus !='' && vtiger_activity.eventstatus = 'Planned')";
 		$log->debug("Exiting get_activities method ...");
 		return GetRelatedList('Quotes','Activities',$focus,$query,$button,$returnset);
 	}
@@ -150,21 +150,21 @@
 	{
 		global $log;
 		$log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT activity.activityid, activity.subject, activity.status,
-				activity.eventstatus, activity.activitytype, contactdetails.contactid,
-				contactdetails.firstname,	contactdetails.lastname, crmentity.modifiedtime,
-				crmentity.createdtime, crmentity.description, users.user_name
-			from activity
-				inner join seactivityrel on seactivityrel.activityid=activity.activityid
-				inner join crmentity on crmentity.crmid=activity.activityid
-				left join cntactivityrel on cntactivityrel.activityid= activity.activityid
-				left join contactdetails on contactdetails.contactid= cntactivityrel.contactid
-				inner join users on crmentity.smcreatorid= users.id
-				left join activitygrouprelation on activitygrouprelation.activityid=activity.activityid
-                                left join groups on groups.groupname=activitygrouprelation.groupname
-			where (activity.activitytype = 'Meeting' or activity.activitytype='Call' or activity.activitytype='Task')
-  				and (activity.status = 'Completed' or activity.status = 'Deferred' or (activity.eventstatus !='Planned' and activity.eventstatus != ''))
-	 	        	and seactivityrel.crmid=".$id;
+		$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status,
+			vtiger_activity.eventstatus, vtiger_activity.activitytype, vtiger_contactdetails.contactid,
+			vtiger_contactdetails.firstname,vtiger_contactdetails.lastname, vtiger_crmentity.modifiedtime,
+			vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
+			from vtiger_activity
+				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
+				left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid
+				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
+				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+			where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
+  				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus !='Planned' and vtiger_activity.eventstatus != ''))
+	 	        	and vtiger_seactivityrel.crmid=".$id;
 		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
 
 		$log->debug("Exiting get_history method ...");

Modified: vtigercrm/trunk/modules/Quotes/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Quotes/Save.php (original)
+++ vtigercrm/trunk/modules/Quotes/Save.php Mon Jun 12 14:26:25 2006
@@ -42,7 +42,7 @@
 $ext_prod_arr = Array();
 if($focus->mode == 'edit')
 {	
-	$query2  = "select * from quotesproductrel where quoteid=".$focus->id;
+	$query2  = "select * from vtiger_quotesproductrel where quoteid=".$focus->id;
 	$result2 = $adb->query($query2);
 	$num_rows = $adb->num_rows($result2);
 	for($i=0; $i<$num_rows;$i++)
@@ -52,8 +52,8 @@
 		$ext_prod_arr[$pro_id] = $pro_qty;	
 	}
 	
-	 $log->debug("Deleting from quotesproductrel table ");
-	$query1 = "delete from quotesproductrel where quoteid=".$focus->id;
+	 $log->debug("Deleting from vtiger_quotesproductrel vtiger_table ");
+	$query1 = "delete from vtiger_quotesproductrel where quoteid=".$focus->id;
 	$adb->query($query1);
 
 }
@@ -82,7 +82,7 @@
 	if($prod_status != 'D')
 	{
 		
-		$query ="insert into quotesproductrel values($focus->id, $prod_id, $qty, $listprice, $vat, $sales, $service)";
+		$query ="insert into vtiger_quotesproductrel values($focus->id, $prod_id, $qty, $listprice, $vat, $sales, $service)";
 		$adb->query($query);
 		//Checking the re-order level and sending mail	
 		updateStk($prod_id,$qty,$focus->mode,$ext_prod_arr,'Quotes');

Modified: vtigercrm/trunk/modules/Quotes/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Quotes/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Quotes/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -79,10 +79,10 @@
 'NTC_COPY_SHIPPING_ADDRESS'=>'Copy shipping address to billing address',
 'NTC_REMOVE_MEMBER_ORG_CONFIRMATION'=>'Are you sure you want to remove this record as a member organization?',
 'LBL_DUPLICATE'=>'Potential Duplicate Accounts',
-'MSG_DUPLICATE' => 'Creating this account may potentialy create a duplicate account. You may either select an account from the list below or you may click on Create New Account to continue creating a new account with the previously entered data.',
+'MSG_DUPLICATE' => 'Creating this vtiger_account may vtiger_potentialy create a duplicate vtiger_account. You may either select an vtiger_account from the list below or you may click on Create New Account to continue creating a new vtiger_account with the previously entered data.',
 
 'LBL_INVITEE'=>'Contacts',
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
 
 'LBL_SELECT_ACCOUNT'=>'Select Account',
 'LBL_GENERAL_INFORMATION'=>'General Information',
@@ -102,7 +102,7 @@
 'LBL_NEW_CONTACT'=>'New Contact',
 'LBL_CONTACT_TITLE'=>'Contacts',
 
-//Added fields after RC1 - Release
+//Added vtiger_fields after RC1 - Release
 'LBL_ALL'=>'All',
 'LBL_PROSPECT'=>'Prospect',
 'LBL_INVESTOR'=>'Investor',

Modified: vtigercrm/trunk/modules/Quotes/pdf_templates/header.php
==============================================================================
--- vtigercrm/trunk/modules/Quotes/pdf_templates/header.php (original)
+++ vtigercrm/trunk/modules/Quotes/pdf_templates/header.php Mon Jun 12 14:26:25 2006
@@ -62,7 +62,7 @@
 $dueBlock=array("80","65");
 $pdf->addRecBlock($valid_till, "Valid Till",$dueBlock);
 
-// invoice number block
+// vtiger_invoice number block
 $invBlock=array("147","65");
 $pdf->addRecBlock($quote_id, "Quote Number",$invBlock);
 

Modified: vtigercrm/trunk/modules/Reports/ChangeFolder.php
==============================================================================
--- vtigercrm/trunk/modules/Reports/ChangeFolder.php (original)
+++ vtigercrm/trunk/modules/Reports/ChangeFolder.php Mon Jun 12 14:26:25 2006
@@ -32,7 +32,7 @@
 function ChangeFolder($reportid,$folderid)
 {
 	global $adb;
-	$imovereportsql = "update report set folderid=".$folderid." where reportid=".$reportid;
+	$imovereportsql = "update vtiger_report set folderid=".$folderid." where vtiger_reportid=".$reportid;
 	$imovereportsqlresult = $adb->query($imovereportsql);
 }
 ?>

Modified: vtigercrm/trunk/modules/Reports/Delete.php
==============================================================================
--- vtigercrm/trunk/modules/Reports/Delete.php (original)
+++ vtigercrm/trunk/modules/Reports/Delete.php Mon Jun 12 14:26:25 2006
@@ -31,10 +31,10 @@
 function DeleteReport($reportid)
 {
 	global $adb;
-	$idelreportsql = "delete from selectquery where queryid=".$reportid;
+	$idelreportsql = "delete from vtiger_selectquery where queryid=".$reportid;
 	$idelreportsqlresult = $adb->query($idelreportsql);
 
-	$ireportsql = "delete from report where reportid=".$reportid;
+	$ireportsql = "delete from vtiger_report where vtiger_reportid=".$reportid;
     $ireportsqlresult = $adb->query($ireportsql);
 }
 ?>

Modified: vtigercrm/trunk/modules/Reports/DeleteReportFolder.php
==============================================================================
--- vtigercrm/trunk/modules/Reports/DeleteReportFolder.php (original)
+++ vtigercrm/trunk/modules/Reports/DeleteReportFolder.php Mon Jun 12 14:26:25 2006
@@ -17,7 +17,7 @@
 $rfid = $_REQUEST['record'];
 if($rfid != "")
 {
-	$sql .= "delete from reportfolder where folderid=".$rfid;
+	$sql .= "delete from vtiger_reportfolder where folderid=".$rfid;
 	$result = $adb->query($sql);
 	if($result!=false)
 	{

Modified: vtigercrm/trunk/modules/Reports/PopulateReports.php
==============================================================================
--- vtigercrm/trunk/modules/Reports/PopulateReports.php (original)
+++ vtigercrm/trunk/modules/Reports/PopulateReports.php Mon Jun 12 14:26:25 2006
@@ -274,7 +274,7 @@
 
 		 Array('reportname'=>'Quotes Detailed Report',
                        'reportfolder'=>'Quote Reports',
-                       'description'=>'Quotes detailed report',
+                       'description'=>'Quotes detailed vtiger_report',
                        'reporttype'=>'tabular',
                        'sortid'=>'','stdfilterid'=>'','advfilterid'=>''),
 
@@ -286,13 +286,13 @@
 
 		 Array('reportname'=>'PurchaseOrder Detailed Report',
                        'reportfolder'=>'PurchaseOrder Reports',
-                       'description'=>'PurchaseOrder detailed report',
+                       'description'=>'PurchaseOrder detailed vtiger_report',
                        'reporttype'=>'tabular',
                        'sortid'=>'','stdfilterid'=>'','advfilterid'=>''),
 
 		 Array('reportname'=>'Invoice Detailed Report',
                        'reportfolder'=>'Invoice Reports',
-                       'description'=>'Invoice detailed report',
+                       'description'=>'Invoice detailed vtiger_report',
                        'reporttype'=>'tabular',
                        'sortid'=>'','stdfilterid'=>'','advfilterid'=>'')
 
@@ -416,13 +416,13 @@
 function PopulateReportFolder($fldrname,$fldrdescription)
 {
 	global $adb;
-	$sql = "INSERT INTO reportfolder ";
+	$sql = "INSERT INTO vtiger_reportfolder ";
 	$sql .= "(FOLDERNAME,DESCRIPTION,STATE) ";
 	$sql .= "VALUES ('".$fldrname."','".$fldrdescription."','SAVED')";
 	$result = $adb->query($sql);
 }
 
-/** Function to add an entry in selestquery table 
+/** Function to add an entry in selestquery vtiger_table 
  *
  */
 
@@ -432,14 +432,14 @@
 	$genQueryId = $adb->getUniqueID("selectquery");
         if($genQueryId != "")
         {
-		$iquerysql = "insert into selectquery (QUERYID,STARTINDEX,NUMOFOBJECTS) values (".$genQueryId.",0,0)";
+		$iquerysql = "insert into vtiger_selectquery (QUERYID,STARTINDEX,NUMOFOBJECTS) values (".$genQueryId.",0,0)";
 		$iquerysqlresult = $adb->query($iquerysql);
 	}
 
 	return $genQueryId;
 }
 
-/** Function to store the field names selected for a report to a database
+/** Function to store the vtiger_field names selected for a vtiger_report to a database
  *  
  *  
  */
@@ -451,16 +451,16 @@
 	{
 		for($i=0;$i < count($columnname);$i++)
 		{
-			$icolumnsql = "insert into selectcolumn (QUERYID,COLUMNINDEX,COLUMNNAME) values (".$queryid.",".$i.",'".$columnname[$i]."')";
+			$icolumnsql = "insert into vtiger_selectcolumn (QUERYID,COLUMNINDEX,COLUMNNAME) values (".$queryid.",".$i.",'".$columnname[$i]."')";
 			$icolumnsqlresult = $adb->query($icolumnsql);	
 		}
 	}
 }
 
 
-/** Function to store the report details to database
+/** Function to store the vtiger_report details to database
  *  This function accepts queryid,folderid,reportname,description,reporttype
- *  as arguments and store the informations in report table
+ *  as arguments and store the informations in vtiger_report vtiger_table
  */
 
 function insertReports($queryid,$folderid,$reportname,$description,$reporttype)
@@ -468,15 +468,15 @@
 	global $adb;
 	if($queryid != "")
 	{
-		$ireportsql = "insert into report (REPORTID,FOLDERID,REPORTNAME,DESCRIPTION,REPORTTYPE,QUERYID,STATE)";
+		$ireportsql = "insert into vtiger_report (REPORTID,FOLDERID,REPORTNAME,DESCRIPTION,REPORTTYPE,QUERYID,STATE)";
                 $ireportsql .= " values (".$queryid.",".$folderid.",'".$reportname."','".$description."','".$reporttype."',".$queryid.",'SAVED')";
 		$ireportresult = $adb->query($ireportsql);
 	}
 }
 
-/** Function to store the report modules to database
+/** Function to store the vtiger_report modules to database
  *  This function accepts queryid,primary module and secondary module
- *  as arguments and store the informations in reportmodules table
+ *  as arguments and store the informations in vtiger_reportmodules vtiger_table
  */
 
 
@@ -485,16 +485,16 @@
 	global $adb;
 	if($queryid != "")
 	{
-		$ireportmodulesql = "insert into reportmodules (REPORTMODULESID,PRIMARYMODULE,SECONDARYMODULES) values (".$queryid.",'".$primarymodule."','".$secondarymodule."')";
+		$ireportmodulesql = "insert into vtiger_reportmodules (REPORTMODULESID,PRIMARYMODULE,SECONDARYMODULES) values (".$queryid.",'".$primarymodule."','".$secondarymodule."')";
 		$ireportmoduleresult = $adb->query($ireportmodulesql);
 	}
 }
 
 
-/** Function to store the report sortorder to database
+/** Function to store the vtiger_report sortorder to database
  *  This function accepts queryid,sortlists
  *  as arguments and store the informations sort columns and
- *  and sortorder in reportsortcol table
+ *  and sortorder in vtiger_reportsortcol vtiger_table
  */
 
 
@@ -505,7 +505,7 @@
 	{
 		foreach($sortlists as $i=>$sort)
                 {
-			$sort_bysql = "insert into reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) 
+			$sort_bysql = "insert into vtiger_reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) 
 					values (".($i+1).",".$queryid.",'".$sort['columnname']."','".$sort['sortorder']."')";
 			$sort_byresult = $adb->query($sort_bysql);
 		}
@@ -514,9 +514,9 @@
 }
 
 
-/** Function to store the report sort date details to database
+/** Function to store the vtiger_report sort date details to database
  *  This function accepts queryid,filtercolumn,datefilter,startdate,enddate
- *  as arguments and store the informations in reportdatefilter table
+ *  as arguments and store the informations in vtiger_reportdatefilter vtiger_table
  */
 
 
@@ -525,15 +525,15 @@
 	global $adb;
 	if($queryid != "")
 	{
-		$ireportmodulesql = "insert into reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$queryid.",'".$filtercolumn."','".$datefilter."','".$startdate."','".$enddate."')";
+		$ireportmodulesql = "insert into vtiger_reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$queryid.",'".$filtercolumn."','".$datefilter."','".$startdate."','".$enddate."')";
 		$ireportmoduleresult = $adb->query($ireportmodulesql);
 	}
 
 }
 
-/** Function to store the report conditions to database
+/** Function to store the vtiger_report conditions to database
  *  This function accepts queryid,filters
- *  as arguments and store the informations in relcriteria table
+ *  as arguments and store the informations in vtiger_relcriteria vtiger_table
  */
 
 
@@ -544,7 +544,7 @@
 	{
 		foreach($filters as $i=>$filter)
 		{
-		      $irelcriteriasql = "insert into relcriteria(QUERYID,COLUMNINDEX,COLUMNNAME,COMPARATOR,VALUE) 
+		      $irelcriteriasql = "insert into vtiger_relcriteria(QUERYID,COLUMNINDEX,COLUMNNAME,COMPARATOR,VALUE) 
 		      values (".$queryid.",".$i.",'".$filter['columnname']."','".$filter['comparator']."','".$filter['value']."')";
 		      $irelcriteriaresult = $adb->query($irelcriteriasql);
 		}

Modified: vtigercrm/trunk/modules/Reports/ReportColumns.php
==============================================================================
--- vtigercrm/trunk/modules/Reports/ReportColumns.php (original)
+++ vtigercrm/trunk/modules/Reports/ReportColumns.php Mon Jun 12 14:26:25 2006
@@ -52,9 +52,9 @@
 	
 }
 
-/** Function to formulate the fields for the primary modules 
+/** Function to formulate the vtiger_fields for the primary modules 
  *  This function accepts the module name 
- *  as arguments and generates the fields for the primary module as
+ *  as arguments and generates the vtiger_fields for the primary module as
  *  a HTML Combo values
  */
 
@@ -85,9 +85,9 @@
 	return $shtml;
 }
 
-/** Function to formulate the fields for the secondary modules
+/** Function to formulate the vtiger_fields for the secondary modules
  *  This function accepts the module name
- *  as arguments and generates the fields for the secondary module as
+ *  as arguments and generates the vtiger_fields for the secondary module as
  *  a HTML Combo values
  */
 

Modified: vtigercrm/trunk/modules/Reports/ReportRun.php
==============================================================================
--- vtigercrm/trunk/modules/Reports/ReportRun.php (original)
+++ vtigercrm/trunk/modules/Reports/ReportRun.php Mon Jun 12 14:26:25 2006
@@ -50,10 +50,10 @@
 		global $modules;
 		global $log;
 
-		$ssql = "select selectcolumn.* from report inner join selectquery on selectquery.queryid = report.queryid";
-                $ssql .= " left join selectcolumn on selectcolumn.queryid = selectquery.queryid";
-		$ssql .= " where report.reportid =".$reportid;
-                $ssql .= " order by selectcolumn.columnindex";
+		$ssql = "select vtiger_selectcolumn.* from vtiger_report inner join vtiger_selectquery on vtiger_selectquery.queryid = vtiger_report.queryid";
+                $ssql .= " left join vtiger_selectcolumn on vtiger_selectcolumn.queryid = vtiger_selectquery.queryid";
+		$ssql .= " where vtiger_report.reportid =".$reportid;
+                $ssql .= " order by vtiger_selectcolumn.columnindex";
 
                 $result = $adb->query($ssql);
 
@@ -82,15 +82,15 @@
 		{
 			if($this->primarymodule == "HelpDesk")
 			{
-				$querycolumn = "case crmentityRelHelpDesk.setype when 'Accounts' then accountRelHelpDesk.accountname when 'Contacts' then contactdetailsRelHelpDesk.lastname End"." '".$selectedfields[2]."', crmentityRelHelpDesk.setype 'Entity_type'";
+				$querycolumn = "case vtiger_crmentityRelHelpDesk.setype when 'Accounts' then vtiger_accountRelHelpDesk.accountname when 'Contacts' then vtiger_contactdetailsRelHelpDesk.lastname End"." '".$selectedfields[2]."', vtiger_crmentityRelHelpDesk.setype 'Entity_type'";
 			}
 			if($this->primarymodule == "Products" || $this->secondarymodule == "Products")
 			{
-				$querycolumn = "case crmentityRelProducts.setype when 'Accounts' then accountRelProducts.accountname when 'Leads' then leaddetailsRelProducts.lastname when 'Potentials' then potentialRelProducts.potentialname End"." '".$selectedfields[2]."', crmentityRelProducts.setype 'Entity_type'";
+				$querycolumn = "case vtiger_crmentityRelProducts.setype when 'Accounts' then vtiger_accountRelProducts.accountname when 'Leads' then vtiger_leaddetailsRelProducts.lastname when 'Potentials' then vtiger_potentialRelProducts.potentialname End"." '".$selectedfields[2]."', vtiger_crmentityRelProducts.setype 'Entity_type'";
 			}
 			if($this->primarymodule == "Activities" || $this->secondarymodule == "Activities")
 			{
-				$querycolumn = "case crmentityRelActivities.setype when 'Accounts' then accountRelActivities.accountname when 'Leads' then leaddetailsRelActivities.lastname when 'Potentials' then potentialRelActivities.potentialname when 'Quotes' then quotesRelActivities.subject when 'PurchaseOrder' then purchaseorderRelActivities.subject when 'Invoice' then invoiceRelActivities.subject End"." '".$selectedfields[2]."', crmentityRelActivities.setype 'Entity_type'";
+				$querycolumn = "case vtiger_crmentityRelActivities.setype when 'Accounts' then vtiger_accountRelActivities.accountname when 'Leads' then vtiger_leaddetailsRelActivities.lastname when 'Potentials' then vtiger_potentialRelActivities.potentialname when 'Quotes' then vtiger_quotesRelActivities.subject when 'PurchaseOrder' then vtiger_purchaseorderRelActivities.subject when 'Invoice' then vtiger_invoiceRelActivities.subject End"." '".$selectedfields[2]."', vtiger_crmentityRelActivities.setype 'Entity_type'";
 			}
 		}
 		return $querycolumn;
@@ -103,9 +103,9 @@
 		global $modules;
 		global $log;
 		
-		$ssql = "select selectcolumn.* from report inner join selectquery on selectquery.queryid = report.queryid"; 
-		$ssql .= " left join selectcolumn on selectcolumn.queryid = selectquery.queryid where report.reportid =".$reportid; 
-		$ssql .= " order by selectcolumn.columnindex";
+		$ssql = "select vtiger_selectcolumn.* from vtiger_report inner join vtiger_selectquery on vtiger_selectquery.queryid = vtiger_report.queryid"; 
+		$ssql .= " left join vtiger_selectcolumn on vtiger_selectcolumn.queryid = vtiger_selectquery.queryid where vtiger_report.reportid =".$reportid; 
+		$ssql .= " order by vtiger_selectcolumn.columnindex";
 		
 		$result = $adb->query($ssql);
 		$noofrows = $adb->num_rows($result);
@@ -209,11 +209,11 @@
 		global $modules;
 		global $log;
 
-		$advfiltersql =  "select relcriteria.* from report";
-		$advfiltersql .= " inner join selectquery on selectquery.queryid = report.queryid";
-                $advfiltersql .= " left join relcriteria on relcriteria.queryid = selectquery.queryid";
-                $advfiltersql .= " where report.reportid =".$reportid;
-                $advfiltersql .= " order by relcriteria.columnindex";
+		$advfiltersql =  "select vtiger_relcriteria.* from vtiger_report";
+		$advfiltersql .= " inner join vtiger_selectquery on vtiger_selectquery.queryid = vtiger_report.queryid";
+                $advfiltersql .= " left join vtiger_relcriteria on vtiger_relcriteria.queryid = vtiger_selectquery.queryid";
+                $advfiltersql .= " where vtiger_report.reportid =".$reportid;
+                $advfiltersql .= " order by vtiger_relcriteria.columnindex";
 		
 		$result = $adb->query($advfiltersql);
 		while($advfilterrow = $adb->fetch_array($result))
@@ -253,9 +253,9 @@
 		global $modules;
 		global $log;
 
-		$stdfiltersql = "select reportdatefilter.* from report";
-		$stdfiltersql .= " inner join reportdatefilter on report.reportid = reportdatefilter.datefilterid";
-		$stdfiltersql .= " where report.reportid = ".$reportid;
+		$stdfiltersql = "select vtiger_reportdatefilter.* from vtiger_report";
+		$stdfiltersql .= " inner join vtiger_reportdatefilter on vtiger_report.reportid = vtiger_reportdatefilter.datefilterid";
+		$stdfiltersql .= " where vtiger_report.reportid = ".$reportid;
 
 		$result = $adb->query($stdfiltersql);
 		$stdfilterrow = $adb->fetch_array($result);
@@ -324,9 +324,9 @@
 		global $modules;
 		global $log;
 
-		$sreportstdfiltersql = "select reportdatefilter.* from report"; 
-		$sreportstdfiltersql .= " inner join reportdatefilter on report.reportid = reportdatefilter.datefilterid"; 
-		$sreportstdfiltersql .= " where report.reportid =".$reportid;
+		$sreportstdfiltersql = "select vtiger_reportdatefilter.* from vtiger_report"; 
+		$sreportstdfiltersql .= " inner join vtiger_reportdatefilter on vtiger_report.reportid = vtiger_reportdatefilter.datefilterid"; 
+		$sreportstdfiltersql .= " where vtiger_report.reportid =".$reportid;
 		
 		$result = $adb->query($sreportstdfiltersql);
 		$noofrows = $adb->num_rows($result);
@@ -568,9 +568,9 @@
 		global $modules;
 		global $log;
 
-		$sreportsortsql = "select reportsortcol.* from report";
-                $sreportsortsql .= " inner join reportsortcol on report.reportid = reportsortcol.reportid";
-                $sreportsortsql .= " where report.reportid =".$reportid." order by reportsortcol.sortcolid";
+		$sreportsortsql = "select vtiger_reportsortcol.* from vtiger_report";
+                $sreportsortsql .= " inner join vtiger_reportsortcol on vtiger_report.reportid = vtiger_reportsortcol.reportid";
+                $sreportsortsql .= " where vtiger_report.reportid =".$reportid." order by vtiger_reportsortcol.sortcolid";
 		
 		$result = $adb->query($sreportsortsql);
 
@@ -607,9 +607,9 @@
 		global $modules;
 		global $log;
 	
-		$sreportsortsql = "select reportsortcol.* from report"; 
-		$sreportsortsql .= " inner join reportsortcol on report.reportid = reportsortcol.reportid"; 
-		$sreportsortsql .= " where report.reportid =".$reportid." order by reportsortcol.sortcolid";
+		$sreportsortsql = "select vtiger_reportsortcol.* from vtiger_report"; 
+		$sreportsortsql .= " inner join vtiger_reportsortcol on vtiger_report.reportid = vtiger_reportsortcol.reportid"; 
+		$sreportsortsql .= " where vtiger_report.reportid =".$reportid." order by vtiger_reportsortcol.sortcolid";
 		
 		$result = $adb->query($sreportsortsql);
 		$noofrows = $adb->num_rows($result);
@@ -654,43 +654,43 @@
 		{
 			if($secmodule == "Accounts")
 			{
-				$query = "left join account on account.accountid = contactdetails.accountid
-                                left join crmentity as crmentityAccounts on crmentityAccounts.crmid=account.accountid
-                                left join accountbillads on account.accountid=accountbillads.accountaddressid
-                                left join accountshipads on account.accountid=accountshipads.accountaddressid
-                                left join accountscf on account.accountid = accountscf.accountid
-                                left join account as accountAccounts on accountAccounts.accountid = account.parentid
-                                left join users as usersAccounts on usersAccounts.id = crmentityAccounts.smownerid ";
+				$query = "left join vtiger_account on vtiger_account.accountid = vtiger_contactdetails.accountid
+                                left join vtiger_crmentity as vtiger_crmentityAccounts on vtiger_crmentityAccounts.crmid=vtiger_account.accountid
+                                left join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid
+                                left join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid
+                                left join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid
+                                left join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid
+                                left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentityAccounts.smownerid ";
 			}
 			if($secmodule == "Potentials")
 			{
-				$query = "left join  potential on potential.accountid = contactdetails.accountid
-				left join crmentity as crmentityPotentials on crmentityPotentials.crmid=potential.potentialid
-				left join account as accountPotentials on potential.accountid = accountPotentials.accountid
-				left join potentialscf on potentialscf.potentialid = potential.potentialid
-				left join users as usersPotentials on usersPotentials.id = crmentityPotentials.smownerid ";
+				$query = "left join  vtiger_potential on vtiger_potential.accountid = vtiger_contactdetails.accountid
+				left join vtiger_crmentity as vtiger_crmentityPotentials on vtiger_crmentityPotentials.crmid=vtiger_potential.potentialid
+				left join vtiger_account as vtiger_accountPotentials on vtiger_potential.accountid = vtiger_accountPotentials.accountid
+				left join vtiger_potentialscf on vtiger_potentialscf.potentialid = vtiger_potential.potentialid
+				left join vtiger_users as vtiger_usersPotentials on vtiger_usersPotentials.id = vtiger_crmentityPotentials.smownerid ";
 			}
 			if($secmodule == "Quotes")
                         {
-                                $query = "left join quotes on quotes.contactid = contactdetails.contactid
-                                left join crmentity as crmentityQuotes on crmentityQuotes.crmid=quotes.quoteid
-                                left join quotesbillads on quotes.quoteid=quotesbillads.quotebilladdressid
-                                left join quotesshipads on quotes.quoteid=quotesshipads.quoteshipaddressid
-                                left join users as usersQuotes on usersQuotes.id = crmentityQuotes.smownerid
-                                left join users as usersRel1 on usersRel1.id = quotes.inventorymanager
-                                left join potential as potentialRel on potentialRel.potentialid = quotes.potentialid
-                                left join contactdetails as contactdetailsQuotes on contactdetailsQuotes.contactid = quotes.contactid
-                                left join account as accountQuotes on accountQuotes.accountid = quotes.accountid ";
+                                $query = "left join vtiger_quotes on vtiger_quotes.contactid = vtiger_contactdetails.contactid
+                                left join vtiger_crmentity as vtiger_crmentityQuotes on vtiger_crmentityQuotes.crmid=vtiger_quotes.quoteid
+                                left join vtiger_quotesbillads on vtiger_quotes.quoteid=vtiger_quotesbillads.quotebilladdressid
+                                left join vtiger_quotesshipads on vtiger_quotes.quoteid=vtiger_quotesshipads.quoteshipaddressid
+                                left join vtiger_users as vtiger_usersQuotes on vtiger_usersQuotes.id = vtiger_crmentityQuotes.smownerid
+                                left join vtiger_users as vtiger_usersRel1 on vtiger_usersRel1.id = vtiger_quotes.inventorymanager
+                                left join vtiger_potential as vtiger_potentialRel on vtiger_potentialRel.potentialid = vtiger_quotes.potentialid
+                                left join vtiger_contactdetails as vtiger_contactdetailsQuotes on vtiger_contactdetailsQuotes.contactid = vtiger_quotes.contactid
+                                left join vtiger_account as vtiger_accountQuotes on vtiger_accountQuotes.accountid = vtiger_quotes.accountid ";
                         }
                         if($secmodule == "PurchaseOrder")
                         {
-                                $query = "left join purchaseorder on purchaseorder.contactid = contactdetails.contactid
-                                left join crmentity as crmentityPurchaseOrder on crmentityPurchaseOrder.crmid=purchaseorder.purchaseorderid
-                                left join pobillads on purchaseorder.purchaseorderid=pobillads.pobilladdressid
-                                left join poshipads on purchaseorder.purchaseorderid=poshipads.poshipaddressid
-                                left join users as usersPurchaseOrder on usersPurchaseOrder.id = crmentityPurchaseOrder.smownerid
-                                left join vendor as vendorRel on vendorRel.vendorid = purchaseorder.vendorid
-                                left join contactdetails as contactdetailsPurchaseOrder on contactdetailsPurchaseOrder.contactid = purchaseorder.contactid ";
+                                $query = "left join vtiger_purchaseorder on vtiger_purchaseorder.contactid = vtiger_contactdetails.contactid
+                                left join vtiger_crmentity as vtiger_crmentityPurchaseOrder on vtiger_crmentityPurchaseOrder.crmid=vtiger_purchaseorder.purchaseorderid
+                                left join vtiger_pobillads on vtiger_purchaseorder.purchaseorderid=vtiger_pobillads.pobilladdressid
+                                left join vtiger_poshipads on vtiger_purchaseorder.purchaseorderid=vtiger_poshipads.poshipaddressid
+                                left join vtiger_users as vtiger_usersPurchaseOrder on vtiger_usersPurchaseOrder.id = vtiger_crmentityPurchaseOrder.smownerid
+                                left join vtiger_vendor as vtiger_vendorRel on vtiger_vendorRel.vendorid = vtiger_purchaseorder.vendorid
+                                left join vtiger_contactdetails as vtiger_contactdetailsPurchaseOrder on vtiger_contactdetailsPurchaseOrder.contactid = vtiger_purchaseorder.contactid ";
                         }
 
 		}
@@ -699,100 +699,100 @@
 		{
 			if($secmodule == "Potentials")
 			{
-				$query = "left join potential on potential.accountid = account.accountid
-				left join crmentity as crmentityPotentials on crmentityPotentials.crmid=potential.potentialid
-                                left join potentialscf on potentialscf.potentialid = potential.potentialid
-                                left join users as usersPotentials on usersPotentials.id = crmentityPotentials.smownerid ";
+				$query = "left join vtiger_potential on vtiger_potential.accountid = vtiger_account.accountid
+				left join vtiger_crmentity as vtiger_crmentityPotentials on vtiger_crmentityPotentials.crmid=vtiger_potential.potentialid
+                                left join vtiger_potentialscf on vtiger_potentialscf.potentialid = vtiger_potential.potentialid
+                                left join vtiger_users as vtiger_usersPotentials on vtiger_usersPotentials.id = vtiger_crmentityPotentials.smownerid ";
 
 			}
 			if($secmodule == "Contacts")
 			{
-				$query = "left join contactdetails on contactdetails.accountid = account.accountid
-				left join crmentity as crmentityContacts on crmentityContacts.crmid = contactdetails.contactid
-                                left join contactaddress on contactdetails.contactid = contactaddress.contactaddressid
-                                left join contactsubdetails on contactdetails.contactid = contactsubdetails.contactsubscriptionid
-				left join contactdetails as contactdetailsContacts on contactdetailsContacts.contactid = contactdetails.reportsto
-				left join account as accountContacts on accountContacts.accountid = contactdetails.accountid 
-                                left join contactscf on contactdetails.contactid = contactscf.contactid
-                                left join users as usersContacts on usersContacts.id = crmentityContacts.smownerid ";
+				$query = "left join vtiger_contactdetails on vtiger_contactdetails.accountid = vtiger_account.accountid
+				left join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid
+                                left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid
+                                left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid
+				left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
+				left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid 
+                                left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid
+                                left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid ";
 			}
 			if($secmodule == "Quotes")
 			{
-				$query = "left join quotes on quotes.accountid = account.accountid
-                                left join crmentity as crmentityQuotes on crmentityQuotes.crmid=quotes.quoteid
-                                left join quotesbillads on quotes.quoteid=quotesbillads.quotebilladdressid
-                                left join quotesshipads on quotes.quoteid=quotesshipads.quoteshipaddressid
-                                left join users as usersQuotes on usersQuotes.id = crmentityQuotes.smownerid
-                                left join users as usersRel1 on usersRel1.id = quotes.inventorymanager
-                                left join potential as potentialRel on potentialRel.potentialid = quotes.potentialid
-                                left join contactdetails as contactdetailsQuotes on contactdetailsQuotes.contactid = quotes.contactid
-                                left join account as accountQuotes on accountQuotes.accountid = quotes.accountid ";
+				$query = "left join vtiger_quotes on vtiger_quotes.accountid = vtiger_account.accountid
+                                left join vtiger_crmentity as vtiger_crmentityQuotes on vtiger_crmentityQuotes.crmid=vtiger_quotes.quoteid
+                                left join vtiger_quotesbillads on vtiger_quotes.quoteid=vtiger_quotesbillads.quotebilladdressid
+                                left join vtiger_quotesshipads on vtiger_quotes.quoteid=vtiger_quotesshipads.quoteshipaddressid
+                                left join vtiger_users as vtiger_usersQuotes on vtiger_usersQuotes.id = vtiger_crmentityQuotes.smownerid
+                                left join vtiger_users as vtiger_usersRel1 on vtiger_usersRel1.id = vtiger_quotes.inventorymanager
+                                left join vtiger_potential as vtiger_potentialRel on vtiger_potentialRel.potentialid = vtiger_quotes.potentialid
+                                left join vtiger_contactdetails as vtiger_contactdetailsQuotes on vtiger_contactdetailsQuotes.contactid = vtiger_quotes.contactid
+                                left join vtiger_account as vtiger_accountQuotes on vtiger_accountQuotes.accountid = vtiger_quotes.accountid ";
 			}
 			if($secmodule == "PurchaseOrder")
 			{
-				$query = "left join purchaseorder on purchaseorder.accountid = account.accountid
-                                left join crmentity as crmentityPurchaseOrder on crmentityPurchaseOrder.crmid=purchaseorder.purchaseorderid
-                                left join pobillads on purchaseorder.purchaseorderid=pobillads.pobilladdressid
-                                left join poshipads on purchaseorder.purchaseorderid=poshipads.poshipaddressid
-                                left join users as usersPurchaseOrder on usersPurchaseOrder.id = crmentityPurchaseOrder.smownerid
-                                left join vendor as vendorRel on vendorRel.vendorid = purchaseorder.vendorid
-                                left join contactdetails as contactdetailsPurchaseOrder on contactdetailsPurchaseOrder.contactid = purchaseorder.contactid ";
+				$query = "left join vtiger_purchaseorder on vtiger_purchaseorder.accountid = vtiger_account.accountid
+                                left join vtiger_crmentity as vtiger_crmentityPurchaseOrder on vtiger_crmentityPurchaseOrder.crmid=vtiger_purchaseorder.purchaseorderid
+                                left join vtiger_pobillads on vtiger_purchaseorder.purchaseorderid=vtiger_pobillads.pobilladdressid
+                                left join vtiger_poshipads on vtiger_purchaseorder.purchaseorderid=vtiger_poshipads.poshipaddressid
+                                left join vtiger_users as vtiger_usersPurchaseOrder on vtiger_usersPurchaseOrder.id = vtiger_crmentityPurchaseOrder.smownerid
+                                left join vtiger_vendor as vtiger_vendorRel on vtiger_vendorRel.vendorid = vtiger_purchaseorder.vendorid
+                                left join vtiger_contactdetails as vtiger_contactdetailsPurchaseOrder on vtiger_contactdetailsPurchaseOrder.contactid = vtiger_purchaseorder.contactid ";
 			}
 			if($secmodule == "Invoice")
 			{
-				$query = "left join invoice on invoice.accountid = account.accountid
-                                left join crmentity as crmentityInvoice on crmentityInvoice.crmid=invoice.invoiceid
-                                left join invoicebillads on invoice.invoiceid=invoicebillads.invoicebilladdressid
-                                left join invoiceshipads on invoice.invoiceid=invoiceshipads.invoiceshipaddressid
-                                left join users as usersInvoice on usersInvoice.id = crmentityInvoice.smownerid
-                                left join account as accountInvoice on accountInvoice.accountid = invoice.accountid ";
+				$query = "left join vtiger_invoice on vtiger_invoice.accountid = vtiger_account.accountid
+                                left join vtiger_crmentity as vtiger_crmentityInvoice on vtiger_crmentityInvoice.crmid=vtiger_invoice.invoiceid
+                                left join vtiger_invoicebillads on vtiger_invoice.invoiceid=vtiger_invoicebillads.invoicebilladdressid
+                                left join vtiger_invoiceshipads on vtiger_invoice.invoiceid=vtiger_invoiceshipads.invoiceshipaddressid
+                                left join vtiger_users as vtiger_usersInvoice on vtiger_usersInvoice.id = vtiger_crmentityInvoice.smownerid
+                                left join vtiger_account as vtiger_accountInvoice on vtiger_accountInvoice.accountid = vtiger_invoice.accountid ";
 			}
 			if($secmodule == "Products")
 			{
-				$query = "left join seproductsrel on seproductsrel.crmid = account.accountid
-				left join products on products.productid = seproductsrel.productid
-                                left join crmentity as crmentityProducts on crmentityProducts.crmid=products.productid
-                                left join productcf on products.productid = productcf.productid
-                                left join users as usersProducts on usersProducts.id = crmentityProducts.smownerid
-                                left join contactdetails as contactdetailsProducts on contactdetailsProducts.contactid = products.contactid
-                                left join vendor as vendorRel on vendorRel.vendorid = products.vendor_id
-                                left join crmentity as crmentityRel on crmentityRel.crmid = seproductsrel.crmid
-                                left join account as accountRel on accountRel.accountid=crmentityRel.crmid
-                                left join leaddetails as leaddetailsRel on leaddetailsRel.leadid = crmentityRel.crmid
-                                left join potential as potentialRel on potentialRel.potentialid = crmentityRel.crmid ";
+				$query = "left join vtiger_seproductsrel on vtiger_seproductsrel.crmid = vtiger_account.accountid
+				left join vtiger_products on vtiger_products.productid = vtiger_seproductsrel.productid
+                                left join vtiger_crmentity as vtiger_crmentityProducts on vtiger_crmentityProducts.crmid=vtiger_products.productid
+                                left join vtiger_productcf on vtiger_products.productid = vtiger_productcf.productid
+                                left join vtiger_users as vtiger_usersProducts on vtiger_usersProducts.id = vtiger_crmentityProducts.smownerid
+                                left join vtiger_contactdetails as vtiger_contactdetailsProducts on vtiger_contactdetailsProducts.contactid = vtiger_products.contactid
+                                left join vtiger_vendor as vtiger_vendorRel on vtiger_vendorRel.vendorid = vtiger_products.vendor_id
+                                left join vtiger_crmentity as vtiger_crmentityRel on vtiger_crmentityRel.crmid = vtiger_seproductsrel.crmid
+                                left join vtiger_account as vtiger_accountRel on vtiger_accountRel.accountid=crmentityRel.crmid
+                                left join vtiger_leaddetails as vtiger_leaddetailsRel on vtiger_leaddetailsRel.leadid = vtiger_crmentityRel.crmid
+                                left join vtiger_potential as vtiger_potentialRel on vtiger_potentialRel.potentialid = vtiger_crmentityRel.crmid ";
 			}
 		}
 		if($module == "Quotes")
 		{
 			if($secmodule == "Accounts")
                         {
-                                $query = "left join account on account.accountid = quotes.accountid
-                                left join crmentity as crmentityAccounts on crmentityAccounts.crmid=account.accountid
-                                left join accountbillads on account.accountid=accountbillads.accountaddressid
-                                left join accountshipads on account.accountid=accountshipads.accountaddressid
-                                left join accountscf on account.accountid = accountscf.accountid
-                                left join account as accountAccounts on accountAccounts.accountid = account.parentid
-                                left join users as usersAccounts on usersAccounts.id = crmentityAccounts.smownerid ";
+                                $query = "left join vtiger_account on vtiger_account.accountid = vtiger_quotes.accountid
+                                left join vtiger_crmentity as vtiger_crmentityAccounts on vtiger_crmentityAccounts.crmid=vtiger_account.accountid
+                                left join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid
+                                left join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid
+                                left join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid
+                                left join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid
+                                left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentityAccounts.smownerid ";
                         }
 			if($secmodule == "Potentials")
                         {
-                                $query = "left join potential on potential.potentialid = quotes.potentialid
-                                left join crmentity as crmentityPotentials on crmentityPotentials.crmid=potential.potentialid 
-				left join potentialscf on potentialscf.potentialid = potential.potentialid
-                                left join users as usersPotentials on usersPotentials.id = crmentityPotentials.smownerid ";
+                                $query = "left join vtiger_potential on vtiger_potential.potentialid = vtiger_quotes.potentialid
+                                left join vtiger_crmentity as vtiger_crmentityPotentials on vtiger_crmentityPotentials.crmid=vtiger_potential.potentialid 
+				left join vtiger_potentialscf on vtiger_potentialscf.potentialid = vtiger_potential.potentialid
+                                left join vtiger_users as vtiger_usersPotentials on vtiger_usersPotentials.id = vtiger_crmentityPotentials.smownerid ";
 
                         }
 			if($secmodule == "Contacts")
                         {
-                                $query = "left join contactdetails on contactdetails.contactid = quotes.contactid
-                                left join crmentity as crmentityContacts on crmentityContacts.crmid = contactdetails.contactid
-                                left join contactaddress on contactdetails.contactid = contactaddress.contactaddressid
-                                left join contactsubdetails on contactdetails.contactid = contactsubdetails.contactsubscriptionid
-                                left join contactdetails as contactdetailsContacts on contactdetailsContacts.contactid = contactdetails.reportsto
-                                left join account as accountContacts on accountContacts.accountid = contactdetails.accountid
-
-                                left join contactscf on contactdetails.contactid = contactscf.contactid
-                                left join users as usersContacts on usersContacts.id = crmentityContacts.smownerid ";
+                                $query = "left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_quotes.contactid
+                                left join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid
+                                left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid
+                                left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid
+                                left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
+                                left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid
+
+                                left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid
+                                left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid ";
                         }
 
 		}
@@ -800,62 +800,62 @@
 		{
 			if($secmodule == "Accounts")
                         {
-                                $query = "left join account on account.accountid = purchaseorder.accountid
-                                left join crmentity as crmentityAccounts on crmentityAccounts.crmid=account.accountid
-                                left join accountbillads on account.accountid=accountbillads.accountaddressid
-                                left join accountshipads on account.accountid=accountshipads.accountaddressid
-                                left join accountscf on account.accountid = accountscf.accountid
-                                left join account as accountAccounts on accountAccounts.accountid = account.parentid
-                                left join users as usersAccounts on usersAccounts.id = crmentityAccounts.smownerid ";
+                                $query = "left join vtiger_account on vtiger_account.accountid = vtiger_purchaseorder.accountid
+                                left join vtiger_crmentity as vtiger_crmentityAccounts on vtiger_crmentityAccounts.crmid=vtiger_account.accountid
+                                left join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid
+                                left join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid
+                                left join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid
+                                left join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid
+                                left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentityAccounts.smownerid ";
                         }
 			if($secmodule == "Contacts")
 			{
-				$query = "left join contactdetails on contactdetails.contactid = purchaseorder.contactid
-                                left join crmentity as crmentityContacts on crmentityContacts.crmid = contactdetails.contactid
-                                left join contactaddress on contactdetails.contactid = contactaddress.contactaddressid
-                                left join contactsubdetails on contactdetails.contactid = contactsubdetails.contactsubscriptionid
-                                left join contactdetails as contactdetailsContacts on contactdetailsContacts.contactid = contactdetails.reportsto
-                                left join account as accountContacts on accountContacts.accountid = contactdetails.accountid
-
-                                left join contactscf on contactdetails.contactid = contactscf.contactid
-                                left join users as usersContacts on usersContacts.id = crmentityContacts.smownerid ";
+				$query = "left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_purchaseorder.contactid
+                                left join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid
+                                left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid
+                                left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid
+                                left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
+                                left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid
+
+                                left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid
+                                left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid ";
 			}
 		}
 		if($module == "Invoice")
 		{
 			if($secmodule == "Accounts")
 			{
-				$query = "left join account on account.accountid = invoice.accountid
-                                left join crmentity as crmentityAccounts on crmentityAccounts.crmid=account.accountid
-                                left join accountbillads on account.accountid=accountbillads.accountaddressid
-                                left join accountshipads on account.accountid=accountshipads.accountaddressid
-                                left join accountscf on account.accountid = accountscf.accountid
-                                left join account as accountAccounts on accountAccounts.accountid = account.parentid
-                                left join users as usersAccounts on usersAccounts.id = crmentityAccounts.smownerid ";
+				$query = "left join vtiger_account on vtiger_account.accountid = vtiger_invoice.accountid
+                                left join vtiger_crmentity as vtiger_crmentityAccounts on vtiger_crmentityAccounts.crmid=vtiger_account.accountid
+                                left join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid
+                                left join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid
+                                left join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid
+                                left join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid
+                                left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentityAccounts.smownerid ";
 			}
 		}
 		if($module == "Products")
 		{
 			if($secmodule == "Accounts")
                         {
-                                $query = "left join account on account.accountid = crmentityRel.crmid
-                                left join crmentity as crmentityAccounts on crmentityAccounts.crmid=account.accountid
-                                left join accountbillads on account.accountid=accountbillads.accountaddressid
-                                left join accountshipads on account.accountid=accountshipads.accountaddressid
-                                left join accountscf on account.accountid = accountscf.accountid
-                                left join account as accountAccounts on accountAccounts.accountid = account.parentid
-                                left join users as usersAccounts on usersAccounts.id = crmentityAccounts.smownerid ";
+                                $query = "left join vtiger_account on vtiger_account.accountid = vtiger_crmentityRel.crmid
+                                left join vtiger_crmentity as vtiger_crmentityAccounts on vtiger_crmentityAccounts.crmid=vtiger_account.accountid
+                                left join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid
+                                left join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid
+                                left join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid
+                                left join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid
+                                left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentityAccounts.smownerid ";
                         }
 			if($secmodule == "Contacts")
                         {
-                                $query = "left join contactdetails on contactdetails.contactid = products.contactid
-                                left join crmentity as crmentityContacts on crmentityContacts.crmid = contactdetails.contactid
-                                left join contactaddress on contactdetails.contactid = contactaddress.contactaddressid
-                                left join contactsubdetails on contactdetails.contactid = contactsubdetails.contactsubscriptionid
-                                left join contactdetails as contactdetailsContacts on contactdetailsContacts.contactid = contactdetails.reportsto
-                                left join account as accountContacts on accountContacts.accountid = contactdetails.accountid
-                                left join contactscf on contactdetails.contactid = contactscf.contactid
-                                left join users as usersContacts on usersContacts.id = crmentityContacts.smownerid ";
+                                $query = "left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_products.contactid
+                                left join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid
+                                left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid
+                                left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid
+                                left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
+                                left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid
+                                left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid
+                                left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid ";
 
                         }
 
@@ -864,68 +864,68 @@
 		{
 			if($secmodule == "Accounts")
                         {
-                                $query = "left join account on account.accountid = potential.accountid
-                                left join crmentity as crmentityAccounts on crmentityAccounts.crmid=account.accountid
-                                left join accountbillads on account.accountid=accountbillads.accountaddressid
-                                left join accountshipads on account.accountid=accountshipads.accountaddressid
-                                left join accountscf on account.accountid = accountscf.accountid
-                                left join account as accountAccounts on accountAccounts.accountid = account.parentid
-                                left join users as usersAccounts on usersAccounts.id = crmentityAccounts.smownerid ";
+                                $query = "left join vtiger_account on vtiger_account.accountid = vtiger_potential.accountid
+                                left join vtiger_crmentity as vtiger_crmentityAccounts on vtiger_crmentityAccounts.crmid=vtiger_account.accountid
+                                left join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid
+                                left join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid
+                                left join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid
+                                left join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid
+                                left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentityAccounts.smownerid ";
                         }
 			if($secmodule == "Contacts")
 			{
-				$query = "left join contactdetails on contactdetails.accountid = potential.accountid
-				left join crmentity as crmentityContacts on crmentityContacts.crmid = contactdetails.contactid
-				left join contactaddress on contactdetails.contactid = contactaddress.contactaddressid
-				left join contactsubdetails on contactdetails.contactid = contactsubdetails.contactsubscriptionid
-				left join contactdetails as contactdetailsContacts on contactdetailsContacts.contactid = contactdetails.reportsto
-				left join account as accountContacts on accountContacts.accountid = contactdetails.accountid
-				left join contactscf on contactdetails.contactid = contactscf.contactid
-				left join users as usersContacts on usersContacts.id = crmentityContacts.smownerid ";
+				$query = "left join vtiger_contactdetails on vtiger_contactdetails.accountid = vtiger_potential.accountid
+				left join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid
+				left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid
+				left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid
+				left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
+				left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid
+				left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid
+				left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid ";
 
 			}
 			if($secmodule == "Quotes")
 			{
-				$query = "left join quotes on quotes.potentialid = potential.potentialid
-                                left join crmentity as crmentityQuotes on crmentityQuotes.crmid=quotes.quoteid
-                                left join quotesbillads on quotes.quoteid=quotesbillads.quotebilladdressid
-                                left join quotesshipads on quotes.quoteid=quotesshipads.quoteshipaddressid
-                                left join users as usersQuotes on usersQuotes.id = crmentityQuotes.smownerid
-                                left join users as usersRel1 on usersRel1.id = quotes.inventorymanager
-                                left join potential as potentialRel on potentialRel.potentialid = quotes.potentialid
-                                left join contactdetails as contactdetailsQuotes on contactdetailsQuotes.contactid = quotes.contactid
-                                left join account as accountQuotes on accountQuotes.accountid = quotes.accountid ";
+				$query = "left join vtiger_quotes on vtiger_quotes.potentialid = vtiger_potential.potentialid
+                                left join vtiger_crmentity as vtiger_crmentityQuotes on vtiger_crmentityQuotes.crmid=vtiger_quotes.quoteid
+                                left join vtiger_quotesbillads on vtiger_quotes.quoteid=vtiger_quotesbillads.quotebilladdressid
+                                left join vtiger_quotesshipads on vtiger_quotes.quoteid=vtiger_quotesshipads.quoteshipaddressid
+                                left join vtiger_users as vtiger_usersQuotes on vtiger_usersQuotes.id = vtiger_crmentityQuotes.smownerid
+                                left join vtiger_users as vtiger_usersRel1 on vtiger_usersRel1.id = vtiger_quotes.inventorymanager
+                                left join vtiger_potential as vtiger_potentialRel on vtiger_potentialRel.potentialid = vtiger_quotes.potentialid
+                                left join vtiger_contactdetails as vtiger_contactdetailsQuotes on vtiger_contactdetailsQuotes.contactid = vtiger_quotes.contactid
+                                left join vtiger_account as vtiger_accountQuotes on vtiger_accountQuotes.accountid = vtiger_quotes.accountid ";
 			}
 		}
 		if($module == "HelpDesk")
 		{
 			if($secmodule == "Products")
 			{
-				$query = "left join products on products.productid = troubletickets.product_id
-                                left join crmentity as crmentityProducts on crmentityProducts.crmid=products.productid
-                                left join productcf on products.productid = productcf.productid
-                                left join users as usersProducts on usersProducts.id = crmentityProducts.smownerid
-																left join contactdetails as contactdetailsProducts on contactdetailsProducts.contactid = products.contactid 
-                                left join vendor as vendorRel on vendorRel.vendorid = products.vendor_id
-                                left join seproductsrel on seproductsrel.productid = products.productid
-                                left join crmentity as crmentityRelProducts on crmentityRelProducts.crmid = seproductsrel.crmid
-                                left join account as accountRelProducts on accountRelProducts.accountid=seproductsrel.crmid
-                                left join leaddetails as leaddetailsRelProducts on leaddetailsRelProducts.leadid = seproductsrel.crmid
-                                left join potential as potentialRelProducts on potentialRelProducts.potentialid = seproductsrel.crmid ";
+				$query = "left join vtiger_products on vtiger_products.productid = vtiger_troubletickets.product_id
+                                left join vtiger_crmentity as vtiger_crmentityProducts on vtiger_crmentityProducts.crmid=vtiger_products.productid
+                                left join vtiger_productcf on vtiger_products.productid = vtiger_productcf.productid
+                                left join vtiger_users as vtiger_usersProducts on vtiger_usersProducts.id = vtiger_crmentityProducts.smownerid
+																left join vtiger_contactdetails as vtiger_contactdetailsProducts on vtiger_contactdetailsProducts.contactid = vtiger_products.contactid 
+                                left join vtiger_vendor as vtiger_vendorRel on vtiger_vendorRel.vendorid = vtiger_products.vendor_id
+                                left join vtiger_seproductsrel on vtiger_seproductsrel.productid = vtiger_products.productid
+                                left join vtiger_crmentity as vtiger_crmentityRelProducts on vtiger_crmentityRelProducts.crmid = vtiger_seproductsrel.crmid
+                                left join vtiger_account as vtiger_accountRelProducts on vtiger_accountRelProducts.accountid=vtiger_seproductsrel.crmid
+                                left join vtiger_leaddetails as vtiger_leaddetailsRelProducts on vtiger_leaddetailsRelProducts.leadid = vtiger_seproductsrel.crmid
+                                left join vtiger_potential as vtiger_potentialRelProducts on vtiger_potentialRelProducts.potentialid = vtiger_seproductsrel.crmid ";
 			}
 		}
 		if($module == "Activities")
 		{
 			if($secmodule == "Contacts")
 			{
-                                $query = "left join contactdetails on contactdetails.contactid = cntactivityrel.contactid 
-                                left join crmentity as crmentityContacts on crmentityContacts.crmid = contactdetails.contactid
-                                left join contactaddress on contactdetails.contactid = contactaddress.contactaddressid
-                                left join contactsubdetails on contactdetails.contactid = contactsubdetails.contactsubscriptionid
-                                left join contactdetails as contactdetailsContacts on contactdetailsContacts.contactid = contactdetails.reportsto
-                                left join account as accountContacts on accountContacts.accountid = contactdetails.accountid
-                                left join contactscf on contactdetails.contactid = contactscf.contactid
-                                left join users as usersContacts on usersContacts.id = crmentityContacts.smownerid ";
+                                $query = "left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid 
+                                left join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid
+                                left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid
+                                left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid
+                                left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
+                                left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid
+                                left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid
+                                left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid ";
 			}
 		}
 		$log->info("ReportRun :: Successfully returned getRelatedModulesQuery".$secmodule);
@@ -936,143 +936,143 @@
 		global $log;
 		if($module == "Leads")
 		{
-			$query = "from leaddetails 
-				inner join crmentity as crmentityLeads on crmentityLeads.crmid=leaddetails.leadid 
-				inner join leadsubdetails on leadsubdetails.leadsubscriptionid=leaddetails.leadid 
-				inner join leadaddress on leadaddress.leadaddressid=leadsubdetails.leadsubscriptionid 
-				inner join leadscf on leaddetails.leadid = leadscf.leadid 
-				left join users as usersLeads on usersLeads.id = crmentityLeads.smownerid
-				where crmentityLeads.deleted=0 and leaddetails.converted=0";
+			$query = "from vtiger_leaddetails 
+				inner join vtiger_crmentity as vtiger_crmentityLeads on vtiger_crmentityLeads.crmid=vtiger_leaddetails.leadid 
+				inner join vtiger_leadsubdetails on vtiger_leadsubdetails.leadsubscriptionid=vtiger_leaddetails.leadid 
+				inner join vtiger_leadaddress on vtiger_leadaddress.leadaddressid=vtiger_leadsubdetails.leadsubscriptionid 
+				inner join vtiger_leadscf on vtiger_leaddetails.leadid = vtiger_leadscf.leadid 
+				left join vtiger_users as vtiger_usersLeads on vtiger_usersLeads.id = vtiger_crmentityLeads.smownerid
+				where vtiger_crmentityLeads.deleted=0 and vtiger_leaddetails.converted=0";
 		}
 
 		if($module == "Accounts")
                 {
-			$query = "from account 
-				inner join crmentity as crmentityAccounts on crmentityAccounts.crmid=account.accountid 
-				inner join accountbillads on account.accountid=accountbillads.accountaddressid 
-				inner join accountshipads on account.accountid=accountshipads.accountaddressid 
-				inner join accountscf on account.accountid = accountscf.accountid 
-				left join account as accountAccounts on accountAccounts.accountid = account.parentid
-				left join users as usersAccounts on usersAccounts.id = crmentityAccounts.smownerid
+			$query = "from vtiger_account 
+				inner join vtiger_crmentity as vtiger_crmentityAccounts on vtiger_crmentityAccounts.crmid=vtiger_account.accountid 
+				inner join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid 
+				inner join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid 
+				inner join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid 
+				left join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid
+				left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentityAccounts.smownerid
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where crmentityAccounts.deleted=0 ";
+				where vtiger_crmentityAccounts.deleted=0 ";
 		}
 
 		if($module == "Contacts")
                 {
-			$query = "from contactdetails
-				inner join crmentity as crmentityContacts on crmentityContacts.crmid = contactdetails.contactid 
-				inner join contactaddress on contactdetails.contactid = contactaddress.contactaddressid 
-				inner join customerdetails on customerdetails.customerid = contactdetails.contactid
-				inner join contactsubdetails on contactdetails.contactid = contactsubdetails.contactsubscriptionid 
-				inner join contactscf on contactdetails.contactid = contactscf.contactid 
-				left join contactdetails as contactdetailsContacts on contactdetailsContacts.contactid = contactdetails.reportsto
-				left join account as accountContacts on accountContacts.accountid = contactdetails.accountid 
-				left join users as usersContacts on usersContacts.id = crmentityContacts.smownerid
+			$query = "from vtiger_contactdetails
+				inner join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid 
+				inner join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid 
+				inner join vtiger_customerdetails on vtiger_customerdetails.customerid = vtiger_contactdetails.contactid
+				inner join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid 
+				inner join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid 
+				left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
+				left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid 
+				left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)." 
-				where crmentityContacts.deleted=0";
+				where vtiger_crmentityContacts.deleted=0";
 		}
 
 		if($module == "Potentials")
 		{
-			$query = "from potential 
-				inner join crmentity as crmentityPotentials on crmentityPotentials.crmid=potential.potentialid 
-				inner join account as accountPotentials on potential.accountid = accountPotentials.accountid 
-				inner join potentialscf on potentialscf.potentialid = potential.potentialid
-				left join users as usersPotentials on usersPotentials.id = crmentityPotentials.smownerid  
+			$query = "from vtiger_potential 
+				inner join vtiger_crmentity as vtiger_crmentityPotentials on vtiger_crmentityPotentials.crmid=vtiger_potential.potentialid 
+				inner join vtiger_account as vtiger_accountPotentials on vtiger_potential.accountid = vtiger_accountPotentials.accountid 
+				inner join vtiger_potentialscf on vtiger_potentialscf.potentialid = vtiger_potential.potentialid
+				left join vtiger_users as vtiger_usersPotentials on vtiger_usersPotentials.id = vtiger_crmentityPotentials.smownerid  
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where crmentityPotentials.deleted=0 ";
+				where vtiger_crmentityPotentials.deleted=0 ";
 		}
 		
 		if($module == "Products")
 		{
-			$query = "from products 
-				inner join crmentity as crmentityProducts on crmentityProducts.crmid=products.productid 
-				left join productcf on products.productid = productcf.productid 
-				left join users as usersProducts on usersProducts.id = crmentityProducts.smownerid 
-				left join contactdetails as contactdetailsProducts on contactdetailsProducts.contactid = products.contactid
-				left join vendor as vendorRel on vendorRel.vendorid = products.vendor_id  
-				left join seproductsrel on seproductsrel.productid = products.productid 
-				left join crmentity as crmentityRelProducts on crmentityRelProducts.crmid = seproductsrel.crmid 
-				left join account as accountRelProducts on accountRelProducts.accountid=crmentityRelProducts.crmid 
-				left join leaddetails as leaddetailsRelProducts on leaddetailsRelProducts.leadid = crmentityRelProducts.crmid 
-				left join potential as potentialRelProducts on potentialRelProducts.potentialid = crmentityRelProducts.crmid 
+			$query = "from vtiger_products 
+				inner join vtiger_crmentity as vtiger_crmentityProducts on vtiger_crmentityProducts.crmid=vtiger_products.productid 
+				left join vtiger_productcf on vtiger_products.productid = vtiger_productcf.productid 
+				left join vtiger_users as vtiger_usersProducts on vtiger_usersProducts.id = vtiger_crmentityProducts.smownerid 
+				left join vtiger_contactdetails as vtiger_contactdetailsProducts on vtiger_contactdetailsProducts.contactid = vtiger_products.contactid
+				left join vtiger_vendor as vtiger_vendorRel on vtiger_vendorRel.vendorid = vtiger_products.vendor_id  
+				left join vtiger_seproductsrel on vtiger_seproductsrel.productid = vtiger_products.productid 
+				left join vtiger_crmentity as vtiger_crmentityRelProducts on vtiger_crmentityRelProducts.crmid = vtiger_seproductsrel.crmid 
+				left join vtiger_account as vtiger_accountRelProducts on vtiger_accountRelProducts.accountid=crmentityRelProducts.crmid 
+				left join vtiger_leaddetails as vtiger_leaddetailsRelProducts on vtiger_leaddetailsRelProducts.leadid = vtiger_crmentityRelProducts.crmid 
+				left join vtiger_potential as vtiger_potentialRelProducts on vtiger_potentialRelProducts.potentialid = vtiger_crmentityRelProducts.crmid 
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where crmentityProducts.deleted=0 ";
+				where vtiger_crmentityProducts.deleted=0 ";
 		}
 
 		if($module == "HelpDesk")
 		{
-			$query = "from troubletickets 
-				inner join crmentity as crmentityHelpDesk 
-				on crmentityHelpDesk.crmid=troubletickets.ticketid 
-				inner join ticketcf on ticketcf.ticketid = troubletickets.ticketid
-        left join crmentity as crmentityRelHelpDesk on crmentityRelHelpDesk.crmid = troubletickets.parent_id
-				left join account as accountRelHelpDesk on accountRelHelpDesk.accountid=crmentityRelHelpDesk.crmid 
-				left join contactdetails as contactdetailsRelHelpDesk on contactdetailsRelHelpDesk.contactid= crmentityRelHelpDesk.crmid
-				left join products as productsRel on productsRel.productid = crmentityRelHelpDesk.crmid
-				left join users as usersHelpDesk on crmentityHelpDesk.smownerid=usersHelpDesk.id 
+			$query = "from vtiger_troubletickets 
+				inner join vtiger_crmentity as vtiger_crmentityHelpDesk 
+				on vtiger_crmentityHelpDesk.crmid=vtiger_troubletickets.ticketid 
+				inner join vtiger_ticketcf on vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid
+        left join vtiger_crmentity as vtiger_crmentityRelHelpDesk on vtiger_crmentityRelHelpDesk.crmid = vtiger_troubletickets.parent_id
+				left join vtiger_account as vtiger_accountRelHelpDesk on vtiger_accountRelHelpDesk.accountid=crmentityRelHelpDesk.crmid 
+				left join vtiger_contactdetails as vtiger_contactdetailsRelHelpDesk on vtiger_contactdetailsRelHelpDesk.contactid= vtiger_crmentityRelHelpDesk.crmid
+				left join vtiger_products as vtiger_productsRel on vtiger_productsRel.productid = vtiger_crmentityRelHelpDesk.crmid
+				left join vtiger_users as vtiger_usersHelpDesk on vtiger_crmentityHelpDesk.smownerid=usersHelpDesk.id 
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where crmentityHelpDesk.deleted=0 ";
+				where vtiger_crmentityHelpDesk.deleted=0 ";
 		}
 
 		if($module == "Activities")
 		{
-			$query = "from activity 
-				inner join crmentity as crmentityActivities on crmentityActivities.crmid=activity.activityid 
-				left join cntactivityrel on cntactivityrel.activityid= activity.activityid 
-				left join contactdetails as contactdetailsActivities on contactdetailsActivities.contactid= cntactivityrel.contactid
-				left join users as usersActivities on usersActivities.id = crmentityActivities.smownerid
-				left join seactivityrel on seactivityrel.activityid = activity.activityid
-				left join crmentity as crmentityRelActivities on crmentityRelActivities.crmid = seactivityrel.crmid
-				left join account as accountRelActivities on accountRelActivities.accountid=crmentityRelActivities.crmid
-				left join leaddetails as leaddetailsRelActivities on leaddetailsRelActivities.leadid = crmentityRelActivities.crmid
-				left join potential as potentialRelActivities on potentialRelActivities.potentialid = crmentityRelActivities.crmid
-				left join quotes as quotesRelActivities on quotesRelActivities.quoteid = crmentityRelActivities.crmid
-				left join purchaseorder as purchaseorderRelActivities on purchaseorderRelActivities.purchaseorderid = crmentityRelActivities.crmid
-				left join invoice as invoiceRelActivities on invoiceRelActivities.invoiceid = crmentityRelActivities.crmid
+			$query = "from vtiger_activity 
+				inner join vtiger_crmentity as vtiger_crmentityActivities on vtiger_crmentityActivities.crmid=vtiger_activity.activityid 
+				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid 
+				left join vtiger_contactdetails as vtiger_contactdetailsActivities on vtiger_contactdetailsActivities.contactid= vtiger_cntactivityrel.contactid
+				left join vtiger_users as vtiger_usersActivities on vtiger_usersActivities.id = vtiger_crmentityActivities.smownerid
+				left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid
+				left join vtiger_crmentity as vtiger_crmentityRelActivities on vtiger_crmentityRelActivities.crmid = vtiger_seactivityrel.crmid
+				left join vtiger_account as vtiger_accountRelActivities on vtiger_accountRelActivities.accountid=crmentityRelActivities.crmid
+				left join vtiger_leaddetails as vtiger_leaddetailsRelActivities on vtiger_leaddetailsRelActivities.leadid = vtiger_crmentityRelActivities.crmid
+				left join vtiger_potential as vtiger_potentialRelActivities on vtiger_potentialRelActivities.potentialid = vtiger_crmentityRelActivities.crmid
+				left join vtiger_quotes as vtiger_quotesRelActivities on vtiger_quotesRelActivities.quoteid = vtiger_crmentityRelActivities.crmid
+				left join vtiger_purchaseorder as vtiger_purchaseorderRelActivities on vtiger_purchaseorderRelActivities.purchaseorderid = vtiger_crmentityRelActivities.crmid
+				left join vtiger_invoice as vtiger_invoiceRelActivities on vtiger_invoiceRelActivities.invoiceid = vtiger_crmentityRelActivities.crmid
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				WHERE crmentityActivities.deleted=0 and (activity.activitytype = 'Meeting' or activity.activitytype='Call' or activity.activitytype='Task')";
+				WHERE vtiger_crmentityActivities.deleted=0 and (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')";
 		}
 		
 		if($module == "Quotes")
 		{
-			$query = "from quotes 
-				inner join crmentity as crmentityQuotes on crmentityQuotes.crmid=quotes.quoteid 
-				inner join quotesbillads on quotes.quoteid=quotesbillads.quotebilladdressid 
-				inner join quotesshipads on quotes.quoteid=quotesshipads.quoteshipaddressid 
-				left join users as usersQuotes on usersQuotes.id = crmentityQuotes.smownerid
-				left join users as usersRel1 on usersRel1.id = quotes.inventorymanager
-				left join potential as potentialRel on potentialRel.potentialid = quotes.potentialid
-				left join contactdetails as contactdetailsQuotes on contactdetailsQuotes.contactid = quotes.contactid
-				left join account as accountQuotes on accountQuotes.accountid = quotes.accountid
+			$query = "from vtiger_quotes 
+				inner join vtiger_crmentity as vtiger_crmentityQuotes on vtiger_crmentityQuotes.crmid=vtiger_quotes.quoteid 
+				inner join vtiger_quotesbillads on vtiger_quotes.quoteid=vtiger_quotesbillads.quotebilladdressid 
+				inner join vtiger_quotesshipads on vtiger_quotes.quoteid=vtiger_quotesshipads.quoteshipaddressid 
+				left join vtiger_users as vtiger_usersQuotes on vtiger_usersQuotes.id = vtiger_crmentityQuotes.smownerid
+				left join vtiger_users as vtiger_usersRel1 on vtiger_usersRel1.id = vtiger_quotes.inventorymanager
+				left join vtiger_potential as vtiger_potentialRel on vtiger_potentialRel.potentialid = vtiger_quotes.potentialid
+				left join vtiger_contactdetails as vtiger_contactdetailsQuotes on vtiger_contactdetailsQuotes.contactid = vtiger_quotes.contactid
+				left join vtiger_account as vtiger_accountQuotes on vtiger_accountQuotes.accountid = vtiger_quotes.accountid
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where crmentityQuotes.deleted=0";
+				where vtiger_crmentityQuotes.deleted=0";
 		}
 		
 		if($module == "PurchaseOrder")
 		{
-			$query = "from purchaseorder 
-				inner join crmentity as crmentityPurchaseOrder on crmentityPurchaseOrder.crmid=purchaseorder.purchaseorderid 
-				inner join pobillads on purchaseorder.purchaseorderid=pobillads.pobilladdressid 
-				inner join poshipads on purchaseorder.purchaseorderid=poshipads.poshipaddressid 
-				left join users as usersPurchaseOrder on usersPurchaseOrder.id = crmentityPurchaseOrder.smownerid 
-				left join vendor as vendorRel on vendorRel.vendorid = purchaseorder.vendorid 
-				left join contactdetails as contactdetailsPurchaseOrder on contactdetailsPurchaseOrder.contactid = purchaseorder.contactid 
+			$query = "from vtiger_purchaseorder 
+				inner join vtiger_crmentity as vtiger_crmentityPurchaseOrder on vtiger_crmentityPurchaseOrder.crmid=vtiger_purchaseorder.purchaseorderid 
+				inner join vtiger_pobillads on vtiger_purchaseorder.purchaseorderid=vtiger_pobillads.pobilladdressid 
+				inner join vtiger_poshipads on vtiger_purchaseorder.purchaseorderid=vtiger_poshipads.poshipaddressid 
+				left join vtiger_users as vtiger_usersPurchaseOrder on vtiger_usersPurchaseOrder.id = vtiger_crmentityPurchaseOrder.smownerid 
+				left join vtiger_vendor as vtiger_vendorRel on vtiger_vendorRel.vendorid = vtiger_purchaseorder.vendorid 
+				left join vtiger_contactdetails as vtiger_contactdetailsPurchaseOrder on vtiger_contactdetailsPurchaseOrder.contactid = vtiger_purchaseorder.contactid 
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where crmentityPurchaseOrder.deleted=0";
+				where vtiger_crmentityPurchaseOrder.deleted=0";
 		}
 
 		if($module == "Invoice")
 		{
-			$query = "from invoice 
-				inner join crmentity as crmentityInvoice on crmentityInvoice.crmid=invoice.invoiceid 
-				inner join invoicebillads on invoice.invoiceid=invoicebillads.invoicebilladdressid 
-				inner join invoiceshipads on invoice.invoiceid=invoiceshipads.invoiceshipaddressid 
-				left join users as usersInvoice on usersInvoice.id = crmentityInvoice.smownerid
-				left join account as accountInvoice on accountInvoice.accountid = invoice.accountid
+			$query = "from vtiger_invoice 
+				inner join vtiger_crmentity as vtiger_crmentityInvoice on vtiger_crmentityInvoice.crmid=vtiger_invoice.invoiceid 
+				inner join vtiger_invoicebillads on vtiger_invoice.invoiceid=vtiger_invoicebillads.invoicebilladdressid 
+				inner join vtiger_invoiceshipads on vtiger_invoice.invoiceid=vtiger_invoiceshipads.invoiceshipaddressid 
+				left join vtiger_users as vtiger_usersInvoice on vtiger_usersInvoice.id = vtiger_crmentityInvoice.smownerid
+				left join vtiger_account as vtiger_accountInvoice on vtiger_accountInvoice.accountid = vtiger_invoice.accountid
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where crmentityInvoice.deleted=0";
+				where vtiger_crmentityInvoice.deleted=0";
 		}
 		$log->info("ReportRun :: Successfully returned getReportsQuery".$module);
 		return $query;
@@ -1407,9 +1407,9 @@
 		global $modules;
 		global $log;
 
-		$coltotalsql = "select reportsummary.* from report";
-        $coltotalsql .= " inner join reportsummary on report.reportid = reportsummary.reportsummaryid";
-        $coltotalsql .= " where report.reportid =".$reportid;
+		$coltotalsql = "select vtiger_reportsummary.* from vtiger_report";
+        $coltotalsql .= " inner join vtiger_reportsummary on vtiger_report.reportid = vtiger_reportsummary.reportsummaryid";
+        $coltotalsql .= " where vtiger_report.reportid =".$reportid;
 
         $result = $adb->query($coltotalsql);
 		
@@ -1449,9 +1449,9 @@
 		global $modules;
 		global $log;
 
-		$sreportstdfiltersql = "select reportsummary.* from report"; 
-		$sreportstdfiltersql .= " inner join reportsummary on report.reportid = reportsummary.reportsummaryid"; 
-		$sreportstdfiltersql .= " where report.reportid =".$reportid;
+		$sreportstdfiltersql = "select vtiger_reportsummary.* from vtiger_report"; 
+		$sreportstdfiltersql .= " inner join vtiger_reportsummary on vtiger_report.reportid = vtiger_reportsummary.reportsummaryid"; 
+		$sreportstdfiltersql .= " where vtiger_report.reportid =".$reportid;
 		
 		$result = $adb->query($sreportstdfiltersql);
 		$noofrows = $adb->num_rows($result);

Modified: vtigercrm/trunk/modules/Reports/Reports.php
==============================================================================
--- vtigercrm/trunk/modules/Reports/Reports.php (original)
+++ vtigercrm/trunk/modules/Reports/Reports.php Mon Jun 12 14:26:25 2006
@@ -63,7 +63,7 @@
 
 /**
  * This class has the informations for Reports and inherits class CRMEntity and
- * has the variables required to generate,save,restore reports
+ * has the variables required to generate,save,restore vtiger_reports
  * and also the required functions for the same
  * Contributor(s): ______________________________________..
  */
@@ -119,9 +119,9 @@
 				 "Invoice"=>Array("Information"=>69,"Address"=>71,"Description"=>74,"Custom Information"=>5)
 				);
 
-/** Function to set primodule,secmodule,reporttype,reportname,reportdescription,folderid for given reportid
- *  This function accepts the reportid as argument
- *  It sets primodule,secmodule,reporttype,reportname,reportdescription,folderid for the given reportid
+/** Function to set primodule,secmodule,reporttype,reportname,reportdescription,folderid for given vtiger_reportid
+ *  This function accepts the vtiger_reportid as argument
+ *  It sets primodule,secmodule,reporttype,reportname,reportdescription,folderid for the given vtiger_reportid
  */
 			
 	function Reports($reportid="")
@@ -130,8 +130,8 @@
 
 		if($reportid != "")
 		{
-			$ssql = "select reportmodules.*,report.* from report inner join reportmodules on report.reportid = reportmodules.reportmodulesid";
-			$ssql .= " where report.reportid =".$reportid;
+			$ssql = "select vtiger_reportmodules.*,vtiger_report.* from vtiger_report inner join vtiger_reportmodules on vtiger_report.reportid = vtiger_reportmodules.reportmodulesid";
+			$ssql .= " where vtiger_report.reportid =".$reportid;
 			$result = $adb->query($ssql);
 		        $reportmodulesrow = $adb->fetch_array($result);
 			if($reportmodulesrow)
@@ -159,7 +159,7 @@
 		global $adb;
 		global $log;
 		$returndata = Array();
-		$sql = "select * from reportfolder order by folderid";
+		$sql = "select * from vtiger_reportfolder order by folderid";
 		$result = $adb->query($sql);
 		$reportfldrow = $adb->fetch_array($result);
 		if($mode != '')
@@ -190,7 +190,7 @@
 			}while($reportfldrow = $adb->fetch_array($result));
 		}
 
-		$log->info("Reports :: ListView->Successfully returned report folder HTML");
+		$log->info("Reports :: ListView->Successfully returned vtiger_report folder HTML");
 		return $returndata;
 	}
 
@@ -210,8 +210,8 @@
 		
 		require_once('include/utils/UserInfoUtil.php');
 		
-		$sql = "select report.*, reportmodules.* from report inner join reportfolder on reportfolder.folderid = report.folderid";
-		$sql .= " inner join reportmodules on reportmodules.reportmodulesid = report.reportid where reportfolder.folderid=".$rpt_fldr_id;
+		$sql = "select vtiger_report.*, vtiger_reportmodules.* from vtiger_report inner join vtiger_reportfolder on vtiger_reportfolder.folderid = vtiger_report.folderid";
+		$sql .= " inner join vtiger_reportmodules on vtiger_reportmodules.reportmodulesid = vtiger_report.reportid where vtiger_reportfolder.folderid=".$rpt_fldr_id;
 		$result = $adb->query($sql);
 		$report = $adb->fetch_array($result);
 		if(count($report)>0)
@@ -231,7 +231,7 @@
 					  }while($report = $adb->fetch_array($result));
 		}
 	
-		$log->info("Reports :: ListView->Successfully returned report details HTML");
+		$log->info("Reports :: ListView->Successfully returned vtiger_report details HTML");
 		return $returndata;
 	}
 
@@ -249,9 +249,9 @@
 		return $srptfldr_js;
 	}
 
-/** Function to set the Primary module fields for the given Report 
+/** Function to set the Primary module vtiger_fields for the given Report 
  *  This function sets the primary module columns for the given Report 
- *  It accepts the Primary module as the argument and set the fields of the module
+ *  It accepts the Primary module as the argument and set the vtiger_fields of the module
  *  to the varialbe pri_module_columnslist and returns true if sucess
  */
 
@@ -267,7 +267,7 @@
 
 /** Function to set the Secondary module fileds for the given Report
  *  This function sets the secondary module columns for the given module
- *  It accepts the module as the argument and set the fields of the module
+ *  It accepts the module as the argument and set the vtiger_fields of the module
  *  to the varialbe sec_module_columnslist and returns true if sucess
  */
 	
@@ -288,11 +288,11 @@
             return true;
         }
 
-/** Function to get fields for the given module and block
- *  This function gets the fields for the given module
+/** Function to get vtiger_fields for the given module and block
+ *  This function gets the vtiger_fields for the given module
  *  It accepts the module and the block as arguments and 
  *  returns the array column lists
- *  Array module_columnlist[ fieldtablename:fieldcolname:module_fieldlabel1:fieldname:fieldtypeofdata]=fieldlabel
+ *  Array module_columnlist[ vtiger_fieldtablename:fieldcolname:module_fieldlabel1:fieldname:fieldtypeofdata]=fieldlabel
  */
 
 	function getColumnsListbyBlock($module,$block)
@@ -308,12 +308,12 @@
 	//Security Check 
 	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0)
 	{
-		$sql = "select * from field where field.uitype != 50 and field.tabid=".$tabid." and field.block in (".$block .") and field.displaytype in (1,2) order by sequence";
+		$sql = "select * from vtiger_field where vtiger_field.uitype != 50 and vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$block .") and vtiger_field.displaytype in (1,2) order by sequence";
 	}
 	else
 	{
 			
-        	$sql = "select * from field inner join profile2field on profile2field.fieldid=field.fieldid inner join def_org_field on def_org_field.fieldid=field.fieldid where field.uitype != 50 and field.tabid=".$tabid." and field.block in (".$block .") and field.displaytype in (1,2) and profile2field.visible=0 and def_org_field.visible=0 and profile2field.profileid in ".$profileList." group by field.fieldid order by sequence";
+        	$sql = "select * from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.uitype != 50 and vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$block .") and vtiger_field.displaytype in (1,2) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList." group by vtiger_field.fieldid order by sequence";
 	}
         $result = $adb->query($sql);
         $noofrows = $adb->num_rows($result);
@@ -375,8 +375,8 @@
 		return $module_columnlist;
 	}
 	
-/** Function to set the standard filter fields for the given report
- *  This function gets the standard filter fields for the given report
+/** Function to set the standard filter vtiger_fields for the given vtiger_report
+ *  This function gets the standard filter vtiger_fields for the given vtiger_report
  *  and set the values to the corresponding variables
  *  It accepts the repordid as argument 
  */
@@ -384,7 +384,7 @@
 	function getSelectedStandardCriteria($reportid)
 	{
 		global $adb;
-		$sSQL = "select reportdatefilter.* from reportdatefilter inner join report on report.reportid = reportdatefilter.datefilterid where report.reportid=".$reportid;
+		$sSQL = "select vtiger_reportdatefilter.* from vtiger_reportdatefilter inner join vtiger_report on vtiger_report.reportid = vtiger_reportdatefilter.datefilterid where vtiger_report.reportid=".$reportid;
 
 		$result = $adb->query($sSQL);
 		$selectedstdfilter = $adb->fetch_array($result);
@@ -406,7 +406,7 @@
 	}
 
 /** Function to get the combo values for the standard filter
- *  This function get the combo values for the standard filter for the given report
+ *  This function get the combo values for the standard filter for the given vtiger_report
  *  and return a HTML string 
  */
 
@@ -441,7 +441,7 @@
 
 /** Function to get the selected standard filter columns 
  *  This function returns the selected standard filter criteria 
- *  which is selected for reports as an array
+ *  which is selected for vtiger_reports as an array
  *  Array stdcriteria_list[fieldtablename:fieldcolname:module_fieldlabel1]=fieldlabel
  */
 
@@ -461,12 +461,12 @@
 
 		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
                 {
-			$sql = "select * from field where field.tabid=".$tabid." and (field.uitype =5 or field.displaytype=2) and field.block in (".$blockids.") order by field.sequence";
+			$sql = "select * from vtiger_field where vtiger_field.tabid=".$tabid." and (vtiger_field.uitype =5 or vtiger_field.displaytype=2) and vtiger_field.block in (".$blockids.") order by vtiger_field.sequence";
 		}
 		else
 		{
 			$profileList = getCurrentUserProfileList();			
-			$sql = "select * from field inner join tab on tab.tabid = field.tabid inner join profile2field on profile2field.fieldid=field.fieldid inner join def_org_field on def_org_field.fieldid=field.fieldid  where field.tabid=".$tabid." and (field.uitype =5 or field.displaytype=2) and profile2field.visible=0 and def_org_field.visible=0 and field.block in (".$blockids.") and profile2field.profileid in ".$profileList." order by field.sequence";
+			$sql = "select * from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid  where vtiger_field.tabid=".$tabid." and (vtiger_field.uitype =5 or vtiger_field.displaytype=2) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_field.block in (".$blockids.") and vtiger_profile2field.profileid in ".$profileList." order by vtiger_field.sequence";
 	
 		}
 		
@@ -720,7 +720,7 @@
 
 /** Function to set the order of grouping and to find the columns responsible
  *  to the grouping
- *  This function accepts the reportid as variable,sets the variable ascdescorder[] to the sort order and
+ *  This function accepts the vtiger_reportid as variable,sets the variable ascdescorder[] to the sort order and
  *  returns the array array_list which has the column responsible for the grouping
  *  Array array_list[0]=columnname
  */
@@ -732,9 +732,9 @@
 		global $adb;
 		global $log;
 
-    	$sreportsortsql = "select reportsortcol.* from report";
-		$sreportsortsql .= " inner join reportsortcol on report.reportid = reportsortcol.reportid";
-		$sreportsortsql .= " where report.reportid =".$reportid." order by reportsortcol.sortcolid";
+    	$sreportsortsql = "select vtiger_reportsortcol.* from vtiger_report";
+		$sreportsortsql .= " inner join vtiger_reportsortcol on vtiger_report.reportid = vtiger_reportsortcol.reportid";
+		$sreportsortsql .= " where vtiger_report.reportid =".$reportid." order by vtiger_reportsortcol.sortcolid";
 
 		$result = $adb->query($sreportsortsql);
 		$noofrows = $adb->num_rows($result);
@@ -751,9 +751,9 @@
 		return $array_list;
 	}
 	
-/** Function to get the selected columns list for a selected report
- *  This function accepts the reportid as the argument and get the selected columns
- *  for the given reportid and it forms a combo lists and returns
+/** Function to get the selected columns list for a selected vtiger_report
+ *  This function accepts the vtiger_reportid as the argument and get the selected columns
+ *  for the given vtiger_reportid and it forms a combo lists and returns
  *  HTML of the combo values
  */
 
@@ -764,9 +764,9 @@
 	    global $modules;
 		global $log;
 
-		$ssql = "select selectcolumn.* from report inner join selectquery on selectquery.queryid = report.queryid";
-		$ssql .= " left join selectcolumn on selectcolumn.queryid = selectquery.queryid where report.reportid =".$reportid;
-		$ssql .= " order by selectcolumn.columnindex";
+		$ssql = "select vtiger_selectcolumn.* from vtiger_report inner join vtiger_selectquery on vtiger_selectquery.queryid = vtiger_report.queryid";
+		$ssql .= " left join vtiger_selectcolumn on vtiger_selectcolumn.queryid = vtiger_selectquery.queryid where vtiger_report.reportid =".$reportid;
+		$ssql .= " order by vtiger_selectcolumn.columnindex";
 
 		$result = $adb->query($ssql);
 		$noofrows = $adb->num_rows($result);
@@ -785,8 +785,8 @@
 		return $shtml;
 	}
 
-/** Function to Set the selected columns for the advanced filter for the report
- *  This function accepts the reportid as the argument and get the selected columns
+/** Function to Set the selected columns for the advanced filter for the vtiger_report
+ *  This function accepts the vtiger_reportid as the argument and get the selected columns
  *  in the advanced filter and sets the values
  *  $this->advft_column[] = The column name
  *  $this->advft_option[] = The filter option
@@ -800,8 +800,8 @@
 		global $adb;
 		global $modules;
 		global $log;
-		$ssql = 'select relcriteria.* from report inner join relcriteria on relcriteria.queryid = report.queryid left join selectquery on relcriteria.queryid = selectquery.queryid';
-		$ssql.= " where report.reportid =".$reportid." order by relcriteria.columnindex";
+		$ssql = 'select vtiger_relcriteria.* from vtiger_report inner join vtiger_relcriteria on vtiger_relcriteria.queryid = vtiger_report.queryid left join vtiger_selectquery on vtiger_relcriteria.queryid = vtiger_selectquery.queryid';
+		$ssql.= " where vtiger_report.reportid =".$reportid." order by vtiger_relcriteria.columnindex";
 
 		$result = $adb->query($ssql);
 
@@ -817,8 +817,8 @@
 	}
 	//<<<<<<<<advanced filter>>>>>>>>>>>>>>
 	
-/** Function to get the list of report folders when Save and run  the report
- *  This function gets the report folders from database and form
+/** Function to get the list of vtiger_report folders when Save and run  the vtiger_report
+ *  This function gets the vtiger_report folders from database and form
  *  a combo values of the folders and return 
  *  HTML of the combo values
  */
@@ -828,7 +828,7 @@
 		global $adb;
 		global $log;
 
-		$sql = "select * from reportfolder order by folderid";
+		$sql = "select * from vtiger_reportfolder order by folderid";
 		$result = $adb->query($sql);
 		$reportfldrow = $adb->fetch_array($result);
 		$x = 0;
@@ -841,10 +841,10 @@
 		return $shtml;
 	}
 
-/** Function to get the column to total fields in Reports 
- *  This function gets columns to total field 
- *  and generated the html for that fields
- *  It returns the HTML of the fields along with the check boxes
+/** Function to get the column to total vtiger_fields in Reports 
+ *  This function gets columns to total vtiger_field 
+ *  and generated the html for that vtiger_fields
+ *  It returns the HTML of the vtiger_fields along with the check boxes
  */
 
 	function sgetColumntoTotal($primarymodule,$secondarymodule)
@@ -862,10 +862,10 @@
 		return $options;
 	}
 	
-/** Function to get the selected columns of total fields in Reports
- *  This function gets selected columns of total field
- *  and generated the html for that fields
- *  It returns the HTML of the fields along with the check boxes
+/** Function to get the selected columns of total vtiger_fields in Reports
+ *  This function gets selected columns of total vtiger_field
+ *  and generated the html for that vtiger_fields
+ *  It returns the HTML of the vtiger_fields along with the check boxes
  */
 	
 	
@@ -876,7 +876,7 @@
 		$options = Array();
 		if($reportid != "")
 		{
-			$ssql = "select reportsummary.* from reportsummary inner join report on report.reportid = reportsummary.reportsummaryid where report.reportid=".$reportid;
+			$ssql = "select vtiger_reportsummary.* from vtiger_reportsummary inner join vtiger_report on vtiger_report.reportid = vtiger_reportsummary.reportsummaryid where vtiger_report.reportid=".$reportid;
 			$result = $adb->query($ssql);
 			if($result)
 			{
@@ -906,14 +906,14 @@
 
 /** Function to form the HTML for columns to total	
  *  This function formulates the HTML format of the
- *  fields along with four checkboxes
- *  It returns the HTML of the fields along with the check boxes
+ *  vtiger_fields along with four checkboxes
+ *  It returns the HTML of the vtiger_fields along with the check boxes
  */
 	
 	
 	function sgetColumnstoTotalHTML($module)
 	{
-		//retreive the tabid	
+		//retreive the vtiger_tabid	
 		global $adb;
 		global $log;
 		global $current_user;
@@ -922,12 +922,12 @@
 		$escapedchars = Array('_SUM','_AVG','_MIN','_MAX');
 		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0)
 		{
-			$ssql = "select * from field inner join tab on tab.tabid = field.tabid where field.uitype != 50 and field.tabid=".$tabid." and field.displaytype = 1 order by sequence";
+			$ssql = "select * from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.uitype != 50 and vtiger_field.tabid=".$tabid." and vtiger_field.displaytype = 1 order by sequence";
 		}
 		else
 		{
 			$profileList = getCurrentUserProfileList();
-			$ssql = "select * from field inner join tab on tab.tabid = field.tabid inner join def_org_field on def_org_field.fieldid=field.fieldid inner join profile2field on profile2field.fieldid=field.fieldid  where field.uitype != 50 and field.tabid=".$tabid." and field.displaytype = 1 and def_org_field.visible=0 and profile2field.visible=0 and profile2field.profileid in ".$profileList." order by sequence";
+			$ssql = "select * from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid  where vtiger_field.uitype != 50 and vtiger_field.tabid=".$tabid." and vtiger_field.displaytype = 1 and vtiger_def_org_field.visible=0 and vtiger_profile2field.visible=0 and vtiger_profile2field.profileid in ".$profileList." order by sequence";
 		}
 		$result = $adb->query($ssql);
 		$columntototalrow = $adb->fetch_array($result);
@@ -1009,8 +1009,8 @@
 	}
 }
 
-/** Function to get the primary module list in reports
- *  This function generates the list of primary modules in reports
+/** Function to get the primary module list in vtiger_reports
+ *  This function generates the list of primary modules in vtiger_reports
  *  and returns an array of permitted modules 
  */
 
@@ -1038,8 +1038,8 @@
 	}
 	return $modules;
 }
-/** Function to get the Related module list in reports
- *  This function generates the list of secondary modules in reports
+/** Function to get the Related module list in vtiger_reports
+ *  This function generates the list of secondary modules in vtiger_reports
  *  and returns the related module as an Array 
  */
 

Modified: vtigercrm/trunk/modules/Reports/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Reports/Save.php (original)
+++ vtigercrm/trunk/modules/Reports/Save.php Mon Jun 12 14:26:25 2006
@@ -94,83 +94,83 @@
 	$genQueryId = $adb->getUniqueID("selectquery");
 	if($genQueryId != "")
 	{
-		$iquerysql = "insert into selectquery (QUERYID,STARTINDEX,NUMOFOBJECTS) values (".$genQueryId.",0,0)";
+		$iquerysql = "insert into vtiger_selectquery (QUERYID,STARTINDEX,NUMOFOBJECTS) values (".$genQueryId.",0,0)";
 		$iquerysqlresult = $adb->query($iquerysql);
-		 $log->info("Reports :: Save->Successfully saved selectquery");
+		 $log->info("Reports :: Save->Successfully saved vtiger_selectquery");
 		if($iquerysqlresult!=false)
 		{
-			//<<<<step2 selectcolumn>>>>>>>>
+			//<<<<step2 vtiger_selectcolumn>>>>>>>>
 			if($selectedcolumnstring != "")
 			{
 				$selectedcolumns = explode(";",$selectedcolumnstring);
 				for($i=0 ;$i< count($selectedcolumns) -1 ;$i++)
 				{
-					$icolumnsql = "insert into selectcolumn (QUERYID,COLUMNINDEX,COLUMNNAME) values (".$genQueryId.",".$i.",'".$selectedcolumns[$i]."')";
+					$icolumnsql = "insert into vtiger_selectcolumn (QUERYID,COLUMNINDEX,COLUMNNAME) values (".$genQueryId.",".$i.",'".$selectedcolumns[$i]."')";
 					$icolumnsqlresult = $adb->query($icolumnsql);
 				}
 			}
-			$log->info("Reports :: Save->Successfully saved selectcolumn");
-			//<<<<step2 selectcolumn>>>>>>>>
+			$log->info("Reports :: Save->Successfully saved vtiger_selectcolumn");
+			//<<<<step2 vtiger_selectcolumn>>>>>>>>
 
 		       //$genReportMId = $adb->getUniqueID("reportmodules");
 
 		       if($genQueryId != "")
 		       {
-				$ireportsql = "insert into report (REPORTID,FOLDERID,REPORTNAME,DESCRIPTION,REPORTTYPE,QUERYID,STATE)";
+				$ireportsql = "insert into vtiger_report (REPORTID,FOLDERID,REPORTNAME,DESCRIPTION,REPORTTYPE,QUERYID,STATE)";
 				$ireportsql .= " values (".$genQueryId.",".$folderid.",'".$reportname."','".$reportdescription."','".$reporttype."',".$genQueryId.",'CUSTOM')";
 				$ireportresult = $adb->query($ireportsql);
-			       	$log->info("Reports :: Save->Successfully saved report");
+			       	$log->info("Reports :: Save->Successfully saved vtiger_report");
 				if($ireportresult!=false)
 				{
 					//<<<<reportmodules>>>>>>>
-					$ireportmodulesql = "insert into reportmodules (REPORTMODULESID,PRIMARYMODULE,SECONDARYMODULES) values (".$genQueryId.",'".$pmodule."','".$smodule."')";
+					$ireportmodulesql = "insert into vtiger_reportmodules (REPORTMODULESID,PRIMARYMODULE,SECONDARYMODULES) values (".$genQueryId.",'".$pmodule."','".$smodule."')";
 					$ireportmoduleresult = $adb->query($ireportmodulesql);
-					$log->info("Reports :: Save->Successfully saved reportmodules");
+					$log->info("Reports :: Save->Successfully saved vtiger_reportmodules");
 					//<<<<reportmodules>>>>>>>
 
-					//<<<<step3 reportsortcol>>>>>>>
+					//<<<<step3 vtiger_reportsortcol>>>>>>>
 					if($sort_by1 != "")
 					{
-						$sort_by1sql = "insert into reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (1,".$genQueryId.",'".$sort_by1."','".$sort_order1."')";
+						$sort_by1sql = "insert into vtiger_reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (1,".$genQueryId.",'".$sort_by1."','".$sort_order1."')";
 						$sort_by1result = $adb->query($sort_by1sql);
 					}
 					if($sort_by2 != "")
 					{
-						$sort_by2sql = "insert into reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (2,".$genQueryId.",'".$sort_by2."','".$sort_order2."')";
+						$sort_by2sql = "insert into vtiger_reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (2,".$genQueryId.",'".$sort_by2."','".$sort_order2."')";
 						$sort_by2result = $adb->query($sort_by2sql);
 					}
 					if($sort_by3 != "")
 					{
-						$sort_by3sql = "insert into reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (3,".$genQueryId.",'".$sort_by3."','".$sort_order3."')";
+						$sort_by3sql = "insert into vtiger_reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (3,".$genQueryId.",'".$sort_by3."','".$sort_order3."')";
 						$sort_by3result = $adb->query($sort_by3sql);
 					}
-					$log->info("Reports :: Save->Successfully saved reportsortcol");
-					//<<<<step3 reportsortcol>>>>>>>
+					$log->info("Reports :: Save->Successfully saved vtiger_reportsortcol");
+					//<<<<step3 vtiger_reportsortcol>>>>>>>
 
 					//<<<<step5 standarfilder>>>>>>>
-					$ireportmodulesql = "insert into reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$genQueryId.",'".$stdDateFilterField."','".$stdDateFilter."','".$startdate."','".$enddate."')";
+					$ireportmodulesql = "insert into vtiger_reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$genQueryId.",'".$stdDateFilterField."','".$stdDateFilter."','".$startdate."','".$enddate."')";
 					$ireportmoduleresult = $adb->query($ireportmodulesql);
-					$log->info("Reports :: Save->Successfully saved reportdatefilter");
+					$log->info("Reports :: Save->Successfully saved vtiger_reportdatefilter");
 					//<<<<step5 standarfilder>>>>>>>
 
 					//<<<<step4 columnstototal>>>>>>>
 					for ($i=0;$i<count($columnstototal);$i++)
 					{
-						$ireportsummarysql = "insert into reportsummary (REPORTSUMMARYID,SUMMARYTYPE,COLUMNNAME) values (".$genQueryId.",".$i.",'".$columnstototal[$i]."')";
+						$ireportsummarysql = "insert into vtiger_reportsummary (REPORTSUMMARYID,SUMMARYTYPE,COLUMNNAME) values (".$genQueryId.",".$i.",'".$columnstototal[$i]."')";
 						$ireportsummaryresult = $adb->query($ireportsummarysql);
 					}
-					$log->info("Reports :: Save->Successfully saved reportsummary");
+					$log->info("Reports :: Save->Successfully saved vtiger_reportsummary");
 					//<<<<step4 columnstototal>>>>>>>
 
 					//<<<<step5 advancedfilter>>>>>>>
                                         for ($i=0;$i<count($adv_filter_col);$i++)
                                         {
-                                                $irelcriteriasql = "insert into relcriteria(QUERYID,COLUMNINDEX,COLUMNNAME,COMPARATOR,VALUE) values (".$genQueryId.",".$i.",'".$adv_filter_col[$i]."','".$adv_filter_option[$i]."','".$adv_filter_value[$i]."')";
+                                                $irelcriteriasql = "insert into vtiger_relcriteria(QUERYID,COLUMNINDEX,COLUMNNAME,COMPARATOR,VALUE) values (".$genQueryId.",".$i.",'".$adv_filter_col[$i]."','".$adv_filter_option[$i]."','".$adv_filter_value[$i]."')";
 						//echo $irelcriteriasql;
 
                                                 $irelcriteriaresult = $adb->query($irelcriteriasql);
                                         }
-					$log->info("Reports :: Save->Successfully saved relcriteria");
+					$log->info("Reports :: Save->Successfully saved vtiger_relcriteria");
                                         //<<<<step5 advancedfilter>>>>>>>
 
 				}else
@@ -198,7 +198,7 @@
 	{
 		if($selectedcolumnstring != "")
 		{
-			$idelcolumnsql = "delete from selectcolumn where queryid=".$reportid;
+			$idelcolumnsql = "delete from vtiger_selectcolumn where queryid=".$reportid;
 			$idelcolumnsqlresult = $adb->query($idelcolumnsql);
 			//echo $idelcolumnsql;
 			if($idelcolumnsqlresult != false)
@@ -206,83 +206,83 @@
 				$selectedcolumns = explode(";",$selectedcolumnstring);
 				for($i=0 ;$i< count($selectedcolumns) -1 ;$i++)
 				{
-					$icolumnsql = "insert into selectcolumn (QUERYID,COLUMNINDEX,COLUMNNAME) values (".$reportid.",".$i.",'".$selectedcolumns[$i]."')";
+					$icolumnsql = "insert into vtiger_selectcolumn (QUERYID,COLUMNINDEX,COLUMNNAME) values (".$reportid.",".$i.",'".$selectedcolumns[$i]."')";
 					$icolumnsqlresult = $adb->query($icolumnsql);
 					//echo $icolumnsql;
 				}
 			}
 		}
 
-		$ireportsql = "update report set";
+		$ireportsql = "update vtiger_report set";
 		$ireportsql .= " REPORTNAME='".$reportname."',";
 		$ireportsql .= " DESCRIPTION='".$reportdescription."',";
 		$ireportsql .= " REPORTTYPE='".$reporttype."'";
 		$ireportsql .= " where REPORTID=".$reportid;
 		$ireportresult = $adb->query($ireportsql);
-		$log->info("Reports :: Save->Successfully saved report");
+		$log->info("Reports :: Save->Successfully saved vtiger_report");
 		//echo $ireportsql;
 
-		$idelreportsortcolsql = "delete from reportsortcol where reportid=".$reportid;
+		$idelreportsortcolsql = "delete from vtiger_reportsortcol where vtiger_reportid=".$reportid;
 		$idelreportsortcolsqlresult = $adb->query($idelreportsortcolsql);
-		$log->info("Reports :: Save->Successfully deleted reportsortcol");
+		$log->info("Reports :: Save->Successfully deleted vtiger_reportsortcol");
 		//echo $idelreportsortcolsql;
 
 		if($idelreportsortcolsqlresult!=false)
 		{
-			//<<<<step3 reportsortcol>>>>>>>
+			//<<<<step3 vtiger_reportsortcol>>>>>>>
 			if($sort_by1 != "")
 			{
-				$sort_by1sql = "insert into reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (1,".$reportid.",'".$sort_by1."','".$sort_order1."')";
+				$sort_by1sql = "insert into vtiger_reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (1,".$reportid.",'".$sort_by1."','".$sort_order1."')";
 				$sort_by1result = $adb->query($sort_by1sql);
 				//echo $sort_by1sql;
 			}
 			if($sort_by2 != "")
 			{
-				$sort_by2sql = "insert into reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (2,".$reportid.",'".$sort_by2."','".$sort_order2."')";
+				$sort_by2sql = "insert into vtiger_reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (2,".$reportid.",'".$sort_by2."','".$sort_order2."')";
 				$sort_by2result = $adb->query($sort_by2sql);
 			}
 			if($sort_by3 != "")
 			{
-				$sort_by3sql = "insert into reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (3,".$reportid.",'".$sort_by3."','".$sort_order3."')";
+				$sort_by3sql = "insert into vtiger_reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (3,".$reportid.",'".$sort_by3."','".$sort_order3."')";
 				$sort_by3result = $adb->query($sort_by3sql);
 			}
-			$log->info("Reports :: Save->Successfully saved reportsortcol");
-			//<<<<step3 reportsortcol>>>>>>>
-
-			$idelreportdatefiltersql = "delete from reportdatefilter where datefilterid=".$reportid;
+			$log->info("Reports :: Save->Successfully saved vtiger_reportsortcol");
+			//<<<<step3 vtiger_reportsortcol>>>>>>>
+
+			$idelreportdatefiltersql = "delete from vtiger_reportdatefilter where datefilterid=".$reportid;
 			$idelreportdatefiltersqlresult = $adb->query($idelreportdatefiltersql);
 			//echo $idelreportsortcolsql;
 
 			//<<<<step5 standarfilder>>>>>>>
-			$ireportmodulesql = "insert into reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$reportid.",'".$stdDateFilterField."','".$stdDateFilter."','".$startdate."','".$enddate."')";
+			$ireportmodulesql = "insert into vtiger_reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$reportid.",'".$stdDateFilterField."','".$stdDateFilter."','".$startdate."','".$enddate."')";
 			$ireportmoduleresult = $adb->query($ireportmodulesql);
-			$log->info("Reports :: Save->Successfully saved reportdatefilter");
+			$log->info("Reports :: Save->Successfully saved vtiger_reportdatefilter");
 			//<<<<step5 standarfilder>>>>>>>
 
 			//<<<<step4 columnstototal>>>>>>>
-			$idelreportsummarysql = "delete from reportsummary where reportsummaryid=".$reportid;
+			$idelreportsummarysql = "delete from vtiger_reportsummary where vtiger_reportsummaryid=".$reportid;
 			$idelreportsummarysqlresult = $adb->query($idelreportsummarysql);
 
 			for ($i=0;$i<count($columnstototal);$i++)
 			{
-				$ireportsummarysql = "insert into reportsummary (REPORTSUMMARYID,SUMMARYTYPE,COLUMNNAME) values (".$reportid.",".$i.",'".$columnstototal[$i]."')";
+				$ireportsummarysql = "insert into vtiger_reportsummary (REPORTSUMMARYID,SUMMARYTYPE,COLUMNNAME) values (".$reportid.",".$i.",'".$columnstototal[$i]."')";
 				$ireportsummaryresult = $adb->query($ireportsummarysql);
 			}
-			$log->info("Reports :: Save->Successfully saved reportsummary");
+			$log->info("Reports :: Save->Successfully saved vtiger_reportsummary");
 			//<<<<step4 columnstototal>>>>>>>
 
 
 			//<<<<step5 advancedfilter>>>>>>>
 
-			$idelrelcriteriasql = "delete from relcriteria where queryid=".$reportid;
+			$idelrelcriteriasql = "delete from vtiger_relcriteria where queryid=".$reportid;
 			$idelrelcriteriasqlresult = $adb->query($idelrelcriteriasql);
 
 			for ($i=0;$i<count($adv_filter_col);$i++)
 			{
-				$irelcriteriasql = "insert into relcriteria(QUERYID,COLUMNINDEX,COLUMNNAME,COMPARATOR,VALUE) values (".$reportid.",".$i.",'".$adv_filter_col[$i]."','".$adv_filter_option[$i]."','".$adv_filter_value[$i]."')";
+				$irelcriteriasql = "insert into vtiger_relcriteria(QUERYID,COLUMNINDEX,COLUMNNAME,COMPARATOR,VALUE) values (".$reportid.",".$i.",'".$adv_filter_col[$i]."','".$adv_filter_option[$i]."','".$adv_filter_value[$i]."')";
 				$irelcriteriaresult = $adb->query($irelcriteriasql);
 			}
-			$log->info("Reports :: Save->Successfully saved relcriteria");
+			$log->info("Reports :: Save->Successfully saved vtiger_relcriteria");
 			//<<<<step5 advancedfilter>>>>>>>
 
 		}else

Modified: vtigercrm/trunk/modules/Reports/SaveAndRun.php
==============================================================================
--- vtigercrm/trunk/modules/Reports/SaveAndRun.php (original)
+++ vtigercrm/trunk/modules/Reports/SaveAndRun.php Mon Jun 12 14:26:25 2006
@@ -48,7 +48,7 @@
 
 	$list_report_form = new vtigerCRM_Smarty;
 	$ogReport->getSelectedStandardCriteria($reportid);
-	//commented to omit dashboards for reports
+	//commented to omit dashboards for vtiger_reports
 	//require_once('modules/Dashboard/ReportsCharts.php');
 	//$image = get_graph_by_type('Report','Report',$primarymodule,'',$sshtml[2]);
 	//$list_report_form->assign("GRAPH", $image);
@@ -176,7 +176,7 @@
 function getReportsinFolder($folderid)
 {
 	global $adb;
-	$query = 'select reportid,reportname from report where folderid='.$folderid;
+	$query = 'select vtiger_reportid,reportname from vtiger_report where folderid='.$folderid;
 	$result = $adb->query($query);
 	$reports_array = Array();
 	for($i=0;$i < $adb->num_rows($result);$i++)	

Modified: vtigercrm/trunk/modules/Reports/SaveReportFolder.php
==============================================================================
--- vtigercrm/trunk/modules/Reports/SaveReportFolder.php (original)
+++ vtigercrm/trunk/modules/Reports/SaveReportFolder.php Mon Jun 12 14:26:25 2006
@@ -27,7 +27,7 @@
 {
 	if($rfid=="")
 	{
-		$sql = "INSERT INTO reportfolder ";
+		$sql = "INSERT INTO vtiger_reportfolder ";
 		$sql .= "(FOLDERID,FOLDERNAME,DESCRIPTION,STATE) ";
 		$sql .= "VALUES ('','".$foldername."','".$folderdesc."','CUSTOMIZED')";
 		$result = $adb->query($sql);
@@ -47,7 +47,7 @@
 {
 	if($rfid != "")
 	{
-		$sql = "update reportfolder set ";
+		$sql = "update vtiger_reportfolder set ";
 		$sql .= "FOLDERNAME='".$foldername."', ";
 		$sql .= "DESCRIPTION='".$folderdesc."' ";
 		$sql .= "where folderid=".$rfid;

Modified: vtigercrm/trunk/modules/Reports/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Reports/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Reports/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -36,7 +36,7 @@
 'LBL_NEW_REP0_HDR3'=>'Note:',
 'LBL_NEW_REP0_HDR4'=>'Report Module and related module once selected cannot be modified later',
 'LBL_CONTINUE_BUTTON'=>'Continue',
-'LBL_NEW_REP1_HDR1'=>'Provide the following report information',
+'LBL_NEW_REP1_HDR1'=>'Provide the following vtiger_report information',
 'LBL_REPORT_TYPE'=>'Report Type',
 'LBL_SELECT_COLUMNS'=>'Select Columns',
 'LBL_SPECIFY_GROUPING'=>'Specify Grouping',
@@ -44,9 +44,9 @@
 'LBL_SPECIFY_CRITERIA'=>'Specify Criteria',
 'LBL_SAVERUN_BUTTON'=>'Save And Run',
 'LBL_TABULAT_REPORT'=>'Tabular Report',
-'LBL_REPORT_TYPE_HDR1'=>'Tabular reports are the simplest and fastest way to get a listing of your data.',
+'LBL_REPORT_TYPE_HDR1'=>'Tabular vtiger_reports are the simplest and fastest way to get a listing of your data.',
 'LBL_SUMMARY_REPORT'=>'Summary Report',
-'LBL_REPORT_TYPE_HDR2'=>'Summary reports allow you to view your data along with subtotals and other summary information.',
+'LBL_REPORT_TYPE_HDR2'=>'Summary vtiger_reports allow you to view your data along with subtotals and other summary information.',
 'LBL_AVAILABLE_COLUMNS'=>'Available Columns:',
 'LBL_SELECTED_COLUMNS'=>'Selected Columns:',
 'LBL_ADD_BUTTON'=>'Add',
@@ -79,15 +79,15 @@
 'LBL_EXPORTXL_BUTTON'=>'Export To Excel',
 
 //Added for 5 Beta
-'LBL_NO_PERMISSION'=>'Your profile dosen\'t allow you view the reports for one of the  module(s)',
-'LBL_SELECT_COLUMNS_TO_GENERATE_REPORTS'=>'Select columns to generate reports',
+'LBL_NO_PERMISSION'=>'Your vtiger_profile dosen\'t allow you view the vtiger_reports for one of the  module(s)',
+'LBL_SELECT_COLUMNS_TO_GENERATE_REPORTS'=>'Select columns to generate vtiger_reports',
 'LBL_AVAILABLE_FIELDS'=>'Available Fields',
 'LBL_SELECTED_FIELDS'=>'Selected Fields',
 'LBL_CALCULATIONS'=>'Calculations',
 'LBL_SELECT_COLUMNS_TO_TOTAL'=>'Select columns to Total',
 'LBL_SELECT_FILTERS_TO_STREAMLINE_REPORT_DATA'=>'Select Filters to Streamline Report Data',
 'LBL_SELECT_FILTERS'=>'Filters',
-'LBL_SELECT_COLUMNS_TO_GROUP_REPORTS'=>'Select columns to group reports',
+'LBL_SELECT_COLUMNS_TO_GROUP_REPORTS'=>'Select columns to group vtiger_reports',
 'LBL_BACK_TO_REPORTS'=>'Back to Reports',
 'LBL_SELECT_ANOTHER_REPORT'=>'Select Another Report',
 'LBL_SELECT_COLUMN'=>'Select Column',
@@ -101,7 +101,7 @@
 'LBL_REPORT_TYPE'=>'Report Type',
 'LBL_REPORT_DETAILS'=>'Report Details',
 'LBL_TYPE_THE_NAME'=>'Type the Name',
-'LBL_DESCRIPTION_FOR_REPORT'=>'Description for the report',
+'LBL_DESCRIPTION_FOR_REPORT'=>'Description for the vtiger_report',
 'LBL_REPORT_NAME'=>'Report Name',
 'LBL_DESCRIPTION'=>'Description',
 'LBL_TOOLS'=>'Tools',
@@ -112,7 +112,7 @@
 'LBL_SELECT_REPORT_TYPE_BELOW'=>'Select Report type Below',
 'LBL_TABULAR_FORMAT'=>'Tabular Format',
 'LBL_TABULAR_REPORTS_ARE_SIMPLEST'=>'Tabular Reports are the simplest and fastest way of getting your data',
-'LBL_SUMMARY_REPORT_VIEW_DATA_WITH_SUBTOTALS'=>'Summary reports allow you to view your data along with subtotals and other summary information',
+'LBL_SUMMARY_REPORT_VIEW_DATA_WITH_SUBTOTALS'=>'Summary vtiger_reports allow you to view your data along with subtotals and other summary information',
 'LBL_FILTERS'=>'Filters',
 
 )

Modified: vtigercrm/trunk/modules/Rss/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Rss/ListView.php (original)
+++ vtigercrm/trunk/modules/Rss/ListView.php Mon Jun 12 14:26:25 2006
@@ -70,7 +70,7 @@
 {
 	$rss_form->assign("TITLE",gerRssTitle());
 	$rss_html = $oRss->getStarredRssHTML();
-	$query = "select rssid from rss where starred=1";
+	$query = "select rssid from vtiger_rss where starred=1";
 	$result = $adb->query($query);
 	$recordid = $adb->query_result($result,0,'rssid');
 	$rss_form->assign("ID",$recordid);

Modified: vtigercrm/trunk/modules/Rss/Popup.php
==============================================================================
--- vtigercrm/trunk/modules/Rss/Popup.php (original)
+++ vtigercrm/trunk/modules/Rss/Popup.php Mon Jun 12 14:26:25 2006
@@ -19,9 +19,9 @@
 if(isset($_REQUEST["record"]))
 {
 	global $adb;
-	$query = 'update rss set starred=0';
+	$query = 'update vtiger_rss set starred=0';
 	$adb->query($query);
-	$query = 'update rss set starred=1 where rssid ='.$_REQUEST["record"]; 
+	$query = 'update vtiger_rss set starred=1 where vtiger_rssid ='.$_REQUEST["record"]; 
 	$adb->query($query);
 	echo $_REQUEST["record"];
 }

Modified: vtigercrm/trunk/modules/Rss/Rss.php
==============================================================================
--- vtigercrm/trunk/modules/Rss/Rss.php (original)
+++ vtigercrm/trunk/modules/Rss/Rss.php Mon Jun 12 14:26:25 2006
@@ -112,7 +112,7 @@
 				$rsstitle = $url;
 			}
 			$genRssId = $adb->getUniqueID("rss");
-			$sSQL = "insert into rss (RSSID,RSSURL,RSSTITLE,RSSTYPE,STARRED) values (".$genRssId.",'".addslashes($url);
+			$sSQL = "insert into vtiger_rss (RSSID,RSSURL,RSSTITLE,RSSTYPE,STARRED) values (".$genRssId.",'".addslashes($url);
 			$sSQL .= "','".addslashes($rsstitle)."',0,".$makestarred.")";
 			$result = $adb->query($sSQL);
 			if($result)
@@ -129,7 +129,7 @@
 		global $adb;
 		global $image_path;
 
-		$sSQL = "select * from rss where rsstype=1";
+		$sSQL = "select * from vtiger_rss where rsstype=1";
 		$result = $adb->query($sSQL);
 		while($allrssrow = $adb->fetch_array($result))
 		{
@@ -157,7 +157,7 @@
 		global $adb;
 		global $image_path;
 
-		$sSQL = "select * from rss where rsstype <> 1";
+		$sSQL = "select * from vtiger_rss where rsstype <> 1";
 		$result = $adb->query($sSQL);
 		while($allrssrow = $adb->fetch_array($result))	
 		{
@@ -179,8 +179,8 @@
 		return $shtml;
 	}
 
-	/** Function to get the rssurl for the given id  
-	  * This Function accepts the rssid as argument and returns the rssurl for that id
+	/** Function to get the vtiger_rssurl for the given id  
+	  * This Function accepts the vtiger_rssid as argument and returns the vtiger_rssurl for that id
 	 */
 	function getRssUrlfromId($rssid)
 	{
@@ -188,7 +188,7 @@
 
 		if($rssid != "")
 		{
-			$sSQL = "select * from rss where rssid=".$rssid;
+			$sSQL = "select * from vtiger_rss where rssid=".$rssid;
 			$result = $adb->query($sSQL);
 			$rssrow = $adb->fetch_array($result);
 
@@ -207,7 +207,7 @@
 
 		if($rssid != "")
 		{
-			$sSQL = "select * from rss where rssid=".$rssid;
+			$sSQL = "select * from vtiger_rss where rssid=".$rssid;
 			$result = $adb->query($sSQL);
 			$rssrow = $adb->fetch_array($result);
 
@@ -238,7 +238,7 @@
 		global $adb;
 		global $image_path;
 
-		$sSQL = "select * from rss where starred=1";
+		$sSQL = "select * from vtiger_rss where starred=1";
 		$result = $adb->query($sSQL);
 		$shtml .= "<img src=\"".$image_path."rss.gif\" border=\"0\" align=\"absmiddle\" hspace=\"2\"><a href=\"#\" onclick='window.open(\"index.php?module=Rss&action=Popup\",\"new\",\"width=500,height=300,resizable=1,scrollbars=1\");'>Add New Rss</a>";
 
@@ -250,8 +250,8 @@
 		return $shtml;
 	}
 	
-	/** Function to get the rssfeed lists for the starred Rss feeds  
-	  * This Function accepts no argument and returns the rss feeds of 
+	/** Function to get the vtiger_rssfeed lists for the starred Rss feeds  
+	  * This Function accepts no argument and returns the vtiger_rss feeds of 
 	  * the starred Feeds as HTML strings
 	 */
 	function getStarredRssHTML()
@@ -259,7 +259,7 @@
 		global $adb;
 		global $image_path,$mod_strings;
 
-		$sSQL = "select * from rss where starred=1";
+		$sSQL = "select * from vtiger_rss where starred=1";
 		$result = $adb->query($sSQL);
 		while($allrssrow = $adb->fetch_array($result))
 		{
@@ -298,15 +298,15 @@
 
 	}
 
-	/** Function to get the rssfeed lists for the given rssid  
-	  * This Function accepts the rssid as argument and returns the rss feeds as HTML strings
+	/** Function to get the vtiger_rssfeed lists for the given vtiger_rssid  
+	  * This Function accepts the vtiger_rssid as argument and returns the vtiger_rss feeds as HTML strings
 	 */
 	function getSelectedRssHTML($rssid)
 	{
 		global $adb;
 		global $image_path, $mod_strings;
 
-		$sSQL = "select * from rss where rssid=".$rssid;
+		$sSQL = "select * from vtiger_rss where rssid=".$rssid;
 		$result = $adb->query($sSQL);
 		while($allrssrow = $adb->fetch_array($result))
 		{
@@ -372,7 +372,7 @@
 		global $adb;
 		global $image_path;
 
-		$sSQL = "select * from rss";
+		$sSQL = "select * from vtiger_rss";
 		$result = $adb->query($sSQL);
 		while($allrssrow = $adb->fetch_array($result))
 		{
@@ -393,7 +393,7 @@
 
 	}
 
-	/** Function to get the rsscategories   
+	/** Function to get the vtiger_rsscategories   
 	* This Function accepts no argument and returns the categorylist as an array
 	*/
 
@@ -401,7 +401,7 @@
 	{
 		global $adb;
 		global $image_path;
-		$sSQL = "select * from rsscategory where presence = 1 order by sortorderid";
+		$sSQL = "select * from vtiger_rsscategory where presence = 1 order by sortorderid";
 		$result = $adb->query($sSQL);
 
 		while($categoryrow = $adb->fetch_array($result))
@@ -426,17 +426,17 @@
 	}
 }
 
-/** Function to get the rsstitle for the given rssid  
- * This Function accepts the rssid as an optional argument and returns the title
- * if no id is passed it will return the tittle of the starred rss
+/** Function to get the vtiger_rsstitle for the given vtiger_rssid  
+ * This Function accepts the vtiger_rssid as an optional argument and returns the title
+ * if no id is passed it will return the tittle of the starred vtiger_rss
  */
 function gerRssTitle($id='')
 {
 	global $adb;
 	if($id == '')
-		$query = 'select * from rss where starred=1';	 
+		$query = 'select * from vtiger_rss where starred=1';	 
 	else		
-		$query = 'select * from rss where rssid ='.$id;	 
+		$query = 'select * from vtiger_rss where rssid ='.$id;	 
 	$result = $adb->query($query);	
 	$title = $adb->query_result($result,0,'rsstitle');
 	return $title;

Modified: vtigercrm/trunk/modules/Rss/Star.php
==============================================================================
--- vtigercrm/trunk/modules/Rss/Star.php (original)
+++ vtigercrm/trunk/modules/Rss/Star.php Mon Jun 12 14:26:25 2006
@@ -18,7 +18,7 @@
 	if(!isset($_REQUEST[starred])) $starred = 0;
 	$starred = $_REQUEST[starred];
 	
-	$sSQL = "update rss set starred=".$starred." where rssid=".$recordid;
+	$sSQL = "update vtiger_rss set starred=".$starred." where vtiger_rssid=".$recordid;
 	$result = $adb->query($sSQL);
 }
 header("Location: index.php?module=Rss&action=index");

Modified: vtigercrm/trunk/modules/SalesOrder/CreateSOPDF.php
==============================================================================
--- vtigercrm/trunk/modules/SalesOrder/CreateSOPDF.php (original)
+++ vtigercrm/trunk/modules/SalesOrder/CreateSOPDF.php Mon Jun 12 14:26:25 2006
@@ -16,7 +16,7 @@
 
 global $adb,$app_strings,$products_per_page;
 
-$sql="select currency_symbol from currency_info";
+$sql="select vtiger_currency_symbol from vtiger_currency_info";
 $result = $adb->query($sql);
 $currency_symbol = $adb->query_result($result,0,'currency_symbol');
 
@@ -25,7 +25,7 @@
 $products_per_page="6";
 
 $id = $_REQUEST['record'];
-//retreiving the invoice info
+//retreiving the vtiger_invoice info
 $focus = new SalesOrder();
 $focus->retrieve_entity_info($_REQUEST['record'],"SalesOrder");
 $account_name = getAccountName($focus->column_fields[account_id]);
@@ -59,7 +59,7 @@
 $status = $focus->column_fields["sostatus"];
 
 // Company information
-$add_query = "select * from organizationdetails";
+$add_query = "select * from vtiger_organizationdetails";
 $result = $adb->query($add_query);
 $num_rows = $adb->num_rows($result);
 
@@ -85,7 +85,7 @@
 $price_total = $currency_symbol.number_format(StripLastZero($focus->column_fields["hdnGrandTotal"]),2,'.',',');
 
 //getting the Product Data
-$query="select products.productname,products.unit_price,products.product_description,soproductrel.* from soproductrel inner join products on products.productid=soproductrel.productid where salesorderid=".$id;
+$query="select vtiger_products.productname,vtiger_products.unit_price,vtiger_products.product_description,vtiger_soproductrel.* from vtiger_soproductrel inner join vtiger_products on vtiger_products.productid=vtiger_soproductrel.productid where vtiger_salesorderid=".$id;
 
 global $result;
 $result = $adb->query($query);

Modified: vtigercrm/trunk/modules/SalesOrder/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/SalesOrder/EditView.php (original)
+++ vtigercrm/trunk/modules/SalesOrder/EditView.php Mon Jun 12 14:26:25 2006
@@ -48,7 +48,7 @@
 	$focus = getConvertQuoteToSoObject($focus,$quote_focus,$quoteid);
 	$focus->id = $quoteid;
 
-	//Added to display the Quotes's associated products -- when we create SO from Quotes DetailView 
+	//Added to display the Quotes's associated vtiger_products -- when we create SO from Quotes DetailView 
 	$associated_prod = getAssociatedProducts("Quotes",$quote_focus);
 	$smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
 	$smarty->assign("MODE", $quote_focus->mode);
@@ -72,7 +72,7 @@
         	}
 
 	}
-	//Handling for dateformat in due_date field
+	//Handling for dateformat in due_date vtiger_field
 	if($focus->column_fields['duedate'] != '')
 	{
 		$curr_due_date = $focus->column_fields['duedate'];
@@ -111,7 +111,7 @@
         		}
 
 		}
-		//Handling for dateformat in due_date field
+		//Handling for dateformat in due_date vtiger_field
 		if($focus->column_fields['duedate'] != '')
 		{
 			$curr_due_date = $focus->column_fields['duedate'];
@@ -123,7 +123,7 @@
 		$quote_focus->retrieve_entity_info($quoteid,"Quotes");
 		$focus = getConvertQuoteToSoObject($focus,$quote_focus,$quoteid);
 
-		//Added to display the Quotes's associated products -- when we select Quote in New SO page
+		//Added to display the Quotes's associated vtiger_products -- when we select Quote in New SO page
 		if(isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] !='')
 		{
 			$associated_prod = getAssociatedProducts("Quotes",$quote_focus,$focus->column_fields['quote_id']);
@@ -163,7 +163,7 @@
         $associated_prod = getAssociatedProducts("Products",$focus,$focus->column_fields['product_id']);
 }
 
-// Get Account address if account is given
+// Get Account address if vtiger_account is given
 if(isset($_REQUEST['account_id']) && $_REQUEST['record']=='' && $_REQUEST['account_id'] != ''){
 	require_once('modules/Accounts/Account.php');
 	$acct_focus = new Account();

Modified: vtigercrm/trunk/modules/SalesOrder/ListTopSalesOrder.php
==============================================================================
--- vtigercrm/trunk/modules/SalesOrder/ListTopSalesOrder.php (original)
+++ vtigercrm/trunk/modules/SalesOrder/ListTopSalesOrder.php Mon Jun 12 14:26:25 2006
@@ -51,7 +51,7 @@
 	//<<<<<<<<<customview>>>>>>>>>
 	$date_var = date('Y-m-d');
 
-	$where = ' and crmentity.smownerid='.$current_user->id.' and  salesorder.duedate >= \''.$date_var.'\' ORDER BY total DESC';
+	$where = ' and vtiger_crmentity.smownerid='.$current_user->id.' and  vtiger_salesorder.duedate >= \''.$date_var.'\' ORDER BY total DESC';
 	$query = getListQuery("SalesOrder",$where);
 
 	//<<<<<<<<customview>>>>>>>>>

Modified: vtigercrm/trunk/modules/SalesOrder/SalesOrder.php
==============================================================================
--- vtigercrm/trunk/modules/SalesOrder/SalesOrder.php (original)
+++ vtigercrm/trunk/modules/SalesOrder/SalesOrder.php Mon Jun 12 14:26:25 2006
@@ -28,20 +28,20 @@
 require_once('data/CRMEntity.php');
 require_once('include/utils/utils.php');
 
-// Account is used to store account information.
+// Account is used to store vtiger_account information.
 class SalesOrder extends CRMEntity {
 	var $log;
 	var $db;
 
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $mode;
 	
 		
 	var $table_name = "salesorder";
-	var $tab_name = Array('crmentity','salesorder','sobillads','soshipads','salesordercf');
-	var $tab_name_index = Array('crmentity'=>'crmid','salesorder'=>'salesorderid','sobillads'=>'sobilladdressid','soshipads'=>'soshipaddressid','salesordercf'=>'salesorderid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_salesorder','vtiger_sobillads','vtiger_soshipads','vtiger_salesordercf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_salesorder'=>'salesorderid','vtiger_sobillads'=>'sobilladdressid','vtiger_soshipads'=>'soshipaddressid','vtiger_salesordercf'=>'salesorderid');
 				
 	
 	var $entity_table = "crmentity";
@@ -58,10 +58,10 @@
 
 	var $sortby_fields = Array('subject','smownerid');		
 
-	// This is used to retrieve related fields from form posts.
+	// This is used to retrieve related vtiger_fields from form posts.
 	var $additional_column_fields = Array('assigned_user_name', 'smownerid', 'opportunity_id', 'case_id', 'contact_id', 'task_id', 'note_id', 'meeting_id', 'call_id', 'email_id', 'parent_name', 'member_id' );
 
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
 				'Order Id'=>Array('crmentity'=>'crmid'),
 				'Subject'=>Array('salesorder'=>'subject'),
@@ -99,7 +99,7 @@
 				        'Quote Name'=>'quote_id'
 				      );
 
-	// This is the list of fields that are required.
+	// This is the list of vtiger_fields that are required.
 	var $required_fields =  array("accountname"=>1);
 
 	//Added these variables which are used as default order by and sortorder in ListView
@@ -131,7 +131,7 @@
 		$button = '';
 
 		$returnset = '&return_module=SalesOrder&return_action=DetailView&return_id='.$id;
-		$query = "SELECT contactdetails.lastname, contactdetails.firstname, contactdetails.contactid, activity.*,seactivityrel.*,crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime, users.user_name from activity inner join seactivityrel on seactivityrel.activityid=activity.activityid inner join crmentity on crmentity.crmid=activity.activityid left join cntactivityrel on cntactivityrel.activityid= activity.activityid left join contactdetails on contactdetails.contactid = cntactivityrel.contactid left join users on users.id=crmentity.smownerid left join activitygrouprelation on activitygrouprelation.activityid=crmentity.crmid left join groups on groups.groupname=activitygrouprelation.groupname where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and (activity.status is not NULL && activity.status != 'Completed') and (activity.status is not NULL && activity.status !='Deferred') or (activity.eventstatus != '' &&  activity.eventstatus = 'Planned')";
+		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or vtiger_activitytype='Call' or vtiger_activitytype='Meeting') and vtiger_crmentity.deleted=0 and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL && vtiger_activity.status !='Deferred') or (vtiger_activity.eventstatus != '' &&  vtiger_activity.eventstatus = 'Planned')";
 		$log->debug("Exiting get_activities method ...");
 		return GetRelatedList('SalesOrder','Activities',$focus,$query,$button,$returnset);
 	}
@@ -144,27 +144,27 @@
 	{
 		global $log;
 		$log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT contactdetails.lastname, contactdetails.firstname, contactdetails.contactid,
-				activity.*, seactivityrel.*, crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime,
-				crmentity.createdtime, crmentity.description, users.user_name
-			from activity
-				inner join seactivityrel on seactivityrel.activityid=activity.activityid
-				inner join crmentity on crmentity.crmid=activity.activityid
-				left join cntactivityrel on cntactivityrel.activityid= activity.activityid
-				left join contactdetails on contactdetails.contactid = cntactivityrel.contactid
-				inner join users on crmentity.smcreatorid=users.id
-				left join activitygrouprelation on activitygrouprelation.activityid=activity.activityid
-                                left join groups on groups.groupname=activitygrouprelation.groupname
-			where (activitytype='Task' or activitytype='Call' or activitytype='Meeting')
-				and (activity.status = 'Completed' or activity.status = 'Deferred' or (activity.eventstatus !='Planned' and activity.eventstatus != ''))
-				and seactivityrel.crmid=".$id;
+		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,
+			vtiger_activity.*, vtiger_seactivityrel.*, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,
+			vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
+			from vtiger_activity
+				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
+				left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
+				inner join vtiger_users on vtiger_crmentity.smcreatorid=vtiger_users.id
+				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+			where (activitytype='Task' or vtiger_activitytype='Call' or vtiger_activitytype='Meeting')
+				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus !='Planned' and vtiger_activity.eventstatus != ''))
+				and vtiger_seactivityrel.crmid=".$id;
 		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
 
 		$log->debug("Exiting get_history method ...");
 		return getHistory('SalesOrder',$query,$id);
 	}
 
-/** Function to get attachments associated with the id
+/** Function to get vtiger_attachments associated with the id
  *  This function accepts the id as arguments and execute the MySQL query using the id
  *  and sends the query and the id as arguments to renderRelatedAttachments() method.
 */
@@ -173,41 +173,41 @@
 		global $log;
 		$log->debug("Entering get_attachments(".$id.") method ...");
 		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crmentity.createdtime, notes.notecontent description, users.user_name
-		// Inserted inner join users on crmentity.smcreatorid= users.id
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename,
-			attachments.type  FileType,crm2.modifiedtime lastmodified,
-			seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid,
-			crmentity.createdtime, notes.notecontent description, users.user_name
-		from notes
-			inner join senotesrel on senotesrel.notesid= notes.notesid
-			inner join crmentity on crmentity.crmid= senotesrel.crmid
-			inner join crmentity crm2 on crm2.crmid=notes.notesid and crm2.deleted=0
-			left join seattachmentsrel  on seattachmentsrel.crmid =notes.notesid
-			left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid
-			inner join users on crmentity.smcreatorid= users.id
-		where crmentity.crmid=".$id;
+		// Desc: Inserted vtiger_crmentity.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
+		$query = "select vtiger_notes.title,'Notes      '  ActivityType, vtiger_notes.filename,
+		vtiger_attachments.type  FileType,crm2.modifiedtime lastmodified,
+		vtiger_seattachmentsrel.attachmentsid vtiger_attachmentsid, vtiger_notes.notesid crmid,
+		vtiger_crmentity.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		from vtiger_notes
+			inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+			left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id;
 		$query .= ' union all ';
 		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crmentity.createdtime, attachments.description, users.user_name
-		// Inserted inner join users on crmentity.smcreatorid= users.id
+		// Desc: Inserted vtiger_crmentity.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
 		// Inserted order by createdtime desc
-		$query .= "select attachments.description  title ,'Attachments'  ActivityType,
-			attachments.name  filename, attachments.type  FileType, crm2.modifiedtime lastmodified,
-			attachments.attachmentsid  attachmentsid, seattachmentsrel.attachmentsid crmid,
-			crmentity.createdtime, attachments.description, users.user_name
-		from attachments
-			inner join seattachmentsrel on seattachmentsrel.attachmentsid= attachments.attachmentsid
-			inner join crmentity on crmentity.crmid= seattachmentsrel.crmid
-			inner join crmentity crm2 on crm2.crmid=attachments.attachmentsid
-			inner join users on crmentity.smcreatorid= users.id
-		where crmentity.crmid=".$id."
+		$query .= "select vtiger_attachments.description  title ,'Attachments'  ActivityType,
+		vtiger_attachments.name  filename, vtiger_attachments.type  FileType, crm2.modifiedtime lastmodified,
+		vtiger_attachments.attachmentsid  vtiger_attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
+		vtiger_crmentity.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		from vtiger_attachments
+			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+			inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id."
 		order by createdtime desc";
 	$log->debug("Exiting get_attachments method ...");
 	return getAttachmentsAndNotes('SalesOrder',$query,$id,$sid='salesorderid');
 	}
 
-/** Function to get invoices associated with the id
+/** Function to get vtiger_invoices associated with the id
  *  This function accepts the id as arguments and execute the MySQL query using the id
  *  and sends the query and the id as arguments to renderRelatedInvoices() method.
 */
@@ -223,7 +223,7 @@
 		$returnset = '&return_module=SalesOrder&return_action=DetailView&return_id='.$id;
 
 
-		$query = "select crmentity.*, invoice.*, account.accountname, salesorder.subject as salessubject from invoice inner join crmentity on crmentity.crmid=invoice.invoiceid left outer join account on account.accountid=invoice.accountid inner join salesorder on salesorder.salesorderid=invoice.salesorderid left join invoicegrouprelation on invoice.invoiceid=invoicegrouprelation.invoiceid left join groups on groups.groupname=invoicegrouprelation.groupname where crmentity.deleted=0 and salesorder.salesorderid=".$id;
+		$query = "select vtiger_crmentity.*, vtiger_invoice.*, vtiger_account.accountname, vtiger_salesorder.subject as salessubject from vtiger_invoice inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_invoice.invoiceid left outer join vtiger_account on vtiger_account.accountid=vtiger_invoice.accountid inner join vtiger_salesorder on vtiger_salesorder.salesorderid=vtiger_invoice.salesorderid left join vtiger_invoicegrouprelation on vtiger_invoice.invoiceid=vtiger_invoicegrouprelation.invoiceid left join vtiger_groups on vtiger_groups.groupname=vtiger_invoicegrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_salesorder.salesorderid=".$id;
 		$log->debug("Exiting get_invoices method ...");
 		return GetRelatedList('SalesOrder','Invoice',$focus,$query,$button,$returnset);
 	

Modified: vtigercrm/trunk/modules/SalesOrder/Save.php
==============================================================================
--- vtigercrm/trunk/modules/SalesOrder/Save.php (original)
+++ vtigercrm/trunk/modules/SalesOrder/Save.php Mon Jun 12 14:26:25 2006
@@ -38,14 +38,14 @@
 if($focus->column_fields["quote_id"] != '')
 {
         $qt_id = $focus->column_fields["quote_id"];
-        $query1 = "update quotes set quotestage='Accepted' where quoteid=".$qt_id;
+        $query1 = "update vtiger_quotes set vtiger_quotestage='Accepted' where quoteid=".$qt_id;
         $adb->query($query1);
 }
 
 $ext_prod_arr = Array();
 if($focus->mode == 'edit')
 {
-	$query2  = "select * from soproductrel where salesorderid=".$focus->id;
+	$query2  = "select * from vtiger_soproductrel where vtiger_salesorderid=".$focus->id;
         $result2 = $adb->query($query2);
         $num_rows = $adb->num_rows($result2);
         for($i=0; $i<$num_rows;$i++)
@@ -56,7 +56,7 @@
         }
 
 	
-        $query1 = "delete from soproductrel where salesorderid=".$focus->id;
+        $query1 = "delete from vtiger_soproductrel where vtiger_salesorderid=".$focus->id;
         $adb->query($query1);
 
 }
@@ -84,7 +84,7 @@
         if($prod_status != 'D')
         {
 
-                $query ="insert into soproductrel values($focus->id, $prod_id , $qty, $listprice, $vat, $sales, $service)";
+                $query ="insert into vtiger_soproductrel values($focus->id, $prod_id , $qty, $listprice, $vat, $sales, $service)";
                 $adb->query($query);
 		updateStk($prod_id,$qty,$focus->mode,$ext_prod_arr,'SalesOrder');
         }

Modified: vtigercrm/trunk/modules/SalesOrder/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/SalesOrder/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/SalesOrder/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -81,10 +81,10 @@
 'NTC_COPY_SHIPPING_ADDRESS'=>'Copy shipping address to billing address',
 'NTC_REMOVE_MEMBER_ORG_CONFIRMATION'=>'Are you sure you want to remove this record as a member organization?',
 'LBL_DUPLICATE'=>'Potential Duplicate Accounts',
-'MSG_DUPLICATE' => 'Creating this account may potentialy create a duplicate account. You may either select an account from the list below or you may click on Create New Account to continue creating a new account with the previously entered data.',
+'MSG_DUPLICATE' => 'Creating this vtiger_account may vtiger_potentialy create a duplicate vtiger_account. You may either select an vtiger_account from the list below or you may click on Create New Account to continue creating a new vtiger_account with the previously entered data.',
 
 'LBL_INVITEE'=>'Contacts',
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
 
 'LBL_SELECT_ACCOUNT'=>'Select Account',
 'LBL_GENERAL_INFORMATION'=>'General Information',
@@ -104,7 +104,7 @@
 'LBL_NEW_CONTACT'=>'New Contact',
 'LBL_CONTACT_TITLE'=>'Contacts',
 
-//Added fields after RC1 - Release
+//Added vtiger_fields after RC1 - Release
 'LBL_ALL'=>'All',
 'LBL_PROSPECT'=>'Prospect',
 'LBL_INVESTOR'=>'Investor',

Modified: vtigercrm/trunk/modules/SalesOrder/pdf_templates/header.php
==============================================================================
--- vtigercrm/trunk/modules/SalesOrder/pdf_templates/header.php (original)
+++ vtigercrm/trunk/modules/SalesOrder/pdf_templates/header.php Mon Jun 12 14:26:25 2006
@@ -67,7 +67,7 @@
 $dueBlock=array("80","65");
 $pdf->addRecBlock($valid_till, "Due Date",$dueBlock);
 
-// invoice number block
+// vtiger_invoice number block
 $invBlock=array("145","65");
 $pdf->addRecBlock($id, "Invoice Number",$invBlock);
 

Modified: vtigercrm/trunk/modules/Settings/AddCustomFieldToDB.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/AddCustomFieldToDB.php (original)
+++ vtigercrm/trunk/modules/Settings/AddCustomFieldToDB.php Mon Jun 12 14:26:25 2006
@@ -23,9 +23,9 @@
 }
 
 
-//checking if the user is trying to create a custom field which already exists  
-
-$checkquery="select * from field where tabid='".$tabid."'and fieldlabel='".$fldlabel."'";
+//checking if the user is trying to create a custom vtiger_field which already exists  
+
+$checkquery="select * from vtiger_field where vtiger_tabid='".$tabid."'and vtiger_fieldlabel='".$fldlabel."'";
 $checkresult=$adb->query($checkquery);
 
 if($adb->num_rows($checkresult) != 0)
@@ -72,7 +72,7 @@
 		$columnName = $max_fieldid;
 	}
   
-	//Assigning the table Name
+	//Assigning the vtiger_table Name
 	$tableName ='';
 	if($fldmodule == 'Leads')
 	{
@@ -228,8 +228,8 @@
 
         
 
-        //1. add the customfield table to the field table as Block4
-        //2. fetch the contents of the custom field and show in the UI
+        //1. add the customfield vtiger_table to the vtiger_field vtiger_table as Block4
+        //2. fetch the contents of the custom vtiger_field and show in the UI
         
 	//retreiving the sequence
 	if($_REQUEST['fieldid'] == '')
@@ -250,30 +250,30 @@
         {
 		if($_REQUEST['fieldid'] == '')
 		{
-			$query = "insert into field values(".$tabid.",".$custfld_fieldid.",'".$columnName."','".$tableName."',2,".$uitype.",'".$columnName."','".$fldlabel."',0,0,0,100,".$custfld_sequece.",$blockid,1,'".$uichekdata."',1,0,'BAS')";
+			$query = "insert into vtiger_field values(".$tabid.",".$custfld_fieldid.",'".$columnName."','".$tableName."',2,".$uitype.",'".$columnName."','".$fldlabel."',0,0,0,100,".$custfld_sequece.",$blockid,1,'".$uichekdata."',1,0,'BAS')";
 			$adb->query($query);
 			$adb->alterTable($tableName, $columnName." ".$type, "Add_Column");
 		}
 		else
 		{
-			$query = "update field set fieldlabel='".$fldlabel."',typeofdata='".$uichekdata."' where fieldid=".$_REQUEST['fieldid'];
+			$query = "update vtiger_field set vtiger_fieldlabel='".$fldlabel."',typeofdata='".$uichekdata."' where vtiger_fieldid=".$_REQUEST['fieldid'];
 			$adb->query($query);
 		}
-		//Inserting values into profile2field tables
+		//Inserting values into vtiger_profile2field vtiger_tables
 		if($_REQUEST['fieldid'] == '')
 		{
-			$sql1 = "select * from profile";
+			$sql1 = "select * from vtiger_profile";
 			$sql1_result = $adb->query($sql1);
 			$sql1_num = $adb->num_rows($sql1_result);
 			for($i=0; $i<$sql1_num; $i++)
 			{
 				$profileid = $adb->query_result($sql1_result,$i,"profileid");
-				$sql2 = "insert into profile2field values(".$profileid.", ".$tabid.", ".$custfld_fieldid.", 0, 1)";
+				$sql2 = "insert into vtiger_profile2field values(".$profileid.", ".$tabid.", ".$custfld_fieldid.", 0, 1)";
 				$adb->query($sql2);	 	
 			}
 
-			//Inserting values into def_org tables
-			$sql_def = "insert into def_org_field values(".$tabid.", ".$custfld_fieldid.", 0, 1)";
+			//Inserting values into def_org vtiger_tables
+			$sql_def = "insert into vtiger_def_org_field values(".$tabid.", ".$custfld_fieldid.", 0, 1)";
 			$adb->query($sql_def);
 		}
 
@@ -283,7 +283,7 @@
 			// Creating the PickList Table and Populating Values
 			$adb->createTable($columnName, $columnName." C(255)");
 			//Adding Primary Key
-			$qur = "ALTER table ".$columnName." ADD PRIMARY KEY (". $columnName.")";
+			$qur = "ALTER vtiger_table ".$columnName." ADD PRIMARY KEY (". $columnName.")";
 			$adb->query($qur);
 
 			$fldPickList =  $_REQUEST['fldPickList'];
@@ -299,11 +299,11 @@
 				}
 			}
 		}
-		//Inserting into LeadMapping table - Jaguar
+		//Inserting into LeadMapping vtiger_table - Jaguar
 		if($fldmodule == 'Leads')
 		{
 
-			$sql_def = "insert into convertleadmapping (leadfid) values(".$custfld_fieldid.")";
+			$sql_def = "insert into vtiger_convertleadmapping (leadfid) values(".$custfld_fieldid.")";
 			$adb->query($sql_def);
 		}
 	}

Modified: vtigercrm/trunk/modules/Settings/AddMailAccount.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/AddMailAccount.php (original)
+++ vtigercrm/trunk/modules/Settings/AddMailAccount.php Mon Jun 12 14:26:25 2006
@@ -30,7 +30,7 @@
 
 if(isset($_REQUEST['record']) && $_REQUEST['record']!='')
 {
-	$sql = "select * from mail_accounts where user_id=".$_REQUEST['record'];
+	$sql = "select * from vtiger_mail_accounts where user_id=".$_REQUEST['record'];
 	$result = $adb->query($sql);
 	$rowcount = $adb->num_rows($result);
 	

Modified: vtigercrm/trunk/modules/Settings/BackupServerConfig.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/BackupServerConfig.php (original)
+++ vtigercrm/trunk/modules/Settings/BackupServerConfig.php Mon Jun 12 14:26:25 2006
@@ -26,7 +26,7 @@
 {
 		$smarty->assign("ERROR_MSG",'<b><font color="purple">'.$_REQUEST["error"].'</font></b>');
 }
-$sql="select * from systems where server_type = 'backup'";
+$sql="select * from vtiger_systems where server_type = 'backup'";
 $result = $adb->query($sql);
 $server = $adb->query_result($result,0,'server');
 $server_username = $adb->query_result($result,0,'server_username');

Modified: vtigercrm/trunk/modules/Settings/CurrencyDelete.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/CurrencyDelete.php (original)
+++ vtigercrm/trunk/modules/Settings/CurrencyDelete.php Mon Jun 12 14:26:25 2006
@@ -11,9 +11,9 @@
 
 $del_id = $_REQUEST['delete_currency_id'];
 $tran_id = $_REQUEST['transfer_currency_id'];
-$sql0 = "update users set currency_id=".$tran_id." where currency_id=".$del_id;
+$sql0 = "update vtiger_users set vtiger_currency_id=".$tran_id." where vtiger_currency_id=".$del_id;
 $adb->query($sql0);
-$sql = "delete from currency_info where id =".$del_id;
+$sql = "delete from vtiger_currency_info where id =".$del_id;
 $adb->query($sql);
 header("Location: index.php?action=SettingsAjax&module=Settings&file=CurrencyListView&ajax=true");
 

Modified: vtigercrm/trunk/modules/Settings/CurrencyDeleteStep1.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/CurrencyDeleteStep1.php (original)
+++ vtigercrm/trunk/modules/Settings/CurrencyDeleteStep1.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 require_once('include/utils/utils.php');
 
 $delete_currency_id = $_REQUEST['id'];
-$sql = "select * from currency_info where id=".$delete_currency_id;
+$sql = "select * from vtiger_currency_info where id=".$delete_currency_id;
 $result = $adb->query($sql);
 $delete_currencyname = $adb->query_result($result,0,"currency_name");
 
@@ -48,7 +48,7 @@
 $output.='<select class="select" name="transfer_currency_id" id="transfer_currency_id">';
 	     
 		 global $adb;	
-         $sql = "select * from currency_info";
+         $sql = "select * from vtiger_currency_info";
          $result = $adb->query($sql);
          $temprow = $adb->fetch_array($result);
          do

Modified: vtigercrm/trunk/modules/Settings/CurrencyEditView.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/CurrencyEditView.php (original)
+++ vtigercrm/trunk/modules/Settings/CurrencyEditView.php Mon Jun 12 14:26:25 2006
@@ -18,10 +18,10 @@
 if(isset($_REQUEST['record']) && $_REQUEST['record']!='')
 {
         $tempid = $_REQUEST['record'];
-        $sql = "select * from currency_info where id=".$tempid;
+        $sql = "select * from vtiger_currency_info where id=".$tempid;
         $result = $adb->query($sql);
         $currencyResult = $adb->fetch_array($result);
-	$sql1 = "select * from users where currency_id=".$tempid;
+	$sql1 = "select * from vtiger_users where vtiger_currency_id=".$tempid;
 	$result1 = $adb->query($sql1);
 	$noofrows = $adb->num_rows($result1);
 	if($noofrows != 0)

Modified: vtigercrm/trunk/modules/Settings/CurrencyListView.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/CurrencyListView.php (original)
+++ vtigercrm/trunk/modules/Settings/CurrencyListView.php Mon Jun 12 14:26:25 2006
@@ -17,7 +17,7 @@
 $image_path=$theme_path."images/";
 $smarty=new vtigerCRM_Smarty;
    $parenttab = $_REQUEST['parenttab'];
-   $sql = "select * from currency_info";
+   $sql = "select * from vtiger_currency_info";
    $result = $adb->query($sql);
    $temprow = $adb->fetch_array($result);
    $cnt=1;

Modified: vtigercrm/trunk/modules/Settings/DeleteCustomField.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/DeleteCustomField.php (original)
+++ vtigercrm/trunk/modules/Settings/DeleteCustomField.php Mon Jun 12 14:26:25 2006
@@ -19,18 +19,18 @@
 $uitype = $_REQUEST["uitype"];
 
 //Deleting the CustomField from the Custom Field Table
-$query='delete from field where fieldid="'.$id.'"';
+$query='delete from vtiger_field where vtiger_fieldid="'.$id.'"';
 $adb->query($query);
 
-//Deleting from profile2field table
-$query='delete from profile2field where fieldid="'.$id.'"';
+//Deleting from vtiger_profile2field vtiger_table
+$query='delete from vtiger_profile2field where vtiger_fieldid="'.$id.'"';
 $adb->query($query);
 
-//Deleting from def_org_field table
-$query='delete from def_org_field where fieldid="'.$id.'"';
+//Deleting from vtiger_def_org_field vtiger_table
+$query='delete from vtiger_def_org_field where vtiger_fieldid="'.$id.'"';
 $adb->query($query);
 
-//Dropping the column in the module table
+//Dropping the column in the module vtiger_table
 if($fld_module == "Leads")
 {
 	$tableName = "leadscf";
@@ -57,20 +57,20 @@
 }
 //echo '<BR>';
 //echo $tableName;
-$dbquery = 'Alter table '.$tableName.' Drop Column '.$colName;
+$dbquery = 'Alter vtiger_table '.$tableName.' Drop Column '.$colName;
 $adb->query($dbquery);
 
-//Deleting from convert lead mapping table- Jaguar
+//Deleting from convert lead mapping vtiger_table- Jaguar
 if($fld_module=="Leads")
 {
-	$deletequery = 'delete from convertleadmapping where leadfid='.$id;
+	$deletequery = 'delete from vtiger_convertleadmapping where leadfid='.$id;
 	$adb->query($deletequery);
 }
 
 
 if($uitype == 15)
 {
-$deltablequery = 'drop table '.$colName;
+$deltablequery = 'drop vtiger_table '.$colName;
 $adb->query($deltablequery);
 }
 header("Location:index.php?module=Settings&action=CustomFieldList&fld_module=".$fld_module."&parenttab=Settings");

Modified: vtigercrm/trunk/modules/Settings/DeleteLeadCustomFieldMapping.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/DeleteLeadCustomFieldMapping.php (original)
+++ vtigercrm/trunk/modules/Settings/DeleteLeadCustomFieldMapping.php Mon Jun 12 14:26:25 2006
@@ -16,7 +16,7 @@
 
 if($id !='')
 {
-	$sql="update convertleadmapping set accountfid ='NULL',contactfid='NULL',potentialfid='NULL' where cfmid=".$id;
+	$sql="update vtiger_convertleadmapping set vtiger_accountfid ='NULL',contactfid='NULL',potentialfid='NULL' where cfmid=".$id;
 	$result = $adb->query($sql);
 }
 

Modified: vtigercrm/trunk/modules/Settings/DeleteMailAccount.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/DeleteMailAccount.php (original)
+++ vtigercrm/trunk/modules/Settings/DeleteMailAccount.php Mon Jun 12 14:26:25 2006
@@ -21,7 +21,7 @@
 {
 	if($account_id != '')
 	{
-		$query = "update mail_accounts set status=0 where account_id=".$account_id;
+		$query = "update vtiger_mail_accounts set status=0 where vtiger_account_id=".$account_id;
 		$adb->query($query);
 	}
 }

Modified: vtigercrm/trunk/modules/Settings/EditCompanyDetails.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/EditCompanyDetails.php (original)
+++ vtigercrm/trunk/modules/Settings/EditCompanyDetails.php Mon Jun 12 14:26:25 2006
@@ -28,7 +28,7 @@
 			$smarty->assign("ERRORFLAG","<font color='red'><B>Error Message<ul><li><font color='red'>Invalid file OR</font><li><font color='red'>File has no data</font></ul></B></font>");
 			break;
 		case 3:
-			$smarty->assign("ERRORFLAG","<B><font color='red'>Sorry, the uploaded file exceeds the maximum filesize limit. Please try a file smaller than 800000 bytes</font></B>");
+			$smarty->assign("ERRORFLAG","<B><font color='red'>Sorry, the uploaded file exceeds the maximum vtiger_filesize limit. Please try a file smaller than 800000 bytes</font></B>");
 			break;
 		case 4:
 			$smarty->assign("ERRORFLAG","<b>Problems in file upload. Please try again! </b><br>");
@@ -44,7 +44,7 @@
 $image_path=$theme_path."images/";
 require_once($theme_path.'layout_utils.php');
 
-$sql="select * from organizationdetails";
+$sql="select * from vtiger_organizationdetails";
 $result = $adb->query($sql);
 $organization_name = $adb->query_result($result,0,'organizationame');
 $organization_address= $adb->query_result($result,0,'address');

Modified: vtigercrm/trunk/modules/Settings/EditFieldBlock.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/EditFieldBlock.php (original)
+++ vtigercrm/trunk/modules/Settings/EditFieldBlock.php Mon Jun 12 14:26:25 2006
@@ -33,7 +33,7 @@
 	global $adb,$saveNames;
 
 	$b = array();	
-	$sql="select fieldid,fieldlabel,block from field,tab where field.tabid=tab.tabid and tab.tabid=$tabId order by block,sequence";
+	$sql="select vtiger_fieldid,fieldlabel,block from vtiger_field,tab where vtiger_field.tabid=vtiger_tab.tabid and vtiger_tab.tabid=$tabId order by block,sequence";
 	$result = $adb->query($sql);
 	$noofrows = $adb->num_rows($result);
 	
@@ -114,7 +114,7 @@
 		{
 			$item = mysql_escape_string($item);
 			$block  = mysql_escape_string($block);
-			$result = $adb->query("UPDATE field SET `block`='$block',`sequence`='$i' WHERE `fieldid`='$item' $col_check;");
+			$result = $adb->query("UPDATE vtiger_field SET `block`='$block',`sequence`='$i' WHERE `fieldid`='$item' $col_check;");
 			$i ++;
 		}
 	}
@@ -244,7 +244,7 @@
 	?>
 
 	<p align="left">
-		<b>Please review the notes at the bottom for things to keep in mind!<br></b>
+		<b>Please review the vtiger_notes at the bottom for things to keep in mind!<br></b>
 	</p>
 <script language="JavaScript" type="text/javascript" src="include/dd/dd_files/coordinates.js"></script>
 <script language="JavaScript" type="text/javascript" src="include/dd/dd_files/drag.js"></script>
@@ -289,16 +289,16 @@
 	</tr>
 </table>
 <p align="left">
-	1) &nbsp;If you move a field into a currently unused block, you will have to update the appropriate language file in
+	1) &nbsp;If you move a vtiger_field into a currently unused block, you will have to update the appropriate language file in
 	<b>modules/Potentials/language/en_us.lang.php</b>.<br>
-	2) &nbsp;Please see notes on arranging fields below:
+	2) &nbsp;Please see vtiger_notes on arranging vtiger_fields below:
 </p>
 <div align="left">
 	<table border="1" cellpadding="0" cellspacing="0" bordercolordark="white" bordercolorlight="black">
 		<tr>
 			<td width="325" align="right">
 				<p align="center">
-					The tabs are arrange in 2 columns as follows:
+					The vtiger_tabs are arrange in 2 columns as follows:
 				</p>
 			</td>
 			<td width="325" align="right">

Modified: vtigercrm/trunk/modules/Settings/EmailConfig.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/EmailConfig.php (original)
+++ vtigercrm/trunk/modules/Settings/EmailConfig.php Mon Jun 12 14:26:25 2006
@@ -28,7 +28,7 @@
 $image_path=$theme_path."images/";
 require_once($theme_path.'layout_utils.php');
 
-$sql="select * from systems where server_type = 'email'";
+$sql="select * from vtiger_systems where server_type = 'email'";
 $result = $adb->query($sql);
 $mail_server = $adb->query_result($result,0,'server');
 $mail_server_username = $adb->query_result($result,0,'server_username');

Modified: vtigercrm/trunk/modules/Settings/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/Forms.php (original)
+++ vtigercrm/trunk/modules/Settings/Forms.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 /*********************************************************************************
  * $Header$
  * Description:  Contains a variety of utility functions used to display UI
- * components such as form headers and footers.  Intended to be modified on a per
+ * components such as form vtiger_headers and footers.  Intended to be modified on a per
  * theme basis.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
@@ -88,7 +88,7 @@
 }
 
 /**
- * Create HTML form to enter a new record with the minimum necessary fields.
+ * Create HTML form to enter a new record with the minimum necessary vtiger_fields.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
@@ -115,7 +115,7 @@
 $qcreate_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
 
 
-$qcreate_get_field="select * from field where tabid=4 and quickcreate=0 order by quickcreatesequence";
+$qcreate_get_field="select * from vtiger_field where vtiger_tabid=4 and quickcreate=0 order by quickcreatesequence";
 $qcreate_get_result=$adb->query($qcreate_get_field);
 $qcreate_get_noofrows=$adb->num_rows($qcreate_get_result);
 
@@ -203,9 +203,9 @@
 $qcreate_form.='</form>';
 $qcreate_form.='<script type="text/javascript">
 
-        var fieldname = new Array('.$fieldName.')
-        var fieldlabel = new Array('.$fieldLabel.')
-        var fielddatatype = new Array('.$fldDataType.')
+        var vtiger_fieldname = new Array('.$fieldName.')
+        var vtiger_fieldlabel = new Array('.$fieldLabel.')
+        var vtiger_fielddatatype = new Array('.$fldDataType.')
 
                 </script>';
 

Modified: vtigercrm/trunk/modules/Settings/LeadCustomFieldMapping.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/LeadCustomFieldMapping.php (original)
+++ vtigercrm/trunk/modules/Settings/LeadCustomFieldMapping.php Mon Jun 12 14:26:25 2006
@@ -31,7 +31,7 @@
 {
 	global $adb;
 	$accountcf=Array();
-	$sql="select fieldid,fieldlabel from field,tab where field.tabid=tab.tabid and generatedtype=2 and tab.name='Accounts'";
+	$sql="select vtiger_fieldid,fieldlabel from vtiger_field,tab where vtiger_field.tabid=vtiger_tab.tabid and generatedtype=2 and vtiger_tab.name='Accounts'";
 	$result = $adb->query($sql);
 	$noofrows = $adb->num_rows($result);
 	
@@ -54,7 +54,7 @@
 {	
 	global $adb;	
 	$contactcf=Array();
-	$sql="select fieldid,fieldlabel from field,tab where field.tabid=tab.tabid and generatedtype=2 and tab.name='Contacts'";
+	$sql="select vtiger_fieldid,fieldlabel from vtiger_field,tab where vtiger_field.tabid=vtiger_tab.tabid and generatedtype=2 and vtiger_tab.name='Contacts'";
 	$result = $adb->query($sql);
 	$noofrows = $adb->num_rows($result);
 	for($i=0; $i<$noofrows; $i++)
@@ -76,7 +76,7 @@
 {
 	global $adb;	
 	$potentialcf=Array();
-	$sql="select fieldid,fieldlabel from field,tab where field.tabid=tab.tabid and generatedtype=2 and tab.name='Potentials'";
+	$sql="select vtiger_fieldid,fieldlabel from vtiger_field,tab where vtiger_field.tabid=vtiger_tab.tabid and generatedtype=2 and vtiger_tab.name='Potentials'";
 	$result = $adb->query($sql);
 	$noofrows = $adb->num_rows($result);
 	for($i=0; $i<$noofrows; $i++)
@@ -93,7 +93,7 @@
 	$potentialcf[$leadid.'_potential']=$potential_cfelement;
         return $potentialcf;
 }
-$lead_sql="select fieldid,fieldlabel from field,tab where field.tabid=tab.tabid and generatedtype=2 and tab.name='Leads'";
+$lead_sql="select vtiger_fieldid,fieldlabel from vtiger_field,tab where vtiger_field.tabid=vtiger_tab.tabid and generatedtype=2 and vtiger_tab.name='Leads'";
 $result = $adb->query($lead_sql);
 $noofrows = $adb->num_rows($result);
 
@@ -103,7 +103,7 @@
 {
 	$lead_field['fieldid']=$adb->query_result($result,$i,"fieldid");
 	$lead_field['fieldlabel']=$adb->query_result($result,$i,"fieldlabel");
-	$convert_sql="select * from convertleadmapping where leadfid=".$lead_field['fieldid'];
+	$convert_sql="select * from vtiger_convertleadmapping where leadfid=".$lead_field['fieldid'];
 	$convert_result = $adb->query($convert_sql);
 
 	$no_rows = $adb->num_rows($convert_result);

Modified: vtigercrm/trunk/modules/Settings/ListLeadCustomFieldMapping.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/ListLeadCustomFieldMapping.php (original)
+++ vtigercrm/trunk/modules/Settings/ListLeadCustomFieldMapping.php Mon Jun 12 14:26:25 2006
@@ -26,7 +26,7 @@
 function getListLeadMapping($image_path)
 {
 	global $adb;
-	$sql="select * from convertleadmapping";
+	$sql="select * from vtiger_convertleadmapping";
 	$result = $adb->query($sql);
 	$noofrows = $adb->num_rows($result);
 	for($i =0;$i <$noofrows;$i++)
@@ -38,20 +38,20 @@
 		$cfmid = $adb->query_result($result,$i,'cfmid');
 
 		$display_val .= '<tr height="20" class="Datafield">';
-		$sql1="select fieldlabel from field where fieldid ='".$leadid."'";
+		$sql1="select vtiger_fieldlabel from vtiger_field where vtiger_fieldid ='".$leadid."'";
 		$result1 = $adb->query($sql1);
 		$leadfield = $adb->query_result($result1,0,'fieldlabel');
 		$label['leadlabel'] = $leadfield;
-		$sql2="select fieldlabel from field where fieldid ='".$accountid."'";
+		$sql2="select vtiger_fieldlabel from vtiger_field where vtiger_fieldid ='".$accountid."'";
 		$result2 = $adb->query($sql2);
 		$accountfield = $adb->query_result($result2,0,'fieldlabel');
 		$label['accountlabel'] = $accountfield;
 		
-		$sql3="select fieldlabel from field where fieldid ='".$contactid."'";
+		$sql3="select vtiger_fieldlabel from vtiger_field where vtiger_fieldid ='".$contactid."'";
 		$result3 = $adb->query($sql3);
 		$contactfield = $adb->query_result($result3,0,'fieldlabel');
 		$label['contactlabel'] = $contactfield;
-		$sql4="select fieldlabel from field where fieldid ='".$potentialid."'";
+		$sql4="select vtiger_fieldlabel from vtiger_field where vtiger_fieldid ='".$potentialid."'";
 		$result4 = $adb->query($sql4);
 		$potentialfield = $adb->query_result($result4,0,'fieldlabel');
 		$label['potentiallabel'] = $potentialfield;

Modified: vtigercrm/trunk/modules/Settings/ListModuleOwners.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/ListModuleOwners.php (original)
+++ vtigercrm/trunk/modules/Settings/ListModuleOwners.php Mon Jun 12 14:26:25 2006
@@ -27,7 +27,7 @@
 		$tabid = getTabid($val);
 		if($tabid != '' && $userid != '')
 		{
-			$sql = 'update moduleowners set user_id = '.$userid.' where tabid = '.$tabid;
+			$sql = 'update vtiger_moduleowners set user_id = '.$userid.' where vtiger_tabid = '.$tabid;
 			$adb->query($sql);
 		}
 	}
@@ -81,7 +81,7 @@
 function getModuleOwner($tabid)
 {
 	global $adb;
-	$sql = "select * from moduleowners where tabid=".$tabid;
+	$sql = "select * from vtiger_moduleowners where vtiger_tabid=".$tabid;
 	$res = $adb->query($sql);
 	$userid = $adb->query_result($res,0,'user_id');
 
@@ -92,7 +92,7 @@
 {
 	global $adb;
 
-	$sql = "select moduleowners.*, tab.name from moduleowners inner join tab on moduleowners.tabid = tab.tabid order by tab.tabsequence";
+	$sql = "select vtiger_moduleowners.*, vtiger_tab.name from vtiger_moduleowners inner join vtiger_tab on vtiger_moduleowners.tabid = vtiger_tab.tabid order by vtiger_tab.tabsequence";
 	$res = $adb->query($sql);
 	$mod_array = Array();
 	while($row = $adb->fetchByAssoc($res))
@@ -106,7 +106,7 @@
 	global $adb;
 
 	$tabid = getTabid($name);
-	$sql = "select * from moduleowners where tabid=".$tabid;
+	$sql = "select * from vtiger_moduleowners where vtiger_tabid=".$tabid;
 	$res = $adb->query($sql);
 	$db_userid = $adb->query_result($res,0,'user_id');
 	

Modified: vtigercrm/trunk/modules/Settings/OrganizationConfig.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/OrganizationConfig.php (original)
+++ vtigercrm/trunk/modules/Settings/OrganizationConfig.php Mon Jun 12 14:26:25 2006
@@ -35,7 +35,7 @@
 
 $smarty = new vtigerCRM_Smarty;
 
-$sql="select * from organizationdetails";
+$sql="select * from vtiger_organizationdetails";
 $result = $adb->query($sql);
 $organization_name = $adb->query_result($result,0,'organizationame');
 $organization_address= $adb->query_result($result,0,'address');

Modified: vtigercrm/trunk/modules/Settings/PickList.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/PickList.php (original)
+++ vtigercrm/trunk/modules/Settings/PickList.php Mon Jun 12 14:26:25 2006
@@ -48,7 +48,7 @@
 	global $adb;
 	$user_fld = Array();
 	$tabid = getTabid($fldmodule);
-	$query = "select fieldlabel,generatedtype,columnname,fieldname from field where displaytype = 1 and (tabid = ".getTabid($fld_module)." AND uitype IN (15,16)) OR (tabid = ".getTabid($fld_module)." AND fieldname='salutationtype')";
+	$query = "select vtiger_fieldlabel,generatedtype,columnname,fieldname from vtiger_field where displaytype = 1 and (tabid = ".getTabid($fld_module)." AND uitype IN (15,16)) OR (tabid = ".getTabid($fld_module)." AND vtiger_fieldname='salutationtype')";
 	$result = $adb->query($query);
 	$noofrows = $adb->num_rows($result);
     if($noofrows > 0)
@@ -115,7 +115,7 @@
 function getPickListModules()
 {
 	global $adb;
-	$query = 'select distinct field.fieldname,field.tabid,tablabel from field inner join tab on tab.tabid=field.tabid where uitype IN (15,16)';
+	$query = 'select distinct vtiger_field.fieldname,vtiger_field.tabid,tablabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where uitype IN (15,16)';
 	$result = $adb->query($query);
 	while($row = $adb->fetch_array($result))
 	{

Modified: vtigercrm/trunk/modules/Settings/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/Save.php (original)
+++ vtigercrm/trunk/modules/Settings/Save.php Mon Jun 12 14:26:25 2006
@@ -21,17 +21,17 @@
 else
 	$smtp_auth = 'false';
 
-$sql="select * from systems where server_type = '".$server_type."'";
+$sql="select * from vtiger_systems where server_type = '".$server_type."'";
 $id=$adb->query_result($adb->query($sql),0,"id");
 
 
 if($id=='')
 {
 	$id = $adb->getUniqueID("systems");
-	$sql="insert into systems values(" .$id .",'".$server."','".$server_username."','".$server_password."','".$server_type."','".$smtp_auth."')";
+	$sql="insert into vtiger_systems values(" .$id .",'".$server."','".$server_username."','".$server_password."','".$server_type."','".$smtp_auth."')";
 }
 else
-	$sql="update systems set server = '".$server."', server_username = '".$server_username."', server_password = '".$server_password."', smtp_auth='".$smtp_auth."', server_type = '".$server_type."' where id = ".$id;
+	$sql="update vtiger_systems set server = '".$server."', server_username = '".$server_username."', server_password = '".$server_password."', smtp_auth='".$smtp_auth."', server_type = '".$server_type."' where id = ".$id;
 
 $adb->query($sql);
 if($server_type == 'backup')

Modified: vtigercrm/trunk/modules/Settings/SaveCompany.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/SaveCompany.php (original)
+++ vtigercrm/trunk/modules/Settings/SaveCompany.php Mon Jun 12 14:26:25 2006
@@ -22,17 +22,17 @@
 $organization_fax=$_REQUEST['organization_fax'];
 $organization_website=$_REQUEST['organization_website'];
 
-$sql="select * from organizationdetails where organizationame = '".$org_name."'";
+$sql="select * from vtiger_organizationdetails where organizationame = '".$org_name."'";
 $result = $adb->query($sql);
 $org_name = $adb->query_result($result,0,'organizationame');
 
 if($org_name=='')
 {
-	$sql="insert into organizationdetails values( '".$organization_name ."','".$organization_address."','". $organization_city."','".$organization_state."','".$organization_code."','".$organization_country."','".$organization_phone."','".$organization_fax."','".$organization_website."')";
+	$sql="insert into vtiger_organizationdetails values( '".$organization_name ."','".$organization_address."','". $organization_city."','".$organization_state."','".$organization_code."','".$organization_country."','".$organization_phone."','".$organization_fax."','".$organization_website."')";
 }
 else
 {
-	$sql="update organizationdetails set organizationame = '".$organization_name."', address = '".$organization_address."', city = '".$organization_city."', state = '".$organization_state."',  code = '".$organization_code."', country = '".$organization_country."' ,  phone = '".$organization_phone."' ,  fax = '".$organization_fax."',  website = '".$organization_website."' where organizationame = '".$org_name."'";
+	$sql="update vtiger_organizationdetails set organizationame = '".$organization_name."', address = '".$organization_address."', city = '".$organization_city."', state = '".$organization_state."',  code = '".$organization_code."', country = '".$organization_country."' ,  phone = '".$organization_phone."' ,  fax = '".$organization_fax."',  website = '".$organization_website."' where organizationame = '".$org_name."'";
 }	
 
 

Modified: vtigercrm/trunk/modules/Settings/SaveConvertLead.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/SaveConvertLead.php (original)
+++ vtigercrm/trunk/modules/Settings/SaveConvertLead.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 
 //echo"<h3> In Save</h3>";
 	
-	$sql="select fieldid from field, tab where field.tabid=tab.tabid and generatedtype=2 and tab.name='Leads';";	
+	$sql="select vtiger_fieldid from vtiger_field, vtiger_tab where vtiger_field.tabid=vtiger_tab.tabid and generatedtype=2 and vtiger_tab.name='Leads';";	
 //	echo $sql;	
 	$result = $adb->query($sql);
 	$noofrows = $adb->num_rows($result);
@@ -43,7 +43,7 @@
 		{
 			$potential_id_val="";
 		}
-		$update_sql="update convertleadmapping set accountfid='".$account_id_val."',contactfid='".$contact_id_val."',potentialfid='".$potential_id_val."' where leadfid=".$lead_id;
+		$update_sql="update vtiger_convertleadmapping set vtiger_accountfid='".$account_id_val."',contactfid='".$contact_id_val."',potentialfid='".$potential_id_val."' where leadfid=".$lead_id;
 
 		$adb->query($update_sql);
 	}

Modified: vtigercrm/trunk/modules/Settings/SaveCurrencyInfo.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/SaveCurrencyInfo.php (original)
+++ vtigercrm/trunk/modules/Settings/SaveCurrencyInfo.php Mon Jun 12 14:26:25 2006
@@ -20,11 +20,11 @@
 
 if(isset($_REQUEST['record']) && $_REQUEST['record']!='')
 {
-        $sql = "update currency_info set currency_name ='".$currency_name."', currency_code ='".$currency_code."', currency_symbol ='".$currency_symbol."', conversion_rate ='".$conversion_rate."',currency_status='".$currency_status."' where id =".$_REQUEST['record'];
+        $sql = "update vtiger_currency_info set vtiger_currency_name ='".$currency_name."', vtiger_currency_code ='".$currency_code."', vtiger_currency_symbol ='".$currency_symbol."', conversion_rate ='".$conversion_rate."',currency_status='".$currency_status."' where id =".$_REQUEST['record'];
 }
 else
 {
-        $sql = "insert into currency_info values(".$db->getUniqueID("currency_info").",'".$currency_name."','".$currency_code."','".$currency_symbol."','".$conversion_rate."','".$currency_status."','0')";
+        $sql = "insert into vtiger_currency_info values(".$db->getUniqueID("currency_info").",'".$currency_name."','".$currency_code."','".$currency_symbol."','".$conversion_rate."','".$currency_status."','0')";
 }
 $adb->query($sql);
 $loc = "Location: index.php?module=Settings&action=CurrencyListView&parenttab=".$_REQUEST['parenttab'];

Modified: vtigercrm/trunk/modules/Settings/SaveMailAccount.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/SaveMailAccount.php (original)
+++ vtigercrm/trunk/modules/Settings/SaveMailAccount.php Mon Jun 12 14:26:25 2006
@@ -28,17 +28,17 @@
 {
 	$id=$_REQUEST['record'];
 }
-#$sql="select * from systems where server_type = '".$server_type."'";
+#$sql="select * from vtiger_systems where server_type = '".$server_type."'";
 #$id=$adb->query_result($adb->query($sql),0,"id");
 
 if(isset($_REQUEST['edit']) && $_REQUEST['edit'] && $_REQUEST['record']!='')
 {
-	$sql="update mail_accounts set display_name = '".$displayname."', mail_id = '".$email."', account_name = '".$account_name."', mail_protocol = '".$mailprotocol."', mail_username = '".$server_username."', mail_password='".$server_password."', mail_servername='".$mail_servername."',  box_refresh='".$box_refresh."',  mails_per_page='".$mails_per_page."', ssltype='".$ssltype."' , sslmeth='".$sslmeth."', int_mailer='".$_REQUEST["int_mailer"]."' where user_id = '".$id."'";
+	$sql="update vtiger_mail_accounts set display_name = '".$displayname."', mail_id = '".$email."', vtiger_account_name = '".$account_name."', mail_protocol = '".$mailprotocol."', mail_username = '".$server_username."', mail_password='".$server_password."', mail_servername='".$mail_servername."',  box_refresh='".$box_refresh."',  mails_per_page='".$mails_per_page."', ssltype='".$ssltype."' , sslmeth='".$sslmeth."', int_mailer='".$_REQUEST["int_mailer"]."' where user_id = '".$id."'";
 }
 else
 {
 	$account_id = $adb->getUniqueID("mail_accounts");
-	$sql="insert into mail_accounts values(" .$account_id .",'".$current_user->id."','".$displayname."','".$email."','".$account_name."','".$mailprotocol."','".$server_username."','".$server_password."','".$mail_servername."','".$box_refresh."','".$mails_per_page."', '".$ssltype."', '".$sslmeth."', '".$_REQUEST["int_mailer"]."','1','0')";
+	$sql="insert into vtiger_mail_accounts values(" .$account_id .",'".$current_user->id."','".$displayname."','".$email."','".$account_name."','".$mailprotocol."','".$server_username."','".$server_password."','".$mail_servername."','".$box_refresh."','".$mails_per_page."', '".$ssltype."', '".$sslmeth."', '".$_REQUEST["int_mailer"]."','1','0')";
 }
 
 $adb->query($sql);

Modified: vtigercrm/trunk/modules/Settings/SettingsSubMenu.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/SettingsSubMenu.php (original)
+++ vtigercrm/trunk/modules/Settings/SettingsSubMenu.php Mon Jun 12 14:26:25 2006
@@ -88,7 +88,7 @@
 		global $theme;
 		$theme_path="themes/".$theme."/";
 		$image_path=$theme_path."images/";
-		$dbQuery = "select fieldid,columnname,fieldlabel,uitype,displaytype from field where tabid=".$tabid." and generatedtype=2 order by sequence";
+		$dbQuery = "select vtiger_fieldid,columnname,fieldlabel,uitype,displaytype from vtiger_field where vtiger_tabid=".$tabid." and generatedtype=2 order by sequence";
 		$result = $adb->query($dbQuery);
 		$row = $adb->fetch_array($result);
 		$count=1;

Modified: vtigercrm/trunk/modules/Settings/TaxConfig.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/TaxConfig.php (original)
+++ vtigercrm/trunk/modules/Settings/TaxConfig.php Mon Jun 12 14:26:25 2006
@@ -63,7 +63,7 @@
 	
 	foreach($taxes_array as $tax_type)
 	{
-		$res = $adb->query("select * from inventorytaxinfo where taxname=\"$tax_type\"");
+		$res = $adb->query("select * from vtiger_inventorytaxinfo where taxname=\"$tax_type\"");
 		$tax_percentages[$tax_type] = $adb->query_result($res,0,'percentage');	
 	}
 	
@@ -84,7 +84,7 @@
 	foreach($new_percentages as $tax_type => $new_val)
 	{
 		if($new_val != '')
-			$res = $adb->query("update inventorytaxinfo set percentage = \"$new_val\" where taxname=\"$tax_type\"");
+			$res = $adb->query("update vtiger_inventorytaxinfo set percentage = \"$new_val\" where taxname=\"$tax_type\"");
 	}
 
 	$log->debug("Exiting from the function updateTaxPercentages");

Modified: vtigercrm/trunk/modules/Settings/add2db.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/add2db.php (original)
+++ vtigercrm/trunk/modules/Settings/add2db.php Mon Jun 12 14:26:25 2006
@@ -99,7 +99,7 @@
 		if(!isset($organization_logoname))
 			$organization_logoname="";
 
-		$sql="SELECT * FROM organizationdetails WHERE organizationame = ".$adb->quote($org_name);
+		$sql="SELECT * FROM vtiger_organizationdetails WHERE organizationame = ".$adb->quote($org_name);
 		$result = $adb->query($sql);
 		$org_name = $adb->query_result($result,0,'organizationame');
 		$org_logo = $adb->query_result($result,0,'logoname'); 
@@ -107,7 +107,7 @@
 
 		if($org_name=='')
 		{
-			$sql="INSERT INTO organizationdetails
+			$sql="INSERT INTO vtiger_organizationdetails
 				(organizationame, address, city, state, code, country, phone, fax, website, logoname)
 				VALUES (".$adb->quote($organization_name).
 					",".$adb->quote($organization_address).
@@ -142,7 +142,7 @@
 				$organization_logoname=$org_logo;
 			}
 
-			$sql = "UPDATE organizationdetails
+			$sql = "UPDATE vtiger_organizationdetails
 				SET organizationame = ".$adb->quote($organization_name).",
 					address = ".$adb->quote($organization_address).",
 					city = ".$adb->quote($organization_city).",

Modified: vtigercrm/trunk/modules/Settings/downloadfile.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/downloadfile.php (original)
+++ vtigercrm/trunk/modules/Settings/downloadfile.php Mon Jun 12 14:26:25 2006
@@ -17,7 +17,7 @@
 
 $fileid = $_REQUEST['fileid'];
 
-//$dbQuery = "SELECT * from seattachmentsrel where crmid = '" .$fileid ."'";
+//$dbQuery = "SELECT * from vtiger_seattachmentsrel where crmid = '" .$fileid ."'";
 //$attachmentsid = $adb->query_result($adb->query($dbQuery),0,'attachmentsid');
 $attachmentsid = $fileid;
 
@@ -26,7 +26,7 @@
 if($_REQUEST['activity_type']=='Settings')
 	$attachmentsid=$fileid;
 
-$dbQuery = "SELECT * FROM organizationdetails ";
+$dbQuery = "SELECT * FROM vtiger_organizationdetails ";
 
 $result = $adb->query($dbQuery) or die("Couldn't get file list");
 if($adb->num_rows($result) == 1)

Modified: vtigercrm/trunk/modules/Settings/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Settings/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Settings/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -62,7 +62,7 @@
 
 'LBL_EMAIL_ADDRESS'=>'Email',
 
-'LBL_TRANSCURR'=>'Transfer User currency to',
+'LBL_TRANSCURR'=>'Transfer User vtiger_currency to',
 
 'LBL_CURRDEL'=>'Currency to be Deleted',
 
@@ -273,7 +273,7 @@
 'LBL_TOOL'=>'Tool',
 
 
-//Added fields for Title Informations -- after 4 Beta
+//Added vtiger_fields for Title Informations -- after 4 Beta
 
 'LBL_EMAIL_CONFIG'=>'Outgoing Mail Server Configuration',
 
@@ -291,7 +291,7 @@
 
 
 
-//Added fields after RC1 - Release
+//Added vtiger_fields after RC1 - Release
 
 'LBL_MAIL_SERVER_INFO'=>'Mail Server Information',
 
@@ -337,13 +337,13 @@
 
 'LBL_ROLES'=>'Roles',
 
-'LBL_CREATE_AND_MANAGE_USER_ROLES'=>'- Create and Manage user roles (e.g., Administrator, Standard User, etc.)',
+'LBL_CREATE_AND_MANAGE_USER_ROLES'=>'- Create and Manage user vtiger_roles (e.g., Administrator, Standard User, etc.)',
 
 'LBL_PROFILES'=>'Profiles',
 
-'LBL_CREATE_AND_MANAGE_USER_PROFILES'=>'- Create and Manage user profiles (e.g., CEO, Sales Manager, etc.)',
-
-'LBL_CREATE_AND_MANAGE_USER_GROUPS'=>'- Create and Manage user groups',
+'LBL_CREATE_AND_MANAGE_USER_PROFILES'=>'- Create and Manage user vtiger_profiles (e.g., CEO, Sales Manager, etc.)',
+
+'LBL_CREATE_AND_MANAGE_USER_GROUPS'=>'- Create and Manage user vtiger_groups',
 
 'LBL_SHARING_ACCESS'=>'Sharing Access',
 
@@ -357,8 +357,8 @@
 
 'LBL_FIELD_ACCESSIBILITY'=>'Field Accessibility',
 
-'LBL_SETTING_FIELD_ACCESSIBILITY'=>' - Setting Field Accessibility for each profiles',
-//<<<<<<<<for edit ordering blocks>>>>>>
+'LBL_SETTING_FIELD_ACCESSIBILITY'=>' - Setting Field Accessibility for each vtiger_profiles',
+//<<<<<<<<for edit ordering vtiger_blocks>>>>>>
 'LBL_FIELD_ORDERING_DESC'=>' - Edit Field Order',
 
 'LBL_FIELD_ORDERING'=>'Edit Field Blocks',
@@ -393,7 +393,7 @@
 
 'LBL_CUSTOM_FIELD_SETTINGS'=>'Custom Field Settings',
 
-'LBL_CREATE_AND_MANAGE_USER_DEFINED_FIELDS'=>'Create and Manage user defined fields...',
+'LBL_CREATE_AND_MANAGE_USER_DEFINED_FIELDS'=>'Create and Manage user defined vtiger_fields...',
 
 'LBL_SELECT_MODULE'=>'Select Module',
 
@@ -403,7 +403,7 @@
 
 'LBL_PICKLIST_SETTINGS'=>'Picklist Settings',
 
-'LBL_EDIT_PICKLIST_VALUES'=>' - Edit values of Picklist fields',
+'LBL_EDIT_PICKLIST_VALUES'=>' - Edit values of Picklist vtiger_fields',
 
 'LBL_EDIT'=>'Editing',
 
@@ -433,7 +433,7 @@
 
 
 
-//Field Types for custom fields
+//Field Types for custom vtiger_fields
 
 'LBL_URL'=>'URL',
 
@@ -487,10 +487,10 @@
 'LBL_LIST_PASSWORD'=>'Password',
 'LBL_MAIL_SERVER_NAME'=>'Mail Server Name or IP',
 'LBL_MAIL_SERVER_SETTINGS'=>'Mail Server Settings',
-'LBL_TEST_SETTINGS'=>'Test my account setting immediately',
-'LBL_TEST_BUTTON_TITLE'=>'Test my account now! [Alt+T]',
+'LBL_TEST_SETTINGS'=>'Test my vtiger_account setting immediately',
+'LBL_TEST_BUTTON_TITLE'=>'Test my vtiger_account now! [Alt+T]',
 'LBL_TEST_BUTTON_KEY'=>'T',
-'LBL_TEST_BUTTON_LABEL'=>'Test my account now!',
+'LBL_TEST_BUTTON_LABEL'=>'Test my vtiger_account now!',
 'LBL_DEFAULT'=>'Default',
 'LBL_IMAP2'=>'IMAP2',
 'LBL_IMAP4'=>'IMAP4',
@@ -573,8 +573,8 @@
 
 //For Custom Fields
 'LBL_LEAD_MAP_CUSTOM_FIELD'=>'Mapping Lead Custom Fields',
-'leadCustomFieldDescription'=>'Map each of your organizations lead custom fields to each of your custom account
-,contact, or potential fields. These mappings will be used when you convert leads',
+'leadCustomFieldDescription'=>'Map each of your organizations lead custom vtiger_fields to each of your custom vtiger_account
+,contact, or vtiger_potential vtiger_fields. These mappings will be used when you convert leads',
 'LBL_MAPPING_INFO'=>'Mapping Information',
 'LBL_ACCOUNT_FIELD'=>'Account Custom Field',
 'LBL_CONTACT_FIELD'=>'Contact Custom Field',
@@ -584,10 +584,10 @@
 'LBL_LEAD_FIELD'=>'Lead Custom Field',
 //After 4.2 GA
 'LBL_TEXT_AREA'=>'Text Area',
-//for Edit ordering the blocks
+//for Edit ordering the vtiger_blocks
 'NOTESCUSTOMFIELDS'=>'Notes Custom Fields',
 
-//Added fields after 4.2 ptach 2
+//Added vtiger_fields after 4.2 ptach 2
 'LBL_ASSIGN_MODULE_OWNERS'=>'Assign Module Owners',
 'LBL_MODULE_OWNERS'=>'Module Owners',
 'LBL_ASSIGN_MODULE_OWNERS_INFO'=>' - Assign Owners for each modules',
@@ -601,12 +601,12 @@
 'LBL_USER_DESCRIPTION'=>'Manage Users list who access CRM',
 'LBL_ROLE_DESCRIPTION'=>'Define hierarchy of Roles and assign to Users',
 'LBL_PROFILE_DESCRIPTION'=>'Define Profiles to provide access rights to each Role',
-'LBL_GROUP_DESCRIPTION'=>'Define Groups based on roles, users, profiles etc',
+'LBL_GROUP_DESCRIPTION'=>'Define Groups based on vtiger_roles, vtiger_users, vtiger_profiles etc',
 'LBL_SHARING_ACCESS_DESCRIPTION'=>'Define privileges for each Role to access CRM modules',
-'LBL_SHARING_FIELDS_DESCRIPTION'=>'Show or hide fields in each CRM Module',
+'LBL_SHARING_FIELDS_DESCRIPTION'=>'Show or hide vtiger_fields in each CRM Module',
 'LBL_MODULE_OWNERS_DESCRIPTION'=>'Assign Owners for each CRM module',
 'LBL_ANNOUNCEMENT_DESCRIPTION'=>'Edit the contents of Announcements display',
-'LBL_CUSTOM_FIELDS_DESCRIPTION'=>'Create and Manage user-defined fields',
+'LBL_CUSTOM_FIELDS_DESCRIPTION'=>'Create and Manage user-defined vtiger_fields',
 'LBL_PICKLIST_DESCRIPTION'=>'Manage contents of Picklists in all CRM Modules',
 'LBL_EMAIL_TEMPLATE_DESCRIPTION'=>'Manage templates for E-Mail module',
 'LBL_MAIL_MERGE_DESCRIPTION'=>'Manage templates for Mail Merging',
@@ -621,11 +621,11 @@
 
 
 
-//Added fields after 5.0 Alpha
+//Added vtiger_fields after 5.0 Alpha
 'LBL_REQUIRE_SMTP_AUTHENTICATION'=>'Require SMTP Authentication?',
 'LBL_ANNOUNCEMENT'=>'Announcements',
 'LBL_SETTING_ANNOUNCEMENT'=>'Announcement',
-'LBL_ANNOUNCEMENT_INFO'=>'Type the announcement text below, and click the save button.',
+'LBL_ANNOUNCEMENT_INFO'=>'Type the vtiger_announcement text below, and click the save button.',
 'LBL_EMAIL_CONTENTS'=>'Email Contents',
 'LBL_SUBJECT'=>'Subject',
 'LBL_MESSAGE'=>'Message',

Modified: vtigercrm/trunk/modules/Users/Announcements.php
==============================================================================
--- vtigercrm/trunk/modules/Users/Announcements.php (original)
+++ vtigercrm/trunk/modules/Users/Announcements.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 global $theme;
 $theme_path="themes/".$theme."/";
 $image_path=$theme_path."images/";
-$query="select * from announcement where creatorid=".$current_user->id;
+$query="select * from vtiger_announcement where creatorid=".$current_user->id;
 $result=$adb->query($query);
 $announcement=$adb->query_result($result,0,'announcement');
 $title_prev=$adb->query_result($result,0,'title');

Modified: vtigercrm/trunk/modules/Users/Authenticate.php
==============================================================================
--- vtigercrm/trunk/modules/Users/Authenticate.php (original)
+++ vtigercrm/trunk/modules/Users/Authenticate.php Mon Jun 12 14:26:25 2006
@@ -55,7 +55,7 @@
 	//$rolename = fetchUserRole($focus->id);
 	//$profilename = fetchUserProfile($focus->id);
 	$profileid = fetchUserProfileId($focus->id);	
-	//setting the role into the session
+	//setting the vtiger_role into the session
 	//$_SESSION['authenticated_user_roleid'] = $profilename;
 
 	//Setting the Object in Session
@@ -128,7 +128,7 @@
         $log->debug("app_unique_key is $application_unique_key");
 
 	
-// Clear all uploaded import files for this user if it exists
+// Clear all uploaded import vtiger_files for this user if it exists
 
 	global $import_dir;
 

Modified: vtigercrm/trunk/modules/Users/ChangePassword.php
==============================================================================
--- vtigercrm/trunk/modules/Users/ChangePassword.php (original)
+++ vtigercrm/trunk/modules/Users/ChangePassword.php Mon Jun 12 14:26:25 2006
@@ -88,17 +88,17 @@
 <?php if (!is_admin($current_user)) {
 	echo "<tr>";
 	echo "<td width='40%' class='dvtCellLabel' align='right'><b>".$mod_strings['LBL_OLD_PASSWORD']."</b></td>\n";
-	echo "<td width='60%' class='dvtCellInfo'><input name='old_password' type='password' tabindex='1' size='15' maxlength='15'></td>\n";
+	echo "<td width='60%' class='dvtCellInfo'><input name='old_password' type='password' vtiger_tabindex='1' size='15' maxlength='15'></td>\n";
 	echo "<input name='is_admin' type='hidden' value='1'>";
 	echo "</tr><tr>\n";
 }
 else echo "<input name='old_password' type='hidden'><input name='is_admin' type='hidden' value='0'>";
 ?>
 <td width='40%' class='dvtCellLabel' nowrap align="right"><b><?php echo $mod_strings['LBL_NEW_PASSWORD']; ?></b></td>
-<td width='60%' class='dvtCellInfo'><input name='new_password' type='password' tabindex='1' size='15' maxlength='15'></td>
+<td width='60%' class='dvtCellInfo'><input name='new_password' type='password' vtiger_tabindex='1' size='15' maxlength='15'></td>
 </tr><tr>
 <td width='40%' class='dvtCellLabel' nowrap align="right"><b><?php echo $mod_strings['LBL_CONFIRM_PASSWORD']; ?></b></td>
-<td width='60%' class='dvtCellInfo'><input name='confirm_new_password' type='password' tabindex='1' size='15' maxlength='15'></td>
+<td width='60%' class='dvtCellInfo'><input name='confirm_new_password' type='password' vtiger_tabindex='1' size='15' maxlength='15'></td>
 </tr><tr>
 <td width='40%' class='dataLabel'></td>
 <td width='60%' class='dvtCellInfo'></td>

Modified: vtigercrm/trunk/modules/Users/CreateProfile.php
==============================================================================
--- vtigercrm/trunk/modules/Users/CreateProfile.php (original)
+++ vtigercrm/trunk/modules/Users/CreateProfile.php Mon Jun 12 14:26:25 2006
@@ -33,7 +33,7 @@
 if(isset($_REQUEST['profileid']) && $_REQUEST['profileid'] != '')
 {
 	global $adb;	
-	$sql = "select * from profile where profileid=".$_REQUEST['profileid'];
+	$sql = "select * from vtiger_profile where vtiger_profileid=".$_REQUEST['profileid'];
 	$profileResult = $adb->query($sql);
 	$profile_name = $adb->query_result($profileResult,0,"profilename");
 	$profile_description = $adb->query_result($profileResult,0,"description");

Modified: vtigercrm/trunk/modules/Users/CreateProfile1.php
==============================================================================
--- vtigercrm/trunk/modules/Users/CreateProfile1.php (original)
+++ vtigercrm/trunk/modules/Users/CreateProfile1.php Mon Jun 12 14:26:25 2006
@@ -18,7 +18,7 @@
 
 if(isset($_REQUEST['dup_check']) && $_REQUEST['dup_check']!='')
 {
-        $query = 'select profilename from profile where profilename="'.$profilename.'"';
+        $query = 'select vtiger_profilename from vtiger_profile where vtiger_profilename="'.$profilename.'"';
         $result = $adb->query($query);
 
         if($adb->num_rows($result) > 0)
@@ -55,7 +55,7 @@
 $smarty->assign("APP", $app_strings);
 $smarty->assign("CMOD", $mod_strings);
 
-$sql = "select * from profile";
+$sql = "select * from vtiger_profile";
 $result = $adb->query($sql);
 $profilelist = array();
 $temprow = $adb->fetch_array($result);

Modified: vtigercrm/trunk/modules/Users/CreateUserPrivilegeFile.php
==============================================================================
--- vtigercrm/trunk/modules/Users/CreateUserPrivilegeFile.php (original)
+++ vtigercrm/trunk/modules/Users/CreateUserPrivilegeFile.php Mon Jun 12 14:26:25 2006
@@ -132,7 +132,7 @@
 
 			//Constructing the Related Module Sharing Array
 			$relModSharArr=Array();	
-			$query ="select * from datashare_relatedmodules";
+			$query ="select * from vtiger_datashare_relatedmodules";
                 	$result=$adb->query($query);
                 	$num_rows = $adb->num_rows($result);
                 	for($i=0;$i<$num_rows;$i++)
@@ -390,8 +390,8 @@
 		$rs_write_per=Array();
 		$grp_read_per=Array();
 		$grp_write_per=Array();
-		//Retreiving from role to role
-		$query="select datashare_role2role.* from datashare_role2role inner join datashare_module_rel on datashare_module_rel.shareid=datashare_role2role.shareid where datashare_module_rel.tabid=".$mod_tabid." and datashare_role2role.to_roleid='".$current_user_roles."'";
+		//Retreiving from vtiger_role to vtiger_role
+		$query="select vtiger_datashare_role2role.* from vtiger_datashare_role2role inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_role2role.shareid where vtiger_datashare_module_rel.tabid=".$mod_tabid." and vtiger_datashare_role2role.to_roleid='".$current_user_roles."'";
 		$result=$adb->query($query);
 		$num_rows=$adb->num_rows($result);
 		for($i=0;$i<$num_rows;$i++)
@@ -439,14 +439,14 @@
 
 
 
-		//Retreiving from role to rs
+		//Retreiving from vtiger_role to rs
 		$parRoleList = "(";
 		foreach($parent_roles as $par_role_id)
 		{
 			$parRoleList .= "'".$par_role_id."',";		
 		}
 		$parRoleList .= "'".$current_user_roles."')";
-		$query="select datashare_role2rs.* from datashare_role2rs inner join datashare_module_rel on datashare_module_rel.shareid=datashare_role2rs.shareid where datashare_module_rel.tabid=".$mod_tabid." and datashare_role2rs.to_roleandsubid in ".$parRoleList;
+		$query="select vtiger_datashare_role2rs.* from vtiger_datashare_role2rs inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_role2rs.shareid where vtiger_datashare_module_rel.tabid=".$mod_tabid." and vtiger_datashare_role2rs.to_roleandsubid in ".$parRoleList;
 		$result=$adb->query($query);
 		$num_rows=$adb->num_rows($result);
 		for($i=0;$i<$num_rows;$i++)
@@ -493,7 +493,7 @@
 		}
 
 
-		//Get roles from Role2Grp
+		//Get vtiger_roles from Role2Grp
 		$grpIterator=false;
 		$groupList = "(";
 		foreach($current_user_groups as $grp_id)
@@ -507,7 +507,7 @@
 		}
 		$groupList .= ")";
 
-		$query="select datashare_role2group.* from datashare_role2group inner join datashare_module_rel on datashare_module_rel.shareid=datashare_role2group.shareid where datashare_module_rel.tabid=".$mod_tabid." and datashare_role2group.to_groupid in ".$groupList;
+		$query="select vtiger_datashare_role2group.* from vtiger_datashare_role2group inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_role2group.shareid where vtiger_datashare_module_rel.tabid=".$mod_tabid." and vtiger_datashare_role2group.to_groupid in ".$groupList;
 		$result=$adb->query($query);
 		$num_rows=$adb->num_rows($result);
 		for($i=0;$i<$num_rows;$i++)
@@ -554,8 +554,8 @@
 
 
 
-		//Retreiving from rs to role
-		$query="select datashare_rs2role.* from datashare_rs2role inner join datashare_module_rel on datashare_module_rel.shareid=datashare_rs2role.shareid where datashare_module_rel.tabid=".$mod_tabid." and datashare_rs2role.to_roleid='".$current_user_roles."'";
+		//Retreiving from rs to vtiger_role
+		$query="select vtiger_datashare_rs2role.* from vtiger_datashare_rs2role inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_rs2role.shareid where vtiger_datashare_module_rel.tabid=".$mod_tabid." and vtiger_datashare_rs2role.to_roleid='".$current_user_roles."'";
 		$result=$adb->query($query);
 		$num_rows=$adb->num_rows($result);
 		for($i=0;$i<$num_rows;$i++)
@@ -614,7 +614,7 @@
 			$parRoleList .= "'".$par_role_id."',";		
 		}
 		$parRoleList .= "'".$current_user_roles."')";
-		$query="select datashare_rs2rs.* from datashare_rs2rs inner join datashare_module_rel on datashare_module_rel.shareid=datashare_rs2rs.shareid where datashare_module_rel.tabid=".$mod_tabid." and datashare_rs2rs.to_roleandsubid in ".$parRoleList;
+		$query="select vtiger_datashare_rs2rs.* from vtiger_datashare_rs2rs inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_rs2rs.shareid where vtiger_datashare_module_rel.tabid=".$mod_tabid." and vtiger_datashare_rs2rs.to_roleandsubid in ".$parRoleList;
 		$result=$adb->query($query);
 		$num_rows=$adb->num_rows($result);
 		for($i=0;$i<$num_rows;$i++)
@@ -666,10 +666,10 @@
 		}
 
 
-		//Get roles from Rs2Grp
-
-
-		$query="select datashare_rs2grp.* from datashare_rs2grp inner join datashare_module_rel on datashare_module_rel.shareid=datashare_rs2grp.shareid where datashare_module_rel.tabid=".$mod_tabid." and datashare_rs2grp.to_groupid in ".$groupList;
+		//Get vtiger_roles from Rs2Grp
+
+
+		$query="select vtiger_datashare_rs2grp.* from vtiger_datashare_rs2grp inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_rs2grp.shareid where vtiger_datashare_module_rel.tabid=".$mod_tabid." and vtiger_datashare_rs2grp.to_groupid in ".$groupList;
 		$result=$adb->query($query);
 		$num_rows=$adb->num_rows($result);
 		for($i=0;$i<$num_rows;$i++)
@@ -726,7 +726,7 @@
 		$mod_share_write_permission['ROLE']=$role_write_per;
 		
 		//Retreiving from the grp2role sharing
-		$query="select datashare_grp2role.* from datashare_grp2role inner join datashare_module_rel on datashare_module_rel.shareid=datashare_grp2role.shareid where datashare_module_rel.tabid=".$mod_tabid." and datashare_grp2role.to_roleid='".$current_user_roles."'";
+		$query="select vtiger_datashare_grp2role.* from vtiger_datashare_grp2role inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_grp2role.shareid where vtiger_datashare_module_rel.tabid=".$mod_tabid." and vtiger_datashare_grp2role.to_roleid='".$current_user_roles."'";
 		$result=$adb->query($query);
 		$num_rows=$adb->num_rows($result);
 		for($i=0;$i<$num_rows;$i++)
@@ -817,7 +817,7 @@
 		//Retreiving from the grp2rs sharing
 
 
-		$query="select datashare_grp2rs.* from datashare_grp2rs inner join datashare_module_rel on datashare_module_rel.shareid=datashare_grp2rs.shareid where datashare_module_rel.tabid=".$mod_tabid." and datashare_grp2rs.to_roleandsubid in ".$parRoleList;
+		$query="select vtiger_datashare_grp2rs.* from vtiger_datashare_grp2rs inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_grp2rs.shareid where vtiger_datashare_module_rel.tabid=".$mod_tabid." and vtiger_datashare_grp2rs.to_roleandsubid in ".$parRoleList;
 		$result=$adb->query($query);
 		$num_rows=$adb->num_rows($result);
 		for($i=0;$i<$num_rows;$i++)
@@ -907,7 +907,7 @@
 
 		//Retreiving from the grp2grp sharing
 
-		$query="select datashare_grp2grp.* from datashare_grp2grp inner join datashare_module_rel on datashare_module_rel.shareid=datashare_grp2grp.shareid where datashare_module_rel.tabid=".$mod_tabid." and datashare_grp2grp.to_groupid in ".$groupList;
+		$query="select vtiger_datashare_grp2grp.* from vtiger_datashare_grp2grp inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_grp2grp.shareid where vtiger_datashare_module_rel.tabid=".$mod_tabid." and vtiger_datashare_grp2grp.to_groupid in ".$groupList;
 		$result=$adb->query($query);
 		$num_rows=$adb->num_rows($result);
 		for($i=0;$i<$num_rows;$i++)
@@ -1031,7 +1031,7 @@
 
 		foreach($mod_sharingrule_members as $sharingid => $sharingInfoArr)
 		{
-			$query = "select datashare_relatedmodule_permission.* from datashare_relatedmodule_permission inner join datashare_relatedmodules on datashare_relatedmodules.datashare_relatedmodule_id=datashare_relatedmodule_permission.datashare_relatedmodule_id where datashare_relatedmodule_permission.shareid=".$sharingid." and datashare_relatedmodules.tabid=".$par_mod_id." and datashare_relatedmodules.relatedto_tabid=".$share_mod_id;
+			$query = "select vtiger_datashare_relatedmodule_permission.* from vtiger_datashare_relatedmodule_permission inner join vtiger_datashare_relatedmodules on vtiger_datashare_relatedmodules.datashare_relatedmodule_id=vtiger_datashare_relatedmodule_permission.datashare_relatedmodule_id where vtiger_datashare_relatedmodule_permission.shareid=".$sharingid." and vtiger_datashare_relatedmodules.tabid=".$par_mod_id." and vtiger_datashare_relatedmodules.relatedto_tabid=".$share_mod_id;
 			$result = $adb->query($query);
 			$share_permission=$adb->query_result($result,0,'permission');	
 
@@ -1410,7 +1410,7 @@
 {
 	global $adb;
 	require('user_privileges/sharing_privileges_'.$userid.'.php');
-	//Deleting from the existing tables
+	//Deleting from the existing vtiger_tables
 	$table_arr=Array('tmp_read_user_sharing_per', 'tmp_write_user_sharing_per','tmp_read_group_sharing_per','tmp_write_group_sharing_per','tmp_read_user_rel_sharing_per','tmp_write_user_rel_sharing_per','tmp_read_group_rel_sharing_per','tmp_write_group_rel_sharing_per');
 	foreach($table_arr as $tabname)
 	{
@@ -1418,7 +1418,7 @@
 		$adb->query($query);
 	}
 
-	//Populating Values into the tmp sharing tables
+	//Populating Values into the tmp sharing vtiger_tables
 	$sharingArray=Array('Leads','Accounts','Contacts','Potentials','HelpDesk','Emails','Campaigns','Quotes','PurchaseOrder','SalesOrder','Invoice');
 	foreach($sharingArray as $module)
 	{
@@ -1427,7 +1427,7 @@
 		populateSharingPrivileges('GROUP',$userid,$module,'read');
 		populateSharingPrivileges('GROUP',$userid,$module,'write');
 	}
-	//Populating Values into the temp related sharing tables
+	//Populating Values into the temp related sharing vtiger_tables
 	foreach($related_module_share as $rel_tab_id => $tabid_arr)
 	{
 		$rel_tab_name=getTabname($rel_tab_id);

Modified: vtigercrm/trunk/modules/Users/DefaultDataPopulator.php
==============================================================================
--- vtigercrm/trunk/modules/Users/DefaultDataPopulator.php (original)
+++ vtigercrm/trunk/modules/Users/DefaultDataPopulator.php Mon Jun 12 14:26:25 2006
@@ -1,2118 +1,2118 @@
-<?php
-
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
- ********************************************************************************/
-
-include_once('config.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-require_once('data/SugarBean.php');
-require_once('data/CRMEntity.php');
-require_once('include/utils/utils.php');
-
-class DefaultDataPopulator extends CRMEntity {
-		
-	function DefaultDataPopulator() {
-		$this->log = LoggerManager::getLogger('DefaultDataPopulator');
-		$this->db = new PearDatabase();
-	}
-
-	var $new_schema = true;
-
-	function create_tables () {
-		global $app_strings;
-
-		$role1_id = $this->db->getUniqueID("role");
-		$role2_id = $this->db->getUniqueID("role");
-		$role3_id = $this->db->getUniqueID("role");
-
-		$profile1_id = $this->db->getUniqueID("profile");
-		$profile2_id = $this->db->getUniqueID("profile");
-		$profile3_id = $this->db->getUniqueID("profile");
-		$profile4_id = $this->db->getUniqueID("profile");
-
-                $this->db->query("insert into role values('H".$role1_id."','Organisation','H".$role1_id."',0)");
-                $this->db->query("insert into role values('H".$role2_id."','administrator','H".$role1_id."::H".$role2_id."',1)");
-                $this->db->query("insert into role values('H".$role3_id."','standard_user','H".$role1_id."::H".$role2_id."::H".$role3_id."',2)");
-                
-
- $this->db->query("INSERT INTO tab VALUES (3,'Home',0,1,'Home',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (7,'Leads',0,4,'Leads',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (6,'Accounts',0,5,'Accounts',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (4,'Contacts',0,6,'Contacts',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (2,'Potentials',0,7,'Potentials',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (8,'Notes',0,9,'Notes',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (9,'Activities',0,3,'Activities',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (10,'Emails',0,10,'Emails',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (13,'HelpDesk',0,11,'HelpDesk',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (14,'Products',0,8,'Products',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (1,'Dashboard',0,12,'Dashboards',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (15,'Faq',0,14,'Faq',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (16,'Events',2,13,'Events',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (17,'Calendar',0,2,'Calendar',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (18,'Vendors',0,15,'Vendors',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (19,'PriceBooks',0,16,'PriceBooks',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (20,'Quotes',0,17,'Quotes',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (21,'PurchaseOrder',0,18,'PurchaseOrder',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (22,'SalesOrder',0,19,'SalesOrder',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (23,'Invoice',0,20,'Invoice',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (24,'Rss',0,21,'Rss',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (25,'Reports',0,22,'Reports',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (26,'Campaigns',0,23,'Campaigns',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (27,'Portal',0,24,'Portal',null,null,1)");
- $this->db->query("INSERT INTO tab VALUES (28,'Webmails',0,25,'Webmails',null,null,1)");
-
-// Populate the blocks table
-$this->db->query("insert into blocks values (1,2,'LBL_OPPORTUNITY_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (2,2,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
-$this->db->query("insert into blocks values (3,2,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)");
-$this->db->query("insert into blocks values (4,4,'LBL_CONTACT_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (5,4,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
-$this->db->query("insert into blocks values (6,4,'LBL_CUSTOMER_PORTAL_INFORMATION',3,0,0,0,0,0)");
-$this->db->query("insert into blocks values (7,4,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0)");
-$this->db->query("insert into blocks values (8,4,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)");
-$this->db->query("insert into blocks values (9,6,'LBL_ACCOUNT_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (10,6,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
-$this->db->query("insert into blocks values (11,6,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)");
-$this->db->query("insert into blocks values (12,6,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)");
-$this->db->query("insert into blocks values (13,7,'LBL_LEAD_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (14,7,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
-$this->db->query("insert into blocks values (15,7,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)");
-$this->db->query("insert into blocks values (16,7,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)");
-$this->db->query("insert into blocks values (17,8,'LBL_NOTE_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (18,8,'',2,1,0,0,0,0)");
-$this->db->query("insert into blocks values (19,9,'LBL_TASK_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (20,9,'',2,1,0,0,0,0)");
-$this->db->query("insert into blocks values (21,10,'LBL_EMAIL_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (22,10,'',2,1,0,0,0,0)");
-$this->db->query("insert into blocks values (23,10,'',3,1,0,0,0,0)");
-$this->db->query("insert into blocks values (24,10,'',4,1,0,0,0,0)");
-$this->db->query("insert into blocks values (25,13,'LBL_TICKET_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (26,13,'',2,1,0,0,0,0)");
-$this->db->query("insert into blocks values (27,13,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0)");
-$this->db->query("insert into blocks values (28,13,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)");
-$this->db->query("insert into blocks values (29,13,'LBL_TICKET_RESOLUTION',5,0,0,1,0,0)");
-$this->db->query("insert into blocks values (30,13,'LBL_COMMENTS',6,0,0,1,0,0)");
-$this->db->query("insert into blocks values (31,14,'LBL_PRODUCT_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (32,14,'LBL_PRICING_INFORMATION',2,0,0,0,0,0)");
-$this->db->query("insert into blocks values (33,14,'LBL_STOCK_INFORMATION',3,0,0,0,0,0)");
-$this->db->query("insert into blocks values (34,14,'LBL_CUSTOM_INFORMATION',4,0,0,0,0,0)");
-$this->db->query("insert into blocks values (35,14,'LBL_IMAGE_INFORMATION',5,0,0,0,0,0)");
-$this->db->query("insert into blocks values (36,14,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)");
-$this->db->query("insert into blocks values (37,15,'LBL_FAQ_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (38,15,'',2,1,0,0,0,0)");
-$this->db->query("insert into blocks values (39,15,'',3,1,0,0,0,0)");
-$this->db->query("insert into blocks values (40,15,'LBL_COMMENT_INFORMATION',4,0,0,1,0,0)");
-$this->db->query("insert into blocks values (41,16,'LBL_EVENT_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (42,16,'',2,1,0,0,0,0)");
-$this->db->query("insert into blocks values (43,16,'',3,1,0,0,0,0)");
-$this->db->query("insert into blocks values (44,18,'LBL_VENDOR_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (45,18,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
-$this->db->query("insert into blocks values (46,18,'LBL_VENDOR_ADDRESS_INFORMATION',3,0,0,0,0,0)");
-$this->db->query("insert into blocks values (47,18,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)");
-$this->db->query("insert into blocks values (48,19,'LBL_PRICEBOOK_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (49,19,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
-$this->db->query("insert into blocks values (50,19,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)");
-$this->db->query("insert into blocks values (51,20,'LBL_QUOTE_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (52,20,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
-$this->db->query("insert into blocks values (53,20,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)");
-$this->db->query("insert into blocks values (54,20,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)");
-$this->db->query("insert into blocks values (55,20,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)");
-$this->db->query("insert into blocks values (56,20,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)");
-$this->db->query("insert into blocks values (57,21,'LBL_PO_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (58,21,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
-$this->db->query("insert into blocks values (59,21,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)");
-$this->db->query("insert into blocks values (60,21,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)");
-$this->db->query("insert into blocks values (61,21,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)");
-$this->db->query("insert into blocks values (62,21,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)");
-$this->db->query("insert into blocks values (63,22,'LBL_SO_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (64,22,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
-$this->db->query("insert into blocks values (65,22,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)");
-$this->db->query("insert into blocks values (66,22,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)");
-$this->db->query("insert into blocks values (67,22,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)");
-$this->db->query("insert into blocks values (68,22,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)");
-$this->db->query("insert into blocks values (69,23,'LBL_INVOICE_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (70,23,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
-$this->db->query("insert into blocks values (71,23,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)");
-$this->db->query("insert into blocks values (72,23,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)");
-$this->db->query("insert into blocks values (73,23,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)");
-$this->db->query("insert into blocks values (74,23,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)");
-$this->db->query("insert into blocks values (75,4,'LBL_IMAGE_INFORMATION',5,0,0,0,0,0)");
-$this->db->query("insert into blocks values (76,26,'LBL_CAMPAIGN_INFORMATION',1,0,0,0,0,0)");
-$this->db->query("insert into blocks values (77,26,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
-$this->db->query("insert into blocks values (78,26,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)");
-
-//
-
-//Account Details -- START
- //Block9
-
-$this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'accountname','account',1,'2','accountname','Account Name',1,0,0,100,1,9,1,'V~M',0,1,'BAS')");	
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'phone','account',1,'11','phone','Phone',1,0,0,100,2,9,1,'V~O',0,2,'BAS')");	
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'website','account',1,'17','website','Website',1,0,0,100,3,9,1,'V~O',0,3,'BAS')");	
-
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'fax','account',1,'1','fax','Fax',1,0,0,100,4,9,1,'V~O',1,null,'BAS')");	
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'tickersymbol','account',1,'1','tickersymbol','Ticker Symbol',1,0,0,100,5,9,1,'V~O',1,null,'BAS')");	
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'otherphone','account',1,'11','otherphone','Other Phone',1,0,0,100,6,9,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'parentid','account',1,'51','account_id','Member Of',1,0,0,100,7,9,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'email1','account',1,'13','email1','Email',1,0,0,100,8,9,1,'E~O',1,null,'BAS')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'employees','account',1,'7','employees','Employees',1,0,0,100,9,9,1,'I~O',1,null,'ADV')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'email2','account',1,'13','email2','Other Email',1,0,0,100,10,9,1,'E~O',1,null,'ADV')");
-
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'ownership','account',1,'1','ownership','Ownership',1,0,0,100,11,9,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'rating','account',1,'1','rating','Rating',1,0,0,100,12,9,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'industry','account',1,'15','industry','industry',1,0,0,100,13,9,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'siccode','account',1,'1','siccode','SIC Code',1,0,0,100,14,9,1,'I~O',1,null,'ADV')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'account_type','account',1,'15','accounttype','Type',1,0,0,100,15,9,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'annualrevenue','account',1,'71','annual_revenue','Annual Revenue',1,0,0,100,16,9,1,'I~O',1,null,'ADV')");
- //Added field emailoptout for accounts -- after 4.2 patch2
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'emailoptout','account',1,'56','emailoptout','Email Opt Out',1,0,0,100,17,9,1,'C~O',1,null,'ADV')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'notify_owner','account',1,56,'notify_owner','Notify Owner',1,0,0,10,18,9,1,'C~O',1,NULL,'ADV')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,19,9,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,20,9,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,21,9,2,'T~O',1,null,'BAS')");
-
-
-
-
- //Block 11
-$this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'street','accountbillads',1,'21','bill_street','Billing Address',1,0,0,100,1,11,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'street','accountshipads',1,'21','ship_street','Shipping Address',1,0,0,100,2,11,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'city','accountbillads',1,'1','bill_city','Billing City',1,0,0,100,5,11,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'city','accountshipads',1,'1','ship_city','Shipping City',1,0,0,100,6,11,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'state','accountbillads',1,'1','bill_state','Billing State',1,0,0,100,7,11,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'state','accountshipads',1,'1','ship_state','Shipping State',1,0,0,100,8,11,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'code','accountbillads',1,'1','bill_code','Billing Code',1,0,0,100,9,11,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'code','accountshipads',1,'1','ship_code','Shipping Code',1,0,0,100,10,11,1,'V~O',1,null,'BAS')");
-
-
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'country','accountbillads',1,'1','bill_country','Billing Country',1,0,0,100,11,11,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'country','accountshipads',1,'1','ship_country','Shipping Country',1,0,0,100,12,11,1,'V~O',1,null,'BAS')");
-
-$this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'pobox','accountbillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,11,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'pobox','accountshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,11,1,'V~O',1,null,'BAS')");
-
-
- //Block12
-$this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,12,1,'V~O',1,null,'BAS')");
- 
-
-
-//Account Details -- END
-
-			
-//Lead Details --- START
-
-//Block13 -- Start
-
-$this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'salutation','leaddetails',1,'55','salutationtype','Salutation',1,0,0,100,1,13,3,'V~O',1,null,'BAS')");	
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'firstname','leaddetails',1,'55','firstname','First Name',1,0,0,100,2,13,1,'V~O',0,1,'BAS')");	
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'phone','leadaddress',1,'11','phone','Phone',1,0,0,100,3,13,1,'V~O',0,4,'BAS')");	
-
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'lastname','leaddetails',1,'2','lastname','Last Name',1,0,0,100,4,13,1,'V~M',0,2,'BAS')");	
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'mobile','leadaddress',1,'1','mobile','Mobile',1,0,0,100,5,13,1,'V~O',1,null,'BAS')");	
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'company','leaddetails',1,'2','company','Company',1,0,0,100,6,13,1,'V~M',0,3,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'campaignid','leaddetails',1,'51','campaignid','Campaign Name',1,0,0,100,6,4,3,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'fax','leadaddress',1,'1','fax','Fax',1,0,0,100,7,13,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'designation','leaddetails',1,'1','designation','Designation',1,0,0,100,8,13,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'email','leaddetails',1,'13','email','Email',1,0,0,100,9,13,1,'E~O',0,5,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'leadsource','leaddetails',1,'15','leadsource','Lead Source',1,0,0,100,10,13,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'website','leadsubdetails',1,'17','website','Website',1,0,0,100,11,13,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'industry','leaddetails',1,'15','industry','Industry',1,0,0,100,12,13,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'leadstatus','leaddetails',1,'15','leadstatus','Lead Status',1,0,0,100,13,13,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'annualrevenue','leaddetails',1,'71','annualrevenue','Annual Revenue',1,0,0,100,14,13,1,'I~O',1,null,'ADV')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'rating','leaddetails',1,'15','rating','Rating',1,0,0,100,15,13,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'noofemployees','leaddetails',1,'1','noofemployees','No Of Employees',1,0,0,100,16,13,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,17,13,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'yahooid','leaddetails',1,'13','yahooid','Yahoo Id',1,0,0,100,18,13,1,'V~O',1,null,'ADV')");
-$this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,19,13,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,20,13,2,'T~O',1,null,'BAS')");
-
-//Block13 -- End
-
-
-//Block15 -- Start
-
-$this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'lane','leadaddress',1,'21','lane','Street',1,0,0,100,1,15,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'code','leadaddress',1,'1','code','Postal Code',1,0,0,100,3,15,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'city','leadaddress',1,'1','city','City',1,0,0,100,4,15,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'country','leadaddress',1,'1','country','Country',1,0,0,100,5,15,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'state','leadaddress',1,'1','state','State',1,0,0,100,6,15,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'pobox','leadaddress',1,'1','pobox','Po Box',1,0,0,100,2,15,1,'V~O',1,null,'BAS')");
-
-//Block15 --End
-
-//Block16 -- Start
-
-$this->db->query("insert into field values (7,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,16,1,'V~O',1,null,'BAS')");
-
-//Block16 -- End
-
-//Lead Details -- END
-
-
-//Contact Details -- START
-//Block4 -- Start
-
-$this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'salutation','contactdetails',1,'55','salutationtype','Salutation',1,0,0,100,1,4,3,'V~O',1,null,'BAS')");	
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'firstname','contactdetails',1,'55','firstname','First Name',1,0,0,100,2,4,1,'V~O',0,1,'BAS')");	
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'phone','contactdetails',1,'11','phone','Office Phone',1,0,0,100,3,4,1,'V~O',0,4,'BAS')");	
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'lastname','contactdetails',1,'2','lastname','Last Name',1,0,0,100,4,4,1,'V~M',0,2,'BAS')");	
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'mobile','contactdetails',1,'1','mobile','Mobile',1,0,0,100,5,4,1,'V~O',1,null,'BAS')");	
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'accountid','contactdetails',1,'51','account_id','Account Name',1,0,0,100,6,4,1,'I~O',0,3,'BAS')");	
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'campaignid','contactdetails',1,'51','campaignid','Campaign Name',1,0,0,100,6,4,3,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'homephone','contactsubdetails',1,'11','homephone','Home Phone',1,0,0,100,7,4,1,'V~O',1,null,'ADV')");	
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'leadsource','contactsubdetails',1,'15','leadsource','Lead Source',1,0,0,100,8,4,1,'V~O',1,null,'BAS')");	
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'otherphone','contactsubdetails',1,'11','otherphone','Phone',1,0,0,100,9,4,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'title','contactdetails',1,'1','title','Title',1,0,0,100,10,4,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'fax','contactdetails',1,'1','fax','Fax',1,0,0,100,11,4,1,'V~O',1,null,'BAS')");	
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'department','contactdetails',1,'1','department','Department',1,0,0,100,12,4,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'birthday','contactsubdetails',1,'5','birthday','Birthdate',1,0,0,100,14,4,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'email','contactdetails',1,'13','email','Email',1,0,0,100,15,4,1,'E~O',0,5,'ADV')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'reportsto','contactdetails',1,'57','contact_id','Reports To',1,0,0,100,16,4,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'assistant','contactsubdetails',1,'1','assistant','Assistant',1,0,0,100,17,4,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'yahooid','contactdetails',1,'13','yahooid','Yahoo Id',1,0,0,100,18,4,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'assistantphone','contactsubdetails',1,'11','assistantphone','Assistant Phone',1,0,0,100,19,4,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'donotcall','contactdetails',1,'56','donotcall','Do Not Call',1,0,0,100,20,4,1,'C~O',1,null,'ADV')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'emailoptout','contactdetails',1,'56','emailoptout','Email Opt Out',1,0,0,100,21,4,1,'C~O',1,null,'ADV')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,22,4,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'reference','contactdetails',1,'56','reference','Reference',1,0,0,10,23,4,1,'C~O',1,null,'ADV')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'notify_owner','contactdetails',1,'56','notify_owner','Notify Owner',1,0,0,10,24,4,1,'C~O',1,null,'ADV')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,25,4,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,26,4,2,'T~O',1,null,'BAS')");
-
-//Block4 -- End
-
-//Block6 - Begin Customer Portal
-
-$this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'portal','customerdetails',1,'56','portal','Portal User',1,0,0,100,1,6,1,'C~O',1,null,'ADV')");
-$this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'support_start_date','customerdetails',1,'5','support_start_date','Support Start Date',1,0,0,100,2,6,1,'D~O',1,null,'ADV')");
-$this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'support_end_date','customerdetails',1,'5','support_end_date','Support End Date',1,0,0,100,3,6,1,'D~O~OTH~GE~support_start_date~Support Start Date',1,null,'ADV')");
-
-//Block6 - End Customer Portal
-
-//Block 7 -- Start
-
-$this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'mailingstreet','contactaddress',1,'21','mailingstreet','Mailing Street',1,0,0,100,1,7,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'otherstreet','contactaddress',1,'21','otherstreet','Other Street',1,0,0,100,2,7,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'mailingcity','contactaddress',1,'1','mailingcity','Mailing City',1,0,0,100,5,7,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'othercity','contactaddress',1,'1','othercity','Other City',1,0,0,100,6,7,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'mailingstate','contactaddress',1,'1','mailingstate','Mailing State',1,0,0,100,7,7,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'otherstate','contactaddress',1,'1','otherstate','Other State',1,0,0,100,8,7,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'mailingzip','contactaddress',1,'1','mailingzip','Mailing Zip',1,0,0,100,9,7,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'otherzip','contactaddress',1,'1','otherzip','Other Zip',1,0,0,100,10,7,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'mailingcountry','contactaddress',1,'1','mailingcountry','Mailing Country',1,0,0,100,11,7,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'othercountry','contactaddress',1,'1','othercountry','Other Country',1,0,0,100,12,7,1,'V~O',1,null,'BAS')");
-$this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'mailingpobox','contactaddress',1,'1','mailingpobox','Mailing Po Box',1,0,0,100,3,7,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'otherpobox','contactaddress',1,'1','otherpobox','Other Po Box',1,0,0,100,4,7,1,'V~O',1,null,'BAS')");
-//Block7 -- End
-
-//ContactImageInformation
- $this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'imagename','contactdetails',1,'69','imagename','Contact Image',1,0,0,100,1,75,1,'V~O',1,null,'ADV')");
-
-
-//Block8 -- Start
-$this->db->query("insert into field values (4,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,8,1,'V~O',1,null,'BAS')");
-//Block8 -- End
-//Contact Details -- END
-
-
-//Potential Details -- START
-//Block1 -- Start
-
-$this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'potentialname','potential',1,'2','potentialname','Potential Name',1,0,0,100,1,1,1,'V~M',0,1,'BAS')");	
- $this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'amount','potential',1,71,'amount','Amount',1,0,0,100,2,1,1,'N~O',0,5,'BAS')");	
- $this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'accountid','potential',1,'50','account_id','Account Name',1,0,0,100,3,1,1,'V~M',0,2,'BAS')");	
- $this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'closingdate','potential',1,'23','closingdate','Expected Close Date',1,0,0,100,5,1,1,'D~M',0,3,'BAS')");	
- $this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'potentialtype','potential',1,'15','opportunity_type','Type',1,0,0,100,6,1,1,'V~O',1,null,'BAS')");	
- $this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'nextstep','potential',1,'1','nextstep','Next Step',1,0,0,100,7,1,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'leadsource','potential',1,'15','leadsource','Lead Source',1,0,0,100,8,1,1,'V~O',1,null,'BAS')");	
- $this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'sales_stage','potential',1,'16','sales_stage','Sales Stage',1,0,0,100,9,1,1,'V~O',0,4,'BAS')");
- $this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,10,1,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'probability','potential',1,'9','probability','Probability',1,0,0,100,11,1,1,'N~O',1,null,'BAS')");
-$this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,13,1,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,14,1,2,'T~O',1,null,'BAS')");
-
-//Block1 -- End
-
-//Block3 -- Start
-
- $this->db->query("insert into field values (2,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,3,1,'V~O',1,null,'BAS')");
-
-//Block3 -- End
-//Potential Details -- END
-
-
-//Rss entries being added
- $this->db->query("insert into field values (24,".$this->db->getUniqueID("field").",'rsscategory','rss',1,'15','rsscategory','rsscategory',1,0,0,255,13,null,1,'V~O',1,null,'BAS')");
-//End of Rss entries
-
-//campaign entries being added
-
-
- $this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'campaignname','campaign',1,'2','campaignname','Campaign Name',1,0,0,100,1,76,1,'V~M',0,1,'BAS')");
- $this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'campaigntype','campaign',1,15,'campaigntype','Campaign Type',1,0,0,100,2,76,1,'V~O',0,5,'BAS')");
- $this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'product_id','campaign',1,59,'product_id','Product',1,0,0,100,3,76,1,'I~O',0,5,'BAS')");
- $this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'campaignstatus','campaign',1,15,'campaignstatus','Campaign Status',1,0,0,100,4,76,1,'V~O',0,5,'BAS')");
- $this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'closingdate','campaign',1,'23','closingdate','Expected Close Date',1,0,0,100,5,76,1,'D~M',0,3,'BAS')");
- $this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'expectedrevenue','campaign',1,'1','expectedrevenue','Expected Revenue',1,0,0,100,6,76,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'budgetcost','campaign',1,'1','budgetcost','Budget Cost',1,0,0,100,7,76,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'actualcost','campaign',1,'1','actualcost','Actual Cost',1,0,0,100,8,76,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'expectedresponse','campaign',1,'15','expectedresponse','Expected Response',1,0,0,100,9,76,1,'V~O',0,4,'BAS')");
- $this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,10,76,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'numsent','campaign',1,'9','numsent','Num Sent',1,0,0,100,11,76,1,'N~O',1,null,'BAS')");
-$this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'sponsor','campaign',1,'1','sponsor','Sponsor',1,0,0,100,12,76,1,'V~O',1,null,'BAS')");
-$this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'targetaudience','campaign',1,'1','targetaudience','Target Audience',1,0,0,100,13,76,1,'V~O',1,null,'BAS')");
-
-$this->db->query("insert into field values(26,".$this->db->getUniqueID("field").",'targetsize','campaign',1,'1','targetsize','TargetSize',1,0,0,100,14,76,1,'N~O',1,null,'BAS')");
-$this->db->query("insert into field values(26,".$this->db->getUniqueID("field").",'expectedresponsecount','campaign',1,'1','expectedresponsecount','Expected Response Count',1,0,0,100,17,76,1,'N~O',1,null,'BAS')");
-$this->db->query("insert into field values(26,".$this->db->getUniqueID("field").",'expectedsalescount','campaign',1,'1','expectedsalescount','Expected Sales Count',1,0,0,100,15,76,1,'N~O',1,null,'BAS')");
-$this->db->query("insert into field values(26,".$this->db->getUniqueID("field").",'expectedroi','campaign',1,'1','expectedroi','Expected ROI',1,0,0,100,19,76,1,'N~O',1,null,'BAS')");
-$this->db->query("insert into field values(26,".$this->db->getUniqueID("field").",'actualresponsecount','campaign',1,'1','actualresponsecount','Actual Response Count',1,0,0,100,18,76,1,'N~O',1,null,'BAS')");
-$this->db->query("insert into field values(26,".$this->db->getUniqueID("field").",'actualsalescount','campaign',1,'1','actualsalescount','Actual Sales Count',1,0,0,100,16,76,1,'N~O',1,null,'BAS')");
-$this->db->query("insert into field values(26,".$this->db->getUniqueID("field").",'actualroi','campaign',1,'1','actualroi','Actual ROI',1,0,0,100,20,76,1,'N~O',1,null,'BAS')");
-$this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,15,76,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,16,76,2,'T~O',1,null,'BAS')");
-
-$this->db->query("insert into field values (26,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,78,1,'V~O',1,null,'BAS')");
-
-//Campaign entries end
-
-
-//Ticket Details -- START
-//Block25 -- Start
-
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,2,25,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'parent_id','troubletickets',1,'68','parent_id','Related To',1,0,0,100,4,25,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'priority','troubletickets',1,'15','ticketpriorities','Priority',1,0,0,100,5,25,1,'V~O',0,3,'BAS')");
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'product_id','troubletickets',1,'59','product_id','Product Name',1,0,0,100,6,25,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'severity','troubletickets',1,'15','ticketseverities','Severity',1,0,0,100,7,25,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'status','troubletickets',1,'15','ticketstatus','Status',1,0,0,100,8,25,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'category','troubletickets',1,'15','ticketcategories','Category',1,0,0,100,9,25,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'update_log','troubletickets',1,'15','update_log','Update History',1,0,0,100,9,25,3,'V~O',1,null,'BAS')");
-$this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,10,25,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,11,25,2,'T~O',1,null,'BAS')");
- //Added on 26-12-2005 to add attachment in ticket editview
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'filename','attachments',1,'61','filename','Attachment',1,0,0,100,12,26,1,'V~O',0,1,'BAS')");
-
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'title','troubletickets',1,'22','ticket_title','Title',1,0,0,100,1,26,1,'V~M',0,1,'BAS')");
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'description','troubletickets',1,'19','description','Description',1,0,0,100,1,28,1,'V~O',0,2,'BAS')");
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'solution','troubletickets',1,'19','solution','Solution',1,0,0,100,1,29,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (13,".$this->db->getUniqueID("field").",'comments','ticketcomments',1,'19','comments','Add Comment',1,0,0,100,1,30,1,'V~O',1,null,'BAS')");
-
-//Block25-30 -- End
-//Ticket Details -- END
-
-//Product Details -- START
-//Block31-36 -- Start
-
-$this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'productname','products',1,'2','productname','Product Name',1,0,0,100,1,31,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'productcode','products',1,'1','productcode','Product Code',1,0,0,100,2,31,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'discontinued','products',1,'56','discontinued','Product Active',1,0,0,100,3,31,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'manufacturer','products',1,'15','manufacturer','Manufacturer',1,0,0,100,4,1,31,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'productcategory','products',1,'15','productcategory','Product Category',1,0,0,100,4,31,1,'V~O',1,null,'BAS')");
-$this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'sales_start_date','products',1,'5','sales_start_date','Sales Start Date',1,0,0,100,5,31,1,'D~O',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'sales_end_date','products',1,'5','sales_end_date','Sales End Date',1,0,0,100,6,31,1,'D~O~OTH~GE~sales_start_date~Sales Start Date',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'start_date','products',1,'5','start_date','Support Start Date',1,0,0,100,7,31,1,'D~O',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'expiry_date','products',1,'5','expiry_date','Support Expiry Date',1,0,0,100,8,31,1,'D~O~OTH~GE~start_date~Start Date',1,null,'BAS')");
- 
-
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'crmid','seproductsrel',1,'66','parent_id','Related To',1,0,0,100,10,31,1,'I~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'contactid','products',1,'57','contact_id','Contact Name',1,0,0,100,11,31,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'website','products',1,'17','website','Website',1,0,0,100,12,31,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'vendor_id','products',1,'75','vendor_id','Vendor Name',1,0,0,100,13,31,1,'I~O',1,null,'BAS')");
-$this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'mfr_part_no','products',1,'1','mfr_part_no','Mfr PartNo',1,0,0,100,14,31,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'vendor_part_no','products',1,'1','vendor_part_no','Vendor PartNo',1,0,0,100,15,31,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'serialno','products',1,'1','serial_no','Serial No',1,0,0,100,16,31,1,'V~O',1,null,'BAS')");
-$this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'productsheet','products',1,'1','productsheet','Product Sheet',1,0,0,100,17,31,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'glacct','products',1,'15','glacct','GL Account',1,0,0,100,18,31,1,'V~O',1,null,'BAS')");
-$this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,19,31,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,20,31,2,'T~O',1,null,'BAS')");
-
-
-//Block32 Pricing Information
-
-$this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'unit_price','products',1,'71','unit_price','Unit Price',1,0,0,100,1,32,1,'N~O',1,null,'BAS')"); 
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'commissionrate','products',1,'9','commissionrate','Commission Rate',1,0,0,100,2,32,1,'N~O',1,null,'BAS')"); 
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'taxclass','producttaxrel',1,'83','taxclass','Tax Class',1,0,0,100,4,32,1,'V~O',1,null,'BAS')");
-
-
-//Block 33 stock info
-
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'usageunit','products',1,'15','usageunit','Usage Unit',1,0,0,100,1,33,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'qty_per_unit','products',1,'1','qty_per_unit','Qty/Unit',1,0,0,100,2,33,1,'N~O',1,null,'ADV')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'qtyinstock','products',1,'1','qtyinstock','Qty In Stock',1,0,0,100,3,33,1,'I~O',1,null,'ADV')");
-$this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'reorderlevel','products',1,'1','reorderlevel','Reorder Level',1,0,0,100,4,33,1,'I~O',1,null,'ADV')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'handler','products',1,'52','assigned_user_id','Handler',1,0,0,100,5,33,1,'I~O',1,null,'ADV')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'qtyindemand','products',1,'1','qtyindemand','Qty In Demand',1,0,0,100,6,33,1,'I~O',1,null,'ADV')");
-
-
-//ProductImageInformation
-
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'imagename','products',1,'69','imagename','Product Image',1,0,0,100,1,35,1,'V~O',1,null,'ADV')");
-
-
-//Block 36 Description Info
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'product_description','products',1,'19','product_description','Description',1,0,0,100,1,36,1,'V~O',1,null,'BAS')");
-
-//Product Details -- END
-
-//Note Details -- START
-//Block17 -- Start
-
-$this->db->query("insert into field values (8,".$this->db->getUniqueID("field").",'contact_id','notes',1,'57','contact_id','Contact Name',1,0,0,100,1,17,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (8,".$this->db->getUniqueID("field").",'crmid','senotesrel',1,'62','parent_id','Related To',1,0,0,100,2,17,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (8,".$this->db->getUniqueID("field").",'title','notes',1,'2','title','Subject',1,0,0,100,3,17,1,'V~M',0,1,'BAS')");
-$this->db->query("insert into field values (8,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,4,17,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (8,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,5,17,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (8,".$this->db->getUniqueID("field").",'filename','notes',1,'61','filename','Attachment',1,0,0,100,4,17,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (8,".$this->db->getUniqueID("field").",'notecontent','notes',1,'19','notecontent','Note',1,0,0,100,5,18,1,'V~O',1,null,'BAS')");
-
-//Block17 -- End
-//Note Details -- END
-
-//Email Details -- START
-//Block21 -- Start
-
-	$this->db->query("insert into field values (10,".$this->db->getUniqueID("field").",'date_start','activity',1,'6','date_start','Date & Time Sent',1,0,0,100,1,21,1,'DT~M~time_start~Time Start',1,null,'BAS')");
-	$this->db->query("insert into field values (10,".$this->db->getUniqueID("field").",'semodule','activity',1,'2','parent_type','Sales Enity Module',1,0,0,100,2,21,3,'',1,null,'BAS')");
-	$this->db->query("insert into field values (10,".$this->db->getUniqueID("field").",'activitytype','activity',1,'2','activitytype','Activtiy Type',1,0,0,100,3,21,3,'V~O',1,null,'BAS')");
-	$this->db->query("insert into field values (10,".$this->db->getUniqueID("field").",'crmid','seactivityrel',1,'357','parent_id','Related To',1,0,0,100,1,22,1,'I~O',1,null,'BAS')");
-	$this->db->query("insert into field values (10,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,5,21,1,'V~M',1,null,'BAS')");
-	$this->db->query("insert into field values (10,".$this->db->getUniqueID("field").",'subject','activity',1,'2','subject','Subject',1,0,0,100,1,23,1,'V~M',1,null,'BAS')");
-	$this->db->query("insert into field values (10,".$this->db->getUniqueID("field").",'filename','attachments',1,'61','filename','Attachment',1,0,0,100,2,23,1,'V~O',1,null,'BAS')");
-	$this->db->query("insert into field values (10,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,24,1,'V~O',1,null,'BAS')");
-	$this->db->query("insert into field values (10,".$this->db->getUniqueID("field").",'time_start','activity',1,'2','time_start','Time Start',1,0,0,100,9,1,23,'T~O',1,null,'BAS')");
-	$this->db->query("insert into field values (10,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,10,1,22,'T~O',1,null,'BAS')");
- 	$this->db->query("insert into field values (10,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,11,21,2,'T~O',1,null,'BAS')");
-
-//Block21 -- End
-//Email Details -- END
-
-//Task Details --START
-//Block19 -- Start
-$this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'subject','activity',1,'2','subject','Subject',1,0,0,100,1,19,1,'V~M',0,1,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,2,19,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'date_start','activity',1,'6','date_start','Start Date & Time',1,0,0,100,3,19,1,'DT~M~time_start',0,2,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'time_start','activity',1,'2','time_start','Time Start',1,0,0,100,4,19,3,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'due_date','activity',1,'23','due_date','Due Date',1,0,0,100,5,19,1,'D~M~OTH~GE~date_start~Start Date & Time',1,null,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'crmid','seactivityrel',1,'66','parent_id','Related To',1,0,0,100,7,19,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'contactid','cntactivityrel',1,'57','contact_id','Contact Name',1,0,0,100,8,19,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'status','activity',1,'15','taskstatus','Status',1,0,0,100,9,19,1,'V~O',0,3,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'eventstatus','activity',1,'15','eventstatus','Status',1,0,0,100,9,19,3,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'priority','activity',1,'15','taskpriority','Priority',1,0,0,100,10,19,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'sendnotification','activity',1,'56','sendnotification','Send Notification',1,0,0,100,11,19,1,'C~O',1,null,'BAS')");
-$this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,14,19,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,15,19,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'activitytype','activity',1,'15','activitytype','Activity Type',1,0,0,100,16,19,3,'V~O',1,null,'BAS')");
- $this->db->query("Insert into field values (9,".$this->db->getUniqueID("field").",'visibility','activity',1,15,'visibility','Visibility',1,0,0,100,17,19,3,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,20,1,'V~O',1,null,'BAS')");
-
-
-$this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'duration_hours','activity',1,'63','duration_hours','Duration',1,0,0,100,17,19,3,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'duration_minutes','activity',1,'15','duration_minutes','Duration Minutes',1,0,0,100,18,19,3,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'location','activity',1,'1','location','Location',1,0,0,100,19,19,3,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'reminder_time','activity_reminder',1,'30','reminder_time','Send Reminder',1,0,0,100,1,19,3,'I~O',1,null,'BAS')");
- 
- $this->db->query("insert into field values (9,".$this->db->getUniqueID("field").",'recurringtype','recurringevents',1,'15','recurringtype','Recurrence',1,0,0,100,6,19,3,'O~O',1,null,'BAS')");
-
- $this->db->query("Insert into field values (9,".$this->db->getUniqueID("field").",'notime','activity',1,56,'notime','No Time',1,0,0,100,20,19,3,'C~O',1,null,'BAS')");
-//Block19 -- End
-//Task Details -- END
-
-//Event Details --START
-//Block41-43-- Start
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'subject','activity',1,'2','subject','Subject',1,0,0,100,1,41,1,'V~M',0,1,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,2,41,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'date_start','activity',1,'6','date_start','Start Date & Time',1,0,0,100,3,41,1,'DT~M~time_start',0,2,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'time_start','activity',1,'2','time_start','Time Start',1,0,0,100,4,41,3,'T~M',1,null,'BAS')");
-
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'due_date','activity',1,'23','due_date','End Date',1,0,0,100,5,41,1,'D~M~OTH~GE~date_start~Start Date & Time',1,null,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'recurringtype','recurringevents',1,'15','recurringtype','Recurrence',1,0,0,100,6,41,1,'O~O',1,null,'BAS')");
-  
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'duration_hours','activity',1,'63','duration_hours','Duration',1,0,0,100,7,41,1,'I~M',0,5,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'duration_minutes','activity',1,'15','duration_minutes','Duration Minutes',1,0,0,100,8,41,3,'O~O',1,null,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'crmid','seactivityrel',1,'66','parent_id','Related To',1,0,0,100,9,41,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'contactid','cntactivityrel',1,'57','contact_id','Contact Name',1,0,0,100,10,41,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'eventstatus','activity',1,'15','eventstatus','Status',1,0,0,100,11,41,1,'V~O',0,3,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'sendnotification','activity',1,'56','sendnotification','Send Notification',1,0,0,100,12,41,1,'C~O',1,null,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'activitytype','activity',1,'15','activitytype','Activity Type',1,0,0,100,13,41,1,'V~O',0,4,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'location','activity',1,'1','location','Location',1,0,0,100,14,41,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,15,41,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,16,41,2,'T~O',1,null,'BAS')");
- $this->db->query("Insert into field values (16,".$this->db->getUniqueID("field").",'priority','activity',1,15,'taskpriority','Priority',1,0,0,100,17,41,1,'V~O',1,null,'BAS')");
- $this->db->query("Insert into field values (16,".$this->db->getUniqueID("field").",'notime','activity',1,56,'notime','No Time',1,0,0,100,18,41,1,'C~O',1,null,'BAS')");
- $this->db->query("Insert into field values (16,".$this->db->getUniqueID("field").",'visibility','activity',1,15,'visibility','Visibility',1,0,0,100,19,41,1,'V~O',1,null,'BAS')");
- 
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,43,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (16,".$this->db->getUniqueID("field").",'reminder_time','activity_reminder',1,'30','reminder_time','Send Reminder',1,0,0,100,1,42,1,'I~O',1,null,'BAS')");
-//Block41-43 -- End
-//Event Details -- END
-
-//Faq Details -- START
-//Block37-40 -- Start
-
-$this->db->query("insert into field values (15,".$this->db->getUniqueID("field").",'product_id','faq',1,'59','product_id','Product Name',1,0,0,100,1,37,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (15,".$this->db->getUniqueID("field").",'category','faq',1,'15','faqcategories','Category',1,0,0,100,2,37,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (15,".$this->db->getUniqueID("field").",'status','faq',1,'15','faqstatus','Status',1,0,0,100,3,37,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (15,".$this->db->getUniqueID("field").",'question','faq',1,'20','question','Question',1,0,0,100,1,38,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (15,".$this->db->getUniqueID("field").",'answer','faq',1,'20','faq_answer','Answer',1,0,0,100,1,39,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (15,".$this->db->getUniqueID("field").",'comments','faqcomments',1,'19','comments','Add Comment',1,0,0,100,1,40,1,'V~O',1,null,'BAS')");
-$this->db->query("insert into field values (15,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,3,37,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (15,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,4,37,2,'T~O',1,null,'BAS')");
-
-
-//Block37-40 -- End
-//Ticket Details -- END
-
-//Vendor Details --START
-//Block44-47
-
-$this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'vendorname','vendor',1,'2','vendorname','Vendor Name',1,0,0,100,1,44,1,'V~M',0,1,'BAS')");
- $this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'phone','vendor',1,'1','phone','Phone',1,0,0,100,3,44,1,'V~O',0,2,'BAS')");
- $this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'email','vendor',1,'13','email','Email',1,0,0,100,4,44,1,'E~O',0,3,'BAS')");
- $this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'website','vendor',1,'17','website','Website',1,0,0,100,5,44,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'glacct','vendor',1,'15','glacct','GL Account',1,0,0,100,6,44,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'category','vendor',1,'1','category','Category',1,0,0,100,7,44,1,'V~O',1,null,'BAS')");
-$this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,8,44,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,9,44,2,'T~O',1,null,'BAS')");
-
-//Block 46
-
-$this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'street','vendor',1,'21','street','Street',1,0,0,100,1,46,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'pobox','vendor',1,'1','pobox','Po Box',1,0,0,100,2,46,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'city','vendor',1,'1','city','City',1,0,0,100,3,46,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'state','vendor',1,'1','state','State',1,0,0,100,4,46,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'postalcode','vendor',1,'1','postalcode','Postal Code',1,0,0,100,5,46,1,'V~O',1,null,'ADV')");
- $this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'country','vendor',1,'1','country','Country',1,0,0,100,6,46,1,'V~O',1,null,'ADV')");
-
-//Block 47
-
-$this->db->query("insert into field values (18,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,47,1,'V~O',1,null,'ADV')");
-
-//Vendor Details -- END
-
-//PriceBook Details Start
-//Block48
-
-$this->db->query("insert into field values (19,".$this->db->getUniqueID("field").",'bookname','pricebook',1,'2','bookname','Price Book Name',1,0,0,100,1,48,1,'V~M',0,1,'BAS')");
- $this->db->query("insert into field values (19,".$this->db->getUniqueID("field").",'active','pricebook',1,'56','active','Active',1,0,0,100,3,48,1,'V~O',0,2,'BAS')");
-$this->db->query("insert into field values (19,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,4,48,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (19,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,5,48,2,'T~O',1,null,'BAS')");
-
-//Block50
-
-$this->db->query("insert into field values (19,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,50,1,'V~O',1,null,'BAS')");
-
-//PriceBook Details End
-
-
-//Quote Details -- START
- //Block51
-
-$this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'subject','quotes',1,'2','subject','Subject',1,0,0,100,1,51,1,'V~M',1,null,'BAS')");	
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'potentialid','quotes',1,'76','potential_id','Potential Name',1,0,0,100,2,51,1,'I~O',1,null,'BAS')");	
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'quotestage','quotes',1,'15','quotestage','Quote Stage',1,0,0,100,3,51,1,'V~O',1,null,'BAS')");	
-
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'validtill','quotes',1,'5','validtill','Valid Till',1,0,0,100,4,51,1,'D~O',1,null,'BAS')");	
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'team','quotes',1,'1','team','Team',1,0,0,100,5,51,1,'V~O',1,null,'BAS')");	
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'contactid','quotes',1,'57','contact_id','Contact Name',1,0,0,100,6,51,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'carrier','quotes',1,'15','carrier','Carrier',1,0,0,100,8,51,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'subtotal','quotes',1,'1','hdnSubTotal','Sub Total',1,0,0,100,9,51,3,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'shipping','quotes',1,'1','shipping','Shipping',1,0,0,100,10,51,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'inventorymanager','quotes',1,'77','assigned_user_id1','Inventory Manager',1,0,0,100,11,51,1,'I~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'tax','quotes',1,'1','txtTax','Tax',1,0,0,100,13,51,3,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'adjustment','quotes',1,'1','txtAdjustment','Adjustment',1,0,0,100,20,51,3,'NN~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'total','quotes',1,'1','hdnGrandTotal','Total',1,0,0,100,14,51,3,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'accountid','quotes',1,'73','account_id','Account Name',1,0,0,100,16,51,1,'I~M',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,17,51,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,18,51,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,19,51,2,'T~O',1,null,'BAS')");
-
-
- //Block 53
-
-$this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'bill_street','quotesbillads',1,'24','bill_street','Billing Address',1,0,0,100,1,53,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'ship_street','quotesshipads',1,'24','ship_street','Shipping Address',1,0,0,100,2,53,1,'V~M',1,null,'BAS')");
-
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'bill_city','quotesbillads',1,'1','bill_city','Billing City',1,0,0,100,5,53,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'ship_city','quotesshipads',1,'1','ship_city','Shipping City',1,0,0,100,6,53,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'bill_state','quotesbillads',1,'1','bill_state','Billing State',1,0,0,100,7,53,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'ship_state','quotesshipads',1,'1','ship_state','Shipping State',1,0,0,100,8,53,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'bill_code','quotesbillads',1,'1','bill_code','Billing Code',1,0,0,100,9,53,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'ship_code','quotesshipads',1,'1','ship_code','Shipping Code',1,0,0,100,10,53,1,'V~O',1,null,'BAS')");
-
-
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'bill_country','quotesbillads',1,'1','bill_country','Billing Country',1,0,0,100,11,53,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'ship_country','quotesshipads',1,'1','ship_country','Shipping Country',1,0,0,100,12,53,1,'V~O',1,null,'BAS')");
-
-$this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'bill_pobox','quotesbillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,53,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'ship_pobox','quotesshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,53,1,'V~O',1,null,'BAS')");
- //Block55
-
-$this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,56,1,'V~O',1,null,'ADV')");
-
-//Block 56
-$this->db->query("insert into field values (20,".$this->db->getUniqueID("field").",'terms_conditions','quotes',1,'19','terms_conditions','Terms & Conditions',1,0,0,100,1,55,1,'V~O',1,null,'ADV')");
-
-
-//Quote Details -- END
-
-//Purchase Order Details -- START
- //Block57
- 
-$this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'subject','purchaseorder',1,'2','subject','Subject',1,0,0,100,1,57,1,'V~M',1,null,'BAS')");	
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'vendorid','purchaseorder',1,'81','vendor_id','Vendor Name',1,0,0,100,3,57,1,'I~M',1,null,'BAS')");	
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'requisition_no','purchaseorder',1,'1','requisition_no','Requisition No',1,0,0,100,4,57,1,'V~O',1,null,'BAS')");	
-
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'tracking_no','purchaseorder',1,'1','tracking_no','Tracking Number',1,0,0,100,5,57,1,'V~O',1,null,'BAS')");	
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'contactid','purchaseorder',1,'57','contact_id','Contact Name',1,0,0,100,6,57,1,'I~O',1,null,'BAS')");	
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'duedate','purchaseorder',1,'5','duedate','Due Date',1,0,0,100,7,57,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'carrier','purchaseorder',1,'15','carrier','Carrier',1,0,0,100,8,57,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'salestax','purchaseorder',1,'1','txtTax','Sales Tax',1,0,0,100,10,57,3,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'adjustment','purchaseorder',1,'1','txtAdjustment','Adjustment',1,0,0,100,10,57,3,'NN~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'salescommission','purchaseorder',1,'1','salescommission','Sales Commission',1,0,0,100,11,57,1,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'exciseduty','purchaseorder',1,'1','exciseduty','Excise Duty',1,0,0,100,12,57,1,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'total','purchaseorder',1,'1','hdnGrandTotal','Total',1,0,0,100,13,57,3,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'subtotal','purchaseorder',1,'1','hdnSubTotal','Sub Total',1,0,0,100,14,57,3,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'postatus','purchaseorder',1,'15','postatus','Status',1,0,0,100,15,57,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,16,57,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,17,57,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,18,57,2,'T~O',1,null,'BAS')");
-
-
-
- //Block 59
-
-$this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'bill_street','pobillads',1,'24','bill_street','Billing Address',1,0,0,100,1,59,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'ship_street','poshipads',1,'24','ship_street','Shipping Address',1,0,0,100,2,59,1,'V~M',1,null,'BAS')");
-
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'bill_city','pobillads',1,'1','bill_city','Billing City',1,0,0,100,5,59,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'ship_city','poshipads',1,'1','ship_city','Shipping City',1,0,0,100,6,59,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'bill_state','pobillads',1,'1','bill_state','Billing State',1,0,0,100,7,59,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'ship_state','poshipads',1,'1','ship_state','Shipping State',1,0,0,100,8,59,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'bill_code','pobillads',1,'1','bill_code','Billing Code',1,0,0,100,9,59,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'ship_code','poshipads',1,'1','ship_code','Shipping Code',1,0,0,100,10,59,1,'V~O',1,null,'BAS')");
-
-
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'bill_country','pobillads',1,'1','bill_country','Billing Country',1,0,0,100,11,59,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'ship_country','poshipads',1,'1','ship_country','Shipping Country',1,0,0,100,12,59,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'bill_pobox','pobillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,59,1,'V~O',1,null,'BAS')");
-  $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'ship_pobox','poshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,59,1,'V~O',1,null,'BAS')");
-  
- //Block61
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,62,1,'V~O',1,null,'ADV')");
-
- //Block62
- $this->db->query("insert into field values (21,".$this->db->getUniqueID("field").",'terms_conditions','purchaseorder',1,'19','terms_conditions','Terms & Conditions',1,0,0,100,1,61,1,'V~O',1,null,'ADV')");
-
-//Purchase Order Details -- END
-
-//Sales Order Details -- START
- //Block63
- 
-$this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'subject','salesorder',1,'2','subject','Subject',1,0,0,100,1,63,1,'V~M',1,null,'BAS')");	
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'potentialid','salesorder',1,'76','potential_id','Potential Name',1,0,0,100,2,63,1,'I~O',1,null,'BAS')");	
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'customerno','salesorder',1,'1','customerno','Customer No',1,0,0,100,3,63,1,'V~O',1,null,'BAS')");
-$this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'quoteid','salesorder',1,'78','quote_id','Quote Name',1,0,0,100,4,63,1,'I~O',1,null,'BAS')");	
-$this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'purchaseorder','salesorder',1,'1','purchaseorder','Purchase Order',1,0,0,100,4,63,1,'V~O',1,null,'BAS')");	
-
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'contactid','salesorder',1,'57','contact_id','Contact Name',1,0,0,100,6,63,1,'I~O',1,null,'BAS')");	
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'duedate','salesorder',1,'5','duedate','Due Date',1,0,0,100,8,63,1,'D~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'carrier','salesorder',1,'15','carrier','Carrier',1,0,0,100,9,63,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'pending','salesorder',1,'1','pending','Pending',1,0,0,100,10,63,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'sostatus','salesorder',1,'15','sostatus','Status',1,0,0,100,11,63,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'salestax','salesorder',1,'1','txtTax','Sales Tax',1,0,0,100,12,63,3,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'adjustment','salesorder',1,'1','txtAdjustment','Sales Tax',1,0,0,100,12,63,3,'NN~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'salescommission','salesorder',1,'1','salescommission','Sales Commission',1,0,0,100,13,63,1,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'exciseduty','salesorder',1,'1','exciseduty','Excise Duty',1,0,0,100,13,63,1,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'total','salesorder',1,'1','hdnGrandTotal','Total',1,0,0,100,14,63,3,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'subtotal','salesorder',1,'1','hdnSubTotal','Total',1,0,0,100,15,63,3,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'accountid','salesorder',1,'73','account_id','Account Name',1,0,0,100,16,63,1,'I~M',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,17,63,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,18,63,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,19,63,2,'T~O',1,null,'BAS')");
-
-
-
- //Block 65
-
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'bill_street','sobillads',1,'24','bill_street','Billing Address',1,0,0,100,1,65,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'ship_street','soshipads',1,'24','ship_street','Shipping Address',1,0,0,100,2,65,1,'V~M',1,null,'BAS')");
-
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'bill_city','sobillads',1,'1','bill_city','Billing City',1,0,0,100,5,65,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'ship_city','soshipads',1,'1','ship_city','Shipping City',1,0,0,100,6,65,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'bill_state','sobillads',1,'1','bill_state','Billing State',1,0,0,100,7,65,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'ship_state','soshipads',1,'1','ship_state','Shipping State',1,0,0,100,8,65,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'bill_code','sobillads',1,'1','bill_code','Billing Code',1,0,0,100,9,65,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'ship_code','soshipads',1,'1','ship_code','Shipping Code',1,0,0,100,10,65,1,'V~O',1,null,'BAS')");
-
-
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'bill_country','sobillads',1,'1','bill_country','Billing Country',1,0,0,100,11,65,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'ship_country','soshipads',1,'1','ship_country','Shipping Country',1,0,0,100,12,65,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'bill_pobox','sobillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,65,1,'V~O',1,null,'BAS')");
-  $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'ship_pobox','soshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,65,1,'V~O',1,null,'BAS')");
-  
-//Block67
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,68,1,'V~O',1,null,'ADV')");
-
- //Block68
- $this->db->query("insert into field values (22,".$this->db->getUniqueID("field").",'terms_conditions','salesorder',1,'19','terms_conditions','Terms & Conditions',1,0,0,100,1,67,1,'V~O',1,null,'ADV')");
-
-
-//Sales Order Details -- END
-
-//Invoice Details -- START
- //Block69
-
-$this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'subject','invoice',1,'2','subject','Subject',1,0,0,100,1,69,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'salesorderid','invoice',1,'80','salesorder_id','Sales Order',1,0,0,100,2,69,1,'I~O',1,null,'BAS')");	
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'customerno','invoice',1,'1','customerno','Customer No',1,0,0,100,3,69,1,'V~O',1,null,'BAS')");	
-
- 
-//to include contact name field in Invoice-start
-$this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'contactid','invoice',1,'57','contact_id','Contact Name',1,0,0,100,4,69,1,'I~O',1,null,'BAS')");
-//end
-
-$this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'invoicedate','invoice',1,'5','invoicedate','Invoice Date',1,0,0,100,5,69,1,'D~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'duedate','invoice',1,'5','duedate','Due Date',1,0,0,100,6,69,1,'D~O',1,null,'BAS')");
-$this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'purchaseorder','invoice',1,'1','purchaseorder','Purchase Order',1,0,0,100,8,69,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'salestax','invoice',1,'1','txtTax','Sales Tax',1,0,0,100,9,69,3,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'adjustment','invoice',1,'1','txtAdjustment','Sales Tax',1,0,0,100,9,69,3,'NN~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'salescommission','invoice',1,'1','salescommission','Sales Commission',1,0,0,10,13,69,1,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'exciseduty','invoice',1,'1','exciseduty','Excise Duty',1,0,0,100,11,69,1,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'subtotal','invoice',1,'1','hdnSubTotal','Sub Total',1,0,0,100,12,69,3,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'total','invoice',1,'1','hdnGrandTotal','Total',1,0,0,100,13,69,3,'N~O',1,null,'BAS')");
-$this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'accountid','invoice',1,'73','account_id','Account Name',1,0,0,100,14,69,1,'I~M',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'invoicestatus','invoice',1,'15','invoicestatus','Status',1,0,0,100,15,69,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'smownerid','crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,16,69,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'createdtime','crmentity',1,'70','createdtime','Created Time',1,0,0,100,17,69,2,'T~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'modifiedtime','crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,18,69,2,'T~O',1,null,'BAS')"); 
-
- //Block 71
-
-$this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'bill_street','invoicebillads',1,'24','bill_street','Billing Address',1,0,0,100,1,71,1,'V~M',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'ship_street','invoiceshipads',1,'24','ship_street','Shipping Address',1,0,0,100,2,71,1,'V~M',1,null,'BAS')");
-
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'bill_city','invoicebillads',1,'1','bill_city','Billing City',1,0,0,100,5,71,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'ship_city','invoiceshipads',1,'1','ship_city','Shipping City',1,0,0,100,6,71,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'bill_state','invoicebillads',1,'1','bill_state','Billing State',1,0,0,100,7,71,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'ship_state','invoiceshipads',1,'1','ship_state','Shipping State',1,0,0,100,8,71,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'bill_code','invoicebillads',1,'1','bill_code','Billing Code',1,0,0,100,9,71,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'ship_code','invoiceshipads',1,'1','ship_code','Shipping Code',1,0,0,100,10,71,1,'V~O',1,null,'BAS')");
-
-
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'bill_country','invoicebillads',1,'1','bill_country','Billing Country',1,0,0,100,11,71,1,'V~O',1,null,'BAS')");
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'ship_country','invoiceshipads',1,'1','ship_country','Shipping Country',1,0,0,100,12,71,1,'V~O',1,null,'BAS')");
-
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'bill_pobox','invoicebillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,71,1,'V~O',1,null,'BAS')");
-  $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'ship_pobox','invoiceshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,71,1,'V~O',1,null,'BAS')");
-
-//Block73
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'description','crmentity',1,'19','description','Description',1,0,0,100,1,74,1,'V~O',1,null,'ADV')");
- //Block74
- $this->db->query("insert into field values (23,".$this->db->getUniqueID("field").",'terms_conditions','invoice',1,'19','terms_conditions','Terms & Conditions',1,0,0,100,1,73,1,'V~O',1,null,'ADV')");
-
-
-//Invoice Details -- END
-
-
-
-                // Insert End
-                
-
-		//New Security Start
-		//Inserting into profile table
-		$this->db->query("insert into profile values ('".$profile1_id."','Administrator',null)");	
-		$this->db->query("insert into profile values ('".$profile2_id."','Sales Profile',null)");
-		$this->db->query("insert into profile values ('".$profile3_id."','Support Profile',null)");
-		$this->db->query("insert into profile values ('".$profile4_id."','Guest Profile',null)");
-		
-		//Inserting into profile2gloabal permissions
-		$this->db->query("insert into profile2globalpermissions values ('".$profile1_id."',1,0)");
-		$this->db->query("insert into profile2globalpermissions values ('".$profile1_id."',2,0)");
-		$this->db->query("insert into profile2globalpermissions values ('".$profile2_id."',1,1)");
-		$this->db->query("insert into profile2globalpermissions values ('".$profile2_id."',2,1)");
-		$this->db->query("insert into profile2globalpermissions values ('".$profile3_id."',1,1)");
-		$this->db->query("insert into profile2globalpermissions values ('".$profile3_id."',2,1)");
-		$this->db->query("insert into profile2globalpermissions values ('".$profile4_id."',1,1)");
-		$this->db->query("insert into profile2globalpermissions values ('".$profile4_id."',2,1)");
-
-		//Inserting into profile2tab
-		$this->db->query("insert into profile2tab values (".$profile1_id.",1,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",2,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",3,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",4,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",6,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",7,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",8,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",9,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",10,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",13,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",14,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",15,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",16,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",17,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",18,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",19,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",20,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",21,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",22,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",23,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",24,0)");
-		$this->db->query("insert into profile2tab values (".$profile1_id.",25,0)");
-       		$this->db->query("insert into profile2tab values (".$profile1_id.",26,0)");
-       		$this->db->query("insert into profile2tab values (".$profile1_id.",27,0)");
-
-		//Inserting into profile2tab
-		$this->db->query("insert into profile2tab values (".$profile2_id.",1,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",2,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",3,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",4,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",6,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",7,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",8,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",9,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",10,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",13,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",14,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",15,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",16,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",17,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",18,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",19,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",20,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",21,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",22,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",23,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",24,0)");
-		$this->db->query("insert into profile2tab values (".$profile2_id.",25,0)");
-        	$this->db->query("insert into profile2tab values (".$profile2_id.",26,0)");
-       		$this->db->query("insert into profile2tab values (".$profile2_id.",27,0)");
-
-		$this->db->query("insert into profile2tab values (".$profile3_id.",1,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",2,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",3,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",4,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",6,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",7,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",8,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",9,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",10,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",13,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",14,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",15,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",16,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",17,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",18,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",19,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",20,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",21,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",22,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",23,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",24,0)");
-		$this->db->query("insert into profile2tab values (".$profile3_id.",25,0)");
-        	$this->db->query("insert into profile2tab values (".$profile3_id.",26,0)");
-       		$this->db->query("insert into profile2tab values (".$profile3_id.",27,0)");
-        
-
-		$this->db->query("insert into profile2tab values (".$profile4_id.",1,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",2,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",3,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",4,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",6,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",7,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",8,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",9,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",10,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",13,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",14,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",15,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",16,0)");	
-		$this->db->query("insert into profile2tab values (".$profile4_id.",17,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",18,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",19,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",20,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",21,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",22,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",23,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",24,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",25,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",26,0)");
-		$this->db->query("insert into profile2tab values (".$profile4_id.",27,0)");
-		//Inserting into profile2standardpermissions  Adminsitrator
-		
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",2,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",2,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",2,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",2,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",2,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",4,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",4,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",4,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",4,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",4,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",6,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",6,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",6,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",6,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",6,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",7,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",7,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",7,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",7,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",7,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",8,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",8,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",8,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",8,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",8,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",9,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",9,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",9,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",9,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",9,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",10,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",10,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",10,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",10,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",10,4,0)");
-
-		
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",13,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",13,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",13,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",13,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",13,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",14,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",14,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",14,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",14,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",14,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",15,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",15,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",15,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",15,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",15,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",16,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",16,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",16,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",16,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",16,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",18,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",18,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",18,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",18,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",18,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",19,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",19,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",19,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",19,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",19,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",20,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",20,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",20,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",20,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",20,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",21,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",21,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",21,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",21,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",21,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",22,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",22,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",22,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",22,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",22,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",23,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",23,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",23,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",23,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",23,4,0)");
-
-
-
-        	$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",26,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",26,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",26,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",26,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile1_id.",26,4,0)");
-
-
-		//Insert into Profile 2 std permissions for Sales User  
-		//Help Desk Create/Delete not allowed. Read-Only	
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",2,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",2,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",2,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",2,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",2,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",4,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",4,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",4,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",4,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",4,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",6,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",6,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",6,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",6,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",6,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",7,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",7,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",7,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",7,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",7,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",8,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",8,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",8,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",8,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",8,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",9,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",9,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",9,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",9,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",9,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",10,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",10,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",10,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",10,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",10,4,0)");
-
-		
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",13,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",13,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",13,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",13,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",13,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",14,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",14,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",14,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",14,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",14,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",15,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",15,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",15,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",15,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",15,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",16,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",16,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",16,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",16,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",16,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",18,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",18,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",18,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",18,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",18,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",19,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",19,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",19,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",19,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",19,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",20,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",20,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",20,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",20,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",20,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",21,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",21,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",21,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",21,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",21,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",22,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",22,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",22,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",22,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",22,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",23,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",23,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",23,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",23,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",23,4,0)");
-
-
-        	$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",26,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",26,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",26,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",26,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile2_id.",26,4,0)");
-
-		//Inserting into profile2std for Support Profile
-		// Potential is read-only
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",2,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",2,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",2,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",2,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",2,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",4,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",4,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",4,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",4,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",4,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",6,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",6,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",6,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",6,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",6,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",7,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",7,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",7,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",7,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",7,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",8,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",8,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",8,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",8,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",8,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",9,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",9,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",9,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",9,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",9,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",10,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",10,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",10,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",10,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",10,4,0)");
-
-		
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",13,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",13,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",13,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",13,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",13,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",14,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",14,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",14,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",14,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",14,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",15,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",15,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",15,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",15,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",15,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",16,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",16,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",16,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",16,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",16,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",18,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",18,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",18,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",18,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",18,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",19,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",19,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",19,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",19,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",19,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",20,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",20,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",20,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",20,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",20,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",21,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",21,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",21,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",21,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",21,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",22,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",22,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",22,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",22,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",22,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",23,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",23,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",23,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",23,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",23,4,0)");
-
-
-        	$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",26,0,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",26,1,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",26,2,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",26,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile3_id.",26,4,0)");
-        
-		//Inserting into profile2stdper for Profile Guest Profile
-		//All Read-Only
-		
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",2,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",2,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",2,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",2,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",2,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",4,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",4,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",4,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",4,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",4,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",6,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",6,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",6,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",6,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",6,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",7,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",7,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",7,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",7,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",7,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",8,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",8,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",8,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",8,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",8,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",9,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",9,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",9,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",9,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",9,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",10,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",10,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",10,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",10,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",10,4,0)");
-
-		
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",13,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",13,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",13,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",13,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",13,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",14,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",14,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",14,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",14,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",14,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",15,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",15,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",15,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",15,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",15,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",16,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",16,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",16,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",16,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",16,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",18,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",18,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",18,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",18,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",18,4,0)");	
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",19,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",19,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",19,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",19,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",19,4,0)");	
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",20,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",20,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",20,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",20,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",20,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",21,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",21,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",21,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",21,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",21,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",22,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",22,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",22,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",22,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",22,4,0)");
-
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",23,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",23,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",23,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",23,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",23,4,0)");	
-
-
-        $this->db->query("insert into profile2standardpermissions values (".$profile4_id.",26,0,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",26,1,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",26,2,1)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",26,3,0)");
-		$this->db->query("insert into profile2standardpermissions values (".$profile4_id.",26,4,0)");
-
-		//Insert into role2profile
-		$this->db->query("insert into role2profile values ('H".$role2_id."',".$profile1_id.")");
-		$this->db->query("insert into role2profile values ('H".$role3_id."',".$profile2_id.")");
-	
-		//Insert into profile2field
-			
-                insertProfile2field($profile1_id);
-                insertProfile2field($profile2_id);	
-                insertProfile2field($profile3_id);	
-                insertProfile2field($profile4_id);
-
-		insert_def_org_field();	
-		
-
-		//Inserting into profile 2 utility Admin
-                $this->db->query("insert into profile2utility values (".$profile1_id.",2,5,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",2,6,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",4,5,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",4,6,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",6,5,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",6,6,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",7,5,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",7,6,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",8,6,0)");
-                //$this->db->query("insert into profile2utility values (".$profile1_id.",9,6,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",10,6,0)");
-		$this->db->query("insert into profile2utility values (".$profile1_id.",7,8,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",6,8,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",4,8,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",13,8,0)");
-		$this->db->query("insert into profile2utility values (".$profile1_id.",14,5,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",14,6,0)");
-                $this->db->query("insert into profile2utility values (".$profile1_id.",7,9,0)");
-
-		//Inserting into profile2utility Sales Profile
-		//Import Export Not Allowed.	
-		$this->db->query("insert into profile2utility values (".$profile2_id.",2,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",2,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",4,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",4,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",6,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",6,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",7,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",7,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",8,6,1)");
-                //$this->db->query("insert into profile2utility values (".$profile2_id.",9,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",10,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",7,8,0)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",6,8,0)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",4,8,0)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",13,8,0)");
-		$this->db->query("insert into profile2utility values (".$profile2_id.",14,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",14,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile2_id.",7,9,0)");
-
-		//Inserting into profile2utility Support Profile
-		//Import Export Not Allowed.	
-		$this->db->query("insert into profile2utility values (".$profile3_id.",2,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",2,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",4,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",4,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",6,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",6,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",7,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",7,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",8,6,1)");
-                //$this->db->query("insert into profile2utility values (".$profile3_id.",9,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",10,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",7,8,0)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",6,8,0)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",4,8,0)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",13,8,0)");
-		$this->db->query("insert into profile2utility values (".$profile3_id.",14,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",14,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile3_id.",7,9,0)");
-
-		//Inserting into profile2utility Guest Profile Read-Only
-		//Import Export BusinessCar Not Allowed.	
-		$this->db->query("insert into profile2utility values (".$profile4_id.",2,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",2,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",4,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",4,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",6,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",6,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",7,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",7,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",8,6,1)");
-                //$this->db->query("insert into profile2utility values (".$profile4_id.",9,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",10,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",7,8,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",6,8,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",4,8,1)");		
-                $this->db->query("insert into profile2utility values (".$profile4_id.",13,8,1)");		
-		$this->db->query("insert into profile2utility values (".$profile4_id.",14,5,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",14,6,1)");
-                $this->db->query("insert into profile2utility values (".$profile4_id.",7,9,0)");
-
-		//Inserting values into org share action mapping
-                $this->db->query("insert into org_share_action_mapping values(0,'Public: Read Only')");
-                $this->db->query("insert into org_share_action_mapping values(1,'Public: Read, Create/Edit')");
-                $this->db->query("insert into org_share_action_mapping values(2,'Public: Read, Create/Edit, Delete')");
-                $this->db->query("insert into org_share_action_mapping values(3,'Private')");
-
-                $this->db->query("insert into org_share_action_mapping values(4,'Hide Details')");
-                $this->db->query("insert into org_share_action_mapping values(5,'Hide Details and Add Events')");
-                $this->db->query("insert into org_share_action_mapping values(6,'Show Details')");
-                $this->db->query("insert into org_share_action_mapping values(7,'Show Details and Add Events')");
-
-
-		//Inserting for all tabs
-                $def_org_tabid= Array(2,4,6,7,9,10,13,16,20,21,22,23,26);
-
-                foreach($def_org_tabid as $def_tabid)
-                {
-                        $this->db->query("insert into org_share_action2tab values(0,".$def_tabid.")");
-                        $this->db->query("insert into org_share_action2tab values(1,".$def_tabid.")");
-                        $this->db->query("insert into org_share_action2tab values(2,".$def_tabid.")");
-                        $this->db->query("insert into org_share_action2tab values(3,".$def_tabid.")");
-                }
-
-                $this->db->query("insert into org_share_action2tab values(4,17)");
-                $this->db->query("insert into org_share_action2tab values(5,17)");
-                $this->db->query("insert into org_share_action2tab values(6,17)");
-                $this->db->query("insert into org_share_action2tab values(7,17)");
-
-		//Insert into default_org_sharingrule
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",2,2,0)");
-
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",4,2,2)");
-
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",6,2,0)");
-
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",7,2,0)");
-
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",9,3,1)");
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",10,2,0)");
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",13,2,0)");
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",16,3,2)");
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",17,7,0)");
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",20,2,0)");
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",21,2,0)");
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",22,2,0)");
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",23,2,0)");
-               $this->db->query("insert into def_org_share values (".$this->db->getUniqueID('def_org_share').",26,2,0)");
-
-		//Populating the DataShare Related Modules
-
-		//Lead Related Module
-		$this->db->query("insert into datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",7,10)");
-
-		//Account Related Module
-		$this->db->query("insert into datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",6,2)");
-		$this->db->query("insert into datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",6,13)");
-		$this->db->query("insert into datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",6,20)");
-		$this->db->query("insert into datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",6,22)");
-		$this->db->query("insert into datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",6,23)");
-		$this->db->query("insert into datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",6,10)");
-
-		//Potential Related Module
-		$this->db->query("insert into datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",2,20)");
-		$this->db->query("insert into datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",2,22)");
-
-		//Quote Related Module
-		$this->db->query("insert into datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",20,22)");
-
-		//SO Related Module
-		$this->db->query("insert into datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",22,23)");	
-
-
-			
-					
-  // New Secutity End
-
-
-         //insert into the notificationscheduler table
-
-	//insert into related list table
-	//Inserting for account related lists
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Potentials").",'get_opportunities',1,'Potentials',0)");	
-		
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Contacts").",'get_contacts',2,'Contacts',0)");
-
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Activities").",'get_activities',3,'Activities',0)");
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("HelpDesk").",'get_tickets',4,'HelpDesk',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Activities").",'get_history',5,'Activity History',0)");
-
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",0,'get_attachments',6,'Attachments',0)");
-
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Quotes").",'get_quotes',7,'Quotes',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Invoice").",'get_invoices',8,'Invoice',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("SalesOrder").",'get_salesorder',9,'Sales Order',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Products").",'get_products',10,'Products',0)");
-
-	//Inserting Lead Related Lists	
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Leads").",".getTabid("Activities").",'get_activities',1,'Activities',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Leads").",".getTabid("Emails").",'get_emails',2,'Emails',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Leads").",".getTabid("Activities").",'get_history',3,'Activity History',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Leads").",0,'get_attachments',4,'Attachments',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Leads").",".getTabid("Products").",'get_products',5,'Products',0)");
-
-	//Inserting for contact related lists
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("Potentials").",'get_opportunities',1,'Potentials',0)");	
-		
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("Activities").",'get_activities',2,'Activities',0)");
-
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("Emails").",'get_emails',3,'Emails',0)");
-
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("HelpDesk").",'get_tickets',4,'HelpDesk',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("Quotes").",'get_quotes',5,'Quotes',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("PurchaseOrder").",'get_purchase_orders',6,'Purchase Order',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("SalesOrder").",'get_salesorder',7,'Sales Order',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("Products").",'get_products',8,'Products',0)");
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("Activities").",'get_history',9,'Activity History',0)");
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",0,'get_attachments',10,'Attachments',0)");
-
-	//Inserting Potential Related Lists	
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",".getTabid("Activities").",'get_activities',1,'Activities',0)");
-
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",".getTabid("Contacts").",'get_contacts',2,'Contacts',0)");
-
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",".getTabid("Products").",'get_products',3,'Products',0)");
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",0,'get_stage_history',4,'Sales Stage History',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",0,'get_attachments',5,'Attachments',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",".getTabid("Quotes").",'get_Quotes',6,'Quotes',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",".getTabid("SalesOrder").",'get_salesorder',7,'Sales Order',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",".getTabid("Activities").",'get_history',8,'Activity History',0)");
-
-		//Inserting Product Related Lists	
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("HelpDesk").",'get_tickets',1,'HelpDesk',0)");
-
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("Activities").",'get_activities',2,'Activities',0)");
-
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",0,'get_attachments',3,'Attachments',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("Quotes").",'get_quotes',4,'Quotes',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("PurchaseOrder").",'get_purchase_orders',5,'Purchase Order',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("SalesOrder").",'get_salesorder',6,'Sales Order',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("Invoice").",'get_invoices',7,'Invoice',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("PriceBooks").",'get_product_pricebooks',8,'PriceBooks',0)");
-	
-		//Inserting Emails Related Lists	
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Emails").",".getTabid("Contacts").",'get_contacts',1,'Contacts',0)");
-
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Emails").",0,'get_users',2,'Users',0)");
-
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Emails").",0,'get_attachments',3,'Attachments',0)");
-
-		//Inserting HelpDesk Related Lists
-		
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("HelpDesk").",".getTabid("Activities").",'get_activities',1,'Activities',0)");
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("HelpDesk").",0,'get_attachments',2,'Attachments',0)");
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("HelpDesk").",0,'get_ticket_history',3,'Ticket History',0)");
-
-	//Inserting PriceBook Related Lists
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("PriceBooks").",14,'get_pricebook_products',2,'Products',0)");
-
-        // Inserting Vendor Related Lists
-        $this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Vendors").",14,'get_products',1,'Products',0)");
-
-        $this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Vendors").",21,'get_purchase_orders',2,'Purchase Order',0)");
-
-        $this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Vendors").",4,'get_contacts',3,'Contacts',0)");
-
-	// Inserting Quotes Related Lists
-	
-        $this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Quotes").",".getTabid("Invoice").",'get_salesorder',1,'Sales Order',0)");
-        
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Quotes").",9,'get_activities',2,'Activities',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Quotes").",9,'get_history',3,'Activity History',0)");
-
-	// Inserting Purchase order Related Lists
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("PurchaseOrder").",9,'get_activities',1,'Activities',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("PurchaseOrder").",0,'get_attachments',2,'Attachments',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("PurchaseOrder").",".getTabid("Activities").",'get_history',3,'Activity History',0)");
-	
-	// Inserting Sales order Related Lists
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("SalesOrder").",9,'get_activities',1,'Activities',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("SalesOrder").",0,'get_attachments',2,'Attachments',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("SalesOrder").",".getTabid("Invoice").",'get_invoices',3,'Invoice',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("SalesOrder").",".getTabid("Activities").",'get_history',4,'Activity History',0)");
-	
-	// Inserting Invoice Related Lists
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Invoice").",9,'get_activities',1,'Activities',0)");
-	
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Invoice").",0,'get_attachments',2,'Attachments',0)");
-
-	$this->db->query("insert into relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Invoice").",".getTabid("Activities").",'get_history',3,'Activity History',0)");
-
-	// Inserting Activities Related Lists
-	
-	$this->db->query("insert into relatedlists values (".$this->db->getUniqueID('relatedlists').",".getTabid("Activities").",0,'get_users',1,'Users',0)");
-	$this->db->query("insert into relatedlists values (".$this->db->getUniqueID('relatedlists').",".getTabid("Activities").",4,'get_contacts',2,'Contacts',0)");
-
-	// Inserting Campaigns Related Lists
-
-         $this->db->query("insert into relatedlists values (".$this->db->getUniqueID('relatedlists').",".getTabid("Campaigns").",".getTabid("Contacts").",'get_contacts',1,'Contacts',0)");
-         $this->db->query("insert into relatedlists values (".$this->db->getUniqueID('relatedlists').",".getTabid("Campaigns").",".getTabid("Leads").",'get_leads',2,'Leads',0)");
-
-               $this->db->query("insert into notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_TASK_NOTIFICATION_DESCRITPION',1,'Task Delay Notification','Tasks delayed beyond 24 hrs ','LBL_TASK_NOTIFICATION')");
-
-
-                $this->db->query("insert into notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_BIG_DEAL_DESCRIPTION' ,1,'Big Deal notification','Success! A big deal has been won! ','LBL_BIG_DEAL')");
-
-
-                $this->db->query("insert into notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_TICKETS_DESCRIPTION',1,'Pending Tickets notification','Ticket pending please ','LBL_PENDING_TICKETS')");
-
-
-                $this->db->query("insert into notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_MANY_TICKETS_DESCRIPTION',1,'Too many tickets Notification','Too many tickets pending against this entity ','LBL_MANY_TICKETS')");
-
-
-                $this->db->query("insert into notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_START_DESCRIPTION' ,1,'Support Start Notification','Support starts please ','LBL_START_NOTIFICATION')");
-
-                $this->db->query("insert into notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_SUPPORT_DESCRIPTION',1,'Support ending please','Support Ending Notification','LBL_SUPPORT_NOTICIATION')");
-		
- 		$this->db->query("insert into notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_ACTIVITY_REMINDER_DESCRIPTION' ,1,'Activity Reminder Notication','This is a reminder notification for the Activity','LBL_ACTIVITY_NOTIFICATION')");
-
-		//Inserting Inventory Notifications
-	$invoice_body = 'Dear {HANDLER},
-
-The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. Kindly procure required number of units as the stock level is below reorder level {REORDERLEVELVALUE}.
-
-Please treat this information as Urgent as the invoice is already sent  to the customer.
-
-Severity: Critical
-
-Thanks,
-{CURRENTUSER}';
-
-		
-               $this->db->query("insert into inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("inventorynotification").",'InvoiceNotification','{PRODUCTNAME} Stock Level is Low','".$invoice_body." ','InvoiceNotificationDescription')");
-
-		$quote_body = 'Dear {HANDLER},
-
-Quote is generated for {QUOTEQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. 
-
-Severity: Minor
-
-Thanks,
-{CURRENTUSER}';	
-		
-		
-               $this->db->query("insert into inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("inventorynotification").",'QuoteNotification','Quote given for {PRODUCTNAME}','".$quote_body." ','QuoteNotificationDescription')");
-
-		$so_body = 'Dear {HANDLER},
-
-SalesOrder is generated for {SOQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. 
-
-Please treat this information  with priority as the sales order is already generated.
-
-Severity: Major
-
-Thanks,
-{CURRENTUSER}';
-
-		
-               $this->db->query("insert into inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("inventorynotification").",'SalesOrderNotification','Sales Order generated for {PRODUCTNAME}','".$so_body." ','SalesOrderNotificationDescription')");
-
-		//Insert into currency table
-		$this->db->query("insert into currency_info values(".$this->db->getUniqueID("currency_info").",'U.S Dollar','USD','$',1,'Active','-11')");
-                
-
-
-
-//insert into email template table
-
-	$body='
-	Hello!
-
-	On behalf of the vtiger team,  I am pleased to announce the release of vtiger crm4.2 . This is a feature packed release including the mass email template handling, custom view feature, reports feature and a host of other utilities. vtiger runs on all platforms.
-
-	Notable Features of vtiger are :
-	-Email Client Integration
-	-Trouble Ticket Integration
-	-Invoice Management Integration
-	-Reports Integration
-	-Portal Integration
-	-Enhanced Word Plugin Support
-	-Custom View Integration
-
-	Known Issues:
-	-ABCD
-	-EFGH
-	-IJKL
-	-MNOP
-	-QRST';
-
-          $this->db->query("insert into emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Announcement for Release','Announcement for Release','Announcement of a release','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
-	
-
-
-$body='name
-street,
-city,
-state,
- zip)
- 
- Dear
- 
- Please check the following invoices that are yet to be paid by you:
- 
- No. Date      Amount
- 1   1/1/01    $4000
- 2   2/2//01   $5000
- 3   3/3/01    $10000
- 4   7/4/01    $23560
- 
- Kindly let us know if there are any issues that you feel are pending to be discussed.
- We will be more than happy to give you a call.
- We would like to continue our business with you.
- 
- Sincerely,
- name
- title';
-
-
-               $this->db->query("insert into emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Pending Invoices','Invoices Pending','Payment Due','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
-
-
-
-
-
-$body=' Dear
-
-Your proposal on the project XYZW has been reviewed by us
-and is acceptable in its entirety.
-
-We are eagerly looking forward to this project
-and are pleased about having the opportunity to work
-together. We look forward to a long standing relationship
-with your esteemed firm.
-
-I would like to take this opportunity to invite you
-to a game of golf on Wednesday morning 9am at the
-Cuff Links Ground. We will be waiting for you in the
-Executive Lounge.
-
-Looking forward to seeing you there.
-
-Sincerely,
-name
-title';
-	       
-               $this->db->query("insert into emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Acceptance Proposal','Acceptance Proposal','Acceptance of Proposal','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
-
-
-$body= ' The undersigned hereby acknowledges receipt and delivery
-of the goods.
-The undersigned will release the payment subject to the goods being discovered not satisfactory.
-
-Signed under seal this <date>
-
-Sincerely,
-name
-title';
-	       
-               $this->db->query("insert into emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Goods received acknowledgement','Goods received acknowledgement','Acknowledged Receipt of Goods','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
-
-
-	       $body= ' Dear
-	 We are in receipt of your order as contained in the
-   purchase order form.We consider this to be final and binding on both sides.
-If there be any exceptions noted, we shall consider them
-only if the objection is received within ten days of receipt of
-this notice.
-
-Thank you for your patronage.
-Sincerely,
-name
-title';
-
-
-	       
-               $this->db->query("insert into emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Accept Order','Accept Order','Acknowledgement/Acceptance of Order','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
-
-
-
-
-$body='Dear
-
-We are relocating our office to
-11111,XYZDEF Cross,
-UVWWX Circle
-The telephone number for this new location is (101) 1212-1328.
-
-Our Manufacturing Division will continue operations
-at 3250 Lovedale Square Avenue, in Frankfurt.
-
-We hope to keep in touch with you all.
-Please update your addressbooks.
-
-
-Thank You,
-name
-title';
-	       
-               $this->db->query("insert into emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Address Change','Change of Address','Address Change','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
-
-
-
-$body='Dear
-
-Thank you for extending us the opportunity to meet with
-you and members of your staff.
-
-I know that John Doe serviced your account
-for many years and made many friends at your firm. He has personally
-discussed with me the deep relationship that he had with your firm.
-While his presence will be missed, I can promise that we will
-continue to provide the fine service that was accorded by
-John to your firm.
-
-I was genuinely touched to receive such fine hospitality.
-
-Thank you once again.
-
-Sincerely,
-name
-title';
-
-
-	       
-               $this->db->query("insert into emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Follow Up','Follow Up','Follow Up of meeting','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
-
-
-
-$body='Congratulations!
-
-The numbers are in and I am proud to inform you that our
-total sales for the previous quarter
-amounts to $100,000,00.00!. This is the first time
-we have exceeded the target by almost 30%.
-We have also beat the previous quarter record by a
-whopping 75%!
-
-Let us meet at Smoking Joe for a drink in the evening!
-
-C you all there guys!
-
-Sincerely,
-name
-title';
-
-	       
-               $this->db->query("insert into emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Target Crossed!','Target Crossed!','Fantastic Sales Spree!','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
-
-$body='
-Dear
-
-Thank you for your confidence in our ability to serve you.
-We are glad to be given the chance to serve you.I look
-forward to establishing a long term partnership with you.
-Consider me as a friend.
-Should any need arise,please do give us a call.
-
-Sincerely,
-name
-title';
-
-	       
-               $this->db->query("insert into emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Thanks Note','Thanks Note','Note of thanks','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
-
-		
-	       //Insert into organizationdetails table 
-	       $this->db->query("insert into organizationdetails(organizationame,address,city,state,country,code,phone,fax,website,logoname) values ('vtiger',' 40-41-42, Sivasundar Apartments, Flat D-II, Shastri Street, Velachery','Chennai','Tamil Nadu','India','600 042','+91-44-5202-1990','+91-44-5202-1990','www.vtiger.com','vtiger-crm-logo.jpg')");
-
-  //Insert into inventory_tandc table
-               $this->db->query("insert into inventory_tandc values('".$this->db->getUniqueID('inventory_tandc')."','Inventory','')");
-
-	$this->db->query("insert into actionmapping values(0,'Save',0)");
-	$this->db->query("insert into actionmapping values(1,'EditView',0)");
-	$this->db->query("insert into actionmapping values(2,'Delete',0)");
-	$this->db->query("insert into actionmapping values(3,'index',0)");
-	$this->db->query("insert into actionmapping values(4,'DetailView',0)");
-	$this->db->query("insert into actionmapping values(5,'Import',0)");
-	$this->db->query("insert into actionmapping values(6,'Export',0)");
-	//$this->db->query("insert into actionmapping values(7,'AddBusinessCard',0)");
-	$this->db->query("insert into actionmapping values(8,'Merge',0)");
-	$this->db->query("insert into actionmapping values(1,'VendorEditView',1)");
-	$this->db->query("insert into actionmapping values(4,'VendorDetailView',1)");
-	$this->db->query("insert into actionmapping values(0,'SaveVendor',1)");
-	$this->db->query("insert into actionmapping values(2,'DeleteVendor',1)");
-	$this->db->query("insert into actionmapping values(1,'PriceBookEditView',1)");
-	$this->db->query("insert into actionmapping values(4,'PriceBookDetailView',1)");
-	$this->db->query("insert into actionmapping values(0,'SavePriceBook',1)");
-	$this->db->query("insert into actionmapping values(2,'DeletePriceBook',1)");
-	$this->db->query("insert into actionmapping values(9,'ConvertLead',0)");
-	$this->db->query("insert into actionmapping values(1,'DetailViewAjax',1)");
-	$this->db->query("insert into actionmapping values(4,'TagCloud',1)");
-	$this->db->query("insert into actionmapping values(1,'QuickCreate',1)");
-	$this->db->query("insert into actionmapping values(3,'Popup',1)");
-
-	//Insert values for moduleowners table which contains the modules and their users. default user id admin - after 4.2 patch 2
-	$module_array = Array('Potentials','Contacts','Accounts','Leads','Notes','Activities','Emails','HelpDesk','Products','Faq','Vendors','PriceBooks','Quotes','PurchaseOrder','SalesOrder','Invoice','Reports','Campaigns');
-	foreach($module_array as $mod)
-	{
-		$this->db->query("insert into moduleowners values(".getTabid($mod).",1)");
-	}
-	//added by jeri for category view from db
-	$this->db->query("insert into parenttab values (1,'My Home Page',1,0)");
-	$this->db->query("insert into parenttab values (2,'Marketing',2,0)");
-	$this->db->query("insert into parenttab values (3,'Sales',3,0)");
-	$this->db->query("insert into parenttab values (4,'Support',4,0)");
-	$this->db->query("insert into parenttab values (5,'Analytics',5,0)");
-	$this->db->query("insert into parenttab values (6,'Inventory',6,0)");
-	$this->db->query("insert into parenttab values (7,'Tools',7,0)");
-	$this->db->query("insert into parenttab values (8,'Settings',8,0)");
-
-	$this->db->query("insert into parenttabrel values (1,9,2)");
-	$this->db->query("insert into parenttabrel values (1,17,3)");
-	$this->db->query("insert into parenttabrel values (1,10,4)");
-	$this->db->query("insert into parenttabrel values (1,3,1)");
-	$this->db->query("insert into parenttabrel values (3,7,1)");
-	$this->db->query("insert into parenttabrel values (3,6,2)");
-	$this->db->query("insert into parenttabrel values (3,4,3)");
-	$this->db->query("insert into parenttabrel values (3,2,4)");
-	$this->db->query("insert into parenttabrel values (3,20,5)");
-	$this->db->query("insert into parenttabrel values (3,22,6)");
-	$this->db->query("insert into parenttabrel values (3,23,7)");
-	$this->db->query("insert into parenttabrel values (3,14,8)");
-	$this->db->query("insert into parenttabrel values (3,19,9)");
-	$this->db->query("insert into parenttabrel values (3,8,10)");
-	$this->db->query("insert into parenttabrel values (4,13,1)");
-	$this->db->query("insert into parenttabrel values (4,15,2)");
-	$this->db->query("insert into parenttabrel values (4,6,3)");
-	$this->db->query("insert into parenttabrel values (4,4,4)");
-	$this->db->query("insert into parenttabrel values (4,14,5)");
-	$this->db->query("insert into parenttabrel values (4,8,6)");
-	$this->db->query("insert into parenttabrel values (5,1,1)");
-	$this->db->query("insert into parenttabrel values (5,25,2)");
-	$this->db->query("insert into parenttabrel values (6,14,1)");
-	$this->db->query("insert into parenttabrel values (6,18,2)");
-	$this->db->query("insert into parenttabrel values (6,19,3)");
-	$this->db->query("insert into parenttabrel values (6,21,4)");
-	$this->db->query("insert into parenttabrel values (6,22,5)");
-	$this->db->query("insert into parenttabrel values (6,20,6)");
-	$this->db->query("insert into parenttabrel values (6,23,7)");
-	$this->db->query("insert into parenttabrel values (7,24,1)");
-	$this->db->query("insert into parenttabrel values (7,27,2)");
-	$this->db->query("insert into parenttabrel values (7,8,3)");
-	$this->db->query("insert into parenttabrel values (2,26,1)");
-	$this->db->query("insert into parenttabrel values (2,6,2)");
-	$this->db->query("insert into parenttabrel values (2,4,3)");
-	$this->db->query("insert into parenttabrel values (2,10,4)");
-	$this->db->query("insert into parenttabrel values (4,10,7)");
-
-	//Added to populate the default inventory tax informations
-	$this->db->query("insert into inventorytaxinfo values(".$this->db->getUniqueID("inventorytaxinfo").",'VAT','4.5')");
-	$this->db->query("insert into inventorytaxinfo values(".$this->db->getUniqueID("inventorytaxinfo").",'Sales','10')");
-	$this->db->query("insert into inventorytaxinfo values(".$this->db->getUniqueID("inventorytaxinfo").",'Service','12.5')");
-	
-	}
-}
-?>
+<?php
+
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ ********************************************************************************/
+
+include_once('config.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+require_once('data/SugarBean.php');
+require_once('data/CRMEntity.php');
+require_once('include/utils/utils.php');
+
+class DefaultDataPopulator extends CRMEntity {
+		
+	function DefaultDataPopulator() {
+		$this->log = LoggerManager::getLogger('DefaultDataPopulator');
+		$this->db = new PearDatabase();
+	}
+
+	var $new_schema = true;
+
+	function create_tables () {
+		global $app_strings;
+
+		$role1_id = $this->db->getUniqueID("role");
+		$role2_id = $this->db->getUniqueID("role");
+		$role3_id = $this->db->getUniqueID("role");
+
+		$profile1_id = $this->db->getUniqueID("profile");
+		$profile2_id = $this->db->getUniqueID("profile");
+		$profile3_id = $this->db->getUniqueID("profile");
+		$profile4_id = $this->db->getUniqueID("profile");
+
+                $this->db->query("insert into vtiger_role values('H".$role1_id."','Organisation','H".$role1_id."',0)");
+                $this->db->query("insert into vtiger_role values('H".$role2_id."','administrator','H".$role1_id."::H".$role2_id."',1)");
+                $this->db->query("insert into vtiger_role values('H".$role3_id."','standard_user','H".$role1_id."::H".$role2_id."::H".$role3_id."',2)");
+                
+
+ $this->db->query("INSERT INTO vtiger_tab VALUES (3,'Home',0,1,'Home',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (7,'Leads',0,4,'Leads',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (6,'Accounts',0,5,'Accounts',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (4,'Contacts',0,6,'Contacts',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (2,'Potentials',0,7,'Potentials',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (8,'Notes',0,9,'Notes',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (9,'Activities',0,3,'Activities',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (10,'Emails',0,10,'Emails',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (13,'HelpDesk',0,11,'HelpDesk',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (14,'Products',0,8,'Products',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (1,'Dashboard',0,12,'Dashboards',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (15,'Faq',0,14,'Faq',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (16,'Events',2,13,'Events',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (17,'Calendar',0,2,'Calendar',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (18,'Vendors',0,15,'Vendors',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (19,'PriceBooks',0,16,'PriceBooks',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (20,'Quotes',0,17,'Quotes',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (21,'PurchaseOrder',0,18,'PurchaseOrder',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (22,'SalesOrder',0,19,'SalesOrder',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (23,'Invoice',0,20,'Invoice',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (24,'Rss',0,21,'Rss',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (25,'Reports',0,22,'Reports',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (26,'Campaigns',0,23,'Campaigns',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (27,'Portal',0,24,'Portal',null,null,1)");
+ $this->db->query("INSERT INTO vtiger_tab VALUES (28,'Webmails',0,25,'Webmails',null,null,1)");
+
+// Populate the vtiger_blocks vtiger_table
+$this->db->query("insert into vtiger_blocks values (1,2,'LBL_OPPORTUNITY_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (2,2,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (3,2,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (4,4,'LBL_CONTACT_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (5,4,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (6,4,'LBL_CUSTOMER_PORTAL_INFORMATION',3,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (7,4,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (8,4,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (9,6,'LBL_ACCOUNT_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (10,6,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (11,6,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (12,6,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (13,7,'LBL_LEAD_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (14,7,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (15,7,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (16,7,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (17,8,'LBL_NOTE_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (18,8,'',2,1,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (19,9,'LBL_TASK_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (20,9,'',2,1,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (21,10,'LBL_EMAIL_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (22,10,'',2,1,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (23,10,'',3,1,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (24,10,'',4,1,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (25,13,'LBL_TICKET_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (26,13,'',2,1,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (27,13,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (28,13,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (29,13,'LBL_TICKET_RESOLUTION',5,0,0,1,0,0)");
+$this->db->query("insert into vtiger_blocks values (30,13,'LBL_COMMENTS',6,0,0,1,0,0)");
+$this->db->query("insert into vtiger_blocks values (31,14,'LBL_PRODUCT_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (32,14,'LBL_PRICING_INFORMATION',2,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (33,14,'LBL_STOCK_INFORMATION',3,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (34,14,'LBL_CUSTOM_INFORMATION',4,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (35,14,'LBL_IMAGE_INFORMATION',5,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (36,14,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (37,15,'LBL_FAQ_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (38,15,'',2,1,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (39,15,'',3,1,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (40,15,'LBL_COMMENT_INFORMATION',4,0,0,1,0,0)");
+$this->db->query("insert into vtiger_blocks values (41,16,'LBL_EVENT_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (42,16,'',2,1,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (43,16,'',3,1,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (44,18,'LBL_VENDOR_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (45,18,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (46,18,'LBL_VENDOR_ADDRESS_INFORMATION',3,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (47,18,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (48,19,'LBL_PRICEBOOK_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (49,19,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (50,19,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (51,20,'LBL_QUOTE_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (52,20,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (53,20,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (54,20,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (55,20,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (56,20,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (57,21,'LBL_PO_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (58,21,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (59,21,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (60,21,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (61,21,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (62,21,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (63,22,'LBL_SO_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (64,22,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (65,22,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (66,22,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (67,22,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (68,22,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (69,23,'LBL_INVOICE_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (70,23,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (71,23,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (72,23,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (73,23,'LBL_TERMS_INFORMATION',5,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (74,23,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (75,4,'LBL_IMAGE_INFORMATION',5,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (76,26,'LBL_CAMPAIGN_INFORMATION',1,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (77,26,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0)");
+$this->db->query("insert into vtiger_blocks values (78,26,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0)");
+
+//
+
+//Account Details -- START
+ //Block9
+
+$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'accountname','vtiger_account',1,'2','accountname','Account Name',1,0,0,100,1,9,1,'V~M',0,1,'BAS')");	
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'phone','vtiger_account',1,'11','phone','Phone',1,0,0,100,2,9,1,'V~O',0,2,'BAS')");	
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'website','vtiger_account',1,'17','website','Website',1,0,0,100,3,9,1,'V~O',0,3,'BAS')");	
+
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'fax','vtiger_account',1,'1','fax','Fax',1,0,0,100,4,9,1,'V~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'tickersymbol','vtiger_account',1,'1','tickersymbol','Ticker Symbol',1,0,0,100,5,9,1,'V~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'otherphone','vtiger_account',1,'11','otherphone','Other Phone',1,0,0,100,6,9,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'parentid','vtiger_account',1,'51','account_id','Member Of',1,0,0,100,7,9,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'email1','vtiger_account',1,'13','email1','Email',1,0,0,100,8,9,1,'E~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'employees','vtiger_account',1,'7','employees','Employees',1,0,0,100,9,9,1,'I~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'email2','vtiger_account',1,'13','email2','Other Email',1,0,0,100,10,9,1,'E~O',1,null,'ADV')");
+
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'ownership','vtiger_account',1,'1','ownership','Ownership',1,0,0,100,11,9,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'rating','vtiger_account',1,'1','rating','Rating',1,0,0,100,12,9,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'industry','vtiger_account',1,'15','industry','industry',1,0,0,100,13,9,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'siccode','vtiger_account',1,'1','siccode','SIC Code',1,0,0,100,14,9,1,'I~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'account_type','vtiger_account',1,'15','accounttype','Type',1,0,0,100,15,9,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'annualrevenue','vtiger_account',1,'71','annual_revenue','Annual Revenue',1,0,0,100,16,9,1,'I~O',1,null,'ADV')");
+ //Added vtiger_field emailoptout for vtiger_accounts -- after 4.2 patch2
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'emailoptout','vtiger_account',1,'56','emailoptout','Email Opt Out',1,0,0,100,17,9,1,'C~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'notify_owner','vtiger_account',1,56,'notify_owner','Notify Owner',1,0,0,10,18,9,1,'C~O',1,NULL,'ADV')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,19,9,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,20,9,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,21,9,2,'T~O',1,null,'BAS')");
+
+
+
+
+ //Block 11
+$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'street','vtiger_accountbillads',1,'21','bill_street','Billing Address',1,0,0,100,1,11,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'street','vtiger_accountshipads',1,'21','ship_street','Shipping Address',1,0,0,100,2,11,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'city','vtiger_accountbillads',1,'1','bill_city','Billing City',1,0,0,100,5,11,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'city','vtiger_accountshipads',1,'1','ship_city','Shipping City',1,0,0,100,6,11,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'state','vtiger_accountbillads',1,'1','bill_state','Billing State',1,0,0,100,7,11,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'state','vtiger_accountshipads',1,'1','ship_state','Shipping State',1,0,0,100,8,11,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'code','vtiger_accountbillads',1,'1','bill_code','Billing Code',1,0,0,100,9,11,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'code','vtiger_accountshipads',1,'1','ship_code','Shipping Code',1,0,0,100,10,11,1,'V~O',1,null,'BAS')");
+
+
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'country','vtiger_accountbillads',1,'1','bill_country','Billing Country',1,0,0,100,11,11,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'country','vtiger_accountshipads',1,'1','ship_country','Shipping Country',1,0,0,100,12,11,1,'V~O',1,null,'BAS')");
+
+$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'pobox','vtiger_accountbillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,11,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'pobox','vtiger_accountshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,11,1,'V~O',1,null,'BAS')");
+
+
+ //Block12
+$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,12,1,'V~O',1,null,'BAS')");
+ 
+
+
+//Account Details -- END
+
+			
+//Lead Details --- START
+
+//Block13 -- Start
+
+$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'salutation','vtiger_leaddetails',1,'55','salutationtype','Salutation',1,0,0,100,1,13,3,'V~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'firstname','vtiger_leaddetails',1,'55','firstname','First Name',1,0,0,100,2,13,1,'V~O',0,1,'BAS')");	
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'phone','vtiger_leadaddress',1,'11','phone','Phone',1,0,0,100,3,13,1,'V~O',0,4,'BAS')");	
+
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'lastname','vtiger_leaddetails',1,'2','lastname','Last Name',1,0,0,100,4,13,1,'V~M',0,2,'BAS')");	
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'mobile','vtiger_leadaddress',1,'1','mobile','Mobile',1,0,0,100,5,13,1,'V~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'company','vtiger_leaddetails',1,'2','company','Company',1,0,0,100,6,13,1,'V~M',0,3,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'campaignid','vtiger_leaddetails',1,'51','campaignid','Campaign Name',1,0,0,100,6,4,3,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'fax','vtiger_leadaddress',1,'1','fax','Fax',1,0,0,100,7,13,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'designation','vtiger_leaddetails',1,'1','designation','Designation',1,0,0,100,8,13,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'email','vtiger_leaddetails',1,'13','email','Email',1,0,0,100,9,13,1,'E~O',0,5,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'leadsource','vtiger_leaddetails',1,'15','leadsource','Lead Source',1,0,0,100,10,13,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'website','vtiger_leadsubdetails',1,'17','website','Website',1,0,0,100,11,13,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'industry','vtiger_leaddetails',1,'15','industry','Industry',1,0,0,100,12,13,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'leadstatus','vtiger_leaddetails',1,'15','leadstatus','Lead Status',1,0,0,100,13,13,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'annualrevenue','vtiger_leaddetails',1,'71','annualrevenue','Annual Revenue',1,0,0,100,14,13,1,'I~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'rating','vtiger_leaddetails',1,'15','rating','Rating',1,0,0,100,15,13,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'noofemployees','vtiger_leaddetails',1,'1','noofemployees','No Of Employees',1,0,0,100,16,13,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,17,13,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'yahooid','vtiger_leaddetails',1,'13','yahooid','Yahoo Id',1,0,0,100,18,13,1,'V~O',1,null,'ADV')");
+$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,19,13,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,20,13,2,'T~O',1,null,'BAS')");
+
+//Block13 -- End
+
+
+//Block15 -- Start
+
+$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'lane','vtiger_leadaddress',1,'21','lane','Street',1,0,0,100,1,15,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'code','vtiger_leadaddress',1,'1','code','Postal Code',1,0,0,100,3,15,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'city','vtiger_leadaddress',1,'1','city','City',1,0,0,100,4,15,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'country','vtiger_leadaddress',1,'1','country','Country',1,0,0,100,5,15,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'state','vtiger_leadaddress',1,'1','state','State',1,0,0,100,6,15,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'pobox','vtiger_leadaddress',1,'1','pobox','Po Box',1,0,0,100,2,15,1,'V~O',1,null,'BAS')");
+
+//Block15 --End
+
+//Block16 -- Start
+
+$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,16,1,'V~O',1,null,'BAS')");
+
+//Block16 -- End
+
+//Lead Details -- END
+
+
+//Contact Details -- START
+//Block4 -- Start
+
+$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'salutation','vtiger_contactdetails',1,'55','salutationtype','Salutation',1,0,0,100,1,4,3,'V~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'firstname','vtiger_contactdetails',1,'55','firstname','First Name',1,0,0,100,2,4,1,'V~O',0,1,'BAS')");	
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'phone','vtiger_contactdetails',1,'11','phone','Office Phone',1,0,0,100,3,4,1,'V~O',0,4,'BAS')");	
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'lastname','vtiger_contactdetails',1,'2','lastname','Last Name',1,0,0,100,4,4,1,'V~M',0,2,'BAS')");	
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'mobile','vtiger_contactdetails',1,'1','mobile','Mobile',1,0,0,100,5,4,1,'V~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'accountid','vtiger_contactdetails',1,'51','account_id','Account Name',1,0,0,100,6,4,1,'I~O',0,3,'BAS')");	
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'campaignid','vtiger_contactdetails',1,'51','campaignid','Campaign Name',1,0,0,100,6,4,3,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'homephone','vtiger_contactsubdetails',1,'11','homephone','Home Phone',1,0,0,100,7,4,1,'V~O',1,null,'ADV')");	
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'leadsource','vtiger_contactsubdetails',1,'15','leadsource','Lead Source',1,0,0,100,8,4,1,'V~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'otherphone','vtiger_contactsubdetails',1,'11','otherphone','Phone',1,0,0,100,9,4,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'title','vtiger_contactdetails',1,'1','title','Title',1,0,0,100,10,4,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'fax','vtiger_contactdetails',1,'1','fax','Fax',1,0,0,100,11,4,1,'V~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'department','vtiger_contactdetails',1,'1','department','Department',1,0,0,100,12,4,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'birthday','vtiger_contactsubdetails',1,'5','birthday','Birthdate',1,0,0,100,14,4,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'email','vtiger_contactdetails',1,'13','email','Email',1,0,0,100,15,4,1,'E~O',0,5,'ADV')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'reportsto','vtiger_contactdetails',1,'57','contact_id','Reports To',1,0,0,100,16,4,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'assistant','vtiger_contactsubdetails',1,'1','assistant','Assistant',1,0,0,100,17,4,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'yahooid','vtiger_contactdetails',1,'13','yahooid','Yahoo Id',1,0,0,100,18,4,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'assistantphone','vtiger_contactsubdetails',1,'11','assistantphone','Assistant Phone',1,0,0,100,19,4,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'donotcall','vtiger_contactdetails',1,'56','donotcall','Do Not Call',1,0,0,100,20,4,1,'C~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'emailoptout','vtiger_contactdetails',1,'56','emailoptout','Email Opt Out',1,0,0,100,21,4,1,'C~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,22,4,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'reference','vtiger_contactdetails',1,'56','reference','Reference',1,0,0,10,23,4,1,'C~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'notify_owner','vtiger_contactdetails',1,'56','notify_owner','Notify Owner',1,0,0,10,24,4,1,'C~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,25,4,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,26,4,2,'T~O',1,null,'BAS')");
+
+//Block4 -- End
+
+//Block6 - Begin Customer Portal
+
+$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'portal','vtiger_customerdetails',1,'56','portal','Portal User',1,0,0,100,1,6,1,'C~O',1,null,'ADV')");
+$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'support_start_date','vtiger_customerdetails',1,'5','support_start_date','Support Start Date',1,0,0,100,2,6,1,'D~O',1,null,'ADV')");
+$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'support_end_date','vtiger_customerdetails',1,'5','support_end_date','Support End Date',1,0,0,100,3,6,1,'D~O~OTH~GE~support_start_date~Support Start Date',1,null,'ADV')");
+
+//Block6 - End Customer Portal
+
+//Block 7 -- Start
+
+$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'mailingstreet','vtiger_contactaddress',1,'21','mailingstreet','Mailing Street',1,0,0,100,1,7,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'otherstreet','vtiger_contactaddress',1,'21','otherstreet','Other Street',1,0,0,100,2,7,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'mailingcity','vtiger_contactaddress',1,'1','mailingcity','Mailing City',1,0,0,100,5,7,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'othercity','vtiger_contactaddress',1,'1','othercity','Other City',1,0,0,100,6,7,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'mailingstate','vtiger_contactaddress',1,'1','mailingstate','Mailing State',1,0,0,100,7,7,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'otherstate','vtiger_contactaddress',1,'1','otherstate','Other State',1,0,0,100,8,7,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'mailingzip','vtiger_contactaddress',1,'1','mailingzip','Mailing Zip',1,0,0,100,9,7,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'otherzip','vtiger_contactaddress',1,'1','otherzip','Other Zip',1,0,0,100,10,7,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'mailingcountry','vtiger_contactaddress',1,'1','mailingcountry','Mailing Country',1,0,0,100,11,7,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'othercountry','vtiger_contactaddress',1,'1','othercountry','Other Country',1,0,0,100,12,7,1,'V~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'mailingpobox','vtiger_contactaddress',1,'1','mailingpobox','Mailing Po Box',1,0,0,100,3,7,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'otherpobox','vtiger_contactaddress',1,'1','otherpobox','Other Po Box',1,0,0,100,4,7,1,'V~O',1,null,'BAS')");
+//Block7 -- End
+
+//ContactImageInformation
+ $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'imagename','vtiger_contactdetails',1,'69','imagename','Contact Image',1,0,0,100,1,75,1,'V~O',1,null,'ADV')");
+
+
+//Block8 -- Start
+$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,8,1,'V~O',1,null,'BAS')");
+//Block8 -- End
+//Contact Details -- END
+
+
+//Potential Details -- START
+//Block1 -- Start
+
+$this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'potentialname','vtiger_potential',1,'2','potentialname','Potential Name',1,0,0,100,1,1,1,'V~M',0,1,'BAS')");	
+ $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'amount','vtiger_potential',1,71,'amount','Amount',1,0,0,100,2,1,1,'N~O',0,5,'BAS')");	
+ $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'accountid','vtiger_potential',1,'50','account_id','Account Name',1,0,0,100,3,1,1,'V~M',0,2,'BAS')");	
+ $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'closingdate','vtiger_potential',1,'23','closingdate','Expected Close Date',1,0,0,100,5,1,1,'D~M',0,3,'BAS')");	
+ $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'potentialtype','vtiger_potential',1,'15','opportunity_type','Type',1,0,0,100,6,1,1,'V~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'nextstep','vtiger_potential',1,'1','nextstep','Next Step',1,0,0,100,7,1,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'leadsource','vtiger_potential',1,'15','leadsource','Lead Source',1,0,0,100,8,1,1,'V~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'sales_stage','vtiger_potential',1,'16','sales_stage','Sales Stage',1,0,0,100,9,1,1,'V~O',0,4,'BAS')");
+ $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,10,1,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'probability','vtiger_potential',1,'9','probability','Probability',1,0,0,100,11,1,1,'N~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,13,1,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,14,1,2,'T~O',1,null,'BAS')");
+
+//Block1 -- End
+
+//Block3 -- Start
+
+ $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,3,1,'V~O',1,null,'BAS')");
+
+//Block3 -- End
+//Potential Details -- END
+
+
+//Rss entries being added
+ $this->db->query("insert into vtiger_field values (24,".$this->db->getUniqueID("field").",'rsscategory','vtiger_rss',1,'15','rsscategory','rsscategory',1,0,0,255,13,null,1,'V~O',1,null,'BAS')");
+//End of Rss entries
+
+//campaign entries being added
+
+
+ $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'campaignname','vtiger_campaign',1,'2','campaignname','Campaign Name',1,0,0,100,1,76,1,'V~M',0,1,'BAS')");
+ $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'campaigntype','vtiger_campaign',1,15,'campaigntype','Campaign Type',1,0,0,100,2,76,1,'V~O',0,5,'BAS')");
+ $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'product_id','vtiger_campaign',1,59,'product_id','Product',1,0,0,100,3,76,1,'I~O',0,5,'BAS')");
+ $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'campaignstatus','vtiger_campaign',1,15,'campaignstatus','Campaign Status',1,0,0,100,4,76,1,'V~O',0,5,'BAS')");
+ $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'closingdate','vtiger_campaign',1,'23','closingdate','Expected Close Date',1,0,0,100,5,76,1,'D~M',0,3,'BAS')");
+ $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'expectedrevenue','vtiger_campaign',1,'1','expectedrevenue','Expected Revenue',1,0,0,100,6,76,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'budgetcost','vtiger_campaign',1,'1','budgetcost','Budget Cost',1,0,0,100,7,76,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'actualcost','vtiger_campaign',1,'1','actualcost','Actual Cost',1,0,0,100,8,76,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'expectedresponse','vtiger_campaign',1,'15','expectedresponse','Expected Response',1,0,0,100,9,76,1,'V~O',0,4,'BAS')");
+ $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,10,76,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'numsent','vtiger_campaign',1,'9','numsent','Num Sent',1,0,0,100,11,76,1,'N~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'sponsor','vtiger_campaign',1,'1','sponsor','Sponsor',1,0,0,100,12,76,1,'V~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'targetaudience','vtiger_campaign',1,'1','targetaudience','Target Audience',1,0,0,100,13,76,1,'V~O',1,null,'BAS')");
+
+$this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("field").",'targetsize','vtiger_campaign',1,'1','targetsize','TargetSize',1,0,0,100,14,76,1,'N~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("field").",'expectedresponsecount','vtiger_campaign',1,'1','expectedresponsecount','Expected Response Count',1,0,0,100,17,76,1,'N~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("field").",'expectedsalescount','vtiger_campaign',1,'1','expectedsalescount','Expected Sales Count',1,0,0,100,15,76,1,'N~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("field").",'expectedroi','vtiger_campaign',1,'1','expectedroi','Expected ROI',1,0,0,100,19,76,1,'N~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("field").",'actualresponsecount','vtiger_campaign',1,'1','actualresponsecount','Actual Response Count',1,0,0,100,18,76,1,'N~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("field").",'actualsalescount','vtiger_campaign',1,'1','actualsalescount','Actual Sales Count',1,0,0,100,16,76,1,'N~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("field").",'actualroi','vtiger_campaign',1,'1','actualroi','Actual ROI',1,0,0,100,20,76,1,'N~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,15,76,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,16,76,2,'T~O',1,null,'BAS')");
+
+$this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,78,1,'V~O',1,null,'BAS')");
+
+//Campaign entries end
+
+
+//Ticket Details -- START
+//Block25 -- Start
+
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,2,25,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'parent_id','vtiger_troubletickets',1,'68','parent_id','Related To',1,0,0,100,4,25,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'priority','vtiger_troubletickets',1,'15','ticketpriorities','Priority',1,0,0,100,5,25,1,'V~O',0,3,'BAS')");
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'product_id','vtiger_troubletickets',1,'59','product_id','Product Name',1,0,0,100,6,25,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'severity','vtiger_troubletickets',1,'15','ticketseverities','Severity',1,0,0,100,7,25,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'status','vtiger_troubletickets',1,'15','ticketstatus','Status',1,0,0,100,8,25,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'category','vtiger_troubletickets',1,'15','ticketcategories','Category',1,0,0,100,9,25,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'update_log','vtiger_troubletickets',1,'15','update_log','Update History',1,0,0,100,9,25,3,'V~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,10,25,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,11,25,2,'T~O',1,null,'BAS')");
+ //Added on 26-12-2005 to add attachment in ticket editview
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'filename','vtiger_attachments',1,'61','filename','Attachment',1,0,0,100,12,26,1,'V~O',0,1,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'title','vtiger_troubletickets',1,'22','ticket_title','Title',1,0,0,100,1,26,1,'V~M',0,1,'BAS')");
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'description','vtiger_troubletickets',1,'19','description','Description',1,0,0,100,1,28,1,'V~O',0,2,'BAS')");
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'solution','vtiger_troubletickets',1,'19','solution','Solution',1,0,0,100,1,29,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("field").",'comments','vtiger_ticketcomments',1,'19','comments','Add Comment',1,0,0,100,1,30,1,'V~O',1,null,'BAS')");
+
+//Block25-30 -- End
+//Ticket Details -- END
+
+//Product Details -- START
+//Block31-36 -- Start
+
+$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'productname','vtiger_products',1,'2','productname','Product Name',1,0,0,100,1,31,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'productcode','vtiger_products',1,'1','productcode','Product Code',1,0,0,100,2,31,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'discontinued','vtiger_products',1,'56','discontinued','Product Active',1,0,0,100,3,31,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'manufacturer','vtiger_products',1,'15','manufacturer','Manufacturer',1,0,0,100,4,1,31,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'productcategory','vtiger_products',1,'15','productcategory','Product Category',1,0,0,100,4,31,1,'V~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'sales_start_date','vtiger_products',1,'5','sales_start_date','Sales Start Date',1,0,0,100,5,31,1,'D~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'sales_end_date','vtiger_products',1,'5','sales_end_date','Sales End Date',1,0,0,100,6,31,1,'D~O~OTH~GE~sales_start_date~Sales Start Date',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'start_date','vtiger_products',1,'5','start_date','Support Start Date',1,0,0,100,7,31,1,'D~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'expiry_date','vtiger_products',1,'5','expiry_date','Support Expiry Date',1,0,0,100,8,31,1,'D~O~OTH~GE~start_date~Start Date',1,null,'BAS')");
+ 
+
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'crmid','vtiger_seproductsrel',1,'66','parent_id','Related To',1,0,0,100,10,31,1,'I~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'contactid','vtiger_products',1,'57','contact_id','Contact Name',1,0,0,100,11,31,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'website','vtiger_products',1,'17','website','Website',1,0,0,100,12,31,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'vendor_id','vtiger_products',1,'75','vendor_id','Vendor Name',1,0,0,100,13,31,1,'I~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'mfr_part_no','vtiger_products',1,'1','mfr_part_no','Mfr PartNo',1,0,0,100,14,31,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'vendor_part_no','vtiger_products',1,'1','vendor_part_no','Vendor PartNo',1,0,0,100,15,31,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'serialno','vtiger_products',1,'1','serial_no','Serial No',1,0,0,100,16,31,1,'V~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'productsheet','vtiger_products',1,'1','productsheet','Product Sheet',1,0,0,100,17,31,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'glacct','vtiger_products',1,'15','glacct','GL Account',1,0,0,100,18,31,1,'V~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,19,31,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,20,31,2,'T~O',1,null,'BAS')");
+
+
+//Block32 Pricing Information
+
+$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'unit_price','vtiger_products',1,'71','unit_price','Unit Price',1,0,0,100,1,32,1,'N~O',1,null,'BAS')"); 
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'commissionrate','vtiger_products',1,'9','commissionrate','Commission Rate',1,0,0,100,2,32,1,'N~O',1,null,'BAS')"); 
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'taxclass','vtiger_producttaxrel',1,'83','taxclass','Tax Class',1,0,0,100,4,32,1,'V~O',1,null,'BAS')");
+
+
+//Block 33 stock info
+
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'usageunit','vtiger_products',1,'15','usageunit','Usage Unit',1,0,0,100,1,33,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'qty_per_unit','vtiger_products',1,'1','qty_per_unit','Qty/Unit',1,0,0,100,2,33,1,'N~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'qtyinstock','vtiger_products',1,'1','qtyinstock','Qty In Stock',1,0,0,100,3,33,1,'I~O',1,null,'ADV')");
+$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'reorderlevel','vtiger_products',1,'1','reorderlevel','Reorder Level',1,0,0,100,4,33,1,'I~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'handler','vtiger_products',1,'52','assigned_user_id','Handler',1,0,0,100,5,33,1,'I~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'qtyindemand','vtiger_products',1,'1','qtyindemand','Qty In Demand',1,0,0,100,6,33,1,'I~O',1,null,'ADV')");
+
+
+//ProductImageInformation
+
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'imagename','vtiger_products',1,'69','imagename','Product Image',1,0,0,100,1,35,1,'V~O',1,null,'ADV')");
+
+
+//Block 36 Description Info
+ $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("field").",'product_description','vtiger_products',1,'19','product_description','Description',1,0,0,100,1,36,1,'V~O',1,null,'BAS')");
+
+//Product Details -- END
+
+//Note Details -- START
+//Block17 -- Start
+
+$this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("field").",'contact_id','vtiger_notes',1,'57','contact_id','Contact Name',1,0,0,100,1,17,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("field").",'crmid','vtiger_senotesrel',1,'62','parent_id','Related To',1,0,0,100,2,17,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("field").",'title','vtiger_notes',1,'2','title','Subject',1,0,0,100,3,17,1,'V~M',0,1,'BAS')");
+$this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,4,17,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,5,17,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("field").",'filename','vtiger_notes',1,'61','filename','Attachment',1,0,0,100,4,17,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("field").",'notecontent','vtiger_notes',1,'19','notecontent','Note',1,0,0,100,5,18,1,'V~O',1,null,'BAS')");
+
+//Block17 -- End
+//Note Details -- END
+
+//Email Details -- START
+//Block21 -- Start
+
+	$this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("field").",'date_start','vtiger_activity',1,'6','date_start','Date & Time Sent',1,0,0,100,1,21,1,'DT~M~time_start~Time Start',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("field").",'semodule','vtiger_activity',1,'2','parent_type','Sales Enity Module',1,0,0,100,2,21,3,'',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("field").",'activitytype','vtiger_activity',1,'2','activitytype','Activtiy Type',1,0,0,100,3,21,3,'V~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("field").",'crmid','vtiger_seactivityrel',1,'357','parent_id','Related To',1,0,0,100,1,22,1,'I~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,5,21,1,'V~M',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("field").",'subject','vtiger_activity',1,'2','subject','Subject',1,0,0,100,1,23,1,'V~M',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("field").",'filename','vtiger_attachments',1,'61','filename','Attachment',1,0,0,100,2,23,1,'V~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,24,1,'V~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("field").",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,0,100,9,1,23,'T~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,10,1,22,'T~O',1,null,'BAS')");
+ 	$this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,11,21,2,'T~O',1,null,'BAS')");
+
+//Block21 -- End
+//Email Details -- END
+
+//Task Details --START
+//Block19 -- Start
+$this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'subject','vtiger_activity',1,'2','subject','Subject',1,0,0,100,1,19,1,'V~M',0,1,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,2,19,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'date_start','vtiger_activity',1,'6','date_start','Start Date & Time',1,0,0,100,3,19,1,'DT~M~time_start',0,2,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,0,100,4,19,3,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'due_date','vtiger_activity',1,'23','due_date','Due Date',1,0,0,100,5,19,1,'D~M~OTH~GE~date_start~Start Date & Time',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'crmid','vtiger_seactivityrel',1,'66','parent_id','Related To',1,0,0,100,7,19,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'contactid','vtiger_cntactivityrel',1,'57','contact_id','Contact Name',1,0,0,100,8,19,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'status','vtiger_activity',1,'15','taskstatus','Status',1,0,0,100,9,19,1,'V~O',0,3,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'eventstatus','vtiger_activity',1,'15','eventstatus','Status',1,0,0,100,9,19,3,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'priority','vtiger_activity',1,'15','taskpriority','Priority',1,0,0,100,10,19,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'sendnotification','vtiger_activity',1,'56','sendnotification','Send Notification',1,0,0,100,11,19,1,'C~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,14,19,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,15,19,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'activitytype','vtiger_activity',1,'15','activitytype','Activity Type',1,0,0,100,16,19,3,'V~O',1,null,'BAS')");
+ $this->db->query("Insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'visibility','activity',1,15,'visibility','Visibility',1,0,0,100,17,19,3,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,20,1,'V~O',1,null,'BAS')");
+
+
+$this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'duration_hours','vtiger_activity',1,'63','duration_hours','Duration',1,0,0,100,17,19,3,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'duration_minutes','vtiger_activity',1,'15','duration_minutes','Duration Minutes',1,0,0,100,18,19,3,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'location','vtiger_activity',1,'1','location','Location',1,0,0,100,19,19,3,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'reminder_time','vtiger_activity_reminder',1,'30','reminder_time','Send Reminder',1,0,0,100,1,19,3,'I~O',1,null,'BAS')");
+ 
+ $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'recurringtype','vtiger_recurringevents',1,'15','recurringtype','Recurrence',1,0,0,100,6,19,3,'O~O',1,null,'BAS')");
+
+ $this->db->query("Insert into vtiger_field values (9,".$this->db->getUniqueID("field").",'notime','activity',1,56,'notime','No Time',1,0,0,100,20,19,3,'C~O',1,null,'BAS')");
+//Block19 -- End
+//Task Details -- END
+
+//Event Details --START
+//Block41-43-- Start
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'subject','vtiger_activity',1,'2','subject','Subject',1,0,0,100,1,41,1,'V~M',0,1,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,2,41,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'date_start','vtiger_activity',1,'6','date_start','Start Date & Time',1,0,0,100,3,41,1,'DT~M~time_start',0,2,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,0,100,4,41,3,'T~M',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'due_date','vtiger_activity',1,'23','due_date','End Date',1,0,0,100,5,41,1,'D~M~OTH~GE~date_start~Start Date & Time',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'recurringtype','vtiger_recurringevents',1,'15','recurringtype','Recurrence',1,0,0,100,6,41,1,'O~O',1,null,'BAS')");
+  
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'duration_hours','vtiger_activity',1,'63','duration_hours','Duration',1,0,0,100,7,41,1,'I~M',0,5,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'duration_minutes','vtiger_activity',1,'15','duration_minutes','Duration Minutes',1,0,0,100,8,41,3,'O~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'crmid','vtiger_seactivityrel',1,'66','parent_id','Related To',1,0,0,100,9,41,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'contactid','vtiger_cntactivityrel',1,'57','contact_id','Contact Name',1,0,0,100,10,41,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'eventstatus','vtiger_activity',1,'15','eventstatus','Status',1,0,0,100,11,41,1,'V~O',0,3,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'sendnotification','vtiger_activity',1,'56','sendnotification','Send Notification',1,0,0,100,12,41,1,'C~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'activitytype','vtiger_activity',1,'15','activitytype','Activity Type',1,0,0,100,13,41,1,'V~O',0,4,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'location','vtiger_activity',1,'1','location','Location',1,0,0,100,14,41,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,15,41,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,16,41,2,'T~O',1,null,'BAS')");
+ $this->db->query("Insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'priority','activity',1,15,'taskpriority','Priority',1,0,0,100,17,41,1,'V~O',1,null,'BAS')");
+ $this->db->query("Insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'notime','activity',1,56,'notime','No Time',1,0,0,100,18,41,1,'C~O',1,null,'BAS')");
+ $this->db->query("Insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'visibility','activity',1,15,'visibility','Visibility',1,0,0,100,19,41,1,'V~O',1,null,'BAS')");
+ 
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,43,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("field").",'reminder_time','vtiger_activity_reminder',1,'30','reminder_time','Send Reminder',1,0,0,100,1,42,1,'I~O',1,null,'BAS')");
+//Block41-43 -- End
+//Event Details -- END
+
+//Faq Details -- START
+//Block37-40 -- Start
+
+$this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("field").",'product_id','vtiger_faq',1,'59','product_id','Product Name',1,0,0,100,1,37,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("field").",'category','vtiger_faq',1,'15','faqcategories','Category',1,0,0,100,2,37,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("field").",'status','vtiger_faq',1,'15','faqstatus','Status',1,0,0,100,3,37,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("field").",'question','vtiger_faq',1,'20','question','Question',1,0,0,100,1,38,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("field").",'answer','vtiger_faq',1,'20','faq_answer','Answer',1,0,0,100,1,39,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("field").",'comments','vtiger_faqcomments',1,'19','comments','Add Comment',1,0,0,100,1,40,1,'V~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,3,37,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,4,37,2,'T~O',1,null,'BAS')");
+
+
+//Block37-40 -- End
+//Ticket Details -- END
+
+//Vendor Details --START
+//Block44-47
+
+$this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'vendorname','vtiger_vendor',1,'2','vendorname','Vendor Name',1,0,0,100,1,44,1,'V~M',0,1,'BAS')");
+ $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'phone','vtiger_vendor',1,'1','phone','Phone',1,0,0,100,3,44,1,'V~O',0,2,'BAS')");
+ $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'email','vtiger_vendor',1,'13','email','Email',1,0,0,100,4,44,1,'E~O',0,3,'BAS')");
+ $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'website','vtiger_vendor',1,'17','website','Website',1,0,0,100,5,44,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'glacct','vtiger_vendor',1,'15','glacct','GL Account',1,0,0,100,6,44,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'category','vtiger_vendor',1,'1','category','Category',1,0,0,100,7,44,1,'V~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,8,44,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,9,44,2,'T~O',1,null,'BAS')");
+
+//Block 46
+
+$this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'street','vtiger_vendor',1,'21','street','Street',1,0,0,100,1,46,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'pobox','vtiger_vendor',1,'1','pobox','Po Box',1,0,0,100,2,46,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'city','vtiger_vendor',1,'1','city','City',1,0,0,100,3,46,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'state','vtiger_vendor',1,'1','state','State',1,0,0,100,4,46,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'postalcode','vtiger_vendor',1,'1','postalcode','Postal Code',1,0,0,100,5,46,1,'V~O',1,null,'ADV')");
+ $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'country','vtiger_vendor',1,'1','country','Country',1,0,0,100,6,46,1,'V~O',1,null,'ADV')");
+
+//Block 47
+
+$this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,47,1,'V~O',1,null,'ADV')");
+
+//Vendor Details -- END
+
+//PriceBook Details Start
+//Block48
+
+$this->db->query("insert into vtiger_field values (19,".$this->db->getUniqueID("field").",'bookname','vtiger_pricebook',1,'2','bookname','Price Book Name',1,0,0,100,1,48,1,'V~M',0,1,'BAS')");
+ $this->db->query("insert into vtiger_field values (19,".$this->db->getUniqueID("field").",'active','vtiger_pricebook',1,'56','active','Active',1,0,0,100,3,48,1,'V~O',0,2,'BAS')");
+$this->db->query("insert into vtiger_field values (19,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,4,48,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (19,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,5,48,2,'T~O',1,null,'BAS')");
+
+//Block50
+
+$this->db->query("insert into vtiger_field values (19,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,50,1,'V~O',1,null,'BAS')");
+
+//PriceBook Details End
+
+
+//Quote Details -- START
+ //Block51
+
+$this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'subject','vtiger_quotes',1,'2','subject','Subject',1,0,0,100,1,51,1,'V~M',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'potentialid','vtiger_quotes',1,'76','potential_id','Potential Name',1,0,0,100,2,51,1,'I~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'quotestage','vtiger_quotes',1,'15','quotestage','Quote Stage',1,0,0,100,3,51,1,'V~O',1,null,'BAS')");	
+
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'validtill','vtiger_quotes',1,'5','validtill','Valid Till',1,0,0,100,4,51,1,'D~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'team','vtiger_quotes',1,'1','team','Team',1,0,0,100,5,51,1,'V~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'contactid','vtiger_quotes',1,'57','contact_id','Contact Name',1,0,0,100,6,51,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'carrier','vtiger_quotes',1,'15','carrier','Carrier',1,0,0,100,8,51,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'subtotal','vtiger_quotes',1,'1','hdnSubTotal','Sub Total',1,0,0,100,9,51,3,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'shipping','vtiger_quotes',1,'1','shipping','Shipping',1,0,0,100,10,51,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'inventorymanager','vtiger_quotes',1,'77','assigned_user_id1','Inventory Manager',1,0,0,100,11,51,1,'I~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'tax','vtiger_quotes',1,'1','txtTax','Tax',1,0,0,100,13,51,3,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'adjustment','vtiger_quotes',1,'1','txtAdjustment','Adjustment',1,0,0,100,20,51,3,'NN~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'total','vtiger_quotes',1,'1','hdnGrandTotal','Total',1,0,0,100,14,51,3,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'accountid','vtiger_quotes',1,'73','account_id','Account Name',1,0,0,100,16,51,1,'I~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,17,51,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,18,51,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,19,51,2,'T~O',1,null,'BAS')");
+
+
+ //Block 53
+
+$this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'bill_street','vtiger_quotesbillads',1,'24','bill_street','Billing Address',1,0,0,100,1,53,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'ship_street','vtiger_quotesshipads',1,'24','ship_street','Shipping Address',1,0,0,100,2,53,1,'V~M',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'bill_city','vtiger_quotesbillads',1,'1','bill_city','Billing City',1,0,0,100,5,53,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'ship_city','vtiger_quotesshipads',1,'1','ship_city','Shipping City',1,0,0,100,6,53,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'bill_state','vtiger_quotesbillads',1,'1','bill_state','Billing State',1,0,0,100,7,53,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'ship_state','vtiger_quotesshipads',1,'1','ship_state','Shipping State',1,0,0,100,8,53,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'bill_code','vtiger_quotesbillads',1,'1','bill_code','Billing Code',1,0,0,100,9,53,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'ship_code','vtiger_quotesshipads',1,'1','ship_code','Shipping Code',1,0,0,100,10,53,1,'V~O',1,null,'BAS')");
+
+
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'bill_country','vtiger_quotesbillads',1,'1','bill_country','Billing Country',1,0,0,100,11,53,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'ship_country','vtiger_quotesshipads',1,'1','ship_country','Shipping Country',1,0,0,100,12,53,1,'V~O',1,null,'BAS')");
+
+$this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'bill_pobox','vtiger_quotesbillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,53,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'ship_pobox','vtiger_quotesshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,53,1,'V~O',1,null,'BAS')");
+ //Block55
+
+$this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,56,1,'V~O',1,null,'ADV')");
+
+//Block 56
+$this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("field").",'terms_conditions','vtiger_quotes',1,'19','terms_conditions','Terms & Conditions',1,0,0,100,1,55,1,'V~O',1,null,'ADV')");
+
+
+//Quote Details -- END
+
+//Purchase Order Details -- START
+ //Block57
+ 
+$this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'subject','vtiger_purchaseorder',1,'2','subject','Subject',1,0,0,100,1,57,1,'V~M',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'vendorid','vtiger_purchaseorder',1,'81','vendor_id','Vendor Name',1,0,0,100,3,57,1,'I~M',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'requisition_no','vtiger_purchaseorder',1,'1','requisition_no','Requisition No',1,0,0,100,4,57,1,'V~O',1,null,'BAS')");	
+
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'tracking_no','vtiger_purchaseorder',1,'1','tracking_no','Tracking Number',1,0,0,100,5,57,1,'V~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'contactid','vtiger_purchaseorder',1,'57','contact_id','Contact Name',1,0,0,100,6,57,1,'I~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'duedate','vtiger_purchaseorder',1,'5','duedate','Due Date',1,0,0,100,7,57,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'carrier','vtiger_purchaseorder',1,'15','carrier','Carrier',1,0,0,100,8,57,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'salestax','vtiger_purchaseorder',1,'1','txtTax','Sales Tax',1,0,0,100,10,57,3,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'adjustment','vtiger_purchaseorder',1,'1','txtAdjustment','Adjustment',1,0,0,100,10,57,3,'NN~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'salescommission','vtiger_purchaseorder',1,'1','salescommission','Sales Commission',1,0,0,100,11,57,1,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'exciseduty','vtiger_purchaseorder',1,'1','exciseduty','Excise Duty',1,0,0,100,12,57,1,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'total','vtiger_purchaseorder',1,'1','hdnGrandTotal','Total',1,0,0,100,13,57,3,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'subtotal','vtiger_purchaseorder',1,'1','hdnSubTotal','Sub Total',1,0,0,100,14,57,3,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'postatus','vtiger_purchaseorder',1,'15','postatus','Status',1,0,0,100,15,57,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,16,57,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,17,57,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,18,57,2,'T~O',1,null,'BAS')");
+
+
+
+ //Block 59
+
+$this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'bill_street','vtiger_pobillads',1,'24','bill_street','Billing Address',1,0,0,100,1,59,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'ship_street','vtiger_poshipads',1,'24','ship_street','Shipping Address',1,0,0,100,2,59,1,'V~M',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'bill_city','vtiger_pobillads',1,'1','bill_city','Billing City',1,0,0,100,5,59,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'ship_city','vtiger_poshipads',1,'1','ship_city','Shipping City',1,0,0,100,6,59,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'bill_state','vtiger_pobillads',1,'1','bill_state','Billing State',1,0,0,100,7,59,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'ship_state','vtiger_poshipads',1,'1','ship_state','Shipping State',1,0,0,100,8,59,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'bill_code','vtiger_pobillads',1,'1','bill_code','Billing Code',1,0,0,100,9,59,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'ship_code','vtiger_poshipads',1,'1','ship_code','Shipping Code',1,0,0,100,10,59,1,'V~O',1,null,'BAS')");
+
+
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'bill_country','vtiger_pobillads',1,'1','bill_country','Billing Country',1,0,0,100,11,59,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'ship_country','vtiger_poshipads',1,'1','ship_country','Shipping Country',1,0,0,100,12,59,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'bill_pobox','vtiger_pobillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,59,1,'V~O',1,null,'BAS')");
+  $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'ship_pobox','vtiger_poshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,59,1,'V~O',1,null,'BAS')");
+  
+ //Block61
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,62,1,'V~O',1,null,'ADV')");
+
+ //Block62
+ $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("field").",'terms_conditions','vtiger_purchaseorder',1,'19','terms_conditions','Terms & Conditions',1,0,0,100,1,61,1,'V~O',1,null,'ADV')");
+
+//Purchase Order Details -- END
+
+//Sales Order Details -- START
+ //Block63
+ 
+$this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'subject','vtiger_salesorder',1,'2','subject','Subject',1,0,0,100,1,63,1,'V~M',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'potentialid','vtiger_salesorder',1,'76','potential_id','Potential Name',1,0,0,100,2,63,1,'I~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'customerno','vtiger_salesorder',1,'1','customerno','Customer No',1,0,0,100,3,63,1,'V~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'quoteid','vtiger_salesorder',1,'78','quote_id','Quote Name',1,0,0,100,4,63,1,'I~O',1,null,'BAS')");	
+$this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'purchaseorder','vtiger_salesorder',1,'1','vtiger_purchaseorder','Purchase Order',1,0,0,100,4,63,1,'V~O',1,null,'BAS')");	
+
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'contactid','vtiger_salesorder',1,'57','contact_id','Contact Name',1,0,0,100,6,63,1,'I~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'duedate','vtiger_salesorder',1,'5','duedate','Due Date',1,0,0,100,8,63,1,'D~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'carrier','vtiger_salesorder',1,'15','carrier','Carrier',1,0,0,100,9,63,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'pending','vtiger_salesorder',1,'1','pending','Pending',1,0,0,100,10,63,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'sostatus','vtiger_salesorder',1,'15','sostatus','Status',1,0,0,100,11,63,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'salestax','vtiger_salesorder',1,'1','txtTax','Sales Tax',1,0,0,100,12,63,3,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'adjustment','vtiger_salesorder',1,'1','txtAdjustment','Sales Tax',1,0,0,100,12,63,3,'NN~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'salescommission','vtiger_salesorder',1,'1','salescommission','Sales Commission',1,0,0,100,13,63,1,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'exciseduty','vtiger_salesorder',1,'1','exciseduty','Excise Duty',1,0,0,100,13,63,1,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'total','vtiger_salesorder',1,'1','hdnGrandTotal','Total',1,0,0,100,14,63,3,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'subtotal','vtiger_salesorder',1,'1','hdnSubTotal','Total',1,0,0,100,15,63,3,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'accountid','vtiger_salesorder',1,'73','account_id','Account Name',1,0,0,100,16,63,1,'I~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,17,63,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,18,63,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,19,63,2,'T~O',1,null,'BAS')");
+
+
+
+ //Block 65
+
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'bill_street','vtiger_sobillads',1,'24','bill_street','Billing Address',1,0,0,100,1,65,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'ship_street','vtiger_soshipads',1,'24','ship_street','Shipping Address',1,0,0,100,2,65,1,'V~M',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'bill_city','vtiger_sobillads',1,'1','bill_city','Billing City',1,0,0,100,5,65,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'ship_city','vtiger_soshipads',1,'1','ship_city','Shipping City',1,0,0,100,6,65,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'bill_state','vtiger_sobillads',1,'1','bill_state','Billing State',1,0,0,100,7,65,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'ship_state','vtiger_soshipads',1,'1','ship_state','Shipping State',1,0,0,100,8,65,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'bill_code','vtiger_sobillads',1,'1','bill_code','Billing Code',1,0,0,100,9,65,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'ship_code','vtiger_soshipads',1,'1','ship_code','Shipping Code',1,0,0,100,10,65,1,'V~O',1,null,'BAS')");
+
+
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'bill_country','vtiger_sobillads',1,'1','bill_country','Billing Country',1,0,0,100,11,65,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'ship_country','vtiger_soshipads',1,'1','ship_country','Shipping Country',1,0,0,100,12,65,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'bill_pobox','vtiger_sobillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,65,1,'V~O',1,null,'BAS')");
+  $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'ship_pobox','vtiger_soshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,65,1,'V~O',1,null,'BAS')");
+  
+//Block67
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,68,1,'V~O',1,null,'ADV')");
+
+ //Block68
+ $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("field").",'terms_conditions','vtiger_salesorder',1,'19','terms_conditions','Terms & Conditions',1,0,0,100,1,67,1,'V~O',1,null,'ADV')");
+
+
+//Sales Order Details -- END
+
+//Invoice Details -- START
+ //Block69
+
+$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'subject','vtiger_invoice',1,'2','subject','Subject',1,0,0,100,1,69,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'salesorderid','vtiger_invoice',1,'80','salesorder_id','Sales Order',1,0,0,100,2,69,1,'I~O',1,null,'BAS')");	
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'customerno','vtiger_invoice',1,'1','customerno','Customer No',1,0,0,100,3,69,1,'V~O',1,null,'BAS')");	
+
+ 
+//to include contact name vtiger_field in Invoice-start
+$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'contactid','vtiger_invoice',1,'57','contact_id','Contact Name',1,0,0,100,4,69,1,'I~O',1,null,'BAS')");
+//end
+
+$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'invoicedate','vtiger_invoice',1,'5','invoicedate','Invoice Date',1,0,0,100,5,69,1,'D~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'duedate','vtiger_invoice',1,'5','duedate','Due Date',1,0,0,100,6,69,1,'D~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'purchaseorder','vtiger_invoice',1,'1','vtiger_purchaseorder','Purchase Order',1,0,0,100,8,69,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'salestax','vtiger_invoice',1,'1','txtTax','Sales Tax',1,0,0,100,9,69,3,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'adjustment','vtiger_invoice',1,'1','txtAdjustment','Sales Tax',1,0,0,100,9,69,3,'NN~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'salescommission','vtiger_invoice',1,'1','salescommission','Sales Commission',1,0,0,10,13,69,1,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'exciseduty','vtiger_invoice',1,'1','exciseduty','Excise Duty',1,0,0,100,11,69,1,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'subtotal','vtiger_invoice',1,'1','hdnSubTotal','Sub Total',1,0,0,100,12,69,3,'N~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'total','vtiger_invoice',1,'1','hdnGrandTotal','Total',1,0,0,100,13,69,3,'N~O',1,null,'BAS')");
+$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'accountid','vtiger_invoice',1,'73','account_id','Account Name',1,0,0,100,14,69,1,'I~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'invoicestatus','vtiger_invoice',1,'15','invoicestatus','Status',1,0,0,100,15,69,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,16,69,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,17,69,2,'T~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,18,69,2,'T~O',1,null,'BAS')"); 
+
+ //Block 71
+
+$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'bill_street','vtiger_invoicebillads',1,'24','bill_street','Billing Address',1,0,0,100,1,71,1,'V~M',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'ship_street','vtiger_invoiceshipads',1,'24','ship_street','Shipping Address',1,0,0,100,2,71,1,'V~M',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'bill_city','vtiger_invoicebillads',1,'1','bill_city','Billing City',1,0,0,100,5,71,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'ship_city','vtiger_invoiceshipads',1,'1','ship_city','Shipping City',1,0,0,100,6,71,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'bill_state','vtiger_invoicebillads',1,'1','bill_state','Billing State',1,0,0,100,7,71,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'ship_state','vtiger_invoiceshipads',1,'1','ship_state','Shipping State',1,0,0,100,8,71,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'bill_code','vtiger_invoicebillads',1,'1','bill_code','Billing Code',1,0,0,100,9,71,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'ship_code','vtiger_invoiceshipads',1,'1','ship_code','Shipping Code',1,0,0,100,10,71,1,'V~O',1,null,'BAS')");
+
+
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'bill_country','vtiger_invoicebillads',1,'1','bill_country','Billing Country',1,0,0,100,11,71,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'ship_country','vtiger_invoiceshipads',1,'1','ship_country','Shipping Country',1,0,0,100,12,71,1,'V~O',1,null,'BAS')");
+
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'bill_pobox','vtiger_invoicebillads',1,'1','bill_pobox','Billing Po Box',1,0,0,100,3,71,1,'V~O',1,null,'BAS')");
+  $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'ship_pobox','vtiger_invoiceshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,71,1,'V~O',1,null,'BAS')");
+
+//Block73
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,74,1,'V~O',1,null,'ADV')");
+ //Block74
+ $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("field").",'terms_conditions','vtiger_invoice',1,'19','terms_conditions','Terms & Conditions',1,0,0,100,1,73,1,'V~O',1,null,'ADV')");
+
+
+//Invoice Details -- END
+
+
+
+                // Insert End
+                
+
+		//New Security Start
+		//Inserting into vtiger_profile vtiger_table
+		$this->db->query("insert into vtiger_profile values ('".$profile1_id."','Administrator',null)");	
+		$this->db->query("insert into vtiger_profile values ('".$profile2_id."','Sales Profile',null)");
+		$this->db->query("insert into vtiger_profile values ('".$profile3_id."','Support Profile',null)");
+		$this->db->query("insert into vtiger_profile values ('".$profile4_id."','Guest Profile',null)");
+		
+		//Inserting into vtiger_profile2gloabal permissions
+		$this->db->query("insert into vtiger_profile2globalpermissions values ('".$profile1_id."',1,0)");
+		$this->db->query("insert into vtiger_profile2globalpermissions values ('".$profile1_id."',2,0)");
+		$this->db->query("insert into vtiger_profile2globalpermissions values ('".$profile2_id."',1,1)");
+		$this->db->query("insert into vtiger_profile2globalpermissions values ('".$profile2_id."',2,1)");
+		$this->db->query("insert into vtiger_profile2globalpermissions values ('".$profile3_id."',1,1)");
+		$this->db->query("insert into vtiger_profile2globalpermissions values ('".$profile3_id."',2,1)");
+		$this->db->query("insert into vtiger_profile2globalpermissions values ('".$profile4_id."',1,1)");
+		$this->db->query("insert into vtiger_profile2globalpermissions values ('".$profile4_id."',2,1)");
+
+		//Inserting into vtiger_profile2tab
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",1,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",2,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",3,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",4,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",6,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",7,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",8,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",9,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",10,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",13,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",14,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",15,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",16,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",17,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",18,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",19,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",20,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",21,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",22,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",23,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",24,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",25,0)");
+       		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",26,0)");
+       		$this->db->query("insert into vtiger_profile2tab values (".$profile1_id.",27,0)");
+
+		//Inserting into vtiger_profile2tab
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",1,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",2,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",3,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",4,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",6,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",7,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",8,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",9,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",10,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",13,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",14,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",15,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",16,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",17,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",18,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",19,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",20,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",21,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",22,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",23,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",24,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",25,0)");
+        	$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",26,0)");
+       		$this->db->query("insert into vtiger_profile2tab values (".$profile2_id.",27,0)");
+
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",1,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",2,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",3,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",4,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",6,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",7,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",8,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",9,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",10,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",13,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",14,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",15,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",16,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",17,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",18,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",19,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",20,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",21,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",22,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",23,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",24,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",25,0)");
+        	$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",26,0)");
+       		$this->db->query("insert into vtiger_profile2tab values (".$profile3_id.",27,0)");
+        
+
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",1,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",2,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",3,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",4,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",6,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",7,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",8,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",9,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",10,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",13,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",14,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",15,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",16,0)");	
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",17,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",18,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",19,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",20,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",21,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",22,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",23,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",24,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",25,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",26,0)");
+		$this->db->query("insert into vtiger_profile2tab values (".$profile4_id.",27,0)");
+		//Inserting into vtiger_profile2standardpermissions  Adminsitrator
+		
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",2,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",2,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",2,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",2,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",2,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",4,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",4,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",4,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",4,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",4,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",6,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",6,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",6,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",6,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",6,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",7,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",7,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",7,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",7,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",7,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",8,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",8,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",8,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",8,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",8,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",9,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",9,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",9,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",9,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",9,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",10,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",10,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",10,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",10,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",10,4,0)");
+
+		
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",13,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",13,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",13,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",13,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",13,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",14,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",14,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",14,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",14,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",14,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",15,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",15,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",15,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",15,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",15,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",16,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",16,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",16,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",16,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",16,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",18,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",18,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",18,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",18,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",18,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",19,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",19,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",19,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",19,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",19,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",20,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",20,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",20,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",20,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",20,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",21,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",21,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",21,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",21,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",21,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",22,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",22,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",22,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",22,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",22,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",23,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",23,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",23,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",23,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",23,4,0)");
+
+
+
+        	$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",26,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",26,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",26,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",26,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile1_id.",26,4,0)");
+
+
+		//Insert into Profile 2 std permissions for Sales User  
+		//Help Desk Create/Delete not allowed. Read-Only	
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",2,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",2,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",2,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",2,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",2,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",4,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",4,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",4,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",4,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",4,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",6,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",6,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",6,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",6,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",6,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",7,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",7,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",7,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",7,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",7,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",8,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",8,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",8,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",8,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",8,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",9,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",9,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",9,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",9,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",9,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",10,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",10,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",10,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",10,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",10,4,0)");
+
+		
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",13,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",13,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",13,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",13,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",13,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",14,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",14,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",14,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",14,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",14,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",15,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",15,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",15,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",15,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",15,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",16,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",16,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",16,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",16,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",16,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",18,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",18,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",18,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",18,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",18,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",19,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",19,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",19,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",19,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",19,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",20,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",20,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",20,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",20,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",20,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",21,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",21,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",21,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",21,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",21,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",22,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",22,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",22,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",22,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",22,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",23,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",23,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",23,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",23,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",23,4,0)");
+
+
+        	$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",26,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",26,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",26,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",26,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile2_id.",26,4,0)");
+
+		//Inserting into vtiger_profile2std for Support Profile
+		// Potential is read-only
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",2,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",2,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",2,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",2,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",2,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",4,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",4,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",4,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",4,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",4,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",6,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",6,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",6,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",6,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",6,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",7,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",7,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",7,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",7,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",7,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",8,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",8,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",8,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",8,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",8,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",9,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",9,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",9,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",9,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",9,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",10,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",10,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",10,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",10,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",10,4,0)");
+
+		
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",13,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",13,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",13,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",13,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",13,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",14,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",14,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",14,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",14,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",14,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",15,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",15,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",15,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",15,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",15,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",16,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",16,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",16,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",16,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",16,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",18,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",18,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",18,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",18,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",18,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",19,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",19,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",19,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",19,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",19,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",20,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",20,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",20,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",20,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",20,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",21,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",21,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",21,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",21,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",21,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",22,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",22,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",22,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",22,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",22,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",23,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",23,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",23,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",23,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",23,4,0)");
+
+
+        	$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",26,0,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",26,1,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",26,2,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",26,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile3_id.",26,4,0)");
+        
+		//Inserting into vtiger_profile2stdper for Profile Guest Profile
+		//All Read-Only
+		
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",2,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",2,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",2,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",2,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",2,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",4,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",4,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",4,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",4,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",4,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",6,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",6,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",6,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",6,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",6,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",7,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",7,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",7,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",7,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",7,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",8,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",8,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",8,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",8,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",8,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",9,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",9,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",9,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",9,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",9,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",10,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",10,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",10,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",10,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",10,4,0)");
+
+		
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",13,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",13,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",13,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",13,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",13,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",14,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",14,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",14,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",14,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",14,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",15,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",15,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",15,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",15,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",15,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",16,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",16,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",16,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",16,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",16,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",18,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",18,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",18,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",18,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",18,4,0)");	
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",19,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",19,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",19,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",19,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",19,4,0)");	
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",20,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",20,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",20,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",20,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",20,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",21,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",21,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",21,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",21,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",21,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",22,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",22,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",22,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",22,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",22,4,0)");
+
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",23,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",23,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",23,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",23,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",23,4,0)");	
+
+
+        $this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",26,0,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",26,1,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",26,2,1)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",26,3,0)");
+		$this->db->query("insert into vtiger_profile2standardpermissions values (".$profile4_id.",26,4,0)");
+
+		//Insert into vtiger_role2profile
+		$this->db->query("insert into vtiger_role2profile values ('H".$role2_id."',".$profile1_id.")");
+		$this->db->query("insert into vtiger_role2profile values ('H".$role3_id."',".$profile2_id.")");
+	
+		//Insert into vtiger_profile2field
+			
+                insertProfile2field($profile1_id);
+                insertProfile2field($profile2_id);	
+                insertProfile2field($profile3_id);	
+                insertProfile2field($profile4_id);
+
+		insert_def_org_field();	
+		
+
+		//Inserting into vtiger_profile 2 utility Admin
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",2,5,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",2,6,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",4,5,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",4,6,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",6,5,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",6,6,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",7,5,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",7,6,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",8,6,0)");
+                //$this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",9,6,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",10,6,0)");
+		$this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",7,8,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",6,8,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",4,8,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",13,8,0)");
+		$this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",14,5,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",14,6,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile1_id.",7,9,0)");
+
+		//Inserting into vtiger_profile2utility Sales Profile
+		//Import Export Not Allowed.	
+		$this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",2,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",2,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",4,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",4,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",6,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",6,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",7,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",7,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",8,6,1)");
+                //$this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",9,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",10,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",7,8,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",6,8,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",4,8,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",13,8,0)");
+		$this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",14,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",14,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile2_id.",7,9,0)");
+
+		//Inserting into vtiger_profile2utility Support Profile
+		//Import Export Not Allowed.	
+		$this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",2,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",2,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",4,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",4,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",6,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",6,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",7,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",7,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",8,6,1)");
+                //$this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",9,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",10,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",7,8,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",6,8,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",4,8,0)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",13,8,0)");
+		$this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",14,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",14,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile3_id.",7,9,0)");
+
+		//Inserting into vtiger_profile2utility Guest Profile Read-Only
+		//Import Export BusinessCar Not Allowed.	
+		$this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",2,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",2,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",4,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",4,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",6,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",6,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",7,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",7,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",8,6,1)");
+                //$this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",9,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",10,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",7,8,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",6,8,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",4,8,1)");		
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",13,8,1)");		
+		$this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",14,5,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",14,6,1)");
+                $this->db->query("insert into vtiger_profile2utility values (".$profile4_id.",7,9,0)");
+
+		//Inserting values into org share action mapping
+                $this->db->query("insert into vtiger_org_share_action_mapping values(0,'Public: Read Only')");
+                $this->db->query("insert into vtiger_org_share_action_mapping values(1,'Public: Read, Create/Edit')");
+                $this->db->query("insert into vtiger_org_share_action_mapping values(2,'Public: Read, Create/Edit, Delete')");
+                $this->db->query("insert into vtiger_org_share_action_mapping values(3,'Private')");
+
+                $this->db->query("insert into vtiger_org_share_action_mapping values(4,'Hide Details')");
+                $this->db->query("insert into vtiger_org_share_action_mapping values(5,'Hide Details and Add Events')");
+                $this->db->query("insert into vtiger_org_share_action_mapping values(6,'Show Details')");
+                $this->db->query("insert into vtiger_org_share_action_mapping values(7,'Show Details and Add Events')");
+
+
+		//Inserting for all vtiger_tabs
+                $def_org_tabid= Array(2,4,6,7,9,10,13,16,20,21,22,23,26);
+
+                foreach($def_org_tabid as $def_tabid)
+                {
+                        $this->db->query("insert into vtiger_org_share_action2tab values(0,".$def_tabid.")");
+                        $this->db->query("insert into vtiger_org_share_action2tab values(1,".$def_tabid.")");
+                        $this->db->query("insert into vtiger_org_share_action2tab values(2,".$def_tabid.")");
+                        $this->db->query("insert into vtiger_org_share_action2tab values(3,".$def_tabid.")");
+                }
+
+                $this->db->query("insert into vtiger_org_share_action2tab values(4,17)");
+                $this->db->query("insert into vtiger_org_share_action2tab values(5,17)");
+                $this->db->query("insert into vtiger_org_share_action2tab values(6,17)");
+                $this->db->query("insert into vtiger_org_share_action2tab values(7,17)");
+
+		//Insert into default_org_sharingrule
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",2,2,0)");
+
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",4,2,2)");
+
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",6,2,0)");
+
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",7,2,0)");
+
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",9,3,1)");
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",10,2,0)");
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",13,2,0)");
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",16,3,2)");
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",17,7,0)");
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",20,2,0)");
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",21,2,0)");
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",22,2,0)");
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",23,2,0)");
+               $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('def_org_share').",26,2,0)");
+
+		//Populating the DataShare Related Modules
+
+		//Lead Related Module
+		$this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",7,10)");
+
+		//Account Related Module
+		$this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",6,2)");
+		$this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",6,13)");
+		$this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",6,20)");
+		$this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",6,22)");
+		$this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",6,23)");
+		$this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",6,10)");
+
+		//Potential Related Module
+		$this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",2,20)");
+		$this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",2,22)");
+
+		//Quote Related Module
+		$this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",20,22)");
+
+		//SO Related Module
+		$this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('datashare_relatedmodules').",22,23)");	
+
+
+			
+					
+  // New Secutity End
+
+
+         //insert into the vtiger_notificationscheduler vtiger_table
+
+	//insert into related list vtiger_table
+	//Inserting for vtiger_account related lists
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Potentials").",'get_opportunities',1,'Potentials',0)");	
+		
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Contacts").",'get_contacts',2,'Contacts',0)");
+
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Activities").",'get_activities',3,'Activities',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("HelpDesk").",'get_tickets',4,'HelpDesk',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Activities").",'get_history',5,'Activity History',0)");
+
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",0,'get_attachments',6,'Attachments',0)");
+
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Quotes").",'get_quotes',7,'Quotes',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Invoice").",'get_invoices',8,'Invoice',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("SalesOrder").",'get_salesorder',9,'Sales Order',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Accounts").",".getTabid("Products").",'get_products',10,'Products',0)");
+
+	//Inserting Lead Related Lists	
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Leads").",".getTabid("Activities").",'get_activities',1,'Activities',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Leads").",".getTabid("Emails").",'get_emails',2,'Emails',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Leads").",".getTabid("Activities").",'get_history',3,'Activity History',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Leads").",0,'get_attachments',4,'Attachments',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Leads").",".getTabid("Products").",'get_products',5,'Products',0)");
+
+	//Inserting for contact related lists
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("Potentials").",'get_opportunities',1,'Potentials',0)");	
+		
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("Activities").",'get_activities',2,'Activities',0)");
+
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("Emails").",'get_emails',3,'Emails',0)");
+
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("HelpDesk").",'get_tickets',4,'HelpDesk',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("Quotes").",'get_quotes',5,'Quotes',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("PurchaseOrder").",'get_purchase_orders',6,'Purchase Order',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("SalesOrder").",'get_salesorder',7,'Sales Order',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("Products").",'get_products',8,'Products',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",".getTabid("Activities").",'get_history',9,'Activity History',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Contacts").",0,'get_attachments',10,'Attachments',0)");
+
+	//Inserting Potential Related Lists	
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",".getTabid("Activities").",'get_activities',1,'Activities',0)");
+
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",".getTabid("Contacts").",'get_contacts',2,'Contacts',0)");
+
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",".getTabid("Products").",'get_products',3,'Products',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",0,'get_stage_history',4,'Sales Stage History',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",0,'get_attachments',5,'Attachments',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",".getTabid("Quotes").",'get_Quotes',6,'Quotes',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",".getTabid("SalesOrder").",'get_salesorder',7,'Sales Order',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Potentials").",".getTabid("Activities").",'get_history',8,'Activity History',0)");
+
+		//Inserting Product Related Lists	
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("HelpDesk").",'get_tickets',1,'HelpDesk',0)");
+
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("Activities").",'get_activities',2,'Activities',0)");
+
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",0,'get_attachments',3,'Attachments',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("Quotes").",'get_quotes',4,'Quotes',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("PurchaseOrder").",'get_purchase_orders',5,'Purchase Order',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("SalesOrder").",'get_salesorder',6,'Sales Order',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("Invoice").",'get_invoices',7,'Invoice',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Products").",".getTabid("PriceBooks").",'get_product_pricebooks',8,'PriceBooks',0)");
+	
+		//Inserting Emails Related Lists	
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Emails").",".getTabid("Contacts").",'get_contacts',1,'Contacts',0)");
+
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Emails").",0,'get_users',2,'Users',0)");
+
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Emails").",0,'get_attachments',3,'Attachments',0)");
+
+		//Inserting HelpDesk Related Lists
+		
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("HelpDesk").",".getTabid("Activities").",'get_activities',1,'Activities',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("HelpDesk").",0,'get_attachments',2,'Attachments',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("HelpDesk").",0,'get_ticket_history',3,'Ticket History',0)");
+
+	//Inserting PriceBook Related Lists
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("PriceBooks").",14,'get_pricebook_products',2,'Products',0)");
+
+        // Inserting Vendor Related Lists
+        $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Vendors").",14,'get_products',1,'Products',0)");
+
+        $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Vendors").",21,'get_purchase_orders',2,'Purchase Order',0)");
+
+        $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Vendors").",4,'get_contacts',3,'Contacts',0)");
+
+	// Inserting Quotes Related Lists
+	
+        $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Quotes").",".getTabid("Invoice").",'get_salesorder',1,'Sales Order',0)");
+        
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Quotes").",9,'get_activities',2,'Activities',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Quotes").",9,'get_history',3,'Activity History',0)");
+
+	// Inserting Purchase order Related Lists
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("PurchaseOrder").",9,'get_activities',1,'Activities',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("PurchaseOrder").",0,'get_attachments',2,'Attachments',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("PurchaseOrder").",".getTabid("Activities").",'get_history',3,'Activity History',0)");
+	
+	// Inserting Sales order Related Lists
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("SalesOrder").",9,'get_activities',1,'Activities',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("SalesOrder").",0,'get_attachments',2,'Attachments',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("SalesOrder").",".getTabid("Invoice").",'get_invoices',3,'Invoice',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("SalesOrder").",".getTabid("Activities").",'get_history',4,'Activity History',0)");
+	
+	// Inserting Invoice Related Lists
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Invoice").",9,'get_activities',1,'Activities',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Invoice").",0,'get_attachments',2,'Attachments',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('relatedlists').",".getTabid("Invoice").",".getTabid("Activities").",'get_history',3,'Activity History',0)");
+
+	// Inserting Activities Related Lists
+	
+	$this->db->query("insert into vtiger_relatedlists values (".$this->db->getUniqueID('relatedlists').",".getTabid("Activities").",0,'get_users',1,'Users',0)");
+	$this->db->query("insert into vtiger_relatedlists values (".$this->db->getUniqueID('relatedlists').",".getTabid("Activities").",4,'get_contacts',2,'Contacts',0)");
+
+	// Inserting Campaigns Related Lists
+
+         $this->db->query("insert into vtiger_relatedlists values (".$this->db->getUniqueID('relatedlists').",".getTabid("Campaigns").",".getTabid("Contacts").",'get_contacts',1,'Contacts',0)");
+         $this->db->query("insert into vtiger_relatedlists values (".$this->db->getUniqueID('relatedlists').",".getTabid("Campaigns").",".getTabid("Leads").",'get_leads',2,'Leads',0)");
+
+               $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_TASK_NOTIFICATION_DESCRITPION',1,'Task Delay Notification','Tasks delayed beyond 24 hrs ','LBL_TASK_NOTIFICATION')");
+
+
+                $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_BIG_DEAL_DESCRIPTION' ,1,'Big Deal notification','Success! A big deal has been won! ','LBL_BIG_DEAL')");
+
+
+                $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_TICKETS_DESCRIPTION',1,'Pending Tickets notification','Ticket pending please ','LBL_PENDING_TICKETS')");
+
+
+                $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_MANY_TICKETS_DESCRIPTION',1,'Too many tickets Notification','Too many tickets pending against this entity ','LBL_MANY_TICKETS')");
+
+
+                $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_START_DESCRIPTION' ,1,'Support Start Notification','Support starts please ','LBL_START_NOTIFICATION')");
+
+                $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_SUPPORT_DESCRIPTION',1,'Support ending please','Support Ending Notification','LBL_SUPPORT_NOTICIATION')");
+		
+ 		$this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("notificationscheduler").",'LBL_ACTIVITY_REMINDER_DESCRIPTION' ,1,'Activity Reminder Notication','This is a reminder notification for the Activity','LBL_ACTIVITY_NOTIFICATION')");
+
+		//Inserting Inventory Notifications
+	$invoice_body = 'Dear {HANDLER},
+
+The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. Kindly procure required number of units as the stock level is below reorder level {REORDERLEVELVALUE}.
+
+Please treat this information as Urgent as the vtiger_invoice is already sent  to the customer.
+
+Severity: Critical
+
+Thanks,
+{CURRENTUSER}';
+
+		
+               $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("inventorynotification").",'InvoiceNotification','{PRODUCTNAME} Stock Level is Low','".$invoice_body." ','InvoiceNotificationDescription')");
+
+		$quote_body = 'Dear {HANDLER},
+
+Quote is generated for {QUOTEQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. 
+
+Severity: Minor
+
+Thanks,
+{CURRENTUSER}';	
+		
+		
+               $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("inventorynotification").",'QuoteNotification','Quote given for {PRODUCTNAME}','".$quote_body." ','QuoteNotificationDescription')");
+
+		$so_body = 'Dear {HANDLER},
+
+SalesOrder is generated for {SOQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. 
+
+Please treat this information  with vtiger_priority as the sales order is already generated.
+
+Severity: Major
+
+Thanks,
+{CURRENTUSER}';
+
+		
+               $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("inventorynotification").",'SalesOrderNotification','Sales Order generated for {PRODUCTNAME}','".$so_body." ','SalesOrderNotificationDescription')");
+
+		//Insert into vtiger_currency vtiger_table
+		$this->db->query("insert into vtiger_currency_info values(".$this->db->getUniqueID("currency_info").",'U.S Dollar','USD','$',1,'Active','-11')");
+                
+
+
+
+//insert into email template vtiger_table
+
+	$body='
+	Hello!
+
+	On behalf of the vtiger team,  I am pleased to announce the release of vtiger crm4.2 . This is a feature packed release including the mass email template handling, custom view feature, vtiger_reports feature and a host of other utilities. vtiger runs on all platforms.
+
+	Notable Features of vtiger are :
+	-Email Client Integration
+	-Trouble Ticket Integration
+	-Invoice Management Integration
+	-Reports Integration
+	-Portal Integration
+	-Enhanced Word Plugin Support
+	-Custom View Integration
+
+	Known Issues:
+	-ABCD
+	-EFGH
+	-IJKL
+	-MNOP
+	-QRST';
+
+          $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Announcement for Release','Announcement for Release','Announcement of a release','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
+	
+
+
+$body='name
+street,
+city,
+state,
+ zip)
+ 
+ Dear
+ 
+ Please check the following vtiger_invoices that are yet to be paid by you:
+ 
+ No. Date      Amount
+ 1   1/1/01    $4000
+ 2   2/2//01   $5000
+ 3   3/3/01    $10000
+ 4   7/4/01    $23560
+ 
+ Kindly let us know if there are any issues that you feel are pending to be discussed.
+ We will be more than happy to give you a call.
+ We would like to continue our business with you.
+ 
+ Sincerely,
+ name
+ title';
+
+
+               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Pending Invoices','Invoices Pending','Payment Due','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
+
+
+
+
+
+$body=' Dear
+
+Your proposal on the project XYZW has been reviewed by us
+and is acceptable in its entirety.
+
+We are eagerly looking forward to this project
+and are pleased about having the opportunity to work
+together. We look forward to a long standing relationship
+with your esteemed firm.
+
+I would like to take this opportunity to invite you
+to a game of golf on Wednesday morning 9am at the
+Cuff Links Ground. We will be waiting for you in the
+Executive Lounge.
+
+Looking forward to seeing you there.
+
+Sincerely,
+name
+title';
+	       
+               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Acceptance Proposal','Acceptance Proposal','Acceptance of Proposal','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
+
+
+$body= ' The undersigned hereby acknowledges receipt and delivery
+of the goods.
+The undersigned will release the payment subject to the goods being discovered not satisfactory.
+
+Signed under seal this <date>
+
+Sincerely,
+name
+title';
+	       
+               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Goods received acknowledgement','Goods received acknowledgement','Acknowledged Receipt of Goods','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
+
+
+	       $body= ' Dear
+	 We are in receipt of your order as contained in the
+   purchase order form.We consider this to be final and binding on both sides.
+If there be any exceptions noted, we shall consider them
+only if the objection is received within ten days of receipt of
+this notice.
+
+Thank you for your patronage.
+Sincerely,
+name
+title';
+
+
+	       
+               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Accept Order','Accept Order','Acknowledgement/Acceptance of Order','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
+
+
+
+
+$body='Dear
+
+We are relocating our office to
+11111,XYZDEF Cross,
+UVWWX Circle
+The telephone number for this new location is (101) 1212-1328.
+
+Our Manufacturing Division will continue operations
+at 3250 Lovedale Square Avenue, in Frankfurt.
+
+We hope to keep in touch with you all.
+Please update your addressbooks.
+
+
+Thank You,
+name
+title';
+	       
+               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Address Change','Change of Address','Address Change','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
+
+
+
+$body='Dear
+
+Thank you for extending us the opportunity to meet with
+you and members of your staff.
+
+I know that John Doe serviced your vtiger_account
+for many years and made many friends at your firm. He has personally
+discussed with me the deep relationship that he had with your firm.
+While his presence will be missed, I can promise that we will
+continue to provide the fine service that was accorded by
+John to your firm.
+
+I was genuinely touched to receive such fine hospitality.
+
+Thank you once again.
+
+Sincerely,
+name
+title';
+
+
+	       
+               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Follow Up','Follow Up','Follow Up of meeting','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
+
+
+
+$body='Congratulations!
+
+The numbers are in and I am proud to inform you that our
+total sales for the previous quarter
+amounts to $100,000,00.00!. This is the first time
+we have exceeded the target by almost 30%.
+We have also beat the previous quarter record by a
+whopping 75%!
+
+Let us meet at Smoking Joe for a drink in the evening!
+
+C you all there guys!
+
+Sincerely,
+name
+title';
+
+	       
+               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Target Crossed!','Target Crossed!','Fantastic Sales Spree!','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
+
+$body='
+Dear
+
+Thank you for your confidence in our ability to serve you.
+We are glad to be given the chance to serve you.I look
+forward to establishing a long term partnership with you.
+Consider me as a friend.
+Should any need arise,please do give us a call.
+
+Sincerely,
+name
+title';
+
+	       
+               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Thanks Note','Thanks Note','Note of thanks','".$body."',0,".$this->db->getUniqueID('emailtemplates').")");
+
+		
+	       //Insert into vtiger_organizationdetails vtiger_table 
+	       $this->db->query("insert into vtiger_organizationdetails(organizationame,address,city,state,country,code,phone,fax,website,logoname) values ('vtiger',' 40-41-42, Sivasundar Apartments, Flat D-II, Shastri Street, Velachery','Chennai','Tamil Nadu','India','600 042','+91-44-5202-1990','+91-44-5202-1990','www.vtiger.com','vtiger-crm-logo.jpg')");
+
+  //Insert into vtiger_inventory_tandc vtiger_table
+               $this->db->query("insert into vtiger_inventory_tandc values('".$this->db->getUniqueID('inventory_tandc')."','Inventory','')");
+
+	$this->db->query("insert into vtiger_actionmapping values(0,'Save',0)");
+	$this->db->query("insert into vtiger_actionmapping values(1,'EditView',0)");
+	$this->db->query("insert into vtiger_actionmapping values(2,'Delete',0)");
+	$this->db->query("insert into vtiger_actionmapping values(3,'index',0)");
+	$this->db->query("insert into vtiger_actionmapping values(4,'DetailView',0)");
+	$this->db->query("insert into vtiger_actionmapping values(5,'Import',0)");
+	$this->db->query("insert into vtiger_actionmapping values(6,'Export',0)");
+	//$this->db->query("insert into vtiger_actionmapping values(7,'AddBusinessCard',0)");
+	$this->db->query("insert into vtiger_actionmapping values(8,'Merge',0)");
+	$this->db->query("insert into vtiger_actionmapping values(1,'VendorEditView',1)");
+	$this->db->query("insert into vtiger_actionmapping values(4,'VendorDetailView',1)");
+	$this->db->query("insert into vtiger_actionmapping values(0,'SaveVendor',1)");
+	$this->db->query("insert into vtiger_actionmapping values(2,'DeleteVendor',1)");
+	$this->db->query("insert into vtiger_actionmapping values(1,'PriceBookEditView',1)");
+	$this->db->query("insert into vtiger_actionmapping values(4,'PriceBookDetailView',1)");
+	$this->db->query("insert into vtiger_actionmapping values(0,'SavePriceBook',1)");
+	$this->db->query("insert into vtiger_actionmapping values(2,'DeletePriceBook',1)");
+	$this->db->query("insert into vtiger_actionmapping values(9,'ConvertLead',0)");
+	$this->db->query("insert into vtiger_actionmapping values(1,'DetailViewAjax',1)");
+	$this->db->query("insert into vtiger_actionmapping values(4,'TagCloud',1)");
+	$this->db->query("insert into vtiger_actionmapping values(1,'QuickCreate',1)");
+	$this->db->query("insert into vtiger_actionmapping values(3,'Popup',1)");
+
+	//Insert values for vtiger_moduleowners vtiger_table which contains the modules and their vtiger_users. default user id admin - after 4.2 patch 2
+	$module_array = Array('Potentials','Contacts','Accounts','Leads','Notes','Activities','Emails','HelpDesk','Products','Faq','Vendors','PriceBooks','Quotes','PurchaseOrder','SalesOrder','Invoice','Reports','Campaigns');
+	foreach($module_array as $mod)
+	{
+		$this->db->query("insert into vtiger_moduleowners values(".getTabid($mod).",1)");
+	}
+	//added by jeri for category view from db
+	$this->db->query("insert into vtiger_parenttab values (1,'My Home Page',1,0)");
+	$this->db->query("insert into vtiger_parenttab values (2,'Marketing',2,0)");
+	$this->db->query("insert into vtiger_parenttab values (3,'Sales',3,0)");
+	$this->db->query("insert into vtiger_parenttab values (4,'Support',4,0)");
+	$this->db->query("insert into vtiger_parenttab values (5,'Analytics',5,0)");
+	$this->db->query("insert into vtiger_parenttab values (6,'Inventory',6,0)");
+	$this->db->query("insert into vtiger_parenttab values (7,'Tools',7,0)");
+	$this->db->query("insert into vtiger_parenttab values (8,'Settings',8,0)");
+
+	$this->db->query("insert into vtiger_parenttabrel values (1,9,2)");
+	$this->db->query("insert into vtiger_parenttabrel values (1,17,3)");
+	$this->db->query("insert into vtiger_parenttabrel values (1,10,4)");
+	$this->db->query("insert into vtiger_parenttabrel values (1,3,1)");
+	$this->db->query("insert into vtiger_parenttabrel values (3,7,1)");
+	$this->db->query("insert into vtiger_parenttabrel values (3,6,2)");
+	$this->db->query("insert into vtiger_parenttabrel values (3,4,3)");
+	$this->db->query("insert into vtiger_parenttabrel values (3,2,4)");
+	$this->db->query("insert into vtiger_parenttabrel values (3,20,5)");
+	$this->db->query("insert into vtiger_parenttabrel values (3,22,6)");
+	$this->db->query("insert into vtiger_parenttabrel values (3,23,7)");
+	$this->db->query("insert into vtiger_parenttabrel values (3,14,8)");
+	$this->db->query("insert into vtiger_parenttabrel values (3,19,9)");
+	$this->db->query("insert into vtiger_parenttabrel values (3,8,10)");
+	$this->db->query("insert into vtiger_parenttabrel values (4,13,1)");
+	$this->db->query("insert into vtiger_parenttabrel values (4,15,2)");
+	$this->db->query("insert into vtiger_parenttabrel values (4,6,3)");
+	$this->db->query("insert into vtiger_parenttabrel values (4,4,4)");
+	$this->db->query("insert into vtiger_parenttabrel values (4,14,5)");
+	$this->db->query("insert into vtiger_parenttabrel values (4,8,6)");
+	$this->db->query("insert into vtiger_parenttabrel values (5,1,1)");
+	$this->db->query("insert into vtiger_parenttabrel values (5,25,2)");
+	$this->db->query("insert into vtiger_parenttabrel values (6,14,1)");
+	$this->db->query("insert into vtiger_parenttabrel values (6,18,2)");
+	$this->db->query("insert into vtiger_parenttabrel values (6,19,3)");
+	$this->db->query("insert into vtiger_parenttabrel values (6,21,4)");
+	$this->db->query("insert into vtiger_parenttabrel values (6,22,5)");
+	$this->db->query("insert into vtiger_parenttabrel values (6,20,6)");
+	$this->db->query("insert into vtiger_parenttabrel values (6,23,7)");
+	$this->db->query("insert into vtiger_parenttabrel values (7,24,1)");
+	$this->db->query("insert into vtiger_parenttabrel values (7,27,2)");
+	$this->db->query("insert into vtiger_parenttabrel values (7,8,3)");
+	$this->db->query("insert into vtiger_parenttabrel values (2,26,1)");
+	$this->db->query("insert into vtiger_parenttabrel values (2,6,2)");
+	$this->db->query("insert into vtiger_parenttabrel values (2,4,3)");
+	$this->db->query("insert into vtiger_parenttabrel values (2,10,4)");
+	$this->db->query("insert into vtiger_parenttabrel values (4,10,7)");
+
+	//Added to populate the default inventory tax informations
+	$this->db->query("insert into vtiger_inventorytaxinfo values(".$this->db->getUniqueID("inventorytaxinfo").",'VAT','4.5')");
+	$this->db->query("insert into vtiger_inventorytaxinfo values(".$this->db->getUniqueID("inventorytaxinfo").",'Sales','10')");
+	$this->db->query("insert into vtiger_inventorytaxinfo values(".$this->db->getUniqueID("inventorytaxinfo").",'Service','12.5')");
+	
+	}
+}
+?>

Modified: vtigercrm/trunk/modules/Users/Delete.php
==============================================================================
--- vtigercrm/trunk/modules/Users/Delete.php (original)
+++ vtigercrm/trunk/modules/Users/Delete.php Mon Jun 12 14:26:25 2006
@@ -10,7 +10,7 @@
  ********************************************************************************/
 
 
-$sql= 'delete from salesmanactivityrel where smid='.$_REQUEST['record'].' and activityid = '.$_REQUEST['return_id'];
+$sql= 'delete from vtiger_salesmanactivityrel where smid='.$_REQUEST['record'].' and vtiger_activityid = '.$_REQUEST['return_id'];
 $adb->query($sql);
 
 if($_REQUEST['return_module'] == 'Activities')

Modified: vtigercrm/trunk/modules/Users/DeleteGroup.php
==============================================================================
--- vtigercrm/trunk/modules/Users/DeleteGroup.php (original)
+++ vtigercrm/trunk/modules/Users/DeleteGroup.php Mon Jun 12 14:26:25 2006
@@ -13,7 +13,7 @@
 global $adb;
 $del_id =  $_REQUEST['groupId'];
 
-//Updating the user2 role table
+//Updating the user2 vtiger_role vtiger_table
 deleteGroup($del_id);
 
 header("Location: index.php?action=listgroups&module=Users&parenttab=Settings");

Modified: vtigercrm/trunk/modules/Users/DeleteUser.php
==============================================================================
--- vtigercrm/trunk/modules/Users/DeleteUser.php (original)
+++ vtigercrm/trunk/modules/Users/DeleteUser.php Mon Jun 12 14:26:25 2006
@@ -13,46 +13,46 @@
 $del_id =  $_REQUEST['delete_user_id'];
 $tran_id = $_REQUEST['transfer_user_id'];
 
-//Updating the smcreatorid,smownerid, modifiedby in crmentity
-$sql1 = "update crmentity set smcreatorid=".$tran_id." where smcreatorid=".$del_id;
+//Updating the smcreatorid,smownerid, modifiedby in vtiger_crmentity
+$sql1 = "update vtiger_crmentity set smcreatorid=".$tran_id." where smcreatorid=".$del_id;
 $adb->query($sql1);
-$sql2 = "update crmentity set smownerid=".$tran_id." where smownerid=".$del_id;
+$sql2 = "update vtiger_crmentity set smownerid=".$tran_id." where smownerid=".$del_id;
 $adb->query($sql2);
-$sql3 = "update crmentity set modifiedby=".$tran_id." where modifiedby=".$del_id;
+$sql3 = "update vtiger_crmentity set modifiedby=".$tran_id." where modifiedby=".$del_id;
 $adb->query($sql3);
 
-//deleting from tracker
-$sql4 = "delete from tracker where user_id='".$del_id."'";
+//deleting from vtiger_tracker
+$sql4 = "delete from vtiger_tracker where user_id='".$del_id."'";
 $adb->query($sql4);
 
-//updating created by in lar table
-$sql5 = "update lar set createdby=".$tran_id." where createdby=".$del_id;
+//updating created by in vtiger_lar vtiger_table
+$sql5 = "update vtiger_lar set createdby=".$tran_id." where createdby=".$del_id;
 $adb->query($sql5);
 
-//updating the import_maps table
-$sql6 ="update import_maps set assigned_user_id='".$tran_id."' where assigned_user_id='".$del_id."'";
+//updating the vtiger_import_maps vtiger_table
+$sql6 ="update vtiger_import_maps set assigned_user_id='".$tran_id."' where assigned_user_id='".$del_id."'";
 $adb->query($sql6);
 
-//update assigned_user_id in files
-$sql7 ="update files set assigned_user_id='".$tran_id."' where assigned_user_id='".$del_id."'";
+//update assigned_user_id in vtiger_files
+$sql7 ="update vtiger_files set assigned_user_id='".$tran_id."' where assigned_user_id='".$del_id."'";
 $adb->query($sql7); 
 
 
-//update assigned_user_id in users_last_import
-$sql8 = "update users_last_import set assigned_user_id='".$tran_id."' where assigned_user_id='".$del_id."'";
+//update assigned_user_id in vtiger_users_last_import
+$sql8 = "update vtiger_users_last_import set assigned_user_id='".$tran_id."' where assigned_user_id='".$del_id."'";
 $adb->query($sql8);
 
-//delete from users to group table
-$sql9 = "delete from user2role where userid=".$del_id;
+//delete from vtiger_users to group vtiger_table
+$sql9 = "delete from vtiger_user2role where userid=".$del_id;
 $adb->query($sql9);
 
-//delete from users to role table
-$sql9 = "delete from users2group where userid=".$del_id;
+//delete from vtiger_users to vtiger_role vtiger_table
+$sql9 = "delete from vtiger_users2group where userid=".$del_id;
 $adb->query($sql9);
 
 
-//delete from user table;
-$sql9 = "delete from users where id=".$del_id;
+//delete from user vtiger_table;
+$sql9 = "delete from vtiger_users where id=".$del_id;
 $adb->query($sql9);
 header("Location: index.php?action=UsersAjax&module=Users&file=ListView&ajax=true");
 ?>

Modified: vtigercrm/trunk/modules/Users/DetailView.php
==============================================================================
--- vtigercrm/trunk/modules/Users/DetailView.php (original)
+++ vtigercrm/trunk/modules/Users/DetailView.php Mon Jun 12 14:26:25 2006
@@ -86,7 +86,7 @@
 $rolename =  getRoleName($role);
 $currencyid=fetchCurrency($focus->id);
 $currency=getCurrencyName($currencyid);
-//the user might belong to multiple groups
+//the user might belong to multiple vtiger_groups
 if($focus->id != 1)
 {
  $groupids = fetchUserGroupids($focus->id);
@@ -180,7 +180,7 @@
 	$buttons = "<input title='".$app_strings['LBL_DUPLICATE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_DUPLICATE_BUTTON_KEY']."' class='classBtn' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value=true; this.form.return_id.value='".$_REQUEST['record']."';this.form.action.value='EditView'\" type='submit' name='Duplicate' value=' ".$app_strings['LBL_DUPLICATE_BUTTON_LABEL']."'   >";
 	$smarty->assign('DUPLICATE_BUTTON',$buttons);
 	
-	//done so that only the admin user can see the customize tab button
+	//done so that only the admin user can see the customize vtiger_tab button
 	if($_REQUEST['record'] == $current_user->id)
 	{
 		$buttons = "<input title='".$app_strings['LBL_TABCUSTOMISE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_TABCUSTOMISE_BUTTON_KEY']."' class='classBtn' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='TabCustomise'; this.form.action.value='TabCustomise'\" type='submit' name='Customise' value=' ".$app_strings['LBL_TABCUSTOMISE_BUTTON_LABEL']." '>";
@@ -221,7 +221,7 @@
 //Getting the Group Lists
 $groupids = fetchUserGroupids($focus->id);
 if($groupids) {
-	$query ="select groupid,groupname from groups where groupid in (".$groupids.")";
+	$query ="select groupid,groupname from vtiger_groups where groupid in (".$groupids.")";
 	$result = $adb->query($query);
 	$num_rows = $adb->num_rows($result);
 } else {

Modified: vtigercrm/trunk/modules/Users/EditHomeOrder.php
==============================================================================
--- vtigercrm/trunk/modules/Users/EditHomeOrder.php (original)
+++ vtigercrm/trunk/modules/Users/EditHomeOrder.php Mon Jun 12 14:26:25 2006
@@ -35,7 +35,7 @@
 $record = $_REQUEST['record'];
 
 global $adb;
-$query = "SELECT users.homeorder FROM users WHERE id=$record";
+$query = "SELECT vtiger_users.homeorder FROM vtiger_users WHERE id=$record";
 $result =& $adb->query($query, false,"Error getting home order");
 $row = $adb->fetchByAssoc($result);
 
@@ -80,7 +80,7 @@
 	global $record,$log,$adb;
 	
 	$home_section_order = implode(",",$data['block']);
-	$sql = "UPDATE users SET homeorder='$home_section_order' WHERE id=$record";
+	$sql = "UPDATE vtiger_users SET homeorder='$home_section_order' WHERE id=$record";
 	$log->debug("Updating user $record with SQL=$sql");
 	$result =& $adb->query($sql, false,"Error getting home order");
     return $result;

Modified: vtigercrm/trunk/modules/Users/EditInventoryNotification.php
==============================================================================
--- vtigercrm/trunk/modules/Users/EditInventoryNotification.php (original)
+++ vtigercrm/trunk/modules/Users/EditInventoryNotification.php Mon Jun 12 14:26:25 2006
@@ -24,7 +24,7 @@
 if(isset($_REQUEST['record']) && $_REQUEST['record']!='') 
 {
     $id = $_REQUEST['record'];
-	$sql="select * from inventorynotification where notificationid = ".$id;
+	$sql="select * from vtiger_inventorynotification where notificationid = ".$id;
 	$result = $adb->query($sql);
 	if($adb->num_rows($result) ==1);
 	{

Modified: vtigercrm/trunk/modules/Users/EditNotification.php
==============================================================================
--- vtigercrm/trunk/modules/Users/EditNotification.php (original)
+++ vtigercrm/trunk/modules/Users/EditNotification.php Mon Jun 12 14:26:25 2006
@@ -25,7 +25,7 @@
 {
     $id = $_REQUEST['record'];
 	
-	$sql="select * from notificationscheduler where schedulednotificationid = ".$id;
+	$sql="select * from vtiger_notificationscheduler where schedulednotificationid = ".$id;
 	$result = $adb->query($sql);
 	if($adb->num_rows($result) ==1);
 	{

Modified: vtigercrm/trunk/modules/Users/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Users/EditView.php (original)
+++ vtigercrm/trunk/modules/Users/EditView.php Mon Jun 12 14:26:25 2006
@@ -45,9 +45,9 @@
 	$mode='create';
 	$password='<tr>
 	   		   <td width="20%" class="dataLabel"><FONT class="required">*</FONT>Password</td>
-		       <td width="30%"><input name="new_password" type="password" tabindex="1" size="25" maxlength="25"></td>
+		       <td width="30%"><input name="new_password" type="password" vtiger_tabindex="1" size="25" maxlength="25"></td>
 			   <td width="20%" class="dataLabel"><FONT class="required">*</FONT>Confirm Password</td>
-			   <td width="30%"><input name="confirm_new_password" type="password" tabindex="2" size="25" maxlength="75"></td>
+			   <td width="30%"><input name="confirm_new_password" type="password" vtiger_tabindex="2" size="25" maxlength="75"></td>
 			  </tr>';
 }
 
@@ -57,9 +57,9 @@
 	$mode='create';
 	$password='<tr>
 	   		   <td width="20%" class="dataLabel"><FONT class="required">*</FONT>Password</td>
-		       <td width="30%"><input name="new_password" type="password" tabindex="1" size="25" maxlength="25"></td>
+		       <td width="30%"><input name="new_password" type="password" vtiger_tabindex="1" size="25" maxlength="25"></td>
 			   <td width="20%" class="dataLabel"><FONT class="required">*</FONT>Confirm Password</td>
-			   <td width="30%"><input name="confirm_new_password" type="password" tabindex="2" size="25" maxlength="75"></td>
+			   <td width="30%"><input name="confirm_new_password" type="password" vtiger_tabindex="2" size="25" maxlength="75"></td>
 			  </tr>';
 }
 
@@ -159,7 +159,7 @@
 $smarty->assign("DATE_FORMAT", $DATE_FORMAT_SELECT_OPTION);
 
 if (is_admin($current_user)) {
-	$status = "<td width='30%'>&nbsp;&nbsp;<select name='status' tabindex='1'";
+	$status = "<td width='30%'>&nbsp;&nbsp;<select name='status' vtiger_tabindex='1'";
 	if (isset($default_user_name)
 		&& $default_user_name != ""
 		&& $default_user_name == $focus->user_name
@@ -175,7 +175,7 @@
 }
 else
 {
-		$status = "<td width='30%'>&nbsp;&nbsp;<select name='status' tabindex='1' disabled>";
+		$status = "<td width='30%'>&nbsp;&nbsp;<select name='status' vtiger_tabindex='1' disabled>";
 		$status .= get_select_options_with_id($app_list_strings['user_status_dom'], $focus->status);
 		$status .= "</select></td>\n";
 		$smarty->assign("USER_STATUS_OPTIONS", $status);
@@ -210,15 +210,15 @@
 		$GROUP_SELECT_OPTION .= '<option value="">--None--</option>';
 		if($focus->id) {
 			$sql = "SELECT groupname
-				FROM users2group
-				INNER JOIN groups
-					ON groups.groupid = users2group.groupid
+				FROM vtiger_users2group
+				INNER JOIN vtiger_groups
+					ON vtiger_groups.groupid = vtiger_users2group.groupid
 				WHERE userid = '" .$focus->id ."'";
 			$result = $adb->query($sql);
 			$groupnameArray = $adb->fetch_array($result);
 		}
 		$groupselected = $groupnameArray["groupname"];
-		$sql2 = "SELECT groupname FROM groups";
+		$sql2 = "SELECT groupname FROM vtiger_groups";
                   $result_name = $adb->query($sql2);
                   $temprow = $adb->fetch_array($result_name);
                    do

Modified: vtigercrm/trunk/modules/Users/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Users/Forms.php (original)
+++ vtigercrm/trunk/modules/Users/Forms.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 /*********************************************************************************
  * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Users/Forms.php,v 1.3 2004/11/08 13:48:29 jack Exp $
  * Description:  Contains a variety of utility functions used to display UI
- * components such as form headers and footers.  Intended to be modified on a per
+ * components such as form vtiger_headers and footers.  Intended to be modified on a per
  * theme basis.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
@@ -96,7 +96,7 @@
 		set_fieldfocus(errorMessage,form.email1);
 	}
 	if (trim(form.email2.value) != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email2.value)) {
-		errorMessage='"' + form.email2.value + '" value in other email field is $err_invalid_email_address';
+		errorMessage='"' + form.email2.value + '" value in other email vtiger_field is $err_invalid_email_address';
 		set_fieldfocus(errorMessage,form.email2);
 	}
 	if(form.mode.value != 'edit')

Modified: vtigercrm/trunk/modules/Users/ListProfiles.php
==============================================================================
--- vtigercrm/trunk/modules/Users/ListProfiles.php (original)
+++ vtigercrm/trunk/modules/Users/ListProfiles.php Mon Jun 12 14:26:25 2006
@@ -24,7 +24,7 @@
 require_once($theme_path.'layout_utils.php');
 
 $smarty = new vtigerCRM_Smarty;
-$sql = "select * from profile";
+$sql = "select * from vtiger_profile";
 $profileListResult = $adb->query($sql);
 $noofrows = $adb->num_rows($profileListResult);
 $list_entries = array($mod_strings['LBL_OERATION'],$mod_strings['LBL_NEW_PROFILE_NAME'],$mod_strings['LBL_DESCRIPTION']);

Modified: vtigercrm/trunk/modules/Users/Listhistory.php
==============================================================================
--- vtigercrm/trunk/modules/Users/Listhistory.php (original)
+++ vtigercrm/trunk/modules/Users/Listhistory.php Mon Jun 12 14:26:25 2006
@@ -19,7 +19,7 @@
 
 
 
-	$dbQuery = "SELECT * from loginhistory order by login_id DESC";
+	$dbQuery = "SELECT * from vtiger_loginhistory order by login_id DESC";
 
 	//echo $dbQuery;
 

Modified: vtigercrm/trunk/modules/Users/Login.php
==============================================================================
--- vtigercrm/trunk/modules/Users/Login.php (original)
+++ vtigercrm/trunk/modules/Users/Login.php Mon Jun 12 14:26:25 2006
@@ -111,11 +111,11 @@
 													<li>Sexier Dashboards,Reports,Calendar</li>	 		
 													<li>Migration Support</li><br>	
 															How is 'vtiger-experience' ? <br>	
-													<li><a href='http://blogs.vtiger.com' tabindex="6">vtiger blogs </a></li>
-													<li><a href='http://www.bloglines.com' tabindex="7">bloglines </a></li>
-													<li><a href='http://technorati.com/' tabindex="8">technorati</a></li>
-													<li><a href='http://digg.com/' tabindex="9">digg</a></li>
-													<li><a href='http://www.blogger.com' tabindex="10">blogger</a></li>
+													<li><a href='http://blogs.vtiger.com' vtiger_tabindex="6">vtiger blogs </a></li>
+													<li><a href='http://www.bloglines.com' vtiger_tabindex="7">bloglines </a></li>
+													<li><a href='http://technorati.com/' vtiger_tabindex="8">technorati</a></li>
+													<li><a href='http://digg.com/' vtiger_tabindex="9">digg</a></li>
+													<li><a href='http://www.blogger.com' vtiger_tabindex="10">blogger</a></li>
 										</div>
 							</td>
 							<td valign="top"><br>
@@ -181,7 +181,7 @@
 																						<?php echo $current_module_strings['LBL_USER_NAME'] ?>
 																				</td>
 																				<td class="small">
-																						<input class="textbox" type="text"  name="user_name"   value="<?php echo $login_user_name ?>" tabindex="1">
+																						<input class="textbox" type="text"  name="user_name"   value="<?php echo $login_user_name ?>" vtiger_tabindex="1">
 																				</td>
 																	</tr>
 																	<tr>
@@ -189,7 +189,7 @@
 																							<?php echo $current_module_strings['LBL_PASSWORD'] ?>
 																				</td>
 																				<td class="small">
-																							<input class="textbox" type="password" size='20' name="user_password"  value="<?php echo $login_password ?>" tabindex="2">
+																							<input class="textbox" type="password" size='20' name="user_password"  value="<?php echo $login_password ?>" vtiger_tabindex="2">
 																				</td>
 																	</tr>
 																	<tr>
@@ -197,7 +197,7 @@
 																						<?php echo $current_module_strings['LBL_THEME'] ?>
 																				</td>
 																				<td class="small" style="background-color:#f5f5f5">
-																							<select class='small' name='login_theme' style="width:120px;" tabindex="3">
+																							<select class='small' name='login_theme' style="width:120px;" vtiger_tabindex="3">
 																									<?php echo get_select_options_with_id(get_themes(), $display_theme) ?>
 																							</select>
 																				</td>
@@ -207,7 +207,7 @@
 																							<?php echo $current_module_strings['LBL_LANGUAGE'] ?>
 																				</td>
 																				<td class="small" style="background-color:#f5f5f5">
-																							<select class='small' name='login_language' style="width:120px;" tabindex="4">
+																							<select class='small' name='login_language' style="width:120px;" vtiger_tabindex="4">
 																										<?php echo get_select_options_with_id(get_languages(), $display_language) ?>
 																								</select>
 																				  </td>
@@ -215,7 +215,7 @@
 																	<tr>
 																			<td></td>
 																			<td>
-																				<input class=small title="<?php echo $current_module_strings['LBL_LOGIN_BUTTON_TITLE'] ?>" accesskey="<?php echo $current_module_strings['LBL_LOGIN_BUTTON_TITLE'] ?>"  type="image" src="include/images/loginBtnSignin.gif" name="Login" value="  <?php echo $current_module_strings['LBL_LOGIN_BUTTON_LABEL'] ?>  "  tabindex="5">
+																				<input class=small title="<?php echo $current_module_strings['LBL_LOGIN_BUTTON_TITLE'] ?>" accesskey="<?php echo $current_module_strings['LBL_LOGIN_BUTTON_TITLE'] ?>"  type="image" src="include/images/loginBtnSignin.gif" name="Login" value="  <?php echo $current_module_strings['LBL_LOGIN_BUTTON_LABEL'] ?>  "  vtiger_tabindex="5">
 																				
 																			 </td>
 																	  </tr>

Modified: vtigercrm/trunk/modules/Users/LoginHistory.php
==============================================================================
--- vtigercrm/trunk/modules/Users/LoginHistory.php (original)
+++ vtigercrm/trunk/modules/Users/LoginHistory.php Mon Jun 12 14:26:25 2006
@@ -22,7 +22,7 @@
 	var $log;
 	var $db;
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $login_id;
 	var $user_name;
 	var $user_ip;
@@ -51,7 +51,7 @@
 		$this->db = new PearDatabase();
 	}
 	
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array('login_id', 'user_name', 'user_ip', 'login_time', 'logout_time', 'status');	
 		
 	var $default_order_by = "login_id";
@@ -60,7 +60,7 @@
 	/** Records the Login info */
 	function user_login(&$usname,&$usip,&$intime)
 	{
-		$query = "Insert into loginhistory (user_name, user_ip, logout_time, login_time, status) values ('$usname','$usip',null,".$this->db->formatDate($intime).",'Signedin')";
+		$query = "Insert into vtiger_loginhistory (user_name, user_ip, logout_time, login_time, status) values ('$usname','$usip',null,".$this->db->formatDate($intime).",'Signedin')";
 		$result = $this->db->query($query)
                         or die("MySQL error: ".mysql_error());
 		
@@ -69,7 +69,7 @@
 	
 	function user_logout(&$usname,&$usip,&$outtime)
 	{
-		$logid_qry = "SELECT max(login_id) AS login_id from loginhistory where user_name='$usname' and user_ip='$usip'";
+		$logid_qry = "SELECT max(login_id) AS login_id from vtiger_loginhistory where user_name='$usname' and user_ip='$usip'";
 		$result = $this->db->query($logid_qry);
 		$loginid = $this->db->query_result($result,0,"login_id");
 		if ($loginid == '')
@@ -77,14 +77,14 @@
                         return;
                 }
 		// update the user login info.
-		$query = "Update loginhistory set logout_time =".$this->db->formatDate($outtime).", status='Signedoff' where login_id = $loginid";
+		$query = "Update vtiger_loginhistory set logout_time =".$this->db->formatDate($outtime).", status='Signedoff' where login_id = $loginid";
 		$result = $this->db->query($query)
                         or die("MySQL error: ".mysql_error());
 	}
 
   	function create_list_query(&$order_by, &$where)
   	{
-		// Determine if the account name is present in the where clause.
+		// Determine if the vtiger_account name is present in the where clause.
 		global $current_user;
 		$query = "SELECT user_name,user_ip, status,
 				".$this->db->getDBDateString("login_time")." AS login_time,

Modified: vtigercrm/trunk/modules/Users/Logout.php
==============================================================================
--- vtigercrm/trunk/modules/Users/Logout.php (original)
+++ vtigercrm/trunk/modules/Users/Logout.php Mon Jun 12 14:26:25 2006
@@ -30,7 +30,7 @@
 $ftpuser = '';
 $ftppassword = '';
 global $adb;
-$query = "select * from systems where server_type='backup'";
+$query = "select * from vtiger_systems where server_type='backup'";
 $result = $adb->query($query);
 $num_rows = $adb->num_rows($result);
 if($num_rows > 0)

Modified: vtigercrm/trunk/modules/Users/OrgSharingDetailView.php
==============================================================================
--- vtigercrm/trunk/modules/Users/OrgSharingDetailView.php (original)
+++ vtigercrm/trunk/modules/Users/OrgSharingDetailView.php Mon Jun 12 14:26:25 2006
@@ -95,7 +95,7 @@
 	{
 
 		$colNameArr=explode("::",$colName);
-		$query = "select ".$table_name.".* from ".$table_name." inner join datashare_module_rel on ".$table_name.".shareid=datashare_module_rel.shareid where datashare_module_rel.tabid=".$tabid;
+		$query = "select ".$table_name.".* from ".$table_name." inner join vtiger_datashare_module_rel on ".$table_name.".shareid=vtiger_datashare_module_rel.shareid where vtiger_datashare_module_rel.tabid=".$tabid;
 		$result=$adb->query($query);
 		$num_rows=$adb->num_rows($result);
 

Modified: vtigercrm/trunk/modules/Users/OrganizationTermsandConditions.php
==============================================================================
--- vtigercrm/trunk/modules/Users/OrganizationTermsandConditions.php (original)
+++ vtigercrm/trunk/modules/Users/OrganizationTermsandConditions.php Mon Jun 12 14:26:25 2006
@@ -24,7 +24,7 @@
 require_once($theme_path.'layout_utils.php');
 
 $smarty = new vtigerCRM_Smarty;
-$sql="select * from inventory_tandc";
+$sql="select * from vtiger_inventory_tandc";
 $result = $adb->query($sql);
 $inventory_id = $adb->query_result($result,0,'id');
 $inventory_type = $adb->query_result($result,0,'type');

Modified: vtigercrm/trunk/modules/Users/ProfileDeleteStep1.php
==============================================================================
--- vtigercrm/trunk/modules/Users/ProfileDeleteStep1.php (original)
+++ vtigercrm/trunk/modules/Users/ProfileDeleteStep1.php Mon Jun 12 14:26:25 2006
@@ -44,7 +44,7 @@
 	<td align="left">';
 	$output.='<select class="select" name="transfer_prof_id">';
 	global $adb;	
-	$sql = "select * from profile";
+	$sql = "select * from vtiger_profile";
 	$result = $adb->query($sql);
 	$temprow = $adb->fetch_array($result);
 	do

Modified: vtigercrm/trunk/modules/Users/RoleDetailView.php
==============================================================================
--- vtigercrm/trunk/modules/Users/RoleDetailView.php (original)
+++ vtigercrm/trunk/modules/Users/RoleDetailView.php Mon Jun 12 14:26:25 2006
@@ -32,9 +32,9 @@
 //Standard PickList Fields
 function getStdOutput($roleid)
 {
-	//Retreiving the related profiles
+	//Retreiving the related vtiger_profiles
 	$roleProfileArr=getRoleRelatedProfiles($roleid);
-	//Retreving the related users
+	//Retreving the related vtiger_users
 	$roleUserArr=getRoleUsers($roleid);
 
 	//Constructing the Profile list

Modified: vtigercrm/trunk/modules/Users/RoleDragDrop.php
==============================================================================
--- vtigercrm/trunk/modules/Users/RoleDragDrop.php (original)
+++ vtigercrm/trunk/modules/Users/RoleDragDrop.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
 
 
 global $adb;
-$query = "select * from role where roleid='".$toid."'";
+$query = "select * from vtiger_role where vtiger_roleid='".$toid."'";
 $result=$adb->query($query);
 $parentRoleList=$adb->query_result($result,0,'parentrole');
 $replace_with=$parentRoleList;
@@ -50,7 +50,7 @@
 	$mvParString=$replace_with.$subPar[1];
 	$subDepth=$mvRoleInfo[2];
 	$mvDepth=$orgDepth+(($subDepth-$stdDepth)+1);
-	$query="update role set parentrole='".$mvParString."',depth=".$mvDepth." where roleid='".$mvRoleId."'";
+	$query="update vtiger_role set parentrole='".$mvParString."',depth=".$mvDepth." where vtiger_roleid='".$mvRoleId."'";
 	//echo $query;
 	$adb->query($query);
 		

Modified: vtigercrm/trunk/modules/Users/RolePopup.php
==============================================================================
--- vtigercrm/trunk/modules/Users/RolePopup.php (original)
+++ vtigercrm/trunk/modules/Users/RolePopup.php Mon Jun 12 14:26:25 2006
@@ -28,7 +28,7 @@
 
 
 //Retreiving the hierarchy
-$hquery = "select * from role order by parentrole asc";
+$hquery = "select * from vtiger_role order by parentrole asc";
 $hr_res = $adb->query($hquery);
 $num_rows = $adb->num_rows($hr_res);
 $hrarray= Array();
@@ -79,7 +79,7 @@
 }
 //Constructing the Roledetails array
 $role_det = getAllRoleDetails();
-$query = "select * from role";
+$query = "select * from vtiger_role";
 $result = $adb->query($query);
 $num_rows=$adb->num_rows($result);
 $mask_roleid='';
@@ -95,7 +95,7 @@
 	foreach($hrarray as $roleid => $value)
 	{
 	
-		//retreiving the role details
+		//retreiving the vtiger_role details
 		$role_det_arr=$role_det[$roleid];
 		$roleid_arr=$role_det_arr[2];
 		$rolename = $role_det_arr[0];

Modified: vtigercrm/trunk/modules/Users/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Users/Save.php (original)
+++ vtigercrm/trunk/modules/Users/Save.php Mon Jun 12 14:26:25 2006
@@ -29,7 +29,7 @@
 $user_name = $_REQUEST['userName'];
 if(isset($_REQUEST['dup_check']) && $_REQUEST['dup_check'] != '')
 {
-        $query = "SELECT user_name FROM users WHERE user_name ='".$user_name."'";
+        $query = "SELECT user_name FROM vtiger_users WHERE user_name ='".$user_name."'";
         $result = $adb->query($query);
         if($adb->num_rows($result) > 0)
         {
@@ -90,7 +90,7 @@
 	}
 	
 	if (!isset($_POST['is_admin'])) $focus->is_admin = 'off';
-	//Code contributed by mike crowe for rearrange the home page and tab
+	//Code contributed by mike crowe for rearrange the home page and vtiger_tab
 	if (!isset($_POST['deleted'])) $focus->deleted = '0';
 	if (!isset($_POST['homeorder']) || $_POST['homeorder'] == "" ) $focus->homeorder = 'ILTI,QLTQ,ALVT,PLVT,CVLVT,HLT,OLV,GRT,OLTSO';
 	

Modified: vtigercrm/trunk/modules/Users/SaveGroup.php
==============================================================================
--- vtigercrm/trunk/modules/Users/SaveGroup.php (original)
+++ vtigercrm/trunk/modules/Users/SaveGroup.php Mon Jun 12 14:26:25 2006
@@ -20,12 +20,12 @@
 {
         if($mode != 'edit')
         {
-                $query = 'select groupname from groups where groupname="'.$groupName.'"';
+                $query = 'select groupname from vtiger_groups where groupname="'.$groupName.'"';
         }
         else
         {
                 $groupid = $_REQUEST['groupid'];
-                $query = 'select groupname from groups  where groupname="'.$groupName.'" and groupid !='.$groupid;
+                $query = 'select groupname from vtiger_groups  where groupname="'.$groupName.'" and groupid !='.$groupid;
 
         }
         $result = $adb->query($query);

Modified: vtigercrm/trunk/modules/Users/SaveInventoryNotification.php
==============================================================================
--- vtigercrm/trunk/modules/Users/SaveInventoryNotification.php (original)
+++ vtigercrm/trunk/modules/Users/SaveInventoryNotification.php Mon Jun 12 14:26:25 2006
@@ -14,7 +14,7 @@
 
 if(isset($_REQUEST['record']) && $_REQUEST['record']!='')
 {
-	$query="UPDATE inventorynotification set notificationsubject='".$_REQUEST['notifysubject']."', notificationbody='".$_REQUEST['notifybody']."' where notificationid=".$_REQUEST['record'];
+	$query="UPDATE vtiger_inventorynotification set notificationsubject='".$_REQUEST['notifysubject']."', notificationbody='".$_REQUEST['notifybody']."' where notificationid=".$_REQUEST['record'];
 	$adb->query($query);	
 }
 $loc = "Location: index.php?action=UsersAjax&file=listinventorynotifications&module=Users&directmode=ajax";

Modified: vtigercrm/trunk/modules/Users/SaveNotification.php
==============================================================================
--- vtigercrm/trunk/modules/Users/SaveNotification.php (original)
+++ vtigercrm/trunk/modules/Users/SaveNotification.php Mon Jun 12 14:26:25 2006
@@ -14,7 +14,7 @@
 
 if(isset($_REQUEST['record']) && $_REQUEST['record']!='')
 {
-	$query="UPDATE notificationscheduler set notificationsubject='".$_REQUEST['notifysubject']."', notificationbody='".$_REQUEST['notifybody']."', active =".$_REQUEST['active']." where schedulednotificationid=".$_REQUEST['record'];
+	$query="UPDATE vtiger_notificationscheduler set notificationsubject='".$_REQUEST['notifysubject']."', notificationbody='".$_REQUEST['notifybody']."', active =".$_REQUEST['active']." where schedulednotificationid=".$_REQUEST['record'];
 	$adb->query($query);	
 }
 $loc = "Location: index.php?action=UsersAjax&file=listnotificationschedulers&module=Users&directmode=ajax";

Modified: vtigercrm/trunk/modules/Users/SaveOrgSharing.php
==============================================================================
--- vtigercrm/trunk/modules/Users/SaveOrgSharing.php (original)
+++ vtigercrm/trunk/modules/Users/SaveOrgSharing.php Mon Jun 12 14:26:25 2006
@@ -12,7 +12,7 @@
 require_once('include/database/PearDatabase.php');
 global $adb;
 
-$sql2 = "select * from def_org_share where editstatus=0";
+$sql2 = "select * from vtiger_def_org_share where editstatus=0";
 $result2 = $adb->query($sql2);
 $num_rows = $adb->num_rows($result2);
 
@@ -22,19 +22,19 @@
 	$tabid=$adb->query_result($result2,$i,'tabid');
 		$reqval = $tabid.'_per';	
 		$permission=$_REQUEST[$reqval];
-		$sql7="update def_org_share set permission=".$permission." where tabid=".$tabid." and ruleid=".$ruleid;
+		$sql7="update vtiger_def_org_share set permission=".$permission." where vtiger_tabid=".$tabid." and ruleid=".$ruleid;
 		$adb->query($sql7);
 
 		if($tabid == 6)
 		{
-			$sql8="update def_org_share set permission=".$permission." where tabid=4";
+			$sql8="update vtiger_def_org_share set permission=".$permission." where vtiger_tabid=4";
 			$adb->query($sql8);
 			
 		}
 
 		if($tabid == 9)
 		{
-			$sql8="update def_org_share set permission=".$permission." where tabid=16";
+			$sql8="update vtiger_def_org_share set permission=".$permission." where vtiger_tabid=16";
 			$adb->query($sql8);
 			
 		}

Modified: vtigercrm/trunk/modules/Users/SaveProfile.php
==============================================================================
--- vtigercrm/trunk/modules/Users/SaveProfile.php (original)
+++ vtigercrm/trunk/modules/Users/SaveProfile.php Mon Jun 12 14:26:25 2006
@@ -18,24 +18,24 @@
 $def_module = $_REQUEST['selected_module'];
 $def_tab = $_REQUEST['selected_tab'];
 //Inserting values into Profile Table
-$sql1 = "insert into profile values('','".$profilename."','".$description."')";
+$sql1 = "insert into vtiger_profile values('','".$profilename."','".$description."')";
 $adb->query($sql1);
 
-        //Retreiving the profileid
-        $sql2 = "select max(profileid) as current_id from profile";
+        //Retreiving the vtiger_profileid
+        $sql2 = "select max(profileid) as current_id from vtiger_profile";
         $result2 = $adb->query($sql2);
         $profileid = $adb->query_result($result2,0,'current_id');
 
 
-//Retreiving the tabs permission array
-$tab_perr_result = $adb->query("select * from profile2tab where profileid=1");
-$act_perr_result = $adb->query("select * from profile2standardpermissions where profileid=1");
-$act_utility_result = $adb->query("select * from profile2utility where profileid=1");
+//Retreiving the vtiger_tabs permission array
+$tab_perr_result = $adb->query("select * from vtiger_profile2tab where vtiger_profileid=1");
+$act_perr_result = $adb->query("select * from vtiger_profile2standardpermissions where vtiger_profileid=1");
+$act_utility_result = $adb->query("select * from vtiger_profile2utility where vtiger_profileid=1");
 $num_tab_per = $adb->num_rows($tab_perr_result);
 $num_act_per = $adb->num_rows($act_perr_result);
 $num_act_util_per = $adb->num_rows($act_utility_result);
 
-	//Updating profile2global permissons table
+	//Updating vtiger_profile2global permissons vtiger_table
 	$view_all_req=$_REQUEST['view_all'];
 	$view_all = getPermissionValue($view_all_req);
 
@@ -43,10 +43,10 @@
 	$edit_all = getPermissionValue($edit_all_req);
 
 
-	$sql4="insert into profile2globalpermissions values(".$profileid.",1, ".$view_all.")";
+	$sql4="insert into vtiger_profile2globalpermissions values(".$profileid.",1, ".$view_all.")";
         $adb->query($sql4);
 
-	$sql4="insert into profile2globalpermissions values(".$profileid.",2, ".$edit_all.")";
+	$sql4="insert into vtiger_profile2globalpermissions values(".$profileid.",2, ".$edit_all.")";
         $adb->query($sql4);
 
 	
@@ -66,23 +66,23 @@
 			{
 				$permission_value = 1;
 			}
-			$sql4="insert into profile2tab values(".$profileid.", ".$tab_id.", ".$permission_value.")";
+			$sql4="insert into vtiger_profile2tab values(".$profileid.", ".$tab_id.", ".$permission_value.")";
                 	$adb->query($sql4);
 
 			if($tab_id ==9)
 			{
-				$sql4="insert into profile2tab values(".$profileid.",16, ".$permission_value.")";
+				$sql4="insert into vtiger_profile2tab values(".$profileid.",16, ".$permission_value.")";
                         	$adb->query($sql4);	
 			}
 		}
 		elseif($tab_id == 13)
 		{
-			$sql4="insert into profile2tab values(".$profileid.",13,0)";
+			$sql4="insert into vtiger_profile2tab values(".$profileid.",13,0)";
                         $adb->query($sql4);
 		}
 		elseif($tab_id == 15)
 		{
-			$sql4="insert into profile2tab values(".$profileid.",15,0)";
+			$sql4="insert into vtiger_profile2tab values(".$profileid.",15,0)";
                         $adb->query($sql4);
 		}
 	}
@@ -118,12 +118,12 @@
 				$permission_value = 1;
 			}
 
-			$sql7="insert into profile2standardpermissions values(".$profileid.", ".$tab_id.", ".$action_id.", ".$permission_value.")";
+			$sql7="insert into vtiger_profile2standardpermissions values(".$profileid.", ".$tab_id.", ".$action_id.", ".$permission_value.")";
                 	$adb->query($sql7);
 
 			if($tab_id ==9)
 			{
-				$sql7="insert into profile2standardpermissions values(".$profileid.", 16, ".$action_id.", ".$permission_value.")";
+				$sql7="insert into vtiger_profile2standardpermissions values(".$profileid.", 16, ".$action_id.", ".$permission_value.")";
                         	$adb->query($sql7);
 			}
 
@@ -133,7 +133,7 @@
 		elseif($tab_id == 15)
 		{
 			
-                          $sql7="insert into profile2standardpermissions values(".$profileid.", 15, ".$action_id.",0)";
+                          $sql7="insert into vtiger_profile2standardpermissions values(".$profileid.", 15, ".$action_id.",0)";
                           $adb->query($sql7);
 		}
 	}
@@ -158,7 +158,7 @@
 			$permission_value = 1;
 		}
 
-		$sql9="insert into profile2utility values(".$profileid.", ".$tab_id.", ".$action_id.", ".$permission_value.")";
+		$sql9="insert into vtiger_profile2utility values(".$profileid.", ".$tab_id.", ".$action_id.", ".$permission_value.")";
                 $adb->query($sql9);
 
 	}
@@ -185,14 +185,14 @@
 		{
 			$visible_value = 1;
 		}
-		//Updating the Mandatory fields
+		//Updating the Mandatory vtiger_fields
 		$uitype = $adb->query_result($fieldListResult,$i,"uitype");
 		if($uitype == 2 || $uitype == 51 || $uitype == 6 || $uitype == 22 || $uitype == 73 || $uitype				== 24 || $uitype == 81 || $uitype == 50 || $uitype == 23 || $uitype == 16)
 		{
 			$visible_value = 0;
 		}
 		//Updating the database
-		$sql11="insert into profile2field values(".$profileid.", ".$tab_id.", ".$fieldid.", ".$visible_value.",1)";
+		$sql11="insert into vtiger_profile2field values(".$profileid.", ".$tab_id.", ".$fieldid.", ".$visible_value.",1)";
                 $adb->query($sql11);
 	}
 }

Modified: vtigercrm/trunk/modules/Users/SaveRole.php
==============================================================================
--- vtigercrm/trunk/modules/Users/SaveRole.php (original)
+++ vtigercrm/trunk/modules/Users/SaveRole.php Mon Jun 12 14:26:25 2006
@@ -17,12 +17,12 @@
 {
 	if($mode != 'edit')
 	{
-		$query = 'select rolename from role where rolename="'.$rolename.'"';
+		$query = 'select vtiger_rolename from vtiger_role where vtiger_rolename="'.$rolename.'"';
 	}
 	else
 	{
 		$roleid=$_REQUEST['roleid'];
-		$query = 'select rolename from role where rolename="'.$rolename.'" and roleid !="'.$roleid.'"';
+		$query = 'select vtiger_rolename from vtiger_role where vtiger_rolename="'.$rolename.'" and vtiger_roleid !="'.$roleid.'"';
 
 	}
 	$result = $adb->query($query);
@@ -51,7 +51,7 @@
 {
 	$selected_col_string = 	$_REQUEST['selectedColumnsString'];
 	$profile_array = explode(';',$selected_col_string);
-	//Inserting into role Table
+	//Inserting into vtiger_role Table
 	$roleId = createRole($rolename,$parentRoleId,$profile_array);
 	 	
 }

Modified: vtigercrm/trunk/modules/Users/TabCustomise.php
==============================================================================
--- vtigercrm/trunk/modules/Users/TabCustomise.php (original)
+++ vtigercrm/trunk/modules/Users/TabCustomise.php Mon Jun 12 14:26:25 2006
@@ -154,7 +154,7 @@
 </style>
 </head>
 <?
-		$tabavail="SELECT tabid,name from tab where presence !=2";
+		$tabavail="SELECT vtiger_tabid,name from vtiger_tab where presence !=2";
 		$tabrow=$adb->query($tabavail);
 		if($adb->num_rows($tabrow) != 0)
 		{
@@ -163,7 +163,7 @@
 				$availabletab[]=$result;
 			}
 		}	
-		$tabsel="SELECT tabid,name from tab where presence=0 order by tabsequence";
+		$tabsel="SELECT vtiger_tabid,name from vtiger_tab where presence=0 order by vtiger_tabsequence";
 		$tabrow=$adb->query($tabsel);
 		if($adb->num_rows($tabrow) != 0)
 		{
@@ -342,7 +342,7 @@
                 } else if (id.indexOf("fieldlist")>=0) {//if Field List
                         if (currSelItemObj.id.indexOf("fd")<0) {
                                 itemObj.style.cursor='move'
-                                itemObj.className='tableBorder mouseover'       //Hiliting Field List only when added fields are removed
+                                itemObj.className='tableBorder mouseover'       //Hiliting Field List only when added vtiger_fields are removed
                         }
                 }
         }

Modified: vtigercrm/trunk/modules/Users/UpdateDefaultFieldLevelAccess.php
==============================================================================
--- vtigercrm/trunk/modules/Users/UpdateDefaultFieldLevelAccess.php (original)
+++ vtigercrm/trunk/modules/Users/UpdateDefaultFieldLevelAccess.php Mon Jun 12 14:26:25 2006
@@ -32,7 +32,7 @@
 		{
 			$visible_value = 1;
 		}
-		//Updating the Mandatory fields
+		//Updating the Mandatory vtiger_fields
 		$uitype = $adb->query_result($fieldListResult,$i,"uitype");
 		if($uitype == 2 || $uitype == 51 || $uitype == 6 || $uitype == 22 || $uitype == 73 || $uitype == 24 || $uitype == 81 || $uitype == 50 || $uitype == 23 || $uitype == 16)
 		{
@@ -40,7 +40,7 @@
 		}		
 
 		//Updating the database
-		$update_query = "update def_org_field set visible=".$visible_value." where fieldid='".$fieldid."' and tabid=".$tab_id;
+		$update_query = "update vtiger_def_org_field set visible=".$visible_value." where vtiger_fieldid='".$fieldid."' and vtiger_tabid=".$tab_id;
 		$adb->query($update_query);
 
 	}

Modified: vtigercrm/trunk/modules/Users/UpdateProfileChanges.php
==============================================================================
--- vtigercrm/trunk/modules/Users/UpdateProfileChanges.php (original)
+++ vtigercrm/trunk/modules/Users/UpdateProfileChanges.php Mon Jun 12 14:26:25 2006
@@ -22,24 +22,24 @@
 else
 	$return_action = 'ListProfiles';
 
-//Retreiving the tabs permission array
-$tab_perr_result = $adb->query("select * from profile2tab where profileid=".$profileid);
-$act_perr_result = $adb->query("select * from profile2standardpermissions where profileid=".$profileid);
-$act_utility_result = $adb->query("select * from profile2utility where profileid=".$profileid);
+//Retreiving the vtiger_tabs permission array
+$tab_perr_result = $adb->query("select * from vtiger_profile2tab where vtiger_profileid=".$profileid);
+$act_perr_result = $adb->query("select * from vtiger_profile2standardpermissions where vtiger_profileid=".$profileid);
+$act_utility_result = $adb->query("select * from vtiger_profile2utility where vtiger_profileid=".$profileid);
 $num_tab_per = $adb->num_rows($tab_perr_result);
 $num_act_per = $adb->num_rows($act_perr_result);
 $num_act_util_per = $adb->num_rows($act_utility_result);
 
-	//Updating profile2global permissons table
+	//Updating vtiger_profile2global permissons vtiger_table
 	$view_all_req=$_REQUEST['view_all'];
 	$view_all = getPermissionValue($view_all_req);
 
 	$edit_all_req=$_REQUEST['edit_all'];
 	$edit_all = getPermissionValue($edit_all_req);
 
-	$update_query = "update  profile2globalpermissions set globalactionpermission=".$view_all." where globalactionid=1 and profileid=".$profileid;
+	$update_query = "update  vtiger_profile2globalpermissions set globalactionpermission=".$view_all." where globalactionid=1 and vtiger_profileid=".$profileid;
 	$adb->query($update_query);
-	$update_query = "update  profile2globalpermissions set globalactionpermission=".$edit_all." where globalactionid=2 and profileid=".$profileid;
+	$update_query = "update  vtiger_profile2globalpermissions set globalactionpermission=".$edit_all." where globalactionid=2 and vtiger_profileid=".$profileid;
 	$adb->query($update_query);
 
 	
@@ -59,11 +59,11 @@
 			{
 				$permission_value = 1;
 			}
-			$update_query = "update profile2tab set permissions=".$permission_value." where tabid=".$tab_id." and profileid=".$profileid;
+			$update_query = "update vtiger_profile2tab set permissions=".$permission_value." where vtiger_tabid=".$tab_id." and vtiger_profileid=".$profileid;
 			$adb->query($update_query);
 			if($tab_id ==9)
 			{
-				$update_query = "update profile2tab set permissions=".$permission_value." where tabid=16 and profileid=".$profileid;
+				$update_query = "update vtiger_profile2tab set permissions=".$permission_value." where vtiger_tabid=16 and vtiger_profileid=".$profileid;
 				$adb->query($update_query);
 			}
 		}
@@ -99,11 +99,11 @@
 			{
 				$permission_value = 1;
 			}
-			$update_query = "update profile2standardpermissions set permissions=".$permission_value." where tabid=".$tab_id." and Operation=".$action_id." and profileid=".$profileid;
+			$update_query = "update vtiger_profile2standardpermissions set permissions=".$permission_value." where vtiger_tabid=".$tab_id." and Operation=".$action_id." and vtiger_profileid=".$profileid;
 			$adb->query($update_query);
 			if($tab_id ==9)
 			{
-				$update_query = "update profile2standardpermissions set permissions=".$permission_value." where tabid=16 and Operation=".$action_id." and profileid=".$profileid;
+				$update_query = "update vtiger_profile2standardpermissions set permissions=".$permission_value." where vtiger_tabid=16 and Operation=".$action_id." and vtiger_profileid=".$profileid;
 				$adb->query($update_query);
 			}
 
@@ -132,7 +132,7 @@
 			$permission_value = 1;
 		}
 
-		$update_query = "update profile2utility set permission=".$permission_value." where tabid=".$tab_id." and activityid=".$action_id." and profileid=".$profileid;
+		$update_query = "update vtiger_profile2utility set permission=".$permission_value." where vtiger_tabid=".$tab_id." and vtiger_activityid=".$action_id." and vtiger_profileid=".$profileid;
 
 		$adb->query($update_query);
 
@@ -160,14 +160,14 @@
 		{
 			$visible_value = 1;
 		}
-		//Updating the Mandatory fields
+		//Updating the Mandatory vtiger_fields
 		$uitype = $adb->query_result($fieldListResult,$i,"uitype");
 		if($uitype == 2 || $uitype == 51 || $uitype == 6 || $uitype == 22 || $uitype == 73 || $uitype				== 24 || $uitype == 81 || $uitype == 50 || $uitype == 23 || $uitype == 16)
 		{
 			$visible_value = 0;
 		}
 		//Updating the database
-		$update_query = "update profile2field set visible=".$visible_value." where fieldid='".$fieldid."' and profileid=".$profileid." and tabid=".$tab_id;
+		$update_query = "update vtiger_profile2field set visible=".$visible_value." where vtiger_fieldid='".$fieldid."' and vtiger_profileid=".$profileid." and vtiger_tabid=".$tab_id;
 		$adb->query($update_query);
 
 	}

Modified: vtigercrm/trunk/modules/Users/UpdateTab.php
==============================================================================
--- vtigercrm/trunk/modules/Users/UpdateTab.php (original)
+++ vtigercrm/trunk/modules/Users/UpdateTab.php Mon Jun 12 14:26:25 2006
@@ -60,12 +60,12 @@
 	$xtpl->out("user_settings");
 }
 
-$sql_set = "update tab set presence=1 where presence !=2";
+$sql_set = "update vtiger_tab set presence=1 where presence !=2";
 $adb->query($sql_set);
 $j=1;
 foreach($_POST as $name=>$value)
 {
-  $sql="update tab set presence=0,tabsequence= " . $j . " where tabid = " .$value;
+  $sql="update vtiger_tab set presence=0,tabsequence= " . $j . " where vtiger_tabid = " .$value;
   $adb->query($sql);
   $j++;
 }

Modified: vtigercrm/trunk/modules/Users/User.php
==============================================================================
--- vtigercrm/trunk/modules/Users/User.php (original)
+++ vtigercrm/trunk/modules/Users/User.php Mon Jun 12 14:26:25 2006
@@ -37,7 +37,7 @@
 class User extends SugarBean {
 	var $log;
 	var $db;
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $user_name;
 	var $user_password;
@@ -85,7 +85,7 @@
 
 	var $module_id='id';
 	
-	var $table_name = "users";
+	var $table_name = "vtiger_users";
 	var $module_name = "Users";
 
 	var $object_name = "User";
@@ -144,10 +144,10 @@
 
 	var $encodeFields = Array("first_name", "last_name", "description");
 
-	// This is used to retrieve related fields from form posts.
+	// This is used to retrieve related vtiger_fields from form posts.
 	var $additional_column_fields = Array('reports_to_name');		
 	
-	// This is the list of fields that are in the lists.
+	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array('id', 'first_name', 'last_name', 'user_name', 'status', 'department', 'yahoo_id', 'is_admin', 'email1', 'phone_work');
 	//commented as we get issues with sugarbean
 	/*
@@ -359,7 +359,7 @@
 		$query = "SELECT * from $this->table_name where user_name='$this->user_name'";
 		$result = $this->db->requireSingleResult($query, false);
 
-		// Get the fields for the user
+		// Get the vtiger_fields for the user
 		$row = $this->db->fetchByAssoc($result);
 
 		$user_hash = strtolower(md5($user_password));
@@ -374,7 +374,7 @@
 			$this->db->query($query, true, "Error setting new hash for {$row['user_name']}: ");	
 		}
 		
-		// now fill in the fields.
+		// now fill in the vtiger_fields.
 		foreach($this->column_fields as $field)
 		{
 			//$this->log->info($field);
@@ -453,14 +453,14 @@
 
 	function retrieve_user_id($user_name)
 	{
-		$query = "SELECT id from users where user_name='$user_name' AND deleted=0";
+		$query = "SELECT id from vtiger_users where user_name='$user_name' AND deleted=0";
 		$result  =& $this->db->query($query, false,"Error retrieving user ID: ");
 		$row = $this->db->fetchByAssoc($result);
 		return $row['id'];
 	}
 	
 	/** 
-	 * @return -- returns a list of all users in the system.
+	 * @return -- returns a list of all vtiger_users in the system.
 	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
 	 * All Rights Reserved..
 	 * Contributor(s): ______________________________________..
@@ -469,12 +469,12 @@
 	{
 		global $mod_strings;
 		
-		$query = "SELECT user_name from users where user_name='$this->user_name' AND id<>'$this->id' AND deleted=0";
+		$query = "SELECT user_name from vtiger_users where user_name='$this->user_name' AND id<>'$this->id' AND deleted=0";
 		$result =$this->db->query($query, true, "Error selecting possible duplicate users: ");
 		$dup_users = $this->db->fetchByAssoc($result);
 		
-		$query = "SELECT user_name from users where is_admin = 'on' AND deleted=0";
-		$result =$this->db->query($query, true, "Error selecting possible duplicate users: ");
+		$query = "SELECT user_name from vtiger_users where is_admin = 'on' AND deleted=0";
+		$result =$this->db->query($query, true, "Error selecting possible duplicate vtiger_users: ");
 		$last_admin = $this->db->fetchByAssoc($result);
 
 		$this->log->debug("last admin length: ".count($last_admin));
@@ -507,7 +507,7 @@
 											 "CITY","STATE","POSTALCODE","COUNTRY");	
   	return $mergeflds;
   }
-		//function added for the listview of users for 5.0 beta
+		//function added for the listview of vtiger_users for 5.0 beta
 	function getUserListViewHeader()
 	{
 		global $mod_strings;
@@ -522,9 +522,9 @@
 	    	$theme_path="themes/".$theme."/";
 	    	$image_path=$theme_path."images/";
 		if($sorder != '' && $orderby !='')
-			$list_query = ' SELECT * from users where deleted=0 order by '.$orderby.' '.$sorder; 	
+			$list_query = ' SELECT * from vtiger_users where deleted=0 order by '.$orderby.' '.$sorder; 	
 		else
-			$list_query = "SELECT * from users where deleted=0 order by ".$this->default_order_by." ".$this->default_sort_order;
+			$list_query = "SELECT * from vtiger_users where deleted=0 order by ".$this->default_order_by." ".$this->default_sort_order;
 		$result =$adb->query($list_query);
 		$entries_list = array();
 		$roleinfo = getAllRoleDetails();
@@ -569,9 +569,9 @@
 	
 	function fill_in_additional_detail_fields()
 	{
-		//$query = "SELECT u1.first_name, u1.last_name from users as u1, users as u2 where u1.id = u2.reports_to_id AND u2.id = '$this->id' and u1.deleted=0";
-		$query = "SELECT u1.first_name, u1.last_name from users u1, users u2 where u1.id = u2.reports_to_id AND u2.id = '$this->id' and u1.deleted=0";
-		$result =$this->db->query($query, true, "Error filling in additional detail fields") ;
+		//$query = "SELECT u1.first_name, u1.last_name from vtiger_users as u1, vtiger_users as u2 where u1.id = u2.reports_to_id AND u2.id = '$this->id' and u1.deleted=0";
+		$query = "SELECT u1.first_name, u1.last_name from vtiger_users u1, vtiger_users u2 where u1.id = u2.reports_to_id AND u2.id = '$this->id' and u1.deleted=0";
+		$result =$this->db->query($query, true, "Error filling in additional detail vtiger_fields") ;
 		
 		$row = $this->db->fetchByAssoc($result);
 		$this->log->debug("additional detail query results: $row");

Modified: vtigercrm/trunk/modules/Users/UserDeleteStep1.php
==============================================================================
--- vtigercrm/trunk/modules/Users/UserDeleteStep1.php (original)
+++ vtigercrm/trunk/modules/Users/UserDeleteStep1.php Mon Jun 12 14:26:25 2006
@@ -46,7 +46,7 @@
 $output.='<select class="select" name="transfer_user_id" id="transfer_user_id">';
 	     
 		 global $adb;	
-         $sql = "select * from users";
+         $sql = "select * from vtiger_users";
          $result = $adb->query($sql);
          $temprow = $adb->fetch_array($result);
          do

Modified: vtigercrm/trunk/modules/Users/UsersAjax.php
==============================================================================
--- vtigercrm/trunk/modules/Users/UsersAjax.php (original)
+++ vtigercrm/trunk/modules/Users/UsersAjax.php Mon Jun 12 14:26:25 2006
@@ -23,7 +23,7 @@
 elseif(isset($_REQUEST['announce_rss']) && ($_REQUEST['announce_rss'] != ''))
 {
 	$announcement='';
-	$sql="select * from announcement order by time";
+	$sql="select * from vtiger_announcement order by time";
 	$result=$adb->query($sql);
 	for($i=0;$i<$adb->num_rows($result);$i++)
 	{
@@ -38,12 +38,12 @@
 	$date_var = date('YmdHis');
 	$announcement = $_REQUEST['announcement'];
 	$title = $_REQUEST['title_announcement'];
-	$sql="select * from announcement where creatorid=".$current_user->id;
+	$sql="select * from vtiger_announcement where creatorid=".$current_user->id;
 	$is_announce=$adb->query($sql);
 	if($adb->num_rows($is_announce) > 0)
-		$query="update announcement set announcement=".$adb->formatString("announcement","announcement",$announcement).",time=".$adb->formatString("announcement","time",$date_var).",title='announcement' where creatorid=".$current_user->id;
+		$query="update vtiger_announcement set vtiger_announcement=".$adb->formatString("announcement","announcement",$announcement).",time=".$adb->formatString("announcement","time",$date_var).",title='announcement' where creatorid=".$current_user->id;
 	else
-		$query="insert into announcement values (".$current_user->id.",".$adb->formatString("announcement","announcement",$announcement).",'announcement','".$date_var."')";
+		$query="insert into vtiger_announcement values (".$current_user->id.",".$adb->formatString("announcement","announcement",$announcement).",'announcement','".$date_var."')";
 	$result=$adb->query($query);
 	echo $announcement;
 }

Modified: vtigercrm/trunk/modules/Users/add2db.php
==============================================================================
--- vtigercrm/trunk/modules/Users/add2db.php (original)
+++ vtigercrm/trunk/modules/Users/add2db.php Mon Jun 12 14:26:25 2006
@@ -67,7 +67,7 @@
 		if($genQueryId != '')
 		{
 			$module = $_REQUEST['target_module'];
-			$sql = "INSERT INTO wordtemplates ";
+			$sql = "INSERT INTO vtiger_wordtemplates ";
 			$sql .= "(templateid,module,date_entered,parent_type,data,description,filename,filesize,filetype) ";
 			$sql .= "VALUES (".$genQueryId.",'".$module."',".$adb->formatString('wordtemplates','date_entered',$date_entered).",'$parent_type',".$adb->getEmptyBlob().",'$strDescription',";
 			$sql .= "'$filename', '$filesize', '$filetype')";
@@ -108,8 +108,8 @@
   {
     include('themes/'.$theme.'/header.php');
     include "upload.php";
-    //$errormessage = "<B><font color='red'>Sorry, the uploaded file exceeds the maximum filesize limit. Please try a smaller file</font></B> <br>";
-	echo "<script>alert('Sorry, the uploaded file exceeds the maximum filesize limit. Please try a smaller file')</script>";	
+    //$errormessage = "<B><font color='red'>Sorry, the uploaded file exceeds the maximum vtiger_filesize limit. Please try a smaller file</font></B> <br>";
+	echo "<script>alert('Sorry, the uploaded file exceeds the maximum vtiger_filesize limit. Please try a smaller file')</script>";	
     //echo $errormessage;
     //echo $errorCode;
   }

Modified: vtigercrm/trunk/modules/Users/binaryfilelist.php
==============================================================================
--- vtigercrm/trunk/modules/Users/binaryfilelist.php (original)
+++ vtigercrm/trunk/modules/Users/binaryfilelist.php Mon Jun 12 14:26:25 2006
@@ -22,7 +22,7 @@
 
 	$dbQuery = "SELECT templateid, filename,filesize,filetype,description,module ";
 
-	$dbQuery .= "FROM wordtemplates" ;
+	$dbQuery .= "FROM vtiger_wordtemplates" ;
 
 	$dbQuery .= " ORDER BY filename ASC";
 

Modified: vtigercrm/trunk/modules/Users/createrole.php
==============================================================================
--- vtigercrm/trunk/modules/Users/createrole.php (original)
+++ vtigercrm/trunk/modules/Users/createrole.php Mon Jun 12 14:26:25 2006
@@ -29,7 +29,7 @@
 	$thisRoleDet=$roleInfo[$roleid];
 	$rolename = $thisRoleDet[0]; 
 	$parent = $thisRoleDet[3]; 
-	//retreiving the profileid
+	//retreiving the vtiger_profileid
 	$roleRelatedProfiles=getRoleRelatedProfiles($roleid);
 
 }

Modified: vtigercrm/trunk/modules/Users/deleteemailtemplate.php
==============================================================================
--- vtigercrm/trunk/modules/Users/deleteemailtemplate.php (original)
+++ vtigercrm/trunk/modules/Users/deleteemailtemplate.php Mon Jun 12 14:26:25 2006
@@ -14,7 +14,7 @@
 
 for($i=0;$i < count($id_array)-1;$i++)
 {
-		$sql = "delete from emailtemplates where templateid =".$id_array[$i];
+		$sql = "delete from vtiger_emailtemplates where templateid =".$id_array[$i];
 		$adb->query($sql);
 }
 

Modified: vtigercrm/trunk/modules/Users/deletewordtemplate.php
==============================================================================
--- vtigercrm/trunk/modules/Users/deletewordtemplate.php (original)
+++ vtigercrm/trunk/modules/Users/deletewordtemplate.php Mon Jun 12 14:26:25 2006
@@ -15,7 +15,7 @@
  for($i=0; $i < count($id_array)-1; $i++)
  {
 
-	         $sql = "delete from wordtemplates where templateid=".$id_array[$i];
+	         $sql = "delete from vtiger_wordtemplates where templateid=".$id_array[$i];
 	         $adb->query($sql);
 
  }

Modified: vtigercrm/trunk/modules/Users/detailviewemailtemplate.php
==============================================================================
--- vtigercrm/trunk/modules/Users/detailviewemailtemplate.php (original)
+++ vtigercrm/trunk/modules/Users/detailviewemailtemplate.php Mon Jun 12 14:26:25 2006
@@ -38,7 +38,7 @@
 {
 	$log->info("The templateid is set");
 	$tempid = $_REQUEST['templateid'];
-	$sql = "select * from emailtemplates where templateid=".$tempid;
+	$sql = "select * from vtiger_emailtemplates where templateid=".$tempid;
 	$result = $adb->query($sql);
 	$emailtemplateResult = $adb->fetch_array($result);
 }

Modified: vtigercrm/trunk/modules/Users/downloadfile.php
==============================================================================
--- vtigercrm/trunk/modules/Users/downloadfile.php (original)
+++ vtigercrm/trunk/modules/Users/downloadfile.php Mon Jun 12 14:26:25 2006
@@ -16,7 +16,7 @@
 
 $templateid = $_REQUEST['record'];
 $dbQuery = "SELECT filename,filetype, data ";
-$dbQuery .= "FROM wordtemplates ";
+$dbQuery .= "FROM vtiger_wordtemplates ";
 $dbQuery .= "WHERE templateid=" .$templateid;
 
 $result = $adb->query($dbQuery) or die("Couldn't get file list");

Modified: vtigercrm/trunk/modules/Users/editemailtemplate.php
==============================================================================
--- vtigercrm/trunk/modules/Users/editemailtemplate.php (original)
+++ vtigercrm/trunk/modules/Users/editemailtemplate.php Mon Jun 12 14:26:25 2006
@@ -31,7 +31,7 @@
 	$templateid = $_REQUEST['templateid'];
 	 $log->debug("the templateid is set to the value ".$templateid);
 }
-$sql = "select * from emailtemplates where templateid=".$templateid;
+$sql = "select * from vtiger_emailtemplates where templateid=".$templateid;
 $result = $adb->query($sql);
 $emailtemplateResult = $adb->fetch_array($result);
 

Modified: vtigercrm/trunk/modules/Users/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Users/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Users/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -123,7 +123,7 @@
 'ERR_LAST_ADMIN_1'=>'The user name ',
 'ERR_LAST_ADMIN_2'=>' is the last Admin user.  At least one user must be an Admin user.<br>Check the Admin user setting.',
 
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
 
 // Additional Fields for i18n --- Release vtigerCRM 3.2 Patch 2
 // Users--listroles.php , createrole.php , ListPermissions.php , editpermissions.php
@@ -186,7 +186,7 @@
 'LBL_COLON'=>':',
 'LBL_EMAIL_TEMPLATE'=>'Email Template',
 'LBL_NEW_TEMPLATE'=>'New Template',
-'LBL_USE_MERGE_FIELDS_TO_EMAIL_CONTENT'=>'Use merge fields to personalize your email content.',
+'LBL_USE_MERGE_FIELDS_TO_EMAIL_CONTENT'=>'Use merge vtiger_fields to personalize your email content.',
 'LBL_AVAILABLE_MERGE_FIELDS'=>'Available Merge Fields',
 'LBL_SELECT_FIELD_TYPE'=>'Select Field Type :',
 'LBL_SELECT_FIELD'=>'Select Field :',
@@ -194,7 +194,7 @@
 'LBL_ACCOUNT_FIELDS'=>'Account Fields',
 'LBL_CONTACT_FIELDS'=>'Contact Fields',
 'LBL_LEAD_FIELDS'=>'Lead Fields',
-'LBL_COPY_AND_PASTE_MERGE_FIELD'=>'Copy and paste the merge field value into your template below.',
+'LBL_COPY_AND_PASTE_MERGE_FIELD'=>'Copy and paste the merge vtiger_field value into your template below.',
 'LBL_EMAIL_TEMPLATE_INFORMATION'=>'Communication Templates > Email Templates > Viewing',
 'LBL_FOLDER'=>'Folder',
 'LBL_PERSONAL'=>'Personal',
@@ -209,7 +209,7 @@
 'LBL_TEMPLATE_MESSAGE'=>'Email Message',
 
 
-// Added fields in createnewgroup.php
+// Added vtiger_fields in createnewgroup.php
 'LBL_CREATE_NEW_GROUP'=>'Create New Group',
 'LBL_NEW_GROUP'=>'New Group',
 'LBL_EDIT_GROUP'=>'Edit Group',
@@ -220,7 +220,7 @@
 'LBL_MEMBER_SELECTED'=>'Selected Member',
 'LBL_DESCRIPTION'=>'Description',
 
-// Added fields in detailViewmailtemplate.html,listgroupmembers.php,listgroups.php
+// Added vtiger_fields in detailViewmailtemplate.html,listgroupmembers.php,listgroups.php
 'LBL_DETAIL_VIEW_OF_EMAIL_TEMPLATE'=>'Detail View of Email Template',
 'LBL_DETAIL_VIEW'=>'Detail View of',
 'LBL_EDIT_VIEW'=>'Edit View of',
@@ -230,7 +230,7 @@
 'LBL_WORD_TEMPLATES'=>'Mail Merge Templates',
 'LBL_NEW_WORD_TEMPLATE'=>'New Template',
 
-// Added fields in TabCustomise.php,html and UpdateTab.php,html
+// Added vtiger_fields in TabCustomise.php,html and UpdateTab.php,html
 'LBL_CUSTOMISE_TABS'=>'Customize Tabs',
 'LBL_CHOOSE_TABS'=>'Choose Tabs',
 'LBL_AVAILABLE_TABS'=>'Available Tabs',
@@ -243,10 +243,10 @@
 'LBL_CHANGE_HOMEPAGE_LABEL'=>'Homepage Order',
 'LBL_CHANGE_HOMEPAGE_TITLE'=>'Homepage',
 
-// Added fields in binaryfilelist.php
+// Added vtiger_fields in binaryfilelist.php
 'LBL_OERATION'=>'Operation',
 
-// Added fields in CreateProfile.php
+// Added vtiger_fields in CreateProfile.php
 'LBL_PROFILE_NAME'=>'Create New Profile:',
 'LBL_NEW_PROFILE'=>'New Profile',
 'LBL_NEW_PROFILE_NAME'=>'Profile Name',
@@ -263,7 +263,7 @@
 'LBL_STANDARD_PRIVILEGES'=>'Standard Privileges',
 'LBL_UTILITY_PRIVILEGES'=>'Utility Privileges',
 'LBL_UTILITIES'=>'Utilities',
-'LBL_BASE_PROFILE_MESG'=>'I would like to setup a base profile and edit privileges <b>(Recommended)</b>',
+'LBL_BASE_PROFILE_MESG'=>'I would like to setup a base vtiger_profile and edit privileges <b>(Recommended)</b>',
 'LBL_BASE_PROFILE'=>'Base Profile:',
 'LBL_OR'=>'OR',
 'LBL_BASE_PROFILE_MESG_ADV'=>'I will choose the privileges from scratch <b>(Advanced Users)</b>',
@@ -275,19 +275,19 @@
 'LBL_MESG_VIEW'=>'to view all information / modules of vtiger CRM',
 'LBL_MESG_EDIT'=>'to edit all information / modules of vtiger CRM',
 'LBL_STD_MESG_OPTION'=>'Select the standard actions to be permitted',
-'LBL_TAB_MESG_OPTION'=>'Select the tabs/modules to be permitted',
+'LBL_TAB_MESG_OPTION'=>'Select the vtiger_tabs/modules to be permitted',
 'LBL_UTILITY_MESG_OPTION'=>'Select the utility actions to be permitted',
-'LBL_FIELD_MESG_OPTION'=>'Select the fields to be permitted',
+'LBL_FIELD_MESG_OPTION'=>'Select the vtiger_fields to be permitted',
 'LBL_FINISH_BUTTON'=>'Finish',
 'LBL_PROFILE_DETAIL_VIEW'=>'Detail View of Profile',
 
 
-//Added fields in createrole.php
+//Added vtiger_fields in createrole.php
 'LBL_HDR_ROLE_NAME'=>'Create New Role:',
 'LBL_TITLE_ROLE_NAME'=>'New Role',
 'LBL_ROLE_NAME'=>'Role Name',
 'LBL_ROLE_PROFILE_NAME'=>'Associate With Profile',
-'LBL_SPECIFY_ROLE_NAME'=>'Specify a name for new role :',
+'LBL_SPECIFY_ROLE_NAME'=>'Specify a name for new vtiger_role :',
 'LBL_ASSIGN_PROFILE'=>'Assign Profile(s)',
 'LBL_PROFILE_SELECT_TEXT'=>'Select the Profiles below and click on assign button',
 'LBL_PROFILES_AVLBL'=>'Profiles Available',
@@ -297,7 +297,7 @@
 'LBL_ASSOCIATED_USERS'=>'Associated Users :',
 
 
-//Added fields in OrgSharingDetailsView.php
+//Added vtiger_fields in OrgSharingDetailsView.php
 'LBL_ORG_SHARING_PRIVILEGES'=>'Organisation Sharing  Privileges',
 'LBL_EDIT_PERMISSIONS'=>'Edit Permissions',
 'LBL_SAVE_PERMISSIONS'=>'Save Permissions',
@@ -306,7 +306,7 @@
 'LBL_READ_CREATE_EDIT_DEL'=>'Public: Read, Create/Edit, Delete',
 'LBL_PRIVATE'=>'Private',
 
-//Added fields in listnotificationschedulers.php
+//Added vtiger_fields in listnotificationschedulers.php
 'LBL_HDR_EMAIL_SCHDS'=>'Users : Email Notifications',
 'LBL_EMAIL_SCHDS_DESC'=>'The following is the list of notifications that are activated automatically when the corresponding event has happened.',
 'LBL_ACTIVE'=>'Active',
@@ -327,13 +327,13 @@
 'LBL_BUTTON_UPDATE'=>'Update',
 'LBL_MODULENAMES'=>'Module',
 
-//Added fields in ListFieldPermissions.html
+//Added vtiger_fields in ListFieldPermissions.html
 'LBL_FIELD_PERMISSION_FIELD_NAME'=>'Field Name',
 'LBL_FIELD_PERMISSION_VISIBLE'=>'Visible',
 'LBL_FIELD_PERMISSIOM_TABLE_HEADER'=>'Standard Fields',
 'LBL_FIELD_LEVEL_ACCESS'=>'Field Level Access',
 
-//Added fields after 4.0.1
+//Added vtiger_fields after 4.0.1
 'LBL_SIGNATURE'=>'Signature',
 
 //Added for Event Reminder 4.2 Alpha release
@@ -352,9 +352,9 @@
 'Show Details'=>'Show Details',
 'Show Details and Add Events'=>'Show Details and Add Events',
 
-'LBL_USR_CANNOT_ACCESS'=>'Users cannot access other users ',
+'LBL_USR_CANNOT_ACCESS'=>'Users cannot access other vtiger_users ',
 'LBL_USR_CAN_ACCESS'=>'Users can ',
-'LBL_USR_OTHERS'=>' other users ',
+'LBL_USR_OTHERS'=>' other vtiger_users ',
 
 'Read Only '=>'Read Only ',
 'Read, Create/Edit, Delete '=>'Read, Create/Edit, Delete ',
@@ -432,7 +432,7 @@
 
 //given for calendar color for an user user
 'LBL_COLOR'=>'Color in Calendar',
-//added for activity view in home page
+//added for vtiger_activity view in home page
 'LBL_ACTIVITY_VIEW'=>'Default Activity View',
 //Added to change Home page order
 'LBL_HOMEPAGE_ORDER_UPDATE'=>'Update Home Page Block Order',
@@ -486,7 +486,7 @@
 'LBL_CREATE_RULE_MESG'=>'to create a new Rule',
 'LBL_SELECT_SCREEN'=>'Select the Screen / Module :',
 'LBL_FIELDS_AVLBL'=>'Fields Available in',
-'LBL_FIELDS_SELECT_DESELECT'=>'Select or De-Select fields to be shown',
+'LBL_FIELDS_SELECT_DESELECT'=>'Select or De-Select vtiger_fields to be shown',
 'LBL_ROLE_TO_BE_DELETED'=>'Role to be Deleted',
 'LBL_TRANSFER_USER_ROLE'=>'Transfer Users to Role',
 'LBL_DELETE_ROLE'=>'Delete Role'

Modified: vtigercrm/trunk/modules/Users/listemailtemplates.php
==============================================================================
--- vtigercrm/trunk/modules/Users/listemailtemplates.php (original)
+++ vtigercrm/trunk/modules/Users/listemailtemplates.php Mon Jun 12 14:26:25 2006
@@ -18,7 +18,7 @@
 
 $log->info("Inside Email Templates List View");
 
-   $sql = "select * from emailtemplates order by templateid DESC";
+   $sql = "select * from vtiger_emailtemplates order by templateid DESC";
    $result = $adb->query($sql);
    $temprow = $adb->fetch_array($result);
    

Modified: vtigercrm/trunk/modules/Users/listinventorynotifications.php
==============================================================================
--- vtigercrm/trunk/modules/Users/listinventorynotifications.php (original)
+++ vtigercrm/trunk/modules/Users/listinventorynotifications.php Mon Jun 12 14:26:25 2006
@@ -18,7 +18,7 @@
 $image_path=$theme_path."images/";
 
 $smarty = new vtigerCRM_Smarty;
-$query = "SELECT * FROM inventorynotification";
+$query = "SELECT * FROM vtiger_inventorynotification";
 $result = $adb->query($query);
 $num_rows = $adb->num_rows($result);
 $output = Array();

Modified: vtigercrm/trunk/modules/Users/listnotificationschedulers.php
==============================================================================
--- vtigercrm/trunk/modules/Users/listnotificationschedulers.php (original)
+++ vtigercrm/trunk/modules/Users/listnotificationschedulers.php Mon Jun 12 14:26:25 2006
@@ -16,7 +16,7 @@
 $image_path=$theme_path."images/";
 
 $smarty = new vtigerCRM_Smarty;
-$query = "SELECT * FROM notificationscheduler";
+$query = "SELECT * FROM vtiger_notificationscheduler";
 $result = $adb->query($query);
 if($adb->num_rows($result) >=1)
 {

Modified: vtigercrm/trunk/modules/Users/listroles.php
==============================================================================
--- vtigercrm/trunk/modules/Users/listroles.php (original)
+++ vtigercrm/trunk/modules/Users/listroles.php Mon Jun 12 14:26:25 2006
@@ -28,7 +28,7 @@
 
 
 //Retreiving the hierarchy
-$hquery = "select * from role order by parentrole asc";
+$hquery = "select * from vtiger_role order by parentrole asc";
 $hr_res = $adb->query($hquery);
 $num_rows = $adb->num_rows($hr_res);
 $hrarray= Array();
@@ -79,7 +79,7 @@
 }
 //Constructing the Roledetails array
 $role_det = getAllRoleDetails();
-$query = "select * from role";
+$query = "select * from vtiger_role";
 $result = $adb->query($query);
 $num_rows=$adb->num_rows($result);
 
@@ -93,7 +93,7 @@
 	foreach($hrarray as $roleid => $value)
 	{
 	
-		//retreiving the role details
+		//retreiving the vtiger_role details
 		$role_det_arr=$role_det[$roleid];
 		$roleid_arr=$role_det_arr[2];
 		$rolename = $role_det_arr[0];

Modified: vtigercrm/trunk/modules/Users/listwordtemplates.php
==============================================================================
--- vtigercrm/trunk/modules/Users/listwordtemplates.php (original)
+++ vtigercrm/trunk/modules/Users/listwordtemplates.php Mon Jun 12 14:26:25 2006
@@ -13,7 +13,7 @@
 require_once('include/database/PearDatabase.php');
 
    global $adb;
-   $sql = "select templateid, module, description, filename, filesize, filetype from wordtemplates order by filename ASC";
+   $sql = "select templateid, module, description, filename, vtiger_filesize, filetype from vtiger_wordtemplates order by filename ASC";
    $result = $adb->query($sql);
 
 $edit="Edit  ";

Modified: vtigercrm/trunk/modules/Users/lookupemailtemplates.php
==============================================================================
--- vtigercrm/trunk/modules/Users/lookupemailtemplates.php (original)
+++ vtigercrm/trunk/modules/Users/lookupemailtemplates.php Mon Jun 12 14:26:25 2006
@@ -36,7 +36,7 @@
                 <th width="65%" class="lvtCol"><b><?php echo $mod_strings['LBL_DESCRIPTION']; ?></b></td>
                 </tr>
 <?php
-   $sql = "select * from emailtemplates order by templateid desc";
+   $sql = "select * from vtiger_emailtemplates order by templateid desc";
    $result = $adb->query($sql);
    $temprow = $adb->fetch_array($result);
 $cnt=1;

Modified: vtigercrm/trunk/modules/Users/massChangeStatus.php
==============================================================================
--- vtigercrm/trunk/modules/Users/massChangeStatus.php (original)
+++ vtigercrm/trunk/modules/Users/massChangeStatus.php Mon Jun 12 14:26:25 2006
@@ -39,7 +39,7 @@
 }
 function updateStatus()
 {
-	var leadstatusvalue=document.setLeadStatus.lead_status.value
+	var vtiger_leadstatusvalue=document.setLeadStatus.lead_status.value
 	//alert(leadstatusvalue);
 	document.setLeadStatus.leadval.value=leadstatusvalue;
 	document.setLeadStatus.action="index.php?module=Users&action=updateLeadDBStatus"
@@ -96,7 +96,7 @@
 }
 elseif(isset($_REQUEST['change_owner']) && $_REQUEST['change_owner']=='true')
 {
-	$result=$adb->query("select * from users");
+	$result=$adb->query("select * from vtiger_users");
 	for($i=0;$i<$adb->num_rows($result);$i++)
 	{
 		$useridlist[$i]=$adb->query_result($result,$i,'id');

Modified: vtigercrm/trunk/modules/Users/massdelete.php
==============================================================================
--- vtigercrm/trunk/modules/Users/massdelete.php (original)
+++ vtigercrm/trunk/modules/Users/massdelete.php Mon Jun 12 14:26:25 2006
@@ -27,7 +27,7 @@
 {
         if(isPermitted($returnmodule,'Delete',$id) == 'yes')
         {
-                $sql="update crmentity set deleted=1 where crmid='" .$id ."'";
+                $sql="update vtiger_crmentity set deleted=1 where crmid='" .$id ."'";
                 $result = $adb->query($sql);
         }
         else

Modified: vtigercrm/trunk/modules/Users/populatetemplate.php
==============================================================================
--- vtigercrm/trunk/modules/Users/populatetemplate.php (original)
+++ vtigercrm/trunk/modules/Users/populatetemplate.php Mon Jun 12 14:26:25 2006
@@ -8,7 +8,7 @@
  * All Rights Reserved.
 *
  ********************************************************************************/
-//query the specific table and then get the data and write the data here 
+//query the specific vtiger_table and then get the data and write the data here 
 require_once('include/database/PearDatabase.php');
 include_once('modules/Contacts/Contact.php');
 include_once('modules/Leads/Lead.php');
@@ -16,7 +16,7 @@
 global $log;
 
 //download the template file and store it in some specific location
-$sql = "select templatename,body from emailtemplates where templateid='".$_REQUEST["templateid"] ."'";
+$sql = "select templatename,body from vtiger_emailtemplates where templateid='".$_REQUEST["templateid"] ."'";
 $tempresult = $adb->query($sql);
 $tempArray = $adb->fetch_array($tempresult);
 $fileContent = $tempArray["body"];
@@ -86,7 +86,7 @@
 
 global $current_user;
 global $adb;
-$query = 'select * from users where id= '.$current_user->id;
+$query = 'select * from vtiger_users where id= '.$current_user->id;
 $result = $adb->query($query);
 $res_row = $adb->fetchByAssoc($result);
 foreach ($res_row as $columnName=>$value)

Modified: vtigercrm/trunk/modules/Users/profilePrivileges.php
==============================================================================
--- vtigercrm/trunk/modules/Users/profilePrivileges.php (original)
+++ vtigercrm/trunk/modules/Users/profilePrivileges.php Mon Jun 12 14:26:25 2006
@@ -71,7 +71,7 @@
 
 
 
-//Initially setting the secondary selected tab
+//Initially setting the secondary selected vtiger_tab
 $mode=$_REQUEST['mode'];
 if($mode == 'create')
 {

Modified: vtigercrm/trunk/modules/Users/saveemailtemplate.php
==============================================================================
--- vtigercrm/trunk/modules/Users/saveemailtemplate.php (original)
+++ vtigercrm/trunk/modules/Users/saveemailtemplate.php Mon Jun 12 14:26:25 2006
@@ -33,7 +33,7 @@
 if(isset($templateid) && $templateid !='')
 {
 	$log->info("the templateid is set");  
-	$sql = "update emailtemplates set foldername = '".$folderName."', templatename ='".$templateName."', subject ='".$subject."', description ='".$description."', body ='".$body."' where templateid =".$templateid;
+	$sql = "update vtiger_emailtemplates set foldername = '".$folderName."', templatename ='".$templateName."', subject ='".$subject."', description ='".$description."', body ='".$body."' where templateid =".$templateid;
 	$adb->query($sql);
  
 	$log->info("about to invoke the detailviewemailtemplate file");  
@@ -42,7 +42,7 @@
 else
 {
 	$templateid = $db->getUniqueID('emailtemplates');
-	$sql = "insert into emailtemplates values ('". $folderName. "','".$templateName."','".$subject."','".$description."','".$body."',0,".$templateid.")";
+	$sql = "insert into vtiger_emailtemplates values ('". $folderName. "','".$templateName."','".$subject."','".$description."','".$body."',0,".$templateid.")";
 	$adb->query($sql);
 
 	 $log->info("added to the db the emailtemplate");

Modified: vtigercrm/trunk/modules/Users/savetermsandconditions.php
==============================================================================
--- vtigercrm/trunk/modules/Users/savetermsandconditions.php (original)
+++ vtigercrm/trunk/modules/Users/savetermsandconditions.php Mon Jun 12 14:26:25 2006
@@ -14,17 +14,17 @@
 $inv_type='Inventory';
 $inv_tandc=$_REQUEST['inventory_tandc'];
 
-$sql="select * from inventory_tandc where type='".$inv_type."'";
+$sql="select * from vtiger_inventory_tandc where type='".$inv_type."'";
 $result = $adb->query($sql);
 $inv_id = $adb->query_result($result,0,'id');
 if($inv_id == '')
 {
         $inv_id=$adb->getUniqueID('inventory_tandc');
-        $sql="insert into inventory_tandc values( '".$inv_id ."','".$inv_type."','". $inv_tandc."')";
+        $sql="insert into vtiger_inventory_tandc values( '".$inv_id ."','".$inv_type."','". $inv_tandc."')";
 }
 else
 {
-	$sql="update inventory_tandc set type = '".$inv_type."', tandc = '".$inv_tandc."' where id = ".$inv_id;
+	$sql="update vtiger_inventory_tandc set type = '".$inv_type."', tandc = '".$inv_tandc."' where id = ".$inv_id;
 }
 $adb->query($sql);
 

Modified: vtigercrm/trunk/modules/Users/updateLeadDBStatus.php
==============================================================================
--- vtigercrm/trunk/modules/Users/updateLeadDBStatus.php (original)
+++ vtigercrm/trunk/modules/Users/updateLeadDBStatus.php Mon Jun 12 14:26:25 2006
@@ -32,7 +32,7 @@
 		if(isPermitted($return_module,'EditView',$id) == 'yes')
 		{
 			if($id != '') {
-				$sql = "update crmentity set modifiedby=".$current_user->id.",smownerid='" .$idval ."', modifiedtime=".$adb->formatString("crmentity","modifiedtime",$date_var)." where crmid='" .$id."'";
+				$sql = "update vtiger_crmentity set modifiedby=".$current_user->id.",smownerid='" .$idval ."', modifiedtime=".$adb->formatString("crmentity","modifiedtime",$date_var)." where crmid='" .$id."'";
 				$result = $adb->query($sql);
 			}
 		}
@@ -49,9 +49,9 @@
 		if(isPermitted($return_module,'EditView',$id) == 'yes')
 		{
 			if($id != '') {
-				$sql = "update leaddetails set leadstatus='" .$leadstatusval ."' where leadid='" .$id."'";
+				$sql = "update vtiger_leaddetails set vtiger_leadstatus='" .$leadstatusval ."' where leadid='" .$id."'";
 				$result = $adb->query($sql);
-				$query = "update crmentity set modifiedby=".$current_user->id.",modifiedtime=".$adb->formatString("crmentity","modifiedtime",$date_var)." where crmid=".$id;
+				$query = "update vtiger_crmentity set modifiedby=".$current_user->id.",modifiedtime=".$adb->formatString("crmentity","modifiedtime",$date_var)." where crmid=".$id;
 				$result1 = $adb->query($query);
 			}
 		}

Modified: vtigercrm/trunk/modules/Users/updateNotificationSchedulers.php
==============================================================================
--- vtigercrm/trunk/modules/Users/updateNotificationSchedulers.php (original)
+++ vtigercrm/trunk/modules/Users/updateNotificationSchedulers.php Mon Jun 12 14:26:25 2006
@@ -23,7 +23,7 @@
 
 global $adb;
 $flag=0;
-//pass the table id as a parameter and then update directly instead of using the name field 
+//pass the vtiger_table id as a parameter and then update directly instead of using the name vtiger_field 
 for ($i=1;$i<10;$i++)
 {
   if($_POST[$i] == 'on')
@@ -34,7 +34,7 @@
   {
     $flag=0;
   }
- $sql = "update notificationscheduler set active=".$flag."  where schedulednotificationid=".$i;
+ $sql = "update vtiger_notificationscheduler set active=".$flag."  where schedulednotificationid=".$i;
  
  $adb->query($sql);
 }

Modified: vtigercrm/trunk/modules/Utilities/Merge.php
==============================================================================
--- vtigercrm/trunk/modules/Utilities/Merge.php (original)
+++ vtigercrm/trunk/modules/Utilities/Merge.php Mon Jun 12 14:26:25 2006
@@ -18,7 +18,7 @@
 $mergeFileName = $_REQUEST['mergefile'];
 //get the particular file from db and store it in the local hard disk.
 //store the path to the location where the file is stored and pass it  as parameter to the method 
-$sql = "select filename,data,filesize from wordtemplatestorage where filename='".$mergeFileName."'";
+$sql = "select filename,data,filesize from vtiger_wordtemplatestorage where filename='".$mergeFileName."'";
 
 $result = $adb->query($sql);
 $temparray = $adb->fetch_array($result);

Modified: vtigercrm/trunk/modules/Vendors/Vendor.php
==============================================================================
--- vtigercrm/trunk/modules/Vendors/Vendor.php (original)
+++ vtigercrm/trunk/modules/Vendors/Vendor.php Mon Jun 12 14:26:25 2006
@@ -22,17 +22,17 @@
 	var $db;
 
 
-	// Stored fields
+	// Stored vtiger_fields
 	var $id;
 	var $mode;
 
-	var $tab_name = Array('crmentity','vendor','vendorcf');
-	var $tab_name_index = Array('crmentity'=>'crmid','vendor'=>'vendorid','vendorcf'=>'vendorid');
+	var $tab_name = Array('vtiger_crmentity','vtiger_vendor','vtiger_vendorcf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_vendor'=>'vendorid','vtiger_vendorcf'=>'vendorid');
 	var $column_fields = Array();
 
 	var $sortby_fields = Array('vendorname','category');		  
 
-        // This is the list of fields that are in the lists.
+        // This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
                                 'Vendor Name'=>Array('vendor'=>'vendorname'),
                                 'Phone'=>Array('vendor'=>'phone'),
@@ -84,7 +84,7 @@
 
 		$returnset = '&return_module=Vendors&return_action=DetailView&return_id='.$id;
 
-		$query = 'select products.productid, products.productname, products.productcode, products.commissionrate, products.qty_per_unit, products.unit_price, crmentity.crmid, crmentity.smownerid,vendor.vendorname from products inner join crmentity on crmentity.crmid = products.productid left outer join vendor on vendor.vendorid = products.vendor_id where vendor.vendorid = '.$id.' and crmentity.deleted = 0';
+		$query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_vendor.vendorname from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid left outer join vtiger_vendor on vtiger_vendor.vendorid = vtiger_products.vendor_id where vtiger_vendor.vendorid = '.$id.' and vtiger_crmentity.deleted = 0';
 		$log->debug("Exiting get_products method ...");
 		return GetRelatedList('Vendors','Products',$focus,$query,$button,$returnset);
 	}
@@ -100,7 +100,7 @@
 
 		$returnset = '&return_module=Vendors&return_action=DetailView&return_id='.$id;
 
-		$query = "select crmentity.*, purchaseorder.*,vendor.vendorname from purchaseorder inner join crmentity on crmentity.crmid=purchaseorder.purchaseorderid left outer join vendor on purchaseorder.vendorid=vendor.vendorid left join pogrouprelation on purchaseorder.purchaseorderid=pogrouprelation.purchaseorderid left join groups on groups.groupname=pogrouprelation.groupname where crmentity.deleted=0 and purchaseorder.vendorid=".$id;
+		$query = "select vtiger_crmentity.*, vtiger_purchaseorder.*,vtiger_vendor.vendorname from vtiger_purchaseorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_purchaseorder.purchaseorderid left outer join vtiger_vendor on vtiger_purchaseorder.vendorid=vtiger_vendor.vendorid left join vtiger_pogrouprelation on vtiger_purchaseorder.purchaseorderid=vtiger_pogrouprelation.purchaseorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_pogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_purchaseorder.vendorid=".$id;
 		$log->debug("Exiting get_purchase_orders method ...");
 		return GetRelatedList('Vendors','PurchaseOrder',$focus,$query,$button,$returnset);
 	}
@@ -115,7 +115,7 @@
 		$button = '';
 		$returnset = '&return_module=Vendors&return_action=DetailView&return_id='.$id;
 
-		$query = 'SELECT contactdetails.*, crmentity.crmid, crmentity.smownerid,vendorcontactrel.vendorid from contactdetails inner join crmentity on crmentity.crmid = contactdetails.contactid  inner join vendorcontactrel on vendorcontactrel.contactid=contactdetails.contactid left join contactgrouprelation on contactdetails.contactid=contactgrouprelation.contactid left join groups on groups.groupname=contactgrouprelation.groupname where crmentity.deleted=0 and vendorcontactrel.vendorid = '.$id;
+		$query = 'SELECT vtiger_contactdetails.*, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_vendorcontactrel.vendorid from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid  inner join vtiger_vendorcontactrel on vtiger_vendorcontactrel.contactid=vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_vendorcontactrel.vendorid = '.$id;
 		$log->debug("Exiting get_contacts method ...");
 		return GetRelatedList('Vendor','Contacts',$focus,$query,$button,$returnset);
 

Modified: vtigercrm/trunk/modules/Vendors/updateRelations.php
==============================================================================
--- vtigercrm/trunk/modules/Vendors/updateRelations.php (original)
+++ vtigercrm/trunk/modules/Vendors/updateRelations.php Mon Jun 12 14:26:25 2006
@@ -21,9 +21,9 @@
 	{
 		if($id != '')
 		{
-			$sql = "insert into vendorcontactrel values (".$_REQUEST["parentid"].",".$id.")";
+			$sql = "insert into vtiger_vendorcontactrel values (".$_REQUEST["parentid"].",".$id.")";
 			$adb->query($sql);
-			$sql = "insert into seproductsrel values (". $_REQUEST["parentid"] .",".$id.")";
+			$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parentid"] .",".$id.")";
 			$adb->query($sql);
 		}
 	}
@@ -33,9 +33,9 @@
 elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
 {
 
-		$sql = "insert into vendorcontactrel values (".$_REQUEST['parid'].",".$_REQUEST['entityid'].")";
+		$sql = "insert into vtiger_vendorcontactrel values (".$_REQUEST['parid'].",".$_REQUEST['entityid'].")";
 		$adb->query($sql);
-		$sql = "insert into seproductsrel values (". $_REQUEST["parid"] .",".$_REQUEST["entityid"] .")";
+		$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parid"] .",".$_REQUEST["entityid"] .")";
 		$adb->query($sql);
  		header("Location:index.php?action=CallRelatedList&module=Vendors&record=".$_REQUEST["parid"]);
 }

Modified: vtigercrm/trunk/modules/Webmails/CallRelatedList.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/CallRelatedList.php (original)
+++ vtigercrm/trunk/modules/Webmails/CallRelatedList.php Mon Jun 12 14:26:25 2006
@@ -52,21 +52,21 @@
 $block["Leads"]= "";
 global $adb;
 if($email->relationship != 0 && $email->relationship["type"] == "Leads") {
-	$q = "SELECT leaddetails.firstname, leaddetails.lastname, leaddetails.email, leaddetails.company, crmentity.smownerid from leaddetails left join crmentity on crmentity.crmid=leaddetails.leadid WHERE leaddetails.leadid='".$email->relationship["id"]."'";
+	$q = "SELECT vtiger_leaddetails.firstname, vtiger_leaddetails.lastname, vtiger_leaddetails.email, vtiger_leaddetails.company, vtiger_crmentity.smownerid from vtiger_leaddetails left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid WHERE vtiger_leaddetails.leadid='".$email->relationship["id"]."'";
 	$rs = $adb->query($q);
 	$block["Leads"]["header"]= array("0"=>"First Name","1"=>"Last Name","2"=>"Company Name","3"=>"Email Address","4"=>"Assigned To");
 	$block["Leads"]["entries"]= array("0"=>array($adb->query_result($rs,0,'firstname'),"1"=>$adb->query_result($rs,0,'lastname'),2=>$adb->query_result($rs,0,'company'),3=>$adb->query_result($rs,0,'email'),4=>$adb->query_result($rs,0,'smownerid')));
 }
 $block["Contacts"]= "";
 if($email->relationship != 0 && $email->relationship["type"] == "Contacts") {
-	$q = "SELECT contactdetails.firstname, contactdetails.lastname, contactdetails.email, contactdetails.title, crmentity.smownerid from contactdetails left join crmentity on crmentity.crmid=contactdetails.contactid WHERE contactdetails.contactid='".$email->relationship["id"]."'";
+	$q = "SELECT vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_contactdetails.email, vtiger_contactdetails.title, vtiger_crmentity.smownerid from vtiger_contactdetails left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid WHERE vtiger_contactdetails.contactid='".$email->relationship["id"]."'";
 	$rs = $adb->query($q);
 	$block["Contacts"]["header"]= array("0"=>"First Name","1"=>"Last Name","2"=>"Title","3"=>"Email Address","4"=>"Assigned To");
 	$block["Contacts"]["entries"]= array("0"=>array($adb->query_result($rs,0,'firstname'),"1"=>$adb->query_result($rs,0,'lastname'),2=>$adb->query_result($rs,0,'title'),3=>$adb->query_result($rs,0,'email'),4=>$adb->query_result($rs,0,'smownerid')));
 }
 $block["Accounts"]= "";
 if($email->relationship != 0 && $email->relationship["type"] == "Accounts") {
-	$q = "SELECT acccount.accountname, account.email1, account.website, account.industry, crmentity.smownerid from account left join crmentity on crmentity.crmid=account.accountid WHERE account.accountid='".$email->relationship["id"]."'";
+	$q = "SELECT acccount.accountname, vtiger_account.email1, vtiger_account.website, vtiger_account.industry, vtiger_crmentity.smownerid from vtiger_account left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid WHERE vtiger_account.accountid='".$email->relationship["id"]."'";
 	$rs = $adb->query($q);
 	$block["Accounts"]["header"]= array("0"=>"Account Name","1"=>"Email","2"=>"Web Site","3"=>"Industry","4"=>"Assigned To");
 	$block["Accounts"]["entries"]= array("0"=>array($adb->query_result($rs,0,'accountname'),"1"=>$adb->query_result($rs,0,'email'),2=>$adb->query_result($rs,0,'website'),3=>$adb->query_result($rs,0,'industry'),4=>$adb->query_result($rs,0,'smownerid')));

Modified: vtigercrm/trunk/modules/Webmails/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/ListView.php (original)
+++ vtigercrm/trunk/modules/Webmails/ListView.php Mon Jun 12 14:26:25 2006
@@ -150,7 +150,7 @@
  	global $mbox,$displayed_msgs,$show_hidden,$new_msgs;
 
   	$num = $mails[$start_message]->msgno;
-  	// TODO: scan the current db tables to find a
+  	// TODO: scan the current db vtiger_tables to find a
   	// matching email address that will make a good
   	// candidate for record_id
   	// this module will also need to be able to associate to any entity type

Modified: vtigercrm/trunk/modules/Webmails/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/Save.php (original)
+++ vtigercrm/trunk/modules/Webmails/Save.php Mon Jun 12 14:26:25 2006
@@ -76,8 +76,8 @@
 $focus->column_fields["description"]=$msgData;
 
 
-//to save the email details in emaildetails tables
-$fieldid = $adb->query_result($adb->query('select fieldid from field where tablename="contactdetails" and fieldname="email" and columnname="email"'),0,'fieldid');
+//to save the email details in vtiger_emaildetails vtiger_tables
+$fieldid = $adb->query_result($adb->query('select vtiger_fieldid from vtiger_field where vtiger_tablename="contactdetails" and vtiger_fieldname="email" and columnname="email"'),0,'fieldid');
 if($email->relationship != 0) {
 	$focus->column_fields['parent_id']=$email->relationship["id"].'@'.$fieldid.'|';
 
@@ -96,7 +96,7 @@
 }
 
 function add_attachment_to_contact($cid,$email) {
-	// add attachments to contact
+	// add vtiger_attachments to contact
 	global $adb,$current_user;
 	for($j=0;$j<2;$j++) {
 	    if($j==0)
@@ -113,16 +113,16 @@
         	$filetype= substr($filename,strstr($filename,"."),strlen($filename));
 		$filesize = $attachments[$i]["filesize"];
 
-                $query = "insert into crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime) values('";
+                $query = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime) values('";
                 $query .= $current_id."','".$current_user->id."','".$current_user->id."','Contacts Attachment','Uploaded from webmail during qualification','".$date_var."')";
                 $result = $adb->query($query);
 
-                $sql = "insert into attachments values(";
+                $sql = "insert into vtiger_attachments values(";
                 $sql .= $current_id.",'".$filename."','Uploaded ".$filename." from webmail','".$filetype."','".$upload_filepath."')";
 		echo $query;
                 $result = $adb->query($sql);
 
-                $sql1 = "insert into seattachmentsrel values('";
+                $sql1 = "insert into vtiger_seattachmentsrel values('";
                 $sql1 .= $cid."','".$current_id."')";
                 $result = $adb->query($sql1);
 
@@ -136,10 +136,10 @@
 $_REQUEST['parent_id'] = $focus->column_fields['parent_id'];
 $focus->save("Emails");
 
-//saving in emaildetails table
+//saving in vtiger_emaildetails vtiger_table
 $id_lists = $focus->column_fields['parent_id'].'@'.$fieldid;
 $all_to_ids = $email->from;
-$query = 'insert into emaildetails values ('.$focus->id.',"","'.$all_to_ids.'","","","","'.$id_lists.'","WEBMAIL")';
+$query = 'insert into vtiger_emaildetails values ('.$focus->id.',"","'.$all_to_ids.'","","","","'.$id_lists.'","WEBMAIL")';
 $adb->query($query);
 
 $return_id = $_REQUEST["mailid"];

Modified: vtigercrm/trunk/modules/Webmails/Webmail.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/Webmail.php (original)
+++ vtigercrm/trunk/modules/Webmails/Webmail.php Mon Jun 12 14:26:25 2006
@@ -137,21 +137,21 @@
 function find_relationships($db,$from) {
 
 	// leads search
-	$sql = "SELECT * from leaddetails left join crmentity on crmentity.crmid=leaddetails.leadid where leaddetails.email = '".$from."' AND crmentity.deleted='0'";
+	$sql = "SELECT * from vtiger_leaddetails left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid where vtiger_leaddetails.email = '".$from."' AND vtiger_crmentity.deleted='0'";
 	$res = $db->query($sql,true,"Error: "."<BR>$query");
 	$numRows = $db->num_rows($res);
 	if($numRows > 0)
 		return array('type'=>"Leads",'id'=>$db->query_result($res,0,"leadid"),'name'=>$db->query_result($res,0,"firstname")." ".$db->query_result($res,0,"lastname"));
 
 	// contacts search
-	$sql = "SELECT * from contactdetails left join crmentity on crmentity.crmid=contactdetails.contactid where contactdetails.email = '".$from."'  AND crmentity.deleted='0'";
+	$sql = "SELECT * from vtiger_contactdetails left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid where vtiger_contactdetails.email = '".$from."'  AND vtiger_crmentity.deleted='0'";
 	$res = $db->query($sql,true,"Error: "."<BR>$query");
 	$numRows = $db->num_rows($res);
 	if($numRows > 0)
 		return array('type'=>"Contacts",'id'=>$db->query_result($res,0,"contactid"),'name'=>$db->query_result($res,0,"firstname")." ".$db->query_result($res,0,"lastname"));
 
-	// accounts search
-	$sql = "SELECT * from account left join crmentity on crmentity.crmid=account.accountid where account.email1 = '".$from."' OR account.email1='".$from."'  AND crmentity.deleted='0'";
+	// vtiger_accounts search
+	$sql = "SELECT * from vtiger_account left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_account.email1 = '".$from."' OR vtiger_account.email1='".$from."'  AND vtiger_crmentity.deleted='0'";
 	$res = $db->query($sql,true,"Error: "."<BR>$query");
 	$numRows = $db->num_rows($res);
 	if($numRows > 0)
@@ -262,7 +262,7 @@
         $content = array();
         $i = 0;
         if (!$parts) { /* Simple message, only 1 piece */
-         $attachment = array(); /* No attachments */
+         $attachment = array(); /* No vtiger_attachments */
          $bod=imap_body($mbox, $mailid);
          if(preg_match("/\<br\>/",$bod))
                 	$content['body'] = $bod;

Modified: vtigercrm/trunk/modules/Webmails/dlAttachments.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/dlAttachments.php (original)
+++ vtigercrm/trunk/modules/Webmails/dlAttachments.php Mon Jun 12 14:26:25 2006
@@ -44,7 +44,7 @@
 	echo "</table><br><br>";
 
 } elseif (count(attachments) == 0 && count($inline) == 0) {
-	echo "<center><strong>No attachments for this email</strong></center><br><br>";
+	echo "<center><strong>No vtiger_attachments for this email</strong></center><br><br>";
 } else {
 
 global $root_directory;

Modified: vtigercrm/trunk/modules/Webmails/images/index.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/images/index.php (original)
+++ vtigercrm/trunk/modules/Webmails/images/index.php Mon Jun 12 14:26:25 2006
@@ -11,7 +11,7 @@
 /**
  ** index.php
  **
- ** This file simply takes any attempt to view source files
+ ** This file simply takes any attempt to view source vtiger_files
  ** and sends those people to the login screen. At this
  ** point no attempt is made to see if the person is logged
  ** or not.

Modified: vtigercrm/trunk/modules/Webmails/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/language/en_us.lang.php (original)
+++ vtigercrm/trunk/modules/Webmails/language/en_us.lang.php Mon Jun 12 14:26:25 2006
@@ -32,7 +32,7 @@
 'LBL_MOVE_TO'=>'Move To',
 'LBL_DELETE'=>'Delete',
 
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
 'LBL_DATE_SENT'=>'Date Sent:',
 'LBL_SUBJECT'=>'Subject :',
 'LBL_DATE_AND_TIME'=>'Date & Time Sent:',
@@ -100,7 +100,7 @@
 'LBL_NEW_ACCOUNT'=>'New Account',
 'LBL_ACCOUNT_TITLE'=>'Accounts',
 
-// Added fields after vtiger4 - Beta
+// Added vtiger_fields after vtiger4 - Beta
 'LBL_USER_TITLE'=>'Users',
 'LBL_NEW_USER'=>'New User',
 

Modified: vtigercrm/trunk/soap/contactserialize.php
==============================================================================
--- vtigercrm/trunk/soap/contactserialize.php (original)
+++ vtigercrm/trunk/soap/contactserialize.php Mon Jun 12 14:26:25 2006
@@ -325,7 +325,7 @@
 
 //end code for mail merge
 
-//Field array for troubletickets
+//Field array for vtiger_troubletickets
 
 $server->wsdl->addComplexType(
 	'tickets_list_array',
@@ -1018,7 +1018,7 @@
 {
 	global $adb;
 	$output = Array();
-	$sql = "select * from products inner join crmentity on crmentity.crmid=products.productid where crmentity.deleted=0";
+	$sql = "select * from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid where vtiger_crmentity.deleted=0";
 	$result = $adb->query($sql);
 	$noofrows = $adb->num_rows($result);
 	for($i=0;$i<$noofrows;$i++)
@@ -1027,26 +1027,26 @@
                 $output['productname']['productname'][$i] = $adb->query_result($result,$i,"productname");
         }
 
-	$result1 = $adb->query("select * from ticketpriorities");
+	$result1 = $adb->query("select * from vtiger_ticketpriorities");
 	for($i=0;$i<$adb->num_rows($result1);$i++)
 	{
 		$output['ticketpriorities']['ticketpriorities'][$i] = $adb->query_result($result1,$i,"ticketpriorities");
 	}
 
-        $result2 = $adb->query("select * from ticketseverities");
+        $result2 = $adb->query("select * from vtiger_ticketseverities");
         for($i=0;$i<$adb->num_rows($result2);$i++)
         {
                 $output['ticketseverities']['ticketseverities'][$i] = $adb->query_result($result2,$i,"ticketseverities");
         }
 
-        $result3 = $adb->query("select * from ticketcategories");
+        $result3 = $adb->query("select * from vtiger_ticketcategories");
         for($i=0;$i<$adb->num_rows($result3);$i++)
         {
                 $output['ticketcategories']['ticketcategories'][$i] = $adb->query_result($result3,$i,"ticketcategories");
         }
 
 	//Added to get the modules list -- september 10 2005
-        $sql2 = "select moduleowners.*,tab.name from moduleowners inner join tab on moduleowners.tabid = tab.tabid order by tab.tabsequence";
+        $sql2 = "select vtiger_moduleowners.*,vtiger_tab.name from vtiger_moduleowners inner join vtiger_tab on vtiger_moduleowners.tabid = vtiger_tab.tabid order by vtiger_tab.tabsequence";
         $result4 = $adb->query($sql2);
 	for($i=0;$i<$adb->num_rows($result4);$i++)
         {
@@ -1059,7 +1059,7 @@
 {
 	global $adb;
 
-	$category_query = "select * from faqcategories";
+	$category_query = "select * from vtiger_faqcategories";
 	$category_result = $adb->query($category_query);
 	$category_noofrows = $adb->num_rows($category_result);
 	for($j=0;$j<$category_noofrows;$j++)
@@ -1068,7 +1068,7 @@
 		$result['faqcategory'][$j] = $faqcategory;
 	}
 
-	$product_query = "select * from products inner join crmentity on crmentity.crmid=products.productid where crmentity.deleted=0";
+	$product_query = "select * from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid where vtiger_crmentity.deleted=0";
         $product_result = $adb->query($product_query);
         $product_noofrows = $adb->num_rows($product_result);
         for($i=0;$i<$product_noofrows;$i++)
@@ -1079,7 +1079,7 @@
                 $result['product'][$i]['productname'] = $productname;
 	}
 
-	$faq_query = "select faq.*, crmentity.createdtime, crmentity.modifiedtime from faq inner join crmentity on crmentity.crmid=faq.id where crmentity.deleted=0 and faq.status='Published' order by crmentity.modifiedtime DESC";
+	$faq_query = "select vtiger_faq.*, vtiger_crmentity.createdtime, vtiger_crmentity.modifiedtime from vtiger_faq inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_faq.id where vtiger_crmentity.deleted=0 and vtiger_faq.status='Published' order by vtiger_crmentity.modifiedtime DESC";
 	$faq_result = $adb->query($faq_query);
 	$faq_noofrows = $adb->num_rows($faq_result);
 	for($k=0;$k<$faq_noofrows;$k++)
@@ -1093,7 +1093,7 @@
 		$result['faq'][$k]['faqcreatedtime'] = $adb->query_result($faq_result,$k,'createdtime');
 		$result['faq'][$k]['faqmodifiedtime'] = $adb->query_result($faq_result,$k,'modifiedtime');
 
-		$faq_comment_query = "select * from faqcomments where faqid=".$faqid;
+		$faq_comment_query = "select * from vtiger_faqcomments where vtiger_faqid=".$faqid;
 		$faq_comment_result = $adb->query($faq_comment_query);
 		$faq_comment_noofrows = $adb->num_rows($faq_comment_result);
 		for($l=0;$l<$faq_comment_noofrows;$l++)
@@ -1141,7 +1141,7 @@
 {
 	global $adb;
 	$createdtime = date('Y-m-d H:i:s');
-	$faq_query = "insert into faqcomments values('',".$faqid.",'".$comment."','".$createdtime."')";
+	$faq_query = "insert into vtiger_faqcomments values('',".$faqid.",'".$comment."','".$createdtime."')";
 	$adb->query($faq_query);
 	$result = get_KBase_details('');
 	return $result;
@@ -1689,12 +1689,12 @@
 	$ticket->column_fields[parent_id]=$parent_id;
 	$ticket->column_fields[product_id]=$product_id;
 
-	//Added to get the user based on module from moduleowners -- 10-11-2005
+	//Added to get the user based on module from vtiger_moduleowners -- 10-11-2005
 	global $adb;
 	$user_id = 1;//Default admin user id
 	if($module != '')
 	{
-		$res = $adb->query("select moduleowners.*, tab.name from moduleowners inner join tab on moduleowners.tabid = tab.tabid where name='".$module."'");
+		$res = $adb->query("select vtiger_moduleowners.*, vtiger_tab.name from vtiger_moduleowners inner join vtiger_tab on vtiger_moduleowners.tabid = vtiger_tab.tabid where name='".$module."'");
 		if($adb->num_rows($res) > 0)
 		{
 			$user_id = $adb->query_result($res,0,"user_id");
@@ -1710,18 +1710,18 @@
 	$contents = ' Ticket ID : '.$ticket->id.'<br> Ticket Title : '.$title.'<br><br>'.$description;
 
 	require_once('modules/Emails/mail.php');
-	//get the contact email id who creates the ticket from portal and use this email as from email id in email
-	$result = $adb->query("select email from contactdetails where contactid=".$parent_id);
+	//get the contact email id who creates the ticket from vtiger_portal and use this email as from email id in email
+	$result = $adb->query("select email from vtiger_contactdetails where contactid=".$parent_id);
 	$contact_email = $adb->query_result($result,0,'email');
 	$from_email = $contact_email;
 
 	//send mail to assigned to user
 	$to_email = getUserEmailId('id',$user_id);
-	$adb->println("Send mail to the user who is the owner of the module about the portal ticket");
+	$adb->println("Send mail to the user who is the owner of the module about the vtiger_portal ticket");
 	$mail_status = send_mail('HelpDesk',$to_email,'',$from_email,$subject,$contents);
 
-	//send mail to the customer(contact who creates the ticket from portal)
-	$adb->println("Send mail to the customer(contact) who creates the portal ticket");
+	//send mail to the customer(contact who creates the ticket from vtiger_portal)
+	$adb->println("Send mail to the customer(contact) who creates the vtiger_portal ticket");
 	$mail_status = send_mail('Contacts',$contact_email,'',$from_email,$subject,$contents);
 
 	$tickets_list =  get_tickets_list($user_name,$parent_id); 
@@ -1750,16 +1750,16 @@
 {
 	global $adb;
 	$servercreatedtime = date("Y-m-d H:i:s");
-	$sql = "insert into ticketcomments values('',".$ticketid.",'".$comments."','".$ownerid."','customer','".$servercreatedtime."')";
+	$sql = "insert into vtiger_ticketcomments values('',".$ticketid.",'".$comments."','".$ownerid."','customer','".$servercreatedtime."')";
 	$adb->query($sql);
 
-	$updatequery = "update crmentity set modifiedtime = '".$servercreatedtime."' where crmid=".$ticketid;
+	$updatequery = "update vtiger_crmentity set modifiedtime = '".$servercreatedtime."' where crmid=".$ticketid;
 	$adb->query($updatequery);
 }
 function close_current_ticket($ticketid)
 {
 	global $adb;
-	$sql = "update troubletickets set status='Closed' where ticketid=".$ticketid;
+	$sql = "update vtiger_troubletickets set status='Closed' where ticketid=".$ticketid;
 	$result = $adb->query($sql);
 	if($result)
 		return "<br><b>Ticket status is updated as 'Closed'.</b>";
@@ -1770,7 +1770,7 @@
 {
 	global $adb;
 	$current_date = date("Y-m-d");
-	$sql = "select id, user_name, user_password,last_login_time, support_start_date, support_end_date from portalinfo inner join customerdetails on portalinfo.id=customerdetails.customerid where user_name='".$username."' and user_password = '".$password."' and isactive=1 and customerdetails.support_end_date >= '".$current_date."'";
+	$sql = "select id, user_name, user_password,last_login_time, support_start_date, support_end_date from vtiger_portalinfo inner join vtiger_customerdetails on vtiger_portalinfo.id=vtiger_customerdetails.customerid where user_name='".$username."' and user_password = '".$password."' and isactive=1 and vtiger_customerdetails.support_end_date >= '".$current_date."'";
 	$result = $adb->query($sql);	
 	$list['id'] = $adb->query_result($result,0,'id');
 	$list['user_name'] = $adb->query_result($result,0,'user_name');
@@ -1784,7 +1784,7 @@
 function change_password($id,$username,$password)
 {
 	global $adb;
-	$sql = "update portalinfo set user_password='".$password."' where id=".$id." and user_name='".$username."'";
+	$sql = "update vtiger_portalinfo set user_password='".$password."' where id=".$id." and user_name='".$username."'";
 	$result = $adb->query($sql);
 
 	$list = authenticate_user($username,$password);
@@ -1798,17 +1798,17 @@
 
 	if($flag == 'login')
 	{
-	        $sql = "update portalinfo set login_time='".$current_time."' where id=".$id;
+	        $sql = "update vtiger_portalinfo set login_time='".$current_time."' where id=".$id;
 	        $result = $adb->query($sql);
 	}
 	elseif($flag == 'logout')
 	{
-		$sql = "select * from portalinfo where id=".$id;
+		$sql = "select * from vtiger_portalinfo where id=".$id;
                 $result = $adb->query($sql);
                 if($adb->num_rows($result) != 0)
                         $last_login = $adb->query_result($result,0,'login_time');
 
-		$sql = "update portalinfo set logout_time = '".$current_time."', last_login_time='".$last_login."' where id=".$id;
+		$sql = "update vtiger_portalinfo set logout_time = '".$current_time."', last_login_time='".$last_login."' where id=".$id;
 		$result = $adb->query($sql);
 	}
 
@@ -1819,12 +1819,12 @@
 	global $adb;
         include("modules/Emails/class.phpmailer.php");
 
-	$sql = "select * from portalinfo  where user_name='".$mailid."'";
+	$sql = "select * from vtiger_portalinfo  where user_name='".$mailid."'";
 	$user_name = $adb->query_result($adb->query($sql),0,'user_name');
 	$password = $adb->query_result($adb->query($sql),0,'user_password');
 	$isactive = $adb->query_result($adb->query($sql),0,'isactive');
 
-	$fromquery = "select users.user_name, users.email1 from users inner join crmentity on users.id = crmentity.smownerid inner join contactdetails on contactdetails.contactid=crmentity.crmid where contactdetails.email ='".$mailid."'";
+	$fromquery = "select vtiger_users.user_name, vtiger_users.email1 from vtiger_users inner join vtiger_crmentity on vtiger_users.id = vtiger_crmentity.smownerid inner join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_crmentity.crmid where vtiger_contactdetails.email ='".$mailid."'";
 	$initialfrom = $adb->query_result($adb->query($fromquery),0,'user_name');
 	$from = $adb->query_result($adb->query($fromquery),0,'email1');
 
@@ -1838,7 +1838,7 @@
         $mail->Body    = $contents;
         $mail->IsSMTP();
 
-        $mailserverresult=$adb->query("select * from systems where server_type='email'");
+        $mailserverresult=$adb->query("select * from vtiger_systems where server_type='email'");
         $mail_server = $adb->query_result($mailserverresult,0,'server');
         $mail_server_username = $adb->query_result($mailserverresult,0,'server_username');
         $mail_server_password = $adb->query_result($mailserverresult,0,'server_password');
@@ -1875,7 +1875,7 @@
 		return "false@@@<b>Mail could not be sent</b>";
 	}
 	else
-		return "true@@@<b>Mail has been sent to your mail id with the customer portal login details</b>";
+		return "true@@@<b>Mail has been sent to your mail id with the customer vtiger_portal login details</b>";
 
 }
 
@@ -1915,7 +1915,7 @@
 
 
 // to do handle smartly handle the manager name
-     $query = "select contactdetails.contactid as contactid from contactdetails inner join crmentity on crmentity.crmid=contactdetails.contactid where crmentity.deleted=0 and contactdetails.firstname like '".$first_name ."' and contactdetails.lastname like '" .$last_name ."'";
+     $query = "select vtiger_contactdetails.contactid as contactid from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid where vtiger_crmentity.deleted=0 and vtiger_contactdetails.firstname like '".$first_name ."' and vtiger_contactdetails.lastname like '" .$last_name ."'";
 
 
 
@@ -1962,7 +1962,7 @@
         return null;
     }
 
-    $query = "select account.accountname accountname,account.accountid accountid from account inner join crmentity on crmentity.crmid=account.accountid where crmentity.deleted=0 and account.accountname='" .$account_name."'";
+    $query = "select vtiger_account.accountname vtiger_accountname,vtiger_account.accountid vtiger_accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_account.accountname='" .$account_name."'";
 
 
 	$db = new PearDatabase();
@@ -2000,7 +2000,7 @@
 {
 	//global $log;
 	
-	//todo make the activity body not be html encoded
+	//todo make the vtiger_activity body not be html encoded
 	//$log->fatal("In Create contact: username: $user_name first/last/email ($first_name, $last_name, $email_address)");
 	
 	global $current_user;

Modified: vtigercrm/trunk/soap/customerportal.php
==============================================================================
--- vtigercrm/trunk/soap/customerportal.php (original)
+++ vtigercrm/trunk/soap/customerportal.php Mon Jun 12 14:26:25 2006
@@ -25,7 +25,7 @@
 
 
 
-//Field array for troubletickets
+//Field array for vtiger_troubletickets
 $server->wsdl->addComplexType(
 	'tickets_list_array',
 	'complexType',
@@ -148,7 +148,7 @@
              )
 );
 
-//Added for ticket attachments
+//Added for ticket vtiger_attachments
 $server->wsdl->addComplexType(
         'get_ticket_attachments_array',
         'complexType',
@@ -291,7 +291,7 @@
 {
 	global $adb;
 	$output = Array();
-	$sql = "select * from products inner join crmentity on crmentity.crmid=products.productid where crmentity.deleted=0";
+	$sql = "select * from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid where vtiger_crmentity.deleted=0";
 	$result = $adb->query($sql);
 	$noofrows = $adb->num_rows($result);
 	for($i=0;$i<$noofrows;$i++)
@@ -300,26 +300,26 @@
                 $output['productname']['productname'][$i] = $adb->query_result($result,$i,"productname");
         }
 
-	$result1 = $adb->query("select * from ticketpriorities");
+	$result1 = $adb->query("select * from vtiger_ticketpriorities");
 	for($i=0;$i<$adb->num_rows($result1);$i++)
 	{
 		$output['ticketpriorities']['ticketpriorities'][$i] = $adb->query_result($result1,$i,"ticketpriorities");
 	}
 
-        $result2 = $adb->query("select * from ticketseverities");
+        $result2 = $adb->query("select * from vtiger_ticketseverities");
         for($i=0;$i<$adb->num_rows($result2);$i++)
         {
                 $output['ticketseverities']['ticketseverities'][$i] = $adb->query_result($result2,$i,"ticketseverities");
         }
 
-        $result3 = $adb->query("select * from ticketcategories");
+        $result3 = $adb->query("select * from vtiger_ticketcategories");
         for($i=0;$i<$adb->num_rows($result3);$i++)
         {
                 $output['ticketcategories']['ticketcategories'][$i] = $adb->query_result($result3,$i,"ticketcategories");
         }
 
 	//Added to get the modules list -- september 10 2005
-        $sql2 = "select moduleowners.*,tab.name from moduleowners inner join tab on moduleowners.tabid = tab.tabid order by tab.tabsequence";
+        $sql2 = "select vtiger_moduleowners.*,vtiger_tab.name from vtiger_moduleowners inner join vtiger_tab on vtiger_moduleowners.tabid = vtiger_tab.tabid order by vtiger_tab.tabsequence";
         $result4 = $adb->query($sql2);
 	for($i=0;$i<$adb->num_rows($result4);$i++)
         {
@@ -332,7 +332,7 @@
 {
 	global $adb;
 
-	$category_query = "select * from faqcategories";
+	$category_query = "select * from vtiger_faqcategories";
 	$category_result = $adb->query($category_query);
 	$category_noofrows = $adb->num_rows($category_result);
 	for($j=0;$j<$category_noofrows;$j++)
@@ -341,7 +341,7 @@
 		$result['faqcategory'][$j] = $faqcategory;
 	}
 
-	$product_query = "select * from products inner join crmentity on crmentity.crmid=products.productid where crmentity.deleted=0";
+	$product_query = "select * from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid where vtiger_crmentity.deleted=0";
         $product_result = $adb->query($product_query);
         $product_noofrows = $adb->num_rows($product_result);
         for($i=0;$i<$product_noofrows;$i++)
@@ -352,7 +352,7 @@
                 $result['product'][$i]['productname'] = $productname;
 	}
 
-	$faq_query = "select faq.*, crmentity.createdtime, crmentity.modifiedtime from faq inner join crmentity on crmentity.crmid=faq.id where crmentity.deleted=0 and faq.status='Published' order by crmentity.modifiedtime DESC";
+	$faq_query = "select vtiger_faq.*, vtiger_crmentity.createdtime, vtiger_crmentity.modifiedtime from vtiger_faq inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_faq.id where vtiger_crmentity.deleted=0 and vtiger_faq.status='Published' order by vtiger_crmentity.modifiedtime DESC";
 	$faq_result = $adb->query($faq_query);
 	$faq_noofrows = $adb->num_rows($faq_result);
 	for($k=0;$k<$faq_noofrows;$k++)
@@ -366,7 +366,7 @@
 		$result['faq'][$k]['faqcreatedtime'] = $adb->query_result($faq_result,$k,'createdtime');
 		$result['faq'][$k]['faqmodifiedtime'] = $adb->query_result($faq_result,$k,'modifiedtime');
 
-		$faq_comment_query = "select * from faqcomments where faqid=".$faqid." order by createdtime DESC";
+		$faq_comment_query = "select * from vtiger_faqcomments where vtiger_faqid=".$faqid." order by createdtime DESC";
 		$faq_comment_result = $adb->query($faq_comment_query);
 		$faq_comment_noofrows = $adb->num_rows($faq_comment_result);
 		for($l=0;$l<$faq_comment_noofrows;$l++)
@@ -389,7 +389,7 @@
 {
 	global $adb;
 	$createdtime = date('Y-m-d H:i:s');
-	$faq_query = "insert into faqcomments values('',".$faqid.",'".$comment."','".$createdtime."')";
+	$faq_query = "insert into vtiger_faqcomments values('',".$faqid.",'".$comment."','".$createdtime."')";
 	$adb->query($faq_query);
 	$result = get_KBase_details('');
 	return $result;
@@ -450,11 +450,11 @@
 	$ticket->column_fields[parent_id]=$parent_id;
 	$ticket->column_fields[product_id]=$product_id;
 
-	//Added to get the user based on module from moduleowners -- 10-11-2005
+	//Added to get the user based on module from vtiger_moduleowners -- 10-11-2005
 	$user_id = 1;//Default admin user id
 	if($module != '')
 	{
-		$res = $adb->query("select moduleowners.*, tab.name from moduleowners inner join tab on moduleowners.tabid = tab.tabid where name='".$module."'");
+		$res = $adb->query("select vtiger_moduleowners.*, vtiger_tab.name from vtiger_moduleowners inner join vtiger_tab on vtiger_moduleowners.tabid = vtiger_tab.tabid where name='".$module."'");
 		if($adb->num_rows($res) > 0)
 		{
 			$user_id = $adb->query_result($res,0,"user_id");
@@ -468,18 +468,18 @@
 	$subject = '[From Portal][ Ticket ID : '.$ticket->id.' ] '.$title;
 	$contents = ' Ticket ID : '.$ticket->id.'<br> Ticket Title : '.$title.'<br><br>'.$description;
 
-	//get the contact email id who creates the ticket from portal and use this email as from email id in email
-	$result = $adb->query("select email from contactdetails where contactid=".$parent_id);
+	//get the contact email id who creates the ticket from vtiger_portal and use this email as from email id in email
+	$result = $adb->query("select email from vtiger_contactdetails where contactid=".$parent_id);
 	$contact_email = $adb->query_result($result,0,'email');
 	$from_email = $contact_email;
 
 	//send mail to assigned to user
 	$to_email = getUserEmailId('id',$user_id);
-	$adb->println("Send mail to the user who is the owner of the module about the portal ticket");
+	$adb->println("Send mail to the user who is the owner of the module about the vtiger_portal ticket");
 	$mail_status = send_mail('HelpDesk',$to_email,'',$from_email,$subject,$contents);
 
-	//send mail to the customer(contact who creates the ticket from portal)
-	$adb->println("Send mail to the customer(contact) who creates the portal ticket");
+	//send mail to the customer(contact who creates the ticket from vtiger_portal)
+	$adb->println("Send mail to the customer(contact) who creates the vtiger_portal ticket");
 	$mail_status = send_mail('Contacts',$contact_email,'',$from_email,$subject,$contents);
 
 	$tickets_list =  get_tickets_list($user_name,$parent_id); 
@@ -508,17 +508,17 @@
 {
 	global $adb;
 	$servercreatedtime = date("Y-m-d H:i:s");
-	$sql = "insert into ticketcomments values('',".$ticketid.",'".$comments."','".$ownerid."','customer','".$servercreatedtime."')";
+	$sql = "insert into vtiger_ticketcomments values('',".$ticketid.",'".$comments."','".$ownerid."','customer','".$servercreatedtime."')";
 	$adb->query($sql);
 
-	$updatequery = "update crmentity set modifiedtime = '".$servercreatedtime."' where crmid=".$ticketid;
+	$updatequery = "update vtiger_crmentity set modifiedtime = '".$servercreatedtime."' where crmid=".$ticketid;
 	$adb->query($updatequery);
 }
 
 function close_current_ticket($ticketid)
 {
 	global $adb;
-	$sql = "update troubletickets set status='Closed' where ticketid=".$ticketid;
+	$sql = "update vtiger_troubletickets set status='Closed' where ticketid=".$ticketid;
 	$result = $adb->query($sql);
 	if($result)
 		return "<br><b>Ticket status is updated as 'Closed'.</b>";
@@ -529,7 +529,7 @@
 {
 	global $adb;
 	$current_date = date("Y-m-d");
-	$sql = "select id, user_name, user_password,last_login_time, support_start_date, support_end_date from portalinfo inner join customerdetails on portalinfo.id=customerdetails.customerid inner join crmentity on crmentity.crmid=portalinfo.id where crmentity.deleted=0 and user_name='".$username."' and user_password = '".$password."' and isactive=1 and customerdetails.support_end_date >= '".$current_date."'";
+	$sql = "select id, user_name, user_password,last_login_time, support_start_date, support_end_date from vtiger_portalinfo inner join vtiger_customerdetails on vtiger_portalinfo.id=vtiger_customerdetails.customerid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_portalinfo.id where vtiger_crmentity.deleted=0 and user_name='".$username."' and user_password = '".$password."' and isactive=1 and vtiger_customerdetails.support_end_date >= '".$current_date."'";
 	$result = $adb->query($sql);	
 	$list['id'] = $adb->query_result($result,0,'id');
 	$list['user_name'] = $adb->query_result($result,0,'user_name');
@@ -544,7 +544,7 @@
 function change_password($id,$username,$password)
 {
 	global $adb;
-	$sql = "update portalinfo set user_password='".$password."' where id=".$id." and user_name='".$username."'";
+	$sql = "update vtiger_portalinfo set user_password='".$password."' where id=".$id." and user_name='".$username."'";
 	$result = $adb->query($sql);
 
 	$list = authenticate_user($username,$password);
@@ -558,17 +558,17 @@
 
 	if($flag == 'login')
 	{
-	        $sql = "update portalinfo set login_time='".$current_time."' where id=".$id;
+	        $sql = "update vtiger_portalinfo set login_time='".$current_time."' where id=".$id;
 	        $result = $adb->query($sql);
 	}
 	elseif($flag == 'logout')
 	{
-		$sql = "select * from portalinfo where id=".$id;
+		$sql = "select * from vtiger_portalinfo where id=".$id;
                 $result = $adb->query($sql);
                 if($adb->num_rows($result) != 0)
                         $last_login = $adb->query_result($result,0,'login_time');
 
-		$sql = "update portalinfo set logout_time = '".$current_time."', last_login_time='".$last_login."' where id=".$id;
+		$sql = "update vtiger_portalinfo set logout_time = '".$current_time."', last_login_time='".$last_login."' where id=".$id;
 		$result = $adb->query($sql);
 	}
 
@@ -578,12 +578,12 @@
 {
 	global $adb;
 
-	$sql = "select * from portalinfo  where user_name='".$mailid."'";
+	$sql = "select * from vtiger_portalinfo  where user_name='".$mailid."'";
 	$user_name = $adb->query_result($adb->query($sql),0,'user_name');
 	$password = $adb->query_result($adb->query($sql),0,'user_password');
 	$isactive = $adb->query_result($adb->query($sql),0,'isactive');
 
-	$fromquery = "select users.user_name, users.email1 from users inner join crmentity on users.id = crmentity.smownerid inner join contactdetails on contactdetails.contactid=crmentity.crmid where contactdetails.email ='".$mailid."'";
+	$fromquery = "select vtiger_users.user_name, vtiger_users.email1 from vtiger_users inner join vtiger_crmentity on vtiger_users.id = vtiger_crmentity.smownerid inner join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_crmentity.crmid where vtiger_contactdetails.email ='".$mailid."'";
 	$initialfrom = $adb->query_result($adb->query($fromquery),0,'user_name');
 	$from = $adb->query_result($adb->query($fromquery),0,'email1');
 
@@ -597,7 +597,7 @@
         $mail->Body    = $contents;
         $mail->IsSMTP();
 
-        $mailserverresult = $adb->query("select * from systems where server_type='email'");
+        $mailserverresult = $adb->query("select * from vtiger_systems where server_type='email'");
         $mail_server = $adb->query_result($mailserverresult,0,'server');
         $mail_server_username = $adb->query_result($mailserverresult,0,'server_username');
         $mail_server_password = $adb->query_result($mailserverresult,0,'server_password');
@@ -634,7 +634,7 @@
 		return "false@@@<b>Mail could not be sent</b>";
 	}
 	else
-		return "true@@@<b>Mail has been sent to your mail id with the customer portal login details</b>";
+		return "true@@@<b>Mail has been sent to your mail id with the customer vtiger_portal login details</b>";
 
 }
 
@@ -642,7 +642,7 @@
 {
 	global $adb;
 
-	$res = $adb->query("select smcreatorid from crmentity where crmid=".$ticketid);
+	$res = $adb->query("select smcreatorid from vtiger_crmentity where crmid=".$ticketid);
 	$creator = $adb->query_result($res,0,'smcreatorid');
 
 	return $creator;
@@ -663,13 +663,13 @@
 	return $picklist_array;
 }
 
-//Added function to get the attachments of the ticket
+//Added function to get the vtiger_attachments of the ticket
 function get_ticket_attachments($userid,$ticketid)
 {
 
 	global $adb;
 
-	$query = "select troubletickets.ticketid, attachments.* from troubletickets inner join seattachmentsrel on seattachmentsrel.crmid = troubletickets.ticketid inner join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid where troubletickets.ticketid=".$ticketid;
+	$query = "select vtiger_troubletickets.ticketid, vtiger_attachments.* from vtiger_troubletickets inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid = vtiger_troubletickets.ticketid inner join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid where vtiger_troubletickets.ticketid=".$ticketid;
 	$res = $adb->query($query);
 	$noofrows = $adb->num_rows($res);
 
@@ -678,7 +678,7 @@
 		$filename = $adb->query_result($res,$i,'name');
 		$filepath = $adb->query_result($res,$i,'path');
 
-		$filesize = filesize($filepath.$filename);
+		$filesize = vtiger_filesize($filepath.$filename);
 		$fileid = $adb->query_result($res,$i,'attachmentsid');
 		$filetype = $adb->query_result($res,$i,'type');
 
@@ -717,13 +717,13 @@
 	$date_var = date('YmdHis');
 	$description = 'CustomerPortal Attachment';
 
-	$crmquery = "insert into crmentity (crmid,setype,description,createdtime) values('".$attachmentid."','HelpDesk Attachment','".$description."','".$date_var."')";
+	$crmquery = "insert into vtiger_crmentity (crmid,setype,description,createdtime) values('".$attachmentid."','HelpDesk Attachment','".$description."','".$date_var."')";
 	$crmresult = $adb->query($crmquery);
 
-	$attachmentquery = "insert into attachments values(".$attachmentid.",'".$new_filename."','".$description."','".$filetype."','".$upload_filepath."')";
+	$attachmentquery = "insert into vtiger_attachments values(".$attachmentid.",'".$new_filename."','".$description."','".$filetype."','".$upload_filepath."')";
 	$attachmentreulst = $adb->query($attachmentquery);
 
-	$relatedquery = $sql1 = "insert into seattachmentsrel values('".$ticketid."','".$attachmentid."')";
+	$relatedquery = $sql1 = "insert into vtiger_seattachmentsrel values('".$ticketid."','".$attachmentid."')";
 	$relatedresult = $adb->query($relatedquery);
 
 }

Modified: vtigercrm/trunk/soap/vtigerolservice.php
==============================================================================
--- vtigercrm/trunk/soap/vtigerolservice.php (original)
+++ vtigercrm/trunk/soap/vtigerolservice.php Mon Jun 12 14:26:25 2006
@@ -314,13 +314,13 @@
           	$email->set_emails_contact_invitee_relationship($email->id,$contactid);
           	$email->set_emails_se_invitee_relationship($email->id,$contactid);
           	$email->set_emails_user_invitee_relationship($email->id,$user_id);
-		$sql = "select email from contactdetails inner join crmentity on crmentity.crmid = contactdetails.contactid where crmentity.deleted =0 and contactdetails.contactid='".$contactid."'";
+		$sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid='".$contactid."'";
 		$result = $adb->query($sql);
 		$camodulerow = $adb->fetch_array($result);
 		if(isset($camodulerow))
 		{
 			$emailid = $camodulerow["email"];
-			$query = 'insert into emaildetails values ('.$email->id.',"","'.$emailid.'","","","","'.$cotactid."@77|".'","OUTLOOK")';
+			$query = 'insert into vtiger_emaildetails values ('.$email->id.',"","'.$emailid.'","","","","'.$cotactid."@77|".'","OUTLOOK")';
 			$adb->query($query);
 		}
 		return $email->id;
@@ -380,7 +380,7 @@
      fwrite($handle,base64_decode($filedata),$filesize);
      fclose($handle);
 
-     $sql1 = "insert into crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) 
+     $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) 
      values(".$crmid.",".$user_id.",".$user_id.",'Emails Attachment',' ',".$adb->formatString("crmentity","createdtime",$date_var).",".$adb->formatString("crmentity","modifiedtime",$date_var).")";
      
      $entityresult = $adb->query($sql1);	
@@ -388,12 +388,12 @@
      
      if($entityresult != false)
      {
-    	$sql2="insert into attachments(attachmentsid, name, description, type, path) 
+    	$sql2="insert into vtiger_attachments(attachmentsid, name, description, type, path) 
                values(".$crmid.",'".$filename."',' ','".$filetype."','".$upload_file_path."')";
     	    
         $result=$adb->query($sql2);
      
-        $sql3='insert into seattachmentsrel values('.$emailid.','.$crmid.')';
+        $sql3='insert into vtiger_seattachmentsrel values('.$emailid.','.$crmid.')';
         $adb->query($sql3);
      
         return $crmid;   
@@ -631,7 +631,7 @@
         return null;
     }
 
-    $query = "select account.accountname accountname,account.accountid accountid from account inner join crmentity on crmentity.crmid=account.accountid where crmentity.deleted=0 and account.accountname='" .$account_name."'";
+    $query = "select vtiger_account.accountname vtiger_accountname,vtiger_account.accountid vtiger_accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_account.accountname='" .$account_name."'";
 
 
 	  $db = new PearDatabase();

Modified: vtigercrm/trunk/soap/webforms.php
==============================================================================
--- vtigercrm/trunk/soap/webforms.php (original)
+++ vtigercrm/trunk/soap/webforms.php Mon Jun 12 14:26:25 2006
@@ -61,7 +61,7 @@
 	if($assigned_user_id == '')
 	{
 		//if the user id is empty then assign it to the admin user
-		$assigned_user_id = $adb->query_result($adb->query("select id from users where user_name='admin'"),0,'id');
+		$assigned_user_id = $adb->query_result($adb->query("select id from vtiger_users where user_name='admin'"),0,'id');
 	}
 
 	require_once("modules/Leads/Lead.php");
@@ -95,7 +95,7 @@
 	if($assigned_user_id == '')
 	{
 		//if the user id is empty then assign it to the admin user
-		$assigned_user_id = $adb->query_result($adb->query("select id from users where user_name='admin'"),0,'id');
+		$assigned_user_id = $adb->query_result($adb->query("select id from vtiger_users where user_name='admin'"),0,'id');
 	}
 
 	require_once('modules/Contacts/Contact.php');





More information about the vtigercrm-commits mailing list