<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>

    <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <title>Doctor Absenteeism</title>

	<link href='http://fonts.googleapis.com/css?family=Roboto:400,400italic,700,700italic' rel='stylesheet' type='text/css'>

	<link href='http://fonts.googleapis.com/css?family=Arimo:400,400italic,700,700italic' rel='stylesheet' type='text/css'>

	<!--Load the Ajax API-->

    <script type="text/javascript" src="https://www.google.com/jsapi"></script>

	<link href='http://fonts.googleapis.com/css?family=Roboto:400,400italic,700,700italic' rel='stylesheet' type='text/css'>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

	<!--tab dependencies-->

	

  <script src="js/jquery.hashchange.min.js" type="text/javascript"></script>

  <script src="js/jquery.easytabs.min.js" type="text/javascript"></script>

    

	<style type="text/css">

	   strong{font-weight:bold;font-size:16px;}

        #container {

            width: 670px;

            margin: 0px auto;

			overflow:hidden;

			background:#fff;

			height:auto;

			font-family:'Arimo','Roboto';

			font-size:14px;

			

        }

	  body{font-family:'Arimo','Roboto';font-size:14px;}

	  .heading{font-family:'Roboto';font-size:26px;color:#D8502F;display:block;}

	  input#submit.btn-primary{

	  color: #FFF;

background-color: #222;

border-color: #222;

display: inline-block;

margin-bottom: 0px;

font-weight: normal;

text-align: center;

vertical-align: middle;

cursor: pointer;

background-image: none;

border: 1px solid transparent;

white-space: nowrap;

padding: 10px 18px;

font-size: 15px;

line-height: 1.42857;

border-radius: 0px;

-moz-user-select: none;

	  }

	  .form-control{

	  display: inline-block;

width: 20%;

height: 43px;

padding: 10px 18px;

font-size: 15px;

line-height: 1.42857;

color: #333;

background-color: #FFF;

background-image: none;

border: 1px solid #CCC;

border-radius: 0px;

box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.075) inset;

margin-right:4%;	  }

.selectedcounty{font-size:30px;}

