From: kilian (ksmachome) Date: Tue, 11 Feb 2020 15:20:25 +0000 (+0100) Subject: v20200210 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=84d7aa9cd49b630673d243738d154f37e8f252a4;p=dksnas.git v20200210 --- diff --git a/.gitignore b/.gitignore index d7aaf69..2cb9b7e 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ data/invoicejournal/tmp/* data/rpinas/* data/invoicejournal/output/* data/invoicejournal/templates/tmp/* +desktopapp/node_modules/* diff --git a/CGI/api/db.cgi b/CGI/api/db.cgi index 40afbb8..6b0aa96 100755 --- a/CGI/api/db.cgi +++ b/CGI/api/db.cgi @@ -60,7 +60,7 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ $sql .= " WHERE ".$p->{filter}.";"; } $html->{result}->{view} = $p->{get}; - $html->{result}->{sqldata} = $db->query($sql); + $html->{result}->{sqldata} = $db->queryarray($sql); } elsif (exists($p->{set})){ my $type = "ins"; @@ -87,14 +87,20 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ if ($type eq "ins"){ @sql = $db->create_ddl_insert($x); + }else { @sql = $db->create_ddl_update($x); } if (scalar(@sql) > 0 ){ + my $rid = $db->exec($sql[0]); - if (keys(%{$rid}) > 0 ){ + if ($type eq "ins" && exists($p->{return})){ + my $rid = $db->query('select seq as id from sqlite_sequence where name="'.$p->{return}.'";'); + $html->{result} = $rid; + } else { $html->{result} = $rid->{0}; } + } } elsif (exists($p->{del})){ @@ -116,7 +122,7 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ $html->{result} = $db->querybykey($p->{key},$p->{sql}); } else { - $html->{result} = $db->query($p->{sql}); + $html->{result} = $db->queryarray($p->{sql}); } } elsif (exists($p->{exec})){ diff --git a/CGI/api/lib/dksdb.pm b/CGI/api/lib/dksdb.pm index 3e48626..b39988f 100644 --- a/CGI/api/lib/dksdb.pm +++ b/CGI/api/lib/dksdb.pm @@ -51,21 +51,15 @@ sub query(){ # print FILE "$stat\n"; # close FILE; my $sth = $dbh->prepare($stat) or return ("ERROR: query: ".$dbh->errstr. "- SQL: ".$stat); - $sth->execute() or return ("query: ".$sth->errstr);; - while(my $data = $sth->fetchrow_hashref()) - { - my $row = (); - foreach my $k (keys %{$data}){ - $row->{$k} = decode("utf-8",$data->{$k}); - } - push @retdata,$row; + $sth->execute() or return ("query: ".$sth->errstr);; + my $data = $sth->fetchrow_hashref(); + my $row = (); + foreach my $k (keys %{$data}){ + $row->{$k} = decode("utf-8",$data->{$k}); } - - - $sth->finish(); - $dbh->disconnect(); - - return \@retdata; + $sth->finish(); + $dbh->disconnect(); + return $row; } sub querybykey(){ @@ -147,43 +141,43 @@ sub exec(){ my $retdata; my $dbh = DBI->connect(((exists($self->{dsn}))?$self->{dsn}:$sitecfg->{dsn}),((exists($self->{dbuser}))?$self->{dbuser}:$sitecfg->{dbuser}),((exists($self->{dbpassword}))?$self->{pbpassword}:$sitecfg->{dbpassword}),{PrintError=>0,RaiseError=>0,AutoCommit=>1}) or return $retdata->{error} = "exec Connection Error!".$!; # $stat = decode("UTF-8", $stat); - open FILE,">>tmp/sql.log"; - print FILE "\n==\n$stat\n==\n"; - close FILE; - my $sth = $dbh->prepare($stat) or return $retdata->{error} = "exec ".$dbh->errstr. "- SQL: ".$stat; - $retdata->{success} = $dbh->do($stat) or return $retdata->{error} = "dbexec ".$dbh->errstr. "- SQL: ".$stat; + # open FILE,">>tmp/sql.log"; + # print FILE "\n==\n$stat\n==\n"; + # close FILE; + my $sth = $dbh->prepare($stat) or return $retdata->{error} = "queryarray ".$dbh->errstr. "- SQL: ".$stat; + $retdata->{success} = $dbh->do($stat) or return $retdata->{error} = "queryarray ".$dbh->errstr. "- SQL: ".$stat; $dbh->disconnect(); return $retdata; } -# sub dbqueryarray(){ -# my $self = shift; -# my $stat = shift; -# my @retdata = (); -# my $dbh = DBI->connect(((exists($self->{dsn}))?$self->{dsn}:$sitecfg->{dsn}),$sitecfg->{dbuser},$sitecfg->{dbpassword},{PrintError=>0,RaiseError=>0,AutoCommit=>1}) or return ({"error" => "dbqueryarray Connection Error!".$!}); -# #$stat = encode("utf8", $stat); -# #open FILE,">>/tmp/sql.log"; -# #print "$stat\n"; -# # close FILE; -# my $sth = $dbh->prepare($stat); +sub queryarray(){ + my $self = shift; + my $stat = shift; + my @retdata = (); + my $dbh = DBI->connect(((exists($self->{dsn}))?$self->{dsn}:$sitecfg->{dsn}),((exists($self->{dbuser}))?$self->{dbuser}:$sitecfg->{dbuser}),((exists($self->{dbpassword}))?$self->{pbpassword}:$sitecfg->{dbpassword}),{PrintError=>0,RaiseError=>0,AutoCommit=>1}) or return ("exec Connection Error!".$!); + #$stat = encode("utf8", $stat); + #open FILE,">>/tmp/sql.log"; + #print "$stat\n"; + # close FILE; + my $sth = $dbh->prepare($stat); -# $sth->execute() or print "dbqueryarray: ".$sth->errstr; -# my $count = 0; + $sth->execute() or print "queryarray: ".$sth->errstr; + my $count = 0; -# while(my $data = $sth->fetchrow_hashref()) -# { -# my $row = (); -# foreach my $k (keys %{$data}){ -# $row->{$k} = decode("utf-8",$data->{$k}); -# } -# push @retdata,$row; -# } + while(my $data = $sth->fetchrow_hashref()) + { + my $row = (); + foreach my $k (keys %{$data}){ + $row->{$k} = decode("utf-8",$data->{$k}); + } + push @retdata,$row; + } -# $sth->finish(); -# $dbh->disconnect(); -# #%retdata = sort {$a <=> $b} keys %retdata; -# return \@retdata; -# } + $sth->finish(); + $dbh->disconnect(); + #%retdata = sort {$a <=> $b} keys %retdata; + return \@retdata; +} sub create_ddl_insert(){ diff --git a/CGI/api/lib/sendemail.pm b/CGI/api/lib/sendemail.pm index 58ed8fb..953d382 100644 --- a/CGI/api/lib/sendemail.pm +++ b/CGI/api/lib/sendemail.pm @@ -31,7 +31,7 @@ sub sendemail(){ my $maildata = (); my $db = dksdb->new(); my $send = -1; - my $tmpl = $db->query("select *,ml.mailtemplate from mailtemplates mt join maillayouts ml on (mt.id_maillayout=ml.id) where templatename='".$template."';"); + my $tmpl = $db->queryarray("select *,ml.mailtemplate from mailtemplates mt join maillayouts ml on (mt.id_maillayout=ml.id) where templatename='".$template."';"); if (keys(%{$tmpl}) > 0){ $tmpl = $tmpl->{0}; } @@ -49,7 +49,7 @@ sub sendemail(){ # open (LOG,">>tmp/sendmail.log"); # print LOG "TEMPLATE DATA:".$datasql."\n"; # close(LOG); - $maildata = $db->query($datasql); + $maildata = $db->queryarray($datasql); $body = $tmpl->{'emailtext'}; $subject = $tmpl->{'mailsubject'}; diff --git a/CGI/api/parsestatement.cgi b/CGI/api/parsestatement.cgi index 7ba5728..0ef17b9 100755 --- a/CGI/api/parsestatement.cgi +++ b/CGI/api/parsestatement.cgi @@ -49,7 +49,7 @@ if (exists($p->{file}) && -f $docpath.'/'.$p->{file}){ my $updates = 0; my $inserts = 0; foreach my $i (keys(%{$sdata})){ - my @tr = $db->query("select id from banktransactions where transactionident='".$sdata->{$i}->{transactionident}."';"); + my @tr = $db->queryarray("select id from banktransactions where transactionident='".$sdata->{$i}->{transactionident}."';"); my $tid=0; if (scalar(@tr) > 1){ $tid = int($tr[0]->{id}); diff --git a/CGI/api/playlist.cgi b/CGI/api/playlist.cgi index d65dc7a..fdb8dc6 100755 --- a/CGI/api/playlist.cgi +++ b/CGI/api/playlist.cgi @@ -40,7 +40,7 @@ if (exists($p->{app}) && exists($p->{db}) && exists($p->{fn}) ) { } $html->{conn} = $dbredirect; my $db = dksdb->new($dbredirect); - my $stres = $db->query("select id,name,spotrotation from stations where id='".$p->{id_station}."';"); + my $stres = $db->queryarray("select id,name,spotrotation from stations where id='".$p->{id_station}."';"); my $station = @$stres[0]; $html->{station} = $station; my $savetopath = $cfg->{plpath}.'/'.$station->{name}; @@ -54,7 +54,7 @@ if (exists($p->{app}) && exists($p->{db}) && exists($p->{fn}) ) { chomp($f); if (($f =~ /\.m3u$/) && ($f ge $p->{datefrom}.'.m3u') && ($f le $p->{dateto}.'.m3u')){ my $cdate = substr($f,0,-4); - my $spt = $db->query("select sp.id,sp.folder || '/' || sp.file || '|' || sp.seconds || '|' || sp.folder || '|' || sp.name as spot from spots sp join stationspots ssp on (sp.id=ssp.id_spot) join stations st on (ssp.id_station = st.id) where date('".$cdate."') between sp.startdate and sp.enddate and st.id=".$p->{id_station}."; "); + my $spt = $db->queryarray("select sp.id,sp.folder || '/' || sp.file || '|' || sp.seconds || '|' || sp.folder || '|' || sp.name as spot from spots sp join stationspots ssp on (sp.id=ssp.id_spot) join stations st on (ssp.id_station = st.id) where date('".$cdate."') between sp.startdate and sp.enddate and st.id=".$p->{id_station}."; "); my $sptcnt = 0; my $sptpos = 0; my $apos = 0; diff --git a/CGI/api/report.cgi b/CGI/api/report.cgi index c3c2dd6..4012918 100755 --- a/CGI/api/report.cgi +++ b/CGI/api/report.cgi @@ -47,7 +47,6 @@ if ($sitecfg->{dbtype} eq "SQLite"){ # } # $html->{p} = $p; # $html->{sess} =$sess; -#my $datapath = $ENV{"DOCUMENT_ROOT"}.dirname(dirname($scriptpath)).'/data/'; if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ # my @params = $cgi->param(); diff --git a/CGI/tmpl/app/invoicejournal/index.tt b/CGI/tmpl/app/invoicejournal/index.tt index 5e61cd2..d33ccdf 100644 --- a/CGI/tmpl/app/invoicejournal/index.tt +++ b/CGI/tmpl/app/invoicejournal/index.tt @@ -9,40 +9,43 @@ + Invoice Journal - +
-
- +
+ + + Invoice Journal
-
-
+
- +