예제 #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);
 }
예제 #2
0
 //set up the controllers and their loggers
 $wcontroller = new \Stratum\Controller\WorldappController();
 $bcontroller = new \Stratum\Controller\BullhornController();
 $bcontroller->setLogger($log);
 $wcontroller->setLogger($log);
 //find the correct form
 $form = $wcontroller->find_form_by_name('Registration Form - Stratum International');
 //load the candidate data from Bullhorn
 $candidate = new Stratum\Model\Candidate();
 $candidate->set("id", $id);
 $bcontroller->load($candidate);
 //find the corporateUser Owner of this candidate (for From and ReplyTo email address)
 $ownerId = $candidate->get("owner")["id"];
 $owner = new \Stratum\Model\CorporateUser();
 $owner->set("id", $ownerId);
 $bcontroller->loadCorporateUser($owner);
 //load the custom Object that contains the template information
 $obj = $this->candidate->loadCustomObject(3);
 //download and store the original template (so we can convert back)
 $emailTemplate = $wcontroller->getEmailTemplate($form->id);
 //set up the correct template
 $newTemplate = [];
 $newTemplate['formId'] = $form->id;
 $newTemplate['from'] = $owner->get("email");
 $newTemplate['replyTo'] = $owner->get("email");
 $newTemplate['subject'] = $emailTemplate->subject;
 $newTemplate['content'] = $obj->get("customTextBlock1");
 //set the correct template on the WorldApp server
 self::$wcontroller->setEmailTemplate($newTemplate);
 //autofilled fields to be extracted from candidate
 //id,firstName,lastName,dateOfBirth,nickName,email,email2,mobile,phone,workPhone,fax3,pager,customTextBlock2