From: Kilian Saffran Date: Tue, 7 May 2019 15:37:06 +0000 (+0200) Subject: staff and coworker updates X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=f1a80bc4d76c935362e5faa15b36f38c6ce99012;p=dks_lu.git staff and coworker updates --- diff --git a/apps/data/db/lechatpotte.sqlite b/apps/data/db/lechatpotte.sqlite index b0f92ef..23e32a2 100644 Binary files a/apps/data/db/lechatpotte.sqlite and b/apps/data/db/lechatpotte.sqlite differ diff --git a/apps/data/db/underatert.sqlite b/apps/data/db/underatert.sqlite index b4d60e2..e1a9931 100644 Binary files a/apps/data/db/underatert.sqlite and b/apps/data/db/underatert.sqlite differ diff --git a/apps/index.cgi b/apps/index.cgi index 5d376b5..5a0d4c5 100644 --- a/apps/index.cgi +++ b/apps/index.cgi @@ -9,13 +9,12 @@ use Template; use CGI; use CGI::Cookie; use CGI::Carp qw/fatalsToBrowser/; -#use FindBin qw($Bin $RealBin); + use Data::Dumper; use JSON::PP; use session; -#my $tmpldir = "/mnt/c/Users/ksaff/Workspace/juridig/app/tmpl"; -# chdir(dirname($0)); + my $skl = "skeleton/index.tt"; my $cgi = new CGI(); my $p=(); @@ -24,6 +23,7 @@ my $cookie; # foreach my $pp (@params){ # $p->{$pp} = $cgi->param($pp); # } +my $status = '200 ok'; my $sess = (); my $se = session->new(); my $page = "index.tt"; @@ -79,7 +79,7 @@ if (($ENV{HTTP_USER_AGENT} !~ /Chrome/) || ($ENV{HTTP_USER_AGENT} =~ /Edge/) || # if (!exists($sesdata->{usersession})){ # $p->{page} = "login"; # } -print $cgi->header(-type=>'text/html', -charset=>"utf-8",-cookie => $cookie); +print $cgi->header(-status => $status, -type=>'text/html', -charset=>"utf-8",-cookie => $cookie); my $template = Template->new({INCLUDE_PATH => [dirname($ENV{"SCRIPT_FILENAME"}).'/tmpl']}); my @lv = split(/\//,$filepath); diff --git a/apps/js/app.js b/apps/js/app.js index c290a08..c946fc3 100644 --- a/apps/js/app.js +++ b/apps/js/app.js @@ -130,7 +130,7 @@ document.addEventListener("keydown", function(e) { } - var https = 'https'; + var https = 'http'; $(document).ready(function() { app.baseurl = https + '://' + location.host + location.pathname.substring(0,location.pathname.lastIndexOf('/apps/')+6); @@ -140,25 +140,5 @@ document.addEventListener("keydown", function(e) { app.loadsites(); }); - // $("#appframe").on('load', function(){ - // //console.log($("#appframe").attr("src")); - // var src = $("#appframe").attr("src").replace(/\\/g,'/'); - // src = src.substring(src.indexOf('/creorga/') + 5); - // src = src.substring(0,src.indexOf('?')); - // $.ajax({ - // encoding:"UTF-8", - // url:app.api() +'prefs.cgi?page=service&set=' +encodeURIComponent('{"lastpage":"'+ src+'"}') , - - // success: function (data){ - - - // }, - // error: function(data){ - - // console.log("Error:" + JSON.stringify(data)); - // }, - // async:false - // }); - // }) \ No newline at end of file diff --git a/apps/js/apps.js b/apps/js/apps.js index b884dda..0a72d71 100644 --- a/apps/js/apps.js +++ b/apps/js/apps.js @@ -1,4 +1,4 @@ -var https ='https'; +var https ='http'; function logout() { myurl = https + '://'+ location.host + '/apps/'; $.ajax({ diff --git a/apps/js/webdatabase.js b/apps/js/webdatabase.js index 7f130f3..029000b 100644 --- a/apps/js/webdatabase.js +++ b/apps/js/webdatabase.js @@ -15,8 +15,8 @@ var appdb = { result=data.result; }, error: function(data){ - - console.log("Error:" + JSON.stringify(data)); + + console.log("Error:" + JSON.stringify(data)); }, async:false }); diff --git a/apps/tmpl/creorga/modules/staff/coworker.tt b/apps/tmpl/creorga/modules/staff/coworker.tt index 6ec5195..154787d 100644 --- a/apps/tmpl/creorga/modules/staff/coworker.tt +++ b/apps/tmpl/creorga/modules/staff/coworker.tt @@ -170,6 +170,15 @@ +
+ + +
+ + h +
+ +
diff --git a/apps/tmpl/creorga/modules/staff/js/coworker.js b/apps/tmpl/creorga/modules/staff/js/coworker.js index ce33f08..41f9ebc 100644 --- a/apps/tmpl/creorga/modules/staff/js/coworker.js +++ b/apps/tmpl/creorga/modules/staff/js/coworker.js @@ -21,15 +21,13 @@ function initdata() { if (pconfig == null) { pconfig = {}; } - parent.appdb.dbexec("update vacancycalendar set vacyear=strftime('%Y',datefrom) where vacyear is null;"); + if (!pconfig.year) { pconfig.year=new Date().getFullYear(); - } - if (!pconfig.printlayout) { - pconfig.printlayout = 'list'; parent.apppref.setpreference("coworker",pconfig); } + var cdatasql = "SELECT jobtitle, prename, surname, address, zip, city, country, entrydate, exitdate, iban, bic, accountname, phone, email, uuid,color,weekhours,maxdayhours FROM staff where uuid='" + pconfig.uuid + "';"; var cdata = parent.appdb.dbquery(cdatasql); cdata = cdata.sqldata[0]; @@ -231,6 +229,7 @@ function load_table_vacancy() { if ((yearvac) && (yearvac.sqldata)){ nvyear = yearvac.sqldata[0].hours; } + $("#vacancyyeartotal").val(nvyear); var vacdatasql = "SELECT '" + "' AS action," + "vacyear," + @@ -253,7 +252,7 @@ function load_table_vacancy() { "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+"));"; -//jsdump("XXSQL:" + vacdatasql + "\n"); + var vacdata = parent.appdb.dbquery(vacdatasql); var sums = { normal:0,except:0,ill:0,normal_ok:0,except_ok:0,ill_ok:0}; @@ -261,7 +260,7 @@ var vacdata = parent.appdb.dbquery(vacdatasql); for (var i in vacdata.sqldata){ var row = vacdata.sqldata[i]; - // sums.all = sums.all + ((row.dayhours != '')?parseFloat(row.dayhours):0.00); + sums.normal = sums.normal + ((row.thnormalnv != '')?parseFloat(row.thnormalnv):0.00); sums.except = sums.except + ((row.thextranv != '')?parseFloat(row.thextranv):0.00); sums.ill = sums.ill + ((row.thillnv != '')?parseFloat(row.thillnv):0.00); @@ -304,7 +303,12 @@ var vacdata = parent.appdb.dbquery(vacdatasql); + '' +""; $("#tbl_vacancy > tfoot").html(tfoot); - + $("#vacancyyeartotalopen").val(""); + if (nvyear != ""){ + var sumrest = parseFloat(nvyear) - sums.normal_ok; + $("#vacancyyeartotalopen").val(sumrest.toFixed(2)); + } + $("#tbl_vacancy").bootstrapTable({ locale: 'fr-FR', pagination: false, @@ -329,14 +333,12 @@ function dlg_vacancy(uuid, type) { timefrom: '00:00', hours: maxdayhours, type:'0', - //dailyduration:'1.0', - //hourmax: whr + }; if (type == 'upd') { var evsql = "select uuid,vacdatefrom,vacdateto,timefrom,description,staffuuid,case when hours = '0.00' then '" + maxdayhours +"' else hours end as hours,accepted from (SELECT uuid, strftime(\"%d.%m.%Y\",datefrom) as vacdatefrom, strftime(\"%d.%m.%Y\",dateto) as vacdateto, timefrom, description, '"+pconfig.uuid+"' as staffuuid,type, printf(\"%.2f\",cast((cast(strftime(\"%s\",timeto) as int)- cast(strftime(\"%s\",timefrom) as int))/3600 as real)) as hours,accepted FROM vacancycalendar where uuid='" + uuid.uuid + "');"; - //var evsql = "SELECT uuid, strftime(\"%d.%m.%Y\",datefrom) as vacdatefrom, strftime(\"%d.%m.%Y\",dateto) as vacdateto, timefrom, description, '"+pconfig.uuid+"' as staffuuid,type, case when timefrom!=timeto then '0.' || (cast(substr(timeto,1,2) as int) - cast(substr(timefrom,1,2) as int)) else 1.0 end as dailyduration,null as hours,accepted FROM vacancycalendar where uuid='" + uuid.uuid + "';"; - //dump("EVSQL: " + evsql + "\n"); + evdata = parent.appdb.dbquery(evsql); evdata = evdata.sqldata[0]; if (evdata.type == -1){ @@ -362,7 +364,7 @@ function dlg_vacancy(uuid, type) { } if ($("#frmeditvacancy #" + w)) { - //dump(w + "->"+evdata[w]+"\n"); + if (w == "type"){ $("#frmeditvacancy #" + w + " select").val(evdata[w]); } else { @@ -432,7 +434,7 @@ function save_vacancy() { } else { savesql = "UPDATE vacancycalendar SET vacyear=" + encodeparam(evsvdata.datefrom, 'year') + ", datefrom = date("+encodeparam(evsvdata.datefrom, 'date')+"), dateto = date("+encodeparam(evsvdata.dateto, 'date')+"), timefrom = "+encodeparam(evsvdata.timefrom, 'text')+", timeto = strftime(\"%H:%M\",time("+encodeparam(evsvdata.timefrom, 'text')+",'+"+evsvdata.hours+" hours')), description = "+encodeparam(evsvdata.description, 'text')+", staffuuid = "+encodeparam(evsvdata.staffuuid, 'text')+", type = "+evsvdata.type+" WHERE uuid = '"+evsvdata.uuid+"';"; } - //dump("VACSAVESQL:" + savesql + "\n"); + parent.appdb.dbexec(savesql); load_table_vacancy(); @@ -490,7 +492,7 @@ $("#vacancylastyearrest").val(0); function set_selectyears() { - var years = parent.appdb.dbquery("select 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='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 minyear = parseInt(years.sqldata[0].minyear); var maxyear = parseInt(years.sqldata[0].maxyear); for (var y=minyear;y<=maxyear;y++){ diff --git a/apps/tmpl/creorga/modules/staff/js/staff.js b/apps/tmpl/creorga/modules/staff/js/staff.js index 59a47e1..17475d4 100644 --- a/apps/tmpl/creorga/modules/staff/js/staff.js +++ b/apps/tmpl/creorga/modules/staff/js/staff.js @@ -21,7 +21,7 @@ function loadtable() { [% IF creorga.modules.staff.delete %] delbtn = ""; [% END %] - var sql = "SELECT '"+delbtn+"' as action, coalesce(prename,'') || '
' || coalesce(surname,'') as name,case when color is not null then '
' else null end color, coalesce(address,'')|| '
' || coalesce(zip,'') || ' ' || coalesce(city,'') || '
' || coalesce(country,'') as address, case when phone is not null then ': ' || phone || '
' else '' end || case when email is not null then ':' || email else '' end as phonemail, coalesce(jobtitle,'') || '
' || case when entrydate is not null then 'à partir du: ' || strftime('%d.%m.%Y',entrydate) else '' end || case when exitdate is not null then ' jusqu''au: ' || strftime('%d.%m.%Y',exitdate) else '' end as jobtitle FROM staff;"; + var sql = "SELECT '"+delbtn+"' as action, coalesce(prename,'') || '
' || coalesce(surname,'') as name,case when color is not null then '
' else null end color, coalesce(address,'')|| '
' || coalesce(zip,'') || ' ' || coalesce(city,'') || '
' || coalesce(country,'') as address, case when phone is not null then ': ' || phone || '
' else '' end || case when email is not null then ':' || email else '' end as phonemail, coalesce(jobtitle,'') || '
' || case when entrydate is not null then 'à partir du: ' || strftime('%d.%m.%Y',entrydate) else '' end || case when exitdate is not null then ' jusqu''au: ' || strftime('%d.%m.%Y',exitdate) else '' end as jobtitle FROM staff where inactive is null;"; var data = parent.appdb.dbqueryarray(sql); diff --git a/dev/db/changes.sql b/dev/db/changes.sql index 4df6520..28243dc 100644 --- a/dev/db/changes.sql +++ b/dev/db/changes.sql @@ -1 +1,5 @@ -ALTER TABLE creche add column idcheckservice TEXT; \ No newline at end of file +ALTER TABLE creche add column idcheckservice TEXT; +update vacancycalendar set vacyear=strftime('%Y',datefrom) where vacyear is null; +update vacancycalendar set timeto='08:00' where timeto='00:00'; +ALTER TABLE vacancycalendar add column vacyear integer; +alter table staff add column inactive boolean; \ No newline at end of file diff --git a/img/logo/logo.svg b/img/logo/logo.svg new file mode 100644 index 0000000..7083c47 --- /dev/null +++ b/img/logo/logo.svg @@ -0,0 +1,68 @@ + +image/svg+xml \ No newline at end of file diff --git a/index.cgi b/index.cgi index 605905a..da4ead7 100644 --- a/index.cgi +++ b/index.cgi @@ -5,13 +5,10 @@ use lib ('./apps/lib'); use File::Basename; use Template; use CGI; -use CGI::Carp qw/fatalsToBrowser/; -#use FindBin qw($Bin $RealBin); - +# use CGI::Carp qw/fatalsToBrowser/; # use Data::Dumper; use JSON::PP; -#my $tmpldir = "/mnt/c/Users/ksaff/Workspace/juridig/app/tmpl"; -# chdir(dirname($0)); + my $cgi = new CGI(); my $p=(); @@ -20,54 +17,35 @@ foreach my $pp (@params){ $p->{$pp} = $cgi->param($pp); } my $page = "index.tt"; -my $basepath = substr(dirname($0),length($ENV{"DOCUMENT_ROOT"})); +my $basepath = substr(dirname($ENV{"SCRIPT_FILENAME"}),length($ENV{"DOCUMENT_ROOT"})); my $filepath = substr($cgi->url({-absolute=>1}),length($basepath)+1); -#if (exists($p->{p})){ + if ($filepath ne ""){ $page = $filepath; $page =~ s/html$/tt/; } -#} -#$p->{dirname} = dirname($0); -#if (!exists($p)) -#$p->{baseurl} = $cgi->url({-base=>1}); -#$p->{pathinfo} = -#$p->{basepath} = ; +my $status = '200 ok'; -# if (!exists($p->{sid})) -# { -# $p->{sid} = $cgi->cookie('juridig'); -# } -# my $se = session->new(); -# my $sesdata = $se->getsession($p->{sid}); -# if (!exists($sesdata->{usersession})){ -# $p->{page} = "login"; -# } -print $cgi->header(-type=>'text/html', -charset=>"utf-8"); -my $template = Template->new({INCLUDE_PATH => [dirname($0).'/tmpl']}); +my $template = Template->new({INCLUDE_PATH => [dirname($ENV{"SCRIPT_FILENAME"}).'/tmpl']}); my @lv = split(/\//,$filepath); my $absnum = scalar(@lv)-1; my $vars->{abspath} = ""; for (my $i=0;$i<$absnum;$i++){ $vars->{abspath} .= "../"; } - +if (! -e dirname($ENV{"SCRIPT_FILENAME"}).'/tmpl/page/'.$page){ + $page = 'error.tt'; + $status = '404 not Found'; +} $vars->{basepath} = $basepath; $vars->{page} = 'page/'.$page; $vars->{pagename} = basename($page); $vars->{pagename} =~ s/\.tt$//; -# print Dumper($vars); + my $skl = dirname($page); -# print Dumper($template); +print $cgi->header(-status=>$status, -type=>'text/html', -charset=>"utf-8"); + $template->process("skeleton/index.tt",$vars) || die "Template process failed X: ", $template->error(), "\n"; -# my %headers = map { $_ => $cgi->http($_) } $cgi->http(); -# print "Got the following headers:\n"; -# for my $header ( keys %headers ) { -# print "$header: $headers{$header}
"; -# } -# for my $e ( keys %ENV ) { -# print "ENV: $e: ".$ENV{$e}."
"; -# } diff --git a/tmpl/page/error.tt b/tmpl/page/error.tt new file mode 100644 index 0000000..46a135f --- /dev/null +++ b/tmpl/page/error.tt @@ -0,0 +1,8 @@ +
+
+

ERROR!

+

Diese Seite existiert nicht!

+

This Page does not exist!

+

cette page n'existe pas!

+
+
\ No newline at end of file
' + sums.ill_ok.toFixed(2) + '