Пример #1
0
 public function createAction()
 {
     $this->isAdmin();
     if (isset($_POST['operator'])) {
         $O_operator = new Operator();
         $O_operator->setName($_POST['name']);
         $O_operator->setFirstName($_POST['firstName']);
         $O_operator->setSizeHarness($_POST['sizeHarness']);
         $O_operator->setEmail($_POST['email']);
         $O_operator->initInceptionDate();
         $O_teamMapper = new TeamMapper();
         $O_team = $O_teamMapper->findByTwoIds($_POST['staff_id'], $_POST['subgroup_id']);
         $O_operator->setTeamId($O_team->getId());
         $O_operatorMapper = new OperatorMapper();
         $I_operatorId = $O_operatorMapper->insert($O_operator);
         //die(header('Location:/user/default/'));
     }
     if (isset($_POST['inspector'])) {
         $O_inspector = new Inspector();
         $O_inspector->setName($_POST['name']);
         $O_inspector->setFirstName($_POST['firstName']);
         $O_inspector->setEmail($_POST['email']);
         $O_inspector->setSubgroupId($_POST['subgroup_id']);
         $O_inspector->initInceptionDate();
         $O_inspectorMapper = new InspectorMapper();
         $I_inspectorId = $O_inspectorMapper->insert($O_inspector);
     }
     $O_user = new User();
     $O_user->setLogin($_POST['login']);
     $O_user->setPassword($_POST['password']);
     $O_user->setProfileId($_POST['profile_id']);
     if (isset($_POST['operator'])) {
         $O_user->setOperatorId($I_operatorId);
     }
     if (isset($_POST['inspector'])) {
         $O_user->setInspectorId($I_inspectorId);
     }
     $O_userMapper = new UserMapper();
     $I_userId = $O_userMapper->insert($O_user);
 }