This commit is contained in:
Ravi Gulhane 2022-05-23 10:33:56 +05:30
parent ac8c288290
commit 611980ef5f
7 changed files with 250 additions and 34 deletions

View File

@ -63,12 +63,20 @@ class ContactController extends Controller
protected function get_form_fields($type, $values){
$response = LambdaRequest::signedrequest('get', 'ums', 'contactattribute/get_all');
$hierar = $this->getlambda('get', 'ums', 'hierarchy', 'dropdown');
$hierar_dd = [];
foreach($hierar->data->items as $hier){
$hierar_dd[$hier->code] = $hier->name . ' (' . $hier->code . ')';
}
//echo '<pre>'; print_r($response); exit;
$fields = [
'name' => ['title' => 'Name', 'type' => 'text', 'required' => true],
'email' => ['title' => 'Email', 'type' => 'email', 'required' => true],
'phone' => ['title' => 'Phone', 'type' => 'text', 'required' => true],
'msl_code' => ['title' => 'MSL Code', 'type' => 'text'],
'position' => ['title' => 'Position', 'type' => 'select', 'required' => true, 'values' => $hierar_dd ],
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ],
];
foreach ($response->data->items as $item) {

View File

@ -200,6 +200,7 @@ class FormController extends Controller
unset($post['email']);
$response = LambdaRequest::postrequest('metric', 'metric_report/view', $post, $token);
//Log::debug(print_r($response, true));
//echo '<pre>'; print_r($response); print_r($post); exit;
if($download) {
@ -254,6 +255,29 @@ class FormController extends Controller
}
}
break;
case 'details':
if($response->data->graph->chart == 'tabular') {
$headers = ['User', 'Employee Code', 'Designation', 'Zone', 'Region', "Area", "Territory"];
foreach($response->data->graph->values->metrics as $metric) {
$headers[] = $metric->metric;
}
$exceldata[] = $headers;
foreach($response->data->graph->values->users as $user) {
$row = [];
$row[] = $user->name;
$row[] = $user->employee_code;
$row[] = $user->designation;
$row[] = isset($user->positions->Zone) ? $user->positions->Zone : '-';
$row[] = isset($user->positions->Region) ? $user->positions->Region : '-';
$row[] = isset($user->positions->Area) ? $user->positions->Area : '-';
$row[] = isset($user->positions->Territory) ? $user->positions->Territory : '-';
foreach($response->data->graph->values->metrics as $metric) {
$row[] = isset($metric->stats->{$user->id}) ? $metric->stats->{$user->id} : '-';
}
$exceldata[] = $row;
}
}
break;
}
//echo '<pre>'; print_r($exceldata); exit;
$data = new \StdClass;

View File

@ -44,10 +44,17 @@ class HierarchyController extends Controller
foreach($users->data->items as $user){
$users_dd[$user->id] = $user->firstname . ' ' . $user->lastname . ' (' . $user->employee_code . ')';
}
$positions = $this->getlambda('get', 'ums', 'hierarchy', 'dropdown');
$positions_dd = [];
foreach($positions->data->items as $position){
$positions_dd[$position->code] = $position->name . ' ('.$position->code.')';
}
return $this->view('list')->with([
'title' => $this->_title,
'base_url' => $this->_base_url,
'items' => $items,
'positions' => $positions_dd,
'myid' => $response->data->me->parent_id,
'designations' => $domain->data->item->designations,
'types' => $domain->data->item->territory_types,
@ -104,4 +111,14 @@ class HierarchyController extends Controller
'level' => ['title' => 'Level', 'type' => 'text'],
];
}
public function postmoveunder(Request $request) {
$post = $request->except('_token');
$response = LambdaRequest::signedrequest('post', $this->_service, 'hierarchy/moveposition', $post);
if($response->statusCode == 200 && $response->status == "success") {
return redirect($this->_base_url.'s')->withMessage('Successfully Saved !!!');
} else {
return \Redirect::back()->withMessage('Some Error occured!');
}
}
}

View File

