예제 #1
0
 public function init()
 {
     $this->setAttrib('class', 'horizontal-form')->setName('form_businessplan');
     $elements = array();
     $elements[] = $this->createElement('hidden', 'id_businessplan')->setDecorators(array('ViewHelper'));
     $elements[] = $this->createElement('hidden', 'expense')->setIsArray(true);
     $elements[] = $this->createElement('hidden', 'detailed_expense')->setIsArray(true);
     $elements[] = $this->createElement('text', 'project_name')->setDecorators($this->getDefaultElementDecorators())->setRequired(true)->setAttrib('class', 'm-wrap span12')->setAttrib('maxlength', 200)->setLabel('Nome do projeto');
     $elements[] = $this->createElement('text', 'district')->setDecorators($this->getDefaultElementDecorators())->setRequired(true)->setAttrib('class', 'm-wrap span12')->setAttrib('readonly', true)->setLabel('Distritu');
     $elements[] = $this->createElement('select', 'fk_id_addsubdistrict')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setRegisterInArrayValidator(false)->setLabel('Sub-Distritu')->setRequired(true);
     $elements[] = $this->createElement('select', 'fk_id_addsucu')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setRegisterInArrayValidator(false)->setLabel('Suku')->setRequired(true);
     $elements[] = $this->createElement('textarea', 'location_description')->setDecorators($this->getDefaultElementDecorators())->addFilter('StringTrim')->setAttrib('class', 'm-wrap span12')->setAttrib('rows', 3)->setLabel('Descrição da localização');
     $elements[] = $this->createElement('text', 'phone')->setDecorators($this->getDefaultElementDecorators())->setAttrib('maxlength', 15)->setAttrib('class', 'm-wrap span12 phone-mask')->setLabel('Telefone');
     $elements[] = $this->createElement('text', 'email')->setDecorators($this->getDefaultElementDecorators())->setAttrib('maxlength', 250)->addFilter('StringTrim')->addValidator('EmailAddress')->setAttrib('class', 'm-wrap span12')->setLabel('E-mail');
     $optYear[''] = '';
     for ($year = date('Y'); $year <= date('Y') + 10; $year++) {
         $optYear[$year] = $year;
     }
     $elements[] = $this->createElement('select', 'year_activity')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->addMultiOptions($optYear)->setLabel('Ano esperado de início de atividade')->setRequired(true);
     $elements[] = $this->createElement('select', 'bussines_plan_developer')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setRegisterInArrayValidator(false)->setLabel('Quem desenvolveu plano de negócios?')->setRequired(true);
     $dbTypeEnterprise = App_Model_DbTable_Factory::get('FEFPTypeEnterprise');
     $rows = $dbTypeEnterprise->fetchAll(array(), array('type_enterprise'));
     $optTypeEnterprise[''] = '';
     foreach ($rows as $row) {
         $optTypeEnterprise[$row->id_fefptypeenterprise] = $row->type_enterprise;
     }
     $elements[] = $this->createElement('select', 'fk_id_fefptypeenterprise')->setDecorators($this->getDefaultElementDecorators())->setLabel('Tipo de Empresa')->addMultiOptions($optTypeEnterprise)->setRequired(true)->setAttrib('class', 'm-wrap span12');
     $mapperPce = new External_Model_Mapper_Pce();
     $descriptionFields = $mapperPce->getDescriptionFields();
     $dynamicElements = array();
     foreach ($descriptionFields as $id => $label) {
         $dynamicElements[] = $this->createElement('textarea', $id)->setDecorators($this->getDefaultElementDecorators())->addFilter('StringTrim')->setAttrib('class', 'm-wrap span12')->setAttrib('rows', 3)->setLabel($label)->setBelongsTo('dynamic_fields')->setRequired(false);
     }
     $this->addDisplayGroup($dynamicElements, 'dynamic_fields');
     $amountFields = array('total_expense', 'investiment', 'annual_expense', 'revenue', 'income_incr', 'income_cost', 'sale_tax', 'reserve_fund', 'first_year' => 'PRIMEIRO ANO', 'following_year' => 'ANOS SEGUINTES');
     foreach ($amountFields as $id => $amountField) {
         $label = 'Total';
         $idElement = $id;
         if (is_int($id)) {
             $idElement = $amountField;
         } else {
             $label = $amountField;
         }
         $element = $this->createElement('text', $idElement)->setDecorators($this->getDefaultElementDecorators())->setAttrib('readOnly', true)->setBelongsTo('total_fields')->setAttrib('class', 'm-wrap span12 money-mask total-fields')->setLabel($label);
         if (is_int($id)) {
             $element->removeDecorator('Label');
         }
         $elements[] = $element;
     }
     $this->addElements($elements);
     $this->setDecorators($this->getDefaultFormDecorators());
 }
