public function insuranceAction() { $request = $this->getRequest(); $landlordssalesreport = new Connect_Form_LandlordsInsuranceSalesReport(); $tenantssalesreport = new Connect_Form_TenantsInsuranceSalesReport(); $this->view->tenantssalesreport = $tenantssalesreport; $this->view->landlordssalesreport = $landlordssalesreport; if ($request->isPost()) { $formdata = $request->getPost(); $landlordssalesreport->populate($formdata); $tenantssalesreport->populate($formdata); if ($landlordssalesreport->isValid($formdata) && isset($formdata['landlordsinsurancesalesreport_producereport'])) { $startdate = new Zend_Date($landlordssalesreport->getElement('landlordsinsurancesalesreport_start')->getValue(), Zend_Date::DAY . '/' . Zend_Date::MONTH . '/' . Zend_Date::YEAR); $enddate = new Zend_Date($landlordssalesreport->getElement('landlordsinsurancesalesreport_end')->getValue(), Zend_Date::DAY . '/' . Zend_Date::MONTH . '/' . Zend_Date::YEAR); $report = new Datasource_Connect_Mi_InsuranceSales(); $this->view->reportdata = $report->landlordsInsuranceSalesForMonthYear($this->_agentSchemeNumber, $startdate, $enddate); $this->view->headLink()->appendStylesheet('/assets/connect/css/print.css', 'print'); $this->render('landlordsinsurancesales_report'); } else { if ($landlordssalesreport->isValid($formdata) && isset($formdata['landlordsinsurancesalesreport_exporttoexcel'])) { $startdate = new Zend_Date($landlordssalesreport->getElement('landlordsinsurancesalesreport_start')->getValue(), Zend_Date::DAY . '/' . Zend_Date::MONTH . '/' . Zend_Date::YEAR); $enddate = new Zend_Date($landlordssalesreport->getElement('landlordsinsurancesalesreport_end')->getValue(), Zend_Date::DAY . '/' . Zend_Date::MONTH . '/' . Zend_Date::YEAR); $this->_sendCsvHeaders('landlords-sales-report.csv'); $report = new Datasource_Connect_Mi_InsuranceSales(); $this->view->reportdata = $report->landlordsInsuranceSalesForMonthYear($this->_agentSchemeNumber, $startdate, $enddate); $this->_helper->getHelper('layout')->disableLayout(); $this->render('landlordsinsurancesales_csv'); } else { if ($tenantssalesreport->isValid($formdata) && isset($formdata['tenantsinsurancesalesreport_producereport'])) { $startdate = new Zend_Date($tenantssalesreport->getElement('tenantsinsurancesalesreport_start')->getValue(), Zend_Date::DAY . '/' . Zend_Date::MONTH . '/' . Zend_Date::YEAR); $enddate = new Zend_Date($tenantssalesreport->getElement('tenantsinsurancesalesreport_end')->getValue(), Zend_Date::DAY . '/' . Zend_Date::MONTH . '/' . Zend_Date::YEAR); $report = new Datasource_Connect_Mi_InsuranceSales(); $this->view->reportdata = $report->tenantsInsuranceSalesForMonthYear($this->_agentSchemeNumber, $startdate, $enddate); $this->view->headLink()->appendStylesheet('/assets/connect/css/print.css', 'print'); $this->render('tenantsinsurancesales_report'); } else { if ($tenantssalesreport->isValid($formdata) && isset($formdata['tenantsinsurancesalesreport_exporttoexcel'])) { $startdate = new Zend_Date($tenantssalesreport->getElement('tenantsinsurancesalesreport_start')->getValue(), Zend_Date::DAY . '/' . Zend_Date::MONTH . '/' . Zend_Date::YEAR); $enddate = new Zend_Date($tenantssalesreport->getElement('tenantsinsurancesalesreport_end')->getValue(), Zend_Date::DAY . '/' . Zend_Date::MONTH . '/' . Zend_Date::YEAR); $this->_sendCsvHeaders('tenants-sales-report.csv'); $report = new Datasource_Connect_Mi_InsuranceSales(); $this->view->reportdata = $report->tenantsInsuranceSalesForMonthYear($this->_agentSchemeNumber, $startdate, $enddate); $this->_helper->getHelper('layout')->disableLayout(); $this->render('tenantsinsurancesales_csv'); } } } } } }