[Vtigercrm-developers] Quotes must retain product add order

Joel Rydbeck Joel.Rydbeck at nubrek.com
Wed May 3 07:32:45 PDT 2006


Forgive my ignorance here, but will we be able to have custom columns for products in 5.0?  I have customers who want to track several item-specific numbers and its difficult at best in 4.2.
 
- Joel

________________________________

From: vtigercrm-developers-bounces at lists.vtigercrm.com on behalf of Dennis Grant
Sent: Wed 5/3/2006 9:30 AM
To: vtigercrm-developers at lists.vtigercrm.com
Subject: [Vtigercrm-developers] Quotes must retain product add order




Something that was a recent hot-button issue here I have addressed in
our codebase and I'd like it folded into the GA versions of 4.2 and 5.0.

The issue is that our sales team wanted Quotes to retain the order in
which products were added to the Quote.

What they are trying to do is group products according to some sort of
logical order, like this:

Product A
Accessory 1 for Product A
Accessory 2 for Product A
Accessory 3 for Product A
Product B
Accessory 1 for Product B
Accessory 2 for product B
...etc...

The intent here being that the PDF version of the quote reflect some
sort of logical grouping, so that customers and their bean counters can
follow what they are getting.

What *was* happening is that the products were being returned out of the
quotesproductrel table in key order - meaning that the order they were
displayed depended on the order that the products had been added to the
product table. This effectively randomized the order of items on the
quote and REALLY pissed them off.

After much analysis, the problem was solved as follows:

1) Added a new column "sequence" int(10) to the quotesproductrel table

2) In Quotes/Save.php, write the sequence number to the table:

------------------
//Printing the total Number of rows
$tot_no_prod = $_REQUEST['totalProductCount'];
$vtlog->logthis("The total Product Count is  ".$tot_no_prod,'debug');

for($i=1; $i<=$tot_no_prod; $i++)
{
        $product_id_var = 'hdnProductId'.$i;
        $status_var = 'hdnRowStatus'.$i;
        $qty_var = 'txtQty'.$i;
        $list_price_var = 'txtListPrice'.$i;

        $prod_id = $_REQUEST[$product_id_var];
        $prod_status = $_REQUEST[$status_var];
        $qty = $_REQUEST[$qty_var];
        $listprice = $_REQUEST[$list_price_var];

        $vtlog->logthis("Row Number: ".$i."  ProductID:
".$prod_id,'debug');

        if($prod_status != 'D')
        {
                        // DG 02 May 206 Write the sequence number to
the quotesproductrel table so we preserve the order in which the
products were added to the quote

                $query ="insert into quotesproductrel
values(".$focus->id.",".$prod_id.",".$qty.",".$listprice.", ".$i.")";
                //echo $query;
                $adb->query($query);
                //Checking the re-order level and sending mail
                updateStk($prod_id,$qty,$focus->mode,$ext_prod_arr);
        }
}
---------------------

3) Anywhere a query is made against quotesproductrel, append the text
"ORDER BY sequence" to the end of the query SQL text. This happens 3
times in includes/utils.php and once in Quotes/CreatePDF.php

This seems to do the trick nicely and appears to be backwards-compatible
with quotes that have null values in the sequence.

Could somebody fold this in to 4.2.X and 5.0 for me?

Could I also renew my plea to PLEASE PLEASE PLEASE add more comments to
the vtiger code - including the Javascript functions? Debugging can be a
nightmare tracing down the developer's intent.

Tanks,

DG

_______________________________________________
This vtiger.com email is sponsored by Zoho Planner. Still scribbling down your To-Do's on bits of paper & palms of your hands? Try the AJAX enabled, personal organizer online, Zoho Planner for FREE instead! http://zohoplanner.com/?vt




-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 7712 bytes
Desc: not available
Url : http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20060503/3efd3e15/attachment-0005.bin 


More information about the vtigercrm-developers mailing list