/**
  * Creates a new dtb_raise_project_team_certificate
  */
 public function createAction()
 {
     if (!$this->request->isPost()) {
         return $this->dispatcher->forward(array("controller" => "dtb_raise_project_team_certificate", "action" => "index"));
     }
     $dtb_raise_project_team_certificate = new DtbRaiseProjectTeamCertificate();
     $dtb_raise_project_team_certificate->setTmmemberId($this->request->getPost("tmmember_id"));
     $dtb_raise_project_team_certificate->setOrganization($this->request->getPost("organization"));
     $dtb_raise_project_team_certificate->setCertificateName($this->request->getPost("certificate_name"));
     $dtb_raise_project_team_certificate->setRewardTs($this->request->getPost("reward_ts"));
     if (!$dtb_raise_project_team_certificate->save()) {
         foreach ($dtb_raise_project_team_certificate->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->dispatcher->forward(array("controller" => "dtb_raise_project_team_certificate", "action" => "new"));
     }
     $this->flash->success("dtb_raise_project_team_certificate was created successfully");
     return $this->dispatcher->forward(array("controller" => "dtb_raise_project_team_certificate", "action" => "index"));
 }
 /**
  * Saves a dtb_raise_project_team edited
  *
  */
 public function saveAction()
 {
     if (!$this->request->isPost()) {
         return $this->dispatcher->forward(array("controller" => "user_raise_team", "action" => "edit", "params" => array($this->request->getPost("raise_id"))));
     }
     $tmmember_id = $this->request->getPost("tmmember_id");
     if (!empty($tmmember_id)) {
         $dtb_raise_project_team = DtbRaiseProjectTeam::findFirstBytmmember_id($tmmember_id);
         if (!$dtb_raise_project_team) {
             $this->flash->error("dtb_raise_project_team does not exist " . $tmmember_id);
         }
         $dtb_raise_project_team_work_info = DtbRaiseProjectTeamWorkInfo::findFirstBytmmember_id($tmmember_id);
         if (!$dtb_raise_project_team_work_info) {
             $dtb_raise_project_team_work_info = new DtbRaiseProjectTeamWorkInfo();
         }
         $dtb_raise_project_team_cert = DtbRaiseProjectTeamCertificate::findFirstBytmmember_id($tmmember_id);
         if (!$dtb_raise_project_team_cert) {
             $dtb_raise_project_team_cert = new DtbRaiseProjectTeamCertificate();
         }
         $dtb_raise_project_team_edc = DtbRaiseProjectTeamEducation::findFirstBytmmember_id($tmmember_id);
         if (!$dtb_raise_project_team_edc) {
             $dtb_raise_project_team_edc = new DtbRaiseProjectTeamEducation();
         }
     } else {
         $dtb_raise_project_team = new DtbRaiseProjectTeam();
         $dtb_raise_project_team_work_info = new DtbRaiseProjectTeamWorkInfo();
         $dtb_raise_project_team_cert = new DtbRaiseProjectTeamCertificate();
         $dtb_raise_project_team_edc = new DtbRaiseProjectTeamEducation();
     }
     $dtb_raise_project_team->setRaiseId($this->request->getPost("raise_id"));
     $dtb_raise_project_team->setUserName($this->request->getPost("user_name"));
     $dtb_raise_project_team->setAvatar($this->request->getPost("avatar"));
     $dtb_raise_project_team->setPosition($this->request->getPost("position"));
     $dtb_raise_project_team->setCommitment($this->request->getPost("commitment"));
     $dtb_raise_project_team->setOwnership($this->request->getPost("ownership"));
     $dtb_raise_project_team->setNationality($this->request->getPost("nationality"));
     $dtb_raise_project_team->setRole($this->request->getPost("role"));
     $dtb_raise_project_team->setBirthday($this->request->getPost("birthday"));
     $dtb_raise_project_team->setCountry($this->request->getPost("country"));
     $dtb_raise_project_team->setCity($this->request->getPost("city"));
     $dtb_raise_project_team->setAddress($this->request->getPost("address"));
     $dtb_raise_project_team->setUpdateTs(time());
     $flag = false;
     $this->di['db']->begin();
     try {
         $res = $dtb_raise_project_team->save();
         $tmmember_id = $dtb_raise_project_team->getTmmemberId();
         $dtb_raise_project_team_work_info->setTmmemberId($tmmember_id);
         $dtb_raise_project_team_work_info->setCompany($this->request->getPost("company"));
         $dtb_raise_project_team_work_info->setPosition($this->request->getPost("position"));
         $dtb_raise_project_team_work_info->setStartTs(strtotime($this->request->getPost("start_ts")));
         $dtb_raise_project_team_work_info->setEndTs(strtotime($this->request->getPost("end_ts")));
         $dtb_raise_project_team_cert->setTmmemberId($tmmember_id);
         $dtb_raise_project_team_cert->setOrganization($this->request->getPost("organization"));
         $dtb_raise_project_team_cert->setCertificateName($this->request->getPost("certificate_name"));
         $dtb_raise_project_team_cert->setRewardTs(strtotime($this->request->getPost("reward_ts")));
         $dtb_raise_project_team_edc->setTmmemberId($tmmember_id);
         $dtb_raise_project_team_edc->setMajor($this->request->getPost("major"));
         $dtb_raise_project_team_edc->setEducation($this->request->getPost("education"));
         $dtb_raise_project_team_edc->setRewardTs(strtotime($this->request->getPost("reward_ts")));
         $res1 = $dtb_raise_project_team_work_info->save();
         $res2 = $dtb_raise_project_team_cert->save();
         $res3 = $dtb_raise_project_team_edc->save();
         if ($res && $res1 && $res2 && $res3) {
             $this->di['db']->commit();
             $flag = true;
         } else {
             $this->di['db']->rollback();
         }
     } catch (Exception $ex) {
         $this->di['db']->rollback();
     }
     if ($flag) {
         $this->flash->success("dtb_raise_project_team was created successfully");
         return $this->response->redirect('/user_raise_team/edit/' . $this->request->getPost("raise_id"));
     } else {
         foreach ($dtb_raise_project_team->getMessages() as $message) {
             $this->flash->error($message);
         }
         foreach ($dtb_raise_project_team_work_info->getMessages() as $message) {
             $this->flash->error($message);
         }
         foreach ($dtb_raise_project_team_cert->getMessages() as $message) {
             $this->flash->error($message);
         }
         foreach ($dtb_raise_project_team_edc->getMessages() as $message) {
             $this->flash->error($message);
         }
     }
 }