  <?php
  include("db_connect.php");
  $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 WHERE rd.secondary_cause_code in ('Expression','Assembly','Association','Safety','Dialogue','Solidarity') and rt.tag_id = 20 and r.eventdate > '2020-01-31' group by c.title order by count desc limit 1");
 $typeHigh = mysqli_fetch_assoc($highestCode);

 $prov = mysqli_query($db,"SELECT count(rd.secondary_cause_code) as count, rl.province_id, 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 ('Expression','Assembly','Association','Safety','Dialogue','Solidarity') and rt.tag_id = 20 and r.eventdate > '2020-01-31' group by rl.province_id order by count desc
  limit 1");
 $provinceHigh = mysqli_fetch_assoc($prov);
//$t = mysqli_num_rows($analysis);

 $tot = mysqli_query($db,"select count(*) 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_tags join reports_details rd on rd.report_id = reports_tags.report_id join reports r on r.id = rd.report_id where tag_id = 20 and r.eventdate > '2020-01-31'"); 
 $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"><?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>
              </div>
              <hr>
                  <div class="number-box clearfix"><br class="d-xs-none">
                highest number of  incidents in  
                <span class="sidebar_start_date"><?php
                if($provinceHigh['province_id'] == '1'){
                  echo "Province 1";
                } else if($provinceHigh['province_id'] == '2'){
                  echo "Province 2";
                }  else if($provinceHigh['province_id'] == '3'){
                  echo "Bagmati";
                } else if($provinceHigh['province_id']== '4'){
                  echo "Gandaki";
                } else if($provinceHigh['province_id'] == '5'){
                  echo "Province 5";
                } else if($provinceHigh['province_id'] == '6'){
                  echo "Karnali";
                } else if($provinceHigh['province_id'] == '7'){
                  echo "Sudur Paschim";
                }


                ?></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>
              </div>
              <hr>
                  <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 myButton nonPrint" id="btnPrint" style="width: 100%;">Print Map</a>
             
<!-- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
        crossorigin="anonymous">
</script> -->
<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>



