/** * */ public function certificateAction() { $id = $this->_getParam('id'); $case = $this->_mapper->detailCase($id); $data = array('beneficiary' => Client_Model_Mapper_Client::buildNameById($case->fk_id_perdata), 'evidence' => Client_Model_Mapper_Client::buildNumById($case->fk_id_perdata)); $file = APPLICATION_PATH . '/../public/forms/Kazu/Sertifikadu_Atendimentu.rtf'; App_Util_Export::toRtf($file, $data); }
/** * * @return int|bool */ public function save() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { $date = new Zend_Date($this->_data['date_appointment']); $date->set($this->_data['time_appointment'], Zend_Date::TIME_SHORT); $dataForm = $this->_data; $today = new Zend_Date(); $this->_data['date_appointment'] = $date->toString('yyyy-MM-dd HH:mm'); if (empty($this->_data['id_appointment'])) { if ($date->isEarlier($today)) { $this->_message->addMessage('Erro: Data no Oras ba audiensia uluk data ohin.', App_Message::ERROR); $this->addFieldError('date_appointment')->addFieldError('time_appointment'); return false; } $mapperCase = new Client_Model_Mapper_Case(); $case = $mapperCase->detailCase($this->_data['fk_id_action_plan']); $this->_data['fk_id_perdata'] = $case->fk_id_perdata; $this->_data['appointment_active'] = 1; $this->_data['appointment_filled'] = 0; } // Save the Note $id = parent::_simpleSave(); // Delete and insert all objetives $dbAppointmentObjective = App_Model_DbTable_Factory::get('Appointment_has_Objective'); $where = array($dbAdapter->quoteInto('fk_id_appointment = ?', $id)); $dbAppointmentObjective->delete($where); // Insert the news objectives foreach ($dataForm['objective'] as $objective) { $row = $dbAppointmentObjective->createRow(); $row->fk_id_appointment = $id; $row->fk_id_appointment_objective = $objective; $row->save(); } $dbAdapter->commit(); return $id; } catch (Exception $e) { $dbAdapter->rollBack(); $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR); return false; } }
/** * * @return int|bool */ public function save() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { if (empty($this->_data['id_case_note'])) { $mapperCase = new Client_Model_Mapper_Case(); $case = $mapperCase->detailCase($this->_data['fk_id_action_plan']); $this->_data['fk_id_perdata'] = $case->fk_id_perdata; $this->_data['fk_id_sysuser'] = Zend_Auth::getInstance()->getIdentity()->id_sysuser; } // Save the Note $id = parent::_simpleSave(); $dbAdapter->commit(); return $id; } catch (Exception $e) { $dbAdapter->rollBack(); $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR); return false; } }
/** * * @return array */ protected function _casesClient() { $mapperCase = new Client_Model_Mapper_Case(); $rows = $mapperCase->casesByClient($this->_data['client']); $cases = array(); foreach ($rows as $row) { $cases[md5($row->id_action_plan)] = $row->ocupation_name_timor . ' - ' . $row->name; } return $cases; }
/** * * @param array $data * @return string */ public function geClassShortlist($data) { $mapperStudentClass = new StudentClass_Model_Mapper_StudentClass(); $mapperClient = new Client_Model_Mapper_Client(); $mapperCase = new Client_Model_Mapper_Case(); $class = $mapperStudentClass->detailStudentClass($data['class']); $client = $mapperClient->detailClient($data['client']); $case = $mapperCase->detailCase($data['case']); $view = Zend_Layout::getMvcInstance()->getView(); $link = '<a href="%s" target="_blank">%s</a>'; $className = str_pad($class->id_fefpstudentclass, 5, '0', STR_PAD_LEFT) . ' - ' . $class->class_name; $clientName = Client_Model_Mapper_Client::buildNumRow($client) . ' - ' . Client_Model_Mapper_Client::buildName($client); $aClass = sprintf($link, $view->baseUrl('/student-class/register/edit/id/' . $class->id_fefpstudentclass), $class->name_dec . ' - ' . $className); $aClient = sprintf($link, $view->baseUrl('/client/client/print/id/' . $client->id_perdata), $clientName); $idCase = str_pad($case->id_action_plan, 5, '0', STR_PAD_LEFT); return sprintf(self::JOB_SHORTLIST, $aClient, $idCase, $case->name_dec, $case->name, $aClass, $class->name_dec); }
/** * * @param type $idCase * @return \App_View_Helper_CaseActive */ public function setCase($idCase) { $mapperCase = new Client_Model_Mapper_Case(); $this->_case = $mapperCase->fetchRow($idCase); return $this; }
/** * */ public function listCaseResultAction() { $this->_helper->layout()->disableLayout(); $data = $this->_getAllParams(); $this->view->rows = $this->_mapper->listCasesResult($data); $this->view->caseActiveGroup()->setCase($data['fk_id_action_plan_group']); $mapperCase = new Client_Model_Mapper_Case(); $this->view->optStatus = $mapperCase->getOptionsStatus(); }
/** * * @return int|bool */ public function addClient() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { $rows = $this->listCasesInGroup($this->_data['case_group']); $clientsInGroup = array(); foreach ($rows as $row) { $clientsInGroup[] = $row->fk_id_perdata; } $newClients = array_diff($this->_data['clients'], $clientsInGroup); // If there is now new clients if (empty($newClients)) { $this->_message->addMessage('Kliente hotu iha grupu tiha ona.', App_Message::ERROR); return false; } // Search for the case group $caseGroup = $this->fetchRow($this->_data['case_group']); $dbActionPlanHasGroup = App_Model_DbTable_Factory::get('Action_Plan_has_Group'); $dbActionPlanBarrier = App_Model_DbTable_Factory::get('Action_Plan_Barrier'); $mapperCase = new Client_Model_Mapper_Case(); // Insert the barriers to the new clients $barriers = $this->listBarriers($this->_data['case_group']); // Generate cases for all the clients foreach ($this->_data['clients'] as $client) { $dataCase = array('fk_id_perdata' => $client, 'fk_id_profocupationtimor' => $this->_data['occupation'], 'fk_id_counselor' => $caseGroup->fk_id_counselor, 'type' => 'G'); // Save the CAse $idCase = $mapperCase->setData($dataCase)->saveCase(); $rowCase = $dbActionPlanHasGroup->createRow(); $rowCase->fk_id_action_plan_group = $this->_data['case_group']; $rowCase->fk_id_action_plan = $idCase; $rowCase->save(); // Insert the reamining barriers foreach ($barriers as $barrier) { $data = $barrier->toArray(); unset($data['id_action_barrier']); $rowBarrier = $dbActionPlanBarrier->createRow($data); $rowBarrier->fk_id_action_plan = $idCase; $rowBarrier->fk_id_sysuser = Zend_Auth::getInstance()->getIdentity()->id_sysuser; $rowBarrier->status = Client_Model_Mapper_Case::BARRIER_PENDING; $rowBarrier->save(); } } $history = 'INSERE KLIENTE IHA KAZU GRUPU: %s'; // Save the audit $history = sprintf($history, $this->_data['case_group']); $this->_sysAudit($history); $dbAdapter->commit(); return $this->_data['case_group']; } catch (Exception $e) { $dbAdapter->rollBack(); $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR); return false; } }
/** * */ public function notifyFollowupCase() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { $filters = array('status' => 1); $today = new Zend_Date(); $mapperCase = new Client_Model_Mapper_Case(); $rows = $mapperCase->listByFilters($filters); // Search the user who must receive notes to follow up cases $noteTypeMapper = new Admin_Model_Mapper_NoteType(); $users = $noteTypeMapper->getUsersByNoteType(Admin_Model_Mapper_NoteType::CASE_FOLLOW_UP); $noteModelMapper = new Default_Model_Mapper_NoteModel(); $noteMapper = new Default_Model_Mapper_Note(); foreach ($rows as $row) { $dateCase = new Zend_Date($row->date_start, 'dd/MM/yyyy'); $days = $today->sub($dateCase); $measure = new Zend_Measure_Time($days->toValue(), Zend_Measure_Time::SECOND); $diffDays = $measure->convertTo(Zend_Measure_Time::DAY, 0); $diff = (double) preg_replace('/[^0-9]/i', '', $diffDays); if ($diff % 15 != 0) { continue; } $usersWarning = $users; $usersWarning[] = $row->fk_id_counselor; $dataNote = array('title' => 'HALO AKOMPAÑAMENTU KAZU HO KLIENTE', 'level' => 0, 'message' => $noteModelMapper->getFollowUpCase($row->client), 'users' => $usersWarning); $noteMapper->setData($dataNote)->saveNote(); } $dbAdapter->commit(); return true; } catch (Exception $e) { $dbAdapter->rollBack(); echo "Error sending cases follow-ups notifications: " . $e->getMessage() . "\n"; return false; } }