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

(-)a/C4/Acquisition.pm (-3 / +85 lines)
Lines 1124-1129 sub ModReceiveOrder { Link Here
1124
    my $order = $sth->fetchrow_hashref();
1124
    my $order = $sth->fetchrow_hashref();
1125
    $sth->finish();
1125
    $sth->finish();
1126
1126
1127
1128
    # If there are still items to be received
1127
    if ( $order->{quantity} > $quantrec ) {
1129
    if ( $order->{quantity} > $quantrec ) {
1128
        $sth=$dbh->prepare("
1130
        $sth=$dbh->prepare("
1129
            UPDATE aqorders
1131
            UPDATE aqorders
Lines 1145-1159 sub ModReceiveOrder { Link Here
1145
        }
1147
        }
1146
        $order->{'quantity'} -= $quantrec;
1148
        $order->{'quantity'} -= $quantrec;
1147
        $order->{'quantityreceived'} = 0;
1149
        $order->{'quantityreceived'} = 0;
1148
        my $newOrder = NewOrder($order);
1150
        my ($newOrder, $newordernumber) = NewOrder($order);
1149
} else {
1151
1150
        $sth=$dbh->prepare("update aqorders
1152
	# Do we have to update order informations from the marc record?
1153
	my ($ordertag, $ordersubtag) = GetMarcFromKohaField('aqorders.ordernumber', 'ACQ');
1154
1155
	# Updating MARC order field if exists
1156
	if ($ordertag and $ordersubtag) {
1157
	    $debug and warn "updating MARC";
1158
	    # Getting record
1159
	    my $record = GetMarcBiblio($biblionumber);
1160
	    if ($record) {
1161
		$debug and warn "updating Record";
1162
		foreach ($record->field($ordertag)) {
1163
		    if ($_->subfield($ordersubtag) eq $ordernumber) {
1164
		       # Updating ordernumber
1165
		       $debug and warn "updating ordernumber $ordernumber => $newordernumber";
1166
		       $_->update($ordersubtag => $newordernumber); 
1167
1168
		       # Updating quantity
1169
		       my ($quantitytag, $quantitysubtag) = GetMarcFromKohaField('aqorders.quantity', 'ACQ');
1170
		       if ($quantitysubtag) {
1171
			    $debug and warn "updating quantity " . $order->{quantity};
1172
			    $_->update($quantitysubtag => $order->{quantity});
1173
		       }
1174
		    }
1175
		}
1176
1177
		# Applying changes
1178
		ModBiblio($record, $biblionumber, 'ACQ'); 
1179
	    }	
1180
	}
1181
1182
1183
    } else {
1184
        $sth = $dbh->prepare(
1185
            "update aqorders
1151
                            set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?,
1186
                            set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?,
1152
                                unitprice=?,freight=?,rrp=?
1187
                                unitprice=?,freight=?,rrp=?
1153
                            where biblionumber=? and ordernumber=?");
1188
                            where biblionumber=? and ordernumber=?");
1154
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$biblionumber,$ordernumber);
1189
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$biblionumber,$ordernumber);
1155
        $sth->finish;
1190
        $sth->finish;
1191
1192
	# Removing MARC order field if exists
1193
	DelMarcOrder($biblionumber, $ordernumber);
1156
    }
1194
    }
1195
1196
    
1157
    return $datereceived;
1197
    return $datereceived;
1158
}
1198
}
1159
#------------------------------------------------------------#
1199
#------------------------------------------------------------#
Lines 1253-1258 sub DelOrder { Link Here
1253
    my $sth = $dbh->prepare($query);
1293
    my $sth = $dbh->prepare($query);
1254
    $sth->execute( $bibnum, $ordernumber );
1294
    $sth->execute( $bibnum, $ordernumber );
1255
    $sth->finish;
1295
    $sth->finish;
1296
1297
    # Removing MARC order field if exists
1298
    DelMarcOrder($bibnum, $ordernumber);
1299
1256
    my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1300
    my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1257
    foreach my $itemnumber (@itemnumbers){
1301
    foreach my $itemnumber (@itemnumbers){
1258
    	C4::Items::DelItem( $dbh, $bibnum, $itemnumber );
1302
    	C4::Items::DelItem( $dbh, $bibnum, $itemnumber );
Lines 1260-1265 sub DelOrder { Link Here
1260
    
1304
    
1261
}
1305
}
1262
1306
1307
=head3 DelMarcOrder
1308
1309
=over 4
1310
1311
&DelMarcOrder($biblionumber, $ordernumber);
1312
1313
Delete the order field from the MARC record. aqorders.ordernumber needs
1314
to be linked to a MARC field/subfield. The field is deleted if the value of
1315
the subfield containing the ordernumber matches the ordernumber given
1316
in parameter
1317
1318
=back
1319
1320
=cut
1321
1322
sub DelMarcOrder {
1323
    my ($biblionumber, $ordernumber) = @_;
1324
1325
    # Do we have to remove order informations from the marc record?
1326
    my ($ordertag, $ordersubtag) = GetMarcFromKohaField('aqorders.ordernumber', 'ACQ');
1327
1328
    # Removing MARC order field if exists
1329
    if ($ordertag and $ordersubtag) {
1330
	# Getting record
1331
	my $record = GetMarcBiblio($biblionumber);
1332
	if ($record) {
1333
	    # Looking for the right field
1334
	    foreach ($record->field($ordertag)) {
1335
		if ($_->subfield($ordersubtag) eq $ordernumber) {
1336
		   $record->delete_field($_); 
1337
		}
1338
	    }
1339
	    # Applying changes
1340
	    ModBiblio($record, $biblionumber, 'ACQ'); 
1341
	}
1342
    }
1343
}
1344
1263
=head2 FUNCTIONS ABOUT PARCELS
1345
=head2 FUNCTIONS ABOUT PARCELS
1264
1346
1265
=cut
1347
=cut
(-)a/acqui/addorder.pl (-25 / +99 lines)
Lines 122-131 if it is an order from an existing suggestion : the id of this suggestion. Link Here
122
use strict;
122
use strict;
123
use warnings;
123
use warnings;
124
use CGI;
124
use CGI;
125
use C4::Auth;			# get_template_and_user
125
use C4::Auth;           # get_template_and_user
126
use C4::Acquisition;	# NewOrder DelOrder ModOrder
126
use C4::Acquisition;    # NewOrder DelOrder ModOrder
127
use C4::Suggestions;	# ModStatus
127
use C4::Suggestions;    # ModStatus
128
use C4::Biblio;			# AddBiblio TransformKohaToMarc
128
use C4::Biblio;         # AddBiblio TransformKohaToMarc
129
use C4::Bookseller qw/GetBookSellerFromId/;
129
use C4::Items;
130
use C4::Items;
130
use C4::Output;
131
use C4::Output;
131
132
Lines 193-233 my $user = $input->remote_user; Link Here
193
# delete biblio if delbiblio has been set to 1 by the librarian
194
# delete biblio if delbiblio has been set to 1 by the librarian
194
my $bibitemnum;
195
my $bibitemnum;
195
if ( $orderinfo->{quantity} ne '0' ) {
196
if ( $orderinfo->{quantity} ne '0' ) {
197
198
    # Getting bookseller's name
199
    my $supplierreference;
200
    if ($$orderinfo{booksellerid}) {
201
        my $bookseller = GetBookSellerFromId($$orderinfo{booksellerid});
202
        $supplierreference = $bookseller->{name};
203
    }
204
205
    # Do we have to add order informations to the marc record?
206
    my ($ordertag, $ordersubtag) = GetMarcFromKohaField('aqorders.ordernumber', 'ACQ'); 
207
    my $record;
208
    my $existingbiblio; # Was the order made on an existing biblio?
209
    my $ordermodif;     # Is this an order modification?
210
196
    #TODO:check to see if biblio exists
211
    #TODO:check to see if biblio exists
197
    unless ( $$orderinfo{biblionumber} ) {
212
    unless ( $$orderinfo{biblionumber} ) {
198
        #if it doesnt create it
213
        #if it doesnt create it
199
        my $record = TransformKohaToMarc(
214
        my $tmprecord = TransformKohaToMarc(
200
            {
215
            {   "biblio.title"                => "$$orderinfo{title}",
201
                "biblio.title"                => "$$orderinfo{title}",
216
                "biblio.author"               => $$orderinfo{author}          ? $$orderinfo{author}          : "",
202
                "biblio.author"               => $$orderinfo{author}          ? $$orderinfo{author}        : "",
217
                "biblio.seriestitle"          => $$orderinfo{series}          ? $$orderinfo{series}          : "",
203
                "biblio.seriestitle"          => $$orderinfo{series}          ? $$orderinfo{series}        : "",
218
                "biblioitems.isbn"            => $$orderinfo{isbn}            ? $$orderinfo{isbn}            : "",
204
                "biblioitems.isbn"            => $$orderinfo{isbn}            ? $$orderinfo{isbn}          : "",
219
                "biblioitems.ean"             => $$orderinfo{ean}             ? $$orderinfo{ean}             : "",
205
                "biblioitems.publishercode"   => $$orderinfo{publishercode}   ? $$orderinfo{publishercode} : "",
220
                "biblioitems.publishercode"   => $$orderinfo{publishercode}   ? $$orderinfo{publishercode}   : "",
206
                "biblioitems.publicationyear" => $$orderinfo{publicationyear} ? $$orderinfo{publicationyear}: "",
221
                "biblioitems.publicationyear" => $$orderinfo{publicationyear} ? $$orderinfo{publicationyear} : "",
207
                "biblio.copyrightdate"        => $$orderinfo{publicationyear} ? $$orderinfo{publicationyear}: "",
222
                "biblioitems.itemtype"        => $$orderinfo{itemtype}        ? $$orderinfo{itemtype}        : "",
208
                "biblioitems.itemtype"        => $$orderinfo{itemtype} ? $$orderinfo{itemtype} : "",
223
                "aqorders.branchcode"         => $$orderinfo{branchcode}      ? $$orderinfo{branchcode}      : "",
209
            });
224
                "aqorders.quantity"           => $$orderinfo{quantity}        ? $$orderinfo{quantity}        : "",
225
                "aqorders.listprice"          => $$orderinfo{listprice}       ? $$orderinfo{listprice}       : "",
226
                "aqorders.uncertainprice"     => $$orderinfo{uncertainprice}  ? $$orderinfo{uncertainprice}  : "",
227
                "aqorders.rrp"                => $$orderinfo{rrp}             ? $$orderinfo{rrp}             : "",
228
                "aqorders.ecost"              => $$orderinfo{ecost}           ? $$orderinfo{ecost}           : "",
229
                "aqorders.notes"              => $$orderinfo{notes}           ? $$orderinfo{notes}           : "",
230
                "aqorders.supplierreference"  => $supplierreference           ? $supplierreference           : "",
231
                "aqorders.sort1"              => $$orderinfo{sort1}           ? $$orderinfo{sort1}           : "",
232
                "aqorders.sort2"              => $$orderinfo{sort2}           ? $$orderinfo{sort2}           : ""
233
            }
234
        );
210
235
211
        # create the record in catalogue, with framework ''
236
        # create the record in catalogue, with framework ''
212
        my ($biblionumber,$bibitemnum) = AddBiblio($record,'');
237
        my ( $biblionumber, $bibitemnum ) = AddBiblio( $tmprecord, '' );
238
213
        # change suggestion status if applicable
239
        # change suggestion status if applicable
214
        if ($$orderinfo{suggestionid}) {
240
        if ($$orderinfo{suggestionid}) {
215
            ModSuggestion( {suggestionid=>$$orderinfo{suggestionid}, STATUS=>'ORDERED', biblionumber=>$biblionumber} );
241
            ModSuggestion( {suggestionid=>$$orderinfo{suggestionid}, STATUS=>'ORDERED', biblionumber=>$biblionumber} );
216
        }
242
        }
217
		$orderinfo->{biblioitemnumber}=$bibitemnum;
243
        $orderinfo->{biblioitemnumber} = $bibitemnum;
218
		$orderinfo->{biblionumber}=$biblionumber;
244
        $orderinfo->{biblionumber}     = $biblionumber;
245
    } else {
246
	$existingbiblio = 1;
219
    }
247
    }
220
248
221
    # if we already have $ordernumber, then it's an ordermodif
249
    # Getting record
222
    if ($$orderinfo{ordernumber}) {
250
    $record = GetMarcBiblio($$orderinfo{biblionumber});
223
        ModOrder( $orderinfo);
251
224
    }
252
    
225
    else { # else, it's a new line
253
254
     # if we already have $ordernumber, then it's an ordermodif
255
    if ( $$orderinfo{ordernumber} ) {
256
        ModOrder($orderinfo);
257
	$ordermodif = 1;
258
	
259
    } else {    # else, it's a new line
226
        @$orderinfo{qw(basketno ordernumber )} = NewOrder($orderinfo);
260
        @$orderinfo{qw(basketno ordernumber )} = NewOrder($orderinfo);
261
262
	# We have to add the ordernumber in the designated subfield
263
	if ($ordertag && $record && !$ordermodif) {
264
	    # To which field do we add it : to the one with currently no ordernumber
265
	    foreach ($record->field($ordertag)) {
266
		if (!$_->subfield($ordersubtag)) {
267
		    $_->update($ordersubtag, $$orderinfo{ordernumber});
268
		}
269
	    }
270
	    ModBiblio($record, $$orderinfo{biblionumber}, 'ACQ');
271
	}
272
273
274
    }
275
276
    if ($record) {
277
278
	# If we have to add order infos to the marc record
279
	if ($ordertag) {
280
281
	    # If the order was made on an existing biblio and it is not a modification, we add the field 
282
	    $record->insert_fields_ordered(new MARC::Field($ordertag, '', '', $ordersubtag => $$orderinfo{ordernumber})) if (!$ordermodif && $existingbiblio);
283
284
	    foreach ($record->field($ordertag)) {
285
		# Looking for the matching one
286
		if ($_->subfield($ordersubtag) eq $$orderinfo{ordernumber}) {
287
288
		    # Replacing or creating subfields
289
		    my ($t, $st);
290
		    for my $tablefield (qw/branchcode quantity listprice uncertainprice rrp ecost notes supplierreference sort1 sort2/) {
291
			($t, $st) = GetMarcFromKohaField("aqorders.$tablefield", 'ACQ');
292
			$_->update($st, $$orderinfo{$tablefield}) if ($$orderinfo{$tablefield} and $st);
293
		    }
294
		    ModBiblio($record, $$orderinfo{biblionumber}, 'ACQ');
295
		}
296
	    }
297
298
	}
299
227
    }
300
    }
228
301
229
    # now, add items if applicable
302
230
    if (C4::Context->preference('AcqCreateItem') eq 'ordering') {
303
      # now, add items if applicable
304
    if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
231
305
232
        my @tags         = $input->param('tag');
306
        my @tags         = $input->param('tag');
233
        my @subfields    = $input->param('subfield');
307
        my @subfields    = $input->param('subfield');
(-)a/admin/koha2marclinks.pl (-6 / +2 lines)
Lines 157-168 q|select tagfield,tagsubfield,liblibrarian,kohafield from marc_subfield_structur Link Here
157
    $template->param(
157
    $template->param(
158
        loop      => \@loop_data,
158
        loop      => \@loop_data,
159
        tablename => CGI::scrolling_list(
159
        tablename => CGI::scrolling_list(
160
            -name   => 'tablename',
160
            -name     => 'tablename',
161
            -values => [
161
            -values   => [ 'biblio', 'biblioitems', 'items', 'aqorders'],
162
                'biblio',
163
                'biblioitems',
164
                'items',
165
            ],
166
            -default  => $tablename,
162
            -default  => $tablename,
167
            -size     => 1,
163
            -size     => 1,
168
            -multiple => 0
164
            -multiple => 0
(-)a/admin/marc_subfields_structure.pl (+6 lines)
Lines 123-128 if ( $op eq 'add_form' ) { Link Here
123
    while ( ( my $field ) = $sth2->fetchrow_array ) {
123
    while ( ( my $field ) = $sth2->fetchrow_array ) {
124
        push @kohafields, "items." . $field;
124
        push @kohafields, "items." . $field;
125
    }
125
    }
126
    $sth2 = $dbh->prepare("SHOW COLUMNS from aqorders");
127
    $sth2->execute;
128
    while ( ( my $field ) = $sth2->fetchrow_array ) {
129
        push @kohafields, "aqorders." . $field;
130
    }
131
126
132
127
    # build authorised value list
133
    # build authorised value list
128
    $sth2->finish;
134
    $sth2->finish;
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2634-2639 CREATE TABLE `aqorders` ( Link Here
2634
  `uncertainprice` tinyint(1),
2634
  `uncertainprice` tinyint(1),
2635
  `claims_count` int(11) default 0,
2635
  `claims_count` int(11) default 0,
2636
  `claimed_date` date default NULL,
2636
  `claimed_date` date default NULL,
2637
  `branchcode` varchar(10) default NULL,
2637
  PRIMARY KEY  (`ordernumber`),
2638
  PRIMARY KEY  (`ordernumber`),
2638
  KEY `basketno` (`basketno`),
2639
  KEY `basketno` (`basketno`),
2639
  KEY `biblionumber` (`biblionumber`),
2640
  KEY `biblionumber` (`biblionumber`),
(-)a/installer/data/mysql/updatedatabase.pl (+11 lines)
Lines 4684-4690 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
4684
    SetVersion($DBversion);
4684
    SetVersion($DBversion);
4685
}
4685
}
4686
4686
4687
$DBversion = "3.07.00.015";
4688
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4689
    $dbh->do("ALTER TABLE `aqorders` ADD `branchcode` VARCHAR( 10 ) NULL");
4690
    print "Upgrade to $DBversion done (Adding branchcode in aqorders)\n";
4691
    SetVersion($DBversion);
4692
}
4693
4694
4687
=head1 FUNCTIONS
4695
=head1 FUNCTIONS
4696
=======
4697
4698
=item DropAllForeignKeys($table)
4688
4699
4689
=head2 DropAllForeignKeys($table)
4700
=head2 DropAllForeignKeys($table)
4690
4701
(-)a/kohaversion.pl (-15 / +8 lines)
Lines 1-22 Link Here
1
# the next koha public release version number;
1
# the next koha public release version number;
2
2
# the kohaversion is divided in 4 parts :
3
=head1 FUNCTIONS
3
# - #1 : the major number. 3 atm
4
4
# - #2 : the functionnal release. 00 atm
5
=head2 kohaversion
5
# - #3 : the subnumber, moves only on a public release
6
6
# - #4 : the developer version. The 4th number is the database subversion.
7
the kohaversion is divided in 4 parts :
7
#        used by developers when the database changes. updatedatabase take care of the changes itself
8
 - #1 : the major number. 3 atm
8
#        and is automatically called by Auth.pm when needed.
9
 - #2 : the functional release. 00 atm
10
 - #3 : the subnumber, moves only on a public release
11
 - #4 : the developer version. The 4th number is the database subversion.
12
        used by developers when the database changes. updatedatabase take care of the changes itself
13
        and is automatically called by Auth.pm when needed.
14
=cut
15
9
16
use strict;
10
use strict;
17
11
18
sub kohaversion {
12
sub kohaversion {
19
    our $VERSION = '3.07.00.014';
13
    our $VERSION = '3.02.00.060';
20
    # version needs to be set this way
14
    # version needs to be set this way
21
    # so that it can be picked up by Makefile.PL
15
    # so that it can be picked up by Makefile.PL
22
    # during install
16
    # during install
23
- 

Return to bug 7294