<?php
/**********************************************************************
***********************************************************************/

function get_item_purchase_requisition_inquiry($stock_id, $BeforeDate, $AfterDate)
{
    $before_date = date2sql($BeforeDate);
    $after_date = date2sql($AfterDate);
    $sql = "SELECT pr.project_id,
                  pr.pr_no,
                  pr.pr_complete,
                  pr.approval_status,
                  loc.location_name,
                  prd.item_pr_description, 
                  prd.quantity,
                  prd.requested_unit,
                  prd.requested_unit_qty,
                  prd.issued_qty,
                  prd.estimate_price,
                  prd.required_date,
                  prd.project_site_id,
                  prd.quantity_ordered,
                  usr.real_name,
                  prd.created_on,
                  prd.req_unit_conv_factor,
                  pm.description project_name,
                  u.name requested_unit_name 

            FROM ".TB_PREF."purchase_requisitions pr 
                JOIN ".TB_PREF."purchase_requisition_details prd 
                    ON pr.pr_no = prd.requisition_id  
                JOIN ".TB_PREF."item_units u  
                    ON u.abbr = prd.requested_unit   
                LEFT JOIN ".TB_PREF."projects_master pm  
                    ON pr.project_id = pm.project_id   
                LEFT JOIN ".TB_PREF."locations loc    
                    ON loc.loc_code = pr.location   
                LEFT JOIN ".TB_PREF."users usr   
                    ON usr.id = prd.created_by  
            WHERE pr.pr_date >= '". $after_date."'
                AND pr.pr_date <= '" . $before_date."'
                AND prd.item_code = ".db_escape($stock_id)." 
                ORDER BY pr.pr_date, prd.id";

    return db_query($sql, "could not get_item_purchase_requisition_inquiry");
}


?>



























































