[Vtigercrm-commits] [vtiger-commits] r5306 - in /vtigercrm/branches/4.2: ./ adodb/ adodb/drivers/ data/ include/ include/database/ install/ modules/Accounts/ modules/Activities/ modules/Calendar/ modules/Contacts/ modules/CustomView/ modules/Emails/ modules/Faq/ modules/HelpDesk/ modules/Home/ modules/Import/ modules/Invoice/ modules/Leads/ modules/Meetings/ modules/Notes/ modules/Orders/ modules/Potentials/ modules/Products/ modules/Quotes/ modules/Reports/ modules/Settings/ modules/Users/ modules/uploads/ schema/

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon Apr 24 18:30:22 EDT 2006


Author: jeffk
Date: Mon Apr 24 16:29:46 2006
New Revision: 5306

Log:
refs #62 and #17. merging source:vtigercrm/branches/4.2_postgresql_integration back to source:vtigercrm/branches/4.2. This closes the 
postgresql_integration branch. Some work will remain to properly support both mysql and postgresql (e.g. in 
source:vtigercrm/branches/4.2/config.inc.php)

What follows is a journal of how this merge was performed:

My present working copy is:

$ svn info
Path: .
URL: http://jeffk@vtiger.fosslabs.com/svn/vtiger/vtigercrm/branches/4.2_postgresql_integration
Repository Root: http://jeffk@vtiger.fosslabs.com/svn/vtiger
Repository UUID: 83ef7b00-670c-0410-b3e3-e45103aa6900
Revision: 5305
Node Kind: directory
Schedule: normal
Last Changed Author: jeffk
Last Changed Rev: 5114
Last Changed Date: 2006-04-13 19:47:22 -0400 (Thu, 13 Apr 2006)


Check that there are no changes in my working copy to commit:

$ svn diff

(there are none)


Check for late changes to the original (target) branch that I should merge first:

$ svn diff -r 5113:HEAD http://jeffk@vtiger.fosslabs.com/svn/vtiger/vtigercrm/branches/4.2

(there are none)


Switch my working copy to the original (target) branch. This is a good preview of files affected by the coming merge of the two 
branches.

$ svn switch http://jeffk@vtiger.fosslabs.com/svn/vtiger/vtigercrm/branches/4.2
U    config.inc.php
U    sendreminder.php
U    modules/Accounts/ListViewTop.php
U    modules/Accounts/Account.php
U    modules/Accounts/Popup_picker.php
U    modules/Accounts/Popup.php
U    modules/Accounts/ListView.php
U    modules/Accounts/AccountFormBase.php
U    modules/Quotes/Quote.php
U    modules/Quotes/Delete.php
U    modules/Quotes/Popup.php
U    modules/Quotes/ListView.php
U    modules/Potentials/Popup.php
U    modules/Potentials/ListView.php
U    modules/Potentials/Opportunity.php
U    modules/Leads/Popup.php
U    modules/Leads/Lead.php
U    modules/Leads/ListView.php
U    modules/Leads/LeadConvertToEntities.php
U    modules/Home/UnifiedSearch.php
U    modules/Notes/Delete.php
U    modules/Notes/ListView.php
U    modules/Invoice/Invoice.php
U    modules/Invoice/ListView.php
U    modules/Orders/SalesOrderListView.php
U    modules/Orders/SalesOrder.php
U    modules/Orders/Order.php
U    modules/Orders/DeleteSalesOrder.php
U    modules/Orders/PopupSalesOrder.php
U    modules/Orders/ListView.php
U    modules/Reports/ReportRun.php
U    modules/Reports/SaveReportFolder.php
U    modules/Reports/Save.php
U    modules/Reports/Reports.php
U    modules/Reports/PopulateReports.php
U    modules/HelpDesk/HelpDesk.php
U    modules/HelpDesk/FaqList.php
U    modules/HelpDesk/ListView.php
U    modules/Settings/SaveConvertLead.php
U    modules/Settings/DeleteCustomField.php
U    modules/Settings/UpdateComboValues.php
U    modules/Users/User.php
U    modules/Users/SaveProfile.php
U    modules/Users/SaveOrgSharing.php
U    modules/Users/massdelete.php
U    modules/Users/LoginHistory.php
U    modules/Users/saveemailtemplate.php
U    modules/Users/ListView.php
U    modules/Users/Security.php
U    modules/Users/updateLeadDBStatus.php
U    modules/Users/UserInfoUtil.php
U    modules/Users/SaveRole.php
U    modules/Products/Popup.php
U    modules/Products/AddProductsToPriceBook.php
U    modules/Products/VendorPopup.php
U    modules/Products/ListView.php
U    modules/Products/Delete.php
U    modules/Products/PriceBookListView.php
U    modules/Products/Product.php
U    modules/Products/VendorListView.php
U    modules/Activities/Activity.php
U    modules/Activities/ListView.php
U    modules/Activities/RenderRelatedListUI.php
U    modules/Activities/OpenListView.php
U    modules/CustomView/Save.php
U    modules/CustomView/CustomView.php
U    modules/Faq/ListView.php
U    modules/uploads/add2db.php
U    modules/Calendar/appointment.pinc
U    modules/Import/UsersLastImport.php
U    modules/Emails/Email.php
U    modules/Emails/ListView.php
U    modules/Meetings/ListView.php
U    modules/Contacts/Contact.php
U    modules/Contacts/Popup.php
U    modules/Contacts/SaveBusinessCard.php
U    modules/Contacts/ListView.php
U    data/CRMEntity.php
U    data/SugarBean.php
U    include/RelatedListView.php
U    include/database/PearDatabase.php
U    include/PopulateComboValues.php
U    include/utils.php
U    soap.php
U    contactserialize.php
U    schema/DatabaseSchema.xml
U    install/5createTables.inc.php
U    install/4createConfigFile.php
U    install/1checkSystem.php
U    install/2setConfig.php
U    install/populateSeedData.php
U    install/3confirmConfig.php
U    adodb/adodb.inc.php
U    adodb/adodb-lib.inc.php
U    adodb/drivers/adodb-mysql.inc.php
Updated to revision 5305.


Confirm my working copy info:

$ svn info
Path: .
URL: http://jeffk@vtiger.fosslabs.com/svn/vtiger/vtigercrm/branches/4.2
Repository Root: http://jeffk@vtiger.fosslabs.com/svn/vtiger
Repository UUID: 83ef7b00-670c-0410-b3e3-e45103aa6900
Revision: 5305
Node Kind: directory
Schedule: normal
Last Changed Author: allanbush
Last Changed Rev: 5113
Last Changed Date: 2006-04-13 17:25:30 -0400 (Thu, 13 Apr 2006)


Perform the actual merge. The form is 'svn merge URL1 URL2'. This updates your working copy with the diff between URL1 and URL2. You 
confirm the correctness of the merge, write an appropriate message referencing trac tickets, and commit.

Since we've been keeping the diff minimized with regular update merges, this merge should a) apply cleanly, and b) represent only the 
required changes to add postgresql support to vtigercrm-4.2.4. This changeset will be a very useful reference for the equivalent 
effort on the vtigercrm/trunk 

$ svn merge http://jeffk@vtiger.fosslabs.com/svn/vtiger/vtigercrm/branches/4.2 
http://jeffk@vtiger.fosslabs.com/svn/vtiger/vtigercrm/branches/4.2_postgresql_integration
U    config.inc.php
U    sendreminder.php
U    modules/Accounts/ListViewTop.php
U    modules/Accounts/Account.php
U    modules/Accounts/Popup_picker.php
U    modules/Accounts/Popup.php
U    modules/Accounts/ListView.php
U    modules/Accounts/AccountFormBase.php
U    modules/Quotes/Quote.php
U    modules/Quotes/Delete.php
U    modules/Quotes/Popup.php
U    modules/Quotes/ListView.php
U    modules/Potentials/Popup.php
U    modules/Potentials/ListView.php
U    modules/Potentials/Opportunity.php
U    modules/Leads/Popup.php
U    modules/Leads/Lead.php
U    modules/Leads/ListView.php
U    modules/Leads/LeadConvertToEntities.php
U    modules/Home/UnifiedSearch.php
U    modules/Notes/Delete.php
U    modules/Notes/ListView.php
U    modules/Invoice/Invoice.php
U    modules/Invoice/ListView.php
U    modules/Orders/SalesOrderListView.php
U    modules/Orders/SalesOrder.php
U    modules/Orders/Order.php
U    modules/Orders/DeleteSalesOrder.php
U    modules/Orders/PopupSalesOrder.php
U    modules/Orders/ListView.php
U    modules/Reports/ReportRun.php
U    modules/Reports/SaveReportFolder.php
U    modules/Reports/Save.php
U    modules/Reports/Reports.php
U    modules/Reports/PopulateReports.php
U    modules/HelpDesk/HelpDesk.php
U    modules/HelpDesk/FaqList.php
U    modules/HelpDesk/ListView.php
U    modules/Settings/SaveConvertLead.php
U    modules/Settings/DeleteCustomField.php
U    modules/Settings/UpdateComboValues.php
U    modules/Users/User.php
U    modules/Users/SaveProfile.php
U    modules/Users/SaveOrgSharing.php
U    modules/Users/massdelete.php
U    modules/Users/LoginHistory.php
U    modules/Users/saveemailtemplate.php
U    modules/Users/ListView.php
U    modules/Users/Security.php
U    modules/Users/updateLeadDBStatus.php
U    modules/Users/UserInfoUtil.php
U    modules/Users/SaveRole.php
U    modules/Products/Popup.php
U    modules/Products/AddProductsToPriceBook.php
U    modules/Products/VendorPopup.php
U    modules/Products/ListView.php
U    modules/Products/Delete.php
U    modules/Products/PriceBookListView.php
U    modules/Products/Product.php
U    modules/Products/VendorListView.php
U    modules/Activities/Activity.php
U    modules/Activities/ListView.php
U    modules/Activities/RenderRelatedListUI.php
U    modules/Activities/OpenListView.php
U    modules/CustomView/Save.php
U    modules/CustomView/CustomView.php
U    modules/Faq/ListView.php
U    modules/uploads/add2db.php
U    modules/Calendar/appointment.pinc
U    modules/Import/UsersLastImport.php
U    modules/Emails/Email.php
U    modules/Emails/ListView.php
U    modules/Meetings/ListView.php
U    modules/Contacts/Contact.php
U    modules/Contacts/Popup.php
U    modules/Contacts/SaveBusinessCard.php
U    modules/Contacts/ListView.php
U    data/CRMEntity.php
U    data/SugarBean.php
U    include/RelatedListView.php
U    include/database/PearDatabase.php
U    include/PopulateComboValues.php
U    include/utils.php
U    soap.php
U    contactserialize.php
U    schema/DatabaseSchema.xml
U    install/5createTables.inc.php
U    install/4createConfigFile.php
U    install/1checkSystem.php
U    install/2setConfig.php
U    install/populateSeedData.php
U    install/3confirmConfig.php
U    adodb/adodb.inc.php
U    adodb/adodb-lib.inc.php
U    adodb/drivers/adodb-mysql.inc.php


All files modified by the merge have indicator 'U', meaning clean update. If there had been any 'C' conflicts, you'd need to repair 
them manually.

Please note that this is only a blind merge of the two branches. In addition to testing, there *will* need to be work done on the 4.2 
branch to support both mysql and postgresql for the end user. This integration should be done as quickly as possible, and a 
vtigercrm/tags/vtigercrm-4.2.5 release created.


Modified:
    vtigercrm/branches/4.2/adodb/adodb-lib.inc.php
    vtigercrm/branches/4.2/adodb/adodb.inc.php
    vtigercrm/branches/4.2/adodb/drivers/adodb-mysql.inc.php
    vtigercrm/branches/4.2/config.inc.php
    vtigercrm/branches/4.2/contactserialize.php
    vtigercrm/branches/4.2/data/CRMEntity.php
    vtigercrm/branches/4.2/data/SugarBean.php
    vtigercrm/branches/4.2/include/PopulateComboValues.php
    vtigercrm/branches/4.2/include/RelatedListView.php
    vtigercrm/branches/4.2/include/database/PearDatabase.php
    vtigercrm/branches/4.2/include/utils.php
    vtigercrm/branches/4.2/install/1checkSystem.php
    vtigercrm/branches/4.2/install/2setConfig.php
    vtigercrm/branches/4.2/install/3confirmConfig.php
    vtigercrm/branches/4.2/install/4createConfigFile.php
    vtigercrm/branches/4.2/install/5createTables.inc.php
    vtigercrm/branches/4.2/install/populateSeedData.php
    vtigercrm/branches/4.2/modules/Accounts/Account.php
    vtigercrm/branches/4.2/modules/Accounts/AccountFormBase.php
    vtigercrm/branches/4.2/modules/Accounts/ListView.php
    vtigercrm/branches/4.2/modules/Accounts/ListViewTop.php
    vtigercrm/branches/4.2/modules/Accounts/Popup.php
    vtigercrm/branches/4.2/modules/Accounts/Popup_picker.php
    vtigercrm/branches/4.2/modules/Activities/Activity.php
    vtigercrm/branches/4.2/modules/Activities/ListView.php
    vtigercrm/branches/4.2/modules/Activities/OpenListView.php
    vtigercrm/branches/4.2/modules/Activities/RenderRelatedListUI.php
    vtigercrm/branches/4.2/modules/Calendar/appointment.pinc
    vtigercrm/branches/4.2/modules/Contacts/Contact.php
    vtigercrm/branches/4.2/modules/Contacts/ListView.php
    vtigercrm/branches/4.2/modules/Contacts/Popup.php
    vtigercrm/branches/4.2/modules/Contacts/SaveBusinessCard.php
    vtigercrm/branches/4.2/modules/CustomView/CustomView.php
    vtigercrm/branches/4.2/modules/CustomView/Save.php
    vtigercrm/branches/4.2/modules/Emails/Email.php
    vtigercrm/branches/4.2/modules/Emails/ListView.php
    vtigercrm/branches/4.2/modules/Faq/ListView.php
    vtigercrm/branches/4.2/modules/HelpDesk/FaqList.php
    vtigercrm/branches/4.2/modules/HelpDesk/HelpDesk.php
    vtigercrm/branches/4.2/modules/HelpDesk/ListView.php
    vtigercrm/branches/4.2/modules/Home/UnifiedSearch.php
    vtigercrm/branches/4.2/modules/Import/UsersLastImport.php
    vtigercrm/branches/4.2/modules/Invoice/Invoice.php
    vtigercrm/branches/4.2/modules/Invoice/ListView.php
    vtigercrm/branches/4.2/modules/Leads/Lead.php
    vtigercrm/branches/4.2/modules/Leads/LeadConvertToEntities.php
    vtigercrm/branches/4.2/modules/Leads/ListView.php
    vtigercrm/branches/4.2/modules/Leads/Popup.php
    vtigercrm/branches/4.2/modules/Meetings/ListView.php
    vtigercrm/branches/4.2/modules/Notes/Delete.php
    vtigercrm/branches/4.2/modules/Notes/ListView.php
    vtigercrm/branches/4.2/modules/Orders/DeleteSalesOrder.php
    vtigercrm/branches/4.2/modules/Orders/ListView.php
    vtigercrm/branches/4.2/modules/Orders/Order.php
    vtigercrm/branches/4.2/modules/Orders/PopupSalesOrder.php
    vtigercrm/branches/4.2/modules/Orders/SalesOrder.php
    vtigercrm/branches/4.2/modules/Orders/SalesOrderListView.php
    vtigercrm/branches/4.2/modules/Potentials/ListView.php
    vtigercrm/branches/4.2/modules/Potentials/Opportunity.php
    vtigercrm/branches/4.2/modules/Potentials/Popup.php
    vtigercrm/branches/4.2/modules/Products/AddProductsToPriceBook.php
    vtigercrm/branches/4.2/modules/Products/Delete.php
    vtigercrm/branches/4.2/modules/Products/ListView.php
    vtigercrm/branches/4.2/modules/Products/Popup.php
    vtigercrm/branches/4.2/modules/Products/PriceBookListView.php
    vtigercrm/branches/4.2/modules/Products/Product.php
    vtigercrm/branches/4.2/modules/Products/VendorListView.php
    vtigercrm/branches/4.2/modules/Products/VendorPopup.php
    vtigercrm/branches/4.2/modules/Quotes/Delete.php
    vtigercrm/branches/4.2/modules/Quotes/ListView.php
    vtigercrm/branches/4.2/modules/Quotes/Popup.php
    vtigercrm/branches/4.2/modules/Quotes/Quote.php
    vtigercrm/branches/4.2/modules/Reports/PopulateReports.php
    vtigercrm/branches/4.2/modules/Reports/ReportRun.php
    vtigercrm/branches/4.2/modules/Reports/Reports.php
    vtigercrm/branches/4.2/modules/Reports/Save.php
    vtigercrm/branches/4.2/modules/Reports/SaveReportFolder.php
    vtigercrm/branches/4.2/modules/Settings/DeleteCustomField.php
    vtigercrm/branches/4.2/modules/Settings/SaveConvertLead.php
    vtigercrm/branches/4.2/modules/Settings/UpdateComboValues.php
    vtigercrm/branches/4.2/modules/Users/ListView.php
    vtigercrm/branches/4.2/modules/Users/LoginHistory.php
    vtigercrm/branches/4.2/modules/Users/SaveOrgSharing.php
    vtigercrm/branches/4.2/modules/Users/SaveProfile.php
    vtigercrm/branches/4.2/modules/Users/SaveRole.php
    vtigercrm/branches/4.2/modules/Users/Security.php
    vtigercrm/branches/4.2/modules/Users/User.php
    vtigercrm/branches/4.2/modules/Users/UserInfoUtil.php
    vtigercrm/branches/4.2/modules/Users/massdelete.php
    vtigercrm/branches/4.2/modules/Users/saveemailtemplate.php
    vtigercrm/branches/4.2/modules/Users/updateLeadDBStatus.php
    vtigercrm/branches/4.2/modules/uploads/add2db.php
    vtigercrm/branches/4.2/schema/DatabaseSchema.xml
    vtigercrm/branches/4.2/sendreminder.php
    vtigercrm/branches/4.2/soap.php

Modified: vtigercrm/branches/4.2/adodb/adodb-lib.inc.php
==============================================================================
--- vtigercrm/branches/4.2/adodb/adodb-lib.inc.php (original)
+++ vtigercrm/branches/4.2/adodb/adodb-lib.inc.php Mon Apr 24 16:29:46 2006
@@ -933,18 +933,19 @@
 	
 	$dbt = $zthis->databaseType;
 	if (isset($zthis->dsnType)) $dbt .= '-'.$zthis->dsnType;
-	if ($inBrowser) {
-		if ($ss) {
-			$ss = '<code>'.htmlspecialchars($ss).'</code>';
-		}
-		if ($zthis->debug === -1)
-			ADOConnection::outp( "<br />\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<br />\n",false);
-		else 
-			ADOConnection::outp( "<hr />\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<hr />\n",false);
-	} else {
-		ADOConnection::outp("-----\n($dbt): ".$sqlTxt."\n-----\n",false);
-	}
-
+/*
+		if ($inBrowser) {
+			if ($ss) {
+				$ss = '<code>'.htmlspecialchars($ss).'</code>';
+			}
+			if ($zthis->debug === -1)
+				ADOConnection::outp( "<br />\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<br />\n",false);
+			else 
+				ADOConnection::outp( "<hr />\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<hr />\n",false);
+		} else {
+			ADOConnection::outp("-----\n($dbt): ".$sqlTxt."\n-----\n",false);
+		}
+// */
 	$qID = $zthis->_query($sql,$inputarr);
 	
 	/* 
@@ -957,6 +958,17 @@
 			if ($err = $zthis->ErrorNo()) ADOConnection::outp($err.': '.$emsg);
 		}
 	} else if (!$qID) {
+		if ($inBrowser) {
+			if ($ss) {
+				$ss = '<code>'.htmlspecialchars($ss).'</code>';
+			}
+			if ($zthis->debug === -1)
+				ADOConnection::outp( "<br />\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<br />\n",false);
+			else 
+				ADOConnection::outp( "<hr />\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; $ss\n<hr />\n",false);
+		} else {
+			ADOConnection::outp("-----\n($dbt): ".$sqlTxt."\n-----\n",false);
+		}
 		ADOConnection::outp($zthis->ErrorNo() .': '. $zthis->ErrorMsg());
 	}
 	
@@ -1018,4 +1030,4 @@
 	return $s;
 }
 
-?>
+?>

Modified: vtigercrm/branches/4.2/adodb/adodb.inc.php
==============================================================================
--- vtigercrm/branches/4.2/adodb/adodb.inc.php (original)
+++ vtigercrm/branches/4.2/adodb/adodb.inc.php Mon Apr 24 16:29:46 2006
@@ -747,7 +747,7 @@
 				$this->_transOK = false;
 				if ($this->debug) ADOConnection::outp("Smart Commit failed");
 			} else
-				if ($this->debug) ADOConnection::outp("Smart Commit occurred");
+				if (false) ADOConnection::outp("Smart Commit occurred");
 		} else {
 			$this->_transOK = false;
 			$this->RollbackTrans();

Modified: vtigercrm/branches/4.2/adodb/drivers/adodb-mysql.inc.php
==============================================================================
--- vtigercrm/branches/4.2/adodb/drivers/adodb-mysql.inc.php (original)
+++ vtigercrm/branches/4.2/adodb/drivers/adodb-mysql.inc.php Mon Apr 24 16:29:46 2006
@@ -171,7 +171,7 @@
 	
 	function BeginTrans()
 	{
-		if ($this->debug) ADOConnection::outp("Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver");
+		//if ($this->debug) ADOConnection::outp("Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver");
 	}
 	
 	function _affectedrows()
@@ -772,4 +772,4 @@
 
 
 }
-?>
+?>

Modified: vtigercrm/branches/4.2/config.inc.php
==============================================================================
--- vtigercrm/branches/4.2/config.inc.php (original)
+++ vtigercrm/branches/4.2/config.inc.php Mon Apr 24 16:29:46 2006
@@ -1,7 +1,7 @@
 <?php
 /*********************************************************************************
  * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
+ * ("License"); You may not use this file except in compliance with the 
  * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
  * Software distributed under the License is distributed on an  "AS IS"  basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
@@ -13,59 +13,169 @@
  * Contributor(s): ______________________________________.
 ********************************************************************************/
 
-require_once("connection.php");
+include('vtigerversion.php');
 
-// make MySQL run in desired port  
-$sock_path=":" .$mysql_port;
-$H_NAME=gethostbyaddr($_SERVER['SERVER_ADDR']);
+// more than 8MB memory needed for graphics
+// memory limit default value = 16M
+ini_set('memory_limit','16M');
+
+// show or hide world clock and calculator
+// world_clock_display default value = true
+// calculator_clock_display default value = true
+$WORLD_CLOCK_DISPLAY = 'true';
+$CALCULATOR_DISPLAY = 'true';
+
+// url for customer portal (Example: http://vtiger.com/portal)
+$PORTAL_URL = 'http://your-domain.com/customerportal';
+
+// helpdesk support email id and support name (Example: 'support at vtiger.com' and 'vtiger support')
+$HELPDESK_SUPPORT_EMAIL_ID = 'support at your-domain.com';
+$HELPDESK_SUPPORT_NAME = 'your-domain name';
 
 /* database configuration
+      db_server
+      db_port
       db_hostname
       db_username
       db_password
       db_name
 */
-// all of these commented values get populated by install.php
-//$dbconfig['db_hostname'] = '$H_NAME.$sock_path';
-//$dbconfig['db_username'] = 'vtigercrm';
-//$dbconfig['db_password'] = '';
-//$dbconfig['db_name'] = 'vtigercrm';
 
-//$host_name = '';
-//$site_URL = '';
-//$root_directory = '';
+$dbconfig['db_server'] = 'localhost:5432';
+$dbconfig['db_port'] = ':3306';
+$dbconfig['db_username'] = 'vtigercrm';
+$dbconfig['db_password'] = 'vtigercrm';
+$dbconfig['db_name'] = 'vtigercrm';
+$dbconfig['db_type'] = 'pgsql';
+$dbconfig['db_status'] = 'true';
 
-// full path to the include directory including the trailing slash
-//$includeDirectory = $root_directory.'include/';
+// TODO: test if port is empty
+// TODO: set db_hostname dependending on db_type
+$dbconfig['db_hostname'] = $dbconfig['db_server'].$dbconfig['db_port'];
 
+// log_sql default value = false
+$dbconfig['log_sql'] = false;
+
+// persistent default value = true
+$dbconfigoption['persistent'] = true;
+
+// autofree default value = false
+$dbconfigoption['autofree'] = false;
+
+// debug default value = 0
+$dbconfigoption['debug'] = 0;
+
+// seqname_format default value = '%s_seq'
+$dbconfigoption['seqname_format'] = '%s_seq';
+
+// portability default value = 0
+$dbconfigoption['portability'] = 0;
+
+// ssl default value = false
+$dbconfigoption['ssl'] = false;
+
+$host_name = $dbconfig['db_hostname'];
+
+$site_URL = 'http://localhost/vtigercrm';
+
+// root directory path
+$root_directory = '/software/vtigercrm42/';
+
+// cache direcory path
+$cache_dir = 'cache/';
+
+// tmp_dir default value prepended by cache_dir = images/
+$tmp_dir = 'cache/images/';
+
+// import_dir default value prepended by cache_dir = import/
+$import_dir = 'cache/import/';
+
+// upload_dir default value prepended by cache_dir = upload/
+$upload_dir = 'cache/upload/';
+
+// mail server parameters
+$mail_server = '';
+$mail_server_username = '';
+$mail_server_password = '';
+
+// maximum file size for uploaded files in bytes also used when uploading import files
+// upload_maxsize default value = 3000000
+$upload_maxsize = 3000000;
+
+// flag to allow export functionality
+// 'all' to allow anyone to use exports 
+// 'admin' to only allow admins to export 
+// 'none' to block exports completely 
+// allow_exports default value = all
+$allow_exports = 'all';
+
+// files with one of these extensions will have '.txt' appended to their filename on upload
+// upload_badext default value = php, php3, php4, php5, pl, cgi, py, asp, cfm, js, vbs, html, htm
+$upload_badext = array('php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', 'asp', 'cfm', 'js', 'vbs', 'html', 'htm');
+
+// full path to include directory including the trailing slash
+// includeDirectory default value = $root_directory..'include/
+$includeDirectory = $root_directory.'include/';
+
+// list_max_entries_per_page default value = 20
 $list_max_entries_per_page = '20';
+
+// history_max_viewed default value = 5
 $history_max_viewed = '5';
 
 // define list of menu tabs
-//$moduleList = Array('Home', 'Dashboard', 'Leads', 'Contacts', 'Accounts', 'Opportunities', 'Cases', 'Notes', 'Calls', 'Emails', 'Meetings', 'Tasks');
+//$moduleList = Array('Home', 'Dashboard', 'Contacts', 'Accounts', 'Opportunities', 'Cases', 'Notes', 'Calls', 'Emails', 'Meetings', 'Tasks','MessageBoard');
 
+// map sugar language codes to jscalendar language codes
+// unimplemented until jscalendar language files are fixed
+// $cal_codes = array('en_us'=>'en', 'ja'=>'jp', 'sp_ve'=>'sp', 'it_it'=>'it', 'tw_zh'=>'zh', 'pt_br'=>'pt', 'se'=>'sv', 'cn_zh'=>'zh', 'ge_ge'=>'de', 'ge_ch'=>'de', 'fr'=>'fr');
+
+// default_module default value = Home
 $default_module = 'Home';
+
+// default_action default value = index
 $default_action = 'index';
 
 // set default theme
+// default_theme default value = blue
 $default_theme = 'blue';
-$databasetype = 'mysql';
 
 // show or hide time to compose each page
+// calculate_response_time default value = true
 $calculate_response_time = true;
 
 // default text that is placed initially in the login form for user name
+// no default_user_name default value
 $default_user_name = '';
 
 // default text that is placed initially in the login form for password
+// no default_password default value
 $default_password = '';
 
 // create user with default username and password
+// create_default_user default value = false
 $create_default_user = false;
+// default_user_is_admin default value = false
+$default_user_is_admin = false;
 
