From: Kilian Saffran Date: Wed, 14 Aug 2019 16:16:46 +0000 (+0200) Subject: billjee and application bug fix X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=74be5ab9e1b107f44a2a58c596a14d3c52912526;p=juridig_lu.git billjee and application bug fix --- diff --git a/backoffice/api/lib/dksinvoice.pm b/backoffice/api/lib/dksinvoice.pm index 1c3331a..123a334 100644 --- a/backoffice/api/lib/dksinvoice.pm +++ b/backoffice/api/lib/dksinvoice.pm @@ -10,6 +10,7 @@ use Data::Dumper; use dksdb; use dksreport; use dksapp; +use Encode; sub new { my $class = shift; @@ -116,7 +117,11 @@ sub newinvoice(){ } my @insql = $self->{db}->create_ddl_insert($inv); - + open(LOG,">>tmp/sql.log"); + print LOG $insql[0]."\n"; + print LOG (); + close(LOG); + $insql[0] = encode("utf-8",$insql[0]); my $newinvid = $self->{db}->dbquery($insql[0]); $prd->{invoiceelements_id_invoice} = $newinvid->{id}; @insql = $self->{db}->create_ddl_insert($prd); diff --git a/backoffice/api/process.cgi b/backoffice/api/process.cgi index 9757262..5337dd3 100644 --- a/backoffice/api/process.cgi +++ b/backoffice/api/process.cgi @@ -61,7 +61,7 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ elsif ($p->{fn} eq "generatevouchers"){ if ($sess->{othergroups} =~ /admin/){ my $sql = "INSERT INTO vouchers (voucher, id_price, used, percentdiscount, expiration) VALUES (substring(md5(random()::text),1,9), ".$p->{id_price}.", false, ".$p->{discount}.", date('".$p->{expiration}."'));"; - foreach (my $i=0..$p->{num}){ + foreach (my $i=0;$i<$p->{num};$i++){ $db->dbexec($sql); } $html->{result} = "OK"; @@ -265,14 +265,26 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ # $html->{result}->{events} = $res; # } elsif($p->{fn} eq "getmonthbilljees"){ - my $sql = "select eventdate,count(*) from billjeetickets where eventdate between date('".$p->{startdate}."') and date(date('".$p->{startdate}."') + interval '41 days') and isdisabled is null and id_user not in (".$sess->{id}.") and (invites is null or invites::text like '%\"' || (select senderemail from billjee where id_user=".$sess->{id}.") || '\"%') group by eventdate order by eventdate;"; - # my $sql = "select eventdate,count(*) from billjeetickets where eventdate between date('".$p->{startdate}."') and date(date('".$p->{startdate}."') + interval '41 days') and isdisabled is null and id_user not in (".$sess->{id}.") and (invites is null or bt.invites::text like '%\"' || (select senderemail from billjee where id_user=".$sess->{id}.") || '\"%') group by eventdate order by eventdate;"; + # my $sql = "select eventdate,count(*) from billjeetickets where eventdate between date('".$p->{startdate}."') and date(date('".$p->{startdate}."') + interval '41 days') and isdisabled is null and id_user not in (".$sess->{id}.") and (invites is null or invites::text like '%\"' || (select senderemail from billjee where id_user=".$sess->{id}.") || '\"%') group by eventdate order by eventdate;"; + $html->{result}->{events} = (); + if (exists($p->{type}) && exists($p->{startdate})){ + my $sql = "select eventdate,count(*) from billjeetickets where eventdate between date('".$p->{startdate}."') and date(date('".$p->{startdate}."') + interval '41 days') and isdisabled is null and id_user not in (".$sess->{id}.") and invites is null group by eventdate order by eventdate;"; + if ($p->{type} eq "user"){ + $sql = "select eventdate,count(*) from billjeetickets where eventdate between date('".$p->{startdate}."') and date(date('".$p->{startdate}."') + interval '41 days') and id_user=".$sess->{id}." group by eventdate order by eventdate;"; + } + if ($p->{type} eq "private"){ + $sql = "select eventdate,count(*) from billjeetickets where eventdate between date('".$p->{startdate}."') and date(date('".$p->{startdate}."') + interval '41 days') and isdisabled is null and id_user not in (".$sess->{id}.") and invites::text like '%\"' || (select senderemail from billjee where id_user=".$sess->{id}.") || '\"%' group by eventdate order by eventdate;"; + } + if ($p->{type} eq "bookings"){ + $sql = "select bt.eventdate,count(*) from billjeetickets bt join billjeebooking bb on (bt.id=bb.id_billjeeticket and bb.id_user=".$sess->{id}.") where eventdate between date('".$p->{startdate}."') and date(date('".$p->{startdate}."') + interval '41 days') group by eventdate order by eventdate;"; + } my $res = $db->dbquerybykey("eventdate",$sql); $html->{result}->{events} = $res; + } # $html->{result}->{sql} = $sql; } elsif($p->{fn} eq "getbilljeeeditor"){ - my $sqlins = "INSERT INTO billjeebooking (".$p->{id}.", ".$sess->{id}.", bookingtime) VALUES(0, 0, current_timestamp);"; + my $sqlins = "INSERT INTO billjeebooking (id_billjeeticket, id_user, bookingtime) VALUES(".$p->{id}.", ".$sess->{id}.", now());"; $db->dbexec($sqlins); my $sql = "select bt.court,bt.room,to_char(bt.eventdate,'DD.MM.YYYY') as dspdate,eventtype,case when eventtype ='offer' then 'offre' else 'demande' end as dspeventtype,bt.dayperiod,bj.senderemail as recipient from billjeetickets bt join billjee bj on (bt.id_user=bj.id_user and bt.id=".$p->{id}.")"; my $res = $db->dbquerysorted($sql); @@ -283,47 +295,77 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ } $html->{result}->{contact} = $res->{0}; } - elsif($p->{fn} eq "getmonthbilljeesbyuser"){ - - my $sql = "select eventdate,count(*) from billjeetickets where eventdate between date('".$p->{startdate}."') and date(date('".$p->{startdate}."') + interval '41 days') and id_user=".$sess->{id}." group by eventdate order by eventdate;"; - my $res = $db->dbquerybykey("eventdate",$sql); - $html->{result}->{events} = $res; - } + # elsif($p->{fn} eq "getmonthbilljeesbyuser"){ + + # my $res = $db->dbquerybykey("eventdate",$sql); + # $html->{result}->{events} = $res; + # } elsif($p->{fn} eq "getbilljeeevents"){ #ownevents + $html->{result}->{events} = (); + if (exists($p->{type}) && exists($p->{startdate}) && exists($p->{enddate})){ my $olyf = ""; if ($p->{onlyfuture} eq "true"){ $olyf = "and bt.eventdate >= CURRENT_DATE"; } - my $sql ="select bt.id,bt.id_user,bt.isdisabled,bt.court,bt.room,to_char(bt.eventdate,'DD.MM.YYYY') as dspdate,bt.dayperiod,bt.eventmsg as msg ,bt.eventtype,case when bt.eventtype ='offer' then 'offre' else 'demande' end as dspeventtype,us.prename,us.surname + +# my $sql ="select bt.id,bt.id_user,bt.isdisabled,bt.court,bt.room,to_char(bt.eventdate,'DD.MM.YYYY') as dspdate,bt.dayperiod,bt.eventmsg as msg ,bt.eventtype,case when bt.eventtype ='offer' then 'offre' else 'demande' end as dspeventtype,us.prename,us.surname +# from billjeetickets bt +# join billjee bj on (bj.id_user=bt.id_user) +# join (select users.id,users.prename,users.surname,appaccess.privateenabled from users join appaccess on (appaccess.id_user=users.id) and appaccess.id_app=7) us on (bt.id_user=us.id) +# where bt.eventdate between date('".$p->{startdate}."') and date('".$p->{enddate}."') and us.privateenabled=true +# and isdisabled is null ".$olyf." +# and bt.id_user not in (".$sess->{id}.") +# and (bt.invites is null or bt.invites::text like '%\"' || (select senderemail from billjee where id_user=".$sess->{id}.")|| '\"%') +# order by bt.eventdate,us.surname,us.prename;"; +my $sql ="select bt.id,bt.id_user,bt.isdisabled,bt.court,bt.room,to_char(bt.eventdate,'DD.MM.YYYY') as dspdate,substr(bt.starttime::TEXT,0,5) as starttime,bt.eventmsg as msg ,bt.eventtype,us.prename,us.surname from billjeetickets bt join billjee bj on (bj.id_user=bt.id_user) join (select users.id,users.prename,users.surname,appaccess.privateenabled from users join appaccess on (appaccess.id_user=users.id) and appaccess.id_app=7) us on (bt.id_user=us.id) -where bt.eventdate between date('".$p->{startdate}."') and date('".$p->{enddate}."') and us.privateenabled=true -and isdisabled is null ".$olyf." -and bt.id_user not in (".$sess->{id}.") -and (bt.invites is null or bt.invites::text like '%\"' || (select senderemail from billjee where id_user=".$sess->{id}.")|| '\"%') -order by bt.eventdate,us.surname,us.prename;"; - +where bt.eventdate between date('".$p->{startdate}."') and date('".$p->{enddate}."') +and us.privateenabled=true and isdisabled is null ".$olyf." +and bt.invites is null order by bt.eventdate,us.surname,us.prename;"; + if ($p->{type} eq "private"){ + $sql ="select bt.id,bt.id_user,bt.isdisabled,bt.court,bt.room,to_char(bt.eventdate,'DD.MM.YYYY') as dspdate,substr(bt.starttime::TEXT,0,5) as starttime,bt.eventmsg as msg ,bt.eventtype,us.prename,us.surname +from billjeetickets bt +join billjee bj on (bj.id_user=bt.id_user) +join (select users.id,users.prename,users.surname,appaccess.privateenabled from users join appaccess on (appaccess.id_user=users.id) and appaccess.id_app=7) us on (bt.id_user=us.id) +where bt.eventdate between date('".$p->{startdate}."') and date('".$p->{enddate}."') +and us.privateenabled=true and isdisabled is null ".$olyf." +and and bt.invites::text like '%\"' || (select senderemail from billjee where id_user=".$sess->{id}.")|| '\"%') order by bt.eventdate,us.surname,us.prename;"; + } + if ($p->{type} eq "user"){ + $sql ="select bt.id,bt.id_user,bt.isdisabled,bt.court,bt.room,to_char(bt.eventdate,'DD.MM.YYYY') as dspdate,substr(bt.starttime::TEXT,0,5) as starttime,bt.eventmsg as msg ,bt.eventtype,bt.eventtype,us.prename,us.surname ,'[' || string_agg(bdata::TEXT,',')|| ']' as bookings +from billjeetickets bt +join billjee bj on (bj.id_user=bt.id_user) +left join (select bbook.id_user,bbook.id_billjeeticket,row_to_json(bbook) as bdata from ( +select us1.prename,us1.surname,bb1.id_billjeeticket,bb1.id_user,to_char(bb1.bookingtime,'DD.MM.YYYY HH:MI') as bookingtime,bt1.senderemail from billjeebooking bb1 join billjee bt1 on (bb1.id_user=bt1.id_user) join users us1 on (bb1.id_user=us1.id) order by bb1.bookingtime ASC) as bbook) bb on (bt.id=bb.id_billjeeticket) +join (select users.id,users.prename,users.surname,appaccess.privateenabled from users join appaccess on (appaccess.id_user=users.id) and appaccess.id_app=7) us on (bt.id_user=us.id) +where bt.eventdate between date('".$p->{startdate}."') and date('".$p->{enddate}."') and us.id=".$sess->{id}." group by bt.id,us.prename,us.surname;"; + } + if ($p->{type} eq "bookings"){ + $sql ="select bt.id,bt.id_user,bt.isdisabled,bt.court,bt.room,to_char(bt.eventdate,'DD.MM.YYYY') as dspdate,substr(bt.starttime::TEXT,0,5) as starttime,bt.eventmsg as msg ,bt.eventtype,bt.eventtype,us.prename,us.surname ,'[' || string_agg(bdata::TEXT,',')|| ']' as bookings +from billjeetickets bt +join billjee bj on (bj.id_user=bt.id_user) +left join (select bbook.id_user,bbook.id_billjeeticket,row_to_json(bbook) as bdata from ( +select us1.prename,us1.surname,bb1.id_billjeeticket,bb1.id_user,to_char(bb1.bookingtime,'DD.MM.YYYY HH:MI') as bookingtime,bt1.senderemail from billjeebooking bb1 join billjee bt1 on (bb1.id_user=bt1.id_user) join users us1 on (bb1.id_user=us1.id) order by bb1.bookingtime ASC) as bbook) bb on (bt.id=bb.id_billjeeticket) +join (select users.id,users.prename,users.surname,appaccess.privateenabled from users join appaccess on (appaccess.id_user=users.id) and appaccess.id_app=7) us on (bt.id_user=us.id) +where bt.eventdate between date('".$p->{startdate}."') and date('".$p->{enddate}."') and bdata.id_user=".$sess->{id}." group by bt.id,us.prename,us.surname;"; + } my $res = $db->dbquerysorted($sql); #$html->{result}->{onlyfuture} = $p->{onlyfuture}; $html->{result}->{events} = $res; + } #$html->{result}->{sql} = $sql; } - elsif($p->{fn} eq "getbilljeeeventsbyuser"){ - #ownevents - my $sql ="select bt.id,bt.id_user,bt.isdisabled,bt.court,bt.room,to_char(bt.eventdate,'DD.MM.YYYY') as dspdate,bt.dayperiod,bt.eventmsg as msg ,bt.eventtype,case when bt.eventtype ='offer' then 'offre' else 'demande' end as dspeventtype,us.prename,us.surname ,'[' || string_agg(bdata::TEXT,',')|| ']' as bookings -from billjeetickets bt -join billjee bj on (bj.id_user=bt.id_user) -left join (select bbook.id_billjeeticket,row_to_json(bbook) as bdata from ( -select us1.prename,us1.surname,bb1.id_billjeeticket,bb1.id_user,to_char(bb1.bookingtime,'DD.MM.YYYY HH:MI') as bookingtime,bt1.senderemail from billjeebooking bb1 join billjee bt1 on (bb1.id_user=bt1.id_user) join users us1 on (bb1.id_user=us1.id) order by bb1.bookingtime ASC) as bbook) bb on (bt.id=bb.id_billjeeticket) -join (select users.id,users.prename,users.surname,appaccess.privateenabled from users join appaccess on (appaccess.id_user=users.id) and appaccess.id_app=7) us on (bt.id_user=us.id) -where bt.eventdate between date('".$p->{startdate}."') and date('".$p->{enddate}."') and us.privateenabled=true and us.id=".$sess->{id}." group by bt.id,us.prename,us.surname;"; + # elsif($p->{fn} eq "getbilljeeeventsbyuser"){ + # #ownevents + # my - my $res = $db->dbquerysorted($sql); + # my $res = $db->dbquerysorted($sql); - $html->{result}->{events} = $res; - } + # $html->{result}->{events} = $res; + # } elsif($p->{fn} eq "billjeepublishevent"){ $html->{result}->{id} = $p->{id}; my $sql = "UPDATE billjeetickets set isdisabled=true where id=".$p->{id}." and id_user=".$sess->{id}.";"; diff --git a/backoffice/css/w3pro.css b/backoffice/css/w3pro.css index a9a7f24..a0ed743 100644 --- a/backoffice/css/w3pro.css +++ b/backoffice/css/w3pro.css @@ -51,7 +51,7 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0} .w3-dropdown-hover:hover .w3-dropdown-content{display:block; } .w3-dropdown-hover:first-child,.w3-dropdown-click:hover{background-color:#ccc;color:#000} .w3-dropdown-hover:hover > .w3-button:first-child,.w3-dropdown-click:hover > .w3-button:first-child{background-color:#ccc;color:#000} -.w3-dropdown-content{cursor:auto;color:#000;background-color:#fff;display:none;position:absolute;min-width:160px;margin:0;padding:0;z-index:1} +.w3-dropdown-content{cursor:auto;color:#000;background-color:#fff;display:none;position:absolute;min-width:160px;margin:0;padding:0;z-index:1000} .w3-check,.w3-radio{width:24px;height:24px;position:relative;top:6px} .w3-sidebar{height:100%;width:200px;background-color:#fff;position:fixed!important;z-index:1;overflow:auto} .w3-bar-block .w3-dropdown-hover,.w3-bar-block .w3-dropdown-click{width:100%} @@ -107,7 +107,7 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0} .w3-circle{border-radius:50%} .w3-round-small{border-radius:2px}.w3-round,.w3-round-medium{border-radius:4px}.w3-round-large{border-radius:8px}.w3-round-xlarge{border-radius:16px}.w3-round-xxlarge{border-radius:32px} .w3-row-padding,.w3-row-padding>.w3-half,.w3-row-padding>.w3-third,.w3-row-padding>.w3-twothird,.w3-row-padding>.w3-threequarter,.w3-row-padding>.w3-quarter,.w3-row-padding>.w3-col{padding:0 8px} -.w3-container,.w3-panel{padding:0.01em 16px}.w3-panel{margin-top:16px;margin-bottom:16px} +.w3-container,.w3-panel{padding:0.01em 16px}.w3-panel{margin-top:0px;margin-bottom:0px} .w3-code,.w3-codespan{font-family:Consolas,"courier new";font-size:16px} .w3-code{width:auto;background-color:#fff;padding:8px 12px;border-left:4px solid #4CAF50;word-wrap:break-word} .w3-codespan{color:crimson;background-color:#f1f1f1;padding-left:4px;padding-right:4px;font-size:110%} diff --git a/backoffice/images/icons/chevron-down.svg b/backoffice/images/icons/chevron-down.svg new file mode 100644 index 0000000..4ac4828 --- /dev/null +++ b/backoffice/images/icons/chevron-down.svg @@ -0,0 +1,3 @@ + + + diff --git a/backoffice/js/request.js b/backoffice/js/request.js index 02024ee..cd43031 100644 --- a/backoffice/js/request.js +++ b/backoffice/js/request.js @@ -36,10 +36,10 @@ var req = { request.open(method.toUpperCase(), sendurl, false); request.onload = function(){ if (request.status >= 200 && request.status <= 400){ - console.log("Status returned: " + request.status + "resp:" + request.getResponseHeader("Content-Type")); + //console.log("Status returned: " + request.status + "resp:" + request.getResponseHeader("Content-Type")); if (request.getResponseHeader("Content-Type").indexOf('application/json') == 0){ var xparse = JSON.parse(request.responseText); - //console.log(xparse); + console.log(xparse); ret = xparse.result; }else if (request.getResponseHeader("Content-Type").indexOf('application/vnd.ms-excel') == 0){ var filename = ""; diff --git a/backoffice/tmpl/block/calendar.tt b/backoffice/tmpl/block/calendar.tt index a731c61..0716f5b 100644 --- a/backoffice/tmpl/block/calendar.tt +++ b/backoffice/tmpl/block/calendar.tt @@ -102,14 +102,8 @@ function loadcalendars(){ document.getElementById("week" + w).innerHTML = ''; weeks++; } - //console.log(lmday); - //console.log("LAST DAY: DATE:" + lmday.getUTCDate() + "DOW:" + lmday.getUTCDay()); - //console.log("First DAY: DATE:" + fmday.getUTCDate() + "DOW:" + fmday.getUTCDay()); - var evfn = "getmonthbilljees"; - if (onlyuser && onlyuser==true){ - evfn = "getmonthbilljeesbyuser"; - } - req.reqdata("POST","process.cgi",{fn:evfn,"startdate":fmday.toJSON().substring(0,10),"enddate":lmday.toJSON().substring(0,10)},set_calendarevents); + + req.reqdata("POST","process.cgi",{fn:"getmonthbilljees","type":bltype,"startdate":fmday.toJSON().substring(0,10),"enddate":lmday.toJSON().substring(0,10)},set_calendarevents); return false; } diff --git a/backoffice/tmpl/block/dlgcontactpublisher.tt b/backoffice/tmpl/block/dlgcontactpublisher.tt index e260057..b39dc05 100644 --- a/backoffice/tmpl/block/dlgcontactpublisher.tt +++ b/backoffice/tmpl/block/dlgcontactpublisher.tt @@ -3,7 +3,7 @@
× -

Êtes-vous sûre de contacter l'éditeur de ce billjee?

+

Êtes-vous sûr de contacter l'éditeur de ce billjee?

diff --git a/backoffice/tmpl/block/dlgdelete.tt b/backoffice/tmpl/block/dlgdelete.tt index a6e51bb..6c0987f 100644 --- a/backoffice/tmpl/block/dlgdelete.tt +++ b/backoffice/tmpl/block/dlgdelete.tt @@ -3,7 +3,7 @@
× -

Êtes-vous sûre de supprimer ce billjee?

+

Êtes-vous sûr de supprimer ce billjee?

diff --git a/backoffice/tmpl/block/dlgpublish.tt b/backoffice/tmpl/block/dlgpublish.tt index b38813d..b7dada2 100644 --- a/backoffice/tmpl/block/dlgpublish.tt +++ b/backoffice/tmpl/block/dlgpublish.tt @@ -16,8 +16,8 @@
+ [% ELSE %]
diff --git a/tmpl/block/avocatlist.tt b/tmpl/block/avocatlist.tt index 598d506..d865c74 100644 --- a/tmpl/block/avocatlist.tt +++ b/tmpl/block/avocatlist.tt @@ -33,9 +33,9 @@ order by lc.surname, lc.prename, lc.company;'); %]
diff --git a/tmpl/block/domaines.tt b/tmpl/block/domaines.tt index c79a096..be04bca 100644 --- a/tmpl/block/domaines.tt +++ b/tmpl/block/domaines.tt @@ -6,7 +6,7 @@ [% FOREACH cats = dksdb.query("select cat.link,cat.category from lawyercategories lcat join categories cat on (lcat.id_category=cat.id) join lawyercatalog lc on (lcat.id_catalog=lc.id) -join appaccess ac on (ac.id_user=lc.id_user and ac.id_app='2' and lcat.selection=true and ac.publicenabled = true) +-- join appaccess ac on (ac.id_user=lc.id_user and ac.id_app='2' and lcat.selection=true and ac.publicenabled = true) group by cat.id order by category;") %]
  • [% cats.category %]