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

(-)a/C4/Utils/DataTables/VirtualShelves.pm (-3 / +1 lines)
Lines 32-37 sub search { Link Here
32
    # But the code is too dirty to refactor...
32
    # But the code is too dirty to refactor...
33
    my $select = q|
33
    my $select = q|
34
        SELECT vs.shelfnumber, vs.shelfname, vs.owner, vs.category AS type,
34
        SELECT vs.shelfnumber, vs.shelfname, vs.owner, vs.category AS type,
35
        vs.creation_time, vs.lastmodified as modification_time,
35
        bo.surname, bo.firstname, vs.sortfield as sortby,
36
        bo.surname, bo.firstname, vs.sortfield as sortby,
36
        count(vc.biblionumber) as count
37
        count(vc.biblionumber) as count
37
    |;
38
    |;
Lines 65-73 sub search { Link Here
65
        push @args, "%$shelfname%";
66
        push @args, "%$shelfname%";
66
    }
67
    }
67
    if ( defined $owner and $owner ne '' ) {
68
    if ( defined $owner and $owner ne '' ) {
68
        #push @where_strs, 'owner LIKE ?';
69
        #push @args, "$owner%";
70
        # WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?);
71
        push @where_strs, '( bo.firstname LIKE ? OR bo.surname LIKE ? )';
69
        push @where_strs, '( bo.firstname LIKE ? OR bo.surname LIKE ? )';
72
        push @args, "%$owner%", "%$owner%";
70
        push @args, "%$owner%", "%$owner%";
73
    }
71
    }
(-)a/C4/VirtualShelves.pm (-5 / +6 lines)
Lines 317-325 sub AddShelf { Link Here
317
317
318
    return -1 unless _CheckShelfName($hashref->{shelfname}, $hashref->{category}, $owner, 0);
318
    return -1 unless _CheckShelfName($hashref->{shelfname}, $hashref->{category}, $owner, 0);
319
319
320
    my $query = qq(INSERT INTO virtualshelves
320
    my $query = q|INSERT INTO virtualshelves
321
        (shelfname,owner,category,sortfield,allow_add,allow_delete_own,allow_delete_other)
321
        (shelfname,owner,category,sortfield,allow_add,allow_delete_own,allow_delete_other, creation_time)
322
        VALUES (?,?,?,?,?,?,?));
322
        VALUES (?,?,?,?,?,?,?, NOW())
323
    |;
323
324
324
    my $sth = $dbh->prepare($query);
325
    my $sth = $dbh->prepare($query);
325
    $sth->execute(
326
    $sth->execute(
Lines 470-482 sub ShelfPossibleAction { Link Here
470
    }
471
    }
471
472
472
    my $dbh = C4::Context->dbh;
473
    my $dbh = C4::Context->dbh;
473
    my $query = qq/
474
    my $query = q{
474
        SELECT COALESCE(owner,0) AS owner, category, allow_add, allow_delete_own, allow_delete_other, COALESCE(sh.borrowernumber,0) AS borrowernumber
475
        SELECT COALESCE(owner,0) AS owner, category, allow_add, allow_delete_own, allow_delete_other, COALESCE(sh.borrowernumber,0) AS borrowernumber
475
        FROM virtualshelves vs
476
        FROM virtualshelves vs
476
        LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
477
        LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
477
        AND sh.borrowernumber=?
478
        AND sh.borrowernumber=?
478
        WHERE vs.shelfnumber=?
479
        WHERE vs.shelfnumber=?
479
    /;
480
        };
480
    my $sth = $dbh->prepare($query);
481
    my $sth = $dbh->prepare($query);
481
    $sth->execute($user, $shelfnumber);
482
    $sth->execute($user, $shelfnumber);
482
    my $shelf= $sth->fetchrow_hashref;
483
    my $shelf= $sth->fetchrow_hashref;
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2311-2316 CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves) Link Here
2311
  `category` varchar(1) default NULL, -- type of list (private [1], public [2])
2311
  `category` varchar(1) default NULL, -- type of list (private [1], public [2])
2312
  `sortfield` varchar(16) default NULL, -- the field this list is sorted on
2312
  `sortfield` varchar(16) default NULL, -- the field this list is sorted on
2313
  `lastmodified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time the list was last modified
2313
  `lastmodified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time the list was last modified
2314
  `creation_time` TIMESTAMP NOT NULL, -- creation time
2314
  `allow_add` tinyint(1) default 0, -- permission for adding entries to list
2315
  `allow_add` tinyint(1) default 0, -- permission for adding entries to list
2315
  `allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself
2316
  `allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself
2316
  `allow_delete_other` tinyint(1) default 0, -- permission for deleting entries from list that another person added
2317
  `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 10301-10306 if ( CheckVersion($DBversion) ) { Link Here
10301
    SetVersion ($DBversion);
10301
    SetVersion ($DBversion);
10302
}
10302
}
10303
10303
10304
$DBversion = "3.19.00.XXX";
10305
if ( CheckVersion($DBversion) ) {
10306
    $dbh->do(q|
10307
        INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES
10308
        (20, 'shelves', 'Virtual shelves', 0)
10309
    |);
10310
    $dbh->do(q|
10311
        INSERT INTO permissions (module_bit, code, description) VALUES
10312
        (20, 'manage_shelves', 'Manage shelves')
10313
    |);
10314
    print "Upgrade to $DBversion done (Bug XXXXX: Add permission for shelves)\n";
10315
    SetVersion ($DBversion);
10316
}
10317
10318
$DBversion = "3.19.00.XXX";
10319
if ( CheckVersion($DBversion) ) {
10320
    $dbh->do(q|
10321
        ALTER TABLE virtualshelves
10322
        ADD COLUMN creation_time TIMESTAMP NOT NULL AFTER lastmodified
10323
    |);
10324
    # Set creation_time = lastmodified
10325
    # I would say it's better than 0000-00-00
10326
    # Set modified to the existing value (do not get the current ts!)
10327
    $dbh->do(q|
10328
        UPDATE virtualshelves
10329
        SET creation_time = lastmodified, lastmodified = lastmodified
10330
    |);
10331
    print "Upgrade to $DBversion done (Bug XXXXX: Add DB field virtualshelves.creation_time)\n";
10332
    SetVersion ($DBversion);
10333
}
10334
10304
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10335
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10305
# SEE bug 13068
10336
# SEE bug 13068
10306
# if there is anything in the atomicupdate, read and execute it.
10337
# if there is anything in the atomicupdate, read and execute it.
(-)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 can_delete_shelf=data.can_delete_shelf type=data.type %]</a>"
24
                    "<a style=\"cursor:pointer\">[% PROCESS action_form shelfnumber=data.shelfnumber can_manage_shelf=data.can_manage_shelf can_delete_shelf=data.can_delete_shelf type=data.type %]</a>"
20
            }[% UNLESS loop.last %],[% END %]
25
            }[% UNLESS loop.last %],[% END %]
21
- 

Return to bug 13421