Example #1
0
 public function init()
 {
     $this->setAttrib('class', 'horizontal-form')->setName('search');
     $elements = array();
     $elements[] = $this->createElement('hidden', 'minimum_amount')->setValue(0)->setDecorators(array('ViewHelper'));
     $elements[] = $this->createElement('hidden', 'maximum_amount')->setValue(100000)->setDecorators(array('ViewHelper'));
     $mapperPceFase = new Fefop_Model_Mapper_PCEContract();
     $studentClasses = $mapperPceFase->listStudentClassContract();
     $optStudentClass[''] = '';
     foreach ($studentClasses as $class) {
         $optStudentClass[$class['id_fefpstudentclass']] = $class['class_name'];
     }
     $elements[] = $this->createElement('select', 'fk_id_fefpstudentclass')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->addMultiOptions($optStudentClass)->setLabel('Formasaun Profisional');
     $elements[] = $this->createElement('text', 'beneficiary')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setLabel('Benefisiariu');
     $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')->addMultiOptions($optCountry)->setLabel('Distritu');
     $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('Setor de Atividade')->addMultiOptions($optDivisionTimor);
     $elements[] = $this->createElement('select', 'fk_id_isicclasstimor')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Atividade de Negócio');
     $elements[] = $this->createElement('text', 'date_start')->setDecorators($this->getDefaultElementDecorators())->setAttrib('maxlength', 10)->setAttrib('class', 'm-wrap span12 date-mask date')->setLabel('Loron Inisiu');
     $elements[] = $this->createElement('text', 'date_finish')->setDecorators($this->getDefaultElementDecorators())->setAttrib('maxlength', 10)->setAttrib('class', 'm-wrap span12 date-mask date')->setLabel('Loron Remata');
     $this->addElements($elements);
 }
Example #2
0
 /**
  * 
  * @param int $client
  * @return boolean
  */
 public function canCreateBusinessPlan($client, $module)
 {
     if (Fefop_Model_Mapper_Module::CEG == $module) {
         return true;
     }
     $mapperPceFase = new Fefop_Model_Mapper_PCEContract();
     $select = $mapperPceFase->getSelect();
     $select->where('pcc.fk_id_perdata = ?', $client)->where('pcc.fk_id_fefop_modules = ?', $module);
     $row = $this->_dbTable->fetchRow($select);
     return !empty($row);
 }
Example #3
0
 /**
  * 
  */
 public function exportAction()
 {
     $id = $this->_getParam('id');
     $row = $this->_mapper->detail($id);
     $contractFiles = array('CEC' => 'Contrato_CEC_I_tet.xlsx', 'CED' => 'Contrato_CED_I_tet.xlsx');
     // Fetch Contract
     $mapperContract = new Fefop_Model_Mapper_Contract();
     $contract = $mapperContract->detail($row->fk_id_fefop_contract);
     $data = $row->toArray();
     $data += $contract->toArray();
     $data['contract'] = Fefop_Model_Mapper_Contract::buildNumById($row->fk_id_fefop_contract);
     $data['date_inserted'] = $this->view->date($data['date_inserted']);
     $data['date_start'] = $this->view->date($data['date_start'], 'yyyy-M-dd');
     $data['date_finish'] = $this->view->date($data['date_finish'], 'yyyy-M-dd');
     $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['electoral'] = $client->electoral;
     $data['gender'] = $client->gender;
     $data['client_fone'] = $client->client_fone;
     $data['email'] = $client->email;
     $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('T8', $data['date_inserted']);
     $activeSheet->setCellValue('F16', $data['evidence_card']);
     $activeSheet->setCellValue('F17', $data['electoral']);
     $activeSheet->setCellValue('E19', $data['client_name']);
     $activeSheet->setCellValue('D100', $data['client_name']);
     $activeSheet->setCellValue('Q19', $data['client_fone']);
     $activeSheet->setCellValue('O20', $data['email']);
     $activeSheet->setCellValue('F25', $data['name_disivion']);
     $activeSheet->setCellValue('L25', $data['name_classtimor']);
     $activeSheet->setCellValue('F27', $data['scholarity']);
     $activeSheet->setCellValue('Q27', $data['external_code']);
     $activeSheet->setCellValue('F29', $data['class_name']);
     //$activeSheet->setCellValue( 'Q23', (float)$data['amount_training'] );
     $activeSheet->setCellValue('F33', $data['date_start']);
     $activeSheet->setCellValue('F34', $data['date_finish']);
     //$activeSheet->setCellValue( 'J27', $data['duration'] . ' days' );
     $activeSheet->setCellValue('P33', $data['district_course']);
     $activeSheet->setCellValue('P34', $data['sub_district']);
     $startExpense = 40;
     $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( 'S' . $startExpense, $total );
     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;
 }