97 lines
4.6 KiB
PHP
97 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Requests\LambdaRequest;
|
|
use DB;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
}
|
|
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
|
|
public function index(Request $request)
|
|
{
|
|
$params = $request->input();
|
|
$reports = $this->getlambda('get', 'metric', 'metric_report', 'list', $params);
|
|
//echo '<pre>'; print_r($reports); exit;
|
|
$sessions = !empty(Auth::user()->sessions) ? json_decode(Auth::user()->sessions) : [];
|
|
if(Auth::user()->id > 2) {
|
|
$sessions = DB::table('sessions')->wherein('code', $sessions)->orderby('id', 'desc')->limit(8)->get();
|
|
} else {
|
|
$sessions = DB::table('sessions')->orderby('id', 'desc')->limit(8)->get();
|
|
}
|
|
//$sessions = DB::table('sessions')->orderby('id', 'desc')->limit(8)->get();
|
|
return view('index')->with(['sessions' => $sessions, 'metrics' => isset($reports->data->metrics) ? $reports->data->metrics : [] ]);
|
|
}
|
|
|
|
|
|
public function index_old(Request $request)
|
|
{
|
|
//$actions = $this->getlambda('get', 'form', 'formaction', 'list');
|
|
//echo '<pre>'; print_r($actions); exit;
|
|
$reports = $this->getlambda('get', 'metric', 'metric_report', 'list');
|
|
//echo '<pre>'; print_r($reports); exit;
|
|
//'actions' => $actions->data->actions,
|
|
$submission = [];
|
|
if(Auth::user()->domain == 'cipla') {
|
|
$histories = LambdaRequest::postrequest('form', 'formentity/getformhistory', ['form_id' => '63c2ff17-a69c-4b47-af33-1d9909c608b6', 'user_id' => Auth::user()->user_id, 'partition' => 'rapport-'.Auth::user()->domain ]);
|
|
if(sizeof($histories->data->submissions) > 0) {
|
|
$submission['value'] = $histories->data->submissions[ sizeof($histories->data->submissions)-1 ];
|
|
$submission['questions'] = $histories->data->questions;
|
|
}
|
|
}
|
|
|
|
$response = LambdaRequest::signedrequest('post', 'metric', 'metric_report/view', ['id' => 'b4d6edba-41a9-4552-a9fa-bfc58b62b67d', 'type' => 'leaderboard', 'chart' => 'leaderboard', 'period' => 'month-0'] );
|
|
$colors = ['FECD00', '01C14B', 'FF8050', '4A5CD0', '707070'];
|
|
//return $this->view('report')->with(['periods' => $response->data->periods, 'charts' => $response->data->available_charts, 'graph' => $response->data->graph, 'post' => $post, 'colors' => $colors]);
|
|
return view('index')->with(['metrics' => $reports->data->metrics, 'submission' => $submission, 'periods' => $response->data->periods, 'charts' => $response->data->available_charts, 'graph' => $response->data->graph, 'colors' => $colors]);
|
|
}
|
|
|
|
public function myaccount(Request $request)
|
|
{
|
|
$response = LambdaRequest::signedrequest('get', 'ums', 'users/get_one', ['id' => Auth::user()->user_id ]);
|
|
//echo '<prE>'; print_r($response); exit;
|
|
$fields = [
|
|
'firstname' => ['title' => 'Firstname', 'type' => 'text', 'required' => true],
|
|
'lastname' => ['title' => 'Lastname', 'type' => 'text', 'required' => true],
|
|
'email' => ['title' => 'Email', 'type' => 'email', 'required' => true],
|
|
'phone' => ['title' => 'Phone', 'type' => 'text', 'required' => true],
|
|
'employee_code' => ['title' => 'Employee Code', 'type' => 'text', 'required' => true],
|
|
'state' => ['title' => 'State', 'type' => 'text', 'required' => true],
|
|
'city' => ['title' => 'City', 'type' => 'text', 'required' => true],
|
|
'pincode' => ['title' => 'Pincode', 'type' => 'text', 'required' => true],
|
|
'address' => ['title' => 'Address', 'type' => 'textarea'],
|
|
'avatar' => ['title' => 'Avatar', 'type' => 'image'],
|
|
];
|
|
|
|
return $this->view('form')->with([
|
|
'title' => 'My Account',
|
|
'mode' => 'edit',
|
|
'fields' => $fields,
|
|
'base_url' => '/myaccount',
|
|
'item' => $response->data->item
|
|
]);
|
|
}
|
|
|
|
public function postmyaccount(Request $request) {
|
|
$post = $request->except('token');
|
|
$post['id'] = Auth::user()->user_id;
|
|
$response = LambdaRequest::signedrequest('post', 'ums', 'users/update', $post);
|
|
if($response->statusCode == 200 && $response->status == "success") {
|
|
return redirect('/myaccount')->withMessage('Successfully Saved !!!');
|
|
} else {
|
|
return \Redirect::back()->withMessage('Some Error occured!');
|
|
}
|
|
}
|
|
}
|