<?php 
//clive is an object that acts as a helper/secatarty for other objects in the khambers_msg module

    class clive 
    {
        function get_client_name($client_id)
        {
            $dataslave = new dataslave();
            $dbn = $dataslave->install_pdo_main();
            $user_query = $dbn->prepare('SELECT * FROM g_users WHERE user_id=:uID');
            $user_query->execute(array(':uID'=>$client_id));
            $user_name='';
            while($user= $user_query->fetch(PDO::FETCH_ASSOC))
            {
                $user_name = $user['user_name'];
            }
            return $user_name;
        }
        function get_lw_name($lw_id)
        {
            $dataslave = new dataslave();
            $dbn = $dataslave->install_pdo_main();
            $user_query = $dbn->prepare('SELECT * FROM lawyers WHERE lawyer_id=:lID');
            $user_query->execute(array(':lID'=>$lw_id));
            $user_name='';
            while($user= $user_query->fetch(PDO::FETCH_ASSOC))
            {
                $user_name = $user['lw_name'].' '.$user['lw_surname'];
            }
            return $user_name;
        }
        function total_space_used_lw($lw_id)
        {
            $dataslave = new dataslave();
            $dbn = $dataslave->install_pdo_docs();

            $docs_query = $dbn->prepare('SELECT * FROM documents_registry WHERE lw_id=:lID');
            $docs_query->execute(array(':lID'=>$lw_id));
            $totalMb =0;
            while($doc = $docs_query->fetch(PDO::FETCH_ASSOC))
            {
                $totalMb += $doc['doc_size'];
            }

            $totalMb = $totalMb / 1000000;
            return $totalMb;
        }

        function get_lw_email($lw_id)
        {
            $dataslave = new dataslave();
            $dbn = $dataslave->install_pdo_main();

            $get_email_query = $dbn->prepare("SELECT * FROM lawyers WHERE lawyer_id=:lwId");
            $get_email_query->execute(array(":lwId"=>$lw_id));
            $email='';
            while($lw_data = $get_email_query->fetch(PDO::FETCH_ASSOC))
            {
                $email = $lw_data['lw_email'];
            }

            return $email;
        }
    }
?>