else {
if ($stmD) {
$stmt = $stmS . $stmD . $stmE;
- }
+ }
}
###############
#check if we are at the beggining of the LOG table?
my $stc =
- $db->prepare('select rowid from LOG order by rowid DESC LIMIT 1;');
- $stc->execute();
+ $db->prepare('select rowid from LOG order by rowid DESC LIMIT 1;');
+ $stc->execute();
my @row = $stc->fetchrow_array();
if ( $row[0] == $rs_prev && $rs_cur == $rs_prev ) {
$tbl_start = -1;
my $ct = $hshCats{ $row[1] };
my $dt = DateTime::Format::SQLite->parse_datetime( $row[2] );
my $log = $row[3];
- my $amm = sprintf "%.2f", $row[4];
+ my $amm = camm(sprintf "%.2f", $row[4]);
#Apostrophe in the log value is doubled to avoid SQL errors.
$log =~ s/''/'/g;
print "<font color=red><b>SERVER ERROR</b></font>:" . $_;
}
}
+
+sub camm {
+ my $amm = sprintf("%.2f", shift @_);
+ # Add one comma each time through the do-nothing loop
+ 1 while $amm =~ s/^(-?\d+)(\d\d\d)/$1,$2/;
+return $amm;
+}
\ No newline at end of file
my $q = CGI->new;
-print $q->header(-expires=>"+6os", -charset=>"UTF-8");
-
+print $q->header(-expires=>"+6os", -charset=>"UTF-8");
print $q->start_html(-title => "Log Data Stats", -BGCOLOR=>"#c8fff8",
-script=>{-type => 'text/javascript', -src => 'wsrc/main.js'},
-style =>{-type => 'text/css', -src => 'wsrc/main.css'},
my $tbl = '<table class="tbl" border="1px"><tr class="r0"><td colspan="4"><b>* PERSONAL LOG DATA STATS *</b></td></tr>';
-
-
my $log_rc = selectSQL('select count(rowid) from LOG;');
my $stm = "SELECT count(date) from LOG where date>=date('now','start of year');";
my $log_this_year_rc = selectSQL($stm);
$stm = 'SELECT sum(ammount) from LOG where date>=date("now","start of year")
AND ID_CAT = '.$id_expense.';';
-my $expense = sprintf("%.2f",selectSQL($stm));
+my $expense = big_money(sprintf("%.2f",selectSQL($stm)));
$stm = 'SELECT sum(ammount) from LOG where date>=date("now","start of year")
AND ID_CAT = '.$id_income.';';
-my $income = sprintf("%.2f",selectSQL($stm));
+my $income = big_money(sprintf("%.2f",selectSQL($stm)));
my $revenue = big_money($income - $expense);
my $hardware_status =`inxi -b -c0;uptime -p`;
$hardware_status =~ s/\n/<br\/>/g;
$number =~ s/^(-?)/$1\$/;
return $number;
}
+
+sub camm {
+ my $amm = sprintf("%.2f", shift @_);
+ # Add one comma each time through the do-nothing loop
+ 1 while $amm =~ s/^(-?\d+)(\d\d\d)/$1,$2/;
+return $amm;
+}
### CGI END