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

(-)a/cataloguing/additem.pl (-6 / +33 lines)
Lines 33-38 use C4::ClassSource; Link Here
33
use C4::Dates;
33
use C4::Dates;
34
use List::MoreUtils qw/any/;
34
use List::MoreUtils qw/any/;
35
use C4::Search;
35
use C4::Search;
36
use C4::Members;
36
37
37
use MARC::File::XML;
38
use MARC::File::XML;
38
use URI::Escape;
39
use URI::Escape;
Lines 100-108 sub _increment_barcode { Link Here
100
101
101
102
102
sub generate_subfield_form {
103
sub generate_subfield_form {
103
        my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i) = @_;
104
        my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i, $limitededition) = @_;
104
  
105
  
105
  my $frameworkcode = &GetFrameworkCode($biblionumber);
106
        my $frameworkcode = &GetFrameworkCode($biblionumber);
107
        my ($barcodefield,    $barcodesubfield)      = GetMarcFromKohaField("items.barcode", $frameworkcode);
108
        my ($notesfield,      $notessubfield)        = GetMarcFromKohaField("items.itemnotes", $frameworkcode);
109
        my ($notforloanfield, $notforloansubfield)   = GetMarcFromKohaField("items.notforloan", $frameworkcode);
110
106
        my %subfield_data;
111
        my %subfield_data;
107
        my $dbh = C4::Context->dbh;        
112
        my $dbh = C4::Context->dbh;        
108
        my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib");
113
        my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib");
Lines 152-157 sub generate_subfield_form { Link Here
152
	    $value = $input->param('barcode');
157
	    $value = $input->param('barcode');
153
	}
158
	}
154
        my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="$subfield_data{maxlength}" );
159
        my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="$subfield_data{maxlength}" );
160
        $attributes_no_value .= 'readonly="readonly" '
161
            if (
162
                $limitededition
163
                and $subfieldtag ne $barcodesubfield
164
                and $subfieldtag ne $notessubfield
165
                and $subfieldtag ne $notforloansubfield
166
            );
167
155
        my $attributes          = qq($attributes_no_value value="$value" );
168
        my $attributes          = qq($attributes_no_value value="$value" );
156
        
169
        
157
        if ( $subfieldlib->{authorised_value} ) {
170
        if ( $subfieldlib->{authorised_value} ) {
Lines 212-218 sub generate_subfield_form { Link Here
212
                $subfield_data{marc_value} = qq(<input type="hidden" $attributes /> $authorised_lib{$value});
225
                $subfield_data{marc_value} = qq(<input type="hidden" $attributes /> $authorised_lib{$value});
213
            }
226
            }
214
            else {
227
            else {
215
                $subfield_data{marc_value} =CGI::scrolling_list(      # FIXME: factor out scrolling_list
228
                my @scrparam = (
216
                    -name     => "field_value",
229
                    -name     => "field_value",
217
                    -values   => \@authorised_values,
230
                    -values   => \@authorised_values,
218
                    -default  => $value,
231
                    -default  => $value,
Lines 224-229 sub generate_subfield_form { Link Here
224
                    -id       => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield,
237
                    -id       => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield,
225
                    -class    => "input_marceditor",
238
                    -class    => "input_marceditor",
226
                );
239
                );
240
241
                push @scrparam, (-readonly => "readonly"), (-disabled => "disabled")
242
                    if (
243
                        $limitededition
244
                        and $subfieldtag ne $barcodesubfield
245
                        and $subfieldtag ne $notessubfield
246
                        and $subfieldtag ne $notforloansubfield
247
                    );
248
                $subfield_data{marc_value} =CGI::scrolling_list(@scrparam);
227
            }
249
            }
228
250
229
        }
251
        }
Lines 308-313 my ($template, $loggedinuser, $cookie) Link Here
308
                 });
330
                 });
309
331
310
332
333
# Does the user have a limited item edition permission?
334
my $uid = GetMember( borrowernumber => $loggedinuser )->{userid} if ($loggedinuser) ;
335
my $limitededition = haspermission($uid,  {'editcatalogue' => 'limited_item_edition'}) if ($uid);
336
# In case user is a superlibrarian, edition is not limited
337
$limitededition = 0 if ($limitededition != 0 && $limitededition->{'superlibrarian'} eq 1);
338
311
my $today_iso = C4::Dates->today('iso');
339
my $today_iso = C4::Dates->today('iso');
312
my $tagslib = &GetMarcStructure(1,$frameworkcode);
340
my $tagslib = &GetMarcStructure(1,$frameworkcode);
313
my $record = GetMarcBiblio($biblionumber);
341
my $record = GetMarcBiblio($biblionumber);
Lines 682-689 if($itemrecord){ Link Here
682
            next if subfield_is_koha_internal_p($subfieldtag);
710
            next if subfield_is_koha_internal_p($subfieldtag);
683
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
711
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
684
712
685
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i);        
713
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $limitededition);
686
687
            push @fields, "$tag$subfieldtag";
