JezK
Edit File: dashboard.php
<?php include("header.php"); $fromdate = isset($_REQUEST['fromdate']) ? $_REQUEST['fromdate'] : ''; $todate = isset($_REQUEST['todate']) ? $_REQUEST['todate'] : ''; $totUsersCnt = $videocon->getTotalUsersCnt('', $fromdate, $todate); $totBusinessCnt = $videocon->getTotalUsersCnt('business', $fromdate, $todate); $totBusinessProfCnt = $videocon->getTotalUsersCnt('businessProfessionals', $fromdate, $todate); $totAmount = $videocon->getTotalUsersCnt('totalAmount', $fromdate, $todate); ////////////////Conference Counts /////// $totConferenceCnt = $videocon->getConferenceCnts('', $fromdate, $todate); $totOnGoingCnt = $videocon->getConferenceCnts('ongoing', $fromdate, $todate); $totCancelledCnt = $videocon->getConferenceCnts('Cancelled', $fromdate, $todate); $totCompletedCnt = $videocon->getConferenceCnts('completed', $fromdate, $todate); ////////////////////Chart Details///// $totregUsersCnt = $videocon->getChartDetails(date('Y-m-d 00:00:00', strtotime('-1 day')), date('Y-m-d H:i:s')); $totregAppointmentCnt = $videocon->getChartDetails(date('Y-m-d 00:00:00', strtotime('-1 day')), date('Y-m-d H:i:s'), 'appointments'); /////////////////Map Business Location///// $businessLoc = $videocon->getBusinessLocation(); /*echo "<pre>"; print_r($businessLoc);*/ $data = array(); $dataa = array(); $data1 = ''; $data2 = ''; $data3 = ''; $data4 = ''; $allow = array(); $type = isset($_REQUEST['status']) ? $_REQUEST['status'] : '0'; $users = $videocon->getUsersDateANdCount($type); $appointments = $videocon->getAppointmentsAndCount($type); if ($type == 0) { $startdate = strtotime(date("Y-m-d")); $missingDates = array(); $dateStart = date_create(date('Y-m-d ', strtotime('-6 days'))); $dateEnd = date_create(strtotime("Y-m-d")); $interval = new DateInterval('P1D'); $period = new DatePeriod($dateStart, $interval, $dateEnd); $vals = ''; $alldates = array(); $avabledates = array(); foreach ($period as $day) { $formatted = $day->format("Y-m-d"); $alldates[] = $formatted; } ///// users ///// foreach ($users as $k => $v) { $data[date("Y-m-d", strtotime($v['date']))] = $v['userscount']; } foreach ($alldates as $v) { if (isset($data[$v]) && $data[$v] != '') { $data1 .= "'" . date("M d", strtotime($v)) . "', "; $data2 .= $data[$v] . ","; } else { $data1 .= "'" . date("M d", strtotime($v)) . "', "; $data2 .= "0, "; } } ///// app ///// foreach ($appointments as $k => $v) { $dataa[date("Y-m-d", strtotime($v['date']))] = $v['appcount']; } foreach ($alldates as $v) { if (isset($dataa[$v]) && $dataa[$v] != '') { $data3 .= $v . ","; $data4 .= $dataa[$v] . ", "; } else { $data3 .= $v . ","; $data4 .= "0, "; } } } else if ($type == 1) { ///// users /////// foreach ($users as $k => $v) { $data1 .= "'" . $k . "',"; $data2 .= $v . ","; } /// app ////// foreach ($appointments as $k => $v) { // $data1.= "'".$k."',"; $data4 .= $v . ","; } } else if ($type == 2) { $startdate = strtotime(date("Y-m")); $missingDates = array(); $dateStart = date_create(date('Y-m ', strtotime('-1 year'))); $dateEnd = date_create(strtotime("Y-m")); $interval = new DateInterval('P1M'); $period = new DatePeriod($dateStart, $interval, $dateEnd); $vals = ''; $alldates = array(); foreach ($period as $day) { $formatted = $day->format("Y-m"); $alldates[] = $formatted; } //// users ////// foreach ($users as $k => $v) { $data[date("Y-m", strtotime($v['date']))] = $v['userscount']; } foreach ($alldates as $v) { if (isset($data[$v]) && $data[$v] != '') { $data1 .= "'" . date("M-Y", strtotime($v)) . "', "; $data2 .= $data[$v] . ","; } else { $data1 .= "'" . date("M-Y", strtotime($v)) . "', "; $data2 .= "0, "; } } ///// app /////// foreach ($appointments as $k => $v) { $dataa[date("Y-m", strtotime($v['date']))] = $v['appcount']; } foreach ($alldates as $v) { if (isset($dataa[$v]) && $dataa[$v] != '') { $data3 .= "'" . date("Y-m", strtotime($v)) . "', "; $data4 .= $dataa[$v] . ","; } else { $data3 .= "'" . date("Y-m", strtotime($v)) . "', "; $data4 .= "0, "; } } $datSomething = date('Y-m-d'); $formattedValue = date("F-Y", strtotime($v)); } function facebookFormattter($digit) { if ($digit >= 1000000000) { return round($digit / 1000000000, 1) . 'G'; } if ($digit >= 1000000) { return round($digit / 1000000, 1) . 'M'; } if ($digit >= 1000) { return round($digit / 1000, 1) . 'K'; } return round($digit); } ?> <section class="dashboard-counts section-padding"> <div class="container-fluid bg-white px-5 py-3"> <div class="row bg-white"> <!--start calender --> <div class="container px-1"> <form action='' method='GET' id="dashboard"> <div class="form-group calender-Right"> <label class="fieldName mt-2 mr-2">Select Date Range</label> <div id="reportrange9" class="col-xl-5 col-md-6 col-lg-8 formField-control" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc;"> <i class=" float-right "><img src="img/calenderdark.png"></i> <span></span> <input type="hidden" class="hidden fromdate" name="fromdate" value=""> <input type="hidden" class="hidden todate" name="todate" value=""> </div> </div> </form> </div> <!--ENd calender --> <div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title d-flex blue-Block"> <!-- <div class="icon"><i class="icon-user"></i></div> --> <div class="icon"><i><img src="img/users.png" class="dashboard-icon1"></i></div> <div class="name mb-2"><strong class="count-number text-white"><?php echo facebookFormattter($totUsersCnt['cnt']); ?></strong> <span>Users</span> <!-- <div class="count-number text-white"></div> --> </div> </div> </div> <div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title d-flex pink-Block"> <!-- <div class="icon"><i class="icon-padnote"></i></div> --> <div class="icon"><i><img src="img/businesses.png" class="dashboard-icon2"></i></div> <div class="name mb-2"><strong class="count-number text-white"><?php echo facebookFormattter($totBusinessCnt['cnt']); ?></strong> <span>Business</span> </div> </div> </div> <div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title orange-Block d-flex"> <!-- <div class="icon"><i class="icon-check"></i></div> --> <div class="icon"><i><img src="img/users.png" class="dashboard-icon3"></i></div> <div class="name mb-2"><strong class="count-number text-white"><?php echo facebookFormattter($totBusinessProfCnt['cnt']); ?></strong> <span>Professionals</span> </div> </div> </div> <div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title green-Block d-flex"> <div class="icon"><i><img src="img/total-income.png" class="dashboard-icon4"></i></div> <div class="name mb-2"><strong class="count-number text-white"><?php echo $totAmount[0]['currency']=="INR"?"Rs.".facebookFormattter($totAmount[0]['cnt']):"$".facebookFormattter($totAmount[0]['cnt']); ?></strong> <span>Total Income By Rs.</span> </div> </div> </div> <div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title green-Block d-flex"> <div class="icon"><i><img src="img/total-income.png" class="dashboard-icon4"></i></div> <div class="name mb-2"><strong class="count-number text-white"><?php echo $totAmount[1]['currency']=="USD"?"$".facebookFormattter($totAmount[1]['cnt']):"Rs.".facebookFormattter($totAmount[1]['cnt']); ?></strong> <span>Total Income By USD</span> </div> </div> </div> </div> </div> </section> <!-- chart and graph section --> <section class="charts"> <div class="container-fluid"> <div class="row"> <div class="col-lg-6"> <div class="card line-chart-example"> <div class="card-body"> <!-- <div id="chart"> --> <form action='' name="" method='GET'> <div id="chart"> <div class="row"> <h6 class="mt-2">User joined vs Appointment</h6> <select name="status" class="col-xl-6 col-md-6 col-lg-8 formField-control" id="appointmentType" onchange="this.form.submit()"> <option value="0" <?php if (isset($type) && $type == 0) { echo "selected"; } else { } ?>>Weekly</option> <option value="1" <?php if (isset($type) && $type == 1) { echo "selected"; } else { } ?>>Monthly</option> <option value="2" <?php if (isset($type) && $type == 2) { echo "selected"; } else { } ?>>Yearly</option> </select> </div> </div> </form> </div> </div> </div> <?php /* $latlan=''; $latitudefirst='' ; $longitudefirst=''; $mapicondesc=" "; foreach($businessLoc as $k=>$v){ $latlan.=" ['".addslashes($v['location']).",".addslashes($v['city'])."'],"; $mapicondesc.="['<div class=".'"'."info_content".'"'.">'+'<h3>".$v["business_name"]."</h3>'+'<p>".addslashes($v["country"])." ".$v["state"].",".$v["city"]."</p>'+'</div>'],"; } $latlan=rtrim($latlan,','); */ ?> <div class="col-lg-6"> <div class="card bar-chart-example"> <div class="card-body"> <h6 class="mt-2">Business Locations</h6> <!-- <div id="map_wrapper"> <div id="map_canvas" class="mapping" style="height: 400px;"></div> </div> --> <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d39403.91546812932!2d-74.1025116876877!3d40.72680098830898!2m3!1f0!2f0!3f0!3m2!1i10!2i0!4i0!3m3!1d39403.91546812932!2d-74.1025116876877!3d40.72680098830898!4i0!5i0" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe> <!-- <iframe src="https://www.google.com/maps/embed?pb=!1m14!1m12!1m3!1d15260.857990789558!2d82.24768!3d17.013145599999998!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2sin!4v1566289458619!5m2!1sen!2sin" width="100%" height="400" frameborder="0" style="border:0" allowfullscreen></iframe> --> </div> </div> </div> </div> </div> </section> <section class="dashboard-counts down-section-padding"> <div class="container-fluid bg-white px-5 py-3"> <div class="row bg-white"> <div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title d-flex violet-block"> <!-- <div class="icon"><i class="icon-user"></i></div> --> <div class="icon"><i><img src="img/total-confrences.png" class="dashboard-icon5"></i></div> <div class="name mb-2"><strong class="count-number text-white"><?php echo facebookFormattter($totConferenceCnt['cnt']); ?></strong> <span>Total Conferences</span> <!-- <div class="count-number text-white"></div> --> </div> </div> </div> <div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title d-flex sky-block"> <!-- <div class="icon"><i class="icon-padnote"></i></div> --> <div class="icon"><i><img src="img/ongoing-conferences.png" class="dashboard-icon6"></i></div> <div class="name mb-2"><strong class="count-number text-white"><?php echo facebookFormattter($totOnGoingCnt['cnt']); ?></strong> <span>Upcoming Conferences</span> <!--<span>Ongoing Conferences</span>--> </div> </div> </div> <div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title darkPink-block d-flex"> <div class="icon"><i><img src="img/cancelled-conferences.png" class="dashboard-icon7"></i></div> <div class="name mb-2"><strong class="count-number text-white"><?php echo facebookFormattter($totCancelledCnt['cnt']); ?></strong> <span>Cancelled Conferences</span> </div> </div> </div> <div class="col-xl-3 col-md-4 col-lg-6"> <div class="wrapper count-title yellow-block d-flex"> <!-- <div class="icon"><i class="icon-bill"></i></div> --> <div class="icon"><i><img src="img/total-confrences.png" class="dashboard-icon8"></i></div> <div class="name mb-2"><strong class="count-number text-white"><?php echo facebookFormattter($totCompletedCnt['cnt']); ?></strong> <span>Completed Conferences</span> </div> </div> </div> </div> </div> </section> <?php include("footer.php"); ?> <script> </script> <?php $address = "india"; foreach ($businessLoc as $k => $v) { if($v['latitude']!='' && $v['longitude'] !='') { if($v['latitude']!='' && $latitudefirst==''){ $latitudefirst=$v['latitude']; } if($v['longitude']!='' && $longitudefirst==''){ $longitudefirst=$v['longitude']; } $latlan.=" ['".addslashes($v['location']).",".addslashes($v["city"]).",".addslashes($v["state"]).",".addslashes($v["country"])."', ".$v['latitude'].",".$v['longitude']."],"; $mapicondesc.="['<div class=".'"'."info_content".'"'.">'+'<h3>".addslashes($v["business_name"])."</h3>'+'<p>".addslashes($v['location'])." ".addslashes($v["city"]).",".addslashes($v["state"]).",".addslashes($v["country"])."</p>'+'</div>'],"; } } $latlan=rtrim($latlan,','); $latitudefirst = ''; $longitudefirst = ''; if ($latitudefirst == '' || $longitudefirst == '') { $latitudefirst = '39.381266'; $longitudefirst = '-97.922211'; } ?> <script type="text/javascript"> function initMap() { var map; var bounds = new google.maps.LatLngBounds(); var mapOptions = { //center: centerCoordinates, zoom: 5, center: {lat: <?php echo $latitudefirst;?>, lng: <?php echo $longitudefirst;?>} // test }; // Display a map on the page map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); map.setTilt(45); // Multiple Markers var markers = [ <?php echo $latlan;?> ]; // Info Window Content var infoWindowContent = [ <?php echo $mapicondesc;?> ]; // Display multiple markers on a map var infoWindow = new google.maps.InfoWindow(), marker, i; // Loop through our array of markers & place each one on the map for( i = 0; i < markers.length; i++ ) { //continue; var position = new google.maps.LatLng(markers[i][1], markers[i][2]); bounds.extend(position); marker = new google.maps.Marker({ position: position, map: map, title: markers[i][0] }); // Allow each marker to have an info window google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infoWindow.setContent(infoWindowContent[i][0]); infoWindow.open(map, marker); } })(marker, i)); map.fitBounds(bounds); } // Override our map zoom level once our fitBounds function runs (Make sure it only runs once) var boundsListener = google.maps.event.addListener((map), 'bounds_changed', function(event) { //this.setZoom(4); google.maps.event.removeListener(boundsListener); }); } ////// date picker starting //////// $(function() { var start = moment().subtract(1, 'days'); var end = moment(); function cb(start, end) { $('.fromdate').val(start.format('YYYY-MM-DD')); $('.todate').val(end.format('YYYY-MM-DD')); $('#reportrange9 span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY')); } $('#reportrange9').daterangepicker({ startDate: start, endDate: end, ranges: { 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] } }, cb); cb(start, end); }); $('#reportrange9').on('apply.daterangepicker', function(ev, picker) { // alert(picker.startDate.format('DD-MM-YYYY')+' To '+picker.endDate.format('DD-MM-YYYY')); var fromdate = picker.startDate.format('YYYY-MM-DD'); var todate = picker.endDate.format('YYYY-MM-DD'); // alert('hai'); $('#dashboard').submit(); }); $(document).ready(function() { var url = window.location.href; function getParameterByName(name, href) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(href); return decodeURIComponent(results[1].replace(/\+/g, " ")); } var from = getParameterByName("fromdate", url); var to = getParameterByName("todate", url); var x1 = moment(from).format('DD MMMM, YYYY '); var y1 = moment(to).format('DD MMMM, YYYY'); $('#reportrange9 span').html(x1 + ' - ' + y1); }); /////// date picker ending ////////// //////// map starting /////////// /*var map; var geocoder; function initMap() { var mapLayer = document.getElementById("map_canvas"); var centerCoordinates = new google.maps.LatLng(20.5937, 78.9629); var defaultOptions = { center: centerCoordinates, zoom: 5 } map = new google.maps.Map(mapLayer, defaultOptions); geocoder = new google.maps.Geocoder(); var i = <?php $i = 0; echo $i; ?>; // var infoWindowContent = ["one","two" ]; var infoWindow = new google.maps.InfoWindow(), marker, i; <?php $address = "india"; foreach ($businessLoc as $k => $v) { $i++; $mapicondesc = ''; // $address= $v["location"].",".$v["country"].",".$v["state"].",".$v["city"]; $address = $v["location"] . "," . $v["city"] . "," . $v["state"] . "," . $v["country"]; $mapicondesc = "['<div class=" . '"' . "info_content" . '"' . ">'+'<h3>" . $v["business_name"] . "</h3>'+'<p>" . addslashes($v["country"]) . " " . $v["state"] . "," . $v["city"] . "</p>'+'</div>'],"; ?> setTimeout(function() { geocoder.geocode({ 'address': "<?php echo $address; ?>" }, function(LocationResult, status) { console.log(status); if (status == google.maps.GeocoderStatus.OK) { var latitude = LocationResult[0].geometry.location.lat(); var longitude = LocationResult[0].geometry.location.lng(); } var infoWindowContent = [ `<?php echo $mapicondesc; ?>` ]; var marker = new google.maps.Marker({ position: new google.maps.LatLng(latitude, longitude), map: map, title: '<?php echo $v["location"]; ?>' }); //////// google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infoWindow.setContent(infoWindowContent[i][0]); infoWindow.open(map, marker); } })(marker, i)); ///////// }); }, 2000); <?php } ?> }*/ ////// map ending /////// </script> <script src="js/apexcharts.js"></script> <script> var type = 0; var m = "labels: ['Oct 05', 'Oct 06', 'Oct 07', 'Oct 08', 'Oct 09', 'Oct 10', 'Oct 11',]"; var options = { chart: { height: 350, type: 'line', stacked: false }, stroke: { show: true, colors: ['#5c91a1', '#3772ee'], width: 2, dashArray: 0, }, series: [{ name: 'Users', type: 'area', color: '#5c91a1', // data: [ 0 ,500, 1000, 150, 2000 ,2500,2800] data: [<?php echo $data2; ?>] }, { name: 'Appointment', type: 'area', color: '#3772ee', // data: [ 0 ,500, 1000, 150, 2000 ,2500,2800] data: [<?php echo $data4; ?>] } ], fill: { type: 'solid', opacity: [0.35, 0.25] }, labels: [<?php echo $data1; ?>], markers: { size: 0 }, legend: { shape: "square", horizontalAlign: 'right', position: 'top', colors: ['#5c91a1', '#3772ee'], radius: 0 }, markers: { size: [3, 3], colors: ['#5c91a1', '#3772ee'], strokeColors: '#fff', strokeWidth: 2, strokeOpacity: 0.9, fillOpacity: 1, discrete: [], shape: "circle", radius: 2, offsetX: 0, offsetY: 0, onClick: undefined, onDblClick: undefined, }, tooltip: { shared: true, intersect: false, y: { formatter: function(y) { if (typeof y !== "undefined") { return y.toFixed(0) + " "; } return y; } } } } var chart = new ApexCharts( document.querySelector("#chart"), options ); chart.render(); </script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBmzC6LorWBcIWA94XksFf6IrpHej_z_pI&callback=initMap"> </script>