customers = array(); } /** loads all customers that have tickets for an event * @param dateId id of the TicketDate */ //----------------------------------------------- function loadCustomersForEvent($dateId){ //----------------------------------------------- $query = sprintf("SELECT DISTINCT customerId FROM bruckm_ticket WHERE dateId = %d", sqlnum($dateId)); $result = dbQuery($query); while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){ $c = new TicketCustomer($line['customerId']); $c->load(); $this->customers[] = $c; } } /** returns all customers as xml * @return xml string */ //----------------------------------------------- function toXml(){ //----------------------------------------------- $xml = ""; foreach($this->customers as $c){ $xml .= $c->toXml(); } $xml .= ""; return $xml; } /** sorts the customers alphabetically * @return nothing */ //----------------------------------------------- function sort(){ //----------------------------------------------- for($i=0; $icustomers)-1; $i++){ $min = $this->findMin($i); if($min != $i){ $this->customers = array_swap($this->customers, $i, $min); } } } /** finds minimal customer * @return index of minimal customer */ //----------------------------------------------- function findMin($offset){ //----------------------------------------------- $min = $offset; for($i=$offset+1; $icustomers); $i++){ $n1 = $this->customers[$i]->getSurname(); $n2 = $this->customers[$min]->getSurname(); if(strcasecmp($n1, $n2) < 0){ $min = $i; } } return $min; } }; ?>