-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproto-pontaj.html
275 lines (264 loc) · 11.5 KB
/
proto-pontaj.html
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="styles/evo-calendar.css"/>
<link rel="stylesheet" href="styles/materialize.css">
<link href="styles/nouislider.css" rel="stylesheet">
<script src="scripts/nouislider.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300&display=swap" rel="stylesheet">
<script src="scripts/wNumb.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<nav>
<div class="nav-wrapper">
<a href="?page=logout" class="right" style="padding-right: 10px;">Logout</a>
<ul id="nav-mobile" class="left">
<li><a href="#" data-target="slide-out" class="sidenav-trigger show-on-small hide-on-med-and-up"><i class="material-icons large">menu</i></a></li>
<li><a class="hide-on-small-only linkDashboard" href="#">Dashboard</a></li>
<li><a class="hide-on-small-only linkCalendar" href="#">Calendar</a></li>
<?php if ($account->permissions['timesheet']): ?>
<li><a class="hide-on-small-only linkPontaj" href="#">Ponteaza</a></li>
<?php endif; ?>
<?php if ($account->permissions['raport']): ?>
<li><a class="hide-on-small-only linkRaport" href="#">Raportari</a></li>
<?php endif; ?>
<?php if ($account->permissions['holiday']): ?>
<li><a class="hide-on-small-only linkConcediu" href="#">Concediu</a></li>
<?php endif; ?>
<?php if ($account->permissions['admin']): ?>
<li><a class="hide-on-small-only linkAdmin" href="/?page=admin">Admin</a></li>
<?php endif; ?>
</ul>
</div>
</nav>
<ul id="slide-out" class="sidenav">
<div class="row">
<h5 style="padding: 10px;">Buna <?php echo $account->getFirstName(); ?><a href="#" class="right" onclick="$('.sidenav').sidenav('close');"><i class="material-icons">close</i></a></h5>
<br>
<li><a href="#" class="linkDashboard">Dashboard</a></li>
<li><a href="#" class="linkCalendar">Calendar</a></li>
<?php if ($account->permissions['timesheet']): ?>
<li><a href="#" class="linkPontaj">Ponteaza</a></li>
<?php endif; ?>
<?php if ($account->permissions['raport']): ?>
<li><a href="#" class="linkRaport" href="#">Raportari</a></li>
<?php endif; ?>
<?php if ($account->permissions['holiday']): ?>
<li><a href="#" class="linkConcediu">Concediu</a></li>
<?php endif; ?>
<?php if ($account->permissions['admin']): ?>
<li><a href="/?page=admin" class="linkAdmin">Admin</a></li>
<?php endif; ?>
<br>
<li><a href="?page=logout">Logout</a></li>
</div>
</ul>
<div class="container">
<div class="row"></div>
<div class="row">
<div class="input-field">
<input id="data-pontaj" type="text" class="datepicker" onclick="getHolidays();">
<label for="data-pontaj">Ziua</label>
<span class="helper-text" data-error="Alege o data corecta" data-success="">Alege ziua pentru care vrei sa pontezi</span>
</div>
</div>
<div class="row" id="cereOrar">
<div class="input-field col s6">
<input id="ora-venire" type="text" class="timepicker">
<label for="ora-venire">Ora venire</label>
<span class="helper-text" data-error="Alege o ora corecta" data-success="">Alege ora de incepere a programului</span>
</div>
<div class="input-field col s6">
<input id="ora-plecare" type="text" class="timepicker">
<label for="ora-plecare">Ora plecare</label>
<span class="helper-text" data-error="Alege o ora corecta" data-success="">Alege ora de incheiere a programului</span>
</div>
</div>
<div class="row" id="maxPontajRow">
<h6 id="maxPontaj"></h6>
</div>
<div class="row sticky" id="pontajPB">
<div class="progress taller" id="workPBMain">
<div id="workPB" class="determinate" style="width: 0%"></div>
</div>
</div>
<div class="row hide" id="timesheetsRow">
<ul id="projTimesheet" class="collapsible">
</ul>
</div>
<!-- <div class="row">
<a class='dropdown-trigger btn' href='#' data-target='addProjDD'>Adauga Proiect</a>
<ul id='addProjDD' class='dropdown-content'>
</ul>
</div> -->
<div class="row">
<div class="input-field col s12 l4">
<select id="addProjDD" class="browser-default" onchange="selectProject(value);">
<option value="" disabled selected>Alege proiectul</option>
</select>
</div>
<div class="input-field col s12 l4" id="select1">
</div>
<div class="input-field col s12 l4" id="select2">
</div>
</div>
<div class="row">
<a id="ponteazaBtn" class="waves-effect waves-light btn" onclick="ponteaza();">Ponteaza</a>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script type="text/javascript" src="scripts/scripts.js"></script>
<script>
function ponteaza() {
$("#data-pontaj").removeClass("valid invalid");
$("#ora-venire").removeClass("valid invalid");
$("#ora-plecare").removeClass("valid invalid");
let URLParams = getParameters(window.location.search);
let isEdit = false;
if (URLParams['edit'] !== undefined) {
try {
isEdit = true;
}
catch (err) {
console.log(err);
}
}
if (validatePontaj()) {
let oraVenire, oraPlecare;
if (settingsElement.cereOrar == 1) {
oraVenire = $("#ora-venire").val();
oraPlecare = $("#ora-plecare").val();
} else {
oraVenire = '10:30';
oraPlecare = '19:30';
}
const formData = {
'action' : 'addTimesheet',
'ziua' : getSelectedDate($("#data-pontaj").val()),
'edit' : $('#ponteazaBtn').html().substring(0,8)=='Modifica'?1:0,
'oraVenire' : oraVenire,
'oraPlecare' : oraPlecare,
'timesheet' : timesheetsObject
};
$.ajax({
type : 'POST', // define the type of HTTP verb we want to use (POST for our form)
url : 'handler.php', // the url where we want to POST
data : formData, // our data object
//dataType : 'json', // what type of data do we expect back from the server
encode : true,
success : function(data) {
if (data.substring(0,8)=="Failure:") {
M.toast({html: data.substring(8)});
}
if (data.substring(0,8)=="Success:") {
//e corecta ma
if (!isEdit) {
window.location.href = location.protocol + "//" + location.host + pontajPage + '&edit=' + btoa(getSelectedISODate($("#data-pontaj").val()));
} else {
M.toast({html: 'Modificari salvate cu succes!'})
}
}
},
error: function(){
//
}
});
}
}
$(document).ready(function(){
addLinks();
$('.sidenav').sidenav();
var pontajDate = new Date();
let URLParams = getParameters(window.location.search);
if (URLParams['date'] !== undefined) {
try {
pontajDate = new Date(atob(URLParams['date']));
}
catch (err) {
console.log(err);
}
}
//$('.datepicker').datepicker();
//$('.timepicker').timepicker();
//$('.collapsible').collapsible();
var elems = document.querySelectorAll('.datepicker');
var instances = M.Datepicker.init(elems, {
defaultDate: pontajDate,
setDefaultDate: true,
format: 'dd mmmm yyyy',
onClose: changeSelectedDate,
firstDay: 1,
i18n: {
weekdays: ['Duminica','Luni','Marti','Miercuri','Joi','Vineri','Sambata'],
weekdaysShort: ['Dum','Lun','Mar','Mie','Joi','Vin','Sam'],
weekdaysAbbrev: ['D','L','M','M','J','V','S'],
months: ['Ianuarie','Februarie','Martie','Aprilie','Mai','Iunie','Iulie','August','Septembrie','Octombrie','Noiembrie','Decembrie'],
monthsShort: ['Ian','Feb','Mar','Apr','Mai','Iun','Iul','Aug','Sep','Oct','Noi','Dec']
}
});
$('.collapsible').collapsible();
$.get("handler.php?r=getSettings", function(data, status) {
//console.log("Data: " + data + "\nStatus: " + status);
try {
let initData = JSON.parse(data);
initData.forEach(element => {
settingsElement[element.name] = element.value;
});
if (settingsElement.cereOrar == 0) {
$('#cereOrar').addClass('hide');
$('#maxPontajRow').addClass('hide');
$('#pontajPB').addClass('hide');
}
} catch (e) {
M.toast({html: e});
}
});
$.get("handler.php?r=init", function(data, status) {
//console.log("Data: " + data + "\nStatus: " + status);
let initData;
try {
initData = JSON.parse(data);
collabsObject = initData.collabs;
projectsObject = initData.projects;
activitiesObject = initData.activities;
phasesObject = initData.phases;
milestonesObject = initData.milestones;
} catch (e) {
M.toast({html: e});
}
//initializare categorii proiect
//populateActiveProjects();
populateActiveDropdown();
$('select').formSelect();
});
$("#ora-venire").change(function() {
updatePB();
});
$("#ora-plecare").change(function() {
updatePB();
});
//check if edit
if (URLParams['edit'] !== undefined) {
try {
let editDate = atob(URLParams['edit']);
$('#ponteazaBtn').html('Modifica');
populateEditPontaj(editDate);
}
catch (err) {
console.log(err);
}
} else {
var elems = document.querySelectorAll('.timepicker');
var instances = M.Timepicker.init(elems, {
twelveHour: false,
onCloseEnd: changeSelectedTime
});
}
});
</script>
</body>
</html>