-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorganisation.php
205 lines (182 loc) · 8.13 KB
/
organisation.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
include_once('php/data.php');
?>
<!DOCTYPE html>
<html>
<head>
<?php
// Including head-contents (files, scripts, metadata,...)
echo file_get_contents("partials/head.html");
?>
<style>
table {
margin-top: 35px;
}
</style>
</head>
<body>
<div id="container">
<div id="dashboard">
<img src="media/images/logo.png" id="logo">
<div id="left-nav">
<div id="opunit-select">
<span>Selected OP UNIT</span>
<span id="selected-opunit">
<?php
// Retrieving name of current opunit
foreach ($operational_units as $opunit) {
if ($opunit->id == $_GET['opunit']) {
echo $opunit->name;
break;
}
}
?>
</span>
<div id="opunits">
<ul>
<?php
// Inserting all Operational Units in top navigation bar
foreach ($operational_units as $opunit) {
echo "<li><a class='opunit' id='".$opunit->id."' href='?opunit=".$opunit->id."'>".$opunit->name."</a></li>";
}
?>
</ul>
</div>
</div>
<?php
// Outputting al dashboard-options
echo str_replace("%opunit%", $_GET['opunit'], file_get_contents("partials/dashboard-options.html"));
?>
</div>
<div id="content">
<h2>Organisation</h2>
<!-- Select for division -->
<!--<select name="division">
<option value="">Select division</option>
<?php
foreach ($divisions as $division) {
echo "<option value='".$division->id."'>".$division->name."</option>";
}
?>
</select>-->
<div class="select">
<input type="hidden" class="value" value="" name="division">
<span class="name">Division</span>
<div class="selected">
<span>Select division</span>
<div class="arrow arrow-down"></div>
</div>
<div class="options">
<div class="option" data-value=""> </div>
<?php
foreach ($divisions as $division) {
echo "<div class='option' data-value='".$division->id."'>".$division->name."</div>";
}
?>
</div>
</div>
<!-- Select for customers -->
<!--
<select name="customer" disabled>
<option value="">Select customer</option>
</select>
-->
<div class="select">
<input type="hidden" class="value" value="" name="customer">
<span class="name">Customer</span>
<div class="selected">
<span>Select Customer</span>
<div class="arrow arrow-down"></div>
</div>
<div class="options" id="customer-options">
</div>
</div>
<!-- Select for month-->
<!--<select name="month">
<option value=''>Select month</option>
<option value='4'>April</option>
</select>-->
<div class="select">
<input type="hidden" class="value" value="" name="month">
<span class="name">Month</span>
<div class="selected">
<span>Select Month</span>
<div class="arrow arrow-down"></div>
</div>
<div class="options">
<div class="option" data-value='1'>January</div>
<div class="option" data-value='2'>February</div>
<div class="option" data-value='3'>March</div>
</div>
</div>
<!-- Table of all advisors matching criteria/filters -->
<table id="advisors">
<thead>
<tr>
<th>ID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Manager</th>
<th>CRM_Links</th>
<th>Details</th>
</tr>
</thead>
<tbody id="data"></tbody>
</table>
</div>
</div>
</div>
<script>
//let select_elements = document.querySelector(".select .value");
/*for (i = 0; i < select_elements.length; i++) {
select_elements[i].addEventListener("change", update_table);
}*/
$(".select .value").on('change', function() {
update_table();
});
//document.getElementsByName("division")[0].addEventListener("change", function() {
$("input[name='division']").on('change', function() {
if (document.getElementsByName("division")[0].value == "") {
//document.getElementsByName("customer")[0].disabled = true;
return;
} else {
//document.getElementsByName("customer")[0].disabled = false;
update_customers();
}
});
function update_table() {
let opunit = get_op_unit();
let division = document.getElementsByName("division")[0].value;
let customer = document.getElementsByName("customer")[0].value;
let url = "php/organisation.php?opunit=" + opunit + "&division=" + division;
if (customer != "") {
url += "&customer=" + customer;
}
$.ajax({
type: 'POST',
url: url,
data: $(this).serialize(),
success: function(response) {
document.getElementById("data").innerHTML = response;
}
});
}
function update_customers() {
let division = document.getElementsByName("division")[0].value;
let url = "php/data.php?division=" + division + "&echo=customers_select_list";
$.ajax({
type: 'POST',
url: url,
data: $(this).serialize(),
success: function(response) {
let str = "<div class='option' data-value=''> </div>";
str += response;
document.getElementById("customer-options").innerHTML = str;
set_option_update_effects(document.getElementById("customer-options"));
}
});
}
$(document).ready(function() {update_table();});
</script>
</body>
</html>