Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Order Price Drop Down
05-17-2016, 10:52 AM,
#1
Order Price Drop Down
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
Reply
05-17-2016, 10:38 PM,
#2
RE: Order Price Drop Down
What if the price this time isn't the same as one of the last 3 times?
Reply
05-17-2016, 11:06 PM,
#3
RE: Order Price Drop Down
(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.

Reply
05-18-2016, 11:26 PM,
#4
RE: Order Price Drop Down
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
Reply
05-18-2016, 11:46 PM,
#5
RE: Order Price Drop Down
(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
Reply
05-19-2016, 03:12 AM,
#6
RE: Order Price Drop Down
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>'
Reply
05-19-2016, 12:45 PM,
#7
RE: Order Price Drop Down
(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.
Reply
05-23-2016, 01:18 AM,
#8
RE: Order Price Drop Down
(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.
Reply
05-24-2016, 12:23 AM,
#9
RE: Order Price Drop Down
Hi Dave, look for the locale_number_format() function in includes/MiscFunctions.php which should format the number for you.

Tim
Reply
05-24-2016, 05:22 AM,
#10
RE: Order Price Drop Down
(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.


Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)