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 (-126 / +150 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 - 2010 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
78
    $template->param("batch_details" => 1,
90
    $template->param("batch_details" => 1,
79
                     "basketno"      => $cgiparams->{'basketno'});
91
                     "basketno"      => $cgiparams->{'basketno'});
80
    import_biblios_list($template, $cgiparams->{'import_batch_id'});
92
    import_biblios_list($template, $cgiparams->{'import_batch_id'});
81
    
93
    if ( C4::Context->preference('AcqCreateItem') eq 'ordering' && !$ordernumber ) {
82
} elsif ($op eq 'import_records'){
94
        # prepare empty item form
95
        my $cell = PrepareItemrecordDisplay( '', '', '', 'ACQ' );
96
97
        #     warn "==> ".Data::Dumper::Dumper($cell);
98
        unless ($cell) {
99
            $cell = PrepareItemrecordDisplay( '', '', '', '' );
100
            $template->param( 'NoACQframework' => 1 );
101
        }
102
        my @itemloop;
103
        push @itemloop, $cell;
104
105
        $template->param( items => \@itemloop );
106
    }
107
#
108
# 3rd step = import the records
109
#
110
} elsif ( $op eq 'import_records' ) {
111
    my $num=FormatNumber();
83
#import selected lines
112
#import selected lines
84
    $template->param('basketno' => $cgiparams->{'basketno'});
113
    $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
114
# 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'};
124
    my $import_batch_id = $cgiparams->{'import_batch_id'};
96
    my $biblios = GetImportBibliosRange($import_batch_id);
125
    my $biblios = GetImportBibliosRange($import_batch_id);
97
    for my $biblio (@$biblios){
126
    for my $biblio (@$biblios){
98
        if($cgiparams->{'order-'.$biblio->{'import_record_id'}}){
127
        # 1st insert the biblio
99
            my ($marcblob, $encoding) = GetImportRecordMarc($biblio->{'import_record_id'});
128
        my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} );
100
            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";
101
            my ($duplicatetitle, $biblionumber);
130
        my ( $duplicatetitle, $biblionumber );
102
            if(!(($biblionumber,$duplicatetitle) = FindDuplicate($marcrecord))){
131
        if ( !( ( $biblionumber, $duplicatetitle ) = FindDuplicate($marcrecord) ) ) {
103
#FIXME: missing: marc21 support (should be same with different field)
132
            # add the biblio
104
                if ( C4::Context->preference("marcflavour") eq 'UNIMARC' ) {
133
            my $bibitemnum;
105
                    my $itemtypeid = "itemtype-" . $biblio->{'import_record_id'};
134
106
                    $marcrecord->field(200)->update("b" => $cgiparams->{$itemtypeid});
135
            # remove ISBN -
107
                }
136
            my ( $isbnfield, $isbnsubfield ) = GetMarcFromKohaField( 'biblioitems.isbn', '' );                
108
                # add the biblio
137
            if ( $marcrecord->field($isbnfield) ) {
109
                my $bibitemnum;
138
                foreach my $field ( $marcrecord->field($isbnfield) ) {
110
                # remove ISBN -
139
                    foreach my $subfield ( $field->subfield($isbnsubfield) ) {
111
                my ($isbnfield,$isbnsubfield) = GetMarcFromKohaField('biblioitems.isbn','');
140
                        my $newisbn = $field->subfield($isbnsubfield);
112
                if ( $marcrecord->field($isbnfield) ) {
141
                        $newisbn =~ s/-//g;
113
                    foreach my $field ( $marcrecord->field($isbnfield) ) {
142
                        $field->update( $isbnsubfield => $newisbn );
114
                        foreach my $subfield ( $field->subfield($isbnsubfield) ) {
115
                            my $newisbn = $field->subfield($isbnsubfield);
116
                            $newisbn =~ s/-//g;
117
                            $field->update( $isbnsubfield => $newisbn );
118
                        }
119
                    }
143
                    }
120
                }
144
                }
121
122
                ( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $cgiparams->{'frameworkcode'} || '' );
123
            } else {
124
                warn("Duplicate item found: ", $biblionumber, "; Duplicate: ", $duplicatetitle);
125
            }
145
            }
146
            ( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $cgiparams->{'frameworkcode'} || '' );
147
            # 2nd add authorities if applicable
126
            if (C4::Context->preference("BiblioAddsAuthorities")){
148
            if (C4::Context->preference("BiblioAddsAuthorities")){
127
                my ($countlinked,$countcreated)=BiblioAddAuthorities($marcrecord, $cgiparams->{'frameworkcode'});
149
                my ($countlinked,$countcreated)=BiblioAddAuthorities($marcrecord, $cgiparams->{'frameworkcode'});
128
            }
150
            }
151
            # 3rd add order
129
            my $patron = C4::Members->GetMember(borrowernumber => $loggedinuser);
152
            my $patron = C4::Members->GetMember(borrowernumber => $loggedinuser);
130
            my $branch = C4::Branch->GetBranchDetail($patron->{branchcode});
153
            my $branch = C4::Branch->GetBranchDetail($patron->{branchcode});
131
            my ($invoice);
154
            my ($invoice);
155
            # get quantity in the MARC record (1 if none)
156
            my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
132
            my %orderinfo = ("biblionumber", $biblionumber,
157
            my %orderinfo = ("biblionumber", $biblionumber,
133
                            "basketno", $cgiparams->{'basketno'},
158
                            "basketno", $cgiparams->{'basketno'},
134
                            "quantity", $cgiparams->{'quantityrec-' . $biblio->{'import_record_id'}},
159
                            "quantity", $quantity,
135
                            "branchcode", $branch,
160
                            "branchcode", $branch,
136
                            "booksellerinvoicenumber", $invoice,
161
                            "booksellerinvoicenumber", $invoice,
137
                            "budget_id", $budget_id,
162
                            "budget_id", $budget_id,
138
                            "uncertainprice", 1,
163
                            "uncertainprice", 1,
164
                            "sort1", $cgiparams->{'sort1'},
165
                            "sort2", $cgiparams->{'sort2'},
139
                            );
166
                            );
140
            # get the price if there is one.
167
            # get the price if there is one.
141
            # filter by storing only the 1st number
168
            # filter by storing only the 1st number
142
            # we suppose the currency is correct, as we have no possibilities to get it.
169
            # we suppose the currency is correct, as we have no possibilities to get it.
143
            if ($marcrecord->subfield("345","d")) {
170
            my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour'));
144
              $orderinfo{'listprice'} = $marcrecord->subfield("345","d");
171
            if ($price){
145
              if ($orderinfo{'listprice'} =~ /^([\d\.,]*)/) {
172
                $price = $num->unformat_number($price);
146
                  $orderinfo{'listprice'} = $1;
147
                  $orderinfo{'listprice'} =~ s/,/\./;
148
                  my $basket = GetBasket($orderinfo{basketno});
149
                  my $bookseller = GetBookSellerFromId($basket->{booksellerid});
150
                  # '//' is like '||' but tests for defined, rather than true
151
                  my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
152
                  $orderinfo{'unitprice'} = $orderinfo{listprice} - ($orderinfo{listprice} * ($bookseller->{discount} / 100));
153
                  $orderinfo{'ecost'} = $orderinfo{unitprice};
154
              } else {
155
                  $orderinfo{'listprice'} = 0;
156
              }
157
              $orderinfo{'rrp'} = $orderinfo{'listprice'};
158
            }
173
            }
159
            elsif ($marcrecord->subfield("010","d")) {
174
            if ($price){
160
              $orderinfo{'listprice'} = $marcrecord->subfield("010","d");
175
                $orderinfo{'listprice'} = $price;
161
              if ($orderinfo{'listprice'} =~ /^([\d\.,]*)/) {
176
                eval "use C4::Acquisition qw/GetBasket/;";
162
                  $orderinfo{'listprice'} = $1;
177
                eval "use C4::Bookseller qw/GetBookSellerFromId/;";
163
                  $orderinfo{'listprice'} =~ s/,/\./;
178
                my $basket     = GetBasket( $orderinfo{basketno} );
164
                  my $basket = GetBasket($orderinfo{basketno});
179
                my $bookseller = GetBookSellerFromId( $basket->{booksellerid} );
165
                  my $bookseller = GetBookSellerFromId($basket->{booksellerid});
180
                my $gst        = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
166
                  my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
181
                $orderinfo{'unitprice'} = $orderinfo{listprice} - ( $orderinfo{listprice} * ( $bookseller->{discount} / 100 ) );
167
                  $orderinfo{'unitprice'} = $orderinfo{listprice} - ($orderinfo{listprice} * ($bookseller->{discount} / 100));
182
                $orderinfo{'ecost'} = $orderinfo{unitprice};
168
                  $orderinfo{'ecost'} = $orderinfo{unitprice};
183
            } else {
169
              } else {
184
                $orderinfo{'listprice'} = 0;
170
                  $orderinfo{'listprice'} = 0;
171
              }
172
              $orderinfo{'rrp'} = $orderinfo{'listprice'};
173
            }
185
            }
186
            $orderinfo{'rrp'} = $orderinfo{'listprice'};
187
174
            # remove uncertainprice flag if we have found a price in the MARC record
188
            # remove uncertainprice flag if we have found a price in the MARC record
175
            $orderinfo{uncertainprice} = 0 if $orderinfo{listprice};
189
            $orderinfo{uncertainprice} = 0 if $orderinfo{listprice};
176
            my $basketno;
190
            my $basketno;
177
            ( $basketno, $ordernumber ) = NewOrder(\%orderinfo);
191
            ( $basketno, $ordernumber ) = NewOrder(\%orderinfo);
178
192
179
            # now, add items if applicable
193
            # 4th, add items if applicable
180
            # parse all items sent by the form, and create an item just for the import_record_id we are dealing with
194
            # parse the item sent by the form, and create an item just for the import_record_id we are dealing with
181
            # this is not optimised, but it's working !
195
            # this is not optimised, but it's working !
182
            if (C4::Context->preference('AcqCreateItem') eq 'ordering') {
196
            if (C4::Context->preference('AcqCreateItem') eq 'ordering') {
183
                my @tags         = $input->param('tag');
197
                my @tags         = $input->param('tag');
184
                my @subfields    = $input->param('subfield');
198
                my @subfields    = $input->param('subfield');
185
                my @field_values = $input->param('field_value');
199
                my @field_values = $input->param('field_value');
186
                my @serials      = $input->param('serial');
200
                my @serials      = $input->param('serial');
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.
188
                my @ind_tag      = $input->param('ind_tag');
201
                my @ind_tag      = $input->param('ind_tag');
189
                my @indicator    = $input->param('indicator');
202
                my @indicator    = $input->param('indicator');
190
                #Rebuilding ALL the data for items into a hash
203
                my $item;
191
                # parting them on $itemid.
204
                push @{ $item->{tags} },         $tags[0];
192
                my %itemhash;
205
                push @{ $item->{subfields} },    $subfields[0];
193
                my $range=scalar(@itemids);
206
                push @{ $item->{field_values} }, $field_values[0];
194
                
207
                push @{ $item->{ind_tag} },      $ind_tag[0];
195
                my $i = 0;
208
                push @{ $item->{indicator} },    $indicator[0];
196
                my @items;
209
                my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values, \@ind_tag, \@indicator );
197
                for my $itemid (@itemids){
210
                my $record = MARC::Record::new_from_xml( $xml, 'UTF-8' );
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
211
                my ( $biblionumber, $bibitemnum, $itemnumber ) = AddItemFromMarc( $record, $biblionumber );
199
                    if ($itemid =~ m/(\d+)-.*/){
212
                NewOrderItem( $itemnumber, $ordernumber );
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
            }
213
            }
234
        }
214
        }
235
    }
215
    }
