
<?php
@session_start();
 $vg_login=$_SESSION["usuario"];
 if($vg_login<>""){}
 else
  {echo "<script>";
   echo "window.location='index.php';";
   echo "</script>";
  }	

  include "../parametros.php";
  include "../conexion.php";
 $sql_datos =mysqli_query($conexion,"select count(*) as contar FROM agenda_tareas
									 where month(fecha)");
 while($datos= mysqli_fetch_row($sql_datos)){ $contar=$datos[0]; }		
 $fechadia=date("Y-m-d");

?>

<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../packages/core/main.css' rel='stylesheet' />
<link href='../packages/daygrid/main.css' rel='stylesheet' />
<link href='../packages/timegrid/main.css' rel='stylesheet' />
<link href='../packages/list/main.css' rel='stylesheet' />
<script src='../packages/core/main.js'></script>
<script src='../packages/interaction/main.js'></script>
<script src='../packages/daygrid/main.js'></script>
<script src='../packages/timegrid/main.js'></script>
<script src='../packages/list/main.js'></script>

  <script src="../../js/jquery.min.js"></script>
  <link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <script src="../../bootstrap/js/bootstrap.min.js"></script>


<script>

		  

  document.addEventListener('DOMContentLoaded', function() {
    var calendarEl = document.getElementById('calendar');

    var calendar = new FullCalendar.Calendar(calendarEl, {
      plugins: [ 'interaction', 'dayGrid', 'timeGrid', 'list' ],
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'dayGridMonth,timeGridWeek,timeGridDay,listMonth'
      },
      defaultDate: '<?php echo $fechadia;?>',
      navLinks: true, // can click day/week names to navigate views
      businessHours: true, // display business hours
      editable: true,
      events: [
	  
	  <?php
	  $c=0;

	  $sql_datos =mysqli_query($conexion,"select actividad,fecha,estado,usuario FROM agenda_actividades");
	 while($datos= mysqli_fetch_row($sql_datos))
			{	
				$actividad=$datos[0];	
				$fecha=$datos[1];
				$estado=$datos2[2];
				$usuario=$datos[3];																						
				
				$horai="00:00:00";
				$horaf="00:00:00";

				if($horai=="00"){$horai="";}
				else {$horai="T".$horai.":00:00";}
				
				if($horaf=="00"){$horaf="";}
				else {$horaf="T".$horaf.":00:00";}
					
				$c++;
				$salidaactividad=$actividad;
				$color="#FFFFFF";

				//$url='../../tarea/frm_tareaseguimiento.php?id=$id';
				
				//$sql_des1=mysqli_query($conexion,"select nombre,color FROM estado where id='".$estado."'");
				//while($datosrs= mysqli_fetch_row($sql_des1)){ $nestado=$datosrs[0];$color=$datosrs[1];}
				$contar=1;
				
			    if($c<$contar)
				 { 	
  	          ?>
					{
					  title: '<?php echo $salidaactividad; ?>',
					  start: '<?php echo $fecha;?><?php echo $horai;?>',
			          end: '<?php echo $fechafin;?><?php echo $horaf;?>',
					  color: '<?php echo $color; ?>',
					},
		   <?php
		         }
			  else
			    {	  
 		  ?>  			
					{
					  title: '<?php echo $salidaactividad; ?>',
					  start: '<?php echo $fecha;?><?php echo $horai;?>',
					  end: '<?php echo $fechafin;?><?php echo $horaf;?>',
					  color: '<?php echo $color; ?>'
					}
		  <?php
		         }
			}	 
		   ?>			
      ]
    });
    calendar.render();
  });

</script>
<style>

  body {
    margin: 40px 10px;
    padding: 0;
    font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
    font-size: 15px;
  }

  #calendar {
    max-width: 900px;

    margin: 0 auto;
  }

</style>
</head>
<body>

<form action="">
<center>
<strong>
<input name="nuevo" type="submit"  id="nuevo"  value="Refresh"     onclick="submit();" class="btn btn-info" />
</strong>
</center>
</form>

  <div id='calendar'></div>

</body>
</html>
