From eafd5feea7cce866102aace013c3ded1df12595b Mon Sep 17 00:00:00 2001 From: Kilian Saffran Date: Wed, 15 May 2019 16:57:42 +0200 Subject: [PATCH] bugfix child planning and daily presence --- apps/data/db/underatert.sqlite | Bin 2667520 -> 2669568 bytes apps/tmpl/creorga/modules/childs/js/child.js | 14 +++++---- .../modules/presences/js/dailypresences.js | 29 +++++++++++------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/apps/data/db/underatert.sqlite b/apps/data/db/underatert.sqlite index 6aa861c468dd7a84fe3aa33f6eb21d1dc792fbcf..9bbf391bf1ff6e5c440cb9a857ca4e90afce1860 100644 GIT binary patch delta 1536 zcma)+e`s4(6vywmH>qiw)MovWrmMEGu}Nc}dB1;z&?Sm&9il^5ah(bW@)X)bB=jut&;;jCW``E9U@~`lr)PMiXx||rotKdg2f3%N#pX8QZNE?w4PzXu^SMAv2^=5`yffrrry{6Y>Ak@)bB_+$JUHnE0-=ppzF7T_5eAs3+& z{f@pyOK6Fvs?bSCGmxZj2K!u=@0(*V;RZ+G4cHW)GzCp$YD`YiMUmrG zN#F!s);Pr~C`R7m^@1hV#nUfyiJ1G(E@<-kG44gA75B0PZ5JSM^A;Y1ziIzr$he0` zVW|xa>KTX3w&zk>P}7R&?i+{mp{5RW1d)r>SAxMN;zw_xmlkr}N!)>wraCFB1w?LTs~|#mA*V#|Fp7j!hif=wrkICjvnTOIpO$8K}%kYn%o#BPsf$xqm#!X@wdT0O@%l@#-;t`zek zXDCITE6DjG#|x7Mu3*W6rSOxInpctgDqU%3bTB#@U5qfJn-O93Fm^I}8Fw-6X7n-o z8BxYPi~&ZBaW7-gr7Q8NIqG?TKu`mfASM~c*YH>Pb^IhA zfKQ>PHaeki+MlbH|1v#$#@7N0{qWszJd~Z0JyAB;+vQZpAl90lZal8(jkji}ZaJ%| z!P$~~rJC5$b;1|&c!4Yn@)I#>ibRL z(~`F7O5GYZdVFpE_#iU{NDz_W&2DeZ!HS%Sux`-*-+2i6=xm^)n@;qAH^8g))U}&v VXuaFnhl^|L@$J39cCpGX|6e~rtB?Qy delta 820 zcma*lUr3Wt6aesh?w$H=ZnZh*OtUukwSBF=+_!IQf0()nA@)%A@5Lh2`KLhe&qG-F zpbzCkBAbJ*Vq%yO1Vv_YA0onnUJRm_dK97ui?Bfi_E2=3kgvh{-G|HJ91iDO3s2IsCSFqVYkfpA<4E^n=w`pO8YAVY+GByZSbc9UIVIeg0rqI@l2kb*izD7E^VtGpg#rbdRbB0)ftOEYh70$B5wl2{^{@MWNN8unWLf z2SFBCdL@JUIsj-jV=+ z?wsxwGYL42#aciHkFYerJZw+u-^qHJQe^R`5sD>YcxzMuJly7li0Ep8c`Jmtp$!t& zh#Cl~LCvM7um_p4kj`GEBIs54;ksr}gAMxxw8TXetyIBYhBNeCjNCbGP0d zzLS^C?{b}JODPXeN=bT+;O+Xjc|sZ8o&KvBo>V4`= datebegin and order by datebegin,dateend;"; if (planuuid){ plansql = "select * from ( select CASE WHEN DATE(birthday,'+' || minage || ' months') < entrydate THEN entrydate ELSE DATE(birthday,'+' || minage || ' months') END AS datebegin, case when date(birthday,'+' || maxage || ' months') > leavedate then leavedate else date(birthday,'+' || maxage || ' months','-1 day') end as dateend, pl.uuid as groupuuid, plt.* from ( select uuid,minage,maxage,grpname,'"+pconfig.uuid+"' as chuuid,(select birthday from childs where childs.uuid='" + pconfig.uuid + "') as birthday, date('"+ curplan.entrydate+"') AS entrydate,date('" + curplan.leavedate +"') AS leavedate from groups) pl join workinghours wk on (wk.datestart <= datebegin) join (select '" + pconfig.uuid + "' as chuuid,* from planningtemplate where planningtemplate.uuid='"+planuuid+"') plt on (plt.chuuid=pl.chuuid) group by groupuuid order by wk.datestart DESC,minage,maxage ) where datebegin!=dateend and dateend >= datebegin order by datebegin,dateend;"; + //console.log(plansql); var plandata = parent.appdb.dbquery(plansql); for (var pl in plandata.sqldata) { @@ -662,7 +663,8 @@ function save_planning() { var sdateend = encodeparam($("#frmeditplanning #dateend").val(),'date'); var checkdatereplace = parent.appdb.dbquery("select uuid from planning where datebegin >= "+sdatebegin+" and dateend <= "+sdateend+" and childuuid='"+pconfig.uuid+"';"); checkdatereplace = checkdatereplace.sqldata; - if (checkdatereplace.length > 0) { + //console.log(checkdatereplace); + if (checkdatereplace && Object.keys(checkdatereplace).length > 0) { var ruuid = new Array(); for (var i in checkdatereplace){ @@ -672,7 +674,7 @@ function save_planning() { } var checkdatesplit = parent.appdb.dbquery("select uuid,dateend from planning where datebegin <= "+sdatebegin+" and dateend >= "+sdateend+" and childuuid='"+pconfig.uuid+"';"); checkdatesplit = checkdatesplit.sqldata; - if (checkdatesplit.length == 1) { + if (checkdatesplit && Object.keys(checkdatesplit).length == 1) { var newuuid = parent.appdb.generate_uuid(); parent.appdb.dbexec("INSERT INTO planning (datebegin, dateend, montimebegin, montimeend, monlunch, tuetimebegin, tuetimeend, tuelunch, wedtimebegin, wedtimeend, wedlunch, thutimebegin, thutimeend, thulunch, fritimebegin, fritimeend, frilunch, sattimebegin, sattimeend, satlunch, suntimebegin, suntimeend, sunlunch, childuuid, uuid, groupuuid, montimebegin2, montimeend2, tuetimebegin2, tuetimeend2, wedtimebegin2, wedtimeend2, thutimebegin2, thutimeend2, fritimebegin2, fritimeend2, sattimebegin2, sattimeend2, suntimebegin2, suntimeend2) SELECT date("+sdateend+",'+1 day'), dateend, montimebegin, montimeend, monlunch, tuetimebegin, tuetimeend, tuelunch, wedtimebegin, wedtimeend, wedlunch, thutimebegin, thutimeend, thulunch, fritimebegin, fritimeend, frilunch, sattimebegin, sattimeend, satlunch, suntimebegin, suntimeend, sunlunch, childuuid, '"+newuuid+"', groupuuid, montimebegin2, montimeend2, tuetimebegin2, tuetimeend2, wedtimebegin2, wedtimeend2, thutimebegin2, thutimeend2, fritimebegin2, fritimeend2, sattimebegin2, sattimeend2, suntimebegin2, suntimeend2 FROM planning where uuid='"+ checkdatesplit[0].uuid +"';"); @@ -681,11 +683,11 @@ function save_planning() { var checkdatefrom = parent.appdb.dbquery("select uuid from planning where datebegin between "+sdatebegin+" and "+sdateend+" and childuuid='"+pconfig.uuid+"';"); var checkdateto = parent.appdb.dbquery("select uuid from planning where dateend between "+sdatebegin+" and "+sdateend+" and childuuid='"+pconfig.uuid+"';"); - if (checkdatefrom.sqldata.length == 1) { + if (checkdatefrom.sqldata && Object.keys(checkdatefrom.sqldata).length == 1) { parent.appdb.dbexec("update planning set datebegin=date("+encodeparam($("#frmeditplanning #dateend").val(),'date')+",'+1 day') where uuid='"+checkdatefrom.sqldata[0].uuid+"'"); } - if (checkdateto.sqldata.length == 1) { + if (checkdateto.sqldata && Object.keys(checkdateto.sqldata).length == 1) { parent.appdb.dbexec("update planning set dateend=date("+encodeparam($("#frmeditplanning #datebegin").val(),'date')+",'-1 day') where uuid='"+checkdateto.sqldata[0].uuid+"'"); } diff --git a/apps/tmpl/creorga/modules/presences/js/dailypresences.js b/apps/tmpl/creorga/modules/presences/js/dailypresences.js index c22b68d..953a308 100644 --- a/apps/tmpl/creorga/modules/presences/js/dailypresences.js +++ b/apps/tmpl/creorga/modules/presences/js/dailypresences.js @@ -81,9 +81,11 @@ $('input[id^="txt"]').on('keydown',function(e){ } }); -$('input[id^="txt"]').focusout(function(e){ - savetime($(this)); -}); +// $('input[id^="txt"]').on('blur',function(e){ +// console.log($(this).attr("id")); +// savetime($(this)); +// } +// ); function initdata() { load_helpers(); @@ -143,16 +145,16 @@ function loadtable(){ rdata += '
'+ ' de: '+ '
' + - '
'+ + '
'+ ' à: '+ '
'+ - '
' + + '' + 'et de: '+ '
' + - '
'+ + ' '+ ' à: '+ '
'+ - '
' + + '' + '
'; rdata += ''+ '
' + @@ -198,8 +200,12 @@ function loadtable(){ } function savetime(obj){ - var fdata =obj.attr('id').split("_"); - var timeval = obj.val(); + var fdata =obj.id.split("_"); + //console.log('savetime'); + //console.log(fdata); + + var timeval = obj.value; + //console.log("Tval 1:" + timeval); var ddltype = $("#" + fdata[1]+ "_ddltype").html(); var psqltime = ""; @@ -208,11 +214,11 @@ function savetime(obj){ }else{ timeval = timeval.replace(/[^\d]/g, '') + "0000"; timeval = timeval.substring(0,2) + ":" + timeval.substring(2,4); - $("#" + obj.attr('id')).val(timeval); + $("#" + obj.id).val(timeval); timeval = "'" + timeval + "'"; } - + // console.log("Tval 2:" + timeval); if (ddltype == 'upd'){ if (fdata[0] == "txtbegintime1"){ @@ -232,6 +238,7 @@ function savetime(obj){ psqltime += "(1,'" + fdata[1] + "',date('" + initdate.toISOString().substring(0,10) + "')," + ((($("#planlunch_" + fdata[1]).exists()) && ($("#planlunch_" + fdata[1]).html() != ''))?"'1'":'null') + ","+timeval+");"; } + // console.log(psqltime); if (psqltime !== ""){ parent.appdb.dbexec(psqltime); -- 2.39.5