From: wbudic Date: Thu, 30 Aug 2018 05:43:44 +0000 (+1000) Subject: Implemented Updating, editing records, and provided row background colours. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=12869f6bccfa2ca26c81c76d9e48a4f7866dd25a;p=LifeLog.git Implemented Updating, editing records, and provided row background colours. --- diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 33fe7c5..1a01b15 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -34,6 +34,7 @@ my $rv; my $today = DateTime->now; $today->set_time_zone( 'Australia/Sydney' ); + my $sth = $dbh->prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='LOG';"); $sth->execute(); @@ -117,14 +118,21 @@ if($rv < 0) { print "

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

"; } - +my $tfId = 1; while(my @row = $sth->fetchrow_array()) { my $ct = $hshCats{@row[1]}; my $dt = DateTime::Format::SQLite->parse_datetime( $row[2] ); - - $tbl = $tbl . ''. $dt->ymd . '' . + + if($tfId==1){ + $tfId = 0; + }else{ + $tfId = 1; + } + + $tbl = $tbl . ''. + $dt->ymd . '' . '' . $dt->hms . "" . '' . $row[3] . "". '' . $ct . ' @@ -170,9 +178,13 @@ sub processSubmit { my $cat = $q->param('cat'); my $edit_mode = $q->param('submit_is_edit'); - if($edit_mode == "1"){ - print "

Sorry Editing Not Implemented Yet

"; - return; + if($edit_mode != "0"){ + #Update + + my $stm = "UPDATE LOG SET ID_CAT='".$cat."', DATE='".$date ."' , LOG='".$log."' WHERE rowid=".$edit_mode.";"; + my $sth = $dbh->prepare($stm); + $sth->execute(); + return; } if($log && $date && $cat){ diff --git a/htdocs/cgi-bin/wsrc/.main.css.swp b/htdocs/cgi-bin/wsrc/.main.css.swp deleted file mode 100644 index 9c0e07b..0000000 Binary files a/htdocs/cgi-bin/wsrc/.main.css.swp and /dev/null differ diff --git a/htdocs/cgi-bin/wsrc/.main.js.swp b/htdocs/cgi-bin/wsrc/.main.js.swp deleted file mode 100644 index 23820d5..0000000 Binary files a/htdocs/cgi-bin/wsrc/.main.js.swp and /dev/null differ diff --git a/htdocs/cgi-bin/wsrc/main.css b/htdocs/cgi-bin/wsrc/main.css index 41b1dde..bb0dd1d 100644 --- a/htdocs/cgi-bin/wsrc/main.css +++ b/htdocs/cgi-bin/wsrc/main.css @@ -21,7 +21,17 @@ table, th, td{ .tbl { border: 1px solid black; + background-color: #e6fff2; } + +#r0{ + background-color: #e6ffff; +} + +#r1{ + background-color: #ccffff; +} + .entry, th, td{ width: 660px; border: 0px; diff --git a/htdocs/cgi-bin/wsrc/main.js b/htdocs/cgi-bin/wsrc/main.js index faa7505..4f83a2a 100644 --- a/htdocs/cgi-bin/wsrc/main.js +++ b/htdocs/cgi-bin/wsrc/main.js @@ -53,7 +53,7 @@ function edit(el){ break; } } - document.getElementById("submit_is_edit").value = "1"; + document.getElementById("submit_is_edit").value = row; return false; }