[Koha-cvs] koha/C4 Labels.pm [dev_week]

Mason James szrj1m at yahoo.com
Fri Oct 19 08:15:55 CEST 2007


CVSROOT:	/sources/koha
Module name:	koha
Branch:		dev_week
Changes by:	Mason James <sushi>	07/10/19 06:15:55

Modified files:
	C4             : Labels.pm 

Log message:
	added split_lccn() sub, and mods for callnum_split col.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Labels.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.3.4.46&r2=1.3.4.47

Patches:
Index: Labels.pm
===================================================================
RCS file: /sources/koha/koha/C4/Labels.pm,v
retrieving revision 1.3.4.46
retrieving revision 1.3.4.47
diff -u -b -r1.3.4.46 -r1.3.4.47
--- Labels.pm	3 Sep 2007 23:07:07 -0000	1.3.4.46
+++ Labels.pm	19 Oct 2007 06:15:54 -0000	1.3.4.47
@@ -27,7 +27,7 @@
 use Algorithm::CheckDigits;
 
 # use Data::Dumper;
-# use Smart::Comments '####';
+ use Smart::Comments '###';
 
 $VERSION = 0.01;
 
@@ -64,14 +64,14 @@
   &get_batches &delete_batch
   &add_batch &SetFontSize &printText
   &GetItemFields
-  &get_text_fields
+  &get_text_fields &get_batch_count
   get_layout  &add_layout
 
   &save_layout
   &set_active_layout &by_order
   &build_text_dropbox
   &delete_layout &get_active_layout
-  &get_highest_batch
+  &get_highest_batch &split_lccn
 
 );
 
@@ -95,6 +95,44 @@
     return $conf_data;
 }
 
+sub get_batch_count {
+       my ($batch_id) = @_;    
+    my $dbh = C4::Context->dbh;
+
+  my $query2 = " SELECT count(*) as count FROM labels where batch_id  = ?";
+    my $sth    = $dbh->prepare($query2);
+    $sth->execute($batch_id);
+    my $count = $sth->fetchrow_hashref;
+### $count
+    $sth->finish;
+    return $count->{'count'};
+}
+
+
+sub split_lccn {
+    my ($lccn) = @_;    
+    my ( $ll, $wnl, $dec, $cutter, $pubdate);
+
+    $lccn = 'HE8700.7 .P6T44 1983';
+    $_ = $lccn;
+
+    my @splits   = m/([a-zA-Z]+)
+        ([0-9]+)
+        (\.[0-9]+)
+        (\s)
+        (\.[a-zA-Z0-9]+)
+        (\s)
+        ([0-9]+)
+        /x;
+
+    splice (@splits, 3,1); 
+    splice (@splits, 4,1); 
+
+    return @splits;
+}
+
+
+
 sub get_layouts {
 
 ## FIXME: this if/else could be compacted...
@@ -568,7 +606,7 @@
         $issn,        $itemtype,     $bcn,            $dcn,
         $classif,     $subclass,     $itemcallnumber, $author,
         $tmpl_id,     $printingtype, $guidebox,       $startlabel,
-        $layoutname
+        $callnum_split,         $layoutname
     ) = @_;
 
     my $dbh    = C4::Context->dbh;
@@ -578,15 +616,15 @@
     my $query2 = "INSERT INTO labels_conf
             ( barcodetype, title, subtitle, isbn,issn, itemtype, barcode,
               dewey, class, subclass, itemcallnumber, author, printingtype,
-                guidebox, startlabel, layoutname, active )
-               values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?, 1 )";
+                guidebox, startlabel, callnum_split, layoutname, active )
+               values ( ?, ?, ?, ?, ?, ?, ?, ?, ?,? ,?, ?, ?, ?,?,?,?, 1 )";
     my $sth2 = $dbh->prepare($query2);
     $sth2->execute(
         $barcodetype, $title, $subtitle, $isbn, $issn,
 
         $itemtype, $bcn,            $dcn,    $classif,
         $subclass, $itemcallnumber, $author, $printingtype,
-        $guidebox, $startlabel,     $layoutname
+        $guidebox, $startlabel,  $callnum_split,   $layoutname
     );
     $sth2->finish;
 
@@ -600,7 +638,7 @@
         $issn,        $itemtype,   $bcn,            $dcn,
         $classif,     $subclass,   $itemcallnumber, $author,
         $ccode,       $tmpl_id,    $printingtype,   $guidebox,
-        $startlabel,  $layoutname, $layout_id
+        $startlabel,  $callnum_split, $layoutname, $layout_id
     ) = @_;
 
 ### @_;
@@ -612,14 +650,14 @@
              barcodetype=?, title=?, subtitle=?, isbn=?,issn=?, 
             itemtype=?, barcode=?,    dewey=?, class=?,
              subclass=?, itemcallnumber=?, author=?, ccode=?,  printingtype=?,  
-               guidebox=?, startlabel=?, layoutname=? where id = ?";
+               guidebox=?, startlabel=?, callnum_split=?,  layoutname=? where id = ?";
     my $sth2 = $dbh->prepare($query2);
     $sth2->execute(
         $barcodetype, $title,        $subtitle,       $isbn,
         $issn,        $itemtype,     $bcn,            $dcn,
         $classif,     $subclass,     $itemcallnumber, $author,
         $ccode,       $printingtype, $guidebox,       $startlabel,
-        $layoutname,  $layout_id
+$callnum_split,         $layoutname,  $layout_id
     );
     $sth2->finish;
 
@@ -744,6 +782,8 @@
         $str = $field;
 #### $str
 
+
+                
         # strip out naughty existing nl/cr's
         $str =~ s/\n//g;
         $str =~ s/\r//g;
@@ -755,9 +795,12 @@
         $str = wrap( "", "", "$str" );
 
         # split the chunks between newline's, into an array
+
         my @strings = split /\n/, $str;
 
         # then loop for each string line
+        
+
         foreach my $str (@strings) {
 
             if ( $justify eq 'r' ) {
@@ -767,10 +810,10 @@
 
             }
 
-            warn "HPOS ,  VPOS $hPos, $vPos\n";
+#            warn "HPOS ,  VPOS $hPos, $vPos\n";
 
             # set the font size A
-
+            $str =~ s/^\*$/ /;
             #   prText( $hPos, $vPos, $str );
             PrintText( $hPos, $vPos, $fontsize, $str );
             $vPos = $vPos - $line_spacer;
@@ -1349,7 +1392,7 @@
 sub drawbox {
     my ( $llx, $lly, $urx, $ury ) = @_;
 
-    warn "llx,y= $llx,$lly  ,   urx,y=$urx,$ury\n";
+   # warn "llx,y= $llx,$lly  ,   urx,y=$urx,$ury\n";
 
     my $str = "q\n";    # save the graphic state
     $str .= "0.5 w\n";              # border color red





More information about the Koha-cvs mailing list