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 init() { $this->setAttrib('class', 'horizontal-form')->setName('search'); $elements = array(); $mapperFeRegistration = new Fefop_Model_Mapper_FERegistration(); // Combo to search clients $clients = $mapperFeRegistration->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 = $mapperFeRegistration->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 = $mapperFeRegistration->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'); $optIdentifier = array('selected' => "Formasaun iha servisu fatin ne'ebe hakarak"); $elements[] = $this->createElement('select', 'identifier')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen focused')->setLabel('Formasaun')->addMultiOptions($optIdentifier); $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('Dezignasaun')->addMultiOptions($optOccupations); $dbScholarityLevel = App_Model_DbTable_Factory::get('PerLevelScholarity'); $levels = $dbScholarityLevel->fetchAll(array(), array('id_perlevelscholarity')); $optLevel[''] = ''; foreach ($levels as $level) { $optLevel[$level->id_perlevelscholarity] = $level->level_scholarity; } $elements[] = $this->createElement('select', 'fk_id_perlevelscholarity')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->addMultiOptions($optLevel)->setLabel('Nivel'); $this->addElements($elements); }
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); }
/** * */ public function indexAction() { $id = $this->_getParam('id'); if (empty($id)) { $stepBreadCrumb = array('label' => 'Rejistu Foun', 'url' => 'client/client'); } else { $stepBreadCrumb = array('label' => 'Edita Rejistu', 'url' => 'client/client/edit/id/' . $id); $row = $this->_mapper->detailClient($id); if (empty($row)) { $this->_helper->redirector->goToSimple('index'); } $this->view->client = $row; $this->view->title()->setSubTitle(Client_Model_Mapper_Client::buildName($row)); } $this->view->id = $id; $this->view->breadcrumb()->addStep($stepBreadCrumb); }
/** * */ public function fetchClientAction() { $mapperClient = new Client_Model_Mapper_Client(); $client = $mapperClient->detailClient($this->_getParam('id')); $data = $client->toArray(); $data['fk_id_perdata'] = $data['id_perdata']; $data['staff_name'] = Client_Model_Mapper_Client::buildName($client); $data['birth_date'] = $data['birth_date_format']; $data['gender'] = substr($data['gender'], 0, 1); $this->_helper->json($data); }
/** * * @param int $client * @param int $idJobTraining * @return string */ public function getFollowUpJob($client) { $view = Zend_Layout::getMvcInstance()->getView(); $mapperClient = new Client_Model_Mapper_Client(); $client = $mapperClient->detailClient($client); $link = '<a href="%s" target="_blank">%s</a>'; $clientName = Client_Model_Mapper_Client::buildNumRow($client) . ' - ' . Client_Model_Mapper_Client::buildName($client); $aClient = sprintf($link, $view->baseUrl('/client/client/view/id/' . $client->id_perdata), $clientName); return sprintf(self::JOB_FOLLOW_UP, $aClient, $client->client_fone, $client->email); }
/** * */ public function fetchClientAction() { $mapperClient = new Client_Model_Mapper_Client(); $client = $mapperClient->detailClient($this->_getParam('id')); $data = array(); $data['fk_id_perdata'] = $client['id_perdata']; $data['beneficiary'] = Client_Model_Mapper_Client::buildName($client); $this->_helper->json($data); }
/** * */ 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; }
/** * */ public function fetchTraineeAction() { $id = $this->_getParam('id'); $mapperJobTraining = new StudentClass_Model_Mapper_JobTraining(); $trainee = $mapperJobTraining->fetchTrainee($id); $data = array(); $mapperClient = new Client_Model_Mapper_Client(); $client = $mapperClient->detailClient($trainee->fk_id_perdata); $contract = $this->_mapper->getContractByTrainee($id); if (!empty($contract)) { $data['valid'] = false; } else { $data['valid'] = true; $data['fk_id_trainee'] = $trainee->id_trainee; $data['fk_id_fefpenterprise'] = $trainee->fk_id_fefpenterprise; $data['fk_id_fefpeduinstitution'] = $trainee->fk_id_fefpeduinstitution; $data['entity'] = $trainee->entity; $data['fk_id_scholarity_area'] = $trainee->fk_id_scholarity_area; $data['beneficiary'] = Client_Model_Mapper_Client::buildName($client); $data['fk_id_perdata'] = $trainee->fk_id_perdata; $data['date_start'] = $trainee->date_start_formated; $data['date_finish'] = $trainee->date_finish_formated; $data['duration_month'] = $trainee->duration; } $this->_helper->json($data); }
/** * */ public function formAction() { $id = $this->_getParam('id'); $mapperClient = new Client_Model_Mapper_Client(); if (empty($id)) { $idClient = $this->_getParam('client'); if (empty($idClient)) { $this->_helper->redirector->goToSimple('list', 'client'); } $client = $mapperClient->detailClient($idClient); if (!empty($client->case)) { $this->_helper->redirector->goToSimple('form', 'case', 'client', array('id' => $client->id_action_plan)); } $stepBreadCrumb = array('label' => 'Rejistu Foun', 'url' => 'client/case'); } else { $stepBreadCrumb = array('label' => 'Edita Rejistu Kazu', 'url' => 'client/case/edit/id/' . $id); $row = $this->_mapper->fetchRow($id); if (empty($row)) { $this->_helper->redirector->goToSimple('list', 'client'); } $client = $mapperClient->detailClient($row->fk_id_perdata); } $this->view->title()->setSubTitle(Client_Model_Mapper_Client::buildName($client)); $this->view->client = $client; $this->view->id = $id; $this->view->breadcrumb()->addStep($stepBreadCrumb); }
/** * */ 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; }
/** * */ public function businessPlanAction() { $id = $this->_getParam('id'); if (empty($id)) { $this->_helper->redirector->goToSimple('index', 'index', 'external'); } if ($this->getRequest()->isXmlHttpRequest()) { $this->_helper->layout()->disableLayout(); } $formBusinessPlan = new External_Form_BusinessPlan(); $formBusinessPlan->setAction($this->_helper->url('save-business-plan')); $businessPlan = $this->_mapper->fetchBusinessPlan($id); // Prepare Subdistrict SELECT Option $mapperSubDistrict = new Register_Model_Mapper_AddSubDistrict(); $rowsSubdistrict = $mapperSubDistrict->listAll($businessPlan->fk_id_adddistrict); $rows = array('' => ''); foreach ($rowsSubdistrict as $subDistrict) { $rows[$subDistrict->id_addsubdistrict] = $subDistrict->sub_district; } $formBusinessPlan->getElement('fk_id_addsubdistrict')->addMultiOptions($rows); // Prepare Business Plan Owner Select $rowOwner = array($businessPlan->fk_id_perdata => Client_Model_Mapper_Client::buildNameById($businessPlan->fk_id_perdata)); $clientsBusinessPlan = $this->_mapper->listClientBusinessPlan($id); foreach ($clientsBusinessPlan as $client) { $rowOwner[$client->id_perdata] = Client_Model_Mapper_Client::buildName($client); } $formBusinessPlan->getElement('bussines_plan_developer')->addMultiOptions($rowOwner); $data = $businessPlan->toArray(); $formBusinessPlan->populate($data); $this->view->formBusiness = $formBusinessPlan; $this->view->businessPlan = $businessPlan; $mapperBudgetCategory = new Fefop_Model_Mapper_Expense(); $expenses = $mapperBudgetCategory->expensesInModule($businessPlan->fk_id_fefop_modules); $initial_expense = $mapperBudgetCategory->expensesInItem(Fefop_Model_Mapper_Expense::CONFIG_PCE_INITIAL); $annual_expense = $mapperBudgetCategory->expensesInItem(Fefop_Model_Mapper_Expense::CONFIG_PCE_ANNUAL); $revenue_expense = $mapperBudgetCategory->expensesInItem(Fefop_Model_Mapper_Expense::CONFIG_PCE_REVENUE); $this->view->expenses = $this->_mapper->aggregateExpenses($expenses, $businessPlan, $mapperBudgetCategory->getModuleToItem($businessPlan->fk_id_fefop_modules)); $this->view->initial_expense = $this->_mapper->aggregateExpenses($initial_expense, $businessPlan, Fefop_Model_Mapper_Expense::CONFIG_PCE_INITIAL); $this->view->annual_expense = $this->_mapper->aggregateExpenses($annual_expense, $businessPlan, Fefop_Model_Mapper_Expense::CONFIG_PCE_ANNUAL); $this->view->revenue_expense = $this->_mapper->aggregateExpenses($revenue_expense, $businessPlan, Fefop_Model_Mapper_Expense::CONFIG_PCE_REVENUE); // Populate form $this->_populateFormBusinessPlan($formBusinessPlan, $businessPlan); if (!empty($data['submitted']) || !empty($businessPlan->business_group)) { foreach ($formBusinessPlan->getElements() as $element) { $element->setAttrib('disabled', true); } $this->view->no_edit = true; } $can_create = $this->_mapper->canCreateBusinessPlan($data['fk_id_perdata'], $data['fk_id_fefop_modules']); if (!$can_create) { foreach ($formBusinessPlan->getElements() as $element) { $element->setAttrib('disabled', true); } } $this->view->can_create = $can_create; }
/** * */ 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['date_start'] = $this->view->date($data['date_start']); $data['date_finish'] = $this->view->date($data['date_finish']); $data['date_inserted'] = $this->view->date($data['date_inserted']); $mapperInstitute = new Register_Model_Mapper_EducationInstitute(); $contacts = $mapperInstitute->listContacts($contract->fk_id_fefpeduinstitution)->toArray(); $beneficiaries = $this->_mapper->listBeneficiaries($id)->toArray(); foreach ($beneficiaries as $key => $beneficiary) { $beneficiaries[$key]['complete_nane'] = Client_Model_Mapper_Client::buildName($beneficiary); $beneficiaries[$key]['evidence'] = Client_Model_Mapper_Client::buildNumRow($beneficiary); } $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_FP_tet.xlsx'); $activeSheet = $objPHPExcel->getActiveSheet(); $activeSheet->setCellValue('S14', $data['contract']); $activeSheet->setCellValue('W12', $data['date_inserted']); $activeSheet->setCellValue('E17', $data['scholarity']); $activeSheet->setCellValue('O17', $data['level_scholarity']); $activeSheet->setCellValue('S17', $data['class_name']); $activeSheet->setCellValue('E20', $data['district']); $activeSheet->setCellValue('Q20', $data['date_start']); $activeSheet->setCellValue('Q21', $data['date_finish']); #$activeSheet->setCellValue( 'F10', $data['institute'] ); if (!empty($contacts)) { $activeSheet->setCellValue('G24', $contacts[0]['contact_name']); $activeSheet->setCellValue('S24', $contacts[0]['cell_fone']); $activeSheet->setCellValue('S25', $contacts[0]['email']); } $activeSheet->setCellValue('R31', $data['unit_cost']); $activeSheet->setCellValue('J29', count($beneficiaries)); $activeSheet->setCellValue('R29', $data['amount']); $startRow = 34; foreach ($beneficiaries as $beneficiary) { $activeSheet->setCellValue('F' . $startRow, $beneficiary['complete_nane']); $activeSheet->setCellValue('L' . $startRow, $beneficiary['evidence']); $activeSheet->setCellValue('N' . $startRow, $beneficiary['electoral']); $activeSheet->setCellValue('P' . $startRow, $beneficiary['gender']); $activeSheet->setCellValue('Q' . $startRow, empty($beneficiary['id_handicapped']) ? 'Lae' : 'Sin'); $activeSheet->setCellValue('R' . $startRow, $beneficiary['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; }