File manager - Edit - /home/autoph/public_html/projects/document_tracking/public/js/analytics.js
Back
function documentGet(category){ alert(category); $.ajax() } $(document).ready(function(e){ var myChart2 = null; // var myChart3 = null; // var myChart4 = null; // var mychart5 = null; // var mychart6 = null; var access_token = localStorage.getItem("token"); $('#indv_id').on('change', function(e){ var id = $('#indv_id').val(); $.ajax({ type: "GET", url:"api/v2/user/analyticsDashboard?id=" + id, datatype:"json", data: null, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ // console.log(response); google.charts.load('current', {'packages':['timeline']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var dataArray = [["name", "start", "end"],]; $.each(response, function (index,value) { //console.log(value); dataArray.push([value.name, new Date(value.start), new Date(value.end)]); }); // console.log(dataArray); var figure = google.visualization.arrayToDataTable(dataArray) var view = new google.visualization.DataView(figure); var chart = new google.visualization.Timeline(document.getElementById("timeline")); chart.draw(view); } }, error: function(e){ alert("something went wrong. Please check your credentials"); } }); }); $('#to_date').on('change', function(e){ if(!$('#from_date').val()){ alert('Please choose starting date'); } }); $('#open-modal-date-filter').on('click', function(e){ // alert('trying to open the modal'); $("#date-filter").modal("show"); }); $('#type_filter_btn').on('click', function(e){ $("#type-filter").modal("show"); // alert("pinindot"); }); $('#type_generate_report_btn').on('click', function(e){ $("#type-generate").modal("show"); }) $('#comp_id').on('change', function(e){ var comp_id = $('#comp_id').val(); $('#dealer_id').find('option').not(':first').remove(); // alert(comp_id) $.ajax({ type: "GET", url: "api/v2/user/getDepartmentsByCompany?comp_id=" + comp_id, datatype: "json", processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ // console.log(response); var len = 0; if(response['data'] != null){ len = response['data'].length; } if(len > 0){ // Read data and create <option > for(var i=0; i<len; i++){ // console.log(response['data']); var id = response['data'][i].dealer_id; var name = response['data'][i].dealer_code; var option = "<option value='"+id+"'>"+name+"</option>"; $("#dealer_id").append(option); } } }, error: function(error){ } }); }); $('#company_id').on('change', function(e){ var comp_id = $('#company_id').val(); $('#dealership_id').find('option').not(':first').remove(); // alert(comp_id) $.ajax({ type: "GET", url: "api/v2/user/getDepartmentsByCompany?comp_id=" + comp_id, datatype: "json", processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ // console.log(response); var len = 0; if(response['data'] != null){ len = response['data'].length; } if(len > 0){ // Read data and create <option > for(var i=0; i<len; i++){ // console.log(response['data']); var id = response['data'][i].dealer_id; var name = response['data'][i].dealer_code; var option = "<option value='"+id+"'>"+name+"</option>"; $("#dealership_id").append(option); } } }, error: function(error){ } }); }); $('#dealer_id').on('change', function(e){ var dealer_id = $('#dealer_id').val(); }); $('#search_type').on('click', function(e){ var comp_id = $('#comp_id').val(); var dealer_id = $('#dealer_id').val(); $('<input>').attr({type:'hidden', id:'company_id', name: 'company_id', value: comp_id}).appendTo($('#yearly-frequency')); $('<input>').attr({type:'hidden', id:'dealers_id', name: 'dealers_id', value: dealer_id}).appendTo($('#yearly-frequency')); $('<input>').attr({type:'hidden', id:'company_id', name: 'company_id', value: comp_id}).appendTo($('#quarterly-frequency')); $('<input>').attr({type:'hidden', id:'dealers_id', name: 'dealers_id', value: dealer_id}).appendTo($('#quarterly-frequency')); $('<input>').attr({type:'hidden', id:'company_id', name: 'company_id', value: comp_id}).appendTo($('#monthly-frequency')); $('<input>').attr({type:'hidden', id:'dealers_id', name: 'dealers_id', value: dealer_id}).appendTo($('#monthly-frequency')); $('<input>').attr({type:'hidden', id:'company_id', name: 'company_id', value: comp_id}).appendTo($('#daily-frequency')); $('<input>').attr({type:'hidden', id:'dealers_id', name: 'dealers_id', value: dealer_id}).appendTo($('#daily-frequency')); $.ajax({ type: "GET", url:"api/v2/user/getDocsByFilter?comp_id=" + comp_id + "&dealer_id=" + dealer_id, datatype:"json", data:null, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ //console.log(response); $("#type-filter").modal("hide"); $('#daily-doc-count').text(response.document_per_day); $('#monthly-doc-count').text(response.document_per_month); $('#quarterly-doc-count').text(response.document_per_quarter); $('#yearly-doc-count').text(response.document_per_year); }, error: function(error){ alert("error"); } }) }); $('#search_type_generate').on('click', function(e){ var company_id = $('#company_id').val(); var dealer_id = $('#dealership_id').val(); var from_date = $('#from_date2').val(); var to_date = $('#to_date2').val(); e.preventDefault(); let timerInterval Swal.fire({ title: 'Generating!', html: 'Please wait while your request is being processed.', //timer: 2000, timerProgressBar: true, didOpen: () => { Swal.showLoading() const b = Swal.getHtmlContainer().querySelector('b') timerInterval = setInterval(() => { b.textContent = Swal.getTimerLeft() }, 100) }, willClose: () => { clearInterval(timerInterval) } }).then((result) => { /* Read more about handling dismissals below */ if (result.dismiss === Swal.DismissReason.timer) { console.log('I was closed by the timer') } }); $.ajax({ type: "GET", url:"api/v2/user/getDocsByFilter?company_id=" + company_id + "&dealer_id=" + dealer_id + "&from_date=" + from_date + "&to_date=" + to_date, datatype:"json", // data:null, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, // beforeSend: function(){ // }, success: function(response){ $("#type-generate").modal("hide"); Swal.fire( 'Report Generated Successfully!', 'success' ) window.location.reload(); }, error: function(error){ alert("error"); } }); }); $('#yearly_show').on('click', function(e){ var comp_id = $('#comp_id').val(); var dealer_id = $('#dealer_id').val(); var status = 1; localStorage.removeItem("comp_id") localStorage.removeItem("deal_id") localStorage.removeItem("status") localStorage.setItem("comp_id",comp_id); localStorage.setItem("deal_id",dealer_id); localStorage.setItem("status", status); window.location.assign('/details'); }); $('#quarterly_show').on('click', function(e){ var comp_id = $('#comp_id').val(); var dealer_id = $('#dealer_id').val(); var status = 2; localStorage.removeItem("comp_id") localStorage.removeItem("deal_id") localStorage.removeItem("status") localStorage.setItem("comp_id",comp_id); localStorage.setItem("deal_id",dealer_id); localStorage.setItem("status", status); window.location.assign('/details'); }); $('#monthly_show').on('click', function(e){ var comp_id = $('#comp_id').val(); var dealer_id = $('#dealer_id').val(); var status = 3; localStorage.removeItem("comp_id") localStorage.removeItem("deal_id") localStorage.removeItem("status") localStorage.setItem("comp_id",comp_id); localStorage.setItem("deal_id",dealer_id); localStorage.setItem("status", status); window.location.assign('/details'); }); $('#daily_show').on('click', function(e){ var comp_id = $('#comp_id').val(); var dealer_id = $('#dealer_id').val(); var status = 4; localStorage.removeItem("comp_id") localStorage.removeItem("deal_id") localStorage.removeItem("status") localStorage.setItem("comp_id",comp_id); localStorage.setItem("deal_id",dealer_id); localStorage.setItem("status", status); window.location.assign('/details'); }); $('#search_date').on('click', function(e){ if(!$('#from_date').val()){ alert('Please choose starting date'); } var search = new FormData(); search.append('from_date',$('#from_date').val()); search.append('to_date',$('#to_date').val()); $.ajax({ type: "POST", url:"api/v2/user/analyticsByDate", datatype:"json", data: search, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ //console.log(response); }, error: function(error){ } }); }); $.ajax({ type: "GET", url:"api/v2/user/adminPanel", datatype:"json", data: null, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ //console.log(response); $('#daily-doc-count').text(response.document_per_day); $('#monthly-doc-count').text(response.document_per_month); $('#quarterly-doc-count').text(response.document_per_quarter); $('#yearly-doc-count').text(response.document_per_year); const labels = [ 'Yearly', 'Quarterly', 'Monthly', 'Daily', ]; const data = { labels: labels, datasets: [{ axis: 'y', label: 'Department File Distribution', backgroundColor: [ 'rgb(255, 99, 132)', 'rgb(54, 162, 235)', 'rgb(255, 205, 86)', 'rgb(255, 86, 198)' ], hoverOffset: 5, borderColor: 'black', data: [response.document_per_year, response.document_per_quarter, response.document_per_month, response.document_per_day], }] }; const config = { type: 'bar', data: data, options: { indexAxis: 'y', onClick(e) { const activePoints = myChart.getElementsAtEventForMode(e, 'nearest', { intersect: true }, false) const [{ index }] = activePoints; // console.log(data.labels[index]); var category = data.labels[index]; //alert(category); documentGet(category); } } }; /////////////////////////////////////////////////// const labels2 = [ 'Closed', 'Open', ]; const data2 = { labels: labels2, datasets: [{ label: 'My First dataset', backgroundColor: [ 'rgb(255, 99, 132)', 'rgb(54, 162, 235)', // 'rgb(255, 205, 86)', // 'rgb(255, 86, 198)' ], hoverOffset: 5, borderColor: 'black', data: [response.document_done_count, response.document_open_count], }] }; const config2 = { type: 'doughnut', data: data2, options: { radius: '100%', } }; ////////////////////////////// const labels5 = [ 'Closed', 'Open', ]; const data5 = { labels: labels5, datasets: [{ //label: 'My First dataset', backgroundColor: [ 'rgb(255, 99, 132)', 'rgb(54, 162, 235)', // 'rgb(255, 205, 86)', // 'rgb(255, 86, 198)' ], hoverOffset: 5, borderColor: 'black', data: [response.document_done_count, response.document_open_count], }] }; const config5 = { type: 'bar', data: data5, options: { //radius: '100%', } }; const myChart = new Chart( document.getElementById('myChart'), config ); myChart2 = new Chart( document.getElementById('myChart2'), config2 ); const myChart3 = new Chart( document.getElementById('myChart3'), config ); const myChart4 = new Chart( document.getElementById('myChart4'), config ); // const mychart5 = new Chart( // document.getElementById('myChart5'), // config5 // ) google.charts.load('current', {'packages':['timeline']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var dataArray = [["name", "file_name", "start", "end"],]; $.each(response.foobar, function (index,value) { //console.log(value); dataArray.push([value.file_name, value.name, new Date(value.start), new Date(value.end)]); }); // console.log(dataArray); var figure = google.visualization.arrayToDataTable(dataArray) var view = new google.visualization.DataView(figure); var chart = new google.visualization.Timeline(document.getElementById("timeline2")); var options = { timeline: { groupByRowLabel: true } }; chart.draw(view, options); //////////////////////////////////////////////////////////////////////////////// google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = [["file_name", "person", "duration"],]; $.each(response.datediff, function (index,value) { //console.log(value); dataArray.push([value.file_id, value.recipient_id, value.duration]); }); google.visualization.arrayToDataTable(dataArray) var options = { title: 'My Daily Activities', is3D: true, }; var chart = new google.visualization.PieChart(document.getElementById('piechart')); chart.draw(data, options); } } }, error: function(e){ alert("something went wrong. Please check your credentials"); } }); $('#status_file').on('change', function(e){ var days = $('#status_file').val(); myChart2.destroy(); $.ajax({ type: "GET", url:"api/v2/user/adminPanel?days="+days, datatype:"json", // data: days, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ //console.log(response); // alert(response.document_per_day_filter); const labels2 = [ 'Closed', 'Open', ]; const data2 = { labels: labels2, datasets: [{ label: 'My First dataset', backgroundColor: [ 'rgb(255, 99, 132)', 'rgb(54, 162, 235)', // 'rgb(255, 205, 86)', // 'rgb(255, 86, 198)' ], hoverOffset: 5, borderColor: 'black', data: [response.count_per_day_filter], }] }; const config2 = { type: 'doughnut', data: data2, options: { radius: '100%', } }; myChart2 = new Chart( document.getElementById('myChart2'), config2 ); }, error: function(error){ } }) }); $.ajax({ type: "GET", url:"api/v2/user/getDocumentsByDealer", datatype:"json", data:null, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ //console.log(response); }, error: function(error){ } }); $.ajax({ type: "GET", url:"api/v2/user/getDocumentsByDepartment", datatype:"json", data:null, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ //console.log(response); }, error: function(error){ } }); });
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings