function GetIncidentsByDay($date, $agencyShortName)
 {
     dprint("GetIncidentsByDay() Start.");
     try {
         $db = new DatabaseTool();
         if ($date == "") {
             $date = date("Y-m-d");
         }
         if ($agencyShortName == "") {
             // create the query
             $query = 'SELECT itemid,event,address,pubdate,pubtime,status,itemid,scrapedatetime,agencyid,fulladdress,lat,lng,zipcode FROM incidents WHERE pubdate = ? ORDER BY pubtime DESC';
             $mysqli = $db->Connect();
             $stmt = $mysqli->prepare($query);
             $stmt->bind_param("s", $date);
             // bind the varibale
         } else {
             $agencyManager = new AgencyManager();
             $agency = $agencyManager->GetAgencyFromShortName($agencyShortName);
             // create the query
             $query = 'SELECT itemid,event,address,pubdate,pubtime,status,itemid,scrapedatetime,agencyid,fulladdress,lat,lng,zipcode FROM incidents WHERE agencyid = ? AND pubdate = ? ORDER BY pubtime DESC';
             $mysqli = $db->Connect();
             $stmt = $mysqli->prepare($query);
             $stmt->bind_param("is", $agency->agencyid, $date);
             // bind the varibale
         }
         $results = $db->Execute($stmt);
         // create an array to put our results into
         $incidents = array();
         $ids = array();
         foreach ($results as $result) {
             if (!in_array($result['itemid'], $ids)) {
                 $incident = new Incident();
                 // pull the information from the row
                 $incident->event = $result['event'];
                 $incident->address = $result['address'];
                 $incident->pubdate = $result['pubdate'];
                 $incident->pubtime = $result['pubtime'];
                 $incident->status = $result['status'];
                 $incident->itemid = $result['itemid'];
                 $incident->scrapedatetime = $result['scrapedatetime'];
                 $incident->agencyid = $result['agencyid'];
                 $incident->fulladdress = $result['fulladdress'];
                 $incident->lat = $result['lat'];
                 $incident->lng = $result['lng'];
                 $incident->zipcode = $result['zipcode'];
                 $incidents[] = $incident;
                 $ids[] = $result['itemid'];
             }
         }
         // close our DB connection
         $db->Close($mysqli, $stmt);
     } catch (Exception $e) {
         dprint("Caught exception: " . $e->getMessage());
     }
     dprint("GetIncidentsByDay() Done.");
     return $incidents;
 }
 function IsValidAgenyShortName($shortname)
 {
     if (is_string($shortname) == False) {
         return False;
     }
     if (strlen($shortname) != 4) {
         return False;
     }
     $agencyManager = new AgencyManager();
     $valid = $agencyManager->ValidAgencyByShortName($shortname);
     return $valid;
 }
 function GetLocationsByDay($date, $agencyShortName)
 {
     dprint("GetLocationsByDay() Start.");
     try {
         $db = new DatabaseTool();
         if ($date == "") {
             $date = date("Y-m-d");
         }
         if ($agencyShortName == "") {
             // create the query
             $query = 'SELECT DISTINCT itemid,event,fulladdress,lat,lng,pubdate,pubtime,agencies.longname AS agencyname FROM incidents JOIN agencies ON incidents.agencyid = agencies.agencyid WHERE pubdate = ? AND lat <> "" AND lng <> "" GROUP BY itemid ORDER BY pubtime DESC';
             $mysqli = $db->Connect();
             $stmt = $mysqli->prepare($query);
             $stmt->bind_param("s", $date);
             // bind the varibale
         } else {
             $agencyManager = new AgencyManager();
             $agency = $agencyManager->GetAgencyFromShortName($agencyShortName);
             // create the query
             $query = 'SELECT DISTINCT itemid,event,fulladdress,lat,lng,pubdate,pubtime,agencies.longname AS agencyname FROM incidents JOIN agencies ON incidents.agencyid = agencies.agencyid WHERE incidents.agencyid = ? AND pubdate = ? AND lat <> "" AND lng <> "" GROUP BY itemid ORDER BY pubtime DESC';
             $mysqli = $db->Connect();
             $stmt = $mysqli->prepare($query);
             $stmt->bind_param("is", $agency->agencyid, $date);
             // bind the varibale
         }
         $results = $db->Execute($stmt);
         // create an array to put our results into
         $incidents = array();
         // decode the rows
         foreach ($results as $result) {
             $incident = (object) array('itemid' => $result['itemid'], 'event' => $result['event'], 'fulladdress' => $result['fulladdress'], 'lat' => $result['lat'], 'lng' => $result['lng'], 'publishdate' => $result['pubdate'], 'publishtime' => $result['pubtime'], 'agencyname' => $result['agencyname']);
             $incidents[] = $incident;
         }
         // close our DB connection
         $db->Close($mysqli, $stmt);
     } catch (Exception $e) {
         dprint("Caught exception: " . $e->getMessage());
     }
     dprint("GetLocationsByDay() Done.");
     return $incidents;
 }
