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

function get_sql_for_asset_quantity_adjustment_inquiry($asset_qty_ajt_req_no, $company_code, $employee_code){
    $sql = "SELECT id,
                    aqar_id req_id,
                    reference,
                    company_code,
                    employee_code,
                    tran_date,
                    total,
                    comment 
                    
            FROM ".TB_PREF."asset_quantity_adjustments                   
            WHERE 1 = 1 ";
   
    if($asset_qty_ajt_req_no > 0){
        $sql .= " AND aqar_id = ".db_escape($asset_qty_ajt_req_no);
    }
    if(strlen($company_code) > 0){
        $sql .= " AND company_code = ".db_escape($company_code);
    }
    if(strlen($employee_code) > 0){
        $sql .= " AND employee_code = ".db_escape($employee_code);
    }
    
    return $sql;
}
        
function view_asset_quantity_adjustment_header($asset_qty_ajt_id){
    $sql = "SELECT *                     
            FROM ".TB_PREF."asset_quantity_adjustments                   
            WHERE id = ".db_escape($asset_qty_ajt_id);
    
    $result = db_query($sql, "could not view_asset_quantity_adjustment_header");
    return db_fetch($result);
}

function view_asset_quantity_adjustment_details($asset_qty_ajt_id){
    $sql = "SELECT aqad.*,
                    am.description asset_description,
                    am.asset_code,
                    am.asset_id 
        
            FROM ".TB_PREF."asset_quantity_adjustment_details aqad
                    LEFT JOIN ".TB_PREF."asset_master am 
                        ON aqad.asset_id = am.asset_id                 
            WHERE aqad.aqa_id = ".db_escape($asset_qty_ajt_id);
    
    return db_query($sql, "could not view_asset_quantity_adjustment_details"); 
}

?>