Initial Work on Calendar Event Repeat

This commit is contained in:
johnny@pittpc.com 2021-03-27 16:50:30 -04:00
parent 8b1e374148
commit a122f97b99
5 changed files with 41 additions and 5 deletions

View File

@ -67,6 +67,22 @@
<input type="datetime-local" class="form-control" name="end" required>
</div>
</div>
<div class="form-group">
<label>Repeat</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-recycle"></i></span>
</div>
<select class="form-control select2" name="repeat">
<option value="">Never</option>
<option>Day</option>
<option>Week</option>
<option>Month</option>
<option>Year</option>
</select>
</div>
</div>
<?php if(isset($client_id)){ ?>

View File

@ -26,6 +26,7 @@ while($row = mysqli_fetch_array($sql)){
$event_title = $row['event_title'];
$event_start = $row['event_start'];
$event_end = $row['event_end'];
$event_repeat = $row['event_repeat'];
$calendar_id = $row['calendar_id'];
$calendar_name = $row['calendar_name'];
$calendar_color = $row['calendar_color'];

3
db.sql
View File

@ -295,6 +295,7 @@ CREATE TABLE `events` (
`event_title` varchar(200) NOT NULL,
`event_start` datetime NOT NULL,
`event_end` datetime DEFAULT NULL,
`event_repeat` varchar(200) DEFAULT NULL,
`event_created_at` datetime NOT NULL,
`event_updated_at` datetime DEFAULT NULL,
`event_archived_at` datetime DEFAULT NULL,
@ -980,4 +981,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-03-24 22:03:13
-- Dump completed on 2021-03-27 16:49:58

View File

@ -66,6 +66,22 @@
<input type="datetime-local" class="form-control" name="end" value="<?php echo date('Y-m-d\TH:i:s', strtotime($event_end)); ?>" required>
</div>
</div>
<div class="form-group">
<label>Repeat</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-recycle"></i></span>
</div>
<select class="form-control select2" name="repeat">
<option <?php if(empty($event_repeat)){ echo "selected"; } ?> value="">Never</option>
<option <?php if($event_repeat == "Day"){ echo "selected"; } ?>>Day</option>
<option <?php if($event_repeat == "Week"){ echo "selected"; } ?>>Week</option>
<option <?php if($event_repeat == "Month"){ echo "selected"; } ?>>Month</option>
<option <?php if($event_repeat == "Year"){ echo "selected"; } ?>>Year</option>
</select>
</div>
</div>
<?php if(isset($client_id)){ ?>
@ -113,4 +129,4 @@
</form>
</div>
</div>
</div>
</div>

View File

@ -842,10 +842,11 @@ if(isset($_POST['add_event'])){
$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']));
$repeat = strip_tags(mysqli_real_escape_string($mysqli,$_POST['repeat']));
$client = intval($_POST['client']);
$email_event = intval($_POST['email_event']);
mysqli_query($mysqli,"INSERT INTO events SET event_title = '$title', event_start = '$start', event_end = '$end', event_created_at = NOW(), calendar_id = $calendar_id, client_id = $client, company_id = $session_company_id");
mysqli_query($mysqli,"INSERT INTO events SET event_title = '$title', event_start = '$start', event_end = '$end', event_repeat = '$repeat', event_created_at = NOW(), calendar_id = $calendar_id, client_id = $client, company_id = $session_company_id");
//If email is checked
if($email_event == 1){
@ -919,10 +920,11 @@ if(isset($_POST['edit_event'])){
$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']));
$repeat = strip_tags(mysqli_real_escape_string($mysqli,$_POST['repeat']));
$client = intval($_POST['client']);
$email_event = intval($_POST['email_event']);
mysqli_query($mysqli,"UPDATE events SET event_title = '$title', event_start = '$start', event_end = '$end', event_updated_at = NOW(), calendar_id = $calendar_id, client_id = $client WHERE event_id = $event_id AND company_id = $session_company_id");
mysqli_query($mysqli,"UPDATE events SET event_title = '$title', event_start = '$start', event_end = '$end', event_repeat = '$repeat', event_updated_at = NOW(), calendar_id = $calendar_id, client_id = $client WHERE event_id = $event_id AND company_id = $session_company_id");
//If email is checked
if($email_event == 1){
@ -3907,4 +3909,4 @@ if(isset($_GET['export_trips_csv'])){
}
?>
?>