middleware('auth'); $this->_service = 'form'; $this->_module = 'survey'; $this->_viewname = 'survey'; $this->_title = 'Survey'; $this->_base_url = '/survey'; } protected function get_list_fields(){ return [ 'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete', 'questions' => ['icon' => 'progress-question', 'querystring' => 'id={ID}'], 'submission' => ['icon' => 'form-select', 'querystring' => 'id={ID}'] ] ], 'title' => ['title' => 'Title', 'type' => 'text'], //'workflow' => ['title' => 'Workflow', 'type' => 'text'], 'status' => ['title' => 'Status', 'type' => 'select'], ]; } protected function get_form_fields($type, $values){ $users = $this->getlambda('get', 'ums', 'users', 'dropdown'); $users_dd = ['l1manager' => 'L1 Manager', 'l2manager' => 'L2 Manager']; foreach($users->data->items as $user){ $users_dd[$user->id] = $user->firstname . ' ' . $user->lastname . ' (' . $user->employee_code . ')'; } $roles = $this->getlambda('get', 'ums', 'roles', 'dropdown'); $roles_dd = []; foreach($roles->data->items as $role){ $roles_dd[$role->id] = $role->name; } return [ 'title' => ['title' => 'Title', 'type' => 'text', 'required' => true], 'description' => ['title' => 'Description', 'type' => 'textarea', 'required' => true, 'fullwidth' => true], 'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ], 'export_fields' => ['title' => 'Export Fields', 'type' => 'textarea', 'required' => false, 'fullwidth' => true ], ]; } public function questions(Request $request) { $entity_id = $request->input('id', 0); if($entity_id === 0) { return redirect('/surveys')->withError('Form not found!'); } else { $request->session()->put('entity_id', $entity_id); return redirect('/surveyquestions'); } } public function submission(Request $request) { $entity_id = $request->input('id', 0); if($entity_id === 0) { return redirect('/surveys')->withError('Form not found!'); } else { $request->session()->put('entity_id', $entity_id); return redirect('/surveysubmissions'); } } public function postimport(Request $request) { $entity_id = $request->input('id'); if( $request->file('importfile') ) { $path = $request->file('importfile')->store('form_import'); $csv = Reader::createFromPath(storage_path('app') .'/' . $path, 'r'); $csv->setHeaderOffset(0); $header = $csv->getHeader(); //returns the CSV header record $records = $csv->getRecords(); //returns all the CSV records as an Iterator object $response = LambdaRequest::signedrequest('get', $this->_service, 'formquestion/get_all', ['entity_id' => $entity_id]); $forfields = []; foreach ($response->data->items as $q) { $forfields[] = $q->code; } $count = 0; $recs = []; // $forfields = ['is-aware-of-the-customer-perspective-potential-prescription-position','has-customer-plan-based-on-customer-perspective','rcpawardicu-quantified-rcpa-comp-taken-pob-dr-perspective-on-molecule-or-price-etc','call-objective-planned-question-opening-statement-materials-and-objection-anticipated','greeted-customer-appropriately','used-planned-opening-statement','gained-attention-of-the-customer','was-ready-with-tab-maintained-eye-contact-with-doctor-had-a-clear-voice','asked-planned-question-as-per-call-planning','asked-question-related-to-customer-behaviourbelief-service','listened-attentively-and-asked-follow-up-question-if-required','generated-desired-response-from-customer','maintained-the-sequence-of-product-as-per-the-speciality-p1p2p3','shared-benefit-of-productdevicesservices-as-per-marketing-strategy','shared-informationused-the-materialstools-as-per-plan-demonstrated-and-discussed-cipla-devices','utilized-the-tab-effectively-smooth-navigation-highlighted-studies-zoomed-graphs-etc','listened-attentively-acknowledged-concern','asked-questions-to-seek-clarity-on-questionobjection','shared-the-relevant-information','confirmed-if-objectionquestion-was-addressed-assured-follow-through-actions-if-required-and-returned-to-call-flow','summarized-the-key-discussion-points','gained-agreement-basis-call-objective-from-the-doctor','quantified-the-demand-with-rx','left-lblreminder-of-focused-product','total_score','area-of-strength','area-of-development','coaching-objective','development-time-frame','next-coaching-visit','development-action-plan']; foreach ($records as $record) { $formdata = []; foreach($forfields as $field) { $formdata[$field] = $record[$field] == 'Yes' ? 1 : ( $record[$field] == 'No' ? 0 : $record[$field] ) ; } $recs[] = [ 'entity_id' => $entity_id, 'formdata' => $formdata, 'employee_code' => $record['employee_code'], 'partition' => 'rapport-'.Auth::user()->domain, 'record_date' => strtotime($record['record_date']), 'createdAt' => strtotime($record['created_date']) ]; if(sizeof($recs) >= 25) { $response = LambdaRequest::signedrequest('post', $this->_service, $this->_module.'/import', $recs); $recs = []; } } $response = LambdaRequest::signedrequest('post', $this->_service, $this->_module.'/import', $recs); return redirect($this->_base_url.'s')->withMessage('Successfully Uploaded !!!'); } else { return \Redirect::back()->withMessage('Some Error occured!'); } } public function ajaxgnpsubmit(Request $request) { $post['emp_id'] = $request->emp_id; $post['emp_name'] = $request->emp_name; $post['emp_phone'] = $request->emp_phone; $post['emp_email'] = $request->emp_email; $post['abm_name'] = $request->abm_name; $post['abm_email'] = $request->abm_email; $post['rbm_name'] = $request->rbm_name; $post['msl_code'] = $request->msl_code; $post['doctor_speciality'] = $request->doctor_speciality; $post['no_of_nebulizer'] = $request->no_of_nebulizer; $post['value_of_parcel'] = $request->value_of_parcel; $post['nebulizer_purpose'] = $request->nebulizer_purpose; $post['doctor_name'] = $request->doctor_name; $post['doctor_phone'] = $request->doctor_phone; $post['address_type'] = $request->address_type; $post['address_building'] = $request->address_building; $post['address_line_1'] = $request->address_line_1; $post['address_line_2'] = $request->address_line_2; $post['address_landmark'] = $request->address_landmark; $post['address_state'] = $request->address_state; $post['address_city'] = $request->address_city; $post['request_letter'] = $request->request_letter; $handler = curl_init(); // curl_setopt($handler, CURLOPT_URL, "http://127.0.0.1:8001/neblogisticsave/ciplatodoctor"); 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 ($response !== false) { var_dump($response); } else { print "Could not get a response"; } } }