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

(-)a/acqui/addorder.pl (-3 / +1 lines)
Lines 32-40 It is called by : Link Here
32
32
33
=over
33
=over
34
34
35
=item neworderbiblio.pl to add an order from nothing.
35
=item neworderempty.pl to add an order from an existing record or from nothing.
36
37
=item neworderempty.pl to add an order from an existing biblio.
38
36
39
=item newordersuggestion.pl to add an order from an existing suggestion.
37
=item newordersuggestion.pl to add an order from an existing suggestion.
40
38
(-)a/acqui/neworderbiblio.pl (-163 lines)
Lines 1-163 Link Here
1
#!/usr/bin/perl
2
3
#origninally script to provide intranet (librarian) advanced search facility
4
#now script to do searching for acquisitions
5
6
# Copyright 2000-2002 Katipo Communications
7
# Copyright 2008-2009 BibLibre SARL
8
#
9
# This file is part of Koha.
10
#
11
# Koha is free software; you can redistribute it and/or modify it
12
# under the terms of the GNU General Public License as published by
13
# the Free Software Foundation; either version 3 of the License, or
14
# (at your option) any later version.
15
#
16
# Koha is distributed in the hope that it will be useful, but
17
# WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU General Public License for more details.
20
#
21
# You should have received a copy of the GNU General Public License
22
# along with Koha; if not, see <http://www.gnu.org/licenses>.
23
24
=head1 NAME
25
26
neworderbiblio.pl
27
28
=head1 DESCRIPTION
29
30
this script allows to perform a new order from an existing record.
31
32
=head1 CGI PARAMETERS
33
34
=over 4
35
36
=item search
37
the title the librarian has typed to search an existing record.
38
39
=item q
40
the keyword the librarian has typed to search an existing record.
41
42
=item author
43
the author of the new record.
44
45
=item num
46
the number of result per page to display
47
48
=item booksellerid
49
the id of the bookseller this script has to add an order.
50
51
=item basketno
52
the basket number to know on which basket this script have to add a new order.
53
54
=back
55
56
=cut
57
58
use Modern::Perl;
59
60
use C4::Search;
61
use CGI qw ( -utf8 );
62
use C4::Biblio;
63
use C4::Auth;
64
use C4::Output;
65
use C4::Koha;
66
use C4::Budgets qw/ GetBudgetHierarchy /;
67
use C4::Languages qw(getlanguage);
68
69
use Koha::Acquisition::Booksellers;
70
use Koha::SearchEngine;
71
use Koha::SearchEngine::Search;
72
use Koha::SearchEngine::QueryBuilder;
73
use Koha::Patrons;
74
75
my $input = new CGI;
76
77
#getting all CGI params into a hash.
78
my $params = $input->Vars;
79
80
my $page             = $params->{'page'} || 1;
81
my $query            = $params->{'q'};
82
my $results_per_page = $params->{'num'} || 20;
83
my $booksellerid     = $params->{'booksellerid'};
84
my $basketno         = $params->{'basketno'};
85
my $sub              = $params->{'sub'};
86
my $bookseller       = Koha::Acquisition::Booksellers->find( $booksellerid );
87
my $lang             = C4::Languages::getlanguage($input);
88
89
# getting the template
90
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
91
    {
92
        template_name   => "acqui/neworderbiblio.tt",
93
        query           => $input,
94
        type            => "intranet",
95
        authnotrequired => 0,
96
        flagsrequired   => { acquisition => 'order_manage' },
97
    }
98
);
99
100
output_and_exit( $input, $cookie, $template, 'unknown_vendor') unless $bookseller;
101
102
# Searching the catalog.
103
104
my @operands = $query;
105
my $QParser;
106
$QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
107
my $builtquery;
108
my $builder  = Koha::SearchEngine::QueryBuilder->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
109
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
110
if ($QParser) {
111
    $builtquery = $query;
112
} else {
113
        ( undef, $builtquery, undef, undef, undef, undef, undef, undef, undef, undef ) =
114
          $builder->build_query_compat( undef, \@operands, undef, undef, undef, 0, $lang );
115
}
116
my ( $error, $marcresults, $total_hits ) = $searcher->simple_search_compat($builtquery, $results_per_page * ($page - 1), $results_per_page);
117
118
if (defined $error) {
119
    $template->param(
120
        query_error => $error,
121
        basketno             => $basketno,
122
        booksellerid     => $bookseller->id,
123
        name             => $bookseller->name,
124
    );
125
    output_html_with_http_headers $input, $cookie, $template->output;
126
    exit;
127
}
128
129
my @results;
130
131
foreach my $result ( @{$marcresults} ) {
132
    my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $result );
133
    my $biblio = TransformMarcToKoha( $marcrecord, '' );
134
135
    $biblio->{booksellerid} = $booksellerid;
136
    push @results, $biblio;
