View | Details | Raw Unified | Return to bug 18060
Collapse All | Expand All

(-)a/C4/Creators/Layout.pm (+13 lines)
Lines 8-13 use autouse 'Data::Dumper' => qw(Dumper); Link Here
8
use C4::Context;
8
use C4::Context;
9
use C4::Debug;
9
use C4::Debug;
10
use C4::Creators::PDF;
10
use C4::Creators::PDF;
11
use C4::Creators;
11
12
12
13
13
# FIXME: Consider this style parameter verification instead...
14
# FIXME: Consider this style parameter verification instead...
Lines 111-116 sub retrieve { Link Here
111
    return $self;
112
    return $self;
112
}
113
}
113
114
115
sub retrieve_all {
116
    my $dbh = C4::Context->dbh;
117
    my $sth = $dbh->prepare("select count(*) from creator_layouts where creator = 'Labels' group by creator");
118
    my $layout = $sth->execute();
119
    if ($layout == '0E0'){
120
        return 0;
121
    } else {
122
        return $layout;
123
    }
124
}
125
114
sub delete {
126
sub delete {
115
    my $self = {};
127
    my $self = {};
116
    my %opts = ();
128
    my %opts = ();
Lines 234-239 sub get_text_wrap_cols { Link Here
234
    return $col_count;
246
    return $col_count;
235
}
247
}
236
248
249
237
1;
250
1;
238
__END__
251
__END__
239
252
(-)a/C4/Creators/Profile.pm (+11 lines)
Lines 90-95 sub retrieve { Link Here
90
    return $self;
90
    return $self;
91
}
91
}
92
92
93
sub retrieve_all {
94
    my $dbh = C4::Context->dbh;
95
    my $sth = $dbh->prepare("select count(*) from printers_profile where creator = 'Labels' group by creator");
96
    my $profile = $sth->execute();
97
    if ($profile == '0E0'){
98
         return 0;
99
    } else {
100
         return $profile;
101
    }
102
}
103
93
sub delete {
104
sub delete {
94
    my $self = {};
105
    my $self = {};
95
    my %opts = ();
106
    my %opts = ();
(-)a/C4/Creators/Template.pm (+11 lines)
Lines 131-136 sub retrieve { Link Here
131
    return $self;
131
    return $self;
132
}
132
}
133
133
134
sub retrieve_all {
135
    my $dbh = C4::Context->dbh;
136
    my $sth = $dbh->prepare("select count(*) FROM creator_templates ct where creator = 'Labels' group by creator");
137
    my $templatecount = $sth->execute();
138
    if ($templatecount == '0E0'){
139
        return 0;
140
    } else {
141
        return $templatecount;
142
    }
143
}
144
134
sub delete {
145
sub delete {
135
    my $self = {};
146
    my $self = {};
136
    my %opts = ();
147
    my %opts = ();
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc (+146 lines)
Lines 13-18 Link Here
13
}
13
}
14
</style>
14
</style>
15
15
16
[% BLOCK translate_justification_types %]
17
 [%  SWITCH type %]
18
 [%   CASE 'L' %]Left
19
 [%   CASE 'C' %]Center
20
 [%   CASE 'R' %]Right
21
 [%  END %]
22
[% END %]
23
24
[% BLOCK translate_label_types %]
25
 [%  SWITCH type %]
26
 [%   CASE 'BIB'    %]Biblio
27
 [%   CASE 'BARBIB' %]Barcode/Biblio
28
 [%   CASE 'BIBBAR' %]Biblio/Barcode
29
 [%   CASE 'ALT'    %]Alternating
30
 [%   CASE 'BAR'    %]Barcode
31
 [%  END %]
32
[% END %]
33
34
[% IF displayonboarding =="acquisitions" %]
16
<div id="onboardingModal">
35
<div id="onboardingModal">
17
        <h2> Acquisition onboarding wizard</h2>
36
        <h2> Acquisition onboarding wizard</h2>
18
        <h3> This onboarding wizard will take you through the process of setting up Acquistions </h3>
37
        <h3> This onboarding wizard will take you through the process of setting up Acquistions </h3>
Lines 57-59 Link Here
57
           </fieldset>
76
           </fieldset>
58
         </form>
77
         </form>
59
</div>
78
</div>
79
80
[% ELSIF displayonboarding == "label" %]
81
<div id="onboardingModal">
82
    <form name="input" action="/cgi-bin/koha/labels/label-edit-layout.pl" method="get">
83
        <fieldset class="rows">
84
        <legend>[% IF ( layout_id ) %]Edit[% ELSE %]Create[% END %] label layout</legend>
85
        <ol>
86
            <li>
87
                <label for="layout_name">Layout name: </label>
88
                <input type="text" name="layout_name" id="layout_name" size="20" value="DEFAULT" />
89
            </li>
90
            <li>
91
                 <label for="barcode_type">Choose barcode type (encoding): </label>
92
                 <select name="barcode_type" id="barcode_type">
93
                    [% FOREACH barcode_type IN barcode_types %]
94
                        [% IF ( barcode_type.selected )     %]
95
                            <option value="[% barcode_type.type %]" selected="selected">[% barcode_type.name %]</option>
96
                        [% ELSE %]
97
                            <option value="[% barcode_type.    type %]">[% barcode_type.name %]</option>
98
                        [% END %]
99
                    [% END %]
100
                </select>
101
            </li>
102
            <li>
103
                <label for="printing_type">Choose layout type: </label>
104
                <select name="printing_type" id="printing_type">
105
                    [% FOREACH label_type IN label_types %]
106
                        [% IF ( label_type.selected ) %]
107
                            <option value="[% label_type.type %]" selected="selected">[% PROCESS translate_label_types type=label_type.type %]</option>
108
                        [% ELSE %]
109
                            <option value="[% label_type.type %]">[% PROCESS translate_label_types type=label_type.type %]</option>
110
                        [% END %]
111
                    [% END %]
112
                </select>
113
            </li>
114
            <li>
115
                   <fieldset>
116
                              <legend>Bibliographic data to print</legend>
117
                              <ol>
118
                                <li class="radio">[% IF ( layout_string ) %]
119
                                    <input type="radio" name="layout_choice" id="layout_choice_order" value="layout_table" checked="checked" /><label for="layout_choice_order">Choose order of text fields to print</label>
120
                                [% ELSE %]
121
                                    <input type="radio" name="layout_choice" id="layout_choice_order" value="layout_table" /><label for="layout_choice_order">Choose Order Of Text Fields to Print</label>
122
                                [% END %]
123
                                <div id="layout_table">
124
                                    <p>
125
                                          [% FOREACH text_field IN fields %]
126
                                                <select name="[% text_field.field_name %]" id="[% text_field.field_name |url %]">
127
                                                    <option value=""></option>
128
                                                    [% FOREACH orde IN [1..field_count] %]
129
                                                        [% IF ( orde == text_field.order ) %]
130
                                                    <option value="[% orde %]" selected="1">[% orde %]</option>
131
                                                        [% ELSE %]
132
                                                    <option value="[% orde %]">[% orde %]</option>
133
                                                        [% END %]
134
                                                    [% END %]
135
                                                </select>&nbsp;<label for="[% text_field.field_name |url %]">[% text_field.field_label %]</label>
136
                                            &nbsp;&nbsp;
137
                                            [% END %]
138
                                    </p>
139
                                </div>
140
                        </fieldset>
141
                </li>
142
                <li>
143
                    <label for="guidebox">Draw guide boxes: </label>
144
                    [% IF ( guidebox ) %]
145
                    <input type="checkbox" name="guidebox" id="guidebox" value="1"  checked="checked" />
146
                    [% ELSE %]
147
                    <input type="checkbox" name="guidebox" id="guidebox" value="1" />
148
                    [% END %]
149
                </li>
150
                <li>
151
                    <label for="callnum_split">Split call numbers: </label>
152
                    [% IF ( callnum_split ) %]
153
                    <input type="checkbox" name="callnum_split" id="callnum_split" value="1"  checked="checked" />
154
                    [% ELSE %]
155
                    <input type="checkbox" name="callnum_split" id="callnum_split" value="1" />
156
                    [% END %]
157
                </li>
158
                <li>
159
                     <label for="text_justify">Text justification: </label>
160
                     <select name="text_justify" id="text_justify">
161
                     [% FOREACH text_justification_type IN text_justification_types %]
162
                        [% IF ( text_justification_type.selected ) %]
163
                            <option value="[% text_justification_type.type %]" selected="selected">[% PROCESS translate_justification_types type=text_justification_type.type %]</option>
164
                        [% ELSE %]
165
                            <option value="[% text_justification_type.type %]">[% PROCESS translate_justification_types type=text_justification_type.type %]</option>
166
                        [% END %]
167
                     [% END %]
168
                     </select>
169
                </li>
170
                <li>
171
                    <label for="font">Font: </label>
172
                    <select name="font" id="font">
173
                        [% FOREACH font_type IN font_types %]
174
                        [% IF ( font_type.selected ) %]
175
                        <option value="[% font_type.type %]" selected="selected">[% font_type.name %]</option>
176
                        [% ELSE %]
177
                        <option value="[% font_type.type %]">[% font_type.name %]</option>
178
                        [% END %]
179
                        [% END %]
180
                    </select>
181
                </li>
182
                <li>
183
                    <label for="font_size">Font size: </label>
184
                    <input type="text" name="font_size" id="font_size" size="2" value="3" />
185
                </li>
186
                <li>
187
                    <label for="oblique_title">Oblique title: </label>
188
                    [% IF ( oblique_title ) %]
189
                    <input type="checkbox" name="oblique_title" id="oblique_title" value="1"  checked="checked" />
190
                    [% ELSE %]
191
                    <input type="checkbox" name="oblique_title" id="oblique_title" value="1" />
192
                    [% END %]
193
                </li>
194
            </ol>
195
        </fielset>
196
        <fieldset class="action">
197
            <input type="submit" value="Save" />
198
            <a class="cancel" href="/cgi-bin/koha/labels/label-manage.pl?label_element=layout">Cancel</a>
199
            <input type="hidden" name="op" value="save" />
200
            <input type="hidden" name="layout_id" value="[% layout_id %]" />
201
            <input type="hidden" name="layoutsubmitted" value=1 />
202
        </fieldset>
203
    </form>
204
</div>
205
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc (-5 / +110 lines)
Lines 13-19 Link Here
13
}
13
}
14
</style>
14
</style>
15
    <div id="onboardingModal">
15
    <div id="onboardingModal">
16
    [% IF  displayonboardscreen == "acquisitions" %]
16
    [% IF  displayonboarding == "acquisitions" %]
17
        <h2> Acquisition onboarding wizard</h2>
17
        <h2> Acquisition onboarding wizard</h2>
18
        <p> Create a budget which is the highest level value in acquisitions accountancy. <br>
18
        <p> Create a budget which is the highest level value in acquisitions accountancy. <br>
19
        After creating this budget you will be prompted to create a fund which is what you will use to set up orders.
19
        After creating this budget you will be prompted to create a fund which is what you will use to set up orders.
Lines 57-63 Link Here
57
                </a>
57
                </a>
58
            </fieldset>
58
            </fieldset>
59
        </form>
59
        </form>
60
    </div>
60
 [% ELSIF displayonboarding == "label" %]
61
    [% ELSIF displayonboardscreen == "label" %]
61
 <form name="input" action="/cgi-bin/koha/labels/label-edit-template.pl" method="get">
62
        <h2>testing</h2>
62
        <fieldset class="rows">
63
    [% END %]
63
            <ol>
64
               <li>
65
                  <span class="label">Template ID:</span>[% IF ( template_id ) %][% template_id %][% ELSE %]N/A[% END %]
66
               </li>
