Bug 13380: Follow-up - only run database update, when it hasn't been run already
[koha.git] / admin / itemtypes.pl
index 3c33073..1bfad90 100755 (executable)
@@ -42,7 +42,7 @@ written 20/02/2002 by paul.poulain@free.fr
 
 use strict;
 #use warnings; FIXME - Bug 2505
-use CGI;
+use CGI qw ( -utf8 );
 
 use List::Util qw/min/;
 use File::Spec;
@@ -73,7 +73,7 @@ my $op          = $input->param('op');
 $searchfield =~ s/\,//g;
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
     {
-        template_name   => "admin/itemtypes.tmpl",
+        template_name   => "admin/itemtypes.tt",
         query           => $input,
         type            => "intranet",
         authnotrequired => 0,
@@ -91,6 +91,9 @@ if ($op) {
 
 my $dbh = C4::Context->dbh;
 
+my $sip_media_type = $input->param('sip_media_type');
+undef($sip_media_type) if defined($sip_media_type) and $sip_media_type =~ /^\s*$/;
+
 ################## ADD_FORM ##################################
 # called by default. Used to create form to add or  modify a record
 if ( $op eq 'add_form' ) {
@@ -121,6 +124,7 @@ if ( $op eq 'add_form' ) {
         checkinmsgtype  => $data->{'checkinmsgtype'},
         imagesets       => $imagesets,
         remote_image    => $remote_image,
+        sip_media_type  => $data->{sip_media_type},
     );
 
     # END $OP eq ADD_FORM
@@ -145,6 +149,7 @@ elsif ( $op eq 'add_validate' ) {
                  , summary = ?
                  , checkinmsg = ?
                  , checkinmsgtype = ?
+                 , sip_media_type = ?
             WHERE itemtype = ?
         ';
         $sth = $dbh->prepare($query2);
@@ -162,15 +167,16 @@ elsif ( $op eq 'add_validate' ) {
             $input->param('summary'),
             $input->param('checkinmsg'),
             $input->param('checkinmsgtype'),
+            $sip_media_type,
             $input->param('itemtype')
         );
     }
     else {    # add a new itemtype & not modif an old
         my $query = "
             INSERT INTO itemtypes
-                (itemtype,description,rentalcharge, notforloan, imageurl, summary, checkinmsg, checkinmsgtype)
+                (itemtype,description,rentalcharge, notforloan, imageurl, summary, checkinmsg, checkinmsgtype, sip_media_type)
             VALUES
-                (?,?,?,?,?,?,?,?);
+                (?,?,?,?,?,?,?,?,?);
             ";
         my $sth = $dbh->prepare($query);
                my $image = $input->param('image');
@@ -185,6 +191,7 @@ elsif ( $op eq 'add_validate' ) {
             $input->param('summary'),
             $input->param('checkinmsg'),
             $input->param('checkinmsgtype'),
+            $sip_media_type,
         );
     }