Ejemplo n.º 1
0
 function load($id)
 {
     $candidate = null;
     if (Cache::has($id)) {
         $candidate = Cache::get($id);
     } else {
         //load the candidate data from Bullhorn
         $candidate = new \Stratum\Model\Candidate();
         $candidate->set("id", $id);
         $bc = new BullhornController();
         $bc->load($candidate);
         Cache::add($id, $candidate, 60);
     }
     return $candidate;
 }
 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);
 }
 private function setup_template($id)
 {
     $template = new FormTemplate();
     //load the id from the request
     //$id = $request->getAttribute('entityid');
     $template->set('id', $id);
     //set up the controllers and their loggers
     $this->wcontroller = new \Stratum\Controller\WorldappController();
     $this->bcontroller = new \Stratum\Controller\BullhornController();
     $formName = 'Registration Form - Stratum International';
     if (Cache::has($formName)) {
         Log::debug("Loading form from cache");
         $form = Cache::get($formName);
     } else {
         //find the correct form
         $form = $this->wcontroller->find_form_by_name($formName);
         Cache::add($formName, $form, 60);
     }
     $template->set('form', $form);
     $candidate = null;
     if (Cache::has($id)) {
         $candidate = Cache::get($id);
         Log::debug("Loading candidate from cache with id " . $id);
     } else {
         //load the candidate data from Bullhorn
         $candidate = new \Stratum\Model\Candidate();
         $candidate->set("id", $id);
         $this->bcontroller->load($candidate);
         Cache::add($id, $candidate, 60);
     }
     $template->set('candidate', $candidate);
     $owner = $this->findCorporateUser($candidate);
     $template->set('owner', $owner);
     //download and store the original template (so we can convert back)
     $emailTemplate = null;
     if (Cache::has('original')) {
         $emailTemplate = Cache::get('original');
     } else {
         $emailTemplate = $this->wcontroller->getEmailTemplate($form->id);
         Cache::add('original', $emailTemplate, 60);
     }
     $template->set('emailTemplate', $emailTemplate);
     return $template;
 }
Ejemplo n.º 4
0
 public function submitPDF(\Stratum\Model\Candidate $bhcandidate, \Stratum\Model\Candidate $wacandidate, \Stratum\Model\Candidate $rqcandidate)
 {
     $this->log_debug("At submitPDF");
     $candidates['bh'] = $bhcandidate;
     $candidates['wa'] = $wacandidate;
     $candidates['rq'] = $rqcandidate;
     //going to use FormResponse (web form) as a template for the pdf.
     //so I will get the section headers - but only display section if
     //there is content.
     $formResult = $wacandidate->get("formResult");
     $form = $formResult->get("form");
     //parsed QandA.txt to get questions in order
     $sections = $form->get("sections");
     //and sections
     $headers = $form->get("sectionHeaders");
     //with appropriate labels
     $sectionData = [];
     for ($i = 0; $i < count($sections); $i++) {
         $section = $sections[$i];
         $label = $headers[$i];
         $retval = $this->exportSectionToPDF($form, $section, $label, $candidates);
         if ($retval) {
             $sectionData[$label] = $retval;
         }
     }
     $sectionData['Skills'] = $this->convertSkillsForPDF($candidates);
     $sectionData['Recommenders'] = $this->convertReferencesForPDF($candidates);
     $sectionData['Additional Tab'] = $this->convertCustomObjForPDF($candidates, $form);
     $sectionData['Notes'] = $this->convertNotesForPDF($candidates);
     return $sectionData;
 }