<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Models;
use Session;
use Illuminate\Support\Arr;
use App\Jobs\SendNewUssdClientEmail;
use App\Jobs\SendUssdClientActiveEmail;
use App\Jobs\SendNewNotesEmailAlert;
use App\Http\Requests;
use Carbon\Carbon;



class ReportsController extends Controller
{   
    public function getRecentClients(){
        $data = [
            'page_title' => 'Recent Clients',
            'current_user' => session('current_user')
        ];
        return view('reports.recent_clients', $data);

    }
    public function getRecentClientsJson(){
        // $clients = Models\Client::where()->get();
        /*
        $clients = \DB::table('clients')
                ->whereRaw('week(created_at) = WEEK(NOW())')
                ->with('auth_user_info')
                ->get();
        */
        $clients = \DB::table('clients')
            ->join('auth_users AS aumngr', 'aumngr.id', '=', 'clients.auth_user_id')
            ->select('clients.id','clients.name', 'clients.status', 'clients.country', 'aumngr.name As accountMgr', 'clients.created_at')
            ->whereRaw("week(clients.created_at) = WEEK(NOW())")
            ->orderBy('name', 'ASC')->paginate(50);

        return response()->json($clients);

    }
}
