Move serials interfaces closer together
[working/Evergreen.git] / Open-ILS / src / templates / serial / subscription.tt2
1 [% USE CGI; %]
2 [% WRAPPER "base.tt2" %]
3 <script>
4     [%- IF CGI.param('context') == 'scv' %]
5     xulG = parent.xulG;
6     [%- END %]
7     [%- IF CGI.param('id') != 'new' %]
8     sub_id = [% CGI.param('id') %];
9     [%- END %]
10     var cap_editor;
11     var cap_importer;
12 </script>
13 <script src="[% ctx.media_prefix %]/js/ui/default/serial/common.js">
14 </script>
15 <script src="[% ctx.media_prefix %]/js/ui/default/serial/subscription.js">
16 </script>
17 <script src="[% ctx.media_prefix %]/js/ui/default/serial/subscription/distribution.js"></script>
18 <script src="[% ctx.media_prefix %]/js/ui/default/serial/subscription/caption_and_pattern.js">
19 </script>
20 <script src="[% ctx.media_prefix %]/js/ui/default/serial/subscription/issuance.js">
21 </script>
22
23 <div dojoType="dijit.layout.ContentPane" layout="top" class="oils-header-panel">
24     <div>[% l('Subscription Details') %]</div>
25     <div>
26         <span dojoType="dijit.form.Button" onClick="clone_dialog.show();">
27             [% l('Clone Subscription') %]
28         </span>
29         <span dojoType="dijit.form.Button" onClick="open_batch_receive();">
30             [% l('Batch Item Receive') %]
31         </span>
32     </div>
33 </div>
34
35 <div dojoType="dijit.layout.TabContainer" jsId="tab_container"
36     class="oils-serial-tab-container">
37
38     <!-- Subscription Summary -->
39     [%- IF CGI.param('context') == 'scv' -%]
40     <div dojoType="dijit.layout.ContentPane" title="[% l('View/Edit') %]" selected="true">
41         <div dojoType="dijit.layout.ContentPane" layout="top"
42             class="oils-header-panel lesser">
43             <div>[% l('Subscriptions') %]</div>
44             <div style="margin-right: 16px;">
45                 <span dojoType="dijit.form.Button"
46                     onClick="open_notes('sub', ssub_grid);">[% l('View/Edit Notes') %]</span>
47             </div>
48         </div>
49
50         <script type="dojo/connect" event="onShow">
51             if(ssub_grid.store && !ssub_grid._fresh) { // onShow fires twice on initial page load; we only want to run the second time (and subsequent times)
52                 ssub_grid.resetStore();
53                 if (sub_id) {
54                     ssub_grid.loadAll(
55                         {"order_by": {"ssub": "start_date DESC"}},
56                         {"id": sub_id}
57                     );
58                 }
59                 ssub_grid._fresh = true;
60             }
61         </script>
62         <table jsId="ssub_grid"
63             dojoType="openils.widget.AutoGrid"
64             query="{id: '*'}"
65             fieldOrder="['id','owning_lib','start_date','end_date']"
66             suppressFields="['record_entry']"
67             fmClass="ssub"
68             showPaginator="true"
69             onPostSubmit="attempt_reload_opac"
70             showSequenceFields="true"
71             editOnEnter="true">
72         </table>
73     </div>
74     [%- ELSE -%]
75     <div dojoType="dijit.layout.ContentPane" title="[% l('Summary') %]" selected="true">
76         <script type="dojo/connect" event="onShow">
77             load_sub_grid(sub_id);
78         </script>
79         <table jsId="sub_grid"
80             dojoType="dojox.grid.DataGrid" query="{id: '*'}" rowSelector="20px">
81             <thead>
82                 <tr>
83                     <th field="id">[% l('ID') %]</th>
84                     <th field="owning_lib" formatter="format_org_unit">
85                         [% l('Owning Library') %]
86                     </th>
87                     <th field="start_date" formatter="format_date">
88                         [% l('Start Date') %]
89                     </th>
90                     <th field="end_date" formatter="format_date">
91                         [% l('End Date') %]
92                     </th>
93                     [%- IF CGI.param('context') != 'scv' -%]
94                     <th field="record_entry" width="20em"
95                         formatter="format_bib">
96                         [% l('Bibliographic Record') %]
97                     </th>
98                     [%- END -%]
99                     <th field="expected_date_offset">[% l('Expected Date Offset') %]</th>
100                     <th field="num_dist">[% l('Number of Distributions') %]</th>
101                 </tr>
102             </thead>
103         </table>
104     </div>
105     [%- END -%]
106
107     <!-- Distributions -->
108     <div dojoType="dijit.layout.ContentPane" jsId="distributions_tab"
109         title="[% l('Distributions') %]" layoutAlign="client">
110         <script type="dojo/connect" event="onShow">
111             if (!dist_grid._fresh) {
112                 dist_grid.resetStore();
113                 dist_grid.loadAll(
114                     {"order_by": {"sdist": "holding_lib"}},
115                     {"subscription": sub_id}
116                 );
117                 dist_grid._fresh = true;
118             }
119
120             if (!dist_grid.overrideEditWidgets.subscription) {
121                 dist_grid.overrideEditWidgets.subscription =
122                     new dijit.form.TextBox({
123                         "disabled": true, "value": sub_id
124                     });
125
126                 // attach the holding_lib selector to the record_entry selector
127                 dist_grid.overrideWidgetArgs.holding_lib = {'dijitArgs' : {'onChange' : function(value) { populate_sre_selector(dist_grid, value); } }};
128                 var _display_grouping_store = new dojo.data.ItemFileReadStore({
129                     "data": {
130                         "identifier": "display_grouping",
131                         "label": "label",
132                         "items": [
133                             {"display_grouping": "chron",
134                                 "label": "[% l('Chronology') %]"},
135                             {"display_grouping": "enum",
136                                 "label": "[% l('Enumeration') %]"}
137                         ]
138                     }
139                 });
140
141                 var settings = fieldmapper.aou.fetchOrgSettingBatch(
142                     openils.User.user.ws_ou(),
143                     ["serial.default_display_grouping"]
144                 );
145                 var default_display_grouping = "chron";
146
147                 if (settings && settings["serial.default_display_grouping"]) {
148                     default_display_grouping =
149                         settings["serial.default_display_grouping"].value;
150                 }
151
152                 dist_grid.overrideEditWidgets.display_grouping =
153                     new dijit.form.FilteringSelect({
154                         "store": _display_grouping_store,
155                         "searchAttr": "label",
156                         "name": "display_grouping"
157                     });
158                     dist_grid.overrideEditWidgets.display_grouping.shove = {
159                         "create": default_display_grouping
160                     };
161
162                 var _summary_method_store = new dojo.data.ItemFileReadStore({
163                     "data": {
164                         "identifier": "summary_method",
165                         "label": "label",
166                         "items": [
167                             {"summary_method": "add_to_sre",
168                                 "label": "[% l('Add to record entry') %]"},
169                             {"summary_method": "merge_with_sre",
170                                 "label": "[% l('Merge with record entry') %]"},
171                             {"summary_method": "use_sre_only",
172                                 "label": "[% l('Use record entry only') %]"},
173                             {"summary_method": "use_sdist_only",
174                                 "label": "[% l('Do not use record entry') %]"}
175                         ]
176                     }
177                 });
178
179                 dist_grid.overrideEditWidgets.summary_method =
180                     new dijit.form.FilteringSelect({
181                         "store": _summary_method_store,
182                         "searchAttr": "label",
183                         "name": "summary_method"
184                     });
185                     // TODO: add setting for default selection?
186                     dist_grid.overrideEditWidgets.summary_method.shove = {
187                         "create": "add_to_sre"
188                     };
189
190             }
191         </script>
192         [% INCLUDE "serial/subscription/distribution.tt2" %]
193     </div>
194
195     <!-- Caption/Pattern -->
196     <div dojoType="dijit.layout.ContentPane"
197         title="[% l('Captions and Patterns') %]" layoutAlign="client">
198         <script type="dojo/connect" event="onShow">
199             if (!cap_editor) {
200                 cap_editor = new SCAPEditor(sub_id);
201                 cap_importer = new SCAPImporter(sub);
202             }
203         </script>
204         [% INCLUDE "serial/subscription/caption_and_pattern.tt2" %]
205     </div>
206
207     <!-- Issuances -->
208     <div dojoType="dijit.layout.ContentPane" jsId="issuances_tab"
209         title="[% l('Issuances') %]" layoutAlign="client">
210         <script type="dojo/connect" event="onShow">
211             if (!iss_grid._fresh) {
212                 iss_grid.resetStore();
213                 iss_grid.loadAll(
214                     {"order_by": {"siss": "date_published"}},
215                     {"subscription": sub_id}
216                 );
217                 iss_grid._fresh = true;
218             }
219
220             if (!iss_grid.overrideEditWidgets.subscription) {
221                 iss_grid.overrideEditWidgets.subscription =
222                     new dijit.form.TextBox({
223                         "disabled": true, "value": sub_id
224                     });
225
226                 iss_grid.overrideEditWidgets.creator =
227                     new dijit.form.TextBox({"disabled": true});
228                 iss_grid.overrideEditWidgets.creator.shove = {
229                     "create": openils.User.user.id()
230                 };
231
232                 iss_grid.overrideEditWidgets.editor =
233                     new dijit.form.TextBox({
234                         "disabled": true, "value": openils.User.user.id()
235                     });
236
237                 iss_grid.overrideEditWidgets.holding_type =
238                     new dijit.form.TextBox({"disabled": true});
239                 iss_grid.overrideEditWidgets.holding_type.shove = {"create":""};
240
241                 iss_grid.overrideEditWidgets.holding_type =
242                     new dijit.form.TextBox;
243             }
244             fresh_scap_selector(iss_grid);
245         </script>
246         [% INCLUDE "serial/subscription/issuance.tt2" %]
247     </div>
248 </div>
249 <div class="hidden">
250     <div dojoType="openils.widget.ProgressDialog" jsId="progress_dialog"></div>
251     <div dojoType="dijit.Dialog" jsId="clone_dialog" title="[% l('Clone Subscription') %]"
252         style="width: 460px;" execute="clone_subscription(arguments[0]);">
253         <div style="margin-bottom: 0.5em;">
254             [% |l %]This feature will clone a subscription and all of its subscription
255             notes, distributions, distribution notes, captions and patterns,
256             streams, and routing list users.[% END %]</div>
257         <div style="margin-bottom: 0.5em;">
258             [% |l %]Holdings-related objects, like issuances, items, units, and
259             summaries will <em>not</em> be cloned.[% END %]
260         </div>
261         <div style="margin-bottom: 0.5em;">
262             [% |l %]To what bibliographic record should the new subscription be
263             attached?[% END %]
264         </div>
265         <table width="100%">
266             <tr>
267                 <td style="padding-right: 0.5em; vertical-align: top;">
268                     <input dojoType="dijit.form.RadioButton"
269                         id="use_ident_no" name="use_ident" value="no"
270                         checked="checked" />
271                 </td>
272                 <td>
273                     <label for="use_ident_no">
274                         [% l('Same record as the existing subscription') %]
275                     </label>
276                 </td>
277             </tr>
278             <tr>
279                 <td style="padding-right: 0.5em; vertical-align: top;">
280                     <input dojoType="dijit.form.RadioButton"
281                         onChange="toggle_clone_ident_field(this);"
282                         id="use_ident_yes" name="use_ident" value="yes" />
283                 </td>
284                 <td>
285                     <label for="use_ident_yes">
286                         [% l('Record specified by this unique identifier:') %]
287                     </label>
288                     <input dojoType="dijit.form.TextBox" name="ident"
289                         jsId="clone_ident" disabled="true"
290                         style="margin-left: 0.5em; width: 10em;" />
291                 </td>
292             </tr>
293             <tr>
294                 <td colspan="2" align="center">
295                     <span dojoType="dijit.form.Button" type="submit">
296                         [% l('Clone!') %]
297                     </span>
298                 </td>
299             </tr>
300         </table>
301     </div>
302 </div>
303 [% END %]