Beispiel #1
0
 /**
  *
  * @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;
     }
 }
Beispiel #2
0
 /**
  * 
  * @param int $idRiContract
  */
 protected function _sendWarningDuration($idRiContract)
 {
     // Search the user who must receive notes when the duration is ultrapassed
     $noteTypeMapper = new Admin_Model_Mapper_NoteType();
     $users = $noteTypeMapper->getUsersByNoteType(Admin_Model_Mapper_NoteType::RI_DURATION_GREATER);
     $noteModelMapper = new Default_Model_Mapper_NoteModel();
     $noteMapper = new Default_Model_Mapper_Note();
     $dataNote = array('title' => 'RI KONTRATU HO DURASAUN KLEUR', 'level' => 0, 'message' => $noteModelMapper->getRIGreaterDuration($this->detail($idRiContract)), 'users' => $users);
     $noteMapper->setData($dataNote)->saveNote();
 }
Beispiel #3
0
 /**
  * 
  */
 public function listByUserRowsAction()
 {
     $id = Zend_Auth::getInstance()->getIdentity()->id_sysuser;
     $this->view->rows = $this->_mapper->listAllNotesByUser($id);
 }
Beispiel #4
0
 /**
  * 
  * @return int|bool
  */
 public function saveClose()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dbShortlist = App_Model_DbTable_Factory::get('ShortlistVacancy');
         $dbHired = App_Model_DbTable_Factory::get('Hired');
         $dbVacancy = App_Model_DbTable_Factory::get('JOBVacancy');
         $dbPerData = App_Model_DbTable_Factory::get('PerData');
         $dbPerExperience = App_Model_DbTable_Factory::get('PerExperience');
         $dbPersonHistory = App_Model_DbTable_Factory::get('Person_History');
         $dbActionPlanReferences = App_Model_DbTable_Factory::get('Action_Plan_References');
         $dbActionPlanBarrier = App_Model_DbTable_Factory::get('Action_Plan_Barrier');
         $dbJobCandidates = App_Model_DbTable_Factory::get('JOBVacancy_Candidates');
         $dataForm = $this->_data;
         // Check if the clients selected are the same quantity defined in the vacancy
         $vacancy = $this->detailVacancy($this->_data['fk_id_jobvacancy']);
         if (count($this->_data['clients']) != $vacancy->num_position) {
             $this->_message->addMessage(sprintf('Tenki seleciona Kliente %s deit ba Kontratasaun!', $vacancy->num_position), App_Message::ERROR);
             return false;
         }
         // Close the vacancy
         $this->_data = array('id_jobvacancy' => $this->_data['fk_id_jobvacancy'], 'close_date' => Zend_Date::now()->toString('yyyy-MM-dd'), 'active' => 0);
         parent::_simpleSave($dbVacancy, false);
         // Insert the Auditing
         $history = 'TAKA VAGA EMPREGU NUMERU: %s ';
         $history = sprintf($history, $dataForm['fk_id_jobvacancy']);
         $this->_sysAudit($history, Job_Form_VacancyClose::ID);
         $now = Zend_Date::now()->toString('yyyy-MM-dd');
         $noteMapper = new Default_Model_Mapper_Note();
         $noteModelMapper = new Default_Model_Mapper_NoteModel();
         // Insert clients as hired
         foreach ($dataForm['clients'] as $client) {
             // Update short list setting client selected
             $whereShortlist = array('fk_id_jobvacancy = ?' => $dataForm['fk_id_jobvacancy'], 'fk_id_perdata = ?' => $client);
             $dbShortlist->update(array('selected' => 1), $whereShortlist);
             // Insert client as hired
             $this->_data = array('fk_id_jobvacancy' => $dataForm['fk_id_jobvacancy'], 'fk_id_perdata' => $client, 'result_date' => $now);
             parent::_simpleSave($dbHired, false);
             $dbPerData->update(array('hired' => 1), array('id_perdata = ?' => $client));
             // Insert experience to client
             $this->_data = array('fk_id_profocupation' => $vacancy->fk_id_profocupation, 'fk_id_perdata' => $client, 'enterprise_name' => $vacancy->enterprise_name, 'post' => ' ', 'start_date' => empty($vacancy->start_job_date) ? $now : $vacancy->start_job_date, 'experience_year' => 0);
             parent::_simpleSave($dbPerExperience, false);
             // Save history to client
             $rowHistory = $dbPersonHistory->createRow();
             $rowHistory->fk_id_perdata = $client;
             $rowHistory->fk_id_jobvacancy = $dataForm['fk_id_jobvacancy'];
             $rowHistory->fk_id_sysuser = Zend_Auth::getInstance()->getIdentity()->id_sysuser;
             $rowHistory->fk_id_dec = $vacancy->fk_id_dec;
             $rowHistory->date_time = Zend_Date::now()->toString('yyyy-MM-dd HH:mm');
             $rowHistory->action = sprintf('KLIENTE IDA NEE HETAN SERBISU TIHA ONA BA VAGA EMPREGO: %s, DATA: %s', $dataForm['fk_id_jobvacancy'], $now);
             $rowHistory->description = '';
             $rowHistory->save();
             // Search if the vacancy was referencied by some barrier
             $whereReference = array('fk_id_jobvacancy = ?' => $dataForm['fk_id_jobvacancy'], 'fk_id_perdata = ?' => $client);
             $reference = $dbActionPlanReferences->fetchRow($whereReference);
             if (!empty($reference)) {
                 $barrier = $dbActionPlanBarrier->fetchRow(array('id_action_barrier = ?' => $reference->fk_id_action_barrier));
                 $barrier->status = Client_Model_Mapper_Case::BARRIER_COMPLETED;
                 $barrier->date_finish = Zend_Date::now()->toString('yyyy-MM-dd');
                 $barrier->save();
             }
             $whereCandidates = array('fk_id_perdata = ?' => $client, 'fk_id_jobvacancy = ?' => $dataForm['fk_id_jobvacancy']);
             $referer = $dbJobCandidates->fetchRow($whereCandidates);
             if (empty($referer->fk_id_sysuser)) {
                 continue;
             }
             $dataNote = array('title' => 'KLIENTE HETAN SERVISU', 'level' => 1, 'message' => $noteModelMapper->geJobService($client, $dataForm['fk_id_jobvacancy']), 'users' => array($referer->fk_id_sysuser));
             $noteMapper->setData($dataNote)->saveNote();
         }
         $dbAdapter->commit();
         return $dataForm['fk_id_jobvacancy'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
Beispiel #5
0
 /**
  * 
  * @param int $idTraining
  */
 protected function _sendWarningAmount($idTraining)
 {
     // Search the user who must receive notes when the amount is ultrapassed
     $noteTypeMapper = new Admin_Model_Mapper_NoteType();
     $users = $noteTypeMapper->getUsersByNoteType(Admin_Model_Mapper_NoteType::DRH_GREATER);
     $noteModelMapper = new Default_Model_Mapper_NoteModel();
     $noteMapper = new Default_Model_Mapper_Note();
     $dataNote = array('title' => 'DRH TRAINING PLAN FOLIN HIRA LIU $' . self::LIMIT_AMOUNT, 'level' => 0, 'message' => $noteModelMapper->getDrhTrainingPlan($this->detail($idTraining)), 'users' => $users);
     $noteMapper->setData($dataNote)->saveNote();
 }
Beispiel #6
0
 /**
  * 
  */
 public function notifyFollowupJob()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $rows = $this->_listJobHiredFollowup();
         // Search the user who must receive notes to follow up cases
         $noteTypeMapper = new Admin_Model_Mapper_NoteType();
         $users = $noteTypeMapper->getUsersByNoteType(Admin_Model_Mapper_NoteType::JOB_FOLLOW_UP);
         $noteModelMapper = new Default_Model_Mapper_NoteModel();
         $noteMapper = new Default_Model_Mapper_Note();
         foreach ($rows as $row) {
             $usersWarning = $users;
             $usersWarning[] = $row->fk_id_sysuser;
             $dataNote = array('title' => 'HALO AKOMPAÑAMENTU HO KLIENTE MAK HETAN SERBISU', 'level' => 0, 'message' => $noteModelMapper->getFollowUpCase($row->fk_id_perdata), '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;
     }
 }
Beispiel #7
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dbShortlist = App_Model_DbTable_Factory::get('ShortlistVacancy');
         $clients = $dbShortlist->fetchAll(array('fk_id_jobvacancy = ?' => $this->_data['id_jobvacancy']));
         $clientsShortlist = array();
         foreach ($clients as $client) {
             $clientsShortlist[] = $client->fk_id_perdata;
         }
         // Get just the new clients to the shortlist
         $clients = array_diff($this->_data['clients'], $clientsShortlist);
         $dbPersonHistory = App_Model_DbTable_Factory::get('Person_History');
         $dbJobCandidates = App_Model_DbTable_Factory::get('JOBVacancy_Candidates');
         $dbActionPlanReferences = App_Model_DbTable_Factory::get('Action_Plan_References');
         // Search the user who must receive notes when an user is refered to shortlist
         $noteTypeMapper = new Admin_Model_Mapper_NoteType();
         $users = $noteTypeMapper->getUsersByNoteType(Admin_Model_Mapper_NoteType::JOB_REFERED_SHORTLIST);
         $noteModelMapper = new Default_Model_Mapper_NoteModel();
         $noteMapper = new Default_Model_Mapper_Note();
         // Insert all the new clients in the shortlist
         foreach ($clients as $client) {
             // Add the client to the shortlist
             $row = $dbShortlist->createRow();
             $row->fk_id_jobvacancy = $this->_data['id_jobvacancy'];
             $row->fk_id_perdata = $client;
             $row->save();
             // Save history to client
             $rowHistory = $dbPersonHistory->createRow();
             $rowHistory->fk_id_perdata = $client;
             $rowHistory->fk_id_jobvacancy = $this->_data['id_jobvacancy'];
             $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 SHORTLIST VAGA EMPREGU NUMERO:%s ', $this->_data['id_jobvacancy']);
             $rowHistory->description = 'KLIENTE SELECIONADO BA SHORTLISTA VAGA EMPREGU';
             $rowHistory->save();
             // Set the list as shortlisted already to avoid to be shortlisted again
             $update = array('shortlisted' => 1);
             $whereUpdate = array('fk_id_perdata = ?' => $client, 'fk_id_jobvacancy = ?' => $this->_data['id_jobvacancy']);
             $dbJobCandidates->update($update, $whereUpdate);
             // Save the auditing
             $history = sprintf('SHORTED LIST KLIENTE: %s - BA VAGA EMPREGU NUMERU: %s ', $client, $this->_data['id_jobvacancy']);
             $this->_sysAudit($history);
             // Search if the vacancy was referencied by some barrier
             $whereReference = array('fk_id_jobvacancy = ?' => $this->_data['id_jobvacancy'], 'fk_id_perdata = ?' => $client);
             $reference = $dbActionPlanReferences->fetchRow($whereReference);
             if (!empty($reference)) {
                 $usersNotify = $users;
                 $usersNotify[] = $reference->fk_id_sysuser;
                 $dataNoteModel = array('client' => $client, 'vacancy' => $this->_data['id_jobvacancy'], 'case' => $reference->fk_id_action_plan, 'user' => $reference->fk_id_sysuser);
                 $dataNote = array('title' => 'KLIENTE REFERE BA SHORTLIST', 'level' => 1, 'message' => $noteModelMapper->geJobShortlist($dataNoteModel), 'users' => $usersNotify);
                 $noteMapper->setData($dataNote)->saveNote();
             }
         }
         $dbAdapter->commit();
         return $this->_data['id_jobvacancy'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
Beispiel #8
0
 /**
  * 
  * @param array $data
  */
 protected function _checkBeneficiaryGraduation($data)
 {
     $mapperClient = new Client_Model_Mapper_Client();
     $types = array(Register_Model_Mapper_PerTypeScholarity::FORMAL, Register_Model_Mapper_PerTypeScholarity::NON_FORMAL);
     $valid = false;
     foreach ($types as $type) {
         // Check all the client level of scholarity to check if it has National certificate level 2 or greater or is graduated
         $scholarities = $mapperClient->listScholarity($data['fk_id_perdata'], $type);
         foreach ($scholarities as $scholarity) {
             if ($scholarity->category == 'N' && $scholarity->level_scholarity >= 2 || $type == Register_Model_Mapper_PerTypeScholarity::FORMAL && $scholarity->fk_id_perlevelscholarity >= 17) {
                 $valid = true;
                 break 2;
             }
         }
     }
     if (!$valid) {
         // Search the user who must receive notes when the client doens't have the necessary qualification
         $noteTypeMapper = new Admin_Model_Mapper_NoteType();
         $users = $noteTypeMapper->getUsersByNoteType(Admin_Model_Mapper_NoteType::FE_GRADUATION);
         $noteModelMapper = new Default_Model_Mapper_NoteModel();
         $noteMapper = new Default_Model_Mapper_Note();
         $dataNote = array('title' => 'FE KONTRATU - BENEFISIARIU LA IHA FORMASAUN', 'level' => 0, 'message' => $noteModelMapper->getFEGraduation($this->detail($data['id_fe_contract'])), 'users' => $users);
         $noteMapper->setData($dataNote)->saveNote();
     }
 }
Beispiel #9
0
 /**
  * 
  * @param array $campaigns
  */
 protected function _sendNotificationCampaigns($campaigns)
 {
     $dbCampaign = App_Model_DbTable_Factory::get('Campaign');
     // Retrieve the campaigns
     $mapperCampaigns = new Sms_Model_Mapper_Campaign();
     $selectCampaings = $mapperCampaigns->getSelectCampaign();
     $selectCampaings->where('c.id_campaign IN(?)', $campaigns);
     $rows = $dbCampaign->fetchAll($selectCampaings);
     $noteMapper = new Default_Model_Mapper_Note();
     $noteModelMapper = new Default_Model_Mapper_NoteModel();
     // Search the user who must receive notes when there is sms
     $noteTypeMapper = new Admin_Model_Mapper_NoteType();
     $users = $noteTypeMapper->getUsersByNoteType(Admin_Model_Mapper_NoteType::SMS_RECEIVED);
     foreach ($rows as $row) {
         $responsibles = $users;
         $responsibles[] = $row['responsible'];
         // save the warning to the user responsible of the department
         $dataNote = array('title' => 'SMS KAMPANHA FOIN TAMA', 'level' => 1, 'message' => $noteModelMapper->getCampaignSmsReceived($row), 'users' => $responsibles);
         $noteMapper->setData($dataNote)->saveNote();
     }
 }
Beispiel #10
0
 /**
  * 
  * @return int|bool
  */
 public function finishClass()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dbActionPlanReferences = App_Model_DbTable_Factory::get('Action_Plan_References');
         $dbActionPlanBarrier = App_Model_DbTable_Factory::get('Action_Plan_Barrier');
         $dbClassCandidates = App_Model_DbTable_Factory::get('StudentClass_Candidates');
         $dataValid = $this->_data;
         $valid = $this->checkFinishClass($this->_data['id']);
         if (empty($valid['valid'])) {
             $this->_message->addMessage('Erro: La bele remata klase! Haree kriterio sira.', App_Message::ERROR);
             return false;
         }
         $this->_data = $dataValid;
         $class = $this->fetchRow($this->_data['id']);
         $class->active = 0;
         $class->real_finish_date = Zend_Date::now()->toString('yyyy-MM-dd');
         $class->save();
         // Search the Students Graduated
         $dbStudentClassPerData = App_Model_DbTable_Factory::get('FEFEPStudentClass_has_PerData');
         $whereStudentClass = array('fk_id_fefpstudentclass = ?' => $this->_data['id'], 'status = ?' => self::GRADUATED);
         $students = $dbStudentClassPerData->fetchAll($whereStudentClass);
         $dbPersonHistory = App_Model_DbTable_Factory::get('Person_History');
         $dbPerScholarity = App_Model_DbTable_Factory::get('PerScholarity_has_PerTypeScholarity');
         // Search the class course
         $mapperScholarity = new Register_Model_Mapper_PerScholarity();
         $course = $mapperScholarity->fetchRow($class->fk_id_perscholarity);
         $noteMapper = new Default_Model_Mapper_Note();
         $noteModelMapper = new Default_Model_Mapper_NoteModel();
         foreach ($students as $student) {
             // Save history to client
             $rowHistory = $dbPersonHistory->createRow();
             $rowHistory->fk_id_perdata = $student->fk_id_perdata;
             $rowHistory->fk_id_student_class = $this->_data['id'];
             $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('REMATA KLASE FORMASAUN: %s ', $this->_data['id']);
             $rowHistory->description = sprintf('REMATA KLASE FORMASAUN: %s ', $this->_data['id']);
             $rowHistory->save();
             $whereScholarity = array('fk_id_perdata = ?' => $student->fk_id_perdata, 'fk_id_perscholarity = ?' => $class->fk_id_perscholarity, 'fk_id_fefpeduinstitution = ?' => $class->fk_id_fefpeduinstitution);
             $hasScholarity = $dbPerScholarity->fetchRow($whereScholarity);
             // If the client already has the scholarity
             if (!empty($hasScholarity)) {
                 continue;
             }
             // Insert the scholarities to the student
             $rowScholarity = $dbPerScholarity->createRow();
             $rowScholarity->fk_id_perdata = $student->fk_id_perdata;
             $rowScholarity->fk_id_perscholarity = $class->fk_id_perscholarity;
             $rowScholarity->fk_id_pertypescholarity = $course->fk_id_pertypescholarity;
             $rowScholarity->fk_id_fefpeduinstitution = $class->fk_id_fefpeduinstitution;
             $rowScholarity->start_date = $class->start_date;
             $rowScholarity->finish_date = $class->real_finish_date;
             $rowScholarity->save();
             // Search if the class was referencied by some barrier
             $whereReference = array('fk_id_fefpstudentclass = ?' => $this->_data['id'], 'fk_id_perdata = ?' => $student->fk_id_perdata);
             $reference = $dbActionPlanReferences->fetchRow($whereReference);
             if (!empty($reference)) {
                 $barrier = $dbActionPlanBarrier->fetchRow(array('id_action_barrier = ?' => $reference->fk_id_action_barrier));
                 $barrier->status = Client_Model_Mapper_Case::BARRIER_COMPLETED;
                 $barrier->date_finish = Zend_Date::now()->toString('yyyy-MM-dd');
                 $barrier->save();
             }
             $whereCandidates = array('fk_id_perdata = ?' => $student->fk_id_perdata, 'fk_id_fefpstudentclass = ?' => $this->_data['id']);
             $referer = $dbClassCandidates->fetchRow($whereCandidates);
             if (empty($referer->fk_id_sysuser)) {
                 continue;
             }
             $dataNote = array('title' => 'KLIENTE GRADUADU IHA KLASE FORMASAUN', 'level' => 1, 'message' => $noteModelMapper->getClassGraduated($student->fk_id_perdata, $this->_data['id']), 'users' => array($referer->fk_id_sysuser));
             $noteMapper->setData($dataNote)->saveNote();
         }
         // Save the auditing
         $history = 'REMATA KLASE FORMASAUN NUMERU: %s';
         $history = sprintf($history, $this->_data['id']);
         $this->_sysAudit($history, StudentClass_Form_RegisterFinish::ID);
         // If the class has a remote ID, save the class to be sent to the INDMO application
         if (!empty($course->remote_id)) {
             $dbStudentClassSent = App_Model_DbTable_Factory::get('StudentClass_Sent');
             $row = $dbStudentClassSent->createRow();
             $row->fk_id_fefpstudentclass = $this->_data['id'];
             $row->save();
         }
         $dbAdapter->commit();
         return $this->_data['id'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
Beispiel #11
0
 /**
  * 
  * @return int|bool
  */
 public function saveTrainee()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dbJobTrainingTrainee = App_Model_DbTable_Factory::get('JOBTraining_Trainee');
         $dbJobTrainingCandidates = App_Model_DbTable_Factory::get('JOBTraining_Candidates');
         $clientTrainee = $dbJobTrainingTrainee->fetchAll(array('fk_id_jobtraining = ?' => $this->_data['id_jobtraining']));
         $clientsCandidates = array();
         foreach ($clientTrainee as $client) {
             $clientsCandidates[] = $client->fk_id_perdata;
         }
         // Get just the new clients to the trainee
         $clients = array_diff($this->_data['clients'], $clientsCandidates);
         $dbPersonHistory = App_Model_DbTable_Factory::get('Person_History');
         $jobTraining = $this->fetchRow($this->_data['id_jobtraining']);
         // Check if the total of participants exceeds the total defined in the information step
         if ($clientTrainee->count() + count($clients) > $jobTraining['total_participants']) {
             $message = sprintf('Erro: Total partisipante la bele liu: %s. Iha %s tiha ona, bele aumenta: %s', $jobTraining['total_participants'], $clientTrainee->count(), $jobTraining['total_participants'] - $clientTrainee->count());
             $this->_message->addMessage($message, App_Message::ERROR);
             return false;
         }
         // Search the user who must receive notes when an user is refered to shortlist
         $noteTypeMapper = new Admin_Model_Mapper_NoteType();
         $users = $noteTypeMapper->getUsersByNoteType(Admin_Model_Mapper_NoteType::CLASS_SHORTLIST);
         $noteMapper = new Default_Model_Mapper_Note();
         $noteModelMapper = new Default_Model_Mapper_NoteModel();
         // Insert all the new clients in the trainee program
         foreach ($clients as $client) {
             // Add the client to the trainee program
             $row = $dbJobTrainingTrainee->createRow();
             $row->fk_id_jobtraining = $this->_data['id_jobtraining'];
             $row->fk_id_perdata = $client;
             $row->fk_id_sysuser = Zend_Auth::getInstance()->getIdentity()->id_sysuser;
             $row->date_start = $jobTraining->date_start;
             $row->date_finish = $jobTraining->date_finish;
             $row->duration = $jobTraining->duration;
             $row->status = 0;
             $row->completed = 0;
             $row->save();
             // Save history to client
             $rowHistory = $dbPersonHistory->createRow();
             $rowHistory->fk_id_perdata = $client;
             $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 JOB TRAINING NUMERU:%s ', $this->_data['id_jobtraining']);
             $rowHistory->description = 'KLIENTE HALO REJISTU KLIENTE SELECIONADO BA JOB TRAINING';
             $rowHistory->save();
             // Set the candidate already selected to avoid to be selected again
             $update = array('selected' => 1);
             $whereUpdate = array('fk_id_perdata  = ?' => $client, 'fk_id_jobtraining = ?' => $this->_data['id_jobtraining']);
             $dbJobTrainingCandidates->update($update, $whereUpdate);
             // Save the auditing
             $history = sprintf('KLIENTE %s SELECIONADO BA JOB TRAINING NUMERU: %s ', $client, $this->_data['id_jobtraining']);
             $this->_sysAudit($history);
             $whereCandidates = array('fk_id_perdata = ?' => $client, 'fk_id_jobtraining = ?' => $this->_data['id_jobtraining']);
             $referer = $dbJobTrainingCandidates->fetchRow($whereCandidates);
             if (empty($referer->fk_id_sysuser)) {
                 continue;
             }
             $usersNotify = $users;
             $usersNotify[] = $referer->fk_id_sysuser;
             $dataNote = array('title' => 'KLIENTE SELECIONADO BA JOB TRAINING', 'level' => 1, 'message' => $noteModelMapper->getJobTrainingCandidate($client, $this->_data['id_jobtraining']), 'users' => $usersNotify);
             $noteMapper->setData($dataNote)->saveNote();
         }
         $dbAdapter->commit();
         return $this->_data['id_jobtraining'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }