Skip to content

Commit

Permalink
changed some things
Browse files Browse the repository at this point in the history
  • Loading branch information
tolson9 committed Apr 22, 2018
1 parent db36850 commit f92611c
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 45 deletions.
2 changes: 1 addition & 1 deletion login.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h1>ATL Gardens, Farms, Orchards</h1>
<div class="row">
<br>
<div class="col-xs-6">
<a href="vistitorregistration.html" class="btn btn-info">New Visitor Registration</a>
<a href="visitorregistration.html" class="btn btn-info">New Visitor Registration</a>
</div>
<div class="col-xs-6">
<a href="ownerregistration.html" class="btn btn-info">New Owner Registration</a>
Expand Down
2 changes: 1 addition & 1 deletion login.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $(function() {
//alert(JSON.stringify(result));
if(result.length == 0) {
//incorrect password
//alert("Incorrect Username or Password");
alert("Incorrect Username or Password");
} else {
document.cookie = result[0].USERNAME;

Expand Down
43 changes: 2 additions & 41 deletions visitor/visitorhome.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,47 +110,8 @@ <h3>Properties</h3>
</tbody>
</table>
</div>
<div class="col-xs-12 col-sm-4 hidden">
<div class="row">
<table class="table table-striped">
<thead>
<tr><th>Detailed View</th></tr>
</thead>
<tbody>
<tr><td>Name:</td></tr>
<tr><td>Owner:</td></tr>
<tr><td>Visits:</td></tr>
<tr><td>Address:</td></tr>
<tr><td>City:</td></tr>
<tr><td>Zip:</td></tr>
<tr><td>Size:</td></tr>
<tr><td>Avg. Rating:</td></tr>
<tr><td>Type:</td></tr>
<tr><td>Public:</td></tr>
<tr><td>Comercial:</td></tr>
<tr><td>ID:</td></tr>

<tr><td>Crops:</td></tr>
<tr><td>Animal:</td></tr>

<tr>
<td>
<div class="form-group">
<label for="rating">Rate Visit</label>
<select class="form-control" id="rating">
<option>1 Star</option>
<option>2 Star</option>
<option>3 Star</option>
<option>4 Star</option>
<option>5 Star</option>
</select>
</div>
<a href="#" class="btn btn-primary">Log Visit</a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-xs-12 col-sm-4 hidden" id="detail-area">

</div>
</div>
</div>
Expand Down
102 changes: 101 additions & 1 deletion visitor/visitorhome.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,106 @@
function query(sql, callback) {
$.ajax({
url:"http://localhost:3000/query",
data: {statement: sql},
dataType: "jsonp",
//headers: {'Access-Control-Allow-Origin': *},
//crossDomain: true,

}).done(function(result){
callback(result);
});
}



$(function() {
//document has loaded
//alert(document.cookie);
$('#name').html(document.cookie);
var username = document.cookie
$('#name').html(username);

if(username) {
//query database and get all
var sql = "Select *, (Select Count(*) From VISIT AS V Where P.PropID = V.PropID) AS Visits, (Select AVG(VI.Rating) From VISIT AS VI Where P.PropID = VI.PropID) AS AvgRating From PROPERTY AS P Where ApprovedBy != NULL";

query(sql,function(result){
//alert(JSON.stringify(result));
if(result.length == 0) {
//incorrect password
alert("No Properties");
} else {

$.each(result, function(index, row) {
$('#table-body').append("<a class='table-result'><tr>");
$.each(row, function(key, col) {
if(key = "PROPID") {
$('#table-body').append("<td class='propid'>"+ col +"</td>");
}
$('#table-body').append("<td>"+ col +"</td>");
});
$('#table-body').append("</tr></a>");
});

}
});
}

$('.table-result').click(function(){
//show detail view
$('#table-area').removeClass('col-sm-12');
$('#table-area').addClass('col-sm-8');
$('#detail-area').removeClass('hidden');

//populate detail view
var propid = $(this).find('.propid').val();
var sql = "Select * From PROPERTY Where PropID = '" + propid +"'";

query(sql, function(result) {
if(result.length > 0) {
$(this).html =
"<div id='propid-tag' class='hidden'>"+result[0]+"</div>" +
"<div class='row'>" +
"<table class='table table-striped'>" +
"<thead>" +
"<tr><th>Detailed View</th></tr>" +
"</thead>" +
"<tbody>" +
"<tr><td>Name:"+ result[0] +"</td></tr>" +
"<tr><td>Owner:"+ result[0] +"</td></tr>" +
"<tr><td>Visits:"+ result[0] +"</td></tr>" +
"<tr><td>Address:"+ result[0] +"</td></tr>" +
"<tr><td>City:"+ result[0] +"</td></tr>" +
"<tr><td>Zip:"+ result[0] +"</td></tr>" +
"<tr><td>Size:"+ result[0] +"</td></tr>" +
"<tr><td>Avg. Rating:"+ result[0] +"</td></tr>" +
"<tr><td>Type:"+ result[0] +"</td></tr>" +
"<tr><td>Public:"+ result[0] +"</td></tr>" +
"<tr><td>Comercial:"+ result[0] +"</td></tr>" +
"<tr><td>ID:"+ result[0] +"</td></tr>" +

"<tr><td>Crops:</td></tr>" +
"<tr><td>Animal:</td></tr>" +
"<tr>" +
"<td>" +
"<div class='form-group'>" +
"<label for='rating'>Rate Visit</label>" +
"<select class='form-control' id='rating'>" +
"<option>1 Star</option>" +
"<option>2 Star</option>" +
"<option>3 Star</option>" +
"<option>4 Star</option>" +
"<option>5 Star</option>" +
"</select>" +
"</div>" +
"<a href='#' class='btn btn-primary' id='logvisit'>Log Visit</a>" +
"</td>" +
"</tr>" +
"</tbody>" +
"</table>" +
"</div>";
}
});

});

});
4 changes: 3 additions & 1 deletion visitorregistration.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="visitorregistration.js"></script>

</head>


Expand Down Expand Up @@ -43,7 +45,7 @@ <h1>New Visitor Registration</h1>
</div>
<div class="row">
<div class="col-xs-6 text-center">
<a href="#" class="btn btn-primary">Submit</a>
<a href="#" class="btn btn-primary" id="submit">Submit</a>
</div>
<div class="col-xs-6 text-center">
<a href="login.html" class="btn btn-info">Back</a>
Expand Down
49 changes: 49 additions & 0 deletions visitorregistration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
function query(sql, callback) {
$.ajax({
url:"http://localhost:3000/query",
data: {statement: sql},
dataType: "jsonp",
//headers: {'Access-Control-Allow-Origin': *},
//crossDomain: true,

}).done(function(result){
callback(result);
});
}

function insert(sql) {
$.ajax({
url:"http://localhost:3000/query",
data: {statement: sql},
dataType: "jsonp"
});
}

$(function() {
//document has loaded
//alert(document.cookie);
$('#submit').click(function() {
var email = $('#email').val();
var name = $('#name').val();
var password = $('#password').val();
var checkpass = $('#passwordcheck').val();

if(email.length && name && password && checkpass) {
if(password == checkpass) {
//query database and get all
var sql = "Insert Into USER (Username, Email, Password, Usertype) " +
"Values (\'" + name + "\',\'" + email + "\', \'" + password + "\', \'Visitor\')";

insert(sql);

document.cookie = name;
document.location = "/visitor/visitorhome.html";
} else {
alert("password and check password must match");
}
} else {
alert("error");
}
});

});

0 comments on commit f92611c

Please sign in to comment.