714
            push @fields, "$tag$subfieldtag";
688
            push (@loop_data, $subfield_data);
715
            push (@loop_data, $subfield_data);
689
            $i++;
716
            $i++;
Lines 702-708 foreach my $tag ( keys %{$tagslib}){ Link Here
702
        my @values = (undef);
729
        my @values = (undef);
703
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)->subfield($subtag)));
730
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)->subfield($subtag)));
704
        for my $value (@values){
731
        for my $value (@values){
705
            my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i); 
732
            my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $limitededition); 
706
            push (@loop_data, $subfield_data);
733
            push (@loop_data, $subfield_data);
707
            $i++;
734
            $i++;
708
        } 
735
        } 
(-)a/installer/data/mysql/en/mandatory/userpermissions.sql (+3 lines)
Lines 6-11 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
6
   ( 9, 'edit_catalogue', 'Edit catalog (Modify bibliographic/holdings data)'),
6
   ( 9, 'edit_catalogue', 'Edit catalog (Modify bibliographic/holdings data)'),
7
   ( 9, 'fast_cataloging', 'Fast cataloging'),
7
   ( 9, 'fast_cataloging', 'Fast cataloging'),
8
   ( 9, 'edit_items', 'Edit Items'),
8
   ( 9, 'edit_items', 'Edit Items'),
9
   ( 9, 'limited_item_edition', 'Limit item modification to barcode, status and note (please note that edit_item is still required)'),
10
   ( 9, 'delete_all_items', 'Delete all items'),
9
   (11, 'vendors_manage', 'Manage vendors'),
11
   (11, 'vendors_manage', 'Manage vendors'),
10
   (11, 'contracts_manage', 'Manage contracts'),
12
   (11, 'contracts_manage', 'Manage contracts'),
11
   (11, 'period_manage', 'Manage periods'),
13
   (11, 'period_manage', 'Manage periods'),
Lines 34-39 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
34
   (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
36
   (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
35
   (13, 'schedule_tasks', 'Schedule tasks to run'),
37
   (13, 'schedule_tasks', 'Schedule tasks to run'),
36
   (13, 'items_batchmod', 'Perform batch modification of items'),
38
   (13, 'items_batchmod', 'Perform batch modification of items'),
39
   (13, 'items_limited_batchmod', 'Limit batch item modification to item status (please note that items_batchmod is still required)'),
37
   (13, 'items_batchdel', 'Perform batch deletion of items'),
40
   (13, 'items_batchdel', 'Perform batch deletion of items'),
38
   (13, 'manage_csv_profiles', 'Manage CSV export profiles'),
41
   (13, 'manage_csv_profiles', 'Manage CSV export profiles'),
39
   (13, 'moderate_tags', 'Moderate patron tags'),
42
   (13, 'moderate_tags', 'Moderate patron tags'),
(-)a/installer/data/mysql/updatedatabase.pl (+21 lines)
Lines 5284-5289 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5284
    SetVersion($DBversion);
5284
    SetVersion($DBversion);
5285
}
5285
}
5286
5286
5287
5288
5289
$DBversion = "3.09.00.007";
5290
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5291
    $dbh->do(qq{
5292
       INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'limited_item_edition', 'Limit item modification to barcode, status and note (please note that edit_item is still required)');
5293
   });
5294
5295
   $dbh->do(qq{
5296
       INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'delete_all_items', 'Delete all items at once');
5297
   });
5298
5299
   $dbh->do(qq{
5300
       INSERT INTO permissions (module_bit, code, description) VALUES ('13', 'items_limited_batchmod', 'Limit batch item modification to item status (please note that items_batchmod is still required)');
5301
   });
5302
5303
    print "Upgrade to $DBversion done (Adds new permissions for cataloguing and batch item modification)\n";
5304
5305
    SetVersion($DBversion);