137
138
}
139
140
my $patron = Koha::Patrons->find( $loggedinuser );
141
my $budgets = GetBudgetHierarchy(q{},$patron->branchcode,$patron->borrowernumber);
142
my $has_budgets = 0;
143
foreach my $r (@{$budgets}) {
144
    if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {
145
        next;
146
    }
147
    $has_budgets = 1;
148
    last;
149
}
150
151
$template->param(
152
    has_budgets          => $has_budgets,
153
    basketno             => $basketno,
154
    booksellerid         => $bookseller->id,
155
    name                 => $bookseller->name,
156
    resultsloop          => \@results,
157
    total                => $total_hits,
158
    query                => $query,
159
    pagination_bar       => pagination_bar( "/cgi-bin/koha/acqui/neworderbiblio.pl?q=$query&booksellerid=$booksellerid&basketno=$basketno&", getnbpages( $total_hits, $results_per_page ), $page, 'page' ),
160
);
161
162
# BUILD THE TEMPLATE
163
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderbiblio.tt (-139 lines)
Lines 1-138 Link Here
1
[% USE raw %]
2
[% USE Asset %]
3
[% PROCESS 'i18n.inc' %]
4
[% SET footerjs = 1 %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Acquisitions &rsaquo; Search existing records</title>
7
[% INCLUDE 'doc-head-close.inc' %]
8
</head>
9
10
<body id="acq_neworderbiblio" class="acq">
11
[% INCLUDE 'header.inc' %]
12
[% INCLUDE 'acquisitions-search.inc' %]
13
14
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | html %]">[% name | html %]</a> &rsaquo; <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno | html %]">Basket [% basketno | html %]</a> &rsaquo; Search existing records</div>
15
16
[% INCLUDE 'blocking_errors.inc' %]
17
18
<div class="main container-fluid">
19
    <div class="row">
20
        <div class="col-sm-10 col-sm-push-2">
21
            <main>
22
23
<h1>Search existing records</h1>
24
25
26
[% IF ( total ) %]
27
<b>[% total | html %] results found </b> 
28
<div class="pages">[% pagination_bar | $raw %]</div>
29
[% ELSE %]
30
<h3> No results found</h3>
31
<p>
32
    No results match your search for <span style="font-weight: bold;">&ldquo;[% query | html %]&rdquo;</span> in [% LibraryName | html %]
33
</p>
34
[% END %]
35
36
[% IF ( query_error ) %]
37
    <div class="dialog alert"><p><strong>Error:</strong> [% query_error | html %]</p></div>
38
[% END %]
39
40
[% IF ( total ) %]
41
<div class="searchresults">
42
    <table id="resultst">
43
    <thead>
44
      <tr>
45
         <th>Summary</th>
46
         <th>Publisher</th>
47
         <th>Copyright</th>
48
         <th>Actions</th>
49
      </tr>
50
    </thead>
51
    <tbody>
52
      [% FOREACH biblio IN resultsloop %]
53
        <tr>
54
            <td>
55
                <p><span class="title"><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]">[% INCLUDE 'biblio-title.inc' %]</a></span>
56
                [% IF ( biblio.author ) %]  by <span class="author">[% biblio.author | html %]</span>,[% END %]</p>
57
                <p>[% IF ( biblio.isbn ) %] [% biblio.isbn | html %][% END %]
58
                [% IF ( biblio.pages ) %] - [% biblio.pages | html %][% END %]
59
                [% IF ( biblio.notes ) %] : [% biblio.notes | html %][% END %]
60
                [% IF ( biblio.size ) %] ; [% biblio.size | html %][% END %]
61
                </p>
62
            </td>
63
            <td>
64
                [% biblio.publishercode | html %]
65
                [% IF ( biblio.place ) %] ; [% biblio.place | html %][% END %]
66
            </td>
67
            <td>
68
                [% biblio.copyrightdate | html %]
69
            </td>
70
            <td class="actions">
71
                <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblio.biblionumber | uri %]&amp;viewas=html" class="previewMARC btn btn-default btn-xs"><i class="fa fa-eye"></i> View MARC</a>
72
                <a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]&amp;biblionumber=[% biblio.biblionumber | uri %]" title="Order this one" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> [% tp('verb', 'Order') | html %]</a>
73
            </td>
74
        </tr>
75
      [% END %]
76
    </tbody>
77
    </table>
78
    <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
79
        <div class="modal-dialog modal-wide">
80
        <div class="modal-content">
81
        <div class="modal-header">
82
            <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
83
            <h3 id="marcPreviewLabel">MARC preview</h3>
84
        </div>
85
        <div class="modal-body">
86
            <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
87
        </div>
88
        <div class="modal-footer">
89
            <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
90
        </div>
91
        </div>
92
        </div>
93
    </div>
94
</div>
95
[% END %]
96
97
[% INCLUDE 'acquisitions-add-to-basket.inc' %]
98
99
</main>
100
</div> <!-- /.col-sm-10.col-sm-push-2 -->
101
102
<div class="col-sm-2 col-sm-pull-10">
103
    <aside>
104
        [% INCLUDE 'acquisitions-menu.inc' %]
105
    </aside>
106
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
107
</div> <!-- /.row -->
108
109
[% MACRO jsinclude BLOCK %]
110
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
111
    [% INCLUDE 'datatables.inc' %]
112
    [% Asset.js("js/acq.js") | $raw %]
113
    <script>
114
         $(document).ready(function() {
115
            var resultst = $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, {
116
                'sDom': 't',
117
                'bPaginate': false,
118
                'bFilter': false,
119
                'bInfo': false,
120
                'bSort': false,
121
            } ) );
122
            $(".previewMARC").on("click", function(e){
123
                e.preventDefault();
124
                var ltitle = $(this).text();
125
                var page = $(this).attr("href");
126
                $("#marcPreviewLabel").text(ltitle);
127
                $("#marcPreview .modal-body").load(page + " table");
128
                $('#marcPreview').modal({show:true});
129
            });
130
            $("#marcPreview").on("hidden.bs.modal", function(){
131
                $("#marcPreviewLabel").html("");
132
                $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
133
            });
134
         });
135
    </script>
136
[% END %]
137
138
[% INCLUDE 'intranet-bottom.inc' %]
139
- 

Return to bug 24347