Commit ac0613b2 authored by Victor Mocelin's avatar Victor Mocelin

Arrumada view que lista as pessoas. Fixes #6.

Adicionado campo timestamp na tabela de presença.
parent be16d564
Pipeline #2842 skipped
......@@ -23,6 +23,6 @@ angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services',
var db = $cordovaSQLite.openDB({name: 'ceitificator.db', iosDatabaseLocation: 'default'});
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, grr TEXT NOT NULL, email TEXT NOT NULL, UNIQUE (name, grr, email))");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS events(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, desc TEXT NOT NULL, date TEXT NOT NULL, place TEXT NOT NULL, hours TEXT NOT NULL, UNIQUE (name, desc, date, place, hours))");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people_events(event_id, person_id, FOREIGN KEY(event_id) REFERENCES events(id), FOREIGN KEY(person_id) REFERENCES people(id), UNIQUE (person_id, event_id))");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people_events(event_id, person_id, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY(event_id) REFERENCES events(id), FOREIGN KEY(person_id) REFERENCES people(id), UNIQUE (person_id, event_id))");
});
})
......@@ -82,7 +82,7 @@ angular.module('app.controllers', [])
$scope.eventX.place + "\n" +
$scope.eventX.hours + "\n";
for (var i = 0; i < $scope.people.length; i++){
for (var i = 0; i < $scope.people.length; i++) {
string += $scope.people[i].name + "#" +
$scope.people[i].email + "\n";
}
......
......@@ -66,7 +66,7 @@ angular.module('app.services', [])
var people = [];
var db = $cordovaSQLite.openDB({name: 'ceitificator.db',
iosDatabaseLocation: 'default'});
$cordovaSQLite.execute(db, "SELECT people.* FROM people, people_events WHERE people.id=people_events.person_id AND people_events.event_id=" + eventId)
$cordovaSQLite.execute(db, "SELECT people.* FROM people, people_events WHERE people.id=people_events.person_id AND people_events.event_id=" + eventId + " ORDER BY timestamp DESC")
.then(function(res) {
for(var i = 0; i < res.rows.length; i++) {
people.push(res.rows.item(i));
......
......@@ -12,7 +12,9 @@
<button id="listaDePresenAEventoX-button2" class="button button-positive button-block icon-right ion-ios-download" on-touch="storeData()">Salvar para arquivo</button>
<button id="listaDePresenAEventoX-button1" class="button button-positive button-block icon-right ion-qr-scanner" on-touch="scan()">Adicionar</button>
<ion-list>
<ion-item ng-repeat="person in people">{{person.name}} - {{person.grr}} - {{person.email}}</ion-item>
<ion-item ng-repeat="person in people">{{person.name}}<br>
GRR{{person.grr}}<br>
{{person.email}}</ion-item>
</ion-list>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment