示例#1
0
 /**
  * 
  */
 public function indexAction()
 {
     $module = $this->_getParam('module');
     if (empty($module)) {
         $this->_helper->redirector->goToSimple('index', 'index', 'external');
     }
     $client = $this->view->session->client->id_perdata;
     $businessPlan = $this->_mapper->fetchBusinessPlanByClient($client, $module);
     if ($businessPlan) {
         $this->view->businessPlan = $businessPlan;
         $this->view->date_ini = $this->view->date($businessPlan->date_inserted);
         $this->view->hasBudgetCategory = $this->_mapper->hasBudgetCategory($businessPlan->id_businessplan);
         if (!$businessPlan->submitted) {
             $this->view->revision = $this->_mapper->getLastRevision($businessPlan->id_businessplan);
         }
         if (!empty($businessPlan->business_group)) {
             $this->view->is_group = true;
         }
         if (!empty($businessPlan->fk_id_fefop_contract)) {
             $mapperContract = new Fefop_Model_Mapper_Contract();
             $this->view->contract = $mapperContract->detail($businessPlan->fk_id_fefop_contract);
         }
     } else {
         $this->view->date_ini = Zend_Date::now()->toString('dd/MM/yyyy');
     }
     $this->view->can_create = $this->_mapper->canCreateBusinessPlan($client, $module);
     $this->view->module = $module;
 }
示例#2
0
 /**
  *
  * @param mixed $contract 
  */
 public function setContract($contract)
 {
     if (!$contract instanceof Zend_Db_Table_Row) {
         $mapperContract = new Fefop_Model_Mapper_Contract();
         $contract = $mapperContract->detail($contract);
     }
     $this->_contract = $contract;
     return $this;
 }
示例#3
0
 /**
  * 
  */
 public function contractAction()
 {
     if ($this->getRequest()->isXMLHTTPRequest()) {
         $this->_helper->layout()->disableLayout();
     }
     $id = $this->_getParam('id');
     if (!empty($id)) {
         $mapperContract = new Fefop_Model_Mapper_Contract();
         $this->view->contract = $mapperContract->detail($id);
     }
 }
示例#4
0
 /**
  *
  * @return string
  * @throws Exception 
  */
 protected function getFefopDir()
 {
     if (empty($this->_data['contract'])) {
         throw new Exception('Tenki informa kliente');
     }
     $dir = APPLICATION_PATH . $this->_ds . '..' . $this->_ds . 'public' . $this->_ds . self::DIR . $this->_ds;
     if (!is_dir($dir)) {
         mkdir($dir);
     }
     $dir .= 'fefop' . $this->_ds;
     if (!is_dir($dir)) {
         mkdir($dir);
     }
     $mapperContract = new Fefop_Model_Mapper_Contract();
     $contract = $mapperContract->detail($this->_data['contract']);
     $dir .= strtolower($contract->num_program) . $this->_ds;
     if (!is_dir($dir)) {
         mkdir($dir);
     }
     $dir .= strtolower($contract->num_module) . $this->_ds;
     if (!is_dir($dir)) {
         mkdir($dir);
     }
     $dir .= md5($this->_data['contract']) . $this->_ds;
     if (!is_dir($dir)) {
         mkdir($dir);
     }
     return realpath($dir) . $this->_ds;
 }
示例#5
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;
 }
示例#6
0
 /**
  * 
  */
 public function contractControlAction()
 {
     $this->_helper->layout()->disableLayout();
     $mapperContract = new Fefop_Model_Mapper_Contract();
     $contract = $mapperContract->detail($this->_getParam('id'));
     $this->view->contract = $contract;
 }
 /**
  * 
  */
 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;
 }
示例#8
0
 /**
  * 
  * @param int $idContract
  * @return boolean
  */
 protected function _tryUpdateStatusContract($idContract)
 {
     $mapperContract = new Fefop_Model_Mapper_Contract();
     $contract = $mapperContract->detail($idContract);
     if (Fefop_Model_Mapper_Status::INITIAL != $contract->id_fefop_status) {
         return false;
     }
     $mapperStatus = new Fefop_Model_Mapper_Status();
     $dataStatus = array('id_fefop_followup' => null, 'contract' => $idContract, 'status' => Fefop_Model_Mapper_Status::PROGRESS, 'description' => 'PRIMEIRO LANSAMENTU FINANSEIRU');
     $mapperStatus->setData($dataStatus)->save();
 }