[Vtigercrm-commits] [vtiger-commits] r10035 - in /vtigercrm/branches/5.0.3: Smarty/templates/ include/utils/ modules/Accounts/ modules/Contacts/ modules/Leads/ modules/Potentials/ modules/Products/ modules/Users/ modules/Vendors/ schema/

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Thu Jan 11 12:39:17 EST 2007


Author: richie
Date: Thu Jan 11 10:38:54 2007
New Revision: 10035

Log:
* Revamped the Product - Lead/Account/Potential and Contact relationship. Now Product can be relate with n number of Leads/Accounts/Contact/Potentials and vice versa

Added:
    vtigercrm/branches/5.0.3/modules/Accounts/updateRelations.php
Modified:
    vtigercrm/branches/5.0.3/Smarty/templates/Popup.tpl
    vtigercrm/branches/5.0.3/Smarty/templates/RelatedListContents.tpl
    vtigercrm/branches/5.0.3/include/utils/DeleteUtils.php
    vtigercrm/branches/5.0.3/include/utils/ListViewUtils.php
    vtigercrm/branches/5.0.3/modules/Contacts/Contacts.php
    vtigercrm/branches/5.0.3/modules/Contacts/updateRelations.php
    vtigercrm/branches/5.0.3/modules/Leads/updateRelations.php
    vtigercrm/branches/5.0.3/modules/Potentials/updateRelations.php
    vtigercrm/branches/5.0.3/modules/Products/Products.php
    vtigercrm/branches/5.0.3/modules/Products/updateRelations.php
    vtigercrm/branches/5.0.3/modules/Users/DefaultDataPopulator.php
    vtigercrm/branches/5.0.3/modules/Vendors/updateRelations.php
    vtigercrm/branches/5.0.3/schema/DatabaseSchema.xml

Modified: vtigercrm/branches/5.0.3/Smarty/templates/Popup.tpl
==============================================================================
--- vtigercrm/branches/5.0.3/Smarty/templates/Popup.tpl (original)
+++ vtigercrm/branches/5.0.3/Smarty/templates/Popup.tpl Thu Jan 11 10:38:54 2007
@@ -18,7 +18,7 @@
 <script language="javascript" type="text/javascript" src="include/scriptaculous/prototype.js"></script>
 <script type="text/javascript">
 function add_data_to_relatedlist(entity_id,recordid,mod) {ldelim}
-        opener.document.location.href="index.php?module={$RETURN_MODULE}&action=updateRelations&destination_module="+mod+"&entityid="+entity_id+"&parid="+recordid+"&return_action={$RETURN_ACTION}";
+        opener.document.location.href="index.php?module={$RETURN_MODULE}&action=updateRelations&destination_module="+mod+"&entityid="+entity_id+"&parid="+recordid+"&return_module={$RETURN_MODULE}&return_action={$RETURN_ACTION}";
 {rdelim}
 
 </script>

Modified: vtigercrm/branches/5.0.3/Smarty/templates/RelatedListContents.tpl
==============================================================================
--- vtigercrm/branches/5.0.3/Smarty/templates/RelatedListContents.tpl (original)
+++ vtigercrm/branches/5.0.3/Smarty/templates/RelatedListContents.tpl Thu Jan 11 10:38:54 2007
@@ -31,7 +31,11 @@
                 {/if}
                 <td align=right>
 			{if $header eq 'Potentials'}
-                                <input title="{$APP.LBL_ADD_NEW} {$APP.Potential}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Potentials'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Potential}">
+				{if $MODULE eq 'Products'}
+					<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Potential}" LANGUAGE=javascript onclick='return window.open("index.php?module=Potentials&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+				{else}
+	                                <input title="{$APP.LBL_ADD_NEW} {$APP.Potential}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Potentials'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Potential}">
+				{/if}
                 </td>
                         {elseif $header eq 'PriceBooks'}
                                 {if $MODULE eq 'Products'}
@@ -40,12 +44,18 @@
                         {elseif $header eq 'Products'}
                                 {if $MODULE eq 'PriceBooks'}
 	                                <input title="{$APP.LBL_SELECT_PRODUCT_BUTTON_LABEL}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_PRODUCT_BUTTON_LABEL}" LANGUAGE=javascript onclick="this.form.action.value='AddProductsToPriceBook';this.form.module.value='Products';this.form.return_module.value='Products';this.form.return_action.value='PriceBookDetailView'"  type="submit" name="button"></td>
+				{elseif $MODULE eq 'Leads'}
+					<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+				{elseif $MODULE eq 'Accounts'}
+					<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+				{elseif $MODULE eq 'Contacts'}
+					<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
 				{elseif $MODULE eq 'Potentials'}
 					<input title="Change" accessKey="" class="crmbutton small save" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">&nbsp;
