Vtiger Mods

Modification's made to Vtiger

Purchase Order Loads From Vendor Product List

Wouldn’t it be great if when you selected the vendor for the Purchase Order the only products that are listed are the ones from that vendor?

In our application we have a lot of products in our global product list and it was getting frustrating to always have to search though the entire list when Vtiger already stores a product list for each vendor. With this mod the product list pop-up only shows the products already added to the specified vendor. You can then click to show all products if you need to.

We will be editing the following files:
include/js/Inventory.js
include/utils/ListViewUtils.php

In include/js/Inventory.js at line 79 change:

popuptype = 'inventory_prod';
	if(module == 'PurchaseOrder')
		popuptype = 'inventory_prod_po';
	var record_id = '';
    if(document.getElementsByName("account_id").length != 0)
    	record_id= document.EditView.account_id.value;
    if(record_id != '')
    	window.open("index.php?module=Products&action=Popup&html=Popup_picker&select=enable&form=HelpDeskEditView&popuptype=" popuptype "&curr_row=" rowId "&relmod_id=" record_id "&parent_module=Accounts&return_module=" module "&currencyid=" currencyid,"productWin","width=640,height=600,resizable=0,scrollbars=0,status=1,top=150,left=200");
    else
		window.open("index.php?module=Products&action=Popup&html=Popup_picker&select=enable&form=HelpDeskEditView&popuptype=" popuptype "&curr_row=" rowId "&return_module=" module "&currencyid=" currencyid,"productWin","width=640,height=600,resizable=0,scrollbars=0,status=1,top=150,left=200");
}

Into:

var record_id = '';
    if(document.getElementsByName("account_id").length != 0)
    	record_id= document.EditView.account_id.value;

	popuptype = 'inventory_prod';
	if(module == 'PurchaseOrder')
	{
		popuptype = 'inventory_prod_po';
		if(document.getElementsByName("vendor_id").length != 0)
    		record_id= document.EditView.vendor_id.value;
	}
    if(record_id != '')
    {
	if(module == 'PurchaseOrder')
	{
		window.open("index.php?module=Products&action=Popup&html=Popup_picker&select=enable&form=HelpDeskEditView&popuptype=" popuptype "&curr_row=" rowId "&relmod_id=" record_id "&parent_module=Vendors&return_module=" module "&currencyid=" currencyid,"productWin","width=640,height=600,resizable=0,scrollbars=0,status=1,top=150,left=200");
	}
	else
	{
    		window.open("index.php?module=Products&action=Popup&html=Popup_picker&select=enable&form=HelpDeskEditView&popuptype=" popuptype "&curr_row=" rowId "&relmod_id=" record_id "&parent_module=Accounts&return_module=" module "&currencyid=" currencyid,"productWin","width=640,height=600,resizable=0,scrollbars=0,status=1,top=150,left=200");
	}
    }    
	else
		window.open("index.php?module=Products&action=Popup&html=Popup_picker&select=enable&form=HelpDeskEditView&popuptype=" popuptype "&curr_row=" rowId "&return_module=" module "&currencyid=" currencyid,"productWin","width=640,height=600,resizable=0,scrollbars=0,status=1,top=150,left=200");
}

And In include/utils/ListViewUtils.php around line 3806 where there is the if statement:

if($relmodule == 'Accounts')

Extend the clause to include the following elseif

elseif($relmodule == 'Vendors')
		{
			$pro_query = "select productid from vtiger_products where vendor_id=?";
			$pro_result = $result = $adb->pquery($pro_query, array($relmod_recordid));
			$rows = $adb->num_rows($pro_result);
			if($rows != 0)
			{
				$proids_comma = "(";
				for($k=0; $k < $rows; $k  )
				{
					$product_ids = $adb->query_result($pro_result,$k,'productid');
					$proids_comma .= $product_ids;
					if($k < ($rows-1))
						$proids_comma.=',';
				}
				$proids_comma.= ")";
			}
			else
				$proids_comma = "(0)";
			$condition ="and vtiger_products.productid in ".$proids_comma;
		}

Similar Posts:


Categorised as: Products, Purchase Orders


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>