]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Added currency symbol, setting.
authorwbudic <redacted>
Mon, 30 Aug 2021 22:53:41 +0000 (08:53 +1000)
committerwbudic <redacted>
Mon, 30 Aug 2021 22:53:41 +0000 (08:53 +1000)
LifeLogLighttpd_8080.cnf [new file with mode: 0644]
dbLifeLog/main.cnf
htdocs/cgi-bin/data.cgi
htdocs/cgi-bin/main.cgi

diff --git a/LifeLogLighttpd_8080.cnf b/LifeLogLighttpd_8080.cnf
new file mode 100644 (file)
index 0000000..c8ea11c
--- /dev/null
@@ -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" 
+}
+
index b44cc6e0348237a58e5b1b525e8efb6e89dd73be..7788bdb8c85a410c3edd34e0e89f7c453492ddfe 100644 (file)
@@ -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:<<AUTO_LOGIN <{alias}/{password}>>> , to enable AUTO_LOGIN option bellow,
- the config in app, has to also be enabled.
+# Credential format:<<AUTO_LOGIN<{alias}/{password}>>> ,
+ to enable AUTO_LOGIN option bellow, the config in app, has to also be enabled.
 <<AUTO_LOGIN<>>>
 # BACKUP_ENABLED -> Enable (1), disable (0) backups to be restored from config page.
 <<BACKUP_ENABLED<1>>>
@@ -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. 
-<<DBI_SOURCE<DBI:SQLite:>>>
+<<DBI_SQL_SOURCE<DBI:SQLite:>>>
 # ProgresSQL DB driver. 
 <<!DBI_SOURCE<DBI:Pg:host=localhost;>>>
 
@@ -42,6 +42,17 @@ Australia/Bondi=Australia/Sydney
 America/Austin=America/Chicago
 America/Texas=America/Chicago
 >>
+<<CURRENCY_SYMBOLS<DATA>
+$`&#36;`&dollar;`&#x24;`Dollar Sign~
+€`&#8364;`&euro;`&#x20AC;`Euro Sign~
+£`&#163;`&pound;`&#xA3;`Pound Sign~
+¤`&#164;`&curren;`&#xA4;`Currency Sign~
+₽`&#8381;`&#x20BD;`Ruble Sign~
+¥`&#165;`&yen;`&#xA5;`Yen Sign~
+₨`&#8360;`&#x20A8;`Rupee Sign~
+৳`&#2547;`&#x9F3;`Bengali Rupee Sign~
+฿`&#3647;`&#xE3F;`Thai Currency Symbol Baht~
+>>
 
 <<PLUGINS<
 HelpPlugin->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.
 >>
 <<CAT<3>
 01|Unspecified `For quick uncategorized entries.
index a23d0c53a7941c28af4522b4a433a5b608acd328..a8da0825e322513b13c9348817a21b156b1ec4c4 100755 (executable)
@@ -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\s+.*?>.*<\/a>/si;
+    $log = wrap('','',$log);
     $log =~ s/''/'/g;
     $log =~ s/\r\n/<br>/gs;
     $log =~ s/\\n/<br>/gs;
@@ -320,10 +323,7 @@ sub log2html{
             $ch_i =~ s/($RE{URI}{HTTP})/<a href="$1" target=_blank>$1<\/a>/gsi;
         }
         $log = join( '', @chnks );
-    }
-
-    #$log =~ s/\<\</&#60;&#60/gs;
-    #$log =~ s/\>\>/&#62&#62;/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 = '<table class="tbl_print" border="0" width="'.$PRC_WIDTH.'%">
-        <tr class="hdr"><th>Date</th><th>Time</th> <th>Log</th><th>Category</th></tr>';
 
+    my ($tot,$assets,$th_amt) = (0,0,''); $th_amt = '<th style="text-align:center;">'.Settings::currenySymbol().'</th>' if $hasAmmounts;
+    my $tbl = qq(<table class="tbl_print" border="0" width="'.$PRC_WIDTH.'%">
+        <tr class="hdr"><th>Date</th><th>Time</th><th>Log</th>
+       </th>$th_amt<th>Category</th></tr>);
+                    $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="<td style='text-align:right;'>".cam($amt).'</td>';
+        }else{$amt=""}
 
-        $tbl = $tbl . '<tr><td class="ctr">'. $dt->ymd . "</td>" .
-            '<td class="ctr">' . $dt->hms . "</td>" .
-            '<td>'."$log</td>\n".
-            '<td class="cat">' . $ct. '</td></tr>';
+        $tbl .= '<tr><td class="ctr">'. $dt->ymd . "</td>" .
+            '<td class="ctr">' . $dt->hms . "</td>" . qq(<td>$log</td>$amt<td class="cat">$ct</td></tr>);
+    }
+    $tot =  Settings::currenySymbol().cam($tot);
+    if ($assets){$assets =  'Assets: '.Settings::currenySymbol().cam($assets)}else{$assets=""}
+    if($hasAmmounts || $assets){
+       $tbl .= qq(<tr><td colspan="6"></td></tr><tr>
+                      <td></td><td></td><td style='text-align:right;'>$assets&nbsp;<b>Total:</b></td><td>$tot</td>
+                      <td></td></tr>);
+       $tbl .= '</table>';
     }
-    $tbl .= '</table>';
     
     print "<center><div>\n$tbl\n</div></center>";
 
@@ -380,5 +400,11 @@ try{
     print "<font color=red><b>SERVER ERROR</b>-> Method NotConfirmed() Page Build Failed!.</font>:<pre>".$@."</pre>";
 }
 }
+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
index 7419b4c960ab64286d9751dcd7f3397a25d5286d..526183e4c9e1dc2e76982debd12eeaf499f83058 100755 (executable)
@@ -253,7 +253,7 @@ for my $key ( keys %hshDesc ) {
         $data_cats .= qq(<meta id="cats[$key]" name="$n" content="$kv">\n);
     }
 }
-my $eh;
+my $eh;my $currsymb = &Settings::currenySymbol;
 if($isPUBViewMode){$eh = ""}else{$eh='<th>Edit</th>'}
 my $log_output =
 qq(<FORM id="frm_log" action="data.cgi" onSubmit="return formDelValidation();">
@@ -261,7 +261,8 @@ qq(<FORM id="frm_log" action="data.cgi" onSubmit="return formDelValidation();">
 <tr class="hdr">
        <th>Date</th>
        <th>Time</th>
-       <th>Log</th><th>#</th>
+       <th>Log</th>
+    <th>$currsymb</th>
        <th>Category</th>
     $eh
 </tr>);
@@ -712,7 +713,7 @@ $log_output .= qq(
 <tr class="r$tfId" id="summary_row">
     <td></td>
     <td></td>
-    <td id="summary" colspan="4" style="text-align:right"># <i>Totals</i>: Assets [ $ass ] Inc [ $tin ] Exp [ <font color="red">$exp</font> ] <b>&#8594; Gross [<i>$tot</i> ] </b></td>
+    <td id="summary" colspan="4" style="text-align:right">$currsymb <i>Totals</i>: Assets [ $ass ] Inc [$currsymb $tin ] Exp [ <font color="red">$currsymb $exp</font> ] <b>&#8594; Gross [$currsymb <i>$tot</i> ] </b></td>
 </tr>);
 
 ###