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

(-)a/C4/Biblio.pm (+90 lines)
Lines 128-133 BEGIN { Link Here
128
      &TransformHtmlToXml
128
      &TransformHtmlToXml
129
      &PrepareItemrecordDisplay
129
      &PrepareItemrecordDisplay
130
      &GetNoZebraIndexes
130
      &GetNoZebraIndexes
131
      &BatchModField
131
    );
132
    );
132
}
133
}
133
134
Lines 3681-3686 sub get_biblio_authorised_values { Link Here
3681
    return $authorised_values;
3682
    return $authorised_values;
3682
}
3683
}
3683
3684
3685
=head3 BatchModField
3686
3687
  Mod subfields in field record
3688
3689
  returns 1,$record if succeed
3690
  returns 0,$record if Action was not processed
3691
  returns -1 if no record
3692
  returns -2 if no action done on record
3693
3694
=cut
3695
3696
sub BatchModField {
3697
    my ( $record, $field, $subfield, $action, $condval, $nocond, $repval ) = @_;
3698
3699
    return -1 unless $record;
3700
    $condval=NormalizeString($condval);
3701
    my $condition=qr/$condval/;
3702
3703
    if($action eq "add"){
3704
        for my $rfield ($record->field($field)){
3705
            $rfield->add_subfields( $subfield => $repval );
3706
        }
3707
        return 1;
3708
    }elsif($action eq "addfield"){
3709
        my $new_field = MARC::Field->new($field,'','',
3710
                                         $subfield => $repval);
3711
        $record->insert_fields_ordered($new_field);
3712
        return 1;
3713
    } else {
3714
        my $done=0;
3715
        for my $rfield ($record->field($field)) {
3716
            if ($subfield && $subfield ne "@"){
3717
                my @subfields = $rfield->subfields();
3718
                my @subfields_to_add;
3719
            foreach my $subf (@subfields) {
3720
                    if ($subf->[0] eq $subfield){
3721
                        $subf->[1]=NormalizeString($subf->[1]);
3722
                        if ( $action eq "mod" ) {
3723
                            if ( $nocond ne "true" && $subf->[1] =~ s/$condition/$repval/) {
3724
                                $done=1;
3725
                            }
3726
                            if ($nocond eq "true"){
3727
                                $subf->[1] = $repval;
3728
                                $done=1;
3729
                    }
3730
                } elsif ( $action eq "del" ) {
3731
                            if ( $subf->[1] =~ m/$condition/ || $nocond eq "true" ) {
3732
                                $done=1;
3733
                                next;
3734
                            }
3735
                        }
3736
                    }
3737
                    push @subfields_to_add,@$subf;
3738
        }
3739
                if ($done){
3740
                    if (@subfields_to_add){
3741
                        $rfield->replace_with(MARC::Field->new($rfield->tag,$rfield->indicator(1),$rfield->indicator(2),@subfields_to_add));
3742
    }
3743
                    else {
3744
                        my $count= $record->delete_field($rfield);
3745
                    }
3746
                }
3747
            }
3748
            else {
3749
                if ($action eq "del"){
3750
                    my $count=$record->delete_field($rfield);
3751
                    $done=1;
3752
                }
3753
                else {
3754
                    if ($field < 10){
3755
                       my $value=$record->field($field)->data();
3756
                       if ($value=~ s/$condition/$repval/){
3757
                        $record->field($field)->update($value);
3758
                        $done=1;
3759
3760
                       }
3761
                       if ( $nocond eq 'true'){
3762
                        $record->field($field)->update($repval);
3763
                        $done=1;
3764
                       }
3765
                    }
3766
                }
3767
            }
3768
        }
3769
        return ($done,$record);
3770
    }
3771
    return -2;
3772
}
3773
3684
1;
3774
1;
3685
3775
3686
__END__
3776
__END__
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/basket.js (+6 lines)
Lines 433-436 $(document).ready(function(){ Link Here
433
	if(basketcount){ updateBasket(basketcount); }
433
	if(basketcount){ updateBasket(basketcount); }
434
});
434
});
435
435
436
function batchEdit(){
437
    var valCookie = readCookie(nameCookie);
438
    var strCookie = nameParam + "=" + valCookie;
436
439
440
    var loc = CGIBIN + "tools/batchedit.pl?" + strCookie;
441
    window.opener.location = loc;
442
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tmpl (+366 lines)
Line 0 Link Here
1
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2
<title><!-- TMPL_IF NAME="LibraryNameTitle" --><!-- TMPL_VAR NAME="LibraryNameTitle" --><!-- TMPL_ELSE -->Koha Online<!-- /TMPL_IF --> Catalog &rsaquo; Your Cart</title>
3
    <!-- TMPL_IF NAME="print_basket" -->
4
5
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
<link rel="shortcut icon" href="<!-- TMPL_VAR NAME="themelang" -->/includes/favicon.ico" type="image/x-icon" />
7
<meta http-equiv="Content-Language" content="en-us" />
8
<style type="text/css">
9
    @import url(<!-- TMPL_VAR NAME="themelang" -->/css/print.css);
10
</style>
11
    <!-- TMPL_ELSE --><!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
12
	<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
13
	<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
14
	<script type="text/javascript">
15
	//<![CDATA[
16
17
$(document).ready(function()
18
    {
19
        $("#itemst").tablesorter({
20
                        headers: { 0: { sorter: false }}
21
                });
22
    }
23
);
24
25
26
function placeHold () {
27
    var checkedItems = $("input:checkbox:checked");
28
    if ($(checkedItems).size() == 0) {
29
        alert(MSG_NO_RECORD_SELECTED);
30
        return false;
31
    }
32
    var bibs = "";
33
    var badBibs = false;
34
    $(checkedItems).each(function() {
35
        var bib = $(this).val();
36
        bibs += bib + "/";
37
    });
38
39
    var newloc = "/cgi-bin/koha/reserve/request.pl?biblionumbers=" + bibs;
40
    if ($(checkedItems).size() > 1) { newloc += "&multi_hold=1"; }
41
    window.opener.location = newloc;
42
    window.close();
43
}
44
45
46
47
	$(document).ready(function(){
48
		$("#CheckAll").click(function(){
49
		var checked = [];
50
		$("#bookbag_form").checkCheckboxes("*", true).each(
51
		    function() {
52
				selRecord(this.value,true);
53
			}
54
		);
55
	        return false;
56
	    });
57
	    $("#CheckNone").click(function(){
58
	    var checked = [];
59
		$("#bookbag_form").unCheckCheckboxes("*",true).each(
60
		    function() {
61
				selRecord(this.value,false);
62
			}
63
		);
64
	        return false;
65
	    });
66
        $(".holdsep").text("| ");
67
        $(".hold").text(_("Place Hold"));
68
	});
69
70
71
	//]]>
72
	</script>
73
	<!-- /TMPL_IF -->
74
</head>
75
<!-- TMPL_IF NAME="print_basket" --><body id="basket" onload="print();history.back();"><!-- TMPL_ELSE --><body id="basket"><!-- /TMPL_IF -->
76
77
<div id="doc" class="yui-t7">
78
<div class="container">
79
<!-- TMPL_UNLESS NAME="print_basket" -->
80
<h1>Your Cart</h1>
81
82
<div id="toolbar">
83
<ul class="toolbar">
84
	<li>
85
	    <span id="addchild" class="yui-button yui-link-button"><span class="first-child">
86
		<!-- TMPL_IF NAME="verbose" --><a href="basket.pl" class="brief" onclick="showLess(); return false;">Brief Display</a><!-- TMPL_ELSE --><a href="basket.pl" class="detail" onclick="showMore(); return false;">More Details</a><!-- /TMPL_IF -->
87
	    </span></span>
88
	</li>
89
    <li>
90
        <span id="batchedit" class="yui-button yui-link-button"><span class="first-child">
91
        <a class="batchedit" href="basket.pl" onclick="batchEdit(); return false;">Batch Edit</a>
92
        </span></span>
93
    </li>
94
	<li>
95
	    <span id="receive" class="yui-button yui-link-button"><span class="first-child">
96
		<a class="send" href="basket.pl" onclick="sendBasket(); return false;">Send</a>
97
	    </span></span>
98
	</li>
99
	<li>
100
	    <span id="savemenuc" class="yui-button yui-link-button"><span class="first-child">
101
		<a class="download" href="basket.pl" onclick="downloadBasket(); return false;">Download</a>
102
	    </span></span>
103
	</li>
104
	<li>
105
	    <span id="printmenuc" class="yui-button yui-link-button"><span class="first-child">
106
		<a class="print" href="basket.pl" onclick="printBasket(); return false;">Print</a>
107
	    </span></span>
108
	</li>
109
	<li>
110
	    <span id="delete" class="yui-button yui-link-button"><span class="first-child">
111
		<a class="empty" href="basket.pl" onclick="delBasket(); return false;">Empty and Close</a>
112
	    </span></span>
113
	</li>
114
	<li>
115
	    <span id="hide" class="yui-button yui-link-button"><span class="first-child">
116
		<a class="hide" href="basket.pl" onclick="quit(); return false;">Hide Window</a>
117
	    </span></span>
118
	</li>
119
</ul>
120
</div>
121
        <!-- /TMPL_UNLESS -->
122
123
<!-- TMPL_IF NAME="verbose" -->
124
	<!-- TMPL_UNLESS NAME="print_basket" --><p style="padding: 7px 0; border-top : 1px solid #E8E8E8;"><a id="CheckAll" href="#">Select All</a> <a id="CheckNone" href="#">Clear All</a> | <b>Selected items :</b>
125
126
    <a href="#" onclick="delSelRecords(); return false;">Remove</a>
127
128
<!-- TMPL_IF NAME="loggedinusername" -->
129
     | <a href="#" onclick="addSelToShelf(); return false;">Add to a list</a>
130
<!-- /TMPL_IF -->
131
132
<!-- TMPL_IF NAME="CAN_user_reserveforothers" -->
133
     | <a href="#" onclick="placeHold(); return false;">Place Hold</a>
134
<!-- /TMPL_IF -->
135
136
</p><!-- /TMPL_UNLESS -->
137
            <form action="basket.pl" method="get" name="bookbag_form" id="bookbag_form">
138
    <!-- TMPL_LOOP NAME="BIBLIO_RESULTS" -->
139
    <h3>
140
        <!-- TMPL_IF NAME="print_basket" -->
141
            <!-- TMPL_VAR NAME="title" ESCAPE="html" -->
142
                <!-- TMPL_IF name="subtitle" --> <!-- TMPL_VAR NAME="subtitle" --><!-- /TMPL_IF -->
143
                <!-- TMPL_IF name="author" --> <!-- TMPL_VAR NAME="author" --><!-- /TMPL_IF -->
144
        <!-- TMPL_ELSE -->
145
                <input type="checkbox" value="<!-- TMPL_VAR NAME="biblionumber" -->" name="bib<!-- TMPL_VAR NAME="biblionumber" -->" id="bib<!-- TMPL_VAR NAME="biblionumber" -->" onclick="selRecord(value,checked)" />
146
                <!-- TMPL_VAR NAME="title" escape="html" -->
147
                <!-- TMPL_IF name="subtitle" --> <!-- TMPL_VAR NAME="subtitle" --><!-- /TMPL_IF -->
148
                <!-- TMPL_IF name="author" --> <!-- TMPL_VAR NAME="author" --><!-- /TMPL_IF -->
149
        <!-- /TMPL_IF -->
150
    </h3>
151
	    <!-- COinS / OpenURL -->
152
    <span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.au=<!-- TMPL_VAR NAME="author" -->&amp;rft.btitle=<!-- TMPL_VAR NAME="title" ESCAPE="url" -->&amp;rft.date=<!-- TMPL_VAR NAME="publicationyear" -->&amp;rft.tpages=<!-- TMPL_VAR NAME="size" -->&amp;rft.isbn=<!-- TMPL_VAR NAME="isbn"  ESCAPE="url" -->&amp;rft.aucorp=&amp;rft.place=<!-- TMPL_VAR NAME="place" -->&amp;rft.pub=<!-- TMPL_VAR NAME="publisher" ESCAPE="url" -->&amp;rft.edition=<!-- TMPL_VAR NAME="edition" -->&amp;rft.series=<!-- TMPL_VAR NAME="series" -->&amp;rft.genre="></span>
153
    <table>
154
        <!-- TMPL_IF name="isbn" -->
155
        <tr>
156
            <th scope="row">ISBN</th>
157
            <td><!-- TMPL_VAR NAME="isbn" --></td>
158
        </tr>
159
        <!-- /TMPL_IF -->
160
161
        <!-- TMPL_IF "HASAUTHORS" -->
162
        <tr>
163
            <th scope="row">Author(s)</th>
164
            <td>
165
                   <!-- TMPL_IF NAME="author" -->
166
                       <p><!-- TMPL_VAR NAME="author" --></p>
167
                   <!-- /TMPL_IF -->
168
                   <!-- TMPL_IF NAME="MARCAUTHORS" -->
169
                       <!-- TMPL_LOOP NAME="MARCAUTHORS" -->
170
                       <p> <!-- TMPL_LOOP NAME="MARCAUTHOR_SUBFIELDS_LOOP" -->
171
                              <!-- TMPL_VAR NAME="separator" -->
172
                                  <!-- TMPL_VAR NAME="value" -->
173
                           <!-- /TMPL_LOOP -->
174
                       </p>
175
                       <!-- /TMPL_LOOP -->
176
                   <!-- /TMPL_IF -->
177
	    </td>
178
        </tr>
179
        <!-- /TMPL_IF -->
180
181
        <!-- TMPL_IF NAME="publishercode" -->
182
            <tr>
183
                <th scope="row">Publisher</th>
184
                <td><!-- TMPL_VAR NAME="place" --> <!-- TMPL_VAR NAME="publishercode" --> <!-- TMPL_VAR NAME="publicationyear" -->
185
                </td>
186
            </tr>
187
        <!-- /TMPL_IF -->
188
        <!-- TMPL_IF NAME="pages" -->
189
            <tr>
190
                <th scope="row">Details</th>
191
                <td><!-- TMPL_VAR NAME="pages" --> <!-- TMPL_VAR NAME="illus" --> <!-- TMPL_VAR NAME="size" --></td>
192
            </tr>
193
        <!-- /TMPL_IF -->
194
        <!-- TMPL_IF name="seriestitle" -->
195
        <tr>
196
            <th scope="row">Collection</th>
197
            <td> <!-- TMPL_VAR NAME="seriestitle" --></td>
198
        </tr>
199
        <!-- /TMPL_IF -->
200
201
        <!-- TMPL_IF name="MARCSUBJCTS" -->
202
        <tr>
203
            <th scope="row">Subject(s)</th>
204
            <td><!-- TMPL_LOOP NAME="MARCSUBJCTS" -->
205
                   <p> <!-- TMPL_LOOP NAME="MARCSUBJECT_SUBFIELDS_LOOP" -->
206
                        <!-- TMPL_VAR NAME="separator" --><!-- TMPL_VAR NAME="value" --><!-- /TMPL_LOOP -->
207
                   </p>
208
                <!-- /TMPL_LOOP --></td>
209
        </tr>
210
        <!-- /TMPL_IF -->
211
212
        <!-- TMPL_IF name="copyrightdate" -->
213
            <tr><th scope="row">Copyright</th>
214
                <td> <!-- TMPL_VAR NAME="copyrightdate" --></td>
215
            </tr>
216
        <!-- /TMPL_IF -->
217
218
        <!-- TMPL_IF name="MARCNOTES" -->
219
        <tr>
220
            <th scope="row">Notes</th>
221
            <td>
222
            <!-- TMPL_LOOP NAME="MARCNOTES" -->
223
                <p>- <!-- TMPL_VAR NAME="marcnote" --></p>
224
            <!-- /TMPL_LOOP --></td>
225
        </tr>
226
        <!-- /TMPL_IF -->
227
228
        <!-- TMPL_IF name="unititle" -->
229
        <tr>
230
            <th scope="row">Unified title</th>
231
            <td> <!-- TMPL_VAR NAME="unititle" --></td>
232
        </tr>
233
        <!-- /TMPL_IF -->
234
        <!-- TMPL_IF name="serial" -->
235
        <tr>
236
            <th scope="row">Serial</th>
237
            <td><!-- TMPL_VAR NAME="serial" --></td>
238
        </tr>
239
        <!-- /TMPL_IF -->
240
        <!-- TMPL_IF name="dewey" -->
241
        <tr>
242
            <th scope="row">Dewey</th>
243
            <td><!-- TMPL_VAR name="dewey" --></td>
244
        </tr>
245
        <!-- /TMPL_IF -->
246
        <!-- TMPL_IF name="classification" -->
247
        <tr>
248
            <th scope="row">Classification</th>
249
            <td> <!-- TMPL_VAR name="classification" --></td>
250
        </tr>
251
        <!-- /TMPL_IF -->
252
        <!-- TMPL_IF name="lccn" -->
253
        <tr>
254
            <th scope="row">LCCN</th>
255
            <td> <!-- TMPL_VAR name="lccn" --></td>
256
        </tr>
257
        <!-- /TMPL_IF -->
258
259
        <!-- TMPL_IF name="MARCURLS" -->
260
        <tr>
261
            <th scope="row">URL(s)</th>
262
            <td>
263
	   <!-- TMPL_LOOP name="MARCURLS" -->
264
		<p><!-- TMPL_IF NAME="part" --><!-- TMPL_VAR NAME="part" -->
265
			<br /><!-- /TMPL_IF -->
266
267
		<!-- TMPL_VAR NAME="MARCURL" -->
268
			<!-- TMPL_IF NAME="notes" --><!-- TMPL_LOOP NAME="notes" --><!-- TMPL_VAR NAME="note" --><br /><!-- /TMPL_LOOP --><!-- /TMPL_IF -->
269
            <!-- /TMPL_LOOP --></p></td>
270
        </tr><!-- /TMPL_IF -->
271
272
        <tr>
273
            <th scope="row">Location(s)</th>
274
            <td><!-- TMPL_IF NAME="ITEM_RESULTS" --><!-- TMPL_LOOP NAME="ITEM_RESULTS" -->
275
                <p>
276
                    <!-- TMPL_VAR NAME="branchname" --> <!-- TMPL_VAR NAME="location_description" -->
277
                    <!-- TMPL_IF name="itemcallnumber" -->
278
                        (<!-- TMPL_VAR NAME="itemcallnumber" -->)
279
                    <!-- /TMPL_IF -->
280
                </p>
281
                <!-- /TMPL_LOOP --><!-- TMPL_ELSE -->This record has no items.<!-- /TMPL_IF --></td>
282
        </tr>
283
    </table>
284
    <!-- /TMPL_LOOP -->
285
            </form>
286
287
<!-- TMPL_ELSE -->
288
<!-- TMPL_UNLESS NAME="print_basket" -->
289
<p style="border-top : 1px solid #E8E8E8;">
290
	<form action="/cgi-bin/koha/basket/basket.pl" method="get" name="bookbag_form" id="bookbag_form">
291
    <a id="CheckAll" href="#">Select All</a>
292
    <a id="CheckNone" href="#">Clear All</a>
293
    | <b>Selected items :</b>
294
<a href="#" onclick="delSelRecords(); return false;">Remove</a>
295
296
<!-- TMPL_IF NAME="loggedinusername" -->
297
     | <a href="#" onclick="addSelToShelf(); return false;">Add to a list</a>
298
<!-- /TMPL_IF -->
299
300
<!-- TMPL_IF NAME="CAN_user_reserveforothers" -->
301
     | <a href="#" onclick="placeHold(); return false;">Place Hold</a>
302
<!-- /TMPL_IF -->
303
304
305
<!-- /TMPL_UNLESS -->
306
</p>
307
    <table id="itemst">
308
	<thead><tr>
309
	    <th>&nbsp;</th>
310
	    <th>Title</th>
311
	    <th>Item Type</th>
312
	    <th>Location</th>
313
        </tr></thead>
314
315
        <!-- TMPL_LOOP NAME="BIBLIO_RESULTS" -->
316
            <!-- TMPL_IF NAME="even" -->
317
                <tr class="highlight">
318
            <!-- TMPL_ELSE -->
319
                <tr>
320
            <!-- /TMPL_IF -->
321
            <!-- TMPL_UNLESS NAME="print_basket" --><td>
322
                        <input type="checkbox" value="<!-- TMPL_VAR NAME="biblionumber" -->" name="bib<!-- TMPL_VAR NAME="biblionumber" -->" id="bib<!-- TMPL_VAR NAME="biblionumber" -->" onclick="selRecord(value,checked);" />
323
324
                </td> <!-- /TMPL_UNLESS -->
325
            <td><a href="#" onclick="openBiblio('<!-- TMPL_VAR name="dest" -->',<!-- TMPL_VAR name="biblionumber" -->)">
326
                        <!-- TMPL_VAR NAME="title" escape="html" -->
327
                    </a>
328
                        <!-- TMPL_VAR NAME="author" -->
329
                        <p><!-- TMPL_IF name="publishercode" -->- <!-- TMPL_VAR name="publishercode" -->
330
                        <!-- TMPL_IF name="place" --> <!-- TMPL_VAR name="place" --><!-- /TMPL_IF --><!-- /TMPL_IF -->
331
                        <!-- TMPL_IF name="pages" --> - <!-- TMPL_VAR name="pages" --><!-- TMPL_IF name="size" --> <!-- TMPL_VAR name="size" -->
332
                        <!-- /TMPL_IF -->
333
                        <!-- /TMPL_IF --></p>
334
                        <!-- TMPL_IF name="notes" -->
335
                        <p><!-- TMPL_VAR name="notes" --></p>
336
                        <!-- /TMPL_IF -->
337
						    <!-- COinS / OpenURL -->
338
    <span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.au=<!-- TMPL_VAR NAME="author" -->&amp;rft.btitle=<!-- TMPL_VAR NAME="title" ESCAPE="url" -->&amp;rft.date=<!-- TMPL_VAR NAME="publicationyear" -->&amp;rft.tpages=<!-- TMPL_VAR NAME="size" -->&amp;rft.isbn=<!-- TMPL_VAR NAME="isbn"  ESCAPE="url" -->&amp;rft.aucorp=&amp;rft.place=<!-- TMPL_VAR NAME="place" -->&amp;rft.pub=<!-- TMPL_VAR NAME="publisher" ESCAPE="url" -->&amp;rft.edition=<!-- TMPL_VAR NAME="edition" -->&amp;rft.series=<!-- TMPL_VAR NAME="series" -->&amp;rft.genre="></span>
339
340
						</td>
341
            <td><!-- TMPL_VAR name="description" --></td>
342
                <td><!-- TMPL_IF NAME="ITEM_RESULTS" --><!-- TMPL_LOOP NAME="ITEM_RESULTS" -->
343
                    <p>
344
                        <!-- TMPL_VAR NAME="branchname" --> <!-- TMPL_VAR NAME="location_description" -->
345
                        <!-- TMPL_IF name="itemcallnumber" -->
346
                            (<!-- TMPL_VAR NAME="itemcallnumber" -->)
347
                        <!-- /TMPL_IF -->
348
                    </p>
349
                    <!-- /TMPL_LOOP --><!-- TMPL_ELSE -->This record has no items.<!-- /TMPL_IF --></td>
350
            </tr>
351
        <!-- /TMPL_LOOP -->
352
    </table></form>
353
<!-- /TMPL_IF -->
354
355
<!-- TMPL_IF NAME="print_basket" -->
356
<a href="#back" class="screen">&lt;&lt; Back to Cart</a>
357
<!-- TMPL_ELSE -->
358
<form name="myform" action="basket/basket.pl" method="get">
359
    <input type="hidden" name="records" id="records" />
360
</form>
361
<!-- /TMPL_IF -->
362
363
</div>
364
</div>
365
</body>
366
</html>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchedit.tt (+227 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Batch Deletion of Items</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
5
[% UNLESS ( modsuccess ) %]
6
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
7
<script type="text/JavaScript" language="JavaScript">
8
//<![CDATA[
9
     var CGIBIN = "/cgi-bin/koha/";
10
11
     function fieldChanged(){
12
        var field = $('#fieldchoice').val();
13
        $.ajax({
14
		url: CGIBIN + 'tools/batchedit.pl?field=' + field,
15
		dataType: 'json',
16
            success: function(data){
17
		$("#subfieldchoice option").remove();
18
19
		    var subfield = $('#subfieldchoice');
20
			$("<option>").attr("value", "@")
21
                                 .text( _('Whole field'))
22
                                 .appendTo('#subfieldchoice');
23
                for( var i=0; i < data.length ; i++){
24
			$("<option>").attr("value", data[i].subfield)
25
                                 .text(data[i].subfield)
26
                                 .appendTo('#subfieldchoice');
27
                }
28
                subfieldChanged();
29
            }
30
        });
31
     }
32
33
     function subfieldChanged(){
34
        var field    = $('#fieldchoice').val();
35
        var subfield = $('#subfieldchoice').val();
36
        $.ajax({
37
		url: CGIBIN + 'tools/batchedit.pl?field=' + field + '&subfield=' + subfield,
38
		dataType: 'json',
39
            success: function(data){
40
41
		    if( data.length > 0) {
42
			$("#condvaltd").html('<select name="condvalchoice" id="condvalchoice" />');
43
			$("<option>").attr("value", "")
44
                        .text("")
45
                        .appendTo('#condvalchoice');
46
			$("#repvaltd" ).html('<select name="repvalchoice" id="repvalchoice" />'  );
47
                    $("<option>").attr("value", "")
48
                        .text("")
49
                        .appendTo('#repvalchoice');
50
51
                    for( var i=0; i < data.length ; i++){
52
			$("<option>").attr("value", data[i].code)
53
                            .text(data[i].value)
54
                            .appendTo('#repvalchoice');
55
			$("<option>").attr("value", data[i].code)
56
                            .text(data[i].value)
57
                            .appendTo('#condvalchoice');
58
                    }
59
		    }else{
60
                    $("#condvaltd").html('<input type="text" name="condvalchoice" id="condvalchoice" />');
61
                    $("#repvaltd").html('<input type="text" name="repvalchoice"  id="repvalchoice" />');
62
		    }
63
                $('<input type="checkbox" id="nocond" name="nocond" value="nocond" onClick="$(\'#condvalchoice\').attr(\'disabled\', ! $(\'#condvalchoice\').attr(\'disabled\') ) ">All</input>').appendTo("#condvaltd");
64
            }
65
        });
66
67
     }
68
69
     function addRule(){
70
        var actionlabel = {
71
                mod: _('Modify'),
72
                del: _('Delete'),
73
                add: _('Create')
74
                };
75
        var repvallabel  = $('#repvalchoice :selected').text()  || $("#repvalchoice").val();
76
77
        var field    = $('#fieldchoice').val();
78
        var subfield = $('#subfieldchoice').val();
79
        var action   = $('#actionchoice').val();
80
        var nocond   = $('#nocond').attr('checked')||(! $('#condvalchoice').val().length);
81
82
        if( ! nocond ) {
83
            var condval  = $('#condvalchoice').val();
84
            var condvallabel = $('#condvalchoice :selected').text() || $("#condvalchoice").val();
85
        }else{
86
            var condvallabel = _("No condition");
87
        }
88
        var repval   = $('#repvalchoice').val();
89
90
        var tmpl = "<tr>"
91
                + '<td><input type="hidden" name="field" value="'    + field + '" />'    + field               + '</td>'
92
                + '<td><input type="hidden" name="subfield" value="' + subfield + '" />' + subfield            + '</td>'
93
                + '<td><input type="hidden" name="action" value="'   + action + '" />'   + actionlabel[action] + '</td>'
94
                + '<td><input type="hidden" name="condval" value="'  + condval + '" />'
95
                    + condvallabel
96
                    + '<input type="hidden" name="nocondval" value="' + nocond + '" />'
97
                + '</td>'
98
99
                + '<td><input type="hidden" name="repval" value="'   + repval + '" />'   + repvallabel         + '</td>'
100
                + '<td><input type="button" value="Delete" onclick="deleteRule(this)" /></td>'
101
            + '</tr>';
102
        $('#rulestable').append(tmpl);
103
104
     }
105
106
     function deleteRule(button){
107
        $(button).parent().parent().remove();
108
        return false;
109
     }
110
111
112
//]]>
113
</script>
114
[% END %]
115
</head>
116
<body>
117
[% INCLUDE 'header.inc' %]
118
[% INCLUDE 'cat-search.inc' %]
119
<div id="doc3" class="yui-t2">
120
    <div id="bd">
121
        <div id="yui-main">
122
            <div class="yui-b">
123
124
<form method="post" enctype="multipart/form-data">
125
[% IF ( inputform ) %]
126
    <h2>Batch records modification</h2>
127
    <fieldset class="rows">
128
	<legend>Use a file</legend>
129
	<ol>
130
	    <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
131
	</ol>
132
    </fieldset>
133
    <fieldset class="rows">
134
	<legend>Or enter records one by one</legend>
135
	<ol>
136
	    <li>
137
		<label for="recordslist">Records numbers list (one number per line): </label>
138
		<textarea rows="10" cols="30" id="recordslist" name="recordslist"></textarea>
139
	    </li>
140
	</ol>
141
    </fieldset>
142
[% ELSE %]
143
    <h2>List of records:</h2>
144
    <table id="bibliolist">
145
        <thead>
146
            <tr>
147
                <th>Biblionumber</th><th>Title</th><th>Author</th>[% IF ( moddone ) %] <th>Status</th>[% END %]
148
            </tr>
149
        </thead>
150
        [% FOREACH biblioinfo IN biblioinfos %]
151
            <tr>
152
                <td>[% biblioinfo.biblionumber %]</td>
153
                <td>[% biblioinfo.title %]</td>
154
                <td>[% biblioinfo.author %]</td>
155
                [% IF ( biblioinfo.moddone ) %]
156
                    [% IF ( biblioinfo.OK ) %]
157
                        <td>
158
                    [% ELSE %]
159
                        <td class="problem">
160
                    [% END %]
161
                    [% IF ( biblioinfo.OK ) %]OK[% END %]
162
                    [% IF ( No_Actions ) %]Nothing done[% END %]
163
                    [% IF ( biblioinfo.Actions_Failed ) %]Some Actions failed. List Follow : <ul>[% FOREACH failed_action IN biblioinfo.failed_actions %]<li>[% failed_action.action %]</li>[% END %]</ul>[% END %]
164
                    </td>
165
                [% END %]
166
            </tr>
167
        [% END %]
168
    </table>
169
[% END %]
170
171
[% IF ( moddone ) %]
172
    <div class="dialog alert">All operations processed</div>
173
[% ELSE %]
174
    <fieldset class="rows">
175
    <h2>Modification rules:</h2>
176
    <input type="submit" value="Submit" />
177
    <input type="hidden" name="op" value="do" />
178
    <input type="hidden" name="bib_list" value="[% bib_list %]" />
179
    <table id="rulestable">
180
        <thead>
181
            <tr>
182
                <th>Field</th><th>Subfield</th><th>Action</th><th>Condition Value</th><th>Value</th><th>&nbsp;</th>
183
            </tr>
184
        </thead>
185
            <tr>
186
                <td>
187
                    <select name="fieldchoice" id="fieldchoice" onchange="fieldChanged();">
188
                    [% FOREACH marcfield IN marcfields %]
189
                        <option value="[% marcfield.tag %]">[% marcfield.tag %]</option>
190
                    [% END %]
191
                    </select>
192
                </td>
193
                <td>
194
                    <select name="subfieldchoice" id="subfieldchoice" onchange="subfieldChanged();">
195
196
                    </select>
197
                </td>
198
                <td>
199
                    <select name="actionchoice" id="actionchoice">
200
                        <option value="mod">Modify subfield</option>
201
                        <option value="add">Create subfield</option>
202
                        <option value="addfield">Create field and subfield</option>
203
                        <option value="del">Delete subfield</option>
204
                    </select>
205
                </td>
206
                <td id="condvaltd">
207
                    <input type="text" name="condvalchoice" id="condvalchoice" />
208
                    <input type="checkbox" id="nocond" name="nocond" value="nocond" onClick="$('#condvalchoice').attr('disabled', ! $('#condvalchoice').attr('disabled') ) ">All</input>
209
                </td>
210
                <td id="repvaltd">
211
                    <input type="text" name="repvalchoice" id="repvalchoice" />
212
                </td>
213
                <td><input type="button" value="Add" onclick="addRule();" /></td>
214
            </tr>
215
        </thead>
216
217
    </table>
218
    <input type="submit" value="Submit" />
219
    </fieldset>
220
    </form>
221
[% END %]
222
            </div>
223
        </div>
224
    </div>
225
</div>
226
</body>
227
</html>
(-)a/tools/batchedit.pl (-1 / +222 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
4
# Copyright 2010 SARL BibLibre
5
#
6
# This file is part of Koha.
7
#
8
# Koha is free software; you can redistribute it and/or modify it under the
9
# terms of the GNU General Public License as published by the Free Software
10
# Foundation; either version 2 of the License, or (at your option) any later
11
# version.
12
#
13
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License along with
18
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19
# Suite 330, Boston, MA  02111-1307 USA
20
21
use CGI;
22
use strict;
23
use C4::Output;
24
use C4::Auth;
25
use C4::Branch;
26
use C4::Koha;
27
use C4::Biblio;
28
use C4::Context;
29
use C4::Debug;
30
use JSON;
31
32
my $input = new CGI;
33
my $dbh = C4::Context->dbh;
34
35
my $filefh = $input->param('uploadfile');
36
my $recordslist = $input->param('recordslist');
37
my $bib_list = $input->param('bib_list');
38
my @biblionumbers;
39
40
if ($filefh) {
41
    while ( my $biblionumber = <$filefh> ) {
42
        $biblionumber =~ s/[\r\n]*$//g;
43
        push @biblionumbers, $biblionumber if $biblionumber;
44
    }
45
} elsif ($recordslist) {
46
    push @biblionumbers, split( /\s\n/, $recordslist );
47
} elsif ($bib_list) {
48
    push @biblionumbers, split('/', $bib_list);
49
}
50
51
my $op            = $input->param('op');
52
my ($template, $loggedinuser, $cookie);
53
54
my $frameworkcode="";
55
my $tagslib = &GetMarcStructure(1,$frameworkcode);
56
my %report_actions;
57
58
if($input->param('field') and not defined $op){
59
    ($template, $loggedinuser, $cookie)
60
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
61
                 query => $input,
62
                 type => "intranet",
63
                 authnotrequired => 0,
64
                 flagsrequired => { tools => "batchedit" },
65
        });
66
67
68
    my $tag      = $input->param('field');
69
    my $subfield = $input->param('subfield');
70
71
    if($input->param('subfield')){
72
        my $branches = GetBranchesLoop();
73
74
        my @authorised_values;
75
        if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
76
             if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) {
77
                foreach my $thisbranch (@$branches) {
78
                    push @authorised_values, {
79
                            code => $thisbranch->{value},
80
                            value => $thisbranch->{branchname},
81
                        };
82
                    # $value = $thisbranch->{value} if $thisbranch->{selected};
83
                }
84
             }elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
85
                 my $sth = $dbh->prepare("SELECT itemtype,description FROM itemtypes ORDER BY description");
86
                 $sth->execute();
87
                 while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
88
                    push @authorised_values, {
89
                        code => $itemtype,
90
                        value => $description,
91
                    };
92
                 }
93
94
            }else {
95
                  # Getting the fields where the item location is
96
                  my ($location_field, $location_subfield) = GetMarcFromKohaField('items.location', $frameworkcode);
97
98
                  # Getting the name of the authorised values' category for item location
99
                  my $item_location_category = $tagslib->{$location_field}->{$location_subfield}->{'authorised_value'};
100
		      # Are we dealing with item location ?
101
                  my $item_location = ($tagslib->{$tag}->{$subfield}->{authorised_value} eq $item_location_category) ? 1 : 0;
102
103
                  # If so, we sort by authorised_value, else by libelle
104
                  my $orderby = $item_location ? 'authorised_value' : 'lib';
105
106
                  my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY $orderby");
107
108
                  $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value});
