Skip to content
This repository was archived by the owner on Oct 17, 2021. It is now read-only.

Commit 36ced81

Browse files
committed
initial recurring event test
1 parent cc58b4d commit 36ced81

31 files changed

+151
-48
lines changed

LICENSE

100644100755
File mode changed.

README.md

100644100755
File mode changed.

addEvent-json.php

100644100755
Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,50 @@
22

33
//echo $_POST['title'];
44
if (isset($_POST['title']) && isset($_POST['description']) && isset($_POST['start']) && isset($_POST['end']) && isset($_POST['color'])){
5-
6-
$jsonString = file_get_contents('json/events.json');
7-
$data = json_decode($jsonString, true);
8-
9-
$last_item = end($data);
10-
$last_item_id = $last_item['id'];
11-
12-
$start = explode(" ", $_POST['start']);
13-
$end = explode(" ", $_POST['end']);
14-
if($start[1] == '00:00:00'){
15-
$_POST['start'] = $start[0];
16-
}
17-
if($end[1] == '00:00:00'){
18-
$_POST['end'] = $end[0];
19-
}
20-
21-
22-
$extra = array(
23-
'id' => ++$last_item_id,
24-
'title' => $_POST['title'],
25-
'description' => $_POST['description'],
26-
'start' => $_POST['start'],
27-
'end' => $_POST['end'],
28-
'color' => $_POST['color'],
29-
);
30-
31-
$data[] = $extra;
32-
33-
$newJsonString = json_encode($data);
34-
file_put_contents('json/events.json', $newJsonString);
355

6+
$jsonString = file_get_contents('json/events.json');
7+
$data = json_decode($jsonString, true);
8+
9+
$last_item = end($data);
10+
$last_item_id = $last_item['id'];
11+
$last_item_rid = $last_item['rid'];
12+
13+
$start = explode(" ", $_POST['start']);
14+
$end = explode(" ", $_POST['end']);
15+
if($start[1] == '00:00:00') {
16+
$_POST['start'] = $start[0];
17+
}
18+
if($end[1] == '00:00:00') {
19+
$_POST['end'] = $end[0];
20+
}
21+
22+
for ($x = 0; $x < $_POST['count']; $x++) {
23+
if ($x > 0) {
24+
$start[0] = date('Y-m-d', strtotime($start[0] . " + 7 day"));
25+
$_POST['start'] = $start[0] . " " . $start[1];
26+
$end[0] = date('Y-m-d', strtotime($end[0] . " + 7 day"));
27+
$_POST['end'] = $end[0] . " " . $end[1];
28+
if($start[1] == '00:00:00') {
29+
$_POST['start'] = $start[0];
30+
}
31+
if($end[1] == '00:00:00') {
32+
$_POST['end'] = $end[0];
33+
}
34+
}
35+
$extra = array(
36+
'id' => ++$last_item_id,
37+
'rid' => $last_item_rid+1,
38+
'repeat' => $_POST['repeat'],
39+
'title' => $_POST['title'],
40+
'description' => $_POST['description'],
41+
'start' => $_POST['start'],
42+
'end' => $_POST['end'],
43+
'color' => $_POST['color'],
44+
);
45+
$data[] = $extra;
46+
$newJsonString = json_encode($data);
47+
file_put_contents('json/events.json', $newJsonString);
48+
}
3649
}
3750
header('Location: '.$_SERVER['HTTP_REFERER']);
3851

addEvent.php

100644100755
File mode changed.

bdd.php

100644100755
File mode changed.

calendar.sql

100644100755
File mode changed.

css/bootstrap.css

100644100755
File mode changed.

css/bootstrap.min.css

100644100755
File mode changed.

css/fullcalendar.css

100644100755
File mode changed.

css/fullcalendar.min.css

100644100755
File mode changed.

0 commit comments

Comments
 (0)