93 lines
2.2 KiB
PHP
93 lines
2.2 KiB
PHP
<?php
|
|
require_once(ROOT."include/config.inc.php");
|
|
require_once(ROOT."include/array.inc.php");
|
|
require_once(ROOT."include/db.inc.php");
|
|
require_once(CMS_DIR."modules/ticketcustomer.class.php");
|
|
|
|
/** TicketCustomerContainer
|
|
*
|
|
* @version 1.9.0
|
|
* @since 2007-03-04
|
|
* @author martin lenzelbauer
|
|
*/
|
|
class TicketCustomerContainer{
|
|
|
|
var $customers;
|
|
|
|
/** C'tor
|
|
*/
|
|
//------------------------------------------------
|
|
function TicketCustomerContainer(){
|
|
//------------------------------------------------
|
|
$this->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 = "<persons>";
|
|
foreach($this->customers as $c){
|
|
$xml .= $c->toXml();
|
|
}
|
|
$xml .= "</persons>";
|
|
return $xml;
|
|
}
|
|
|
|
|
|
/** sorts the customers alphabetically
|
|
* @return nothing
|
|
*/
|
|
//-----------------------------------------------
|
|
function sort(){
|
|
//-----------------------------------------------
|
|
for($i=0; $i<sizeof($this->customers)-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; $i<sizeof($this->customers); $i++){
|
|
$n1 = $this->customers[$i]->getSurname();
|
|
$n2 = $this->customers[$min]->getSurname();
|
|
if(strcasecmp($n1, $n2) < 0){
|
|
$min = $i;
|
|
}
|
|
}
|
|
return $min;
|
|
}
|
|
|
|
};
|
|
|
|
|
|
?>
|