{{extend 'layout.html'}}
{{include 'web2py_ajax.html'}}
<script>
$(function(){
$('.activateButton').click(function(){
turnusId = $(this).val();
$.ajax({
type: 'POST',
url: '{{=URL('settings', 'activateTurnus.json')}}',
data: {value: turnusId},
dataType: 'json',
success: function(result){
//console.log("OK");
location.reload(true);
//$('#tablediv').load(document.URL + ' #thisdiv');
},
error: function(){
// console.log("Ni OK");
// TODO ERROR MSG v kolkor se ni nč zgodivo
}
});
});
$('.deleteButton').click(function(){
turnusId = $(this).val();
$.ajax({
type: 'POST',
url: '{{=URL('settings', 'deleteTurnus.json')}}',
data: {value: turnusId},
dataType: 'json',
success: function(result){
//console.log("OK");
location.reload(true);
//$('#tablediv').load(document.URL + ' #thisdiv');
},
error: function(){
// console.log("Ni OK");
// TODO ERROR MSG v kolkor se ni nč zgodivo
}
});
});
});
var ColorPicker = function(){
var picker = $('input[name=sh_color]');
picker.ColorPicker({
onSubmit: function(hsb, hex, rgb, el) {
$(el).val(hex);
$(el).ColorPickerHide();
$(el).parent().css('background', '#'+hex);
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
}
})
.bind('keyup', function(){
$(this).ColorPickerSetColor(this.value);
});
picker.each(function() {
if (this.value) {
$(this).parent().css('background', '#' + this.value);
}
});
};
function compareTime(start, end) {
var s1 = start.split(":")[0] * 3600 + start.split(":")[1] * 60;
var s2 = end.split(":")[0] * 3600 + end.split(":")[1] * 60;
//console.log(s1,s2);
if (s1 > s2) {
result = (86400 - s1) + s2;
}
else {
result = Math.abs(s1 - s2);// Gets difference in seconds
}
return result
}
//alert(dateCompare("12:40:13","20:01:01"));
$(document).ready(function() {
$('.time').clockpicker({
donetext: doneText,
autoclose: true
});
ColorPicker();
jQuery.timeEntry.setDefaults({showSeconds: false});
///Pogledamo če je kje vv gruidu None da se ne kaže
//console.log($('.web2py_htmltable'));
//nastavimo polje lenght da je read only ker se vrednost zračuna
//$('#shift_sh_length1').attr("disabled", true)
$('#shift_sh_code').prop('readonly', true);
$('#shift_sh_code').css( 'background-color', 'DarkGray');
$('#shift_sh_length1').prop('readonly', true);
$('#shift_sh_length1').css( 'background-color', 'DarkGray');
$('#shift_sh_length2').prop('readonly', true);
$('#shift_sh_length2').css( 'background-color', 'DarkGray');
$('#shift_sh_duration').prop('readonly', true);
//polja turnus code in duration se računjo tako za dur1 in dur2
$( ".time" ).change(function() {
//length1
start = $('#shift_sh_start1').val(),
end = $('#shift_sh_end1').val();
var dur = compareTime(start,end)/ 60;
$('#shift_sh_length1').val(dur);
//length2
start2 = $('#shift_sh_start2').val(),
end2 = $('#shift_sh_end2').val();
if (start2){
var codeBeg1 = start.split(":")[0] + start.split(":")[1];
var codeEnd1 = end.split(":")[0] + end.split(":")[1];
var codeBeg2 = start2.split(":")[0] + start2.split(":")[1];
var codeEnd2 = end2.split(":")[0] + end2.split(":")[1];
var tCodeL = codeBeg1 +'-' + codeEnd1 + '&' + codeBeg2 + '-' + codeEnd2;
$('#shift_sh_code').val(tCodeL);
var dur2 = compareTime(start2,end2)/ 60;
$('#shift_sh_length2').val(dur2);
$('#shift_sh_duration').val(dur + dur2);
}
else {
$('#shift_sh_length2').val(null);
//code
var beg = start.split(":")[0] + start.split(":")[1];
var ed = end.split(":")[0] + end.split(":")[1];
var tCode = beg +"-" + ed;
$('#shift_sh_code').val(tCode);
$('#shift_sh_duration').val(dur);
}
});
});
</script>
<style>
.web2py_form {
width: 100%;
}
.w2p_fw {
width: 70%;
}
.generic-widget {
height : 110%;
}
.affix {
top: 60px;
}
.input-group {
width: 100%;
}
.row {
margin-bottom: 10px;
}
.sectionHeader {
margin-bottom: 0;
}
</style>
<head>
<title>{{ =response.title + " - " +T('Shifts')}} </title>
</head>
<h1>{{=T('Edit shifts')}}</h1>
<h3>{{=T('Active shifts')}}</h3>
<div class="col-md-12">
{{=grid_shifts}}
</div>
<!-- Ful grd if ampak dela -->
<!-- In nimam pojma zakaj OR operator ne dela-->
{{if ((str((request.url, request.env.query_string)).find("new") < 0)):}}
{{if ((str((request.url, request.env.query_string)).find("edit") < 0)):}}
<div class="col-md-12" id = "inactiveShifts">
<h3>{{=T('Inactive shitfs')}}</h3>
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<th>{{=T('Code')}}</th>
<th>{{=T('Name')}}</th>
<th>{{=T('Start')}}</th>
<th>{{=T('End')}}</th>
<th>{{=T('Length 1')}}</th>
<th>{{=T('Start 2')}}</th>
<th>{{=T('End 2')}}</th>
<th>{{=T('Length 2')}}</th>
<th>{{=T('Note')}}</th>
<th>{{=T('Activate')}}</th>
<th>{{=T('Delete')}}</th>
</tr>
</thead>
<tbody>
{{for rec in query_inactive:}}
<tr>
<td>{{=rec['sh_code']}}</td>
<td>{{=rec['sh_name']}}</td>
<td>{{=rec['sh_start1']}}</td>
<td>{{=rec['sh_end1']}}</td>
<td>{{=rec['sh_length1']}}</td>
<td>{{=rec['sh_start2']}}</td>
<td>{{=rec['sh_end2']}}</td>
<td>{{=rec['sh_length2']}}</td>
<td>{{=rec['sh_note']}}</td>
<td><button type="button" id = "activateButton" class="activateButton glyphicon glyphicon-ok" value="{{=rec['id']}}"></button></td>
<td><button type="button" id = "deleteButton" class="deleteButton glyphicon glyphicon-trash" value="{{=rec['id']}}"></button></td>
</tr>
{{pass}}
{{pass}}
</tbody>
</table>
</div>
</div>
</div>
{{pass}}