Пример #4
0
    echo 'window.location = "./index.php"';
    echo '</script>';
}
?>


	<?php 
require_once "./tools/AgencyManager.class.php";
require_once "./tools/Agency.class.php";
require_once "./tools/IncidentManager.class.php";
require_once "./tools/Incident.class.php";
// get the agency we are viewing
$agencyshortname = $_GET['agency'];
// TODO: sanity check this
// create an instance of our agency manager object
$agencyManager = new AgencyManager();
// create an instance of our incident manager
$incidentManager = new IncidentManager();
// get agency information using the shortname passed in by the user
$agency = $agencyManager->GetAgencyFromShortName($agencyshortname);
// get the last 25 incidents this agency has seen
$incidents = $incidentManager->GetIncidentsByAgencyID($agency->agencyid, 25);
// note: 25 here is the number of incidents to return
// do some decode if we haven't decoded the 4 letter code yet
//if( $agency->longname == "" )
//	$agency->longname = "- unknown -";
// get the current year
$year = date("Y");
// get todays date for later use
$todaysdate = date("Y-m-d");
// get the total number of calls for todays date
Пример #5
0
require_once "./tools/AgencyManager.class.php";
require_once "./tools/Agency.class.php";
// calculate tomorrow
$tomorrowtime = strtotime('+1 day', strtotime($date));
$tommorrow = date('Y-m-d', $tomorrowtime);
// calculate yesterday
$yesterdaytime = strtotime('-1 day', strtotime($date));
$yesterday = date('Y-m-d', $yesterdaytime);
// get all of the incidents for the date passed in by the user
$start_get_incidents = getmicrotime();
$incidentManager = new IncidentManager();
$incidents = $incidentManager->GetIncidentsByDay($date, $agencyShortName);
$end_get_incidents = getmicrotime();
echo "\n\n<!-- incidents gotten in: " . ($end_get_incidents - $start_get_incidents) . "-->";
// to handle all agency related querys
$agencyManager = new AgencyManager();
// display links to go to previous day and next day
echo '<div class="yesterdaylink">';
echo '<a href="incidents.php?date=' . $yesterday . '">Incidents for ' . date("l F j, Y", strtotime($yesterday)) . '</a>';
echo '</div>';
if ($date != date("Y-m-d")) {
    echo '<div class="tomorrowlink">';
    echo '<a href="incidents.php?date=' . $tommorrow . '">Incidents for ' . date("l F j, Y", strtotime($tommorrow)) . '</a>';
    echo '</div>';
}
echo '<br><br>';
echo '<div>';
echo '<br>';
echo '<center><h2>Incidents for ' . date("l F j, Y", strtotime($date)) . '</h2></center>';
if ($agencyShortName != "") {
    $targetAgency = $agencyManager->GetAgencyFromShortName($agencyShortName);
Пример #6
0
	<th><font size="2">Today Call Count</font></th>
	<td><b><font size="2">Agency</font</th>
	<td><b><font size="2">Info</font></b></th>
	</tr>
	
	<td width=\"120\"></td>
	<td width=\"120\"></td>
	<td width=\"160\"></td>
	<td width=\"400\"></td>
	<td width=\"100\"></td>

	<?php 
require_once "./tools/IncidentManager.class.php";
require_once "./tools/AgencyManager.class.php";
require_once "./tools/Agency.class.php";
$agencyManager = new AgencyManager();
$incidentManager = new IncidentManager();
$agencies = $agencyManager->GetAllAgencies();
$dailycountsdict = $agencyManager->GetTodayAllAgencyCounts();
foreach ($agencies as $agency) {
    // get todays date
    //$todaysdate = date("Y-m-d");
    // get the total number of calls for today for the agency
    //$todaycallcount = $incidentManager->GetIncidentCountByAgencyIDAndDate($agency->agencyid, $todaysdate);
    if (isset($dailycountsdict[$agency->agencyid])) {
        $todaycallcount = $dailycountsdict[$agency->agencyid];
    } else {
        $todaycallcount = 0;
    }
    echo "<tr>\n";
    echo '<td width="80"><font size="2">' . $agency->shortname . "</font></td>\n";