67
               <li>
68
                  <label for="template_code">Template code:</label>
69
                  <input type="text" size="30" maxlength="43" name="template_code" id="template_code" value="DEFAULT TEMPLATE"/>
70
               </li>
71
               <li>
72
                  <label for="template_desc">Template description:</label>
73
                  <textarea cols="30" rows="3" id="template_desc" name="template_desc">Default description</textarea>
74
               </li>
75
               <li>
76
                  <label for="units">Units:</label>
77
                  <select id="units" name="units">
78
                  [% FOREACH unit IN units %]
79
                    [% IF ( unit.selected ) %]
80
                        <option value="[% unit.type %]" selected="selected">
81
                    [% ELSE %]
82
                        <option value="[% unit.type %]">
83
                    [% END %]
84
                    [% unit.desc %]
85
                       </option>
86
                    [% END %]
87
                   </select>
88
                </li>
89
                <li>
90
                  <label for="page_height">Page height:</label>
91
                  <input type="text" size="4" name="page_height" id="page_height" value="[% page_height %]" />
92
                </li>
93
                <li>
94
                  <label for="page_width">Page width:</label>
95
                  <input type="text" size="4" name="page_width" id="page_width" value="[% page_width %]" />
96
                </li>
97
                <li>
98
                  <label for="label_width">Label width:</label>