예제 #2
0
 public function init()
 {
     $this->setAttrib('class', 'horizontal-form')->setName('search');
     $elements = array();
     $dbDistrict = App_Model_DbTable_Factory::get('AddDistrict');
     $districts = $dbDistrict->fetchAll();
     $optCountry[''] = '';
     foreach ($districts as $district) {
         $optCountry[$district['id_adddistrict']] = $district['District'];
     }
     $elements[] = $this->createElement('select', 'fk_id_adddistrict')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->addMultiOptions($optCountry)->setLabel('Distritu');
     $optModule[''] = '';
     $mapperModule = new Fefop_Model_Mapper_Module();
     $rows = $mapperModule->listModules(Fefop_Model_Mapper_Program::PCE);
     foreach ($rows as $row) {
         $optModule[$row['id_fefop_modules']] = $row['num_module'] . ' - ' . $row['module'];
     }
     $elements[] = $this->createElement('select', 'fk_id_fefop_modules')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->addMultiOptions($optModule)->setLabel('Modulu');
     $mapperIsicDivision = new Register_Model_Mapper_IsicDivision();
     $rows = $mapperIsicDivision->listAll();
     $optDivisionTimor[''] = '';
     foreach ($rows as $row) {
         $optDivisionTimor[$row->id_isicdivision] = $row->name_disivion;
     }
     $elements[] = $this->createElement('select', 'fk_id_isicdivision')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Setór atividade nian')->setAttrib('onchange', 'Fefop.PceContract.searchIsicClass(this)')->addMultiOptions($optDivisionTimor);
     $elements[] = $this->createElement('select', 'fk_id_isicclasstimor')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Área negósiu nian')->setRegisterInArrayValidator(false);
     $optPartisipants[''] = '';
     $optPartisipants['S'] = 'Ema ida';
     $optPartisipants['G'] = 'Grupu';
     $elements[] = $this->createElement('select', 'partisipants')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setLabel('Grupu')->addMultiOptions($optPartisipants);
     $mapperPce = new External_Model_Mapper_Pce();
     $rows = $mapperPce->listBeneficiaries();
     $optBeneficiaries[''] = '';
     foreach ($rows as $row) {
         $optBeneficiaries[$row->id_perdata] = Client_Model_Mapper_Client::buildNumRow($row) . ' - ' . Client_Model_Mapper_Client::buildName($row);
     }
     $elements[] = $this->createElement('select', 'bussines_plan_developer')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel("Naran ema ne'ebé dezenvolve Planu Negósiu nian")->addMultiOptions($optBeneficiaries);
     $optIsSubmitted[''] = '';
     $optIsSubmitted['1'] = 'Tiha ona';
     $optIsSubmitted['0'] = 'Seidauk';
     $elements[] = $this->createElement('select', 'submitted')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setLabel('Submit')->addMultiOptions($optIsSubmitted);
     $optIsSubmitted[''] = '';
     $optIsSubmitted['1'] = 'Tiha ona';
     $optIsSubmitted['0'] = 'Seidauk';
     $elements[] = $this->createElement('select', 'contract')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setLabel('Iha Kontratu')->addMultiOptions($optIsSubmitted);
     $this->addElements($elements);
 }
예제 #3
0
 /**
  * 
  */
 public function financialAnalysisAction()
 {
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->_helper->layout()->disableLayout();
     }
     $financialAnalysis = $this->_mapper->financialAnalysis($this->_getAllParams());
     $this->view->financial_analysis = $financialAnalysis;
     $this->view->submitted = $this->_getParam('submitted');
 }
