Exemplo n.º 1
0
 /**
  * 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));
 }
Exemplo n.º 2
0
 /**
  * Create a new PPI Invoice
  * 
  * @author David Stansfield
  * @public
  * @param int $clientID, int $claimID
  */
 public function action_create_invoice()
 {
     // -- Check that one hasn't been created for this product
     // ------------------------------------------------------
     // -- Set the POST variables
     // -------------------------
     $clientID = \Input::post('Invoice_ClientID');
     $productTypeID = \Input::post('Invoice_Product_Type_ID');
     $clientProductID = \Input::post('Invoice_Client_Product_ID');
     $referenceID = \Input::post('Invoice_ReferenceID');
     $refundMethodID = \Input::post('Refund_Method');
     $correspondence = \Crm\Ppi\Ppi_correspondence::forge((int) $clientID);
     if ($refundMethodID > 0) {
         $refundMethod = \Crm\Ppi\Ppi_class::getRefundMethod($refundMethodID);
     }
     $description = \Input::post('Invoice_Description');
     $qty = \Input::post('Invoice_Qty');
     $charge = \Input::post('Invoice_Charge');
     $fee = \Input::post('Invoice_Fee');
     $vatPc = \Input::post('VAT_Percentage');
     $vat = 0;
     $total = 0;
     $feeTotal = $charge / 100 * $fee;
     $total = $feeTotal * $qty;
     $vat = $total / 100 * $vatPc;
     $total = $total + $vat;
     // -- Create the Invoice
     // ---------------------
     $details = array();
     $details = array('description' => $description . (isset($refundMethod) ? ' | Chosen refund method is ' . $refundMethod : false), 'qty' => $qty, 'charge' => $charge, 'vat_pc' => $vatPc, 'vat_amount' => $vat, 'fee' => $fee, 'total' => $total);
     $invoiceID = \Crm\Invoice\Invoice_class::createInvoice($clientID, $productTypeID, $clientProductID, $referenceID, $details);
     if ($invoiceID > 0) {
         // -- Invoice has been created in the system, now create a Refund Method entry
         // ---------------------------------------------------------------------------
         $refundData = array('claim_id' => $referenceID, 'invoice_id' => $invoiceID, 'method_id' => 0, 'refund_amount' => $charge);
         if (\Crm\Ppi\Ppi_class::createRefundMethod($refundData)) {
             // -- Print the Invoice
             // --------------------
             $extraData = array('date' => date("jS F Y"), 'invoiceDescription' => $description, 'invoiceQuantity' => $qty, 'invoiceCharge' => $charge, 'vatPc' => $vatPc, 'vatAmount' => $vat, 'totalGross' => $feeTotal, 'invoiceCostTotal' => $total, 'claimID' => $referenceID);
             $fileName = 'invoice_' . $clientID . '_' . $invoiceID . '.pdf';
             \Crm\Letter\Letter::forge($clientID, null, $extraData)->writeContent(27)->setOutputFilename($fileName)->printLetter(2)->create();
             // -- Save Correspondence
             // ----------------------
             $correspondence = \Crm\Ppi\Ppi_correspondence::forge((int) $clientID);
             $correspondence->saveNew($referenceID, 10, 28, 0, 'Invoice #' . $invoiceID . ' Created and printed <a href="/uploads/crm/letter/' . $fileName . '" target="_blank">View Letter</a>');
             // -- Save the invoice ID to the claim
             // -----------------------------------
             $claim = \Crm\Ppi\Ppi_claims::forge($referenceID);
             $claim->setInvoiceID($invoiceID);
             $message = $invoiceID;
             $status = 'done';
         } else {
             $message = 'Unable to save Refund Method';
             $status = 'error';
         }
     } else {
         $message = 'Unable to create a new invoice';
         $status = 'error';
     }
     $this->response(array('status' => $status, 'message' => $message));
 }
Exemplo n.º 3
0
 /**
  * Load up all the possible extraData for the PPI letters
  * 
  * @author David Stansfield
  * @private
  * @return array
  */
 private function getExtraPPILetterData($clientID, $claimID)
 {
     $client = \Crm\ClientClass::forge((int) $clientID);
     $ppiClient = \Crm\Ppi\Ppi_class::forge($clientID);
     $claim = null;
     if ($claimID > 0) {
         $claim = \Crm\Ppi\Ppi_claims::forge((int) $claimID);
     }
     // -- Get the Agents Name
     list($driver, $user_id) = \Auth::get_user_id();
     $agentName = \DB::query("SELECT\n                                 name\n                               FROM\n                                 users\n                               WHERE\n                                 id = " . $user_id . "\n                               LIMIT 1\n                              ", \DB::select())->execute()->as_array();
     $extraData = array('creditorName' => is_object($claim) ? $claim->getCreditorDetails()->name : '', 'creditorAddress' => is_object($claim) ? $claim->getCreditorDetails()->address("<br />") : '', 'inlineClientAddress' => $client->address(), 'accountReference' => is_object($claim) ? $claim->account_ref : '', 'accountNumber' => is_object($claim) ? $claim->account_number : '', 'sortCode' => is_object($claim) ? $claim->sort_code : 'n/a', 'undersigned' => $agentName[0]['name'], 'date' => date("jS F Y"), 'packSentDate' => date("d/m/Y", strtotime($ppiClient->pack_sent_date)), 'claimID' => $claimID > 0 ? $claimID : '');
     return $extraData;
 }
Exemplo n.º 4
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));
 }
Exemplo n.º 5
0
 /**
  * Create a new Partner
  * 
  * @author David Stansfield
  * @access public
  * @param array $data Holds values to create a partner.
  */
 public static function createPartner($data = array())
 {
     if (count($data) <= 0) {
         \Log::write(1, 'No values were passed to create a Partner');
         return;
     }
     $partnerID = 0;
     $partnerID = \Crm\PartnerModel::createPartner($data);
     if ($partnerID > 0) {
         // -- Partner created, so now need to update the client ppi table with the partner.
         // -- Need to change this to allow for different products.
         // --------------------------------------------------------------------------------
         \Crm\Ppi\Ppi_class::updatePartnerID($data['clientID'], $partnerID);
         return true;
     } else {
         return false;
     }
 }