Exemplo n.º 1
0
 public function action_delete($id = null)
 {
     is_null($id) and Response::redirect('Survey_Question_Answer');
     if ($survey_question_answer = Model_Survey_Question_Answer::find($id)) {
         $survey_question_answer->delete();
         Session::set_flash('success', 'Deleted survey_question_answer #' . $id);
     } else {
         Session::set_flash('error', 'Could not delete survey_question_answer #' . $id);
     }
     Response::redirect('survey/question/answer');
 }
Exemplo n.º 2
0
 public function sendForConsolidation($emailData = array())
 {
     // -- Send the referral for consolidation
     // --------------------------------------
     // -- Create an Email to send to the consolidators
     // -----------------------------------------------
     $Email = \Email::forge();
     // -- Address needs to be from the company the agent is with
     // ---------------------------------------------------------
     $Email->from('*****@*****.**', 'Hot Key Referral');
     // -- Needs to include the company the referral was sent from, with referral ID and lead name
     // ------------------------------------------------------------------------------------------
     $Email->subject('Hot Key Referral');
     // -- This needs to go to the address set in the companies table
     // -------------------------------------------------------------
     $Email->to(\Company_class::salesEmail($this->_values['company_id']));
     // -- Referral Details
     // -------------------
     $emailData['referralID'] = $this->_referralID;
     $emailData['introducer'] = $this->_values['introducerName'];
     $emailData['company'] = $this->_values['companyName'];
     $emailData['productName'] = $this->_values['productName'];
     $emailData['referralDate'] = $this->_values['referralDate'];
     $emailData['agent'] = $this->_values['introducer_agent_name'];
     $emailData['introducer'] = \Model_Call_Center::find($this->_values['introducer_id'])->title;
     // -- Lead Details
     // ---------------
     $emailData['leadName'] = $this->fullName();
     $emailData['leadAddress'] = $this->address();
     $emailData['telHome'] = $this->_values['tel_home'];
     $emailData['telWork'] = $this->_values['tel_work'];
     $emailData['telMobile'] = $this->_values['tel_mobile'];
     /* No Need to load Data now as we get it from the answers table
        $loadData = $this->loadData();
        $emailData['questions']   = $loadData['referralQuestions'];
        */
     $answerDetails = \Model_Survey_Response::query()->where('reference', $this->_referralID)->get();
     $emailQuestions = array();
     foreach ($answerDetails as $answers) {
         $question = \Model_Survey_Question::find($answers->question_id);
         $eQuestion = $question->question;
         $answer = \Model_Survey_Question_Answer::find($answers->answer_id);
         $eAnswer = $answer->answer;
         $extraAnswer = $answers->extra;
         $emailQuestions[] = array('question' => $eQuestion, 'answer' => $eAnswer, 'extra' => $extraAnswer);
     }
     $emailData['questions'] = $emailQuestions;
     $Email->html_body(\View::forge($this->_emailTemplateDir . 'referral.php', $emailData));
     // -- Send the Email out
     // ---------------------
     $Email->send();
     $tempReferralID = empty($emailData['debtsolvLeadID']) ? $this->_referralID : $emailData['debtsolvLeadID'];
     \Log::write('Info', 'New ' . $this->_values['productName'] . ' lead referred with the ID of ' . $tempReferralID . ' from ' . $this->_values['introducerName'] . '.', 'Crm_Referrals');
 }
Exemplo n.º 3
0
 public static function generate_externals_report($introducer = null, $_startDate = null, $_endDate = null)
 {
     ini_set('memory_limit', '-1');
     $startDate = is_null($_startDate) ? date('Y-m-d') : $_startDate;
     $endDate = is_null($_endDate) ? date('Y-m-d') : $_endDate;
     $externalReferrals = \Model_Crmreferral::query();
     if (!is_null($introducer)) {
         if (is_array($introducer)) {
             $externalReferrals->where('introducer_id', "IN", $introducer);
         } else {
             $externalReferrals->where('introducer_id', (int) $introducer);
         }
     } else {
         return null;
     }
     if (!is_null($_endDate)) {
         $externalReferrals->where(DB::expr('DATE(referral_date)'), '>=', $startDate)->where(DB::expr('DATE(referral_date)'), '<=', $endDate);
     } else {
         $externalReferrals->where(DB::expr('DATE(referral_date)'), '=', $startDate);
     }
     $externalReferralResult = $externalReferrals->get();
     $allReferrals = array();
     foreach ($externalReferralResult as $referral) {
         $questionCount = 0;
         $responses = \Model_Survey_Response::query()->where('reference', $referral->id)->get();
         $responseList = array();
         foreach ($responses as $singleResponse) {
             if ($singleResponse->answer_id != 0) {
                 $questionCount++;
                 $responseList[$singleResponse->question_id] = array(Model_Survey_Question::find($singleResponse->question_id)->question, Model_Survey_Question_Answer::find($singleResponse->answer_id)->answer, $singleResponse->extra);
             }
         }
         // Check if the lead has been referred
         $thisCheck = Model_Survey_Lead_Dialler::query()->where('referral_id', $referral->id);
         if ($thisCheck->count() > 0) {
             $details = $thisCheck->get_one();
             $status = $details->type;
             $goDetails = \Goautodial\Model_Vicidial_List::find($details->dialler_id);
             $completed = array('DMPLUS', 'DR', 'PPICOM');
             $failed = array('PPICLM', 'DNC', 'DNCL', 'HUNGUP', 'TPS', 'NI', 'DNQ', 'DEC', 'ALLRDY', 'NP');
             if (in_array($goDetails->status, $completed)) {
                 $statusMessage = "Success. This referral continued with the " . $status . " package.";
             } else {
                 if (in_array($goDetails->status, $failed)) {
                     $statusMessage = "Unfortunately this referral did not continue with the " . $status . " package.";
                     $status .= "no";
                 } else {
                     $statusMessage = "Referral has qualified for " . $status . ". This status will change when we have more information.";
                 }
             }
         } else {
             if (strtotime("now -48 hours") < strtotime($referral->referral_date)) {
                 $status = null;
                 $statusMessage = "Referral has not yet been passed to the Consumer. Please wait, this will change.";
             } else {
                 $status = null;
                 $statusMessage = "Referral has not yet qualified for any services. This status may change in the future.";
             }
         }
         $allReferrals[] = array($referral->id, trim(ucwords(trim($referral->title) . " " . trim($referral->forename) . " " . trim($referral->surname))), $referral->introducer_agent_name, \Model_Call_Center::find($referral->introducer_id)->title, $referral->dialler_list_id, date("d/m/Y", strtotime($referral->referral_date)), date("H:i", strtotime($referral->referral_date)), $questionCount, $responseList, $status, $statusMessage);
     }
     //print_r($allReferrals);
     return $allReferrals;
 }