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

//--------------------------------------------------------------------------------------------------



function get_stock_adjustment_header($trans_no)
{
    $sql = "SELECT 
                sa.*,
                l.location_name issuing_location_name,
                pm.description project_description,
                apn.value_name task_description,
                ap.approval_path_name approval_path_description,
                u.real_name requestor_name, 
                s.supp_name supplier_name, 
                dm.name customer_name 
            FROM ".TB_PREF."stock_adjustments sa 
                INNER JOIN ".TB_PREF."projects_master pm ON 
                    sa.project_id = pm.project_id 
                INNER JOIN ".TB_PREF."project_tasks pt ON 
                    sa.task_id = pt.task_id 
                INNER JOIN ".TB_PREF."locations l ON 
                    sa.location = l.loc_code 
                INNER JOIN ".TB_PREF."users u ON 
                     sa.created_by = u.id 
                LEFT JOIN ".TB_PREF."approval_path ap ON 
                    pt.approval_path_id = ap.approval_path_id 
                LEFT JOIN ".TB_PREF."list_values apn ON 
                    pt.type_id = apn.id 
                LEFT JOIN ".TB_PREF."suppliers s ON 
                    sa.supplier_id = s.supplier_id  
                LEFT JOIN ".TB_PREF."debtors_master dm ON 
                    sa.customer_id = dm.debtor_no     
                
            WHERE  
                sa.id = ".  db_escape($trans_no);
    
    $result = db_query($sql,"The adjustment transfer record could not be retreived");

    return db_fetch($result);
}

function get_stock_adjustment_header_record($trans_no)
{
    $sql = "SELECT * 
            FROM ".TB_PREF."stock_adjustments  
                WHERE  
                id = ".  db_escape($trans_no);
    
    $result = db_query($sql,"get_stock_adjustment_header_record");

    return db_fetch($result);
}

?>