Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MRP - Planned Purchase Orders - Convert Link
10-20-2018, 09:18 PM (This post was last modified: 10-20-2018 09:53 PM by VortecCPI.)
Post: #1
MRP - Planned Purchase Orders - Convert Link
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


https://www.linkedin.com/in/eclipsepaulbecker
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)