Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prices on Product Selection form (SelectProduct.php)
06-17-2013, 11:25 PM,
#1
Prices on Product Selection form (SelectProduct.php)
Have been working through the code on this form and getting to grips with the way it displays default prices. I can see that it checks the value of DB_num_rows from the $PriceResult object and displays either the price or a "No default price ..." message accordingly, but I can not see what purpose the subsequent DB_fetch_row loop has - as far as I can see the $PriceResult query can never return more than one row. Is there a situation where this is not the case?
Reply
06-18-2013, 07:00 AM,
#2
RE: Prices on Product Selection form (SelectProduct.php)
Yes there can be any number of prices ... for different currencies, and price lists - the select product form just displays the price for the default sales type. Also, prices are set with effectivity so a price which kicks in next month for a week will be in the prices table so we need to check for the current price based on effective from < today and effective to > today
In days gone by all prices were displayed - but this was pretty ugly when there were a lot of prices set up so we changed it to just the current price for the default price list - it maybe that this loop is a legacy feature and needs to be dumped now.
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply
06-18-2013, 05:29 PM,
#3
RE: Prices on Product Selection form (SelectProduct.php)
Thankyou, Phil. Yes, I can see how that loop would have displayed multiple prices before the selection statement was changed to narrow it down to just the single one for the default date/currency/type. I agree that it is better to keep the excessive detail off an index/summary page.
Reply
06-18-2013, 08:53 PM,
#4
RE: Prices on Product Selection form (SelectProduct.php)
Reworked this a bit too:

Code:
if (DB_num_rows($PriceResult) == 0) {
            echo _('No Default Price Set in Home Currency') . '</td></tr>';
            $Price = 0;
        } else {
            $PriceRow = DB_fetch_row($PriceResult);
            $Price = $PriceRow[1];
            echo $PriceRow[0] . '</td>
                <td class="select">' . locale_number_format($Price, $_SESSION['CompanyRecord']['decimalplaces']) . '</td>
                <th class="number">' . _('Gross Profit') . '</th>
                <td class="select">';
            if ($Price > 0) {
                $GP = locale_number_format(($Price - $Cost) * 100 / $Price, 1);
            } else {
                $GP = _('N/A');
            }
            echo $GP . '%' . '</td>
                </tr>';
        }
Looks like a whole block of redundant code there - so just ditched it
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)