예제 #4
0
 /**
  * 
  */
 public function exportAction()
 {
     $id = $this->_getParam('id');
     $row = $this->_mapper->fetchBusinessPlan($id);
     $contractFiles = array('CEG' => 'Contrato_CEG_tet.xlsx', 'CEC' => 'Contrato_CEC_II_tet.xlsx', 'CED' => 'Contrato_CED_II_tet.xlsx');
     // Fetch Contract
     $mapperContract = new Fefop_Model_Mapper_Contract();
     $contract = $mapperContract->detail($row->fk_id_fefop_contract);
     $data = $row->toArray();
     $data += $contract->toArray();
     $reserve_fund = $this->_mapper->getTotal($id, 'reserve_fund');
     $reserve_fund = $reserve_fund < 1 ? 600 : $reserve_fund;
     $data['contract'] = Fefop_Model_Mapper_Contract::buildNumById($row->fk_id_fefop_contract);
     $data['business_plan'] = External_Model_Mapper_Pce::buildNumRow($row);
     $data['date_inserted'] = $this->view->date($data['date_inserted']);
     $dateInsert = new Zend_Date($data['date_inserted']);
     $data['date_finish'] = $dateInsert->addYear(2)->toString('dd/MM/yyyy');
     $mapperClient = new Client_Model_Mapper_Client();
     $client = $mapperClient->detailClient($row->fk_id_perdata);
     $data['evidence_card'] = Client_Model_Mapper_Client::buildNumRow($client);
     $data['client_name'] = Client_Model_Mapper_Client::buildName($client);
     $data['is_handicapped'] = Client_Model_Mapper_Client::isHandicapped($row->fk_id_perdata);
     $data['electoral'] = $client->electoral;
     $data['gender'] = $client->gender;
     $data['client_fone'] = $client->client_fone;
     $group = array();
     $rowsGroup = $this->_mapper->listClientBusinessPlan($id);
     foreach ($rowsGroup as $rowGroup) {
         $group[] = array('name' => Client_Model_Mapper_Client::buildName($rowGroup), 'evidence_card' => Client_Model_Mapper_Client::buildNumRow($rowGroup), 'electoral' => $client->electoral, 'gender' => $client->gender, 'is_handicapped' => Client_Model_Mapper_Client::isHandicapped($client->id_perdata));
     }
     $expensesRows = $mapperContract->listExpensesContract($row->fk_id_fefop_contract);
     $expenses = array();
     $total = 0;
     foreach ($expensesRows as $expense) {
         $expenses[] = array('name' => $expense->description, 'amount' => (double) $expense->amount);
         $total += (double) $expense->amount;
     }
     $excelPath = APPLICATION_PATH . '/../library/PHPExcel/';
     require_once $excelPath . 'PHPExcel/IOFactory.php';
     $objReader = PHPExcel_IOFactory::createReader('Excel2007');
     $objPHPExcel = $objReader->load(APPLICATION_PATH . '/../public/forms/FEFOP/' . $contractFiles[$data['num_module']]);
     $activeSheet = $objPHPExcel->getActiveSheet();
     $activeSheet->setCellValue('P12', $data['contract']);
     $activeSheet->setCellValue('Q40', $data['business_plan']);
     $activeSheet->setCellValue('T8', $data['date_inserted']);
     $activeSheet->setCellValue('F45', $data['date_inserted']);
     $activeSheet->setCellValue('F46', $data['date_finish']);
     $activeSheet->setCellValue('F16', $data['evidence_card']);
     $activeSheet->setCellValue('F17', $data['electoral']);
     $activeSheet->setCellValue('E19', $data['client_name']);
     $activeSheet->setCellValue('D117', $data['client_name']);
     $activeSheet->setCellValue('Q19', $data['client_fone']);
     $activeSheet->setCellValue('O20', $data['email']);
     $activeSheet->setCellValue('H25', $data['total_partisipants']);
     // Responsible
     $activeSheet->setCellValue('E28', $data['client_name']);
     $activeSheet->setCellValue('M28', $data['evidence_card']);
     $activeSheet->setCellValue('O28', $data['electoral']);
     $activeSheet->setCellValue('Q28', $data['gender']);
     $activeSheet->setCellValue('R28', $data['is_handicapped'] ? 'Sin' : 'Lae');
     $startPerson = 29;
     foreach ($group as $person) {
         $activeSheet->setCellValue('E' . $startPerson, $person['name']);
         $activeSheet->setCellValue('M' . $startPerson, $person['evidence_card']);
         $activeSheet->setCellValue('O' . $startPerson, $person['electoral']);
         $activeSheet->setCellValue('Q' . $startPerson, $person['gender']);
         $activeSheet->setCellValue('R' . $startPerson, $person['is_handicapped'] ? 'Sin' : 'Lae');
         $startPerson++;
     }
     $activeSheet->setCellValue('F38', $data['name_disivion']);
     $activeSheet->setCellValue('L38', $data['name_classtimor']);
     $activeSheet->setCellValue('F40', $data['project_name']);
     $activeSheet->setCellValue('P45', $data['district']);
     $activeSheet->setCellValue('P46', $data['sub_district']);
     $activeSheet->setCellValue('P47', $data['sucu']);
     $startExpense = 52;
     $count = 'A';
     foreach ($expenses as $expense) {
         $activeSheet->setCellValue('B' . $startExpense, $count++);
         $activeSheet->setCellValue('C' . $startExpense, $expense['name']);
         $activeSheet->setCellValue('S' . $startExpense, $expense['amount']);
         $startExpense++;
     }
     $activeSheet->setCellValue('B' . $startExpense, $count++);
     $activeSheet->setCellValue('C' . $startExpense, 'Fundu Maneiu (600 USD + 10% rubrika sira iha leten)');
     $activeSheet->setCellValue('S' . $startExpense, $reserve_fund);
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     $file = sprintf('Contract_%s.xlsx', $data['contract']);
     header(sprintf('Content-Disposition: attachment;filename="%s"', $file));
     header('Cache-Control: max-age=0');
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save('php://output');
     exit;
 }