From: wbudic Date: Mon, 30 Aug 2021 22:53:41 +0000 (+1000) Subject: Added currency symbol, setting. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=de86859fc23dd4d7d3b783b6d57a024e4c6961de;p=LifeLog.git Added currency symbol, setting. --- diff --git a/LifeLogLighttpd_8080.cnf b/LifeLogLighttpd_8080.cnf new file mode 100644 index 0000000..c8ea11c --- /dev/null +++ b/LifeLogLighttpd_8080.cnf @@ -0,0 +1,37 @@ +#ExecStart=/usr/sbin/lighttpd -D -f /home/will/dev/LifeLog/lighttpd.conf +server.document-root = "/home/will/dev/LifeLog/" + +server.port = 8080 + +server.username = "will" +server.groupname = "will" + +server.modules = ( +#"mod_access", +"mod_accesslog", +#"mod_auth", +"mod_expire", +"mod_compress", +"mod_redirect", +"mod_setenv", +"mod_rewrite", +"mod_alias", +"mod_cgi" +#"mod_openssl" +) +mimetype.assign = ( + ".html" => "text/html", + ".txt" => "text/plain", + ".jpg" => "image/jpeg", + ".png" => "image/png" +) + +static-file.exclude-extensions = ( ".ico" ) +index-file.names = ( "index.html" ) +server.dir-listing = "enable" + +$HTTP["host"] == "192.168.1.44" { +# server.document-root = "/var/www/servers/www2.example.org/pages/" +server.document-root = "/home/will/dev/LifeLog/htdocs" +} + diff --git a/dbLifeLog/main.cnf b/dbLifeLog/main.cnf index b44cc6e..7788bdb 100644 --- a/dbLifeLog/main.cnf +++ b/dbLifeLog/main.cnf @@ -3,8 +3,8 @@ This is the main configuration file for the LifeLog applications settings. https://github.com/wbudic/LifeLog This is an Open Source License project -> https://choosealicense.com/licenses/isc/ -# Credential format:<>> , to enable AUTO_LOGIN option bellow, - the config in app, has to also be enabled. +# Credential format:<>> , + to enable AUTO_LOGIN option bellow, the config in app, has to also be enabled. <>> # BACKUP_ENABLED -> Enable (1), disable (0) backups to be restored from config page. <>> @@ -16,7 +16,7 @@ Note Remove -> '!' prefix to tag name, to enable, set, and override any previously set from now on, top to end of file approach. # # SQLite DB driver. -<>> +<>> # ProgresSQL DB driver. <>> @@ -42,6 +42,17 @@ Australia/Bondi=Australia/Sydney America/Austin=America/Chicago America/Texas=America/Chicago >> +< +$`$`$`$`Dollar Sign~ +€`€`€`€`Euro Sign~ +£`£`£`£`Pound Sign~ +¤`¤`¤`¤`Currency Sign~ +₽`₽`₽`Ruble Sign~ +Â¥`¥`¥`¥`Yen Sign~ +₨`₨`₨`Rupee Sign~ +à§³`৳`৳`Bengali Rupee Sign~ +฿`฿`฿`Thai Currency Symbol Baht~ +>> <help.pl @@ -85,6 +96,7 @@ BankingPlugin->banking.pl 40|$SUBPAGEDIR =docs`Directory to scan for subpages like documents. 42|$DISP_ALL = 1`Display whole log entry, default -> 1=true, 0=false for display single line only. 44|$TRANSPARENCY= 1`Should log panel be transparent, default is yes or on. +50|$CURR_SYMBOL = $`Currency symbol. >> < 01|Unspecified `For quick uncategorized entries. diff --git a/htdocs/cgi-bin/data.cgi b/htdocs/cgi-bin/data.cgi index a23d0c5..a8da082 100755 --- a/htdocs/cgi-bin/data.cgi +++ b/htdocs/cgi-bin/data.cgi @@ -246,9 +246,12 @@ try{ } } -sub log2html{ +use Text::Wrap; $Text::Wrap::columns=80; $Text::Wrap::separator="\n"; + +sub log2html { my $log = shift; my ($re_a_tag, $sub) = qr/.*<\/a>/si; + $log = wrap('','',$log); $log =~ s/''/'/g; $log =~ s/\r\n/
/gs; $log =~ s/\\n/
/gs; @@ -320,10 +323,7 @@ sub log2html{ $ch_i =~ s/($RE{URI}{HTTP})/$1<\/a>/gsi; } $log = join( '', @chnks ); - } - - #$log =~ s/\<\\>/>>/gs; + } return $log; } @@ -333,11 +333,11 @@ sub PrintView { try{ my $SQLID = 'rowid'; $SQLID = 'ID' if( Settings::isProgressDB() ); - my $stmS = "SELECT ID, PID, (select NAME from CAT WHERE ID_CAT = CAT.ID) as CAT, DATE, LOG from VW_LOG WHERE"; + my $stmS = "SELECT ID, PID, (select NAME from CAT WHERE ID_CAT = CAT.ID) as CAT, DATE, LOG, AMOUNT from VW_LOG WHERE"; my $stmE = " ORDER BY DATE DESC, ID DESC;"; #Get ids and build confirm table and check - my $stm = $stmS ." "; + my $stm = " "; foreach my $id ($cgi->param('chk')){ if($opr == 2){ $stm = $stm . "$SQLID = " . $id . " OR "; @@ -346,30 +346,50 @@ try{ $stm = $stm . "PID = " . $id . " OR "; } } - $stm =~ s/ OR $//; $stm .= $stmE; - my $st = Settings::selectRecords($db, $stm); - + $stm =~ s/ OR $//; + my $sql = $stmS.$stm.$stmE; print $cgi->header(-expires=>"+6os"); print $cgi->start_html(-title => "LifeLog Excerpt ".Settings::dbFile()." - ".$today->strftime('%d/%m/%Y %H:%M'), -style => {-type => 'text/css', -src => "wsrc/print.css"} ); - print $cgi->pre("###PrintView()->[stm:$stm]") if($DEBUG); + print $cgi->pre("###PrintView()->[sql:$sql]") if($DEBUG); + my $st = Settings::selectRecords($db, "SELECT sum(AMOUNT) FROM VW_LOG WHERE $stm;"); + my $hasAmmounts = 0; while(my @r = $st->fetchrow_array()) {if($r[0]>0){$hasAmmounts = 1}} - my $tbl = ' - '; + my ($tot,$assets,$th_amt) = (0,0,''); $th_amt = '' if $hasAmmounts; + my $tbl = qq(
DateTime LogCategory
'.Settings::currenySymbol().'
+ + $th_amt); + $st = Settings::selectRecords($db, $sql); while(my @row = $st->fetchrow_array()) { my $ct = $row[2]; my $dt = DateTime::Format::SQLite->parse_datetime( $row[3] ); my $log = log2html($row[4]); + my $amt = $row[5]; + if($hasAmmounts){ + if($ct eq 'Expense'){ + $tot = $tot - $amt; $amt = "-$amt"; + }elsif($ct eq 'Income'){ + $tot += $amt; + }else{ + $assets += $amt; + } + $amt="'; + }else{$amt=""} - $tbl = $tbl . '" . - '" . - '\n". - ''; + $tbl .= '" . + '" . qq($amt); + } + $tot = Settings::currenySymbol().cam($tot); + if ($assets){$assets = 'Assets: '.Settings::currenySymbol().cam($assets)}else{$assets=""} + if($hasAmmounts || $assets){ + $tbl .= qq( + + ); + $tbl .= '
DateTimeLogCategory
".cam($amt).'
'. $dt->ymd . "' . $dt->hms . "'."$log' . $ct. '
'. $dt->ymd . "' . $dt->hms . "$log$ct
$assets Total:$tot
'; } - $tbl .= ''; print "
\n$tbl\n
"; @@ -380,5 +400,11 @@ try{ print "SERVER ERROR-> Method NotConfirmed() Page Build Failed!.:
".$@."
"; } } +sub cam { + my $am = sprintf( "%.2f", shift @_ ); + # Add one comma each time through the do-nothing loop + 1 while $am =~ s/^(-?\d+)(\d\d\d)/$1,$2/; + return $am; +} 1; \ No newline at end of file diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 7419b4c..526183e 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -253,7 +253,7 @@ for my $key ( keys %hshDesc ) { $data_cats .= qq(\n); } } -my $eh; +my $eh;my $currsymb = &Settings::currenySymbol; if($isPUBViewMode){$eh = ""}else{$eh='Edit'} my $log_output = qq(
@@ -261,7 +261,8 @@ qq( Date Time - Log# + Log + $currsymb Category $eh ); @@ -712,7 +713,7 @@ $log_output .= qq( - # Totals: Assets [ $ass ] Inc [ $tin ] Exp [ $exp ] → Gross [$tot ] + $currsymb Totals: Assets [ $ass ] Inc [$currsymb $tin ] Exp [ $currsymb $exp ] → Gross [$currsymb $tot ] ); ###