/** * */ public function notifyClassExpired() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { // Search all the expired classes $studentClassMapper = new StudentClass_Model_Mapper_StudentClass(); $selectClass = $studentClassMapper->getSelectClass(); $selectClass->where('sc.active = ?', 1)->where('sc.schedule_finish_date < ?', Zend_Date::now()->toString('yyyy-MM-dd')); $dbStudentClass = App_Model_DbTable_Factory::get('FEFPStudentClass'); $rows = $dbStudentClass->fetchAll($selectClass); // Search the user who must receive notes when class are expired $noteTypeMapper = new Admin_Model_Mapper_NoteType(); $users = $noteTypeMapper->getUsersByNoteType(Admin_Model_Mapper_NoteType::CLASS_EXPIRED); $noteModelMapper = new Default_Model_Mapper_NoteModel(); $noteMapper = new Default_Model_Mapper_Note(); foreach ($rows as $row) { $dataNote = array('title' => 'KLASE LORON REMATA LIU TIHA ONA', 'level' => 0, 'message' => $noteModelMapper->getClassExpired($row->id_fefpstudentclass), 'users' => $users); $noteMapper->setData($dataNote)->saveNote(); } $dbAdapter->commit(); return true; } catch (Exception $e) { $dbAdapter->rollBack(); echo "Error sending class expired notifications: " . $e->getMessage() . "\n"; return false; } }
/** * * @return array */ public function getDataClassIndmo() { $dbStudentClassSent = App_Model_DbTable_Factory::get('StudentClass_Sent'); $rows = $dbStudentClassSent->fetchAll(array('sent = ?' => 0)); $mapperStudentClass = new StudentClass_Model_Mapper_StudentClass(); $mapperScholarity = new Register_Model_Mapper_PerScholarity(); $classes = array(); foreach ($rows as $row) { $class = $mapperStudentClass->detailStudentClass($row->fk_id_fefpstudentclass); $course = $mapperScholarity->fetchRow($class->fk_id_perscholarity); $dataClass = array('id' => $class->id_fefpstudentclass, 'title' => $class->class_name, 'start_date' => $class->start_date, 'finish_date' => $class->schedule_finish_date, 'qualification' => $course->remote_id, 'training_provider' => $class->num_register, 'id_training_provider' => $class->fk_id_fefpeduinstitution); $students = $mapperStudentClass->listClientClass($row->fk_id_fefpstudentclass); $studentsClass = array(); foreach ($students as $student) { $dataStudent = array('id' => $student->id_perdata, 'first_name' => $student->first_name, 'second_name' => $student->medium_name, 'evidence' => Client_Model_Mapper_Client::buildNumRow($student), 'last_name' => $student->last_name, 'district' => $student->num_district, 'sub_district' => $student->num_subdistrict, 'birth_date' => $student->birth_date, 'gender' => $student->gender, 'email' => $student->email, 'tel' => $student->client_fone, 'result' => $student->status_class, 'competencies' => array()); $competencies = $mapperStudentClass->listCompetencyClass($row->fk_id_fefpstudentclass, $student->id_perdata); foreach ($competencies as $competency) { $dataStudent['competencies'][] = array('id' => $competency->id_external, 'code' => $competency->external_code, 'result' => $competency->status); } $studentsClass[] = $dataStudent; } $dataClass['students'] = $studentsClass; $classes[] = $dataClass; } return $classes; }
/** * * @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); }
/** * */ public function classClientAction() { $this->_helper->layout()->disableLayout(); $mapperStudentClass = new StudentClass_Model_Mapper_StudentClass(); $class = $mapperStudentClass->detailStudentClass($this->_getParam('class')); $this->view->class = $class; }
/** * * @return Zend_Db_Table_Rowset */ public function listStudentClassContract() { $mapperStudentClasss = new StudentClass_Model_Mapper_StudentClass(); $select = $mapperStudentClasss->getSelectClass(); $dbPCEContract = App_Model_DbTable_Factory::get('PCEContract'); $select->join(array('pcc' => $dbPCEContract), 'pcc.fk_id_fefpstudentclass = sc.id_fefpstudentclass', array())->group(array('id_fefpstudentclass')); return $dbPCEContract->fetchAll($select); }
/** * */ public function fetchClassAction() { $mapperStudentClass = new StudentClass_Model_Mapper_StudentClass(); $studentClass = $mapperStudentClass->detailStudentClass($this->_getParam('id')); $data = array(); $data['fk_id_fefpstudentclass'] = $studentClass['id_fefpstudentclass']; $data['class_name'] = $studentClass['class_name']; $data['date_start'] = $this->view->date($studentClass['start_date']); $data['date_finish'] = $this->view->date($studentClass['schedule_finish_date']); $dateInit = new Zend_Date($studentClass['start_date']); $dateFinish = new Zend_Date($studentClass['schedule_finish_date']); $diff = $dateFinish->sub($dateInit); $measure = new Zend_Measure_Time($diff->toValue(), Zend_Measure_Time::SECOND); $diffDays = $measure->convertTo(Zend_Measure_Time::DAY, 0); $data['duration'] = preg_replace('/[^0-9]/i', '', $diffDays); $this->_helper->json($data); }
/** * */ public function trainingListAction() { $mapperStudentClass = new StudentClass_Model_Mapper_StudentClass(); $filters = array('active' => 1); $this->view->rows = $mapperStudentClass->listByFilters($filters); }
/** * * @param int $barrier * @return Zend_Db_Table_Rowset */ public function listClassIntervention($intervention, $case) { $mapperStudentClass = new StudentClass_Model_Mapper_StudentClass(); $selectStudentClass = $mapperStudentClass->getSelectClass(); $dbActionPlanBarrier = App_Model_DbTable_Factory::get('Action_Plan_Barrier'); $dbActionPlanReferences = App_Model_DbTable_Factory::get('Action_Plan_References'); $dbActionpPlanHasGroup = App_Model_DbTable_Factory::get('Action_Plan_has_Group'); $selectStudentClass->join(array('apr' => $dbActionPlanReferences), 'apr.fk_id_fefpstudentclass = sc.id_fefpstudentclass', array())->join(array('apb' => $dbActionPlanBarrier), 'apb.id_action_barrier = apr.fk_id_action_barrier', array())->join(array('apg' => $dbActionpPlanHasGroup), 'apg.fk_id_action_plan = apb.fk_id_action_plan', array())->where('apg.fk_id_action_plan_group = ?', $case)->where('apb.fk_id_barrier_intervention = ?', $intervention)->group(array('id_fefpstudentclass')); return $dbActionPlanReferences->fetchAll($selectStudentClass); }
/** * * @param type $idStudentClass * @return \App_View_Helper_StudentClassActive */ public function setStudentClass($idStudentClass) { $mapperStudentClass = new StudentClass_Model_Mapper_StudentClass(); $this->_studentClass = $mapperStudentClass->fetchRow($idStudentClass); return $this; }
/** * */ public function calcUnitCostAction() { $cost = App_General_String::toFloat($this->_getParam('cost')); $idClass = $this->_getParam('id_class'); $mapperStudentClass = new StudentClass_Model_Mapper_StudentClass(); $clients = $mapperStudentClass->listClientClass($idClass); $data = array('total' => 0, 'costs' => array(), 'man' => 0, 'woman' => 0); if ($clients->count()) { foreach ($clients as $client) { $value = $cost; if (!empty($client->id_handicapped)) { $value = $value * 1.25; } $data['costs'][$client->id_perdata] = number_format($value, 2, '.', ','); $data['total'] += $value; if ('MANE' == $client->gender) { $data['man']++; } else { $data['woman']++; } } $womanPercentage = floor($data['woman'] * 100 / $clients->count()); if ($womanPercentage >= 40 && $womanPercentage <= 70) { $data['total'] = $data['total'] * 1.1; } } $data['total'] = number_format($data['total'], 2, '.', ','); $this->_helper->json($data); }
/** * * @return int|bool */ public function clientClass() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { $dbStudentClassCandidates = App_Model_DbTable_Factory::get('StudentClass_Candidates'); $dbPersonHistory = App_Model_DbTable_Factory::get('Person_History'); $dbActionPlanReferences = App_Model_DbTable_Factory::get('Action_Plan_References'); // Fetch the case $case = $this->fetchRow($this->_data['id']); // Fetch the class $mapperStudentClass = new StudentClass_Model_Mapper_StudentClass(); $studentClass = $mapperStudentClass->fetchRow($this->_data['idClass']); if ($studentClass->active != 1) { $this->_message->addMessage('Klase Formasaun ida ne\'e taka tiha ona, la bele tau kliente iha lista kandidatu.', App_Message::ERROR); return false; } $where = array('fk_id_fefpstudentclass = ?' => $this->_data['idClass'], 'fk_id_perdata = ?' => $case->fk_id_perdata); $hasCandidateList = $dbStudentClassCandidates->fetchRow($where); // If the candidate is already in candidate list if (!empty($hasCandidateList)) { $this->_message->addMessage('Kliente iha Lista Kandidatu tiha ona ba klase formasaun ida ne\'e.', App_Message::ERROR); return false; } // Add the client to the list candidates $row = $dbStudentClassCandidates->createRow(); $row->fk_id_fefpstudentclass = $this->_data['idClass']; $row->fk_id_perdata = $case->fk_id_perdata; $row->fk_id_sysuser = Zend_Auth::getInstance()->getIdentity()->id_sysuser; $row->shortlisted = 0; $row->source = 'C'; $row->save(); // Save history to client $rowHistory = $dbPersonHistory->createRow(); $rowHistory->fk_id_perdata = $case->fk_id_perdata; $rowHistory->fk_id_student_class = $this->_data['idClass']; $rowHistory->fk_id_sysuser = Zend_Auth::getInstance()->getIdentity()->id_sysuser; $rowHistory->fk_id_dec = Zend_Auth::getInstance()->getIdentity()->fk_id_dec; $rowHistory->date_time = Zend_Date::now()->toString('yyyy-MM-dd HH:mm'); $rowHistory->action = sprintf('KLIENTE SELECIONADO BA LISTA KANDIDATU TURMA TREINAMENTU NUMERO: %s ', $this->_data['idClass']); $rowHistory->description = 'KLIENTE SELECIONADO BA LISTA KANDIDATU TURMA TREINAMENTU NUMERO'; $rowHistory->save(); // Save the auditing $history = sprintf('KLIENTE BA LISTA KANDIDATU: %s - BA TURMA TREINAMENTU NUMERU: %s ', $case->fk_id_perdata, $this->_data['idClass']); $this->_sysAudit($history); // Insert the reference to the action barrier $rowReference = $dbActionPlanReferences->createRow(); $rowReference->fk_id_perdata = $case->fk_id_perdata; $rowReference->fk_id_action_plan = $this->_data['id']; $rowReference->fk_id_action_barrier = $this->_data['barrier']; $rowReference->fk_id_sysuser = Zend_Auth::getInstance()->getIdentity()->id_sysuser; $rowReference->fk_id_fefpstudentclass = $this->_data['idClass']; $rowReference->save(); $dbAdapter->commit(); return $this->_data['id']; } catch (Exception $e) { $dbAdapter->rollBack(); $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR); return false; } }