Bug 15758: Koha::Libraries - Remove GetBranchesLoop
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / batch_record_modification.tt
1 [% PROCESS 'authorities-search-results.inc' %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Tools &rsaquo; Batch record modification</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
6 [% INCLUDE 'datatables.inc' %]
7 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
8 <script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar.js"></script>
9 <script type="text/javascript">
10 //<![CDATA[
11 $(document).ready(function() {
12   $("#selectall").click(function(e){
13     e.preventDefault();
14     $(".records").checkCheckboxes();
15   });
16   $("#clearall").click(function(e){
17     e.preventDefault();
18     $(".records").unCheckCheckboxes();
19   });
20   $("#selectall").click();
21
22   $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
23     "aoColumnDefs": [
24       { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
25       { "aTargets": [ 1 ], "sType": "num-html" }
26     ],
27     "sDom": 't',
28     "aaSorting": [],
29     "bPaginate": false
30   }));
31
32   $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
33     "aoColumnDefs": [
34       { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
35       { "aTargets": [ 1 ], "sType": "num-html" }
36     ],
37     "sDom": 't',
38     "aaSorting": [],
39     "bPaginate": false
40   }));
41
42   $("#mainformsubmit").click(function(){
43     if ($("input[type=checkbox][name='record_id']:checked").length == 0 ) {
44       alert(_("Please select at least one record to process"));
45       return false;
46     }
47     if ( $("#marc_modification_template_id").val() <= 0 ) {
48       alert(_("Please select a modification template."));
49       return false;
50     }
51     return submitBackgroundJob(document.getElementById("process"));
52   });
53
54   $("#marc_modification_template_id").change(function(){
55     var url = "/cgi-bin/koha/svc/records/preview?"
56     var mmtid = $(this).val();
57     $("a.previewMARC").each(function(){
58       $(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid);
59     });
60   });
61
62     $("body").on("click",".previewMARC", function(e){
63         e.preventDefault();
64         var ltitle = $(this).text();
65         var page = $(this).attr("href");
66         $("#marcPreviewLabel").text(ltitle);
67         $("#marcPreview .modal-body").load(page + " div");
68         $('#marcPreview').modal({show:true});
69     });
70     $("#marcPreview").on("hidden", function(){
71         $("#marcPreviewLabel").html("");
72         $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/loading-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
73     });
74
75 });
76 //]]>
77 </script>
78 </head>
79 <body id="tools_batch_record_modification" class="tools">
80 [% INCLUDE 'header.inc' %]
81 [% INCLUDE 'cat-search.inc' %]
82
83 <div id="breadcrumbs">
84     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
85     <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
86     <a href="/cgi-bin/koha/tools/batch_record_modification.pl">Batch record modification</a>
87 </div>
88
89 <div id="doc3" class="yui-t2">
90 <div id="bd">
91 <div id="yui-main">
92 <div class="yui-b">
93   <h1>Batch record modification</h1>
94   [% FOREACH message IN messages %]
95     [% IF message.type == 'success' %]
96       <div class="dialog message">
97     [% ELSIF message.type == 'warning' %]
98       <div class="dialog alert">
99     [% ELSIF message.type == 'error' %]
100       <div class="dialog error" style="margin:auto;">
101     [% END %]
102                   <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber %]">[% biblio.title %]</a></td>
103     [% IF message.code == 'no_action_defined_for_the_template' %]
104       The selected template (id=[% message.mmtid%]) does not exist or no action is defined.
105     [% ELSIF message.code == 'biblio_not_exists' %]
106       The biblionumber [% message.biblionumber %] does not exist in the database.
107     [% ELSIF message.code == 'authority_not_exists' %]
108       The authority id [% message.authid %] does not exist in the database.
109     [% ELSIF message.code == 'biblio_not_modified' %]
110       The biblio <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% message.biblionumber %]">[% message.biblionumber %]</a> has not been modified. An error occurred on modifying it.
111     [% ELSIF message.code == 'authority_not_modified' %]
112       The authority <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid %]">[% message.authid %]</a> has not been modified. An error occurred on modifying it.
113     [% ELSIF message.code == 'biblio_modified' %]
114       The biblio <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% message.biblionumber %]">[% message.biblionumber %]</a> has successfully been modified.
115     [% ELSIF message.code == 'authority_modified' %]
116       The authority <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid %]">[% message.authid %]</a> has successfully been modified.
117     [% END %]
118     [% IF message.error %]
119       (The error was: [% message.error%], see the Koha logfile for more information).
120     [% END %]
121     </div>
122   [% END %]
123   [% IF view == 'form' %]
124     <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batch_record_modification.pl">
125       <fieldset class="rows">
126         <legend>Record type</legend>
127         <ol>
128           <li><label for="biblio_type">Biblios: </label><input type="radio" name="recordtype" value="biblio" id="biblio_type" checked="checked" /></li>
129           <li><label for="authority_type">Authorities: </label><input type="radio" name="recordtype" value="authority" id="authority_type" /></li>
130         </ol>
131       </fieldset>
132       <fieldset class="rows">
133         <legend>Use a file</legend>
134         <ol>
135           <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
136         </ol>
137       </fieldset>
138       <fieldset class="rows">
139         <legend>Or enter a list of record numbers</legend>
140         <ol>
141           <li>
142             <label for="recordnumber_list">Record number list (one per line): </label>
143             <textarea rows="10" cols="30" id="recordnumber_list" name="recordnumber_list"></textarea>
144           </li>
145         </ol>
146       </fieldset>
147       <fieldset class="rows">
148         <legend>Use MARC Modification Template:</legend>
149         <ol>
150           <li>
151             <label for="marc_modification_template_id" class="required">Modify record using the following template: </label>
152             <select name="marc_modification_template_id" id="marc_modification_template_id" required="required">
153               <option value="">Select a template</option>
154                 [% FOREACH mmt IN MarcModificationTemplatesLoop %]
155                   <option value="[% mmt.template_id %]">[% mmt.name %]</option>
156                 [% END %]
157             </select>
158           </li>
159         </ol>
160       </fieldset>
161       <fieldset class="action">
162         <input type="hidden" name="op" value="list" />
163         <input type="submit" value="Continue" class="button" />
164         <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
165       </fieldset>
166     </form>
167   [% ELSIF view == 'list' %]
168     [% IF records %]
169       <form action="/cgi-bin/koha/tools/batch_record_modification.pl" method="post" id="process">
170         <label for="marc_modification_template_id" class="required">Modify record using the following template: </label>
171         <select name="marc_modification_template_id" id="marc_modification_template_id" required="required">
172           <option value="">Select a template</option>
173           [% FOREACH mmt IN MarcModificationTemplatesLoop %]
174             [% IF mmt.selected %]
175               <option value="[% mmt.template_id %]" selected="selected">[% mmt.name %]</option>
176             [% ELSE %]
177               <option value="[% mmt.template_id %]">[% mmt.name %]</option>
178             [% END %]
179           [% END %]
180         </select>
181         <div id="marcPreview" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
182             <div class="modal-header">
183                 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
184                 <h3 id="marcPreviewLabel">MARC preview</h3>
185             </div>
186             <div class="modal-body">
187                 <div id="loading"> <img src="[% interface %]/[% theme %]/img/loading-small.gif" alt="" /> Loading </div>
188             </div>
189             <div class="modal-footer">
190                 <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
191             </div>
192         </div>
193         [% IF recordtype == 'biblio' %]
194           <div id="toolbar">
195             <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
196             | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
197           </div>
198           <table id="biblios" class="records">
199             <thead>
200               <tr>
201                 <th></th>
202                 <th>Biblionumber</th>
203                 <th>Title</th>
204                 <th>Preview</th>
205               </tr>
206             </thead>
207             <tbody>
208               [% FOR biblio IN records %]
209                 <tr>
210                   <td><input type="checkbox" name="record_id" value="[% biblio.biblionumber %]" data-items="[% biblio.itemnumbers.size %]" data-issues="[% biblio.issues_count %]" data-reserves="[% biblio.reserves.size %]" /></td>
211                   <td>[% biblio.biblionumber %]</td>
212                   <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber %]">[% biblio.title %]</a></td>
213                   <td><a href="/cgi-bin/koha/svc/records/preview?record_type=biblio&record_id=[% biblio.biblionumber %]&mmtid=[% mmtid %]" class="previewMARC" data-record_type="biblio" data-record_id="[% biblio.biblionumber %]" data-mmtid="[% mmtid %]" title="Preview MARC" >Preview MARC</a>
214                 </tr>
215               [% END %]
216             </tbody>
217           </table>
218           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected biblios!</div>
219         [% ELSE %]
220           <div id="toolbar">
221             <a id="selectall" href="#"><i class="fa fa-check"></i> Select all</a>
222             | <a id="clearall" href="#"><i class="fa fa-remove"></i> Clear all</a>
223           </div>
224           <table id="authorities" class="records">
225             <thead>
226               <tr>
227                 <th></th>
228                 <th>Authid</th>
229                 <th>Summary</th>
230                 <th>Preview</th>
231               </tr>
232             </thead>
233             <tbody>
234               [% FOR authority IN records %]
235                 <tr>
236                   <td><input type="checkbox" name="record_id" value="[% authority.authid %]" data-usage="[% authority.count_usage %]" /></td>
237                   <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid %]">[% authority.authid %]</a></td>
238                   <td>[% PROCESS authresult summary=authority.summary %]</td>
239                   <td><a href="/cgi-bin/koha/svc/records/preview?record_type=authority&record_id=[% authority.authid %]&mmtid=[% mmtid %]" data-record_type="authority" data-record_id="[% authority.authid %]" data-mmtid="[% mmtid %]" class="previewMARC">Preview MARC</a>
240                 </tr>
241               [% END %]
242             </tbody>
243           </table>
244           <div class="note"><i class="fa fa-exclamation"></i> Reminder: this action will modify all selected authorities!</div>
245         [% END %]
246         <fieldset class="action">
247           <input type="hidden" name="op" value="modify" />
248           <input type="hidden" name="recordtype" value="[% recordtype %]" />
249           <input type="button" id="mainformsubmit" value="Modify selected records" class="button" />
250           <input type="hidden" name="runinbackground" id="runinbackground" value="" />
251           <input type="hidden" name="completedJobID" id="completedJobID" value="" />
252           <a class="cancel" href="/cgi-bin/koha/tools/batch_record_modification.pl">Cancel</a>
253         </fieldset>
254         <div id="jobpanel">
255           <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
256           <div id="jobfailed"></div>
257         </div>
258       </form>
259     [% ELSE %]
260       There is no record ids defined.
261     [% END %]
262   [% ELSIF view == 'report' %]
263     [% IF report.total_records == report.total_success %]
264       All records have successfully been modified!
265     [% ELSE %]
266       [% report.total_success %] / [% report.total_records %] records have successfully been modified.
267       Some errors occurred.
268     [% END %]
269     <p><a href="/cgi-bin/koha/tools/batch_record_modification.pl" title="New batch record modification">New batch record modification</a></p>
270   [% ELSIF view == 'errors' %]
271     [% FOR error IN errors %]
272       [% IF error == 'no_template_defined' %]
273         No MARC modification template is defined. You have <a href="/cgi-bin/koha/tools/marc_modification_templates.pl">to create</a> at least one template for using this tool.
274       [% END %]
275     [% END %]
276   [% ELSE %]
277     No action defined for the template.
278   [% END %]
279 </div>
280 </div>
281 <div class="yui-b">
282   [% INCLUDE 'tools-menu.inc' %]
283 </div>
284 </div>
285 [% INCLUDE 'intranet-bottom.inc' %]