From 3945397a2eb8f529c74df75559e44cf1a6d33554 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Wed, 17 May 2017 09:57:41 +0000 Subject: [PATCH] Bug 18060 - Implemented redirect to label-edit-profile.pl after the user has created a template using the label onboarding tool --- C4/Creators/Profile.pm | 11 +++ .../prog/en/includes/onboardinginclude1.inc | 15 +--- .../prog/en/includes/onboardinginclude2.inc | 14 +--- .../prog/en/includes/onboardinginclude3.inc | 85 +++++++++++++++++++++- labels/label-edit-layout.pl | 17 ++++- labels/label-edit-template.pl | 11 ++- labels/label-home.pl | 26 +++---- 7 files changed, 135 insertions(+), 44 deletions(-) diff --git a/C4/Creators/Profile.pm b/C4/Creators/Profile.pm index 37512fa..ba82145 100644 --- a/C4/Creators/Profile.pm +++ b/C4/Creators/Profile.pm @@ -90,6 +90,17 @@ sub retrieve { return $self; } +sub retrieve_all { + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("select count(*) from printers_profile where creator = 'Labels' group by creator"); + my $profile = $sth->execute(); + if ($profile == '0E0'){ + return 0; + } else { + return $profile; + } +} + sub delete { my $self = {}; my %opts = (); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc index 55324ee..2d33777 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc @@ -1,15 +1,7 @@ [% BLOCK translate_justification_types %] @@ -88,7 +80,7 @@
  1. - +
  2. @@ -184,7 +176,7 @@
  3. - +
  4. @@ -201,6 +193,7 @@ Cancel + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc index 08d2bc4..031492e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc @@ -1,15 +1,7 @@
    [% IF displayonboarding == "acquisitions" %] @@ -68,11 +60,11 @@
  5. - +
  6. - +
  7. diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude3.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude3.inc index 954869e..f4d1b5b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude3.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude3.inc @@ -13,6 +13,7 @@
    + [% IF displayonboarding == "label" %]

    Acquisition onboarding wizard

    Fill out this form to create a fund which will be assigned to the budget you just created.
    A fund is an accounting value you will use to set up orders

    @@ -69,5 +70,87 @@ - +[% ELSIF displayonboarding == "label" %] +
    +
    Profile settings +
      +
    1. + [% IF ( profile_id ) %] + Printer name:[% printer_name %] + + [% ELSE %] + + [% END %] +
    2. +
    3. + [% IF ( profile_id ) %] + Paper bin: [% paper_bin %] + + [% ELSE %] + + [% END %] +
    4. +
    5. + [% IF ( label_template ) %] + [% label_template %] + [% ELSE %] + Template name: Profile unassigned + [% END %] +
    6. +
    7. + + +
    8. +
    +
    +
    Offset: +
      +
    1. + +
    2. +
    3. + +
    4. +
    +
    +
    Creep: +
      +
    1. + +
    2. +
    3. + +
    4. +
    +
    +
    + + Cancel + + +
    +
    +[% END %]
    + diff --git a/labels/label-edit-layout.pl b/labels/label-edit-layout.pl index f9e9e9d..8ee664c 100755 --- a/labels/label-edit-layout.pl +++ b/labels/label-edit-layout.pl @@ -123,8 +123,20 @@ elsif ($op eq 'save') { $layout = C4::Labels::Layout->new(@params); $layout_id = $layout->save(); } - print $cgi->redirect("label-manage.pl?label_element=layout" . ($layout_id == -1 ? "&element_id=$layout_id&op=$op&error=1" : '')); - exit; + + my $layoutvalue = C4::Creators::Layout->retrieve_all(); + my $templatecount = C4::Creators::Template->retrieve_all(); + $template->param( layoutvalue => $layoutvalue, + templatevalue => $templatecount, + ); + + if ($templatecount == 0) { + print $cgi->redirect("/cgi-bin/koha/labels/label-home.pl"); + exit; + } else { + print $cgi->redirect("label-manage.pl?label_element=layout" . ($layout_id == -1 ? "&element_id=$layout_id&op=$op&error=1" : '')); + exit; + } } else { # if we get here, this is a new layout $layout = C4::Labels::Layout->new(); @@ -152,4 +164,5 @@ else { # if we get here, this is a new layout 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-edit-template.pl b/labels/label-edit-template.pl index bcee714..d7d891b 100755 --- a/labels/label-edit-template.pl +++ b/labels/label-edit-template.pl @@ -111,8 +111,15 @@ elsif ($op eq 'save') { $profile->save(); } } - print $cgi->redirect("label-manage.pl?label_element=template"); - exit; + + my $profilevalue = C4::Creators::Profile->retrieve_all(); + if ($profilevalue == 0) { + print $cgi->redirect("label-edit-profile.pl"); + exit; + }else{ + print $cgi->redirect("/cgi-bin/koha/labels/label-home.pl"); + exit; + } } else { # if we get here, this is a new layout $label_template = C4::Labels::Template->new(); diff --git a/labels/label-home.pl b/labels/label-home.pl index 44dbf0c..4c5645b 100755 --- a/labels/label-home.pl +++ b/labels/label-home.pl @@ -43,18 +43,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -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: @@ -78,7 +71,6 @@ sub _select_format_string { # generate field table based on format_string 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; @@ -98,22 +90,22 @@ 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 $units = get_unit_values(); $template->param( barcode_types => $barcode_types, -# label_types => $label_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 + units => $units, +); + +my $layoutvalue = C4::Creators::Layout->retrieve_all(); +my $templatevalue = C4::Creators::Template->retrieve_all(); +$template->param( layoutvalue => $layoutvalue, + templatevalue => $templatevalue, ); output_html_with_http_headers $cgi, $cookie, $template->output; -- 2.1.4