Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SupplierTenders.php & DefineOfferClass.php webERP v4.07.7
05-17-2012, 10:12 AM,
#1
SupplierTenders.php & DefineOfferClass.php webERP v4.07.7
Problem A


Do the following:
1. Create new tender for items (item0, item1, item2).
2. invite vendors (vendor0, vendor1, vendor2).
3. log out
4. log in as vendor0
5. from the select box choose the third choice (View any open tenders without an offer ) then press select.
6. add the quantities, prices and delivery dates for the items (item0, item1, item2) then press process tender.
7. This redirects you to Confirm the Response For Tender page. The only shown item is the last one (item2)

Reason:

in line 542: you initiate $i but you did not increment its value inside the followed while loop. This cause all the items to have the same index which will always equals zero so each new one overwrites the previous and only the last is shown.

solution:

before the end of the while loop add this
PHP Code:
$i++; 

Problem B


Do the following:
1. log in as vendor.
2. from the select box choose the second choice (Create a new offer) then press select.
3. In the page Search for Inventory Items press search now.
4. Add prices and quantities for any 3 items and press add to offer.
5. Press Save offer.
6. Go to main menu and from the select box choose the first choice (View or amend outstanding offers).
7. Items to offer are now displayed. Try to remove any one of them by pressing on the remove link.
8. Item was not removed.

Reason:
What happens when you press the remove link is:
lines 35-39 are executed:
PHP Code:
if (isset($_GET['Delete'])) {
    
$_POST['SupplierID']=$_SESSION['offer'.$identifier]->SupplierID;
    
$_POST['TenderType']=$_GET['Type'];
    
$_SESSION['offer'.$identifier]->remove_from_offer($_GET['Delete']);

remove_from_offer() is defined in the file DefineOfferClass.php lines 148-150:
PHP Code:
function remove_from_offer(&$LineNo){
     
$this->LineItems[$LineNo]->Deleted True;

So Now the Deleted flag of lineItem (the one to be removed) has the value true. till now this is okay.
The problem is:
I. you are overwriting this flag later. Lines 290-317 where you check if this is type = 1 (first choice in the dropDownList) and the page is not refreshed (refresh button is not pressed), then fetch the offers from the database and store them into the session. So the old lineItems and all related flags of it are gone and we are back to a fresh copy from the database.

Solution:
Chang line 290 to:
PHP Code:
if (isset($_POST['TenderType']) AND $_POST['TenderType']==AND !isset($_POST['Refresh']) AND !isset($_GET['Delete'])) { 

II. Although you had set the Deleted flag to true the file DefineOfferClass.php has not any mechanism to delete the lineItems. The LineItem can be flagged as Deleted using the function remove_from_offer() but there is no part of code that makes any use of that flag to delete from the DB.

Solution:
Following changes are made to the function Save() so it can delete the LineItems when Deleted flag = true. The changes are in the Update='' else block (begins in line 107):
PHP Code:
foreach ($this->LineItems as $LineItem) {
                            if (
$LineItem->Deleted==false){  //Update only the LineItems which is not flagged as deleted
                
$sql="UPDATE offers SET
                        quantity='"
.$LineItem->Quantity."',
                        price='"
.$LineItem->Price."',
                        expirydate='"
.FormatDateForSQL($LineItem->ExpiryDate)."'
                    WHERE offerid='"
.$LineItem->LineNo "'";
                
$ErrMsg =  _('The suppliers offer could not be updated on the database because');
                
$DbgMsg _('The SQL statement used to update the suppliers offer record and failed was');
                
$result DB_query($sql,$db,$ErrMsg,$DbgMsg,true);
                if (
DB_error_no($db)==0) {
                    
prnMsg_('The offer for').' '.$LineItem->StockID.' '._('has been updated in the database'), 'success');
                    
$this->OfferMailText .= $LineItem->Quantity.' '.$LineItem->Units.' '._('of').' '.$LineItem->StockID.' '._('at a price of').
                        
' '.$this->CurrCode.$LineItem->Price."\n";
                } else {
                    
prnMsg_('The offer for').' '.$LineItem->StockID.' '._('could not be updated in the database'), 'error');
                    include(
'includes/footer.inc');
                    exit;
                }
                            } else { 
// the LineItem is Deleted flag is true so delete it
                                
$sql "DELETE from offers WHERE offerid='".$LineItem->LineNo "'";
                                
$ErrMsg =  _('The suppliers offer could not be deleted on the database because');
                
$DbgMsg _('The SQL statement used to delete the suppliers offer record and failed was');
                                
$result DB_query($sql,$db,$ErrMsg,$DbgMsg,true);
                                if (
DB_error_no($db)==0) {
                                    
prnMsg_('The offer for').' '.$LineItem->StockID.' '._('has been deleted in the database'), 'success');
                                }
                            }
            } 

This works for me. Kindly note I did not add any thing to $this->OfferMailText after the delete because I do not know what should be added to the email when some thing is deleted.
Reply
05-18-2012, 09:02 AM,
#2
RE: SupplierTenders.php & DefineOfferClass.php webERP v4.07.7
Hi, Ahmed:

Thank you for you detailed report and analysis. I'll check it and update the svn later.

Best regards!

Exson
Reply
05-18-2012, 06:34 PM,
#3
RE: SupplierTenders.php & DefineOfferClass.php webERP v4.07.7
Hi, Ahmed:

Those fixes are committed to SVN. Thank you very much!

Best regards!

Exson
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)