mirror of https://github.com/itflow-org/itflow
Added Calendar and Event Functionality
This commit is contained in:
parent
2416f80dba
commit
095def07a1
|
|
@ -0,0 +1,67 @@
|
|||
<div class="modal" id="addCalendarEventModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-calendar-plus"></i> New Event</h5>
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label>Title</label>
|
||||
<input type="text" class="form-control" name="title" placeholder="Title of the event" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Calendar</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-calendar"></i></span>
|
||||
</div>
|
||||
<select class="form-control" name="calendar" required>
|
||||
<option value="">- Select Calendar -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM calendars");
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$calendar_id = $row['calendar_id'];
|
||||
$calendar_name = $row['calendar_name'];
|
||||
?>
|
||||
<option value="<?php echo $calendar_id; ?>"><?php echo $calendar_name; ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label>Starts</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-clock"></i></span>
|
||||
</div>
|
||||
<input type="datetime-local" class="form-control" name="start" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col">
|
||||
<label>Ends</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-stopwatch"></i></span>
|
||||
</div>
|
||||
<input type="datetime-local" class="form-control" name="end" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="add_calendar_event" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
<?php include("header.php"); ?>
|
||||
|
||||
<?php
|
||||
|
||||
if(isset($_GET['calendar_id'])){
|
||||
$calendar_selected_id = intval($_GET['calendar_id']);
|
||||
}
|
||||
|
||||
//Get Calendar list for the select box
|
||||
$sql_calendars = mysqli_query($mysqli,"SELECT * FROM calendars ORDER BY calendar_name DESC");
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM calendars, calendar_events WHERE calendars.calendar_id = calendar_events.calendar_id AND calendar_events.calendar_id LIKE '%$calendar_selected_id%' ORDER BY calendar_event_id DESC");
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h6 class="float-left mt-1"><i class="fa fa-calendar"></i> Events</h6>
|
||||
<form>
|
||||
<select onchange="this.form.submit()" class="form-control mt-5" name="calendar_id">
|
||||
<option value="">ALL</option>
|
||||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql_calendars)){
|
||||
$calendar_id = $row['calendar_id'];
|
||||
$calendar_name = $row['calendar_name'];
|
||||
?>
|
||||
<option <?php if($calendar_id == $calendar_selected_id){ ?> selected <?php } ?> value="<?php echo $calendar_id; ?>"> <?php echo $calendar_name; ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</select>
|
||||
</form>
|
||||
|
||||
<button type="button" class="btn btn-primary btn-sm mr-auto float-right" data-toggle="modal" data-target="#addCalendarEventModal"><i class="fas fa-plus"></i> New</button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-borderless table-hover" id="dataTable" width="100%" cellspacing="0">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Times</th>
|
||||
<th>Title</th>
|
||||
<th>Calendar</th>
|
||||
<th class="text-center">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$calendar_event_id = $row['calendar_event_id'];
|
||||
$calendar_event_title = $row['calendar_event_title'];
|
||||
$calendar_event_start = $row['calendar_event_start'];
|
||||
$calendar_event_end = $row['calendar_event_end'];
|
||||
$calendar_id = $row['calendar_id'];
|
||||
$calendar_name = $row['calendar_name'];
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo date( 'm/d/y', strtotime($calendar_event_start)); ?></td>
|
||||
<td><?php echo date( 'g:i A', strtotime($calendar_event_start)); ?> - <?php echo date( 'g:i A', strtotime($calendar_event_end)); ?></td>
|
||||
<td><?php echo $calendar_event_title; ?></td>
|
||||
<td><?php echo $calendar_name; ?></td>
|
||||
<td>
|
||||
<div class="dropdown dropleft text-center">
|
||||
<button class="btn btn-secondary btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editCalendarEventModal<?php echo $calendar_event_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="post.php?delete_calendar_event=<?php echo $calendar_event_id; ?>">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
include("edit_calendar_event_modal.php");
|
||||
}
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("add_calendar_event_modal.php"); ?>
|
||||
|
||||
<?php include("footer.php");
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
<div class="modal" id="editCalendarEventModal<?php echo $calendar_event_id; ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-calendar"></i> Edit Event</h5>
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="calendar_event_id" value="<?php echo $calendar_event_id; ?>">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label>Title</label>
|
||||
<input type="text" class="form-control" name="title" placeholder="Title of the event" value="<?php echo $calendar_event_title; ?>" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Calendar</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-calendar"></i></span>
|
||||
</div>
|
||||
<select class="form-control" name="calendar" required>
|
||||
<?php
|
||||
|
||||
$sql_calendars_select = mysqli_query($mysqli,"SELECT * FROM calendars");
|
||||
while($row = mysqli_fetch_array($sql_calendars_select)){
|
||||
$calendar_id_select = $row['calendar_id'];
|
||||
$calendar_name_select = $row['calendar_name'];
|
||||
?>
|
||||
<option <?php if($calendar_id == $calendar_id_select){ echo "selected"; } ?> value="<?php echo $calendar_id_select; ?>"><?php echo $calendar_name_select; ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label>Starts</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-clock"></i></span>
|
||||
</div>
|
||||
<input type="datetime-local" class="form-control" name="start" value="<?php echo date('Y-m-d\TH:i:s', strtotime($calendar_event_start)); ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col">
|
||||
<label>Ends</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-stopwatch"></i></span>
|
||||
</div>
|
||||
<input type="datetime-local" class="form-control" name="end" value="<?php echo date('Y-m-d\TH:i:s', strtotime($calendar_event_end)); ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="edit_calendar_event" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
42
post.php
42
post.php
|
|
@ -272,6 +272,48 @@ if(isset($_GET['delete_client'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_calendar_event'])){
|
||||
|
||||
$calendar_id = intval($_POST['calendar']);
|
||||
$title = strip_tags(mysqli_real_escape_string($mysqli,$_POST['title']));
|
||||
$start = strip_tags(mysqli_real_escape_string($mysqli,$_POST['start']));
|
||||
$end = strip_tags(mysqli_real_escape_string($mysqli,$_POST['end']));
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO calendar_events SET calendar_event_title = '$title', calendar_event_start = '$start', calendar_event_end = '$end', calendar_id = $calendar_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Event added to the calendar";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_calendar_event'])){
|
||||
|
||||
$calendar_event_id = intval($_POST['calendar_event_id']);
|
||||
$calendar_id = intval($_POST['calendar']);
|
||||
$title = strip_tags(mysqli_real_escape_string($mysqli,$_POST['title']));
|
||||
$start = strip_tags(mysqli_real_escape_string($mysqli,$_POST['start']));
|
||||
$end = strip_tags(mysqli_real_escape_string($mysqli,$_POST['end']));
|
||||
|
||||
mysqli_query($mysqli,"UPDATE calendar_events SET calendar_event_title = '$title', calendar_event_start = '$start', calendar_event_end = '$end', calendar_id = $calendar_id WHERE calendar_event_id = $calendar_event_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Event modified on the calendar";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_GET['delete_calendar_event'])){
|
||||
$calendar_event_id = intval($_GET['delete_calendar_event']);
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM calendar_events WHERE calendar_event_id = $calendar_event_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Event deleted on the calendar";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_vendor'])){
|
||||
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@
|
|||
<i class="fas fa-fw fa-users mx-2"></i>
|
||||
<span>Clients</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="calendar_events.php">
|
||||
<i class="fas fa-fw fa-calendar mx-2"></i>
|
||||
<span>Calendar</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="products.php">
|
||||
<i class="fas fa-fw fa-box mx-2"></i>
|
||||
|
|
|
|||
Loading…
Reference in New Issue