-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.php
183 lines (139 loc) · 4.46 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Mi Calendario:: Ing. Urian Viera</title>
<link rel="stylesheet" type="text/css" href="css/fullcalendar.min.css">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/home.css">
</head>
<body>
<?php
include('config.php');
$SqlEventos = ("SELECT * FROM eventoscalendar");
$resulEventos = mysqli_query($con, $SqlEventos);
?>
<div class="mt-5"></div>
<div class="container">
<div class="row">
<div class="col msjs">
<?php
include('msjs.php');
?>
</div>
</div>
<div class="row">
<div class="col-md-12 mb-3">
<h3 class="text-center" id="title">Como crear un Calendario de Eventos con PHP y MYSQL</h3>
</div>
</div>
</div>
<div id="calendar"></div>
<?php
include('modalNuevoEvento.php');
include('modalUpdateEvento.php');
?>
<script src ="js/jquery-3.0.0.min.js"> </script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/moment.min.js"></script>
<script type="text/javascript" src="js/fullcalendar.min.js"></script>
<script src='locales/es.js'></script>
<script type="text/javascript">
$(document).ready(function() {
$("#calendar").fullCalendar({
header: {
left: "prev,next today",
center: "title",
right: "month,agendaWeek,agendaDay"
},
locale: 'es',
defaultView: "month",
navLinks: true,
editable: true,
eventLimit: true,
selectable: true,
selectHelper: false,
//Nuevo Evento
select: function(start, end){
$("#exampleModal").modal();
$("input[name=fecha_inicio]").val(start.format('DD-MM-YYYY'));
var valorFechaFin = end.format("DD-MM-YYYY");
var F_final = moment(valorFechaFin, "DD-MM-YYYY").subtract(1, 'days').format('DD-MM-YYYY'); //Le resto 1 dia
$('input[name=fecha_fin').val(F_final);
},
events: [
<?php
while($dataEvento = mysqli_fetch_array($resulEventos)){ ?>
{
_id: '<?php echo $dataEvento['id']; ?>',
title: '<?php echo $dataEvento['evento']; ?>',
start: '<?php echo $dataEvento['fecha_inicio']; ?>',
end: '<?php echo $dataEvento['fecha_fin']; ?>',
color: '<?php echo $dataEvento['color_evento']; ?>'
},
<?php } ?>
],
//Eliminar Evento
eventRender: function(event, element) {
element
.find(".fc-content")
.prepend("<span id='btnCerrar'; class='closeon material-icons'></span>");
//Eliminar evento
element.find(".closeon").on("click", function() {
var pregunta = confirm("Deseas Borrar este Evento?");
if (pregunta) {
$("#calendar").fullCalendar("removeEvents", event._id);
$.ajax({
type: "POST",
url: 'deleteEvento.php',
data: {id:event._id},
success: function(datos)
{
$(".alert-danger").show();
setTimeout(function () {
$(".alert-danger").slideUp(500);
}, 3000);
}
});
}
});
},
//Moviendo Evento Drag - Drop
eventDrop: function (event, delta) {
var idEvento = event._id;
var start = (event.start.format('DD-MM-YYYY'));
var end = (event.end.format("DD-MM-YYYY"));
$.ajax({
url: 'drag_drop_evento.php',
data: 'start=' + start + '&end=' + end + '&idEvento=' + idEvento,
type: "POST",
success: function (response) {
// $("#respuesta").html(response);
}
});
},
//Modificar Evento del Calendario
eventClick:function(event){
var idEvento = event._id;
$('input[name=idEvento').val(idEvento);
$('input[name=evento').val(event.title);
$('input[name=fecha_inicio').val(event.start.format('DD-MM-YYYY'));
$('input[name=fecha_fin').val(event.end.format("DD-MM-YYYY"));
$("#modalUpdateEvento").modal();
},
});
//Oculta mensajes de Notificacion
setTimeout(function () {
$(".alert").slideUp(300);
}, 3000);
});
</script>
<!--------- WEB DEVELOPER ------>
<!--------- URIAN VIERA ----------->
<!--------- PORTAFOLIO: https://blogangular-c7858.web.app -------->
</body>
</html>