[31/40] Misc bugfixes and cosmetic cleanup.

This commit is contained in:
Chris Nighswonger 2009-08-14 00:07:35 -04:00
parent 71a4704f83
commit 38817fb300
12 changed files with 67 additions and 60 deletions

View File

@ -349,8 +349,10 @@ sub draw_label_text {
}
($field->{'code'} eq 'title') ? (($font =~ /T/) ? ($font = 'TI') : ($font = ($font . 'O'))) : ($font = $font);
my $field_data = $field->{'data'};
$field_data =~ s/\n//g;
$field_data =~ s/\r//g;
if ($field_data) {
$field_data =~ s/\n//g;
$field_data =~ s/\r//g;
}
my @label_lines;
my @callnumber_list = ('itemcallnumber', '050a', '050b', '082a', '952o'); # Fields which hold call number data FIXME: ( 060? 090? 092? 099? )
if ((grep {$field->{'code'} =~ m/$_/} @callnumber_list) and ($self->{'printing_type'} eq 'BIB') and ($self->{'callnum_split'})) { # If the field contains the call number, we do some sp
@ -368,10 +370,12 @@ sub draw_label_text {
}
}
else {
$field_data =~ s/\/$//g; # Here we will strip out all trailing '/' in fields other than the call number...
$field_data =~ s/\(/\\\(/g; # Escape '(' and ')' for the pdf object stream...
$field_data =~ s/\)/\\\)/g;
eval{local($Text::Wrap::columns) = $self->{'text_wrap_cols'};};
if ($field_data) {
$field_data =~ s/\/$//g; # Here we will strip out all trailing '/' in fields other than the call number...
$field_data =~ s/\(/\\\(/g; # Escape '(' and ')' for the pdf object stream...
$field_data =~ s/\)/\\\)/g;
}
eval{$Text::Wrap::columns = $self->{'text_wrap_cols'};};
my @line = split(/\n/ ,wrap('', '', $field_data));
# If this is a title field, limit to two lines; all others limit to one... FIXME: this is rather arbitrary
if ($field->{'code'} eq 'title' && scalar(@line) >= 2) {

View File

@ -441,6 +441,7 @@ sub get_table_names {
sub html_table {
my $headers = shift;
my $data = shift;
return undef if scalar(@$data) == 0; # no need to generate a table if there is not data to display
my $table = [];
my $fields = [];
my @headers = ();

View File

@ -13,22 +13,22 @@
function yuiToolbar() {
var layouts = [
{text: _("Manage Layouts"), url: "/cgi-bin/koha/labels/label-manage.pl?label_element=layout" },
{text: _("New Layout"), url: "/cgi-bin/koha/labels/label-edit-layout.pl" }
{text: _("New Layout"), url: "/cgi-bin/koha/labels/label-edit-layout.pl?op=new" }
];
var templates = [
{text: _("Manage Templates"), url: "/cgi-bin/koha/labels/label-manage.pl?label_element=template" },
{text: _("New Template"), url: "/cgi-bin/koha/labels/label-edit-template.pl" }
{text: _("New Template"), url: "/cgi-bin/koha/labels/label-edit-template.pl?op=new" }
];
var profiles = [
{text: _("Manage Profiles"), url: "/cgi-bin/koha/labels/label-manage.pl?label_element=profile" },
{text: _("New Profile"), url: "/cgi-bin/koha/labels/label-edit-profile.pl" }
{text: _("New Profile"), url: "/cgi-bin/koha/labels/label-edit-profile.pl?op=new" }
];
var batches = [
{text: _("Manage Batches"), url: "/cgi-bin/koha/labels/label-manage.pl?label_element=batch" },
{text: _("New Batch"), url: "/cgi-bin/koha/labels/label-edit-batch.pl" }
{text: _("New Batch"), url: "/cgi-bin/koha/labels/label-edit-batch.pl?op=new" }
];
new YAHOO.widget.Button({

View File

@ -9,7 +9,8 @@
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
<a href="/cgi-bin/koha/labels/labels-home.pl">Labels</a> &rsaquo;
<a href="/cgi-bin/koha/labels/labels-home.pl">Labels Home</a> &rsaquo;
<a href="/cgi-bin/koha/labels/label-manage.pl?label_element=batch">Mange Label Batches</a> &rsaquo;
Manage Batch Number <!-- TMPL_VAR NAME="batch_id" -->
</div>
<div id="doc3" class="yui-t2">

View File

@ -25,7 +25,8 @@
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
<a href="/cgi-bin/koha/labels/label-home.pl">Labels</a> &rsaquo;
<a href="/cgi-bin/koha/labels/label-home.pl">Labels Home</a> &rsaquo;
<a href="/cgi-bin/koha/labels/label-manage.pl?label_element=layout">Mange Label Layouts</a> &rsaquo;
<!-- TMPL_IF NAME="layout_id" -->Edit<!-- TMPL_ELSE -->Create<!-- /TMPL_IF --> Label Layout
</div>
<div id="doc3" class="yui-t2">
@ -158,7 +159,8 @@
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" value="Submit" /><a class="cancel" href="/cgi-bin/koha/labels/label-layout.pl">Cancel</a>
<span class="yui-button yui-link-button"><span class="first-child"><input type="submit" value="Save" /></span></span>
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" value="Cancel" onclick="window.location='/cgi-bin/koha/labels/label-manage.pl?label_element=layout';" /></span></span>
<input type="hidden" name="op" value="save" />
<input type="hidden" name="layout_id" value="<!-- TMPL_VAR NAME="layout_id" -->" />
</fieldset>

View File

@ -82,7 +82,8 @@
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" value="Submit" /><a class="cancel" href="/cgi-bin/koha/labels/label-manage.pl?label_element=profile">Cancel</a>
<span class="yui-button yui-link-button"><span class="first-child"><input type="submit" value="Save" /></span></span>
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" value="Cancel" onclick="window.location='/cgi-bin/koha/labels/label-manage.pl?label_element=profile';" /></span></span>
<input type="hidden" name="op" value="save" />
<input type="hidden" name="profile_id" value="<!-- TMPL_VAR NAME="profile_id" -->" />
</fieldset>

View File

@ -117,7 +117,8 @@
</div>
<div class="yui-g">
<fieldset class="action">
<input type="submit" value="Submit" /><a class="cancel" href="/cgi-bin/koha/labels/label-manage.pl?label_element=template">Cancel</a>
<span class="yui-button yui-link-button"><span class="first-child"><input type="submit" value="Save" /></span></span>
<span class="yui-button yui-link-button"><span class="first-child"><input type="button" value="Cancel" onclick="window.location='/cgi-bin/koha/labels/label-manage.pl?label_element=template';" /></span></span>
<input type="hidden" name="op" value="save" />
<!-- TMPL_IF NAME="template_id" -->
<input type="hidden" name="template_id" value="<!-- TMPL_VAR NAME="template_id" -->" />

View File

@ -2,6 +2,8 @@
<title>Koha &rsaquo; Tools &rsaquo; Labels &rsaquo; Manage Label Elements</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<!-- TMPL_INCLUDE NAME="greybox.inc" -->
<!-- Uncomment the following script line to enable firebug lite for use on IE -->
<!-- <script type='text/javascript' src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> -->
<script type="text/JavaScript" language="JavaScript">
//<![CDATA[
function DeleteConfirm() {
@ -50,15 +52,7 @@
alert("Please select at least one batch to export.");
return; // no batch selected
}
var msg = "Are you sure you want to export the selected batch(s)?"
var answer = confirm(msg);
if (answer) {
return GB_showCenter('Export Labels', "/cgi-bin/koha/labels/label-print.pl?" + getstr, 700, 800);
// window.location = "/cgi-bin/koha/labels/label-print.pl?" + getstr;
}
else {
return; // abort export
}
return GB_showCenter('Export Labels', "/cgi-bin/koha/labels/label-print.pl?" + getstr, 700, 800);
};
function selected_layout(op) {
var selected = new Array;
@ -80,11 +74,6 @@
if (document.layouts.action.checked){
return(document.layouts.action.value);
}
//var x=document.getElementsByName("action");
//if (x[0].checked) {
// alert(x[0].value);
// return(x[0].value);
//};
};
alert("Please select a <!-- TMPL_VAR NAME="label_element" -->.");
return (-1);
@ -98,7 +87,7 @@
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
<a href="/cgi-bin/koha/labels/labels-home.pl">Labels</a> &rsaquo;
<a href="/cgi-bin/koha/labels/label-home.pl">Labels Home</a> &rsaquo;
Manage Label <!-- TMPL_VAR NAME="label_element_title" -->
</div>
<div id="doc3" class="yui-t2">
@ -109,6 +98,7 @@
<div class="yui-gc">
<div class="yui-u first" id="manage-label-layouts">
<div class="hint">Current Branch: <!-- TMPL_VAR NAME="LoginBranchname" --></div>
<!-- TMPL_IF NAME="table_loop" -->
<form name="layouts">
<h2>Currently Available <!-- TMPL_VAR NAME="label_element_title" --></h2>
<table>
@ -124,8 +114,10 @@
<!-- TMPL_LOOP NAME="text_fields" -->
<!-- TMPL_IF NAME="select_field" -->
<td align="center"><input type="checkbox" name="action" value="<!-- TMPL_VAR NAME="field_value" -->"></td>
<!-- TMPL_ELSE -->
<!-- TMPL_ELSIF NAME="field_value" -->
<td><!-- TMPL_VAR NAME="field_value" --></td>
<!-- TMPL_ELSE -->
<td>&nbsp;</td>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</tr>
@ -138,6 +130,10 @@
<!-- TMPL_IF NAME="print" --><span class="yui-button yui-link-button"><span class="first-child"><input type="button" id="print" onclick="Xport()" value="Export"></span></span><!-- /TMPL_IF -->
</div>
</form>
<!-- TMPL_ELSE -->
<h2>There Are No <!-- TMPL_VAR NAME="label_element_title" --> Currently Available.</h2>
<div class="hint"><h3>Use the toolbar above to create a new <!-- TMPL_VAR NAME="label_element" -->.</h3></div>
<!-- /TMPL_IF -->
</div>
<!-- TMPL_IF NAME="error" -->
<div class="yui-u">

View File

@ -17,7 +17,7 @@
<form>
<div align="center">
<div class="message">
<h2>Click on the following link(s) to download the exported batch(es).</h2>
<b>Click on the following link(s) to download the exported batch(es).</b>
</div>
</div>
<fieldset class="rows">
@ -96,11 +96,11 @@
<div align="center">
<div class="message">
<!-- TMPL_IF NAME="label_ids" -->
<h2>Exporting <!-- TMPL_VAR NAME="label_count" --> label(s).</h2>
<b>Exporting <!-- TMPL_VAR NAME="label_count" --> label(s).</b>
<!-- TMPL_ELSIF NAME="item_numbers"-->
<h2>Exporting <!-- TMPL_VAR NAME="item_count" --> label(s).</h2>
<b>Exporting <!-- TMPL_VAR NAME="item_count" --> label(s).</b>
<!-- TMPL_ELSE -->
<h2><!-- TMPL_VAR NAME="multi_batch_count" --> batch(es) to export.</h2>
<b><!-- TMPL_VAR NAME="multi_batch_count" --> batch(es) to export.</b>
<!-- /TMPL_IF -->
</div>
</div>

View File

@ -56,7 +56,7 @@ my $display_columns = [ {_label_number => {label => 'Label Number', link_field
{_barcode => {label => 'Barcode', link_field => 0}},
{select => {label => 'Select', value => '_label_id'}},
];
my $op = $cgi->param('op') || undef;
my $op = $cgi->param('op') || 'edit';
my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || undef;
my @label_ids = $cgi->param('label_id') if $cgi->param('label_id');
my @item_numbers = $cgi->param('item_number') if $cgi->param('item_number');

View File

@ -104,7 +104,7 @@ sub _select_format_string { # generate field table based on format_string
}
if ($op eq 'edit') {
syslog("LOG_ERR", "labels/label-edit-layout.pl : Error performing '%s': No 'layout_id' passed in.", $op) unless ($layout);
syslog("LOG_ERR", "labels/label-edit-layout.pl : Error performing '%s': No 'layout_id' passed in.", $op) unless ($layout_id);
$layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);
}

View File

@ -25,6 +25,7 @@ use vars qw($debug);
use Sys::Syslog qw(syslog);
use CGI;
use HTML::Template::Pro;
use Data::Dumper;
use C4::Auth qw(get_template_and_user);
use C4::Output qw(output_html_with_http_headers);
@ -49,34 +50,34 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my $error = 0;
my $db_rows = {};
my $display_columns = { layout => [ #db column => display column
{layout_id => {label => 'Layout ID', link_field => 0}},
{layout_name => {label => 'Layout', link_field => 0}},
{barcode_type => {label => 'Barcode Type', link_field => 0}},
{printing_type => {label => 'Print Type', link_field => 0}},
{format_string => {label => 'Fields to Print', link_field => 0}},
{select => {label => 'Select', value => 'layout_id'}},
my $display_columns = { layout => [ # db column => {col label is link?
{layout_id => {label => 'Layout ID', link_field => 0}},
{layout_name => {label => 'Layout', link_field => 0}},
{barcode_type => {label => 'Barcode Type', link_field => 0}},
{printing_type => {label => 'Print Type', link_field => 0}},
{format_string => {label => 'Fields to Print',link_field => 0}},
{select => {label => 'Select', value => 'layout_id'}},
],
template => [ {template_id => {label => 'Template ID', link_field => 0}},
{template_code => {label => 'Template Name', link_field => 0}},
{template_desc => {label => 'Description', link_field => 0}},
{select => {label => 'Select', value => 'template_id'}},
template => [ {template_id => {label => 'Template ID', link_field => 0}},
{template_code => {label => 'Template Name', link_field => 0}},
{template_desc => {label => 'Description', link_field => 0}},
{select => {label => 'Select', value => 'template_id'}},
],
profile => [ {profile_id => {label => 'Profile ID', link_field => 0}},
{printer_name => {label => 'Printer Name', link_field => 0}},
{paper_bin => {label => 'Paper Bin', link_field => 0}},
{_template_code => {label => 'Template Name', link_field => 0}}, # this display column does not have a corrisponding db column in the profile table, hence the underscore
{select => {label => 'Select', value => 'profile_id'}},
profile => [ {profile_id => {label => 'Profile ID', link_field => 0}},
{printer_name => {label => 'Printer Name', link_field => 0}},
{paper_bin => {label => 'Paper Bin', link_field => 0}},
{_template_code => {label => 'Template Name', link_field => 0}}, # this display column does not have a corrisponding db column in the profile table, hence the underscore
{select => {label => 'Select', value => 'profile_id'}},
],
batch => [ {batch_id => {label => 'Batch ID', link_field => 0}},
{_item_count => {label => 'Item Count', link_field => 0}},
{select => {label => 'Select', value => 'batch_id'}},
batch => [ {batch_id => {label => 'Batch ID', link_field => 0}},
{_item_count => {label => 'Item Count', link_field => 0}},
{select => {label => 'Select', value => 'batch_id'}},
],
};
my $label_element = $cgi->param('label_element');
my $op = $cgi->param('op');
my $element_id = $cgi->param('element_id');
my $label_element = $cgi->param('label_element') || undef;
my $op = $cgi->param('op') || 'none';
my $element_id = $cgi->param('element_id') || undef;
my $branch_code = ($label_element eq 'batch' ? get_branch_code_from_name($template->param('LoginBranchname')) : '');
@ -91,7 +92,7 @@ if ($op eq 'delete') {
if ($label_element eq 'layout') {$db_rows = get_all_layouts();}
elsif ($label_element eq 'template') {$db_rows = get_all_templates();}
elsif ($label_element eq 'profile') {$db_rows = get_all_profiles();}
elsif ($label_element eq 'batch') {$db_rows = get_batch_summary(filter => "branch_code=\'$branch_code\'");}
elsif ($label_element eq 'batch') {$db_rows = get_batch_summary(filter => "branch_code=\'$branch_code\' OR branch_code=\'NB\'");}
else {} # FIXME: Some error trapping code
my $table = html_table($display_columns->{$label_element}, $db_rows);