From: Will Budic Date: Thu, 7 Nov 2019 02:09:50 +0000 (+1100) Subject: Implemented in session view mode pagin for categories. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=cb59110b21c579d9f13653e7e236c18985385c50;p=LifeLog.git Implemented in session view mode pagin for categories. --- diff --git a/htdocs/cgi-bin/config.cgi b/htdocs/cgi-bin/config.cgi index 8265ded..6c06258 100755 --- a/htdocs/cgi-bin/config.cgi +++ b/htdocs/cgi-bin/config.cgi @@ -764,7 +764,7 @@ try{ } catch{ $db->do('ROLLBACK;'); - die qq(@&processDBFix error:$_ with statement->$sql for $date update counter:$cntr_upd); + die qq(@&processDBFix error -> $_ with statement->$sql for $date update counter:$cntr_upd); } } @@ -1073,11 +1073,11 @@ sub cats{ sub dbExecute{ my $ret = $db->prepare(shift); - $ret->execute() or die "

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

"; + $ret->execute() or die "

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

"; return $ret; } -sub error{ +sub error { my $url = $cgi->url(); print qq(

Sorry Encountered Errors

Page -> $url

$ERROR

); print qq(

CGI Parameters

); @@ -1086,7 +1086,7 @@ sub error{ print '
  • '.$_.'=='. $cgi->param($_).'
  • '; } print "\n"; - print "Return to -> $url"; + print "Return to -> $url"; print $cgi->end_html; $db->disconnect(); exit; diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 7f263a1..d7d524f 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -37,9 +37,9 @@ our $AUTO_WRD_LMT = 1000; our $FRAME_SIZE = 0; our $RTF_SIZE = 0; -my $THEME = 'Standard'; -my $TH_CSS = 'main.css'; -my $BGCOL = '#c8fff8'; +my $THEME = 'Standard'; +my $TH_CSS = 'main.css'; +my $BGCOL = '#c8fff8'; #Set to 1 to get debug help. Switch off with 0. my $DEBUG = 0; #END OF SETTINGS @@ -64,7 +64,7 @@ elsif ( !$userid || !$dbname ) { my $database = '../../dbLifeLog/' . $dbname; my $dsn = "DBI:SQLite:dbname=$database"; -my $db = DBI->connect( $dsn, $userid, $password, { RaiseError => 1 } ) +my $db = DBI->connect( $dsn, $userid, $password, { PrintError => 0, RaiseError => 1 } ) or die "

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

    "; my ( $imgw, $imgh ); @@ -149,8 +149,6 @@ if($prm_xc){ $sss->flush(); - - #tag related framed sizing. my @arrwh = split /x/, $IMG_W_H; if ( @arrwh == 2 ) { @@ -216,6 +214,8 @@ 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;"; +print qq("## Using db -> $dsn) if $DEBUG; + $st = $db->prepare($stmtCat); $rv = $st->execute() or die "

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

    "; @@ -324,7 +324,7 @@ qq(
    vc=$prm_vc|xc=$prm_xc] -> ".$stmt) if $DEBUG; + print $cgi->pre("###[sss PARAMS->vc=$prm_vc|xc=$prm_xc] -> ".$stmt) if $DEBUG; if ( $log_start > 0 ) { @@ -685,7 +685,8 @@ qq(\n); Search Failed to Retrive any records on keywords: [$rs_keys]$criter!); } else { - $log_output .= 'Database is New or Empty!\n'; + if (&isInViewMode) { $log_output .= 'You have reached the end of the data view!' } + else{ $log_output .= 'Database is New or Empty!'} } } @@ -742,7 +743,7 @@ _TXT  Amount: -   +   Marks as: - '; + $sm_reset_all = 'Reset View
    '; + $srh .= ' + +
    '; } else {$srh .= ''}; @@ -889,6 +889,7 @@ $sm_reset_all + sub processSubmit { my $date = $cgi->param('date'); @@ -907,6 +908,7 @@ sub processSubmit { if($rtf eq 'on'){$rtf = 1} else {$rtf = 0} if($sticky eq 'on'){$sticky = 1} else {$sticky = 0} + if(!$am){$am=0} try { #Apostroph's need to be replaced with doubles and white space to be fixed for the SQL. @@ -923,8 +925,13 @@ sub processSubmit { AFLAG = '$af', RTF='$rtf', STICKY='$sticky' WHERE rowid="$edit_mode";); - my $st = $db->prepare($stm); - $st->execute(); + # + print $stm if $DEBUG; + # + + my $dbUpd = DBI->connect( $dsn, $userid, $password, { RaiseError => 1 } ) or die "

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

    "; + my $st = $dbUpd->prepare($stm); + $st->execute(); return; } @@ -962,20 +969,25 @@ sub processSubmit { #check for double entry # - my $st = $db->prepare(qq(SELECT DATE,LOG FROM LOG where DATE='$date' AND LOG='$log';)); + my $stm = qq(SELECT DATE,LOG FROM LOG where DATE='$date' AND LOG='$log';); + my $st = $db->prepare($stm); $st->execute(); - if ( my @row = $st->fetchrow_array() ) { + + if ($st->fetchrow_array() ) { return; } - $st = $db->prepare('INSERT INTO LOG VALUES (?,?,?,?,?,?,?)'); - $st->execute( $cat, $date, $log, $am, $af, $rtf, $sticky ); + $stm = qq(INSERT INTO LOG (ID_CAT, DATE, LOG, AMOUNT, AFLAG, RTF, STICKY) + VALUES($cat, '$date', '$log', $am, $af, $rtf, $sticky); + ); + print "\n###$stm\n" if $DEBUG; + + $st = $db->prepare($stm); + $st->execute(); + if($rtf){ #Update 0 ground NOTES entry to the just inserted log. - - #last_insert_id() -> Not reliable commented out. - #my $gzero = $db->last_insert_id();#//$db->prepare('SELECT last_insert_rowid();'); - $st->finish(); + $st = $db->prepare('SELECT ID FROM VW_LOG LIMIT 1;'); $st -> execute(); my @lid = $st->fetchrow_array(); @@ -984,7 +996,7 @@ sub processSubmit { my @gzero = $st->fetchrow_array(); - if(scalar @lid > 0 && scalar @gzero > 0){ + if(scalar @lid > 0){ #By Notes.LID contraint, there should NOT be an already existing log rowid entry just submitted in the Notes table! #What happened? We must check and delete, regardles. As data is renumerated and shuffled from perl in database. :( $st = $db->prepare("SELECT LID FROM NOTES WHERE LID = '$lid[0]';"); @@ -1042,7 +1054,17 @@ sub processSubmit { } } catch { + + + print "ERROR -> " . $_; + +print qq( +
    +Reached2! -> $cat, $date, $log, $am, $af, $rtf, $sticky
    +
    param('sss_vc')||$sss->param('sss_xc'); + my $vmode = "[View Mode] " if &isInViewMode; if($REC_LIMIT == 0){ @@ -1256,7 +1278,10 @@ sub authenticate { $TH_CSS = "main_earth.css"; $BGCOL = 'green'; } + } + sub isInViewMode { + return $sss->param('sss_vc') || $sss->param('sss_xc'); }