Lines 237-242 if ($op eq ""){ Link Here
237
    print $input->redirect("/cgi-bin/koha/acqui/basket.pl?basketno=".$cgiparams->{'basketno'});
217
    print $input->redirect("/cgi-bin/koha/acqui/basket.pl?basketno=".$cgiparams->{'basketno'});
238
    exit;
218
    exit;
239
}
219
}
220
221
my $budgets = GetBudgets();
222
my $budget_id = @$budgets[0]->{'budget_id'};
223
# build bookfund list
224
my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
225
my ( $flags, $homebranch ) = ( $borrower->{'flags'}, $borrower->{'branchcode'} );
226
my $budget = GetBudget($budget_id);
227
228
# build budget list
229
my $budget_loop = [];
230
my $budgets = GetBudgetHierarchy( q{}, $borrower->{branchcode}, $borrower->{borrowernumber} );
231
foreach my $r ( @{$budgets} ) {
232
    if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
233
        next;
234
    }
235
    push @{$budget_loop},
236
      { b_id  => $r->{budget_id},
237
        b_txt => $r->{budget_name},
238
        b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0,
239
      };
240
}
241
$template->param( budget_loop    => $budget_loop,);
242
243
my $CGIsort1;
244
if ($budget) {    # its a mod ..
245
    if ( defined $budget->{'sort1_authcat'} ) {    # with custom  Asort* planning values
246
        $CGIsort1 = GetAuthvalueDropbox( 'sort1', $budget->{'sort1_authcat'}, $data->{'sort1'} );
247
    }
248
} elsif ( scalar(@$budgets) ) {
249
    $CGIsort1 = GetAuthvalueDropbox( 'sort1', @$budgets[0]->{'sort1_authcat'}, '' );
250
} else {
251
    $CGIsort1 = GetAuthvalueDropbox( 'sort1', '', '' );
252
}
253
254
# if CGIsort is successfully fetched, the use it
255
# else - failback to plain input-field
256
if ($CGIsort1) {
257
    $template->param( CGIsort1 => $CGIsort1 );
258
} else {
259
    $template->param( sort1 => $data->{'sort1'} );
260
}
261
262
my $CGIsort2;
263
if ($budget) {
264
    if ( defined $budget->{'sort2_authcat'} ) {
265
        $CGIsort2 = GetAuthvalueDropbox( 'sort2', $budget->{'sort2_authcat'}, $data->{'sort2'} );
266
    }
267
} elsif ( scalar(@$budgets) ) {
268
    $CGIsort2 = GetAuthvalueDropbox( 'sort2', @$budgets[0]->{sort2_authcat}, '' );
269
} else {
270
    $CGIsort2 = GetAuthvalueDropbox( 'sort2', '', '' );
271
}
272
273
if ($CGIsort2) {
274
    $template->param( CGIsort2 => $CGIsort2 );
275
} else {
276
    $template->param( sort2 => $data->{'sort2'} );
277
}
278
240
output_html_with_http_headers $input, $cookie, $template->output;
279
output_html_with_http_headers $input, $cookie, $template->output;
241
280
242
281
Lines 268-279 sub import_biblios_list { Link Here
268
    my $batch = GetImportBatch($import_batch_id,'staged');
307
    my $batch = GetImportBatch($import_batch_id,'staged');
269
    my $biblios = GetImportBibliosRange($import_batch_id,'','','staged');
308
    my $biblios = GetImportBibliosRange($import_batch_id,'','','staged');
270
    my @list = ();
309
    my @list = ();
271
# # Itemtype is mandatory for adding a biblioitem, we just add a default, the user needs to modify this aftewards
310
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) {
311
    foreach my $biblio (@$biblios) {
278
        my $citation = $biblio->{'title'};
312
        my $citation = $biblio->{'title'};
279
        $citation .= " $biblio->{'author'}" if $biblio->{'author'};
313
        $citation .= " $biblio->{'author'}" if $biblio->{'author'};
Lines 293-310 sub import_biblios_list { Link Here
293
            match_biblionumber => $#$match > -1 ? $match->[0]->{'biblionumber'} : 0,
327
            match_biblionumber => $#$match > -1 ? $match->[0]->{'biblionumber'} : 0,
294
            match_citation => $#$match > -1 ? $match->[0]->{'title'} . ' ' . $match->[0]->{'author'} : '',
328
            match_citation => $#$match > -1 ? $match->[0]->{'title'} . ' ' . $match->[0]->{'author'} : '',
295
            match_score => $#$match > -1 ? $match->[0]->{'score'} : 0,
329
            match_score => $#$match > -1 ? $match->[0]->{'score'} : 0,
296
#             itemtypes => \@itemtypes,
297
        );
330
        );
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;
331
        push @list, \%cellrecord;
306
307
308
    }
