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

(-)a/acqui/addorderiso2709.pl (-62 / +66 lines)
Lines 4-10 Link Here
4
#the script first displays a list of import batches, then when a batch is selected displays all the biblios in it.
4
#the script first displays a list of import batches, then when a batch is selected displays all the biblios in it.
5
#The user can then pick which biblios he wants to order
5
#The user can then pick which biblios he wants to order
6
6
7
# Copyright 2008 - 2010 BibLibre SARL
7
# Copyright 2008 - 2011 BibLibre SARL
8
#
8
#
9
# This file is part of Koha.
9
# This file is part of Koha.
10
#
10
#
Lines 124-134 if ($op eq ""){ Link Here
124
    my $import_batch_id = $cgiparams->{'import_batch_id'};
124
    my $import_batch_id = $cgiparams->{'import_batch_id'};
125
    my $biblios = GetImportBibliosRange($import_batch_id);
125
    my $biblios = GetImportBibliosRange($import_batch_id);
126
    for my $biblio (@$biblios){
126
    for my $biblio (@$biblios){
127
        # 1st insert the biblio
127
        # 1st insert the biblio, or find it through matcher
128
        my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} );
128
        my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} );
129
        my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information";
129
        my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information";
130
        my ( $duplicatetitle, $biblionumber );
130
        my $match = GetImportRecordMatches( $biblio->{'import_record_id'}, 1 );
131
        if ( !( ( $biblionumber, $duplicatetitle ) = FindDuplicate($marcrecord) ) ) {
131
        my $biblionumber=$#$match > -1?$match->[0]->{'biblionumber'}:0;
132
133
        unless ( $biblionumber ) {
132
            # add the biblio
134
            # add the biblio
133
            my $bibitemnum;
135
            my $bibitemnum;
134
136
Lines 148-213 if ($op eq ""){ Link Here
148
            if (C4::Context->preference("BiblioAddsAuthorities")){
150
            if (C4::Context->preference("BiblioAddsAuthorities")){
149
                my ($countlinked,$countcreated)=BiblioAddAuthorities($marcrecord, $cgiparams->{'frameworkcode'});
151
                my ($countlinked,$countcreated)=BiblioAddAuthorities($marcrecord, $cgiparams->{'frameworkcode'});
150
            }
152
            }
151
            # 3rd add order
153
        } else {
152
            my $patron = C4::Members->GetMember(borrowernumber => $loggedinuser);
154
            SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' );
153
            my $branch = C4::Branch->GetBranchDetail($patron->{branchcode});
155
        }
154
            my ($invoice);
156
        # 3rd add order
155
            # get quantity in the MARC record (1 if none)
157
        my $patron = C4::Members->GetMember( borrowernumber => $loggedinuser );
156
            my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
158
        my $branch = C4::Branch->GetBranchDetail( $patron->{branchcode} );
157
            my %orderinfo = ("biblionumber", $biblionumber,
159
        my ($invoice);
158
                            "basketno", $cgiparams->{'basketno'},
160
        # get quantity in the MARC record (1 if none)
159
                            "quantity", $quantity,
161
        my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
160
                            "branchcode", $branch,
162
        my %orderinfo = (
161
                            "booksellerinvoicenumber", $invoice,
163
            "biblionumber", $biblionumber, "basketno", $cgiparams->{'basketno'},
162
                            "budget_id", $budget_id,
164
            "quantity", $quantity, "branchcode", $branch, 
163
                            "uncertainprice", 1,
165
            "booksellerinvoicenumber", $invoice, 
164
                            "sort1", $cgiparams->{'sort1'},
166
            "budget_id", $budget_id, "uncertainprice", 1,
165
                            "sort2", $cgiparams->{'sort2'},
167
            "sort1", $cgiparams->{'sort1'},"sort2", $cgiparams->{'sort2'},
166
                            );
168
            "notes", $cgiparams->{'notes'}, "budget_id", $cgiparams->{'budget_id'},
167
            # get the price if there is one.
169
        );
168
            # filter by storing only the 1st number
170
        # get the price if there is one.
169
            # we suppose the currency is correct, as we have no possibilities to get it.
171
        # filter by storing only the 1st number
170
            my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour'));
172
        # we suppose the currency is correct, as we have no possibilities to get it.
171
            if ($price){
173
        my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour'));
172
                $price = $num->unformat_number($price);
174
        if ($price){
173
            }
175
            $price = $num->unformat_number($price);
174
            if ($price){
176
        }
175
                $orderinfo{'listprice'} = $price;
177
        if ($price){
176
                eval "use C4::Acquisition qw/GetBasket/;";
178
            $orderinfo{'listprice'} = $price;
177
                eval "use C4::Bookseller qw/GetBookSellerFromId/;";
179
            eval "use C4::Acquisition qw/GetBasket/;";
178
                my $basket     = GetBasket( $orderinfo{basketno} );
180
            eval "use C4::Bookseller qw/GetBookSellerFromId/;";
179
                my $bookseller = GetBookSellerFromId( $basket->{booksellerid} );
181
            my $basket     = GetBasket( $orderinfo{basketno} );
180
                my $gst        = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
182
            my $bookseller = GetBookSellerFromId( $basket->{booksellerid} );
181
                $orderinfo{'unitprice'} = $orderinfo{listprice} - ( $orderinfo{listprice} * ( $bookseller->{discount} / 100 ) );
183
            my $gst        = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
182
                $orderinfo{'ecost'} = $orderinfo{unitprice};
184
            $orderinfo{'unitprice'} = $orderinfo{listprice} - ( $orderinfo{listprice} * ( $bookseller->{discount} / 100 ) );
183
            } else {
185
            $orderinfo{'ecost'} = $orderinfo{unitprice};
184
                $orderinfo{'listprice'} = 0;
186
        } else {
185
            }
187
            $orderinfo{'listprice'} = 0;
186
            $orderinfo{'rrp'} = $orderinfo{'listprice'};
188
        }
189
        $orderinfo{'rrp'} = $orderinfo{'listprice'};
187
190
188
            # remove uncertainprice flag if we have found a price in the MARC record
191
        # remove uncertainprice flag if we have found a price in the MARC record
189
            $orderinfo{uncertainprice} = 0 if $orderinfo{listprice};
192
        $orderinfo{uncertainprice} = 0 if $orderinfo{listprice};
190
            my $basketno;
193
        my $basketno;
191
            ( $basketno, $ordernumber ) = NewOrder(\%orderinfo);
194
        ( $basketno, $ordernumber ) = NewOrder( \%orderinfo );
192
195
193
            # 4th, add items if applicable
196
        # 4th, add items if applicable
194
            # parse the item sent by the form, and create an item just for the import_record_id we are dealing with
197
        # parse the item sent by the form, and create an item just for the import_record_id we are dealing with
195
            # this is not optimised, but it's working !
198
        # this is not optimised, but it's working !
196
            if (C4::Context->preference('AcqCreateItem') eq 'ordering') {
199
        if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
197
                my @tags         = $input->param('tag');
200
            my @tags         = $input->param('tag');
198
                my @subfields    = $input->param('subfield');
201
            my @subfields    = $input->param('subfield');
199
                my @field_values = $input->param('field_value');
202
            my @field_values = $input->param('field_value');
200
                my @serials      = $input->param('serial');
203
            my @serials      = $input->param('serial');
201
                my @ind_tag      = $input->param('ind_tag');
204
            my @ind_tag   = $input->param('ind_tag');
202
                my @indicator    = $input->param('indicator');
205
            my @indicator = $input->param('indicator');
203
                my $item;
206
            my $item;
204
                push @{ $item->{tags} },         $tags[0];
207
            push @{ $item->{tags} },         $tags[0];
205
                push @{ $item->{subfields} },    $subfields[0];
208
            push @{ $item->{subfields} },    $subfields[0];
206
                push @{ $item->{field_values} }, $field_values[0];
209
            push @{ $item->{field_values} }, $field_values[0];
207
                push @{ $item->{ind_tag} },      $ind_tag[0];
210
            push @{ $item->{ind_tag} },      $ind_tag[0];
208
                push @{ $item->{indicator} },    $indicator[0];
211
            push @{ $item->{indicator} },    $indicator[0];
209
                my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values, \@ind_tag, \@indicator );
212
            my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values, \@ind_tag, \@indicator );
210
                my $record = MARC::Record::new_from_xml( $xml, 'UTF-8' );
213
            my $record = MARC::Record::new_from_xml( $xml, 'UTF-8' );
214
            for (my $qtyloop=1;$qtyloop <=$quantity;$qtyloop++) {
211
                my ( $biblionumber, $bibitemnum, $itemnumber ) = AddItemFromMarc( $record, $biblionumber );
215
                my ( $biblionumber, $bibitemnum, $itemnumber ) = AddItemFromMarc( $record, $biblionumber );
212
                NewOrderItem( $itemnumber, $ordernumber );
216
                NewOrderItem( $itemnumber, $ordernumber );
213
            }
217
            }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tmpl (-3 / +9 lines)
