]> lifelog.hopto.org Git - LifeLog.git/commitdiff
bug fixes 9,10.
authorMetabox <redacted>
Fri, 4 Oct 2019 22:10:57 +0000 (08:10 +1000)
committerMetabox <redacted>
Fri, 4 Oct 2019 22:10:57 +0000 (08:10 +1000)
Current Development Check List.md
htdocs/cgi-bin/config.cgi
htdocs/cgi-bin/main.cgi
htdocs/cgi-bin/wsrc/main.js

index 3b05c75a60005d41050ddf4f74ab4bd76952974e..f8fbfb7274b1241c2104f638d00e202895d5e6b5 100644 (file)
@@ -1,22 +1,22 @@
 # 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
 
-*&#10004; Dropdown for type of log amount (Mark as Expense). Default is Asset. Asset is neither, income or expense.
-*&#10004; Implement RTF Documents.
+* &#10004; Dropdown for type of log amount (Mark as Expense). Default is Asset. Asset is neither, income or expense.
+* &#10004; Implement RTF Documents.
 > Useful as more document style formated details can be added instead of just plain text.
 *&#10004; Preserve Search view selections. After edits and submit.
 > * &#10004; Preserve from to date selections.
 > * &#10004; Date View not working on Local entered date format.
-*&#10004; Sum selected, income, expense, totals. 
+*&#10004; Sum selected, income, expense, totals.
 &#10004; Sum on view.
 
 
@@ -69,8 +69,8 @@ This version is not compatible in data structure to prior versions. Data migrati
 >&#10004; 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.
+* &#10004; Bug - 10 Expense type entries don't fill ammount field on edit button clicked.
+* &#10004; 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.
 * &#10004; Bug - 06, Invalid Time 00. Javascript error thrown, when 00am used.
index 6865a28c7394ac7bd61021a3319697b3ee92ec0b..3f1100f4bd2dd69f54586f8522017ca86d486c65 100755 (executable)
@@ -704,7 +704,7 @@ sub processDBFix {
      my $wipe_ss = $cgi->param("wipe_syst");
 
      
-     my $issue;
+     my $sql;
      my $date;
      my $cntr_upd =0;
 try{
@@ -717,7 +717,7 @@ 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;');                        
@@ -733,48 +733,13 @@ try{
         }
 
         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;
@@ -792,7 +757,7 @@ try{
 }
 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);
 }
 }
 
@@ -979,20 +944,20 @@ sub importCatCSV {
             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);
@@ -1001,25 +966,28 @@ sub updateCATDB {
             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;
@@ -1028,7 +996,7 @@ sub importLogCSV {
 sub updateLOGDB {
     my @flds = @_;
     if(@flds>3){
-    try{       
+    try{
             my $id_cat = $flds[0];
             my $date   = $flds[1];
             my $log    = $flds[2];
@@ -1042,24 +1010,15 @@ sub updateLOGDB {
                 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>:".$_;
@@ -1141,4 +1100,45 @@ sub getTheme{
         $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
index 83147fa947361b88c0c950d3aa760277e46ddb6c..791b9acce4835bceba22c4cd88923ee1a20d237c 100755 (executable)
@@ -909,7 +909,7 @@ return $today;
                    #last_insert_id() -> Not reliable commented out.
                    #my $gzero = $db->last_insert_id();#//$db->prepare('SELECT last_insert_rowid();');
                    $st->finish();
-                   $st = $db->prepare('SELECT rowid FROM LOG ORDER BY rowid DESC LIMIT 1;'); 
+                   $st = $db->prepare('SELECT rowid FROM LOG ORDER BY rowid DESC LIMIT 1;');
                    $st -> execute(); 
                    my @lid = $st->fetchrow_array();
                    $st = $db->prepare("SELECT DOC FROM NOTES WHERE LID = '0';"); 
index d11ae21df79de09d0542aea75959ff0c66239935..94266969b07501c1be4e338fa4ebebcb2470eb53 100644 (file)
@@ -144,15 +144,14 @@ function loadedBody(toggle) {
         // 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){
@@ -166,8 +165,7 @@ function loadedBody(toggle) {
                 }
             }
           }});
-    
-
+    }
 }
 
 
@@ -292,7 +290,7 @@ function edit(row) {
     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();
@@ -306,11 +304,11 @@ function edit(row) {
         $("#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);
@@ -324,8 +322,8 @@ function edit(row) {
     $("#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');