From 00e2937e11521d6cbc4e6c45a71e42002fb0bec2 Mon Sep 17 00:00:00 2001 From: wbudic Date: Sat, 23 Mar 2019 12:01:49 +1100 Subject: [PATCH] Bug fix with search, Search/View By look overhaul. --- htdocs/cgi-bin/main.cgi | 177 +++++++++++++++++++----------------- htdocs/cgi-bin/remove.cgi | 11 ++- htdocs/cgi-bin/search.cgi | 2 +- htdocs/cgi-bin/stats.cgi | 6 +- htdocs/cgi-bin/wsrc/main.js | 31 +++++-- 5 files changed, 129 insertions(+), 98 deletions(-) diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index edc77af..0c56acb 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -80,11 +80,16 @@ my $stmt = "SELECT rowid, ID_CAT, DATE, LOG, AMMOUNT FROM LOG ORDER BY DATE D $st = $db->prepare( $stmtCat ); $rv = $st->execute() or die or die "

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

"; -my $cats = '\n'; my %hshCats; - +my $c_sel = 1; while(my @row = $st->fetchrow_array()) { - $cats = $cats. '\n'; + if($row[0]==$c_sel){ + $cats = $cats. '\n'; + } + else{ + $cats = $cats. '\n'; + } $hshCats{$row[0]} = $row[1]; } @@ -103,6 +108,8 @@ if($rs_keys){ my @keywords = split / /, $rs_keys; if($rs_cat_idx){ $stmS = $stmS ." ID_CAT='".$rs_cat_idx."' AND"; + }else{ + $stmS = $stmS ." ID_CAT='0' OR"; } if($stmD){ $stmS = $stmS .$stmD." AND"; @@ -140,14 +147,6 @@ else{ # Enable to see main query statement issued! #print $q->pre("### -> ".$stmt); -# -#Fetch entries! -# -$st = $db->prepare( $stmt ); -$rv = $st->execute() or die or die "

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

"; -if($rv < 0) { - print "

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

"; -} my $tfId = 0; my $id = 0; @@ -165,8 +164,14 @@ if($tbl_start>0){ } $stc->finish(); } - - +# +#Fetch entries! +# +$st = $db->prepare( $stmt ); +$rv = $st->execute() or die or die "

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

"; +if($rv < 0) { + print "

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

"; +} while(my @row = $st->fetchrow_array()) { $id = $row[0]; @@ -239,12 +244,15 @@ if($tbl_start>0){ if($stmD){ $tbl = $tbl . ' - Search Failed to Retrive any records on select: ['. $stmD .'] ! - '; + Search Failed to Retrive any records on select: ['. $stmD .'] !'; } elsif($rs_keys){ + my $criter = ""; + if($rs_cat_idx>0){ + $criter = "->Criteria[".$hshCats{$rs_cat_idx}."]"; + } $tbl = $tbl . ' - Search Failed to Retrive any records on keywords: ['. $rs_keys .'] ! + Search Failed to Retrive any records on keywords: ['. $rs_keys .']'.$criter.' ! '; } else{ @@ -252,18 +260,19 @@ if($tbl_start>0){ } } - $tbl .= ' + $tbl .= '   + -
Keywords: +Keywords:
'; -my $frm = qq( + my $frm = qq(
@@ -300,33 +309,31 @@ my $srh = qq(
* LOG ENTRY FORM *
- - - ); - -my $ctmsg = '

  (Use the Category dropdown to change).

'; -if($rs_keys || $rs_cat_idx || $stmD){ - $srh .= ''; - $ctmsg = ""; -} - - - -$srh .= ' - - + ); + +$cats =~ s/selected//g; +$srh .= ' + + - -
Search/View By
Keywords: -
-
View by Category: - - '.$ctmsg.'
View by Date:
View by Category:'.$cats.' + +
View by Date: From:  To: 

-

