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

(-)a/C4/Biblio.pm (+68 lines)
Lines 79-84 BEGIN { Link Here
79
      &GetUsedMarcStructure
79
      &GetUsedMarcStructure
80
      &GetXmlBiblio
80
      &GetXmlBiblio
81
      &GetCOinSBiblio
81
      &GetCOinSBiblio
82
      &GetMarcPrice
83
      &GetMarcQuantity
82
84
83
      &GetAuthorisedValueDesc
85
      &GetAuthorisedValueDesc
84
      &GetMarcStructure
86
      &GetMarcStructure
Lines 1243-1248 sub GetCOinSBiblio { Link Here
1243
    return $coins_value;
1245
    return $coins_value;
1244
}
1246
}
1245
1247
1248
1249
=head2 GetMarcPrice
1250
1251
return the prices in accordance with the Marc format.
1252
=cut
1253
1254
sub GetMarcPrice {
1255
    my ( $record, $marcflavour ) = @_;
1256
    my @listtags;
1257
    my $subfield;
1258
    
1259
    if ( $marcflavour eq "MARC21" ) {
1260
        @listtags = ('345', '020');
1261
        $subfield="c";
1262
    } elsif ( $marcflavour eq "UNIMARC" ) {
1263
        @listtags = ('345', '010');
1264
        $subfield="d";
1265
    } else {
1266
        return;
1267
    }
1268
    
1269
    for my $field ( $record->field(@listtags) ) {
1270
        for my $subfield_value  ($field->subfield($subfield)){
1271
            #check value
1272
            return $subfield_value if ($subfield_value);
1273
        }
1274
    }
1275
    return 0; # no price found
1276
}
1277
1278
=head2 GetMarcQuantity
1279
1280
return the quantity of a book. Used in acquisition only, when importing a file an iso2709 from a bookseller
1281
Warning : this is not really in the marc standard. In Unimarc, Electre (the most widely used bookseller) use the 969$a
1282
1283
=cut
1284
1285
sub GetMarcQuantity {
1286
    my ( $record, $marcflavour ) = @_;
1287
    my @listtags;
1288
    my $subfield;
1289
    
1290
    if ( $marcflavour eq "MARC21" ) {
1291
        return 0
1292
    } elsif ( $marcflavour eq "UNIMARC" ) {
1293
        @listtags = ('969');
1294
        $subfield="a";
1295
    } else {
1296
        return;
1297
    }
1298
    
1299
    for my $field ( $record->field(@listtags) ) {
1300
        for my $subfield_value  ($field->subfield($subfield)){
1301
            #check value
1302
            if ($subfield_value) {
1303
                 # in France, the cents separator is the , but sometimes, ppl use a .
1304
                 # in this case, the price will be x100 when unformatted ! Replace the . by a , to get a proper price calculation
1305
                $subfield_value =~ s/\./,/ if C4::Context->preference("CurrencyFormat") eq "FR";
1306
                return $subfield_value;
1307
            }
1308
        }
1309
    }
1310
    return 0; # no price found
1311
}
1312
1313
1246
=head2 GetAuthorisedValueDesc
1314
=head2 GetAuthorisedValueDesc
1247
1315
1248
  my $subfieldvalue =get_authorised_value_desc(
1316
  my $subfieldvalue =get_authorised_value_desc(
(-)a/acqui/addorderiso2709.pl (-155 / +217 lines)
Lines 3-11 Link Here
3
#A script that lets the user populate a basket from an iso2709 file
3
#A script that lets the user populate a basket from an iso2709 file
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
#written by john.soros@biblibre.com 01/12/2008
7
6
8
# Copyright 2008 - 2009 BibLibre SARL
7
# Copyright 2008 - 2011 BibLibre SARL
9
#
8
#
10
# This file is part of Koha.
9
# This file is part of Koha.
11
#
10
#
Lines 25-44 Link Here
25
use strict;
24
use strict;
26
use warnings;
25
use warnings;
27
use CGI;
26
use CGI;
27
use Number::Format qw(:all);
28
28
use C4::Context;
29
use C4::Context;
29
use C4::Auth;
30
use C4::Auth;
30
use C4::Input;
31
use C4::Input;
31
use C4::Output;
32
use C4::Output;
32
use C4::ImportBatch qw/GetImportBatchRangeDesc GetNumberOfNonZ3950ImportBatches GetImportRecordMatches GetImportBibliosRange GetImportBatchOverlayAction GetImportBatchNoMatchAction GetImportBatchItemAction GetImportRecordMarc GetImportBatch/;
33
use C4::ImportBatch;
33
use C4::Matcher;
34
use C4::Matcher;
34
use C4::Search qw/FindDuplicate BiblioAddAuthorities/;
35
use C4::Search qw/FindDuplicate BiblioAddAuthorities/;
35
use C4::Acquisition qw/NewOrder/;
36
use C4::Acquisition;
36
use C4::Biblio;
37
use C4::Biblio;
37
use C4::Items;
38
use C4::Items;
38
use C4::Koha qw/GetItemTypes/;
39
use C4::Koha;
39
use C4::Budgets qw/GetBudgets/;
40
use C4::Budgets;
40
use C4::Acquisition qw/NewOrderItem GetBasket/;
41
use C4::Acquisition;
41
use C4::Bookseller qw/GetBookSellerFromId/;
42
use C4::Bookseller qw/GetBookSellerFromId/;
43
use C4::Dates;
44
use C4::Suggestions;    # GetSuggestion
45
use C4::Branch;         # GetBranches
46
use C4::Members;
42
47
43
my $input = new CGI;
48
my $input = new CGI;
44
my ($template, $loggedinuser, $cookie) = get_template_and_user({
49
my ($template, $loggedinuser, $cookie) = get_template_and_user({
Lines 53-58 my $cgiparams = $input->Vars; Link Here
53
my $op = $cgiparams->{'op'};
58
my $op = $cgiparams->{'op'};
54
my $booksellerid  = $input->param('booksellerid');
59
my $booksellerid  = $input->param('booksellerid');
55
my $bookseller = GetBookSellerFromId($booksellerid);
60
my $bookseller = GetBookSellerFromId($booksellerid);
61
my $data;
56
62
57
$template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl",
63
$template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl",
58
                booksellerid => $booksellerid,
64
                booksellerid => $booksellerid,
Lines 69-85 if (! $cgiparams->{'basketno'}){ Link Here
69
    die "Basketnumber required to order from iso2709 file import";
75
    die "Basketnumber required to order from iso2709 file import";
70
}
76
}
71
77
78
#
79
# 1st step = choose the file to import into acquisition
80
#
72
if ($op eq ""){
81
if ($op eq ""){
73
    $template->param("basketno" => $cgiparams->{'basketno'});
82
    $template->param("basketno" => $cgiparams->{'basketno'});
74
#display batches
83
#display batches
75
    import_batches_list($template);
84
    import_batches_list($template);
85
#
86
# 2nd step = display the content of the choosen file
87
#
76
} elsif ($op eq "batch_details"){
88
} elsif ($op eq "batch_details"){
77
#display lines inside the selected batch
89
#display lines inside the selected batch
90
    # get currencies (for change rates calcs if needed)
91
    my $active_currency = GetCurrency();
92
    my $default_currency;
93
    if (! $data->{currency} ) { # New order no currency set
94
        if ( $bookseller->{listprice} ) {
95
            $default_currency = $bookseller->{listprice};
96
        }
97
        else {
98
            $default_currency = $active_currency->{currency};
99
        }
100
    }
101
    my @rates = GetCurrencies();
102
103
    # ## @rates
104
105
    my @loop_currency = ();
106
    for my $curr ( @rates ) {
107
        my $selected;
108
        if ($data->{currency} ) {
109
            $selected = $curr->{currency} eq $data->{currency};
110
        }
111
        else {
112
            $selected = $curr->{currency} eq $default_currency;
113
        }
114
        push @loop_currency, {
115
            currcode => $curr->{currency},
116
            rate     => $curr->{rate},
117
            selected => $selected,
118
        }
119
    }
120
78
    $template->param("batch_details" => 1,
121
    $template->param("batch_details" => 1,
79
                     "basketno"      => $cgiparams->{'basketno'});
122
                     "basketno"      => $cgiparams->{'basketno'},
123
                     loop_currencies  => \@loop_currency,
124
                     );
80
    import_biblios_list($template, $cgiparams->{'import_batch_id'});
125
    import_biblios_list($template, $cgiparams->{'import_batch_id'});
81
    
126
    if ( C4::Context->preference('AcqCreateItem') eq 'ordering' && !$ordernumber ) {
82
} elsif ($op eq 'import_records'){
127
        # prepare empty item form
128
        my $cell = PrepareItemrecordDisplay( '', '', '', 'ACQ' );
129
130
        #     warn "==> ".Data::Dumper::Dumper($cell);
131
        unless ($cell) {
132
            $cell = PrepareItemrecordDisplay( '', '', '', '' );
133
            $template->param( 'NoACQframework' => 1 );
134
        }
135
        my @itemloop;
136
        push @itemloop, $cell;
137
138
        $template->param( items => \@itemloop );
139
    }
140
#
141
# 3rd step = import the records
142
#
143
} elsif ( $op eq 'import_records' ) {
144
    my $num=FormatNumber();
83
#import selected lines
145
#import selected lines
84
    $template->param('basketno' => $cgiparams->{'basketno'});
146
    $template->param('basketno' => $cgiparams->{'basketno'});
85
# Budget_id is mandatory for adding an order, we just add a default, the user needs to modify this aftewards
147
# Budget_id is mandatory for adding an order, we just add a default, the user needs to modify this aftewards
Lines 95-235 if ($op eq ""){ Link Here
95
    my $import_batch_id = $cgiparams->{'import_batch_id'};
157
    my $import_batch_id = $cgiparams->{'import_batch_id'};
96
    my $biblios = GetImportBibliosRange($import_batch_id);
158
    my $biblios = GetImportBibliosRange($import_batch_id);
97
    for my $biblio (@$biblios){
159
    for my $biblio (@$biblios){
98
        if($cgiparams->{'order-'.$biblio->{'import_record_id'}}){
160
        # 1st insert the biblio, or find it through matcher
99
            my ($marcblob, $encoding) = GetImportRecordMarc($biblio->{'import_record_id'});
161
        my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} );
100
            my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information";
162
        my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information";
101
            my ($duplicatetitle, $biblionumber);
163
        my $match = GetImportRecordMatches( $biblio->{'import_record_id'}, 1 );
102
            if(!(($biblionumber,$duplicatetitle) = FindDuplicate($marcrecord))){
164
        my $biblionumber=$#$match > -1?$match->[0]->{'biblionumber'}:0;
103
#FIXME: missing: marc21 support (should be same with different field)
165
104
                if ( C4::Context->preference("marcflavour") eq 'UNIMARC' ) {
166
        unless ( $biblionumber ) {
105
                    my $itemtypeid = "itemtype-" . $biblio->{'import_record_id'};
167
            # add the biblio
106
                    $marcrecord->field(200)->update("b" => $cgiparams->{$itemtypeid});
168
            my $bibitemnum;
107
                }
169
108
                # add the biblio
170
            # remove ISBN -
109
                my $bibitemnum;
171
            my ( $isbnfield, $isbnsubfield ) = GetMarcFromKohaField( 'biblioitems.isbn', '' );                
110
                # remove ISBN -
172
            if ( $marcrecord->field($isbnfield) ) {
111
                my ($isbnfield,$isbnsubfield) = GetMarcFromKohaField('biblioitems.isbn','');
173
                foreach my $field ( $marcrecord->field($isbnfield) ) {
112
                if ( $marcrecord->field($isbnfield) ) {
174
                    foreach my $subfield ( $field->subfield($isbnsubfield) ) {
113
                    foreach my $field ( $marcrecord->field($isbnfield) ) {
175
                        my $newisbn = $field->subfield($isbnsubfield);
114
                        foreach my $subfield ( $field->subfield($isbnsubfield) ) {
176
                        $newisbn =~ s/-//g;
115
                            my $newisbn = $field->subfield($isbnsubfield);
177
                        $field->update( $isbnsubfield => $newisbn );
116
                            $newisbn =~ s/-//g;
117
                            $field->update( $isbnsubfield => $newisbn );
118
                        }
119
                    }
178
                    }
120
                }
179
                }
121
122
                ( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $cgiparams->{'frameworkcode'} || '' );
123
            } else {
124
                warn("Duplicate item found: ", $biblionumber, "; Duplicate: ", $duplicatetitle);
125
            }
180
            }
181
            ( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $cgiparams->{'frameworkcode'} || '' );
182
            # 2nd add authorities if applicable
126
            if (C4::Context->preference("BiblioAddsAuthorities")){
183
            if (C4::Context->preference("BiblioAddsAuthorities")){
127
                my ($countlinked,$countcreated)=BiblioAddAuthorities($marcrecord, $cgiparams->{'frameworkcode'});
184
                my ($countlinked,$countcreated)=BiblioAddAuthorities($marcrecord, $cgiparams->{'frameworkcode'});
128
            }
185
            }
129
            my $patron = C4::Members->GetMember(borrowernumber => $loggedinuser);
186
        } else {
130
            my $branch = C4::Branch->GetBranchDetail($patron->{branchcode});
187
            SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' );
131
            my ($invoice);
188
        }
132
            my %orderinfo = ("biblionumber", $biblionumber,
189
        # 3rd add order
133
                            "basketno", $cgiparams->{'basketno'},
190
        my $patron = C4::Members->GetMember( borrowernumber => $loggedinuser );
134
                            "quantity", $cgiparams->{'quantityrec-' . $biblio->{'import_record_id'}},
191
        my $branch = C4::Branch->GetBranchDetail( $patron->{branchcode} );
135
                            "branchcode", $branch,
192
        my ($invoice);
136
                            "booksellerinvoicenumber", $invoice,
193
        # get quantity in the MARC record (1 if none)
137
                            "budget_id", $budget_id,
194
        my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
138
                            "uncertainprice", 1,
195
        my %orderinfo = (
139
                            );
196
            "biblionumber", $biblionumber, "basketno", $cgiparams->{'basketno'},
140
            # get the price if there is one.
197
            "quantity", $quantity, "branchcode", $branch, 
141
            # filter by storing only the 1st number
198
            "booksellerinvoicenumber", $invoice, 
142
            # we suppose the currency is correct, as we have no possibilities to get it.
199
            "budget_id", $budget_id, "uncertainprice", 1,
143
            if ($marcrecord->subfield("345","d")) {
200
            "sort1", $cgiparams->{'sort1'},"sort2", $cgiparams->{'sort2'},
144
              $orderinfo{'listprice'} = $marcrecord->subfield("345","d");
201
            "notes", $cgiparams->{'notes'}, "budget_id", $cgiparams->{'budget_id'},
145
              if ($orderinfo{'listprice'} =~ /^([\d\.,]*)/) {
202
            "currency",$cgiparams->{'currency'},
146
                  $orderinfo{'listprice'} = $1;
203
        );
147
                  $orderinfo{'listprice'} =~ s/,/\./;
204
        # get the price if there is one.
148
                  my $basket = GetBasket($orderinfo{basketno});
205
        # filter by storing only the 1st number
149
                  my $bookseller = GetBookSellerFromId($basket->{booksellerid});
206
        # we suppose the currency is correct, as we have no possibilities to get it.
150
                  # '//' is like '||' but tests for defined, rather than true
207
        my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour'));
151
                  my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
208
        if ($price){
152
                  $orderinfo{'unitprice'} = $orderinfo{listprice} - ($orderinfo{listprice} * ($bookseller->{discount} / 100));
209
            $price = $num->unformat_number($price);
153
                  $orderinfo{'ecost'} = $orderinfo{unitprice};
210
        }
154
              } else {
211
        if ($price){
155
                  $orderinfo{'listprice'} = 0;
212
            $orderinfo{'listprice'} = $price;
156
              }
213
            eval "use C4::Acquisition qw/GetBasket/;";
157
              $orderinfo{'rrp'} = $orderinfo{'listprice'};
214
            eval "use C4::Bookseller qw/GetBookSellerFromId/;";
158
            }
215
            my $basket     = GetBasket( $orderinfo{basketno} );
159
            elsif ($marcrecord->subfield("010","d")) {
216
            my $bookseller = GetBookSellerFromId( $basket->{booksellerid} );
160
              $orderinfo{'listprice'} = $marcrecord->subfield("010","d");
217
            my $gst        = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
161
              if ($orderinfo{'listprice'} =~ /^([\d\.,]*)/) {
218
            $orderinfo{'unitprice'} = $orderinfo{listprice} - ( $orderinfo{listprice} * ( $bookseller->{discount} / 100 ) );
162
                  $orderinfo{'listprice'} = $1;
219
            $orderinfo{'ecost'} = $orderinfo{unitprice};
163
                  $orderinfo{'listprice'} =~ s/,/\./;
220
        } else {
164
                  my $basket = GetBasket($orderinfo{basketno});
221
            $orderinfo{'listprice'} = 0;
165
                  my $bookseller = GetBookSellerFromId($basket->{booksellerid});
222
        }
166
                  my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
223
        $orderinfo{'rrp'} = $orderinfo{'listprice'};
167
                  $orderinfo{'unitprice'} = $orderinfo{listprice} - ($orderinfo{listprice} * ($bookseller->{discount} / 100));
224
168
                  $orderinfo{'ecost'} = $orderinfo{unitprice};
225
        # remove uncertainprice flag if we have found a price in the MARC record
169
              } else {
226
        $orderinfo{uncertainprice} = 0 if $orderinfo{listprice};
170
                  $orderinfo{'listprice'} = 0;
227
        my $basketno;
171
              }
228
        ( $basketno, $ordernumber ) = NewOrder( \%orderinfo );
172
              $orderinfo{'rrp'} = $orderinfo{'listprice'};
229
173
            }
230
        # 4th, add items if applicable
174
            # remove uncertainprice flag if we have found a price in the MARC record
231
        # parse the item sent by the form, and create an item just for the import_record_id we are dealing with
175
            $orderinfo{uncertainprice} = 0 if $orderinfo{listprice};
232
        # this is not optimised, but it's working !
176
            my $basketno;
233
        if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
177
            ( $basketno, $ordernumber ) = NewOrder(\%orderinfo);
234
            my @tags         = $input->param('tag');
178
235
            my @subfields    = $input->param('subfield');
179
            # now, add items if applicable
236
            my @field_values = $input->param('field_value');
180
            # parse all items sent by the form, and create an item just for the import_record_id we are dealing with
237
            my @serials      = $input->param('serial');
181
            # this is not optimised, but it's working !
238
            my @ind_tag   = $input->param('ind_tag');
182
            if (C4::Context->preference('AcqCreateItem') eq 'ordering') {
239
            my @indicator = $input->param('indicator');
183
                my @tags         = $input->param('tag');
240
            my $item;
184
                my @subfields    = $input->param('subfield');
241
            push @{ $item->{tags} },         $tags[0];
185
                my @field_values = $input->param('field_value');
242
            push @{ $item->{subfields} },    $subfields[0];
186
                my @serials      = $input->param('serial');
243
            push @{ $item->{field_values} }, $field_values[0];
187
                my @itemids       = $input->param('itemid'); # hint : in iso2709, the itemid contains the import_record_id, not an item id. It is used to get the right item, as we have X biblios.
244
            push @{ $item->{ind_tag} },      $ind_tag[0];
188
                my @ind_tag      = $input->param('ind_tag');
245
            push @{ $item->{indicator} },    $indicator[0];
189
                my @indicator    = $input->param('indicator');
246
            my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values, \@ind_tag, \@indicator );
190
                #Rebuilding ALL the data for items into a hash
247
            my $record = MARC::Record::new_from_xml( $xml, 'UTF-8' );
191
                # parting them on $itemid.
248
            for (my $qtyloop=1;$qtyloop <=$quantity;$qtyloop++) {
192
                my %itemhash;
249
                my ( $biblionumber, $bibitemnum, $itemnumber ) = AddItemFromMarc( $record, $biblionumber );
193
                my $range=scalar(@itemids);
250
                NewOrderItem( $itemnumber, $ordernumber );
194
                
195
                my $i = 0;
196
                my @items;
197
                for my $itemid (@itemids){
198
                    my $realitemid;     #javascript generated random itemids, in the form itemid-randomnumber, $realitemid is the itemid, while $itemid is the itemide parsed from the html
199
                    if ($itemid =~ m/(\d+)-.*/){
200
                        my @splits = split(/-/, $itemid);
201
                        $realitemid = $splits[0];
202
                    }
203
                    if ( ( $realitemid && $cgiparams->{'order-'. $realitemid} && $realitemid eq $biblio->{import_record_id}) || ($itemid && $cgiparams->{'order-'. $itemid} && $itemid eq $biblio->{import_record_id}) ){
204
                        my ($item, $found);
205
                        for my $tmpitem (@items){
206
                            if ($tmpitem->{itemid} eq $itemid){
207
                                $item = $tmpitem;
208
                                $found = 1;
209
                            }
210
                        }
211
                        push @{$item->{tags}}, $tags[$i];
212
                        push @{$item->{subfields}}, $subfields[$i];
213
                        push @{$item->{field_values}}, $field_values[$i];
214
                        push @{$item->{ind_tag}}, $ind_tag[$i];
215
                        push @{$item->{indicator}}, $indicator[$i];
216
                        $item->{itemid} = $itemid;
217
                        if (! $found){
218
                             push @items, $item;
219
                        }
220
                    }
221
                    ++$i
222
                }
223
                foreach my $item (@items){
224
                        my $xml = TransformHtmlToXml( $item->{'tags'},
225
                                                $item->{'subfields'},
226
                                                $item->{'field_values'},
227
                                                $item->{'ind_tag'},
228
                                                $item->{'indicator'});
229
                        my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
230
                        my ($biblionumber,$bibitemnum,$itemnumber) = AddItemFromMarc($record,$biblionumber);
231
                        NewOrderItem( $itemnumber, $ordernumber);
232
                }
233
            }
251
            }
234
        }
252
        }
235
    }
253
    }
Lines 237-242 if ($op eq ""){ Link Here
237
    print $input->redirect("/cgi-bin/koha/acqui/basket.pl?basketno=".$cgiparams->{'basketno'});
255
    print $input->redirect("/cgi-bin/koha/acqui/basket.pl?basketno=".$cgiparams->{'basketno'});
238
    exit;
256
    exit;
239
}
257
}
258
259
my $budgets = GetBudgets();
260
my $budget_id = @$budgets[0]->{'budget_id'};
261
# build bookfund list
262
my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
263
my ( $flags, $homebranch ) = ( $borrower->{'flags'}, $borrower->{'branchcode'} );
264
my $budget = GetBudget($budget_id);
265
266
# build budget list
267
my $budget_loop = [];
268
my $budgets = GetBudgetHierarchy( q{}, $borrower->{branchcode}, $borrower->{borrowernumber} );
269
foreach my $r ( @{$budgets} ) {
270
    if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
271
        next;
272
    }
273
    push @{$budget_loop},
274
      { b_id  => $r->{budget_id},
275
        b_txt => $r->{budget_name},
276
        b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0,
277
      };
278
}
279
$template->param( budget_loop    => $budget_loop,);
280
281
my $CGIsort1;
282
if ($budget) {    # its a mod ..
283
    if ( defined $budget->{'sort1_authcat'} ) {    # with custom  Asort* planning values
284
        $CGIsort1 = GetAuthvalueDropbox( 'sort1', $budget->{'sort1_authcat'}, $data->{'sort1'} );
285
    }
286
} elsif ( scalar(@$budgets) ) {
287
    $CGIsort1 = GetAuthvalueDropbox( 'sort1', @$budgets[0]->{'sort1_authcat'}, '' );
288
} else {
289
    $CGIsort1 = GetAuthvalueDropbox( 'sort1', '', '' );
290
}
291
292
# if CGIsort is successfully fetched, the use it
293
# else - failback to plain input-field
294
if ($CGIsort1) {
295
    $template->param( CGIsort1 => $CGIsort1 );
296
} else {
297
    $template->param( sort1 => $data->{'sort1'} );
298
}
299
300
my $CGIsort2;
301
if ($budget) {
302
    if ( defined $budget->{'sort2_authcat'} ) {
303
        $CGIsort2 = GetAuthvalueDropbox( 'sort2', $budget->{'sort2_authcat'}, $data->{'sort2'} );
304
    }
305
} elsif ( scalar(@$budgets) ) {
306
    $CGIsort2 = GetAuthvalueDropbox( 'sort2', @$budgets[0]->{sort2_authcat}, '' );
307
} else {
308
    $CGIsort2 = GetAuthvalueDropbox( 'sort2', '', '' );
309
}
310
311
if ($CGIsort2) {
312
    $template->param( CGIsort2 => $CGIsort2 );
313
} else {
314
    $template->param( sort2 => $data->{'sort2'} );
315
}
316
240
output_html_with_http_headers $input, $cookie, $template->output;
317
output_html_with_http_headers $input, $cookie, $template->output;
241
318
242
319
Lines 268-279 sub import_biblios_list { Link Here
268
    my $batch = GetImportBatch($import_batch_id,'staged');
345
    my $batch = GetImportBatch($import_batch_id,'staged');
269
    my $biblios = GetImportBibliosRange($import_batch_id,'','','staged');
346
    my $biblios = GetImportBibliosRange($import_batch_id,'','','staged');
270
    my @list = ();
347
    my @list = ();
271
# # Itemtype is mandatory for adding a biblioitem, we just add a default, the user needs to modify this aftewards
348
272
#     my $itemtypehash = GetItemTypes();
273
#     my @itemtypes;
274
#     for my $key (sort { $itemtypehash->{$a}->{description} cmp $itemtypehash->{$b}->{description} } keys %$itemtypehash) {
275
#         push(@itemtypes, $itemtypehash->{$key});
276
#     }
277
    foreach my $biblio (@$biblios) {
349
    foreach my $biblio (@$biblios) {
278
        my $citation = $biblio->{'title'};
350
        my $citation = $biblio->{'title'};
279
        $citation .= " $biblio->{'author'}" if $biblio->{'author'};
351
        $citation .= " $biblio->{'author'}" if $biblio->{'author'};
Lines 293-310 sub import_biblios_list { Link Here
293
            match_biblionumber => $#$match > -1 ? $match->[0]->{'biblionumber'} : 0,
365
            match_biblionumber => $#$match > -1 ? $match->[0]->{'biblionumber'} : 0,
294
            match_citation => $#$match > -1 ? $match->[0]->{'title'} . ' ' . $match->[0]->{'author'} : '',
366
            match_citation => $#$match > -1 ? $match->[0]->{'title'} . ' ' . $match->[0]->{'author'} : '',
295
            match_score => $#$match > -1 ? $match->[0]->{'score'} : 0,
367
            match_score => $#$match > -1 ? $match->[0]->{'score'} : 0,
296
#             itemtypes => \@itemtypes,
297
        );
368
        );
298
#         if (C4::Context->preference('AcqCreateItem') eq 'ordering' && !$ordernumber) {
299
#             # prepare empty item form
300
#             my $cell = PrepareItemrecordDisplay();
301
#             my @itemloop;
302
#             push @itemloop,$cell;
303
#             $cellrecord{'items'} = \@itemloop;
304
#         }
305
        push @list, \%cellrecord;
369
        push @list, \%cellrecord;
306
307
308
    }
370
    }
309
    my $num_biblios = $batch->{'num_biblios'};
371
    my $num_biblios = $batch->{'num_biblios'};
310
    my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
372
    my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tmpl (-19 / +123 lines)
Lines 8-13 Link Here
8
</title>
8
</title>
9
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
9
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
10
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
10
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
11
<script type="text/javascript" src="<!-- TMPL_VAR NAME='themelang' -->/js/acq.js"></script>
11
<script type="text/JavaScript">
12
<script type="text/JavaScript">
12
//<![CDATA[
13
//<![CDATA[
13
    $(document).ready(function() {
14
    $(document).ready(function() {
Lines 28-69 Link Here
28
   <div id="bd">
29
   <div id="bd">
29
       <div id="yui-main">
30
       <div id="yui-main">
30
           <div class="yui-b">
31
           <div class="yui-b">
31
             <h1>Add orders from staged file: <!-- TMPL_VAR name="comments" --></h1>
32
             <!-- TMPL_IF name="batch_details" -->
32
             <!-- TMPL_IF name="batch_details" -->
33
               <div>
33
                  <h1>Add orders from <!-- TMPL_VAR name="comments" -->
34
                     <dl>
34
                    (<!-- TMPL_VAR name="file_name" --> staged on <!-- TMPL_VAR name="upload_timestamp" -->)
35
                       <dd><strong>File name:</strong> <!-- TMPL_VAR name="file_name" --></dd>
35
                  </h1>
36
                       <dd><strong>Staged on:</strong> <!-- TMPL_VAR name="upload_timestamp" --></dd>
37
                     </dl>
38
               </div>
39
               <div>
36
               <div>
40
                   <form action="<!--TMPL_VAR name="scriptname" -->" method="post" name="import_biblios">
37
                   <form action="<!--TMPL_VAR name="scriptname" -->" method="post" name="import_biblios">
41
                     <table>
38
                     <table>
42
                     <tr>
39
                     <tr>
43
                         <th>#</th>
44
                         <th>Citation</th>
40
                         <th>Citation</th>
45
                         <th>Match?</th>
41
                         <th>Match?</th>
46
                         <th>Order</th>
42
                         <th>Order</th>
47
                       </tr>
43
                       </tr>
48
                       <!-- TMPL_LOOP name="biblio_list" -->
44
                       <!-- TMPL_LOOP name="biblio_list" -->
49
                         <tr>
45
                         <tr>
50
                             <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=<!-- TMPL_VAR name="import_record_id" -->" rel="gb_page_center[600,500]"><!-- TMPL_VAR name="record_sequence"--></a></td>
51
                             <td>
46
                             <td>
52
                                <!-- TMPL_VAR name="citation"-->
47
                                <!-- TMPL_VAR name="citation"-->
53
48
54
                             </td>
49
                             </td>
55
                             <td><!-- TMPL_VAR name="overlay_status"--></td>
50
                             <td><!-- TMPL_VAR name="overlay_status"--></td>
56
                             <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>
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>
57
                         </tr>
52
                         </tr>
58
                         <!-- TMPL_IF name="match_biblionumber" -->
53
     <!-- TMPL_IF name="match_biblionumber" -->
59
                           <tr>
54
    <tr>
60
                             <td />
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>
61
                             <td class="highlight" colspan="3">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>
62
                           </tr>
57
    <!-- /TMPL_IF -->
63
                         <!-- /TMPL_IF -->
58
                      <!-- /TMPL_LOOP -->
64
                       <!-- /TMPL_LOOP -->
65
                     </table>
59
                     </table>
66
                     <input type="button" value="Save" onclick="this.form.submit()" />
67
                   </form>
60
                   </form>
68
               </div>
61
               </div>
69
              <!-- TMPL_IF name="pages" -->
62
              <!-- TMPL_IF name="pages" -->
Lines 79-84 Link Here
79
              <!-- /TMPL_IF -->
72
              <!-- /TMPL_IF -->
80
             <!-- TMPL_ELSE -->
73
             <!-- TMPL_ELSE -->
81
               <div>
74
               <div>
75
                <h1>Choose the file to add to the basket</h1>
82
                   <table id="files">
76
                   <table id="files">
83
                     <thead>
77
                     <thead>
84
                     <tr>
78
                     <tr>
Lines 106-111 Link Here
106
               </div>
100
               </div>
107
             <!-- /TMPL_IF -->
101
             <!-- /TMPL_IF -->
108
           </div>
102
           </div>
103
        <!-- TMPL_IF name="import_batch_id" -->
104
            <div class="yui-b">
105
            <h2>Import All</h2>
106
            <p>Import all the lines in the basket with the following parameters:</p>
107
            <form action="/cgi-bin/koha/acqui/addorderiso2709.pl" method="post" id="Aform">
108
                    <input type="hidden" name="op" value="import_records"/>
109
                    <input type="hidden" name="ordernumber" value="<!-- TMPL_VAR NAME="ordernumber" -->" />
110
                    <input type="hidden" name="basketno" value="<!-- TMPL_VAR NAME="basketno" -->" />
111
                    <input type="hidden" name="booksellerid" value="<!-- TMPL_VAR NAME="booksellerid" -->" />
112
                    <input type="hidden" name="import_batch_id" value="<!-- TMPL_VAR name="import_batch_id" -->" />
113
114
                    <!-- TMPL_LOOP NAME="loop_currencies" -->
115
                        <input type="hidden" name="<!-- TMPL_VAR NAME="currency" -->" value="<!-- TMPL_VAR NAME="rate" -->" />
116
                    <!-- /TMPL_LOOP -->
117
118
                <!-- TMPL_IF name="items" -->
119
                <fieldset class="rows">
120
                    <legend>Item</legend>
121
                    <!-- TMPL_IF name="NoACQframework" -->
122
                        <div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div>
123
                    <!-- /TMPL_IF -->
124
125
                    <!-- TMPL_LOOP NAME="items" -->
126
                    <div id="outeritemblock">
127
                    <div id="itemblock">
128
                        <ol><!-- TMPL_LOOP NAME="iteminformation" --><li>
129
                            <div class="subfield_line" style="<!-- TMPL_VAR NAME='hidden' -->;" id="subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
130
131
                                <label><!-- TMPL_VAR NAME="subfield" --> - <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF --><!-- TMPL_VAR NAME="marc_lib" --><!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF --></label>
132
                                <!-- TMPL_VAR NAME="marc_value" -->
133
                                <input type="hidden" name="itemid" value="1" />
134
                                <input type="hidden" name="kohafield" value="<!-- TMPL_VAR NAME="kohafield" -->" />
135
                                <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
136
                                <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
137
                                <input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
138
                            </div></li>
139
                        <!-- /TMPL_LOOP-->
140
                        </ol>
141
                    </div><!-- /iteminformation -->
142
                    </div>
143
144
                    <!--/TMPL_LOOP--> <!-- /items -->
145
                </fieldset>
146
                <!-- /TMPL_IF --> <!-- items -->
147
                <fieldset class="rows">
148
                    <legend>Accounting Details</legend>
149
                    <ol>
150
                        <li>
151
                            <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
152
                            <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" />
153
                        </li>
154
                        <li>
155
                            <!-- TMPL_IF name="close" -->
156
                        <span class="label">Budget: </span>
157
                                <input type="hidden" size="20" name="budget_id" id="budget_id" value="<!-- TMPL_VAR NAME="budget_id" -->" /><!-- TMPL_VAR NAME="Budget_name" -->
158
                            <!-- TMPL_ELSE -->
159
                            <li>
160
                            <label for="currency">Currency:</label>
161
                            <select name="currency" id="currency" onchange="calcNeworderTotal();">
162
                            <!-- TMPL_LOOP name="loop_currencies" -->
163
                                    <!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR name="currcode" -->" selected="selected"><!-- TMPL_VAR name="currcode" --></option><!-- TMPL_ELSE --><option value="<!-- TMPL_VAR name="currcode" -->"><!-- TMPL_VAR name="currcode" --></option><!-- /TMPL_IF --><!-- /TMPL_LOOP -->
164
                            </select>
165
                            </li>
166
                            <li>
167
                            <label for="budget_id">Budget: </label>
168
                            <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
169
                            <!-- TMPL_LOOP NAME="budget_loop" -->
170
                                <!-- TMPL_IF NAME="b_sel" -->
171
                                    <option value="<!-- TMPL_VAR NAME='b_id' -->" selected="selected"><!-- TMPL_VAR NAME="b_txt" --></option>
172
                                <!-- TMPL_ELSE -->
173
                                    <option value="<!-- TMPL_VAR NAME='b_id' -->"><!-- TMPL_VAR NAME="b_txt" --></option>
174
                                <!-- /TMPL_IF -->
175
                            <!-- /TMPL_LOOP -->
176
                            </select>
177
                            </li>
178
                            <!--/TMPL_IF-->
179
                        </li>
180
                        <li>
181
                            <label for="notes">Notes: </label>
182
                            <textarea id="notes" cols="30" rows="3" name="notes"></textarea>
183
                        </li>
184
                        <li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
185
                            <label for="sort1">Planning value1: </label>
186
187
                            <!-- TMPL_IF Name="CGIsort1" -->
188
                                <!-- TMPL_VAR Name="CGIsort1" -->
189
                            <!-- TMPL_ELSE -->
190
191
                                <input type="text" id="sort1" size="20" name="sort1" value="<!-- TMPL_VAR NAME="sort1" -->" />
192
                            <!--/TMPL_IF -->
193
                        </li>
194
                        <li>
195
                            <label for="sort2">Planning value2: </label>
196
197
                            <!-- TMPL_IF Name="CGIsort2" -->
198
                                <!-- TMPL_VAR Name="CGIsort2" -->
199
                            <!-- TMPL_ELSE -->
200
                                <input type="text" id="sort2" size="20" name="sort2" value="<!-- TMPL_VAR NAME="sort2" -->" />
201
                            <!--/TMPL_IF -->
202
                        </li>
203
                        <li>
204
                            
205
                        </li>
206
            </ol>
207
                </fieldset>
208
                <fieldset class="action">
209
                    <input type="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=<!-- TMPL_VAR NAME="basketno" -->">Cancel</a>
210
                </fieldset>
211
            </form>
212
            </div>
213
        <!-- /TMPL_IF -->
109
       </div>
214
       </div>
110
   </div>
215
   </div>
111
</div>
216
</div>
112
- 

Return to bug 5961