]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Implemented auto sum for ammount field. Bug 35 fixed.
authorwbudic <redacted>
Mon, 9 Aug 2021 14:10:21 +0000 (00:10 +1000)
committerwbudic <redacted>
Mon, 9 Aug 2021 14:10:21 +0000 (00:10 +1000)
Current Development Check List.md
htdocs/cgi-bin/main.cgi
htdocs/cgi-bin/wsrc/main.js

index 524369ae65d5b92bc1b3271689ea75e800f90371..a83468c2786a066917f4fcc715bddc55d8dd9b8f 100644 (file)
@@ -6,8 +6,8 @@
 
 ### New Development
 
-* Bug 35. SQL migration, version update, not working for PG based databases.
-* JS - Event, on expense sum in log numbers found at beginning of lines.
+* &#10004; Bug 35. SQL migration, version update, not working for PG based databases.
+* &#10004; JS - Event, on expense sum in log numbers found at beginning of lines.
 * &#10004; Update to CNF v.2.2, branch to $RELEASE_VER = 2.3, Earth Stage initial.
 * Plugins
   * Perl files enabled by being including them in main.cnf file under the <<PLUGINS<>>> list, and placed in the plugins directory.
@@ -207,7 +207,7 @@ between 2018-08-22 04:13:55 **Moon Stable** production release and this
 
 ### v. 2.2 Encountered/Fixed
 
-* Bug 35, Migration and version updating SQL is wrong for PG database, it doesn't have rowid's.
+* &#10004; Bug 35, Migration and version updating SQL is wrong for PG database, it doesn't have rowid's.
 * Bug 34, DB fix in config, removes associated RTF documents, for some reason.
 * &#10004; Bug 33 Changing session timeout in config to an lib. background unparsable format cause unrecoverable system error.
   * i.e. Putting +1hr instead of +1h.
index 95dc496a32f08aaac76c13c2f7c88b4f357df9af..9bec9d6048c0314033139a46eb211a008f935e75 100755 (executable)
@@ -239,7 +239,6 @@ while ( my @row = $st->fetchrow_array() ) {
     }
     $td_cat .= "<li id='$row[0]'><a href='#'>$row[1]</a></li>";
     $td_itm_cnt++;
-
 }
 if($td_itm_cnt<5){#fill spacing.
     for (my $i=0;$i<5-$td_itm_cnt;$i++){
@@ -280,7 +279,6 @@ qq(<FORM id="frm_log" action="data.cgi" onSubmit="return formDelValidation();">
         my @keywords = split /\W/, $rs_keys;
         if ($prm_vc && $prm_vc != $prm_xc) {
 
-
                 if(@vc_lst){
                     $stmS .= $prm_aa;
                     foreach (@vc_lst){
@@ -440,12 +438,14 @@ sub buildLog {
         my $ct  = $hshCats{$cid}; #ID_CAT        
         my $dt  = DateTime::Format::SQLite->parse_datetime( $row[$i++] ); #LOG.DATE
         my $log = $row[$i++]; #LOG.LOG
-        my $rtf = $row[$i++];     #ID_RTF since v.1.8 but just RTF from v.2.1
+        my $rtf = $row[$i++]; #ID_RTF since v.1.8 but just RTF from v.2.1
         my $am  = $row[$i++]; #LOG.AMOUNT
         my $af  = $row[$i++]; #AFLAG -> Asset as 0, Income as 1, Expense as 2
         my $sticky = $row[$i++]; #Sticky to top
         my $pid = $row[$i++]; #PID actual log ID in View.
 
+        $am =~ s/^\D|\,//g; #trim if it is money sql data type formated.
+
         if ( $af == 1 ) { #AFLAG Income, assets are neutral.
             $sum += $am;
         }
@@ -691,13 +691,6 @@ sub buildLog {
                           </div>
                         </td></tr>);
         }
-
-                        #      <span id="q-scroll$id" 
-                        #         style="height:auto;  max-width:100%; max-height:480px; padding: 10px; background:#fffafa; overflow-x:scroll; overflow-y:auto;">
-                        #     <div class="log" style="overflow-x:scroll; max-width:100%; scrollbar-width:none;">
-                        #     <div id="q-container$id"></div></div>
-                        #   </span>
-
         $log_rc += 1;
 
         if ( $rec_limit > 0 && $log_rc == $rec_limit ) {
index 59da59598bc1f30a26dbdc2fd64284c4ce01fb7f..2c87725bbb262f7c7e7651f148eabbac158237f4 100644 (file)
@@ -102,6 +102,30 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) {
         offsetX: 5,
         showTimeout: 100
     });
+    $('#am').click(function(e){
+        e.preventDefault();
+        let v = $('#am').val();
+        if(v.length==0 || v==0.00){
+            const regex = /^\D*\d+\.*\d*/gm;
+            let str = $('#el').val();
+            let m; let tot = 0;
+
+            while ((m = regex.exec(str)) !== null) {                
+                if (m.index === regex.lastIndex) {
+                    regex.lastIndex++;
+                }
+                m.forEach( (match, groupIndex) => {
+                    //console.log(`Found match, group ${groupIndex}: ${match}`);
+                    tot += parseFloat(`${match}`.replace(/^\$/g,''));
+
+                });
+            }
+            $('#am').val(tot);
+            
+        }
+
+
+     });
 
     $('#sss_xc').poshytip({
         content: "When checked, system will try to remember your view mode while in session.",
@@ -273,6 +297,7 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) {
         }
     }).mouseleave(function(e){$("#cat_desc").hide();});
 
+    
     $( "#dlgValidation" ).dialog({
         dialogClass: "alert",
         buttons: [