forked from itflow-org/itflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calendar_events.php
156 lines (126 loc) · 5.5 KB
/
calendar_events.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
<?php include("header.php"); ?>
<?php
if(isset($_GET['calendar_id'])){
$calendar_selected_id = intval($_GET['calendar_id']);
}
?>
<div id='calendar'></div>
<?php
include("add_calendar_event_modal.php");
include("add_calendar_modal.php");
include("add_quick_modal.php");
?>
<?php
//loop through IDs and create a modal for each
$sql = mysqli_query($mysqli,"SELECT * FROM events, calendars WHERE event_calendar_id = calendar_id AND calendars.company_id = $session_company_id");
while($row = mysqli_fetch_array($sql)){
$event_id = $row['event_id'];
$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'];
$client_id = $row['event_client_id'];
include("edit_calendar_event_modal.php");
}
?>
<?php include("footer.php"); ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
themeSystem: 'bootstrap',
defaultView: 'dayGridMonth',
customButtons: {
addEvent: {
bootstrapFontAwesome: 'fa fa-plus',
click: function() {
$("#addCalendarEventModal").modal();
}
},
addCalendar: {
bootstrapFontAwesome: 'fa fa-calendar-plus',
click: function() {
$("#addCalendarModal").modal();
}
}
},
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay,listMonth addEvent addCalendar'
},
events: [
<?php
$sql = mysqli_query($mysqli,"SELECT * FROM events, calendars WHERE event_calendar_id = calendar_id AND calendars.company_id = $session_company_id");
while($row = mysqli_fetch_array($sql)){
$event_id = $row['event_id'];
$event_title = $row['event_title'];
$event_start = $row['event_start'];
$event_end = $row['event_end'];
$calendar_id = $row['calendar_id'];
$calendar_name = $row['calendar_name'];
$calendar_color = $row['calendar_color'];
echo "{ id: '$event_id', title: '$event_title', start: '$event_start', end: '$event_end', color: '$calendar_color'},";
}
?>
<?php
//Invoices Created
$sql = mysqli_query($mysqli,"SELECT * FROM clients, invoices WHERE client_id = invoice_client_id AND clients.company_id = $session_company_id");
while($row = mysqli_fetch_array($sql)){
$event_id = $row['invoice_id'];
$event_title = $row['invoice_prefix'] . $row['invoice_number'] . " " . $row['invoice_scope'];
$event_start = $row['invoice_date'];
echo "{ id: '$event_id', title: ". json_encode($event_title) .", start: '$event_start', color: 'blue'},";
}
?>
<?php
//Quotes Created
$sql = mysqli_query($mysqli,"SELECT * FROM clients, quotes WHERE client_id = quote_client_id AND clients.company_id = $session_company_id");
while($row = mysqli_fetch_array($sql)){
$event_id = $row['quote_id'];
$event_title = $row['quote_prefix'] . $row['quote_number'] . " " . $row['quote_scope'];
$event_start = $row['quote_date'];
echo "{ id: '$event_id', title: ". json_encode($event_title) .", start: '$event_start', color: 'purple'},";
}
?>
<?php
//Tickets Created
$sql = mysqli_query($mysqli,"SELECT * FROM clients, tickets WHERE client_id = ticket_client_id AND clients.company_id = $session_company_id");
while($row = mysqli_fetch_array($sql)){
$event_id = $row['ticket_id'];
$event_title = $row['ticket_prefix'] . $row['ticket_number'] . " " . $row['ticket_subject'];
$event_start = $row['ticket_created_at'];
echo "{ id: '$event_id', title: ". json_encode($event_title) .", start: '$event_start', color: 'orange'},";
}
?>
<?php
//Vendors Added Created
$sql = mysqli_query($mysqli,"SELECT * FROM clients, vendors WHERE client_id = vendor_client_id AND clients.company_id = $session_company_id");
while($row = mysqli_fetch_array($sql)){
$event_id = $row['vendor_id'];
$event_title = $row['vendor_name'];
$event_start = $row['vendor_created_at'];
echo "{ id: '$event_id', title: ". json_encode($event_title) .", start: '$event_start', color: 'brown'},";
}
?>
<?php
//Clients Added
$sql = mysqli_query($mysqli,"SELECT * FROM clients WHERE clients.company_id = $session_company_id");
while($row = mysqli_fetch_array($sql)){
$event_id = $row['client_id'];
$event_title = $row['client_name'];
$event_start = $row['client_created_at'];
echo "{ id: '$event_id', title: ". json_encode($event_title) .", start: '$event_start', color: 'green'},";
}
?>
],
eventClick: function(editEvent) {
$('#editEventModal'+editEvent.event.id).modal();
}
});
calendar.render();
});
</script>