99
                  <input type="text" size="4" name="label_width" id="label_width" value="[% label_width %]" />
100
                </li>
101
                <li>
102
                  <label for="label_height">Label height:</label>
103
                  <input type="text" size="4" name="label_height" id="label_height" value="[% label_height %]" />
104
               </li>
105
            </ol>
106
        </fieldset>
107
        <fieldset class="rows">
108
               <ol><li>
109
                     <label for="top_margin">Top page margin:</label>
110
                     <input type="text" size="4" name="top_margin" id="top_margin" value="[% top_margin %]" />
111
                   </li>
112
                   <li>
113
                     <label for="left_margin">Left page margin:</label>
114
                     <input type="text" size="4" name="left_margin" id="left_margin" value="[% left_margin %]" />
115
                   </li>
116
                   <li>
117
                     <label for="top_text_margin">Top text margin:</label>
118
                     <input type="text" size="4" name="top_text_margin" id="top_text_margin" value="[% top_text_margin %]" />
119
                   </li>
120
                   <li>
121
                     <label for="left_text_margin">Left text margin:</label>
122
                     <input type="text" size="4" name="left_text_margin" id="left_text_margin" value="[% left_text_margin %]" />
123
                   </li>
124
                   <li>
125
                     <label for="cols">Number of columns:</label>
126
                     <input type="text" size="4" name="cols" id="cols" value="[% cols %]" />
127
                   </li>
128
                   <li>
129
                     <label for="rows">Number of rows:</label>
130
                     <input type="text" size="4" name="rows" id="rows" value="[% rows %]" />
131
                   </li>
132
                   <li>
133
                     <label for="col_gap">Gap between columns:</label>
134
                     <input type="text" size="4" name="col_gap" id="col_gap" value="[% col_gap %]" />
135
                   </li>
136
                   <li>
137
                     <label for="row_gap">Gap between rows:</label>
138
                     <input type="text" size="4" name="row_gap" id="row_gap" value="[% row_gap %]" />
139
                   </li>
140
141
                   <li>
142
                     <label for="profile_id">Profile:</label>
143
                     [% IF ( profile_list ) %]
144
                          <select id="profile_id" name="profile_id">
145
                          [% FOREACH profile_lis IN profile_list %]
146
                               [% IF ( profile_lis.selected ) %]
147
                                    <option value="[% profile_lis.profile_id %]" selected="selected">
148
                               [% ELSE %]
149
                                    <option value="[% profile_lis.profile_id %]">
150
                               [% END %]
151
                               [% profile_lis.printer_name %]/[% profile_lis.paper_bin %]
152
                                    </option>
153
                               [% END %]
154
                           </select>
155
                           [% ELSE %]
156
                               <a href="/cgi-bin/koha/labels/label-edit-profile.pl?op=new">Click here to define a printer profile.</a>
157
                           [% END %]
158
                   </li>
159
               </ol>
160
            <input type="submit" class="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/labels/label-manage.pl?label_element=template">Cancel</a>
161
            <input type="hidden" name="op" value="save" />
162
            [% IF ( template_id ) %]
163
                  <input type="hidden" name="template_id" value="[% template_id %]" />
164
            [% END %]
165
       </fieldset>
166
</form>
167
[% END %]
168
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt (-2 / +3 lines)
Lines 92-97 $(document).ready(function() { Link Here
92
    $("#show").click(function(){
92
    $("#show").click(function(){
93
        $("#aqhelp").show();
93
        $("#aqhelp").show();
94
    });
94
    });
95
95
});
96
});
96
//]]>
97
//]]>
97
</script>
98
</script>
Lines 112-118 $(document).ready(function() { Link Here
112
[% INCLUDE 'acquisitions-toolbar.inc' %]
113
[% INCLUDE 'acquisitions-toolbar.inc' %]
113
    [% UNLESS ( loop_budget ) %]
114
    [% UNLESS ( loop_budget ) %]
114
        [% IF ( CAN_user_acquisition_period_manage ) %]
115
        [% IF ( CAN_user_acquisition_period_manage ) %]
115
            [% displayonboardscreen = "acquisitions" %]
116
            [% displayonboarding = "acquisitions" %]
116
            [% IF step == 1 %]
117
            [% IF step == 1 %]
117
                [% INCLUDE onboardinginclude1.inc %]
118
                [% INCLUDE onboardinginclude1.inc %]
118
            [% ELSIF step == 2 %]
119
            [% ELSIF step == 2 %]
Lines 265-271 $(document).ready(function() { Link Here
265
        <b>Click <a href="/cgi-bin/koha/acqui/supplier.pl?op=enter">here</a> to create a vendor.</b>
266
        <b>Click <a href="/cgi-bin/koha/acqui/supplier.pl?op=enter">here</a> to create a vendor.</b>
266
        <br><br>
267
        <br><br>
267
        <h2> 2. Create your first basket</h2>
268
        <h2> 2. Create your first basket</h2>
268
        <p> A basket is the conceptual container that holds orders. Each basket is assigned to a single vendor so you can perform multiple separate orders from a single vendor simultaneously. Because of its reliance on vendor the basket must be created after the vendor</p>
269
        <p> A basket is the conceptual container that holds orders. Each basket is assigned to a single vendor so you can perform multiple seperate orders from a single vendor simultaneously. Because of its reliance on vendor the basket must be created after the vendor</p>
269
        <b> To create a basket, click the 'New basket' button on the Vendor Information page which is displayed after you create a vendor</b>
270
        <b> To create a basket, click the 'New basket' button on the Vendor Information page which is displayed after you create a vendor</b>
270
        <br><br>
271
        <br><br>
271
        <h2> 3. Create an order</h2>
272
        <h2> 3. Create an order</h2>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-home.tt (-1 / +7 lines)
Lines 20-26 Link Here
20
                    <div class="yui-g">
20
                    <div class="yui-g">
21
                    [% INCLUDE 'labels-toolbar.inc' %]
21
                    [% INCLUDE 'labels-toolbar.inc' %]
22
                        <div class="yui-u first">
22
                        <div class="yui-u first">
23
23
                            [% IF !(layoutvalue) %]
24
                                [% displayonboarding = "label" %]
25
                                [% INCLUDE 'onboardinginclude1.inc' %]
26
                            [% ELSIF !(templatevalue) %]
27
                                [% displayonboarding = "label" %]
28
                                [% INCLUDE 'onboardinginclude2.inc' %]
29
                            [% END %]
24
                        </div>
30
                        </div>
25
                    </div>
31
                    </div>
26
                </div>
32
                </div>
(-)a/labels/label-edit-layout.pl (-9 / +22 lines)
Lines 123-142 elsif ($op eq 'save') { Link Here
123
        $layout = C4::Labels::Layout->new(@params);
123
        $layout = C4::Labels::Layout->new(@params);
124
        $layout_id = $layout->save();
124
        $layout_id = $layout->save();
125
    }
125
    }
126
    print $cgi->redirect("label-manage.pl?label_element=layout" . ($layout_id == -1 ? "&element_id=$layout_id&op=$op&error=1" : ''));
126
127
    exit;
127
    my $layoutvalue = C4::Creators::Layout->retrieve_all();
128
    my $templatecount = C4::Creators::Template->retrieve_all();
129
    $template->param( layoutvalue => $layoutvalue,
130
         templatevalue => $templatecount,
131
    );
132
133
    if ($templatecount == 0) {
134
        print $cgi->redirect("/cgi-bin/koha/labels/label-home.pl");
135
        exit;
136
    } else {
137
        print $cgi->redirect("label-manage.pl?label_element=layout" . ($layout_id == -1 ? "&element_id=$layout_id&op=$op&error=1" : ''));
138
        exit;
139
    }
128
}
140
}
129
else {  # if we get here, this is a new layout
141
else {  # if we get here, this is a new layout
130
    $layout = C4::Labels::Layout->new();
142
    $layout = C4::Labels::Layout->new();
131
}
143
}
132
144
133
my $barcode_types = _set_selected(get_barcode_types(), $layout, 'barcode_type');
145
    my $barcode_types = _set_selected(get_barcode_types(), $layout, 'barcode_type');
134
my $label_types = _set_selected(get_label_types(), $layout, 'printing_type');
146
    my $label_types = _set_selected(get_label_types(), $layout, 'printing_type');
135
my $font_types = _set_selected(get_font_types(), $layout, 'font');
147
    my $font_types = _set_selected(get_font_types(), $layout, 'font');
136
my $text_justification_types = _set_selected(get_text_justification_types(), $layout, 'text_justify');
148
    my $text_justification_types = _set_selected(get_text_justification_types(), $layout, 'text_justify');
137
my ($select_text_fields, $select_text_fields_cnt) = _select_format_string($layout->get_attr('format_string'));
149
    my ($select_text_fields, $select_text_fields_cnt) = _select_format_string($layout->get_attr('format_string'));
138
150
139
$template->param(
151
    $template->param(
140
        barcode_types   => $barcode_types,
152
        barcode_types   => $barcode_types,
141
        label_types     => $label_types,
153
        label_types     => $label_types,
142
        font_types      => $font_types,
154
        font_types      => $font_types,
Lines 151-155 $template->param( Link Here
151
        callnum_split   => $layout->get_attr('callnum_split'),
163
        callnum_split   => $layout->get_attr('callnum_split'),
152
        format_string   => $layout->get_attr('format_string'),
164
        format_string   => $layout->get_attr('format_string'),
153
        layout_string   => 1,   # FIXME: This should not be hard-coded; It should perhaps be yet another syspref... CN
165
        layout_string   => 1,   # FIXME: This should not be hard-coded; It should perhaps be yet another syspref... CN
154
);
166
    );
167
155
output_html_with_http_headers $cgi, $cookie, $template->output;
168
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/labels/label-edit-template.pl (-2 / +9 lines)
Lines 111-118 elsif ($op eq 'save') { Link Here
111
            $profile->save();
111
            $profile->save();
112
        }
112
        }
113
    }
113
    }
114
    print $cgi->redirect("label-manage.pl?label_element=template");
114
115
    exit;
115
    my $profilevalue = C4::Creators::Profile->retrieve_all();
116
    if ($profilevalue == 0) {
117
        print $cgi->redirect("label-edit-profile.pl");
118
        exit;
119
    }else{
120
        print $cgi->redirect("/cgi-bin/koha/labels/label-home.pl");
121
        exit;
122
    }
116
}
123
}
117
else {  # if we get here, this is a new layout
124
else {  # if we get here, this is a new layout
118
    $label_template = C4::Labels::Template->new();
125
    $label_template = C4::Labels::Template->new();
(-)a/labels/label-home.pl (-1 / +70 lines)
Lines 22-30 use strict; Link Here
22
use warnings;
22
use warnings;
23
23
24
use CGI qw ( -utf8 );
24
use CGI qw ( -utf8 );
25
use POSIX;
25
26
26
use C4::Auth qw(get_template_and_user);
27
use C4::Auth qw(get_template_and_user);
27
use C4::Output qw(output_html_with_http_headers);
28
use C4::Output qw(output_html_with_http_headers);
29
use C4::Creators::Layout;
30
use C4::Creators::Template;
31
use C4::Creators;
32
use C4::Labels;
28
33
29
my $cgi = new CGI;
34
my $cgi = new CGI;
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
35
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 38-41 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
38
    }
43
    }
39
);
44
);
40
45
46
my $op = $cgi->param('op') || '';
47
my $layout_id = $cgi->param('layout_id') || $cgi->param('element_id') || '';
48
my $layout_choice = $cgi->param('layout_choice') || '';
49
my $layout = C4::Labels::Layout->new();
50
51
sub _set_selected {
52
    my ($type_list, $object, $data_type) = @_;
53
    SET_SELECTED:
54
    foreach my $type (@$type_list) {
55
    if ($layout->get_attr($data_type)) {
56
     if ($type->{'type'} eq $layout->get_attr($data_type)) {
57
           $type->{'selected'} = 1;
58
     }
59
   }
60
   else {
61
      $type->{'selected'} = 1;
62
      last SET_SELECTED;
63
   }
64
};
65
return $type_list;
66
}
67
68
sub _select_format_string {     # generate field table based on format_string
69
   my $format_string = shift;
70
71
   my @text_fields = grep /\w/, split /\s*,\s/, $format_string;
72
  my %tf = map {$_ => 1} @text_fields;
73
   my @missing_fields = grep { !$tf{$_} } @{ C4::Labels::Layout->PRESET_FIELDS };
74
   my $field_count = scalar(@text_fields) + scalar( @missing_fields);
75
76
    my @fields;
77
    my $field_index = 1;
78
   foreach my $f (@text_fields) {
79
      push @fields, {field_name => ($f . "_tbl"), field_label => $f, order => $field_index};
80
      $field_index++;
81
   }
82
   foreach my $f (@missing_fields) {
83
      push @fields, {field_name => ($f . "_tbl"), field_label => $f};
84
   }
85
   return (\@fields, $field_count);
86
}
87
88
my $barcode_types = _set_selected(get_barcode_types(), $layout, 'barcode_type');
89
my $label_types = _set_selected(get_label_types(), $layout, 'printing_type');
90
my $font_types = _set_selected(get_font_types(), $layout, 'font');
91
my $text_justification_types = _set_selected(get_text_justification_types(), $layout, 'text_justify');
92
my ($select_text_fields, $select_text_fields_cnt) = _select_format_string($layout->get_attr('format_string'));
93
my $units = get_unit_values();
94
95
$template->param(
96
   barcode_types   => $barcode_types,
97
   label_types     => $label_types,
98
   font_types      => $font_types,
99
   text_justification_types    => $text_justification_types,
100
   fields          => $select_text_fields,
101
   field_count     => $select_text_fields_cnt,
102
   units           => $units,
103
);
104
105
my $layoutvalue = C4::Creators::Layout->retrieve_all();
106
my $templatevalue = C4::Creators::Template->retrieve_all();
107
$template->param( layoutvalue => $layoutvalue,
108
                  templatevalue => $templatevalue,
109
);
110
41
output_html_with_http_headers $cgi, $cookie, $template->output;
111
output_html_with_http_headers $cgi, $cookie, $template->output;
42
- 

Return to bug 18060