/** * * @return boolean */ public function sendClassIndmo() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { $classes = $this->getDataClassIndmo(); if (empty($classes)) { return true; } $dataIndmo = array('classes' => serialize($classes)); $response = App_Util_Indmo::request('api/class', $dataIndmo); $dbStudentClassSent = App_Model_DbTable_Factory::get('StudentClass_Sent'); $trainingProvider = array(); foreach ($classes as $class) { if (!empty($response['classnotfound']) && in_array($class['id'], $response['classnotfound'])) { $trainingProvider[] = $class['id_training_provider']; continue; } $where = array('fk_id_fefpstudentclass = ?' => $class['id'], 'sent = ?' => 0); $row = $dbStudentClassSent->fetchRow($where); $row->date_sent = Zend_Date::now()->toString('yyyy-MM-dd HH:mm'); $row->sent = empty($response['status']) ? 0 : 1; if (!empty($response['msg'])) { $row->log = $response; } $row->save(); } if (!empty($trainingProvider)) { // Search the user who must receive notes when training provider was not found at INDMO $noteTypeMapper = new Admin_Model_Mapper_NoteType(); $users = $noteTypeMapper->getUsersByNoteType(Admin_Model_Mapper_NoteType::TP_NOT_FOUND); $noteModelMapper = new Default_Model_Mapper_NoteModel(); $noteMapper = new Default_Model_Mapper_Note(); $dataNote = array('title' => 'SENTRU FORMASAUN LA REJISTRADU', 'level' => 0, 'message' => $noteModelMapper->getTrainingProviderNotFound($trainingProvider), 'users' => $users); $noteMapper->setData($dataNote)->saveNote(); } $dbAdapter->commit(); return true; } catch (Exception $e) { $dbAdapter->rollBack(); echo 'Error sending classes: ' . $e->getMessage(); return false; } }
/** * * @return boolean */ public function sendQualification() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { $qualifications = array(array('nome' => 'Sertifikadu II iha Administrasaun TESTE', 'id' => 31, 'codigo' => 'ADFAD113', 'nivel' => 3, 'competencies' => array(array('nome' => 'Uza pratika serbisu neebé sustentavel ba ambiente', 'id' => '10', 'codigo' => 'ADFAD1001A'), array('nome' => 'Halao prosedimentu kleriku', 'id' => '12', 'codigo' => 'ADFJT4002A'))), array('nome' => 'Sertifikadu III iha Servisus Finanseiru', 'id' => 55, 'codigo' => 'ADFSF311', 'nivel' => 4, 'competencies' => array(array('nome' => 'Jere ita-nia dezempeñu profisionál rasik', 'id' => '17', 'codigo' => 'ADFJT4001A'), array('nome' => 'Maneja no ekilibra osan-kontadu', 'id' => '25', 'codigo' => 'ADFSF3004A')))); $response = App_Util_Indmo::request('cron/api/qualification', array('qualifications' => $qualifications)); $dbAdapter->commit(); return true; } catch (Exception $e) { $dbAdapter->rollBack(); echo 'Error sending qualifications: ' . $e->getMessage(); return false; } }