]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Accounting now on changed category list.
authorMetabox <redacted>
Wed, 24 Apr 2019 07:18:36 +0000 (17:18 +1000)
committerMetabox <redacted>
Wed, 24 Apr 2019 07:18:36 +0000 (17:18 +1000)
htdocs/cgi-bin/login_ctr.cgi

index 359e7efbd63f235106553928a677cbebe86f6031..a78298cd8a2a55382e86693dc566a4892cb04c2d 100755 (executable)
@@ -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 (?,?,?)');