<?php
session_name("AUTHENUSER");
session_start();
$USERNAME = $_SESSION['SES_USERNAME'];
if(!session_name("AUTHENUSER"))
	{
?>
						<script language="javascript">
						 alert("Waktu Login telah habis.Silahkan Login Kembali");
						document.location="index.php";
						</script>
<?php
	}
if(!$USERNAME)
	{
?>
						<script language="javascript">
						 alert("Harap Login Dahulu.");
						document.location="index.php";
						</script>
<?php
	}
	?>
	<?php include "common/config.php";
	include "include/head.php"; 
	?>
    
<body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
  <h1><i class="icon-calendar"></i> Buletin Board</h1>
</div>
<ol class="breadcrumb">
  <li><a href="add_calender.php">Add Calender</a></li>
<!--  <li><a href="#">Bread</a></li>
  <li><a href="#">Crumbs</a></li>
  <li class="active">Example</li>-->
</ol>
   <div class="main-content">
            <div class="widget">
              <div class="widget-content-white">
                <div id="calendar"></div>
              </div>
            </div>
          </div>
        </div>
      </div>

    </div>
  </div>
</div>

<?php include "include/foot.php"; ?>
<!--<script src='assets/js/for_pages/calendar.js'></script>-->
<script language="javascript">
(function() {
  $(function() {
    var calendar, d, date, m, y;
    date = new Date();
    d = date.getDate();
    m = date.getMonth();
    y = date.getFullYear();
    return calendar = $("#calendar").fullCalendar({
      header: {
        left: "prev,next today",
        center: "title",
        right: "month,agendaWeek,agendaDay"
      },
      selectable: true,
      selectHelper: true,
      select: function(start, end, allDay) {
        var title;
        title = prompt("Event Title:");
        if (title) {
          calendar.fullCalendar("renderEvent", {
            title: title,
            start: start,
            end: end,
            allDay: allDay
          }, true);
        }
        return calendar.fullCalendar("unselect");
      },
      editable: true,
     events: [
	 <?php 
	  //$now = date('Y-m-d');
	  $test33 = mysql_query("select datediff(now(),startdate) as start1,datediff(now(),enddate) as end1,startdate,enddate,description 
	  from calender where user_update  = '$USERNAME'");
	  while($test3 = mysql_fetch_array($test33))
	  {
		  $description = $test3['description'];
		  $startdate = $test3['startdate'];
		  $start1 = $test3['start1']; 
		  $enddate = $test3['enddate']; 
		  $end1 = $test3['end1'];
		  if(strtotime($startdate) < strtotime($now))
		  { 
		 	 $start1 = '+'.$start1;
		  }
		  else
		  {
			  $start1 = '-'.$start1;
		  }
		   
		   if(strtotime($enddate) < strtotime($now))
		  { 
		 	 $end1 = '+'.$end1;
		  }
		  else
		  {
			  $end1 = '-'.$end1;
		  }
	  ?>
         {
          title: '<?php echo $description; ?>',
          start: new Date(y, m, d <?php echo $start1; ?>),
          end: new Date(y, m, d <?php echo $end1; ?>)
        },
		<?php
	  }
	  ?>
      ]
    });
  });

}).call(this);


</script>
</body>

</html>