From 0275c26626346a3958a06c37e9cd750af2f6e2d7 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Wed, 17 May 2017 03:27:40 +0000 Subject: [PATCH] Bug 18060 - Working label onboarding tool for creating a layout and a template --- C4/Creators/Layout.pm | 10 +- C4/Creators/Template.pm | 8 +- .../prog/en/includes/onboardinginclude1.inc | 149 ++++++++++++++++++++- .../prog/en/includes/onboardinginclude2.inc | 117 +++++++++++++++- .../prog/en/modules/acqui/acqui-home.tt | 2 +- .../prog/en/modules/labels/label-home.tt | 7 +- labels/label-edit-layout.pl | 14 +- labels/label-home.pl | 79 ++++++++++- 8 files changed, 356 insertions(+), 30 deletions(-) diff --git a/C4/Creators/Layout.pm b/C4/Creators/Layout.pm index de2ee45..e806499 100644 --- a/C4/Creators/Layout.pm +++ b/C4/Creators/Layout.pm @@ -8,6 +8,7 @@ use autouse 'Data::Dumper' => qw(Dumper); use C4::Context; use C4::Debug; use C4::Creators::PDF; +use C4::Creators; # FIXME: Consider this style parameter verification instead... @@ -113,9 +114,13 @@ sub retrieve { sub retrieve_all { my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("select count(*) from creator_layouts w here creator = 'Labels'"); + my $sth = $dbh->prepare("select count(*) from creator_layouts where creator = 'Labels' group by creator"); my $layout = $sth->execute(); - return $layout; + if ($layout == '0E0'){ + return 0; + } else { + return $layout; + } } sub delete { @@ -241,6 +246,7 @@ sub get_text_wrap_cols { return $col_count; } + 1; __END__ diff --git a/C4/Creators/Template.pm b/C4/Creators/Template.pm index e9f9d55..87240b9 100644 --- a/C4/Creators/Template.pm +++ b/C4/Creators/Template.pm @@ -133,9 +133,13 @@ sub retrieve { sub retrieve_all { my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("select count(*) from creator_templates where creator = 'Labels'"); + my $sth = $dbh->prepare("select count(*) FROM creator_templates ct where creator = 'Labels' group by creator"); my $templatecount = $sth->execute(); - return $templatecount; + if ($templatecount == '0E0'){ + return 0; + } else { + return $templatecount; + } } sub delete { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc index 057a074..55324ee 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc @@ -12,7 +12,25 @@ } -[% IF onboarding =="acqui" %] +[% BLOCK translate_justification_types %] + [% SWITCH type %] + [% CASE 'L' %]Left + [% CASE 'C' %]Center + [% CASE 'R' %]Right + [% END %] +[% END %] + +[% BLOCK translate_label_types %] + [% SWITCH type %] + [% CASE 'BIB' %]Biblio + [% CASE 'BARBIB' %]Barcode/Biblio + [% CASE 'BIBBAR' %]Biblio/Barcode + [% CASE 'ALT' %]Alternating + [% CASE 'BAR' %]Barcode + [% END %] +[% END %] + +[% IF displayonboarding =="acqui" %]

Acquisition onboarding wizard

This onboarding wizard will take you through the process of setting up Acquistions

@@ -62,9 +80,128 @@
-[% ELSIF onboarding == "label" %] - -hello there - - +[% ELSIF displayonboarding == "label" %] +
+
+
+ [% IF ( layout_id ) %]Edit[% ELSE %]Create[% END %] label layout +
    +
  1. + + +
  2. +
  3. + + +
  4. +
  5. + + +
  6. +
  7. +
    + Bibliographic data to print +
      +
    1. [% IF ( layout_string ) %] + + [% ELSE %] + + [% END %] +
      +

      + [% FOREACH text_field IN fields %] +   +    + [% END %] +

      +
      +
    +
  8. +
  9. + + [% IF ( guidebox ) %] + + [% ELSE %] + + [% END %] +
  10. +
  11. + + [% IF ( callnum_split ) %] + + [% ELSE %] + + [% END %] +
  12. +
  13. + + +
  14. +
  15. + + +
  16. +
  17. + + +
  18. +
  19. + + [% IF ( oblique_title ) %] + + [% ELSE %] + + [% END %] +
  20. +
