/** * PPI Claim Report * * @author David Stansfield */ public function action_claim_report() { $this->template->title = "PPI Claim Report"; $search = array(); $search = array('claimID' => \Input::post('PPI-ClaimID'), 'accountRef' => \Input::post('PPI-Account-Ref'), 'stage' => \Input::post('PPI-Stage'), 'status' => \Input::post('PPI-Stage-Status'), 'customReport' => \Input::post('PPI-Custom-Report')); $report = \Crm\Reports\Model_Ppi::searchClaims($search); // -- Search Select List // --------------------- $dispositionList = \Crm\Referrals\Referrals_class::loadStaticDispositionList(); $stages = \Crm\Ppi\Ppi_class::listStages(); $stagesNotToShow = array(1, 2); $ppiStages = array(); // -- Only include Stages listed in $stagesNotToShow array // ------------------------------------------------------- foreach ($stages as $key => $stage) { if (!in_array($stage['id'], $stagesNotToShow)) { $ppiStages[] = $stages[$key]; } } // -- Custom PPI Reports // --------------------- $customReports = array(); #$customReports = array(1 => array('name' => 'Canceled Clients')); $this->template->content = View::forge(static::$_viewPath . 'ppi/claim_report.php', array('claims' => $report, 'dispositionList' => $dispositionList, 'ppiStages' => $ppiStages, 'search' => $search, 'customReports' => $customReports)); }
public function action_save_creditors() { $referralID = \Input::post('referralID'); $clientID = \Input::post('clientID'); $i = 0; $referral = \Crm\Referrals\Referrals_class::forge($referralID); $addCreditors = array(); $data = array('creditors'); foreach ($_POST['creditors'] as $creditors) { $data['creditors'][] = array('creditor_choice' => $creditors['new-creditor-choice'] > 0 ? $creditors['new-creditor-choice'] : $creditors['creditor_choice'], 'creditor_account_number' => $creditors['creditor_account_number'], 'creditor_sort_code' => $creditors['creditor_sort_code'], 'creditor_value' => $creditors['creditor_value'], 'creditor_signatory' => $creditors['creditor_signatory'], 'creditor_debttype' => $creditors['creditor_debttype']); } $referral->saveData($data); // -- Send a response back // ----------------------- $this->response(array('status' => 'done')); }
public static function choice($questions = null, $portal_form = null, $apiKey = null) { // Before anything, do a duplicate check $dupes = \Crm\Referrals\Referrals_model::duplicationCheck(array('forename' => isset($portal_form['first_name']) ? $portal_form['first_name'] : null, 'surname' => isset($portal_form['last_name']) ? $portal_form['last_name'] : null, 'post_code' => isset($portal_form['postcode']) ? $portal_form['postcode'] : null, 'tel_home' => isset($portal_form['phone_number']) ? $portal_form['phone_number'] : null, 'tel_work' => null, 'tel_mobile' => isset($portal_form['alt_phone']) ? $portal_form['alt_phone'] : null)); if (count($dupes) > 0) { // We have a duplicate so lets find out where it comes from } else { $noppi = true; $nodr = true; } $centerDetails = \Model_Call_Center::find()->where('api_key', $apiKey)->get_one(); $clientID = \Crm\Referrals\Referrals_model::createReferral(array('user_id' => '', 'company_id' => 1, 'product_id' => 1, 'dialler_lead_id' => isset($portal_form['lead_id']) ? $portal_form['lead_id'] : null, 'dialler_list_id' => isset($portal_form['list_id']) ? $portal_form['list_id'] : null, 'dialler_list_name' => '', 'disposition_id' => '', 'title' => isset($portal_form['title']) ? $portal_form['title'] : null, 'forename' => isset($portal_form['first_name']) ? $portal_form['first_name'] : null, 'surname' => isset($portal_form['last_name']) ? $portal_form['last_name'] : null, 'street_and_number' => isset($portal_form['address1']) ? $portal_form['address1'] : null, 'area' => isset($portal_form['address2']) ? $portal_form['address2'] : null, 'district' => isset($portal_form['address3']) ? $portal_form['address3'] : null, 'town' => isset($portal_form['city']) ? $portal_form['city'] : null, 'county' => isset($portal_form['state']) ? $portal_form['state'] : null, 'post_code' => isset($portal_form['postal_code']) ? $portal_form['postal_code'] : null, 'date_of_birth' => isset($portal_form['date_of_birth']) ? $portal_form['date_of_birth'] : null, 'tel_home' => isset($portal_form['phone_number']) ? $portal_form['phone_number'] : null, 'tel_work' => 0, 'tel_mobile' => isset($portal_form['alt_phone']) ? $portal_form['alt_phone'] : null, 'email' => isset($portal_form['email']) ? $portal_form['email'] : null, 'notes' => isset($portal_form['comments']) ? $portal_form['comments'] : null, 'introducer_id' => $centerDetails->id)); if (Portal_Check::values_to_bool($questions['form-q5']) === true) { return array('type' => 'DNQ', 'reason' => 'being in an IVA or Declared Bankrupt.'); } else { if (Portal_Check::values_to_bool($questions['form-q3']) === false and Portal_Check::values_to_bool($questions['form-q4']) === false) { // Get client ID from the PPI system $Referral = \Crm\Referrals\Referrals_class::forge($clientID); $saveData['referralQuestions'] = $questions; $Referral->saveData($saveData); $Referral->product_id = 1; $Referral->company_id = 3; $Referral->save(); $Referral = \Crm\Referrals\Referrals_class::forge($clientID); $Referral->setDisposition(14); $Referral->sendForConsolidation(); return array('type' => 'PPI', 'clientID' => $clientID); } else { // Save details and get client ID from Debtsolv $Debtsolv = \Crm\Referrals\Referrals_debtsolv_class::forge((int) $clientID); $saveData['referralQuestions'] = $questions; $Debtsolv->saveData($saveData); $Debtsolv->product_id = 2; $Debtsolv->company_id = 1; $Debtsolv->save(); // Reload the referral $Debtsolv = \Crm\Referrals\Referrals_debtsolv_class::forge((int) $clientID); $client_ID = $Debtsolv->addNewLead(); $Debtsolv->setDisposition(25); $Debtsolv->sendForDRConsolidation(); return array('type' => 'DR', 'clientID' => $client_ID); } } return null; }
/** * Process the rreturned pack documents * @access public * @author David */ public function action_pack_in_check($clientID = 0) { // -- Get the serialized documents info for checking when packs were chased // ------------------------------------------------------------------------ $savedDocuments = array(); $ppiClient = \Crm\Ppi\Ppi_class::forge((int) $clientID); $savedDocuments = $ppiClient->getPackReturnedDocuments(); $date = date("d/m/Y"); $documents = array(); $documents = array('Creditor Information' => array('Completed' => \Input::post('DOCCHECK_Creditor_Information') == 'on' ? 'Yes' : 'No', 'Chase Date' => isset($savedDocuments['Creditor Information']['Chase Date']) && $savedDocuments['Creditor Information']['Chase Date'] != '' && \Input::post('DOCCHECK_Creditor_Information') != 'on' ? $savedDocuments['Creditor Information']['Chase Date'] : (\Input::post('DOCCHECK_Creditor_Information') != 'on' ? $date : ''), 'Notes' => ''), 'LOA' => array('Completed' => \Input::post('DOCCHECK_LOA') == 'on' ? 'Yes' : 'No', 'Chase Date' => isset($savedDocuments['LOA']['Chase Date']) && $savedDocuments['LOA']['Chase Date'] != '' && \Input::post('DOCCHECK_LOA') != 'on' ? $savedDocuments['LOA']['Chase Date'] : (\Input::post('DOCCHECK_LOA') != 'on' ? $date : ''), 'Notes' => ''), 'TaC' => array('Completed' => \Input::post('DOCCHECK_TaC') == 'on' ? 'Yes' : 'No', 'Chase Date' => isset($savedDocuments['TaC']['Chase Date']) && $savedDocuments['TaC']['Chase Date'] != '' && \Input::post('DOCCHECK_TaC') != 'on' ? $savedDocuments['TaC']['Chase Date'] : (\Input::post('DOCCHECK_TaC') != 'on' ? $date : ''), 'Notes' => ''), 'Section F' => array('Completed' => \Input::post('DOCCHECK_Section_F') == 'on' ? 'Yes' : 'No', 'Chase Date' => isset($savedDocuments['Section F']['Chase Date']) && $savedDocuments['Section F']['Chase Date'] != '' && \Input::post('DOCCHECK_Section_F') != 'on' ? $savedDocuments['Section F']['Chase Date'] : (\Input::post('DOCCHECK_Section_F') != 'on' ? $date : ''), 'Notes' => '')); if ($ppiClient->pack_completed == 'no') { // -- Only process if the pack isn't completed // ------------------------------------------- // -- Save the document information back // ------------------------------------- $ppiClient->savePackReturnedDocuments($documents); $correspondence = \Crm\Ppi\Ppi_correspondence::forge((int) $clientID); $correspondenceMsg = null; // -- If any of the documents have missing infomation and it isn't currently being chased then send out a letter and paperwork, also add a new correspondence // ---------------------------------------------------------------------------------------------------------------------------------------------------------- if (\Input::post('DOCCHECK_Creditor_Information') == 'on' && \Input::post('DOCCHECK_LOA') == 'on' && \Input::post('DOCCHECK_TaC') == 'on' && \Input::post('DOCCHECK_Section_F') == 'on') { // -- All paperwork is now complete // -------------------------------- // 1) Mark the Pack as complete // 2) Create a correspondence that the pack is complete $ppiClient->setPackCompleted(); $correspondence->saveNew(0, 2, 5, 0, 'Pack Completed'); } else { $letterHead = array(); $letterBlank = array(); $missing = array(); $referralInfo = \Crm\Referrals\Referrals_class::forge((int) $correspondence->referral_id); $creditors = $referralInfo->loadData('creditors'); $letterConfig = \Crm\Ppi\Ppi_class::loadLettersList((int) $ppiClient->company_id); unset($referralInfo); // -- Missing Creditor Information // ------------------------------- if (\Input::post('DOCCHECK_Creditor_Information') != 'on' && $savedDocuments['Creditor Information']['Chase Date'] == '') { $correspondenceMsg .= 'Pack Incomplete. Missing information found on the Creditor Information Section.' . "\r\n"; $letterHead[] = array('id' => $letterConfig['missing_loa'], 'qty' => 1, 'tray_id' => 2); $letterBlank[] = array('id' => $letterConfig['ppi_form_of_authority'], 'qty' => count($creditors) > 0 ? count($creditors) : 3, 'tray_id' => 1); $missing[] = '<li>Creditor name / Account Number</li>'; } // -- Missing LOA // -------------- if (\Input::post('DOCCHECK_LOA') != 'on' && $savedDocuments['LOA']['Chase Date'] == '') { $correspondenceMsg .= 'Pack Incomplete. Missing information found on the LOA Section.' . "\r\n"; $letterHead[] = array('id' => $letterConfig['missing_loa'], 'qty' => 1, 'tray_id' => 2); $letterBlank[] = array('id' => $letterConfig['ppi_form_of_authority'], 'qty' => count($creditors) > 0 ? count($creditors) : 3, 'tray_id' => 1); $missing[] = '<li>Signed Form of Authority</li>'; } // -- Missing Terms and Conditions // ------------------------------- if (\Input::post('DOCCHECK_TaC') != 'on' && $savedDocuments['TaC']['Chase Date'] == '') { $correspondenceMsg .= 'Pack Incomplete. Missing information found on the Terms and Conditions Section.' . "\r\n"; $letterHead[] = array('id' => $letterConfig['missing_tac'], 'qty' => 1, 'tray_id' => 2); $letterBlank[] = array('id' => $letterConfig['terms_and_conditions_GAB'], 'qty' => 1, 'tray_id' => 1); $missing[] = '<li>Signed Terms and Conditions</li>'; } // -- Missing Section "F" // ---------------------- if (\Input::post('DOCCHECK_Section_F') != 'on' && $savedDocuments['Section F']['Chase Date'] == '') { $correspondenceMsg .= 'Pack Incomplete. Missing information Section F Isn\'t filled in.' . "\r\n"; $missing[] = '<li>Signed Section F</li>'; $printSectionF = true; } } } if (!is_null($correspondenceMsg)) { // -- Pack is found to be incomplete. Set correspondence and send letter out // ------------------------------------------------------------------------- $correspondence->saveNew(0, 2, 2, 0, $correspondenceMsg); if ($ppiClient->company_id == 1) { $timeSlot = 1; } else { if ($ppiClient->company_id == 3) { $timeSlot = 2; } } // -- Persolvo Letters if (count($missing) > 1) { unset($letterHead); $letterHead[] = array('id' => $letterConfig['missing_several_documents'], 'qty' => 1, 'tray_id' => 2); $extraData = array(); $freeText = ''; foreach ($missing as $missingText) { $freeText .= $missingText; } $extraData = array('freeText' => $freeText); } #if(count($letterHead) > 0) # \Crm\Letter\Pack::forge((int)$clientID,null,$letterHead)->setOutputFilename('ppi_missing_info_pack_coverletter_' . date("dmy") . '_' .(int)$clientID.'.pdf')->printLetter(2, 40)->timeSlot($timeSlot)->create(); \Crm\Letter\Letter::forge($clientID, null, $extraData)->writeContent($letterHead[0]['id'])->setOutputFilename('ppi_missing_info_pack_coverletter_' . date("dmy") . '_' . (int) $clientID . '.pdf')->printLetter($letterHead[0]['tray_id'])->timeSlot($timeSlot)->create(); if (count($letterBlank) > 0) { \Crm\Letter\Pack::forge((int) $clientID, null, $letterBlank)->setOutputFilename('ppi_missing_info_pack_' . date("dmy") . '_' . (int) $clientID . '.pdf')->printLetter(1, 40)->timeSlot($timeSlot)->create(); } if ($printSectionF == true) { \Printmanager\Queue::add(DOCROOT . 'uploads/crm/forms/section_f_form.pdf', $timeSlot == 1 ? date('Y-m-d 14:00:00') : date('Y-m-d 20:30:00'), 1); } #\Printmanager\Queue::add(DOCROOT . 'uploads/crm/forms/section_f_form.pdf', ( (int)date('H') < 14 ) ? date('Y-m-d 14:00:00') : date('Y-m-d 20:30:00'), 1); $correspondence->saveNew(0, 2, 3, 0, 'Letter Sent to Client'); } // -- If all the documents have been completed, then set the Pack Completed field as Yes // ------------------------------------------------------------------------------------- Response::redirect('crm/view_client/' . $clientID . '/'); }
public static function choice($questions = null, $portal_form = null, $apiKey = null) { // Before anything, do a duplicate check $apiCheck = \Crm\Portal\Portal_Check::api_key($apiKey); $surveyChoice = $apiCheck->survey; $surveyDetails = \Model_Survey::find($surveyChoice); $collectOnly = true; if ($surveyDetails->type == 'CHOICE') { $collectOnly = false; } else { $collectOnly = true; } $dupes = \Crm\Referrals\Referrals_model::duplicationCheck(array('forename' => isset($portal_form['first_name']) ? $portal_form['first_name'] : null, 'surname' => isset($portal_form['last_name']) ? $portal_form['last_name'] : null, 'post_code' => isset($portal_form['postcode']) ? $portal_form['postcode'] : null, 'tel_home' => isset($portal_form['phone_number']) ? $portal_form['phone_number'] : null, 'tel_work' => null, 'tel_mobile' => isset($portal_form['alt_phone']) ? $portal_form['alt_phone'] : null)); if (count($dupes) > 0) { // We have a duplicate so lets find out where it comes from } else { $noppi = true; $nodr = true; } $centerDetails = \Model_Call_Center::query()->where('api_key', $apiKey)->get_one(); $clientID = \Crm\Referrals\Referrals_model::createReferral(array('user_id' => '', 'company_id' => 3, 'product_id' => 1, 'dialler_lead_id' => isset($portal_form['lead_id']) ? $portal_form['lead_id'] : null, 'dialler_list_id' => isset($portal_form['list']) ? $portal_form['list'] : null, 'dialler_list_name' => '', 'introducer_agent_name' => isset($portal_form['agent']) ? $portal_form['agent'] : null, 'disposition_id' => '', 'title' => isset($portal_form['title']) ? $portal_form['title'] : null, 'forename' => isset($portal_form['first_name']) ? $portal_form['first_name'] : null, 'surname' => isset($portal_form['last_name']) ? $portal_form['last_name'] : null, 'street_and_number' => isset($portal_form['address1']) ? $portal_form['address1'] : null, 'area' => isset($portal_form['address2']) ? $portal_form['address2'] : null, 'district' => isset($portal_form['address3']) ? $portal_form['address3'] : null, 'town' => isset($portal_form['city']) ? $portal_form['city'] : null, 'county' => isset($portal_form['state']) ? $portal_form['state'] : null, 'post_code' => isset($portal_form['postal_code']) ? $portal_form['postal_code'] : null, 'date_of_birth' => isset($portal_form['date_of_birth']) ? $portal_form['date_of_birth'] : null, 'tel_home' => isset($portal_form['phone_number']) ? $portal_form['phone_number'] : null, 'tel_work' => 0, 'tel_mobile' => isset($portal_form['alt_phone']) ? $portal_form['alt_phone'] : null, 'email' => isset($portal_form['email']) ? $portal_form['email'] : null, 'notes' => isset($portal_form['comments']) ? $portal_form['comments'] : null, 'introducer_id' => $centerDetails->id)); \log::write('PPI-DEBUG', \Format::forge($questions)->to_json()); foreach ($questions as $questionId => $questionAnswer) { if (substr($questionId, 0, 6) == "form-q") { $answers = new \Model_Survey_Response(); $answers->reference = $clientID; $answers->question_id = (int) str_replace("form-q", "", $questionId); $answers->answer_id = !is_null($questionAnswer) ? $questionAnswer : ""; $answers->extra = !is_null($questions['form-e' . (int) str_replace("form-q", "", $questionId)]) ? $questions['form-e' . (int) str_replace("form-q", "", $questionId)] : "-"; $answers->save(); } } if (!$collectOnly) { if ((int) $questions['form-q21'] == 126) { return array('type' => 'DNQ', 'reason' => 'being in an IVA or Declared Bankrupt.'); } else { if ((int) $questions['form-q19'] == 123 and (int) $questions['form-q20'] == 125) { // Get client ID from the PPI system $Referral = \Crm\Referrals\Referrals_class::forge($clientID); $saveData['referralQuestions'] = $questions; $Referral->saveData($saveData); $Referral->product_id = 1; $Referral->company_id = 3; $Referral->save(); $Referral = \Crm\Referrals\Referrals_class::forge($clientID); $Referral->setDisposition(14); $Referral->sendForConsolidation(); return array('type' => 'PPI', 'clientID' => $clientID); } else { // Save details and get client ID from Debtsolv $Debtsolv = \Crm\Referrals\Referrals_debtsolv_class::forge((int) $clientID); $saveData['referralQuestions'] = $questions; $Debtsolv->saveData($saveData); $Debtsolv->product_id = 2; $Debtsolv->company_id = 1; $Debtsolv->save(); // Reload the referral $Debtsolv = \Crm\Referrals\Referrals_debtsolv_class::forge((int) $clientID); $client_ID = $Debtsolv->addNewLead(); $Debtsolv->setDisposition(25); $Debtsolv->sendForDRConsolidation(); return array('type' => 'DR', 'clientID' => $client_ID); } } } else { return array('type' => 'DONE', 'clientID' => $client_ID); } return null; }