Execute PHP internal web-server on nix-shell

This commit is contained in:
coolneng 2020-06-18 15:59:21 +02:00
parent ac456c2328
commit 7106239d88
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
6 changed files with 5755 additions and 67 deletions

View File

@ -16,5 +16,7 @@ mkShell {
mysql --socket="$(pwd)/.mysql/mysql.sock" -u root < $(pwd)/database/db.sql
alias mysql='mysql --socket="$(pwd)/.mysql/mysql.sock" -u root'
php -S localhost:8000
'';
}

View File

@ -8,9 +8,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../static/style.css" type="text/css" media="screen" />
<link href='../lib/fullcalendar/core/main.css' rel='stylesheet' />
<link href='../lib/fullcalendar/daygrid/main.css' rel='stylesheet' />
<script src='../lib/fullcalendar/core/main.js'></script>
<script src='../lib/fullcalendar/daygrid/main.js'></script>
<script src='../lib/fullcalendar/moment/main.min.js'></script>
<script src="../static/jquery-3.5.1.min.js"></script>
<script src="../static/moment.js"></script>
<script src="calendar.js"></script>
</head>
<body>
@ -31,6 +32,7 @@
</ul>
</nav>
</header>
<div class="response"></div>
<div id="calendar" style="max-width: 700px; margin: auto;"></div>
</body>
</html>

View File

@ -1,27 +1,79 @@
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
$(document).ready(function () {
var calendar = $('#calendar').fullCalendar({
editable: true,
events: "fetch-event.php",
displayEventTime: false,
eventRender: function (event, element, view) {
if (event.allDay === 'true') {
event.allDay = true;
} else {
event.allDay = false;
}
},
selectable: true,
selectHelper: true,
select: function (start, end, allDay) {
var title = prompt('Event Title:');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'dayGrid' ]
});
if (title) {
var start = $.fullCalendar.formatDate(start, "Y-MM-DD HH:mm:ss");
var end = $.fullCalendar.formatDate(end, "Y-MM-DD HH:mm:ss");
calendar.render();
});
$.ajax({
url: 'add-event.php',
data: 'title=' + title + '&start=' + start + '&end=' + end,
type: "POST",
success: function (data) {
displayMessage("Added Successfully");
}
});
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay
},
true
);
}
calendar.fullCalendar('unselect');
},
editable: true,
eventDrop: function (event, delta) {
var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");
var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss");
$.ajax({
url: 'edit-event.php',
data: 'title=' + event.title + '&start=' + start + '&end=' + end + '&id=' + event.id,
type: "POST",
success: function (response) {
displayMessage("Updated Successfully");
}
});
},
eventClick: function (event) {
var deleteMsg = confirm("Do you really want to delete?");
if (deleteMsg) {
$.ajax({
type: "POST",
url: "delete-event.php",
data: "&id=" + event.id,
success: function (response) {
if(parseInt(response) > 0) {
$('#calendar').fullCalendar('removeEvents', event.id);
displayMessage("Deleted Successfully");
}
}
});
}
}
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
defaultDate: new Date(),
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
dayClick: function(date, jsEvent, view) {
$("#successModal").modal("show");
$("#eventDate").val(date.format());
},
events: <?php echo json_encode($appointments); ?>
});
});
function displayMessage(message) {
$(".response").html("<div class='success'>"+message+"</div>");
setInterval(function() { $(".success").fadeOut(); }, 1000);
}

View File

@ -1,42 +0,0 @@
<?php session_start(); ?>
<html class="no-js" lang="es">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Gestión de citas</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../static/style.css" type="text/css" media="screen" />
<link href='../lib/fullcalendar/core/main.css' rel='stylesheet' />
<link href='../lib/fullcalendar/daygrid/main.css' rel='stylesheet' />
<script src='../lib/fullcalendar/core/main.js'></script>
<script src='../lib/fullcalendar/daygrid/main.js'></script>
<script src="calendar.js"></script>
</head>
<body>
<header>
<nav>
<ul class="navbar-left">
<li class="list"><a href="index.php">Página principal</a></li>
<?php if(isset($_SESSION["user"])) : ?>
<li class="list"><a href="user.php">Usuarios</a></li>
<li class="list"><a href="patient.php">Pacientes</a></li>
<li class="list"><a href="appointment.php">Citas</a></li>
<li class="list"><a href="holiday.php">Vacaciones</a></li>
<?php endif ?>
<?php if($_SESSION["user_type"] == 2) : ?>
<li class="list"><a href="report.php">Informes</a></li>
<?php endif ?>
<li class="list"><a href="login.php">Login</a></li>
</ul>
</nav>
</header>
<form action="../calendar_management.php" method="post">
<div class="input-group">
<label for="eventtitle">:</label>
<input type="eventTitle" name="eventTitle" class="form-control" id="eventTitle" required="">
<input type="hidden" name="eventDate" class="form-control" id="eventDate">
</div>
<button class="btn" type="submit" name="submit" >Guardar</button>
</form>
</body>

5668
static/moment.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -148,3 +148,9 @@ main {
margin-top: 0;
margin-bottom: 0.5em;
}
.success {
background: #cdf3cd;
padding: 10px 60px;
border: #c3e6c3 1px solid;
display: inline-block;
}