From 03da057288f472907c20a3c739b121d7e4511c1b Mon Sep 17 00:00:00 2001 From: Will Budic Date: Thu, 7 Nov 2019 09:40:23 +1100 Subject: [PATCH] Implemented View sessioned on categories. --- htdocs/cgi-bin/main.cgi | 92 ++++++++++++++++++++++++++++--------- htdocs/cgi-bin/wsrc/main.js | 5 +- 2 files changed, 73 insertions(+), 24 deletions(-) diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index b890019..7f263a1 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -112,11 +112,45 @@ if ( $rs_dat_from && $rs_dat_to ) { my $toggle = ""; if ( $rs_keys || $rs_cat_idx || $stmD || $prm_vc > 0 || $prm_xc > 0) { $toggle = 1; } + +##Handle Session Keeps $sss->expire($SESSN_EXPR); $sss->param('theme', $TH_CSS); $sss->param('bgcolor', $BGCOL); + + +#Reset Clicked +if($cgi->param('srch_reset') == 1){ + $sss->clear('sss_vc'); + $sss->clear('sss_xc'); +} + +if($prm_vc){ + if ($cgi->param('sss_xc') eq 'on'){ + $sss->param('sss_vc', $prm_vc) + } + else{ + $sss->clear('sss_vc'); + } +}else{ + $prm_vc = $sss->param('sss_vc'); +} +if($prm_xc){ + if ($cgi->param('sss_xc') eq 'on'){ + $sss->param('sss_xc', $prm_xc) + } + else{ + $sss->clear('sss_xc'); + } +}else{ + $prm_xc = $sss->param('sss_xc'); +} + + $sss->flush(); + + #tag related framed sizing. my @arrwh = split /x/, $IMG_W_H; if ( @arrwh == 2 ) { @@ -150,8 +184,6 @@ print $cgi->start_html( -src => 'wsrc/tip-yellowsimple/tip-yellowsimple.css' }, -# {-type => 'application/atom+xml', -# -src=>'https://quilljs.com/feed.xml', -title=>"Quill - Your powerful rich text editor"}, { -type => 'text/css', -src => 'wsrc/quill/katex.min.css' }, { -type => 'text/css', -src => 'wsrc/quill/monokai-sublime.min.css' }, { -type => 'text/css', -src => 'wsrc/quill/quill.snow.css' }, @@ -182,7 +214,7 @@ print $cgi->start_html( my $rv; my $st; my $stmtCat = "SELECT ID, NAME, DESCRIPTION FROM CAT ORDER BY ID;"; -my $stmt = "SELECT ID, ID_CAT, DATE, LOG, AMOUNT, AFLAG, RTF, STICKY FROM VW_LOG WHERE STICKY =1;"; +my $stmt = "SELECT ID, ID_CAT, DATE, LOG, AMOUNT, AFLAG, RTF, STICKY FROM VW_LOG WHERE STICKY = 1;"; $st = $db->prepare($stmtCat); $rv = $st->execute() or die "

Error->" & $DBI::errstri & "

"; @@ -301,7 +333,7 @@ qq(
".$stmt) if $DEBUG; + print $cgi->pre("###[sss_xc PARAM->vc=$prm_vc|xc=$prm_xc] -> ".$stmt) if $DEBUG; if ( $log_start > 0 ) { @@ -747,9 +779,9 @@ _TXT ); - + my $sss_checked = 'checked' if $sss->param('sss_vc') || $sss->param('sss_xc') ; $srh .= - qq( + qq( View by Category: @@ -758,6 +790,15 @@ _TXT + + Exclude Category: + + $cats_x    + + + Keep In Seession + + View by Date: @@ -771,24 +812,17 @@ _TXT    - - - Exclude Category: - - $cats_x    - - - - + ); if ( ( $rs_keys && $rs_keys ne '*' ) || $rs_cat_idx || $stmD || $prm_xc ) { $sm_reset_all = 'Reset View
'; - $srh .= ' + '; } + else {$srh .= ''}; $srh .= '
'; my $quill = &quill( $cgi->param('submit_is_edit') ); @@ -807,7 +841,12 @@ qq(
-Log
+Log
+ + + + +
Stats
Config
Delete
@@ -896,7 +935,7 @@ sub processSubmit { if ( $view_mode == "1" ) { if ($rs_cur) { - + my $sand = ""; if ( $rs_cur == $rs_prev ) { #Mid page back button if id ordinal. $rs_cur += $REC_LIMIT; @@ -906,7 +945,15 @@ sub processSubmit { else { $rs_page++; } - $stmt = qq(SELECT PID, ID_CAT, DATE, LOG, AMOUNT, AFLAG, RTF, STICKY from VW_LOG where PID <= $rs_cur and STICKY != 1;); + + if($prm_vc){ + $sand = "and ID_CAT == $prm_vc"; + } + elsif($prm_xc){ + $sand = "and ID_CAT != $prm_xc"; + } + + $stmt = qq(SELECT PID, ID_CAT, DATE, LOG, AMOUNT, AFLAG, RTF, STICKY from VW_LOG where PID <= $rs_cur and STICKY != 1 $sand;); return; } } @@ -1014,24 +1061,25 @@ sub processSubmit { $tfId = 1; } + my $vmode = "[View Mode] " if $sss->param('sss_vc')||$sss->param('sss_xc'); if($REC_LIMIT == 0){ $log_output .= ''; - $log_output .= qq! + $log_output .= qq!$vmode !; } else{ if ($rs_cur < $log_top && $rs_prev && $rs_prev > 0 && $log_start > 0 && $rs_page > 0) { - $log_output .= qq!   + $log_output .= qq!$vmode     !; } else { - $log_output .= 'Top    '; + $log_output .= qq($vmodeTop    ); } diff --git a/htdocs/cgi-bin/wsrc/main.js b/htdocs/cgi-bin/wsrc/main.js index 50255b8..44c3323 100644 --- a/htdocs/cgi-bin/wsrc/main.js +++ b/htdocs/cgi-bin/wsrc/main.js @@ -445,11 +445,12 @@ function resetDoc(){ function resetView() { - $("#frm_srch input").val(""); + $("#frm_srch input").val(""); + $("#srch_reset").val(1); $("#idx_cat").val(0); $('#vc>option[value="0"]').prop('selected', true); $('#xc>option[value="0"]').prop('selected', true); - + $("#sss_xc").prop('checked', false); $("#frm_srch").submit(); } -- 2.34.1