Esempio n. 1
0
 /**
  * 
  */
 public function indexAction()
 {
     $id = $this->_getParam('id');
     if (empty($id)) {
         $stepBreadCrumb = array('label' => 'Rejistu Foun', 'url' => 'student-class/job-training');
     } else {
         $stepBreadCrumb = array('label' => 'Edita Rejistu', 'url' => 'student-class/job-training/edit/id/' . $id);
         $row = $this->_mapper->fetchRow($id);
         if (empty($row)) {
             $this->_helper->redirector->goToSimple('index');
         }
         $this->view->title()->setSubTitle($row->title);
     }
     $this->view->id = $id;
     $this->view->user = Zend_Auth::getInstance()->getIdentity();
     $this->view->breadcrumb()->addStep($stepBreadCrumb);
 }
Esempio n. 2
0
 /**
  *
  * @param type $idJobTraining
  * @return \App_View_Helper_JobTrainingActive 
  */
 public function setJobTraining($idJobTraining)
 {
     $mapperJobTraining = new StudentClass_Model_Mapper_JobTraining();
     $this->_jobTraining = $mapperJobTraining->fetchRow($idJobTraining);
     return $this;
 }
Esempio n. 3
0
 /**
  * 
  * @return int|bool
  */
 public function clientToJobTraining()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dbActionPlan = App_Model_DbTable_Factory::get('Action_Plan');
         $dbActionPlanBarrier = App_Model_DbTable_Factory::get('Action_Plan_Barrier');
         $dbJobTrainingCandidates = App_Model_DbTable_Factory::get('JOBTraining_Candidates');
         $dbPersonHistory = App_Model_DbTable_Factory::get('Person_History');
         $dbActionPlanReferences = App_Model_DbTable_Factory::get('Action_Plan_References');
         $clients = array();
         $casesClient = array();
         // Fetch the clients related to the case
         $rows = $dbActionPlan->fetchAll(array('id_action_plan IN (?)' => $this->_data['cases']));
         foreach ($rows as $row) {
             $clients[] = $row->fk_id_perdata;
             $casesClient[$row->fk_id_perdata] = $row->id_action_plan;
         }
         // Fetch the job training
         $mapperJobTraining = new StudentClass_Model_Mapper_JobTraining();
         $jobTraining = $mapperJobTraining->fetchRow($this->_data['idJobTraining']);
         if ($jobTraining->status != 1) {
             $this->_message->addMessage('Job Training ida ne\'e taka tiha ona, la bele tau kliente iha lista kandidatu.', App_Message::ERROR);
             return false;
         }
         $where = array('fk_id_jobtraining = ?' => $this->_data['idJobTraining']);
         $rows = $dbJobTrainingCandidates->fetchAll($where);
         $clientsCandidates = array();
         foreach ($rows as $row) {
             $clientsCandidates[] = $row->fk_id_perdata;
         }
         $newClients = array_diff($clients, $clientsCandidates);
         // If all the candidates are already in candidate list
         if (empty($newClients)) {
             $this->_message->addMessage('Kliente hotu iha Lista Kandidatu tiha ona ba job training ida ne\'e.', App_Message::ERROR);
             return false;
         }
         // Insert all the clients in the candidate list
         foreach ($newClients as $client) {
             // Add the client to the list candidates
             $row = $dbJobTrainingCandidates->createRow();
             $row->fk_id_jobtraining = $this->_data['idJobTraining'];
             $row->fk_id_perdata = $client;
             $row->fk_id_sysuser = Zend_Auth::getInstance()->getIdentity()->id_sysuser;
             $row->selected = 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 LISTA KANDIDATU JOB TRAINING NUMERO: %s ', $this->_data['idJobTraining']);
             $rowHistory->description = 'KLIENTE SELECIONADO BA LISTA KANDIDATU JOB TRAININGU NUMERO';
             $rowHistory->save();
             // Save the auditing
             $history = sprintf('KLIENTE BA LISTA KANDIDATU: %s - BA JOB TRAINING NUMERU: %s ', $client, $this->_data['idJobTraining']);
             $this->_sysAudit($history);
             $whereBarrier = array('fk_id_action_plan = ?' => $casesClient[$client], 'fk_id_barrier_intervention = ?' => $this->_data['intervention']);
             $barrier = $dbActionPlanBarrier->fetchRow($whereBarrier);
             // Insert the reference to the action barrier
             $rowReference = $dbActionPlanReferences->createRow();
             $rowReference->fk_id_perdata = $client;
             $rowReference->fk_id_action_plan = $casesClient[$client];
             $rowReference->fk_id_action_barrier = $barrier->id_action_barrier;
             $rowReference->fk_id_sysuser = Zend_Auth::getInstance()->getIdentity()->id_sysuser;
             $rowReference->fk_id_jobtraining = $this->_data['idJobTraining'];
             $rowReference->save();
         }
         $dbAdapter->commit();
         return $this->_data['case_id'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }