コード例 #1
0
 /**
  * create a new child matter for a matter
  * *
  */
 public function childAction()
 {
     $this->_helper->layout->disableLayout();
     $matterModel = new Application_Model_Matter();
     if ($this->getRequest()->isPost()) {
         $this->_helper->viewRenderer->setNoRender();
         $matter['category_code'] = $this->getRequest()->getPost('category_code');
         $matter['country'] = $this->getRequest()->getPost('country');
         $matter['origin'] = $this->getRequest()->getPost('origin');
         $matter['type_code'] = $this->getRequest()->getPost('type_code');
         $matter['caseref'] = $this->getRequest()->getPost('caseref');
         $matter['responsible'] = $this->getRequest()->getPost('responsible');
         $priority = $this->getRequest()->getPost('priority');
         $container = $this->getRequest()->getPost('container');
         $matter_id = $this->getRequest()->getPost('matter_ID');
         if ($matter['origin'] == '') {
             $matter['origin'] = null;
         }
         if ($matter['type_code'] == '') {
             $matter['type_code'] = null;
         }
         if ($priority == 0) {
             $matter['parent_ID'] = $matter_id;
         }
         if ($container == 0) {
             $current_matter = $matterModel->getMatter($matter_id);
             $matter['container_ID'] = $matterModel->getMatterContainer($matter_id);
             $matter['responsible'] = $current_matter[0]['responsible'];
         }
         $result = $matterModel->child($matter);
         if (!$result) {
             $msg = "Failed to create child matter";
             $this->view->matter_status = false;
             echo "false";
         } else {
             if ($container == 1) {
                 $matterModel->cloneActors($matter_id, $result);
                 $matterModel->cloneClassifiers($matter_id, $result);
             } else {
                 $matterModel->childActors($matter_id, $result);
             }
             $matterModel->clonePriorities($matter_id, $result);
             if ($priority == 0) {
                 $matterModel->childParentFiledEvent($result, $matter_id);
             } else {
                 $matterModel->childPriClaimEvent($matter_id, $result);
             }
             $msg = "Child Matter created successfully";
             $this->view->matter_status = true;
             echo $result;
         }
     } else {
         $category_id = $this->_getParam('category_id');
         $category_arr = explode('-', $category_id);
         $country_id = $this->_getParam('country');
         $country_arr = explode('-', $country_id);
         $origin = $this->_getParam('origin');
         $type_code = $this->_getParam('type');
         $caseref = $this->_getParam('caseref');
         if (!isset($category_arr[1])) {
             $category_arr[1] = "";
         }
         $this->view->category = $category_arr[0];
         $this->view->category_code = $category_arr[1];
         $this->view->country_name = $country_arr[0];
         $this->view->country_code = $country_arr[1];
         $this->view->username = $this->username;
         $this->view->caseref = $caseref;
         $this->view->matter_title = "New Child Matter";
         $origin_arr = $matterModel->getCountryByCode($origin);
         $this->view->origin_name = $origin_arr['name'];
         $this->view->origin_code = $origin_arr['iso'];
         $type_arr = $matterModel->getTypeCode($type_code);
         $this->view->type_name = $type_arr['type'];
         $this->view->type_code = $type_arr['code'];
         $this->view->matter_cap = "New Child";
         $this->view->matter_cap_id = "child-matter-submit";
         $this->view->child = 1;
         $this->render('add');
     }
 }