public function init() { $this->setAttrib('class', 'horizontal-form')->setName('search'); $elements = array(); $mapperFeContract = new Fefop_Model_Mapper_FEContract(); // Combo to search clients $clients = $mapperFeContract->listBeneficiaries(); $optClients[''] = ''; foreach ($clients as $row) { $optClients[$row['id_perdata']] = Client_Model_Mapper_Client::buildNumRow($row) . ' - ' . Client_Model_Mapper_Client::buildName($row); } $elements[] = $this->createElement('select', 'fk_id_perdata')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->addMultiOptions($optClients)->setLabel('Benefisiariu'); // Combo to search enterprises $enterprises = $mapperFeContract->listEnterprises(); $optEnterprises[''] = ''; foreach ($enterprises as $row) { $optEnterprises[$row['id_fefpenterprise']] = $row['enterprise_name']; } $elements[] = $this->createElement('select', 'fk_id_fefpenterprise')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->addMultiOptions($optEnterprises)->setLabel('Empreza'); // Combo to search institutes $intitutes = $mapperFeContract->listInstitutes(); $optInstitutes[''] = ''; foreach ($intitutes as $row) { $optInstitutes[$row['id_fefpeduinstitution']] = $row['institution']; } $elements[] = $this->createElement('select', 'fk_id_fefpeduinstitution')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->addMultiOptions($optInstitutes)->setLabel('Inst. Ensinu'); $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'); $elements[] = $this->createElement('select', 'fk_id_addsubdistrict')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setRegisterInArrayValidator(false)->setLabel('Sub-Distritu'); $mapperScholarityArea = new Register_Model_Mapper_ScholarityArea(); $sections = $mapperScholarityArea->fetchAll(); $optScholarityArea[''] = ''; foreach ($sections as $section) { $optScholarityArea[$section['id_scholarity_area']] = $section['scholarity_area']; } $elements[] = $this->createElement('select', 'fk_id_scholarity_area')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen focused')->setLabel('Area Kursu')->addMultiOptions($optScholarityArea); $dbOccupationTimor = App_Model_DbTable_Factory::get('PROFOcupationTimor'); $occupations = $dbOccupationTimor->fetchAll(); $optOccupations[''] = ''; foreach ($occupations as $occupation) { $optOccupations[$occupation['id_profocupationtimor']] = $occupation['acronym'] . ' ' . $occupation['ocupation_name_timor']; } $elements[] = $this->createElement('select', 'fk_id_profocupationtimor')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Okupasaun')->addMultiOptions($optOccupations); $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); }
/** * */ public function exportAction() { $id = $this->_getParam('id'); $contract = $this->_mapper->detail($id); $data = $contract->toArray(); $data['contract'] = Fefop_Model_Mapper_Contract::buildNumById($contract->fk_id_fefop_contract); $data['evidence'] = Client_Model_Mapper_Client::buildNumById($contract->fk_id_perdata); $data['date_start'] = $this->view->date($data['date_start']); $data['date_finish'] = $this->view->date($data['date_finish']); $data['date_formation'] = $this->view->date($data['date_formation']); $data['date_inserted'] = $this->view->date($data['date_inserted']); $expenses = $this->_mapper->listExpenses($id); $data['expenses'] = $expenses->toArray(); $excelPath = APPLICATION_PATH . '/../library/PHPExcel/'; require_once $excelPath . 'PHPExcel/IOFactory.php'; $objReader = PHPExcel_IOFactory::createReader('Excel2007'); $objPHPExcel = $objReader->load(APPLICATION_PATH . '/../public/forms/FEFOP/Contrato_FE_tet.xlsx'); $activeSheet = $objPHPExcel->getActiveSheet(); $activeSheet->setCellValue('R10', $data['contract']); $activeSheet->setCellValue('V8', $data['date_inserted']); $activeSheet->setCellValue('F15', $data['scholarity_area']); $activeSheet->setCellValue('F16', $data['ocupation_name_timor']); $activeSheet->setCellValue('G21', $data['date_start']); $activeSheet->setCellValue('G22', $data['date_finish']); $activeSheet->setCellValue('K21', (int) $data['duration_month']); $activeSheet->setCellValue('Q21', $data['district']); $activeSheet->setCellValue('Q22', $data['sub_district']); $activeSheet->setCellValue('H28', $data['entity']); $activeSheet->setCellValue('H29', $data['beneficiary']); $activeSheet->setCellValue('E117', $data['beneficiary']); $activeSheet->setCellValue('S29', $data['evidence']); //$activeSheet->setCellValue( 'U28', $data['date_formation'] ); // Expenses $startRow = 34; foreach ($data['expenses'] as $expense) { $activeSheet->setCellValue('D' . $startRow, $expense['description']); $activeSheet->setCellValue('U' . $startRow, $expense['amount']); $startRow++; } 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; }
/** * */ public function editTraineeAction() { $this->_helper->layout()->disableLayout(); // Form Edit Trainee $formEditTrainee = $this->_initForm('editTrainee'); $idTrainee = $this->_getParam('trainee'); $trainee = $this->_mapper->fetchTrainee($idTrainee); $data = $trainee->toArray(); $date = new Zend_Date(); if (!empty($data['date_start'])) { $data['date_start'] = $date->set($data['date_start'])->toString('dd/MM/yyyy'); } if (!empty($data['date_finish'])) { $data['date_finish'] = $date->set($data['date_finish'])->toString('dd/MM/yyyy'); } $formEditTrainee->populate($data); // Fetch the client $mapperClient = new Client_Model_Mapper_Client(); $this->view->client = $mapperClient->detailClient($trainee->fk_id_perdata); if (!$this->view->jobTrainingActive()->hasAccessEdit()) { $formEditTrainee->getElement('save')->setAttrib('disabled', true); } $mapperFeContract = new Fefop_Model_Mapper_FEContract(); $contract = $mapperFeContract->getContractByTrainee($idTrainee); if (!empty($contract)) { $formEditTrainee->getElement('date_start')->setAttrib('readonly', true)->setAttrib('class', 'm-wrap span12'); $formEditTrainee->getElement('date_finish')->setAttrib('readonly', true)->setAttrib('class', 'm-wrap span12 '); $this->view->contract = $contract->fk_id_fefop_contract; } $this->view->form = $formEditTrainee; $this->view->trainee = $trainee; }
/** * * @return Zend_Db_Table_Rowset */ public function feFormationReport() { $mapperFeContract = new Fefop_Model_Mapper_FEContract(); $select = $mapperFeContract->getSelect(); $dbBudgetCategory = App_Model_DbTable_Factory::get('BudgetCategory'); $dbFEFOPTransaction = App_Model_DbTable_Factory::get('FEFOPTransaction'); $select->join(array('bc' => $dbBudgetCategory), 'bc.id_budget_category = bcc.fk_id_budget_category', array('expense' => 'description'))->joinLeft(array('t' => $dbFEFOPTransaction), 't.fk_id_fefop_contract = fec.fk_id_fefop_contract AND t.fk_id_budget_category = bcc.fk_id_budget_category', array('total_spent' => new Zend_Db_Expr("IFNULL(ABS(SUM(t.amount * IF(t.operation = 'D', -1, 1))), 0)")))->where('UPPER(bc.description) LIKE ?', '%Crédito%')->group(array('id_fe_contract'))->order(array('date_formation DESC')); if (!empty($this->_data['fk_id_dec'])) { $select->where('u.fk_id_dec IN(?)', $this->_data['fk_id_dec']); } if (!empty($this->_data['id_adddistrict'])) { $select->where('d.id_adddistrict IN(?)', $this->_data['id_adddistrict']); } if (!empty($this->_data['id_fefop_status'])) { $select->where('cs.id_fefop_status IN(?)', $this->_data['id_fefop_status']); } //Período $select->where("DATE(c.date_inserted) >= STR_TO_DATE(?, '%d/%m/%Y')", $this->_data['date_start']); $select->where("DATE(c.date_inserted) <= STR_TO_DATE(?, '%d/%m/%Y')", $this->_data['date_finish']); return array('rows' => $dbBudgetCategory->fetchAll($select)); }