]> lifelog.hopto.org Git - LifeLog.git/commitdiff
View by amount type implemented. Bug 23 Fix,.
authorWill Budic <redacted>
Sat, 9 May 2020 06:51:47 +0000 (16:51 +1000)
committerWill Budic <redacted>
Sat, 9 May 2020 06:51:47 +0000 (16:51 +1000)
Current Development Check List.md
htdocs/cgi-bin/config.cgi
htdocs/cgi-bin/main.cgi
htdocs/cgi-bin/wsrc/main.js

index 0b67c7e3046ed7f5fcb62369390aecda62491e9d..4a910fbcb24328cdd180d1b40b0b6a6b17cd4e6d 100644 (file)
@@ -94,6 +94,7 @@ This version is not compatible in data structure to prior versions. Data migrati
 
 ### v. 1.9 Encountered/Fixed
 
+* &#10004; Bug 23 - Delete not working in view mode.
 * &#10004; Bug 22 - Delete selection of entries not working after a while, db fix in config page required.
 * &#10004; Bug 21 - Income sum for year in stats is displayed wrong.
 * &#10004; Bug 20 - Autologin bypasses, wanted new alias login (on logoff).
index f2d2682aa1c8253c99ce4a94ad10ab855de20784..50db9e7dcb5f5a437a392bc5d533095dc465a4a8 100755 (executable)
@@ -93,8 +93,8 @@ print qq(<div id="menu" title="To close this menu click on its heart, and wait."
 <a id="menu_close" href="#" onclick="return hide('menu_close');"><span  class="ui-icon ui-icon-heart" style="float:none;"></span></a>
 </div>
 <hr>
-<a class="a_" href="stats.cgi">Stats</a><hr>
 <a class="a_" href="main.cgi">Log</a><hr>
+<a class="a_" href="stats.cgi">Stats</a><hr>
 <font size="2"><b>Jump to Sections</b><br>
 <a href="#categories">Categories</a><br>
 <a href="#vars">System</a><br>
index 4c9d4719b28b2676866e672cbbb090ad0b4444c0..440fe586865949f80826d672f1a9fe2e3b4a5180 100755 (executable)
@@ -58,6 +58,7 @@ my $log_rc_prev = 0;
 my $log_cur_id  = 0;
 my $log_top     = 0;
 my $rs_keys     = $cgi->param('keywords');
+my $prm_aa      = $cgi->param("aa");
 my $prm_vc      = $cgi->param("vc");
 my $prm_xc      = $cgi->param("xc");
 my $prm_xc_lst  = $cgi->param("xclst");
@@ -66,8 +67,9 @@ my $rs_dat_to   = $cgi->param('v_to');
 my $rs_prev     = $cgi->param('rs_prev');
 my $rs_cur      = $cgi->param('rs_cur');
 my $rs_page     = $cgi->param('rs_page');
-my $stmS        = 'SELECT PID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY from VW_LOG WHERE';
-my $stmE        = "";
+my $sqlView     = 'SELECT ID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY, PID FROM VW_LOG';#Only to be found here, the main SQL select statement.
+my $stmS        = $sqlView." WHERE";
+my $stmE        = ' LIMIT '.&Settings::viewAllLimit.';';
 my $stmD        = "";
 my $sm_reset_all;
 my $rec_limit   = &Settings::recordLimit;
@@ -106,7 +108,7 @@ if ( $rs_dat_from && $rs_dat_to ) {
 
 #Toggle if search deployed.
 my $toggle = "";
-if ( $rs_keys || $stmD || $prm_vc > 0 || $prm_xc > 0) { $toggle = 1; }
+if ( $rs_keys || $stmD || $prm_vc > 0 || $prm_xc > 0 || $prm_aa > 0) { $toggle = 1; }
 
 
 ##Handle Session Keeps
@@ -227,7 +229,7 @@ print $cgi->start_html(
 
 my $st;
 my $sqlCAT = "SELECT ID, NAME, DESCRIPTION FROM CAT ORDER BY ID;";
-my $sqlVWL = "SELECT ID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY, PID FROM VW_LOG WHERE STICKY = 1 LIMIT ".&Settings::viewAllLimit.";";
+my $sqlVWL = "$stmS STICKY = 1 $stmE";
 
 print qq(## Using db -> $dsn\n) if $DEBUG;
 
@@ -278,26 +280,28 @@ qq(<form id="frm_log" action="data.cgi" onSubmit="return formDelValidation();">
        <th>Category</th>
     <th>Edit</th>
 </tr>);
-
+    #We use js+perl, trickery to filter by amount type, as well.
+    if ($prm_aa >0){my $s = $prm_aa - 1;$prm_aa = " AFLAG=$s AND";}else{$prm_aa=""}
 
     if ( $rs_keys && $rs_keys ne '*' ) {
 
         my @keywords = split / /, $rs_keys;
         if ($prm_vc && $prm_vc != $prm_xc) {
-            $stmS .= " ID_CAT='" . $prm_vc . "' AND";
+            $stmS .= $prm_aa . " ID_CAT='" . $prm_vc . "' AND";
         }
         else {
             if($prm_xc>0){
                 if(@xc_lst){
                     foreach (@xc_lst){
-                            $stmS .= " ID_CAT!=$_ AND";
+                            $stmS .= $prm_aa . " ID_CAT!=$_ AND";
                     }
                 }
-                else{       $stmS .= " ID_CAT!=$prm_xc AND"; }
+                else{       $stmS .= $prm_aa . " ID_CAT!=$prm_xc AND"; }
             }
         }
+
         if ($stmD) {
-            $stmS = $stmS . $stmD . " AND";
+            $stmS = $stmS .$prm_aa . $stmD . " AND";
         }
 
         if (@keywords) {
@@ -313,13 +317,15 @@ qq(<form id="frm_log" action="data.cgi" onSubmit="return formDelValidation();">
     elsif ($prm_vc && $prm_vc != $prm_xc) {
 
         if ($stmD) {
-            $sqlVWL = $stmS . $stmD . " AND ID_CAT=" . $prm_vc . $stmE;
+            $sqlVWL = $stmS . $prm_aa . $stmD . " AND ID_CAT=" . $prm_vc .$prm_aa. $stmE;
         }
         else {
-            $sqlVWL = $stmS . " ID_CAT=" . $prm_vc . ";" . $stmE;
+            $sqlVWL = $stmS . $prm_aa . " ID_CAT=" . $prm_vc . $stmE;
         }
     }
     else {
+
+
         if($prm_xc>0){
 
                 if(@xc_lst){
@@ -327,21 +333,27 @@ qq(<form id="frm_log" action="data.cgi" onSubmit="return formDelValidation();">
                     foreach (@xc_lst){
                             $ands .= " ID_CAT!=$_ AND";
                     }
+
                     $ands =~ s/AND$//g;
-                    $sqlVWL = $stmS . $ands . $stmE;
+                    $sqlVWL = $stmS .$prm_aa. $ands . $stmE;
                 }
                 else{
-                    $sqlVWL = $stmS . " ID_CAT!=$prm_xc;" . $stmE;
+                    $sqlVWL = $stmS . $prm_aa." ID_CAT!=$prm_xc;" . $stmE;
                 }
 
-
-
         }
+
         if ($stmD) {
-            $sqlVWL = $stmS . $stmD . $stmE;
+            $sqlVWL = $stmS . $prm_aa.' '. $stmD . $stmE;
+        }
+        elsif($prm_aa){
+                    $prm_aa =~ s/AND$//g;
+                    $sqlVWL = $stmS .$prm_aa.' '.$stmE;
         }
     }
 
+
+
 ###################
     &processSubmit;
 ###################
@@ -350,10 +362,9 @@ qq(<form id="frm_log" action="data.cgi" onSubmit="return formDelValidation();">
     my $id        = 0;
     my $log_start = index $sqlVWL, "<=";
     my $re_a_tag  = qr/<a\s+.*?>.*<\/a>/si;
-    #TODO implement isView instead of quering params over and over again.
-    my $isView = rindex ($sqlVWL, 'PID<=') > 0 || rindex ($sqlVWL, 'ID_CAT=') > 0;
+    my $isInViewMode = rindex ($sqlVWL, 'PID<=') > 0 || rindex ($sqlVWL, 'ID_CAT=') > 0 || $prm_aa;
 
-    print $cgi->pre("###[Session PARAMS->isV:$isView|vc=$prm_vc|xc=$prm_xc|xc_lst=$prm_xc_lst|\@xc_lst=@xc_lst|keepExcludes=".&Settings::keepExcludes."] -> ".$sqlVWL) if $DEBUG;
+    print $cgi->pre("###[Session PARAMS->isV:$isInViewMode|vc=$prm_vc|xc=$prm_xc|aa: $prm_aa|xc_lst=$prm_xc_lst|\@xc_lst=@xc_lst|keepExcludes=".&Settings::keepExcludes."] -> ".$sqlVWL) if $DEBUG;
 
     if ( $log_start > 0 ) {
 
@@ -379,8 +390,8 @@ qq(<form id="frm_log" action="data.cgi" onSubmit="return formDelValidation();">
     #place sticky or view param.ed entries first!
     buildLog(traceDBExe($sqlVWL));
     #Following is saying is in page selection, not view selection, or accounting on type of sticky entries.
-    if( !$isView && !$prm_vc  && !$prm_xc && !$rs_keys && !$rs_dat_from ){
-        $sqlVWL = "SELECT ID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY, PID FROM VW_LOG WHERE STICKY != 1 LIMIT ".&Settings::viewAllLimit.";";
+    if( !$isInViewMode && !$prm_vc  && !$prm_xc && !$rs_keys && !$rs_dat_from ){
+        $sqlVWL = "$stmS STICKY != 1 $stmE";
         print $cgi->pre("###2 -> ".$sqlVWL)  if $DEBUG;
         ;
         &buildLog(traceDBExe($sqlVWL));
@@ -707,7 +718,7 @@ sub buildLog {
                        <b>Search Failed to Retrive any records on keywords: [<i>$rs_keys</i>]$criter!</b></td></tr>);
         }
         else {
-            if (&isInViewMode) { $log_output .= '<tr><td colspan="5"><b>You have reached the end of the data view!</b></td></tr>' }
+            if ($isInViewMode) { $log_output .= '<tr><td colspan="5"><b>You have reached the end of the data view!</b></td></tr>' }
             else{ $log_output .= '<tr><td colspan="5"><b>Database is New or  Empty!</b></td></tr>'}
         }
     }
@@ -777,7 +788,7 @@ _TXT
                <td id="al">
                        <input id="am" name="am" type="text">&nbsp;
             Marks as:
-            <select id="amf" name="amf">
+            <select id="amf" name="amf" class="ui-button" data-dropdown="#dropdown-standard">
                 <option value="0" selected>Asset</option>
                 <option value="1">Income</option>
                 <option value="2">Expense</option>
@@ -814,7 +825,7 @@ _TXT
         </td>
       </tr>
     );
-    my $sss_checked = 'checked' if &isInViewMode;
+    my $sss_checked = 'checked' if $isInViewMode;
     my $tdivxc = '<td id="divxc_lbl" align="right" style="display:none"><b>Excludes:</b></td><td align="left" id="divxc"></td>';
     my $catselected  = '<i>&nbsp;&nbsp;&nbsp;<font size=1>-- Select --</font>&nbsp;&nbsp;&nbsp;</i>';
     my $xcatselected = '<i>&nbsp;&nbsp;&nbsp;<font size=1>-- Select --</font>&nbsp;&nbsp;&nbsp;</i>';
@@ -840,6 +851,16 @@ _TXT
         $xcatselected =~ s/^(.*)/'&nbsp;' x $n . $1/e;
         $tdivxc = '<td id="divxc_lbl" align="right"><b>Excludes:</b></td><td align="left" id="divxc">'.$hshCats{$prm_xc}.'</td>';
     }
+    #select options of $prm_aa in dropdown.
+    my $aopts = "";
+    my ($s,$i) = ("",0);
+    my $aa = $cgi->param('aa');
+    if(!$prm_aa){$aa = 0}else{$aa--};
+    foreach ('Asset','Income','Expense') {
+        if($aa == $i){$s='selected'}else{$s=""}
+        $aopts .= "\t<option value=\"$i\" $s>$_</option>\n";
+        $i++;
+    }
     $srh .=
     qq(
     <tr class="collpsd">
@@ -855,6 +876,13 @@ _TXT
 
             <input id="vc" name="vc" type="hidden" value="$prm_vc"/>
             <button id="btn_cat" onclick="viewByCategory(this);">View</button>
+&nbsp;&nbsp;
+            <b>View by Amount Type:</b>
+&nbsp;&nbsp;
+            <select id="amf2" name="aa" class="ui-button">
+                $aopts
+            </select>&nbsp;<button id="btn_amt" onclick="viewByAmountType(this);">View</button>
+
      </td>
    </tr>
    <tr class="collpsd">
@@ -1057,7 +1085,7 @@ try {
 
                     }
 
-                    $sqlVWL = qq(SELECT PID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY from VW_LOG where PID<=$rs_cur and STICKY!=1 $sand)." LIMIT ".&Settings::viewAllLimit.";";
+                    $sqlVWL = qq($stmS PID<=$rs_cur and STICKY!=1 $sand $stmE);
                     return;
                 }
             }
@@ -1148,7 +1176,7 @@ print $cgi->header,
         }
 
         $vmode = "[In Page Mode]&nbsp;";
-        $vmode = "<font color='red'>[In View Mode]</font>&nbsp;" if &isInViewMode;
+        $vmode = "<font color='red'>[In View Mode]</font>&nbsp;" if$isInViewMode;
 
         if($rec_limit == 0){
             $log_output .= qq!<tr class="r$tfId"><td>$vmode</td><td colspan="3">
@@ -1290,12 +1318,6 @@ sub cam {
     return $am;
 }
 
-
-sub isInViewMode {
-    return $sss->param('sss_vc') || $sss->param('sss_xc');
-}
-
-
 sub quill{
 
     my ( $log_id, $height ) = shift;
index d1e5a79c13e3e8b5680ef214a746deba33ffb205..85018d0e5a44b6a240154418453a91ba98a17782 100644 (file)
@@ -155,17 +155,18 @@ function onBodyLoad(toggle, tz, today, expires, rs_cur) {
         var amf = $( "#amf" );//Amount Field Type dropdown
         var ec = $( "#ec" );  //Category dropdown
 
-        $( amf ).selectmenu({style: "dropdown", width:120,
+        $( "#amf2" ).selectmenu({style: "dropdown", width:100});
+
+         amf.selectmenu({style: "dropdown", width:100,
           change: function( event, data ) {
             var evv =ec.val();
             if(ec.val()<2||evv==32||evv==35||data.item.value == 0){
                 var sel = null;
                 if(data.item.label == "Income"){ sel = 35; }
                 else if(data.item.label == "Expense"){sel = 32; }
-                else if(data.item.value == 0 && (evv == 35||evv==32)){sel = 1; }
+                else if(data.item.value == 0 && (evv == 35||evv==32)){sel = 1;}
                 if(sel){
                     ec.val(sel);
-                   // ec.selectmenu("refresh");
                 }
             }
           }});
@@ -456,7 +457,7 @@ function edit(row) {
     ec_v = amt.val();
     $("#amf").focus();
     $("#amf").val(ec_v);
-    //$("#amf").selectmenu('refresh');
+    $("#amf").selectmenu('refresh');
 
     $("#el").focus();
 
@@ -725,6 +726,11 @@ function display(desc, times){
     pnl.fadeOut(1000*times);
 }
 
+function viewByAmountType(btn) {
+    var aa = $("#amf2 option:selected");
+        aa.val(parseInt(aa.val())+1);
+}
+
 function viewByCategory(btn) {
     $("#rs_keys").value = "";
     $("#xc").val(0);