public function upload(Request $request) { $entityBody = file_get_contents('php://input'); Log::debug($entityBody); $formController = new \Stratum\Controller\FormController(); Log::debug("parsing input data"); $formResult = $formController->parse($entityBody); Log::Debug("parsed input data"); //form has updated mappings for each question $candidate = new \Stratum\Model\Candidate(); $candidateController = new \Stratum\Controller\CandidateController(); $candidate = $candidateController->populate($candidate, $formResult); Log::debug("Form Completed for " . $candidate->getName()); $controller = new \Stratum\Controller\BullhornController(); //upload files from WorldApp to Bullhorn $controller->submit_files($candidate); //update availability Note in Bullhorn $availability = $formResult->findByWorldApp("Call Availability"); Log::debug($availability); if ($availability) { $note['comments'] = "Call Availability: " . $availability['Call Availability']['value']; $note['action'] = 'Availability'; Log::debug($note); $candidate->set("Note", $note); $controller->submit_note($candidate); } $cc = new CanCon(); $c3 = $cc->load($candidate->get("id")); //Bullhorn Candidate record, from cache if available $owner = $c3->get("owner"); /* array ( 'id' => 10237, 'firstName' => 'Stratum', 'lastName' => 'API', ) */ $cuser = new \Stratum\Model\CorporateUser(); $cuser->set("id", $owner['id']); $cuser = $controller->loadCorporateUser($cuser); $to_email = $cuser->get("email"); if (!$to_email) { $to_email = "*****@*****.**"; } Log::debug("sending email to " . $cuser->getName() . " at " . $to_email . " about Form Submission"); $maildata['candidateName'] = $candidate->getName(); $maildata['candidateID'] = $candidate->get("id"); $maildata['date'] = date(DATE_RFC2822); Mail::send('email.form_uploaded', $maildata, function ($m) use($to_email, $candidate) { $m->from('*****@*****.**', 'Plum Data Integration Service'); $m->to($to_email)->subject('Form Submission from ' . $candidate->getName() . ' ' . $candidate->get("id")); }); $controller->updateCandidateStatus($candidate, "Form Completed"); //Now to store form results in local storage $entityBody = Storage::disk('local')->put($candidate->get("id") . ".txt", $entityBody); }
public function index($id) { $cuc = new CorporateUserController(); $controller = new \Stratum\Controller\FormController(); $ccontroller = new \Stratum\Controller\CandidateController(); $entityBody = Storage::disk('local')->get($id . '.txt'); $formResult = $controller->parse($entityBody); $candidate = new \Stratum\Model\Candidate(); $candidate = $ccontroller->populate($candidate, $formResult); $cc = new CanCon(); $c3 = $cc->load($id); //Bullhorn Candidate record, from cache if available Log::debug("Bullhorn Category:"); Log::debug($c3->get("category")); Log::debug($c3->get("categoryID")); $candidate->set("categoryID", $c3->get("categoryID")); $candidate->set("category", $c3->get("category")); $candidate->set("customText4", $c3->get("customText4")); $form = $formResult->get("form"); $questions = $formResult->get('questions'); $qbyq = []; foreach ($questions as $q1) { $qbyq[$q1->get("humanQuestionId")][] = $q1; $qbyq[$q1->get('humanQAId')][] = $q1; } //expand/collapse all button depends on presence of values in the section $valuesPresent = []; //$form->output_sections(); $sections = $form->get("sections"); $headers = $form->get("sectionHeaders"); $index = 0; foreach ($sections as $sec) { $header = $headers[$index]; $index++; $valuePresent = false; Log::debug("Got to section {$index} with label {$header}, checking for values present"); foreach ($sec as $qmap) { $answers = []; $qid = $qmap->getBestId(); if (!array_key_exists($qid, $qbyq)) { //Log::debug("No $qid in QbyQ"); } else { $qs = $qbyq[$qid]; if (is_array($qs)) { foreach ($qs as $q) { $answers = $formResult->getValue($qid, $q, $qmap, $answers); if ($answers['valueFound']) { $valuePresent = true; //never set back to false } } } else { if ($qs) { $answers = $formResult->getValue($qid, $qs, $qmap, $answers); if ($answers['valueFound']) { $valuePresent = true; //never set back to false } } } } if (!$valuePresent) { $valuePresent = $qmap->checkforBullhornValue($candidate); } } $valuesPresent[$header] = $valuePresent; } $data['valuesPresent'] = $valuesPresent; $data['form'] = $form; $data['qbyq'] = $qbyq; $data['candidate'] = $candidate; $data['formResult'] = $formResult; $data['candidates'] = $cuc->load_candidates(); $data['page_title'] = "Form Response"; return view('formresponse')->with($data); }