View | Details | Raw Unified | Return to bug 13421
Collapse All | Expand All

(-)a/C4/Utils/DataTables/VirtualShelves.pm (-3 / +1 lines)
Lines 31-36 sub search { Link Here
31
    # But the code is too dirty to refactor...
31
    # But the code is too dirty to refactor...
32
    my $select = q|
32
    my $select = q|
33
        SELECT vs.shelfnumber, vs.shelfname, vs.owner, vs.category AS type,
33
        SELECT vs.shelfnumber, vs.shelfname, vs.owner, vs.category AS type,
34
        vs.creation_time, vs.lastmodified as modification_time,
34
        bo.surname, bo.firstname, vs.sortfield as sortby,
35
        bo.surname, bo.firstname, vs.sortfield as sortby,
35
        count(vc.biblionumber) as count
36
        count(vc.biblionumber) as count
36
    |;
37
    |;
Lines 64-72 sub search { Link Here
64
        push @args, "%$shelfname%";
65
        push @args, "%$shelfname%";
65
    }
66
    }
66
    if ( defined $owner and $owner ne '' ) {
67
    if ( defined $owner and $owner ne '' ) {
67
        #push @where_strs, 'owner LIKE ?';
68
        #push @args, "$owner%";
69
        # WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?);
70
        push @where_strs, '( bo.firstname LIKE ? OR bo.surname LIKE ? )';
68
        push @where_strs, '( bo.firstname LIKE ? OR bo.surname LIKE ? )';
71
        push @args, "%$owner%", "%$owner%";
69
        push @args, "%$owner%", "%$owner%";
72
    }
70
    }
