Location.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. use Doctrine\Common\Collections\ArrayCollection;
  3. use Doctrine\Common\Collections\Collection;
  4. /**
  5. * @Entity @Table(name="locations")
  6. */
  7. class Location extends BaseDBO
  8. {
  9. /**
  10. * @Id @Column(type="integer") @GeneratedValue
  11. */
  12. private $id;
  13. /**
  14. * @Column(type="string")
  15. */
  16. public $name;
  17. /**
  18. * @Column(type="string")
  19. */
  20. public $description;
  21. public static function GetLocations()
  22. {
  23. global $entityManager;
  24. $locs = $entityManager->getRepository('Location')->findAll();
  25. return $locs;
  26. }
  27. public static function EchoLocations()
  28. {
  29. $locs = Location::GetLocations();
  30. echo "<select id='locations' style='width: 400px' class='form-input content__main__form__series'>";
  31. $str = '<option value="0"><Выберите локацию из списка></option>';
  32. foreach ($locs as $loc)
  33. {
  34. $str .= "<option value='$loc->id'>$loc->name</option>";
  35. }
  36. echo "$str</select>";
  37. }
  38. public static function Add($name, $desc)
  39. {
  40. $loc = new Location();
  41. $loc->name = $name;
  42. $loc->description = $desc;
  43. $loc->Save();
  44. echo "Локация создана";
  45. }
  46. public function getName(): string
  47. {
  48. return $this->name;
  49. }
  50. public function setName(string $name): self
  51. {
  52. $this->name = $name;
  53. return $this;
  54. }
  55. }