koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/admin itemtypes.pl [rel_3_0]


From: Antoine Farnault
Subject: [Koha-cvs] koha/admin itemtypes.pl [rel_3_0]
Date: Thu, 19 Oct 2006 09:02:20 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         rel_3_0
Changes by:     Antoine Farnault <toins>        06/10/19 09:02:20

Modified files:
        admin          : itemtypes.pl 

Log message:
        fix a bug when adding a new itemtypes. Now use a different query to add 
& to modify an itemtype.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/admin/itemtypes.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.24&r2=1.24.2.1

Patches:
Index: itemtypes.pl
===================================================================
RCS file: /sources/koha/koha/admin/itemtypes.pl,v
retrieving revision 1.24
retrieving revision 1.24.2.1
diff -u -b -r1.24 -r1.24.2.1
--- itemtypes.pl        4 Jul 2006 14:36:51 -0000       1.24
+++ itemtypes.pl        19 Oct 2006 09:02:20 -0000      1.24.2.1
@@ -71,7 +71,7 @@
 my $searchfield=$input->param('description');
 my $script_name="/cgi-bin/koha/admin/itemtypes.pl";
 my $itemtype=$input->param('itemtype');
-my $pagesize=5;
+my $pagesize=10;
 my $op = $input->param('op');
 $searchfield=~ s/\,//g;
 my ($template, $borrowernumber, $cookie)
@@ -107,12 +107,19 @@
        my $imagedir_filesystem = getitemtypeimagedir();
     my $imagedir_web = getitemtypeimagesrc();
     opendir(DIR, $imagedir_filesystem)
-        or die "can't opendir ".$imagedir_filesystem.": ".$!;
+        or warn "can't opendir ".$imagedir_filesystem.": ".$!;
        my @imagelist;
+       my $i=0;
+       my $image_per_line=12;
        while (my $line = readdir(DIR)) {
+           $i++;
                if ($line =~ /\.(gif|png)$/i) {
-            push(
-                @imagelist,
+                   if($i==$image_per_line){
+                       $i=0;
+                       push @imagelist,{KohaImage => '',KohaImageSrc => ''};
+                   }
+                   else{
+                push( @imagelist,
                 {
                     KohaImage => $line,
                     KohaImageSrc => $imagedir_web.'/'.$line,
@@ -121,6 +128,7 @@
             );
                }
        }
+       }
        closedir DIR;
 
     my $remote_image = undef;
@@ -145,15 +153,28 @@
 } elsif ($op eq 'add_validate') {
        my $dbh = C4::Context->dbh;
 
+    my $modif='';
+    my $query = "
+        SELECT itemtype
+        FROM   itemtypes
+        WHERE  itemtype = ?
+    ";
+    my $sth = $dbh->prepare($query);
+    $sth->execute($itemtype);
+    if($sth->fetchrow){
+        $modif = 1;
+    }
+    
+    if($modif){  # it 's a modification
     my $query = '
-UPDATE itemtypes
+            UPDATE itemtypes
   SET description = ?
     , renewalsallowed = ?
     , rentalcharge = ?
     , notforloan = ?
     , imageurl = ?
   WHERE itemtype = ?
-';
+        ';
     my $sth=$dbh->prepare($query);
        $sth->execute(
         $input->param('description'),
@@ -167,8 +188,29 @@
                 : $input->param('image'),
                $input->param('itemtype'),
     );
+    }
+    else { # add a new itemtype & not modif an old
+        my $query = "
+            INSERT INTO itemtypes
+                (itemtype,description,renewalsallowed,rentalcharge, 
notforloan, imageurl)
+            VALUES
+                (?,?,?,?,?,?);
+            ";
+        my $sth=$dbh->prepare($query);
+           $sth->execute(
+           $input->param('itemtype'),
+        $input->param('description'),
+           $input->param('renewalsallowed'),
+        $input->param('rentalcharge'),
+               $input->param('notforloan') ? 1 : 0,
+            $input->param('image') eq 'removeImage'
+            ? undef
+            : $input->param('image') eq 'remoteImage'
+                ? $input->param('remoteImage')
+                : $input->param('image'),
+        );
+    }
 
-       $sth->finish;
        print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; 
URL=itemtypes.pl\"></html>";
        exit;
                                                                                
                        # END $OP eq ADD_VALIDATE




reply via email to

[Prev in Thread] Current Thread [Next in Thread]