From eb44dcc1be260d1710ec6055a664fd97eebc5c37 Mon Sep 17 00:00:00 2001 From: Metabox Date: Wed, 24 Apr 2019 17:18:36 +1000 Subject: [PATCH] Accounting now on changed category list. --- htdocs/cgi-bin/login_ctr.cgi | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/htdocs/cgi-bin/login_ctr.cgi b/htdocs/cgi-bin/login_ctr.cgi index 359e7ef..a78298c 100755 --- a/htdocs/cgi-bin/login_ctr.cgi +++ b/htdocs/cgi-bin/login_ctr.cgi @@ -147,18 +147,16 @@ try{ ); ); $rv = $db->do($stmt); - - $st = $db->prepare('INSERT INTO CAT VALUES (?,?,?)'); - $st->execute(1,"Unspecified", "For quick uncategorised entries."); - $st->execute(3,"File System", "Operating file system short log."); - $st->execute(6,"System Log", "Operating system important log."); - $st->execute(9,"Event", "Event that occured, meeting, historically important."); - $st->execute(28,"Personal", "Personal log of historical importants, diary type."); - $st->execute(32, "Expense", "Significant yearly expense."); - $st->execute(35, "Income", "Significant yearly income."); - $st->execute(40, "Work", "Work related entry, worth monitoring."); - $st->execute(45, "Food", "Quick reference to recepies, observations."); + insertDefCats($db); } + #Have cats been wiped out? + $st = $db->prepare('SELECT count(ID) FROM CAT;'); + $st->execute(); + if($st->fetchrow_array()==0) { + insertDefCats($db); + } + + $st = $db->prepare(selSQLTbl('AUTH')); $st->execute(); if(!$st->fetchrow_array()) { @@ -215,6 +213,21 @@ sub selSQLTbl{ return "SELECT name FROM sqlite_master WHERE type='table' AND name='$name';" } +sub insertDefCats{ + my + $st = $_[0]->prepare('INSERT INTO CAT VALUES (?,?,?)'); + $st->execute(1,"Unspecified", "For quick uncategorised entries."); + $st->execute(3,"File System", "Operating file system short log."); + $st->execute(6,"System Log", "Operating system important log."); + $st->execute(9,"Event", "Event that occured, meeting, historically important."); + $st->execute(28,"Personal", "Personal log of historical importants, diary type."); + $st->execute(32, "Expense", "Significant yearly expense."); + $st->execute(35, "Income", "Significant yearly income."); + $st->execute(40, "Work", "Work related entry, worth monitoring."); + $st->execute(45, "Food", "Quick reference to recepies, observations."); + $st->finish(); +} + sub populateConfig{ my $db = shift; my $st = $db->prepare('INSERT INTO CONFIG VALUES (?,?,?)'); -- 2.34.1