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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchedit.tt (-55 / +68 lines)
Lines 122-131 Link Here
122
            <div class="yui-b">
122
            <div class="yui-b">
123
123
124
<form method="post" enctype="multipart/form-data">
124
<form method="post" enctype="multipart/form-data">
125
[% IF ( inputform ) %]
125
[% IF ( moddone ) %]
126
    <div class="dialog message">All operations processed</div>
127
[% END %]
128
129
[% UNLESS ( bib_list ) %]
126
    <h2>Batch records modification</h2>
130
    <h2>Batch records modification</h2>
127
    <fieldset class="rows">
131
    <fieldset class="rows">
128
	<legend>Use a file</legend>
132
	<legend>Use a file of biblionumbers</legend>
129
	<ol>
133
	<ol>
130
	    <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
134
	    <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
131
	</ol>
135
	</ol>
Lines 134-143 Link Here
134
	<legend>Or enter records one by one</legend>
138
	<legend>Or enter records one by one</legend>
135
	<ol>
139
	<ol>
136
	    <li>
140
	    <li>
137
		<label for="recordslist">Records numbers list (one number per line): </label>
141
		<label for="recordslist">One biblionumber per line: </label>
138
		<textarea rows="10" cols="30" id="recordslist" name="recordslist"></textarea>
142
		<textarea rows="10" cols="30" id="recordslist" name="recordslist"></textarea>
139
	    </li>
143
	    </li>
140
	</ol>
144
	</ol>
145
    <p><b>Reminder</b>: you can also add biblios to your cart and reach this page from the cart</p>
141
    </fieldset>
146
    </fieldset>
142
[% ELSE %]
147
[% ELSE %]
143
    <h2>List of records:</h2>
148
    <h2>List of records:</h2>
Lines 152-166 Link Here
152
                <td>[% biblioinfo.biblionumber %]</td>
157
                <td>[% biblioinfo.biblionumber %]</td>
153
                <td>[% biblioinfo.title %]</td>
158
                <td>[% biblioinfo.title %]</td>
154
                <td>[% biblioinfo.author %]</td>
159
                <td>[% biblioinfo.author %]</td>
155
                [% IF ( biblioinfo.moddone ) %]
160
                [% IF ( moddone ) %]
156
                    [% IF ( biblioinfo.OK ) %]
161
                    [% IF ( biblioinfo.OK ) %]
157
                        <td>
162
                        <td>
158
                    [% ELSE %]
163
                    [% ELSE %]
159
                        <td class="problem">
164
                        <td class="problem">
160
                    [% END %]
165
                    [% END %]
161
                    [% IF ( biblioinfo.OK ) %]OK[% END %]
166
                    [% IF ( biblioinfo.OK ) %]OK[% END %]
162
                    [% IF ( No_Actions ) %]Nothing done[% END %]