Lines 38-43 Link Here
38
                     <table>
38
                     <table>
39
                     <tr>
39
                     <tr>
40
                         <th>Citation</th>
40
                         <th>Citation</th>
41
                         <th>Match?</th>
41
                         <th>Order</th>
42
                         <th>Order</th>
42
                       </tr>
43
                       </tr>
43
                       <!-- TMPL_LOOP name="biblio_list" -->
44
                       <!-- TMPL_LOOP name="biblio_list" -->
Lines 46-54 Link Here
46
                                <!-- TMPL_VAR name="citation"-->
47
                                <!-- TMPL_VAR name="citation"-->
47
48
48
                             </td>
49
                             </td>
49
                             <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=<!--TMPL_VAR name="booksellerid" -->&amp;basketno=<!-- TMPL_VAR name="basketno" -->&amp;booksellerid=<!-- TMPL_VAR name="booksellerid" -->&amp;breedingid=<!-- TMPL_VAR name="import_record_id" -->&amp;import_batch_id=<!-- TMPL_VAR name="import_batch_id" -->">Add order</a></td>
50
                             <td><!-- TMPL_VAR name="overlay_status"--></td>
51
                             <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=<!--TMPL_VAR name="booksellerid" -->&amp;basketno=<!-- TMPL_VAR name="basketno" -->&amp;booksellerid=<!-- TMPL_VAR name="booksellerid" -->&amp;breedingid=<!-- TMPL_VAR name="import_record_id" -->&amp;import_batch_id=<!-- TMPL_VAR name="import_batch_id" -->&amp;biblionumber=<!-- TMPL_VAR name="match_biblionumber" -->">Add order</a></td>
50
                         </tr>
52
                         </tr>
51
                       <!-- /TMPL_LOOP -->
53
     <!-- TMPL_IF name="match_biblionumber" -->
54
    <tr>
55
      <td class="highlight" colspan="3">&nbsp;&nbsp;&nbsp;Matches biblio <!-- TMPL_VAR name="match_biblionumber" --> (score = <!-- TMPL_VAR name="match_score" -->): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR name="match_biblionumber" -->"><!-- TMPL_VAR name="match_citation" --></a></td>
56
    </tr>
57
    <!-- /TMPL_IF -->
58
                      <!-- /TMPL_LOOP -->
52
                     </table>
59
                     </table>
53
                   </form>
60
                   </form>
54
               </div>
61
               </div>
55
- 

Return to bug 5961