Changes
This commit is contained in:
parent
60ff13a206
commit
c54af3f4aa
|
|
@ -52,6 +52,11 @@ class AppreciationcategoryController extends Controller
|
|||
foreach($groups->data->items as $group){
|
||||
$groups_dd[$group->id] = $group->name;
|
||||
}
|
||||
$metrics = $this->getlambda('get', 'metric', 'metric', 'get_all');
|
||||
$metric_dd = [];
|
||||
foreach($metrics->data->items as $metric){
|
||||
$metric_dd[$metric->id] = $metric->name;
|
||||
}
|
||||
|
||||
$fields = [
|
||||
'title' => ['title' => 'Title', 'type' => 'text', 'required' => true],
|
||||
|
|
@ -61,6 +66,7 @@ class AppreciationcategoryController extends Controller
|
|||
'points' => ['title' => 'Points', 'type' => 'text', 'required' => true],
|
||||
'groups' => ['title' => 'Groups', 'type' => 'multiselect', 'required' => true, 'values' => $groups_dd ],
|
||||
'roles' => ['title' => 'Roles', 'type' => 'multiselect', 'required' => true, 'values' => $roles_dd ],
|
||||
'mapped_metric' => ['title' => 'Metric', 'type' => 'select', 'values' => $metric_dd ],
|
||||
|
||||
'icon' => ['title' => 'Icon', 'type' => 'image', 'required' => true ],
|
||||
|
||||
|
|
@ -71,6 +77,10 @@ class AppreciationcategoryController extends Controller
|
|||
|
||||
protected function _beforesave($type, $request) {
|
||||
$data = $request->except('_token');
|
||||
if(!isset($data['mapped_metric'])) {
|
||||
$data['mapped_metric'] = "";
|
||||
}
|
||||
|
||||
if( $request->file('icon') ) {
|
||||
$data['icon'] = $this->_uploadMedia($request, 'icon', 'recognition_appreciation');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ use Illuminate\Http\Request;
|
|||
use App\Http\Requests\LambdaRequest;
|
||||
use DB;
|
||||
use Auth;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\InvoicesExport;
|
||||
use App\Mail\ReportExcel;
|
||||
use Mail;
|
||||
|
||||
class CampaignController extends Controller
|
||||
{
|
||||
|
|
@ -36,7 +40,7 @@ class CampaignController extends Controller
|
|||
|
||||
protected function get_list_fields(){
|
||||
return [
|
||||
'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete', 'rules' => ['icon' => 'brightness-percent', 'querystring' => 'id={ID}'] ] ],
|
||||
'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete', 'rules' => ['icon' => 'brightness-percent', 'querystring' => 'id={ID}'], 'teammembers' => ['icon' => 'account-multiple', 'querystring' => 'id={ID}'] ] ],
|
||||
'title' => ['title' => 'Title', 'type' => 'text'],
|
||||
'validity_start' => ['title' => 'Validity start', 'type' => 'text'],
|
||||
'validity_end' => ['title' => 'Validity end', 'type' => 'text'],
|
||||
|
|
@ -120,6 +124,24 @@ class CampaignController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function teammembers(Request $request) {
|
||||
$id = $request->input('id', 0);
|
||||
$response = LambdaRequest::signedrequest('get', $this->_service, $this->_module.'/get_one', ['id' => $id]);
|
||||
$values = $response->data->item;
|
||||
$teams = [];
|
||||
foreach($values->teams as $t) {
|
||||
$team = LambdaRequest::signedrequest('get', 'ums', 'team/get_one', ['id' => $t, 'players' => true]);
|
||||
$players = [];
|
||||
foreach($team->data->players as $player) {
|
||||
$players[] = $player->owner_info;
|
||||
}
|
||||
$teams[] = ['team_details' => ['id' => $team->data->item->id, 'name' => $team->data->item->name, 'description' => $team->data->item->description], 'players' => $players ];
|
||||
}
|
||||
$teams = json_decode(json_encode($teams), FALSE);
|
||||
//echo '<pre>'; print_r($teams); exit;
|
||||
return $this->view('teammembers')->with(['teams' => $teams]);
|
||||
}
|
||||
|
||||
public function report(Request $request) {
|
||||
$post = $request->except('_token');
|
||||
$response = LambdaRequest::signedrequest('post', $this->_service, $this->_module.'/view', $post, 60);
|
||||
|
|
@ -140,4 +162,85 @@ class CampaignController extends Controller
|
|||
return $this->view('dashboard')->with(['periods' => $response->data->periods, 'user' => $user, 'metrics' => $response->data->metrics, 'post' => $response->data->post ]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function export(Request $request) {
|
||||
$post = $request->except('_token');
|
||||
//$post['export'] = 1;
|
||||
$response = LambdaRequest::signedrequest('post', $this->_service, $this->_module.'/view', $post, 60);
|
||||
//echo '<pre>'; print_r($response); exit;
|
||||
//echo '<pre>'; print_r($response); print_r($post); exit;
|
||||
$exceldata = [];
|
||||
// foreach($response->data->periods as $v) {
|
||||
// if($post['period'] == $v->value) {
|
||||
// $exceldata[] = ['Period: '.ucwords($v->label)];
|
||||
// }
|
||||
// }
|
||||
if(!isset($post['type'])) {
|
||||
$post['type'] = 'details';
|
||||
}
|
||||
$exceldata[] = [''];
|
||||
switch($post['type']) {
|
||||
case 'leaderboard':
|
||||
$exceldata[] = ["Rank", "User", "Designation", "Units", "Percent"];
|
||||
foreach($response->data->graph->values as $val) {
|
||||
$exceldata[] = [(string)$val->rank, (string)$val->user->name, $val->user->designation, (string)round($val->score, 2), (string)$response->data->graph->values[0]->rank != 0 ? ($response->data->graph->values[0]->rank == 1 ? ($response->data->graph->values[0]->score ? ceil(($val->score/$response->data->graph->values[0]->score)*100) : 0) : ($response->data->graph->values[1]->score ? ceil(($val->score/$response->data->graph->values[1]->score)*100) : 0 ) ) : 0 ];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'details':
|
||||
$headers = ['User', 'Employee Code', 'Email', 'Designation', 'Zone', 'Region', "Area", "Territory", "Rank", "Total Units", "Total Points"];
|
||||
foreach($response->data->metrics as $metric) {
|
||||
$headers[] = $metric->name . ' Units';
|
||||
$headers[] = $metric->name . ' Points';
|
||||
}
|
||||
$exceldata[] = $headers;
|
||||
foreach($response->data->users as $user) {
|
||||
$row = [];
|
||||
$row[] = $user->user_info->name;
|
||||
$row[] = $user->user_info->employee_code;
|
||||
$row[] = $user->user_info->email;
|
||||
$row[] = $user->user_info->designation;
|
||||
|
||||
$row[] = isset($user->user_info->positions->Zone) ? $user->user_info->positions->Zone : '-';
|
||||
$row[] = isset($user->user_info->positions->Region) ? $user->user_info->positions->Region : '-';
|
||||
$row[] = isset($user->user_info->positions->Area) ? $user->user_info->positions->Area : '-';
|
||||
$row[] = isset($user->user_info->positions->Territory) ? $user->user_info->positions->Territory : '-';
|
||||
|
||||
$row[] = $user->rank;
|
||||
$row[] = $user->units;
|
||||
$row[] = $user->total;
|
||||
|
||||
foreach($response->data->metrics as $metric) {
|
||||
$row[] = isset($user->metrics->{$metric->id}) ? $user->metrics->{$metric->id} : '-';
|
||||
$row[] = isset($user->metric_points->{$metric->id}) ? $user->metric_points->{$metric->id} : '-';
|
||||
}
|
||||
$exceldata[] = $row;
|
||||
}
|
||||
break;
|
||||
}
|
||||
//echo '<pre>'; print_r($exceldata); exit;
|
||||
if(isset($post['email']) && $post['email'] == 1) {
|
||||
$data = new \StdClass;
|
||||
$data->sender_name = 'Rapport Support';
|
||||
$data->sender_email = 'support@stratawiz.com';
|
||||
$data->subject = 'Attached Report';
|
||||
$data->body = '';
|
||||
|
||||
$report = Excel::raw(new InvoicesExport($exceldata), 'Xlsx');
|
||||
$data->attachment = $report;
|
||||
$data->attachment_name = 'campaign.xlsx';
|
||||
|
||||
Mail::to( $response->data->user->email )->send(new ReportExcel($data));
|
||||
//Mail::to( 'ravigulhane1983@gmail.com' )->send(new ReportExcel($data));
|
||||
return response()->json(['sent' => 'yes']);
|
||||
} elseif(isset($post['s3']) && $post['s3'] == 1) {
|
||||
$filename = 'reports/'.strtotime("now").'-report.xlsx';
|
||||
$res = Excel::store(new InvoicesExport($exceldata), $filename);
|
||||
Log::debug('https://did94hhhcgq1d.cloudfront.net/'.$filename);
|
||||
return response()->json(['sent' => 'yes', 'filename' => 'https://did94hhhcgq1d.cloudfront.net/'.$filename]);
|
||||
} else {
|
||||
return Excel::download(new InvoicesExport($exceldata), 'campaign.xlsx');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,4 +221,82 @@ class CampaignreportController extends Controller
|
|||
|
||||
}
|
||||
|
||||
public function export(Request $request) {
|
||||
$post = $request->except('_token');
|
||||
$token = $request->header('Authorization');
|
||||
if($token != '') {
|
||||
$request->session()->put('metric_access_key', $token);
|
||||
} else {
|
||||
$token = $request->session()->get('metric_access_key');
|
||||
}
|
||||
|
||||
$response = LambdaRequest::postrequest($this->_service, $this->_module.'/view', $post, $token);
|
||||
$exceldata = [];
|
||||
if(!isset($post['type'])) {
|
||||
$post['type'] = 'details';
|
||||
}
|
||||
$exceldata[] = [''];
|
||||
switch($post['type']) {
|
||||
case 'leaderboard':
|
||||
$exceldata[] = ["Rank", "User", "Designation", "Units", "Percent"];
|
||||
foreach($response->data->graph->values as $val) {
|
||||
$exceldata[] = [(string)$val->rank, (string)$val->user->name, $val->user->designation, (string)round($val->score, 2), (string)$response->data->graph->values[0]->rank != 0 ? ($response->data->graph->values[0]->rank == 1 ? ($response->data->graph->values[0]->score ? ceil(($val->score/$response->data->graph->values[0]->score)*100) : 0) : ($response->data->graph->values[1]->score ? ceil(($val->score/$response->data->graph->values[1]->score)*100) : 0 ) ) : 0 ];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'details':
|
||||
$headers = ['User', 'Employee Code', 'Email', 'Designation', 'Zone', 'Region', "Area", "Territory", "Rank", "Total Units", "Total Points"];
|
||||
foreach($response->data->metrics as $metric) {
|
||||
$headers[] = $metric->name . ' Units';
|
||||
$headers[] = $metric->name . ' Points';
|
||||
}
|
||||
$exceldata[] = $headers;
|
||||
foreach($response->data->users as $user) {
|
||||
$row = [];
|
||||
$row[] = $user->user_info->name;
|
||||
$row[] = $user->user_info->employee_code;
|
||||
$row[] = $user->user_info->email;
|
||||
$row[] = $user->user_info->designation;
|
||||
|
||||
$row[] = isset($user->user_info->positions->Zone) ? $user->user_info->positions->Zone : '-';
|
||||
$row[] = isset($user->user_info->positions->Region) ? $user->user_info->positions->Region : '-';
|
||||
$row[] = isset($user->user_info->positions->Area) ? $user->user_info->positions->Area : '-';
|
||||
$row[] = isset($user->user_info->positions->Territory) ? $user->user_info->positions->Territory : '-';
|
||||
|
||||
$row[] = $user->rank;
|
||||
$row[] = $user->units;
|
||||
$row[] = $user->total;
|
||||
|
||||
foreach($response->data->metrics as $metric) {
|
||||
$row[] = isset($user->metrics->{$metric->id}) ? $user->metrics->{$metric->id} : '-';
|
||||
$row[] = isset($user->metric_points->{$metric->id}) ? $user->metric_points->{$metric->id} : '-';
|
||||
}
|
||||
$exceldata[] = $row;
|
||||
}
|
||||
break;
|
||||
}
|
||||
//echo '<pre>'; print_r($exceldata); exit;
|
||||
if(isset($post['email']) && $post['email'] == 1) {
|
||||
$data = new \StdClass;
|
||||
$data->sender_name = 'Rapport Support';
|
||||
$data->sender_email = 'support@stratawiz.com';
|
||||
$data->subject = 'Attached Report';
|
||||
$data->body = '';
|
||||
|
||||
$report = Excel::raw(new InvoicesExport($exceldata), 'Xlsx');
|
||||
$data->attachment = $report;
|
||||
$data->attachment_name = 'campaign.xlsx';
|
||||
|
||||
Mail::to( $response->data->user->email )->send(new ReportExcel($data));
|
||||
//Mail::to( 'ravigulhane1983@gmail.com' )->send(new ReportExcel($data));
|
||||
return response()->json(['sent' => 'yes']);
|
||||
} elseif(isset($post['s3']) && $post['s3'] == 1) {
|
||||
$filename = 'reports/'.strtotime("now").'-report.xlsx';
|
||||
$res = Excel::store(new InvoicesExport($exceldata), $filename);
|
||||
Log::debug('https://did94hhhcgq1d.cloudfront.net/'.$filename);
|
||||
return response()->json(['sent' => 'yes', 'filename' => 'https://did94hhhcgq1d.cloudfront.net/'.$filename]);
|
||||
} else {
|
||||
return Excel::download(new InvoicesExport($exceldata), 'campaign.xlsx');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,7 @@ class CampaignruleController extends Controller
|
|||
'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete' ] ],
|
||||
//'media_thumb' => ['title' => 'Media Thumb', 'type' => 'image'],
|
||||
'metric_name' => ['title' => 'Metric Name', 'type' => 'text'],
|
||||
'block_size' => ['title' => 'Block Size', 'type' => 'text'],
|
||||
'points' => ['title' => 'Points', 'type' => 'text'],
|
||||
'range_start' => ['title' => 'Range Start', 'type' => 'text'],
|
||||
'range_end' => ['title' => 'Range End', 'type' => 'text'],
|
||||
|
|
@ -66,6 +67,7 @@ class CampaignruleController extends Controller
|
|||
'range_end' => ['title' => 'Range End', 'type' => 'number', 'required' => true],
|
||||
'metric_interval' => ['title' => 'Metric Interval', 'type' => 'select', 'required' => true, 'values' => ['OVERALL' => 'OVERALL', 'MONTHLY' => 'MONTHLY', 'WEEKLY' => 'WEEKLY'] ],
|
||||
'scoring_type' => ['title' => 'Scoring Type', 'type' => 'select', 'required' => true, 'values' => ['LINEAR' => 'LINEAR', 'STAGGERED' => 'STAGGERED'] ],
|
||||
'block_size' => ['title' => 'Block Size', 'type' => 'number', 'required' => true],
|
||||
'points' => ['title' => 'Points', 'type' => 'text', 'required' => true],
|
||||
];
|
||||
return $fields;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class FormexportController extends Controller
|
|||
return redirect('/formentitys')->withError('Question not found!');
|
||||
}
|
||||
$response = LambdaRequest::signedrequest('get', $this->_service, $this->_module . '/get_all', ['entity_id' => $entity_id]);
|
||||
//echo '<pre>'; print_r($response); exit;
|
||||
echo '<pre>'; print_r($response); exit;
|
||||
$fields = $this->get_list_fields();
|
||||
return $this->view('list')->with([
|
||||
'title' => $this->_title,
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class MetricreportController extends Controller
|
|||
break;
|
||||
case 'details':
|
||||
if($response->data->graph->chart == 'tabular') {
|
||||
$headers = ['User', 'Employee Code', 'Email', 'Designation', 'Manager 1 Name', 'Manager 1 Emp Code', 'Manager 1 Email', 'Manager 2 Name', 'Manager 2 Emp Code', 'Manager 2 Email', 'Zone', 'Region', "Area", "Territory"];
|
||||
$headers = ['User', 'Employee Code', 'Email', 'Designation', 'Manager 1 Name', 'Manager 1 Emp Code', 'Manager 1 Email', 'Manager 2 Name', 'Manager 2 Emp Code', 'Manager 2 Email', 'Zone', 'Region', "Area", "Territory", "Role"];
|
||||
foreach($response->data->graph->values->metrics as $metric) {
|
||||
$headers[] = $metric->metric;
|
||||
}
|
||||
|
|
@ -152,6 +152,7 @@ class MetricreportController extends Controller
|
|||
$row[] = isset($user->positions->Region) ? $user->positions->Region : '-';
|
||||
$row[] = isset($user->positions->Area) ? $user->positions->Area : '-';
|
||||
$row[] = isset($user->positions->Territory) ? $user->positions->Territory : '-';
|
||||
$row[] = isset($user->roles) ? (is_array($user->roles) ? implode(',', $user->roles) : $user->roles) : '-';
|
||||
foreach($response->data->graph->values->metrics as $metric) {
|
||||
$row[] = isset($metric->stats->{$user->id}) ? $metric->stats->{$user->id} : '-';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ use Illuminate\Http\Request;
|
|||
use App\Http\Requests\LambdaRequest;
|
||||
use DB;
|
||||
use Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\InvoicesExport;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
|
|
@ -26,6 +28,8 @@ class UserController extends Controller
|
|||
'firstname' => ['title' => 'Firstname', 'type' => 'text'],
|
||||
'lastname' => ['title' => 'Lastname', 'type' => 'text'],
|
||||
'email' => ['title' => 'Email', 'type' => 'text'],
|
||||
'logged_in' => ['title' => 'Is Logged In', 'type' => 'text'],
|
||||
'roles' => ['title' => 'Roles', 'type' => 'text'],
|
||||
'phone' => ['title' => 'Phone', 'type' => 'text'],
|
||||
'designation' => ['title' => 'Designation', 'type' => 'text'],
|
||||
'state' => ['title' => 'State', 'type' => 'text'],
|
||||
|
|
@ -36,7 +40,7 @@ class UserController extends Controller
|
|||
}
|
||||
|
||||
protected function get_list_buttons() {
|
||||
return [ ['title' => 'Add New', 'link' => $this->_base_url.'/addnew' ], ['title' => 'Import Users', 'link' => $this->_base_url.'/import'] ];
|
||||
return [ ['title' => 'Add New', 'link' => $this->_base_url.'/addnew' ], ['title' => 'Import Users', 'link' => $this->_base_url.'/import'], ['title' => 'Export Users', 'link' => $this->_base_url.'/export'] ];
|
||||
}
|
||||
|
||||
protected function get_form_fields($type, $values){
|
||||
|
|
@ -119,4 +123,28 @@ class UserController extends Controller
|
|||
'buttons' => $this->get_list_buttons()
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(Request $request) {
|
||||
$response = LambdaRequest::signedrequest('get', $this->_service, $this->_module.'/get_all', ['start' => 0, 'length' => 9999, 'search' => json_encode([]), 'keyword' => "" ]);
|
||||
//echo '<pre>'; print_r($response); exit;
|
||||
|
||||
$headers = ['Employee Code', 'Firstname', 'Lastname', 'Email', 'Is Logged In', 'Roles', 'Phone', 'Designation', 'State', 'City', 'Status'];
|
||||
$exceldata[] = $headers;
|
||||
foreach($response->data->items as $user) {
|
||||
$row = [];
|
||||
$row[] = isset($user->employee_code) ? $user->employee_code : '-';
|
||||
$row[] = isset($user->firstname) ? $user->firstname : '-';
|
||||
$row[] = isset($user->lastname) ? $user->lastname : '-';
|
||||
$row[] = isset($user->email) ? $user->email : '-';
|
||||
$row[] = isset($user->logged_in) ? $user->logged_in : '-';
|
||||
$row[] = isset($user->roles) ? $user->roles : '-';
|
||||
$row[] = isset($user->phone) ? $user->phone : '-';
|
||||
$row[] = isset($user->designation) ? $user->designation : '-';
|
||||
$row[] = isset($user->state) ? $user->state : '-';
|
||||
$row[] = isset($user->city) ? $user->city : '-';
|
||||
$row[] = isset($user->status) ? $user->status : '-';
|
||||
$exceldata[] = $row;
|
||||
}
|
||||
return Excel::download(new InvoicesExport($exceldata), 'users.xlsx');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,10 @@
|
|||
<a href="/campaignreport/report?id={{$post->id}}&type=myteam&chart=myteam&period=month-0" class="btn {{($post->type == 'myteam' ) ? 'btn-soft-warning' : 'btn-soft-blue' }} btn-rounded">My Team</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 text-end mt-2">
|
||||
<button class="btn btn-dark btn-xs" id="export">Export</button>
|
||||
<button class="btn btn-warning btn-xs" id="email-export">Send me Email</button>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="row mt-3 mb-2">
|
||||
<label for="period" class="col-6 col-xl-5 col-form-label">Select Period</label>
|
||||
|
|
@ -305,21 +308,12 @@
|
|||
$('#export').click(function(){
|
||||
//$("#pageloader").fadeIn();
|
||||
let href = new URL(window.location.href);
|
||||
window.location.href = href.origin + '/metricreport/export' + href.search
|
||||
window.location.href = href.origin + '/campaignreport/export' + href.search
|
||||
})
|
||||
// $('#export').click(function(){
|
||||
// let href = new URL(window.location.href);
|
||||
// $('.loader').show()
|
||||
// $.get( href.origin + '/metricreport/export' + href.search + '&download=1&s3=1', function( data ) {
|
||||
// console.log(data)
|
||||
// $('.loader').hide()
|
||||
// $('#graph-wrapper').prepend('<div class="button-list pe-xl-4 d-grid"><a href="" download class="btn btn--md btn-pink waves-effect waves-light">Download Report</a></div>');
|
||||
// });
|
||||
// })
|
||||
$('#email-export').click(function(){
|
||||
$("#pageloader").fadeIn();
|
||||
let href = new URL(window.location.href);
|
||||
$.get( href.origin + '/metricreport/export' + href.search + '&email=1', function( data ) {
|
||||
$.get( href.origin + '/campaignreport/export' + href.search + '&email=1', function( data ) {
|
||||
$("#pageloader").fadeOut();
|
||||
alert( "Email has been sent to your email id." );
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,6 +36,13 @@
|
|||
<a href="/campaign/report?id={{$post->id}}&type=leaderboard&chart=leaderboard&period=month-0" class="btn {{($post->type == 'leaderboard' ) ? 'btn-soft-warning' : 'btn-soft-blue' }} btn-rounded">Leaderboard</a>
|
||||
<a href="/campaign/report?id={{$post->id}}&type=myteam&chart=myteam&period=month-0" class="btn {{($post->type == 'myteam' ) ? 'btn-soft-warning' : 'btn-soft-blue' }} btn-rounded">My Team</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4 text-end">
|
||||
<button class="btn btn-dark btn-xs" id="export">Export</button>
|
||||
<button class="btn btn-warning btn-xs" id="email-export">Send me Email</button>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="row mb-3">
|
||||
|
|
@ -57,6 +64,7 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="widget-chart text-center" dir="ltr">
|
||||
|
|
@ -301,23 +309,13 @@
|
|||
@endif
|
||||
|
||||
$('#export').click(function(){
|
||||
//$("#pageloader").fadeIn();
|
||||
let href = new URL(window.location.href);
|
||||
window.location.href = href.origin + '/metricreport/export' + href.search
|
||||
window.location.href = href.origin + '/campaign/export' + href.search
|
||||
})
|
||||
// $('#export').click(function(){
|
||||
// let href = new URL(window.location.href);
|
||||
// $('.loader').show()
|
||||
// $.get( href.origin + '/metricreport/export' + href.search + '&download=1&s3=1', function( data ) {
|
||||
// console.log(data)
|
||||
// $('.loader').hide()
|
||||
// $('#graph-wrapper').prepend('<div class="button-list pe-xl-4 d-grid"><a href="" download class="btn btn--md btn-pink waves-effect waves-light">Download Report</a></div>');
|
||||
// });
|
||||
// })
|
||||
$('#email-export').click(function(){
|
||||
$("#pageloader").fadeIn();
|
||||
let href = new URL(window.location.href);
|
||||
$.get( href.origin + '/metricreport/export' + href.search + '&email=1', function( data ) {
|
||||
$.get( href.origin + '/campaign/export' + href.search + '&email=1', function( data ) {
|
||||
$("#pageloader").fadeOut();
|
||||
alert( "Email has been sent to your email id." );
|
||||
});
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
<select class="form-control" id="field-{{$field}}" name="{{$field}}" {{isset($props['required'])&&$props['required']?'required':'' }}>
|
||||
<option value=""> -- Select {{$props['title']}} -- </option>
|
||||
@foreach($props['values'] as $k => $v)
|
||||
<option value="{{$k}}" {{$mode=='edit' && $item->{$field} == $k ? 'selected="selected"':''}}>{{$v}}</option>
|
||||
<option value="{{$k}}" {{$mode=='edit' && isset($item->{$field}) && $item->{$field} == $k ? 'selected="selected"':''}}>{{$v}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@break
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@
|
|||
@endforeach
|
||||
@break
|
||||
@case('file')
|
||||
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" value="" accept="image/jpg, image/jpeg, image/png" required>
|
||||
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" value="" accept="image/jpg, image/jpeg, image/png" {{$question->required == 'yes'?'required':'' }}>
|
||||
@break
|
||||
@case('multitextbox')
|
||||
<div class="row">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,215 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@include('layouts.shared/title-meta', ['title' => "Form"])
|
||||
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
||||
<link href="{{asset('assets/libs/sweetalert2/sweetalert2.min.css')}}" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<div id="pageloader">
|
||||
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
||||
</div>
|
||||
<body class="loading">
|
||||
<div class="account-pages">
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8 col-lg-6 col-xl-5 p-0">
|
||||
<div class="card bg-pattern">
|
||||
<div class="card-body p-3 row">
|
||||
|
||||
@if(Session::has('error'))<div class="alert alert-danger">{{Session::get('error')}}</div>
|
||||
<br>@endif
|
||||
@if(session('success'))<div class=" alert alert-success">{{ session('success') }}
|
||||
</div>
|
||||
<br>@endif
|
||||
<div class="col-8">
|
||||
<h4 class="page-title">{{$form->title}}</h4>
|
||||
</div>
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="col-4">
|
||||
@if($form->link_type == 'form')
|
||||
<a href="/form/history" class="float-end pt-1">View History</a>
|
||||
@else
|
||||
<a href="{{url()->previous()}}" class="float-end pt-1">Back</a>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
<form method="POST" action="/form/submit" id="report-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="{{$form_id}}">
|
||||
@csrf
|
||||
@if($id)
|
||||
<input type="hidden" name="id" value="{{$id}}">
|
||||
@endif
|
||||
@if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="field-user_id" class="form-label"> Select User / Territory <span class="text-danger">*</span> </label>
|
||||
<select class="form-control" id="field-user_id" name="user_id" required>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach($form->users as $option)
|
||||
<option value="{{$option->value}}" hierarchy="{{$option->hierarchy_id}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@foreach($questions as $question)
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="field-{{$question->code}}" class="form-label">{{$question->question}} {!!$question->required == 'yes' ? '<span class="text-danger">*</span>':''!!} </label>
|
||||
@switch($question->type)
|
||||
@case('hidden')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
@case('text')
|
||||
@case('email')
|
||||
@case('tel')
|
||||
@case('date')
|
||||
<input type="{{$question->type}}" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:''}}">
|
||||
@break
|
||||
@case('number')
|
||||
<input type="{{$question->type}}" min="0" max="9999999999" step="1" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}">
|
||||
@break
|
||||
@case('textarea')
|
||||
<textarea id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" {{$question->required == 'yes'?'required':'' }}>{{isset($question->value)?$question->value:''}}</textarea>
|
||||
@break
|
||||
@case('dropdown')
|
||||
<select class="form-control" id="field-{{$question->code}}" name="{{$question->code}}" {{$question->required == 'yes'?'required':'' }}>
|
||||
<option value=""> -- Select -- </option>
|
||||
@foreach($question->options as $option)
|
||||
<option value="{{$option->value}}" {{isset($question->value) && $question->value == $option->value ? 'selected':''}}>{{$option->display}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@break
|
||||
@case('checkbox')
|
||||
@foreach($question->options as $option)
|
||||
<div class="form-check mb-2 form-check-primary">
|
||||
<input class="form-check-input" type="checkbox" id="field-{{$question->code}}-{{$option->value}}" name="{{$question->code}}[]" value="{{$option->value}}" {{isset($question->value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
|
||||
<label class="form-check-label" for="field-{{$question->code}}-{{$option->value}}">{{$option->display}}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
@break
|
||||
@case('file')
|
||||
<input type="file" id="field-{{$question->code}}" name="{{$question->code}}" class="form-control" value="" accept="image/jpg, image/jpeg, image/png" required>
|
||||
@break
|
||||
@case('multitextbox')
|
||||
<div class="row">
|
||||
@foreach($question->options as $option)
|
||||
<div class="col-6">{{$option->display}}</div>
|
||||
<div class="col-6 mb-1">
|
||||
<input type="number" id="field-{{$option->value}}" name="{{$option->value}}" class="form-control" required value="{{isset($option->val)?$option->val:0}}">
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@break
|
||||
@endswitch
|
||||
</div>
|
||||
@endforeach
|
||||
@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
|
||||
<div class="text-center d-grid mt-3">
|
||||
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit </button>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
</div> <!-- end card-body -->
|
||||
</div>
|
||||
<!-- end card -->
|
||||
|
||||
<!-- end row -->
|
||||
|
||||
</div> <!-- end col -->
|
||||
</div>
|
||||
<!-- end row -->
|
||||
</div>
|
||||
<!-- end container -->
|
||||
</div>
|
||||
<!-- end page -->
|
||||
<style type="text/css">
|
||||
#pageloader {
|
||||
background: rgba( 255, 255, 255, 0.8 );
|
||||
display: none;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#pageloader img {
|
||||
left: 50%;
|
||||
margin-left: -32px;
|
||||
margin-top: -32px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
}
|
||||
</style>
|
||||
@include('layouts.shared/footer-script')
|
||||
<script src="{{asset('assets/libs/sweetalert2/sweetalert2.min.js')}}"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('#field-user_id').change(function(){
|
||||
let hierarchy = $('option:selected', this).attr('hierarchy');
|
||||
event.preventDefault();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/form/getdoctorlist?partition={{$form->partition}}&hierarchy='+hierarchy,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
$("#pageloader").fadeOut();
|
||||
$('#field-contact_id').html('')
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
|
||||
for(let itm of data) {
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
console.log(hierarchy)
|
||||
})
|
||||
|
||||
$('#field-arnicor_50_mg').parent().hide()
|
||||
$('#field-arnicor_100_mg').parent().hide()
|
||||
$('#field-arnicor_200_mg').parent().hide()
|
||||
$('#field-free_strips_given').change(function(){
|
||||
if($(this).val() == 'Yes') {
|
||||
$('#field-arnicor_50_mg').parent().show()
|
||||
$('#field-arnicor_100_mg').parent().show()
|
||||
$('#field-arnicor_200_mg').parent().show()
|
||||
} else {
|
||||
$('#field-arnicor_50_mg').parent().hide()
|
||||
$('#field-arnicor_100_mg').parent().hide()
|
||||
$('#field-arnicor_200_mg').parent().hide()
|
||||
}
|
||||
})
|
||||
|
||||
$('#report-form').on('submit', function(event){
|
||||
event.preventDefault();
|
||||
$("#pageloader").fadeIn();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/form/ajaxsubmit',
|
||||
data: new FormData($('#report-form')[0]),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
$("#pageloader").fadeOut();
|
||||
if(data.status == 'success') {
|
||||
Swal.fire({
|
||||
title: 'Great!',
|
||||
text: 'Your data is successfully submitted!',
|
||||
icon: 'success'
|
||||
})
|
||||
$('#report-form').trigger("reset");
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Data not submitted',
|
||||
text: 'Something went wrong, please try again after some time!'
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -139,6 +139,27 @@
|
|||
$('#field-pob_total').val( parseInt($('#field-pob_arni_50mg').val()) + parseInt($('#field-pob_arni_100mg').val()) + parseInt($('#field-pob_arni_200mg').val()) )
|
||||
})
|
||||
|
||||
@if(isset($questions[0]->value))
|
||||
if($('#field-customer_type').val() == 'Doctor') {
|
||||
$('#field-contact_id').parent().show()
|
||||
$('#field-msl_code').parent().show()
|
||||
$('#field-contact_id').prop('required',true)
|
||||
$('#field-rx_arnicode_50mg').parent().show()
|
||||
$('#field-rx_arnicode_100mg').parent().show()
|
||||
$('#field-rx_arnicode_200mg').parent().show()
|
||||
} else {
|
||||
$('#field-retailer_name').parent().show()
|
||||
$('#field-pob_arni_50mg').parent().show()
|
||||
$('#field-pob_arni_100mg').parent().show()
|
||||
$('#field-pob_arni_200mg').parent().show()
|
||||
$('#field-pob_total').parent().show()
|
||||
$('#field-contact_id').removeAttr('required')
|
||||
}
|
||||
$('#field-record_date').parent().show()
|
||||
$('#report-form input').removeAttr('required')
|
||||
$('#report-form input:visible').prop('required',true)
|
||||
@endif
|
||||
|
||||
$('#field-customer_type').change(function(){
|
||||
$('#report-form input').parent().find('.col-md-12').hide()
|
||||
$('#field-customer_type').parent().show()
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@
|
|||
<th>Region</th>
|
||||
<th>Area</th>
|
||||
<th>Territory</th>
|
||||
<th>Role</th>
|
||||
@foreach($graph->values->metrics as $metric)
|
||||
<th>{{$metric->metric}}</th>
|
||||
@endforeach
|
||||
|
|
@ -234,6 +235,7 @@
|
|||
<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>
|
||||
<td>{{ isset($user->roles) ? (is_array($user->roles) ? implode(',', $user->roles) : $user->roles) : '-' }}</td>
|
||||
@foreach($graph->values->metrics as $metric)
|
||||
<td>{{ isset($metric->stats->{$user->id}) ? $metric->stats->{$user->id} : '-' }}</th>
|
||||
@endforeach
|
||||
|
|
|
|||
Loading…
Reference in New Issue