Line 0
Link Here
|
|
|
1 |
[% INCLUDE 'doc-head-open.inc' %] |
2 |
<title>Koha › Tools › Toggle new status</title> |
3 |
[% INCLUDE 'doc-head-close.inc' %] |
4 |
<script type="text/javascript">//<![CDATA[ |
5 |
function clear_inputs(node, new_node) { |
6 |
var selects = $(node).find("select"); |
7 |
$(selects).each(function(i) { |
8 |
var select = this; |
9 |
$(new_node).find("select").eq(i).val($(select).val()); |
10 |
}); |
11 |
var inputs = $(node).find("input"); |
12 |
$(inputs).each(function(i) { |
13 |
var input = this; |
14 |
$(new_node).find("input").eq(i).val($(input).val()); |
15 |
}); |
16 |
} |
17 |
|
18 |
function remove_block_action( link ) { |
19 |
var blocks = $(link).parent().parent(); |
20 |
if( $(blocks).find(".block").length > 2 ) { |
21 |
$(blocks).find("a.remove_block").show(); |
22 |
} else { |
23 |
$(blocks).find("a.remove_block").hide(); |
24 |
} |
25 |
$(link).parent().remove(); |
26 |
} |
27 |
|
28 |
function remove_rule_action( link ) { |
29 |
if( $("#rules").find("div.rule").length < 2 ) { |
30 |
$("#edit_rules").hide(); |
31 |
} |
32 |
$(link).parent().remove(); |
33 |
} |
34 |
|
35 |
function clone_block(block) { |
36 |
var new_block = $(block).clone(1); |
37 |
clear_inputs(block, new_block); |
38 |
$(new_block).find('a.remove_block').show(); |
39 |
var blocks = $(block).parent(); |
40 |
$(blocks).append(new_block); |
41 |
$(blocks).find('a.remove_block').click(function(){ |
42 |
remove_block_action($(this)); |
43 |
}).show(); |
44 |
} |
45 |
|
46 |
$(document).ready(function() { |
47 |
$("#new_rule a.remove_rule").hide(); |
48 |
$("#new_rule a.remove_block").hide(); |
49 |
$("#rules a.remove_block").click(function(){ |
50 |
remove_block_action($(this)); |
51 |
}); |
52 |
$("#rules a.remove_rule").click(function(){ |
53 |
remove_rule_action($(this)); |
54 |
}); |
55 |
|
56 |
var unique_id = $("div.rule").length + 1; |
57 |
$("a.add_rule").click(function(){ |
58 |
var rule = $("#new_rule"); |
59 |
var new_rule = $(rule).clone(1); |
60 |
$(new_rule).removeAttr('id'); |
61 |
$(new_rule).attr('class', 'rule'); |
62 |
clear_inputs(rule, new_rule); |
63 |
$(new_rule).find("select[name='condition_field']").attr('name', 'condition_field_' + unique_id); |
64 |
$(new_rule).find("select[name='substitution_field']").attr('name', 'substitution_field_' + unique_id); |
65 |
$(new_rule).find("input[name='condition_value']").attr('name', 'condition_value_' + unique_id); |
66 |
$(new_rule).find("input[name='substitution_value']").attr('name', 'substitution_value_' + unique_id); |
67 |
$(new_rule).find("input[name='duration']").attr('name', 'duration_' + unique_id); |
68 |
$(new_rule).find("input[name='unique_id']").val(unique_id); |
69 |
|
70 |
$("#rules").append(new_rule); |
71 |
|
72 |
if( $("#rules").find("div.rule").length > 0 ) { |
73 |
$("#edit_rules").show(); |
74 |
} |
75 |
if( $("#rules").find(".conditions > .condition").length > 1 ) { |
76 |
|
77 |
} |
78 |
if( $("#rules").find(".conditions > .condition").length > 1 ) { |
79 |
|
80 |
} |
81 |
$(new_rule).find('a.remove_rule').click(function(){ |
82 |
remove_rule_action( $(this) ); |
83 |
}).show(); |
84 |
unique_id++; |
85 |
}); |
86 |
|
87 |
$("a.add_block").click(function(){ |
88 |
clone_block( $(this).parent() ); |
89 |
}); |
90 |
|
91 |
if( $("#rules").find("div.rule").length < 1 ) { |
92 |
$("#edit_rules").hide(); |
93 |
} |
94 |
|
95 |
$("#rules .rule .blocks").each(function(){ |
96 |
if ( $(this).find(".block").length == 1 ) { |
97 |
$(this).find("a.remove_block").hide(); |
98 |
} |
99 |
}); |
100 |
}); |
101 |
//]]> |
102 |
</script> |
103 |
</head> |
104 |
<body id="tools_toggle_new_status" class="tools"> |
105 |
[% INCLUDE 'header.inc' %] |
106 |
[% INCLUDE 'cat-search.inc' %] |
107 |
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › <a href="/cgi-bin/koha/tools/toggle_new_status.pl">Toggle new status</a></div> |
108 |
|
109 |
<div id="doc3" class="yui-t2"> |
110 |
<div id="bd"> |
111 |
<div id="yui-main"> |
112 |
<div class="yui-b"> |
113 |
<h3>Toggle new status</h3> |
114 |
<div id="toolbar" class="btn-toolbar"> |
115 |
<a class="btn btn-small" id="newentry" href="/cgi-bin/koha/tools/toggle_new_status.pl?op=edit_form"><i class="icon-plus"></i> Edit</a> |
116 |
</div> |
117 |
[% FOR message IN messages %] |
118 |
[% IF message.type == "error" %] |
119 |
<div class="dialog error"> |
120 |
[% END %] |
121 |
[% IF message.code == "unable_to_load_configuration" %] |
122 |
An error occurs: Unable to load the configuration. |
123 |
[% END %] |
124 |
</div> |
125 |
[% END %] |
126 |
|
127 |
[% IF rules and op == 'edit_form' %] |
128 |
<form method="post" action="/cgi-bin/koha/tools/toggle_new_status.pl"> |
129 |
<div id="edit_rules"> |
130 |
<div id="rules"> |
131 |
<h4>List of rules</h4> |
132 |
[% FOR rule IN rules %] |
133 |
<div class="rule"> |
134 |
<input type="hidden" name="unique_id" value="[% loop.count %]" /> <!-- FIXME on update, the unique_id should be filled --> |
135 |
<div class="duration"> |
136 |
<h5>Duration</h5> |
137 |
<input type="text" value="[% rule.duration %]" name="duration_[% loop.count %]" required="required" /> days |
138 |
</div> |
139 |
<div class="blocks"> |
140 |
<h5>Conditions</h5> |
141 |
(they are cumulatives but you can separate with a pipe '|' for a field with several values): |
142 |
[% FOR condition IN rule.conditions %] |
143 |
<div class="block"> |
144 |
<select name="condition_field_[% loop.count %]"> |
145 |
<option value="">Choose a field name</option> |
146 |
[% FOR field IN item_fields %] |
147 |
[% IF condition.field == field %] |
148 |
<option value="[% field %]" selected="selected">items.[% field %]</option> |
149 |
[% ELSE %] |
150 |
<option value="[% field %]">items.[% field %]</option> |
151 |
[% END %] |
152 |
[% END %] |
153 |
</select> |
154 |
= |
155 |
<input type="text" value="[% condition.value %]" name="condition_value_[% loop.count %]" /> |
156 |
<a class="add_block" style="cursor:pointer">Add</a> |
157 |
<a class="remove_block" style="cursor:pointer">Remove</a> |
158 |
</div> |
159 |
[% END %] |
160 |
</div> |
161 |
<div class="blocks"> |
162 |
<h5>Substitutions</h5> |
163 |
If the value is an empty string, the field will be deleted. |
164 |
[% FOR substitution IN rule.substitutions %] |
165 |
<div class="block"> |
166 |
<select name="substitution_field_[% loop.count %]"> |
167 |
<option value="">Choose a field name</option> |
168 |
[% FOR field IN item_fields %] |
169 |
[% IF substitution.field == field %] |
170 |
<option value="[% field %]" selected="selected">items.[% field %]</option> |
171 |
[% ELSE %] |
172 |
<option value="[% field %]">items.[% field %]</option> |
173 |
[% END %] |
174 |
[% END %] |
175 |
</select> |
176 |
= |
177 |
<input type="text" value="[% substitution.value %]" name="substitution_value_[% loop.count %]" /> |
178 |
<a class="add_block" style="cursor:pointer">Add</a> |
179 |
<a class="remove_block" style="cursor:pointer">Remove</a> |
180 |
</div> |
181 |
[% END %] |
182 |
</div> |
183 |
<a class="remove_rule" style="cursor:pointer">Remove</a> |
184 |
</div> |
185 |
[% END %] |
186 |
</div> |
187 |
<fieldset class="action"> |
188 |
<input type="hidden" name="op" value="update" /> |
189 |
<a class="cancel" href="/cgi-bin/koha/tools/toggle_new_status.pl">Cancel</a> |
190 |
<input type="submit" value="Submit" /> |
191 |
</fieldset> |
192 |
</div> |
193 |
</form> |
194 |
<h4>Add a new rule</h4> |
195 |
<div id="new_rule"> |
196 |
<input type="hidden" name="unique_id" /> |
197 |
<div class="duration"> |
198 |
<h5>Duration</h5> |
199 |
<input type="text" value="" name="duration" required="required" /> days |
200 |
</div> |
201 |
<div class="blocks"> |
202 |
<h5>Conditions</h5> |
203 |
(they are cumulatives but you can separate with a pipe '|' for a field with several values). |
204 |
<div class="block"> |
205 |
<select name="condition_field"> |
206 |
<option value="">Choose a field name</option> |
207 |
[% FOR field IN item_fields %] |
208 |
<option value="[% field %]">items.[% field %]</option> |
209 |
[% END %] |
210 |
</select> |
211 |
= |
212 |
<input type="text" value="" name="condition_value" /> |
213 |
<a class="add_block" style="cursor:pointer">Add</a> |
214 |
<a class="remove_block" style="cursor:pointer">Remove</a> |
215 |
</div> |
216 |
</div> |
217 |
<div class="blocks"> |
218 |
<h5>Substitutions</h5> |
219 |
If the value is an empty string, the field will be deleted. |
220 |
<div class="block"> |
221 |
<select name="substitution_field"> |
222 |
<option value="">Choose a field name</option> |
223 |
[% FOR field IN item_fields %] |
224 |
<option value="[% field %]">items.[% field %]</option> |
225 |
[% END %] |
226 |
</select> |
227 |
= |
228 |
<input type="text" value="" name="substitution_value" /> |
229 |
<a class="add_block" style="cursor:pointer">Add</a> |
230 |
<a class="remove_block" style="cursor:pointer">Remove</a> |
231 |
</div> |
232 |
</div> |
233 |
<a class="add_rule" style="cursor:pointer">Add</a> |
234 |
<a class="remove_rule" style="cursor:pointer">Remove</a> |
235 |
</div> |
236 |
[% ELSIF rules and op == 'show' %] |
237 |
<div id="rules"> |
238 |
<h4>List of rules</h4> |
239 |
[% FOR rule IN rules %] |
240 |
<div class="rule"> |
241 |
<div class="duration"> |
242 |
<h5>Duration</h5> |
243 |
[% rule.duration %] days |
244 |
</div> |
245 |
<div class="blocks"> |
246 |
<h5>Conditions</h5> |
247 |
[% FOR condition IN rule.conditions %] |
248 |
[% IF condition.field %] |
249 |
<div class="block"> |
250 |
[% condition.field %] = [% condition.value %] |
251 |
</div> |
252 |
[% ELSE %] |
253 |
There is no condition for this rule. |
254 |
[% END %] |
255 |
[% END %] |
256 |
</div> |
257 |
<div class="blocks"> |
258 |
<h5>Substitutions</h5> |
259 |
[% FOR substitution IN rule.substitutions %] |
260 |
[% IF substitution.field %] |
261 |
<div class="block"> |
262 |
[% substitution.field %] = [% substitution.value %] |
263 |
</div> |
264 |
[% ELSE %] |
265 |
There is no substitution for this rule. |
266 |
[% END %] |
267 |
[% END %] |
268 |
</div> |
269 |
</div> |
270 |
[% END %] |
271 |
</div> |
272 |
[% ELSE %] |
273 |
There is no rule defined. Please click on the edit button. |
274 |
[% END %] |
275 |
|
276 |
</div> |
277 |
</div> |
278 |
<div class="yui-b noprint"> |
279 |
[% INCLUDE 'tools-menu.inc' %] |
280 |
</div> |
281 |
</div> |
282 |
[% INCLUDE 'intranet-bottom.inc' %] |