109
110
111
                  while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
112
                    push @authorised_values, {
113
                        code => $value,
114
                        value => ($item_location) ? $value . " - " . $lib : $lib,
115
                    };
116
117
                  }
118
            }
119
        }
120
      $template->param('return' => to_json(\@authorised_values));
121
    }else{
122
        my @modifiablesubf;
123
124
        foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
125
            next if subfield_is_koha_internal_p($subfield);
126
            next if $subfield eq "@";
127
            next if ($tagslib->{$tag}->{$subfield}->{'tab'} eq "10");
128
            my %subfield_data;
129
            $subfield_data{subfield} = $subfield;
130
            push @modifiablesubf, \%subfield_data;
131
        }
132
        $template->param('return' => to_json(\@modifiablesubf));
133
    }
134
135
136
    output_html_with_http_headers $input, $cookie, $template->output;
137
    exit;
138
}else{
139
    ($template, $loggedinuser, $cookie)
140
            = get_template_and_user({template_name => "tools/batchedit.tmpl",
141
                     query => $input,
142
                     type => "intranet",
143
                     authnotrequired => 0,
144
                     flagsrequired => { tools => "batchedit" },
145
                     });
146
147
    $template->param( inputform => 1, ) unless @biblionumbers;
148
149
    if(!defined $op) {
150
        my @modifiablefields;
151
152
        foreach my $tag (sort keys %{$tagslib}) {
153
            my %subfield_data;
154
            foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
155
                next if $subfield_data{tag};
156
                next if subfield_is_koha_internal_p($subfield);
157
                next if ($tagslib->{$tag}->{$subfield}->{'tab'} eq "10");
158
159
                $subfield_data{tag}      = $tag;
160
161
                push @modifiablefields, \%subfield_data;
162
            }
163
        }
164
165
        $template->param( marcfields  => \@modifiablefields,
166
                          bib_list    => $input->param('bib_list'),
167
                         );
168
169
    }else{
170
        my @fields     = $input->param('field');
171
        my @subfields  = $input->param('subfield');
172
        my @actions    = $input->param('action');
173
        my @condvals   = $input->param('condval');
174
        my @nocondvals = $input->param('nocondval');
175
        my @repvals    = $input->param('repval');
176
        foreach my $biblionumber ( @biblionumbers ){
177
            my $record = GetMarcBiblio($biblionumber);
178
            my ($count, $biblio) = GetBiblio($biblionumber);
179
            my $report = 0;
180
            my @failed_actions;
181
            for(my $i = 0 ; $i < scalar(@fields) ; $i++ ){
182
                my $field    = $fields[$i];
183
                my $subfield = $subfields[$i];
184
                my $action   = $actions[$i];
185
                my $condval  = $condvals[$i];
186
                my $nocond   = $nocondvals[$i];
187
                my $repval   = $repvals[$i];
188
189
                my ($result,$record)   = BatchModField($record, $field, $subfield, $action, $condval, $nocond, $repval);
190
                push @failed_actions, {action=>"$field $subfield $action ".($nocond eq "true"?"all":$condval)." $repval"} if ($result<=0);
191
            }
192
            if (@failed_actions == scalar(@fields)){
193
                $report_actions{$biblionumber}->{status}="No_Actions";
194
            }
195
            elsif (@failed_actions>0 and @failed_actions < scalar(@fields)){
196
                $report_actions{$biblionumber}->{status}="Actions_Failed";
197
                $report_actions{$biblionumber}->{failed_actions}=\@failed_actions;
198
            }
199
            elsif (@failed_actions == 0){
200
                $report_actions{$biblionumber}->{status}="OK";
201
            }
202
            ModBiblio($record, $biblionumber, $biblio->{frameworkcode}) unless ($report);
203
        }
204
        $template->param('moddone' => 1);
205
    }
206
207
}
208
209
my @biblioinfos;
210
211
for my $biblionumber (@biblionumbers){
212
    my ($count,$biblio) = GetBiblio($biblionumber);
213
    if (defined $op){
214
        $biblio->{$report_actions{$biblionumber}->{status}}=1;
215
        $biblio->{failed_actions}=$report_actions{$biblionumber}->{failed_actions};
216
    }
217
    push @biblioinfos, $biblio;
218
}
219
220
$template->param(biblioinfos => \@biblioinfos);
221
output_html_with_http_headers $input, $cookie, $template->output;
222
exit;

Return to bug 5725