.statsheading{font-size:16px;color:#fff;background:#428BCA;padding:5px 10px 5px 10px;display:block;font-weight:bold;}

.title{font-size:14px;font-weight:bold;}

#greybg{background:#E6E6E6;padding:20px;margin-top:20px;}





/* styles for tabs */

    .etabs { margin: 0; padding: 0; }

    .tab { display: inline-block; zoom:1; *display:inline; background: #eee; border: solid 1px #999; border-bottom: none; -moz-border-radius: 4px 4px 0 0; -webkit-border-radius: 4px 4px 0 0; }

    .tab a { font-size: 14px; line-height: 2em; display: block; padding: 0 10px; outline: none; }

    .tab a:hover { text-decoration: underline; }

    .tab.active { background: #fff; padding-top: 6px; position: relative; top: 1px; border-color: #666; }

    .tab a.active { font-weight: bold; }

    .tab-container .panel-container { background: #fff; border: solid #666 1px; padding: 10px; -moz-border-radius: 0 4px 4px 4px; -webkit-border-radius: 0 4px 4px 4px; }

    .panel-container { margin-bottom: 10px; }



	</style>

	

	 <script type="text/javascript">

    $(document).ready( function() {

      $('#tab-container').easytabs();

    });

  </script>

	<link rel="stylesheet" type="text/css" href="css/style.css">

	</head>

	<body>

	<div id="container">

	

	<div id="tab-container" class='tab-container'>

 <ul class='etabs'>

   <li class='tab'><a href="#doc_absenteeism">Doctor absenteeism</a></li>

   <li class='tab'><a href="#retained_doctors">Retained doctors</a></li>

   <li class='tab'><a href="#health_facilities">Health facilities</a></li>

 </ul>

 <div class='panel-container'>

  <div id="doc_absenteeism">

  <form action="" method="post" enctype="multipart/form-data">

  <div style="font-weight:bold;font-size:16px;padding-bottom:10px;">Select your county from the dropdown menu</div>

	<?php

	include "config.php";

	

				  echo "<select class='form-control' id='txtcounty' name='txtcounty'>";

				  //populate county select

	              //start of querying db for county

                  $result = mysqli_query($conDB,"select county  from doctor_absentism order by county asc");

                  while($row = mysqli_fetch_array($result)){

                  echo "<option value='".$row["county"]."'>".$row["county"]."</option>";

                  }

                  echo "</select>";

	include "closedb.php";

	?>

	<input type="submit" name="submit" id="submit" value="Click to view &raquo;" class="btn-primary">

	</form><!--end form-->

	</br>

	 <?php

	             if ( isset( $_POST['submit'] ) ) {

				 include 'config.php';

	             $county=$_POST['txtcounty'];

				 

				 //trim the variables

				 $county=trim($county);

				

				 //escape the variables

				 $county=mysqli_escape_string($conDB,$county);

				 

				 $return_arr = array();

				//select from db

				$results = mysqli_query($conDB,"select * from doctor_absentism where county='".$county."'");

				while($row = mysqli_fetch_array($results)) {

				$county=$row['county'];

				$staff_present=number_format($row['staff_present']);

				$staff_absent=$row['staff_absent'];

				$percent_absent=$row['percent_absent'];

				$maternity_or_sick_leave=$row['maternity_or_sick_leave'];

				$in_training=$row['in_training'];

				$official_mission=$row['official_mission'];

				$approved_absence=$row['approved_absence'];

				$gone_to_retrieve_salary=$row['gone_to_retrieve_salary'];

				$not_approved_absence=$row['not_approved_absence'];

				$not_on_shift=$row['not_on_shift'];

				$all_others=$row['all_others'];

				$grand_total=number_format($row['grand_total']);

				

				

				

				echo "<table>";

				echo "<thead>";

		        echo "<tr>";

		    echo "<th>"."<span class=selectedcounty>".$county.'&nbsp;county'."</span>"."</th>";

		    echo "</thead>";

				

				echo "<td>"."<span class='statsheading'>".'Doctor absenteeism statistics'."</span>"."</td>";

				echo "</tr>";

				echo "<td>"."<span class='title'>".'Staff present:'.'&nbsp;'."</span>".$staff_present."</td>";

				echo "</tr>";

				echo "<td>"."<span class='title'>".'Staff absent:'.'&nbsp;'."</span>".$staff_absent."</td>";

				echo "</tr>";

				echo "<td>"."<span class='title'>".'Percent absent:'.'&nbsp;'."</span>".$percent_absent."</td>";

				echo "</tr>";

				echo "<td>"."<span class='title'>".'Maternity or sick leave:'.'&nbsp;'."</span>".$maternity_or_sick_leave."</td>";

				echo "</tr>";

				echo "<td>"."<span class='title'>".'In training:'.'&nbsp;'."</span>".$in_training."</td>";

				echo "</tr>";

				echo "<td>"."<span class='title'>".'Official mission:'.'&nbsp;'."</span>".$official_mission."</td>";

				echo "</tr>";

				echo "<td>"."<span class='title'>".'Approved absence:'.'&nbsp;'."</span>".$approved_absence."</td>";

				echo "</tr>";

				echo "<td>"."<span class='title'>".'Gone to retrieve salary:'.'&nbsp;'."</span>".$gone_to_retrieve_salary."</td>";

				echo "</tr>";

				echo "<td>"."<span class='title'>".'Not approved absence:'.'&nbsp;'."</span>".$not_approved_absence."</td>";

				echo "</tr>";

				echo "<td>"."<span class='title'>".'Not on shift:'.'&nbsp;'."</span>".$not_on_shift."</td>";

				echo "</tr>";

				echo "<td>"."<span class='title'>".'All others:'.'&nbsp;'."</span>".$all_others."</td>";

				echo "</tr>";

				echo "<td>"."<span class='title'>".'Grand total:'.'&nbsp;'."</span>".$grand_total."</td>";

				echo "</tr>";

				echo "</table>";

				}

				echo "</br>";

				echo "<span class='statsheading'>Reasons for absenteeism</span>";

				

				/* Your Database Name */

$dbname = 'wheredoctorsare';

/* Your Database User Name and Passowrd */



$username = 'root';

$password = 'root';



try {



      /* Establish the database connection */



      $conn = new PDO("mysql:host=localhost;dbname=$dbname", $username, $password);



      $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);





/* select all the weekly tasks from the table googlechart */



      $result = $conn->query("SELECT * FROM doctor_absentism where county='$county'");



	  



      



      $rows = array();



      $table = array();



      $table['cols'] = array(







        // Labels for your chart, these represent the column titles.



        /* 



            note that one column is in "string" format and another one is in "number" format 



            as pie chart only required "numbers" for calculating percentage 



            and string will be used for Slice title



        */







        array('label' => 'County', 'type' => 'string'),



        array('label' => 'Maternity or sick leave', 'type' => 'number'),



		array('label' => 'In training', 'type' => 'number'),



		array('label' => 'Official mission', 'type' => 'number'),



		array('label' => 'Approved absence', 'type' => 'number'),

		

		array('label' => 'Gone to retrieve salary', 'type' => 'number'),



		array('label' => 'Not approved absence', 'type' => 'number'),



		array('label' => 'Not on shift', 'type' => 'number'),



		array('label' => 'All others', 'type' => 'number')







    );



        /* Extract the information from $result */



        foreach($result as $r) {







          $temp = array();







          // the following line will be used to slice the Pie chart







          $temp[] = array('v' => (string) $r['county']); 







          // Values of each slice







          $temp[] = array('v' => (string) $r['maternity_or_sick_leave']); 



		  $temp[] = array('v' => (string) $r['in_training']); 



		  $temp[] = array('v' => (string) $r['official_mission']); 



		  $temp[] = array('v' => (string) $r['approved_absence']); 

		  

		  $temp[] = array('v' => (string) $r['gone_to_retrieve_salary']); 

		  

		  $temp[] = array('v' => (string) $r['not_approved_absence']); 

		  

		  $temp[] = array('v' => (string) $r['not_on_shift']); 

		  

		  $temp[] = array('v' => (string) $r['all_others']); 

		  



          $rows[] = array('c' => $temp);



        }







    $table['rows'] = $rows;







    // convert data into JSON format



    $jsonTable = json_encode($table);



    //echo $jsonTable;



    } catch(PDOException $e) {



        echo 'ERROR: ' . $e->getMessage();



    }

				

				?>

				<script type="text/javascript">



    // Load the Visualization API and the piechart package.

    google.load('visualization', '1', {'packages':['corechart']});



    // Set a callback to run when the Google Visualization API is loaded.

    google.setOnLoadCallback(drawChart);



    function drawChart() {



      // Create our data table out of JSON data loaded from server.

      var data = new google.visualization.DataTable(<?=$jsonTable?>);

      var options = {

           title: 'Reasons for absence',

          is3D: 'false',

          width: 650,

          height: 600

        };

      // Instantiate and draw our chart, passing in some options.

      // Do not forget to check your div ID

      var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));

      chart.draw(data, {title:"Reasons for absence",hAxis: {chartArea:{left:10,top:10,width:"100%",height:"100%"},title: "Number of doctors",titleTextStyle: {color: '#000'}},vAxis:{title:""},width: 650, height: 300,fontName:'Roboto',logScale: true});

    }

	

    </script>

				 <!--Div that will hold the pie chart-->

    <div id="chart_div"></div>

				

				<?php

				//include 'dimplesbarchart/barchart.php';

				include 'closedb.php';

	             }

				?>

				<iframe width="650" height="700" frameborder="0" src="per_county_mapped.html"></iframe>

</div>

   <div id="retained_doctors">

   <iframe width="650" height="700" frameborder="0" src="http://localhost/retained_doctors"></iframe>

</div>

  <div id="health_facilities">

   <iframe width="650" height="700" frameborder="0" src="http://localhost/health_facilities"></iframe>

 </div>

  

 </div>

</div>

	

	

	

	

	

	

				

				 

              

	

	</div><!--close container-->

	</body>

	</html>