<?php ob_start(); session_start();
 include('session.php');
 require_once('dbcon.php');


	
	 
     $rows = mysqli_query($con,"select * from airtime_customer where customer_id = '$session_id'") or die (mysqli_error());
				$dat = mysqli_fetch_array($rows);
				
	$shop = mysqli_query($con,"select * from airtime_sending_credentials where customer_id = '$session_id' ");
	$getshop = mysqli_fetch_array($shop);
	$sid = $getshop['API_Account'];
				
	   $id=$dat['customer_id'];
	   $target = 'profileimages/';
	   $img = $dat['image'];
	   $photo= $target.$img; 
?>
<!DOCTYPE html>
<html lang="en">
  <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <!-- Meta, title, CSS, favicons, etc. -->
    
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Airtime Portal </title>
	<link rel="icon" href="images/mlogo.png" type="image/png" sizes="16x16">	
    <!-- Bootstrap -->
    <link href="vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- iCheck -->
    <link href="vendors/iCheck/skins/flat/green.css" rel="stylesheet">
    <!-- bootstrap-progressbar -->
    <link href="vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet">
    <!-- jVectorMap -->
    <link href="css/maps/jquery-jvectormap-2.0.3.css" rel="stylesheet"/>

    <!-- Custom Theme Style -->
    <link href="css/custom.css" rel="stylesheet">
  </head>

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">

            <div class="clearfix"></div>

			
            <!-- menu profile quick info -->
            <div class="profile">
              <div class="profile_pic">
			   <?php 
			  if($img == ""){
				  ?>
				   <img src="profileimages/noimage.gif" alt="..." class="img-circle profile_img">
				  <?php
			  }else{
				?>
				 <img src="<?php echo $photo ?>" alt="..." class="img-circle profile_img" width="40px;" height="60px;">
            <?php				
			  }
			  ?>
              </div>
			  
              <div class="profile_info">
                <span>Welcome,</span>
				<h2> <?php $fname = $dat['fname']; $lname = $dat['lname']; $comp = $dat['company'];  if(empty($comp)){ echo ucwords($fname." ".$lname); }else{ echo ucwords($comp); }  ?> </h2>
             <!--   <h2>John Doe</h2> -->
              </div>
            </div>
            <!-- /menu profile quick info -->

            <br/> 

            <!-- sidebar menu -->
            <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
              <div class="menu_section">
			  
                <h3>General</h3>
                <ul class="nav side-menu">
                  <li class="active"><a  href="homepage.php" ><i class="fa fa-home"></i>  Home <span class="fa fa-chevron-right"></span></a> </li>
                  <li><a href="#"><i class="fa fa-building"></i> My Contacts <span class="fa fa-chevron-down"></span></a> 
				  <ul class="nav child_menu">
					    <li><a  href="addcontact.php" ><i class="fa fa-user-plus"></i>Add New Contact<span class="fa fa-chevron-right"></span></a> </li>
						<li><a  href="addnewcontact.php" ><i class="fa fa-eye"></i>View Contacts<span class="fa fa-chevron-down"></span></a> 
						<!--ul class="nav child_menu">
						 <li><a  href="addnewcontact.php" ><i class="fa fa-bug"></i>List<span class="fa fa-chevron-right"></span></a> </li>
						<li><a  href="viewcontacts.php" ><i class="fa fa-bug"></i>Grid<span class="fa fa-chevron-right"></span></a> </li>
						</ul-->
						</li>
					   </ul>
				  </li>
                  <li><a><i class="fa fa-users"></i> Groups <span class="fa fa-chevron-down"></span></a> 
				        <ul class="nav child_menu">
					   <li><a  href="creategroup.php" ><i class="fa fa-paw"></i>Create Group<span class="fa fa-chevron-right"></span></a> </li>
						<li><a  href="viewgroups.php" ><i class="fa fa-eye"></i>View Groups<span class="fa fa-chevron-right"></span></a> </li>
					   </ul>
				  </li>
                  <li><a><i class="fa fa-table"></i> Topup <span class="fa fa-chevron-down"></span></a>  
				   <ul class="nav child_menu">
						<li><a  href="sendtogroup.php"><i class="fa fa-cloud-download"></i>Top-up Group Contacts<span class="fa fa-chevron-right"></span></a> </li>
						<li><a href="selectcontacttosend.php" ><i class="fa fa-building"></i>Select Contact(s)<span class="fa fa-chevron-right"></span></a> </li>
						 <li><a  href="sendtome.php"  ><i class="fa fa-mobile"></i> Top-up My Line<span class="fa fa-chevron-right"></span></a> </li>
						 <li><a href="autosend-airtime.php" ><i class="fa fa-recycle"></i> Auto-Send Airtime <span class="fa fa-chevron-right"></span></a> </li>
					   </ul>				  
				  </li>
                 
				  <li><a><i class="fa fa-gg"></i> Billing <span class="fa fa-chevron-down"></span></a> 
				   <ul class="nav child_menu">
                     <li><a  href="purchasetome.php" ><i class="fa fa-server"></i> Top-up My Account<span class="fa fa-chevron-right"></span></a> </li>
					   </ul>
				  </li>
				   <li><a><i class="fa fa-bar-chart-o"></i> History <span class="fa fa-chevron-down"></span></a>  
				      <!--  <ul class="nav side-menu"> -->
					   <ul class="nav child_menu">
					    <li><a  href="creditassignment.php" ><i class="fa fa-bars"></i>Credit Assignment<span class="fa fa-chevron-right"></span></a> </li>
						
					   </ul>
				   </li>
                </ul>
              </div>

            </div>
            <!-- /sidebar menu -->

            <!-- /menu footer buttons -->
       <!----     <div class="sidebar-footer hidden-small">
              <a data-toggle="tooltip" data-placement="top" title="Settings">
                <span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
              </a>
              <a data-toggle="tooltip" data-placement="top" title="FullScreen">
                <span class="glyphicon glyphicon-fullscreen" aria-hidden="true"></span>
              </a>
              <a data-toggle="tooltip" data-placement="top" title="Lock">
                <span class="glyphicon glyphicon-eye-close" aria-hidden="true"></span>
              </a>
              <a data-toggle="tooltip" data-placement="top" title="Logout">
                <span class="glyphicon glyphicon-off" aria-hidden="true"></span>
              </a>
            </div> -->
            <!-- /menu footer buttons -->
          </div>
        </div>

        <!-- top navigation -->
        <div class="top_nav">

          <div class="nav_menu">
            <nav class="" role="navigation">
              <div class="nav toggle">
                <a id="menu_toggle"><i class="fa fa-bars"></i></a>
              </div>
			<?php include('checkbalance.php'); ?>
              <ul class="nav navbar-nav navbar-right">
			 <div style="margin-top:30px;font-size:22px;"> <label class="btn btn-danger" > Account Balance: <?php echo " "."Ksh. ".$bal;    ?> </label> </div>
               <div style="margin-top:-30px;margin-right:20px;">
			   <li class="">
                  <a href="javascript:;" class="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                    <img src="images/loggeduser.png" alt=""> <?php $fname = $dat['fname']; $lname = $dat['lname']; echo ucwords($fname." ".$lname); ?> 
					
                    <span class=" fa fa-angle-down"></span>
                  </a>
                  <ul class="dropdown-menu dropdown-usermenu pull-right">
                    <li><a href="profile.php">  Profile</a>
                    </li>
                    <li><a href="logout.php"><i class="fa fa-sign-out pull-right"></i> Logout</a>
                    </li>
                  </ul>
                </li>
				</div>

              </ul>
            </nav>
          </div>

        </div>
        <!-- /top navigation -->


        <!-- page content -->
        <div class="right_col" role="main">
             <div class="row">
          <!-- top tiles -->
		  
          <div class="row tile_count">
		  
		  
            <div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count">
            </div>  
          </div>
		  </div>
		  <hr/>
          <!-- /top tiles -->

          <div class="row">
		    <div class="col-md-4 col-sm-4 col-xs-12">
              <div class="x_panel tile fixed_height_320">
                <div class="x_title">
                  <h2>Account Statistics</h2>
                  <ul class="nav navbar-right panel_toolbox">
                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                    </li>
                    <li class="dropdown">
                      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                      <ul class="dropdown-menu" role="menu">
                        <li><a href="#">Settings 1</a>
                        </li>
                        <li><a href="#">Settings 2</a>
                        </li>
                      </ul>
                    </li>
                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                    </li>
                  </ul>
                  <div class="clearfix"></div>
                </div>
                <div class="x_content">
                  <h4>Account Current Status</h4>
                  <div class="widget_summary">
                    <div class="w_left w_25">
                      <span>1</span>
                    </div>
                    <div class="w_center w_55">
                        <div   style="width: 66%;">
                          <span> <b>Groups</b></span>
                        </div>
                    </div>
                    <div class="w_right w_20">
					<?php 
					$s=mysqli_query($con,"select * from airtime_groups where customer_id='$session_id' ");
					$nums=mysqli_num_rows($s);
					?>
                      <span><?php echo $nums; ?></span>
                    </div>
                    <div class="clearfix"></div>
                  </div>

                  <div class="widget_summary">
                    <div class="w_left w_25">
                      <span>2</span>
                    </div>
                    <div class="w_center w_55">
                        <div  style="width: 66%;">
                          <span ><b>Contacts</b></span>
                        </div>
                    </div>
                    <div class="w_right w_20">
					<?php 
					$s2=mysqli_query($con,"select * from airtime_contacts where customer_id='$session_id' ");
					$nums2=mysqli_num_rows($s2);
					?>
                      <span><?php echo $nums2; ?></span>
                    </div>
                    <div class="clearfix"></div>
                  </div>
				  
                  <div class="widget_summary">
                    <div class="w_left w_25">
                      <span>3</span>
                    </div>
                    <div class="w_center w_55">
                        <div  style="width: 66%;">
                          Credit Received (Ksh) 
                        </div>
                    </div>
                    <div class="w_right w_20">
					<?php 
					//$result = mysqli_query($con,"SELECT SUM(amount_awarded) AS value_sum FROM airtime_topup_requests where customer_id='$session_id' and status='Done' ");
					
					$result = mysqli_query($con,"SELECT SUM(credit_amount) AS value_sum FROM credit_topup where shop_id='$sid' ");
						$row = mysqli_fetch_array($result); 
						$sum = $row['value_sum'];
					?>
                      <span><?php echo $sum; ?></span>
                    </div>
                    <div class="clearfix"></div>
                  </div>
				  
                  <div class="widget_summary">
                    <div class="w_left w_25">
                      <span>4</span>
                    </div>
                    <div class="w_center w_55">
                        <div  style="width: 66%;">
                          <span>Total Credit Sent (Ksh)</span>
                        </div>
                    </div>
                    <div class="w_right w_20">
					<?php
					//	$bal=$usrcr['current_amount'];
						$bal=$usrcr['amount'];
						$total =$sum;
						$sent =  $total - (int)$bal;
					 ?>
                      <span><?php echo $sent; ?></span>
                    </div>
                    <div class="clearfix"></div>
                  </div>
				  
                  <div class="widget_summary">
                    <div class="w_left w_25">
                      <span>5</span>
                    </div>
                    <div class="w_center w_55">
                        <div  style="width: 66%;">
                          <span >Credit Balance (Ksh)</span>
                        </div>
                    </div>
                    <div class="w_right w_20">
					<?php 
					//$bal=$usrcr['current_amount'];
					$bal=$usrcr['amount'];
					$rem = (int)$bal;
					?>
                      <span><?php echo $rem;?></span>
                    </div>
                    <div class="clearfix"></div>
                  </div>

                </div>
              </div>
            </div>
			
			
			   <div class="col-md-4 col-sm-4 col-xs-12">
              <div class="x_panel tile fixed_height_320 overflow_hidden">
                <div class="x_title">
                  <h2>Recent Account Topups</h2>
                  <ul class="nav navbar-right panel_toolbox">
                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                    </li>
                    <li class="dropdown">
                      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                      <ul class="dropdown-menu" role="menu">
                        <li><a href="#">Settings 1</a>
                        </li>
                        <li><a href="#">Settings 2</a>
                        </li>
                      </ul>
                    </li>
                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                    </li>
                  </ul>
                  <div class="clearfix"></div>
                </div>
                <div class="x_content">
					 <table class="table table-hover">
                      <thead>
                        <tr>
                          <th>Date</th>
                          <th>Amount Credited (Ksh)</th>
                        </tr>
                      </thead>
                      <tbody>
						<?php
					      // $s=mysql_query("select * from airtime_topup_requests where customer_id='$session_id' and amount_awarded !='' order by date_awarded desc limit 5");
						  
						    $s=mysqli_query($con,"select * from credit_topup where shop_id='$sid' and credit_amount !='' order by topup_time desc limit 5");
							while($data=mysqli_fetch_array($s)){
								?>
								 <tr>
									<td><?php echo $data['topup_time']; ?> </td>
									<td> <?php echo money_format("Ksh. %i",$data['credit_amount']); ?> </td>
								</tr>
								<?php
							}
					  
						?>
                      
                      </tbody>
                    </table>
                </div>
              </div>
            </div>


            <div class="col-md-4 col-sm-4 col-xs-12">
              <div class="x_panel tile fixed_height_320">
                <div class="x_title">
                  <h2>Recent Credit Transfers</h2>
                  <ul class="nav navbar-right panel_toolbox">
                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                    </li>
                    <li class="dropdown">
                      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                      <ul class="dropdown-menu" role="menu">
                        <li><a href="#">Settings 1</a>
                        </li>
                        <li><a href="#">Settings 2</a>
                        </li>
                      </ul>
                    </li>
                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                    </li>
                  </ul>
                  <div class="clearfix"></div>
                </div>
                <div class="x_content">
					 <table class="table table-hover">
                      <thead>
                        <tr>
                          <th>Phone Number</th>
                          <th>Amount Credited (Ksh)</th>
                        </tr>
                      </thead>
                      <tbody>
						<?php 
						 file_put_contents("error_log.log", $session_id ,FILE_APPEND);
					        $s1=mysqli_query($con,"select * from airtime_sending_records where customer_id = '$session_id' order by date_sent desc limit 5");
								while($data=mysqli_fetch_array($s1)){
								 ?>
									 <tr>
										<td> <?php echo $data['recipient']; ?> </td>
										<td> <?php echo rtrim($data['airtime_sent'],"00"); ?> </td>
									</tr>
								<?php
								}
						?>
                      </tbody>
                    </table>
                </div>
              </div>
            </div>
		
		  </div>
		   <div class="row">
		   
		    <div class="col-md-12 col-sm-12 col-xs-12">
              <div class="x_panel">
                <div class="x_title">
                  <h2>Recent Activities <small>Sessions</small></h2>
                  <ul class="nav navbar-right panel_toolbox">
                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                    </li>
                    <li class="dropdown">
                      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                      <ul class="dropdown-menu" role="menu">
                        <li><a href="#">Settings 1</a>
                        </li>
                        <li><a href="#">Settings 2</a>
                        </li>
                      </ul>
                    </li>
                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                    </li>
                  </ul>
                  <div class="clearfix"></div>
                </div>
                <div class="x_content">
                  <div class="dashboard-widget-content">

                    <ul class="list-unstyled timeline widget">
					<?php
					//$s=mysqli_query("select * from airtime_logs where customer_id = '$session_id' and user_actions != 'Logged into the System.' order by id DESC limit 5");
					$s1 = mysqli_query($con,"select * from airtime_logs where customer_id = '$session_id' and user_actions = '' order by id DESC limit 5");
					while($sessiondata = mysqli_fetch_array($s1)){
						?>
						<li>
							<div class="block">
								<div class="block_content">
									<h5 class="title">
                                              <a>Date&nbsp;&nbsp;<b><?php echo $sessiondata['login_date'];?></b>&nbsp;&nbsp;From &nbsp;&nbsp;<b><?php echo $sessiondata['login_time'];?></b>&nbsp;&nbsp;To &nbsp;&nbsp;<b><?php echo $sessiondata['logout_time'];?> </b></a>
                                    </h5>
									<div class="byline"> </div>
									<p class="excerpt" > <?php echo $sessiondata['user_actions'];?> </p>
								</div>
							</div>
						</li>
						<?php
					}
					
					?>
                   
                    </ul>
                  </div>
                </div>
              </div>
            </div>
		   </div>
		   
		   
		 
          <br />
        
       
        </div>
        <!-- /page content. End of main -->

        <!-- footer content -->
        	<?php 
	    $s2 = mysqli_query($con,"select * from airtime_customer where customer_id = '$session_id' ") or die (mysqli_error());
				$rows = mysqli_fetch_array($s2);
				$comp = $rows['company']; 
				
	?>
        <footer>
          <div  style="text-align:center;" >  
            Copyright &copy; <?php echo date("Y").".";?> &nbsp;&nbsp;<b><?php echo ucwords($comp);//echo strtoupper($comp);  ?> Airtime Portal.</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Powered By <a href="https://www.mobisky.biz"><u>Mobisky Innovations Ltd.</u></a> 
            
          </div>
          <div class="clearfix"></div>
        </footer>
        <!-- /footer content -->
     

    <!-- jQuery -->
    <script src="vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="vendors/nprogress/nprogress.js"></script>
    <!-- Chart.js -->
    <script src="vendors/Chart.js/dist/Chart.min.js"></script>
    <!-- gauge.js -->
    <script src="vendors/bernii/gauge.js/dist/gauge.min.js"></script>
    <!-- bootstrap-progressbar -->
    <script src="vendors/bootstrap-progressbar/bootstrap-progressbar.min.js"></script>
    <!-- iCheck -->
    <script src="vendors/iCheck/icheck.min.js"></script>
    <!-- Skycons -->
    <script src="vendors/skycons/skycons.js"></script>
    <!-- Flot -->
    <script src="vendors/Flot/jquery.flot.js"></script>
    <script src="vendors/Flot/jquery.flot.pie.js"></script>
    <script src="vendors/Flot/jquery.flot.time.js"></script>
    <script src="vendors/Flot/jquery.flot.stack.js"></script>
    <script src="vendors/Flot/jquery.flot.resize.js"></script>
    <!-- Flot plugins -->
    <script src="js/flot/jquery.flot.orderBars.js"></script>
    <script src="js/flot/date.js"></script>
    <script src="js/flot/jquery.flot.spline.js"></script>
    <script src="js/flot/curvedLines.js"></script>
    <!-- jVectorMap -->
    <script src="js/maps/jquery-jvectormap-2.0.3.min.js"></script>
    <!-- bootstrap-daterangepicker -->
    <script src="js/moment/moment.min.js"></script>
    <script src="js/datepicker/daterangepicker.js"></script>


    <!-- Custom Theme Scripts -->
    <script src="js/custom.js"></script>

    <!-- Flot -->
    <script>
      $(document).ready(function() {
        var data1 = [
          [gd(2012, 1, 1), 17],
          [gd(2012, 1, 2), 74],
          [gd(2012, 1, 3), 6],
          [gd(2012, 1, 4), 39],
          [gd(2012, 1, 5), 20],
          [gd(2012, 1, 6), 85],
          [gd(2012, 1, 7), 7]
        ];

        var data2 = [
          [gd(2012, 1, 1), 82],
          [gd(2012, 1, 2), 23],
          [gd(2012, 1, 3), 66],
          [gd(2012, 1, 4), 9],
          [gd(2012, 1, 5), 119],
          [gd(2012, 1, 6), 6],
          [gd(2012, 1, 7), 9]
        ];
        $("#canvas_dahs").length && $.plot($("#canvas_dahs"), [
          data1, data2
        ], {
          series: {
            lines: {
              show: false,
              fill: true
            },
            splines: {
              show: true,
              tension: 0.4,
              lineWidth: 1,
              fill: 0.4
            },
            points: {
              radius: 0,
              show: true
            },
            shadowSize: 2
          },
          grid: {
            verticalLines: true,
            hoverable: true,
            clickable: true,
            tickColor: "#d5d5d5",
            borderWidth: 1,
            color: '#fff'
          },
          colors: ["rgba(38, 185, 154, 0.38)", "rgba(3, 88, 106, 0.38)"],
          xaxis: {
            tickColor: "rgba(51, 51, 51, 0.06)",
            mode: "time",
            tickSize: [1, "day"],
            //tickLength: 10,
            axisLabel: "Date",
            axisLabelUseCanvas: true,
            axisLabelFontSizePixels: 12,
            axisLabelFontFamily: 'Verdana, Arial',
            axisLabelPadding: 10
          },
          yaxis: {
            ticks: 8,
            tickColor: "rgba(51, 51, 51, 0.06)",
          },
          tooltip: false
        });

        function gd(year, month, day) {
          return new Date(year, month - 1, day).getTime();
        }
      });
    </script>
    <!-- /Flot -->

    <!-- jVectorMap -->
    <script src="js/maps/jquery-jvectormap-world-mill-en.js"></script>
    <script src="js/maps/jquery-jvectormap-us-aea-en.js"></script>
    <script src="js/maps/gdp-data.js"></script>
    <script>
      $(document).ready(function(){
        $('#world-map-gdp').vectorMap({
          map: 'world_mill_en',
          backgroundColor: 'transparent',
          zoomOnScroll: false,
          series: {
            regions: [{
              values: gdpData,
              scale: ['#E6F2F0', '#149B7E'],
              normalizeFunction: 'polynomial'
            }]
          },
          onRegionTipShow: function(e, el, code) {
            el.html(el.html() + ' (GDP - ' + gdpData[code] + ')');
          }
        });
      });
    </script>
    <!-- /jVectorMap -->

    <!-- Skycons -->
    <script>
      $(document).ready(function() {
        var icons = new Skycons({
            "color": "#73879C"
          }),
          list = [
            "clear-day", "clear-night", "partly-cloudy-day",
            "partly-cloudy-night", "cloudy", "rain", "sleet", "snow", "wind",
            "fog"
          ],
          i;

        for (i = list.length; i--;)
          icons.set(list[i], list[i]);

        icons.play();
      });
    </script>
    <!-- /Skycons -->

    <!-- Doughnut Chart -->
    <script>
      $(document).ready(function(){
        var options = {
          legend: false,
          responsive: false
        };

        new Chart(document.getElementById("canvas1"), {
          type: 'doughnut',
          tooltipFillColor: "rgba(51, 51, 51, 0.55)",
          data: {
            labels: [
              "Symbian",
              "Blackberry",
              "Other",
              "Android",
              "IOS"
            ],
            datasets: [{
              data: [15, 20, 30, 10, 30],
              backgroundColor: [
                "#BDC3C7",
                "#9B59B6",
                "#E74C3C",
                "#26B99A",
                "#3498DB"
              ],
              hoverBackgroundColor: [
                "#CFD4D8",
                "#B370CF",
                "#E95E4F",
                "#36CAAB",
                "#49A9EA"
              ]
            }]
          },
          options: options
        });
      });
    </script>
    <!-- /Doughnut Chart -->
    
    <!-- bootstrap-daterangepicker -->
    <script>
      $(document).ready(function() {

        var cb = function(start, end, label) {
          console.log(start.toISOString(), end.toISOString(), label);
          $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
        };

        var optionSet1 = {
          startDate: moment().subtract(29, 'days'),
          endDate: moment(),
          minDate: '01/01/2012',
          maxDate: '12/31/2015',
          dateLimit: {
            days: 60
          },
          showDropdowns: true,
          showWeekNumbers: true,
          timePicker: false,
          timePickerIncrement: 1,
          timePicker12Hour: true,
          ranges: {
            'Today': [moment(), moment()],
            'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
            'Last 7 Days': [moment().subtract(6, 'days'), moment()],
            'Last 30 Days': [moment().subtract(29, 'days'), moment()],
            'This Month': [moment().startOf('month'), moment().endOf('month')],
            'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
          },
          opens: 'left',
          buttonClasses: ['btn btn-default'],
          applyClass: 'btn-small btn-primary',
          cancelClass: 'btn-small',
          format: 'MM/DD/YYYY',
          separator: ' to ',
          locale: {
            applyLabel: 'Submit',
            cancelLabel: 'Clear',
            fromLabel: 'From',
            toLabel: 'To',
            customRangeLabel: 'Custom',
            daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
            monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
            firstDay: 1
          }
        };
        $('#reportrange span').html(moment().subtract(29, 'days').format('MMMM D, YYYY') + ' - ' + moment().format('MMMM D, YYYY'));
        $('#reportrange').daterangepicker(optionSet1, cb);
        $('#reportrange').on('show.daterangepicker', function() {
          console.log("show event fired");
        });
        $('#reportrange').on('hide.daterangepicker', function() {
          console.log("hide event fired");
        });
        $('#reportrange').on('apply.daterangepicker', function(ev, picker) {
          console.log("apply event fired, start/end dates are " + picker.startDate.format('MMMM D, YYYY') + " to " + picker.endDate.format('MMMM D, YYYY'));
        });
        $('#reportrange').on('cancel.daterangepicker', function(ev, picker) {
          console.log("cancel event fired");
        });
        $('#options1').click(function() {
          $('#reportrange').data('daterangepicker').setOptions(optionSet1, cb);
        });
        $('#options2').click(function() {
          $('#reportrange').data('daterangepicker').setOptions(optionSet2, cb);
        });
        $('#destroy').click(function() {
          $('#reportrange').data('daterangepicker').remove();
        });
      });
    </script>
    <!-- /bootstrap-daterangepicker -->

    <!-- gauge.js -->
    <script>
      var opts = {
          lines: 12,
          angle: 0,
          lineWidth: 0.4,
          pointer: {
              length: 0.75,
              strokeWidth: 0.042,
              color: '#1D212A'
          },
          limitMax: 'false',
          colorStart: '#1ABC9C',
          colorStop: '#1ABC9C',
          strokeColor: '#F0F3F3',
          generateGradient: true
      };
      var target = document.getElementById('foo'),
          gauge = new Gauge(target).setOptions(opts);

      gauge.maxValue = 6000;
      gauge.animationSpeed = 32;
      gauge.set(3200);
      gauge.setTextField(document.getElementById("gauge-text"));
    </script>
    <!-- /gauge.js -->
  </body>
</html>