(-)a/C4/VirtualShelves.pm (-5 / +6 lines)
Lines 321-329 sub AddShelf { Link Here
321
321
322
    return -1 unless _CheckShelfName($hashref->{shelfname}, $hashref->{category}, $owner, 0);
322
    return -1 unless _CheckShelfName($hashref->{shelfname}, $hashref->{category}, $owner, 0);
323
323
324
    my $query = qq(INSERT INTO virtualshelves
324
    my $query = q|INSERT INTO virtualshelves
325
        (shelfname,owner,category,sortfield,allow_add,allow_delete_own,allow_delete_other)
325
        (shelfname,owner,category,sortfield,allow_add,allow_delete_own,allow_delete_other, creation_time)
326
        VALUES (?,?,?,?,?,?,?));
326
        VALUES (?,?,?,?,?,?,?, NOW())
327
    |;
327
328
328
    my $sth = $dbh->prepare($query);
329
    my $sth = $dbh->prepare($query);
329
    $sth->execute(
330
    $sth->execute(
Lines 467-479 sub ShelfPossibleAction { Link Here
467
    return 0 unless defined($shelfnumber);
468
    return 0 unless defined($shelfnumber);
468
469
469
    my $dbh = C4::Context->dbh;
470
    my $dbh = C4::Context->dbh;
470
    my $query = qq/
471
    my $query = q{
471
        SELECT COALESCE(owner,0) AS owner, category, allow_add, allow_delete_own, allow_delete_other, COALESCE(sh.borrowernumber,0) AS borrowernumber
472
        SELECT COALESCE(owner,0) AS owner, category, allow_add, allow_delete_own, allow_delete_other, COALESCE(sh.borrowernumber,0) AS borrowernumber
472
        FROM virtualshelves vs
473
        FROM virtualshelves vs
473
        LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
474
        LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
474
        AND sh.borrowernumber=?
475
        AND sh.borrowernumber=?
475
        WHERE vs.shelfnumber=?
476
        WHERE vs.shelfnumber=?
476
    /;
477
        };
477
    my $sth = $dbh->prepare($query);
478
    my $sth = $dbh->prepare($query);
478
    $sth->execute($user, $shelfnumber);
479
    $sth->execute($user, $shelfnumber);
479
    my $shelf= $sth->fetchrow_hashref;
480
    my $shelf= $sth->fetchrow_hashref;
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2320-2325 CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves) Link Here
2320
  `category` varchar(1) default NULL, -- type of list (private [1], public [2])
2320
  `category` varchar(1) default NULL, -- type of list (private [1], public [2])
2321
  `sortfield` varchar(16) default NULL, -- the field this list is sorted on
2321
  `sortfield` varchar(16) default NULL, -- the field this list is sorted on
2322
  `lastmodified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time the list was last modified
2322
  `lastmodified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time the list was last modified
2323
  `creation_time` TIMESTAMP NOT NULL, -- creation time
2323
  `allow_add` tinyint(1) default 0, -- permission for adding entries to list
2324
  `allow_add` tinyint(1) default 0, -- permission for adding entries to list
2324
  `allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself
2325
  `allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself
2325
  `allow_delete_other` tinyint(1) default 0, -- permission for deleting entries from list that another person added
2326
  `allow_delete_other` tinyint(1) default 0, -- permission for deleting entries from list that another person added
(-)a/installer/data/mysql/updatedatabase.pl (+31 lines)
Lines 9585-9590 if ( CheckVersion($DBversion) ) { Link Here
9585
    SetVersion ($DBversion);
9585
    SetVersion ($DBversion);
9586
}
9586
}
9587
9587
9588
$DBversion = "3.19.00.XXX";
9589
if ( CheckVersion($DBversion) ) {
9590
    $dbh->do(q|
9591
        INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES
9592
        (20, 'shelves', 'Virtual shelves', 0)
9593
    |);
9594
    $dbh->do(q|
9595
        INSERT INTO permissions (module_bit, code, description) VALUES
9596
        (20, 'manage_shelves', 'Manage shelves')
9597
    |);
9598
    print "Upgrade to $DBversion done (Bug XXXXX: Add permission for shelves)\n";
9599
    SetVersion ($DBversion);
9600
}
9601
9602
$DBversion = "3.19.00.XXX";
9603
if ( CheckVersion($DBversion) ) {
9604
    $dbh->do(q|
9605
        ALTER TABLE virtualshelves
9606
        ADD COLUMN creation_time TIMESTAMP NOT NULL AFTER lastmodified
9607
    |);
9608
    # Set creation_time = lastmodified
9609
    # I would say it's better than 0000-00-00
9610
    # Set modified to the existing value (do not get the current ts!)
9611
    $dbh->do(q|
9612
        UPDATE virtualshelves
9613
        SET creation_time = lastmodified, lastmodified = lastmodified
9614
    |);
9615
    print "Upgrade to $DBversion done (Bug XXXXX: Add DB field virtualshelves.creation_time)\n";
9616
    SetVersion ($DBversion);
9617
}
9618
9588
=head1 FUNCTIONS
9619
=head1 FUNCTIONS
9589
9620
9590
=head2 TableExists($table)
9621
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (+6 lines)
Lines 54-59 $(document).ready(function(){ Link Here
54
            { 'mDataProp': 'dt_count' },
54
            { 'mDataProp': 'dt_count' },
55
            { 'mDataProp': 'dt_owner' },
55
            { 'mDataProp': 'dt_owner' },
56
            { 'mDataProp': 'dt_sortby' },
56
            { 'mDataProp': 'dt_sortby' },
57
            { 'mDataProp': 'dt_creation_time' },
58
            { 'mDataProp': 'dt_modification_time' },
57
            { 'mDataProp': 'dt_action', 'bSortable': false }
59
            { 'mDataProp': 'dt_action', 'bSortable': false }
58
        ],
60
        ],
59
        "aoColumnDefs": [
61
        "aoColumnDefs": [
Lines 603-608 function placeHold () { Link Here
603
                        <th>Contents</th>
605
                        <th>Contents</th>
604
                        <th>Owner</th>
606
                        <th>Owner</th>
605
                        <th>Sort by</th>
607
                        <th>Sort by</th>
608
                        <th>Creation date</th>
609
                        <th>Modification date</th>
606
                        <th>Actions</th>
610
                        <th>Actions</th>
607
                    </tr>
611
                    </tr>
608
                    <tr class="filters_row">
612
                    <tr class="filters_row">
Lines 620-625 function placeHold () { Link Here
620
                            </select>
624
                            </select>
621
                        </th>
625
                        </th>
622
                        <th></th>
626
                        <th></th>
627
                        <th></th>
628
                        <th></th>
623
                    </tr>
629
                    </tr>
624
                </thead>
630
                </thead>
625
                <tbody></tbody>
631
                <tbody></tbody>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt (-1 / +5 lines)
Lines 1-3 Link Here
1
[% USE KohaDates %]
1
{
2
{
2
    "sEcho": [% sEcho %],
3
    "sEcho": [% sEcho %],
3
    "iTotalRecords": [% iTotalRecords %],
4
    "iTotalRecords": [% iTotalRecords %],
Lines 15-20 Link Here
15
                    "<a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=[% data.owner %]'>[% data.firstname %] [% data.surname %]</a>",
16
                    "<a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=[% data.owner %]'>[% data.firstname %] [% data.surname %]</a>",
16
                "dt_sortby":
17
                "dt_sortby":
17
                    [% IF data.sortby == "author" %]"Author"[% ELSIF data.sortby == "copyrightdate" %]"Year"[% ELSIF data.sortby == "itemcallnumber" %]"Call number"[% ELSE %]"Title"[% END %],
18
                    [% IF data.sortby == "author" %]"Author"[% ELSIF data.sortby == "copyrightdate" %]"Year"[% ELSIF data.sortby == "itemcallnumber" %]"Call number"[% ELSE %]"Title"[% END %],
19
                "dt_creation_time":
20
                    "[% data.creation_time | $KohaDates %]",
21
                "dt_modification_time":
22
                    "[% data.modification_time | $KohaDates %]",
18
                "dt_action":
23
                "dt_action":
19
                    "<a style=\"cursor:pointer\">[% PROCESS action_form shelfnumber=data.shelfnumber can_manage_shelf=data.can_manage_shelf %]</a>"
24
                    "<a style=\"cursor:pointer\">[% PROCESS action_form shelfnumber=data.shelfnumber can_manage_shelf=data.can_manage_shelf %]</a>"
20
            }[% UNLESS loop.last %],[% END %]
25
            }[% UNLESS loop.last %],[% END %]
21
- 

Return to bug 13421