Guest User

Untitled

a guest
Jun 20th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. public function createrobotAction()
  2. {
  3. $request = $this->getRequest();
  4. $form = new Setup_Form_Unit_Robot_Create();
  5.  
  6. if ($this->getRequest()->isPost())
  7. {
  8.  
  9. if ($form->isValid($request->getPost()))
  10. {
  11. echo 'valid';
  12.  
  13. $machine = Doctrine::getTable('Do_Machine')->find($this->_session->machine_id);
  14. $robot = new Do_UnitRobot();
  15. $robot->description = $form->getValue('description');
  16.  
  17. $robot->enabled = $form->getValue('enabled');
  18.  
  19. $robot->station_id = $form->getValue('station');
  20.  
  21. $robot->Machine = $machine;
  22.  
  23. $positionRobot = new Do_Position();
  24. $positionRobot->description = 'Position ' . $robot->description;
  25. $positionRobot->available = true;
  26. $positionRobot->Machine = $machine;
  27.  
  28. $robot->RobotPosition = $positionRobot;
  29. $robot->save();
  30.  
  31. }
  32. }
  33. else
  34. {
  35. $machine = Doctrine::getTable('Do_Machine')->find($this->_session->machine_id);
  36.  
  37. $stations = $machine->Stations;
  38. $stationArray = null;
  39.  
  40. foreach($stations as $station)
  41. {
  42. if ($station->station_type == 'transporter')
  43. {
  44. $stationArray[$station->station_id] = $station->id_logic;
  45. }
  46. }
  47.  
  48. $form->station->setMultiOptions($stationArray);
  49. $this->view->form = $form;
  50. }
  51. }
Add Comment
Please, Sign In to add comment