eventhelper.class.php 1012 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use Luracast\Restler\RestException;
  3. class EventHelper
  4. {
  5. private ApiInvoice $apiInvoice;
  6. public $db;
  7. /**
  8. *
  9. */
  10. public function __construct()
  11. {
  12. global $db;
  13. $this->db = $db;
  14. }
  15. public function noEmptySpaces($event_id, $reservations)
  16. {
  17. $sql = "SELECT ace.max_num, ace.buffer, ace.participants FROM llx_actioncomm as ac
  18. INNER JOIN llx_actioncomm_extrafields as ace ON ace.fk_object = ac.id
  19. WHERE ac.id = {$event_id}";
  20. //print $sql;exit;
  21. $result = $this->db->query($sql);
  22. if ($this->db->num_rows($result) == 0) {
  23. return true;
  24. }
  25. while ($row = $this->db->fetch_object($result)) {
  26. if($row->participants >= $row->max_num){
  27. return true;
  28. }
  29. if($row->participants + $reservations > $row->max_num + $row->buffer){
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. }