From a50a6f9ab184a8fb754ec2ac338865f0a6a235ce Mon Sep 17 00:00:00 2001 From: Will Budic Date: Sat, 9 May 2020 16:51:47 +1000 Subject: [PATCH] View by amount type implemented. Bug 23 Fix,. --- Current Development Check List.md | 1 + htdocs/cgi-bin/config.cgi | 2 +- htdocs/cgi-bin/main.cgi | 86 +++++++++++++++++++------------ htdocs/cgi-bin/wsrc/main.js | 14 +++-- 4 files changed, 66 insertions(+), 37 deletions(-) diff --git a/Current Development Check List.md b/Current Development Check List.md index 0b67c7e..4a910fb 100644 --- a/Current Development Check List.md +++ b/Current Development Check List.md @@ -94,6 +94,7 @@ This version is not compatible in data structure to prior versions. Data migrati ### v. 1.9 Encountered/Fixed +* ✔ Bug 23 - Delete not working in view mode. * ✔ Bug 22 - Delete selection of entries not working after a while, db fix in config page required. * ✔ Bug 21 - Income sum for year in stats is displayed wrong. * ✔ Bug 20 - Autologin bypasses, wanted new alias login (on logoff). diff --git a/htdocs/cgi-bin/config.cgi b/htdocs/cgi-bin/config.cgi index f2d2682..50db9e7 100755 --- a/htdocs/cgi-bin/config.cgi +++ b/htdocs/cgi-bin/config.cgi @@ -93,8 +93,8 @@ print qq(
-Stats
Log
+Stats
Jump to Sections
Categories
System
diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 4c9d471..440fe58 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -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(
Category Edit ); - + #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( 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( 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( my $id = 0; my $log_start = index $sqlVWL, "<="; my $re_a_tag = qr/.*<\/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( #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 { Search Failed to Retrive any records on keywords: [$rs_keys]$criter!); } else { - if (&isInViewMode) { $log_output .= 'You have reached the end of the data view!' } + if ($isInViewMode) { $log_output .= 'You have reached the end of the data view!' } else{ $log_output .= 'Database is New or Empty!'} } } @@ -777,7 +788,7 @@ _TXT   Marks as: - @@ -814,7 +825,7 @@ _TXT ); - my $sss_checked = 'checked' if &isInViewMode; + my $sss_checked = 'checked' if $isInViewMode; my $tdivxc = 'Excludes:'; my $catselected = '   -- Select --   '; my $xcatselected = '   -- Select --   '; @@ -840,6 +851,16 @@ _TXT $xcatselected =~ s/^(.*)/' ' x $n . $1/e; $tdivxc = 'Excludes:'.$hshCats{$prm_xc}.''; } + #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\n"; + $i++; + } $srh .= qq( @@ -855,6 +876,13 @@ _TXT +   + View by Amount Type: +   +   + @@ -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] "; - $vmode = "[In View Mode] " if &isInViewMode; + $vmode = "[In View Mode] " if$isInViewMode; if($rec_limit == 0){ $log_output .= qq!$vmode @@ -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; diff --git a/htdocs/cgi-bin/wsrc/main.js b/htdocs/cgi-bin/wsrc/main.js index d1e5a79..85018d0 100644 --- a/htdocs/cgi-bin/wsrc/main.js +++ b/htdocs/cgi-bin/wsrc/main.js @@ -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); -- 2.34.1