Example #1
0
 public static function getMyEmployees($company_id, $client_id)
 {
     /* return DB::table('users as u')
        ->select(DB::raw("u.user_id, CONCAT(u.first_name, ' ', u.last_name) as full_name, o.office_name,"
                . "(SELECT start_timestamp from time_registry where user_id = u.user_id order by time_registry_id DESC Limit 1) as start_timestamp,"
                . "(SELECT status from time_registry where user_id = u.user_id order by time_registry_id DESC Limit 1) as status,"
                . "(SELECT notes from time_registry where user_id = u.user_id order by time_registry_id DESC Limit 1) as notes,"
                . "(SELECT finish_timestamp from time_registry where user_id = u.user_id order by time_registry_id DESC Limit 1) as finish_timestamp"))
        ->join('user_company as uc', 'uc.user_id', '=', 'u.user_id')
        ->join('company_office as co', 'co.company_id', '=', 'uc.company_id')
        ->join('offices as o', 'o.office_id', '=', 'co.office_id')
        ->where('uc.company_id', $company_id)
        ->groupBy('u.user_id')
        ->distinct()   
        ->get();*/
     $com = Client::get_company_names($client_id);
     if (count($com) > 0) {
         // loop to get per company of the client
         foreach ($com as $k => $v) {
             $emp = Client::get_employees($v->company_id);
             if (!empty($emp)) {
                 foreach ($emp as $x) {
                     $time_reg = Client::get_time_registry($x->user_id);
                     print_r($x);
                     print_r($time_reg);
                     //print_r(@$time_reg[0]->display_name);
                     //echo self::get_employee_status($time_reg, $v->company_name ). "<br/>";
                 }
             }
         }
     }
 }