Пример #1
0
 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 show($id)
 {
     $message = "Candidate Information";
     $candidate = $this->load($id);
     $data['thecandidate'] = $candidate;
     $fc = new \Stratum\Controller\FormController();
     $data['form'] = $fc->setupForm();
     $cuc = new CorporateUserController();
     $data['candidates'] = $cuc->load_candidates();
     $data['message'] = $message;
     return view('candidate')->with($data);
 }
 public function confirmValues(Request $request)
 {
     $id = $request->input("id");
     $fc = new \Stratum\Controller\FormController();
     $cc = new \Stratum\Controller\CandidateController();
     $cuc = new CorporateUserController();
     $entityBody = Storage::disk('local')->get($id . '.txt');
     $formResult = $fc->parse($entityBody);
     $c2 = new \Stratum\Model\Candidate();
     $c2 = $cc->populate($c2, $formResult);
     $form = $formResult->get("form");
     $candidate = new \Stratum\Model\Candidate();
     $candidate = $cc->populateFromRequest($candidate, $request->all(), $c2, $formResult);
     if ($candidate->get("validated") != 'true') {
         $data['errormessage']['message'] = "You must confirm that this form is correct and accurate.  Use the Browser Back button to avoid losing your edits.";
         $error['propertyName'] = "validated";
         $error['severity'] = 'Validation Failure';
         $error['type'] = 'Must Accept Form';
         $data['errormessage']['errors'][] = $error;
         $data['message'] = "Validation Failure: Data Not Uploaded";
     } else {
         if (!$candidate->get("customText16")) {
             $candidate->set("tier", $candidate->get("customText16"));
             //must transfer to human-readable attribute name
             $data['errormessage']['message'] = "You must assign a Tier to this Candidate.  Use the Browser Back button to avoid losing your edits.";
             $error['propertyName'] = "tier";
             $error['severity'] = 'Validation Failure';
             $error['type'] = 'Must Assign Tier';
             $data['errormessage']['errors'][] = $error;
             $data['message'] = "Validation Failure: Data Not Uploaded";
         } else {
             $now = new \DateTime();
             $stamp = $now->format("U") * 1000;
             $candidate->set("customDate1", $stamp);
             $candidate->set("customDate2", $stamp);
             //$data['message'] = 'Debugging only, nothing uploaded to Bullhorn';
             $bc = new \Stratum\Controller\BullhornController();
             $c1 = new \Stratum\Model\Candidate();
             $c1->set("id", $id);
             $c1 = $bc->loadFully($c1);
             //$c1 is the bullhorn existing candidate
             $c2->set("formResult", $formResult);
             //trojan horse to get formResult to pdf
             $pdf_data = $this->generatePDF($id, $c1, $c2, $candidate, $bc);
             $this->uploadPDF($candidate, $pdf_data, $bc);
             Log::debug("Uploaded PDF record from form");
             // to shortcut to html view
             //return view('export_the_pdf')->with($pdf_data);
             $retval = $bc->submit($candidate);
             if (array_key_exists("errorMessage", $retval)) {
                 $data['errormessage']['message'] = $retval['errorMessage'];
                 $data['errormessage']['errors'] = $retval['errors'];
                 $data['message'] = "Problem uploading data";
             } else {
                 $data['message'] = "Data Uploaded";
                 $bc->updateCandidateStatus($candidate, "Interview Done");
                 $cuc->flushCandidatesFromCache();
                 Log::debug("sending email to admin@stratum-int.com about Interview completion");
                 $user = Auth::user();
                 $maildata['candidateName'] = $candidate->getName();
                 $maildata['candidateID'] = $id;
                 $maildata['consultantName'] = $user->name;
                 $maildata['date'] = date(DATE_RFC2822);
                 Mail::send('email.interview_complete', $maildata, function ($m) use($candidate, $id) {
                     $m->from('*****@*****.**', 'Plum Data Integration Service');
                     $m->to('*****@*****.**')->subject('Interview Complete ' . $candidate->getName() . ' ' . $id);
                 });
             }
         }
     }
     $data['candidates'] = $cuc->load_candidates();
     $data['thecandidate'] = $candidate;
     $fc = new \Stratum\Controller\FormController();
     $data['form'] = $fc->setupForm();
     return view('candidate')->with($data);
 }