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


function add_asset_material($asset_id, $component, $loc_code, $unit, $qty )                           
                           
{
    $created_by = $_SESSION['wa_current_user']->user;
    $created_on = date('Y-m-d H:i:s');
    
	$sql = "INSERT INTO ".TB_PREF."asset_transfers
                        ( asset_id, stock_id, loc_code, tran_unit, tran_qty, created_by, created_on )                            
                            
		VALUES (".db_escape($asset_id).", 
                        ".db_escape($component).", 
                        ".db_escape($loc_code).",
                        ".db_escape($unit).", 
                        ".db_escape($qty).",
                        ".db_escape($created_by).",                     
                        ".db_escape($created_on).")"; 

              	db_query($sql, "Could not insert asset material ");
        
}

//
//function update_asset_material($asset_id, $component, $loc_code, $unit, $qty)
//{
//   $sql = "UPDATE ".TB_PREF."asset_transfers 
//       
//           SET stock_id=".db_escape($component).",
//               loc_code=".db_escape($loc_code).",
//               tran_unit=".db_escape($unit).",
//               tran_qty=".db_escape($qty)."
//   
//         WHERE asset_id=".db_escape($asset_id);         
//                   
//   db_query($sql, "Could not update asset material");
//   return db_num_affected_rows();
//    
//    
// }
 
 function delete_asset_material($id)
{
    $sql = "DELETE FROM ".TB_PREF."asset_transfers WHERE id=".db_escape($id);
    db_query($sql,"Could not delete BOM item");
        
}

function get_asset_material($asset_id)
{
    $sql = "SELECT asset_id,
                   stock_id,
                   loc_code,
                   tran_unit,
                   tran_qty
                FROM ".TB_PREF."asset_transfers 
                WHERE asset_id = ".db_escape($asset_id);                    
                
	
    return db_query($sql, "The bill of material processes could not be retrieved");
        
}


function get_asset_material_for_editing($asset_id)
{
    $sql = "SELECT asset_id,
                   stock_id,
                   loc_code,
                   tran_unit,
                   tran_qty
                FROM ".TB_PREF."asset_transfers 
                WHERE asset_id = ".db_escape($asset_id);                    
                
	
    return db_query($sql, "The bill of material processes could not be retrieved");
        
}



?>