+ +
+ + Cancel + + +
+ +
[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc index 7646eb8..08d2bc4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc @@ -11,8 +11,8 @@ bottom:auto; } -
- [% IF displayonboardscreen == "acquisitions" %] +
+ [% IF displayonboarding == "acquisitions" %]

Acquisition onboarding wizard

Create a budget which is the highest level value in acquisitions accountancy.
After creating this budget you will be prompted to create a fund which is what you will use to set up orders. @@ -59,7 +59,112 @@ -

- [% ELSIF displayonboardscreen == "label" %] -

testing

- [% END %] + [% ELSIF displayonboarding == "label" %] +
+
+
    +
  1. + Template ID:[% IF ( template_id ) %][% template_id %][% ELSE %]N/A[% END %] +
  2. +
  3. + + +
  4. +
  5. + + +
  6. +
  7. + + +
  8. +
  9. + + +
  10. +
  11. + + +
  12. +
  13. + + +
  14. +
  15. + + +
  16. +
+
+
+
  1. + + +
  2. +
  3. + + +
  4. +
  5. + + +
  6. +
  7. + + +
  8. +
  9. + + +
  10. +
  11. + + +
  12. +
  13. + + +
  14. +
  15. + + +
  16. + +
  17. + + [% IF ( profile_list ) %] + + [% ELSE %] + Click here to define a printer profile. + [% END %] +
  18. +
+ Cancel + + [% IF ( template_id ) %] + + [% END %] +
+
+[% END %] +
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt index 72336ac..70bcd09 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt @@ -113,7 +113,7 @@ $(document).ready(function() { [% INCLUDE 'acquisitions-toolbar.inc' %] [% UNLESS ( loop_budget ) %] [% IF ( CAN_user_acquisition_period_manage ) %] - [% displayonboardscreen = "acquisitions" %] + [% displayonboarding = "acquisitions" %] [% IF step == 1 %] [% INCLUDE onboardinginclude1.inc %] [% ELSIF step == 2 %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-home.tt index e2004d4..c20ccce 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-home.tt @@ -20,9 +20,12 @@
[% INCLUDE 'labels-toolbar.inc' %]
- [% IF !(layout || template) %] - [% onboarding = "label" %] + [% IF !(layoutvalue) %] + [% displayonboarding = "label" %] [% INCLUDE 'onboardinginclude1.inc' %] + [% ELSIF !(templatevalue) %] + [% displayonboarding = "label" %] + [% INCLUDE 'onboardinginclude2.inc' %] [% END %]
diff --git a/labels/label-edit-layout.pl b/labels/label-edit-layout.pl index c1aafd4..f9e9e9d 100755 --- a/labels/label-edit-layout.pl +++ b/labels/label-edit-layout.pl @@ -130,13 +130,13 @@ else { # if we get here, this is a new layout $layout = C4::Labels::Layout->new(); } -my $barcode_types = _set_selected(get_barcode_types(), $layout, 'barcode_type'); -my $label_types = _set_selected(get_label_types(), $layout, 'printing_type'); -my $font_types = _set_selected(get_font_types(), $layout, 'font'); -my $text_justification_types = _set_selected(get_text_justification_types(), $layout, 'text_justify'); -my ($select_text_fields, $select_text_fields_cnt) = _select_format_string($layout->get_attr('format_string')); + my $barcode_types = _set_selected(get_barcode_types(), $layout, 'barcode_type'); + my $label_types = _set_selected(get_label_types(), $layout, 'printing_type'); + my $font_types = _set_selected(get_font_types(), $layout, 'font'); + my $text_justification_types = _set_selected(get_text_justification_types(), $layout, 'text_justify'); + my ($select_text_fields, $select_text_fields_cnt) = _select_format_string($layout->get_attr('format_string')); -$template->param( + $template->param( barcode_types => $barcode_types, label_types => $label_types, font_types => $font_types, @@ -151,5 +151,5 @@ $template->param( callnum_split => $layout->get_attr('callnum_split'), format_string => $layout->get_attr('format_string'), layout_string => 1, # FIXME: This should not be hard-coded; It should perhaps be yet another syspref... CN -); + ); output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/labels/label-home.pl b/labels/label-home.pl index 075162d..44dbf0c 100755 --- a/labels/label-home.pl +++ b/labels/label-home.pl @@ -22,11 +22,14 @@ use strict; use warnings; use CGI qw ( -utf8 ); +use POSIX; use C4::Auth qw(get_template_and_user); use C4::Output qw(output_html_with_http_headers); use C4::Creators::Layout; use C4::Creators::Template; +use C4::Creators; +use C4::Labels; my $cgi = new CGI; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -40,9 +43,77 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -my $layout = C4::Creators::Layout->retrieve_all(); -my $templatecount = C4::Creators::Template->retrieve_all(); -$template->param( layout => $layout, - template => $templatecount); +warn my $layoutvalue = C4::Creators::Layout->retrieve_all(); +warn my $templatecount = C4::Creators::Template->retrieve_all(); +$template->param( layoutvalue => $layoutvalue, + templatevalue => $templatecount, +); + +my $op = $cgi->param('op') || ''; +my $layout_id = $cgi->param('layout_id') || $cgi->param('element_id') || ''; +my $layout_choice = $cgi->param('layout_choice') || ''; +my $layout = C4::Labels::Layout->new(); + + +sub _set_selected { + my ($type_list, $object, $data_type) = @_; + SET_SELECTED: + foreach my $type (@$type_list) { + if ($layout->get_attr($data_type)) { + if ($type->{'type'} eq $layout->get_attr($data_type)) { + $type->{'selected'} = 1; + } + } + else { + $type->{'selected'} = 1; + last SET_SELECTED; + } +}; +return $type_list; +} + +sub _select_format_string { # generate field table based on format_string + my $format_string = shift; + + my @text_fields = grep /\w/, split /\s*,\s/, $format_string; + my %tf = map {$_ => 1} @text_fields; + my @missing_fields = grep { !$tf{$_} } @{ C4::Labels::Layout->PRESET_FIELDS }; +# + my $field_count = scalar(@text_fields) + scalar( @missing_fields); + + my @fields; + my $field_index = 1; + foreach my $f (@text_fields) { + push @fields, {field_name => ($f . "_tbl"), field_label => $f, order => $field_index}; + $field_index++; + } + foreach my $f (@missing_fields) { + push @fields, {field_name => ($f . "_tbl"), field_label => $f}; + } + return (\@fields, $field_count); +} + +my $barcode_types = _set_selected(get_barcode_types(), $layout, 'barcode_type'); +my $label_types = _set_selected(get_label_types(), $layout, 'printing_type'); +my $font_types = _set_selected(get_font_types(), $layout, 'font'); +my $text_justification_types = _set_selected(get_text_justification_types(), $layout, 'text_justify'); +my ($select_text_fields, $select_text_fields_cnt) = _select_format_string($layout->get_attr('format_string')); + +$template->param( + barcode_types => $barcode_types, +# label_types => $label_types, + font_types => $font_types, + text_justification_types => $text_justification_types, + fields => $select_text_fields, + field_count => $select_text_fields_cnt, +# layout_id => $layout->get_attr('layout_id') > -1 ? $layout->get_attr('layout_id') : '', +# layout_name => $layout->get_attr('layout_name'), +# guidebox => $layout->get_attr('guidebox'), +# oblique_title => $layout->get_attr('oblique_title'), +# font_size => $layout->get_attr('font_size'), +# callnum_split => $layout->get_attr('callnum_split'), +# format_string => $layout->get_attr('format_string'), +# layout_string => 1, # FIXME: This should not be hard-coded; It should perhaps be yet another syspref... CN +); output_html_with_http_headers $cgi, $cookie, $template->output; -- 2.1.4