Cron jobs final

master
Goncalo Bras 2017-08-18 09:51:24 +01:00
parent 15fad88d88
commit dac08d4fbc
11 changed files with 452 additions and 9209 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
laravel/CRON_JOB_LOG.txt
laravel/NUL

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ use DateTime;
class UpdateDatabase extends Command
{
private $keys = array("AIzaSyDs4W6IghtD3Wom6EZ_nxM934CR3vLqtTs", "AIzaSyDsZDCiU1k6mSuywRRL88xxXY-81RMEU7s", "AIzaSyAHkz73a9x-GmDi6-TrRKdmnrPEHZE2SFs", "AIzaSyAlJB4WvHqzbe2lmydazxqQsho3aqPSVQw");
private $keys = array("AIzaSyDsZDCiU1k6mSuywRRL88xxXY-81RMEU7s", "AIzaSyAHkz73a9x-GmDi6-TrRKdmnrPEHZE2SFs", "AIzaSyAlJB4WvHqzbe2lmydazxqQsho3aqPSVQw", "AIzaSyDs4W6IghtD3Wom6EZ_nxM934CR3vLqtTs");
/**
* The name and signature of the console command.
*

View File

@ -97,7 +97,7 @@ class LandingController extends BaseController
$stations = Station::join('district', 'station.district', 'district.id')
->join('fuel_price', 'station.fuel_price', 'fuel_price.id')
->join('location', 'station.location', 'location.id')
->join('services', 'station.services', 'services.id')
//->join('services', 'station.services', 'services.id')
->where('district.name','like', "%$district%")
->where("fuel_price.$fuelType",'!=', null)
->orderBy("fuel_price.$fuelType", "asc")

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Mail;
use App\Vehicle;
use App\Vehicles;
@ -21,6 +22,8 @@ class UserPageController extends Controller
{
private $apiKey = 'AIzaSyDsZDCiU1k6mSuywRRL88xxXY-81RMEU7s';
private $address;
public function index(Request $request)
{
$user = Auth::user();
@ -309,4 +312,29 @@ class UserPageController extends Controller
}
public function sendEmailRoute(Request $request){
/*
Mail::raw('Endereço $this->address', function ($message){
$message->from('geo.comb.ipl@gmail.com')
->to(Auth::user()->email)
->subject("A minha rota Geocomb");
});
$user = Auth::user();
$vehicles = Vehicle::join('vehicles', 'vehicle.id', 'vehicles.vehicle_id')
->join('users', 'users.id', 'vehicles.user_id')
->where('users.email', $user->email)
->select('vehicle.id as vehicleId', 'brand', 'model')
->get();
$vehicleData = null;
$vehicleData = Vehicle::where('id', $request->upSelectVehicle)
->first();
return view('planRoute', ['name'=>$user->name, 'vehicles' => $vehicles, 'vehicleData' => $vehicleData]);*/
}
}

View File

