  <?php
  include("db_connect.php");
  $province = mysqli_real_escape_string($db,$_GET['province']);
 $highestCode = mysqli_query($db,"SELECT count(rd.secondary_cause_code) as count, c.title as type,COUNT(CASE WHEN rd.violent_nonviolent ='violent' THEN 1 END) AS violent,COUNT(CASE WHEN rd.violent_nonviolent ='nonviolent' THEN 1 END) AS nonviolent FROM `reports_details` rd join causes c on c.code = rd.secondary_cause_code join reports r on r.id = rd.report_id join reports_tags rt on r.id = rt.report_id join reports_locations rl on rl.report_id = r.id WHERE rd.secondary_cause_code in('991','992','993','994','995','996') and rt.tag_id = 19 and rl.province_id = $province group by rd.secondary_cause_code order by count desc limit 1");
$typeHigh = mysqli_fetch_assoc($highestCode);

$prov = mysqli_query($db,"SELECT count(rd.secondary_cause_code) as count, ld.title as district,COUNT(CASE WHEN rd.violent_nonviolent ='violent' THEN 1 END) AS violent,COUNT(CASE WHEN rd.violent_nonviolent ='nonviolent' THEN 1 END) AS nonviolent FROM `reports_details` rd join causes c on c.code = rd.secondary_cause_code join reports r on r.id = rd.report_id join reports_tags rt on r.id = rt.report_id join reports_locations rl on rl.report_id = r.id join location_districts ld on ld.id = rl.district_id WHERE rd.secondary_cause_code in('991','992','993','994','995','996') and rt.tag_id = 19 and rl.province_id = $province group by ld.title order by count desc limit 1");
$provinceHigh = mysqli_fetch_assoc($prov);
//$t = mysqli_num_rows($analysis);

$tot = mysqli_query($db,"select count(province_id) as total,COUNT(CASE WHEN rd.violent_nonviolent ='violent' THEN 1 END) AS violent,COUNT(CASE WHEN rd.violent_nonviolent ='nonviolent' THEN 1 END) AS nonviolent from reports r join reports_locations rl on r.id = rl.report_id join reports_tags rt on r.id = rt.report_id join reports_details rd on rd.report_id = rt.report_id where rt.tag_id = 19 and province_id = $province"); 
$totalIncidents = mysqli_fetch_assoc($tot);
  ?>
  <div class="number-box clearfix"><br class="d-xs-none">
                Total number of  incidents 
                <!-- <span class="sidebar_start_date">Covid-19</span> -->
              
                <div class="number total_number_of_incidents"><?php echo $totalIncidents['total'];?></div>
                 Violent Incidents
                <div class="violencenumber"><?php echo $totalIncidents['violent'];?></div>
               
                Other Incidents
                <div class="nonviolencenumber"><?php echo $totalIncidents['nonviolent'];?></div>
                <hr>
              </div>

                  <div class="number-box clearfix"><br class="d-xs-none">
                Highest number of  incidents in  
                <span class="sidebar_start_date"><?php
            echo $provinceHigh['district'];

                ?></span>
                 
                
                <div class="number total_number_of_incidents"><?php echo $provinceHigh['count'];?></div>
                 Violent Incidents
                <div class="violencenumber"><?php echo $provinceHigh['violent'];?></div>
               
                Other Incidents
                <div class="nonviolencenumber"><?php echo $provinceHigh['nonviolent'];?></div>
                <hr>
              </div>
                  <div class="number-box clearfix"><br class="d-xs-none">
                Highest number of incidents related to  
                <span class="sidebar_start_date"><?php echo $typeHigh['type']?></span>
                 
                
                <div class="number total_number_of_incidents"><?php echo $typeHigh['count'];?></div>
                 Violent Incidents
                <div class="violencenumber"><?php echo $typeHigh['violent'];?></div>
               
                Other Incidents
                <div class="nonviolencenumber"><?php echo $typeHigh['nonviolent'];?></div>
              
              </div>
              <a class="btn bg-primary nonPrint" id="btnPrint" style="width: 100%;">Print Map</a>

              <script type="text/javascript">


$('#btnPrint').click(function () {
   //document.getElementsByTagName("BODY")[0].style.display = "none";
   //alert(1);
   $(".nonPrint").hide();
   //$("#map").css("height","1270px");
   window.print();
   //$("#map").css("height","635px");
   $(".nonPrint").show();

});
  
</script>