From a5817d6ad75ead63a982dc4f6ec19f0a3fd5e066 Mon Sep 17 00:00:00 2001 From: wbudic Date: Wed, 22 Aug 2018 16:00:03 +1000 Subject: [PATCH] added remove.cgi --- htdocs/cgi-bin/main.cgi | 9 +-- htdocs/cgi-bin/remove.cgi | 117 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 4 deletions(-) create mode 100755 htdocs/cgi-bin/remove.cgi diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 365faa8..202138a 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -101,11 +101,12 @@ my %hshCats; $cats = $cats.''; -my $tbl = '
'; +my $tbl = ' +
DateTimeLogCategoryDel
'; my $tbl_rc = 0; ################################## -&processSubmit($q, %hshCats); +&processSubmit; ################################## #Fetch entries! @@ -126,7 +127,7 @@ if($rv < 0) { $tbl = $tbl . "" . "" . "". "\n"; + "\n"; $tbl_rc +=1; } @@ -139,7 +140,7 @@ if($rv < 0) { my $frm = qq(
DateTimeLogCategoryDel
". $dt->ymd . "" . $dt->hms . "" . $row[3] . "" . $ct . - "
- + diff --git a/htdocs/cgi-bin/remove.cgi b/htdocs/cgi-bin/remove.cgi new file mode 100755 index 0000000..2ac56f0 --- /dev/null +++ b/htdocs/cgi-bin/remove.cgi @@ -0,0 +1,117 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use CGI; +use DBI; + +use DateTime; +use DateTime::Format::SQLite; + +my $q = CGI->new; + +my $driver = "SQLite"; +my $database = "../../dbLifeLog/data_log.db"; +my $dsn = "DBI:$driver:dbname=$database"; +my $userid = ""; +my $password = ""; +my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) + or die "

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

"; + + + +print $q->header(-expires=>"+6os"); + +print $q->start_html(-title => "Personal Log Record Removal", + -script=>{-type => 'text/javascript', -src => 'wsrc/main.js'}, + -style =>{-type => 'text/css', -src => 'wsrc/main.css'} + + ); + + +my $today = DateTime->now; +$today->set_time_zone( 'Australia/Sydney' ); + +my $stmtCat = "SELECT * FROM CAT;"; + + +$sth = $dbh->prepare( $stmtCat ); +my $rv = $sth->execute() or die or die "

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

"; + +my %hshCats; + + while(my @row = $sth->fetchrow_array()) { + $hshCats{$row[0]} = $row[1]; + } + + +my $stmS = "SELECT rowid, ID_CAT, DATE, LOG from LOG WHERE"; +my $stmE = " ORDER BY rowid DESC, DATE DESC;"; +my $tbl = '
Datehms . qq(">Date:hms . qq(">Category:
Log: ).$cats.qq(
'; +my $confirmed = $q->param('confirmed'); +if (!$confirmed){ + &NotConfirmed; +} +else{ + &ConfirmedDelition; +} + +print $q->end_html; +$dbh->disconnect(); + +sub NotConfirmed{ +#Get prms and build confirm table and check + +### TODO + +#Fetch entries! +# +$sth = $dbh->prepare( $stmt ); +$rv = $sth->execute() or die or die "

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

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

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

"; +} + + + + while(my @row = $sth->fetchrow_array()) { + + my $ct = $hshCats{@row[1]}; + my $dt = DateTime::Format::SQLite->parse_datetime( $row[2] ); + + $tbl = $tbl . "" . + "" . "". + "\n"; + $tbl_rc +=1; + } + + if($tbl_rc==1){ + $tbl = $tbl . "\n"; + } + $tbl = $tbl . ""; + $tbl = $tbl . "
DateTimeLogCategoryDel
". $dt->ymd . "" . $dt->hms . "" . $row[3] . "" . $ct . + "
Table is Empty!
"; + +my $frm = qq( +
+ + + + + + +
Datehms . qq(">
Log: ).$cats.qq(
+
+ ); + + + +print "
\n" . $frm ."
"; +print "
\n" . $tbl ."
"; +} + +sub ConfirmedDelition{ +#### TODO +} + -- 2.34.1