]> mj.ucw.cz Git - pciids.git/commitdiff
Update to admin interface
authorMichal Vaner <vorner@ucw.cz>
Sun, 26 Oct 2008 19:47:04 +0000 (20:47 +0100)
committerMichal Vaner <vorner@ucw.cz>
Sun, 26 Oct 2008 19:47:04 +0000 (20:47 +0100)
* List whole history of an item
* Put the select boxes only to items with names

PciIds/DBQ.pm
PciIds/Html/Admin.pm

index ac476107ddc89b9c80ba63bd09d48da16ea7cd53..10657970ed2e105feb1edf5d4ef8c7b191635370 100644 (file)
@@ -21,15 +21,16 @@ use strict;
 use warnings;
 use base 'PciIds::DBQAny';
 
-my $adminDumpSql = 'SELECT
+my $adminDumpSql = 'SELECT DISTINCT
                        locations.id, locations.name, locations.note, locations.mainhistory, musers.email, musers.login, main.discussion, main.time,
-                       history.id, history.discussion, history.nodename, history.nodenote, users.email, users.login, history.time
+                       history.id, history.discussion, history.nodename, history.nodenote, users.email, users.login, history.time, history.seen
                FROM
                        locations INNER JOIN history ON history.location = locations.id
                        LEFT OUTER JOIN users ON history.owner = users.id
                        LEFT OUTER JOIN history AS main ON locations.mainhistory = main.id
                        LEFT OUTER JOIN users AS musers ON main.owner = musers.id
-               WHERE history.seen = "0" AND locations.id LIKE ?
+                       LEFT OUTER JOIN history AS test ON test.location = locations.id
+               WHERE test.seen = "0" AND locations.id LIKE ?
                ORDER BY locations.id, history.id
                LIMIT ';
 
index 7b73cb4dff2a987fc428d0982cd86a4db8497160..31833f2e82e2faea01d8f130aa8c4eb7d61fb623 100644 (file)
@@ -47,7 +47,11 @@ sub mailEncode( $$ ) {
 sub genHist( $$$$$$$$$$$ ) {
        my( $class, $email, $login, $time, $name, $note, $disc, $selname, $selvalue, $delname, $delvalue ) = @_;
        print "<tr class='$class'>";
-       print "<td class='selects'><input type='radio' name='$selname' value='$selvalue'>\n";
+       if( defined $selname ) {
+               print "<td class='selects'><input type='radio' name='$selname' value='$selvalue'>\n";
+       } else {
+               print "<td class='empty'>\n";
+       }
        if( defined $delname ) {
                print "<td class='deletes'><input type='checkbox' name='$delname' value='$delvalue'>\n";
        } else {
@@ -155,7 +159,7 @@ function answer( id ) {
        print "// --></script>";
        foreach( @{$tables->adminDump( $prefix, $limit )} ) {
                my( $locId, $actName, $actNote, $actHist, $actEmail, $actLogin, $actDisc, $actTime,
-                       $hist, $disc, $name, $note, $email, $login, $time ) = @{$_};
+                       $hist, $disc, $name, $note, $email, $login, $time, $seen ) = @{$_};
                if( !defined( $lastId ) || ( $lastId ne $locId ) ) {
                        last if( $hiscnt > ( defined $limit ? $limit : 80 ) );
                        $lastId = $locId;
@@ -186,15 +190,17 @@ function answer( id ) {
                        print "<td class='path' colspan='2'>";
                        genPathBare( $req, $addr, 1, 0, $tables );
                        print "<input type='hidden' name='loc-$cnt' value='$locId'>";
-                       if( defined $actHist ) {
-                               genHist( 'main-history', $actEmail, $actLogin, $actTime, $actName, $actNote, $actDisc, "loc-$cnt-sel", 'seen', undef, undef );
-                       } else {
+                       if( !defined $actHist ) {
                                print "<tr class='main-history'><td><input type='radio' name='loc-$cnt-sel' value='seen'>";
                        }
                }
                $hiscnt ++;
                $subcnt ++;
-               genHist( 'unseen-history', $email, $login, $time, $name, $note, $disc, "loc-$cnt-sel", $hist, "del-$hiscnt", "del-$hist" );
+               if( $hist eq $actHist ) {
+                       genHist( 'main-history', $actEmail, $actLogin, $actTime, $actName, $actNote, $actDisc, "loc-$cnt-sel", 'seen', undef, undef );
+               } else {
+                       genHist( $seen ? 'history' : 'unseen-history', $email, $login, $time, $name, $note, $disc, ( defined $name && $name ne '' ) ? "loc-$cnt-sel" : undef, $hist, "del-$hiscnt", "del-$hist" );
+               }
                print "<input type='hidden' name='owner-$hist' value='$locId'>";
                print "<input type='hidden' name='his-$cnt-$subcnt' value='$hist'>";
        }