-// login message
-// if a message is provided, it will be placed on the login screen
-// this is for site specific special instructions
-$login_message = 'Please login to the application.';
+// if your MySQL/PHP configuration does not support persistent connections set this to true to avoid a large performance slowdown
+// disable_persistent_connections default value = false
+$disable_persistent_connections = false;
+
+// defined languages available. the key must be the language file prefix. (Example 'en_us' is the prefix for every 'en_us.lang.php' file)
+// languages default value = en_us=>US English
+$languages = Array('en_us'=>'US English',);
+
+// default charset
+// default charset default value = ISO-8859-1
+$default_charset = 'ISO-8859-1';
+
+// default language
+// default_language default value = en_us
+$default_language = 'en_us';
+
+// add the language pack name to every translation string in the display.
+// translation_string_prefix default value = false
+$translation_string_prefix = false;
 
 ?>

Modified: vtigercrm/branches/4.2/contactserialize.php
==============================================================================
--- vtigercrm/branches/4.2/contactserialize.php (original)
+++ vtigercrm/branches/4.2/contactserialize.php Mon Apr 24 16:29:46 2006
@@ -1189,9 +1189,10 @@
 function add_contacts_matching_email_address(&$output_list, $email_address, &$seed_contact)	
 {
   //global $log;
+	global $adb;
 	$safe_email_address = addslashes($email_address);
 	
-	$where = "email1 like '$safe_email_address' OR email2 like '$safe_email_address'";
+	$where = "email1 ".$adb->getLike()." '$safe_email_address' OR email2 ".$adb->getLike()." '$safe_email_address'";
 	$response = $seed_contact->get_list("first_name,last_name,primary_address_city", $where, 0);
 	$contactList = $response['list'];
 	
@@ -1306,8 +1307,9 @@
 function contact_by_search($name) 
 { 
 //	global $log;
+	global $adb;
 	$seed_contact = new Contact();
-	$where = "first_name like '$name%' OR last_name like '$name%' OR email1 like '$name%' OR email2 like '$name%'";
+	$where = "first_name ".$adb->getLike()." '$name%' OR last_name ".$adb->getLike()." '$name%' OR email1 ".$adb->getLike()." '$name%' OR email2 ".$adb->getLike()." '$name%'";
 	$response = $seed_contact->get_list("first_name, last_name", $where, 0);
 	$contactList = $response['list'];
 	//$row_count = $response['row_count'];
@@ -1661,6 +1663,7 @@
 
 function retrievereportsto($reports_to,$user_id,$account_id)
 {
+	global $adb;
   if($reports_to=="")
     {
         return null;
@@ -1695,7 +1698,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 contactdetails.contactid as contactid from contactdetails inner join crmentity on crmentity.crmid=contactdetails.contactid where crmentity.deleted=0 and contactdetails.firstname ".$adb->getLike()." '".$first_name ."' and contactdetails.lastname ".$adb->getLike()." '" .$last_name ."'";
 
 
 
@@ -1972,8 +1975,9 @@
 function retrieve_task($name) 
 { 
 //	global $log;
+	global $adb;
 	$task = new Task();
-	$where = "name like '$name%'";
+	$where = "name ".$adb->getLike()." '$name%'";
 	$response = $task->get_list("name", $where, 0);
 	$taskList = $response['list'];
 	$output_list = Array();
@@ -2218,8 +2222,9 @@
 
 function retrieve_calendar($name) 
 { 
+	global $adb;
 	$task = new Task();
-	$where = "name like '$name%'";
+	$where = "name ".$adb->getLike()." '$name%'";
 	$response = $task->get_list("name", $where, 0);
 	$taskList = $response['list'];
 	$output_list = Array();

Modified: vtigercrm/branches/4.2/data/CRMEntity.php
==============================================================================
--- vtigercrm/branches/4.2/data/CRMEntity.php (original)
+++ vtigercrm/branches/4.2/data/CRMEntity.php Mon Apr 24 16:29:46 2006
@@ -130,11 +130,11 @@
 
   function insertIntoAttachment1($id,$module,$filedata,$filename,$filesize,$filetype,$user_id)
   {
-    $date_var = date('YmdHis');
     // global $current_user;
     global $adb;
     //global $root_directory;
 	global $vtlog;
+    $date_var = $adb->database->DBTimeStamp(date('YmdHis'));
 
     $ownerid = $user_id;
 		
@@ -156,7 +156,7 @@
 	$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 crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(".$current_id.",".$current_user->id.",".$ownerid.",'".$module." Attachment','"."',".$date_var.",".$date_var.")";
     $adb->query($sql1);
 
     //$this->id = $current_id;
@@ -176,12 +176,12 @@
 
   function insertIntoAttachment($id,$module)
   {
-    $date_var = date('YmdHis');
     global $current_user;
     global $adb;
     global $root_directory;
     global $upload_badext;
 
+    $date_var = $adb->database->DBTimeStamp(date('YmdHis'));
     $ownerid = $this->column_fields['assigned_user_id'];
     $adb->println("insertattach ownerid=".$ownerid." mod=".$module);
     $adb->println($this->column_fields);	
@@ -226,7 +226,7 @@
 	$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','".$this->column_fields['description']."',".$adb->formatString("crmentity","createdtime",$date_var).",".$adb->formatString("crmentity","modifiedtime",$date_var).")";
+	$sql1 = "insert into crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(".$current_id.",".$current_user->id.",".$ownerid.",'".$module." Attachment','".$this->column_fields['description']."',".$date_var.",".$date_var.")";
       $adb->query($sql1);
 
       //$this->id = $current_id;
@@ -261,7 +261,7 @@
     global $current_user;
     global $vtlog;	
                 
-    $date_var = date('YmdHis');
+    $date_var = $adb->database->DBTimeStamp(date('YmdHis'));
     if($_REQUEST['assigntype'] == 'T')
     {
       $ownerid= 0;
@@ -284,7 +284,7 @@
     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;
+	$sql = "update crmentity set smownerid=".$ownerid.",modifiedby=".$current_user->id.",description=".$description_val.", modifiedtime=".$date_var." where crmid=".$this->id;
 			
       $adb->query($sql);
     }
@@ -325,7 +325,7 @@
 		else
 		{
       $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.",'".$date_var."','".$date_var."')";
+      $sql = "insert into crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values('".$current_id."','".$current_user->id."','".$ownerid."','".$module."',".$description_val.",".$date_var.",".$date_var.")";
       $adb->query($sql);
       $this->id = $current_id;
                 }
@@ -611,9 +611,10 @@
 			  $sales_stage = $adb->query_result($adb->query($dbquery),0,'sales_stage');
 			  if($sales_stage != $_REQUEST['sales_stage'])
 			  {
-				  $date_var = date('YmdHis');
+    				  $date_var = $adb->database->DBTimeStamp(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 potstagehistory values('',".$this->id.",'".$_REQUEST['amount']."','".$sales_stage."','".$_REQUEST['probability']."',0,".$adb->formatString("potstagehistory","closedate",$_REQUEST['closingdate']).",".$adb->formatString("potstagehistory","lastmodified",$date_var).")";
+				  $id = $adb->getUniqueID('potstagehistory');
+				  $sql = "insert into potstagehistory values($id,".$this->id.",'".$_REQUEST['amount']."','".$sales_stage."','".$_REQUEST['probability']."',0,".$adb->formatString("potstagehistory","closedate",$_REQUEST['closingdate']).",".$date_var.")";
 				  $adb->query($sql);
 			  }
 		  }
@@ -742,8 +743,9 @@
 	else
 		$ownertype = 'customer';
 
-	$comment = addslashes($_REQUEST['comments']);
-	$sql = "insert into ticketcomments values('',".$this->id.",'".$comment."','".$current_user->id."','".$ownertype."','".$current_time."')";
+	$comment = $adb->quote($_REQUEST['comments']);
+	$id = $adb->getUniqueID("ticketcomments_commentid");
+	$sql = "insert into ticketcomments values(".$id.",".$this->id.",".$comment.",'".$current_user->id."','".$ownertype."','".$current_time."')";
         $adb->query($sql);
 }
 function insertIntoFAQCommentTable($table_name, $module)
@@ -754,8 +756,9 @@
 
         $current_time = date('Y-m-d H:i:s');
 
-	$comment = addslashes($_REQUEST['comments']);
-	$sql = "insert into faqcomments values('',".$this->id.",'".$comment."','".$current_time."')";
+	$comment = $adb->quote($_REQUEST['comments']);
+	$id = $adb->getUniqueID("faqcomments_commentid");
+	$sql = "insert into faqcomments values(".$id.",".$this->id.",".$comment.",'".$current_time."')";
 	$adb->query($sql);
 }
 function insertIntoReminderTable($table_name,$module,$recurid)
@@ -817,7 +820,7 @@
 	{
 		$activity_id=$this->id;
 
-		$sql='select min(recurringdate) min_date,max(recurringdate) max_date,recurringtype from recurringevents where activityid='. $activity_id.' group by activityid';
+		$sql='select min(recurringdate) AS min_date, max(recurringdate) AS max_date, recurringtype from recurringevents where activityid='. $activity_id.' group by activityid, recurringtype';
 		
 		$result = $adb->query($sql);
 		$noofrows = $adb->num_rows($result);
@@ -886,7 +889,7 @@
 				$tdate=$date_array[$k];
 				if($tdate <= $end_date)
 				{
-					$max_recurid_qry = 'select max(recurringid) recurid  from recurringevents;';
+					$max_recurid_qry = 'select max(recurringid) AS recurid from recurringevents;';
 					$result = $adb->query($max_recurid_qry);
 					$noofrows = $adb->num_rows($result);
 					for($i=0; $i<$noofrows; $i++)
@@ -894,7 +897,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 recurringevents values (".$adb->quote($current_id).','.$adb->quote($this->id).','.$adb->quote($tdate).','.$adb->quote($type).')';
 					$adb->query($recurring_insert);
 					if($_REQUEST['set_reminder'] == 'Yes')
 					{

Modified: vtigercrm/branches/4.2/data/SugarBean.php
==============================================================================
--- vtigercrm/branches/4.2/data/SugarBean.php (original)
+++ vtigercrm/branches/4.2/data/SugarBean.php Mon Apr 24 16:29:46 2006
@@ -185,6 +185,7 @@
 		if ($id == -1) {
 			$id = $this->id;
 		}
+		if('' == $id) return null;
 // GS porting crmentity
 $query = "SELECT * FROM $this->table_name WHERE $this->module_id = '$id'";
 //		$query = "SELECT * FROM $this->table_name WHERE ID = '$id'";

Modified: vtigercrm/branches/4.2/include/PopulateComboValues.php
==============================================================================
--- vtigercrm/branches/4.2/include/PopulateComboValues.php (original)
+++ vtigercrm/branches/4.2/include/PopulateComboValues.php Mon Apr 24 16:29:46 2006
@@ -28,13 +28,14 @@
           $i=0;
           foreach ($values as $val => $cal)
           {
+		$id = $adb->getUniqueID($tableName);  // horrible assumption on the name of the sequence for this table
             if($val != '')
             {
-              $adb->query("insert into ".$tableName. " values('','".$val."',".$i.",1)");
+              $adb->query("insert into ".$tableName. " values($id,'".$val."',".$i.",1)");
             }
             else
             {
-              $adb->query("insert into ".$tableName. " values('','--None--',".$i.",1)");
+              $adb->query("insert into ".$tableName. " values($id,'--None--',".$i.",1)");
             }
             $i++;
           }

Modified: vtigercrm/branches/4.2/include/RelatedListView.php
==============================================================================
--- vtigercrm/branches/4.2/include/RelatedListView.php (original)
+++ vtigercrm/branches/4.2/include/RelatedListView.php Mon Apr 24 16:29:46 2006
@@ -78,7 +78,8 @@
 }
 
 //Appending the group by for Jaguar/Don
-if($relatedmodule == 'Activities')
+// group by won't work this way in postgres
+if($relatedmodule == 'Activities' && !$adb->isPostgres())
 {
 	$query .= ' group by crmentity.crmid';
 }

Modified: vtigercrm/branches/4.2/include/database/PearDatabase.php
==============================================================================
--- vtigercrm/branches/4.2/include/database/PearDatabase.php (original)
+++ vtigercrm/branches/4.2/include/database/PearDatabase.php Mon Apr 24 16:29:46 2006
@@ -35,8 +35,9 @@
 	var $lastmysqlrow = -1;
 	var $enableSQLlog = false;
 
-	function isMySQL() { return dbType=='mysql'; }
-	function isOracle() { return dbType=='oci8'; }
+	function isMySQL() { return $this->dbType=='mysql'; }
+	function isOracle() { return $this->dbType=='oci8'; }
+	function isPostgres() { return $this->dbType=='pgsql'; }
 	
 	function println($msg)
 	{
@@ -59,8 +60,9 @@
 	
 	function setDatabaseType($type){
 		$this->dbType = $type;
-	}
-	
+		$this->like = $this->isPostgres() ? 'ilike' : 'like';
+	}
+
 	function setUserName($name){
 		$this->userName = $name;
 	}
@@ -86,6 +88,10 @@
 	
 	function getDataSourceName(){
 		return 	$this->dbType. "://".$this->userName.":".$this->userPassword."@". $this->dbHostName . "/". $this->dbName;
+	}
+
+	function getLike(){
+		return $this->like;
 	}
 
 	function startTransaction()
@@ -258,7 +264,14 @@
 	{
 		$this->println("updateBlobFile t=".$tablename." c=".$colname." id=".$id." f=".$filename);
 		$this->checkConnection();
-		$result = $this->database->UpdateBlobFile($tablename, $colname, $filename, $id);
+		if($this->isPostgres()) {
+			$fp = fopen($filename, "r");
+			$filecontent = fread($fp, filesize($filename));
+			$result = $this->database->UpdateBlob($tablename, $colname, $filecontent, $id);
+			fclose($fp);
+		} else {
+			$result = $this->database->UpdateBlobFile($tablename, $colname, $filename, $id);
+		}
 		$this->println("updateBlobFile t=".$tablename." c=".$colname." id=".$id." f=".$filename." status=".$result);
 		return $result;
 	}
@@ -663,9 +676,9 @@
 		}
 		
 		$this->database = ADONewConnection($this->dbType);
-		//$this->database->debug = true;
-		
-		$this->database->PConnect($this->dbHostName, $this->userName, $this->userPassword, $this->dbName);
+		$this->database->debug = true;
+		
+		$this->database->Connect($this->dbHostName, $this->userName, $this->userPassword, $this->dbName);
 		$this->database->LogSQL($this->enableSQLlog);
 		//$this->database->SetFetchMode(ADODB_FETCH_ASSOC); 
 		//$this->println("ADODB type=".$this->dbType." host=".$this->dbHostName." dbname=".$this->dbName." user=".$this->userName." password=".$this->userPassword);		
@@ -924,11 +937,11 @@
 	return $date;
 }
 
-function getDBDateString($datecolname)
+function getDBDateString($datecolname, $format='Y-m-d, H:i:s')
 {
 	$this->checkConnection();
 	$db = &$this->database;
-	$datestr = $db->SQLDate("Y-m-d, H:i:s" ,$datecolname);
+	$datestr = $db->SQLDate($format ,$datecolname);
 	return $datestr;	
 }
 

Modified: vtigercrm/branches/4.2/include/utils.php
==============================================================================
--- vtigercrm/branches/4.2/include/utils.php (original)
+++ vtigercrm/branches/4.2/include/utils.php Mon Apr 24 16:29:46 2006
@@ -397,6 +397,8 @@
   */
 function append_where_clause(&$where_clauses, $variable_name, $SQL_name = null)
 {
+	global $adb;
+
 	if($SQL_name == null)
 	{
 		$SQL_name = $variable_name;
@@ -404,7 +406,7 @@
 
 	if(isset($_REQUEST[$variable_name]) && $_REQUEST[$variable_name] != "")
 	{
-		array_push($where_clauses, "$SQL_name like '$_REQUEST[$variable_name]%'");
+		array_push($where_clauses, "$SQL_name ".$adb->getLike()." '$_REQUEST[$variable_name]%'");
 	}
 }
 
@@ -2412,13 +2414,15 @@
 	global $adb;
 	$column_fld = Array();
         $tabid = getTabid($module);
-	$sql = "select * from field where tabid=".$tabid;
-        $result = $adb->query($sql);
-        $noofrows = $adb->num_rows($result);
-	for($i=0; $i<$noofrows; $i++)
-	{
-		$fieldname = $adb->query_result($result,$i,"fieldname");
-		$column_fld[$fieldname] = ''; 
+	if($tabid) {
+		$sql = "select * from field where tabid=".$tabid;
+		$result = $adb->query($sql);
+		$noofrows = $adb->num_rows($result);
+		for($i=0; $i<$noofrows; $i++)
+		{
+			$fieldname = $adb->query_result($result,$i,"fieldname");
+			$column_fld[$fieldname] = ''; 
+		}
 	}
 	return $column_fld;	
 }
@@ -3146,8 +3150,10 @@
 					elseif($module == 'Quotes' && $name == 'Potential Name')
 					{
 						$potential_id = $adb->query_result($list_result,$i-1,"potentialid");
-						$potential_name = getPotentialName($potential_id);
-						$value = '<a href="index.php?module=Potentials&action=DetailView&record='.$potential_id.'">'.$potential_name.'</a>';
+						if('' != $potential_id) {
+							$potential_name = getPotentialName($potential_id);
+							$value = '<a href="index.php?module=Potentials&action=DetailView&record='.$potential_id.'">'.$potential_name.'</a>';
+						}
 					}
 					elseif($owner_id == 0 && $name == 'Assigned To')
                                         {
@@ -3748,8 +3754,12 @@
 }
 
 
-function getListQuery($module,$where='')
-{
+function getListQuery($module,$where='',$distincton='')
+{
+	if($distincton) {
+		$distincton = "DISTINCT ON ($distincton)";
+	}
+
 	if($module == "HelpDesk")
 	{
 		$query = "select crmentity.crmid,troubletickets.title,troubletickets.status,troubletickets.priority,crmentity.smownerid, contactdetails.contactid, troubletickets.parent_id, 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 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";
@@ -3777,7 +3787,7 @@
 	}
         if($module == "Notes")
         {
-		$query="select crmentity.crmid, notes.title, notes.contact_id, notes.filename, crmentity.modifiedtime,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";
+		$query="select $distincton crmentity.crmid, notes.title, notes.contact_id, notes.filename, crmentity.modifiedtime,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";
         }
         if($module == "Calls")
         {
@@ -3785,7 +3795,22 @@
         }
 	if($module == "Contacts")
         {
-                $query = "select crmentity.crmid, crmentity.smownerid, contactdetails.*, contactaddress.*, contactsubdetails.*, contactscf.*, account.accountname from contactdetails, contactaddress, contactsubdetails, contactscf inner join crmentity on crmentity.crmid=contactdetails.contactid and contactdetails.contactid=contactaddress.contactaddressid and contactdetails.contactid = contactscf.contactid and contactaddress.contactaddressid=contactsubdetails.contactsubscriptionid left join account on account.accountid = contactdetails.accountid where crmentity.deleted=0";
+                $query = "SELECT crmentity.crmid, crmentity.smownerid,
+				contactdetails.*, contactaddress.*,
+				contactsubdetails.*, contactscf.*,
+				account.accountname
+			from contactdetails
+				INNER JOIN contactaddress
+					ON contactdetails.contactid=contactaddress.contactaddressid
+				INNER JOIN contactsubdetails
+					ON contactaddress.contactaddressid=contactsubdetails.contactsubscriptionid
+				INNER JOIN contactscf
+					ON contactdetails.contactid = contactscf.contactid
+				INNER JOIN crmentity
+					ON crmentity.crmid=contactdetails.contactid
+				LEFT JOIN account
+					ON account.accountid = contactdetails.accountid
+			WHERE crmentity.deleted=0";
 		//$query = "select crmentity.crmid, crmentity.smownerid, contactdetails.*, contactaddress.*, contactsubdetails.*, contactscf.*, account.accountname from contactdetails, contactaddress, contactsubdetails, contactscf,crmentity,account where crmentity.crmid=contactdetails.contactid and contactdetails.contactid=contactaddress.contactaddressid and contactdetails.contactid = contactscf.contactid and contactaddress.contactaddressid=contactsubdetails.contactsubscriptionid and account.accountid = contactdetails.accountid and crmentity.deleted=0";
         }
 	if($module == "Meetings")
@@ -3794,7 +3819,7 @@
         }
 	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 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 $distincton 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 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  ;
 		//included by Jaguar
         }
 	if($module == "Emails")
@@ -4209,7 +4234,11 @@
 	}
 		
 	//echo $display_date;
-	$insert_date=$y.'-'.$m.'-'.$d;
+	if(!$y && !$m && !$d) {
+		$insert_date = '';
+	} else {
+		$insert_date=$y.'-'.$m.'-'.$d;
+	}
 	return $insert_date;
 }
 

Modified: vtigercrm/branches/4.2/install/1checkSystem.php
==============================================================================
--- vtigercrm/branches/4.2/install/1checkSystem.php (original)
+++ vtigercrm/branches/4.2/install/1checkSystem.php Mon Apr 24 16:29:46 2006
@@ -174,7 +174,7 @@
 		<tr>
 			<td bgcolor="#EEEEEE"><strong>Database</strong></td>
 
-        	<td align="right"><?php echo function_exists('mysql_connect')?"<strong><font color=\"#0066CC\">Available</font></strong>":"<strong><font color=\"#FF0000\">Not Available</font></strong>";?></td>
+        	<td align="right"><?php echo function_exists('mysql_connect') || function_exists('pg_connect')?"<strong><font color=\"#0066CC\">Available</font></strong>":"<strong><font color=\"#FF0000\">Not Available</font></strong>";?></td>
 
 	    </tr>
 		<tr>

Modified: vtigercrm/branches/4.2/install/2setConfig.php
==============================================================================
--- vtigercrm/branches/4.2/install/2setConfig.php (original)
+++ vtigercrm/branches/4.2/install/2setConfig.php Mon Apr 24 16:29:46 2006
@@ -340,14 +340,27 @@
             <tr>
               <td nowrap bgcolor="#F5F5F5"><strong>Database Name</strong> <sup><font color=red>*</font></sup></td>
               <td align="left"><input type="text" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" /></td>
-              <input type="hidden" name="dbtype" value="
-              <?php
-                if(isset($dbconfig['db_type']) && $dbconfig['db_type'] != '')
-                        echo $dbconfig['db_type'];
-                elseif(isset($databasetype) && $databasetype != '')
-                        echo $databasetype;
-              ?>">
-            </tr>
+            </tr>
+		<?php if(function_exists('mysql_connect') && function_exists('pg_connect')) : ?>
+	    <tr>
+	      <td nowrap bgcolor="#F5F5F5"><strong>Database Type</strong> <sup><font color=red>*</font></sup></td>
+	      <td align="left">
+	        <select class="dataInput" name="dbtype">
+		  <option value="mysql" <?php echo $dbconfig['db_type'] == 'mysql' ? 'selected' : '' ?>>MySQL</option>
+		  <option value="pgsql" <?php echo $dbconfig['db_type'] == 'pgsql' ? 'selected' : '' ?>>Postgresql</option>
+	        </select>
+	      </td>
+	    </tr>
+		<?php elseif(function_exists('mysql_connect')) : ?>
+			<input type="hidden" name="dbtype" value="mysql" />
+		<?php elseif(function_exists('pg_connect')) : ?>
+			<input type="hidden" name="dbtype" value="pgsql" />
+		<?php else : ?>
+	   <tr>
+	      <td nowrap bgcolor="#F5F5F5"><strong>Database Type</strong> <sup><font color=red>*</font></sup></td>
+	      <td align="left" class="dataInput">ERROR: none detected</td>
+	   </tr>
+		<?php endif ?>
           </table>
               <!-- tr>
                <td></td><td nowrap><strong>Drop Existing Tables?</strong></td>

Modified: vtigercrm/branches/4.2/install/3confirmConfig.php
==============================================================================
--- vtigercrm/branches/4.2/install/3confirmConfig.php (original)
+++ vtigercrm/branches/4.2/install/3confirmConfig.php Mon Apr 24 16:29:46 2006
@@ -73,14 +73,10 @@
 if (isset($_REQUEST['dbtype']))
 	$dbtype	= $_REQUEST['dbtype'];
 
-//Checking for mysql connection parameters
+//Checking for mysql or pgsql connection parameters
 $mysql_status = '';
 $mysql_db_status = '';
-if($dbtype != 'mysql' || $dbtype =='') {
-	$mysql_status = 'true';
-	$mysql_db_status = 'true';
-}
-else {
+if($dbtype == 'mysql') {
 	$conn = @mysql_pconnect($db_hostname,$db_username,$db_password);
 	if(!$conn)
 		$mysql_status = 'false';
@@ -94,6 +90,19 @@
 			$mysql_db_status = 'false';
 		}
 	}
+} elseif($dbtype == 'pgsql') {
+	$host = explode(':', $db_hostname);
+	$conn = @pg_connect("host=".$host[0]." port=".$host[1]." user=$db_username password=$db_password dbname=$db_name");
+	if(!$conn) {
+		$mysql_status = 'false';
+		$mysql_db_status = 'false';
+	} else {
+		$mysql_status = 'true';
+		$mysql_db_status = 'true';
+	}
+} else {
+	$mysql_status = 'true';
+	$mysql_db_status = 'true';
 }
 ?>
 
@@ -203,6 +212,7 @@
              <input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
              <input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
              <input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+	     <input type="hidden" class="dataInput" name="db_type" value="<?php if (isset($dbtype)) echo "$dbtype"; ?>" />
              <input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
              <input type="hidden" class="dataInput" name="site_URL" value="<?php if (isset($site_URL)) echo "$site_URL"; ?>" />
              <input type="hidden" class="dataInput" name="root_directory" value="<?php if (isset($root_directory)) echo "$root_directory"; ?>" />
@@ -236,6 +246,7 @@
 			<input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
 			<input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
 			<input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+			<input type="hidden" class="dataInput" name="db_type" value="<?php if (isset($dbtype)) echo "$dbtype"; ?>" />
 			<input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
 			<input type="hidden" class="dataInput" name="site_URL" value="<?php if (isset($site_URL)) echo "$site_URL"; ?>" />
 			<input type="hidden" class="dataInput" name="root_directory" value="<?php if (isset($root_directory)) echo "$root_directory"; ?>" />
@@ -260,6 +271,7 @@
 			<input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
 			<input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
 			<input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+			<input type="hidden" class="dataInput" name="db_type" value="<?php if (isset($dbtype)) echo "$dbtype"; ?>" />
 			<input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
 			<input type="hidden" class="dataInput" name="site_URL" value="<?php if (isset($site_URL)) echo "$site_URL"; ?>" />
 			<input type="hidden" class="dataInput" name="root_directory" value="<?php if (isset($root_directory)) echo "$root_directory"; ?>" />
@@ -368,6 +380,7 @@
 		<input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
 		<input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
 		<input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+		<input type="hidden" class="dataInput" name="db_type" value="<?php if (isset($dbtype)) echo "$dbtype"; ?>" />
 		<input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
 		<input type="hidden" class="dataInput" name="site_URL" value="<?php if (isset($site_URL)) echo "$site_URL"; ?>" />
 		<input type="hidden" class="dataInput" name="root_directory" value="<?php if (isset($root_directory)) echo "$root_directory"; ?>" />
@@ -438,6 +451,7 @@
 			<input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
 			<input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
 			<input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+			<input type="hidden" class="dataInput" name="db_type" value="<?php if (isset($dbtype)) echo "$dbtype"; ?>" />
 			<input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
 			<input type="hidden" class="dataInput" name="site_URL" value="<?php if (isset($site_URL)) echo "$site_URL"; ?>" />
 			<input type="hidden" class="dataInput" name="root_directory" value="<?php if (isset($root_directory)) echo "$root_directory"; ?>" />

Modified: vtigercrm/branches/4.2/install/4createConfigFile.php
==============================================================================
--- vtigercrm/branches/4.2/install/4createConfigFile.php (original)
+++ vtigercrm/branches/4.2/install/4createConfigFile.php Mon Apr 24 16:29:46 2006
@@ -25,7 +25,6 @@
 }
 
 require_once('include/utils.php');
-include('vtigerversion.php');
 
 session_start();
 
@@ -40,6 +39,9 @@
 
 if (isset($_REQUEST['db_name']))
   $db_name = $_REQUEST['db_name'];
+
+if (isset($_REQUEST['db_type']))
+  $db_type = $_REQUEST['db_type'];
 
 if (isset($_REQUEST['db_drop_tables']))
   $db_drop_tables = $_REQUEST['db_drop_tables'];
@@ -149,7 +151,7 @@
       $buffer = str_replace( "_DBC_USER_", $db_username, $buffer);
       $buffer = str_replace( "_DBC_PASS_", $db_password, $buffer);
       $buffer = str_replace( "_DBC_NAME_", $db_name, $buffer);
-      $buffer = str_replace( "_DBC_TYPE_", "mysql", $buffer);
+      $buffer = str_replace( "_DBC_TYPE_", $db_type, $buffer);
       
       $buffer = str_replace( "_SITE_URL_", $site_URL, $buffer);
       
@@ -200,6 +202,7 @@
               <input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
               <input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
               <input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+              <input type="hidden" class="dataInput" name="db_type" value="<?php if (isset($db_type)) echo "$db_type"; ?>" />
               <input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
               <input type="hidden" class="dataInput" name="db_create" value="<?php if (isset($db_create)) echo "$db_create"; ?>" />
               <input type="hidden" class="dataInput" name="db_populate" value="<?php if (isset($db_populate)) echo "$db_populate"; ?>" />

Modified: vtigercrm/branches/4.2/install/5createTables.inc.php
==============================================================================
--- vtigercrm/branches/4.2/install/5createTables.inc.php (original)
+++ vtigercrm/branches/4.2/install/5createTables.inc.php Mon Apr 24 16:29:46 2006
@@ -227,6 +227,32 @@
 else
 	eecho("Tables Successfully created.\n");
 
+// ensure required sequences are created (adodb creates them as needed, but if
+// creation occurs within a transaction we get problems
+$db->getUniqueID("activity_reminder");
+$db->getUniqueID("crmentity");
+$db->getUniqueID("customfield_sequence");
+$db->getUniqueID("customview");
+$db->getUniqueID("def_org_share");
+$db->getUniqueID("emailtemplates");
+$db->getUniqueID("faqcomments_commentid");
+$db->getUniqueID("field");
+$db->getUniqueID("import_maps");
+$db->getUniqueID("inventorynotification");
+$db->getUniqueID("mail_accounts");
+$db->getUniqueID("notificationscheduler");
+$db->getUniqueID("potstagehistory");
+$db->getUniqueID("profile");
+$db->getUniqueID("relatedlists");
+$db->getUniqueID("reportmodules");
+$db->getUniqueID("role");
+$db->getUniqueID("rss");
+$db->getUniqueID("selectquery");
+$db->getUniqueID("systems");
+$db->getUniqueID("ticketcomments_commentid");
+$db->getUniqueID("wordtemplates");
+
+
 eecho ("Creating tables for module: ");
 foreach ( $modules as $module ) {
         $focus = new $module();

Modified: vtigercrm/branches/4.2/install/populateSeedData.php
==============================================================================
--- vtigercrm/branches/4.2/install/populateSeedData.php (original)
+++ vtigercrm/branches/4.2/install/populateSeedData.php Mon Apr 24 16:29:46 2006
@@ -74,9 +74,9 @@
 function create_date() {
 	$date = "";
 	$date .= "2006";
-	$date .= "/";
+	$date .= "-";
 	$date .= rand(1,9);
-	$date .= "/";
+	$date .= "-";
 	$date .= rand(1,28);
 	
 	return $date;
@@ -454,6 +454,8 @@
 $status_array = array (
 	"Draft",
 	"Reviewed",
+	"Published",
+	"Draft",
 	"Published");
 
 $question_array = array (
@@ -497,6 +499,7 @@
 	$faq->column_fields["faqstatus"] = $status_array[$i];
 	$faq->column_fields["question"]	= $question_array[$i];
 	$faq->column_fields["faq_answer"] = $answer_array[$i];
+	$faq->column_fields["comments"] = "Test ".$i;
 
 	$faq->save("Faq");
 	$faq_ids[] = $faq ->id;
@@ -542,6 +545,7 @@
 	$helpdesk->column_fields["ticketcategories"] = $category_array[$i];
 	//$rand_key = array_rand($s);
 	$helpdesk->column_fields["ticket_title"] = $ticket_title_array[$i];
+	$helpdesk->column_fields["assigned_user_id"] = $assigned_user_id;
 	
 	$helpdesk->save("HelpDesk");
 	$helpdesk_ids[] = $helpdesk->id;
@@ -633,12 +637,13 @@
 	}
 	else
 		$event->column_fields["activitytype"]	= "Call";	
+	$event->column_fields["assigned_user_id"] = $assigned_user_id;
 
 	$event->save("Activities");
         $event_ids[] = $event->id;
 }
 
-$adb->query("update crmentity set crmentity.smcreatorid=".$assigned_user_id);
+$adb->query("update crmentity set smcreatorid=".$assigned_user_id);
 
 /*
 for($i = 0; $i < $company_name_count; $i++) {

Modified: vtigercrm/branches/4.2/modules/Accounts/Account.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Accounts/Account.php (original)
+++ vtigercrm/branches/4.2/modules/Accounts/Account.php Mon Apr 24 16:29:46 2006
@@ -230,7 +230,7 @@
 	{
           // First, get the list of IDs.
 //          $query = "SELECT activity.subject,semodule,activitytype,date_start,status,priority from activity inner join seactivityrel on seactivityrel.activityid=activity.activityid where seactivityrel.crmid=".$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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and ( activity.status is NULL || activity.status != 'Completed' ) and (  activity.eventstatus is NULL ||  activity.eventstatus != 'Held')";
+	  $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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and ( activity.status is NULL OR activity.status != 'Completed' ) and (  activity.eventstatus is NULL OR  activity.eventstatus != 'Held')";
           renderRelatedTasks($query,$id); //Query Changed by Jaguar
 
           //return $this->build_related_list($query, new Task());
@@ -293,9 +293,9 @@
 
 	function get_attachments($id)
 	{
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename, attachments.type  FileType,crm2.modifiedtime  lastmodified, seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid 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 where crmentity.crmid=".$id;
+		$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 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 where 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 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 where crmentity.crmid=".$id;
+		$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 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 where crmentity.crmid=".$id;
 		renderRelatedAttachments($query,$id);
 	}
 	function get_quotes($id)
@@ -547,14 +547,15 @@
 		do not include any $this-> because this is called on without having the class instantiated
 	*/
 	function build_generic_where_clause ($the_query_string) {
+		global $adb;
 	
 	$where_clauses = Array();
 	$the_query_string = addslashes($the_query_string);
-	array_push($where_clauses, "accountname like '$the_query_string%'");
+	array_push($where_clauses, "accountname ".$adb->getLike()." '$the_query_string%'");
 	if (is_numeric($the_query_string)) {
-		array_push($where_clauses, "otherphone like '%$the_query_string%'");
-		array_push($where_clauses, "fax like '%$the_query_string%'");
-		array_push($where_clauses, "phone like '%$the_query_string%'");
+		array_push($where_clauses, "otherphone ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "fax ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "phone ".$adb->getLike()." '%$the_query_string%'");
 	}
 	
 	$the_where = "";
@@ -623,8 +624,8 @@
 		{
           
   $query = $this->constructCustomQueryAddendum() . ", 
-			account.*, ".$this->entity_table.".*, accountbillads.city  billing_city, accountbillads.country  billing_country, accountbillads.code  billing_code, accountbillads.state  billing_state, accountbillads.street  billing_street, accountshipads.city  shipping_city, accountshipads.country  shipping_country, accountshipads.code  shipping_code, accountshipads.state  shipping_state,  accountshipads.street  shipping_street,
-                        users.user_name, users.status  user_status
+			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, AS accountshipads.street AS shipping_street,
+                        users.user_name, users.status AS user_status
                         FROM ".$this->entity_table."
                         INNER JOIN account
                         ON crmentity.crmid=account.accountid
@@ -641,8 +642,8 @@
 		else
 		{
                   $query = "SELECT 
-			account.*, ".$this->entity_table.".*, accountbillads.city  billing_city, accountbillads.country  billing_country, accountbillads.code  billing_code, accountbillads.state billing_state, accountbillads.street billing_street, accountshipads.city shipping_city, accountshipads.country shipping_country, accountshipads.code shipping_code, accountshipads.state shipping_state,  accountshipads.street shipping_street,
-                        users.user_name, users.status user_status
+			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
                         FROM ".$this->entity_table."
                         INNER JOIN account
                         ON crmentity.crmid=account.accountid

Modified: vtigercrm/branches/4.2/modules/Accounts/AccountFormBase.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Accounts/AccountFormBase.php (original)
+++ vtigercrm/branches/4.2/modules/Accounts/AccountFormBase.php Mon Apr 24 16:29:46 2006
@@ -26,6 +26,7 @@
 function checkForDuplicates($prefix){
 	require_once('include/formbase.php');
 	require_once('modules/Accounts/Account.php');
+	global $adb;
 	$focus = new Account();
 	if(!checkRequired($prefix, array_keys($focus->required_fields))){
 		return null;
@@ -33,15 +34,15 @@
 	$query = '';
 	$baseQuery = 'select id, name, website, billing_address_city  from accounts where deleted!=1 and (';
 	if(isset($_POST[$prefix.'name']) && !empty($_POST[$prefix.'name'])){
-	$query = $baseQuery ."  name like ".PearDatabase::quote('%'.$_POST[$prefix.'name'].'%');	
-        //$query = $baseQuery ."  name like '%".PearDatabase::quote($_POST[$prefix.'name'])."%'";
+	$query = $baseQuery ."  name ".$adb->getLike()." ".PearDatabase::quote('%'.$_POST[$prefix.'name'].'%');	
+        //$query = $baseQuery ."  name ".$adb->getLike()." '%".PearDatabase::quote($_POST[$prefix.'name'])."%'";
 	}
 	if(isset($_POST[$prefix.'website']) && !empty($_POST[$prefix.'website'])){	
 		if(empty($query)){
-                  //			$query = $baseQuery ."  website like '".PearDatabase::quote($_POST[$prefix.'website'])."%'";
-	$query = $baseQuery ."  website like ".PearDatabase::quote($_POST[$prefix.'website'].'%');
+                  //			$query = $baseQuery ."  website ".$adb->getLike()." '".PearDatabase::quote($_POST[$prefix.'website'])."%'";
+	$query = $baseQuery ."  website ".$adb->getLike()." ".PearDatabase::quote($_POST[$prefix.'website'].'%');
 		}else {
-			$query .= "or website like '".$_POST[$prefix.'website']."%'";
+			$query .= "or website ".$adb->getLike()." '".$_POST[$prefix.'website']."%'";
 		}
 	}
 	if(!empty($query)){
@@ -201,4 +202,4 @@
 	
 }
 }
-?>
+?>

Modified: vtigercrm/branches/4.2/modules/Accounts/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Accounts/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Accounts/ListView.php Mon Apr 24 16:29:46 2006
@@ -95,7 +95,7 @@
 		if($uitype[$i] == 56)
 			$str=" accountscf.".$column[$i]." = 1";
 		else
-	                $str=" accountscf.".$column[$i]." like '$customfield[$i]%'";
+	                $str=" accountscf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
                 array_push($where_clauses, $str);
 		$url_string .="&".$column[$i]."=".$customfield[$i];
         }
@@ -104,57 +104,57 @@
 
 	if(isset($name) && $name != "")
 	{
-		array_push($where_clauses, "account.accountname like ".PearDatabase::quote($name."%"));
+		array_push($where_clauses, "account.accountname ".$adb->getLike()." ".PearDatabase::quote($name."%"));
 		$url_string .= "&accountname=".$name;
 	}
 	if(isset($website) && $website != "")
 	{
-		array_push($where_clauses, "account.website like ".PearDatabase::quote("%".$website."%"));
+		array_push($where_clauses, "account.website ".$adb->getLike()." ".PearDatabase::quote("%".$website."%"));
 		$url_string .= "&website=".$website;
 	}
 	if(isset($phone) && $phone != "")
 	{
-		array_push($where_clauses, "(account.phone like ".PearDatabase::quote("%".$phone."%")." OR account.otherphone like ".PearDatabase::quote("%".$phone."%")." OR account.fax like ".PearDatabase::quote("%".$phone."%").")");
+		array_push($where_clauses, "(account.phone ".$adb->getLike()." ".PearDatabase::quote("%".$phone."%")." OR account.otherphone ".$adb->getLike()." ".PearDatabase::quote("%".$phone."%")." OR account.fax ".$adb->getLike()." ".PearDatabase::quote("%".$phone."%").")");
 		$url_string .= "&phone=".$phone;
 	}
 	if(isset($annual_revenue) && $annual_revenue != "")
 	{
-		array_push($where_clauses, "account.annualrevenue like ".PearDatabase::quote($annual_revenue."%"));
+		array_push($where_clauses, "account.annualrevenue ".$adb->getLike()." ".PearDatabase::quote($annual_revenue."%"));
 		$url_string .= "&annual_revenue=".$annual_revenue;
 	}
 	if(isset($employees) && $employees != "")
 	{
-		array_push($where_clauses, "account.employees like ".PearDatabase::quote($employees."%"));
+		array_push($where_clauses, "account.employees ".$adb->getLike()." ".PearDatabase::quote($employees."%"));
 		$url_string .= "&employees=".$employees;
 	}
 	if(isset($address_street) && $address_street != "")
 	{
-		array_push($where_clauses, "(accountbillads.street like ".PearDatabase::quote($address_street."%")." OR accountshipads.street like ".PearDatabase::quote($address_street."%").")");
+		array_push($where_clauses, "(accountbillads.street ".$adb->getLike()." ".PearDatabase::quote($address_street."%")." OR accountshipads.street ".$adb->getLike()." ".PearDatabase::quote($address_street."%").")");
 		$url_string .= "&address_street=".$address_street;
 	}
 	if(isset($address_city) && $address_city != "")
 	{
-		array_push($where_clauses, "(accountbillads.city like ".PearDatabase::quote($address_city."%")." OR accountshipads.city like ".PearDatabase::quote($address_city."%").")");
+		array_push($where_clauses, "(accountbillads.city ".$adb->getLike()." ".PearDatabase::quote($address_city."%")." OR accountshipads.city ".$adb->getLike()." ".PearDatabase::quote($address_city."%").")");
 		$url_string .= "&bill_city=".$address_city;
 	}
 	if(isset($address_state) && $address_state != "")
 	{
-		array_push($where_clauses, "(accountbillads.state like ".PearDatabase::quote($address_state."%")." OR accountshipads.state like ".PearDatabase::quote($address_state."%").")");
+		array_push($where_clauses, "(accountbillads.state ".$adb->getLike()." ".PearDatabase::quote($address_state."%")." OR accountshipads.state ".$adb->getLike()." ".PearDatabase::quote($address_state."%").")");
 		$url_string .= "&bill_state=".$address_state;
 	}
 	if(isset($address_postalcode) && $address_postalcode != "")
 	{
-		array_push($where_clauses, "(accountbillads.code like ".PearDatabase::quote($address_postalcode."%")." OR accountshipads.code like ".PearDatabase::quote($address_postalcode."%").")");
+		array_push($where_clauses, "(accountbillads.code ".$adb->getLike()." ".PearDatabase::quote($address_postalcode."%")." OR accountshipads.code ".$adb->getLike()." ".PearDatabase::quote($address_postalcode."%").")");
 		$url_string .= "&bill_code=".$address_postalcode;
 	}
 	if(isset($address_country) && $address_country != "")
 	{
-		array_push($where_clauses, "(accountbillads.country like ".PearDatabase::quote($address_country."%")." OR accountshipads.country like ".PearDatabase::quote($address_country."%").")");
+		array_push($where_clauses, "(accountbillads.country ".$adb->getLike()." ".PearDatabase::quote($address_country."%")." OR accountshipads.country ".$adb->getLike()." ".PearDatabase::quote($address_country."%").")");
 		$url_string .= "&bill_country=".$address_country;
 	}
 	if(isset($email) && $email != "")
 	{
-		array_push($where_clauses, "(account.email1 like ".PearDatabase::quote($email."%")." OR account.email2 like ".PearDatabase::quote($email."%").")");
+		array_push($where_clauses, "(account.email1 ".$adb->getLike()." ".PearDatabase::quote($email."%")." OR account.email2 ".$adb->getLike()." ".PearDatabase::quote($email."%").")");
 		$url_string .= "&email=".$email;
 	}
 	if(isset($industry) && $industry != "")
@@ -164,18 +164,18 @@
 	}
 	if(isset($ownership) && $ownership != "")
 	{
-	 	array_push($where_clauses, "account.ownership like ".PearDatabase::quote($ownership."%"));
+	 	array_push($where_clauses, "account.ownership ".$adb->getLike()." ".PearDatabase::quote($ownership."%"));
 		$url_string .= "&ownership=".$ownership;
 	}
-	if(isset($rating) && $rating != "") array_push($where_clauses, "account.rating like ".PearDatabase::quote($rating."%"));
+	if(isset($rating) && $rating != "") array_push($where_clauses, "account.rating ".$adb->getLike()." ".PearDatabase::quote($rating."%"));
 	if(isset($sic_code) && $sic_code != "")
 	{
-		array_push($where_clauses, "account.siccode like ".PearDatabase::quote($sic_code."%"));
+		array_push($where_clauses, "account.siccode ".$adb->getLike()." ".PearDatabase::quote($sic_code."%"));
 		$url_string .= "&siccode=".$sic_code;
 	}
 	if(isset($ticker_symbol) && $ticker_symbol != "")
 	{
-		array_push($where_clauses, "account.tickersymbol like ".PearDatabase::quote($ticker_symbol."%"));
+		array_push($where_clauses, "account.tickersymbol ".$adb->getLike()." ".PearDatabase::quote($ticker_symbol."%"));
 		$url_string .= "&tickersymbol=".$ticker_symbol;
 	}
 	if(isset($account_type) && $account_type != "")

Modified: vtigercrm/branches/4.2/modules/Accounts/ListViewTop.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Accounts/ListViewTop.php (original)
+++ vtigercrm/branches/4.2/modules/Accounts/ListViewTop.php Mon Apr 24 16:29:46 2006
@@ -29,7 +29,7 @@
 $current_module_strings = return_module_language($current_language, "Accounts");
 $log = LoggerManager::getLogger('top accounts_list');
 
-$list_query = 'select account.accountid, account.accountname, 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.accountname order by 3 desc;';
+$list_query = "select account.accountid, account.accountname, 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.accountname, account.accountid order by 3 desc;";
 $list_result=$adb->query($list_query);
 $open_accounts_list = array();
 $noofrows = min($adb->num_rows($list_result),7);

Modified: vtigercrm/branches/4.2/modules/Accounts/Popup.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Accounts/Popup.php (original)
+++ vtigercrm/branches/4.2/modules/Accounts/Popup.php Mon Apr 24 16:29:46 2006
@@ -82,23 +82,23 @@
 
         if(isset($customfield[$i]) && $customfield[$i] != '')
         {
-                $str=" accountcf.".$column[$i]." like '$customfield[$i]%'";
+                $str=" accountcf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
                 array_push($where_clauses, $str);
         }
 }
 //upto this added for Custom Field
 */	
 	if(isset($name) && $name != ""){
-		array_push($where_clauses, "account.accountname like ".PearDatabase::quote($name."%"));
+		array_push($where_clauses, "account.accountname ".$adb->getLike()." ".PearDatabase::quote($name."%"));
 		$url_string .= "&name=".$name;
 	}
-	if(isset($website) && $website != "") array_push($where_clauses, "account.website like ".PearDatabase::quote("%".$website."%"));
-	if(isset($phone) && $phone != "") array_push($where_clauses, "(account.phone like ".PearDatabase::quote("%".$phone."%")." OR account.otherphone like ".PearDatabase::quote("%".$phone."%")." OR account.fax like ".PearDatabase::quote("%".$phone."%").")");
+	if(isset($website) && $website != "") array_push($where_clauses, "account.website ".$adb->getLike()." ".PearDatabase::quote("%".$website."%"));
+	if(isset($phone) && $phone != "") array_push($where_clauses, "(account.phone ".$adb->getLike()." ".PearDatabase::quote("%".$phone."%")." OR account.otherphone ".$adb->getLike()." ".PearDatabase::quote("%".$phone."%")." OR account.fax ".$adb->getLike()." ".PearDatabase::quote("%".$phone."%").")");
 	if(isset($address_city) && $address_city != ""){
-		array_push($where_clauses, "(accountbillads.city like ".PearDatabase::quote("%".$address_city."%")." OR accountshipads.city like ".PearDatabase::quote($address_city."%").")");
+		array_push($where_clauses, "(accountbillads.city ".$adb->getLike()." ".PearDatabase::quote("%".$address_city."%")." OR accountshipads.city ".$adb->getLike()." ".PearDatabase::quote($address_city."%").")");
 		$url_string .= "&address_city=".$address_city;
 	}
-	if(isset($ownership) && $ownership != "") array_push($where_clauses, "account.ownership like ".PearDatabase::quote($ownership."%"));
+	if(isset($ownership) && $ownership != "") array_push($where_clauses, "account.ownership ".$adb->getLike()." ".PearDatabase::quote($ownership."%"));
 	if(isset($current_user_only) && $current_user_only != ""){
 		array_push($where_clauses, "crmentity.smownerid='$current_user->id'");
 		$url_string .= "&current_user_only=".$current_user_only;

Modified: vtigercrm/branches/4.2/modules/Accounts/Popup_picker.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Accounts/Popup_picker.php (original)
+++ vtigercrm/branches/4.2/modules/Accounts/Popup_picker.php Mon Apr 24 16:29:46 2006
@@ -51,11 +51,11 @@
 
 	if(isset($name))
 	{
-		array_push($where_clauses, "name like '$name%'");
+		array_push($where_clauses, "name ".$adb->getLike()." '$name%'");
 	}
 	if(isset($billing_address_city))
 	{
-		array_push($where_clauses, "billing_address_city like '$billing_address_city%'");
+		array_push($where_clauses, "billing_address_city ".$adb->getLike()." '$billing_address_city%'");
 	}
 
 	$where = "";

Modified: vtigercrm/branches/4.2/modules/Activities/Activity.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Activities/Activity.php (original)
+++ vtigercrm/branches/4.2/modules/Activities/Activity.php Mon Apr 24 16:29:46 2006
@@ -438,6 +438,7 @@
 	
 	function activity_reminder($activity_id,$reminder_time,$reminder_sent=0,$recurid,$remindermode='')
 	{
+		if($recurid == '') $recurid = $this->db->getUniqueID($this->reminder_table);
 		//Check for activityid already present in the reminder_table
 		$query_exist = "SELECT activity_id FROM ".$this->reminder_table." WHERE activity_id = ".$activity_id;
 		$result_exist = $this->db->query($query_exist);

Modified: vtigercrm/branches/4.2/modules/Activities/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Activities/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Activities/ListView.php Mon Apr 24 16:29:46 2006
@@ -123,20 +123,20 @@
 	}
 	if(isset($name) && $name != '')
 	{
-		array_push($where_clauses, "activity.subject like ".PearDatabase::quote($name.'%')."");
+		array_push($where_clauses, "activity.subject ".$adb->getLike()." ".PearDatabase::quote($name.'%')."");
 		$url_string .= "&name=".$name;
 	}
 	if(isset($contactname) && $contactname != '')
 	{
 		//$contactnames = explode(" ", $contactname);
 		//foreach ($contactnames as $name) {
-		array_push($where_clauses, "(contactdetails.firstname like ".PearDatabase::quote($contactname.'%')." OR contactdetails.lastname like ".PearDatabase::quote($contactname.'%').")");
+		array_push($where_clauses, "(contactdetails.firstname ".$adb->getLike()." ".PearDatabase::quote($contactname.'%')." OR contactdetails.lastname ".$adb->getLike()." ".PearDatabase::quote($contactname.'%').")");
 		$url_string .= "&contactname=".$contactname;
 		//}
 	}
 	if(isset($duedate) && $duedate != '')
 	{
-		array_push($where_clauses, "activity.duedate like ".PearDatabase::quote($datedue.'%')."");
+		array_push($where_clauses, "activity.duedate ".$adb->getLike()." ".PearDatabase::quote($datedue.'%')."");
 	}
 	if(isset($status) && $status != '')
 	{
@@ -236,13 +236,20 @@
 
 //Retreive the list from Database
 //<<<<<<<<<customview>>>>>>>>>
+$distincton = '';
+if($adb->isPostgres()) {
+	if(isset($order_by) && $order_by != '') {
+		$distincton = $order_by . ', ';
+	}
+	$distincton .= 'crmid';
+}
 if($viewid != "0")
 {
-	$listquery = getListQuery("Activities");
+	$listquery = getListQuery("Activities", '', $distincton);
 	$list_query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Activities");
 }else
 {
-	$list_query = getListQuery("Activities");
+	$list_query = getListQuery("Activities", '', $distincton);
 }
 //<<<<<<<<customview>>>>>>>>>
 
@@ -290,7 +297,9 @@
 	set_selected();
 	</script>";
 
+	if(!$adb->isPostgres()) {  // postgres wont group if all members of the select list aren't in the group by, use distinct on instead
 $list_query .= ' GROUP BY crmentity.crmid'; //Appeding for the recurring event by jaguar
+	}
 
 if(isset($order_by) && $order_by != '')
 {

Modified: vtigercrm/branches/4.2/modules/Activities/OpenListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Activities/OpenListView.php (original)
+++ vtigercrm/branches/4.2/modules/Activities/OpenListView.php Mon Apr 24 16:29:46 2006
@@ -55,24 +55,22 @@
 		 account.accountid, 
 		 account.accountname, 
 		 recurringevents.recurringtype,
-		 recurringevents.recurringdate, 
-		 GREATEST(recurringevents.recurringdate,activity.date_start) as sort_date
+		 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 
+		 LEFT OUTER JOIN recurringevents ON recurringevents.activityid = activity.activityid AND recurringevents.recurringdate <= '$later'
 		 INNER JOIN salesmanactivityrel ON salesmanactivityrel.activityid = activity.activityid 
 		 WHERE crmentity.deleted=0 
-		 AND ( activity.status is NULL || activity.status != 'Completed' ) 
-		 AND ( activity.eventstatus is NULL ||  activity.eventstatus != 'Held') 
-		 AND ( activity.eventstatus is NULL ||  activity.eventstatus != 'Not Held' )
+		 AND ( activity.status is NULL OR activity.status != 'Completed' ) 
+		 AND ( activity.eventstatus is NULL OR  activity.eventstatus != 'Held') 
+		 AND ( activity.eventstatus is NULL OR  activity.eventstatus != 'Not Held' )
 		 AND ( date_start <= '$later' OR recurringevents.recurringdate <= '$later' )
 		 AND salesmanactivityrel.smid ='{$current_user->id}'
-		 HAVING sort_date <= '$later'
-		 ORDER BY sort_date, activity.time_start";
+		 ORDER BY GREATEST(recurringevents.recurringdate,activity.date_start), activity.time_start";
 
 //$list_query = getListQuery("Activities",$where);
 //echo $list_query."<h3>END</h3>";

Modified: vtigercrm/branches/4.2/modules/Activities/RenderRelatedListUI.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Activities/RenderRelatedListUI.php (original)
+++ vtigercrm/branches/4.2/modules/Activities/RenderRelatedListUI.php Mon Apr 24 16:29:46 2006
@@ -113,14 +113,16 @@
 		global $adb,$image_path,$vtlog;
 		$avail_flag="false";
 		$avail_date=getDBInsertDateValue($avail_date);
+		$distincton = $adb->isPostgres() ? 'DISTINCT ON (crmid)' : '';
+		$groupby = $adb->isPostgres() ? '' : 'GROUP BY crmid';
 		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 group by crmid;";
+			$usr_query="select $distincton 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."' ".$adb->getLike()." date_start) and crmentity.smownerid=".$userid." and activity.activityid !=".$activity_id."  and crmentity.deleted=0 $groupby;";
 		}
 		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 group by crmid;";
+			$usr_query="select $distincton 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."' ".$adb->getLike()." date_start) and crmentity.smownerid=".$userid." and activity.activityid !=".$activity_id." and crmentity.deleted=0 $groupby;";
 		}
 		$result_cal=$adb->query($usr_query);   
 		$noofrows_cal = $adb->num_rows($result_cal);
@@ -149,7 +151,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 group by crmid";
+			$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."' ".$adb->getLike()." recurringevents.recurringdate) and crmentity.smownerid=".$userid." and activity.activityid !=".$activity_id." and crmentity.deleted=0";
 			
 			$result_cal=$adb->query($recur_query);   
 			$noofrows_cal = $adb->num_rows($result_cal);
@@ -266,7 +268,8 @@
 	$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 .' group by activity.activityid';
+		$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;
+		if(!$adb->isPostgres()) $recur_dates_qry .= ' group by activity.activityid';
 		$recur_result=$adb->query($recur_dates_qry);
 		$noofrows_recur = $adb->num_rows($recur_result);
 
@@ -386,7 +389,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  userid from users,crmentity where users.id=crmentity.smownerid and crmentity.crmid='.$id;
+	$activity_owner_qry='select users.user_name,users.id AS userid from users,crmentity where users.id=crmentity.smownerid and crmentity.crmid='.$id;
 	$result_owner=$adb->query($activity_owner_qry);
 
         while($row_owner = $adb->fetch_array($result_owner))

Modified: vtigercrm/branches/4.2/modules/Calendar/appointment.pinc
==============================================================================
--- vtigercrm/branches/4.2/modules/Calendar/appointment.pinc (original)
+++ vtigercrm/branches/4.2/modules/Calendar/appointment.pinc Mon Apr 24 16:29:46 2006
@@ -1933,7 +1933,7 @@
 		}
 
 		$q.=" ((activity.date_start < '". $sx2 ."' AND activity.date_start >= '". $sx1."')";
-		$q.=" and (activity.date_start like (activity.due_date) or (activity.date_start != '0000-00-00' ))";//query modified by Jag
+		$q.=" and (activity.date_start like (activity.due_date) or (activity.date_start != null ))";//query modified by Jag
 		#$q .= " OR (a_end < ". $x2 ." AND a_end   >= ". $x1 .")";
 		#$q .= " OR (a_start < ". $x1 ." AND a_end   >= ". $x2 .")";
 		#$q .= " OR (date_start < ". $sx1 .")";
@@ -2026,7 +2026,7 @@
 		$q.=" activity.activitytype in ('Call','Meeting') AND ";
 
 		$q.=" ((activity.date_start < '". $sx2 ."' AND activity.date_start >= '". $sx1."')";
-		$q.=" and (activity.date_start like (activity.due_date) or (activity.date_start != '0000-00-00' ))";//query modified by Jag
+		$q.=" and (activity.date_start like (activity.due_date) or (activity.date_start != null ))";//query modified by Jag
 
 		$q .= " AND crmentity.deleted = 0)";
 		$q .= " and crmentity.smownerid=0 and users2group.userid=".$current_user->id;	

Modified: vtigercrm/branches/4.2/modules/Contacts/Contact.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Contacts/Contact.php (original)
+++ vtigercrm/branches/4.2/modules/Contacts/Contact.php Mon Apr 24 16:29:46 2006
@@ -235,7 +235,8 @@
 
         function get_contacts1($user_name,$email_address)
     {   
-      $query = "select 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 where user_name='" .$user_name ."' and crmentity.deleted=0  and contactdetails.email like '%" .$email_address ."%' limit 50";
+	    global $adb;
+      $query = "select 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 where user_name='" .$user_name ."' and crmentity.deleted=0  and contactdetails.email ".$adb->getLike()." '%" .$email_address ."%' limit 50";
       //echo $query;
       return $this->process_list_query1($query);
     }
@@ -350,7 +351,7 @@
           // First, get the list of IDs.
 
 		//$query = 'SELECT contactdetails.lastname, contactdetails.firstname,  activity.activityid , activity.subject, activity.activitytype, activity.date_start, cntactivityrel.contactid, crmentity.crmid, crmentity.smownerid, crmentity.modifiedtime 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 where contactdetails.contactid = '.$id.' and (activitytype="Task" or activitytype="Call" or activitytype="Meeting") and crmentity.deleted=0';
-		$query = "SELECT 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 outer join recurringevents on recurringevents.activityid=activity.activityid where contactdetails.contactid = ".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and ( activity.status is NULL || activity.status != 'Completed' ) and (  activity.eventstatus is NULL ||  activity.eventstatus != 'Held')"; //recurring type is added in Query -Jaguar
+		$query = "SELECT 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 outer join recurringevents on recurringevents.activityid=activity.activityid where contactdetails.contactid = ".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 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
 		renderRelatedTasks($query,$id);		
 
           //return $this->build_related_list($query, new Task());
@@ -370,9 +371,9 @@
         function get_attachments($id)
         {
 		//$query = 'select notes.title,"Notes      " as ActivityType, notes.filename, attachments.type as "FileType",crm2.modifiedtime as "lastmodified", notes.notesid as noteattachmentid 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 left join seattachmentsrel  on seattachmentsrel.crmid =notes.notesid left join attachments on seattachmentsrel.attachmentsid = attachments.attachmentsid where crmentity.crmid='.$id;
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename, attachments.type  FileType,crm2.modifiedtime  lastmodified, seattachmentsrel.attachmentsid  attachmentsid, notes.notesid crmid 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 where crmentity.crmid=".$id;
+		$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 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 where 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 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 where crmentity.crmid=".$id;
+		$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 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 where crmentity.crmid=".$id;
                 renderRelatedAttachments($query,$id);
 	  }
 	  function get_quotes($id)
@@ -492,8 +493,8 @@
 		{
 	   $query =  $this->constructCustomQueryAddendum() .",
                                 contactdetails.*, contactaddress.*,
-                                account.accountname account_name,
-                                users.user_name assigned_user_name
+                                account.accountname AS account_name,
+                                users.user_name AS assigned_user_name
                                 FROM contactdetails
 				inner join crmentity on crmentity.crmid=contactdetails.contactid
                                 LEFT JOIN users ON crmentity.smcreatorid=users.id
@@ -506,8 +507,8 @@
 		{
                   	 $query = "SELECT
                                 contactdetails.*, contactaddress.*,
-                                account.accountname account_name,
-                                users.user_name assigned_user_name
+                                account.accountname AS account_name,
+                                users.user_name AS assigned_user_name
                                 FROM contactdetails
                                 inner join crmentity on crmentity.crmid=contactdetails.contactid
                                 LEFT JOIN users ON crmentity.smcreatorid=users.id
@@ -754,21 +755,22 @@
 		do not include any $this-> because this is called on without having the class instantiated
 	*/
 	function build_generic_where_clause ($the_query_string) {
+		global $adb;
 	$where_clauses = Array();
 	$the_query_string = addslashes($the_query_string);
-	array_push($where_clauses, "lastname like '$the_query_string%'");
-	array_push($where_clauses, "firstname like '$the_query_string%'");
-	array_push($where_clauses, "contactsubdetails.assistant like '$the_query_string%'");
-	array_push($where_clauses, "email like '$the_query_string%'");
-	array_push($where_clauses, "otheremail like '$the_query_string%'");
-	array_push($where_clauses, "yahooid like '$the_query_string%'");
+	array_push($where_clauses, "lastname ".$adb->getLike()." '$the_query_string%'");
+	array_push($where_clauses, "firstname ".$adb->getLike()." '$the_query_string%'");
+	array_push($where_clauses, "contactsubdetails.assistant ".$adb->getLike()." '$the_query_string%'");
+	array_push($where_clauses, "email ".$adb->getLike()." '$the_query_string%'");
+	array_push($where_clauses, "otheremail ".$adb->getLike()." '$the_query_string%'");
+	array_push($where_clauses, "yahooid ".$adb->getLike()." '$the_query_string%'");
 	if (is_numeric($the_query_string)) {
-		array_push($where_clauses, "phone like '%$the_query_string%'");
-		array_push($where_clauses, "mobile like '%$the_query_string%'");
-		array_push($where_clauses, "contactsubdetails.homephone like '%$the_query_string%'");
-		array_push($where_clauses, "contactsubdetails.otherphone like '%$the_query_string%'");
-		array_push($where_clauses, "fax like '%$the_query_string%'");
-		array_push($where_clauses, "contactsubdetails.assistantphone like '%$the_query_string%'");
+		array_push($where_clauses, "phone ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "mobile ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "contactsubdetails.homephone ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "contactsubdetails.otherphone ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "fax ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "contactsubdetails.assistantphone ".$adb->getLike()." '%$the_query_string%'");
 	}
 	
 	$the_where = "";

Modified: vtigercrm/branches/4.2/modules/Contacts/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Contacts/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Contacts/ListView.php Mon Apr 24 16:29:46 2006
@@ -96,7 +96,7 @@
 		if($uitype[$i] == 56)
 			$str=" contactscf.".$column[$i]." = 1";
 		else
-	        	$str=" contactscf.".$column[$i]." like '$customfield[$i]%'";
+	        	$str=" contactscf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
                 array_push($where_clauses, $str);
 		$url_string .="&".$column[$i]."=".$customfield[$i];
         }
@@ -105,15 +105,15 @@
 
 
 	if(isset($lastname) && $lastname != "") {
-			array_push($where_clauses, "contactdetails.lastname like ".PearDatabase::quote($lastname.'%')."");
+			array_push($where_clauses, "contactdetails.lastname ".$adb->getLike()." ".PearDatabase::quote($lastname.'%')."");
 			$url_string .= "&lastname=".$lastname;
 	}
 	if(isset($firstname) && $firstname != "") {
-			array_push($where_clauses, "contactdetails.firstname like ".PearDatabase::quote($firstname.'%')."");
+			array_push($where_clauses, "contactdetails.firstname ".$adb->getLike()." ".PearDatabase::quote($firstname.'%')."");
 			$url_string .= "&firstname=".$firstname;
 	}
 	if(isset($accountname) && $accountname != "")	{
-			array_push($where_clauses, "account.accountname like ".PearDatabase::quote($accountname.'%')."");
+			array_push($where_clauses, "account.accountname ".$adb->getLike()." ".PearDatabase::quote($accountname.'%')."");
 			$url_string .= "&accountname=".$accountname;
 	}
 	if(isset($leadsource) && $leadsource != "") {
@@ -125,39 +125,39 @@
 			$url_string .= "&donotcall=".$donotcall;
 	}
 	if(isset($phone) && $phone != "") {
-			array_push($where_clauses, "(contactdetails.phone like ".PearDatabase::quote('%'.$phone.'%')." OR contactdetails.mobile like ".PearDatabase::quote('%'.$phone.'%')." OR contactdetails.fax like ".PearDatabase::quote('%'.$phone.'%').")");
+			array_push($where_clauses, "(contactdetails.phone ".$adb->getLike()." ".PearDatabase::quote('%'.$phone.'%')." OR contactdetails.mobile ".$adb->getLike()." ".PearDatabase::quote('%'.$phone.'%')." OR contactdetails.fax ".$adb->getLike()." ".PearDatabase::quote('%'.$phone.'%').")");
 			$url_string .= "&phone=".$phone;
 	}
 	if(isset($email) && $email != "") {
-			array_push($where_clauses, "(contactdetails.email like ".PearDatabase::quote($email.'%').")");
+			array_push($where_clauses, "(contactdetails.email ".$adb->getLike()." ".PearDatabase::quote($email.'%').")");
 			$url_string .= "&email=".$email;
 	}
 	if(isset($yahooid) && $yahooid != "") {
-			array_push($where_clauses, "contactdetails.yahooid like ".PearDatabase::quote($yahooid.'%')."");
+			array_push($where_clauses, "contactdetails.yahooid ".$adb->getLike()." ".PearDatabase::quote($yahooid.'%')."");
 			$url_string .= "&yahooid=".$yahooid;
 	}
 	if(isset($assistant) && $assistant != "") {
-			array_push($where_clauses, "contactsubdetails.assistant like ".PearDatabase::quote($assistant.'%')."");
+			array_push($where_clauses, "contactsubdetails.assistant ".$adb->getLike()." ".PearDatabase::quote($assistant.'%')."");
 			$url_string .= "&yahooid=".$yahooid;
 	}
 	if(isset($mailingstreet) && $mailingstreet != "") {
-			array_push($where_clauses, "(contactaddress.mailingstreet like ".PearDatabase::quote($mailingstreet.'%')." OR contactaddress.otherstreet like ".PearDatabase::quote($mailingstreet.'%').")");
+			array_push($where_clauses, "(contactaddress.mailingstreet ".$adb->getLike()." ".PearDatabase::quote($mailingstreet.'%')." OR contactaddress.otherstreet ".$adb->getLike()." ".PearDatabase::quote($mailingstreet.'%').")");
 			$url_string .= "&mailingstreet=".$mailingstreet;
 	}
 	if(isset($mailingcity) && $mailingcity != "") {
-			array_push($where_clauses, "(contactaddress.mailingcity like ".PearDatabase::quote($mailingcity.'%')." OR contactaddress.othercity like ".PearDatabase::quote($mailingcity.'%').")");
+			array_push($where_clauses, "(contactaddress.mailingcity ".$adb->getLike()." ".PearDatabase::quote($mailingcity.'%')." OR contactaddress.othercity ".$adb->getLike()." ".PearDatabase::quote($mailingcity.'%').")");
 			$url_string .= "&mailingcity=".$mailingcity;
 	}
 	if(isset($mailingstate) && $mailingstate != "") {
-			array_push($where_clauses, "(contactaddress.mailingstate like ".PearDatabase::quote($mailingstate.'%')." OR contactaddress.otherstate like ".PearDatabase::quote($mailingstate.'%').")");
+			array_push($where_clauses, "(contactaddress.mailingstate ".$adb->getLike()." ".PearDatabase::quote($mailingstate.'%')." OR contactaddress.otherstate ".$adb->getLike()." ".PearDatabase::quote($mailingstate.'%').")");
 			$url_string .= "&mailingstate=".$mailingstate;
 	}
 	if(isset($mailingzip) && $mailingzip != "") {
-			array_push($where_clauses, "(contactaddress.mailingzip like ".PearDatabase::quote($mailingzip.'%')." OR contactaddress.otherzip like ".PearDatabase::quote($mailingzip.'%').")");
+			array_push($where_clauses, "(contactaddress.mailingzip ".$adb->getLike()." ".PearDatabase::quote($mailingzip.'%')." OR contactaddress.otherzip ".$adb->getLike()." ".PearDatabase::quote($mailingzip.'%').")");
 			$url_string .= "&mailingzip=".$mailingzip;
 	}
 	if(isset($mailingcountry) && $mailingcountry != "") {
-			array_push($where_clauses, "(contactaddress.mailingcountry like ".PearDatabase::quote($mailingcountry.'%')." OR contactaddress.othercountry like ".PearDatabase::quote($mailingcountry.'%').")");
+			array_push($where_clauses, "(contactaddress.mailingcountry ".$adb->getLike()." ".PearDatabase::quote($mailingcountry.'%')." OR contactaddress.othercountry ".$adb->getLike()." ".PearDatabase::quote($mailingcountry.'%').")");
 			$url_string .= "&mailingcountry=".$mailingcountry;
 	}
 	if(isset($current_user_only) && $current_user_only != "") {

Modified: vtigercrm/branches/4.2/modules/Contacts/Popup.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Contacts/Popup.php (original)
+++ vtigercrm/branches/4.2/modules/Contacts/Popup.php Mon Apr 24 16:29:46 2006
@@ -86,15 +86,15 @@
 	$where_clauses = Array();
 
 	if(isset($lastname) && $lastname != "") {
-			array_push($where_clauses, "contactdetails.lastname like ".PearDatabase::quote($lastname.'%')."");
+			array_push($where_clauses, "contactdetails.lastname ".$adb->getLike()." ".PearDatabase::quote($lastname.'%')."");
 			$url_string .= "&lastname=".$lastname;
 	}
 	if(isset($firstname) && $firstname != "") {
-			array_push($where_clauses, "contactdetails.firstname like ".PearDatabase::quote($firstname.'%')."");
+			array_push($where_clauses, "contactdetails.firstname ".$adb->getLike()." ".PearDatabase::quote($firstname.'%')."");
 			$url_string .= "&firstname=".$firstname;
 	}
 	if(isset($title) && $title != "")	{
-			array_push($where_clauses, "contactdetails.title like ".PearDatabase::quote("%".$title.'%')."");
+			array_push($where_clauses, "contactdetails.title ".$adb->getLike()." ".PearDatabase::quote("%".$title.'%')."");
 			$url_string .= "&title=".$title;
 	}
 	if(isset($current_user_only) && $current_user_only != "") {

Modified: vtigercrm/branches/4.2/modules/Contacts/SaveBusinessCard.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Contacts/SaveBusinessCard.php (original)
+++ vtigercrm/branches/4.2/modules/Contacts/SaveBusinessCard.php Mon Apr 24 16:29:46 2006
@@ -59,7 +59,7 @@
 $contactnotesdescription = $_POST['ContactNotesdescription'];
 
 
-$date_var = date('YmdHis');
+$date_var = $adb->formatDate(date('YmdHis'));
 
 if(($acctname != '') && ($lastname != ''))
 {
@@ -67,7 +67,7 @@
 
   $account_id = $adb->getUniqueID("crmentity");
   $idholderaccount = $account_id;
-  $sql = "insert into crmentity (crmid,smcreatorid,smownerid,modifiedby,setype,description,createdtime,modifiedtime,viewedtime,presence,deleted) values(".$account_id.",".$current_user->id.",".$current_user->id.",".$current_user->id.",'Accounts','created from business card','".$date_var."','".$date_var."','".$date_var."',0,0".")";
+  $sql = "insert into crmentity (crmid,smcreatorid,smownerid,modifiedby,setype,description,createdtime,modifiedtime,viewedtime,presence,deleted) values(".$account_id.",".$current_user->id.",".$current_user->id.",".$current_user->id.",'Accounts','created from business card',".$date_var.",".$date_var.",".$date_var.",0,0".")";
   $adb->query($sql);
  
   $sql_insertacct = "insert into account(accountid,accountname,phone,website) values(".$account_id.",'".$acctname."','".$acctphone."','".$acctwebsite ."')";
@@ -84,7 +84,7 @@
   {
    
     $accountnote_id = $adb->getUniqueID("crmentity");
-    $sql = "insert into crmentity (crmid,smcreatorid,smownerid,modifiedby,setype,description,createdtime,modifiedtime,viewedtime,presence,deleted) values(".$accountnote_id.",".$current_user->id.",".$current_user->id.",".$current_user->id.",'notes','created from business card','".$date_var."','".$date_var."','".$date_var."',0,0".")";
+    $sql = "insert into crmentity (crmid,smcreatorid,smownerid,modifiedby,setype,description,createdtime,modifiedtime,viewedtime,presence,deleted) values(".$accountnote_id.",".$current_user->id.",".$current_user->id.",".$current_user->id.",'notes','created from business card',".$date_var.",".$date_var.",".$date_var.",0,0".")";
     $adb->query($sql);
  
     $sql_insertnote = "insert into notes(notesid,title,notecontent) values(".$accountnote_id.",'".$acctnotesname."','".$acctnotesdescription ."')";
@@ -102,7 +102,7 @@
 
   $contact_id = $adb->getUniqueID("crmentity");
   $idholdercontact = $contact_id;
-  $sql = "insert into crmentity (crmid,smcreatorid,smownerid,modifiedby,setype,description,createdtime,modifiedtime,viewedtime,presence,deleted) values(".$contact_id.",".$current_user->id.",".$current_user->id.",".$current_user->id.",'Contacts','created from business card','".$date_var."','".$date_var."','".$date_var."',0,0".")";
+  $sql = "insert into crmentity (crmid,smcreatorid,smownerid,modifiedby,setype,description,createdtime,modifiedtime,viewedtime,presence,deleted) values(".$contact_id.",".$current_user->id.",".$current_user->id.",".$current_user->id.",'Contacts','created from business card',".$date_var.",".$date_var.",".$date_var.",0,0".")";
   $adb->query($sql);
  
  
@@ -113,7 +113,7 @@
 
   $adb->query("insert into contactaddress (contactaddressid, mailingstreet, otherstreet, mailingcity, othercity, mailingstate, otherstate, mailingzip, otherzip, mailingcountry, othercountry) values(".$contact_id.", '', '', '".$mailingcity."', '', '".$mailingstate."', '', '".$mailingcode."', '', '".$mailingcountry."', '')");
 
-  $adb->query("insert into contactsubdetails (contactsubscriptionid, homephone, leadsource, otherphone, birthday, assistant, assistantphone) values(".$contact_id.", '', '--None--', '', '', '', '')");
+  $adb->query("insert into contactsubdetails (contactsubscriptionid, leadsource) values(".$contact_id.", '--None--')");
 
   $adb->query("insert into contactscf (contactid) values(".$contact_id.")");
 
@@ -121,7 +121,7 @@
   {
    
     $contactnote_id = $adb->getUniqueID("crmentity");
-    $sql = "insert into crmentity (crmid,smcreatorid,smownerid,modifiedby,setype,description,createdtime,modifiedtime,viewedtime,presence,deleted) values(".$contactnote_id.",".$current_user->id.",".$current_user->id.",".$current_user->id.",'notes','created from business card','".$date_var."','".$date_var."','".$date_var."',0,0".")";
+    $sql = "insert into crmentity (crmid,smcreatorid,smownerid,modifiedby,setype,description,createdtime,modifiedtime,viewedtime,presence,deleted) values(".$contactnote_id.",".$current_user->id.",".$current_user->id.",".$current_user->id.",'notes','created from business card',".$date_var.",".$date_var.",".$date_var.",0,0".")";
     $adb->query($sql);
  
     $sql_insertnote = "insert into notes(notesid,contact_id,title,notecontent) values(".$contactnote_id.",".$contact_id.",'".$contactnotesname."','".$contactnotesdescription ."')";
@@ -230,7 +230,7 @@
     $id = $adb->getUniqueID("crmentity");
     $type = $_POST['appointment'];
     
-    $sql= "insert into crmentity (crmid,smcreatorid,smownerid,modifiedby,setype,description,createdtime,modifiedtime,viewedtime,presence,deleted) values(".$id.",".$current_user->id.",".$current_user->id.",".$current_user->id.",'Activities','created from business card','".$date_var."','".$date_var."','".$date_var."',0,0".")";
+    $sql= "insert into crmentity (crmid,smcreatorid,smownerid,modifiedby,setype,description,createdtime,modifiedtime,viewedtime,presence,deleted) values(".$id.",".$current_user->id.",".$current_user->id.",".$current_user->id.",'Activities','created from business card',".$date_var.",".$date_var.",".$date_var.",0,0".")";
     
     $adb->query($sql);
 

Modified: vtigercrm/branches/4.2/modules/CustomView/CustomView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/CustomView/CustomView.php (original)
+++ vtigercrm/branches/4.2/modules/CustomView/CustomView.php Mon Apr 24 16:29:46 2006
@@ -795,6 +795,7 @@
 
 	function getAdvComparator($comparator,$value)
 	{
+		global $adb;
 /*		fLabels['e'] = 'equals';
 		fLabels['n'] = 'not equal to';
 		fLabels['s'] = 'starts with';
@@ -828,15 +829,15 @@
 		}
 		if($comparator == "s")
 		{
-			$rtvalue = " like ".PearDatabase::quote($value."%");
+			$rtvalue = " ".$adb->getLike()." ".PearDatabase::quote($value."%");
 		}
 		if($comparator == "c")
 		{
-			$rtvalue = " like ".PearDatabase::quote("%".$value."%");
+			$rtvalue = " ".$adb->getLike()." ".PearDatabase::quote("%".$value."%");
 		}
 		if($comparator == "k")
 		{
-			$rtvalue = " not like ".PearDatabase::quote("%".$value."%");
+			$rtvalue = " not ".$adb->getLike()." ".PearDatabase::quote("%".$value."%");
 		}
 		if($comparator == "l")
 		{
@@ -1104,7 +1105,7 @@
                 {
                         $listviewquery = substr($listquery, strpos($listquery,'from'),strlen($listquery));
 
-                        $query = "select count(*) count ".$listviewquery;
+                        $query = "select count(*) as count ".$listviewquery;
                         
 			$stdfiltersql = $this->getCVStdFilterSQL($viewid);
                         $advfiltersql = $this->getCVAdvFilterSQL($viewid);

Modified: vtigercrm/branches/4.2/modules/CustomView/Save.php
==============================================================================
--- vtigercrm/branches/4.2/modules/CustomView/Save.php (original)
+++ vtigercrm/branches/4.2/modules/CustomView/Save.php Mon Apr 24 16:29:46 2006
@@ -122,8 +122,10 @@
 			    $stdfiltersql = "insert into cvstdfilter(cvid,columnname,stdfilter,startdate,enddate)";
 			    $stdfiltersql .= " values (".$genCVid.",'".$std_filter_list["columnname"]."',";
 			    $stdfiltersql .= "'".$std_filter_list["stdfilter"]."',";
-			    $stdfiltersql .= "'".$std_filter_list["startdate"]."',";
-			    $stdfiltersql .= "'".$std_filter_list["enddate"]."')";
+			    if($std_filter_list["startdate"]) $stdfiltersql .= "'".$std_filter_list["startdate"]."',";
+			    else $stdfiltersql .= "null,";
+			    if($std_filter_list["enddate"]) $stdfiltersql .= "'".$std_filter_list["enddate"]."')";
+			    else $stdfiltersql .= "null)";
 			    //echo $stdfiltersql;
 			    $stdfilterresult = $adb->query($stdfiltersql);
 			    $vtlog->logthis("CustomView :: Save :: cvstdfilter created successfully","info");

Modified: vtigercrm/branches/4.2/modules/Emails/Email.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Emails/Email.php (original)
+++ vtigercrm/branches/4.2/modules/Emails/Email.php Mon Apr 24 16:29:46 2006
@@ -139,9 +139,9 @@
   }
   function get_attachments($id)
   {
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename, attachments.type  FileType,crm2.modifiedtime  lastmodified, seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid 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 where crmentity.crmid=".$id;
+		$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 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 where 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 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 where crmentity.crmid=".$id;
+                $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 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 where crmentity.crmid=".$id;
 
     renderRelatedAttachments($query,$id);
   }

Modified: vtigercrm/branches/4.2/modules/Emails/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Emails/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Emails/ListView.php Mon Apr 24 16:29:46 2006
@@ -64,7 +64,7 @@
 				$listView = $filename;
 				$classname = "tabOff";
 			}
-			elseif(stristr($label,$_REQUEST['smodule']))
+			elseif($_REQUEST['smodule'] && stristr($label,$_REQUEST['smodule']))
 			{
 				echo '<td class="tabOn" nowrap><a href="index.php?module=squirrelmail-1.4.4&action=redirect&smodule='.$_REQUEST['smodule'].'" class="tabLink">'.$mod_strings[$label].'</a></td>';	
 				$listView = $filename;
@@ -218,19 +218,19 @@
 	}
 	if(isset($name) && $name != '')
 	{
-		array_push($where_clauses, "activity.subject like ".PearDatabase::quote($name.'%')."");
+		array_push($where_clauses, "activity.subject ".$adb->getLike()." ".PearDatabase::quote($name.'%')."");
 		$url_string .= "&subject=".$name;
 
 	}
 	if(isset($contactname) && $contactname != '')
 	{
-		array_push($where_clauses, "(contactdetails.firstname like ".PearDatabase::quote($contactname.'%')." OR contactdetails.lastname like ".PearDatabase::quote($contactname.'%').")");
+		array_push($where_clauses, "(contactdetails.firstname ".$adb->getLike()." ".PearDatabase::quote($contactname.'%')." OR contactdetails.lastname ".$adb->getLike()." ".PearDatabase::quote($contactname.'%').")");
 		$url_string .= "&contactname=".$contactname;
 
 	}
 	if(isset($date_start) && $date_start != '')
 	{
-		array_push($where_clauses, "events.eventdatestart like ".PearDatabase::quote($date_start.'%')."");
+		array_push($where_clauses, "events.eventdatestart ".$adb->getLike()." ".PearDatabase::quote($date_start.'%')."");
 	}
 	if(isset($location) && $location != '')
 	{

Modified: vtigercrm/branches/4.2/modules/Faq/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Faq/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Faq/ListView.php Mon Apr 24 16:29:46 2006
@@ -65,14 +65,14 @@
 
 	if(isset($question) && $question != "")
 	{
-		array_push($where_clauses, "faq.question like '%".$question."%'");
+		array_push($where_clauses, "faq.question ".$adb->getLike()." '%".$question."%'");
 		$url_string .= "&question=".$question;
 		$search_form->assign("QUESTION", $question);
 
 	}
 	if(isset($faqcategories) && $faqcategories != "")
 	{
-		array_push($where_clauses, "faq.category like '%".$faqcategories."%'"); 
+		array_push($where_clauses, "faq.category ".$adb->getLike()." '%".$faqcategories."%'"); 
 		$url_string .= "&faqcategories=".$faqcategories;
 		$search_form->assign("FAQCATEGORIES", $faqcategories);
 

Modified: vtigercrm/branches/4.2/modules/HelpDesk/FaqList.php
==============================================================================
--- vtigercrm/branches/4.2/modules/HelpDesk/FaqList.php (original)
+++ vtigercrm/branches/4.2/modules/HelpDesk/FaqList.php Mon Apr 24 16:29:46 2006
@@ -41,14 +41,14 @@
 
 	if (isset($category) && $category !='')
 	{
-	 	$search_query .= " and faq.category like '".$category."%'";
+	 	$search_query .= " and faq.category ".$adb->getLike()." '".$category."%'";
 		$query_val .= "&category=".$category;
 		$xtpl->assign("CATEGORY", $category);
 	}
 
 	if (isset($question) && $question !='')
 	{
-		$search_query .= " and faq.question like '".$question."%'";
+		$search_query .= " and faq.question ".$adb->getLike()." '".$question."%'";
 		$query_val .= "&question=".$question;
 		$xtpl->assign("QUESTION", $question);
 	}
@@ -58,12 +58,12 @@
 		$date_criteria = $_REQUEST['date_crit'];
 		if($date_criteria == 'is')
 		{ 
-	 		$search_query .= " and faq.date_created like '".$date."%'";
+	 		$search_query .= " and faq.date_created ".$adb->getLike()." '".$date."%'";
 			$xtpl->assign("IS", 'selected');
 		}
 		if($date_criteria == 'isnot')
 		{ 
-	 		$search_query .= " and faq.date_created not like '".$date."%'";
+	 		$search_query .= " and faq.date_created not ".$adb->getLike()." '".$date."%'";
 			$xtpl->assign("ISNOT", 'selected');
 		}
 		if($date_criteria == 'before')

Modified: vtigercrm/branches/4.2/modules/HelpDesk/HelpDesk.php
==============================================================================
--- vtigercrm/branches/4.2/modules/HelpDesk/HelpDesk.php (original)
+++ vtigercrm/branches/4.2/modules/HelpDesk/HelpDesk.php Mon Apr 24 16:29:46 2006
@@ -85,9 +85,9 @@
 	function get_attachments($id)
 	{
 		//Done for Merge -- Don
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename, attachments.type  FileType,crm2.modifiedtime  lastmodified, seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid 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 where crmentity.crmid=".$id;
+		$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 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 where 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 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 where crmentity.crmid=".$id;	
+                $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 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 where crmentity.crmid=".$id;	
 		renderRelatedAttachments($query,$id);	
 	}
 

Modified: vtigercrm/branches/4.2/modules/HelpDesk/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/HelpDesk/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/HelpDesk/ListView.php Mon Apr 24 16:29:46 2006
@@ -81,7 +81,7 @@
 			if($uitype[$i] == 56)
 				$str=" ticketcf.".$column[$i]." = 1";
 			else
-		                $str=" ticketcf.".$column[$i]." like '$customfield[$i]%'";
+		                $str=" ticketcf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
 	                array_push($where_clauses, $str);
 			$url_string .="&".$column[$i]."=".$customfield[$i];
 	        }
@@ -92,14 +92,14 @@
 	if(isset($name) && $name != "")
 	{
 		if($_REQUEST['button'] == 'Search')
-			array_push($where_clauses, "troubletickets.title like '%".$name."%'");
+			array_push($where_clauses, "troubletickets.title ".$adb->getLike()." '%".$name."%'");
 		else
-			array_push($where_clauses, "troubletickets.title like '".$name."%'");
+			array_push($where_clauses, "troubletickets.title ".$adb->getLike()." '".$name."%'");
 		$url_string .= "&ticket_title=".$name;
 	}
 	if(isset($contact_name) && $contact_name != "")
 	{
-		array_push($where_clauses, "(contactdetails.firstname like".PearDatabase::quote($contact_name.'%')." OR contactdetails.lastname like ".PearDatabase::quote($contact_name.'%').")");
+		array_push($where_clauses, "(contactdetails.firstname ".$adb->getLike()."".PearDatabase::quote($contact_name.'%')." OR contactdetails.lastname ".$adb->getLike()." ".PearDatabase::quote($contact_name.'%').")");
 		$url_string .= "&contact_name=".$contact_name;
 
 	}
@@ -124,11 +124,11 @@
 		$format_date = getDBInsertDateValue($date);
 		if($date_criteria == 'is')
 		{
-			array_push($where_clauses, "crmentity.createdtime like '%".$format_date."%'");
+			array_push($where_clauses, "crmentity.createdtime ".$adb->getLike()." '%".$format_date."%'");
 		}
 		if($date_criteria == 'isnot')
 		{
-			array_push($where_clauses, "crmentity.createdtime not like '".$format_date."%'");
+			array_push($where_clauses, "crmentity.createdtime not ".$adb->getLike()." '".$format_date."%'");
 		}
 		if($date_criteria == 'before')
 		{
@@ -358,7 +358,7 @@
            $defaultcv_criteria = $_REQUEST['viewname'];
        }
 
-  	$list_query .= " and priority like "."'%" .$defaultcv_criteria ."%'";
+  	$list_query .= " and priority ".$adb->getLike()." "."'%" .$defaultcv_criteria ."%'";
 	$viewname = $_REQUEST['viewname'];
   	$view_script = "<script language='javascript'>
 		function set_selected()

Modified: vtigercrm/branches/4.2/modules/Home/UnifiedSearch.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Home/UnifiedSearch.php (original)
+++ vtigercrm/branches/4.2/modules/Home/UnifiedSearch.php Mon Apr 24 16:29:46 2006
@@ -29,13 +29,14 @@
 global $mod_strings;
 
 function build_account_where_clause ($the_query_string) {
+	global $adb;
 	$where_clauses = Array();
 
-	array_push($where_clauses, "accountname like '$the_query_string%'");
+	array_push($where_clauses, "accountname ".$adb->getLike()." '$the_query_string%'");
 	if (is_numeric($the_query_string)) {
-		array_push($where_clauses, "otherphone like '%$the_query_string%'");
-		array_push($where_clauses, "fax like '%$the_query_string%'");
-		array_push($where_clauses, "phone like '%$the_query_string%'");
+		array_push($where_clauses, "otherphone ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "fax ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "phone ".$adb->getLike()." '%$the_query_string%'");
 	}
 	
 	$the_where = "";
@@ -51,18 +52,19 @@
 }
 
 function build_contact_where_clause ($the_query_string) {
+	global $adb;
 	$where_clauses = Array();
 
-	array_push($where_clauses, "lastname like '$the_query_string%'");
-	array_push($where_clauses, "firstname like '$the_query_string%'");
-	array_push($where_clauses, "contactsubdetails.assistant like '$the_query_string%'");
+	array_push($where_clauses, "lastname ".$adb->getLike()." '$the_query_string%'");
+	array_push($where_clauses, "firstname ".$adb->getLike()." '$the_query_string%'");
+	array_push($where_clauses, "contactsubdetails.assistant ".$adb->getLike()." '$the_query_string%'");
 	if (is_numeric($the_query_string)) {
-		array_push($where_clauses, "phone like '%$the_query_string%'");
-		array_push($where_clauses, "mobile like '%$the_query_string%'");
-		array_push($where_clauses, "homephone like '%$the_query_string%'");
-		array_push($where_clauses, "otherphone like '%$the_query_string%'");
-		array_push($where_clauses, "phone_fax like '%$the_query_string%'");
-		array_push($where_clauses, "assistant_phone like '%$the_query_string%'");
+		array_push($where_clauses, "phone ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "mobile ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "homephone ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "otherphone ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "phone_fax ".$adb->getLike()." '%$the_query_string%'");
+		array_push($where_clauses, "assistant_phone ".$adb->getLike()." '%$the_query_string%'");
 	}
 	
 	$the_where = "";
@@ -78,9 +80,10 @@
 }
 
 function build_opportunity_where_clause ($the_query_string) {
+	global $adb;
 	$where_clauses = Array();
 
-	array_push($where_clauses, "potentialname like '$the_query_string%'");
+	array_push($where_clauses, "potentialname ".$adb->getLike()." '$the_query_string%'");
 
 	$the_where = "";
 	foreach($where_clauses as $clause)
@@ -95,10 +98,11 @@
 }
 /*
 function build_case_where_clause ($the_query_string) {
+	global $adb;
 	$where_clauses = Array();
 
-	array_push($where_clauses, "cases.name like '$the_query_string%'");
-	if (is_numeric($the_query_string)) array_push($where_clauses, "cases.number like '$the_query_string%'");
+	array_push($where_clauses, "cases.name ".$adb->getLike()." '$the_query_string%'");
+	if (is_numeric($the_query_string)) array_push($where_clauses, "cases.number ".$adb->getLike()." '$the_query_string%'");
 
 	$the_where = "";
 	foreach($where_clauses as $clause)

Modified: vtigercrm/branches/4.2/modules/Import/UsersLastImport.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Import/UsersLastImport.php (original)
+++ vtigercrm/branches/4.2/modules/Import/UsersLastImport.php Mon Apr 24 16:29:46 2006
@@ -173,7 +173,7 @@
 				AND accounts.deleted=0
 				AND users.status='ACTIVE'";*/
 				$query = "SELECT distinct account.*, accountbillads.city,
-                                users.user_name assigned_user_name,
+                                users.user_name AS assigned_user_name,
 				crmid, smownerid 
 				FROM account
 				inner join crmentity on crmentity.crmid=account.accountid
@@ -215,9 +215,9 @@
 				AND users.status='ACTIVE'";*/
 
 			$query = "SELECT distinct
-                                account.accountid account_id,
-                                account.accountname account_name,
-                                users.user_name assigned_user_name,
+                                account.accountid AS account_id,
+                                account.accountname AS account_name,
+                                users.user_name AS assigned_user_name,
 				crmentity.crmid, smownerid,
 				potential.*
                                FROM potential 
@@ -236,7 +236,7 @@
 		else if($this->bean_type == 'Leads')
 		{
 			$query = "SELECT distinct leaddetails.*, crmentity.crmid, leadaddress.phone,leadsubdetails.website,
-                                users.user_name assigned_user_name,
+                                users.user_name AS assigned_user_name,
 				smownerid 
 				FROM leaddetails 
 				inner join crmentity on crmentity.crmid=leaddetails.leadid 

Modified: vtigercrm/branches/4.2/modules/Invoice/Invoice.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Invoice/Invoice.php (original)
+++ vtigercrm/branches/4.2/modules/Invoice/Invoice.php Mon Apr 24 16:29:46 2006
@@ -166,7 +166,7 @@
 	}
 	function get_activities($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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and ( activity.status is NULL || activity.status != 'Completed' ) and (  activity.eventstatus is NULL ||  activity.eventstatus != 'Held')";
+		$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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and ( activity.status is NULL OR activity.status != 'Completed' ) and (  activity.eventstatus is NULL OR  activity.eventstatus != 'Held')";
 		renderRelatedActivities($query,$id);
 	}
 	function get_history($id)
@@ -176,9 +176,9 @@
 	}
 	function get_attachments($id)
 	{
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename, attachments.type  FileType,crm2.modifiedtime  lastmodified, seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid 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 where crmentity.crmid=".$id;
+		$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 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 where 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 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 where crmentity.crmid=".$id;
+		$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 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 where crmentity.crmid=".$id;
 		renderRelatedAttachments($query,$id);
 	}
 

Modified: vtigercrm/branches/4.2/modules/Invoice/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Invoice/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Invoice/ListView.php Mon Apr 24 16:29:46 2006
@@ -78,7 +78,7 @@
 		if($uitype[$i] == 56)
 			$str=" invoicecf.".$column[$i]." = 1";
 		else
-	                $str=" invoicecf.".$column[$i]." like '$customfield[$i]%'";
+	                $str=" invoicecf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
                 array_push($where_clauses, $str);
 		$url_string .="&".$column[$i]."=".$customfield[$i];
         }
@@ -87,12 +87,12 @@
 	
 	if(isset($subject) && $subject != "") 
 	{
-		array_push($where_clauses, "invoice.subject like ".PearDatabase::quote($subject."%"));
+		array_push($where_clauses, "invoice.subject ".$adb->getLike()." ".PearDatabase::quote($subject."%"));
 		$url_string .= "&subject=".$subject;
 	}
 	if(isset($salesorder) && $salesorder != "")
 	{
-		array_push($where_clauses, "salesorder.subject like ".PearDatabase::quote("%".$salesorder."%"));
+		array_push($where_clauses, "salesorder.subject ".$adb->getLike()." ".PearDatabase::quote("%".$salesorder."%"));
 		$url_string .= "&salesorder=".$salesorder;
 	}
 	

Modified: vtigercrm/branches/4.2/modules/Leads/Lead.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Leads/Lead.php (original)
+++ vtigercrm/branches/4.2/modules/Leads/Lead.php Mon Apr 24 16:29:46 2006
@@ -211,7 +211,7 @@
 		{
           
   $query = $this->constructCustomQueryAddendum() . ", 
-			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
+			leaddetails.*, ".$this->entity_table.".*, leadsubdetails.*,leadaddress.city AS city, leadaddress.state AS state,leadaddress.code AS code,leadaddress.country AS country, leadaddress.phone AS phone, users.user_name, users.status AS user_status
                         FROM ".$this->entity_table."
                         INNER JOIN leaddetails
                         ON crmentity.crmid=leaddetails.leadid
@@ -228,7 +228,7 @@
 		else
 		{
                   $query = "SELECT 
-			leaddetails.*, ".$this->entity_table.".*, leadsubdetails.*,leadaddress.*,users.user_name, users.status user_status FROM ".$this->entity_table."
+			leaddetails.*, ".$this->entity_table.".*, leadsubdetails.*,leadaddress.*,users.user_name, users.status AS user_status FROM ".$this->entity_table."
                         INNER JOIN leaddetails
                         ON crmentity.crmid=leaddetails.leadid
                         LEFT JOIN leadsubdetails
@@ -260,7 +260,7 @@
 	function get_activities($id)
 	{
           // 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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') AND ( activity.status is NULL || activity.status != 'Completed' ) and (  activity.eventstatus is NULL ||  activity.eventstatus != 'Held')";
+	    $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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') AND ( activity.status is NULL or activity.status != 'Completed' ) and (  activity.eventstatus is NULL or  activity.eventstatus != 'Held')";
           //include('modules/Leads/RenderRelatedListUI.php');
           renderRelatedTasks($query,$id);
         }
@@ -309,9 +309,9 @@
 
   function get_attachments($id)
   {
-		$query = "select notes.title,'Notes      ' ActivityType, notes.filename, attachments.type  FileType,crm2.modifiedtime lastmodified, seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid 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 where crmentity.crmid=".$id;
+		$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 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 where 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 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 where crmentity.crmid=".$id;
+                $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 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 where crmentity.crmid=".$id;
 
     renderRelatedAttachments($query,$id);
   }

Modified: vtigercrm/branches/4.2/modules/Leads/LeadConvertToEntities.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Leads/LeadConvertToEntities.php (original)
+++ vtigercrm/branches/4.2/modules/Leads/LeadConvertToEntities.php Mon Apr 24 16:29:46 2006
@@ -279,7 +279,7 @@
 $adb->query($sql_insert_contact);
 
 
-$sql_insert_contactsubdetails = "INSERT INTO contactsubdetails (contactsubscriptionid,homephone,otherphone,leadsource) VALUES (".$contact_id.",'','','".$adb->quote($row['leadsource'])."')";
+$sql_insert_contactsubdetails = "INSERT INTO contactsubdetails (contactsubscriptionid,homephone,otherphone,leadsource) VALUES (".$contact_id.",'','',".$adb->quote($row['leadsource']).")";
 
 $adb->query($sql_insert_contactsubdetails);
 

Modified: vtigercrm/branches/4.2/modules/Leads/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Leads/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Leads/ListView.php Mon Apr 24 16:29:46 2006
@@ -97,7 +97,7 @@
 		if($uitype[$i] == 56)
 			$str=" leadscf.".$column[$i]." = 1";
 		else
-	                $str=" leadscf.".$column[$i]." like '$customfield[$i]%'";
+	                $str=" leadscf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
                 array_push($where_clauses, $str);
 		$url_string .="&".$column[$i]."=".$customfield[$i];
         }
@@ -106,15 +106,15 @@
 
 
 	if(isset($lastname) && $lastname != ""){
-		array_push($where_clauses, "leaddetails.lastname like '$lastname%'");
+		array_push($where_clauses, "leaddetails.lastname ".$adb->getLike()." '$lastname%'");
 		$url_string .= "&lastname=".$lastname;
 	}
 	if(isset($firstname) && $firstname != ""){
-	 	array_push($where_clauses, "leaddetails.firstname like '$firstname%'");
+	 	array_push($where_clauses, "leaddetails.firstname ".$adb->getLike()." '$firstname%'");
 		$url_string .= "&firstname=".$firstname;
 	}
 	if(isset($company) && $company != ""){
-		array_push($where_clauses, "leaddetails.company like '$company%'");
+		array_push($where_clauses, "leaddetails.company ".$adb->getLike()." '$company%'");
 		$url_string .= "&company=".$company;
 	}
 	if(isset($leadsource) && $leadsource != ""){
@@ -126,19 +126,19 @@
 		$url_string .= "&industry=".$industry;
 	}
 	if(isset($phone) && $phone != ""){
-		array_push($where_clauses, "leadaddress.phone like '%$phone%'");
+		array_push($where_clauses, "leadaddress.phone ".$adb->getLike()." '%$phone%'");
 		$url_string .= "&phone=".$phone;
 	}
 	if(isset($fax) && $fax != ""){
-		array_push($where_clauses, "leadaddress.fax like '%$fax%'");
+		array_push($where_clauses, "leadaddress.fax ".$adb->getLike()." '%$fax%'");
 		$url_string .= "&fax=".$fax;
 	}
 	if(isset($email) && $email != ""){
-		array_push($where_clauses, "leaddetails.email like '$email%'");
+		array_push($where_clauses, "leaddetails.email ".$adb->getLike()." '$email%'");
 		$url_string .= "&email=".$email;
 	}
 	if(isset($mobile) && $mobile != ""){
-		array_push($where_clauses, "leadaddress.mobile like '%$mobile%'");
+		array_push($where_clauses, "leadaddress.mobile ".$adb->getLike()." '%$mobile%'");
 		$url_string .= "&mobile=".$mobile;
 	}
 	if(isset($leadstatus) && $leadstatus != ""){
@@ -150,23 +150,23 @@
 		$url_string .= "&rating=".$rating;
 	}
 	if(isset($address_street) && $address_street != ""){
-		array_push($where_clauses, "leadaddress.lane like '$address_street%'");
+		array_push($where_clauses, "leadaddress.lane ".$adb->getLike()." '$address_street%'");
 		$url_string .= "&address_street=".$address_street;
 	}
 	if(isset($address_city) && $address_city != ""){
-		array_push($where_clauses, "leadaddress.city like '$address_city%'");
+		array_push($where_clauses, "leadaddress.city ".$adb->getLike()." '$address_city%'");
 		$url_string .= "&address_city=".$address_city;
 	}
 	if(isset($address_state) && $address_state != ""){
-		array_push($where_clauses, "leadaddress.state like '$address_state%'");
+		array_push($where_clauses, "leadaddress.state ".$adb->getLike()." '$address_state%'");
 		$url_string .= "&address_state=".$address_state;
 	}
 	if(isset($address_postalcode) && $address_postalcode != ""){
-		array_push($where_clauses, "leadaddress.code like '$address_postalcode%'");
+		array_push($where_clauses, "leadaddress.code ".$adb->getLike()." '$address_postalcode%'");
 		$url_string .= "&address_postalcode=".$address_postalcode;
 	}
 	if(isset($address_country) && $address_country != ""){
-		array_push($where_clauses, "leadaddress.country like '$address_country%'");
+		array_push($where_clauses, "leadaddress.country ".$adb->getLike()." '$address_country%'");
 		$url_string .= "&address_country=".$address_country;
 	}
 	if(isset($current_user_only) && $current_user_only != ""){

Modified: vtigercrm/branches/4.2/modules/Leads/Popup.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Leads/Popup.php (original)
+++ vtigercrm/branches/4.2/modules/Leads/Popup.php Mon Apr 24 16:29:46 2006
@@ -75,15 +75,15 @@
 	$where_clauses = Array();
 
 	if(isset($last_name) && $last_name != ""){
-		array_push($where_clauses, "leaddetails.lastname like '$last_name%'");
+		array_push($where_clauses, "leaddetails.lastname ".$adb->getLike()." '$last_name%'");
 		$url_string .= "&last_name=".$last_name;
 	}
 	if(isset($first_name) && $first_name != ""){
-		array_push($where_clauses, "leaddetails.firstname like '%$first_name%'");
+		array_push($where_clauses, "leaddetails.firstname ".$adb->getLike()." '%$first_name%'");
 		$url_string .= "&first_name=".$first_name;
 	}
 	if(isset($company) && $company != ""){
-		array_push($where_clauses, "leaddetails.company like '%$company%'");
+		array_push($where_clauses, "leaddetails.company ".$adb->getLike()." '%$company%'");
 		$url_string .= "&company=".$company;
 	}
 	if(isset($current_user_only) && $current_user_only != ""){

Modified: vtigercrm/branches/4.2/modules/Meetings/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Meetings/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Meetings/ListView.php Mon Apr 24 16:29:46 2006
@@ -81,18 +81,18 @@
 	if(isset($current_user_only) && $current_user_only != "") array_push($where_clauses, "meetings.assigned_user_id='$current_user->id'");
 	if(isset($name) && $name != '')
 	{
-		array_push($where_clauses, "meetings.name like '".PearDatabase::quote($name)."%'");
+		array_push($where_clauses, "meetings.name ".$adb->getLike()." '".PearDatabase::quote($name)."%'");
 	}
 	if(isset($contact_name) && $contact_name != '')
 	{
 		$contact_names = explode(" ", $contact_name);
 		foreach ($contact_names as $name) {
-			array_push($where_clauses, "(contacts.first_name like '".PearDatabase::quote($name)."%' OR contacts.last_name like '".PearDatabase::quote($name)."%')");
+			array_push($where_clauses, "(contacts.first_name ".$adb->getLike()." '".PearDatabase::quote($name)."%' OR contacts.last_name ".$adb->getLike()." '".PearDatabase::quote($name)."%')");
 		}
 	}
 	if(isset($date_start) && $date_start != '')
 	{
-		array_push($where_clauses, "meetings.date_start like '".PearDatabase::quote($date_start)."%'");
+		array_push($where_clauses, "meetings.date_start ".$adb->getLike()." '".PearDatabase::quote($date_start)."%'");
 	}
 	if(isset($location) && $location != '')
 	{

Modified: vtigercrm/branches/4.2/modules/Notes/Delete.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Notes/Delete.php (original)
+++ vtigercrm/branches/4.2/modules/Notes/Delete.php Mon Apr 24 16:29:46 2006
@@ -32,8 +32,10 @@
 	$sql = 'update notes set contact_id = 0 where notesid = '.$_REQUEST['record'];
 	$adb->query($sql);
 }
-$sql = 'delete from senotesrel where notesid = '.$_REQUEST['record']. ' and crmid = '.$_REQUEST['return_id'];
-$adb->query($sql);
+if($_REQUEST['return_id']) {
+	$sql = 'delete from senotesrel where notesid = '.$_REQUEST['record']. ' and crmid = '.$_REQUEST['return_id'];
+	$adb->query($sql);
+}
 
 $sql_recentviewed ='delete from tracker where user_id = '.$current_user->id.' and item_id = '.$_REQUEST['record'];
 $adb->query($sql_recentviewed);

Modified: vtigercrm/branches/4.2/modules/Notes/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Notes/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Notes/ListView.php Mon Apr 24 16:29:46 2006
@@ -111,14 +111,14 @@
 
 	if(isset($name) && $name != '')
 	{
-		array_push($where_clauses, "notes.title like ".PearDatabase::quote($name.'%')."");
+		array_push($where_clauses, "notes.title ".$adb->getLike()." ".PearDatabase::quote($name.'%')."");
 		$url_string .= "&title=".$name;
 	}
 	if(isset($contact_name) && $contact_name != '')
 	{
 		$contact_names = explode(" ", $contact_name);
 		foreach ($contact_names as $name) {
-			array_push($where_clauses, "(contactdetails.firstname like ".PearDatabase::quote($name.'%')." OR contactdetails.lastname like ".PearDatabase::quote($name.'%').")");
+			array_push($where_clauses, "(contactdetails.firstname ".$adb->getLike()." ".PearDatabase::quote($name.'%')." OR contactdetails.lastname ".$adb->getLike()." ".PearDatabase::quote($name.'%').")");
 		}
 		$url_string .= "&contact_name=".$contact_name;
 	}
@@ -212,7 +212,9 @@
         $query .= ' and '.$where;
 }
 
-$query .= ' group by notes.notesid';
+if(!$adb->isPostgres()) {  // postgres wont group if all members of the select list aren't in the group by, use distinct on instead
+	$query .= ' group by notes.notesid';
+}
 
 if(isset($order_by) && $order_by != '')
 {

Modified: vtigercrm/branches/4.2/modules/Orders/DeleteSalesOrder.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Orders/DeleteSalesOrder.php (original)
+++ vtigercrm/branches/4.2/modules/Orders/DeleteSalesOrder.php Mon Apr 24 16:29:46 2006
@@ -37,17 +37,17 @@
 }
 elseif($_REQUEST['return_module'] == "Quotes")
 {
-	$relation_query = "UPDATE salesorder set quoteid='' where salesorderid=".$_REQUEST['record'];
+	$relation_query = "UPDATE salesorder set quoteid=null where salesorderid=".$_REQUEST['record'];
 	$adb->query($relation_query);
 }
 elseif($_REQUEST['return_module'] == "Potentials")
 {
-	$relation_query = "UPDATE salesorder set potentialid='' where salesorderid=".$_REQUEST['record'];
+	$relation_query = "UPDATE salesorder set potentialid=null where salesorderid=".$_REQUEST['record'];
 	$adb->query($relation_query);
 }
 elseif($_REQUEST['return_module'] == "Contacts")
 {
-	$relation_query = "UPDATE salesorder set contactid='' where salesorderid=".$_REQUEST['record'];
+	$relation_query = "UPDATE salesorder set contactid=null where salesorderid=".$_REQUEST['record'];
 	$adb->query($relation_query);
 }
 elseif($_REQUEST['return_module'] == "Products")

Modified: vtigercrm/branches/4.2/modules/Orders/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Orders/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Orders/ListView.php Mon Apr 24 16:29:46 2006
@@ -79,7 +79,7 @@
 		if($uitype[$i] == 56)
 			$str=" purchaseordercf.".$column[$i]." = 1";
 		else
-	                $str=" purchaseordercf.".$column[$i]." like '$customfield[$i]%'";
+	                $str=" purchaseordercf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
                 array_push($where_clauses, $str);
 		$url_string .="&".$column[$i]."=".$customfield[$i];
         }
@@ -88,17 +88,17 @@
 	
 	if(isset($subject) && $subject != "") 
 	{
-		array_push($where_clauses, "purchaseorder.subject like ".PearDatabase::quote($subject."%"));
+		array_push($where_clauses, "purchaseorder.subject ".$adb->getLike()." ".PearDatabase::quote($subject."%"));
 		$url_string .= "&subject=".$subject;
 	}
 	if(isset($vendorname) && $vendorname != "")
 	{
-		array_push($where_clauses, "vendor.vendorname like ".PearDatabase::quote("%".$vendorname."%"));
+		array_push($where_clauses, "vendor.vendorname ".$adb->getLike()." ".PearDatabase::quote("%".$vendorname."%"));
 		$url_string .= "&vendorname=".$vendorname;
 	}
 	if(isset($trackingno) && $trackingno != "")
 	{
-		array_push($where_clauses, "purchaseorder.tracking_no like ".PearDatabase::quote("%".$trackingno."%"));
+		array_push($where_clauses, "purchaseorder.tracking_no ".$adb->getLike()." ".PearDatabase::quote("%".$trackingno."%"));
 		$url_string .= "&trackingno=".$trackingno;
 	}
 	

Modified: vtigercrm/branches/4.2/modules/Orders/Order.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Orders/Order.php (original)
+++ vtigercrm/branches/4.2/modules/Orders/Order.php Mon Apr 24 16:29:46 2006
@@ -166,7 +166,7 @@
 	}
 	function get_activities($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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and ( activity.status is NULL || activity.status != 'Completed' ) and (  activity.eventstatus is NULL ||  activity.eventstatus != 'Held')";
+		$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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and ( activity.status is NULL OR activity.status != 'Completed' ) and (  activity.eventstatus is NULL OR  activity.eventstatus != 'Held')";
 		renderRelatedActivities($query,$id);
 	}
 	function get_history($id)
@@ -176,9 +176,9 @@
 	}
 	function get_attachments($id)
 	{
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename, attachments.type  FileType,crm2.modifiedtime  lastmodified, seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid 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 where crmentity.crmid=".$id;
+		$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 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 where 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 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 where crmentity.crmid=".$id;
+		$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 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 where crmentity.crmid=".$id;
 		renderRelatedAttachments($query,$id);
 	}
 

Modified: vtigercrm/branches/4.2/modules/Orders/PopupSalesOrder.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Orders/PopupSalesOrder.php (original)
+++ vtigercrm/branches/4.2/modules/Orders/PopupSalesOrder.php Mon Apr 24 16:29:46 2006
@@ -61,22 +61,22 @@
 
 	if (isset($subject) && $subject !='')
 	{
-		array_push($where_clauses, "salesorder.subject like ".PearDatabase::quote($subject.'%'));
-		//$search_query .= " and productname like '".$productname."%'";
+		array_push($where_clauses, "salesorder.subject ".$adb->getLike()." ".PearDatabase::quote($subject.'%'));
+		//$search_query .= " and productname ".$adb->getLike()." '".$productname."%'";
 		$url_string .= "&subject=".$subject;
 	}
 	
 	if (isset($accountname) && $accountname !='')
 	{
-		array_push($where_clauses, "account.accountname like ".PearDatabase::quote($accountname.'%'));
-		//$search_query .= " and productcode like '".$productcode."%'";
+		array_push($where_clauses, "account.accountname ".$adb->getLike()." ".PearDatabase::quote($accountname.'%'));
+		//$search_query .= " and productcode ".$adb->getLike()." '".$productcode."%'";
 		$url_string .= "&accountname=".$accountname;
 	}
 
 	if (isset($quotename) && $quotename !='')
 	{
-		array_push($where_clauses, "quotes.subject like ".PearDatabase::quote($quotename.'%'));
-		 //$search_query .= " and commissionrate like '".$commissionrate."%'";
+		array_push($where_clauses, "quotes.subject ".$adb->getLike()." ".PearDatabase::quote($quotename.'%'));
+		 //$search_query .= " and commissionrate ".$adb->getLike()." '".$commissionrate."%'";
 		 $url_string .= "&quotename=".$quotename;
 	}
 	

Modified: vtigercrm/branches/4.2/modules/Orders/SalesOrder.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Orders/SalesOrder.php (original)
+++ vtigercrm/branches/4.2/modules/Orders/SalesOrder.php Mon Apr 24 16:29:46 2006
@@ -172,7 +172,7 @@
 	}
 	function get_activities($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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and ( activity.status is NULL || activity.status != 'Completed' ) and (  activity.eventstatus is NULL ||  activity.eventstatus != 'Held')";
+		$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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and ( activity.status is NULL OR activity.status != 'Completed' ) and (  activity.eventstatus is NULL OR  activity.eventstatus != 'Held')";
 		renderSalesRelatedActivities($query,$id);
 	}
 	function get_history($id)
@@ -182,9 +182,9 @@
 	}
 	function get_attachments($id)
 	{
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename, attachments.type  FileType,crm2.modifiedtime  lastmodified, seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid 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 where crmentity.crmid=".$id;
+		$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 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 where 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 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 where crmentity.crmid=".$id;
+		$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 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 where crmentity.crmid=".$id;
 		renderRelatedAttachments($query,$id,$sid='salesorderid');
 	}
 	function get_invoices($id)

Modified: vtigercrm/branches/4.2/modules/Orders/SalesOrderListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Orders/SalesOrderListView.php (original)
+++ vtigercrm/branches/4.2/modules/Orders/SalesOrderListView.php Mon Apr 24 16:29:46 2006
@@ -77,7 +77,7 @@
 			if($uitype[$i] == 56)
                                 $str=" salesordercf.".$column[$i]." = 1";
                         else
-			        $str=" salesordercf.".$column[$i]." like '$customfield[$i]%'";
+			        $str=" salesordercf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
 		        array_push($where_clauses, $str);
 	       	//	  $search_query .= ' and '.$str;
 			$url_string .="&".$column[$i]."=".$customfield[$i];
@@ -87,22 +87,22 @@
 
 	if (isset($subject) && $subject !='')
 	{
-		array_push($where_clauses, "salesorder.subject like ".PearDatabase::quote($subject.'%'));
-		//$search_query .= " and productname like '".$productname."%'";
+		array_push($where_clauses, "salesorder.subject ".$adb->getLike()." ".PearDatabase::quote($subject.'%'));
+		//$search_query .= " and productname ".$adb->getLike()." '".$productname."%'";
 		$url_string .= "&subject=".$subject;
 	}
 	
 	if (isset($accountname) && $accountname !='')
 	{
-		array_push($where_clauses, "account.accountname like ".PearDatabase::quote($accountname.'%'));
-		//$search_query .= " and productcode like '".$productcode."%'";
+		array_push($where_clauses, "account.accountname ".$adb->getLike()." ".PearDatabase::quote($accountname.'%'));
+		//$search_query .= " and productcode ".$adb->getLike()." '".$productcode."%'";
 		$url_string .= "&accountname=".$accountname;
 	}
 
 	if (isset($quotename) && $quotename !='')
 	{
-		array_push($where_clauses, "quotes.subject like ".PearDatabase::quote($quotename.'%'));
-		 //$search_query .= " and commissionrate like '".$commissionrate."%'";
+		array_push($where_clauses, "quotes.subject ".$adb->getLike()." ".PearDatabase::quote($quotename.'%'));
+		 //$search_query .= " and commissionrate ".$adb->getLike()." '".$commissionrate."%'";
 		 $url_string .= "&quotename=".$quotename;
 	}
 	

Modified: vtigercrm/branches/4.2/modules/Potentials/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Potentials/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Potentials/ListView.php Mon Apr 24 16:29:46 2006
@@ -90,7 +90,7 @@
 		if($uitype[$i] == 56)
 			$str=" potentialscf.".$column[$i]." = 1";
 		else
-	                $str=" potentialscf.".$column[$i]." like '$customfield[$i]%'";
+	                $str=" potentialscf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
                 array_push($where_clauses, $str);
 		$url_string .="&".$column[$i]."=".$customfield[$i];
         }
@@ -98,11 +98,11 @@
 //upto this added for Custom Field
 
 	if(isset($name) && $name != "") {
-			array_push($where_clauses, "potential.potentialname like ".PearDatabase::quote($name.'%')."");
+			array_push($where_clauses, "potential.potentialname ".$adb->getLike()." ".PearDatabase::quote($name.'%')."");
 			$url_string .= "&potentialname=".$name;
 	}
 	if(isset($accountname) && $accountname != "") {
-			array_push($where_clauses, "account.accountname like ".PearDatabase::quote($accountname.'%')."");
+			array_push($where_clauses, "account.accountname ".$adb->getLike()." ".PearDatabase::quote($accountname.'%')."");
 			$url_string .= "&accountname=".$accountname;
 
 
@@ -121,11 +121,11 @@
 			$url_string .= "&opportunity_type=".$opportunity_type;
 	}
 	if(isset($amount) && $amount != "") {
-			array_push($where_clauses, "potential.amount like ".PearDatabase::quote($amount.'%')."");
+			array_push($where_clauses, "potential.amount ".$adb->getLike()." ".PearDatabase::quote($amount.'%')."");
 			$url_string .= "&amount=".$amount;
 	}
 	if(isset($nextstep) && $nextstep != "") {
-			array_push($where_clauses, "potential.nextstep like ".PearDatabase::quote($nextstep.'%')."");
+			array_push($where_clauses, "potential.nextstep ".$adb->getLike()." ".PearDatabase::quote($nextstep.'%')."");
 			$url_string .= "&nextstep=".$nextstep;
 	}
 	if(isset($sales_stage) && $sales_stage != "") {
@@ -136,7 +136,7 @@
 			$url_string .= "&sales_stage=".$sales_stage;
 	}
 	if(isset($probability) && $probability != "") {
-			array_push($where_clauses, "potential.probability like ".PearDatabase::quote($probability.'%')."");
+			array_push($where_clauses, "potential.probability ".$adb->getLike()." ".PearDatabase::quote($probability.'%')."");
 			$url_string .= "&probability=".$probability;
 
 	}
@@ -145,7 +145,7 @@
 			$url_string .= "&current_user_only=".$current_user_only;
 	}
 	if(isset($date_closed) && $date_closed != "") {
-			array_push($where_clauses, $adb->getDBDateString("potential.closingdate")." like ".PearDatabase::quote($date_closed.'%')."");
+			array_push($where_clauses, $adb->getDBDateString("potential.closingdate")." ".$adb->getLike()." ".PearDatabase::quote($date_closed.'%')."");
 			$url_string .= "&closingdate=".$date_closed;
 	}
 	if(isset($date_closed_start) && $date_closed_start != "" && isset($date_closed_end) && $date_closed_end != "")
@@ -357,7 +357,7 @@
             $defaultcv_criteria = $_REQUEST['viewname'];
        }
 
-  	$list_query .= " and sales_stage like "."'%" .$defaultcv_criteria ."%'";
+  	$list_query .= " and sales_stage ".$adb->getLike()." "."'%" .$defaultcv_criteria ."%'";
 	$viewname = $_REQUEST['viewname'];
         $view_script = "<script language='javascript'>
                 function set_selected()

Modified: vtigercrm/branches/4.2/modules/Potentials/Opportunity.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Potentials/Opportunity.php (original)
+++ vtigercrm/branches/4.2/modules/Potentials/Opportunity.php Mon Apr 24 16:29:46 2006
@@ -312,8 +312,8 @@
 		if($this->checkIfCustomTableExists())
 		{
  $query = $this->constructCustomQueryAddendum() .",                                potential.*,
-                                account.accountname account_name,
-                                users.user_name assigned_user_name
+                                account.accountname AS account_name,
+                                users.user_name AS assigned_user_name
                                 FROM potential
                                 INNER JOIN crmentity
                                 ON crmentity.crmid=potential.potentialid
@@ -325,8 +325,8 @@
 		{
                   	$query = "SELECT
                                 potential.*,
-                                account.accountname account_name,
-                                users.user_name assigned_user_name
+                                account.accountname AS account_name,
+                                users.user_name AS assigned_user_name
                                 FROM potential inner join crmentity on crmentity.crmid=potential.potentialid                                LEFT JOIN users
                                 ON crmentity.smcreatorid=users.id
                                 LEFT JOIN account on potential.accountid=account.accountid  LEFT JOIN potentialscf on potentialscf.potentialid=potential.potentialid where crmentity.deleted=0 ";
@@ -612,7 +612,7 @@
 	function get_activities($id)
 	{
           //$query = "SELECT activity.subject,semodule,activitytype,date_start,status,priority from activity inner join seactivityrel on seactivityrel.activityid=activity.activityid where seactivityrel.crmid=".$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 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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and ( activity.status is NULL || activity.status != 'Completed' ) and (  activity.eventstatus is NULL ||  activity.eventstatus != 'Held')";
+	  $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 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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and crmentity.deleted=0 and ( activity.status is NULL or activity.status != 'Completed' ) and (  activity.eventstatus is NULL or  activity.eventstatus != 'Held')";
           //include('modules/Potentials/RenderRelatedListUI.php');
           renderRelatedActivities($query,$id);
 	}
@@ -648,9 +648,9 @@
 
 	function get_attachments($id)
 	{
-		$query = "select notes.title,'Notes      '  ActivityType, notes.filename, attachments.type  FileType,crm2.modifiedtime lastmodified, seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid 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 where crmentity.crmid=".$id;
+		$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 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 where 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 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 where crmentity.crmid=".$id;
+                $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 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 where crmentity.crmid=".$id;
 
 		renderRelatedAttachments($query,$id);
 	}
@@ -690,9 +690,10 @@
 		do not include any $this-> because this is called on without having the class instantiated
 	*/
 	function build_generic_where_clause ($the_query_string) {
+		global $adb;
 	$where_clauses = Array();
 	$the_query_string = addslashes($the_query_string);
-	array_push($where_clauses, "potentialname like '$the_query_string%'");
+	array_push($where_clauses, "potentialname ".$adb->getLike()." '$the_query_string%'");
 
 	$the_where = "";
 	foreach($where_clauses as $clause)

Modified: vtigercrm/branches/4.2/modules/Potentials/Popup.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Potentials/Popup.php (original)
+++ vtigercrm/branches/4.2/modules/Potentials/Popup.php Mon Apr 24 16:29:46 2006
@@ -73,11 +73,11 @@
 	$where_clauses = array();
 
 	if(isset($name) && $name != "") {
-			array_push($where_clauses, "potential.potentialname like ".PearDatabase::quote($name.'%')."");
+			array_push($where_clauses, "potential.potentialname ".$adb->getLike()." ".PearDatabase::quote($name.'%')."");
 			$url_string .= "&name=".$name;		
 	}
 	if(isset($accountname) && $accountname != "") {
-			array_push($where_clauses, "account.accountname like ".PearDatabase::quote('%'.$accountname.'%')."");
+			array_push($where_clauses, "account.accountname ".$adb->getLike()." ".PearDatabase::quote('%'.$accountname.'%')."");
 			$url_string .= "&account_name=".$accountname;		
 	}
 	if(isset($current_user_only) && $current_user_only != "") {

Modified: vtigercrm/branches/4.2/modules/Products/AddProductsToPriceBook.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Products/AddProductsToPriceBook.php (original)
+++ vtigercrm/branches/4.2/modules/Products/AddProductsToPriceBook.php Mon Apr 24 16:29:46 2006
@@ -86,7 +86,7 @@
 			if($uitype[$i] == 56)
                                 $str=" productcf.".$column[$i]." = 1";
                         else
-			        $str=" productcf.".$column[$i]." like '$customfield[$i]%'";
+			        $str=" productcf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
 		        array_push($where_clauses, $str);
 	       	//	  $search_query .= ' and '.$str;
 			$url_string .="&".$column[$i]."=".$customfield[$i];
@@ -96,65 +96,65 @@
 
 	if (isset($productname) && $productname !='')
 	{
-		array_push($where_clauses, "productname like ".PearDatabase::quote($productname.'%'));
-		//$search_query .= " and productname like '".$productname."%'";
+		array_push($where_clauses, "productname ".$adb->getLike()." ".PearDatabase::quote($productname.'%'));
+		//$search_query .= " and productname ".$adb->getLike()." '".$productname."%'";
 		$url_string .= "&productname=".$productname;
 	}
 	
 	if (isset($productcode) && $productcode !='')
 	{
-		array_push($where_clauses, "productcode like ".PearDatabase::quote($productcode.'%'));
-		//$search_query .= " and productcode like '".$productcode."%'";
+		array_push($where_clauses, "productcode ".$adb->getLike()." ".PearDatabase::quote($productcode.'%'));
+		//$search_query .= " and productcode ".$adb->getLike()." '".$productcode."%'";
 		$url_string .= "&productcode=".$productcode;
 	}
 
 	if (isset($commissionrate) && $commissionrate !='')
 	{
-		array_push($where_clauses, "commissionrate like ".PearDatabase::quote($commissionrate.'%'));
-		 //$search_query .= " and commissionrate like '".$commissionrate."%'";
+		array_push($where_clauses, "commissionrate ".$adb->getLike()." ".PearDatabase::quote($commissionrate.'%'));
+		 //$search_query .= " and commissionrate ".$adb->getLike()." '".$commissionrate."%'";
 		 $url_string .= "&commissionrate=".$commissionrate;
 	}
 	
 	if (isset($qtyperunit) && $qtyperunit !='')
 	{
-		array_push($where_clauses, "qty_per_unit like ".PearDatabase::quote($qtyperunit.'%'));
-	 	//$search_query .= " and qty_per_unit like '".$qtyperunit."%'";
+		array_push($where_clauses, "qty_per_unit ".$adb->getLike()." ".PearDatabase::quote($qtyperunit.'%'));
+	 	//$search_query .= " and qty_per_unit ".$adb->getLike()." '".$qtyperunit."%'";
 		$url_string .= "&qtyperunit=".$qtyperunit;
 	}
 	
 	if (isset($unitprice) && $unitprice !='')
 	{
-		array_push($where_clauses, "unit_price like ".PearDatabase::quote($unitprice.'%'));
-	 //	$search_query .= " and unit_price like '".$unitprice."%'";
+		array_push($where_clauses, "unit_price ".$adb->getLike()." ".PearDatabase::quote($unitprice.'%'));
+	 //	$search_query .= " and unit_price ".$adb->getLike()." '".$unitprice."%'";
 		$url_string .= "&unitprice=".$unitprice;
 	}
 	if (isset($manufacturer) && $manufacturer !='' && $manufacturer !='--None--')
         {
-		array_push($where_clauses, "manufacturer like ".PearDatabase::quote($manufacturer.'%'));
-        	//$search_query .= " and manufacturer like '".$manufacturer."%'";
+		array_push($where_clauses, "manufacturer ".$adb->getLike()." ".PearDatabase::quote($manufacturer.'%'));
+        	//$search_query .= " and manufacturer ".$adb->getLike()." '".$manufacturer."%'";
                 $url_string .= "&manufacturer=".$manufacturer;
 	}
 	if (isset($productcategory) && $productcategory !='' && $productcategory !='--None--')
         {
-		array_push($where_clauses, "productcategory like ".PearDatabase::quote($productcategory.'%'));
-        	//$search_query .= " and productcategory like '".$productcategory."%'";
+		array_push($where_clauses, "productcategory ".$adb->getLike()." ".PearDatabase::quote($productcategory.'%'));
+        	//$search_query .= " and productcategory ".$adb->getLike()." '".$productcategory."%'";
                 $url_string .= "&productcategory=".$productcategory;
 	}
 	if (isset($start_date) && $start_date !='')
         {
-		array_push($where_clauses, "start_date like ".PearDatabase::quote($start_date.'%'));
+		array_push($where_clauses, "start_date ".$adb->getLike()." ".PearDatabase::quote($start_date.'%'));
                 //$search_query .= " and start_date = '".$start_date."%'";
                 $url_string .= "&start_date=".$start_date;
         } 
 	if (isset($expiry_date) && $expiry_date !='')
         {
-		array_push($where_clauses, "expiry_date like ".PearDatabase::quote($expiry_date.'%'));
+		array_push($where_clauses, "expiry_date ".$adb->getLike()." ".PearDatabase::quote($expiry_date.'%'));
                 //$search_query .= " and expiry_date = '".$expiry_date."%'";
                 $url_string .= "&expiry_date=".$expiry_date;
         } 
 	if (isset($purchase_date) && $purchase_date !='')
         {
-		array_push($where_clauses, "purchase_date like ".PearDatabase::quote($purchase_date.'%'));
+		array_push($where_clauses, "purchase_date ".$adb->getLike()." ".PearDatabase::quote($purchase_date.'%'));
                 //$search_query .= " and purchase_date = '".$purchase_date."%'";
                 $url_string .= "&purchase_date=".$purchase_date;
         }

Modified: vtigercrm/branches/4.2/modules/Products/Delete.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Products/Delete.php (original)
+++ vtigercrm/branches/4.2/modules/Products/Delete.php Mon Apr 24 16:29:46 2006
@@ -37,7 +37,7 @@
 	if($_REQUEST['return_module'] == 'Potentials' || $_REQUEST['return_module'] == 'Accounts' || $_REQUEST['return_module'] == 'Leads')
 		$sql = 'delete from seproductsrel where crmid = '.$_REQUEST['return_id'].' and productid = '.$_REQUEST['record'];
 
-	$adb->query($sql);
+	if($sql) $adb->query($sql);
 }
 if($_REQUEST['return_module'] == "Contacts")
 {

Modified: vtigercrm/branches/4.2/modules/Products/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Products/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Products/ListView.php Mon Apr 24 16:29:46 2006
@@ -84,7 +84,7 @@
 			if($uitype[$i] == 56)
                                 $str=" productcf.".$column[$i]." = 1";
                         else
-			        $str=" productcf.".$column[$i]." like '$customfield[$i]%'";
+			        $str=" productcf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
 		        array_push($where_clauses, $str);
 	       	//	  $search_query .= ' and '.$str;
 			$url_string .="&".$column[$i]."=".$customfield[$i];
@@ -94,65 +94,65 @@
 
 	if (isset($productname) && $productname !='')
 	{
-		array_push($where_clauses, "productname like ".PearDatabase::quote($productname.'%'));
-		//$search_query .= " and productname like '".$productname."%'";
+		array_push($where_clauses, "productname ".$adb->getLike()." ".PearDatabase::quote($productname.'%'));
+		//$search_query .= " and productname ".$adb->getLike()." '".$productname."%'";
 		$url_string .= "&productname=".$productname;
 	}
 	
 	if (isset($productcode) && $productcode !='')
 	{
-		array_push($where_clauses, "productcode like ".PearDatabase::quote($productcode.'%'));
-		//$search_query .= " and productcode like '".$productcode."%'";
+		array_push($where_clauses, "productcode ".$adb->getLike()." ".PearDatabase::quote($productcode.'%'));
+		//$search_query .= " and productcode ".$adb->getLike()." '".$productcode."%'";
 		$url_string .= "&productcode=".$productcode;
 	}
 
 	if (isset($commissionrate) && $commissionrate !='')
 	{
-		array_push($where_clauses, "commissionrate like ".PearDatabase::quote($commissionrate.'%'));
-		 //$search_query .= " and commissionrate like '".$commissionrate."%'";
+		array_push($where_clauses, "commissionrate ".$adb->getLike()." ".PearDatabase::quote($commissionrate.'%'));
+		 //$search_query .= " and commissionrate ".$adb->getLike()." '".$commissionrate."%'";
 		 $url_string .= "&commissionrate=".$commissionrate;
 	}
 	
 	if (isset($qtyperunit) && $qtyperunit !='')
 	{
-		array_push($where_clauses, "qty_per_unit like ".PearDatabase::quote($qtyperunit.'%'));
-	 	//$search_query .= " and qty_per_unit like '".$qtyperunit."%'";
+		array_push($where_clauses, "qty_per_unit ".$adb->getLike()." ".PearDatabase::quote($qtyperunit.'%'));
+	 	//$search_query .= " and qty_per_unit ".$adb->getLike()." '".$qtyperunit."%'";
 		$url_string .= "&qtyperunit=".$qtyperunit;
 	}
 	
 	if (isset($unitprice) && $unitprice !='')
 	{
-		array_push($where_clauses, "unit_price like ".PearDatabase::quote($unitprice.'%'));
-	 //	$search_query .= " and unit_price like '".$unitprice."%'";
+		array_push($where_clauses, "unit_price ".$adb->getLike()." ".PearDatabase::quote($unitprice.'%'));
+	 //	$search_query .= " and unit_price ".$adb->getLike()." '".$unitprice."%'";
 		$url_string .= "&unitprice=".$unitprice;
 	}
 	if (isset($manufacturer) && $manufacturer !='' && $manufacturer !='--None--')
         {
-		array_push($where_clauses, "manufacturer like ".PearDatabase::quote($manufacturer.'%'));
-        	//$search_query .= " and manufacturer like '".$manufacturer."%'";
+		array_push($where_clauses, "manufacturer ".$adb->getLike()." ".PearDatabase::quote($manufacturer.'%'));
+        	//$search_query .= " and manufacturer ".$adb->getLike()." '".$manufacturer."%'";
                 $url_string .= "&manufacturer=".$manufacturer;
 	}
 	if (isset($productcategory) && $productcategory !='' && $productcategory !='--None--')
         {
-		array_push($where_clauses, "productcategory like ".PearDatabase::quote($productcategory.'%'));
-        	//$search_query .= " and productcategory like '".$productcategory."%'";
+		array_push($where_clauses, "productcategory ".$adb->getLike()." ".PearDatabase::quote($productcategory.'%'));
+        	//$search_query .= " and productcategory ".$adb->getLike()." '".$productcategory."%'";
                 $url_string .= "&productcategory=".$productcategory;
 	}
 	if (isset($start_date) && $start_date !='')
         {
-		array_push($where_clauses, "start_date like ".PearDatabase::quote($start_date.'%'));
+		array_push($where_clauses, "start_date ".$adb->getLike()." ".PearDatabase::quote($start_date.'%'));
                 //$search_query .= " and start_date = '".$start_date."%'";
                 $url_string .= "&start_date=".$start_date;
         } 
 	if (isset($expiry_date) && $expiry_date !='')
         {
-		array_push($where_clauses, "expiry_date like ".PearDatabase::quote($expiry_date.'%'));
+		array_push($where_clauses, "expiry_date ".$adb->getLike()." ".PearDatabase::quote($expiry_date.'%'));
                 //$search_query .= " and expiry_date = '".$expiry_date."%'";
                 $url_string .= "&expiry_date=".$expiry_date;
         } 
 	if (isset($purchase_date) && $purchase_date !='')
         {
-		array_push($where_clauses, "purchase_date like ".PearDatabase::quote($purchase_date.'%'));
+		array_push($where_clauses, "purchase_date ".$adb->getLike()." ".PearDatabase::quote($purchase_date.'%'));
                 //$search_query .= " and purchase_date = '".$purchase_date."%'";
                 $url_string .= "&purchase_date=".$purchase_date;
         }

Modified: vtigercrm/branches/4.2/modules/Products/Popup.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Products/Popup.php (original)
+++ vtigercrm/branches/4.2/modules/Products/Popup.php Mon Apr 24 16:29:46 2006
@@ -37,7 +37,7 @@
         $xtpl->assign("SMODULE",$_REQUEST['smodule']);
 	$smodule = $_REQUEST['smodule'];
 	$url_string = '&smodule=VENDOR';
-	$search_query .= " and vendor_id=''";
+	$search_query .= " and vendor_id is null";
 }
 
 
@@ -68,20 +68,20 @@
 
 	if (isset($productname) && $productname !='')
 	{
-		$search_query .= " and productname like '".$productname."%'";
+		$search_query .= " and productname ".$adb->getLike()." '".$productname."%'";
 		$url_string .= "&productname=".$productname;
 		$xtpl->assign("PRODUCT_NAME", $productname);
 	}
 	
 	if (isset($productcode) && $productcode !='')
 	{
-		$search_query .= " and productcode like '%".$productcode."%'";
+		$search_query .= " and productcode ".$adb->getLike()." '%".$productcode."%'";
 		$url_string .= "&productcode=".$productcode;
 		$xtpl->assign("PRODUCT_CODE", $productcode);
 	}
 	if (isset($unitprice) && $unitprice !='')
 	{
-	 	$search_query .= " and unit_price like '%".$unitprice."%'";
+	 	$search_query .= " and unit_price ".$adb->getLike()." '%".$unitprice."%'";
 		$url_string .= "&unitprice=".$unitprice;
 		$xtpl->assign("UNITPRICE", $unitprice);
 	}

Modified: vtigercrm/branches/4.2/modules/Products/PriceBookListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Products/PriceBookListView.php (original)
+++ vtigercrm/branches/4.2/modules/Products/PriceBookListView.php Mon Apr 24 16:29:46 2006
@@ -78,7 +78,7 @@
 			if($uitype[$i] == 56)
                                 $str=" pricebookcf.".$column[$i]." = 1";
                         else
-			        $str=" pricebookcf.".$column[$i]." like '$customfield[$i]%'";
+			        $str=" pricebookcf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
 		        array_push($where_clauses, $str);
 	       	//	  $search_query .= ' and '.$str;
 			$url_string .="&".$column[$i]."=".$customfield[$i];
@@ -88,15 +88,15 @@
 
 	if (isset($bookname) && $bookname !='')
 	{
-		array_push($where_clauses, "bookname like ".PearDatabase::quote($bookname.'%'));
-		//$search_query .= " and productname like '".$productname."%'";
+		array_push($where_clauses, "bookname ".$adb->getLike()." ".PearDatabase::quote($bookname.'%'));
+		//$search_query .= " and productname ".$adb->getLike()." '".$productname."%'";
 		$url_string .= "&bookname=".$bookname;
 	}
 	
 	if (isset($active) && $active !='')
 	{
 		array_push($where_clauses, "active = 1");
-		//$search_query .= " and productcode like '".$productcode."%'";
+		//$search_query .= " and productcode ".$adb->getLike()." '".$productcode."%'";
 		$url_string .= "&active=".$active;
 	}
 	$where = "";

Modified: vtigercrm/branches/4.2/modules/Products/Product.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Products/Product.php (original)
+++ vtigercrm/branches/4.2/modules/Products/Product.php Mon Apr 24 16:29:46 2006
@@ -99,9 +99,9 @@
 	function get_attachments($id)
         {
 	
-		$query = "select notes.title,'Notes      ' ActivityType, notes.filename, attachments.type  FileType,crm2.modifiedtime  lastmodified, seattachmentsrel.attachmentsid attachmentsid, notes.notesid crmid 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 where crmentity.crmid=".$id;
+		$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 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 where 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 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 where crmentity.crmid=".$id;	
+                $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 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 where crmentity.crmid=".$id;
 
 		renderRelatedAttachments($query,$id);
         }
@@ -158,7 +158,7 @@
 	}
 	function product_novendor()
 	{
-		$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 products.productname,crmentity.deleted from products inner join crmentity on crmentity.crmid=products.productid where crmentity.deleted=0 and products.vendor_id is null";
 		$result=$this->db->query($query);
 		return $this->db->num_rows($result);
 	}
@@ -215,27 +215,29 @@
 	
 	function create_export_query(&$order_by, &$where)
 	{
+		global $adb;
+
 		if($this->checkIfCustomTableExists())
 		{
 
 			$query = $this->constructCustomQueryAddendum() . 
 				",    
 				products.productid productid,
-			products.productname productname,
-			products.productcode productcode,
-			products.productcategory productcategory,
-			products.manufacturer manufacturer,
-			products.product_description product_description,
-			products.qty_per_unit qty_per_unit,
-			products.unit_price unit_price,
-			products.weight weight,
-			products.pack_size 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 cost_factor,
-			products.commissionrate commissionrate,
-			products.commissionmethod commissionmethod,
-			products.discontinued discontinued,
+			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, "
+			.$adb->getDBDateString('products.start_date', 'Y-M-D')." AS start_date, "
+			.$adb->getDBDateString('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,
@@ -260,22 +262,22 @@
 		else
 		{
 			$query = "SELECT
-				products.productid productid,
-			products.productname productname,
-			products.productcode productcode,
-			products.productcategory productcategory,
-			products.manufacturer manufacturer,
-			products.product_description product_description,
-			products.qty_per_unit qty_per_unit,
-			products.unit_price unit_price,
-			products.weight weight,
-			products.pack_size 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 cost_factor,
-			products.commissionrate commissionrate,
-			products.commissionmethod commissionmethod,
-			products.discontinued discontinued,
+				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, "
+			.$adb->getDBDateString('products.start_date', 'Y-M-D')." AS start_date, "
+			.$adb->getDBDateString('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,

Modified: vtigercrm/branches/4.2/modules/Products/VendorListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Products/VendorListView.php (original)
+++ vtigercrm/branches/4.2/modules/Products/VendorListView.php Mon Apr 24 16:29:46 2006
@@ -79,7 +79,7 @@
 			if($uitype[$i] == 56)
                                 $str=" vendorcf.".$column[$i]." = 1";
                         else
-			        $str="vendorcf.".$column[$i]." like '$customfield[$i]%'";
+			        $str="vendorcf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
 		        array_push($where_clauses, $str);
 	       	//	  $search_query .= ' and '.$str;
 			$url_string .="&".$column[$i]."=".$customfield[$i];
@@ -89,72 +89,72 @@
 
 	if (isset($vendorname) && $vendorname !='')
 	{
-		array_push($where_clauses, "vendorname like ".PearDatabase::quote($vendorname.'%'));
-		//$search_query .= " and productname like '".$productname."%'";
+		array_push($where_clauses, "vendorname ".$adb->getLike()." ".PearDatabase::quote($vendorname.'%'));
+		//$search_query .= " and productname ".$adb->getLike()." '".$productname."%'";
 		$url_string .= "&vendorname=".$vendorname;
 	}
 
 	if (isset($email) && $email !='')
 	{
 		array_push($where_clauses, "email =".PearDatabase::quote($email));
-		//$search_query .= " and productcode like '".$productcode."%'";
+		//$search_query .= " and productcode ".$adb->getLike()." '".$productcode."%'";
 		$url_string .= "&email=".$email;
 	}
 	
 	if (isset($category) && $category !='')
 	{
-		array_push($where_clauses, "category like ".PearDatabase::quote($category.'%'));
-		//$search_query .= " and productcode like '".$productcode."%'";
+		array_push($where_clauses, "category ".$adb->getLike()." ".PearDatabase::quote($category.'%'));
+		//$search_query .= " and productcode ".$adb->getLike()." '".$productcode."%'";
 		$url_string .= "&category=".$category;
 	}
 
 /*	if (isset($commissionrate) && $commissionrate !='')
 	{
-		array_push($where_clauses, "commissionrate like ".PearDatabase::quote($commissionrate.'%'));
-		 //$search_query .= " and commissionrate like '".$commissionrate."%'";
+		array_push($where_clauses, "commissionrate ".$adb->getLike()." ".PearDatabase::quote($commissionrate.'%'));
+		 //$search_query .= " and commissionrate ".$adb->getLike()." '".$commissionrate."%'";
 		 $url_string .= "&commissionrate=".$commissionrate;
 	}
 
 	if (isset($qtyperunit) && $qtyperunit !='')
 	{
-		array_push($where_clauses, "qty_per_unit like ".PearDatabase::quote($qtyperunit.'%'));
-	 	//$search_query .= " and qty_per_unit like '".$qtyperunit."%'";
+		array_push($where_clauses, "qty_per_unit ".$adb->getLike()." ".PearDatabase::quote($qtyperunit.'%'));
+	 	//$search_query .= " and qty_per_unit ".$adb->getLike()." '".$qtyperunit."%'";
 		$url_string .= "&qtyperunit=".$qtyperunit;
 	}
 
 	if (isset($unitprice) && $unitprice !='')
 	{
-		array_push($where_clauses, "unit_price like ".PearDatabase::quote($unitprice.'%'));
-	 //	$search_query .= " and unit_price like '".$unitprice."%'";
+		array_push($where_clauses, "unit_price ".$adb->getLike()." ".PearDatabase::quote($unitprice.'%'));
+	 //	$search_query .= " and unit_price ".$adb->getLike()." '".$unitprice."%'";
 		$url_string .= "&unitprice=".$unitprice;
 	}
 	if (isset($manufacturer) && $manufacturer !='' && $manufacturer !='--None--')
         {
-		array_push($where_clauses, "manufacturer like ".PearDatabase::quote($manufacturer.'%'));
-        	//$search_query .= " and manufacturer like '".$manufacturer."%'";
+		array_push($where_clauses, "manufacturer ".$adb->getLike()." ".PearDatabase::quote($manufacturer.'%'));
+        	//$search_query .= " and manufacturer ".$adb->getLike()." '".$manufacturer."%'";
                 $url_string .= "&manufacturer=".$manufacturer;
 	}
 	if (isset($productcategory) && $productcategory !='' && $productcategory !='--None--')
         {
-		array_push($where_clauses, "productcategory like ".PearDatabase::quote($productcategory.'%'));
-        	//$search_query .= " and productcategory like '".$productcategory."%'";
+		array_push($where_clauses, "productcategory ".$adb->getLike()." ".PearDatabase::quote($productcategory.'%'));
+        	//$search_query .= " and productcategory ".$adb->getLike()." '".$productcategory."%'";
                 $url_string .= "&productcategory=".$productcategory;
 	}
 	if (isset($start_date) && $start_date !='')
         {
-		array_push($where_clauses, "start_date like ".PearDatabase::quote($start_date.'%'));
+		array_push($where_clauses, "start_date ".$adb->getLike()." ".PearDatabase::quote($start_date.'%'));
                 //$search_query .= " and start_date = '".$start_date."%'";
                 $url_string .= "&start_date=".$start_date;
         }
 	if (isset($expiry_date) && $expiry_date !='')
         {
-		array_push($where_clauses, "expiry_date like ".PearDatabase::quote($expiry_date.'%'));
+		array_push($where_clauses, "expiry_date ".$adb->getLike()." ".PearDatabase::quote($expiry_date.'%'));
                 //$search_query .= " and expiry_date = '".$expiry_date."%'";
                 $url_string .= "&expiry_date=".$expiry_date;
         }
 	if (isset($purchase_date) && $purchase_date !='')
         {
-		array_push($where_clauses, "purchase_date like ".PearDatabase::quote($purchase_date.'%'));
+		array_push($where_clauses, "purchase_date ".$adb->getLike()." ".PearDatabase::quote($purchase_date.'%'));
                 //$search_query .= " and purchase_date = '".$purchase_date."%'";
                 $url_string .= "&purchase_date=".$purchase_date;
         }

Modified: vtigercrm/branches/4.2/modules/Products/VendorPopup.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Products/VendorPopup.php (original)
+++ vtigercrm/branches/4.2/modules/Products/VendorPopup.php Mon Apr 24 16:29:46 2006
@@ -81,7 +81,7 @@
 			if($uitype[$i] == 56)
                                 $str=" vendorcf.".$column[$i]." = 1";
                         else
-			        $str="vendorcf.".$column[$i]." like '$customfield[$i]%'";
+			        $str="vendorcf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
 		        array_push($where_clauses, $str);
 	       	//	  $search_query .= ' and '.$str;
 			$url_string .="&".$column[$i]."=".$customfield[$i];
@@ -91,22 +91,22 @@
 
 	if (isset($vendorname) && $vendorname !='')
 	{
-		array_push($where_clauses, "vendorname like ".PearDatabase::quote($vendorname.'%'));
-		//$search_query .= " and productname like '".$productname."%'";
+		array_push($where_clauses, "vendorname ".$adb->getLike()." ".PearDatabase::quote($vendorname.'%'));
+		//$search_query .= " and productname ".$adb->getLike()." '".$productname."%'";
 		$url_string .= "&vendorname=".$vendorname;
 	}
 
 	if (isset($companyname) && $companyname !='')
 	{
-		array_push($where_clauses, "company_name like ".PearDatabase::quote($companyname.'%'));
-		//$search_query .= " and productcode like '".$productcode."%'";
+		array_push($where_clauses, "company_name ".$adb->getLike()." ".PearDatabase::quote($companyname.'%'));
+		//$search_query .= " and productcode ".$adb->getLike()." '".$productcode."%'";
 		$url_string .= "&companyname=".$companyname;
 	}
 	
 	if (isset($category) && $category !='')
 	{
-		array_push($where_clauses, "category like ".PearDatabase::quote($category.'%'));
-		//$search_query .= " and productcode like '".$productcode."%'";
+		array_push($where_clauses, "category ".$adb->getLike()." ".PearDatabase::quote($category.'%'));
+		//$search_query .= " and productcode ".$adb->getLike()." '".$productcode."%'";
 		$url_string .= "&category=".$category;
 	}
 

Modified: vtigercrm/branches/4.2/modules/Quotes/Delete.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Quotes/Delete.php (original)
+++ vtigercrm/branches/4.2/modules/Quotes/Delete.php Mon Apr 24 16:29:46 2006
@@ -37,12 +37,12 @@
 }
 elseif($_REQUEST['return_module'] == "Potentials")
 {
-	$relation_query = "UPDATE quotes set potentialid='' where quoteid=".$_REQUEST['record'];
+	$relation_query = "UPDATE quotes set potentialid=null where quoteid=".$_REQUEST['record'];
 	$adb->query($relation_query);
 }
 elseif($_REQUEST['return_module'] == "Contacts")
 {
-	$relation_query = "UPDATE quotes set contactid='' where quoteid=".$_REQUEST['record'];
+	$relation_query = "UPDATE quotes set contactid=null where quoteid=".$_REQUEST['record'];
 	$adb->query($relation_query);
 }
 elseif($_REQUEST['return_module'] == "Products")

Modified: vtigercrm/branches/4.2/modules/Quotes/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Quotes/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Quotes/ListView.php Mon Apr 24 16:29:46 2006
@@ -79,7 +79,7 @@
 		if($uitype[$i] == 56)
 			$str=" quotescf.".$column[$i]." = 1";
 		else
-	                $str=" quotescf.".$column[$i]." like '$customfield[$i]%'";
+	                $str=" quotescf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
                 array_push($where_clauses, $str);
 		$url_string .="&".$column[$i]."=".$customfield[$i];
         }
@@ -88,23 +88,23 @@
 	
 	if(isset($subject) && $subject != "") 
 	{
-		array_push($where_clauses, "quotes.subject like ".PearDatabase::quote($subject."%"));
+		array_push($where_clauses, "quotes.subject ".$adb->getLike()." ".PearDatabase::quote($subject."%"));
 		$url_string .= "&subject=".$subject;
 	}
 	if(isset($potentialname) && $potentialname != "")
 	{
-		array_push($where_clauses, "potential.potentialname like ".PearDatabase::quote("%".$potentialname."%"));
+		array_push($where_clauses, "potential.potentialname ".$adb->getLike()." ".PearDatabase::quote("%".$potentialname."%"));
 		$url_string .= "&potentialname=".$potentialname;
 	}
 	if(isset($accountname) && $accountname != "")
 	{
-		array_push($where_clauses, "account.accountname like ".PearDatabase::quote("%".$accountname."%"));
+		array_push($where_clauses, "account.accountname ".$adb->getLike()." ".PearDatabase::quote("%".$accountname."%"));
 		$url_string .= "&accountname=".$accountname;
 	}
 
 	if(isset($quotestage) && $quotestage != "")
 	{
-		array_push($where_clauses, "quotes.quotestage like ".PearDatabase::quote("%".$quotestage."%"));
+		array_push($where_clauses, "quotes.quotestage ".$adb->getLike()." ".PearDatabase::quote("%".$quotestage."%"));
 		$url_string .= "&quotestage=".$quotestage;
 	}
 	

Modified: vtigercrm/branches/4.2/modules/Quotes/Popup.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Quotes/Popup.php (original)
+++ vtigercrm/branches/4.2/modules/Quotes/Popup.php Mon Apr 24 16:29:46 2006
@@ -88,7 +88,7 @@
 		if($uitype[$i] == 56)
 			$str=" quotescf.".$column[$i]." = 1";
 		else
-	                $str=" quotescf.".$column[$i]." like '$customfield[$i]%'";
+	                $str=" quotescf.".$column[$i]." ".$adb->getLike()." '$customfield[$i]%'";
                 array_push($where_clauses, $str);
 		$url_string .="&".$column[$i]."=".$customfield[$i];
         }
@@ -97,18 +97,18 @@
 	
 	if(isset($subject) && $subject != "") 
 	{
-		array_push($where_clauses, "quotes.subject like ".PearDatabase::quote($subject."%"));
+		array_push($where_clauses, "quotes.subject ".$adb->getLike()." ".PearDatabase::quote($subject."%"));
 		$url_string .= "&subject=".$subject;
 	}
 	if(isset($accountname) && $accountname != "")
 	{
-		array_push($where_clauses, "account.accountname like ".PearDatabase::quote("%".$accountname."%"));
+		array_push($where_clauses, "account.accountname ".$adb->getLike()." ".PearDatabase::quote("%".$accountname."%"));
 		$url_string .= "&accountname=".$accountname;
 	}
 
 	if(isset($quotestage) && $quotestage != "")
 	{
-		array_push($where_clauses, "quotes.quotestage like ".PearDatabase::quote("%".$quotestage."%"));
+		array_push($where_clauses, "quotes.quotestage ".$adb->getLike()." ".PearDatabase::quote("%".$quotestage."%"));
 		$url_string .= "&quotestage=".$quotestage;
 	}
 	

Modified: vtigercrm/branches/4.2/modules/Quotes/Quote.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Quotes/Quote.php (original)
+++ vtigercrm/branches/4.2/modules/Quotes/Quote.php Mon Apr 24 16:29:46 2006
@@ -179,7 +179,7 @@
 	}
 	function get_activities($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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and ( activity.status is NULL || activity.status != 'Completed' ) and (  activity.eventstatus is NULL ||  activity.eventstatus != 'Held')";
+		$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 where seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and ( activity.status is NULL OR activity.status != 'Completed' ) and (  activity.eventstatus is NULL OR  activity.eventstatus != 'Held')";
 		renderRelatedActivities($query,$id);
 	}
 	function get_history($id)

Modified: vtigercrm/branches/4.2/modules/Reports/PopulateReports.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Reports/PopulateReports.php (original)
+++ vtigercrm/branches/4.2/modules/Reports/PopulateReports.php Mon Apr 24 16:29:46 2006
@@ -413,8 +413,8 @@
 {
 	global $adb;
 	$sql = "INSERT INTO reportfolder ";
-	$sql .= "(FOLDERID,FOLDERNAME,DESCRIPTION,STATE) ";
-	$sql .= "VALUES ('','".$fldrname."','".$fldrdescription."','SAVED')";
+	$sql .= "(FOLDERNAME,DESCRIPTION,STATE) ";
+	$sql .= "VALUES ('".$fldrname."','".$fldrdescription."','SAVED')";
 	$result = $adb->query($sql);
 }
 

Modified: vtigercrm/branches/4.2/modules/Reports/ReportRun.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Reports/ReportRun.php (original)
+++ vtigercrm/branches/4.2/modules/Reports/ReportRun.php Mon Apr 24 16:29:46 2006
@@ -65,7 +65,9 @@
 			$querycolumns = $this->getEscapedColumns($selectedfields);
 			if($querycolumns == "")
 			{
-				$columnslist[$fieldcolname] = $selectedfields[0].".".$selectedfields[1]." '".$selectedfields[2]."'";
+		// mysql my need quotes around the alias I'm not sure
+		//		$columnslist[$fieldcolname] = $selectedfields[0].".".$selectedfields[1]." as '".$selectedfields[2]."'";
+				$columnslist[$fieldcolname] = $selectedfields[0].".".$selectedfields[1]." as ".$selectedfields[2]."";
 			}else
 			{
 				$columnslist[$fieldcolname] = $querycolumns;
@@ -91,15 +93,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 crmentityRelHelpDesk.setype when 'Accounts' then accountRelHelpDesk.accountname when 'Contacts' then contactdetailsRelHelpDesk.lastname End"." AS \"".$selectedfields[2]."\", crmentityRelHelpDesk.setype AS 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 crmentityRelProducts.setype when 'Accounts' then accountRelProducts.accountname when 'Leads' then leaddetailsRelProducts.lastname when 'Potentials' then potentialRelProducts.potentialname End"." AS \"".$selectedfields[2]."\", crmentityRelProducts.setype AS 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 'Orders' then purchaseorderRelActivities.subject when 'Invoice' then invoiceRelActivities.subject End"." '".$selectedfields[2]."', crmentityRelActivities.setype 'Entity_type'";
+				$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 'Orders' then purchaseorderRelActivities.subject when 'Invoice' then invoiceRelActivities.subject End"." AS \"".$selectedfields[2]."\", crmentityRelActivities.setype AS Entity_type";
 			}
 		}
 		/*if($fieldname == "contact_id")
@@ -173,7 +175,7 @@
 	function getAdvComparator($comparator,$value)
         {
 
-		global $vtlog;
+		global $adb, $vtlog;
 
 		if($comparator == "e")
                 {
@@ -197,15 +199,15 @@
                 }
                 if($comparator == "s")
                 {
-                        $rtvalue = " like ".PearDatabase::quote($value."%");
+                        $rtvalue = " ".$adb->getLike()." ".PearDatabase::quote($value."%");
                 }
                 if($comparator == "c")
                 {
-                        $rtvalue = " like ".PearDatabase::quote("%".$value."%");
+                        $rtvalue = " ".$adb->getLike()." ".PearDatabase::quote("%".$value."%");
                 }
                 if($comparator == "k")
                 {
-                        $rtvalue = " not like ".PearDatabase::quote("%".$value."%");
+                        $rtvalue = " not ".$adb->getLike()." ".PearDatabase::quote("%".$value."%");
                 }
                 if($comparator == "l")
                 {
@@ -296,7 +298,7 @@
 			{
 				if($datefilter == "custom")
                                 {
-                                        if($startdate != "0000-00-00" && $enddate != "0000-00-00")
+                                        if($startdate && $startdate != "0000-00-00" && $enddate && $enddate != "0000-00-00")
                                         {
                                                 $selectedfields = explode(":",$fieldcolname);
                                                 $stdfilterlist[$fieldcolname] = $selectedfields[0].".".$selectedfields[1]." between '".$startdate."' and '".$enddate."'";
@@ -1469,19 +1471,19 @@
 					$fieldlist = explode(":",$fieldcolname);
 					if($fieldlist[4] == 2)
 					{
-					  $stdfilterlist[$fieldcolname] = "sum(".$fieldlist[1].".".$fieldlist[2].") ".$fieldlist[3];
+					  $stdfilterlist[$fieldcolname] = "sum(".$fieldlist[1].".".$fieldlist[2].") AS ".$fieldlist[3];
 					}
 					if($fieldlist[4] == 3)
 					{
-					  $stdfilterlist[$fieldcolname] = "avg(".$fieldlist[1].".".$fieldlist[2].") ".$fieldlist[3];
+					  $stdfilterlist[$fieldcolname] = "avg(".$fieldlist[1].".".$fieldlist[2].") AS ".$fieldlist[3];
 					}
 					if($fieldlist[4] == 4)
 					{
-					  $stdfilterlist[$fieldcolname] = "min(".$fieldlist[1].".".$fieldlist[2].") ".$fieldlist[3];
+					  $stdfilterlist[$fieldcolname] = "min(".$fieldlist[1].".".$fieldlist[2].") AS ".$fieldlist[3];
 					}
 					if($fieldlist[4] == 5)
 					{
-					  $stdfilterlist[$fieldcolname] = "max(".$fieldlist[1].".".$fieldlist[2].") ".$fieldlist[3];
+					  $stdfilterlist[$fieldcolname] = "max(".$fieldlist[1].".".$fieldlist[2].") AS ".$fieldlist[3];
 					}
 			}
 		}

Modified: vtigercrm/branches/4.2/modules/Reports/Reports.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Reports/Reports.php (original)
+++ vtigercrm/branches/4.2/modules/Reports/Reports.php Mon Apr 24 16:29:46 2006
@@ -963,8 +963,8 @@
 		global $modules;
 		global $vtlog;
 
-		$ssql = "select relcriteria.* from report inner join selectquery on relcriteria.queryid = report.queryid";
-		$ssql.= " left join relcriteria on relcriteria.queryid = selectquery.queryid";
+		$ssql = "select relcriteria.* from report inner join selectquery on selectquery.queryid = report.queryid";
+		$ssql.= " left join relcriteria on relcriteria.queryid = report.queryid";
 		$ssql.= " where report.reportid =".$reportid." order by relcriteria.columnindex";
 
 		$result = $adb->query($ssql);

Modified: vtigercrm/branches/4.2/modules/Reports/Save.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Reports/Save.php (original)
+++ vtigercrm/branches/4.2/modules/Reports/Save.php Mon Apr 24 16:29:46 2006
@@ -36,17 +36,17 @@
 //<<<<<<<reportmodules>>>>>>>>>
 
 //<<<<<<<report>>>>>>>>>
-$reportname = $_REQUEST["reportName"];
-$reportdescription = $_REQUEST["reportDesc"];
-$reporttype = $_REQUEST["reportType"];
-$folderid = $_REQUEST["folder"];
+$reportname = $adb->quote($_REQUEST["reportName"]);
+$reportdescription = $adb->quote($_REQUEST["reportDesc"]);
+$reporttype = $adb->quote($_REQUEST["reportType"]);
+$folderid = $adb->quote($_REQUEST["folder"]);
 //<<<<<<<report>>>>>>>>>
 
 //<<<<<<<standarfilters>>>>>>>>>
 $stdDateFilterField = $_REQUEST["stdDateFilterField"];
 $stdDateFilter = $_REQUEST["stdDateFilter"];
-$startdate = $_REQUEST["startdate"];
-$enddate = $_REQUEST["enddate"];
+$startdate = $adb->database->DBTimeStamp($_REQUEST["startdate"]);
+$enddate = $adb->database->DBTimeStamp($_REQUEST["enddate"]);
 //<<<<<<<standardfilters>>>>>>>>>
 
 //<<<<<<<columnstototal>>>>>>>>>>
@@ -117,7 +117,7 @@
 		       if($genQueryId != "")
 		       {
 				$ireportsql = "insert into report (REPORTID,FOLDERID,REPORTNAME,DESCRIPTION,REPORTTYPE,QUERYID,STATE)";
-				$ireportsql .= " values (".$genQueryId.",".$folderid.",'".$reportname."','".$reportdescription."','".$reporttype."',".$genQueryId.",'CUSTOM')";
+				$ireportsql .= " values (".$genQueryId.",".$folderid.",".$reportname.",".$reportdescription.",".$reporttype.",".$genQueryId.",'CUSTOM')";
 				$ireportresult = $adb->query($ireportsql);
 				$vtlog->logthis("Reports :: Save->Successfully saved report","info");
 			       	if($ireportresult!=false)
@@ -148,7 +148,7 @@
 					//<<<<step3 reportsortcol>>>>>>>
 
 					//<<<<step5 standarfilder>>>>>>>
-					$ireportmodulesql = "insert into reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$genQueryId.",'".$stdDateFilterField."','".$stdDateFilter."','".$startdate."','".$enddate."')";
+					$ireportmodulesql = "insert into reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$genQueryId.",'".$stdDateFilterField."','".$stdDateFilter."',".$startdate.",".$enddate.")";
 					$ireportmoduleresult = $adb->query($ireportmodulesql);
 					$vtlog->logthis("Reports :: Save->Successfully saved reportdatefilter","info");
 					//<<<<step5 standarfilder>>>>>>>
@@ -214,9 +214,9 @@
 		}
 		
 		$ireportsql = "update report set";
-		$ireportsql .= " REPORTNAME='".$reportname."',";
-		$ireportsql .= " DESCRIPTION='".$reportdescription."',";
-		$ireportsql .= " REPORTTYPE='".$reporttype."'";
+		$ireportsql .= " REPORTNAME=".$reportname.",";
+		$ireportsql .= " DESCRIPTION=".$reportdescription.",";
+		$ireportsql .= " REPORTTYPE=".$reporttype."";
 		$ireportsql .= " where REPORTID=".$reportid;
 		$ireportresult = $adb->query($ireportsql);
 		$vtlog->logthis("Reports :: Save->Successfully saved report","info");
@@ -254,7 +254,7 @@
 			//echo $idelreportsortcolsql;
 
 			//<<<<step5 standarfilder>>>>>>>
-			$ireportmodulesql = "insert into reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$reportid.",'".$stdDateFilterField."','".$stdDateFilter."','".$startdate."','".$enddate."')";
+			$ireportmodulesql = "insert into reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$reportid.",'".$stdDateFilterField."','".$stdDateFilter."',".$startdate.",".$enddate.")";
 			$ireportmoduleresult = $adb->query($ireportmodulesql);
 			$vtlog->logthis("Reports :: Save->Successfully saved reportdatefilter","info");
 			//<<<<step5 standarfilder>>>>>>>

Modified: vtigercrm/branches/4.2/modules/Reports/SaveReportFolder.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Reports/SaveReportFolder.php (original)
+++ vtigercrm/branches/4.2/modules/Reports/SaveReportFolder.php Mon Apr 24 16:29:46 2006
@@ -19,8 +19,8 @@
 
 $rfid = $_REQUEST['record'];
 $mode = $_REQUEST['mode'];
-$foldername = addslashes($_REQUEST["folderName"]);
-$folderdesc = addslashes($_REQUEST["folderDesc"]);
+$foldername = $adb->quote($_REQUEST["folderName"]);
+$folderdesc = $adb->quote($_REQUEST["folderDesc"]);
 //echo $id.$mode."1".$foldername."2".$folderdesc;
 
 if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = $_REQUEST['return_module'];
@@ -32,9 +32,8 @@
 {
 	if($rfid=="")
 	{
-		$sql = "INSERT INTO reportfolder ";
-		$sql .= "(FOLDERID,FOLDERNAME,DESCRIPTION,STATE) ";
-		$sql .= "VALUES ('','".$foldername."','".$folderdesc."','CUSTOMIZED')";
+		$sql = "INSERT INTO reportfolder (foldername,description,state)
+			VALUES (".$foldername.",".$folderdesc.",'CUSTOMIZED')";
 		$result = $adb->query($sql);
 		if($result!=false)
 		{
@@ -53,8 +52,8 @@
 	if($rfid != "")
 	{
 		$sql = "update reportfolder set ";
-		$sql .= "FOLDERNAME='".$foldername."', ";
-		$sql .= "DESCRIPTION='".$folderdesc."' ";
+		$sql .= "FOLDERNAME=".$foldername.", ";
+		$sql .= "DESCRIPTION=".$folderdesc." ";
 		$sql .= "where folderid=".$rfid;
 		$result = $adb->query($sql);
 		if($result!=false)

Modified: vtigercrm/branches/4.2/modules/Settings/DeleteCustomField.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Settings/DeleteCustomField.php (original)
+++ vtigercrm/branches/4.2/modules/Settings/DeleteCustomField.php Mon Apr 24 16:29:46 2006
@@ -19,15 +19,15 @@
 $uitype = $_REQUEST["uitype"];
 
 //Deleting the CustomField from the Custom Field Table
-$query='delete from field where fieldid="'.$id.'"';
+$query="delete from field where fieldid='".$id."'";
 $adb->query($query);
 
 //Deleting from profile2field table
-$query='delete from profile2field where fieldid="'.$id.'"';
+$query="delete from profile2field where fieldid='".$id."'";
 $adb->query($query);
 
 //Deleting from def_org_field table
-$query='delete from def_org_field where fieldid="'.$id.'"';
+$query="delete from def_org_field where fieldid='".$id."'";
 $adb->query($query);
 
 //Dropping the column in the module table

Modified: vtigercrm/branches/4.2/modules/Settings/SaveConvertLead.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Settings/SaveConvertLead.php (original)
+++ vtigercrm/branches/4.2/modules/Settings/SaveConvertLead.php Mon Apr 24 16:29:46 2006
@@ -27,23 +27,23 @@
 		$contact_id_name=$lead_id."_contact";			
 		$potential_id_name=$lead_id."_potential";			
 		
-		$account_id_val=$_REQUEST[$account_id_name];
-		$contact_id_val=$_REQUEST[$contact_id_name];
-		$potential_id_val=$_REQUEST[$potential_id_name];
+		$account_id_val = (int) $_REQUEST[$account_id_name];
+		$contact_id_val = (int) $_REQUEST[$contact_id_name];
+		$potential_id_val = (int) $_REQUEST[$potential_id_name];
 
 		if($account_id_val=="None")
 		{
-			$account_id_val="";
+			$account_id_val="null";
 		}
 		if($contact_id_val=="None")
 		{
-			$contact_id_val="";
+			$contact_id_val="null";
 		}
 		if($potential_id_val =="None")	
 		{
-			$potential_id_val="";
+			$potential_id_val="null";
 		}
-		$update_sql="update convertleadmapping set accountfid='".$account_id_val."',contactfid='".$contact_id_val."',potentialfid='".$potential_id_val."' where leadfid=".$lead_id;
+		$update_sql="update convertleadmapping set accountfid=".$account_id_val.",contactfid=".$contact_id_val.",potentialfid=".$potential_id_val." where leadfid=".$lead_id;
 
 		$adb->query($update_sql);
 	}

Modified: vtigercrm/branches/4.2/modules/Settings/UpdateComboValues.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Settings/UpdateComboValues.php (original)
+++ vtigercrm/branches/4.2/modules/Settings/UpdateComboValues.php Mon Apr 24 16:29:46 2006
@@ -34,8 +34,10 @@
 	{
 		if($custom)
 			$query = "insert into ".$tableName." values('".$pickArray[$i]."')";
-		else
-			$query = "insert into ".$tableName." values('','".$pickArray[$i]."',".$i.",1)";
+		else {
+			$id = $adb->getUniqueID($tableName);
+			$query = "insert into ".$tableName." values($id,'".$pickArray[$i]."',".$i.",1)";
+		}
 
                 $adb->query($query);
 	}

Modified: vtigercrm/branches/4.2/modules/Users/ListView.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Users/ListView.php (original)
+++ vtigercrm/branches/4.2/modules/Users/ListView.php Mon Apr 24 16:29:46 2006
@@ -66,21 +66,22 @@
 
 	$where_clauses = Array();
 	
-	if(isset($last_name) && $last_name != "") array_push($where_clauses, "last_name like ".PearDatabase::quote($last_name.'%')."");
-	if(isset($first_name) && $first_name != "") array_push($where_clauses, "first_name like ".PearDatabase::quote($first_name.'%')."");
-	if(isset($user_name) && $user_name != "") array_push($where_clauses, "user_name like ".PearDatabase::quote($user_name.'%')."");
+	$adb->checkConnection();
+	if(isset($last_name) && $last_name != "") array_push($where_clauses, "last_name ".$adb->getLike()." ".PearDatabase::quote($last_name.'%')."");
+	if(isset($first_name) && $first_name != "") array_push($where_clauses, "first_name ".$adb->getLike()." ".PearDatabase::quote($first_name.'%')."");
+	if(isset($user_name) && $user_name != "") array_push($where_clauses, "user_name ".$adb->getLike()." ".PearDatabase::quote($user_name.'%')."");
 	if(isset($status) && $status != "") array_push($where_clauses, "status = ".PearDatabase::quote($status)."");
 	if(isset($is_admin) && $is_admin != "") array_push($where_clauses, "is_admin = ".PearDatabase::quote($is_admin)."");
-	if(isset($phone) && $phone != "") array_push($where_clauses, "(phone_home like ".PearDatabase::quote('%'.$phone.'%')." OR phone_mobile like ".PearDatabase::quote('%'.$phone.'%')." OR phone_work like ".PearDatabase::quote('%'.$phone.'%')." OR phone_other like ".PearDatabase::quote('%'.$phone.'%')." OR phone_fax like ".PearDatabase::quote('%'.$phone.'%').")");
-	if(isset($email) && $email != "") array_push($where_clauses, "(users.email1 like ".PearDatabase::quote($email.'%')." OR users.email2 like ".PearDatabase::quote($email.'%').")");
-	if(isset($yahoo_id) && $yahoo_id != "") array_push($where_clauses, "yahoo_id like ".PearDatabase::quote($yahoo_id.'%')."");
-	if(isset($department) && $department != "") array_push($where_clauses, "department like ".PearDatabase::quote($department.'%')."");
-	if(isset($title) && $title != "") array_push($where_clauses, "title like ".PearDatabase::quote($title.'%')."");
-	if(isset($address_street) && $address_street != "") array_push($where_clauses, "address_street like ".PearDatabase::quote($address_street.'%')."");
-	if(isset($address_city) && $address_city != "") array_push($where_clauses, "address_city like ".PearDatabase::quote($address_city.'%')."");
-	if(isset($address_state) && $address_state != "") array_push($where_clauses, "address_state like ".PearDatabase::quote($address_state.'%')."");
-	if(isset($address_postalcode) && $address_postalcode != "") array_push($where_clauses, "address_postalcode like ".PearDatabase::quote($address_postalcode.'%')."");
-	if(isset($address_country) && $address_country != "") array_push($where_clauses, "address_country like ".PearDatabase::quote($address_country.'%')."");
+	if(isset($phone) && $phone != "") array_push($where_clauses, "(phone_home ".$adb->getLike()." ".PearDatabase::quote('%'.$phone.'%')." OR phone_mobile ".$adb->getLike()." ".PearDatabase::quote('%'.$phone.'%')." OR phone_work ".$adb->getLike()." ".PearDatabase::quote('%'.$phone.'%')." OR phone_other ".$adb->getLike()." ".PearDatabase::quote('%'.$phone.'%')." OR phone_fax ".$adb->getLike()." ".PearDatabase::quote('%'.$phone.'%').")");
+	if(isset($email) && $email != "") array_push($where_clauses, "(users.email1 ".$adb->getLike()." ".PearDatabase::quote($email.'%')." OR users.email2 ".$adb->getLike()." ".PearDatabase::quote($email.'%').")");
+	if(isset($yahoo_id) && $yahoo_id != "") array_push($where_clauses, "yahoo_id ".$adb->getLike()." ".PearDatabase::quote($yahoo_id.'%')."");
+	if(isset($department) && $department != "") array_push($where_clauses, "department ".$adb->getLike()." ".PearDatabase::quote($department.'%')."");
+	if(isset($title) && $title != "") array_push($where_clauses, "title ".$adb->getLike()." ".PearDatabase::quote($title.'%')."");
+	if(isset($address_street) && $address_street != "") array_push($where_clauses, "address_street ".$adb->getLike()." ".PearDatabase::quote($address_street.'%')."");
+	if(isset($address_city) && $address_city != "") array_push($where_clauses, "address_city ".$adb->getLike()." ".PearDatabase::quote($address_city.'%')."");
+	if(isset($address_state) && $address_state != "") array_push($where_clauses, "address_state ".$adb->getLike()." ".PearDatabase::quote($address_state.'%')."");
+	if(isset($address_postalcode) && $address_postalcode != "") array_push($where_clauses, "address_postalcode ".$adb->getLike()." ".PearDatabase::quote($address_postalcode.'%')."");
+	if(isset($address_country) && $address_country != "") array_push($where_clauses, "address_country ".$adb->getLike()." ".PearDatabase::quote($address_country.'%')."");
 
 
 	$where = "";

Modified: vtigercrm/branches/4.2/modules/Users/LoginHistory.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Users/LoginHistory.php (original)
+++ vtigercrm/branches/4.2/modules/Users/LoginHistory.php Mon Apr 24 16:29:46 2006
@@ -98,16 +98,16 @@
 	function user_login(&$usname,&$usip,&$intime)
 	{
 		//print("GS --> intime=".$intime);
-		$query = "Insert into loginhistory values ('','$usname','$usip','',".$this->db->formatDate($intime).",'Signedin')";
+		$query = "Insert into 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());
+                        or die("SQL error: ".$this->db->database->ErrorMsg());
 		
 		return $result;
 	}
 	
 	function user_logout(&$usname,&$usip,&$outtime)
 	{
-		$logid_qry = "SELECT max(login_id) login_id from loginhistory where user_name='$usname' and user_ip='$usip'";
+		$logid_qry = "SELECT max(login_id) as login_id from loginhistory where user_name='$usname' and user_ip='$usip'";
 		$result = $this->db->query($logid_qry);
 		//if($this->db->num_rows($result) !=1 ) return;
 		$loginid = $this->db->query_result($result,0,"login_id");
@@ -126,7 +126,7 @@
 		// Determine if the account name is present in the where clause.
 	//	$query = "SELECT * from loginhistory order by login_time";
 		global $current_user;
-		$query = "SELECT user_name,user_ip,".$this->db->getDBDateString("login_time")." login_time,".$this->db->getDBDateString("logout_time")." logout_time,status FROM $this->table_name ";
+		$query = "SELECT user_name,user_ip,".$this->db->getDBDateString("login_time")." AS login_time,".$this->db->getDBDateString("logout_time")." AS logout_time,status FROM $this->table_name ";
 		if($where != "")
 		{
 			if(!is_admin($current_user))

Modified: vtigercrm/branches/4.2/modules/Users/SaveOrgSharing.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Users/SaveOrgSharing.php (original)
+++ vtigercrm/branches/4.2/modules/Users/SaveOrgSharing.php Mon Apr 24 16:29:46 2006
@@ -23,7 +23,7 @@
 	if($tabid != 8 && $tab_id != 14 && $tab_id != 15 && $tab_id != 18 && $tab_id != 19 && $tab_id != 16 & $tab_id != 22)
 	{
 		$reqval = $tabid.'_per';	
-		$permission=$_REQUEST[$reqval];
+		$permission = (int) $_REQUEST[$reqval];
 		$sql7="update def_org_share set permission=".$permission." where tabid=".$tabid." and ruleid=".$ruleid;
 		//echo $sql7;
 		//echo '<BR>';

Modified: vtigercrm/branches/4.2/modules/Users/SaveProfile.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Users/SaveProfile.php (original)
+++ vtigercrm/branches/4.2/modules/Users/SaveProfile.php Mon Apr 24 16:29:46 2006
@@ -15,7 +15,8 @@
 $profilename = $_REQUEST['profileName'];
 $parentProfileId= $_REQUEST['parentProfileId'];
 //Inserting values into Profile Table
-$sql1 = "insert into profile values('','".$profilename."')";
+$id = $adb->getUniqueID('profile');
+$sql1 = "insert into profile (profileid, profilename) values($id,'".$profilename."')";
 $adb->query($sql1);
 
 //Retreiving the profileid

Modified: vtigercrm/branches/4.2/modules/Users/SaveRole.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Users/SaveRole.php (original)
+++ vtigercrm/branches/4.2/modules/Users/SaveRole.php Mon Apr 24 16:29:46 2006
@@ -25,7 +25,7 @@
 }
 else
 {
-	$sql1 = "insert into role values('','".$rolename."','')";
+	$sql1 = "insert into role (name) values('".$rolename."')";
 	$adb->query($sql1);
 
 	//Retreiving the profileid

Modified: vtigercrm/branches/4.2/modules/Users/Security.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Users/Security.php (original)
+++ vtigercrm/branches/4.2/modules/Users/Security.php Mon Apr 24 16:29:46 2006
@@ -43,28 +43,28 @@
                 $table_name="user2role";
                 $table_name="role2tab";
 
- $this->db->query("INSERT INTO tab VALUES (3,'Home',0,1,'Home','','',1)");
- $this->db->query("INSERT INTO tab VALUES (7,'Leads',0,4,'Leads','','',1)");
- $this->db->query("INSERT INTO tab VALUES (6,'Accounts',0,5,'Accounts','','',1)");
- $this->db->query("INSERT INTO tab VALUES (4,'Contacts',0,6,'Contacts','','',1)");
- $this->db->query("INSERT INTO tab VALUES (2,'Potentials',0,7,'Potentials','','',1)");
- $this->db->query("INSERT INTO tab VALUES (8,'Notes',0,9,'Notes','','',1)");
- $this->db->query("INSERT INTO tab VALUES (9,'Activities',0,3,'Activities','','',1)");
- $this->db->query("INSERT INTO tab VALUES (10,'Emails',0,10,'Emails','','',1)");
- $this->db->query("INSERT INTO tab VALUES (13,'HelpDesk',0,11,'HelpDesk','','',1)");
- $this->db->query("INSERT INTO tab VALUES (14,'Products',0,8,'Products','','',1)");
- $this->db->query("INSERT INTO tab VALUES (1,'Dashboard',0,12,'Dashboards','','',1)");
- $this->db->query("INSERT INTO tab VALUES (15,'Faq',2,14,'Faq','','',1)");
- $this->db->query("INSERT INTO tab VALUES (16,'Events',2,13,'Events','','',1)");
- $this->db->query("INSERT INTO tab VALUES (17,'Calendar',0,2,'Calendar','','',1)");
- $this->db->query("INSERT INTO tab VALUES (18,'Vendor',2,15,'Vendor','','',1)");
- $this->db->query("INSERT INTO tab VALUES (19,'PriceBook',2,16,'PriceBook','','',1)");
- $this->db->query("INSERT INTO tab VALUES (20,'Quotes',0,17,'Quotes','','',1)");
- $this->db->query("INSERT INTO tab VALUES (21,'Orders',0,18,'Orders','','',1)");
- $this->db->query("INSERT INTO tab VALUES (22,'SalesOrder',2,19,'SalesOrder','','',1)");
- $this->db->query("INSERT INTO tab VALUES (23,'Invoice',0,20,'Invoice','','',1)");
- $this->db->query("INSERT INTO tab VALUES (24,'Rss',0,21,'Rss','','',1)");
- $this->db->query("INSERT INTO tab VALUES (25,'Reports',0,22,'Reports','','',1)");
+ $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',2,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,'Vendor',2,15,'Vendor',null,null,1)");
+ $this->db->query("INSERT INTO tab VALUES (19,'PriceBook',2,16,'PriceBook',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,'Orders',0,18,'Orders',null,null,1)");
+ $this->db->query("INSERT INTO tab VALUES (22,'SalesOrder',2,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)");
 //Account Details -- START
  //Block1
  $this->db->query("insert into field values (6,".$this->db->getUniqueID("field").",'accountname','account',1,'2','accountname','Account Name',1,0,0,100,1,1,1,'V~M')");	

Modified: vtigercrm/branches/4.2/modules/Users/User.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Users/User.php (original)
+++ vtigercrm/branches/4.2/modules/Users/User.php Mon Apr 24 16:29:46 2006
@@ -478,7 +478,11 @@
 	{
 		global $mod_strings;
 		
-		$query = "SELECT user_name from users where user_name='$this->user_name' AND id<>'$this->id' AND deleted=0";
+		if('' == $this->id) {
+			$query = "SELECT user_name from users where user_name='$this->user_name' AND deleted=0";
+		} else {
+			$query = "SELECT user_name from 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);
 		

Modified: vtigercrm/branches/4.2/modules/Users/UserInfoUtil.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Users/UserInfoUtil.php (original)
+++ vtigercrm/branches/4.2/modules/Users/UserInfoUtil.php Mon Apr 24 16:29:46 2006
@@ -425,6 +425,7 @@
   global $adb;
   $sqldelete = "delete from users2group where userid = '" .$userid ."'";
   $result_delete = $adb->query($sqldelete);
+  if($groupname == '') return;
   $sql = "insert into users2group(groupname,userid) values('" .$groupname ."','" .$userid ."')";
   $result = $adb->query($sql);
 }
@@ -442,6 +443,7 @@
 function insertUsers2GroupMapping($groupname,$userid)
 {
   global $adb;
+  if($groupname == '') return;
   $sql = "insert into users2group(groupname,userid) values('" .$groupname ."','" .$userid ."')";
   $adb->query($sql);
 }
@@ -527,6 +529,7 @@
 function insert2LeadGroupRelation($leadid,$groupname)
 {
 global $adb;
+  if($groupname == '') return;
   $sql = "insert into leadgrouprelation values (" .$leadid .",'".$groupname."')";
   $adb->query($sql);
 
@@ -536,6 +539,7 @@
  global $adb;
   $sqldelete = "delete from leadgrouprelation where leadid=".$leadid;
   $adb->query($sqldelete);
+  if($groupname == '') return;
   $sql = "insert into leadgrouprelation values (".$leadid .",'" .$groupname ."')";  
   $adb->query($sql);
 
@@ -545,6 +549,7 @@
  global $adb;
   $sqldelete = "delete from ticketgrouprelation where ticketid=".$ticketid;
   $adb->query($sqldelete);
+  if($groupname == '') return;
   $sql = "insert into ticketgrouprelation values (".$ticketid .",'" .$groupname ."')";  
   $adb->query($sql);
 
@@ -553,6 +558,7 @@
 function insert2ActivityGroupRelation($activityid,$groupname)
 {
 global $adb;
+  if($groupname == '') return;
   $sql = "insert into activitygrouprelation values (" .$activityid .",'".$groupname."')";
   $adb->query($sql);
 
@@ -561,6 +567,7 @@
 function insert2TicketGroupRelation($ticketid,$groupname)
 {
 global $adb;
+  if($groupname == '') return;
   $sql = "insert into ticketgrouprelation values (" .$ticketid .",'".$groupname."')";
   $adb->query($sql);
 

Modified: vtigercrm/branches/4.2/modules/Users/massdelete.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Users/massdelete.php (original)
+++ vtigercrm/branches/4.2/modules/Users/massdelete.php Mon Apr 24 16:29:46 2006
@@ -25,7 +25,8 @@
 $storearray = explode(";",$idlist);
 foreach($storearray as $id)
 {
-	$sql="update crmentity set crmentity.deleted=1 where crmentity.crmid='" .$id ."'";
+	if('' == $id) continue;
+	$sql="update crmentity set deleted=1 where crmid='" .$id ."'";
 	$result = $adb->query($sql);
 }
 if(isset($_REQUEST['smodule']) && ($_REQUEST['smodule']!=''))

Modified: vtigercrm/branches/4.2/modules/Users/saveemailtemplate.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Users/saveemailtemplate.php (original)
+++ vtigercrm/branches/4.2/modules/Users/saveemailtemplate.php Mon Apr 24 16:29:46 2006
@@ -27,13 +27,14 @@
 	  $vtlog->logthis("the body is ".$body,'debug');  
 if ($body !='')
 {
-	$body = to_html($body);
+	$body = $adb->database->qstr(to_html($body));
+	$description = $adb->database->qstr($description);
 	  $vtlog->logthis("the body value is set ",'info');  
 }
 if(isset($templateid) && $templateid !='')
 {
 	$vtlog->logthis("the templateid is set",'info');  
-	$sql = "update emailtemplates set foldername = '".$folderName."', templatename ='".$templateName."', subject ='".$subject."', description ='".$description."', body ='".$body."' where templateid =".$templateid;
+	$sql = "update emailtemplates set foldername = '".$folderName."', templatename ='".$templateName."', subject ='".$subject."', description =".$description.", body =".$body." where templateid =".$templateid;
 	$adb->query($sql);
  
 	$vtlog->logthis("about to invoke the detailviewemailtemplate file",'info');  
@@ -41,7 +42,7 @@
 }
 else
 {
-	$sql = "insert into emailtemplates values ('". $folderName. "','".$templateName."','".$subject."','".$description."','".$body."',0,".$db->getUniqueID('emailtemplates').")";
+	$sql = "insert into emailtemplates values ('". $folderName. "','".$templateName."','".$subject."',".$description.",".$body.",0,".$db->getUniqueID('emailtemplates').")";
 	$adb->query($sql);
 
 	$vtlog->logthis("added to the db the emailtemplate",'info');  

Modified: vtigercrm/branches/4.2/modules/Users/updateLeadDBStatus.php
==============================================================================
--- vtigercrm/branches/4.2/modules/Users/updateLeadDBStatus.php (original)
+++ vtigercrm/branches/4.2/modules/Users/updateLeadDBStatus.php Mon Apr 24 16:29:46 2006
@@ -21,6 +21,7 @@
 
 global $adb;
 $storearray = explode(";",$idlist);
+$storearray = array_filter($storearray);
 
 $date_var = date('YmdHis');
 if(isset($_REQUEST['user_id']) && $_REQUEST['user_id']!='')

Modified: vtigercrm/branches/4.2/modules/uploads/add2db.php
==============================================================================
--- vtigercrm/branches/4.2/modules/uploads/add2db.php (original)
+++ vtigercrm/branches/4.2/modules/uploads/add2db.php Mon Apr 24 16:29:46 2006
@@ -40,7 +40,7 @@
 		$current_id = $adb->getUniqueID("crmentity");
 		$desc = $_REQUEST['txtDescription'];
 		$description = addslashes($desc);
-		$date_var = date('YmdHis');
+		$date_var = $adb->database->DBTimeStamp(date('YmdHis'));
 
 		//$data = addslashes(fread(fopen($uploaddir.$binFile, "r"), $filesize));
 		$filenameBase64 = $filename.".base64";
@@ -50,8 +50,8 @@
 		fwrite($wfh,base64_encode(fread($rfh, $filesize)));
 		deleteFile($uploaddir,$filename);
 		
-		$query = "insert into crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime) values('";
-		$query .= $current_id."','".$current_user->id."','".$current_user->id."','".$_REQUEST['return_module'].' Attachment'."','".$description."','".$date_var."')";
+		$query = "insert into crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values('";
+		$query .= $current_id."','".$current_user->id."','".$current_user->id."','".$_REQUEST['return_module'].' Attachment'."','".$description."',".$date_var.",".$date_var.")";
 		$result = $adb->query($query);
 
 		$sql = "insert into attachments values(";

Modified: vtigercrm/branches/4.2/schema/DatabaseSchema.xml
==============================================================================
--- vtigercrm/branches/4.2/schema/DatabaseSchema.xml (original)
+++ vtigercrm/branches/4.2/schema/DatabaseSchema.xml Mon Apr 24 16:29:46 2006
@@ -915,7 +915,6 @@
 		</field>
 
        		<field name="date_start" type="D">      
-			<NOTNULL/>
                         </field>                        
 		<field name="due_date" type="D">      
                         </field>                        
@@ -2034,18 +2033,6 @@
 	</table>
 
 
-
-	<table name="seticketsrel" alter="true">
-		
-		<constraint>ADD CONSTRAINT fk_SeTicketsRel1 FOREIGN KEY (crmid) REFERENCES crmentity(crmid) ON DELETE CASCADE</constraint>
-		
-		<opt>Type=InnoDB</opt>
-		
-		<data>
-		</data>
-	</table>
-
-
 	<table name="seticketsrel" alter="true">
 		
 		<constraint>ADD CONSTRAINT fk_SeTicketsRel2 FOREIGN KEY (ticketid) REFERENCES troubletickets(ticketid) ON DELETE CASCADE</constraint>
@@ -4077,13 +4064,6 @@
 
 	<table name="quotes" alter="true">
 	<constraint>ADD CONSTRAINT fk_Quotes2 FOREIGN KEY (potentialid) REFERENCES potential(potentialid) ON DELETE CASCADE</constraint>
-		<opt>Type=InnoDB</opt>
-		<data>
-		</data>
-	</table>
-
-	<table name="quotes" alter="true">
-	<constraint>ADD CONSTRAINT fk_Quotes3 FOREIGN KEY (contactid) REFERENCES contactdetails(contactid) ON DELETE CASCADE</constraint>
 		<opt>Type=InnoDB</opt>
 		<data>
 		</data>

Modified: vtigercrm/branches/4.2/sendreminder.php
==============================================================================
--- vtigercrm/branches/4.2/sendreminder.php (original)
+++ vtigercrm/branches/4.2/sendreminder.php Mon Apr 24 16:29:46 2006
@@ -33,7 +33,7 @@
 $vtlog->logthis(" invoked sendreminder ",'debug');
 
 //modified query for recurring events -Jag
- 	$query="select crmentity.crmid,activity.*,activity_reminder.reminder_time,activity_reminder.reminder_sent,activity_reminder.recurringid,recurringevents.recurringdate from activity inner join crmentity on crmentity.crmid=activity.activityid inner join activity_reminder on activity.activityid=activity_reminder.activity_id left outer join recurringevents on activity.activityid=recurringevents.activityid where DATE_FORMAT(activity.date_start,'%Y-%m-%d, %H:%i:%s') >= '".date('Y-m-d')."' and crmentity.crmid != 0 and activity.eventstatus = 'Planned' and activity_reminder.reminder_sent = 0 group by activity.activityid,recurringevents.recurringid ;";
+$query="select crmentity.crmid,activity.*,activity_reminder.reminder_time,activity_reminder.reminder_sent,activity_reminder.recurringid,recurringevents.recurringdate from activity inner join crmentity on crmentity.crmid=activity.activityid inner join activity_reminder on activity.activityid=activity_reminder.activity_id left outer join recurringevents on activity.activityid=recurringevents.activityid where ".$adb->getDBDateString('activity.date_start', 'Y-m-d, H:i:s')." >= '".date('Y-m-d')."' and crmentity.crmid != 0 and activity.eventstatus = 'Planned' and activity_reminder.reminder_sent = 0 group by activity.activityid,recurringevents.recurringid ;";
 
 $result = $adb->query($query);
 

Modified: vtigercrm/branches/4.2/soap.php
==============================================================================
--- vtigercrm/branches/4.2/soap.php (original)
+++ vtigercrm/branches/4.2/soap.php Mon Apr 24 16:29:46 2006
@@ -153,10 +153,10 @@
 }
 function add_contacts_matching_email_address(&$output_list, $email_address, &$seed_contact, &$msi_id)
 {
-	global $log;
+	global $adb, $log;
 	$safe_email_address = addslashes($email_address);
 
-	$where = "email1 like '$safe_email_address' OR email2 like '$safe_email_address'";
+	$where = "email1 ".$adb->getLike()." '$safe_email_address' OR email2 ".$adb->getLike()." '$safe_email_address'";
 	$response = $seed_contact->get_list("first_name, last_name", $where, 0);
 	$contactList = $response['list'];
 





More information about the vtigercrm-commits mailing list