Ejemplo n.º 1
0
 /**
  * Show a specific referral to the user.
  * 
  * @access public
  * @param mixed $clientID
  * @return void
  */
 public function action_referral($referalID, $clientID)
 {
     list($driver, $user_id) = \Auth::get_user_id();
     $referral = Referrals_class::forge($referalID);
     $debtList = \Crm\Ppi\Ppi_class::getDebtList();
     if ($referral->isValid === false) {
         \Log::error('Consolidator ' . Auth::get_screen_name() . ' tried to access referral ' . $referalID . ' which does not exist!', 'Crm_Ppi');
         \Session::set_flash('fail', "The referral ID you entered does not exist!");
         \Response::redirect('crm/ppi/referrals');
     }
     // Check through dispositions
     switch ($referral->disposition_id) {
         case 5:
             \Log::warning('Consolidator ' . Auth::get_screen_name() . ' tried to access referral ' . $referalID . ' which has been Packed Out as a PPI!', 'Crm_Ppi');
             \Session::set_flash('success', "Referral with ID of " . $referalID . " has been Packed Out as a PPI.");
             \Response::redirect('crm/ppi/referrals/' . $clientID);
             break;
         case 6:
             \Log::warning('Consolidator ' . Auth::get_screen_name() . ' tried to access referral ' . $referalID . ' which has been set to Not Interested!', 'Crm_Ppi');
             \Session::set_flash('fail', "Referral with ID of " . $referalID . " is set to 'Not Interested' and should not be contacted.");
             \Response::redirect('crm/ppi/referrals');
             break;
         case 23:
             \Log::warning('Consolidator ' . Auth::get_screen_name() . ' tried to access referral ' . $referalID . ' which has been set to Does Not Qualify!', 'Crm_Ppi');
             \Session::set_flash('fail', "Referral with ID of " . $referalID . " is set to 'Does Not Qualify' and should not be contacted.");
             \Response::redirect('crm/ppi/referrals');
             break;
         case 24:
             \Log::warning('Consolidator ' . Auth::get_screen_name() . ' tried to access referral ' . $referalID . ' which has upsold to Debt Reduction!', 'Crm_Ppi');
             \Session::set_flash('success', "Referral with ID of " . $referalID . " has been upsold to Debt Reduction!");
             \Response::redirect('crm/ppi/referrals');
             break;
         case 25:
             \Log::warning('Consolidator ' . Auth::get_screen_name() . ' tried to access referral ' . $referalID . ' which was referred as Debt Reduction!', 'Crm_Ppi');
             \Session::set_flash('fail', "Referral with ID of " . $referalID . " was sent as Debt Reduction. If you feel this is an error please contact the IT department!");
             \Response::redirect('crm/ppi/referrals');
             break;
         case 27:
             \Log::warning('Consolidator ' . Auth::get_screen_name() . ' tried to access referral ' . $referalID . ', this referral has already claimed PPI!', 'Crm_Ppi');
             \Session::set_flash('fail', "Referral with ID of " . $referalID . " has already claimed PPI!");
             \Response::redirect('crm/ppi/referrals');
             break;
         case 28:
             \Log::warning('Consolidator ' . Auth::get_screen_name() . ' tried to access referral ' . $referalID . ', this referral DNQ for PPI and not interested in DR!', 'Crm_Ppi');
             \Session::set_flash('fail', "Referral with ID of " . $referalID . " DNQ for PPI and not interested in DR!");
             \Response::redirect('crm/ppi/referrals');
             break;
     }
     if ($referral->user_id == 0 || $referral->user_id == $user_id) {
         $thisUser = \Model_User::find($user_id);
         $referral->user_id = $user_id;
         $referral->consolidation_centre = $thisUser->call_center_id;
         $referral->save();
     } else {
         $thisUser = \Model_User::find($referral->user_id)->username;
         \Log::warning('Consolidator ' . Auth::get_screen_name() . ' tried to access referral ' . $referalID . ' which was locked to ' . $thisUser . '!', 'Crm_Ppi');
         \Session::set_flash('fail', "The referral you requested is locked to another user. If you feel this is an error please contact the IT department.");
         \Response::redirect('crm/ppi/referrals');
     }
     // -- Log that the Agent opened up the Referral Type ID = 3 Referral Open
     // ----------------------------------------------------------------------
     Referral_log::create($referalID, 3);
     $creditorLoad = $referral->loadData();
     $creditorList = Creditor_class::loadCreditorList();
     \Log::write('Info', 'Consolidator ' . Auth::get_screen_name() . ' viewed referral with ID of ' . $referalID . '.', 'Crm_Ppi');
     $this->template->title = "Client View";
     $this->template->content = View::forge(static::$_viewPath . '/referral.php', array('creditors' => isset($creditorLoad['creditors']) ? $creditorLoad['creditors'] : null, 'creditorList' => $creditorList, 'debtList' => $debtList, 'client' => array('id' => $referalID, 'title' => $referral->title, 'forename' => $referral->forename, 'surname' => $referral->surname, 'street_and_number' => $referral->street_and_number, 'area' => $referral->area, 'district' => $referral->district, 'town' => $referral->town, 'county' => $referral->county, 'post_code' => $referral->post_code, 'date_of_birth' => $referral->date_of_birth, 'tel_home' => $referral->tel_home, 'tel_work' => $referral->tel_work, 'tel_mobile' => $referral->tel_mobile, 'email' => $referral->email, 'notes' => $referral->notes)));
 }
