<?php //
/**********************************************************************
***********************************************************************/
function add_project_user($project_id, $user_id)
{   
        $id_user = $_SESSION['wa_current_user']->user;
        $datetime = date('Y-m-d H:i:s');
                
        $sql = "INSERT INTO ".TB_PREF."project_users (project_id, user_id, created_by, created_on) 
                VALUES (".db_escape($project_id)
                .", ".db_escape($user_id).", ".db_escape($id_user).
                                " , ".db_escape($datetime).")";

        db_query($sql,"Project user could not be added");		
}

//function update_task_details($task_id, $description, $long_description, $start_date, $end_date, $budget, $approval_path_id)
//{
//                $id_user = $_SESSION['wa_current_user']->user;
//                $datetime = date('Y-m-d H:i:s');
//        $sql = "UPDATE ".TB_PREF."project_tasks SET description=".db_escape($description).", 
//                long_description=".db_escape($long_description).",       
//                                start_date=".db_escape(date2sql($start_date)).",
//                                end_date=".db_escape(date2sql($end_date)).",
//                                    updated_by=".db_escape($id_user).",
//                                        budget=".db_escape($budget).",
//                                            approval_path_id=".db_escape($approval_path_id).",
//                                updated_on=".db_escape($datetime)."
//                                  WHERE task_id=".db_escape($task_id);
//
//        db_query($sql,"Task could not be updated");		
//}
//
function delete_project_user($project_id, $selected_id)
{
	$sql="DELETE FROM ".TB_PREF."project_users WHERE project_id= ".db_escape($project_id).
                "AND user_id = ".db_escape($selected_id);
	db_query($sql,"task could not be deleted");			
}
//
//
function get_project_users($project_id)
{
     
        $sql = "SELECT pu.user_id,
                        pm.description,
                        u.real_name
                FROM ".TB_PREF."project_users pu,
                        ".TB_PREF."users u,
                            ".TB_PREF."projects_master pm
                        WHERE pu.project_id = ".  db_escape($project_id). "
                            AND pu.user_id = u.id 
                            AND pu.project_id = pm.project_id";
                    
        
        
	return db_query($sql,"tasks could not be retreived");
    
}
//
//function get_task_details($task_id)
//{
//	$sql = "SELECT * FROM ".TB_PREF."project_tasks WHERE task_id=".db_escape($task_id);
//	
//	$result = db_query($sql,"task details could not be retreived");
//	
//	return db_fetch($result);
//}
//function get_task_approval_path($task_id)
//{
//    $sql = "SELECT pt.approval_path_id, ap.approval_path_name 
//                FROM ".TB_PREF."project_tasks pt 
//                    LEFT JOIN ".TB_PREF."approval_path ap ON pt.approval_path_id = ap.approval_path_id 
//                        WHERE pt.task_id = ".  db_escape($task_id);
//    
//    $result = db_query($sql,"approval path could not be retreived");
//    return db_fetch($result);
//}

?>