doctype html
html
style(type='text/css').
.nested_task .gantt_add{
display: none !important;
}
.hideTask{visibility: hidden;}
.updColor{
background-color:#ffeb8a!important;
display: none !important;
}
head
title Munka nyílvántartó
h2.contHeader(id='title') #{title}
br
link(rel='stylesheet' href='/bower_components/bootstrap/dist/css/bootstrap.css')
link(rel='stylesheet', href='/bower_components/bootstrap/dist/css/bootstrap.min.css')
link(rel='stylesheet', href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css')
link(rel='stylesheet' href='/bower_components/jquery-typeahead/dist/jquery.typeahead.min.css')
style.
div.a {
text-indent: 50px;
}
body
#form-group(style='margin-left:20px')
.row
.col-sm-2
select.form-control(id='employeesel',name='employeesel',value=0, tabindex='29', style='background-color:#2C3446;color: #FFFFFF; width: 200px')
option(value='All',selected) Mindenki
each option in employee
option(value=(option.name)) #{option.name}
.col-sm-3
button.btn.btn-default(type='button' id='ajaxSubmit') Új
.col-sm-3
a.btn.btn-success(href='/employee/accesslist') Vissza
br
#form-group
meta(http-equiv='Content-type', content='text/html; charset=utf-8')
script(src='https://cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.js')
link(href='https://cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.css', rel='stylesheet')
style(type='text/css').
html, body{
height:100%;
padding:0px;
margin:0px;
overflow: hidden;
}
#gantt_here(style='width:100%; height:100%;')
script(src='../gantt/locale/locale_hu.js', charset='utf-8')
script(src='/bower_components/jquery/dist/jquery.js')
script(type='text/javascript', src='/bower_components/jquery/dist/jquery.min.js')
script(type='text/javascript', src='/bower_components/moment/min/moment.min.js')
script(src='/bower_components/bootstrap/dist/js/bootstrap.js')
//script(type='text/javascript', src='https://cdn.dhtmlx.com/gantt/edge/ext/dhtmlxgantt_marker.js')
script.
// $("#mworkers").click();
$("#listholidaysadd").addClass("active");
gantt.plugins({
marker: true
});
// Employee list get AJAX
$.get( 'get_employee_list', function(data) {
$('#results').html(data);
// Ligfhtbox customization
var emps=[];
$.each(data,function (idx,emp){
emps.push({'key':emp._id,'label':emp.name})
//console.log(emp); a(href='#',id='1', data-value='worktimeControl') Munkaidő rögzítés
})
gantt.config.lightbox.sections = [
//{name:"description", height:38, map_to:"text", type:"textarea", focus:true},
{name:"employee", height:22, map_to:"employee", type:"select", options: emps, focus:true,
},
{name:"time", height:72, type:"time", map_to:"auto",time_format:["%Y","%m","%d"]}
];
});
// Alkalmazottak szűrése dropdown szerint
/* gantt.attachEvent("onBeforeTaskDisplay", function(id, task){
var selText= document.getElementById("employeesel").value
//console.log(selText);
if (selText==='All') return true;
if (task.text == selText){
return true;
}
return false;
});*/
/* gantt.attachEvent("onLoadEnd", function(){
$('.gantt_grid_head_cell.gantt_grid_head_add.gantt_last_cell').hide();
});*/
/* $("#employeesel").click(function () {
gantt.refreshData();
});*/
gantt.locale.labels.section_employee = "Dolgozó";
/* gantt.config.fit_tasks = true;
gantt.templates.task_class = function(start, end, task){
var children = gantt.getChildren(task.id);
if(children.length)
return "hideTask";
return "";
};*/
// Task childtask hozzáadás gombelrejtése
gantt.templates.grid_row_class = function( start, end, task ){
//console.log(task);
if ( task.$level >=1)
{
// console.log("nested");
return "nested_task";
}
return "";
};
//Read only
function isEditableTask(task){
var dt= moment(task.end_date).isBefore(new Date());
//if (dt===false)
return dt ;
}
gantt.attachEvent("onBeforeTaskDrag", function(task){
var dt= moment(task.end_date).isBefore(new Date());
return !dt;
});
gantt.attachEvent("onBeforeLightbox", function(task){
var dt= moment(task.end_date).isBefore(new Date());
//console.log(dt);
if (!dt)
{
return false;
}
else
{
return true;
}
});
/* gantt.attachEvent("onTaskLoading", function(task){
var dt= moment(task.start_date).isBefore(new Date());
if (dt===true){
task.readOnly=true;//moment(task.end_date).isBefore(new Date());
task.color='gray';
task.editable=false;
}
//task.editable = task.has_owner && task.editable && task.text;
return true;
});*/
//prevent moving to another sub-branch:
gantt.attachEvent("onBeforeTaskDrag", function(id, mode, e){
var task = gantt.getTask(id);
var dt= moment(task.start_date).isBefore(new Date());
if (dt===true)
return false;
return true;
});
// prevent moving to another sub-branch
// Header task hozzáadás gomb elrejtése
/*gantt.templates.grid_header_class = function(columnName, column){
if(columnName == 'add' )
return "updColor";
};*/
gantt.config.columns=[
{name:"text", label:"Dolgozó", tree:true, width:'*' },
{name:"start_date", label:"Kezdési idő", align: "center" },
{name:"duration", label:"Időtartam", align: "center" },
{name:"add", label:"", width:44, hide:false }
];
gantt.config.open_split_tasks = true;
var date_to_str = gantt.date.date_to_str(gantt.config.task_date);
var markerId = gantt.addMarker({
start_date: new Date(),
css: "today",
text: "Most",
title:date_to_str( new Date())
});
gantt.getMarker(markerId); //->{css:"today", text:"Now", id:...}
// gantt.locale.labels.section_priority = "Priority";
/*gantt.init("gantt_here");
var data = {
tasks:[
{id:1, text:"Jacica", type:gantt.config.types.project,render: 'split'},
{id:2, text:"Task #1", start_date:"02-05-2020", duration:6, parent:1},
{id:3, text:"Task #2", start_date:"11-11-2020", duration:8, parent:1, editable:false}
]
};
gantt.parse(data);
*/
gantt.load("/employee/data");
console.log(gantt);
var dp = new gantt.dataProcessor("/employee/api");
dp.init(gantt);
dp.setTransactionMode("REST");