@ -29,7 +29,8 @@ return [
|
*/
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
//'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'host' => env('MAIL_HOST', ''),
/*
|--------------------------------------------------------------------------
@ -56,8 +57,8 @@ return [
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
'address' => env('MAIL_FROM_ADDRESS', null),
'name' => env('MAIL_FROM_NAME', null),
],
/*
@ -84,9 +85,9 @@ return [
|
*/
'username' => env('MAIL_USERNAME'),
'username' => env('MAIL_USERNAME', ''),
'password' => env('MAIL_PASSWORD'),
'password' => env('MAIL_PASSWORD', ''),
/*
|--------------------------------------------------------------------------

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -3,6 +3,7 @@ var js = $(document).ready(function(){
var waypts = [];
getLocation();
var routePoints = [];
$("#district").val(localStorage.getItem("district"));
@ -13,18 +14,18 @@ var js = $(document).ready(function(){
response($.ui.autocomplete.filter(array, request.term));
}else{
$.ajax({
url: "api/districts",
type: "GET",
dataType: "json",
//delay: 50,
data: request.term,
url: "api/districts",
type: "GET",
dataType: "json",
//delay: 50,
data: request.term,
success: function (data) {
response(array = $.map(data["districts"] , function (key, value) {
return data["districts"][value];
}))}
success: function (data) {
response(array = $.map(data["districts"] , function (key, value) {
return data["districts"][value];
}))}
});
});
}
}
});
@ -88,18 +89,18 @@ var array2;
$.ajax({
async: false,
url: link,
type: "GET",
dataType: "json",
type: "GET",
dataType: "json",
success: function (data) {
stationsData = data["stations"];
//console.table(stationsData);
},
error: function (textStatus, errorThrown) {
console.log("Error getting the station data")
}
error: function (textStatus, errorThrown) {
console.log("Error getting the station data")
}
});
});
}
//console.table(stationsData);
@ -116,7 +117,7 @@ var array2;
if($("#latitude").val()!='' && $("#longitude").val()!=''){
coordinates = {"latitude": $("#latitude").val(), "longitude": $("#longitude").val()};
}else{
coordinates = {"latitude": 39.676944, "longitude": -8.1425};
coordinates = {"latitude": 39.676944, "longitude": -8.1425};
}
}
@ -158,11 +159,11 @@ var array2;
}else{
if($("#latitude").val()==="" || $("#longitude").val()===""){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
alert("Geolocation is not supported by this browser.");
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
alert("Geolocation is not supported by this browser.");
}
}
}
}
@ -179,20 +180,20 @@ var array2;
$.ajax({
async: false,
url: link,
type: "GET",
dataType: "json",
type: "GET",
dataType: "json",
success: function (data) {
localStorage.setItem("district", data["results"]["0"]["address_components"]["1"]["long_name"]);
},
error: function (textStatus, errorThrown) {
console.log("Error getting the station data")
}
error: function (textStatus, errorThrown) {
console.log("Error getting the station data")
}
});
});
submitForm();
submitForm();
}
function submitForm(){
@ -219,42 +220,42 @@ var array2;
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
function geocodeAddress(geocoder, resultsMap) {
var address = $('#district').val();
var location = { 'latitude':null, 'longitude':null};
geocoder.geocode({'address': address}, function(results, status) {
if (status === 'OK') {
location.latitude = results[0].geometry.location.lat();
location.longitude = results[0].geometry.location.lng();
initMap(location);
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
var address = $('#district').val();
var location = { 'latitude':null, 'longitude':null};
geocoder.geocode({'address': address}, function(results, status) {
if (status === 'OK') {
location.latitude = results[0].geometry.location.lat();
location.longitude = results[0].geometry.location.lng();
initMap(location);
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
$('#landingSearch').click(function(){
/*$.ajax({
url: "api/stations",
type: "GET",
dataType: "json",
//delay: 50,
//data: request,
url: "api/stations",
type: "GET",
dataType: "json",
//delay: 50,
//data: request,
success: function (data) {
response($.map(data["districts"] , function (key, value) {
//console.log(data["districts"][value]);
return data["districts"][value];
}))}
success: function (data) {
response($.map(data["districts"] , function (key, value) {
//console.log(data["districts"][value]);
return data["districts"][value];
}))}
});*/
initMap();
});*/
initMap();
});
function updateVehiclePage(brand, model, fuel, consumption, preferred){
@ -338,7 +339,7 @@ var array2;
});
currentMarker.addListener('dblclick', function() {
alert("double click"+ currentMarker.position);
//alert("double click"+ currentMarker.position);
waypts.push({
location:currentMarker.position,
stopover: true
@ -352,24 +353,36 @@ var array2;
});
}
$('#sendRouteEmail').click(function(){
//console.table(routePoints);
var start = routePoints["legs"][0]["start_address"];
var station = routePoints["legs"][0]["end_address"];
var end = routePoints["legs"][1]["end_address"];
var link = "https://www.google.com/maps/dir/"+start+"/"+station+"/"+end;
$('#routeLink').val("asdf");
console.log(link);
});
function calculateAndDisplayRoute(directionsService, directionsDisplay) {
directionsService.route({
origin: $("#upOrigin").val(),
destination: $("#upDestination").val(),
waypoints: waypts,
optimizeWaypoints: true,
travelMode: 'DRIVING'
}, function(response, status) {
if (status === 'OK') {
directionsDisplay.setDirections(response);
var route = response.routes[0];
directionsService.route({
origin: $("#upOrigin").val(),
destination: $("#upDestination").val(),
waypoints: waypts,
optimizeWaypoints: true,
travelMode: 'DRIVING'
}, function(response, status) {
if (status === 'OK') {
directionsDisplay.setDirections(response);
var route = response.routes[0];
routePoints = route;
//console.table(route);
} else {
window.alert('Directions request failed due to ' + status);
}
});
}
} else {
window.alert('Directions request failed due to ' + status);
}
});
}
function getCoordinates(){
@ -397,33 +410,33 @@ var array2;
return coordinates;
}
function getStationsUP(){
var origin = $("#upOrigin").val();
var destination = $("#upDestination").val();
var autonomy = localStorage.getItem("autonomy");
var link= "api/stationsup/"+origin+"/"+destination+"/"+autonomy;
var stationsData =null;
//console.log(link);
$.ajax({
async: false,
url: link,
type: "GET",
dataType: "json",
success: function (data) {
stationsData = data["stations"];
//console.table(stationsData);
},
function getStationsUP(){
var origin = $("#upOrigin").val();
var destination = $("#upDestination").val();
var autonomy = localStorage.getItem("autonomy");
var link= "api/stationsup/"+origin+"/"+destination+"/"+autonomy;
var stationsData =null;
//console.log(link);
$.ajax({
async: false,
url: link,
type: "GET",
dataType: "json",
success: function (data) {
stationsData = data["stations"];
//console.table(stationsData);
},
error: function (textStatus, errorThrown) {
console.log("Error getting the station data")
}
error: function (textStatus, errorThrown) {
console.log("Error getting the station data")
}
});
});
//console.table(stationsData);
return stationsData;
//console.table(stationsData);
return stationsData;
}
}
window.initMap = initMap;
window.initMapUP = initMapUP;

View File

@ -87,6 +87,16 @@
</div>
<form method="post" action="{{route('sendRouteEmail')}}">
{{csrf_field()}}
<input type="text" name="routeLink">
</form>
<a id="sendRouteEmail" type="button" class="btn btn-info btn-lg" >Enviar rota para o meu Email</a>
</div>
</div>

View File

@ -65,6 +65,8 @@ Route::group(['middleware' => 'auth'], function () {
Route::get('/userpage/info', 'UserPageController@getInfo')->name('manageInfo');
Route::get('/userpage/vehicles/{id}', 'UserPageController@removeVehicle')->name('removeVehicle');
Route::post('/userpage', 'UserPageController@index')->name('selectVehicle');
Route::get('/sendRouteEmail', 'UserPageController@sendEmailRoute')->name('sendRouteEmail');
Route::post('/sendRouteEmail', 'UserPageController@sendEmailRoute')->name('sendRouteEmail');
});
Route::post('/showGpsCoordinates', 'LandingController@index');