<?php

function view_dashboard_top_suppliers_details($supplier_id, $from_date, $to_date) {
    
    $sql = "SELECT (i.unit_cost * i.qty_recd) grn_total,
                    b.id grn_no, b.delivery_date, b.purch_order_no, b.supplier_id,
                    loc.location_name 
            FROM ".TB_PREF."grn_batch b 
                JOIN ".TB_PREF."grn_items i 
                    ON i.grn_batch_id = b.id 
                JOIN ".TB_PREF."locations loc  
                    ON loc.loc_code = b.loc_code   
            WHERE delivery_date >= ".db_escape($from_date)." 
                AND delivery_date <= ".db_escape($to_date)." 
                AND supplier_id = ".db_escape($supplier_id)." 
            GROUP BY b.id ";
    
                
        return db_query($sql, "view_dashboard_top_suppliers_details");  
}
