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

(-)a/C4/Biblio.pm (-3 / +5 lines)
Lines 982-1000 sub GetMarcStructure { Link Here
982
982
983
    my $dbh = C4::Context->dbh;
983
    my $dbh = C4::Context->dbh;
984
    my $sth = $dbh->prepare(
984
    my $sth = $dbh->prepare(
985
        "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable 
985
        "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable,ind1_defaultvalue,ind2_defaultvalue
986
        FROM marc_tag_structure 
986
        FROM marc_tag_structure 
987
        WHERE frameworkcode=? 
987
        WHERE frameworkcode=? 
988
        ORDER BY tagfield"
988
        ORDER BY tagfield"
989
    );
989
    );
990
    $sth->execute($frameworkcode);
990
    $sth->execute($frameworkcode);
991
    my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable );
991
    my ( $liblibrarian, $libopac, $tag, $res, $tab, $mandatory, $repeatable, $ind1_defaultvalue, $ind2_defaultvalue );
992
992
993
    while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable ) = $sth->fetchrow ) {
993
    while ( ( $tag, $liblibrarian, $libopac, $mandatory, $repeatable, $ind1_defaultvalue, $ind2_defaultvalue ) = $sth->fetchrow ) {
994
        $res->{$tag}->{lib}        = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
994
        $res->{$tag}->{lib}        = ( $forlibrarian or !$libopac ) ? $liblibrarian : $libopac;
995
        $res->{$tag}->{tab}        = "";
995
        $res->{$tag}->{tab}        = "";
996
        $res->{$tag}->{mandatory}  = $mandatory;
996
        $res->{$tag}->{mandatory}  = $mandatory;
997
        $res->{$tag}->{repeatable} = $repeatable;
997
        $res->{$tag}->{repeatable} = $repeatable;
998
	$res->{$tag}->{ind1_defaultvalue} = $ind1_defaultvalue;
999
	$res->{$tag}->{ind2_defaultvalue} = $ind2_defaultvalue;
998
    }
1000
    }