@ -0,0 +1,104 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests\LambdaRequest;
use DB;
class PositionController extends Controller
{
public function __construct()
{
$this->middleware('auth');
$this->_service = 'ums';
$this->_module = 'hierarchy';
$this->_viewname = 'position';
$this->_title = 'Position';
$this->_base_url = '/position';
}
protected function get_list_fields(){
return [
'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete' ] ],
'name' => ['title' => 'Position Name', 'type' => 'text'],
'code' => ['title' => 'Position Code', 'type' => 'text'],
'type' => ['title' => 'Type', 'type' => 'text'],
'designation' => ['title' => 'Designation', 'type' => 'text'],
//'visiblity' => ['title' => 'Visiblity', 'type' => 'select'],
//'channel' => ['title' => 'Channels', 'type' => 'select'],
'status' => ['title' => 'Status', 'type' => 'select'],
];
}
public function list(Request $request) {
$response = LambdaRequest::signedrequest('get', $this->_service, $this->_module.'/get_all', ['positions' => true]);
//echo '<pre>'; print_r($response); exit;
if($response->statusCode == 401) {
return redirect('/unauthorised');
}
$fields = $this->get_list_fields();
//echo '<pre>'; print_r($fields); exit;
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()
]);
}
protected function get_form_fields($type, $values){
// $channels = $this->getlambda('get', 'ums', 'channel', 'dropdown');
// $channels_dd = [];
// foreach($channels->data->items as $channel){
// $channels_dd[$channel->id] = $channel->name;
// }
// $users = $this->getlambda('get', 'ums', 'users', 'dropdown');
// $users_dd = [];
// foreach($users->data->items as $user){
// $users_dd[$user->id] = $user->firstname . ' ' . $user->lastname . ' (' . $user->employee_code . ')';
// }
return [
'name' => ['title' => 'Position Name', 'type' => 'text', 'required' => true],
'code' => ['title' => 'Position Code', 'type' => 'text', 'required' => true],
'type' => ['title' => 'Type', 'type' => 'text', 'required' => true],
'designation' => ['title' => 'Designation', 'type' => 'text', 'required' => true],
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ],
];
}
protected function get_import_fields($records){
$domain = LambdaRequest::signedrequest('get', $this->_service, 'domain/get_one');
$designations_dd = [];
foreach($domain->data->item->designations as $designation){
$designations_dd[$designation] = $designation;
}
$types_dd = [];
foreach($domain->data->item->territory_types as $type){
$types_dd[$type] = $type;
}
$response = LambdaRequest::signedrequest('get', $this->_service, $this->_module.'/dropdown');
//echo '<pre>'; print_r($types_dd); exit;
$items = [];
foreach($response->data->items as $item) {
$items[$item->code] = $item->code;
}
foreach($records as $record) {
$items[$record['code']] = $record['code'];
}
return [
'type' => ['title' => 'Type', 'type' => 'select', 'values' => $types_dd, 'required' => true],
'name' => ['title' => 'Name', 'type' => 'text'],
'code' => ['title' => 'Code', 'type' => 'text', 'required' => true],
'parent' => ['title' => 'Parent', 'type' => 'select', 'values' => $items, 'required' => true],
'designation' => ['title' => 'Designation', 'type' => 'select', 'values' => $designations_dd, 'required' => true],
'email' => ['title' => 'Email', 'type' => 'text'],
'reportee' => ['title' => 'Reportee Email', 'type' => 'text'],
'level' => ['title' => 'Level', 'type' => 'text'],
];
}
}

View File

