<?php

function dashboard_view_top_purchased_items_details($item, $from_date, $to_date) {
    
    $sql = "SELECT i.*,
                    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 i.item_code = ".db_escape($item);
    
                
        return db_query($sql, "dashboard_view_top_purchased_items_details");  
}