999
1001
1000
    $sth = $dbh->prepare(
1002
    $sth = $dbh->prepare(
(-)a/admin/marctagstructure.pl (-7 / +21 lines)
Lines 89-95 if ($op eq 'add_form') { Link Here
89
	#---- if primkey exists, it's a modify action, so read values to modify...
89
	#---- if primkey exists, it's a modify action, so read values to modify...
90
	my $data;
90
	my $data;
91
	if ($searchfield) {
91
	if ($searchfield) {
92
		$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where tagfield=? and frameworkcode=?");
92
		$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,ind1_defaultvalue,ind2_defaultvalue from marc_tag_structure where tagfield=? and frameworkcode=?");
93
		$sth->execute($searchfield,$frameworkcode);
93
		$sth->execute($searchfield,$frameworkcode);
94
		$data=$sth->fetchrow_hashref;
94
		$data=$sth->fetchrow_hashref;
95
	}
95
	}
Lines 108-113 if ($op eq 'add_form') { Link Here
108
            repeatable => $data->{'repeatable'},
108
            repeatable => $data->{'repeatable'},
109
            mandatory => $data->{'mandatory'},
109
            mandatory => $data->{'mandatory'},
110
            authorised_value => $data->{authorised_value},
110
            authorised_value => $data->{authorised_value},
111
            ind1_defaultvalue => $data->{'ind1_defaultvalue'},
112
            ind2_defaultvalue => $data->{'ind2_defaultvalue'},
111
			frameworkcode => $frameworkcode,
113
			frameworkcode => $frameworkcode,
112
    );  # FIXME: move checkboxes to presentation layer
114
    );  # FIXME: move checkboxes to presentation layer
113
													# END $OP eq ADD_FORM
115
													# END $OP eq ADD_FORM
Lines 120-140 if ($op eq 'add_form') { Link Here
120
	my $repeatable       = $input->param('repeatable') ? 1 : 0;
122
	my $repeatable       = $input->param('repeatable') ? 1 : 0;
121
	my $mandatory        = $input->param('mandatory')  ? 1 : 0;
123
	my $mandatory        = $input->param('mandatory')  ? 1 : 0;
122
	my $authorised_value = $input->param('authorised_value');
124
	my $authorised_value = $input->param('authorised_value');
125
    my $ind1_defaultvalue = $input->param('ind1_defaultvalue');
126
    my $ind2_defaultvalue = $input->param('ind2_defaultvalue');
123
    if ($input->param('modif')) {
127
    if ($input->param('modif')) {
124
        $sth = $dbh->prepare(
128
        $sth = $dbh->prepare(
125
        "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?"
129
        "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=?, ind1_defaultvalue=?, ind2_defaultvalue=? WHERE frameworkcode=? AND tagfield=?"
126
        );
130
        );
127
        $sth->execute(  $liblibrarian,
131
        $sth->execute(  $liblibrarian,
128
                        $libopac,
132
                        $libopac,
129
                        $repeatable,
133
                        $repeatable,
130
                        $mandatory,
134
                        $mandatory,
131
                        $authorised_value,
135
                        $authorised_value,
136
                        $ind1_defaultvalue,
137
                        $ind2_defaultvalue,
132
                        $frameworkcode,
138
                        $frameworkcode,
133
                        $tagfield
139
                        $tagfield
134
        );
140
        );
135
    } else {
141
    } else {
136
        $sth = $dbh->prepare(
142
        $sth = $dbh->prepare(
137
        "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)"
143
        "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,ind1_defaultvalue,ind2_defaultvalue,frameworkcode) values (?,?,?,?,?,?,?,?,?)"
138
        );
144
        );
139
        $sth->execute($tagfield,
145
        $sth->execute($tagfield,
140
                      $liblibrarian,
146
                      $liblibrarian,
Lines 142-147 if ($op eq 'add_form') { Link Here
142
                      $repeatable,
148
                      $repeatable,
143
                      $mandatory,
149
                      $mandatory,
144
                      $authorised_value,
150
                      $authorised_value,
151
                      $ind1_defaultvalue,
152
                      $ind2_defaultvalue,
145
                      $frameworkcode
153
                      $frameworkcode
146
        );
154
        );
147
    }
155
    }
Lines 155-161 if ($op eq 'add_form') { Link Here
155
################## DELETE_CONFIRM ##################################
163
################## DELETE_CONFIRM ##################################
156
# called by default form, used to confirm deletion of data in DB
164
# called by default form, used to confirm deletion of data in DB
157
} elsif ($op eq 'delete_confirm') {
165
} elsif ($op eq 'delete_confirm') {
158
	$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where tagfield=? and frameworkcode=?");
166
	$sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,ind1_defaultvalue,ind2_defaultvalue from marc_tag_structure where tagfield=? and frameworkcode=?");
159
    $sth->execute($searchfield, $frameworkcode);
167
    $sth->execute($searchfield, $frameworkcode);
160
    my $data = $sth->fetchrow_hashref;
168
    my $data = $sth->fetchrow_hashref;
161
	$template->param(
169
	$template->param(
Lines 215-220 if ($op eq 'add_form') { Link Here
215
		              marc_tag_structure.repeatable as mts_repeatable,
223
		              marc_tag_structure.repeatable as mts_repeatable,
216
		              marc_tag_structure.mandatory as mts_mandatory,
224
		              marc_tag_structure.mandatory as mts_mandatory,
217
		              marc_tag_structure.authorised_value as mts_authorized_value,
225
		              marc_tag_structure.authorised_value as mts_authorized_value,
226
			      marc_tag_structure.ind1_defaultvalue as mts_ind1_defaultvalue,
227
			      marc_tag_structure.ind1_defaultvalue as mts_ind2_defaultvalue,
218
		              marc_subfield_structure.*
228
		              marc_subfield_structure.*
219
                FROM marc_tag_structure 
229
                FROM marc_tag_structure 
220
                LEFT JOIN marc_subfield_structure ON (marc_tag_structure.tagfield=marc_subfield_structure.tagfield AND marc_tag_structure.frameworkcode=marc_subfield_structure.frameworkcode) WHERE (marc_tag_structure.tagfield >= ? and marc_tag_structure.frameworkcode=?) AND marc_subfield_structure.tab>=0 ORDER BY marc_tag_structure.tagfield,marc_subfield_structure.tagsubfield");
230
                LEFT JOIN marc_subfield_structure ON (marc_tag_structure.tagfield=marc_subfield_structure.tagfield AND marc_tag_structure.frameworkcode=marc_subfield_structure.frameworkcode) WHERE (marc_tag_structure.tagfield >= ? and marc_tag_structure.frameworkcode=?) AND marc_subfield_structure.tab>=0 ORDER BY marc_tag_structure.tagfield,marc_subfield_structure.tagsubfield");
Lines 236-241 if ($op eq 'add_form') { Link Here
236
			$row_data{repeatable}       = $results[$i]->{'mts_repeatable'};
246
			$row_data{repeatable}       = $results[$i]->{'mts_repeatable'};
237
			$row_data{mandatory}        = $results[$i]->{'mts_mandatory'};
247
			$row_data{mandatory}        = $results[$i]->{'mts_mandatory'};
238
			$row_data{authorised_value} = $results[$i]->{'mts_authorised_value'};
248
			$row_data{authorised_value} = $results[$i]->{'mts_authorised_value'};
249
			$row_data{ind1_defaultvalue} = $results[$i]->{'mts_ind1_defaultvalue'};
250
			$row_data{ind2_defaultvalue} = $results[$i]->{'mts_ind2_defaultvalue'};
239
			$row_data{subfield_link} = "marc_subfields_structure.pl?op=add_form&tagfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
251
			$row_data{subfield_link} = "marc_subfields_structure.pl?op=add_form&tagfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
240
			$row_data{edit}          = "$script_name?op=add_form&searchfield="            .$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
252
			$row_data{edit}          = "$script_name?op=add_form&searchfield="            .$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
241
			$row_data{delete}        = "$script_name?op=delete_confirm&searchfield="      .$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
253
			$row_data{delete}        = "$script_name?op=delete_confirm&searchfield="      .$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
Lines 281-286 if ($op eq 'add_form') { Link Here
281
			$row_data{repeatable}       = $results->[$i]{'repeatable'};
293
			$row_data{repeatable}       = $results->[$i]{'repeatable'};
282
			$row_data{mandatory}        = $results->[$i]{'mandatory'};
294
			$row_data{mandatory}        = $results->[$i]{'mandatory'};
283
			$row_data{authorised_value} = $results->[$i]{'authorised_value'};
295
			$row_data{authorised_value} = $results->[$i]{'authorised_value'};
296
			$row_data{ind1_defaultvalue} = $results->[$i]{'ind1_defaultvalue'};
297
			$row_data{ind2_defaultvalue} = $results->[$i]{'ind2_defaultvalue'};
284
			$row_data{subfield_link}    = "marc_subfields_structure.pl?tagfield="          .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
298
			$row_data{subfield_link}    = "marc_subfields_structure.pl?tagfield="          .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
285
			$row_data{edit}             = "$script_name?op=add_form&searchfield="      .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
299
			$row_data{edit}             = "$script_name?op=add_form&searchfield="      .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
286
			$row_data{delete}           = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
300
			$row_data{delete}           = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
Lines 313-319 output_html_with_http_headers $input, $cookie, $template->output; Link Here
313
sub StringSearch  {
327
sub StringSearch  {
314
	my ($searchstring,$frameworkcode)=@_;
328
	my ($searchstring,$frameworkcode)=@_;
315
	my $sth = C4::Context->dbh->prepare("
329
	my $sth = C4::Context->dbh->prepare("
316
    SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value
330
    SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,ind1_defaultvalue,ind2_defaultvalue
317
     FROM  marc_tag_structure
331
     FROM  marc_tag_structure
318
     WHERE (tagfield >= ? and frameworkcode=?)
332
     WHERE (tagfield >= ? and frameworkcode=?)
319
    ORDER BY tagfield
333
    ORDER BY tagfield
Lines 329-336 sub StringSearch { Link Here
329
sub duplicate_framework {
343
sub duplicate_framework {
330
	my ($newframeworkcode,$oldframeworkcode) = @_;
344
	my ($newframeworkcode,$oldframeworkcode) = @_;
331
	my $dbh = C4::Context->dbh;
345
	my $dbh = C4::Context->dbh;
332
    $dbh->do(q|INSERT INTO marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode)
346
    $dbh->do(q|INSERT INTO marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, ind1_defaultvalue, ind2_defaultvalue, frameworkcode)
333
        SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value, ? from marc_tag_structure where frameworkcode=?|, undef, $newframeworkcode, $oldframeworkcode );
347
        SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value, ind1_defaultvalue, ind2_defaultvalue, ? from marc_tag_structure where frameworkcode=?|, undef, $newframeworkcode, $oldframeworkcode );
334
348
335
    $dbh->do(q|INSERT INTO marc_subfield_structure (frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden)
349
    $dbh->do(q|INSERT INTO marc_subfield_structure (frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden)
336
        SELECT ?,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden from marc_subfield_structure where frameworkcode=?
350
        SELECT ?,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden from marc_subfield_structure where frameworkcode=?
(-)a/cataloguing/addbiblio.pl (-2 / +2 lines)
Lines 663-670 sub build_tabs { Link Here
663
                        tag_lib          => $tagslib->{$tag}->{lib},
663
                        tag_lib          => $tagslib->{$tag}->{lib},
664
                        repeatable       => $tagslib->{$tag}->{repeatable},
664
                        repeatable       => $tagslib->{$tag}->{repeatable},
665
                        mandatory       => $tagslib->{$tag}->{mandatory},
665
                        mandatory       => $tagslib->{$tag}->{mandatory},
666
                        indicator1       => $indicator1,
666
                        indicator1       => ( $indicator1 || $tagslib->{$tag}->{ind1_defaultvalue} ), #if not set, try to load the default value
667
                        indicator2       => $indicator2,
667
                        indicator2       => ( $indicator2 || $tagslib->{$tag}->{ind2_defaultvalue} ), #use short-circuit operator for efficiency
668
                        subfield_loop    => \@subfields_data,
668
                        subfield_loop    => \@subfields_data,
669
                        tagfirstsubfield => $subfields_data[0],
669
                        tagfirstsubfield => $subfields_data[0],
670
                        fixedfield       => $tag < 10?1:0,
670
                        fixedfield       => $tag < 10?1:0,
(-)a/installer/data/mysql/atomicupdate/bug_9701-add_default_indicators.sql (+3 lines)
Line 0 Link Here
1
ALTER TABLE marc_tag_structure
2
ADD COLUMN ind2_defaultvalue VARCHAR(1) NOT NULL DEFAULT '' AFTER authorised_value,
3
ADD COLUMN ind1_defaultvalue VARCHAR(1) NOT NULL DEFAULT '' AFTER authorised_value;
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 1139-1144 CREATE TABLE `marc_tag_structure` ( Link Here
1139
  `repeatable` tinyint(4) NOT NULL default 0,
1139
  `repeatable` tinyint(4) NOT NULL default 0,
1140
  `mandatory` tinyint(4) NOT NULL default 0,
1140
  `mandatory` tinyint(4) NOT NULL default 0,
1141
  `authorised_value` varchar(10) default NULL,
1141
  `authorised_value` varchar(10) default NULL,
1142
  `ind1_defaultvalue` varchar(1) NOT NULL default '',
1143
  `ind2_defaultvalue` varchar(1) NOT NULL default '',
1142
  `frameworkcode` varchar(4) NOT NULL default '',
1144
  `frameworkcode` varchar(4) NOT NULL default '',
1143
  PRIMARY KEY  (`frameworkcode`,`tagfield`)
1145
  PRIMARY KEY  (`frameworkcode`,`tagfield`)
1144
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1146
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt (-1 / +12 lines)
Lines 79-84 Link Here
79
            <input type="checkbox" name="mandatory" id="mandatory" value="1" />
79
            <input type="checkbox" name="mandatory" id="mandatory" value="1" />
80
        [% END %]
80
        [% END %]
81
    </li>
81
    </li>
82
    <li><label for="ind1_defaultvalue">First indicator default value: </label>
83
	    <input id="ind1_defaultvalue" type="text" name="ind1_defaultvalue" value="[% ind1_defaultvalue |html %]" maxlength="1" size="1" />
84
    </li>
85
    <li><label for="ind2_defaultvalue">Second indicator default value: </label>
86
	    <input id="ind2_defaultvalue" type="text" name="ind2_defaultvalue" value="[% ind2_defaultvalue |html %]" maxlength="1" size="1" />
87
    </li>
82
    <li><label for="authorised_value">Authorized value: </label>
88
    <li><label for="authorised_value">Authorized value: </label>
83
        <select name="authorised_value" id="authorised_value" size="1">
89
        <select name="authorised_value" id="authorised_value" size="1">
84
            <option value=""></option>
90
            <option value=""></option>
Lines 170-175 Link Here
170
        <th>Repeatable</th>
176
        <th>Repeatable</th>
171
        <th>Mandatory</th>
177
        <th>Mandatory</th>
172
        <th>Auth value</th>
178
        <th>Auth value</th>
179
        <th>Indicator 1</th>
180
        <th>Indicator 2</th>
173
        <th>&nbsp;</th>
181
        <th>&nbsp;</th>
174
        </tr>
182
        </tr>
175
    </thead>
183
    </thead>
Lines 190-195 Link Here
190
            <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
198
            <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
191
            <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
199
            <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
192
            <td>[% loo.authorised_value %]</td>
200
            <td>[% loo.authorised_value %]</td>
201
            <td>[% loo.ind1_defaultvalue %]</td>
202
            <td>[% loo.ind2_defaultvalue %]</td>
193
            <td>
203
            <td>
194
                <div class="dropdown">
204
                <div class="dropdown">
195
                    <a class="btn btn-default btn-xs dropdown-toggle" id="marctagactions[% loo.tagfield %]" role="button" data-toggle="dropdown" href="#">
205
                    <a class="btn btn-default btn-xs dropdown-toggle" id="marctagactions[% loo.tagfield %]" role="button" data-toggle="dropdown" href="#">
Lines 211-216 Link Here
211
        <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
221
        <td>[% IF ( loo.repeatable ) %]Yes[% ELSE %]No[% END %]</td>
212
        <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
222
        <td>[% IF ( loo.mandatory ) %]Yes[% ELSE %]No[% END %]</td>
213
        <td>[% loo.authorised_value %]</td>
223
        <td>[% loo.authorised_value %]</td>
224
        <td>[% loo.ind1_defaultvalue %]</td>
225
        <td>[% loo.ind2_defaultvalue %]</td>
214
        <td>
226
        <td>
215
            <div class="dropdown">
227
            <div class="dropdown">
216
                <a class="btn btn-default btn-xs dropdown-toggle" id="marctagactions[% loo.tagfield %]" role="button" data-toggle="dropdown" href="#">
228
                <a class="btn btn-default btn-xs dropdown-toggle" id="marctagactions[% loo.tagfield %]" role="button" data-toggle="dropdown" href="#">
217
- 

Return to bug 9701