Ejemplo n.º 2
0
 public function action_view_client($clientID = 6273)
 {
     /*
      ** Client class now displays the client on the page
      ** NEEDS TO:
      **   * Display a list of products for the client
      **   * Show the status for these products
      **   * If we are still in 'Pack Sent' status then an icon lets us 're-send' a pack
      */
     $this->template->title = 'View Client';
     $ppiDetails = \Crm\Ppi\Ppi_class::forge($clientID);
     $chosenClient = \Crm\ClientClass::forge($clientID);
     // -- Check to see if the client has a partner saved
     // -------------------------------------------------
     $partnerDetails = array();
     if ($ppiDetails->hasPartner()) {
         $partner = \Crm\PartnerClass::forge($ppiDetails->partner_id);
         $partnerDetails = array('partnerID' => $ppiDetails->partner_id, 'title' => $partner->title, 'forename' => $partner->forename, 'surname' => $partner->surname, 'streetAndNumber' => $partner->streetAndNumber, 'area' => $partner->area, 'district' => $partner->district, 'town' => $partner->town, 'county' => $partner->county, 'postCode' => $partner->postCode, 'dateOfBirth' => $partner->dateOfBirth == "0000-00-00" ? "Not Taken" : date("d/m/Y", strtotime($partner->dateOfBirth)), 'telHome' => $partner->telHome == 0 ? "Not Taken" : "0" . $partner->telHome, 'telMobile' => $partner->telMobile == 0 ? "Not Taken" : "0" . $partner->telMobile, 'telWork' => $partner->telWork == 0 ? "Not Taken" : "0" . $partner->telWork, 'email' => $partner->email);
     }
     $referralDetails = Referrals_class::forge($ppiDetails->referral_id);
     $packDocuments = $ppiDetails->getPackReturnedDocuments();
     $creditorList = Creditor_class::loadCreditorList();
     $disposisionList = $referralDetails->loadDispositionList();
     // -- Is the client Active
     // -----------------------
     $clientProduct = \Crm\Product\Client_product_class::forge(\Crm\Product\Product_class::getClientProductID($ppiDetails->referral_id));
     // -- Correspondence
     // -----------------
     $correspondence = \Crm\Ppi\Ppi_correspondence::forge($clientID);
     $correspondenceList = $correspondence->getCorrespondences(5);
     // -- PPI Claims
     // -------------
     $claims = \Crm\Ppi\Ppi_claims::getClaims($ppiDetails->id);
     $ppiStages = \Crm\Ppi\Ppi_class::listStages();
     $niceCreditorList = array();
     foreach ($creditorList as $creditor) {
         $niceCreditorList[$creditor['id']] = $creditor['name'];
     }
     // -- Get a nice Debt Type List
     // ----------------------------
     $debtTypeList = \Crm\Ppi\Ppi_class::getDebtList();
     $niceDebtTypeList = array();
     foreach ($debtTypeList as $debt) {
         $niceDebtTypeList[$debt['id']] = $debt['description'];
     }
     $fullNoteList = $chosenClient->loadClientNotes();
     // -- Letters - Chase Letter and Non Claim Letter
     // ----------------------------------------------
     $letterConfig = \Crm\Ppi\Ppi_class::loadLettersList((int) $ppiDetails->company_id);
     $letters = array();
     $letters[] = array('id' => $letterConfig['client_free_text'], 'details' => \Crm\Letter\Letter::letterDetails($letterConfig['client_free_text']), 'freeText' => true, 'tray' => 2);
     $letters[] = array('id' => $letterConfig['ppi_welcome_letter'], 'details' => \Crm\Letter\Letter::letterDetails($letterConfig['ppi_welcome_letter']), 'freeText' => false, 'tray' => 2);
     $letters[] = array('id' => $letterConfig['ppi_form_of_authority'], 'details' => \Crm\Letter\Letter::letterDetails($letterConfig['ppi_form_of_authority']), 'freeText' => false, 'tray' => 1);
     $letters[] = array('id' => $letterConfig['recommand_a_friend'], 'details' => \Crm\Letter\Letter::letterDetails($letterConfig['recommand_a_friend']), 'freeText' => false, 'tray' => 1);
     $letters[] = array('id' => $letterConfig['terms_and_conditions_GAB'], 'details' => \Crm\Letter\Letter::letterDetails($letterConfig['terms_and_conditions_GAB']), 'freeText' => false, 'tray' => 1);
     $letters[] = array('id' => $letterConfig['terms_and_conditions_CUSTOMER'], 'details' => \Crm\Letter\Letter::letterDetails($letterConfig['terms_and_conditions_CUSTOMER']), 'freeText' => false, 'tray' => 1);
     $letters[] = array('id' => $letterConfig['missing_loa'], 'details' => \Crm\Letter\Letter::letterDetails($letterConfig['missing_loa']), 'freeText' => false, 'tray' => 2);
     $letters[] = array('id' => $letterConfig['missing_tac'], 'details' => \Crm\Letter\Letter::letterDetails($letterConfig['missing_tac']), 'freeText' => false, 'tray' => 2);
     $letters[] = array('id' => $letterConfig['ipad_questionnaire'], 'details' => \Crm\Letter\Letter::letterDetails($letterConfig['ipad_questionnaire']), 'freeText' => false, 'tray' => 1);
     $letters[] = array('id' => $letterConfig['client_pack_not_returned_1'], 'details' => \Crm\Letter\Letter::letterDetails($letterConfig['client_pack_not_returned_1']), 'freeText' => false, 'tray' => 2);
     $letters[] = array('id' => $letterConfig['client_pack_not_returned_2'], 'details' => \Crm\Letter\Letter::letterDetails($letterConfig['client_pack_not_returned_2']), 'freeText' => false, 'tray' => 2);
     $letters[] = array('id' => $letterConfig['client_missing_creditor_details'], 'details' => \Crm\Letter\Letter::letterDetails($letterConfig['client_missing_creditor_details']), 'freeText' => false, 'tray' => 2);
     $this->template->content = View::forge(static::$_viewPath . '/view_client.php', array('productDetails' => array('ppi' => array('companyName' => $ppiDetails->company_name, 'referralID' => $ppiDetails->referral_id, 'account_created' => date("d/m/Y", strtotime($ppiDetails->account_created)), 'pack_sent_date' => $ppiDetails->pack_sent_date == "0000-00-00" ? "Not Sent" : date("d/m/Y", strtotime($ppiDetails->pack_sent_date)), 'pack_returned_date' => $ppiDetails->pack_returned_date == "0000-00-00" ? "Not Received" : date("d/m/Y", strtotime($ppiDetails->pack_returned_date)), 'hasReturnedPack' => $ppiDetails->hasResentPack())), 'isActive' => $clientProduct->status('active'), 'creditorList' => $creditorList, 'claims' => $claims, 'allCreditors' => $niceCreditorList, 'allDebtTypes' => $niceDebtTypeList, 'debtList' => $debtTypeList, 'disposisionList' => $disposisionList, 'ppiStages' => $ppiStages, 'packDocuments' => $packDocuments, 'packCompleted' => $ppiDetails->pack_completed, 'canCreateClaims' => $ppiDetails->canCreateClaims(), 'agentDetails' => $ppiDetails->getReferralAgent(), 'clientDetails' => array('clientID' => $clientID, 'title' => $chosenClient->title, 'forename' => $chosenClient->forename, 'surname' => $chosenClient->surname, 'streetAndNumber' => $chosenClient->streetAndNumber, 'area' => $chosenClient->area, 'district' => $chosenClient->district, 'town' => $chosenClient->town, 'county' => $chosenClient->county, 'postCode' => $chosenClient->postCode, 'dateOfBirth' => $chosenClient->dateOfBirth == "0000-00-00" ? "Not Taken" : date("d/m/Y", strtotime($chosenClient->dateOfBirth)), 'telHome' => $chosenClient->telHome == 0 ? "Not Taken" : "0" . $chosenClient->telHome, 'telMobile' => $chosenClient->telMobile == 0 ? "Not Taken" : "0" . $chosenClient->telMobile, 'telWork' => $chosenClient->telWork == 0 ? "Not Taken" : "0" . $chosenClient->telWork, 'email' => $chosenClient->email, 'notes' => $chosenClient->notes, 'creditors' => $referralDetails->loadData(), 'allNotes' => $fullNoteList, 'correspondences' => $correspondenceList, 'hasPartner' => $chosenClient->hasPartner()), 'partnerDetails' => $partnerDetails, 'letters' => $letters));
 }