@ -54,42 +54,19 @@
</div>
<div class="modal-body p-4">
<div class="row">
<div class="col-md-6">
<div class="col-md-12">
<div class="mb-2">
<label for="terrytory-name" class="form-label">Position Name</label>
<input type="text" class="form-control" id="terrytory-name" name="name">
</div>
</div>
<div class="col-md-6">
<div class="mb-2">
<label for="terrytory-code" class="form-label">Position Code</label>
<input type="text" class="form-control" id="terrytory-code" name="code">
</div>
</div>
<div class="col-md-6">
<div class="mb-2">
<label for="terrytory-designation" class="form-label">Designation</label>
<select class="form-control" id="terrytory-designation" name="designation" required>
<option value=""> -- Select Designation -- </option>
@foreach($designations as $designation)
<option value="{{$designation}}">{{$designation}}</option>
@endforeach
</select>
</div>
</div>
<div class="col-md-6">
<div class="mb-2">
<label for="terrytory-type" class="form-label">Type</label>
<select class="form-control" id="terrytory-type" name="type" required>
<label for="position" class="form-label">Position</label>
<select class="form-control" id="terrytory-position" name="code" required>
<option value=""> -- Select Type -- </option>
@foreach($types as $type)
<option value="{{$type}}">{{$type}}</option>
@foreach($positions as $code => $position)
<option value="{{$code}}">{{$position}}</option>
@endforeach
</select>
</div>
</div>
<div class="col-md-6">
<div class="col-md-12">
<div class="mb-2">
<label for="terrytory-owner" class="form-label">User</label>
<select class="form-control" id="terrytory-owner" name="owner" required>
@ -163,6 +140,42 @@
</div>
</div><!-- /.modal -->
<div id="move-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<form method="post" id="tomove-add-form" enctype="multipart/form-data" action="/hierarchy/moveunder">
@csrf
<input type="hidden" name="parent_id" id="tomove-parent_id" value="">
<input type="hidden" name="id" id="tomove-id" value="">
<input type="hidden" name="previous_owner" id="tomove-previous_owner" value="">
<div class="modal-header">
<h4 class="modal-title">Move this position to another </h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body p-4">
<div class="row">
<div class="col-md-12">
<div class="mb-2">
<label for="position" class="form-label">Position</label>
<select class="form-control" id="terrytory-position" name="code" required>
<option value=""> -- Select Type -- </option>
@foreach($positions as $code => $position)
<option value="{{$code}}">{{$position}}</option>
@endforeach
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info waves-effect waves-light">Save changes</button>
</div>
</form>
</div>
</div>
</div><!-- /.modal -->
<style type="text/css">
.dd-list .dd-item button {
@ -201,6 +214,7 @@
$(document).on('click', '.add-child-btn', function(){
$('#add-clild-modal .modal-title').html('Add New Child for ' + $(this).attr('myname'))
$('#terrytory-parent_id').val($(this).attr('myid'));
$('#terrytory-position option:not(:selected)').removeAttr('disabled')
$('#hierarchy-add-form').trigger("reset");
$('#add-clild-modal').modal("show")
});
@ -220,13 +234,24 @@
$('#terrytory-id').val(data.id);
$('#terrytory-parent_id').val(data.parent_id);
$('#terrytory-previous_owner').val(data.owner);
$('#terrytory-name').val(data.name)
$('#terrytory-code').val(data.code)
//$('#terrytory-name').val(data.name)
//$('#terrytory-code').val(data.code)
$('#terrytory-position').val(data.code)
$('#terrytory-designation').val(data.designation)
$('#terrytory-type').val(data.type)
$('#terrytory-owner').val(data.owner)
$('#terrytory-position option:not(:selected)').attr('disabled', true);
$('#add-clild-modal').modal("show")
});
$(document).on('click', '.move-btn', function(){
$('#tomove-add-form').trigger("reset");
let data = JSON.parse($(this).attr("mydata"))
$('#move-modal .modal-title').html('Move "' + data.name + '"" to another position')
$('#tomove-id').val(data.id);
$('#tomove-parent_id').val(data.parent_id);
$('#tomove-previous_owner').val(data.owner);
$('#move-modal').modal("show")
});
$(document).on('click', '.delete-btn', function(){
console.log("/hierarchy/delete?id=" + $(this).attr('myid'))
window.location.href = "/hierarchy/delete?id=" + $(this).attr('myid');

View File

@ -6,6 +6,7 @@
{{$item->name}} ({{$item->type}}) - {{$item->is_vacant? 'Vacant' : $item->owner_info->name .' (' .$item->owner_info->employee_code. ')'}}
<button type="button" class="btn btn-soft-secondary btn-xs float-end delete-btn" myid="{{$item->id}}" title="Delete"><i class="mdi mdi-delete text-danger"></i></button>
<button type="button" class="btn btn-soft-secondary btn-xs float-end edit-btn" myid="{{$item->id}}" mydata="{{json_encode($item)}}" title="Edit"><i class="mdi mdi-square-edit-outline text-warning"></i></button>
<button type="button" class="btn btn-soft-secondary btn-xs float-end move-btn" myid="{{$item->id}}" mydata="{{json_encode($item)}}" title="Move"><i class="mdi mdi-arrow-decision text-info"></i></button>
<button type="button" class="btn btn-soft-secondary btn-xs float-end add-child-btn" myid="{{$item->id}}" myname="{{$item->name}}" title="Add child"><i class="mdi mdi-file-tree text-dark"></i></button>
</div>
@include('hierarchy.part', ['myid' => $item->id, 'items' => $items])

View File

@ -27,7 +27,7 @@
<p class="text-muted"><i class="mdi mdi-calendar" aria-hidden="true"></i> {{$graph->valid_from}} to {{$graph->valid_till}}</p>
</div>
<div class="col-4 text-end">
@if((in_array($post['type'], ['trend','leaderboard']) && !in_array($post['chart'], ['line', 'bar']) ) || ($post['type'] == 'graphical' && $graph->type == 'grouped') )
@if((in_array($post['type'], ['trend','leaderboard']) && !in_array($post['chart'], ['line', 'bar']) ) || ($post['type'] == 'graphical' && $graph->type == 'grouped') || ($post['type'] == 'details' && $graph->chart == 'tabular') )
<button class="btn btn-warning btn-xs" id="email-export">Send me Email</button>
@endif
</div>
@ -70,13 +70,11 @@
@switch(true)
@case($graph->chart == 'leaderboard')
<div id="cardCollpase4" class="collapse pt-3 show">
@if($graph->agg_type == 'individual')
<div class="btn-group mb-2">
<button type="button" class="btn btn-info leaderboard-prev" {{$graph->current_level==$graph->level?'disabled':''}}><i class="mdi mdi-play mdi-rotate-180 mdi-18px"></i></button>
<button type="button" class="btn btn-info">Level {{$graph->current_level}}</button>
<button type="button" class="btn btn-info leaderboard-next" {{$graph->current_level==1?'disabled':''}}><i class="mdi mdi-play mdi-18px"></i></button>
</div>
@endif
@php
$leader_id = '';
@endphp
@ -142,6 +140,45 @@
</div> <!-- .table-responsive -->
</div> <!-- end collapse-->
@break
@case($post['type'] == 'details' && $graph->chart == 'tabular')
<div id="cardCollpase4" class="collapse pt-3 show">
<div class="table-responsive">
@if(isset($graph->values->metrics))
<table class="table table-centered table-nowrap table-borderless mb-0">
<thead class="table-light">
<tr>
<th colspan="2">User</th>
<th>Employee Code</th>
<th>Zone</th>
<th>Region</th>
<th>Area</th>
<th>Territory</th>
@foreach($graph->values->metrics as $metric)
<th>{{$metric->metric}}</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach($graph->values->users as $user)
<tr>
<td><img src="{{isset($user->avatar) ? $user->avatar : ''}}" class="avatar-sm rounded-circle"></td>
<td>{{ $user->name }} <br/>{{$user->designation}}</td>
<td>{{ isset($user->employee_code) ? $user->employee_code:''}}</td>
<td>{{ isset($user->positions->Zone) ? $user->positions->Zone : '-' }}</td>
<td>{{ isset($user->positions->Region) ? $user->positions->Region : '-' }}</td>
<td>{{ isset($user->positions->Area) ? $user->positions->Area : '-' }}</td>
<td>{{ isset($user->positions->Territory) ? $user->positions->Territory : '-' }}</td>
@foreach($graph->values->metrics as $metric)
<td>{{ isset($metric->stats->{$user->id}) ? $metric->stats->{$user->id} : '-' }}</th>
@endforeach
</tr>
@endforeach
</tbody>
</table>
@endif
</div> <!-- .table-responsive -->
</div> <!-- end collapse-->
@break
@default
<div id="chart-{{$graph->id}}" class="mt-0" data-colors="#f1556c"></div>
@if($post['type'] == 'value' || ($post['type'] == 'graphical' && $graph->chart = 'percentile' && $graph->type == 'simple' ))