332
    }
309
    my $num_biblios = $batch->{'num_biblios'};
333
    my $num_biblios = $batch->{'num_biblios'};
310
    my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
334
    my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tmpl (-19 / +107 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>
46
                         <th>Order</th>
41
                         <th>Order</th>
47
                       </tr>
42
                       </tr>
48
                       <!-- TMPL_LOOP name="biblio_list" -->
43
                       <!-- TMPL_LOOP name="biblio_list" -->
49
                         <tr>
44
                         <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>
45
                             <td>
52
                                <!-- TMPL_VAR name="citation"-->
46
                                <!-- TMPL_VAR name="citation"-->
53
47
54
                             </td>
48
                             </td>
55
                             <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>
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>
57
                         </tr>
50
                         </tr>
58
                         <!-- TMPL_IF name="match_biblionumber" -->
59
                           <tr>
60
                             <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>
62
                           </tr>
63
                         <!-- /TMPL_IF -->
64
                       <!-- /TMPL_LOOP -->
51
                       <!-- /TMPL_LOOP -->
65
                     </table>
52
                     </table>
66
                     <input type="button" value="Save" onclick="this.form.submit()" />
67
                   </form>
53
                   </form>
68
               </div>
54
               </div>
69
              <!-- TMPL_IF name="pages" -->
55
              <!-- TMPL_IF name="pages" -->
Lines 79-84 Link Here
79
              <!-- /TMPL_IF -->
65
              <!-- /TMPL_IF -->
80
             <!-- TMPL_ELSE -->
66
             <!-- TMPL_ELSE -->
81
               <div>
67
               <div>
68
                <h1>Choose the file to add to the basket</h1>
82
                   <table id="files">
69
                   <table id="files">
83
                     <thead>
70
                     <thead>
84
                     <tr>
71
                     <tr>
Lines 106-111 Link Here
106
               </div>
93
               </div>
107
             <!-- /TMPL_IF -->
94
             <!-- /TMPL_IF -->
108
           </div>
95
           </div>
96
        <!-- TMPL_IF name="import_batch_id" -->
97
            <div class="yui-b">
98
            <h2>Import All</h2>
99
            <p>Import all the lines in the basket with the following parameters:</p>
100
            <form action="/cgi-bin/koha/acqui/addorderiso2709.pl" method="post" id="Aform">
101
                    <input type="hidden" name="op" value="import_records"/>
102
                    <input type="hidden" name="ordernumber" value="<!-- TMPL_VAR NAME="ordernumber" -->" />
103
                    <input type="hidden" name="basketno" value="<!-- TMPL_VAR NAME="basketno" -->" />
104
                    <input type="hidden" name="booksellerid" value="<!-- TMPL_VAR NAME="booksellerid" -->" />
105
                    <input type="hidden" name="import_batch_id" value="<!-- TMPL_VAR name="import_batch_id" -->" />
106
107
                    <!-- TMPL_LOOP NAME="loop_currencies" -->
108
                        <input type="hidden" name="<!-- TMPL_VAR NAME="currency" -->" value="<!-- TMPL_VAR NAME="rate" -->" />
109
                    <!-- /TMPL_LOOP -->
110
111
                <!-- TMPL_IF name="items" -->
112
                <fieldset class="rows">
113
                    <legend>Item</legend>
114
                    <!-- TMPL_IF name="NoACQframework" -->
115
                        <div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div>
116
                    <!-- /TMPL_IF -->
117
118
                    <!-- TMPL_LOOP NAME="items" -->
119
                    <div id="outeritemblock">
120
                    <div id="itemblock">
121
                        <ol><!-- TMPL_LOOP NAME="iteminformation" --><li>
122
                            <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" -->">
123
124
                                <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>
125
                                <!-- TMPL_VAR NAME="marc_value" -->
126
                                <input type="hidden" name="itemid" value="1" />
127
                                <input type="hidden" name="kohafield" value="<!-- TMPL_VAR NAME="kohafield" -->" />
128
                                <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
129
                                <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
130
                                <input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
131
                            </div></li>
132
                        <!-- /TMPL_LOOP-->
133
                        </ol>
134
                    </div><!-- /iteminformation -->
135
                    </div>
136
137
                    <!--/TMPL_LOOP--> <!-- /items -->
138
                </fieldset>
139
                <!-- /TMPL_IF --> <!-- items -->
140
                <fieldset class="rows">
141
                    <legend>Accounting Details</legend>
142
                    <ol>
143
                        <li>
144
                            <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
145
                            <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" />
146
                        </li>
147
                        <li>
148
                            <!-- TMPL_IF name="close" -->
149
                        <span class="label">Budget: </span>
150
                                <input type="hidden" size="20" name="budget_id" id="budget_id" value="<!-- TMPL_VAR NAME="budget_id" -->" /><!-- TMPL_VAR NAME="Budget_name" -->
151
                            <!-- TMPL_ELSE -->
152
                            <label for="budget_id">Budget: </label>
153
                            <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
154
                            <!-- TMPL_LOOP NAME="budget_loop" -->
155
                                <!-- TMPL_IF NAME="b_sel" -->
156
                                    <option value="<!-- TMPL_VAR NAME='b_id' -->" selected="selected"><!-- TMPL_VAR NAME="b_txt" --></option>
157
                                <!-- TMPL_ELSE -->
158
                                    <option value="<!-- TMPL_VAR NAME='b_id' -->"><!-- TMPL_VAR NAME="b_txt" --></option>
159
                                <!-- /TMPL_IF -->
160
                            <!-- /TMPL_LOOP -->
161
                            </select>
162
                            <!--/TMPL_IF-->
163
                        </li>
164
                        <li>
165
                            <label for="notes">Notes: </label>
166
                            <textarea id="notes" cols="30" rows="3" name="notes"></textarea>
167
                        </li>
168
                        <li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
169
                            <label for="sort1">Planning value1: </label>
170
171
                            <!-- TMPL_IF Name="CGIsort1" -->
172
                                <!-- TMPL_VAR Name="CGIsort1" -->
173
                            <!-- TMPL_ELSE -->
174
175
                                <input type="text" id="sort1" size="20" name="sort1" value="<!-- TMPL_VAR NAME="sort1" -->" />
176
                            <!--/TMPL_IF -->
177
                        </li>
178
                        <li>
179
                            <label for="sort2">Planning value2: </label>
180
181
                            <!-- TMPL_IF Name="CGIsort2" -->
182
                                <!-- TMPL_VAR Name="CGIsort2" -->
183
                            <!-- TMPL_ELSE -->
184
                                <input type="text" id="sort2" size="20" name="sort2" value="<!-- TMPL_VAR NAME="sort2" -->" />
185
                            <!--/TMPL_IF -->
186
                        </li>
187
                        <li>
188
                            
189
                        </li>
190
            </ol>
191
                </fieldset>
192
                <fieldset class="action">
193
                    <input type="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=<!-- TMPL_VAR NAME="basketno" -->">Cancel</a>
194
                </fieldset>
195
            </form>
196
            </div>
197
        <!-- /TMPL_IF -->
109
       </div>
198
       </div>
110
   </div>
199
   </div>
111
</div>
200
</div>
112
- 

Return to bug 5961