Ejemplo n.º 1
0
 /**
  * 
  */
 public function handicappedAction()
 {
     $this->_helper->layout()->disableLayout();
     // Form Handicapped
     $formHandicapped = $this->_initForm('handicapped');
     $id = $this->_getParam('id');
     if (!empty($id)) {
         $row = $this->_mapper->fetchRow($id);
         $data = $row->toArray();
         $data['fk_id_jobvacancy'] = $data['id_jobvacancy'];
         $formHandicapped->populate($data);
         if (!$this->view->jobActive()->hasAccessEdit()) {
             $formHandicapped->getElement('save')->setAttrib('disabled', true);
         }
     }
     $this->view->form = $formHandicapped;
 }
Ejemplo n.º 2
0
 /**
  * 
  * @return int|bool
  */
 public function clientToVacancy()
 {
     $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');
         $dbJobCandidates = App_Model_DbTable_Factory::get('JOBVacancy_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 vacancy
         $mapperVacancy = new Job_Model_Mapper_JobVacancy();
         $vacancy = $mapperVacancy->fetchRow($this->_data['vacancy']);
         if ($vacancy->active != 1) {
             $this->_message->addMessage('Vaga ida ne\'e taka tiha ona, la bele tau kliente iha lista kandidatu.', App_Message::ERROR);
             return false;
         }
         $where = array('fk_id_jobvacancy = ?' => $this->_data['vacancy']);
         $rows = $dbJobCandidates->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 vaga empregu iha ne\'e.', App_Message::ERROR);
             return false;
         }
         // Insert all the clients in the candidate list
         foreach ($newClients as $client) {
             // Add the client to the shortlist
             $row = $dbJobCandidates->createRow();
             $row->fk_id_jobvacancy = $this->_data['vacancy'];
             $row->fk_id_perdata = $client;
             $row->fk_id_sysuser = Zend_Auth::getInstance()->getIdentity()->id_sysuser;
             $row->source = 'C';
             $row->save();
             // Save history to client
             $rowHistory = $dbPersonHistory->createRow();
             $rowHistory->fk_id_perdata = $client;
             $rowHistory->fk_id_jobvacancy = $this->_data['vacancy'];
             $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 VAGA EMPREGU NUMERO:%s ', $this->_data['vacancy']);
             $rowHistory->description = 'KLIENTE SELECIONADO BA LISTA KANDIDATU BA VAGA EMPREGU';
             $rowHistory->save();
             // Save the auditing
             $history = sprintf('KLIENTE BA LISTA KANDIDATU: %s - BA VAGA EMPREGU NUMERU: %s ', $client, $this->_data['vacancy']);
             $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_jobvacancy = $this->_data['vacancy'];
             $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;
     }
 }