-					<input title="{$APP.LBL_ADD_NEW} {$APP.Product}" accessyKey="F" class="crmbutton small save" onclick="this.form.action.value='EditView';this.form.module.value='Products';this.form.return_module.value='{$MODULE}';this.form.return_action.value='{$return_modname}'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Product}"></td>
+					<!-- input title="{$APP.LBL_ADD_NEW} {$APP.Product}" accessyKey="F" class="crmbutton small save" onclick="this.form.action.value='EditView';this.form.module.value='Products';this.form.return_module.value='{$MODULE}';this.form.return_action.value='{$return_modname}'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Product}"></td -->
 
 				{elseif $MODULE eq 'Vendors'}
-					<input title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" accessyKey="F" class="crmbutton small create" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module=Products&action=Popup&return_action={$return_modname}&popuptype=detailview&form=DetailView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button" name="button" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}">
+					<input title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" accessyKey="F" class="crmbutton small create" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module=Vendors&action=Popup&return_action={$return_modname}&popuptype=detailview&form=DetailView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button" name="button" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}">
 					<input title="{$APP.LBL_ADD_NEW} {$APP.Product}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Products';this.form.return_module.value='{$MODULE}';this.form.return_action.value='{$return_modname}'; this.form.parent_id.value='';" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Product}"></td>
                                 {else}
 					<input title="{$APP.LBL_ADD_NEW} {$APP.Product}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Products';this.form.return_module.value='{$MODULE}';this.form.return_action.value='{$return_modname}'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Product}"></td>
@@ -55,19 +65,29 @@
 				{$LEADCVCOMBO} <span id="lead_list_button"><input title="{$MOD.LBL_LOAD_LIST}" accessKey="" class="crmbutton small edit" value="{$MOD.LBL_LOAD_LIST}" type="button"  name="button"></span>
 				<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Lead}" LANGUAGE=javascript onclick='return window.open("index.php?module=Leads&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
 				{/if}
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Lead}" accessyKey="F" class="crmbutton small edit" onclick="this.form.action.value='EditView';this.form.module.value='Leads'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Lead}"></td>
+				{if $MODULE eq 'Products'}
+					<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Lead}" LANGUAGE=javascript onclick='return window.open("index.php?module=Leads&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+				{else}
+					<input title="{$APP.LBL_ADD_NEW} {$APP.Lead}" accessyKey="F" class="crmbutton small edit" onclick="this.form.action.value='EditView';this.form.module.value='Leads'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Lead}"></td>
+				{/if}
+			{elseif $header eq 'Accounts'}
+				{if $MODULE eq 'Products'}
+					<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Account}" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+				{/if}
 			{elseif $header eq 'Contacts' }
 				{if $MODULE eq 'Calendar' || $MODULE eq 'Potentials' || $MODULE eq 'Vendors'}
-				<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}{$search_string}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button"></td>
+					<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}{$search_string}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button"></td>
 				{elseif $MODULE eq 'Emails'}
-				<input title="{$APP.LBL_BULK_MAILS}" accessykey="F" class="crmbutton small create" onclick="this.form.action.value='sendmail';this.form.return_action.value='DetailView';this.form.module.value='Emails';this.form.return_module.value='Emails';" name="button" value="{$APP.LBL_BULK_MAILS}" type="submit">&nbsp;
-				<input title="Change" accessKey="" class="crmbutton small create" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module=Emails&action=Popup&popuptype=detailview&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button"></td>
+					<input title="{$APP.LBL_BULK_MAILS}" accessykey="F" class="crmbutton small create" onclick="this.form.action.value='sendmail';this.form.return_action.value='DetailView';this.form.module.value='Emails';this.form.return_module.value='Emails';" name="button" value="{$APP.LBL_BULK_MAILS}" type="submit">&nbsp;
+					<input title="Change" accessKey="" class="crmbutton small create" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module=Emails&action=Popup&popuptype=detailview&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button"></td>
 				{elseif $MODULE eq 'Campaigns'}
-				{$CONTCVCOMBO}  <span id="contact_list_button"><input title="{$MOD.LBL_LOAD_LIST}" accessKey="" class="crmbutton small edit" value="{$MOD.LBL_LOAD_LIST}" type="button"  name="button"></span>
-				<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Contact}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Contacts'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Contact}"></td>
+					{$CONTCVCOMBO}  <span id="contact_list_button"><input title="{$MOD.LBL_LOAD_LIST}" accessKey="" class="crmbutton small edit" value="{$MOD.LBL_LOAD_LIST}" type="button"  name="button"></span>
+					<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+					<input title="{$APP.LBL_ADD_NEW} {$APP.Contact}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Contacts'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Contact}"></td>
+				{elseif $MODULE eq 'Products'}
+					<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
 				{else}
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Contact}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Contacts'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Contact}"></td>
+					<input title="{$APP.LBL_ADD_NEW} {$APP.Contact}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Contacts'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Contact}"></td>
 				{/if}
 			{elseif $header eq 'Activities'}
 				{if $MODULE eq 'PurchaseOrder' || $MODULE eq 'Invoice' || $MODULE eq 'SalesOrder' || $MODULE eq 'Quotes' || $MODULE eq 'Campaigns'}

Modified: vtigercrm/branches/5.0.3/include/utils/DeleteUtils.php
==============================================================================
--- vtigercrm/branches/5.0.3/include/utils/DeleteUtils.php (original)
+++ vtigercrm/branches/5.0.3/include/utils/DeleteUtils.php Thu Jan 11 10:38:54 2007
@@ -27,15 +27,28 @@
 
 	switch($module):
 	case Leads:
-		if($return_module == "Campaigns") {
+		if($return_module == "Campaigns")
+		{
 			$sql = 'delete from vtiger_campaignleadrel where leadid='.$record.' and campaignid='.$return_id;
 			$adb->query($sql);
-		} else {
+		}
+		elseif($return_module == 'Products')//Delete Lead from Product relatedlist
+		{
+			$sql = "delete from vtiger_seproductsrel where crmid=$record and productid=$return_id";
+			$adb->query($sql);
+		}
+		else
+		{
 			$sql = 'delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
 			$adb->query($sql);
 		}
 	break;
 	case Accounts:
+		if($return_module == 'Products')//Delete Account from Product relatedlist
+		{
+			$sql = "delete from vtiger_seproductsrel where crmid=$record and productid=$return_id";
+			$adb->query($sql);
+		}
 		if($return_id!='')
 		{
 			$sql ='delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
@@ -73,9 +86,9 @@
 			$sql_recentviewed ='delete from vtiger_tracker where user_id = '.$current_user->id.' and item_id = '.$record;
 			$adb->query($sql_recentviewed);
 		}
-		if($return_module == 'Products')
-		{
-			$sql = 'delete from vtiger_vendorcontactrel where contactid='.$record.' and vendorid='.$return_id;
+		if($return_module == 'Products')//Delete Contact from Product relatedlist
+		{
+			$sql = "delete from vtiger_seproductsrel where crmid=$record and productid=$return_id";
 			$adb->query($sql);
 		}
 		if($return_module == 'Vendors')
@@ -94,6 +107,11 @@
 		{
 			//we can call $focus->mark_deleted($record)
 			$sql = 'update vtiger_crmentity set deleted = 1 where crmid = '.$record;
+			$adb->query($sql);
+		}
+		if($return_module == 'Products')//Delete Potential from Product relatedlist
+		{
+			$sql = "delete from vtiger_seproductsrel where crmid=$record and productid=$return_id";
 			$adb->query($sql);
 		}
 		$sql ='delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
@@ -156,14 +174,8 @@
 			if($return_module == 'Calendar')
 				$sql = 'delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
 
-			if($return_module == 'Potentials' || $return_module == 'Accounts' || $return_module == 'Leads')
+			if($return_module == 'Leads' || $return_module == 'Accounts' || $return_module == 'Contacts' || $return_module == 'Potentials')
 				$sql = 'delete from vtiger_seproductsrel where crmid = '.$return_id.' and productid = '.$record;
-
-			$adb->query($sql);
-		}
-		if($return_module == "Contacts")
-		{
-			$sql = "UPDATE vtiger_products set contactid = '' where productid = ".$record;
 			$adb->query($sql);
 		}
 		if($return_module == "Vendors")

Modified: vtigercrm/branches/5.0.3/include/utils/ListViewUtils.php
==============================================================================
--- vtigercrm/branches/5.0.3/include/utils/ListViewUtils.php (original)
+++ vtigercrm/branches/5.0.3/include/utils/ListViewUtils.php Thu Jan 11 10:38:54 2007
@@ -1774,16 +1774,7 @@
 				ON vtiger_crmentity.crmid = vtiger_products.productid
 			LEFT JOIN vtiger_productcf
 				ON vtiger_products.productid = vtiger_productcf.productid
-			LEFT JOIN vtiger_seproductsrel
-				ON vtiger_seproductsrel.productid = vtiger_products.productid
-			WHERE vtiger_crmentity.deleted = 0
-			AND ((vtiger_seproductsrel.crmid IS NULL
-					AND (vtiger_products.contactid = 0
-						OR vtiger_products.contactid IS NULL))
-				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Leads').")
-				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Accounts').")
-				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Potentials').")
-				OR vtiger_products.contactid IN (".getReadEntityIds('Contacts').")) ";
+			WHERE vtiger_crmentity.deleted = 0";
 			break;
 	Case "Notes":
 		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.modifiedtime,
@@ -2224,12 +2215,10 @@
 				ON vtiger_seproductsrel.productid = vtiger_products.productid
 			WHERE vtiger_crmentity.deleted = 0
 			AND ((vtiger_seproductsrel.crmid IS NULL
-					OR vtiger_products.contactid = 0
-					OR vtiger_products.contactid IS NULL)
 				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Leads').")
 				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Accounts').")
 				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Potentials').")
-				OR vtiger_products.contactid IN (".getReadEntityIds('Contacts').")) ";
+				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Contacts').")) ";
 	}
 
 	if($module == "PurchaseOrder")

Modified: vtigercrm/branches/5.0.3/modules/Contacts/Contacts.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Contacts/Contacts.php (original)
+++ vtigercrm/branches/5.0.3/modules/Contacts/Contacts.php Thu Jan 11 10:38:54 2007
@@ -553,9 +553,15 @@
 		else
 			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
 
-		 $query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_contactdetails.lastname from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid left outer join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_products.contactid where vtiger_contactdetails.contactid = '.$id.' and vtiger_crmentity.deleted = 0';
+		 $query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_contactdetails.lastname 
+		 		FROM vtiger_products 
+				INNER JOIN vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid 
+				INNER JOIN vtiger_seproductsrel ON vtiger_seproductsrel.productid=vtiger_products.productid
+				INNER JOIN vtiger_contactdetails on vtiger_seproductsrel.crmid = vtiger_contactdetails.contactid 
+				where vtiger_crmentity.deleted = 0 and vtiger_contactdetails.contactid = '.$id;
+
 		$log->debug("Exiting get_products method ...");
-		 return GetRelatedList('Contacts','Products',$focus,$query,$button,$returnset);
+		return GetRelatedList('Contacts','Products',$focus,$query,$button,$returnset);
 	 }
 
 	/**

Modified: vtigercrm/branches/5.0.3/modules/Contacts/updateRelations.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Contacts/updateRelations.php (original)
+++ vtigercrm/branches/5.0.3/modules/Contacts/updateRelations.php Thu Jan 11 10:38:54 2007
@@ -13,8 +13,26 @@
 require_once('user_privileges/default_module_view.php');
 global $adb, $singlepane_view;
 $idlist = $_REQUEST['idlist'];
-$update_mod = $_REQUEST['destination_module'];
+$dest_mod = $_REQUEST['destination_module'];
 $rel_table = 'vtiger_campaigncontrel';
+
+if($singlepane_view == 'true')
+	$action = "DetailView";
+else
+	$action = "CallRelatedList";
+
+//save the relationship when we select Product from Contact RelatedList
+if($dest_mod == 'Products')
+{
+	$contactid = $_REQUEST['parid'];
+	$productid = $_REQUEST['entityid'];
+	if($contactid != '' && $productid != '')
+		$adb->query("insert into vtiger_seproductsrel values($contactid,$productid)");
+
+	$record = $contactid;
+}
+
+
 if(isset($_REQUEST['idlist']) && $_REQUEST['idlist'] != '')
 {
 	//split the string and store in an array
@@ -27,19 +45,19 @@
 	            $adb->query($sql);
 		}
 	}
-	if($singlepane_view == 'true')
-		header("Location: index.php?action=DetailView&module=Contacts&record=".$_REQUEST["parentid"]);
-	else
- 		header("Location: index.php?action=CallRelatedList&module=Contacts&record=".$_REQUEST["parentid"]);
+	$record = $_REQUEST["parentid"];
 }
 elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
 {	
-		$sql = "insert into ".$rel_table." values(".$_REQUEST["entityid"].",".$_REQUEST["parid"].")";
-		$adb->query($sql);
-		if($singlepane_view == 'true')
-			header("Location: index.php?action=DetailView&module=Contacts&record=".$_REQUEST["parid"]);
-		else
- 			header("Location: index.php?action=CallRelatedList&module=Contacts&record=".$_REQUEST["parid"]);
+	$sql = "insert into ".$rel_table." values(".$_REQUEST["entityid"].",".$_REQUEST["parid"].")";
+	$adb->query($sql);
+	$record = $_REQUEST["parid"];
 }
 
+$module = 'Contacts';
+if($_REQUEST['return_module'] != '') $module = $_REQUEST['return_module'];
+
+
+header("Location: index.php?action=$action&module=$module&record=".$record);
+
 ?>

Modified: vtigercrm/branches/5.0.3/modules/Leads/updateRelations.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Leads/updateRelations.php (original)
+++ vtigercrm/branches/5.0.3/modules/Leads/updateRelations.php Thu Jan 11 10:38:54 2007
@@ -13,8 +13,25 @@
 require_once('user_privileges/default_module_view.php');
 global $adb, $singlepane_view;
 $idlist = $_REQUEST['idlist'];
-$update_mod = $_REQUEST['destination_module'];
+$dest_mod = $_REQUEST['destination_module'];
 $rel_table = 'vtiger_campaignleadrel';
+
+if($singlepane_view == 'true')
+	$action = "DetailView";
+else
+	$action = "CallRelatedList";
+
+//save the relationship when we select Product from Lead RelatedList
+if($dest_mod == 'Products')
+{
+	$leadid = $_REQUEST['parid'];
+	$productid = $_REQUEST['entityid'];
+	if($leadid != '' && $productid != '')
+		$adb->query("insert into vtiger_seproductsrel values($leadid,$productid)");
+	
+	$record = $leadid;
+}
+
 if(isset($_REQUEST['idlist']) && $_REQUEST['idlist'] != '')
 {
 	//split the string and store in an array
@@ -27,20 +44,22 @@
 	            $adb->query($sql);
 		}
 	}
-	if($singlepane_view == 'true')
-		header("Location: index.php?action=DetailView&module=Leads&record=".$_REQUEST["parentid"]);
-	else
- 		header("Location: index.php?action=CallRelatedList&module=Leads&record=".$_REQUEST["parentid"]);
+
+	$record = $_REQUEST["parentid"];
 }
 elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
 {	
-		$sql = "insert into ".$rel_table." values(".$_REQUEST["entityid"].",".$_REQUEST["parid"].")";
-		$adb->query($sql);
+	$sql = "insert into ".$rel_table." values(".$_REQUEST["entityid"].",".$_REQUEST["parid"].")";
+	$adb->query($sql);
 
-		if($singlepane_view == 'true')
-			header("Location: index.php?action=DetailView&module=Leads&record=".$_REQUEST["parid"]);
-		else
- 			header("Location: index.php?action=CallRelatedList&module=Leads&record=".$_REQUEST["parid"]);
+	$record = $_REQUEST["parid"];
 }
 
+$module = "Leads";
+if($_REQUEST['return_module'] != '') $module = $_REQUEST['return_module'];
+
+header("Location: index.php?action=$action&module=$module&record=".$record);
+
+
+
 ?>

Modified: vtigercrm/branches/5.0.3/modules/Potentials/updateRelations.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Potentials/updateRelations.php (original)
+++ vtigercrm/branches/5.0.3/modules/Potentials/updateRelations.php Thu Jan 11 10:38:54 2007
@@ -14,6 +14,11 @@
 global $adb, $singlepane_view;
 $idlist = $_REQUEST['idlist'];
 $returnmodule = $_REQUEST['return_module'];
+
+if($singlepane_view == 'true')
+	$action = "DetailView";
+else
+	$action = "CallRelatedList";
 if(isset($_REQUEST['idlist']) && $_REQUEST['idlist'] != '')
 {
 	//split the string and store in an array
@@ -22,27 +27,23 @@
 	{
 		if($id != '')
 		{
-		$sql = "insert into vtiger_contpotentialrel values (".$id.",".$_REQUEST["parentid"] .")";
-		$adb->query($sql);
-		$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parentid"] .",".$id.")";
-		$adb->query($sql);
+			$sql = "insert into vtiger_contpotentialrel values (".$id.",".$_REQUEST["parentid"] .")";
+			$adb->query($sql);
+			$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parentid"] .",".$id.")";
+			$adb->query($sql);
 		}
 	}
-	if($singlepane_view == 'true')
-		header("Location: index.php?action=DetailView&module=Potentials&record=".$_REQUEST["parentid"]);
-	else
- 		header("Location: index.php?action=CallRelatedList&module=Potentials&record=".$_REQUEST["parentid"]);
+
+	header("Location: index.php?action=$action&module=Potentials&record=".$_REQUEST["parentid"]);
 }
 elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
 {
-		$sql = "insert into vtiger_contpotentialrel values (". $_REQUEST["entityid"] .",".$_REQUEST["parid"] .")";
-		$adb->query($sql);
-		$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parid"] .",".$_REQUEST["entityid"] .")";
-		$adb->query($sql);
-		if($singlepane_view == 'true')
-			header("Location: index.php?action=DetailView&module=Potentials&record=".$_REQUEST["parid"]);
-		else
- 			header("Location: index.php?action=CallRelatedList&module=Potentials&record=".$_REQUEST["parid"]);
+	$sql = "insert into vtiger_contpotentialrel values (". $_REQUEST["entityid"] .",".$_REQUEST["parid"] .")";
+	$adb->query($sql);
+	$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parid"] .",".$_REQUEST["entityid"] .")";
+	$adb->query($sql);
+
+	header("Location: index.php?action=$action&module=Potentials&record=".$_REQUEST["parid"]);
 }
 
 ?>

Modified: vtigercrm/branches/5.0.3/modules/Products/Products.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Products/Products.php (original)
+++ vtigercrm/branches/5.0.3/modules/Products/Products.php Thu Jan 11 10:38:54 2007
@@ -270,30 +270,142 @@
         	return getAttachmentsAndNotes('Products',$query,$id);
 	}
 
+	/**	function used to get the list of leads which are related to the product
+	 *	@param int $id - product id 
+	 *	@return array - array which will be returned from the function GetRelatedList
+	 */
+	function get_leads($id)
+	{
+		global $log, $singlepane_view, $mod_strings;
+		$log->debug("Entering get_leads(".$id.") method ...");
+
+		require_once('modules/Leads/Leads.php');
+		$focus = new Leads();
+
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_leaddetails.leadid, vtiger_crmentity.crmid, vtiger_leaddetails.firstname, vtiger_leaddetails.lastname, vtiger_leaddetails.company, vtiger_leadaddress.phone, vtiger_leadsubdetails.website, vtiger_leaddetails.email, case when (vtiger_users.user_name not like \"\") then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_crmentity.smownerid, vtiger_products.productname, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_products.expiry_date
+			FROM vtiger_leaddetails
+			INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_leaddetails.leadid
+			INNER JOIN vtiger_leadaddress ON vtiger_leadaddress.leadaddressid = vtiger_leaddetails.leadid
+			INNER JOIN vtiger_leadsubdetails ON vtiger_leadsubdetails.leadsubscriptionid = vtiger_leaddetails.leadid
+			INNER JOIN vtiger_seproductsrel ON vtiger_seproductsrel.crmid=vtiger_leaddetails.leadid
+			INNER JOIN vtiger_products ON vtiger_seproductsrel.productid = vtiger_products.productid
+			LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_leadgrouprelation ON vtiger_leaddetails.leadid = vtiger_leadgrouprelation.leadid
+			LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_leadgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 AND vtiger_products.productid = ".$id;
+
+		$log->debug("Exiting get_leads($id) method ...");
+		return GetRelatedList('Products','Leads',$focus,$query,$button,$returnset);
+        }
+
+	/**	function used to get the list of accounts which are related to the product
+	 *	@param int $id - product id 
+	 *	@return array - array which will be returned from the function GetRelatedList
+	 */
+	function get_accounts($id)
+	{
+		global $log, $singlepane_view, $mod_strings;
+		$log->debug("Entering get_accounts(".$id.") method ...");
+
+		require_once('modules/Accounts/Accounts.php');
+		$focus = new Accounts();
+
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_account.accountid, vtiger_crmentity.crmid, vtiger_account.accountname, vtiger_accountbillads.city, vtiger_account.website, vtiger_account.phone, case when (vtiger_users.user_name not like \"\") then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_crmentity.smownerid, vtiger_products.productname, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_products.expiry_date
+			FROM vtiger_account
+			INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_account.accountid
+			INNER JOIN vtiger_accountbillads ON vtiger_accountbillads.accountaddressid = vtiger_account.accountid
+			INNER JOIN vtiger_seproductsrel ON vtiger_seproductsrel.crmid=vtiger_account.accountid
+			INNER JOIN vtiger_products ON vtiger_seproductsrel.productid = vtiger_products.productid
+			LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_accountgrouprelation ON vtiger_account.accountid = vtiger_accountgrouprelation.accountid
+			LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_accountgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 AND vtiger_products.productid = ".$id;
+
+			
+		$log->debug("Exiting get_accounts method ...");
+		return GetRelatedList('Products','Accounts',$focus,$query,$button,$returnset);
+        }
+
+	/**	function used to get the list of contacts which are related to the product
+	 *	@param int $id - product id 
+	 *	@return array - array which will be returned from the function GetRelatedList
+	 */
+	function get_contacts($id)
+	{
+		global $log, $singlepane_view, $mod_strings;
+		$log->debug("Entering get_contacts(".$id.") method ...");
+
+		require_once('modules/Contacts/Contacts.php');
+		$focus = new Contacts();
+
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_contactdetails.title, vtiger_contactdetails.accountid, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, case when (vtiger_users.user_name not like \"\") then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_crmentity.smownerid, vtiger_products.productname, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_products.expiry_date
+			FROM vtiger_contactdetails
+			INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
+			INNER JOIN vtiger_seproductsrel ON vtiger_seproductsrel.crmid=vtiger_contactdetails.contactid
+			INNER JOIN vtiger_products ON vtiger_seproductsrel.productid = vtiger_products.productid
+			LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_contactgrouprelation ON vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
+			LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 AND vtiger_products.productid = ".$id;
+
+		$log->debug("Exiting get_contacts method ...");
+		return GetRelatedList('Products','Contacts',$focus,$query,$button,$returnset);
+        }
+
+
 	/**	function used to get the list of potentials which are related to the product
 	 *	@param int $id - product id 
-	 *	@return void - but this function will call the function renderRelatedPotentials with parameter query
+	 *	@return array - array which will be returned from the function GetRelatedList
 	 */
 	function get_opportunities($id)
 	{
-		global $log;
+		global $log, $singlepane_view, $mod_strings;
 		$log->debug("Entering get_opportunities(".$id.") method ...");
-		$query = "SELECT vtiger_potential.potentialid, vtiger_potential.potentialname,
-			vtiger_potential.potentialtype, vtiger_products.productid,
-			vtiger_products.productname, vtiger_products.qty_per_unit,
-			vtiger_products.unit_price, vtiger_products.expiry_date
+
+		require_once('modules/Potentials/Potentials.php');
+		$focus = new Potentials();
+
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_potential.potentialid, vtiger_crmentity.crmid, vtiger_potential.potentialname, vtiger_account.accountname, vtiger_potential.accountid, vtiger_potential.sales_stage, vtiger_potential.amount, vtiger_potential.closingdate, case when (vtiger_users.user_name not like \"\") then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_crmentity.smownerid, vtiger_products.productname, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_products.expiry_date
 			FROM vtiger_potential
-			INNER JOIN vtiger_products
-				ON vtiger_potential.productid = vtiger_products.productid
-			LEFT JOIN vtiger_potentialgrouprelation
-				ON vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
-			inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid
-			WHERE vtiger_crmentity.deleted = 0
-			AND vtiger_products.productid = ".$id;
-		$log->debug("Exiting get_opportunities method ...");
-          renderRelatedPotentials($query);
+			INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_potential.potentialid
+			INNER JOIN vtiger_account ON vtiger_potential.accountid = vtiger_account.accountid
+			INNER JOIN vtiger_seproductsrel ON vtiger_seproductsrel.crmid = vtiger_potential.potentialid
+			INNER JOIN vtiger_products ON vtiger_seproductsrel.productid = vtiger_products.productid
+			LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_potentialgrouprelation ON vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid
+			LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 AND vtiger_products.productid = ".$id;
+
+		$log->debug("Exiting get_opportunities($id) method ...");
+		return GetRelatedList('Products','Potentials',$focus,$query,$button,$returnset);
         }
 
 	/**	function used to get the list of tickets which are related to the product
@@ -315,7 +427,7 @@
 		else
 			$returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id;
 
-		$query = "SELECT vtiger_users.user_name, vtiger_users.id,
+		$query = "SELECT  case when (vtiger_users.user_name not like \"\") then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_users.id,
 			vtiger_products.productid, vtiger_products.productname,
 			vtiger_troubletickets.ticketid,
 			vtiger_troubletickets.parent_id, vtiger_troubletickets.title,
@@ -335,7 +447,8 @@
 				ON vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname
 			WHERE vtiger_crmentity.deleted = 0
 			AND vtiger_products.productid = ".$id;
-	$log->debug("Exiting get_tickets method ...");
+	
+		$log->debug("Exiting get_tickets method ...");
 		return GetRelatedList('Products','HelpDesk',$focus,$query,$button,$returnset);
 	}
 
@@ -662,18 +775,19 @@
 			LEFT JOIN vtiger_potential vtiger_ProductRelatedToPotential
 				ON vtiger_ProductRelatedToPotential.potentialid = vtiger_seproductsrel.crmid
 	
-			LEFT JOIN vtiger_contactdetails 
-				ON vtiger_contactdetails.contactid = vtiger_products.contactid
+			LEFT JOIN vtiger_contactdetails vtiger_ProductRelatedToContact 
+				ON vtiger_ProductRelatedToContact.contactid = vtiger_seproductsrel.crmid
+
 			LEFT JOIN vtiger_vendor
 				ON vtiger_vendor.vendorid = vtiger_products.vendor_id
 			
 			WHERE vtiger_crmentity.deleted = 0 AND vtiger_users.status = 'Active'
-				AND ((vtiger_seproductsrel.crmid IS NULL
-					AND (vtiger_products.contactid = 0 OR vtiger_products.contactid IS NULL))
-				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Leads').")
-				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Accounts').")
-				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Potentials').")
-				OR vtiger_products.contactid IN (".getReadEntityIds('Contacts').")) 
+				AND (
+					(vtiger_seproductsrel.crmid IS NULL)
+					OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Leads').")
+					OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Accounts').")
+					OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Potentials').")
+					OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Contacts').")) 
 			group by vtiger_products.productid
 			";
 			//ProductRelatedToLead, Account and Potential tables are added to get the Related to field

Modified: vtigercrm/branches/5.0.3/modules/Products/updateRelations.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Products/updateRelations.php (original)
+++ vtigercrm/branches/5.0.3/modules/Products/updateRelations.php Thu Jan 11 10:38:54 2007
@@ -11,30 +11,39 @@
 
 require_once('include/database/PearDatabase.php');
 global $adb;
+$dest_mod = $_REQUEST['destination_module'];
 
-//This if will be true, when we select product from vendor related list
-if($_REQUEST['destination_module']=='Products')
+//if select Lead, Account, Contact, Potential from Product RelatedList we have to insert in vtiger_seproductsrel
+if($dest_mod =='Leads' || $dest_mod =='Accounts' ||$dest_mod =='Contacts' ||$dest_mod =='Potentials')
 {
-	if($_REQUEST['parid'] != '' && $_REQUEST['entityid'] != '')
+	//For Bulk updates
+	if($_REQUEST['idlist'] != '')
 	{
-		$sql = "update vtiger_products set vendor_id=".$_REQUEST['parid']." where productid=".$_REQUEST['entityid'];
-		$adb->query($sql);
+		$entityids = explode(';',trim($_REQUEST['idlist'],';'));
+		$productid = $_REQUEST['parentid'];
 	}
-}
-if($_REQUEST['destination_module']=='Contacts')
-{
-	if($_REQUEST['smodule']=='VENDOR')
+	else
 	{
-		$sql = "insert into vtiger_vendorcontactrel values (".$_REQUEST['parid'].",".$_REQUEST['entityid'].")";
-		$adb->query($sql);
+		$entityids[] = $_REQUEST['entityid'];
+		$productid = $_REQUEST['parid'];
+	}
+	
+	foreach($entityids as $ind => $crmid)
+	{
+		if($crmid != '' && $productid != '')
+		{
+			$sql = "insert into vtiger_seproductsrel values ($crmid,$productid)";
+			$adb->query($sql);
+		}
 	}
 }
 
 $return_action = 'DetailView';
-if($_REQUEST['return_action'] != '')
-	$return_action = $_REQUEST['return_action'];
+$return_module = 'Vendors';
+if($_REQUEST['return_action'] != '') $return_action = $_REQUEST['return_action'];
+if($_REQUEST['return_module'] != '') $return_module = $_REQUEST['return_module'];
 
-header("Location:index.php?action=$return_action&module=Vendors&record=".$_REQUEST["parid"]);
+header("Location:index.php?action=$return_action&module=$return_module&record=".$_REQUEST["parid"]);
 
 
 

Modified: vtigercrm/branches/5.0.3/modules/Users/DefaultDataPopulator.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Users/DefaultDataPopulator.php (original)
+++ vtigercrm/branches/5.0.3/modules/Users/DefaultDataPopulator.php Thu Jan 11 10:38:54 2007
@@ -436,9 +436,6 @@
  $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'expiry_date','vtiger_products',1,'5','expiry_date','Support Expiry Date',1,0,0,100,8,31,1,'D~O~OTH~GE~start_date~Start Date',1,null,'BAS')");
  
 
- $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'crmid','vtiger_seproductsrel',1,'66','parent_id','Related To',1,0,0,100,10,31,1,'I~O',1,null,'BAS')");
-
- $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'contactid','vtiger_products',1,'57','contact_id','Contact Name',1,0,0,100,11,31,1,'I~O',1,null,'BAS')");
  $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'website','vtiger_products',1,'17','website','Website',1,0,0,100,12,31,1,'V~O',1,null,'BAS')");
  $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'vendor_id','vtiger_products',1,'75','vendor_id','Vendor Name',1,0,0,100,13,31,1,'I~O',1,null,'BAS')");
 $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'mfr_part_no','vtiger_products',1,'1','mfr_part_no','Mfr PartNo',1,0,0,100,14,31,1,'V~O',1,null,'BAS')");
@@ -1754,7 +1751,12 @@
 	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Invoice").",'get_invoices',7,'Invoice',0)");
 	
 	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("PriceBooks").",'get_product_pricebooks',8,'PriceBooks',0)");
-	
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Leads").",'get_leads',9,'Leads',0)");
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Accounts").",'get_accounts',10,'Accounts',0)");
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Contacts").",'get_contacts',11,'Contacts',0)");
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Potentials").",'get_opportunities',12,'Potentials',0)");
+
 		//Inserting Emails Related Lists	
 
 	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Emails").",".getTabid("Contacts").",'get_contacts',1,'Contacts',0)");

Modified: vtigercrm/branches/5.0.3/modules/Vendors/updateRelations.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Vendors/updateRelations.php (original)
+++ vtigercrm/branches/5.0.3/modules/Vendors/updateRelations.php Thu Jan 11 10:38:54 2007
@@ -15,6 +15,22 @@
 
 $idlist = $_REQUEST['idlist'];
 
+if($singlepane_view == 'true')
+	$action = "DetailView";
+else
+	$action = "CallRelatedList";
+	
+//This will be true, when we select product from vendor related list
+if($_REQUEST['destination_module']=='Products')
+{
+	if($_REQUEST['parid'] != '' && $_REQUEST['entityid'] != '')
+	{
+		$sql = "update vtiger_products set vendor_id=".$_REQUEST['parid']." where productid=".$_REQUEST['entityid'];
+		$adb->query($sql);
+		$record = $_REQUEST['parid'];
+	}
+}
+
 if(isset($_REQUEST['idlist']) && $_REQUEST['idlist'] != '')
 {
 	//split the string and store in an array
@@ -29,10 +45,8 @@
 			$adb->query($sql);
 		}
 	}
-	if($singlepane_view == 'true')
-		header("Location: index.php?action=DetailView&module=Vendors&record=".$_REQUEST["parentid"]);
-	else
- 		header("Location: index.php?action=CallRelatedList&module=Vendors&record=".$_REQUEST["parentid"]);
+ 	
+	$record = $_REQUEST["parentid"];	
 }
 
 elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
@@ -42,13 +56,12 @@
 		$adb->query($sql);
 		$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parid"] .",".$_REQUEST["entityid"] .")";
 		$adb->query($sql);
-		if($singlepane_view == 'true')
-			header("Location: index.php?action=DetailView&module=Vendors&record=".$_REQUEST["parid"]);
-		else
- 			header("Location:index.php?action=CallRelatedList&module=Vendors&record=".$_REQUEST["parid"]);
+		
+		$record = $_REQUEST["parid"];
 }
 
 
+header("Location:index.php?action=$action&module=Vendors&record=".$record);
 
 
 

Modified: vtigercrm/branches/5.0.3/schema/DatabaseSchema.xml
==============================================================================
--- vtigercrm/branches/5.0.3/schema/DatabaseSchema.xml (original)
+++ vtigercrm/branches/5.0.3/schema/DatabaseSchema.xml Thu Jan 11 10:38:54 2007
@@ -1106,7 +1106,6 @@
 		<field name="discontinued" type="I" size="1" />
 		<field name="usageunit" type="C" size="200" />
 		<field name="handler" type="I" size="11" />
-		<field name="contactid" type="I" size="11" />
 		<field name="currency" type="C" size="200" />
 		<field name="reorderlevel" type="I" size="11" />
 		<field name="website" type="C" size="100" />





More information about the vtigercrm-commits mailing list