webERP Forum
Order Price Drop Down - Printable Version

+- webERP Forum (http://www.weberp.org/forum)
+-- Forum: webERP Discussion (http://www.weberp.org/forum/forumdisplay.php?fid=1)
+--- Forum: Development Discussion & Specification (http://www.weberp.org/forum/forumdisplay.php?fid=10)
+--- Thread: Order Price Drop Down (/showthread.php?tid=2758)

Pages: 1 2


Order Price Drop Down - daveparrish - 05-17-2016

I would like to be able to have it where we can select the price when placing an order for the item, this list would contain the last three prices paid for the item and be able to select one of them.
Can anyone guide me how to accomplish this?
Thanks
Dave


RE: Order Price Drop Down - agaluski - 05-17-2016

What if the price this time isn't the same as one of the last 3 times?


RE: Order Price Drop Down - daveparrish - 05-17-2016

(05-17-2016, 10:38 PM)agaluski Wrote: What if the price this time isn't the same as one of the last 3 times?
They should have the ability to change it there then.




RE: Order Price Drop Down - agaluski - 05-18-2016

Is this on the purchasing or sales side?
Does it matter the partner (last 3 for this supplier/customer or last 3 period)?
What if pricing is setup in the system - ignore it and use this logic? or use system defined pricing and show this next to it?
Last 3 prices period or last 3 different prices? example:
If the prices were from most recent to oldest $1.00, 1.02, $1.00, $1.00 and $1.04 and $1.06 would you want to see 1.00, 1.02 and 1.00 or 1.00, 1.02 and 1.04


RE: Order Price Drop Down - daveparrish - 05-18-2016

(05-18-2016, 11:26 PM)agaluski Wrote: Is this on the purchasing or sales side?
Does it matter the partner (last 3 for this supplier/customer or last 3 period)?
What if pricing is setup in the system - ignore it and use this logic? or use system defined pricing and show this next to it?
Last 3 prices period or last 3 different prices? example:
If the prices were from most recent to oldest $1.00, 1.02, $1.00, $1.00 and $1.04 and $1.06 would you want to see 1.00, 1.02 and 1.00 or 1.00, 1.02 and 1.04
This is on the sales side.
Partner customer.
Ignore pricing and use this logic.
Last 3 prices period.
Thanks



RE: Order Price Drop Down - agaluski - 05-19-2016

Not fully tested but this is a poor man's version - to display the last 3 prices for this customer/item under the price input field. No price override, nothing fancy with selecting but it might get you started.
I am using a modified version of 4.11 so your lines numbers and details might be slightly different.

Around line 1500 inside the "foreach ($_SESSION['Items'.$identifier]->LineItems as $OrderLine) {" loop and before the next 'echo' add this code:
PHP Code:
$last3sql "SELECT unitprice
                        FROM salesorderdetails
                        INNER JOIN salesorders ON salesorders.orderno=salesorderdetails.orderno
                        WHERE salesorderdetails.stkcode= '" 
$OrderLine->StockID "'
                        AND salesorders.debtorno = '" 
$_SESSION['Items'.$identifier]->DebtorNo "'
                        ORDER by salesorders.orddate DESC LIMIT 3"
;
            
            
$ErrMsg _('The details for the last 3 prices cannot be retrieved');
            
$DbgMsg _('SQL used to retrieve the details was') . ':<br />' $last3sql;
            
$last3result =DB_query($last3sql,$db,$ErrMsg,$DbgMsg);
            
$last3=array();
            while (
$mylast3=DB_fetch_array($last3result)) {
                
$last3[]=$mylast3['unitprice'];
            } 
Then change this line:
PHP Code:
echo '<td><input class="number" type="text" required="required" name="Price_' $OrderLine->LineNumber '" size="16" maxlength="16" value="' locale_number_format($OrderLine->Price,$_SESSION['StandardCostDecimalPlaces'])  . '" title="' _('Enter the price to charge the customer for this item') . '" /></td>
                    <td><input class="number" type="text" required="required" name="Discount_' 
$OrderLine->LineNumber '" size="5" maxlength="6" value="' locale_number_format(($OrderLine->DiscountPercent 100),2) . '" title="' _('Enter the discount percentage to apply to the price for this item') . '" /></td>
                    <td><input class="number" type="text" required="required" name="GPPercent_' 
$OrderLine->LineNumber '" size="4" maxlength="40" value="' locale_number_format($OrderLine->GPPercent,2) . '" title="' _('Enter a gross profit percentage to use as the basis to calculate the price to charge the customer for this line item') . '" /></td>'
To this:
PHP Code:
echo '<td><input class="number" type="text" required="required" name="Price_' $OrderLine->LineNumber '" size="16" maxlength="16" value="' locale_number_format($OrderLine->Price,$_SESSION['StandardCostDecimalPlaces'])  . '" title="' _('Enter the price to charge the customer for this item') . '" />
                    <br>' 
                    
implode("<br>",$last3) . 
                    
'</td>
                    <td><input class="number" type="text" required="required" name="Discount_' 
$OrderLine->LineNumber '" size="5" maxlength="6" value="' locale_number_format(($OrderLine->DiscountPercent 100),2) . '" title="' _('Enter the discount percentage to apply to the price for this item') . '" /></td>
                    <td><input class="number" type="text" required="required" name="GPPercent_' 
$OrderLine->LineNumber '" size="4" maxlength="40" value="' locale_number_format($OrderLine->GPPercent,2) . '" title="' _('Enter a gross profit percentage to use as the basis to calculate the price to charge the customer for this line item') . '" /></td>'



RE: Order Price Drop Down - daveparrish - 05-19-2016

(05-19-2016, 03:12 AM)agaluski Wrote: Not fully tested but this is a poor man's version - to display the last 3 prices for this customer/item under the price input field. No price override, nothing fancy with selecting but it might get you started.
I am using a modified version of 4.11 so your lines numbers and details might be slightly different.

Around line 1500 inside the "foreach ($_SESSION['Items'.$identifier]->LineItems as $OrderLine) {" loop and before the next 'echo' add this code:
PHP Code:
$last3sql "SELECT unitprice
                        FROM salesorderdetails
                        INNER JOIN salesorders ON salesorders.orderno=salesorderdetails.orderno
                        WHERE salesorderdetails.stkcode= '" 
$OrderLine->StockID "'
                        AND salesorders.debtorno = '" 
$_SESSION['Items'.$identifier]->DebtorNo "'
                        ORDER by salesorders.orddate DESC LIMIT 3"
;
            
            
$ErrMsg _('The details for the last 3 prices cannot be retrieved');
            
$DbgMsg _('SQL used to retrieve the details was') . ':<br />' $last3sql;
            
$last3result =DB_query($last3sql,$db,$ErrMsg,$DbgMsg);
            
$last3=array();
            while (
$mylast3=DB_fetch_array($last3result)) {
                
$last3[]=$mylast3['unitprice'];
            } 
Then change this line:
PHP Code:
echo '<td><input class="number" type="text" required="required" name="Price_' $OrderLine->LineNumber '" size="16" maxlength="16" value="' locale_number_format($OrderLine->Price,$_SESSION['StandardCostDecimalPlaces'])  . '" title="' _('Enter the price to charge the customer for this item') . '" /></td>
                    <td><input class="number" type="text" required="required" name="Discount_' 
$OrderLine->LineNumber '" size="5" maxlength="6" value="' locale_number_format(($OrderLine->DiscountPercent 100),2) . '" title="' _('Enter the discount percentage to apply to the price for this item') . '" /></td>
                    <td><input class="number" type="text" required="required" name="GPPercent_' 
$OrderLine->LineNumber '" size="4" maxlength="40" value="' locale_number_format($OrderLine->GPPercent,2) . '" title="' _('Enter a gross profit percentage to use as the basis to calculate the price to charge the customer for this line item') . '" /></td>'
To this:
PHP Code:
echo '<td><input class="number" type="text" required="required" name="Price_' $OrderLine->LineNumber '" size="16" maxlength="16" value="' locale_number_format($OrderLine->Price,$_SESSION['StandardCostDecimalPlaces'])  . '" title="' _('Enter the price to charge the customer for this item') . '" />
                    <br>' 
                    
implode("<br>",$last3) . 
                    
'</td>
                    <td><input class="number" type="text" required="required" name="Discount_' 
$OrderLine->LineNumber '" size="5" maxlength="6" value="' locale_number_format(($OrderLine->DiscountPercent 100),2) . '" title="' _('Enter the discount percentage to apply to the price for this item') . '" /></td>
                    <td><input class="number" type="text" required="required" name="GPPercent_' 
$OrderLine->LineNumber '" size="4" maxlength="40" value="' locale_number_format($OrderLine->GPPercent,2) . '" title="' _('Enter a gross profit percentage to use as the basis to calculate the price to charge the customer for this line item') . '" /></td>'
Thanks for the help just what I needed.



RE: Order Price Drop Down - daveparrish - 05-23-2016

(05-19-2016, 12:45 PM)daveparrish Wrote:
(05-19-2016, 03:12 AM)agaluski Wrote: Not fully tested but this is a poor man's version - to display the last 3 prices for this customer/item under the price input field. No price override, nothing fancy with selecting but it might get you started.
I am using a modified version of 4.11 so your lines numbers and details might be slightly different.

Around line 1500 inside the "foreach ($_SESSION['Items'.$identifier]->LineItems as $OrderLine) {" loop and before the next 'echo' add this code:
PHP Code:
$last3sql "SELECT unitprice
                        FROM salesorderdetails
                        INNER JOIN salesorders ON salesorders.orderno=salesorderdetails.orderno
                        WHERE salesorderdetails.stkcode= '" 
$OrderLine->StockID "'
                        AND salesorders.debtorno = '" 
$_SESSION['Items'.$identifier]->DebtorNo "'
                        ORDER by salesorders.orddate DESC LIMIT 3"
;
            
            
$ErrMsg _('The details for the last 3 prices cannot be retrieved');
            
$DbgMsg _('SQL used to retrieve the details was') . ':<br />' $last3sql;
            
$last3result =DB_query($last3sql,$db,$ErrMsg,$DbgMsg);
            
$last3=array();
            while (
$mylast3=DB_fetch_array($last3result)) {
                
$last3[]=$mylast3['unitprice'];
            } 
Then change this line:
PHP Code:
echo '<td><input class="number" type="text" required="required" name="Price_' $OrderLine->LineNumber '" size="16" maxlength="16" value="' locale_number_format($OrderLine->Price,$_SESSION['StandardCostDecimalPlaces'])  . '" title="' _('Enter the price to charge the customer for this item') . '" /></td>
                    <td><input class="number" type="text" required="required" name="Discount_' 
$OrderLine->LineNumber '" size="5" maxlength="6" value="' locale_number_format(($OrderLine->DiscountPercent 100),2) . '" title="' _('Enter the discount percentage to apply to the price for this item') . '" /></td>
                    <td><input class="number" type="text" required="required" name="GPPercent_' 
$OrderLine->LineNumber '" size="4" maxlength="40" value="' locale_number_format($OrderLine->GPPercent,2) . '" title="' _('Enter a gross profit percentage to use as the basis to calculate the price to charge the customer for this line item') . '" /></td>'
To this:
PHP Code:
echo '<td><input class="number" type="text" required="required" name="Price_' $OrderLine->LineNumber '" size="16" maxlength="16" value="' locale_number_format($OrderLine->Price,$_SESSION['StandardCostDecimalPlaces'])  . '" title="' _('Enter the price to charge the customer for this item') . '" />
                    <br>' 
                    
implode("<br>",$last3) . 
                    
'</td>
                    <td><input class="number" type="text" required="required" name="Discount_' 
$OrderLine->LineNumber '" size="5" maxlength="6" value="' locale_number_format(($OrderLine->DiscountPercent 100),2) . '" title="' _('Enter the discount percentage to apply to the price for this item') . '" /></td>
                    <td><input class="number" type="text" required="required" name="GPPercent_' 
$OrderLine->LineNumber '" size="4" maxlength="40" value="' locale_number_format($OrderLine->GPPercent,2) . '" title="' _('Enter a gross profit percentage to use as the basis to calculate the price to charge the customer for this line item') . '" /></td>'
Thanks for the help just what I needed.
Just one more thing how do I format the implode with two decimal places I have looked all over and have not been able find anything.



RE: Order Price Drop Down - TimSchofield - 05-24-2016

Hi Dave, look for the locale_number_format() function in includes/MiscFunctions.php which should format the number for you.

Tim


RE: Order Price Drop Down - daveparrish - 05-24-2016

(05-24-2016, 12:23 AM)falkoner Wrote: Hi Dave, look for the locale_number_format() function in includes/MiscFunctions.php which should format the number for you.

Tim

Ok here is what I did
<td class="number">' . implode ("<br>",$last3), locale_number_format($OrderLine->DecimalPlaces).'</td>

The first of the three shows the Decimal Places but not the next two.