<?php require_once("config.php"); ?>
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="css/material-dashboard.css" rel="stylesheet"/>
<!--link href="assets/font-awesome/css/font-awesome.min.css" rel="stylesheet"-->
<!--script src="assets/js/jquery.min.js" type="text/javascript"></script-->
<link href='js/fullcalendar.min.css' rel='stylesheet' />
<link href='js/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='js/moment.min.js'></script>
<script src='js/fullcalendar.min.js'></script>
<script src='js/locale-all.js'></script>
<script src='js/es.js'></script>
<!--body-->
<?php
class ReservasData {
public static $tablename = "tcalendario";
public function ReservasData() {
$this->name = "";
$this->lastname = "";
$this->email = "";
$this->password = "";
$this->created_at = "NOW()";
}
public static function getEvery() {
$dbhost = "localhost";
$dbname = "clube1";
$dbuser = "root";
$dbpass = "";
$db = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
$sql = "select * from " . self::$tablename;
$query = array($db->query($sql), $db->insert_id);
return self::many($query[0], new ReservasData());
}
public static function many($query, $aclass) {
$cnt = 0;
$array = array();
while ($r = $query->fetch_array()) {
$array[$cnt] = new $aclass;
$cnt2 = 1;
foreach ($r as $key => $v) {
if ($cnt2 > 0 && $cnt2 % 2 == 0) {
$array[$cnt]->$key = $v;
}
$cnt2++;
}
$cnt++;
}
return $array;
}
}
$thejson = null;
$events = ReservasData::getEvery();
foreach ($events as $event) {
$thejson[] = array("title" => $event->title, "start" => $event->date_at . "T" . $event->time_at);
}
?>
<script>
$(document).ready(function () {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,listMonth'
},
defaultDate: '<?php echo date('Y-m-d'); ?>',
defaultView:'listMonth',
editable: false,
navLinks: true,
timeFormat: 'H(:mm)', // uppercase H for 24-hour clock
weekNumbers: true,
weekNumbersWithinDays: true,
weekNumberCalculation: 'ISO',
businessHours: true,
eventLimit: true, // allow "more" link when too many events
events: <?php echo json_encode($thejson); ?>
});
});
</script>
<script>
$('#refresh_cal').puibutton();
$("#zdk_cal_act .bt-refresh_cal").click(function () {
$('#calendar').fullCalendar( 'refetchEvents' );
// aqui estoy intentando hacer que se refresque la vista, pero no lo hace,
});
</script>
<div class="card-content table-responsive" id="zdk_cal_act" >
<button class="bt-refresh_cal" id="refresh_cal">Actualizar</button>
<div id="calendar"></div>
</div>