167
                    [% IF ( biblioinfo.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 %]
168
                    [% IF ( biblioinfo.Actions_Failed ) %]
169
                        Some actions failed. List follow : <ul>[% FOREACH failed_action IN biblioinfo.failed_actions %]<li>[% failed_action.action %]</li>[% END %]</ul>
170
                    [% END %]
164
                    </td>
171
                    </td>
165
                [% END %]
172
                [% END %]
166
            </tr>
173
            </tr>
Lines 168-223 Link Here
168
    </table>
175
    </table>
169
[% END %]
176
[% END %]
170
177
171
[% IF ( moddone ) %]
178
[% UNLESS ( moddone ) %]
172
    <div class="dialog alert">All operations processed</div>
179
173
[% ELSE %]
180
    [% IF ( bib_list ) %]
174
    <fieldset class="rows">
181
        <fieldset class="rows">
175
    <h2>Modification rules:</h2>
182
        <h2>Modification rules:</h2>
176
    <input type="submit" value="Submit" />
183
        <input type="submit" value="Submit" />
177
    <input type="hidden" name="op" value="do" />
184
        <input type="hidden" name="op" value="do" />
178
    <input type="hidden" name="bib_list" value="[% bib_list %]" />
185
        <input type="hidden" name="bib_list" value="[% bib_list %]" />
179
    <table id="rulestable">
186
        <table id="rulestable">
180
        <thead>
187
            <thead>
181
            <tr>
188
                <tr>
182
                <th>Field</th><th>Subfield</th><th>Action</th><th>Condition Value</th><th>Value</th><th>&nbsp;</th>
189
                    <th>Field</th><th>Subfield</th><th>Action</th><th>Condition Value</th><th>Value</th><th>&nbsp;</th>
183
            </tr>
190
                </tr>
184
        </thead>
191
            </thead>
185
            <tr>
192
                <tr>
186
                <td>
193
                    <td>
187
                    <select name="fieldchoice" id="fieldchoice" onchange="fieldChanged();">
194
                        <select name="fieldchoice" id="fieldchoice" onchange="fieldChanged();">
188
                    [% FOREACH marcfield IN marcfields %]
195
                        [% FOREACH marcfield IN marcfields %]
189
                        <option value="[% marcfield.tag %]">[% marcfield.tag %]</option>
196
                            <option value="[% marcfield.tag %]">[% marcfield.tag %]</option>
190
                    [% END %]
197
                        [% END %]
191
                    </select>
198
                        </select>
192
                </td>
199
                    </td>
193
                <td>
200
                    <td>
194
                    <select name="subfieldchoice" id="subfieldchoice" onchange="subfieldChanged();">
201
                        <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
202
217
    </table>
203
                        </select>
218
    <input type="submit" value="Submit" />
204
                    </td>
219
    </fieldset>
205
                    <td>
220
    </form>
206
                        <select name="actionchoice" id="actionchoice">
207
                            <option value="mod">Modify subfield</option>
208
                            <option value="add">Create subfield</option>
209
                            <option value="addfield">Create field and subfield</option>
210
                            <option value="del">Delete subfield</option>
211
                        </select>
212
                    </td>
213
                    <td id="condvaltd">
214
                        <input type="text" name="condvalchoice" id="condvalchoice" />
215
                        <input type="checkbox" id="nocond" name="nocond" value="nocond" onClick="$('#condvalchoice').attr('disabled', ! $('#condvalchoice').attr('disabled') ) ">All</input>
216
                    </td>
217
                    <td id="repvaltd">
218
                        <input type="text" name="repvalchoice" id="repvalchoice" />
219
                    </td>
220
                    <td><input type="button" value="Add" onclick="addRule();" /></td>
221
                </tr>
222
            </thead>
223
224
        </table>
225
        <input type="hidden" name="bib_list" value="[% bib_list %]" />
226
        <input type="submit" value="Submit" /> (don't forget to click "Add" button on the right of the previous form before submitting)
227
        </fieldset>
228
        </form>
229
    [% ELSE %]
230
        <input type="submit" value="Submit" />
231
        </fieldset>
232
        </form>
233
    [% END %]
221
[% END %]
234
[% END %]
222
            </div>
235
            </div>
223
        </div>
236
        </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+5 lines)
Lines 103-108 Link Here
103
    <dd>Modify items in a batch</dd>
103
    <dd>Modify items in a batch</dd>
104
    [% END %]
104
    [% END %]
105
    
105
    
106
    [% IF ( CAN_user_tools_batchedit ) %]
107
    <dt><a href="/cgi-bin/koha/tools/batchedit.pl">Batch biblio modification</a></dt>
108
    <dd>Modify biblios in a batch</dd>
109
    [% END %]
110
    
106
    [% IF ( CAN_user_tools_export_catalog ) %]
111
    [% IF ( CAN_user_tools_export_catalog ) %]
107
    <dt><a href="/cgi-bin/koha/tools/export.pl">Export bibliographic and holdings</a></dt>
112
    <dt><a href="/cgi-bin/koha/tools/export.pl">Export bibliographic and holdings</a></dt>
108
    <dd>Export bibliographic and holdings data</dd>
113
    <dd>Export bibliographic and holdings data</dd>
(-)a/tools/batchedit.pl (-9 / +7 lines)
Lines 37-42 my $recordslist = $input->param('recordslist'); Link Here
37
my $bib_list = $input->param('bib_list');
37
my $bib_list = $input->param('bib_list');
38
my @biblionumbers;
38
my @biblionumbers;
39
39
40
#retrieve the list of biblionumber, from a file, a list entered manually or the basket
40
if ($filefh) {
41
if ($filefh) {
41
    while ( my $biblionumber = <$filefh> ) {
42
    while ( my $biblionumber = <$filefh> ) {
42
        $biblionumber =~ s/[\r\n]*$//g;
43
        $biblionumber =~ s/[\r\n]*$//g;
Lines 55-60 my $frameworkcode=""; Link Here
55
my $tagslib = &GetMarcStructure(1,$frameworkcode);
56
my $tagslib = &GetMarcStructure(1,$frameworkcode);
56
my %report_actions;
57
my %report_actions;
57
58
59
# if this script is called by ajax, buid an ajax/xml answer
58
if($input->param('field') and not defined $op){
60
if($input->param('field') and not defined $op){
59
    ($template, $loggedinuser, $cookie)
61
    ($template, $loggedinuser, $cookie)
60
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
62
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
Lines 136-141 if($input->param('field') and not defined $op){ Link Here
136
    output_html_with_http_headers $input, $cookie, $template->output;
138
    output_html_with_http_headers $input, $cookie, $template->output;
137
    exit;
139
    exit;
138
}else{
140
}else{
141
# standard call (via web browser)
139
    ($template, $loggedinuser, $cookie)
142
    ($template, $loggedinuser, $cookie)
140
            = get_template_and_user({template_name => "tools/batchedit.tmpl",
143
            = get_template_and_user({template_name => "tools/batchedit.tmpl",
141
                     query => $input,
144
                     query => $input,
Lines 144-151 if($input->param('field') and not defined $op){ Link Here
144
                     flagsrequired => { tools => "batchedit" },
147
                     flagsrequired => { tools => "batchedit" },
145
                     });
148
                     });
146
149
147
    $template->param( inputform => 1, ) unless @biblionumbers;
150
    $template->param( bib_list => join('/', @biblionumbers));
148
151
    # if no $op, just display the form
149
    if(!defined $op) {
152
    if(!defined $op) {
150
        my @modifiablefields;
153
        my @modifiablefields;
151
154
Lines 161-169 if($input->param('field') and not defined $op){ Link Here
161
                push @modifiablefields, \%subfield_data;
164
                push @modifiablefields, \%subfield_data;
162
            }
165
            }
163
        }
166
        }
164
167
        $template->param(marcfields  => \@modifiablefields,
165
        $template->param( marcfields  => \@modifiablefields,
166
                          bib_list    => $input->param('bib_list'),
167
                         );
168
                         );
168
169
169
    }else{
170
    }else{
Lines 176-182 if($input->param('field') and not defined $op){ Link Here
176
        foreach my $biblionumber ( @biblionumbers ){
177
        foreach my $biblionumber ( @biblionumbers ){
177
            my $record = GetMarcBiblio($biblionumber);
178
            my $record = GetMarcBiblio($biblionumber);
178
            my ($count, $biblio) = GetBiblio($biblionumber);
179
            my ($count, $biblio) = GetBiblio($biblionumber);
179
            my $report = 0;
180
            my @failed_actions;
180
            my @failed_actions;
181
            for(my $i = 0 ; $i < scalar(@fields) ; $i++ ){
181
            for(my $i = 0 ; $i < scalar(@fields) ; $i++ ){
182
                my $field    = $fields[$i];
182
                my $field    = $fields[$i];
Lines 185-191 if($input->param('field') and not defined $op){ Link Here
185
                my $condval  = $condvals[$i];
185
                my $condval  = $condvals[$i];
186
                my $nocond   = $nocondvals[$i];
186
                my $nocond   = $nocondvals[$i];
187
                my $repval   = $repvals[$i];
187
                my $repval   = $repvals[$i];
188
189
                my ($result,$record)   = BatchModField($record, $field, $subfield, $action, $condval, $nocond, $repval);
188
                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);
189
                push @failed_actions, {action=>"$field $subfield $action ".($nocond eq "true"?"all":$condval)." $repval"} if ($result<=0);
191
            }
190
            }
Lines 199-205 if($input->param('field') and not defined $op){ Link Here
199
            elsif (@failed_actions == 0){
198
            elsif (@failed_actions == 0){
200
                $report_actions{$biblionumber}->{status}="OK";
199
                $report_actions{$biblionumber}->{status}="OK";
201
            }
200
            }
202
            ModBiblio($record, $biblionumber, $biblio->{frameworkcode}) unless ($report);
201
            ModBiblio($record, $biblionumber, $biblio->{frameworkcode});
203
        }
202
        }
204
        $template->param('moddone' => 1);
203
        $template->param('moddone' => 1);
205
    }
204
    }
206
- 

Return to bug 5725