webERP Forum

Full Version: MRP - Planned Purchase Orders - Convert Link
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
MRPPlannedPurchaseOrders.php

When items have never been ordered the "Convert" hyperlink is missing attribute data. I added code to only show the hyperlink is data is available and the data now uses either last PO or PurchData values.

Can somebody please check my hack job and commit this so others can use it?

Aroubnd line 337:

PHP Code:
list($lastdate,$lastsupplier,$preferredsupplier,$conversionfactor) = GetPartInfo($db,$myrow['part']);
            
            if (
$preferredsupplier == '') {
                
$hyperlink '';
            } else {
                
$hyperlink '<a href="' $RootPath '/PO_Header.php?NewOrder=Yes&amp;SelectedSupplier=' $preferredsupplier '&amp;StockID=' $myrow['part'] . '&amp;Quantity=' $myrow['supplyquantity']/$conversionfactor '">' _('Convert') . '</a>';
            }
            
            echo 
'<td>' $hyperlink '</td> 

Last function in the code:

PHP Code:
function GetPartInfo(&$db,$part) {
    
// Get last purchase order date and supplier for part, and also preferred supplier
    // Printed when there is a part break    
    
$sql "SELECT orddate as maxdate,
                   purchorders.orderno
            FROM purchorders INNER JOIN purchorderdetails
            ON purchorders.orderno = purchorderdetails.orderno
            WHERE purchorderdetails.itemcode = '" 
$part ."'
            ORDER BY orddate DESC LIMIT 1"
;
    
$result DB_query($sql);
    if (
DB_num_rows($result)>0) {
        
$myrow DB_fetch_array($result,$db);
        
$PartInfo[] = ConvertSQLDate($myrow['maxdate']);
        
$OrderNo$myrow['orderno'];
        
$sql "SELECT supplierno
                FROM purchorders
                WHERE purchorders.orderno = '" 
.$OrderNo"'";
        
$result DB_query($sql);
        
$myrow DB_fetch_array($result,$db);
        
$PartInfo[] = $myrow['supplierno'];
    } else {
        
$PartInfo[] = '';
        
$PartInfo[] = '';
    }
    
$sql "SELECT supplierno, conversionfactor
            FROM purchdata
            WHERE stockid = '" 
$part "'
            AND preferred='1'"
;
    
$result DB_query($sql);
    if (
DB_num_rows($result)>0) {
        
$myrow DB_fetch_array($result,$db);
        
$PartInfo[] = $myrow['supplierno'];
        
$PartInfo[] = $myrow['conversionfactor'];
    } else {
        
$PartInfo[] = '';
        
$PartInfo[] = '';
    }
    return 
$PartInfo