Ejemplo n.º 1
0
 /**
  * 
  */
 public function clientJobTrainingAction()
 {
     $return = $this->_mapper->setData($this->_getAllParams())->clientJobTraining();
     $message = $this->_mapper->getMessage()->toArray();
     $result = array('status' => (bool) $return, 'id' => $return, 'message' => $message);
     $this->_helper->json($result);
 }
Ejemplo n.º 2
0
 /**
  * 
  * @return int|bool
  */
 public function addClient()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $rows = $this->listCasesInGroup($this->_data['case_group']);
         $clientsInGroup = array();
         foreach ($rows as $row) {
             $clientsInGroup[] = $row->fk_id_perdata;
         }
         $newClients = array_diff($this->_data['clients'], $clientsInGroup);
         // If there is now new clients
         if (empty($newClients)) {
             $this->_message->addMessage('Kliente hotu iha grupu tiha ona.', App_Message::ERROR);
             return false;
         }
         // Search for the case group
         $caseGroup = $this->fetchRow($this->_data['case_group']);
         $dbActionPlanHasGroup = App_Model_DbTable_Factory::get('Action_Plan_has_Group');
         $dbActionPlanBarrier = App_Model_DbTable_Factory::get('Action_Plan_Barrier');
         $mapperCase = new Client_Model_Mapper_Case();
         // Insert the barriers to the new clients
         $barriers = $this->listBarriers($this->_data['case_group']);
         // Generate cases for all the clients
         foreach ($this->_data['clients'] as $client) {
             $dataCase = array('fk_id_perdata' => $client, 'fk_id_profocupationtimor' => $this->_data['occupation'], 'fk_id_counselor' => $caseGroup->fk_id_counselor, 'type' => 'G');
             // Save the CAse
             $idCase = $mapperCase->setData($dataCase)->saveCase();
             $rowCase = $dbActionPlanHasGroup->createRow();
             $rowCase->fk_id_action_plan_group = $this->_data['case_group'];
             $rowCase->fk_id_action_plan = $idCase;
             $rowCase->save();
             // Insert the reamining barriers
             foreach ($barriers as $barrier) {
                 $data = $barrier->toArray();
                 unset($data['id_action_barrier']);
                 $rowBarrier = $dbActionPlanBarrier->createRow($data);
                 $rowBarrier->fk_id_action_plan = $idCase;
                 $rowBarrier->fk_id_sysuser = Zend_Auth::getInstance()->getIdentity()->id_sysuser;
                 $rowBarrier->status = Client_Model_Mapper_Case::BARRIER_PENDING;
                 $rowBarrier->save();
             }
         }
         $history = 'INSERE KLIENTE IHA KAZU GRUPU: %s';
         // Save the audit
         $history = sprintf($history, $this->_data['case_group']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $this->_data['case_group'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }