Bug 13757: (QA followup) Make opac-memberentry.pl handle attrs deletion
[koha.git] / patroncards / edit-layout.pl
index e28dda3..fb495b1 100755 (executable)
@@ -96,6 +96,8 @@ if ($op eq 'edit') {
             push @text_fields, (
                                 "field_" . $field_number . "_llx" => $field_params->{'llx'},
                                 "field_" . $field_number . "_lly" => $field_params->{'lly'},
+                                "field_" . $field_number . "_height_scale" => $field_params->{'height_scale'},
+                                "field_" . $field_number . "_width_scale" => $field_params->{'width_scale'},
                                 "field_" . $field_number . "_font" => _set_selected($field_params->{'font'}, $font_types),
                                 "field_" . $field_number . "_font_size" => $field_params->{'font_size'},
                                 "field_" . $field_number . "_text_alignment" => _set_selected($field_params->{'text_alignment'}, $alignment_types),
@@ -138,7 +140,15 @@ if ($op eq 'edit') {
 #   Handle barcodes...
     my @barcode = ();
     foreach my $barcode_param (keys %{$layout_xml->{'barcode'}->[0]}) {
-        push @barcode, (($barcode_param eq 'type' ? ("barcode_" . $barcode_param => _set_selected($layout_xml->{'barcode'}->[0]->{'barcode_type'}, $barcode_types)) : ("barcode_" . $barcode_param => $layout_xml->{'barcode'}->[0]->{$barcode_param})));
+        push @barcode, (($barcode_param eq 'type' ? ("barcode_" . $barcode_param => _set_selected($layout_xml->{'barcode'}->[0]->{'type'}, $barcode_types)) : ("barcode_" . $barcode_param => $layout_xml->{'barcode'}->[0]->{$barcode_param})));
+    }
+
+    foreach my $unit (@$units){
+        if ($unit->{'type'} eq $layout->get_attr('units')) {
+            $unit->{'selected'} = 1;
+        } else {
+            $unit->{'selected'} = 0;
+        }
     }
 
     $template->param(
@@ -148,7 +158,7 @@ if ($op eq 'edit') {
             guide_box       => $layout_xml->{'guide_box'},
             units           => $units,
             @barcode,
-            barcode_type    => get_barcode_types(),
+            barcode_type    => _set_selected($layout_xml->{'barcode'}->[0]->{'type'}, $barcode_types),
             @text_fields,
             @images,
             guidebox        => 0,
@@ -212,6 +222,7 @@ elsif  ($op eq 'save') {
     }
     $layout->{'text'} = $text_lines;
     my @params = (layout_name => $layout_name, layout_id => $layout_id, layout_xml => XMLout($layout));
+    push(@params,units => $layout->{'units'}) if $layout->{'units'};
     if ($layout_id) {   # if a label_id was passed in, this is an update to an existing layout
         $layout = C4::Patroncards::Layout->retrieve(layout_id => $layout_id);
         $layout->set_attr(@params);
@@ -227,7 +238,7 @@ elsif  ($op eq 'save') {
 elsif  ($op eq 'new') { # this is a new layout
     $layout = C4::Patroncards::Layout->new();
     my @fields = ();
-    for (my $field; $field < 4; $field++) {     # limit 3 text fields
+    for (my $field = 0; $field < 4; $field++) {     # limit 3 text fields
         push @fields, (
                         "field_$field" . "_font" => get_font_types(),
                         "field_$field" . "_text_alignment" => get_text_justification_types(),
@@ -235,7 +246,7 @@ elsif  ($op eq 'new') { # this is a new layout
     }
 
     my @images = ();
-    for (my $image; $image < 3; $image++) {     #limit 2 images
+    for (my $image = 0; $image < 3; $image++) {     #limit 2 images
         push @images, (
                         "image_$image" . "_image_source" => $image_sources,
                         "image_$image" . "_image_name" => $image_names,