5 [% USE TablesSettings %]
6 [% USE AuthorisedValues %]
8 [% INCLUDE 'doc-head-open.inc' %]
10 [% IF op =='add_form' %]
11 [% IF agreement.agreement_id %]
15 [% END %] › [% ELSE %]
16 [% IF op == 'delete_confirm' %]
17 Confirm deletion of agreement › [% END %]
19 Agreements › Electronic resources management › Koha
21 [% INCLUDE 'doc-head-close.inc' %]
24 <body id="erm_agreements" class="erm">
25 [% INCLUDE 'header.inc' %]
26 [% INCLUDE 'erm-search.inc' %]
28 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
31 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
34 <a href="/cgi-bin/koha/erm/erm-home.pl">Electronic resources management</a>
37 [% IF op == 'add_form' %]
39 <a href="/cgi-bin/koha/erm/agreements.pl">Agreements</a>
42 <a href="#" aria-current="page">
43 [% IF agreement.agreement_id %]
51 [% ELSIF op == 'delete_confirm' %]
53 <a href="/cgi-bin/koha/erm/agreements.pl">Agreements</a>
56 <a href="#" aria-current="page">
57 Confirm deletion of agreement
63 <a href="#" aria-current="page">
71 <div class="main container-fluid">
73 <div class="col-sm-10 col-sm-push-2">
76 [% FOR m IN messages %]
77 <div class="dialog [% m.type | html %]">
79 [% CASE 'error_on_update' %]
80 An error occurred when updating this agreement. Perhaps it already exists.
81 [% CASE 'error_on_insert' %]
82 An error occurred when adding this agreement. The agreement id might already exist.
83 [% CASE 'error_on_delete' %]
84 An error occurred when deleting this agreement. Check the logs.
85 [% CASE 'success_on_update' %]
86 Agreement updated successfully.
87 [% CASE 'success_on_insert' %]
88 Agreement added successfully.
89 [% CASE 'success_on_delete' %]
90 Agreement deleted successfully.
91 [% CASE 'already_exists' %]
92 This agreement already exists.
99 [% IF op == 'add_form' %]
101 <h1>Modify a agreement</h1>
103 <h1>New agreement</h1>
106 <form action="/cgi-bin/koha/erm/agreements.pl" name="Aform" method="post" class="validated">
107 <input type="hidden" name="op" value="add_validate" />
108 <input type="hidden" name="agreement_id" value="[% agreement.agreement_id | html %]" />
110 <fieldset class="rows">
113 <li><span class="label">Agreement ID: </span>[% agreement.agreement_id | html %]</li>
117 <label for="vendor_id">Vendor: </label>
118 <select name="vendor_id">
119 <option value=""></option>
120 [% FOR v IN vendors %]
121 [% IF v.id == agreement.vendor_id %]
122 <option value="[% v.id %]" selected="selected">[% v.name %]</option>
124 <option value="[% v.id %]">[% v.name %]</option>
130 <label for="name" class="required">Name: </label>
131 <input type="text" name="name" id="name" size="80" value="[% agreement.name | html %]" required="required" class="required" /> <span class="required">Required</span>
133 <label for="description">Description: </label>
134 <input type="text" name="description" id="description" size="80" value="[% agreement.description | html %]" />
136 <label for="status" class="required">Status: </label>
137 <select name="status" required="required" required="required">
138 <option value=""></option>
139 [% PROCESS options_for_authorised_values authorised_values => AuthorisedValues.GetAuthValueDropbox( 'ERM_AGREEMENT_STATUS' ), selected_av => agreement.status %]
141 <span class="required">Required</span>
144 <label for="closure_reason">Closure reason: </label>
145 <select name="closure_reason">
146 <option value=""></option>
147 [% PROCESS options_for_authorised_values authorised_values => AuthorisedValues.GetAuthValueDropbox( 'ERM_AGREEMENT_CLOSURE_REASON' ), selected_av => agreement.closure_reason %]
151 <label for="is_perpetual">Is perpetual: </label>
152 <label for="is_perpetual_yes"> Yes
153 [% IF agreement.is_perpetual %]
154 <input type="radio" id="is_perpetual_yes" name="is_perpetual" value="1" checked="checked">
156 <input type="radio" id="is_perpetual_yes" name="is_perpetual" value="1">
159 <label for="is_perpetual_no"> No
160 [% IF agreement.is_perpetual %]
161 <input type="radio" id="is_perpetual_no" name="is_perpetual" value="0">
163 <input type="radio" id="is_perpetual_no" name="is_perpetual" value="0" checked="checked">
168 <label for="renewal_priority">Renewal priority: </label>
169 <select name="renewal_priority">
170 <option value=""></option>
171 [% PROCESS options_for_authorised_values authorised_values => AuthorisedValues.GetAuthValueDropbox( 'ERM_AGREEMENT_RENEWAL_PRIORITY' ), selected_av => agreement.renewal_priority %]
174 <label for="license_info">License info: </label>
175 <input type="text" name="license_info" id="license_info" size="80" value="[% agreement.license_info | html %]" />
180 [% BLOCK agreement_period %]
181 <fieldset class="agreement_period">
183 Agreement period <span class="period_count">[% id | html %]</span>
184 <a href="#" class="remove_period"><i class="fa fa-trash"></i> Remove this period</a>
186 <input type="hidden" name="period_unique_id" value="[% id | html %]" />
189 <label for="started_on" class="required">Start date: </label>
190 <input type="text" id="started_on_[% id | html %]" class="started_on" name="started_on_[% id | html %]" value="[% p.started_on | $KohaDates %]" class="flatpickr" data-date_to="ended_on_[% id | html %]" />
191 <span class="required">Required</span>
192 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
195 <label for="ended_on">End date: </label>
196 <input type="text" id="ended_on_[% id | html %]" class="ended_on" name="ended_on_[% id | html %]" value="[% p.ended_on | $KohaDates %]" class="flatpickr" />
197 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
200 <label>Cancellation deadline: </label>
201 <input type="text" class="cancellation_deadline" name="cancellation_deadline_[% id | html %]" value="[% p.cancellation_deadline | $KohaDates %]" class="flatpickr" />
202 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
205 <label>Notes: </label>
206 <input type="text" class="notes" name="notes_[% id | html %]" value="[% p.notes | html %]" />
212 <fieldset class="rows" id="agreement_periods">
213 <legend>Periods</legend>
214 [% IF agreement.periods.count %]
215 [% FOR p IN agreement.periods %]
216 [% PROCESS agreement_period period => p, id => loop.count %]
219 [% PROCESS agreement_period id => 1 %]
221 <button class="add_new_period" type="button" class="btn btn-primary"><i class="fa fa-plus" aria-hidden="true"></i>Add new period</button>
224 <fieldset class="action">
225 <input type="submit" value="Submit" />
226 <a class="cancel" href="/cgi-bin/koha/erm/agreements.pl">Cancel</a>
231 [% IF op == 'delete_confirm' %]
232 <div class="dialog alert">
233 <h3>Delete agreement "[% agreement.agreement_id | html %]?"</h3>
235 <tr><th>Agreement id</th>
236 <td>[% agreement.agreement_id| html %]</td>
239 <td>[% agreement.vendor_id| html %]</td>
242 <td>[% agreement.name| html %]</td>
244 <tr><th>Description</th>
245 <td>[% agreement.description| html %]</td>
248 <td>[% agreement.status| html %]</td>
250 <tr><th>Closure_reason</th>
251 <td>[% agreement.closure_reason| html %]</td>
253 <tr><th>Is perpetual</th>
254 <td>[% agreement.is_perpetual| html %]</td>
256 <tr><th>Renewal priority</th>
257 <td>[% agreement.renewal_priority| html %]</td>
259 <tr><th>License info</th>
260 <td>[% agreement.license_info| html %]</td>
263 <form action="/cgi-bin/koha/erm/agreements.pl" method="post">
264 <input type="hidden" name="op" value="delete_confirmed" />
265 <input type="hidden" name="agreement_id" value="[% agreement.agreement_id | html %]" />
266 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
268 <form action="/cgi-bin/koha/erm/agreements.pl" method="get">
269 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
274 [% IF op == 'list' %]
276 <div id="toolbar" class="btn-toolbar">
277 <a class="btn btn-default" id="newagreement" href="/cgi-bin/koha/erm/agreements.pl?op=add_form"><i class="fa fa-plus"></i> New agreement</a>
281 [% IF agreement_name_filter %]
282 Searching: [% agreement_name_filter | html %]
285 [% IF agreements_count > 0 %]
286 <div class="table_agreements_table_controls"></div>
287 <table id="table_agreements">
295 <th>Closure reason</th>
296 <th>Is perpetual</th>
297 <th>Renewal priority</th>
298 <th data-class-name="actions noExport">Actions</th>
303 <div class="dialog message">
304 There are no agreements defined. <a href="/cgi-bin/koha/erm/agreements.pl?op=add_form">Create a new agreement</a>.
310 </div> <!-- /.col-sm-10.col-sm-push-2 -->
312 <div class="col-sm-2 col-sm-pull-10">
314 [% INCLUDE 'erm-menu.inc' %]
316 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
317 </div> <!-- /.row -->
319 [% MACRO jsinclude BLOCK %]
320 [% Asset.js("js/erm-menu.js") | $raw %]
321 [% INCLUDE 'calendar.inc' %]
322 [% INCLUDE 'datatables.inc' %]
323 [% INCLUDE 'columns_settings.inc' %]
326 const agreement_statuses = [% To.json(AuthorisedValues.Get('ERM_AGREEMENT_STATUS')) | $raw %];
327 let agreement_statuses_map = agreement_statuses.reduce((map, e) => {
328 map[e.authorised_value] = e;
331 const agreement_closure_reasons = [% To.json(AuthorisedValues.Get('ERM_AGREEMENT_CLOSURE_REASON')) | $raw %];
332 let agreement_closure_reasons_map = agreement_closure_reasons.reduce((map, e) => {
333 map[e.authorised_value] = e;
336 const agreement_renewal_priorities = [% To.json(AuthorisedValues.Get('ERM_AGREEMENT_RENEWAL_PRIORITY')) | $raw %];
337 let agreement_renewal_priorities_map = agreement_renewal_priorities.reduce((map, e) => {
338 map[e.authorised_value] = e;
344 var columns_settings = [% TablesSettings.GetColumns( 'erm', 'agreements', 'table_agreements', 'json' ) | $raw %];
345 $(document).ready(function() {
346 var agreements_table_url = '/api/v1/erm/agreements?';
348 [% IF agreement_name_filter %]
349 var agreement_name_filter = {
351 "like": '%[%- agreement_name_filter | html -%]%'
354 agreements_table_url += 'q='+ encodeURIComponent(JSON.stringify(agreement_name_filter));
357 var agreements_table = $("#table_agreements").kohaTable({
359 "url": agreements_table_url
361 "order": [[ 1, "asc" ]],
364 "data": "agreement_id",
379 "data": "description",
387 "render": function( data, type, row, meta ) {
388 return escape_str(agreement_statuses_map[row.status].lib);
392 "data": "closure_reason",
395 "render": function( data, type, row, meta ) {
396 return row.closure_reason != undefined && row.closure_reason != "" ? escape_str(agreement_closure_reasons_map[row.closure_reason].lib) : "";
400 "data": "is_perpetual",
403 "render": function( data, type, row, meta ) {
404 return escape_str(row.is_perpetual ? _("Yes") : _("No"));
408 "data": "renewal_priority",
411 "render": function( data, type, row, meta ) {
412 return row.renewal_priority != undefined && row.renewal_priority != "" ? escape_str(agreement_renewal_priorities_map[row.renewal_priority].lib) : "";
416 "data": function( row, type, val, meta ) {
418 var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/erm/agreements.pl?op=add_form&agreement_id='+ encodeURIComponent(row.agreement_id) +'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n";
419 result += '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/erm/agreements.pl?op=delete_confirm&agreement_id='+ encodeURIComponent(row.agreement_id) +'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Delete")+'</a>';
427 }, columns_settings, 1);
429 $(".add_new_period").on("click", function(e){
431 let new_period_block = $("fieldset.agreement_period:first").clone(1);
432 new_period_block.find("input").val("");
433 $(new_period_block).insertBefore(this);
434 update_period_count();
436 $(".remove_period").on("click", function(e){
438 $(this).parent().parent().remove();
439 update_period_count();
441 update_period_count();
444 function update_period_count(){
445 $("fieldset.agreement_period").each(function(i, period){
447 let remove_period_link = $(this).find(".remove_period");
449 $(remove_period_link).hide();
451 $(remove_period_link).show();
453 $(period).find(".period_count").text(id);
454 $(period).find("input[name='period_unique_id']").val(id);
456 let ended_on_input = $(period).find("input.ended_on");
457 $(ended_on_input).attr("id", "ended_on_" + id);
458 $(ended_on_input).attr("name", "ended_on_" + id);
459 $(ended_on_input).flatpickr();
461 let started_on_input = $(period).find("input.started_on");
462 $(started_on_input).attr("name", "started_on_" + id);
463 $(started_on_input).data("date_to", "ended_on_" + id);
464 $(started_on_input).flatpickr();
466 let cancellation_deadline_input = $(period).find("input.cancellation_deadline");
467 $(cancellation_deadline_input).attr("name", "cancellation_deadline_" + id);
468 $(cancellation_deadline_input).flatpickr();
470 $(period).find(".notes").attr("name", "notes_" + id);
476 [% INCLUDE 'intranet-bottom.inc' %]