# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-use CGI;
use strict;
+#use warnings; FIXME - Bug 2505
+use CGI;
use C4::Auth;
use C4::Output;
use C4::Biblio;
query => $query,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {editcatalogue => 1},
+ flagsrequired => { editcatalogue => 'edit_items' },
debug => 1,
});
if ($itemnumber) {
# And then, we get the item
- my $item = GetItem($itemnumber);
-
- if ($item) {
-
- # We delete the item from the old record (we can't delete afterwards, because of constraint on barcode duplicity)
- my $results = GetBiblioFromItemNumber($itemnumber, $barcode);
- my $frombiblionumber = $results->{'biblionumber'};
-
- my $order = GetOrderFromItemnumber($itemnumber);
- if ($order){
- $order->{'biblionumber'} = $biblionumber;
- ModOrder($order);
- }
-
- if ($frombiblionumber) {
- DelItem(C4::Context->dbh, $frombiblionumber, $itemnumber);
- }
-
- # We add the item to the requested record
- my ($biblionumber, $biblioitemnumber, $newitemnumber) = AddItem($item, $biblionumber);
-
- if ($order){
- my $orderitem = {
- ordernumber => $order->{'ordernumber'},
- itemnumber => $itemnumber,
- newitemnumber => $newitemnumber,
- };
- ModOrderItem($orderitem);
- }
-
- if ($newitemnumber) {
- $template->param(success => 1);
- } else {
- $template->param(error => 1,
- errornonewitem => 1);
- }
- } else {
- $template->param(error => 1,
- errornoitem => 1);
- }
+ my $item = GetItem($itemnumber);
+
+ if ($item) {
+
+ my $results = GetBiblioFromItemNumber($itemnumber, $barcode);
+ my $frombiblionumber = $results->{'biblionumber'};
+
+ my $moveresult = MoveItemFromBiblio($itemnumber, $frombiblionumber, $biblionumber);
+ if ($moveresult) {
+ $template->param(success => 1);
+ } else {
+ $template->param(error => 1,
+ errornonewitem => 1);
+ }
+
+
+ } else {
+ $template->param(error => 1,
+ errornoitem => 1);
+ }
} else {
- $template->param(error => 1,
- errornoitemnumber => 1);
+ $template->param(error => 1,
+ errornoitemnumber => 1);
+
}
$template->param(
barcode => $barcode,
itemnumber => $itemnumber,
);
+
} else {
$template->param(missingparameter => 1);
if (!$barcode) { $template->param(missingbarcode => 1); }