diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php
index ac507077..66c04163 100644
--- a/app/Http/Controllers/ContactController.php
+++ b/app/Http/Controllers/ContactController.php
@@ -15,33 +15,48 @@ class ContactController extends Controller
$this->_viewname = 'contact';
$this->_title = 'Contact';
$this->_base_url = '/contact';
+ $this->_listtype = 'ajaxlist';
}
public function list(Request $request) {
- $response = LambdaRequest::signedrequest('get', $this->_service, $this->_module.'/get_all');
- //echo '
'; print_r($items); exit;
- $items = [];
- foreach ($response->data->items as $item) {
- $item->position = $item->hierarchy_info->code;
- unset($item->hierarchy_info);
- $items[] = $item;
- }
-
$fields = $this->get_list_fields();
- return $this->view('list')->with([
+ return $this->view($this->_listtype)->with([
'title' => $this->_title,
'fields' => $fields,
'base_url' => $this->_base_url,
- 'items' => $items,
+ //'items' => $response->data->items,
'buttons' => $this->get_list_buttons()
]);
}
+
+ // public function list(Request $request) {
+ // $response = LambdaRequest::signedrequest('get', $this->_service, $this->_module.'/get_all');
+ // //echo ''; print_r($items); exit;
+ // $items = [];
+ // foreach ($response->data->items as $item) {
+ // $item->position = $item->hierarchy_info->code;
+ // unset($item->hierarchy_info);
+ // $items[] = $item;
+ // }
+
+ // $fields = $this->get_list_fields();
+ // return $this->view('list')->with([
+ // 'title' => $this->_title,
+ // 'fields' => $fields,
+ // 'base_url' => $this->_base_url,
+ // 'items' => $items,
+ // 'buttons' => $this->get_list_buttons()
+ // ]);
+ // }
+
protected function get_list_fields(){
return [
'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete' ] ],
'name' => ['title' => 'Name', 'type' => 'text'],
- 'position' => ['title' => 'Position', 'type' => 'text'],
+ 'msl_code' => ['title' => 'MSL Code', 'type' => 'text'],
+ 'position_name' => ['title' => 'Position', 'type' => 'text'],
+ 'user_name' => ['title' => 'Rep Name', 'type' => 'text'],
'status' => ['title' => 'Status', 'type' => 'select'],
];
}
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index dc3fa8c3..cc531ee5 100755
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -21,6 +21,7 @@ class Controller extends BaseController
protected $_title;
protected $_id;
protected $_request;
+ protected $_listtype = 'list';
protected function view($viewname) {
if (\View::exists($this->_viewname.'.'.$viewname)) {
@@ -84,7 +85,7 @@ class Controller extends BaseController
}
$fields = $this->get_list_fields();
//echo ''; print_r($fields); exit;
- return $this->view('list')->with([
+ return $this->view($this->_listtype)->with([
'title' => $this->_title,
'fields' => $fields,
'base_url' => $this->_base_url,
@@ -93,6 +94,63 @@ class Controller extends BaseController
]);
}
+ public function ajaxlist(Request $request) {
+ $params = $request->input();
+ $search = [];
+ foreach($params['columns'] as $col) {
+ if($col['search']['value'] != '') {
+ $search[$col['data']] = $col['search']['value'];
+ }
+ }
+ $fields = $this->get_list_fields();
+ $response = LambdaRequest::signedrequest('get', $this->_service, $this->_module.'/get_all', ['start' => $params['start'], 'length' => $params['length'], 'search' => json_encode($search), 'keyword' => $params['search']['value'] ]);
+ Log::debug(print_r($response, true));
+
+ $users = [];
+ foreach($response->data->items as $item) {
+ $user = [];
+ foreach($fields as $field => $props){
+ if($field != 'actions') {
+ switch($props['type']){
+ case('image'):
+ $user[$field] = '
';
+ break;
+ case('text'):
+ case('select'):
+ $user[$field] = isset($item->{$field}) ? $item->{$field} : '';
+ break;
+ case('date'):
+ $user[$field] = date("d M Y", strtotime($item->{$field}));
+ break;
+ }
+ } else {
+ $user['actions'] = [];
+ foreach($props['buttons'] as $key => $button){
+ switch($button) {
+ case 'edit':
+ $user['actions'][] = ['link' => '/edit?id='.$item->id, 'icon' => 'square-edit-outline text-warning'];
+ break;
+ case 'delete':
+ $user['actions'][] = ['link' => '/delete?id='.$item->id, 'icon' => 'delete text-danger'];
+ break;
+ default:
+ $querystring = $button['querystring'];
+ foreach((array)$item as $k => $v) {
+ if(strpos($querystring,'{'.strtoupper($k).'}') !== false)
+ $querystring = str_replace('{'.strtoupper($k).'}', $v, $querystring);
+ }
+ $user['actions'][] = ['link' => '/'.$key.'?'.$querystring, 'icon' => $button['icon']];
+ break;
+ }
+ }
+ }
+ }
+ $users[] = $user;
+ }
+
+ return response()->json(['data' => $users, 'iTotalRecords' => $response->data->count, 'iTotalDisplayRecords' => $response->data->count]);
+ }
+
public function unauthorised() {
return view('common.unauthorised');
}
diff --git a/app/Http/Controllers/FormController.php b/app/Http/Controllers/FormController.php
index 41cc4e2d..27978588 100644
--- a/app/Http/Controllers/FormController.php
+++ b/app/Http/Controllers/FormController.php
@@ -62,10 +62,11 @@ class FormController extends Controller
public function handle($finfo, Request $request) {
$request->session()->put('finfo', $finfo);
$finfo = Cache::remember($finfo, 3600, function () use ($finfo) {
- return LambdaRequest::postrequest('form', 'formentity/getforminfo', ['finfo' => $finfo]);
+ return LambdaRequest::postrequest('form', 'formentity/getforminfo', ['finfo' => $finfo]);
});
-
- $request->session()->put('formdata', $finfo->data->formdata);
+ // $finfo = LambdaRequest::postrequest('form', 'formentity/getforminfo', ['finfo' => $finfo]);
+ // Log::debug(print_r($finfo, true));
+ $request->session()->put('formdata', $finfo->data->formdata);
if($finfo->status == 'success' && $finfo->data->formdata->link_type == 'form') {
return $this->deliverform($finfo->data->formdata, $finfo->data->questions);
} elseif($finfo->status == 'success' && $finfo->data->formdata->link_type == 'list') {
diff --git a/app/Http/Controllers/MetricreportController.php b/app/Http/Controllers/MetricreportController.php
index a8dd7a87..d6509550 100644
--- a/app/Http/Controllers/MetricreportController.php
+++ b/app/Http/Controllers/MetricreportController.php
@@ -60,6 +60,7 @@ class MetricreportController extends Controller
//echo ''; print_r($response); print_r($post); exit;
$colors = ['FECD00', '01C14B', 'FF8050', '4A5CD0', '707070'];
+ //echo ''; print_r(['periods' => $response->data->periods, 'charts' => $response->data->available_charts, 'graph' => $response->data->graph, 'post' => $post, 'colors' => $colors]); exit;
return $this->view('report')->with(['periods' => $response->data->periods, 'charts' => $response->data->available_charts, 'graph' => $response->data->graph, 'post' => $post, 'colors' => $colors]);
}
diff --git a/app/Http/Controllers/MetricviewController.php b/app/Http/Controllers/MetricviewController.php
index 94527a56..b3a6a4ba 100644
--- a/app/Http/Controllers/MetricviewController.php
+++ b/app/Http/Controllers/MetricviewController.php
@@ -150,7 +150,12 @@ class MetricviewController extends Controller
protected function _beforeform($type, $values) {
if ($type == 'edit') {
$values->designations = explode('#', $values->designations);
- $values->report_roles = explode('#', $values->report_roles);
+ if(isset($values->report_roles)) {
+ $values->report_roles = explode('#', $values->report_roles);
+ } else {
+ $values->report_roles = [];
+ }
+
$values->validity_start = date("d/m/Y", strtotime($values->validity_start));
$values->validity_end = date('d/m/Y', strtotime($values->validity_end));
}
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index d5f795af..83555838 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests\LambdaRequest;
use DB;
+use Log;
class UserController extends Controller
{
@@ -15,6 +16,7 @@ class UserController extends Controller
$this->_viewname = 'users';
$this->_title = 'Users';
$this->_base_url = '/user';
+ $this->_listtype = 'ajaxlist';
}
protected function get_list_fields(){
@@ -88,6 +90,7 @@ class UserController extends Controller
$channels_dd[$channel->id] = $channel->name;
}
return [
+ 'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete' ] ],
'employee_code' => ['title' => 'Employee Code', 'type' => 'text', 'required' => true],
'firstname' => ['title' => 'Firstname', 'type' => 'text', 'required' => true],
'lastname' => ['title' => 'Lastname', 'type' => 'text'],
@@ -105,4 +108,15 @@ class UserController extends Controller
'hierarchy' => ['title' => 'Heirarchy', 'type' => 'text'],
];
}
+
+ public function list(Request $request) {
+ $fields = $this->get_list_fields();
+ return $this->view($this->_listtype)->with([
+ 'title' => $this->_title,
+ 'fields' => $fields,
+ 'base_url' => $this->_base_url,
+ //'items' => $response->data->items,
+ 'buttons' => $this->get_list_buttons()
+ ]);
+ }
}
diff --git a/resources/views/common/ajaxlist.blade.php b/resources/views/common/ajaxlist.blade.php
new file mode 100644
index 00000000..d22350d2
--- /dev/null
+++ b/resources/views/common/ajaxlist.blade.php
@@ -0,0 +1,216 @@
+@extends('layouts.vertical', ["page_title"=> "Datatables"])
+
+@section('css')
+
+
+
+
+@endsection
+
+@section('content')
+
+
+
+
+
+
+
{{$title}} Management
+
+
+ @if(isset($buttons))
+ @foreach($buttons as $button)
+
{{$button['title']}}
+ @endforeach
+ @endif
+
+
+
+@if(session()->has('message'))
+
+ {{ session()->get('message') }}
+
+@endif
+@if(session()->has('error'))
+
+ {{ session()->get('error') }}
+
+@endif
+
+
+
+
+
+
+
+ @foreach($fields as $field => $props)
+ | {{$props['title']}} |
+ @endforeach
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+@endsection
+
+@section('script')
+
+
+
+
+
+@endsection
\ No newline at end of file
diff --git a/resources/views/form/list.blade.php b/resources/views/form/list.blade.php
index 5d2dfb43..ec321328 100644
--- a/resources/views/form/list.blade.php
+++ b/resources/views/form/list.blade.php
@@ -52,7 +52,7 @@
| {{date("d M Y", strtotime(isset($submission->record_date) ? $submission->record_date : $submission->updatedAt))}} |
-
+
|
{{$submission->user_info->name}}
@@ -62,7 +62,7 @@
@if(count((array)$question->options) > 0)
| {{ isset($submission->formdata->{$code}) && isset($question->options->{ $submission->formdata->{$code} }) ? $question->options->{ $submission->formdata->{$code} } : '' }} |
@else
- {{ $submission->formdata->{$code} }} |
+ {{ isset($submission->formdata->{$code}) ? $submission->formdata->{$code} : '' }} |
@endif
@endforeach
diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php
index f4a22c86..b1670fea 100755
--- a/resources/views/index.blade.php
+++ b/resources/views/index.blade.php
@@ -45,7 +45,7 @@
{{$metric->label}}
- {{$metric->value}}
+ {{$metric->value}} {{$metric->type=='verses' ? ' / ' . $metric->max : ''}}
@break
+ @case($post['type'] == 'trend' && $graph->type == 'verses' && $graph->chart == 'tabular' )
+
+
+
+
+
+ | Periods |
+ Actual |
+ Target |
+ Percent |
+
+
+
+ @foreach($graph->values[0]->stats as $i => $val)
+
+ | {{$val->x}} |
+ {{$val->actual}} |
+ {{$val->target}} |
+ {{$val->y}}% |
+
+ @endforeach
+
+
+
+
+ @break
@default
- @if($post['type'] == 'value' || ($post['type'] == 'graphical' && $graph->chart = 'percentile' && $graph->type == 'simple' ))
+ @if(($post['type'] == 'value' && $graph->type != 'verses') || ($post['type'] == 'graphical' && $graph->chart = 'percentile' && $graph->type == 'simple' ))
{{ $graph->type == 'simple' ? $graph->label : 'Total ' . $graph->name }}
{{$graph->value}}
@endif
+ @if(($post['type'] == 'graphical' || $post['type'] == 'value') && $graph->type == 'verses' )
+ {{ $graph->type == 'simple' ? $graph->label : 'Total ' . $graph->name }}
+ {{$graph->value}} / {{$graph->max}}
+ @endif
+ @if($post['type'] == 'trend' && $graph->type == 'verses' )
+
+
+
+
+
+ | Periods |
+ Actual |
+ Target |
+
+
+
+ @foreach($graph->values[0]->stats as $i => $val)
+
+ | {{$val->x}} |
+ {{$val->actual}} |
+ {{$val->target}} |
+
+ @endforeach
+
+
+
+
+ @endif
@break
@endswitch
@@ -279,7 +338,7 @@
let chart = {}
let values = []
colors.shift()
- @if($graph->type == 'grouped')
+ @if($graph->type == 'grouped' || $graph->type == 'verses')
@switch($post['type'])
@case('graphical')
values = {!!json_encode($graph->values)!!}
@@ -344,6 +403,45 @@
categories: values.map(a => a.label),
}
};
+ @elseif($graph->type == 'verses' && $post['chart'] == 'progress')
+ options = {
+ series: [{{ $graph->max > 0 ? ceil(($graph->value/$graph->max)*100) : 0 }}],
+ chart: {
+ height: 250,
+ type: 'radialBar',
+ animations: {
+ enabled: true,
+ easing: 'easeinout',
+ speed: 2000,
+ }
+ },
+ plotOptions: {
+ radialBar: {
+ startAngle: -90,
+ endAngle: 270,
+ hollow: {
+ size: '58%',
+ }
+ },
+ },
+ fill: {
+ type: 'gradient',
+ gradient: {
+ shade: 'dark',
+ shadeIntensity: 0.15,
+ inverseColors: false,
+ opacityFrom: 1,
+ opacityTo: 1,
+ stops: [0, 50, 65, 91]
+ },
+ },
+ stroke: {
+ dashArray: 7
+ },
+ colors: colors,
+ labels: ['{{$graph->label}}'],
+ };
+
@endif
@break
@@ -476,6 +574,88 @@
@endswitch
+ @elseif($graph->type == 'verses')
+ @switch($post['type'])
+ @case('graphical')
+ options = {
+ series: [{{ $graph->max > 0 ? ceil(($graph->value/$graph->max)*100) : 0 }}],
+ chart: {
+ height: 250,
+ type: 'radialBar',
+ animations: {
+ enabled: true,
+ easing: 'easeinout',
+ speed: 2000,
+ }
+ },
+ plotOptions: {
+ radialBar: {
+ startAngle: -90,
+ endAngle: 270,
+ hollow: {
+ size: '58%',
+ }
+ },
+ },
+ fill: {
+ type: 'gradient',
+ gradient: {
+ shade: 'dark',
+ shadeIntensity: 0.15,
+ inverseColors: false,
+ opacityFrom: 1,
+ opacityTo: 1,
+ stops: [0, 50, 65, 91]
+ },
+ },
+ stroke: {
+ dashArray: 7
+ },
+ colors: colors,
+ labels: ['{{$graph->label}}'],
+ };
+ @break
+ @case('trend')
+
+ values = {!!json_encode($graph->values)!!}
+ options = {
+ series: [{
+ name: "{{$graph->label}}",
+ data: values.map(a => a.y)
+ }],
+ chart: {
+ height: 350,
+ type: '{{$post['chart']}}',
+ zoom: {
+ enabled: false
+ },
+ animations: {
+ enabled: true,
+ easing: 'easeinout',
+ speed: 2000,
+ }
+ },
+ dataLabels: {
+ enabled: false
+ },
+ stroke: {
+ curve: 'straight'
+ },
+ grid: {
+ row: {
+ colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
+ opacity: 0.5
+ },
+ },
+ xaxis: {
+ categories: values.map(a => a.x),
+ }
+ };
+
+ @break
+
+ @endswitch
+
@endif
chart = new ApexCharts(document.querySelector("#chart-{{$graph->id}}"), options);
diff --git a/routes/web.php b/routes/web.php
index d4a39a9e..bf65b638 100755
--- a/routes/web.php
+++ b/routes/web.php
@@ -60,6 +60,10 @@ Route::get('/myaccount', [DashboardController::class, 'myaccount'])->name('myacc
Route::get('/myaccounts', [DashboardController::class, 'myaccount'])->name('myaccount');
Route::post('/myaccount', [DashboardController::class, 'postmyaccount']);
+Route::get('/home', function () {
+ return 'Nothing here';
+});
+
$modules = ['user' => UserController::class,
'group' => GroupController::class,
'channel' => ChannelController::class,
|