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

(-)a/C4/Items.pm (-8 / +13 lines)
Lines 992-1003 sub GetItemsForInventory { Link Here
992
    my $dbh = C4::Context->dbh;
992
    my $dbh = C4::Context->dbh;
993
    my ( @bind_params, @where_strings );
993
    my ( @bind_params, @where_strings );
994
994
995
    my $query = <<'END_SQL';
995
    my $select_columns = q{
996
SELECT SQL_CALC_FOUND_ROWS items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, biblio.frameworkcode, datelastseen, homebranch, location, notforloan, damaged, itemlost, stocknumber
996
        SELECT SQL_CALC_FOUND_ROWS items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, biblio.frameworkcode, datelastseen, homebranch, location, notforloan, damaged, itemlost, stocknumber
997
FROM items
997
    };
998
  LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber
998
    my $select_count = q{SELECT COUNT(*)};
999
  LEFT JOIN biblioitems on items.biblionumber = biblioitems.biblionumber
999
    my $query = q{
1000
END_SQL
1000
        FROM items
1001
        LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber
1002
        LEFT JOIN biblioitems on items.biblionumber = biblioitems.biblionumber
1003
    };
1001
    if ($statushash){
1004
    if ($statushash){
1002
        for my $authvfield (keys %$statushash){
1005
        for my $authvfield (keys %$statushash){
1003
            if ( scalar @{$statushash->{$authvfield}} > 0 ){
1006
            if ( scalar @{$statushash->{$authvfield}} > 0 ){
Lines 1052-1065 END_SQL Link Here
1052
        $query .= join ' AND ', @where_strings;
1055
        $query .= join ' AND ', @where_strings;
1053
    }
1056
    }
1054
    $query .= ' ORDER BY items.cn_sort, itemcallnumber, title';
1057
    $query .= ' ORDER BY items.cn_sort, itemcallnumber, title';
1058
    my $count_query = $select_count . $query;
1055
    $query .= " LIMIT $offset, $size" if ($offset and $size);
1059
    $query .= " LIMIT $offset, $size" if ($offset and $size);
1060
    $query = $select_columns . $query;
1056
    my $sth = $dbh->prepare($query);
1061
    my $sth = $dbh->prepare($query);
1057
    $sth->execute( @bind_params );
1062
    $sth->execute( @bind_params );
1058
1063
1059
    my @results;
1064
    my @results;
1060
    my $tmpresults = $sth->fetchall_arrayref({});
1065
    my $tmpresults = $sth->fetchall_arrayref({});
1061
    $sth = $dbh->prepare("SELECT FOUND_ROWS()");
1066
    $sth = $dbh->prepare( $count_query );
1062
    $sth->execute();
1067
    $sth->execute( @bind_params );
1063
    my ($iTotalRecords) = $sth->fetchrow_array();
1068
    my ($iTotalRecords) = $sth->fetchrow_array();
1064
1069
1065
    foreach my $row (@$tmpresults) {
1070
    foreach my $row (@$tmpresults) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt (-11 / +12 lines)
Lines 1-3 Link Here
1
[% USE KohaDates %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Inventory</title>
3
<title>Koha &rsaquo; Tools &rsaquo; Inventory</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 16-23 $(document).ready(function(){ Link Here
16
        } ));
17
        } ));
17
18
18
19
19
    $("#continuewithoutmarkingbutton").click(function(){
20
        $("#continuewithoutmarkingbutton").click(function(){
20
                inventorydt.fnPageChange( 'next' );
21
            inventorydt.fnPageChange( 'next' );
21
            return false;
22
            return false;
22
        });
23
        });
23
24
Lines 82-88 $(document).ready(function(){ Link Here
82
    <div id="yui-main">
83
    <div id="yui-main">
83
    <div class="yui-b">
84
    <div class="yui-b">
84
    <h1>Inventory/Stocktaking</h1>
85
    <h1>Inventory/Stocktaking</h1>
85
    [% IF (moddatecount) %]<div class="dialog message">[% moddatecount %] items modified : datelastseen set to [% date %]</div>[% END %]
86
    [% IF (moddatecount) %]<div class="dialog message">[% moddatecount %] items modified : datelastseen set to [% date | $KohaDates %]</div>[% END %]
86
    [% IF (errorfile) %]<div class="dialog alert">[% errorfile %] can't be opened</div>[% END %]
87
    [% IF (errorfile) %]<div class="dialog alert">[% errorfile %] can't be opened</div>[% END %]
87
    [% FOREACH error IN errorloop %]
88
    [% FOREACH error IN errorloop %]
88
        <div class="dialog alert">
89
        <div class="dialog alert">
Lines 100-106 $(document).ready(function(){ Link Here
100
            <legend>Use a barcode file</legend>
101
            <legend>Use a barcode file</legend>
101
     <ol>
102
     <ol>
102
            <li><label for="uploadbarcodes">Barcode file: </label> <input type="file" id="uploadbarcodes" name="uploadbarcodes" /></li>
103
            <li><label for="uploadbarcodes">Barcode file: </label> <input type="file" id="uploadbarcodes" name="uploadbarcodes" /></li>
103
            <li><label for="setdate">Set inventory date to:</label> <input type="text" id="setdate" name="setdate" value="[% today %]" class="datepickerfrom" />
104
            <li><label for="setdate">Set inventory date to:</label> <input type="text" id="setdate" name="setdate" value="[% today | $KohaDates %]" class="datepickerfrom" />
104
            </li>
105
            </li>
105
          </ol>
106
          </ol>
106
        </fieldset>
107
        </fieldset>
Lines 109-118 $(document).ready(function(){ Link Here
109
        <ol><li>
110
        <ol><li>
110
        <label for="branch">Library: </label>
111
        <label for="branch">Library: </label>
111
            <input type="radio" name="branch" value="homebranch"> Home library</input>
112
            <input type="radio" name="branch" value="homebranch"> Home library</input>
112
            <input type="radio" name="branch" value="holdingbranch"> Current location</input>
113
            <input type="radio" name="branch" value="holdingbranch"> Current library</input>
113
        </li><li>
114
        </li><li>
114
        <label for="branchloop">Library: </label><select id="branchloop" name="branchcode" style="width:12em;">
115
        <label for="branchloop">Library: </label><select id="branchloop" name="branchcode" style="width:12em;">
115
            <option value="">All locations</option>
116
            <option value="">All libraries</option>
116
        [% FOREACH branchloo IN branchloop %]
117
        [% FOREACH branchloo IN branchloop %]
117
            [% IF ( branchloo.selected ) %]
118
            [% IF ( branchloo.selected ) %]
118
                <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
119
                <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
Lines 172-178 $(document).ready(function(){ Link Here
172
        [% END %]
173
        [% END %]
173
174
174
        <li><label for="datelastseen">Inventory date:</label>
175
        <li><label for="datelastseen">Inventory date:</label>
175
            <input type="text" id="datelastseen" name="datelastseen" value="[% datelastseen %]" class="datepickerfrom" />
176
            <input type="text" id="datelastseen" name="datelastseen" value="[% datelastseen | $KohaDates %]" class="datepickerfrom" />
176
        </li>
177
        </li>
177
        <li><label for="ignoreissued">Skip copies on loan: </label>
178
        <li><label for="ignoreissued">Skip copies on loan: </label>
178
            [% IF (ignoreissued) %]
179
            [% IF (ignoreissued) %]
Lines 206-218 $(document).ready(function(){ Link Here
206
    <input type="hidden" name="datelastseen" value="[% datelastseen %]" />
207
    <input type="hidden" name="datelastseen" value="[% datelastseen %]" />
207
    <input type="hidden" name="pagesize" value="[% pagesize %]" />
208
    <input type="hidden" name="pagesize" value="[% pagesize %]" />
208
    <input type="hidden" name="offset" value="[% offset %]" />
209
    <input type="hidden" name="offset" value="[% offset %]" />
209
    <div><a href="#" class="checkall">[Select All]</a> <a href="#" class="clearall">[Clear All]</a></div>
210
    <div><a href="#" class="checkall">[Select all]</a> <a href="#" class="clearall">[Clear all]</a></div>
210
    <table id="inventoryt">
211
    <table id="inventoryt">
211
    <thead>
212
    <thead>
212
        <tr>
213
        <tr>
213
            <th>Seen</th>
214
            <th>Seen</th>
214
            <th>Barcode</th>
215
            <th>Barcode</th>
215
            <th>Location</th>
216
            <th>Library</th>
216
            <th>Title</th>
217
            <th>Title</th>
217
            <th>Status</th>
218
            <th>Status</th>
218
            <th>Lost</th>
219
            <th>Lost</th>
Lines 246-252 $(document).ready(function(){ Link Here
246
            [% result.damaged | html %]
247
            [% result.damaged | html %]
247
            </td>
248
            </td>
248
            <td>
249
            <td>
249
            [% result.datelastseen | html %]
250
            [% result.datelastseen | html | $KohaDates%]
250
            </td>
251
            </td>
251
            <td>
252
            <td>
252
            [% IF (result.wrongplace) %]<p>Item should not have been scanned</p>[% ELSIF (result.missingitem) %]<p>Item missing</p>[% ELSIF (result.changestatus) %]<p>Change item status</p>[% END %]
253
            [% IF (result.wrongplace) %]<p>Item should not have been scanned</p>[% ELSIF (result.missingitem) %]<p>Item missing</p>[% ELSIF (result.changestatus) %]<p>Change item status</p>[% END %]
Lines 257-263 $(document).ready(function(){ Link Here
257
    </table>
258
    </table>
258
    <div class="spacer"></div>
259
    <div class="spacer"></div>
259
      <p style="display:block;"><span class="exportSelected"></span></p>
260
      <p style="display:block;"><span class="exportSelected"></span></p>
260
    <div style="padding : .3em 0"><a href="#" class="checkall">[Select All]</a> <a href="#" class="clearall">[Clear All]</a></div>
261
    <div style="padding : .3em 0"><a href="#" class="checkall">[Select all]</a> <a href="#" class="clearall">[Clear all]</a></div>
261
     <input type="submit" id="markseenandquit" value="Mark seen and quit" />
262
     <input type="submit" id="markseenandquit" value="Mark seen and quit" />
262
     <input type="submit" value="Mark Seen and Continue &gt;&gt;" id="markseenandcontinuebutton" />
263
     <input type="submit" value="Mark Seen and Continue &gt;&gt;" id="markseenandcontinuebutton" />
263
     <input type="submit" value="Continue without Marking &gt;&gt;" id="continuewithoutmarkingbutton" class="submit" />
264
     <input type="submit" value="Continue without Marking &gt;&gt;" id="continuewithoutmarkingbutton" class="submit" />
(-)a/tools/ajax-inventory.pl (-21 / +1 lines)
Lines 1-27 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
#
3
2
4
use Modern::Perl;
3
use Modern::Perl;
5
6
use CGI;
4
use CGI;
7
use JSON;
8
9
use C4::Auth;
5
use C4::Auth;
10
use C4::Circulation qw/CanBookBeRenewed/;
6
use C4::Items qw( ModDateLastSeen );
11
use C4::Context;
12
use C4::Koha qw/getitemtypeimagelocation/;
13
use C4::Reserves qw/CheckReserves/;
14
use C4::Utils::DataTables;
15
use C4::Output;
16
use C4::Biblio;
17
use C4::Items;
18
use C4::Dates qw/format_date format_date_in_iso/;
19
use C4::Koha;
20
use C4::Branch;    # GetBranches
21
use C4::Reports::Guided;    #_get_column_defs
22
use C4::Charset;
23
use List::MoreUtils qw /none/;
24
25
7
26
my $input = new CGI;
8
my $input = new CGI;
27
9
Lines 38-43 foreach ( @seent ) { Link Here
38
    /SEEN-(.+)/ and &ModDateLastSeen($1);
20
    /SEEN-(.+)/ and &ModDateLastSeen($1);
39
}
21
}
40
22
41
42
print $input->header('application/json');
23
print $input->header('application/json');
43
(-)a/tools/inventory.pl (-8 / +11 lines)
Lines 31-42 use C4::Context; Link Here
31
use C4::Output;
31
use C4::Output;
32
use C4::Biblio;
32
use C4::Biblio;
33
use C4::Items;
33
use C4::Items;
34
use C4::Dates qw/format_date format_date_in_iso/;
35
use C4::Koha;
34
use C4::Koha;
36
use C4::Branch; # GetBranches
35
use C4::Branch; # GetBranches
37
use C4::Circulation;
36
use C4::Circulation;
38
use C4::Reports::Guided;    #_get_column_defs
37
use C4::Reports::Guided;    #_get_column_defs
39
use C4::Charset;
38
use C4::Charset;
39
use Koha::DateUtils;
40
use List::MoreUtils qw/none/;
40
use List::MoreUtils qw/none/;
41
41
42
42
Lines 134-140 $statussth =~ s, and $,,g; Link Here
134
$template->param(
134
$template->param(
135
    branchloop               => \@branch_loop,
135
    branchloop               => \@branch_loop,
136
    authorised_values        => \@authorised_value_list,
136
    authorised_values        => \@authorised_value_list,
137
    today                    => C4::Dates->today(),
137
    today                    => dt_from_string,
138
    minlocation              => $minlocation,
138
    minlocation              => $minlocation,
139
    maxlocation              => $maxlocation,
139
    maxlocation              => $maxlocation,
140
    location                 => $location,
140
    location                 => $location,
Lines 160-166 my $barcodelist; Link Here
160
my @errorloop;
160
my @errorloop;
161
if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) {
161
if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) {
162
     my $dbh = C4::Context->dbh;
162
     my $dbh = C4::Context->dbh;
163
    my $date = format_date_in_iso( $input->param('setdate') ) || C4::Dates->today('iso');
163
    my $date = dt_from_string( $input->param('setdate') );
164
    $date = output_pref( $date, 'iso' );
164
165
165
    my $strsth  = "select * from issues, items where items.itemnumber=issues.itemnumber and items.barcode =?";
166
    my $strsth  = "select * from issues, items where items.itemnumber=issues.itemnumber and items.barcode =?";
166
    my $qonloan = $dbh->prepare($strsth);
167
    my $qonloan = $dbh->prepare($strsth);
Lines 197-203 if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) { Link Here
197
    }
198
    }
198
    $qonloan->finish;
199
    $qonloan->finish;
199
    $qwthdrawn->finish;
200
    $qwthdrawn->finish;
200
    $template->param( date => format_date($date), Number => $count );
201
    $template->param( date => $date, Number => $count );
201
    $template->param( errorloop => \@errorloop ) if (@errorloop);
202
    $template->param( errorloop => \@errorloop ) if (@errorloop);
202
203
203
204
Lines 220-226 if ( $markseen or $op ) { Link Here
220
}
221
}
221
222
222
# set "missing" flags for all items with a datelastseen before the choosen datelastseen
223
# set "missing" flags for all items with a datelastseen before the choosen datelastseen
223
foreach (@$res) { $_->{missingitem}=1 if C4::Dates->new($_->{datelastseen})->output('iso') lt C4::Dates->new($datelastseen)->output('iso'); }
224
foreach my $r ( @$res ) {
225
    $r->{missingitem} = 1
226
        if output_pref( dt_from_string( $_->{datelastseen} ), 'iso' )
227
            lt output_pref( dt_from_string( $datelastseen ), 'iso' );
228
}
224
229
225
# removing missing items from loop if "Compare barcodes list to results" has not been checked
230
# removing missing items from loop if "Compare barcodes list to results" has not been checked
226
@$res = grep {!$_->{missingitem} == 1 } @$res if (!$input->param('compareinv2barcd'));
231
@$res = grep {!$_->{missingitem} == 1 } @$res if (!$input->param('compareinv2barcd'));
Lines 254-260 foreach my $temp (@brcditems) { Link Here
254
        my $biblio = C4::Biblio::GetBiblioData($temp->{biblionumber});
259
        my $biblio = C4::Biblio::GetBiblioData($temp->{biblionumber});
255
        $temp->{title} = $biblio->{title};
260
        $temp->{title} = $biblio->{title};
256
        $temp->{author} = $biblio->{author};
261
        $temp->{author} = $biblio->{author};
257
        $temp->{datelastseen} = format_date($temp->{datelastseen});
258
        push @$res, $temp;
262
        push @$res, $temp;
259
263
260
    }
264
    }
Lines 264-270 foreach my $temp (@brcditems) { Link Here
264
        my $biblio = C4::Biblio::GetBiblioData($temp->{biblionumber});
268
        my $biblio = C4::Biblio::GetBiblioData($temp->{biblionumber});
265
        $temp2->{title} = $biblio->{title};
269
        $temp2->{title} = $biblio->{title};
266
        $temp2->{author} = $biblio->{author};
270
        $temp2->{author} = $biblio->{author};
267
        $temp2->{datelastseen} = format_date($temp->{datelastseen});
271
        $temp2->{datelastseen} = $temp->{datelastseen};
268
        push @$res, $temp2;
272
        push @$res, $temp2;
269
    }
273
    }
270
}
274
}
271
- 

Return to bug 7684