" from (" +
"select vc.uuid,vc.vacyear,vc.datefrom,vc.dateto,vc.type,vc.description,vc.accepted," +
"((strftime('%s',vc.dateto) - strftime('%s',vc.datefrom)) /84600) + 1 as days," +
- "((((strftime('%s',vc.dateto) - strftime('%s',vc.datefrom)) /84600) + 1) / 7) * (7 - (st.weekhours / st.maxdayhours)) as day_to_much," +
+ "((((strftime('%s',vc.dateto) - strftime('%s',vc.datefrom)) /84600) + 2) / 7) * (7 - (st.weekhours / st.maxdayhours)) as day_to_much," +
"(select count(v.vacancydate) from vacancy v where v.vacancydateto is null and strftime('%s',v.vacancydate) not in ('0','6') and v.vacancydate between vc.datefrom and vc.dateto) as vdays,st.weekhours,st.weekhours / maxdayhours as days_per_week,vc.timefrom,vc.timeto,st.maxdayhours, " +
"cast(cast(strftime(\"%s\",vc.timeto) as int)- cast(strftime(\"%s\",vc.timefrom) as int) as real)/3600 as hours " +
"from vacancycalendar vc join staff st on (vc.staffuuid=st.uuid) where vc.staffuuid='"+ pconfig.uuid+"' and vc.vacyear=" + pconfig.year+"));";
-
+ //days_to_much => +2 for sat+sun => +1 for saturday icluded
var vacdata = parent.appdb.dbquery(vacdatasql);
var sums = { normal:0,except:0,ill:0,normal_ok:0,except_ok:0,ill_ok:0};
function set_selectyears() {
- var years = parent.appdb.dbquery("select COALESCE((select cast(min(vacancyyear) as TEXT) as minyear from staffvacancydays where staffuuid='4b86fe07-d175-c74e-aafc-40e2275f3b6d'),strftime('%Y',coalesce(min(entrydate),date('now','-1 year')))) as minyear,strftime('%Y',date('now', '+1 year')) as maxyear from staff where uuid='"+pconfig.uuid+"';");
+ var years = parent.appdb.dbquery("select COALESCE((select cast(min(vacancyyear) as TEXT) as minyear from staffvacancydays where staffuuid='" + pconfig.uuid + "'),strftime('%Y',coalesce(min(entrydate),date('now','-1 year')))) as minyear,strftime('%Y',date('now', '+1 year')) as maxyear from staff where uuid='"+pconfig.uuid+"';");
var minyear = parseInt(years.sqldata[0].minyear);
var maxyear = parseInt(years.sqldata[0].maxyear);
for (var y=minyear;y<=maxyear;y++){