function getAttendees(&$event) { global $tblprefix; $query = "SELECT " . Attendee::getFields('a') . "," . PersonDetail::getFields('p') . "," . Location::getFields('l') . " FROM " . $tblprefix . "attendee a" . " JOIN " . $tblprefix . "people p ON a.person_id = p.person_id" . " LEFT JOIN " . $tblprefix . "locations l ON l.location_id = a.location_id" . PersonDetail::getJoins(); $query .= " WHERE a.event_id = " . $event->event_id; $query .= $this->addPersonRestriction(" AND "); //TODO error message $result = $this->runQuery($query, ''); $res = array(); while ($row = $this->getNextRow($result)) { $e = new Attendee(); $e->loadFields($row, "a_"); $per = new PersonDetail(); $per->loadFields($row, L_HEADER, "p_"); $per->name->loadFields($row, "n_"); $per->name->person_id = $per->person_id; $e->person = $per; $e->location->loadFields($row, "l_"); $res[] = $e; } $this->freeResultSet($result); $event->attendees = $res; }
function getTrackedPeople() { global $tblprefix, $currentRequest, $err_listpeeps; $query = "SELECT p.person_id as p_person_id," . PersonDetail::getFields() . ",updated, DATE_FORMAT(updated, " . $currentRequest->datefmt . ") AS ddate" . " FROM " . $tblprefix . "people p " . PersonDetail::getJoins() . " JOIN " . $tblprefix . "tracking t ON p.person_id = t.person_id" . " WHERE " . "t.email = " . quote_smart($_SESSION["email"]); $result = $this->runQuery($query, $err_listpeeps); $res = array(); while ($row = $this->getNextRow($result)) { $per = new PersonDetail(); $per->loadFields($row, L_HEADER, "p_"); $per->name->loadFields($row, "n_"); $per->name->person_id = $per->person_id; $per->updated = $row["updated"]; $per->dupdated = $row["ddate"]; $res[] = $per; } return $res; }
function getMissingRecords($cen) { global $tblprefix; $tquery = "SELECT DISTINCT " . PersonDetail::getFields() . " FROM " . $tblprefix . "people p " . " LEFT JOIN " . $tblprefix . "attendee a ON p.person_id = a.person_id" . " LEFT JOIN " . $tblprefix . "census c ON a.event_id = c.event_id AND census = " . $cen->census_id . " JOIN " . $tblprefix . "census_years cy ON cy.census_id = " . $cen->census_id . PersonDetail::getJoins() . "WHERE c.event_id is null AND (b.date1 <= cy.census_date AND d.date1 >= cy.census_date)"; $tquery .= $this->addPersonRestriction(" AND ", "p"); $tquery .= " ORDER BY date_of_birth"; //TODO error message $tresult = $this->runQuery($tquery, ""); $ret = array(); while ($trow = $this->getNextRow($tresult)) { $p = new PersonDetail(); $p->loadFields($trow, L_HEADER, "p_"); $p->name->loadFields($trow, "n_"); $ret[] = $p; } $this->freeResultSet($tresult); return $ret; }
function getAttendeePlaces(&$locations, $person = null) { global $tblprefix, $strEvent, $datefmt; global $strBirthPlace, $strAddress; $query = "SELECT " . Attendee::getFields('a') . "," . PersonDetail::getFields('p') . ", " . Event::getFields("e") . "," . Location::getFields("l") . "," . Location::getFields("el") . " FROM " . $tblprefix . "attendee a" . " JOIN " . $tblprefix . "people p ON a.person_id = p.person_id" . " JOIN " . $tblprefix . "event e ON a.event_id = e.event_id" . " LEFT JOIN " . $tblprefix . "locations el ON el.location_id = e.location_id" . " LEFT JOIN " . $tblprefix . "locations l ON l.location_id = a.location_id" . PersonDetail::getJoins() . " WHERE (a.location_id is not null OR e.location_id is not null)" . " AND (NOT (e.etype = " . BANNS_EVENT . " OR e.etype=" . MARRIAGE_EVENT . "))"; $query .= $this->addPersonRestriction(" AND "); if ($locations->location_id > 0) { $query .= " AND (a.location_id = " . $locations->location_id . " OR e.location_id = " . $locations->location_id . ")"; } $presult = $this->runQuery($query, ""); while ($prow = $this->getNextRow($presult)) { $per = new PersonDetail(); $per->loadFields($prow, L_HEADER, 'p_'); $per->name->loadFields($prow, 'n_'); $per->setPermissions(); $e = new Event(); $e->loadFields($prow, "e_"); $loc = new Location(); $loc->loadFields($prow, "l_"); $loc->setPermissions(); if ($per->isViewable() && $loc->hasData()) { $text = $per->getLink() . ' '; switch ($e->type) { case CENSUS_EVENT: $text .= $strEvent[$e->type] . " " . $strBirthPlace; break; default: $text .= $strAddress; break; } $text .= ' ' . $e->getDate1(); if ($locations->location_id > 0 && $loc->location_id == $locations->location_id || $locations->location_id <= 0) { $p = $this->createPlace($locations, $loc, $text); } } $e->location->loadFields($prow, "el_"); $e->location->setPermissions(); if ($per->isViewable() && $e->location->hasData()) { $text = $per->getLink() . ' ' . $strEvent[$e->type] . ' ' . $e->getDate1(); if ($locations->location_id > 0 && $e->location->location_id == $locations->location_id || $locations->location_id <= 0) { $p = $this->createPlace($locations, $e->location, $text); } } } $this->freeResultSet($presult); }