'; + Keywords: + + + '; + +if($rs_keys || $rs_cat_idx || $stmD){ + $srh .= ' + '; +} + +#$srh .='
+$srh.='
'; # #Page printout from here! # @@ -347,50 +354,6 @@ exit; -sub buildNavigationButtons{ - - my $is_end_of_rs = shift; - - if(!$tbl_cur_id){ - #Following is a quick hack as previous id as current minus one might not - #coincide in the database table! - $tbl_cur_id = $id-1; - } - if($tfId==1){ - $tfId = 0; - }else{ - $tfId = 1; - } - - $tbl .= ''; - - if($rs_prev && $rs_prev>0 && $tbl_start>0){ - - $tbl = $tbl . ' - '; - - } - else{ - $tbl = $tbl .'Top'; - } - - - $tbl = $tbl .''; - - if($is_end_of_rs == 1){ - $tbl = $tbl .'End'; - } - else{ - - $tbl = $tbl . ''; - - } - - $tbl = $tbl .''; -} sub processSubmit { @@ -478,6 +441,50 @@ catch{ } +sub buildNavigationButtons{ + + my $is_end_of_rs = shift; + + if(!$tbl_cur_id){ + #Following is a quick hack as previous id as current minus one might not + #coincide in the database table! + $tbl_cur_id = $id-1; + } + if($tfId==1){ + $tfId = 0; + }else{ + $tfId = 1; + } + + $tbl .= ''; + + if($rs_prev && $rs_prev>0 && $tbl_start>0){ + + $tbl = $tbl . ' + '; + + } + else{ + $tbl = $tbl .'Top'; + } + + + $tbl = $tbl .''; + + if($is_end_of_rs == 1){ + $tbl = $tbl .'End'; + } + else{ + + $tbl = $tbl . ''; + + } + + $tbl = $tbl .''; +} sub checkCreateTables(){ diff --git a/htdocs/cgi-bin/remove.cgi b/htdocs/cgi-bin/remove.cgi index 1902b4a..aafa7e2 100755 --- a/htdocs/cgi-bin/remove.cgi +++ b/htdocs/cgi-bin/remove.cgi @@ -34,6 +34,13 @@ my $rv = $st->execute() or die or die "

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

"; my %hshCats; my $tbl_rc =0; + +#SETTINGS HERE! +our $REC_LIMIT = 25; +our $TIME_ZONE = 'Australia/Sydney'; +our $PRC_WIDTH = '60'; +#END OF SETTINGS + while(my @row = $st->fetchrow_array()) { $hshCats{$row[0]} = $row[1]; } @@ -42,7 +49,7 @@ while(my @row = $st->fetchrow_array()) { my $stmS = "SELECT rowid, ID_CAT, DATE, LOG from LOG WHERE"; my $stmE = " ORDER BY DATE DESC, rowid DESC;"; my $tbl = '
- +
'; @@ -75,7 +82,7 @@ $db->disconnect(); exit; sub DisplayDateDiffs{ - $tbl = '
DateTimeLogCategory
+ $tbl = '
'; $stm = 'SELECT DATE, LOG FROM LOG WHERE '; diff --git a/htdocs/cgi-bin/search.cgi b/htdocs/cgi-bin/search.cgi index 69e36ad..694b269 100755 --- a/htdocs/cgi-bin/search.cgi +++ b/htdocs/cgi-bin/search.cgi @@ -69,7 +69,7 @@ else{ print $q->center($q->h2({-style=>'Color: red;'},'No Keywords Submitted!')); } - print $q->pre("### -> ".$stm); + print $q->pre("### -> ".$stm); print $q->end_html; diff --git a/htdocs/cgi-bin/stats.cgi b/htdocs/cgi-bin/stats.cgi index ce614bb..2320fa5 100755 --- a/htdocs/cgi-bin/stats.cgi +++ b/htdocs/cgi-bin/stats.cgi @@ -83,9 +83,9 @@ $tbl = $tbl . '
* DATE DIFFERENCES *
Number of Records:'.
'; -print '
' . $tbl .'
'; -print '

Server Info

' . $hardware_status .'
'; -print '

Processes Info

' . $processes .'
i
'; +print '
' . $tbl .'
'; +print '

Server Info

' . $hardware_status .'

'; +print '

Processes Info

' . $processes .'
'; print $q->end_html; $dbh->disconnect(); diff --git a/htdocs/cgi-bin/wsrc/main.js b/htdocs/cgi-bin/wsrc/main.js index bb89c07..5b49fab 100644 --- a/htdocs/cgi-bin/wsrc/main.js +++ b/htdocs/cgi-bin/wsrc/main.js @@ -26,6 +26,11 @@ function formValidation(){ var date = document.getElementById("frm_entry").date; var log = document.getElementById("frm_entry").log; +var cat = document.getElementById("frm_entry").cat; +if(cat.value ==0){ + alert("Category -> has not been selected!"); + return false; +} return validDate(date.value) && validLog(log.value); @@ -81,7 +86,7 @@ function edit(row){ document.getElementById("el").value = ev_v.innerText; document.getElementById("ed").value = ed_v.innerText + " " + et_v.innerText; document.getElementById("am").value = ea_v.innerText; - + //Change selected catergory for(var i = 0, j = ec.options.length; i < j; ++i) { if(ec.options[i].innerHTML === ec_v) { ec.selectedIndex = i; @@ -94,6 +99,18 @@ function edit(row){ return false; } + + +function selectAllLogs(){ + var frm = document.getElementById("frm_log"); + var chks = document.getElementsByName("chk"); + for(var i=0, n=chks.length;i