]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Sum interaction, updated.
authorwbudic <redacted>
Fri, 10 Sep 2021 08:54:50 +0000 (18:54 +1000)
committerwbudic <redacted>
Fri, 10 Sep 2021 08:54:50 +0000 (18:54 +1000)
.gitignore
Current Development Check List.md
htdocs/cgi-bin/main.cgi
htdocs/cgi-bin/wsrc/main.js

index d0bfbb6e0058f1970dfee20b476f4d53f10d8a7f..384b7be3993545b3c035919397f09f05674e4082 100644 (file)
@@ -18,6 +18,7 @@ cgisess_*
 .vscode
 .vstags
 .history
+.history/*
 tags
 */bck/*
 bck_*
index ea566c4a4a32405ef20300b26e8946ceea5b39fa..fb623d78dd950359b5fe141c7619f046845442f4 100644 (file)
@@ -6,6 +6,8 @@
 
 ### New Development v.2.3+
 
+* &#10004; Sums and dynamic calculations, interactions further to be refined.
+  * Canceling submit, leaves the translated '**\n**' for transfer not reverted.
 * &#10004; Setting should provide page color defaults in form of an hash.
   * These should/can change based on selected theme. That possibly in future can be changed via config.
   * colBG,colFG, colSHDW, etc...
index 761a82bf4ed26eccdd5509e11aa109fe378da274..c74e272856498ac7b5c2b1dc688d22a4e4026499 100755 (executable)
@@ -925,7 +925,7 @@ HTML
             <button class="bordered" data-dropdown="#dropdown-standard-v" style="margin: 0px; padding: 0; padding-right:8px;">
             <span id="lcat_v" class="ui-button">$catselected</span>
             &#171;</button>
-            <div id="dropdown-standard-v" class="dropdown-menu dropdown-anchor-left-center dropdown-has-anchor">
+            <div id="dropdown-standard-v" class="dropdown-menu dropdown-anchor-top-center   dropdown-has-anchor">
                         <table class="tbl">$td_cat</table>
             </div>
 
index 1bc0dffedfcffd338ddcd871d64e62cb6747cf39..c2e856a41ee93255a8454f97c86eefc8335a3f1f 100644 (file)
@@ -113,7 +113,7 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) {
         if(v.length==0 || v==0.00){
             const regex = /^[\D]?\d+\.*\d*/gm;
             let str = $('#el').val();
-            let m; let tot = 0;
+            let m; var tot = 0;
 
             while ((m = regex.exec(str)) !== null) {                
                 if (m.index === regex.lastIndex) {
@@ -141,7 +141,7 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) {
                 });
             }
             if(tot==0){tot=""}
-            $('#am').val(tot);            
+            $('#am').val(tot.toFixed(2));            
         }
 
 
@@ -289,8 +289,8 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) {
         lbl = lbl.replace(/\s*$/g, "");
         lbl = lbl + "&nbsp;".repeat(16-lbl.length);
         $("#lcat_v").html(lbl);
-        $("#vc").val(ci);
-        $("#cat_desc").show();
+        $("#vc").val(ci);        
+        $("#cat_desc").show();        
     }).mouseenter(function(e){
         var pr = $(event.target).parent(); pr = pr.attr('id');
         if(pr){
@@ -398,13 +398,19 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) {
     display("Log page is ready!");    
 }
 
-function encodeText(el){
+function encodeText(){
     var el = $("#frm_entry [name=log]");
     var txt = el.val();
     txt = txt.replace(/\r\n/g, "\\n");
     txt = txt.replace(/\n/g, "\\n");
     el.val(txt);
 }
+function decodeText(){
+    var el = $("#frm_entry [name=log]");
+    var txt = el.val();
+        txt = txt.replace(/\\n/g, "\n");
+    el.val(txt);
+}
 
 function formValidation() {
     // if ($("#ec option:selected").val() == 0) {
@@ -1052,22 +1058,31 @@ function exportToCSV(dat, view){
 
 function sumSelected() {
     var chks = document.getElementsByName("chk");
-    var sum = 0;
+    var sum = 0; var amount=0; var html="";
     for (var i = 0, n = chks.length; i < n; i++) {
         if (chks[i].checked) {
-            var id = chks[i].value;
-            var am = $("#a"+id).text();
-            var ty = $("#c"+id).text();
+            let id = chks[i].value;
+            let am = $("#a"+id).text();
+            let ct = $("#c"+id).text();
+            let at = $("#f"+id).val();           
+
             am = am.replace(/\,/g,"");//rem formatting
-            if(ty=='Expense'){
+            if(ct=='Expense' || at=='2'){
                 sum = sum - Number(am);
-            }
-            else{
+                html += "-"+am+"<br>";
+            }else
+            if(ct=='Income' || at=='1'){ //marked as income or category is income type for amount.
                 sum = sum + Number(am);
+                html += "+"+am+"<br>";
+            }else{
+                amount += Number(am);
+                html += "<i>"+am+"</i><br>";
             }
         }
     }
-    $("#summary").html(sum.toFixed(2));
+    if(amount!=0){amount = "Amount sum: <i>"+amount+"</i> <b>Accounting sum: "}else{amount="<b>Accounting sum: "}
+    html += amount + sum.toFixed(2)+"</b>";
+    $("#summary").html(html);
     return false;
 }
 
@@ -1116,16 +1131,21 @@ function saveRTF(id, action) {
                     'Click on the No button, and then on Now button on the form.</div>');
                 },
                 buttons: [
-                    {  text: "Yes",                    
-                        icons: { primary: "ui-icon-circle-check" },
+
+                    { text: "Yes",                    
+                      icons: { primary: "ui-icon-circle-check" },
                         click: function() {
-                        $( this ).dialog( "close" );
-                        $("#frm_entry").submit();
+                            $( this ).dialog( "close" );
+                            $("#frm_entry").submit();
                         }
                     },
         
                     { text: "No",
-                        click: function() {$( this ).dialog( "close" ); return false;}
+                        click: function() {
+                            decodeText();
+                            $( this ).dialog( "close" );                        
+                            return false;
+                        }
                     }
                 ]
             });