public function indexAction() { //$role = Zend_Auth::getInstance()->getIdentity()->role; $identity = Zend_Auth::getInstance()->getIdentity()->toArray(); $clientGateway = new Clients_Model_ClientGateway(); if ($identity['role'] === 'Root') { $this->view->pendingList = Zend_Paginator::factory($clientGateway->fetchAllPendingClients()); $this->view->activeList = Zend_Paginator::factory($clientGateway->fetchAllActiveClients()); } else { $this->view->pendingList = Zend_Paginator::factory($clientGateway->fetchPendingClientsByAgentId($identity['agent_id'])); $this->view->activeList = Zend_Paginator::factory($clientGateway->fetchActiveClientsByAgentId($identity['agent_id'])); } $request = Zend_Controller_Front::getInstance()->getRequest(); $this->view->module = $request->getModuleName(); $this->view->controller = $request->getControllerName(); $this->view->pendingList->setCurrentPageNumber($this->_getParam('page')); $this->view->activeList->setCurrentPageNumber($this->_getParam('page')); }
/** * Add Client Spouse Action */ public function processAddClientSpouseAction() { if (!$this->_request->isXmlHttpRequest() || !$this->_request->isPost()) { $this->_redirect('/admin/clients/'); } $return = array(); $clientGateway = new Clients_Model_ClientGateway(); $form = $clientGateway->getForm('CreateClientSpouse'); $validForm = $form->isValid($this->_request->getParams()); // Check the form for validity if (!$validForm) { $return['formErrors'] = $form->getMessages(); $return['formResult'] = FALSE; } else { //Since we are working with spouse data the spouse id //actually refers to our client $clientId = $this->_request->getParam('spouse_id'); $formData = $form->getValues(); $formData['client_dob'] = $this->_dateFormatter->saveDateFormat($formData['client_dob'], $formData['altDOB']); unset($formData['altDOB']); $client = $clientGateway->create($formData); $client->save(); $flashMessenger = $this->_helper->getHelper('FlashMessenger'); $flashMessenger->setNamespace('notifications')->addMessage('Client Spouse Added'); if ($this->_request->getParam('close') == 1) { $return['redirect']['location'] = '/admin/clients/'; } else { $return['redirect']['location'] = '/admin/clients/modify/spouse/' . $clientId; } } $this->_helper->json->sendJson($return); }
/** * Overview Index Action */ public function indexAction() { $financials = array(); if ($this->_request->getParam('id', null) === null) { $this->_redirect('/admin/clients/'); } $this->view->clientId = array('client_id' => $this->_request->id); //Fetch Client & Spouse Details $clientGateway = new Clients_Model_ClientGateway(); $clientContact = $clientGateway->fetchClient($this->_request->id); if (is_object($clientContact)) { $clientContact = $clientContact->toArray(); } $clientContact['client_dob'] = $this->_dateFormatter->viewDateFormat($clientContact['client_dob']); $clientSpouse = $clientGateway->fetchClientSpouse($this->_request->id); if (is_object($clientSpouse)) { $clientSpouse = $clientSpouse->toArray(); } if ($clientSpouse) { $clientSpouse['client_dob'] = $this->_dateFormatter->viewDateFormat($clientSpouse['client_dob']); } //Calculate Asset Totals $clientAssetGateway = new Clients_Model_ClientAssetGateway(); $financials['assetsTotalEquity'] = $clientAssetGateway->calculateAssetsTotalEquity($this->_request->id); $financials['assetsTotalEquity'] = number_format($financials['assetsTotalEquity'], 2); //Calculate Investment Totals - Investments and Retirement Plans $clientInvestmentGateway = new Clients_Model_ClientInvestmentGateway(); $financials['investmentsTotal'] = $clientInvestmentGateway->calculateInvestmentsTotal($this->_request->id); $clientEmploymentGateway = new Clients_Model_ClientEmploymentGateway(); $financials['investmentsTotal'] += $clientEmploymentGateway->calculateRetirementPlanTotals($this->_request->id); $financials['investmentsTotal'] = number_format($financials['investmentsTotal'], 2); //Calculate Incomes Total $clientIncomeGateway = new Clients_Model_ClientIncomeGateway(); $incomeTotal = $clientIncomeGateway->calculateIncomeTotals($this->_request->id); $empIncomeTotal = $clientEmploymentGateway->calculateEmploymentIncomeTotal($this->_request->id); $financials['incomeTotal'] = $incomeTotal + $empIncomeTotal; $financials['incomeTotal'] = number_format($financials['incomeTotal'], 2); //Calculate Total Monthly Expenses $financials['mthlyExpenses'] = $clientEmploymentGateway->calculateRetirementMonthlyExpense($this->_request->id); $clientInsuranceGateway = new Clients_Model_ClientInsuranceGateway(); $financials['mthlyExpenses'] += $clientInsuranceGateway->calculateMonthlyInsuranceExpense($this->_request->id); $financials['mthlyExpenses'] += $clientAssetGateway->calculateAssetsTotalMonthlyExpense($this->_request->id); $financials['mthlyExpenses'] += $clientInvestmentGateway->calculateInvestmentsMonthlyExpense($this->_request->id); $clientExpenseGateway = new Clients_Model_ClientExpenseGateway(); $financials['mthlyExpenses'] += $clientExpenseGateway->calculateTotalMonthlyExpenses($this->_request->id); $financials['mthlyExpenses'] = number_format($financials['mthlyExpenses'], 2); //Calculate Total Accumulated Debt $financials['debtTotal'] = $clientExpenseGateway->calculateTotalAccumulatedExpenses($this->_request->id); $financials['debtTotal'] += $clientAssetGateway->calculateAssetsTotalDebt($this->_request->id); $financials['debtTotal'] = number_format($financials['debtTotal'], 2); //Calculate Emergency Funds $financials['emergencyFunds'] = $clientAssetGateway->calculateAssetEmergencyFunds($this->_request->id); $financials['emergencyFunds'] = $clientInvestmentGateway->calculateInvestmentEmergencyFunds($this->_request->id); $financials['emergencyFunds'] = number_format($financials['emergencyFunds'], 2); $request = Zend_Controller_Front::getInstance()->getRequest(); $this->view->module = $request->getModuleName(); $this->view->controller = $request->getControllerName(); $this->view->clientContact = $clientContact; $this->view->clientSpouse = $clientSpouse; $this->view->financials = $financials; }
/** * Get Employment Data for Client/Spouse * @param Client $id */ public function getEmploymentData($id) { $employment = array(); $employment['client'] = array(); $employment['spouse'] = array(); //Check to see if this client has a spouse $clientGateway = new Clients_Model_ClientGateway(); // retrieve spouse details $spouseId = $clientGateway->fetchClientSpouseId($id); $clientEmploymentGateway = new Clients_Model_ClientEmploymentGateway(); //Spouse confirmed if ($spouseId) { // retrieve spouse details $clientEmployment = $clientEmploymentGateway->fetchClientAndSpouseEmployment($id); if (count($clientEmployment) == '2') { if ($clientEmployment['0']['client_id'] == $id) { $employment['client'] = $clientEmployment['0']; $employment['spouse'] = $clientEmployment['1']; } else { $employment['client'] = $clientEmployment['1']; $employment['spouse'] = $clientEmployment['0']; } } elseif (count($clientEmployment) == '1') { if ($clientEmployment['0']['client_id'] == $id) { $employment['client'] = $clientEmployment['0']; } else { $employment['spouse'] = $clientEmployment['0']; } } } else { $clientEmployment = $clientEmploymentGateway->fetchClientEmployment($id); if (is_object($clientEmployment)) { $employment['client'] = $clientEmployment->toArray(); } else { $employment['client'] = $clientEmployment; } } return $employment; }
/** * Get the Clients Date of Birth then calculate * the clients age based on todays date * @param client $id */ public function getClientAge($id) { $this->checkAcl('read'); //Get Current Date $currentDate = new DateTime(); //Get Client Retirement year from Employment data $clientGateway = new Clients_Model_ClientGateway(); $clientDob = $clientGateway->fetchClientDOB($id); if ($clientDob) { $dobDate = new DateTime($clientDob['client_dob']); } else { return null; } $clientAge = $dobDate->diff($currentDate); return $clientAge->y; }