# Branch Development LifeLog in Perl - Sun Stage v. 1.6
-*This page lists current development and issues being worked on in the LifeLog app. Being in the **Sun** stage, means there is a production environment. And usable, used. When the project reaches **Earth** stage. It will be at its final specification. No data structures or major new features can be added or requested anymore. Only bug fixes, enhancements and efficiency fixes, if any at the **Earth** stage.*
+*This page lists current development and issues being worked on in the LifeLog app. Being in the **Sun** stage, means there is a production environment. And usable, used. When, the project reaches **Earth** stage. It will be at its final specification. No data structures or major new features can be added or requested anymore. Only bug fixes, enhancements and efficiency fixes, if any at the **Earth** stage.*
This version is not compatible in data structure to prior versions. Data migration is required, to transfer previous data (see ../dbLifeLog/main.cnf).
-## LifeLog
+## LifeLog
* Implement sticky log entries.
* $CUR_MTH_SVIEW - Start view page is for current month, and the sticky set.
* Some System settings to be stored in session. As these are known even before logon.
> i.e. $SESSN_EXPR, $RELEASE_VER, $TIME_ZONE, $LOG_PATH
-*✔ Dropdown for type of log amount (Mark as Expense). Default is Asset. Asset is neither, income or expense.
-*✔ Implement RTF Documents.
+* ✔ Dropdown for type of log amount (Mark as Expense). Default is Asset. Asset is neither, income or expense.
+* ✔ Implement RTF Documents.
> Useful as more document style formated details can be added instead of just plain text.
*✔ Preserve Search view selections. After edits and submit.
> * ✔ Preserve from to date selections.
> * ✔ Date View not working on Local entered date format.
-*✔ Sum selected, income, expense, totals.
+*✔ Sum selected, income, expense, totals.
✔ Sum on view.
>✔ Deletion of log, deletes the document.
## Bugs
-* Bug - 10 Expense type entries don't field ammount field on edit button clicked.
-* Bug - 09 RTF documents lost on data renumeration of log. Data fix options in config. Needs urgent revision.
+* ✔ Bug - 10 Expense type entries don't fill ammount field on edit button clicked.
+* ✔ Bug - 09 RTF documents lost on data renumeration of log. Data fix options in config. Needs urgent revision.
* Bug - 08 CSV imports duplicate on DB Fix in config page.
* Bug - 07, Editing and RTF entry, Dosen't strip the attached html to view in place.
* ✔ Bug - 06, Invalid Time 00. Javascript error thrown, when 00am used.
my $wipe_ss = $cgi->param("wipe_syst");
- my $issue;
+ my $sql;
my $date;
my $cntr_upd =0;
try{
my $cntr_del =0;
my $existing;
my @row;
-
+
$db->do('BEGIN TRANSACTION;');
#Check for duplicates, which are possible during imports or migration as internal rowid is not primary in log.
$dbs = dbExecute('SELECT rowid, DATE FROM LOG ORDER BY DATE;');
}
foreach my $del (@dlts){
- $issue = "DELETE FROM LOG WHERE rowid=$del;";
- #print "$issue\n<br>";
- my $st_del = $db->prepare($issue);
+ $sql = "DELETE FROM LOG WHERE rowid=$del;";
+ #print "$sql\n<br>";
+ my $st_del = $db->prepare($sql);
$st_del->execute();
}
- #Renumerate Log! Copy into temp. table.
- $dbs = dbExecute("CREATE TABLE life_log_temp_table AS SELECT * FROM LOG;");
- $dbs = dbExecute('SELECT rowid, DATE FROM LOG WHERE RTF == 1 ORDER BY DATE;');
- #update notes with new log id
- while(@row = $dbs->fetchrow_array()) {
- my $sql_date = $row[1];
- #$sql_date =~ s/T/ /;
- $sql_date = DateTime::Format::SQLite->parse_datetime($sql_date);
- $issue = "SELECT rowid, DATE FROM life_log_temp_table WHERE RTF = 1 AND DATE = '".$sql_date."';";
- $dbs = dbExecute($issue);
- my @new = $dbs->fetchrow_array();
- if(scalar @new > 0){
- $db->do("UPDATE NOTES SET LID =". $new[0]." WHERE LID==".$row[0].";");
- }
- }
-
- # Delete Orphaned Notes entries.
- $dbs = dbExecute("SELECT LID, LOG.rowid from NOTES LEFT JOIN LOG ON
- NOTES.LID = LOG.rowid WHERE LOG.rowid is NULL;");
- while(my @row = $dbs->fetchrow_array()) {
- $db->do("DELETE FROM NOTES WHERE LID=$row[0];");
- }
- $dbs = dbExecute('DROP TABLE LOG;');
- $dbs = dbExecute(qq(CREATE TABLE LOG (
- ID_CAT TINY NOT NULL,
- DATE DATETIME NOT NULL,
- LOG VCHAR (128) NOT NULL,
- AMOUNT INTEGER,
- AFLAG TINY DEFAULT 0,
- RTF BOOL DEFAULT 0);));
- $dbs = dbExecute('INSERT INTO LOG (ID_CAT,DATE,LOG,AMOUNT,AFLAG, RTF)
- SELECT ID_CAT, DATE, LOG, AMOUNT, AFLAG, RTF
- FROM life_log_temp_table ORDER by DATE;');
- $dbs = dbExecute('DROP TABLE life_log_temp_table;');
-
-
+ &renumerate;
&resetCategories if $rs_cats;
&resetSystemConfiguration($db) if $rs_syst;
&wipeSystemConfiguration if $wipe_ss;
}
catch{
$db->do('ROLLBACK;');
- die qq(@&processDBFix error:$_ with statement->$issue for $date update counter:$cntr_upd);
+ die qq(@&processDBFix error:$_ with statement->$sql for $date update counter:$cntr_upd);
}
}
updateCATDB(@flds);
}else{
warn "Data could not be parsed: $line\n";
- }
+ }
}
}
sub updateCATDB {
my @flds = @_;
if(@flds>2){
- try{
+ try{
my $id = $flds[0];
my $name = $flds[1];
my $desc = $flds[2];
-
+
#is it existing entry?
- $dbs = dbExecute("SELECT ID, NAME, DESCRIPTION FROM CAT WHERE ID = '$id';");
+ $dbs = dbExecute("SELECT ID, NAME, DESCRIPTION FROM CAT WHERE ID = '$id';");
if(not defined $dbs->fetchrow_array()){
$dbs = $db->prepare('INSERT INTO CAT VALUES (?,?,?)');
$dbs->execute($id, $name, $desc);
else{
#TODO Update
}
-
+
}
catch{
print "<font color=red><b>SERVER ERROR</b>->updateCATDB</font>:".$_;
}
}
}
+
sub importLogCSV {
my $hndl = $cgi->upload("data_log");
- my $csv = Text::CSV->new ( { binary => 1, strict => 1, eol => $/ } );
+ my $csv = Text::CSV->new ( { binary => 1, strict => 1, eol => $/ } );
+
while (my $line = <$hndl>) {
chomp $line;
- if ($csv->parse($line)) {
+ if ($csv->parse($line)) {
my @flds = $csv->fields();
updateLOGDB(@flds);
}else{
warn "Data could not be parsed: $line\n";
- }
- }
+ }
+ }
+ &renumerate;
$db->disconnect();
print $cgi->redirect('main.cgi');
exit;
sub updateLOGDB {
my @flds = @_;
if(@flds>3){
- try{
+ try{
my $id_cat = $flds[0];
my $date = $flds[1];
my $log = $flds[2];
return;
}
#is it existing entry?
- $dbs = $db->prepare("SELECT ID_CAT, DATE, LOG, AMOUNT, AFLAG, RTF FROM LOG WHERE date = '$date';");
+ my $sql = "SELECT DATE FROM LOG WHERE DATE is '$pdate';";
+ $dbs = $db->prepare($sql);
$dbs->execute();
- if(!$dbs->fetchrow_array()){
- $dbs = $db->prepare('INSERT INTO LOG VALUES (?,?,?,?,?,?, ?)');
- $dbs->execute( $id_cat, $pdate, $log, $amv, $amf, $rtf, $sticky);
+ my @rows = $dbs->fetchrow_array();
+ if(scalar @rows == 0){
+ $dbs = $db->prepare('INSERT INTO LOG VALUES (?,?,?,?,?,?,?)');
+ $dbs->execute( $id_cat, $pdate, $log, $amv, $amf, $rtf, $sticky);
}
- #Renumerate
- # $dbs = $db->prepare('select rowid from LOG ORDER BY DATE;');
- # $dbs->execute();
- # my @row = $dbs->fetchrow_array();
- # my $cnt = 1;
- # while(my @row = $dbs->fetchrow_array()) {
- # my $st_upd = $db->prepare("UPDATE LOG SET rowid=".$cnt.
- # " WHERE rowid='".$row[0]."';");
- # $st_upd->execute();
- # $cnt = $cnt + 1;
- # }
- #$dbs->finish;
+ $dbs->finish();
}
catch{
print "<font color=red><b>SERVER ERROR</b>->exportLogToCSV</font>:".$_;
$BGCOL = 'green';
}
+}
+
+
+sub renumerate {
+ #Renumerate Log! Copy into temp. table.
+ my $sql;
+ $dbs = dbExecute("CREATE TABLE life_log_temp_table AS SELECT * FROM LOG;");
+ $dbs = dbExecute('SELECT rowid, DATE FROM LOG WHERE RTF == 1 ORDER BY DATE;');
+ #update notes with new log id
+ while(my @row = $dbs->fetchrow_array()) {
+ my $sql_date = $row[1];
+ #$sql_date =~ s/T/ /;
+ $sql_date = DateTime::Format::SQLite->parse_datetime($sql_date);
+ $sql = "SELECT rowid, DATE FROM life_log_temp_table WHERE RTF = 1 AND DATE = '".$sql_date."';";
+ $dbs = dbExecute($sql);
+ my @new = $dbs->fetchrow_array();
+ if(scalar @new > 0){
+ $db->do("UPDATE NOTES SET LID =". $new[0]." WHERE LID==".$row[0].";");
+ }
+ }
+
+ # Delete Orphaned Notes entries.
+ $dbs = dbExecute("SELECT LID, LOG.rowid from NOTES LEFT JOIN LOG ON
+ NOTES.LID = LOG.rowid WHERE LOG.rowid is NULL;");
+ while(my @row = $dbs->fetchrow_array()) {
+ $db->do("DELETE FROM NOTES WHERE LID=$row[0];");
+ }
+ $dbs = dbExecute('DROP TABLE LOG;');
+ $dbs = dbExecute(qq(CREATE TABLE LOG (
+ ID_CAT TINY NOT NULL,
+ DATE DATETIME NOT NULL,
+ LOG VCHAR (128) NOT NULL,
+ AMOUNT INTEGER,
+ AFLAG TINY DEFAULT 0,
+ RTF BOOL DEFAULT 0,
+ STICKY BOOL DEFAULT 0
+ );));
+ $dbs = dbExecute('INSERT INTO LOG (ID_CAT,DATE,LOG,AMOUNT,AFLAG, RTF)
+ SELECT ID_CAT, DATE, LOG, AMOUNT, AFLAG, RTF
+ FROM life_log_temp_table ORDER by DATE;');
+ $dbs = dbExecute('DROP TABLE life_log_temp_table;');
}
\ No newline at end of file
// toggleDocument();
}
+ var rgb = $('#editor-container').css('background-color');
+ if(rgb){
+ DEF_BACKGROUND = RGBToHex(rgb);
+ $("#fldBG").val(DEF_BACKGROUND);
+ var amf = $( "#amf" );//Amount Field Type dropdown
+ var ec = $( "#ec" ); //Category dropdown
- DEF_BACKGROUND = RGBToHex($('#editor-container').css('background-color'));
- $("#fldBG").val(DEF_BACKGROUND);
-
- // $( function() {
- var amf = $( "#amf" );//Amount Field Type dropdown
- var ec = $( "#ec" ); //Category dropdown
-
- $( amf ).selectmenu({style: "dropdown", width:120,
+ $( amf ).selectmenu({style: "dropdown", width:120,
change: function( event, data ) {
var evv =ec.val();
if(ec.val()<2||evv==32||evv==35||data.item.value == 0){
}
}
}});
-
-
+ }
}
var tag = $("#g" + row); //orig. tagged log text.
var log = $("#v" + row); //log
var rtf = $("#r" + row); //RTF doc
- var amf = $("#f" + row); //Amount type.
+ var amt = $("#f" + row); //Amount type.
var isRTF = (rtf.val()>0?true:false);
if(!isRTF){
$('#rtf_doc').hide();
$("#el").val(decodeToHTMLText(tag.val()));
} else {
- $("#el").val(decodeToText(log.html()));
+ $("#el").val(decodeToText(log.text()));
}
$("#ed").val(ed_v.val() + " " + et_v.html()); //Time field
- var val = ea_v.html();
+ var val = ea_v.text();
val = val.replace(/\,/g,"");
$("#am").val(val); //Amount field, fix 04-08-2019 HTML input doesn't accept formated string.
$("#RTF").prop('checked', isRTF);
$("#ec option:contains(" + ec_v + ")").prop('selected', true);
$("#submit_is_edit").val(row);
-
- ec_v = amf.val();
+ //Amount type
+ ec_v = amt.val();
$("#amf").focus();
$("#amf").val(ec_v);
$("#amf").selectmenu('refresh');