diff --git a/app/Http/Controllers/CampaignController.php b/app/Http/Controllers/CampaignController.php index 875b465a..f3fa58b1 100644 --- a/app/Http/Controllers/CampaignController.php +++ b/app/Http/Controllers/CampaignController.php @@ -166,7 +166,7 @@ class CampaignController extends Controller public function export(Request $request) { $post = $request->except('_token'); - //$post['export'] = 1; + $post['export'] = 1; $response = LambdaRequest::signedrequest('post', $this->_service, $this->_module.'/view', $post, 60); //echo '
'; print_r($response); exit;
//echo ''; print_r($response); print_r($post); exit;
@@ -189,7 +189,7 @@ class CampaignController extends Controller
break;
case 'details':
- $headers = ['User', 'Employee Code', 'Email', 'Designation', 'Zone', 'Region', "Area", "Territory", "Rank", "Total Units", "Total Points"];
+ $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", "Rank", "Total Units", "Total Points"];
foreach($response->data->metrics as $metric) {
$headers[] = $metric->name . ' Units';
$headers[] = $metric->name . ' Points';
@@ -202,6 +202,13 @@ class CampaignController extends Controller
$row[] = $user->user_info->email;
$row[] = $user->user_info->designation;
+ $row[] = isset($user->user_info->manager1->name) ? $user->user_info->manager1->name : '-';
+ $row[] = isset($user->user_info->manager1->employee_code) ? $user->user_info->manager1->employee_code : '-';
+ $row[] = isset($user->user_info->manager1->email) ? $user->user_info->manager1->email : '-';
+ $row[] = isset($user->user_info->manager2->name) ? $user->user_info->manager2->name : '-';
+ $row[] = isset($user->user_info->manager2->employee_code) ? $user->user_info->manager2->employee_code : '-';
+ $row[] = isset($user->user_info->manager2->email) ? $user->user_info->manager2->email : '-';
+
$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 : '-';
diff --git a/app/Http/Controllers/CampaignreportController.php b/app/Http/Controllers/CampaignreportController.php
index fcee28e3..d5ca8a52 100644
--- a/app/Http/Controllers/CampaignreportController.php
+++ b/app/Http/Controllers/CampaignreportController.php
@@ -229,7 +229,7 @@ class CampaignreportController extends Controller
} else {
$token = $request->session()->get('metric_access_key');
}
-
+ $post['export'] = 1;
$response = LambdaRequest::postrequest($this->_service, $this->_module.'/view', $post, $token);
$exceldata = [];
if(!isset($post['type'])) {
@@ -245,7 +245,7 @@ class CampaignreportController extends Controller
break;
case 'details':
- $headers = ['User', 'Employee Code', 'Email', 'Designation', 'Zone', 'Region', "Area", "Territory", "Rank", "Total Units", "Total Points"];
+ $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", "Rank", "Total Units", "Total Points"];
foreach($response->data->metrics as $metric) {
$headers[] = $metric->name . ' Units';
$headers[] = $metric->name . ' Points';
@@ -258,6 +258,13 @@ class CampaignreportController extends Controller
$row[] = $user->user_info->email;
$row[] = $user->user_info->designation;
+ $row[] = isset($user->user_info->manager1->name) ? $user->user_info->manager1->name : '-';
+ $row[] = isset($user->user_info->manager1->employee_code) ? $user->user_info->manager1->employee_code : '-';
+ $row[] = isset($user->user_info->manager1->email) ? $user->user_info->manager1->email : '-';
+ $row[] = isset($user->user_info->manager2->name) ? $user->user_info->manager2->name : '-';
+ $row[] = isset($user->user_info->manager2->employee_code) ? $user->user_info->manager2->employee_code : '-';
+ $row[] = isset($user->user_info->manager2->email) ? $user->user_info->manager2->email : '-';
+
$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 : '-';
diff --git a/app/Http/Controllers/DomainController.php b/app/Http/Controllers/DomainController.php
index cb7ae140..4f70fb7a 100644
--- a/app/Http/Controllers/DomainController.php
+++ b/app/Http/Controllers/DomainController.php
@@ -68,6 +68,9 @@ class DomainController extends Controller
'territory_types' => ['title' => 'Territory Types', 'type' => 'multiselect', 'required' => true, 'values' => $territories ],
'logo' => ['title' => 'Group Image or Icon', 'type' => 'image', 'required' => true],
'description' => ['title' => 'Description', 'type' => 'textarea', 'required' => true],
+ 'use_default_otp' => ['title' => 'Use Default OTP', 'type' => 'select', 'required' => true, 'values' => ['Yes' => 'Yes', 'No' => 'No'] ],
+ 'default_otp' => ['title' => 'Default OTP to be used', 'type' => 'number', 'required' => true],
+
'terms_text' => ['title' => 'Login Terms & Conditions Text', 'type' => 'textarea', 'required' => true, 'fullwidth' => true],
];
diff --git a/app/Http/Controllers/FormController.php b/app/Http/Controllers/FormController.php
index f127e110..46498cb3 100644
--- a/app/Http/Controllers/FormController.php
+++ b/app/Http/Controllers/FormController.php
@@ -28,7 +28,9 @@ class FormController extends Controller
protected function deliverform($formdata, $questions, $id = false) {
$additional_info = $this->get_additional_info($formdata);
-
+ // if($formdata->form_id == '1672808391-a35fbd00-fbc8-40a6-ad40-6172011c546e') {
+ // echo ''; print_r($formdata); print_r($questions); exit;
+ // }
//echo ''; print_r($formdata); print_r($questions); exit;
$data = ['questions' => $questions, 'form' => $formdata, 'form_id' => $formdata->form_id, 'id' => false, 'id' => $id ];
if(sizeof($additional_info) > 0) {
@@ -359,7 +361,21 @@ class FormController extends Controller
$post['powerof5_triohale_rx'] = $post['triohale_rx'];
}
break;
-
+ case '1675171879-850cf63f-864d-42e1-82e7-2a60e92712b6':
+ $post['launched_count'] = [];
+ foreach($post['contact_id'] as $i => $c) {
+ $post['launched_count'][] = $post['launched'][$i] == 'Yes' ? 1 : 0;
+ }
+ break;
+ case '1672051617-b274ae94-8706-4f0f-8e65-6e4380f7c005':
+ case '1673857541-fe4fef4b-6b1c-4326-96ec-f71634ee91db':
+ if($post['is_hridayam_doctor'] == 'Yes') {
+ $rxformdata = $post;
+ $rxformdata['form_id'] = '1672051617-b274ae94-8704-4f0f-8e85-6e4380f7c4543';
+ LambdaRequest::postrequest('form', 'formentity/submitform', ['formdata' => $rxformdata, 'entity_id' => $rxformdata['form_id'], 'user_id' => $user_id, 'partition' => $partition ]);
+ }
+ break;
+
}
return $post;
@@ -770,7 +786,7 @@ class FormController extends Controller
foreach($history->data->submissions as $submission) {
$row = [];
$row[] = $submission->createdAt;
- $row[] = $submission->user_info->name;
+ $row[] = isset($submission->user_info->name) ? $submission->user_info->name : '';
foreach($history->data->questions as $q => $v) {
$row[] = isset($submission->formdata->{$q}) ? $submission->formdata->{$q} : '-';
}
@@ -886,6 +902,19 @@ class FormController extends Controller
if(isset($formdata) && !empty($formdata) && $formdata->user_id != '') {
$post = $this->processformdata($formdata->form_id, $post, $formdata->user_id, $formdata->partition);
$finfo = LambdaRequest::postrequest('form', 'survey/submitform', ['formdata' => $post, 'entity_id' => $formdata->form_id, 'user_id' => $formdata->user_id, 'partition' => $formdata->partition ]);
+
+ if($formdata->form_id == '1674212914-9f377f34-4762-4b40-team3-8b282d183332') {
+ unset($post['form_id']);
+ Log::debug(print_r($post, true));
+ echo ''; print_r($post); exit;
+ $handler = curl_init();
+ curl_setopt($handler, CURLOPT_URL, "https://gnpdoctor.buildrapport.co/neblogisticsave/ciplatodoctor");
+ curl_setopt($handler, CURLOPT_POSTFIELDS, http_build_query($post));
+ curl_setopt($handler, CURLOPT_POST, 1);
+ curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
+ $response = curl_exec($handler);
+
+ }
if($finfo->status == 'success') {
return response()->json(['status' => 'success']);
} else {
@@ -895,4 +924,59 @@ class FormController extends Controller
return response()->json(['status' => 'failure']);
}
}
+
+
+ public function quizhandle($finfo, Request $request) {
+ $request->session()->put('finfo', $finfo);
+ $finfo = LambdaRequest::postrequest('form', 'quiz/getforminfo', ['finfo' => $finfo]);
+ //echo ''; print_r($finfo); exit;
+ $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);
+ $formdata = $finfo->data->formdata;
+ $questions = $finfo->data->questions;
+ $data = ['questions' => $questions, 'form' => $formdata, 'form_id' => $formdata->form_id, 'id' => false];
+ if (\View::exists('quiz.'.$formdata->partition.'.'.$formdata->form_id)) {
+ return view('quiz.'.$formdata->partition.'.'.$formdata->form_id)->with($data);
+ } elseif (\View::exists('quiz.'.$formdata->form_id)) {
+ return view('quiz.'.$formdata->form_id)->with($data);
+ } else {
+ // return $data;
+ return view('quiz.common')->with($data);
+ }
+
+ } elseif($finfo->status == 'success' && $finfo->data->formdata->link_type == 'list') {
+ //echo ''; print_r($finfo->data); exit;
+ if (\View::exists('quiz.list-'.$finfo->data->formdata->form_id)) {
+ return view('quiz.list-'.$finfo->data->formdata->form_id)->with(['questions' => $finfo->data->questions, 'submissions' => $finfo->data->submissions, 'formname' => $finfo->data->formdata->title, 'form_id' => $finfo->data->formdata->form_id, 'lastkey' => $finfo->data->lastkey ]);
+ } else {
+ return view('quiz.list')->with(['questions' => $finfo->data->questions, 'submissions' => $finfo->data->submissions, 'formname' => $finfo->data->formdata->title, 'form_id' => $finfo->data->formdata->form_id, 'lastkey' => $finfo->data->lastkey ]);
+ }
+ }
+ }
+
+ public function ajaxquizsubmit(Request $request) {
+ $post = $request->except('_token');
+ $formdata = $request->session()->get('formdata');
+ //print_r($formdata); exit;
+
+
+ if(isset($post['user_id']) && $post['user_id'] != '') {
+ $formdata->user_id = $post['user_id'];
+ }
+ if(isset($formdata) && !empty($formdata) && $formdata->user_id != '') {
+ // echo ''; print_r(['formdata' => $post, 'entity_id' => $formdata->form_id, 'user_id' => $formdata->user_id, 'partition' => $formdata->partition ]); exit;
+
+
+ $finfo = LambdaRequest::postrequest('form', 'quiz/submitform', ['formdata' => $post, 'entity_id' => $formdata->form_id, 'user_id' => $formdata->user_id, 'partition' => $formdata->partition ]);
+ //echo ''; print_r($finfo); exit;
+ if($finfo->status == 'success') {
+ return response()->json(['status' => 'success', 'submission' => $finfo->data->submission]);
+ } else {
+ return response()->json(['status' => 'failure']);
+ }
+ } else {
+ return response()->json(['status' => 'failure']);
+ }
+ }
}
\ No newline at end of file
diff --git a/app/Http/Controllers/FormactionController.php b/app/Http/Controllers/FormactionController.php
index d804fa73..34fbb6ea 100644
--- a/app/Http/Controllers/FormactionController.php
+++ b/app/Http/Controllers/FormactionController.php
@@ -51,13 +51,18 @@ class FormactionController extends Controller
$forms_dd[$form->id] = $form->title . ' (Survey)';
}
+ $quizs = $this->getlambda('get', 'form', 'quiz', 'dropdown');
+ foreach($quizs->data->items as $form){
+ $forms_dd[$form->id] = $form->name . ' (Quiz)';
+ }
+
return [
'name' => ['title' => 'Title', 'type' => 'text', 'required' => true],
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ],
'groups' => ['title' => 'Groups', 'type' => 'multiselect', 'required' => true, 'values' => $groups_dd ],
'roles' => ['title' => 'Roles', 'type' => 'multiselect', 'required' => true, 'values' => $roles_dd ],
- 'target_type' => ['title' => 'Target Type', 'type' => 'select', 'required' => true, 'values' => ['form' => 'Web Form', 'survey' => 'Surveys', 'external' => 'External Webpage', 'nativeform' => 'Native Form (coming soon)'] ],
+ 'target_type' => ['title' => 'Target Type', 'type' => 'select', 'required' => true, 'values' => ['form' => 'Web Form', 'survey' => 'Surveys', 'quiz' => 'Quizs', 'external' => 'External Webpage', 'nativeform' => 'Native Form (coming soon)'] ],
'form_id' => ['title' => 'Form', 'type' => 'select', 'values' => $forms_dd ],
'link_type' => ['title' => 'Menu Type (valid of forms only)', 'type' => 'select', 'required' => true, 'values' => ['form' => 'Web Form', 'list' => 'Submitted Data'] ],
'external_url' => ['title' => 'External Url', 'type' => 'text'],
diff --git a/app/Http/Controllers/FormentityController.php b/app/Http/Controllers/FormentityController.php
index dd04cabf..dca0108d 100644
--- a/app/Http/Controllers/FormentityController.php
+++ b/app/Http/Controllers/FormentityController.php
@@ -41,6 +41,12 @@ class FormentityController extends Controller
foreach($roles->data->items as $role){
$roles_dd[$role->id] = $role->name;
}
+
+ $coattr = $this->getlambda('get', 'ums', 'contactattribute', 'get_all');
+ $coattr_dd = [];
+ foreach($coattr->data->items as $coatt){
+ $coattr_dd[$coatt->code] = $coatt->attribute;
+ }
return [
'title' => ['title' => 'Title', 'type' => 'text', 'required' => true],
@@ -49,7 +55,8 @@ class FormentityController extends Controller
'metric_authkey' => ['title' => 'Auth Key', 'type' => 'text', 'required' => true],
'manager_de_roles' => ['title' => 'Manager Data Entry Roles', 'type' => 'multiselect', 'values' => $roles_dd ],
-
+ 'contact_attributes' => ['title' => 'Include Doctor Attributes in Export', 'type' => 'multiselect', 'values' => $coattr_dd],
+
'self_notification' => ['title' => 'Self Email Notification', 'type' => 'yesno', 'required' => true, 'fullwidth' => true],
'manager1_email_notification' => ['title' => '1st Level Manager Email Notification', 'type' => 'yesno', 'required' => true],
'manager1_push_notification' => ['title' => '1st Level Manager Mobile Notification', 'type' => 'yesno', 'required' => true],
@@ -62,6 +69,8 @@ class FormentityController extends Controller
'approver_can_edit' => ['title' => 'Approver can edit entry', 'type' => 'yesno', 'required' => true],
'is_personalized' => ['title' => 'Is Personalization Needed', 'type' => 'yesno', 'required' => true],
'workflow_approvers' => ['title' => 'Metric', 'type' => 'mapping', 'required' => true, 'approvers' => $users_dd, 'fullwidth' => true ],
+
+
];
}
diff --git a/app/Http/Controllers/FormquestionController.php b/app/Http/Controllers/FormquestionController.php
index 569038fc..58d6d80d 100644
--- a/app/Http/Controllers/FormquestionController.php
+++ b/app/Http/Controllers/FormquestionController.php
@@ -56,7 +56,7 @@ class FormquestionController extends Controller
return [
'question' => ['title' => 'Question', 'type' => 'text', 'required' => true, 'fullwidth' => true],
'code' => ['title' => 'Code (small caps without spaces and special chars except "_")', 'type' => 'text', 'required' => true],
- 'type' => ['title' => 'Question Type', 'type' => 'select', 'required' => true, 'values' => ['text' => 'Text', 'number' => 'Number', 'date' => 'Date', 'email' => 'Email', 'url' => 'Url', 'dropdown' => 'Dropdown', 'checkbox' => 'Checkbox', 'radio' => 'Radio', 'multitextbox' => 'Multi Text Boxes', 'contacts' => 'Contacts', 'file' => 'File Upload'] ],
+ 'type' => ['title' => 'Question Type', 'type' => 'select', 'required' => true, 'values' => ['text' => 'Text', 'number' => 'Number', 'date' => 'Date', 'time' => 'Time', 'email' => 'Email', 'url' => 'Url', 'dropdown' => 'Dropdown', 'checkbox' => 'Checkbox', 'radio' => 'Radio', 'multitextbox' => 'Multi Text Boxes', 'contacts' => 'Contacts', 'file' => 'File Upload'] ],
'required' => ['title' => 'Is Required', 'type' => 'yesno', 'required' => true],
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ],
'options' => ['title' => 'Options', 'type' => 'mapping', 'fullwidth' => true ],
diff --git a/app/Http/Controllers/MetricreportController.php b/app/Http/Controllers/MetricreportController.php
index 9826e199..502d645c 100644
--- a/app/Http/Controllers/MetricreportController.php
+++ b/app/Http/Controllers/MetricreportController.php
@@ -88,9 +88,41 @@ class MetricreportController extends Controller
$exceldata[] = [''];
switch($response->data->post->type) {
case 'leaderboard':
- $exceldata[] = ["Rank", "User", "Designation", "Units", "Percent"];
+ $headings = ["Rank", "User", "User Id", "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", "Units", "Percent", "Active User"];
+ if(count($response->data->graph->values) > 0 && isset($response->data->graph->values[0]->stats->prescribers) ){
+ $headings[] = "Prescribers";
+ }
+ foreach($response->data->graph->metrics as $val) {
+ $headings[] = $val->display;
+ }
+
+ $exceldata[] = $headings;
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 ];
+ $rowdata = [(string)$val->rank, (string)$val->user->name, (string)$val->user->id, $val->user->designation];
+ $user = $val->user;
+ $rowdata[] = isset($user->manager1->name) ? $user->manager1->name : '-';
+ $rowdata[] = isset($user->manager1->employee_code) ? $user->manager1->employee_code : '-';
+ $rowdata[] = isset($user->manager1->email) ? $user->manager1->email : '-';
+ $rowdata[] = isset($user->manager2->name) ? $user->manager2->name : '-';
+ $rowdata[] = isset($user->manager2->employee_code) ? $user->manager2->employee_code : '-';
+ $rowdata[] = isset($user->manager2->email) ? $user->manager2->email : '-';
+
+ $rowdata[] = isset($user->positions->Zone) ? $user->positions->Zone : '-';
+ $rowdata[] = isset($user->positions->Region) ? $user->positions->Region : '-';
+ $rowdata[] = isset($user->positions->Area) ? $user->positions->Area : '-';
+ $rowdata[] = isset($user->positions->Territory) ? $user->positions->Territory : '-';
+
+ $rowdata[] = (string)round($val->score, 2);
+ $rowdata[] = (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;
+ $rowdata[] = (String)isset($val->stats->ucount) ? $val->stats->ucount:0;
+
+ if(isset($val->stats->prescribers) ) {
+ $rowdata[] = $val->stats->prescribers;
+ }
+ foreach($response->data->graph->metrics as $m) {
+ $rowdata[] = isset($val->stats->{$m->metric}) ? $val->stats->{$m->metric} : 0;
+ }
+ $exceldata[] = $rowdata;
}
break;
case 'trend':
@@ -164,7 +196,11 @@ class MetricreportController extends Controller
if($response->data->graph->chart == 'contacts') {
//echo ''; print_r($response->data->graph->values); exit;
- $headers = ['Doctor', 'MSL Code', '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 = ['Doctor', 'MSL Code'];
+ foreach($response->data->graph->contact_attributes as $attr) {
+ $headers[] = ucwords($attr);
+ }
+ $headers = array_merge($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"]);
foreach($response->data->graph->values->metrics as $metric) {
$headers[] = $metric->metric;
}
@@ -173,8 +209,12 @@ class MetricreportController extends Controller
$row = [];
$row[] = $contact->name;
$row[] = $contact->msl_code;
- $user = $response->data->graph->values->users->{$contact->id};
+ foreach($response->data->graph->contact_attributes as $attr) {
+ $row[] = isset($contact->{$attr}) ? $contact->{$attr} : '';
+ }
+
+ $user = $response->data->graph->values->users->{$contact->id};
$row[] = $user->name;
$row[] = $user->employee_code;
$row[] = $user->email;
diff --git a/app/Http/Controllers/MetricviewController.php b/app/Http/Controllers/MetricviewController.php
index 6dc26605..259dc565 100644
--- a/app/Http/Controllers/MetricviewController.php
+++ b/app/Http/Controllers/MetricviewController.php
@@ -73,7 +73,13 @@ class MetricviewController extends Controller
foreach($roles->data->items as $role){
$roles_dd[$role->id] = $role->name;
}
-
+
+ $coattr = $this->getlambda('get', 'ums', 'contactattribute', 'get_all');
+ $coattr_dd = [];
+ foreach($coattr->data->items as $coatt){
+ $coattr_dd[$coatt->code] = $coatt->attribute;
+ }
+ //echo ''; print_r($coattr_dd); exit;
$fields = [
'name' => ['title' => 'Name', 'type' => 'text', 'required' => true],
//'type' => ['title' => 'Type', 'type' => 'select', 'required' => true, 'values' => ['simple' => 'Simple', 'grouped' => 'Grouped', 'verses' => 'A vs B'] ],
@@ -125,7 +131,9 @@ class MetricviewController extends Controller
'report_roles' => ['title' => 'Data Report from Roles', 'type' => 'multiselect', 'values' => $roles_dd, 'required' => true],
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ],
+ 'show_positions' => ['title' => 'Show Position in Reports', 'type' => 'select', 'required' => true, 'values' => ['Yes' => 'Yes', 'No' => 'No'] ],
+ 'contact_attributes' => ['title' => 'Include Doctor Attributes', 'type' => 'multiselect', 'values' => $coattr_dd],
]);
return $fields;
@@ -140,11 +148,12 @@ class MetricviewController extends Controller
} else {
foreach($data['metric'] as $k => $metric) {
- $data['metrics'][] = ['metric' => $metric, 'display' => $data['display_unit'][$k] ];
+ $data['metrics'][] = ['metric' => $metric, 'display' => $data['display_unit'][$k], 'sort_order' => $data['sort_order'][$k] ];
}
}
unset($data['metric']);
unset($data['display_unit']);
+ unset($data['sort_order']);
//echo ''; print_r($data); exit;
return $data;
}
diff --git a/app/Http/Controllers/QuizController.php b/app/Http/Controllers/QuizController.php
new file mode 100644
index 00000000..f047935b
--- /dev/null
+++ b/app/Http/Controllers/QuizController.php
@@ -0,0 +1,142 @@
+middleware('auth');
+ $this->_service = 'form';
+ $this->_module = 'quiz';
+ $this->_viewname = 'quiz';
+ $this->_title = 'Quiz';
+ $this->_base_url = '/quiz';
+ }
+
+ protected function get_list_fields(){
+ return [
+ 'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete', 'submission' => ['icon' => 'form-select', 'querystring' => 'id={ID}'] ] ],
+ 'name' => ['title' => 'Name', 'type' => 'text'],
+ 'show_score' => ['title' => 'Show Score', 'type' => 'text'],
+ 'show_answers' => ['title' => 'Show Answers', 'type' => 'text'],
+ 'number_attempts' => ['title' => 'No. of Attempts', 'type' => 'text'],
+ 'start_time' => ['title' => 'Start Time', 'type' => 'text'],
+ 'end_time' => ['title' => 'End Time', 'type' => 'text'],
+ 'status' => ['title' => 'Status', 'type' => 'select'],
+ ];
+ }
+
+
+ protected function get_form_fields($type, $values){
+ return [
+ 'name' => ['title' => 'Name', 'type' => 'text', 'required' => true, 'fullwidth' => true],
+ 'show_score' => ['title' => 'Show Score', 'type' => 'select', 'required' => true, 'values' => ['Yes' => 'Yes', 'No' => 'No' ]],
+ 'show_answers' => ['title' => 'Show Answers', 'type' => 'select', 'required' => true, 'values' => ['Yes' => 'Yes', 'No' => 'No' ]],
+ 'limit_attempts' => ['title' => 'Limit Attempts', 'type' => 'select', 'required' => true, 'values' => ['Yes' => 'Yes', 'No' => 'No' ]],
+ 'number_attempts' => ['title' => 'No. of attempts', 'type' => 'number', 'required' => true],
+ 'start_time' => ['title' => 'Start Time', 'type' => 'datetime', 'required' => true],
+ 'end_time' => ['title' => 'End Time', 'type' => 'datetime', 'required' => true],
+ 'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ],
+ ];
+ }
+
+ public function form($type, $id = null) {
+ $values = [];
+ $questions = [];
+ if($type == 'edit') {
+ $this->_request->session()->put('current_quiz', $id);
+ $response = LambdaRequest::signedrequest('get', $this->_service, $this->_module.'/get_one', ['id' => $id]);
+ $values = $response->data->item;
+
+ $questions = LambdaRequest::signedrequest('get', $this->_service, 'quizquestion/get_all', ['entity_id' => $id]);
+ $questions = $questions->data->items;
+ }
+ $data = $this->_beforeform($type, $values);
+ $fields = $this->get_form_fields($type, $values);
+
+ return $this->view('form')->with([
+ 'title' => $this->_title,
+ 'mode' => $type,
+ 'fields' => $fields,
+ 'base_url' => $this->_base_url,
+ 'item' => $values,
+ 'questions' => $questions
+ ]);
+ }
+
+ public function addquestion($request) {
+ $post = $request->input();
+ $quiz_id = $request->session()->get('current_quiz');
+ return $this->view('question-form')->with('quiz_id', $quiz_id)->with('edit', false);
+ }
+ public function editquestion($request) {
+ $post = $request->input();
+ $quiz_id = $request->session()->get('current_quiz');
+ $question = LambdaRequest::signedrequest('get', $this->_service, 'quizquestion/get_one', ['id' => $post['id']]);
+ $question = $question->data->item;
+ return $this->view('question-form')->with('quiz_id', $quiz_id)->with('edit', true)->with('question', $question);
+ }
+
+ public function postaddquestion($request) {
+ $post = $request->input();
+ $quiz_id = $request->session()->get('current_quiz');
+ $options = [];
+ foreach ($post['options'] as $index => $value) {
+ $options[] = ['option' => $value, 'is_correct' => ($index == $post['correct_ans']) ];
+ }
+ LambdaRequest::signedrequest('post', $this->_service, 'quizquestion/create', ['entity_id' => $quiz_id, 'question' => $post['question'], 'options' => $options]);
+ $message = 'Question added successfully!';
+ return redirect('/quiz/edit?id='.$quiz_id)->with('message', $message);
+ }
+
+ public function posteditquestion($request) {
+ $post = $request->input();
+ //echo ''; print_r($post); exit;
+ $quiz_id = $request->session()->get('current_quiz');
+ $options = [];
+ foreach ($post['options'] as $index => $value) {
+ $options[] = ['option' => $value, 'is_correct' => ($index == $post['correct_ans']) ];
+ }
+ LambdaRequest::signedrequest('post', $this->_service, 'quizquestion/update', ['id' => $post['id'], 'entity_id' => $quiz_id, 'question' => $post['question'], 'options' => $options]);
+ $message = 'Question added successfully!';
+ return redirect('/quiz/edit?id='.$quiz_id)->with('message', $message);
+ }
+
+
+ public function questions(Request $request) {
+ $entity_id = $request->input('id', 0);
+ if($entity_id === 0) {
+ return redirect('/quizs')->withError('Quiz not found!');
+ } else {
+ $request->session()->put('entity_id', $entity_id);
+ return redirect('/quizquestions');
+ }
+ }
+
+ public function submission(Request $request) {
+ $entity_id = $request->input('id', 0);
+ if($entity_id === 0) {
+ return redirect('/quizs')->withError('Quiz not found!');
+ } else {
+ $request->session()->put('entity_id', $entity_id);
+ return redirect('/quizsubmissions');
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/QuizquestionController.php b/app/Http/Controllers/QuizquestionController.php
new file mode 100644
index 00000000..e8c7e65c
--- /dev/null
+++ b/app/Http/Controllers/QuizquestionController.php
@@ -0,0 +1,87 @@
+middleware('auth');
+ $this->_service = 'form';
+ $this->_module = 'quizquestion';
+ $this->_viewname = 'quizquestion';
+ $this->_title = 'Quiz Questions';
+ $this->_base_url = '/quizquestion';
+ }
+
+ public function list(Request $request) {
+ $entity_id = $request->session()->get('entity_id');
+ if($entity_id === 0) {
+ return redirect('/quizquestions')->withError('Question not found!');
+ }
+ $response = LambdaRequest::signedrequest('get', $this->_service, $this->_module.'/get_all', ['entity_id' => $entity_id]);
+ //echo ''; print_r($response); exit;
+ $fields = $this->get_list_fields();
+ return $this->view('list')->with([
+ 'title' => $this->_title,
+ 'fields' => $fields,
+ 'base_url' => $this->_base_url,
+ 'items' => $response->data->items,
+ 'buttons' => $this->get_list_buttons()
+ ]);
+ }
+
+ protected function get_list_buttons() {
+ return [ ['title' => 'Add New', 'link' => $this->_base_url.'/addnew' ], ['title' => 'Back to Quizs', 'link' => '/quizs'] ];
+ }
+
+ protected function get_list_fields(){
+ return [
+ 'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete' ] ],
+ //'media_thumb' => ['title' => 'Media Thumb', 'type' => 'image'],
+ 'question' => ['title' => 'Question', 'type' => 'text'],
+ 'status' => ['title' => 'Status', 'type' => 'select'],
+ ];
+ }
+
+ protected function get_form_fields($type, $values){
+ $groups = $this->getlambda('get', 'ums', 'group', 'dropdown');
+ $groups_dd = [];
+ foreach($groups->data->items as $group){
+ $groups_dd[$group->id] = $group->name;
+ }
+ return [
+ 'question' => ['title' => 'Question', 'type' => 'text', 'required' => true, 'fullwidth' => true],
+ 'code' => ['title' => 'Code (small caps without spaces and special chars except "_")', 'type' => 'text', 'required' => true],
+ 'type' => ['title' => 'Question Type', 'type' => 'select', 'required' => true, 'values' => ['text' => 'Text', 'number' => 'Number', 'date' => 'Date', 'email' => 'Email', 'url' => 'Url', 'dropdown' => 'Dropdown', 'checkbox' => 'Checkbox', 'radio' => 'Radio', 'radiometrix' => 'RadioMetrix', 'multitextbox' => 'Multi Text Boxes', 'contacts' => 'Contacts', 'file' => 'File Upload'] ],
+ 'required' => ['title' => 'Is Required', 'type' => 'yesno', 'required' => true],
+ 'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ],
+ 'options' => ['title' => 'Options', 'type' => 'mapping', 'fullwidth' => true ],
+ ];
+ }
+
+ protected function _beforesave($type, $request) {
+ $data = $request->except('_token');
+ $data['entity_id'] = $request->session()->get('entity_id');
+ $options = [];
+ if(isset($data['option_value'])) {
+ foreach($data['option_value'] as $k => $ov) {
+ $options[] = ['value' => $ov, 'display' => $data['option_name'][$k], 'cost' => $data['option_cost'][$k] ];
+ }
+ $data['options'] = $options;
+ unset($data['option_value']);
+ unset($data['option_name']);
+ unset($data['option_cost']);
+ }
+ return $data;
+ }
+
+ protected function _beforeform($type, $values) {
+
+ return $values;
+ }
+
+}
diff --git a/app/Http/Controllers/QuizsubmissionController.php b/app/Http/Controllers/QuizsubmissionController.php
new file mode 100644
index 00000000..e511a67f
--- /dev/null
+++ b/app/Http/Controllers/QuizsubmissionController.php
@@ -0,0 +1,136 @@
+middleware('auth');
+ $this->_service = 'form';
+ $this->_module = 'quiz';
+ $this->_viewname = 'quizsubmission';
+ $this->_title = ' : Submitted Data';
+ $this->_base_url = '/quizsubmission';
+ }
+
+ protected function get_list_buttons()
+ {
+ return [['title' => 'Date Filter', 'link' => '#.'], ['title' => 'Export Excel', 'link' => $this->_base_url . '/export']];
+ }
+
+ public function list(Request $request)
+ {
+ $user = Auth::user();
+ $form_id = $request->session()->get('entity_id');
+ $post = $request->input();
+ if (isset($post['startdate']))
+ $startdate = $post['startdate'];
+ else
+ $startdate = date("Y/m/d", strtotime("-365 day"));
+
+ if (isset($post['enddate']))
+ $enddate = $post['enddate'];
+ else
+ $enddate = date("Y/m/d", strtotime("now") + 86400);
+
+ $reqdata = ["partition" => 'rapport-' . $user->domain, "form_id" => $form_id, "alldata" => true, "date_range" => $startdate . '_' . $enddate];
+ $request->session()->put('formdata_request', $reqdata);
+ //echo ''; print_r($reqdata); exit;
+ $response = LambdaRequest::signedrequest('post', $this->_service, $this->_module . '/getformhistory', $reqdata);
+ if ($response->statusCode == 401) {
+ return redirect('/unauthorised');
+ }
+ //echo ''; print_r($response); exit;
+ $fields = [
+ 'user' => ['title' => 'Submitted By', 'type' => 'text'],
+ 'date' => ['title' => 'Record Date', 'type' => 'text'],
+ 'sdate' => ['title' => 'Submitted On', 'type' => 'text'],
+ 'total_questions' => ['title' => 'Total Questions', 'type' => 'text'],
+ 'correct_answers' => ['title' => 'Correct Answers', 'type' => 'text'],
+ 'time_taken' => ['title' => 'Time Taken (in Sec)', 'type' => 'text'],
+ ];
+ foreach ($response->data->questions as $qid => $question) {
+ $fields['field_' . $qid] = ['title' => $question->label, 'type' => 'text'];
+ }
+ //echo '';
+ // print_r($fields);
+ // exit;
+ $items = [];
+ // print_r($response->data->questions);
+
+ //echo ''; print_r($response->data->submissions); exit;
+
+ foreach ($response->data->submissions as $submission) {
+ $item = ['user' => $submission->user_info->name,
+ 'date' => date("d M Y", strtotime($submission->record_date)),
+ 'sdate' => date("d M Y", strtotime($submission->createdAt)),
+ 'total_questions' => $submission->total_questions,
+ 'correct_answers' => $submission->correct_answers,
+ 'time_taken' => $submission->time_taken,
+ ];
+ foreach ($response->data->questions as $qid => $question) {
+ $item['field_' . $qid] = $submission->formdata->{$qid} ? 'Correct' : 'Incorrect';
+ }
+ $items[] = (object)$item;
+ }
+ //echo ''; print_r($items); exit;
+
+ return $this->view('list')->with([
+ 'title' => $response->data->formname . $this->_title,
+ 'fields' => $fields,
+ 'base_url' => $this->_base_url,
+ 'items' => $items,
+ 'buttons' => $this->get_list_buttons(),
+ 'startdate' => $startdate,
+ 'enddate' => $enddate
+ ]);
+ }
+
+ public function export(Request $request)
+ {
+ $reqdata = $request->session()->get('formdata_request');
+ //$reqdata = ["partition" => 'rapport-vitalis1', "form_id" => '1650365457-c86bd7f2-a33c-49a5-9671-3c2511b57f3b', "alldata" => true, "date_range" => '2022/_'.$enddate ];
+ $response = LambdaRequest::signedrequest('post', $this->_service, $this->_module . '/getformhistory', $reqdata);
+ //echo ''; print_r($reqdata); print_r($response); exit;
+ $fields = ['Submitted By', 'User identification', 'Email', 'Employee Code', 'Record Date', 'Submitted On', 'Total Questions', 'Correct Answers', 'Time Taken (in Sec)'];
+ foreach ($response->data->questions as $qid => $question) {
+ $fields[] = $question->label;
+ }
+ list($startdate, $enddate) = explode('_', $reqdata['date_range']);
+ $exceldata = [];
+ $exceldata[] = [ucwords($response->data->formname . $this->_title) . ' Report'];
+ $exceldata[] = ['Start Date: ' . date("d M Y", strtotime($startdate))];
+ $exceldata[] = ['End Date: ' . date("d M Y", strtotime($enddate))];
+ $exceldata[] = [''];
+ $exceldata[] = $fields;
+
+ foreach ($response->data->submissions as $submission) {
+ $item = [$submission->user_info->name,
+ $submission->user_info->id,
+ $submission->email,
+ $submission->employee_code,
+ date("d M Y", strtotime($submission->record_date)),
+ date("d M Y", strtotime($submission->createdAt)),
+ $submission->total_questions,
+ $submission->correct_answers,
+ $submission->time_taken,
+ ];
+ foreach ($response->data->questions as $qid => $question) {
+ $item[] = $submission->formdata->{$qid} ? 'Correct' : 'Incorrect';
+ }
+ $exceldata[] = $item;
+ }
+ return Excel::download(new InvoicesExport($exceldata), 'report.xlsx');
+ }
+}
diff --git a/app/Http/Controllers/SurveysubmissionController.php b/app/Http/Controllers/SurveysubmissionController.php
index 787cad1a..efb2ead0 100644
--- a/app/Http/Controllers/SurveysubmissionController.php
+++ b/app/Http/Controllers/SurveysubmissionController.php
@@ -37,7 +37,7 @@ class SurveysubmissionController extends Controller
if (isset($post['startdate']))
$startdate = $post['startdate'];
else
- $startdate = date("Y/m/d", strtotime("-1 day"));
+ $startdate = date("Y/m/d", strtotime("-365 day"));
if (isset($post['enddate']))
$enddate = $post['enddate'];
@@ -69,15 +69,59 @@ class SurveysubmissionController extends Controller
foreach ($response->data->submissions as $submission) {
$item = ['user' => $submission->user_info->name, 'date' => date("d M Y", strtotime($submission->record_date)), 'sdate' => date("d M Y", strtotime($submission->createdAt))];
foreach ($response->data->questions as $qid => $question) {
- if ($question->type == 'radiometrix') {
- $rm = [];
- foreach ($submission->formdata->$qid as $key => $val) {
- $rm[] = $key . ':' . $val;
- }
- $item['field_' . $qid] = implode(', ', $rm);
- } else {
- $item['field_' . $qid] = count((array)$question->options) > 0 && isset($question->options->{$submission->formdata->{$qid}}) ? $question->options->{$submission->formdata->{$qid}} : $submission->formdata->{$qid};
+ //print_r($submission->formdata->{$qid});
+
+ switch($question->type) {
+ case 'text':
+ case 'date':
+ $item['field_' . $qid] = isset($submission->formdata->{$qid}) ? $submission->formdata->{$qid} : '';
+ break;
+ case 'dropdown':
+ case 'radio':
+ $item['field_' . $qid] = isset($submission->formdata->{$qid}) ? (isset($question->options->{$submission->formdata->{$qid}}) ? $question->options->{$submission->formdata->{$qid}} : '') : '';
+ break;
+ case 'checkbox':
+ $item['field_' . $qid] = isset($submission->formdata->{$qid}) ? ( is_array($submission->formdata->{$qid}) ? implode(',', $submission->formdata->{$qid}) : $submission->formdata->{$qid} ) : '';
+ $item['field_' . $qid] = explode(',', $item['field_' . $qid]);
+ foreach($item['field_' . $qid] as &$v) {
+ $v = (isset($question->options->{$v}) ? $question->options->{$v} : '');
+ }
+ $item['field_' . $qid] = implode(', ', $item['field_' . $qid]);
+
+ //$item['field_' . $qid] = array_map(function($v) { return (isset($question->options->{$v}) ? $question->options->{$v} : ''); } , $item['field_' . $qid] );
+
+ break;
+ case 'radiometrix':
+ if(isset($submission->formdata->{$qid}) && is_object($submission->formdata->{$qid})) {
+ $rm = [];
+ foreach ($submission->formdata->$qid as $key => $val) {
+ $rm[] = $key . ':' . $val;
+ }
+ $item['field_' . $qid] = implode(' , ', $rm);
+ } else {
+ $item['field_' . $qid] = '';
+ }
+
+
+ //echo ''; print_r($submission->formdata->{$qid}); echo '';
+ break;
+ default:
+ if ($question->type == 'radiometrix') {
+ $rm = [];
+ // foreach ($submission->formdata->$qid as $key => $val) {
+ // $rm[] = $key . ':' . $val;
+ // }
+ // $item['field_' . $qid] = implode(', ', $rm);
+ $item['field_' . $qid] = $question->type;
+ } else {
+ //$item['field_' . $qid] = count((array)$question->options) > 0 && isset($question->options->{$submission->formdata->{$qid}}) ? $question->options->{$submission->formdata->{$qid}} : $submission->formdata->{$qid};
+ $item['field_' . $qid] = $question->type;
+ }
+ break;
}
+
+
+
}
$items[] = (object)$item;
}
@@ -101,10 +145,29 @@ class SurveysubmissionController extends Controller
$reqdata = $request->session()->get('formdata_request');
//$reqdata = ["partition" => 'rapport-vitalis1', "form_id" => '1650365457-c86bd7f2-a33c-49a5-9671-3c2511b57f3b', "alldata" => true, "date_range" => '2022/_'.$enddate ];
$response = LambdaRequest::signedrequest('post', $this->_service, $this->_module . '/getformhistory', $reqdata);
- $fields = ['Submitted By', 'User identification', 'Record Date', 'Submitted On'];
+ $fields = ['Submitted By', 'User identification', 'Email', 'Employee Code', 'Record Date', 'Submitted On'];
+ $fieldoptions = ['', '', '', '', '', ''];
foreach ($response->data->questions as $qid => $question) {
$fields[] = $question->label;
+ if($question->type == 'radiometrix') {
+ $count = 0;
+ foreach($question->orig_options as $opv) {
+ $fieldoptions[] = $opv->display;
+ if($count > 0) $fields[] = '';
+ $count++;
+ }
+ } else if($question->type == 'checkbox') {
+ $count = 0;
+ foreach($question->options as $opk => $opv) {
+ $fieldoptions[] = $opv;
+ if($count > 0) $fields[] = '';
+ $count++;
+ }
+ } else {
+ $fieldoptions[] = '';
+ }
}
+ //echo ''; print_r($fields); print_r($fieldoptions); exit;
list($startdate, $enddate) = explode('_', $reqdata['date_range']);
$exceldata = [];
$exceldata[] = [ucwords($response->data->formname . $this->_title) . ' Report'];
@@ -112,11 +175,73 @@ class SurveysubmissionController extends Controller
$exceldata[] = ['End Date: ' . date("d M Y", strtotime($enddate))];
$exceldata[] = [''];
$exceldata[] = $fields;
+ $exceldata[] = $fieldoptions;
foreach ($response->data->submissions as $submission) {
- $item = [$submission->user_info->name, $submission->user_info->id, date("d M Y", strtotime($submission->record_date)), date("d M Y", strtotime($submission->createdAt))];
+ $item = [$submission->user_info->name,
+ $submission->user_info->id,
+ $submission->email,
+ $submission->employee_code,
+ date("d M Y", strtotime($submission->record_date)),
+ date("d M Y", strtotime($submission->createdAt))];
foreach ($response->data->questions as $qid => $question) {
- $item[] = $submission->formdata->{$qid};
+ //$item[] = $submission->formdata->{$qid};
+ switch($question->type) {
+ case 'text':
+ case 'date':
+ $item[] = isset($submission->formdata->{$qid}) ? $submission->formdata->{$qid} : '';
+ break;
+ case 'dropdown':
+ case 'radio':
+ $opts = array_values((array)$question->options);
+ $item[] = isset($submission->formdata->{$qid}) ? (isset($question->options->{$submission->formdata->{$qid}}) ? $question->options->{$submission->formdata->{$qid}} : ( $submission->formdata->{$qid} == 'on' ? $opts[0] : '') ) : '';
+ break;
+ case 'checkbox':
+ foreach($question->options as $opk => $opv) {
+ $item[] = isset($submission->formdata->{$qid}) ? ( is_array($submission->formdata->{$qid}) ? (in_array($opk,$submission->formdata->{$qid}) ? 'Yes' : '' ) : $submission->formdata->{$qid} ) : '';
+ }
+
+ // $it = isset($submission->formdata->{$qid}) ? ( is_array($submission->formdata->{$qid}) ? implode(',', $submission->formdata->{$qid}) : $submission->formdata->{$qid} ) : '';
+ // $it = explode(',', $it);
+ // foreach($it as &$v) {
+ // $v = (isset($question->options->{$v}) ? $question->options->{$v} : '');
+ // }
+ // $item[] = implode(', ', $it);
+
+ //$item['field_' . $qid] = array_map(function($v) { return (isset($question->options->{$v}) ? $question->options->{$v} : ''); } , $item['field_' . $qid] );
+
+ break;
+ case 'radiometrix':
+ foreach($question->orig_options as $opv) {
+ if(isset($submission->formdata->{$qid}) && is_object($submission->formdata->{$qid})) {
+ // $rm = [];
+ // foreach ($submission->formdata->$qid as $key => $val) {
+ // $rm[] = $key . ':' . $val;
+ // }
+ // $item[] = implode(' , ', $rm);
+ $item[] = isset($submission->formdata->{$qid}->{$opv->display}) ? $submission->formdata->{$qid}->{$opv->display} : '';
+ } else {
+ $item[] = '';
+ }
+ }
+
+ //echo ''; print_r($submission->formdata->{$qid}); echo '';
+ break;
+ default:
+ if ($question->type == 'radiometrix') {
+ $rm = [];
+ // foreach ($submission->formdata->$qid as $key => $val) {
+ // $rm[] = $key . ':' . $val;
+ // }
+ // $item['field_' . $qid] = implode(', ', $rm);
+ $item['field_' . $qid] = $question->type;
+ } else {
+ //$item['field_' . $qid] = count((array)$question->options) > 0 && isset($question->options->{$submission->formdata->{$qid}}) ? $question->options->{$submission->formdata->{$qid}} : $submission->formdata->{$qid};
+ $item['field_' . $qid] = $question->type;
+ }
+ break;
+ }
+
}
$exceldata[] = $item;
}
diff --git a/app/Http/Requests/LambdaRequest.php b/app/Http/Requests/LambdaRequest.php
index 90d5fe1b..e6bf6591 100644
--- a/app/Http/Requests/LambdaRequest.php
+++ b/app/Http/Requests/LambdaRequest.php
@@ -31,6 +31,9 @@ class LambdaRequest
public static function postrequest($service, $url, $params, $token = '') {
$params['application'] = 'rapport';
$fullurl = self::genurl($service, $url);
+ if(self::REMOTE_ENV != 'local' && $service == 'form' && $url == 'formentity/getformhistory') {
+ $fullurl = 'https://sgrmuxa46z7xfouezyvg3tnhnq0yptjn.lambda-url.ap-south-1.on.aws/';
+ }
if($token == '') {
$response = Http::post($fullurl, $params);
} else {
diff --git a/public/assets/js/pages/timeme.js b/public/assets/js/pages/timeme.js
new file mode 100755
index 00000000..6f86b10b
--- /dev/null
+++ b/public/assets/js/pages/timeme.js
@@ -0,0 +1,415 @@
+/*Copyright (c) 2019 Jason Zissman
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+(function () {
+ (function (root, factory) {
+ if (typeof module !== 'undefined' && module.exports) {
+ // CommonJS
+ return module.exports = factory();
+ } else if (typeof define === 'function' && define.amd) {
+ // AMD
+ define([], function () {
+ return (root.TimeMe = factory());
+ });
+ } else {
+ // Global Variables
+ return root.TimeMe = factory();
+ }
+ })(this, function () {
+
+ var TimeMe = {
+
+ startStopTimes: {},
+ idleTimeoutMs: 30 * 1000,
+ currentIdleTimeMs: 0,
+ checkStateRateMs: 250,
+ active: false, // state if we are actively recording time
+ idle: false, // state if user on page but not interacting
+ currentPageName: "default-page-name",
+ timeElapsedCallbacks: [],
+ userLeftCallbacks: [],
+ userReturnCallbacks: [],
+
+ trackTimeOnElement: function (elementId) {
+ var element = document.getElementById(elementId);
+ if (element) {
+ element.addEventListener("mouseover", function () {
+ TimeMe.startTimer(elementId);
+ });
+ element.addEventListener("mousemove", function () {
+ TimeMe.startTimer(elementId);
+ });
+ element.addEventListener("mouseleave", function () {
+ TimeMe.stopTimer(elementId);
+ });
+ element.addEventListener("keypress", function () {
+ TimeMe.startTimer(elementId);
+ });
+ element.addEventListener("focus", function () {
+ TimeMe.startTimer(elementId);
+ });
+ }
+ },
+
+ getTimeOnElementInSeconds: function (elementId) {
+ var time = TimeMe.getTimeOnPageInSeconds(elementId);
+ if (time) {
+ return time;
+ } else {
+ return 0;
+ }
+ },
+
+ // startTime is optional. If provided, must be of type Date(). By providing
+ // startTime, you are overriding the internal timing mechanism and manually
+ // indicating the start time.
+ startTimer: function (pageName, startTime) {
+ if (!pageName) {
+ pageName = TimeMe.currentPageName;
+ }
+
+ if (TimeMe.startStopTimes[pageName] === undefined) {
+ TimeMe.startStopTimes[pageName] = [];
+ } else {
+ var arrayOfTimes = TimeMe.startStopTimes[pageName];
+ var latestStartStopEntry = arrayOfTimes[arrayOfTimes.length - 1];
+ if (latestStartStopEntry !== undefined && latestStartStopEntry.stopTime === undefined) {
+ // Can't start new timer until previous finishes.
+ return;
+ }
+ }
+ TimeMe.startStopTimes[pageName].push({
+ "startTime": startTime || new Date(),
+ "stopTime": undefined
+ });
+ TimeMe.active = true;
+ TimeMe.idle = false;
+ },
+
+ stopAllTimers: function () {
+ var pageNames = Object.keys(TimeMe.startStopTimes);
+ for (var i = 0; i < pageNames.length; i++) {
+ TimeMe.stopTimer(pageNames[i]);
+ }
+ },
+
+ // stopTime is optional. If provided, must be of type Date(). By providing
+ // stopTime, you are overriding the internal timing mechanism and manually
+ // indicating the stop time.
+ stopTimer: function (pageName, stopTime) {
+ if (!pageName) {
+ pageName = TimeMe.currentPageName;
+ }
+ var arrayOfTimes = TimeMe.startStopTimes[pageName];
+ if (arrayOfTimes === undefined || arrayOfTimes.length === 0) {
+ // Can't stop timer before you've started it.
+ return;
+ }
+ if (arrayOfTimes[arrayOfTimes.length - 1].stopTime === undefined) {
+ arrayOfTimes[arrayOfTimes.length - 1].stopTime = stopTime || new Date();
+ }
+ TimeMe.active = false;
+ },
+
+ getTimeOnCurrentPageInSeconds: function () {
+ return TimeMe.getTimeOnPageInSeconds(TimeMe.currentPageName);
+ },
+
+ getTimeOnPageInSeconds: function (pageName) {
+ var timeInMs = TimeMe.getTimeOnPageInMilliseconds(pageName);
+ if (timeInMs === undefined) {
+ return undefined;
+ } else {
+ return timeInMs / 1000;
+ }
+ },
+
+ getTimeOnCurrentPageInMilliseconds: function () {
+ return TimeMe.getTimeOnPageInMilliseconds(TimeMe.currentPageName);
+ },
+
+ getTimeOnPageInMilliseconds: function (pageName) {
+
+ var totalTimeOnPage = 0;
+
+ var arrayOfTimes = TimeMe.startStopTimes[pageName];
+ if (arrayOfTimes === undefined) {
+ // Can't get time on page before you've started the timer.
+ return;
+ }
+
+ var timeSpentOnPageInSeconds = 0;
+ for (var i = 0; i < arrayOfTimes.length; i++) {
+ var startTime = arrayOfTimes[i].startTime;
+ var stopTime = arrayOfTimes[i].stopTime;
+ if (stopTime === undefined) {
+ stopTime = new Date();
+ }
+ var difference = stopTime - startTime;
+ timeSpentOnPageInSeconds += (difference);
+ }
+
+ totalTimeOnPage = Number(timeSpentOnPageInSeconds);
+ return totalTimeOnPage;
+ },
+
+ getTimeOnAllPagesInSeconds: function () {
+ var allTimes = [];
+ var pageNames = Object.keys(TimeMe.startStopTimes);
+ for (var i = 0; i < pageNames.length; i++) {
+ var pageName = pageNames[i];
+ var timeOnPage = TimeMe.getTimeOnPageInSeconds(pageName);
+ allTimes.push({
+ "pageName": pageName,
+ "timeOnPage": timeOnPage
+ });
+ }
+ return allTimes;
+ },
+
+ setIdleDurationInSeconds: function (duration) {
+ var durationFloat = parseFloat(duration);
+ if (isNaN(durationFloat) === false) {
+ TimeMe.idleTimeoutMs = duration * 1000;
+ } else {
+ throw {
+ name: "InvalidDurationException",
+ message: "An invalid duration time (" + duration + ") was provided."
+ };
+ }
+ return this;
+ },
+
+ setCurrentPageName: function (pageName) {
+ TimeMe.currentPageName = pageName;
+ return this;
+ },
+
+ resetRecordedPageTime: function (pageName) {
+ delete TimeMe.startStopTimes[pageName];
+ },
+
+ resetAllRecordedPageTimes: function () {
+ var pageNames = Object.keys(TimeMe.startStopTimes);
+ for (var i = 0; i < pageNames.length; i++) {
+ TimeMe.resetRecordedPageTime(pageNames[i]);
+ }
+ },
+
+ resetIdleCountdown: function () {
+ if (TimeMe.idle) {
+ TimeMe.triggerUserHasReturned();
+ }
+ TimeMe.idle = false;
+ TimeMe.currentIdleTimeMs = 0;
+ },
+
+ callWhenUserLeaves: function (callback, numberOfTimesToInvoke) {
+ this.userLeftCallbacks.push({
+ callback: callback,
+ numberOfTimesToInvoke: numberOfTimesToInvoke
+ })
+ },
+
+ callWhenUserReturns: function (callback, numberOfTimesToInvoke) {
+ this.userReturnCallbacks.push({
+ callback: callback,
+ numberOfTimesToInvoke: numberOfTimesToInvoke
+ })
+ },
+
+ triggerUserHasReturned: function () {
+ if (!TimeMe.active) {
+ for (var i = 0; i < this.userReturnCallbacks.length; i++) {
+ var userReturnedCallback = this.userReturnCallbacks[i];
+ var numberTimes = userReturnedCallback.numberOfTimesToInvoke;
+ if (isNaN(numberTimes) || (numberTimes === undefined) || numberTimes > 0) {
+ userReturnedCallback.numberOfTimesToInvoke -= 1;
+ userReturnedCallback.callback();
+ }
+ }
+ }
+ TimeMe.startTimer();
+ },
+
+ triggerUserHasLeftPage: function () {
+ if (TimeMe.active) {
+ for (var i = 0; i < this.userLeftCallbacks.length; i++) {
+ var userHasLeftCallback = this.userLeftCallbacks[i];
+ var numberTimes = userHasLeftCallback.numberOfTimesToInvoke;
+ if (isNaN(numberTimes) || (numberTimes === undefined) || numberTimes > 0) {
+ userHasLeftCallback.numberOfTimesToInvoke -= 1;
+ userHasLeftCallback.callback();
+ }
+ }
+ }
+ TimeMe.stopAllTimers();
+ },
+
+ callAfterTimeElapsedInSeconds: function (timeInSeconds, callback) {
+ TimeMe.timeElapsedCallbacks.push({
+ timeInSeconds: timeInSeconds,
+ callback: callback,
+ pending: true
+ });
+ },
+
+ checkState: function () {
+ for (var i = 0; i < TimeMe.timeElapsedCallbacks.length; i++) {
+ if (TimeMe.timeElapsedCallbacks[i].pending && TimeMe.getTimeOnCurrentPageInSeconds() > TimeMe.timeElapsedCallbacks[i].timeInSeconds) {
+ TimeMe.timeElapsedCallbacks[i].callback();
+ TimeMe.timeElapsedCallbacks[i].pending = false;
+ }
+ }
+ if (TimeMe.idle === false && TimeMe.currentIdleTimeMs > TimeMe.idleTimeoutMs) {
+ TimeMe.idle = true;
+ TimeMe.triggerUserHasLeftPage();
+ } else {
+ TimeMe.currentIdleTimeMs += TimeMe.checkStateRateMs;
+ }
+ },
+
+ visibilityChangeEventName: undefined,
+ hiddenPropName: undefined,
+
+ listenForVisibilityEvents: function () {
+
+ if (typeof document.hidden !== "undefined") {
+ TimeMe.hiddenPropName = "hidden";
+ TimeMe.visibilityChangeEventName = "visibilitychange";
+ } else if (typeof document.mozHidden !== "undefined") {
+ TimeMe.hiddenPropName = "mozHidden";
+ TimeMe.visibilityChangeEventName = "mozvisibilitychange";
+ } else if (typeof document.msHidden !== "undefined") {
+ TimeMe.hiddenPropName = "msHidden";
+ TimeMe.visibilityChangeEventName = "msvisibilitychange";
+ } else if (typeof document.webkitHidden !== "undefined") {
+ TimeMe.hiddenPropName = "webkitHidden";
+ TimeMe.visibilityChangeEventName = "webkitvisibilitychange";
+ }
+
+ document.addEventListener(TimeMe.visibilityChangeEventName, function () {
+ if (document[TimeMe.hiddenPropName]) {
+ TimeMe.triggerUserHasLeftPage();
+ } else {
+ TimeMe.triggerUserHasReturned();
+ }
+ }, false);
+
+ window.addEventListener('blur', function () {
+ TimeMe.triggerUserHasLeftPage();
+ });
+
+ window.addEventListener('focus', function () {
+ TimeMe.triggerUserHasReturned();
+ });
+
+ document.addEventListener("mousemove", function () { TimeMe.resetIdleCountdown(); });
+ document.addEventListener("keyup", function () { TimeMe.resetIdleCountdown(); });
+ document.addEventListener("touchstart", function () { TimeMe.resetIdleCountdown(); });
+ window.addEventListener("scroll", function () { TimeMe.resetIdleCountdown(); });
+
+ setInterval(function () {
+ TimeMe.checkState();
+ }, TimeMe.checkStateRateMs);
+ },
+
+ websocket: undefined,
+
+ websocketHost: undefined,
+
+ setUpWebsocket: function (websocketOptions) {
+ if (window.WebSocket && websocketOptions) {
+ var websocketHost = websocketOptions.websocketHost; // "ws://hostname:port"
+ try {
+ TimeMe.websocket = new WebSocket(websocketHost);
+ window.onbeforeunload = function (event) {
+ TimeMe.sendCurrentTime(websocketOptions.appId);
+ };
+ TimeMe.websocket.onopen = function () {
+ TimeMe.sendInitWsRequest(websocketOptions.appId);
+ }
+ TimeMe.websocket.onerror = function (error) {
+ if (console) {
+ console.log("Error occurred in websocket connection: " + error);
+ }
+ }
+ TimeMe.websocket.onmessage = function (event) {
+ if (console) {
+ console.log(event.data);
+ }
+ }
+ } catch (error) {
+ if (console) {
+ console.error("Failed to connect to websocket host. Error:" + error);
+ }
+ }
+ }
+ return this;
+ },
+
+ websocketSend: function (data) {
+ TimeMe.websocket.send(JSON.stringify(data));
+ },
+
+ sendCurrentTime: function (appId) {
+ var timeSpentOnPage = TimeMe.getTimeOnCurrentPageInMilliseconds();
+ var data = {
+ type: "INSERT_TIME",
+ appId: appId,
+ timeOnPageMs: timeSpentOnPage,
+ pageName: TimeMe.currentPageName
+ };
+ TimeMe.websocketSend(data);
+ },
+ sendInitWsRequest: function (appId) {
+ var data = {
+ type: "INIT",
+ appId: appId
+ };
+ TimeMe.websocketSend(data);
+ },
+
+ initialize: function (options) {
+
+ var idleTimeoutInSeconds = TimeMe.idleTimeoutMs || 30;
+ var currentPageName = TimeMe.currentPageName || "default-page-name";
+ var websocketOptions = undefined;
+ var initialStartTime = undefined;
+
+ if (options) {
+ idleTimeoutInSeconds = options.idleTimeoutInSeconds || idleTimeoutInSeconds;
+ currentPageName = options.currentPageName || currentPageName;
+ websocketOptions = options.websocketOptions;
+ initialStartTime = options.initialStartTime;
+ }
+
+ TimeMe.setIdleDurationInSeconds(idleTimeoutInSeconds)
+ .setCurrentPageName(currentPageName)
+ .setUpWebsocket(websocketOptions)
+ .listenForVisibilityEvents();
+
+ // TODO - only do this if page currently visible.
+
+ TimeMe.startTimer(undefined, initialStartTime);
+ }
+ };
+ return TimeMe;
+ });
+}).call(this);
diff --git a/resources/views/campaign/appreport.blade.php b/resources/views/campaign/appreport.blade.php
index 72b01f4a..130c4f25 100644
--- a/resources/views/campaign/appreport.blade.php
+++ b/resources/views/campaign/appreport.blade.php
@@ -153,12 +153,13 @@
@break
@case($post->type == 'myteam')
+ @if(isset($users) && isset($users[0]->level))
-
+ @endif
@if(isset($users))
@@ -288,7 +289,7 @@
window.location.href = href.toString()
});
- @if($post->type == 'leaderboard' || $post->type == 'myteam')
+ @if(isset($users) && isset($users[0]->level) && $post->type == 'leaderboard' || $post->type == 'myteam')
$('.leaderboard-next').click(function(){
$("#pageloader").fadeIn();
let href = new URL(window.location.href);
diff --git a/resources/views/campaign/teammembers.blade.php b/resources/views/campaign/teammembers.blade.php
new file mode 100644
index 00000000..e0651441
--- /dev/null
+++ b/resources/views/campaign/teammembers.blade.php
@@ -0,0 +1,99 @@
+@extends('layouts.vertical', ["page_title"=> "Dashboard", "mode" => $mode ?? "", "demo" => $demo ?? ""])
+
+@section('css')
+
+
+
+
+@endsection
+
+@section('content')
+
+
+
+
+
+
+
+
+ Team Members
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @php
+ $firstdone = true;
+ @endphp
+ @foreach($teams as $team)
+
+ {{$team->team_details->name}}
+ {{$team->team_details->description}}
+
+
+
+
+
+ Name
+ Employee Code
+
+
+
+ @foreach($team->players as $player)
+
+ {{$player->name}}
+ {{$player->employee_code}}
+
+ @endforeach
+
+
+
+
+ @php
+ $firstdone = false;
+ @endphp
+ @endforeach
+
+
+
+
+
+
+
+
+
+
+
+@endsection
+
+@section('script')
+
+
+
+
+
+
+
+@endsection
\ No newline at end of file
diff --git a/resources/views/common/form.blade.php b/resources/views/common/form.blade.php
index 273027f4..3a1f6595 100644
--- a/resources/views/common/form.blade.php
+++ b/resources/views/common/form.blade.php
@@ -6,6 +6,7 @@
+
@endsection
@@ -53,7 +54,7 @@
@break
@case('datetime')
-
+
@break
@case('textarea')
@@ -150,6 +151,8 @@
+
+
+
+
+