+#warn "CREATEBIBITEM = $input->param('createbibitem')";
+#warn Dumper $input->param('createbibitem');
+my $createbibitem = $input->param('createbibitem');
+
+# create, modify or delete biblio
+# create if $quantity>=0 and $existing='no'
+# modify if $quantity>=0 and $existing='yes'
+# delete if $quantity has been se to 0 by the librarian
+my $biblionumber=$input->param('biblionumber');
+my $bibitemnum;
+if ( $quantity ne '0' ) {
+ #check to see if biblio exists
+ if ( $existing eq 'no' ) {
+
+ #if it doesnt create it
+ my $record = TransformKohaToMarc(
+ {
+ "biblio.title" => "$title",
+ "biblio.author" => "$author",
+ "biblio.copyrightdate" => $copyrightdate ? $copyrightdate : "",
+ "biblio.series" => $series ? $series : "",
+ "biblioitems.itemtype" => $itemtype ? $itemtype : "",
+ "biblioitems.isbn" => $isbn ? $isbn : "",
+ "biblioitems.publishercode" => $publishercode ? $publishercode : "",
+ });
+ # create the record in catalogue, with framework ''
+ ($biblionumber,$bibitemnum) = AddBiblio($record,'');
+
+ # change suggestion status if applicable
+ if ($suggestionid) {
+ ModStatus( $suggestionid, 'ORDERED', '', $biblionumber );
+ }
+ }
+ # if we already have $ordnum, then it's an ordermodif
+ if ($ordnum) {
+ ModOrder(
+ $title, $ordnum, $quantity, $listprice,
+ $biblionumber, $basketno, $booksellerid, $loggedinuser,
+ $notes, $bookfund, $bibitemnum, $rrp,
+ $ecost, $gst, $budget, $cost,
+ $invoice, $sort1, $sort2, $purchaseorder
+ );
+ }
+ else { # else, it's a new line
+ ( $basketno, $ordnum ) = NewOrder(
+ $basketno, $biblionumber, $title, $quantity,
+ $listprice, $booksellerid, $loggedinuser, $notes,
+ $bookfund, $bibitemnum, $rrp, $ecost,
+ $gst, $budget, $cost, $sub,
+ $invoice, $sort1, $sort2, $purchaseorder
+ );
+ }
+}
+else { # qty=0, delete the line
+ $biblionumber = $input->param('biblionumber');
+ DelOrder( $biblionumber, $ordnum );
+}
+print $input->redirect("basket.pl?basketno=$basketno");