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 |
$(new_rule).find('a.add_rule').remove(); |
85 |
unique_id++; |
86 |
}); |
87 |
|
88 |
$("a.add_block").click(function(){ |
89 |
clone_block( $(this).parent() ); |
90 |
}); |
91 |
|
92 |
if( $("#rules").find("div.rule").length < 1 ) { |
93 |
$("#edit_rules").hide(); |
94 |
} |
95 |
|
96 |
$("#rules .rule .blocks").each(function(){ |
97 |
if ( $(this).find(".block").length == 1 ) { |
98 |
$(this).find("a.remove_block").hide(); |
99 |
} |
100 |
}); |
101 |
}); |
102 |
//]]> |
103 |
</script> |
104 |
</head> |
105 |
<body id="tools_toggle_new_status" class="tools"> |
106 |
[% INCLUDE 'header.inc' %] |
107 |
[% INCLUDE 'cat-search.inc' %] |
108 |
<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> |
109 |
|
110 |
<div id="doc3" class="yui-t2"> |
111 |
<div id="bd"> |
112 |
<div id="yui-main"> |
113 |
<div class="yui-b"> |
114 |
<h3>Toggle new status</h3> |
115 |
<div id="toolbar" class="btn-toolbar"> |
116 |
<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> |
117 |
</div> |
118 |
[% FOR message IN messages %] |
119 |
[% IF message.type == "error" %] |
120 |
<div class="dialog error"> |
121 |
[% END %] |
122 |
[% IF message.code == "unable_to_load_configuration" %] |
123 |
An error occurs: Unable to load the configuration. |
124 |
[% END %] |
125 |
</div> |
126 |
[% END %] |
127 |
|
128 |
[% IF op == 'edit_form' %] |
129 |
<form method="post" action="/cgi-bin/koha/tools/toggle_new_status.pl"> |
130 |
<div id="edit_rules"> |
131 |
<div id="rules"> |
132 |
<h4>List of rules</h4> |
133 |
[% FOR rule IN rules %] |
134 |
[% SET id = loop.count %] |
135 |
<div class="rule"> |
136 |
<input type="hidden" name="unique_id" value="[% loop.count %]" /> <!-- FIXME on update, the unique_id should be filled --> |
137 |
<div class="duration"> |
138 |
<h5>Duration</h5> |
139 |
<input type="text" value="[% rule.duration %]" name="duration_[% id %]" /> days |
140 |
</div> |
141 |
<div class="blocks"> |
142 |
<h5>Conditions</h5> |
143 |
[% FOR condition IN rule.conditions %] |
144 |
<div class="block"> |
145 |
<select name="condition_field_[% id %]"> |
146 |
<option value="">Choose a field name</option> |
147 |
[% FOR field IN item_fields %] |
148 |
[% IF condition.field == field %] |
149 |
<option value="[% field %]" selected="selected">items.[% field %]</option> |
150 |
[% ELSE %] |
151 |
<option value="[% field %]">items.[% field %]</option> |
152 |
[% END %] |
153 |
[% END %] |
154 |
</select> |
155 |
= |
156 |
<input type="text" value="[% condition.value %]" name="condition_value_[% id%]" /> |
157 |
<a class="add_block" style="cursor:pointer"><i class="icon-plus"></i></a> |
158 |
<a class="remove_block" style="cursor:pointer"><i class="icon-remove"></i></a> |
159 |
</div> |
160 |
[% END %] |
161 |
</div> |
162 |
<div class="blocks"> |
163 |
<h5>Substitutions</h5> |
164 |
[% FOR substitution IN rule.substitutions %] |
165 |
<div class="block"> |
166 |
<select name="substitution_field_[% id %]"> |
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_[% id %]" /> |
178 |
<a class="add_block" style="cursor:pointer"><i class="icon-plus"></i></a> |
179 |
<a class="remove_block" style="cursor:pointer"><i class="icon-remove"></i></a> |
180 |
</div> |
181 |
[% END %] |
182 |
</div> |
183 |
<a class="remove_rule" style="cursor:pointer">Remove this rule</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 theses rules" /> |
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" /> days |
200 |
</div> |
201 |
<div class="blocks"> |
202 |
<h5>Conditions</h5> |
203 |
<div class="block"> |
204 |
<select name="condition_field"> |
205 |
<option value="">Choose a field name</option> |
206 |
[% FOR field IN item_fields %] |
207 |
<option value="[% field %]">items.[% field %]</option> |
208 |
[% END %] |
209 |
</select> |
210 |
= |
211 |
<input type="text" value="" name="condition_value" /> |
212 |
<a class="add_block" style="cursor:pointer"><i class="icon-plus"></i></a> |
213 |
<a class="remove_block" style="cursor:pointer"><i class="icon-remove"></i></a> |
214 |
</div> |
215 |
</div> |
216 |
<div class="blocks"> |
217 |
<h5>Substitutions</h5> |
218 |
<div class="block"> |
219 |
<select name="substitution_field"> |
220 |
<option value="">Choose a field name</option> |
221 |
[% FOR field IN item_fields %] |
222 |
<option value="[% field %]">items.[% field %]</option> |
223 |
[% END %] |
224 |
</select> |
225 |
= |
226 |
<input type="text" value="" name="substitution_value" /> |
227 |
<a class="add_block" style="cursor:pointer"><i class="icon-plus"></i></a> |
228 |
<a class="remove_block" style="cursor:pointer"><i class="icon-remove"></i></a> |
229 |
</div> |
230 |
</div> |
231 |
<a class="add_rule" style="cursor:pointer">Add this rule</a> |
232 |
<a class="remove_rule" style="cursor:pointer">Remove this rule</a> |
233 |
</div> |
234 |
[% ELSIF rules and op == 'show' %] |
235 |
<div id="rules"> |
236 |
<h4>List of rules</h4> |
237 |
[% FOR rule IN rules %] |
238 |
<div class="rule"> |
239 |
<div class="duration"> |
240 |
<h5>Duration</h5> |
241 |
[% IF rule.duration.defined and rule.duration.length > 0 %] |
242 |
[% rule.duration %] days |
243 |
[% ELSE %] |
244 |
There is no duration for this rule. |
245 |
[% END %] |
246 |
</div> |
247 |
<div class="blocks"> |
248 |
<h5>Conditions</h5> |
249 |
[% FOR condition IN rule.conditions %] |
250 |
[% IF condition.field %] |
251 |
<div class="block"> |
252 |
[% condition.field %] = [% condition.value %] |
253 |
</div> |
254 |
[% ELSE %] |
255 |
There is no condition for this rule. |
256 |
[% END %] |
257 |
[% END %] |
258 |
</div> |
259 |
<div class="blocks"> |
260 |
<h5>Substitutions</h5> |
261 |
[% FOR substitution IN rule.substitutions %] |
262 |
<div class="block"> |
263 |
[% substitution.field %] = [% substitution.value %] |
264 |
</div> |
265 |
[% END %] |
266 |
</div> |
267 |
</div> |
268 |
[% END %] |
269 |
</div> |
270 |
[% ELSE %] |
271 |
There is no rule defined. Please click on the edit button. |
272 |
[% END %] |
273 |
|
274 |
</div> |
275 |
</div> |
276 |
<div class="yui-b noprint"> |
277 |
[% INCLUDE 'tools-menu.inc' %] |
278 |
</div> |
279 |
</div> |
280 |
[% INCLUDE 'intranet-bottom.inc' %] |