var routes_Search = { set_int : "", lazy_scroll : false, event_time : "", truck_watch_name : "", initialize : function(){ $('#get_routes').bind('click', function(){ console.log('get the log'); var start_date = $('#my_start_date').val(); var end_date = $('#my_start_date').val(); // check for value in the date bar if ( start_date == "" || end_date == "" ){ alert ('You must select and start and end date!'); } else{ routes_Search.populate_Routes( start_date, end_date ); } // color the row var id = $(this).attr('id_local'); $('#'+id).css('background-color','gray'); $('#right_jobs').html(""); }); this.bind_close_view_all_trucks_overlay(); /*$('#truck_job').bind('click', function(){ console.log('get the job'); var departure_time = $.attr('dt'); var return_time = $(this).attr('rt'); var vehicle = $(this).attr('veh'); console.log( 'departure time' + departure_time ); routes_Search.truck_job( departure_time, return_time, vehicle ); });*/ var month_a = {0:"01",1:"02",2:"03",3:"04",4:"05",5:"06",6:"07",7:"08",8:"09",9:"10",10:"11",11:"12"}; var today = new Date(); var milliseconds = today.getTime(); var time_diff = 1000 * 60 * 60 * 24 * 15; var time_diff_day = 1000 * 60 * 60 * 24; milliseconds = milliseconds - time_diff_day; var year = today.getFullYear(); var month = today.getMonth(); var start = new Date(milliseconds); var start_year = start.getFullYear(); var start_month = start.getMonth(); var start_day = start.getDate(); var start_date = month_a[start_month]+"/"+start_day+"/"+start_year; var day = today.getDate(); var todays_date = month_a[month]+"/"+day+"/"+year; $('#my_start_date').val( start_date ); //$('#my_end_date').val( todays_date ); }, pull_time_slices : function(){ $('#global_message').html("Pulling Stored Time Slices..."); $('#global_message').show(); $.ajax({ type: "get", url: "/grab_routes4.php", data: {"search_type" : "pull_time_slices", "client_id" : } }).done(function(results){ var jobs_o = JSON.parse(results); var adder = ""; for( key in jobs_o ){ adder += "Name: "+jobs_o[key].slice_name+" Link: /time_slice/"+jobs_o[key].slice_id+"/
"+ "Vehicle: " + jobs_o[key].fleetio_match+ " Start Time: " + jobs_o[key].start_time + " End Time: " + jobs_o[key].end_time + " *Warning - Deleting may permanently get rid of this data. Do not click unless you are sure.

"; } $('#time_slices').html(adder); $('#global_message').hide(); routes_Search.bind_time_slice_delete(); }); }, bind_time_slice_delete : function(){ $('.delete_slice').click(function(){ var slice_id = $(this).attr('slice_id'); $('#global_message').html("Delete Time Slice..."); $('#global_message').show(); $.ajax({ type: "post", url: "/grab_routes4.php", data: {"search_type" : "delete_time_slice", "client_id" : , "slice_id" : slice_id} }).done(function(results){ if ( results == 'success' ){ routes_Search.pull_time_slices(); $('#global_message').hide(); } }); }); }, bind_close_view_all_trucks_overlay : function(){ $('#close_view_all_trucks_overlay').click(function(){ $('#view_all_trucks_overlay').hide(); $('#global_question_cover').hide(); clearInterval(routes_Search.set_int); }); }, populate_expansives : function(){ $.ajax({ type: "get", url: "/expansive_geofences.txt", data: {"search_type" : "get_expansive_geofences", "client_id" : } }).done(function(results){ var jobs_o = JSON.parse(results); var j_adder = ""; for( key in jobs_o ){ j_adder += ""; } $('#inv_range_job').html(j_adder); }); }, get_route_map : function(){ //var url = $(this).attr("url"); //$('#id_frame_eetrack_map').attr('src', url); $('#old_map').css('display', 'none'); $('#new_google_map').css('display', 'none'); $('#new_google_map_buttons').css('display', 'none'); $('#new_map').css('display', 'block'); var client_id = $(this).attr('client_id'); var nick = $(this).attr('nick'); var start_date = $(this).attr('start_date'); var end_date = $(this).attr('end_date'); $('#tabs').tabs('option', 'active', 5); GetMap(nick, client_id, start_date, end_date); }, bind_view_exception : function(){ $('.view_exception_button').click(function(){ var obj = $(this); routes_Search.view_exception(obj); }); }, bind_view_payroll_exception : function(){ $('.view_payroll_exception_button').click(function(){ var obj = $(this); routes_Search.view_exception(obj); }); }, view_exception : function(obj){ //var url = $(this).attr("url"); //$('#id_frame_eetrack_map').attr('src', url); $('#old_map').css('display', 'none'); $('#new_google_map').css('display', 'none'); $('#new_google_map_buttons').css('display', 'none'); $('#new_map').css('display', 'block'); var client_id = obj.attr('client_id'); var nick = obj.attr('nick'); var start_date = obj.attr('start_date'); var end_date = obj.attr('end_date'); $('#tabs').tabs('option', 'active', 5); routes_Search.lazy_scroll = true; routes_Search.event_time = obj.attr('event_time'); GetMap(nick, client_id, start_date, end_date); }, bind_view_route : function(){ $('.view_route_button').click(function(){ //var url = $(this).attr("url"); //$('#id_frame_eetrack_map').attr('src', url); $('#old_map').css('display', 'none'); $('#new_google_map').css('display', 'none'); $('#new_google_map_buttons').css('display', 'none'); $('#new_map').css('display', 'block'); var client_id = $(this).attr('client_id'); var nick = $(this).attr('nick'); var start_date = $(this).attr('start_date'); var end_date = $(this).attr('end_date'); $('#tabs').tabs('option', 'active', 5); GetMap(nick, client_id, start_date, end_date); }); }, bind_make_inv_range : function(){ $('#inv_range_button').click(function(){ //$('#old_map').css('display', 'none'); //$('#new_google_map').css('display', 'none'); //$('#new_google_map_buttons').css('display', 'none'); //$('#new_map').css('display', 'block'); var client_id = ; var nick = $('#truck_watch_name').val(); var start_date = $('#start_date_tw').val()+' '+$('#start_time_hour_tw').val()+':'+$('#start_time_min_tw').val()+':00 '+$('#start_time_meridiem_tw').val(); var end_date = $('#end_date_tw').val()+' '+$('#end_time_hour_tw').val()+':'+$('#end_time_min_tw').val()+':00 '+$('#end_time_meridiem_tw').val(); var job_id = $('#inv_range_job').val(); // call inventory line maker /*$('#global_message').html('Creating Inventory Lines......'); $('#global_message').show('fast'); $.ajax({ type: "get", url: "/grab_routes3.php", data: {"search_type" : "search_inventory_geos", "client_id" : client_id, "start_date" : start_date, "end_date" : end_date, "nick" : nick, "timezone" : '' } }).done(function(results){ if( results == 'success' ){ $('#global_message').hide('fast'); } });*/ $('#global_message').html('Creating Inventory Lines......'); $('#global_message').show('fast'); $.ajax({ type: "post", url: "/grab_routes3.php", data: {"search_type" : "create_inventory_line", "client_id" : client_id, "start_date" : start_date, "end_date" : end_date, "nick" : nick, "timezone" : '', "job_id" : job_id } }).done(function(results){ if( results == 'success' ){ $('#global_message').hide('fast'); } }); //$('#tabs').tabs('option', 'active', 5); //GetMap(nick, client_id, start_date, end_date); }); }, bind_make_inv : function(){ $('.gps_make_inv_line').click(function(){ //$('#old_map').css('display', 'none'); //$('#new_google_map').css('display', 'none'); //$('#new_google_map_buttons').css('display', 'none'); //$('#new_map').css('display', 'block'); var client_id = $(this).attr('client_id'); var nick = $(this).attr('nick'); var start_date = $(this).attr('start_date'); var end_date = $(this).attr('end_date'); var job_id = $(this).attr('job_id'); // call inventory line maker /*$('#global_message').html('Creating Inventory Lines......'); $('#global_message').show('fast'); $.ajax({ type: "get", url: "/grab_routes3.php", data: {"search_type" : "search_inventory_geos", "client_id" : client_id, "start_date" : start_date, "end_date" : end_date, "nick" : nick, "timezone" : '' } }).done(function(results){ if( results == 'success' ){ $('#global_message').hide('fast'); } });*/ $('#global_message').html('Creating Inventory Lines......'); $('#global_message').show('fast'); $.ajax({ type: "post", url: "/grab_routes3.php", data: {"search_type" : "create_inventory_line", "client_id" : client_id, "start_date" : start_date, "end_date" : end_date, "nick" : nick, "timezone" : '', "job_id" : job_id } }).done(function(results){ if( results == 'success' ){ $('#global_message').hide('fast'); } }); //$('#tabs').tabs('option', 'active', 5); //GetMap(nick, client_id, start_date, end_date); }); }, bind_view_route_tw : function(){ $('#view_route_button_tw').click(function(){ var client_id = $(this).attr('client_id'); routes_Search.truck_watch_name = $('#truck_watch_name').val(); var nick = $('#truck_watch_name').val(); var start_date = $('#start_date_tw').val(); var end_date = $('#end_date_tw').val(); // get time var hour_start = $('#start_time_hour_tw').val(); var min_start = $('#start_time_min_tw').val(); var meridiem_start = $('#start_time_meridiem_tw').val(); var hour_end = $('#end_time_hour_tw').val(); var min_end = $('#end_time_min_tw').val(); var meridiem_end = $('#end_time_meridiem_tw').val(); var truck_watch_vehicle_class = $('#truck_watch_vehicle_class').val(); start_date = start_date + " " + hour_start + ":" + min_start + ":00 " + meridiem_start; end_date = end_date + " " + hour_end + ":" + min_end + ":00 " + meridiem_end; if ( nick == 'view_all' ){ $('#view_all_trucks_overlay').show(); $('#global_question_cover').show(); console.log("view_all"); //GetMapAll(, truck_watch_vehicle_class ); var map_date = $('#route_builder_date_picker').val(); if( route_Builder.opt_remember_date != map_date ){ route_Builder.opt_remember_routes = Array(); } route_Builder.new_watch = true; route_Builder.open_watch_map( map_date ); clearInterval(routes_Search.set_int); routes_Search.set_int = setInterval(function(){ //GetMapAll(, truck_watch_vehicle_class); var map_date = $('#route_builder_date_picker').val(); route_Builder.open_watch_map( map_date ); }, 300000 ); } else if ( nick == 'view_all_no_opt'){ $('#tabs').tabs('option', 'active', 5); $('#old_map').css('display', 'none'); $('#new_google_map').css('display', 'none'); $('#new_google_map_buttons').css('display', 'none'); $('#new_map').css('display', 'block'); GetMapAll(, truck_watch_vehicle_class ); //var map_date = $('#route_builder_date_picker').val(); //if( route_Builder.opt_remember_date != map_date ){ //route_Builder.opt_remember_routes = Array(); //} //route_Builder.new_watch = true; //route_Builder.open_map( map_date ); clearInterval(routes_Search.set_int); routes_Search.set_int = setInterval(function(){ GetMapAll(, truck_watch_vehicle_class); //var map_date = $('#route_builder_date_picker').val(); //route_Builder.open_map( map_date ); }, 300000 ); } else{ $('#tabs').tabs('option', 'active', 5); $('#old_map').css('display', 'none'); $('#new_google_map').css('display', 'none'); $('#new_google_map_buttons').css('display', 'none'); $('#new_map').css('display', 'block'); clearInterval(routes_Search.set_int); GetMap(nick, client_id, start_date, end_date); } }); }, active_colors : "all", /*bind_update_truck_colors : function(){ var truck_watch_vehicle_class = $('#truck_watch_vehicle_class').val(); GetMapAll(, truck_watch_vehicle_class); clearInterval(routes_Search.set_int); routes_Search.set_int = setInterval(function(){ GetMapAll(, truck_watch_vehicle_class); }, 300000 ); },*/ bind_all_routes : function(){ /*$('#view_all_trucks').click(function(){ //var url = $(this).attr("url"); //$('#id_frame_eetrack_map').attr('src', url); $('#old_map').css('display', 'none'); $('#new_map').css('display', 'block'); //var client_id = $(this).attr('client_id'); //var nick = $(this).attr('nick'); //var start_date = $(this).attr('start_date'); //var end_date = $(this).attr('end_date'); $('#tabs').tabs('option', 'active', 5); GetMapAll(); });*/ }, bind_view_job : function(){ $('.view_job_button').click(function(){ //var url = $(this).attr("url"); //$('#id_frame_eetrack_map').attr('src', url); $('#old_map').css('display', 'none'); $('#new_google_map').css('display', 'none'); $('#new_google_map_buttons').css('display', 'none'); $('#new_map').css('display', 'block'); var client_id = $(this).attr('client_id'); var nick = $(this).attr('nick'); var start_date = $(this).attr('start_date'); var end_date = $(this).attr('end_date'); $('#tabs').tabs('option', 'active', 5); GetMap(nick, client_id, start_date, end_date); }); }, bind_data_export : function(){ console.log('my export_binded'); $('.gps_export_data').click(function(){ var client_id = $(this).attr('client_id'); var nick = $(this).attr('nick'); var start_date_time = $(this).attr('start_date'); var end_date_time = $(this).attr('end_date'); console.log('my export clicked'); console.log(nick); console.log(client_id); console.log(start_date_time); console.log(end_date_time); document.location = "/grab_routes.php?search_type=get_route_points_export&vehicle=" + nick + "&client_id=" + client_id + "&start_date_time=" + start_date_time + "&end_date_time=" + end_date_time + "&offset=&" + "timezone="; }); }, populate_Routes : function(start_date, end_date){ $('#route_stop').css('visibility', 'visible'); $.ajax({ type: "get", url: "/grab_routes.php", data: "search_type=route_range&start_date="+start_date+"&end_date="+end_date+"&user_id=&offset=&timezone=", success: function(data){ $('#routes_jobs').html(data); $('#route_stop').css('visibility', 'hidden'); $('.truck_job').bind('click', function(e){ e.preventDefault(); var departure_time = $(this).attr('dt'); var return_time = $(this).attr('rt'); var vehicle = $(this).attr('veh'); var loc_id = $(this).attr('id_local'); var route_id = $(this).attr('route_id'); var route_date = $(this).attr('route_date'); routes_Search.truck_job(departure_time, return_time, vehicle, loc_id, route_id, route_date); }); routes_Search.bind_view_route(); //routes_Search.bind_make_inv(); } }); }, initial_population : function(){ var start_date = $('#my_start_date').val(); var end_date = $('#my_start_date').val(); //$('#view_routes').bind('click', function(){ // routes_Search.forward_to_route(); //}); // check for value in the date bar if ( start_date == "" || end_date == "" ){ alert ('Error, dates not read, contact admin.'); } else{ routes_Search.populate_Routes( start_date, end_date ); } }, post : function (path, params, method) { method = method || "post"; // Set method to post by default if not specified. // The rest of this code assumes you are not using a library. // It can be made less wordy if you use one. var form = document.createElement("form"); form.setAttribute("method", method); form.setAttribute("action", path); for(var key in params) { if(params.hasOwnProperty(key)) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", key); hiddenField.setAttribute("value", params[key]); form.appendChild(hiddenField); } } document.body.appendChild(form); form.submit(); }, truck_job : function(departure_time, return_time, vehicle, loc_id, route_id, route_date){ //console.log('truck_job'); $('#route_stop').css('visibility', 'visible'); $.ajax({ type: "post", url: "/grab_routes.php", data: "search_type=job_range&level_dropdown=&truck="+vehicle+"&start_date="+departure_time+"&end_date="+return_time+"&client_id=&offset=&timezone=&route_id="+route_id+"&route_date="+route_date, success: function(data){ $('#right_jobs').html(data); routes_Search.bind_view_job(); routes_Search.bind_data_export(); $('#route_stop').css('visibility', 'hidden'); // color the row console.log(loc_id); $(routes_Search.row_color).css('background-color',''); routes_Search.row_color = '#row_'+loc_id+' td'; $('#row_'+loc_id+' td').css('background-color','#C0C0C0'); routes_Search.bind_make_inv(); } }); //var my_location = "http://www.eetrack.com/RouteSpan.aspx"; //routes_Search.post(my_location, { __EVENTTARGET : "GridView2", __EVENTARGUMENT : "ViewPlayback$2" }); }, row_color : "", };