5306
}
5307
5287
=head1 FUNCTIONS
5308
=head1 FUNCTIONS
5288
5309
5289
=head2 TableExists($table)
5310
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (-1 / +1 lines)
Lines 117-123 function confirm_items_deletion() { Link Here
117
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Edit as new (duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]&amp;frameworkcode=&amp;op=duplicate" },[% END %]
117
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Edit as new (duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]&amp;frameworkcode=&amp;op=duplicate" },[% END %]
118
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Replace record via Z39.50"), onclick: {fn: PopupZ3950 } },[% END %]
118
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Replace record via Z39.50"), onclick: {fn: PopupZ3950 } },[% END %]
119
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Delete record"), onclick: {fn: confirm_deletion }[% IF ( count ) %],id:'disabled'[% END %] },[% END %]
119
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Delete record"), onclick: {fn: confirm_deletion }[% IF ( count ) %],id:'disabled'[% END %] },[% END %]
120
            [% IF ( CAN_user_editcatalogue_edit_items ) %]{ text: _("Delete all items"), onclick: {fn: confirm_items_deletion }[% UNLESS ( count ) %],id:'disabled'[% END %] }[% END %]
120
            [% IF ( CAN_user_editcatalogue_delete_all_items ) %]{ text: _("Delete all items"), onclick: {fn: confirm_items_deletion }[% UNLESS ( count ) %],id:'disabled'[% END %] }[% END %]
121
	    ];
121
	    ];
122
		if(editmenu.length){
122
		if(editmenu.length){
123
			new YAHOO.widget.Button({
123
			new YAHOO.widget.Button({
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-1 / +8 lines)
Lines 52-57 function Check(f) { Link Here
52
52
53
    var alertString2;
53
    var alertString2;
54
    if (total_errors==0) {
54
    if (total_errors==0) {
55
        // Explanation about this line: 
56
        // In case of limited edition permission, we have to prevent user from modifying some fields.
57
        // But there is no such thing as readonly attribute for select elements.
58
        // So we use disabled instead. But disabled prevent values from being passed through the form at submit.
59
        // So we "un-disable" the elements just before submitting.
60
        // That's a bit clumsy, and if someone comes up with a better solution, feel free to improve that.
61
        $("select[name=field_value]").removeAttr("disabled");
55
        return true;
62
        return true;
56
    } else {
63
    } else {
57
        alertString2  = _("Form not submitted because of the following problem(s)");
64
        alertString2  = _("Form not submitted because of the following problem(s)");
Lines 222-228 $(document).ready(function() { Link Here
222
</div>
229
</div>
223
<div class="yui-u">
230
<div class="yui-u">
224
<div id="cataloguing_additem_newitem">
231
<div id="cataloguing_additem_newitem">
225
    <form method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
232
    <form id="f" method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
226
    <input type="hidden" name="op" value="[% op %]" />
233
    <input type="hidden" name="op" value="[% op %]" />
227
    [% IF (popup) %]
234
    [% IF (popup) %]
228
        <input type="hidden" name="popup" value="1" />
235
        <input type="hidden" name="popup" value="1" />
(-)a/tools/batchMod.pl (-1 / +7 lines)
Lines 33-38 use C4::BackgroundJob; Link Here
33
use C4::ClassSource;
33
use C4::ClassSource;
34
use C4::Dates;
34
use C4::Dates;
35
use C4::Debug;
35
use C4::Debug;
36
use C4::Members;
36
use MARC::File::XML;
37
use MARC::File::XML;
37
38
38
my $input = new CGI;
39
my $input = new CGI;
Lines 67-72 my ($template, $loggedinuser, $cookie) Link Here
67
                 flagsrequired => $template_flag,
68
                 flagsrequired => $template_flag,
68
                 });
69
                 });
69
70
71
# Does the user have a limited item edition permission?
72
my $uid = GetMember( borrowernumber => $loggedinuser )->{userid} if ($loggedinuser) ;
73
my $limitededition = haspermission($uid,  {'tools' => 'items_limited_batchmod'}) if ($uid);
74
# In case user is a superlibrarian, edition is not limited
75
$limitededition = 0 if ($limitededition != 0 && $limitededition->{'superlibrarian'} eq 1);
70
76
71
my $today_iso = C4::Dates->today('iso');
77
my $today_iso = C4::Dates->today('iso');
72
$template->param(today_iso => $today_iso);
78
$template->param(today_iso => $today_iso);
Lines 280-285 foreach my $tag (sort keys %{$tagslib}) { Link Here
280
    # loop through each subfield
286
    # loop through each subfield
281
    foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
287
    foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
282
     	next if subfield_is_koha_internal_p($subfield);
288
     	next if subfield_is_koha_internal_p($subfield);
289
        next if ($limitededition && $tagslib->{$tag}->{$subfield}->{'kohafield'} ne 'items.notforloan');
283
    	next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
290
    	next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
284
        # barcode and stocknumber are not meant to be batch-modified
291
        # barcode and stocknumber are not meant to be batch-modified
285
    	next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode';
292
    	next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode';
286
- 

Return to bug 7673