Lines 1-171
Link Here
|
1 |
[% USE Koha %] |
1 |
[% USE Koha %] |
2 |
[% USE Branches %] |
2 |
[% USE Branches %] |
|
|
3 |
[% SET footerjs = 1 %] |
3 |
[% INCLUDE 'doc-head-open.inc' %] |
4 |
[% INCLUDE 'doc-head-open.inc' %] |
4 |
<title>Koha › Tools › Notices[% IF ( add_form or copy_form ) %][% IF ( modify ) %] › Modify notice[% ELSE %] › Add notice[% END %][% END %][% IF ( add_validate or copy_validate) %] › Notice added[% END %][% IF ( delete_confirm ) %] › Confirm deletion[% END %]</title> |
5 |
<title>Koha › Tools › Notices[% IF ( add_form or copy_form ) %][% IF ( modify ) %] › Modify notice[% ELSE %] › Add notice[% END %][% END %][% IF ( add_validate or copy_validate) %] › Notice added[% END %][% IF ( delete_confirm ) %] › Confirm deletion[% END %]</title> |
5 |
[% INCLUDE 'doc-head-close.inc' %] |
6 |
[% INCLUDE 'doc-head-close.inc' %] |
6 |
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> |
7 |
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> |
7 |
[% INCLUDE 'datatables.inc' %] |
|
|
8 |
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script> |
9 |
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.insertatcaret.js"></script> |
10 |
<script type="text/javascript"> |
11 |
//<![CDATA[ |
12 |
$(document).ready(function() { |
13 |
[% IF add_form or copy_form %] |
14 |
$('#toolbar').fixFloat(); |
15 |
[% END %] |
16 |
$("#lettert:has(tbody tr)").dataTable($.extend(true, {}, dataTablesDefaults, { |
17 |
"sDom": 't', |
18 |
"aoColumnDefs": [ |
19 |
{ "bSortable": false, "bSearchable": false, 'aTargets': [ 'nosort' ] } |
20 |
], |
21 |
"bPaginate": false |
22 |
})); |
23 |
[% IF no_op_set %] |
24 |
$('#branch').change(function() { |
25 |
$('#op').val(""); |
26 |
$('#selectlibrary').submit(); |
27 |
}); |
28 |
$('#newnotice').click(function() { |
29 |
$('#op').val("add_form"); |
30 |
return true; |
31 |
}); |
32 |
[% END %] |
33 |
|
34 |
$("#newmodule").on("change",function(){ |
35 |
if( $("#branch").val() == ""){ |
36 |
var branchcode = "*"; |
37 |
} else { |
38 |
var branchcode = $("#branch").val(); |
39 |
} |
40 |
window.location.href = "/cgi-bin/koha/tools/letter.pl?op=add_form&module=" + $(this).val() + "&branchcode=" + branchcode; |
41 |
}); |
42 |
|
43 |
$("#submit_form").click( function(event) { |
44 |
event.preventDefault(); |
45 |
var at_least_one_exists = 0; |
46 |
var are_valid = 1; |
47 |
$("fieldset.mtt").each( function(){ |
48 |
var title = $(this).find('input[name="title"]').val(); |
49 |
var content = $(this).find('textarea[name="content"]').val(); |
50 |
if ( |
51 |
( title.length == 0 && content.length > 0 ) |
52 |
|| ( title.length > 0 && content.length == 0 ) |
53 |
) { |
54 |
var mtt = $(this).find('input[name="message_transport_type"]').val(); |
55 |
var msg = _("Please specify title and content for %s"); |
56 |
msg = msg.replace( "%s", mtt ); |
57 |
at_least_one_exists = 1; |
58 |
alert(msg); |
59 |
return are_valid = false; |
60 |
} else if ( title.length > 0 && content.length > 0 ) { |
61 |
at_least_one_exists = 1; |
62 |
} |
63 |
} ); |
64 |
if ( ! at_least_one_exists ) { |
65 |
alert( _("Please fill at least one template.") ); |
66 |
return false; |
67 |
} |
68 |
if ( ! are_valid ) { |
69 |
return false; |
70 |
} |
71 |
|
72 |
// Test if code already exists in DB |
73 |
var new_lettercode = $("#code").val(); |
74 |
var new_branchcode = $("#branch").val(); |
75 |
[% IF ( add_form and code ) # IF edit %] |
76 |
if ( new_lettercode != '[% code %]' ) { |
77 |
[% END %] |
78 |
$.ajax({ |
79 |
data: { code: new_lettercode, branchcode: new_branchcode }, |
80 |
type: 'GET', |
81 |
url: '/cgi-bin/koha/svc/letters/', |
82 |
success: function (data) { |
83 |
if ( data.letters.length > 0 ) { |
84 |
if( new_branchcode == '' ) { |
85 |
alert( _("A default letter with the code '%s' already exists.").format(new_lettercode) ); |
86 |
} else { |
87 |
alert( _("A letter with the code '%s' already exists for '%s'.").format(new_lettercode, new_branchcode) ); |
88 |
} |
89 |
return false; |
90 |
} else { |
91 |
$("#add_notice").submit(); |
92 |
} |
93 |
}, |
94 |
}); |
95 |
[% IF ( add_form and code ) %] |
96 |
} else { |
97 |
$("#add_notice").submit(); |
98 |
} |
99 |
[% END %] |
100 |
}); |
101 |
|
102 |
var sms_limit = 160; |
103 |
$("#content_sms").on("keyup", function(){ |
104 |
var length = $(this).val().length; |
105 |
$("#sms_counter").html(length + "/" + sms_limit + _(" characters")); |
106 |
if ( length > sms_limit ) { |
107 |
$("#sms_counter").css("color", "red"); |
108 |
} else { |
109 |
$("#sms_counter").css("color", "black"); |
110 |
} |
111 |
}); |
112 |
$( ".transport-types" ).accordion({ collapsible: true, active:false, animate: 200 }); |
113 |
$(".insert").on("click",function(){ |
114 |
var containerid = $(this).data("containerid"); |
115 |
insertValueQuery( containerid ); |
116 |
}) |
117 |
|
118 |
$("#tabs").tabs(); |
119 |
|
120 |
$("#saveandcontinue").on("click",function(e){ |
121 |
e.preventDefault(); |
122 |
$("#redirect").val("just_save"); |
123 |
$("#submit_form").click(); |
124 |
}); |
125 |
|
126 |
}); |
127 |
[% IF add_form or copy_form %] |
128 |
|
129 |
function cancel(f) { |
130 |
$('#op').val(""); |
131 |
f.method = "get"; |
132 |
f.submit(); |
133 |
} |
134 |
|
135 |
function isNotNull(f,noalert) { |
136 |
if (f.value.length ==0) { |
137 |
return false; |
138 |
} |
139 |
return true; |
140 |
} |
141 |
|
142 |
function isNum(v,maybenull) { |
143 |
var n = new Number(v.value); |
144 |
if (isNaN(n)) { |
145 |
return false; |
146 |
} |
147 |
if (maybenull==0 && v.value=='') { |
148 |
return false; |
149 |
} |
150 |
return true; |
151 |
} |
152 |
function insertValueQuery(containerid) { |
153 |
var fieldset = $("#" + containerid); |
154 |
var myQuery = $(fieldset).find('textarea[name="content"]'); |
155 |
var myListBox = $(fieldset).find('select[name="SQLfieldname"]'); |
156 |
|
157 |
if($(myListBox).find('option').length > 0) { |
158 |
$(myListBox).find('option').each( function (){ |
159 |
if ( $(this).attr('selected') && $(this).val().length > 0 ) { |
160 |
$(myQuery).insertAtCaret("<<" + $(this).val() + ">>"); |
161 |
} |
162 |
}); |
163 |
} |
164 |
} |
165 |
[% END %] |
166 |
//]]> |
167 |
</script> |
168 |
</head> |
8 |
</head> |
|
|
9 |
|
169 |
<body id="tools_letter" class="tools"> |
10 |
<body id="tools_letter" class="tools"> |
170 |
[% INCLUDE 'header.inc' %] |
11 |
[% INCLUDE 'header.inc' %] |
171 |
[% INCLUDE 'letters-search.inc' %] |
12 |
[% INCLUDE 'letters-search.inc' %] |
Lines 555-558
$(document).ready(function() {
Link Here
|
555 |
</div> |
396 |
</div> |
556 |
[% END %] |
397 |
[% END %] |
557 |
</div> |
398 |
</div> |
|
|
399 |
|
400 |
[% MACRO jsinclude BLOCK %] |
401 |
<script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script> |
402 |
[% INCLUDE 'datatables.inc' %] |
403 |
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script> |
404 |
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.insertatcaret.js"></script> |
405 |
<script type="text/javascript"> |
406 |
$(document).ready(function() { |
407 |
[% IF add_form or copy_form %] |
408 |
$('#toolbar').fixFloat(); |
409 |
[% END %] |
410 |
$("#lettert:has(tbody tr)").dataTable($.extend(true, {}, dataTablesDefaults, { |
411 |
"sDom": 't', |
412 |
"aoColumnDefs": [ |
413 |
{ "bSortable": false, "bSearchable": false, 'aTargets': [ 'nosort' ] } |
414 |
], |
415 |
"bPaginate": false |
416 |
})); |
417 |
[% IF no_op_set %] |
418 |
$('#branch').change(function() { |
419 |
$('#op').val(""); |
420 |
$('#selectlibrary').submit(); |
421 |
}); |
422 |
$('#newnotice').click(function() { |
423 |
$('#op').val("add_form"); |
424 |
return true; |
425 |
}); |
426 |
[% END %] |
427 |
|
428 |
$("#newmodule").on("change",function(){ |
429 |
if( $("#branch").val() == ""){ |
430 |
var branchcode = "*"; |
431 |
} else { |
432 |
var branchcode = $("#branch").val(); |
433 |
} |
434 |
window.location.href = "/cgi-bin/koha/tools/letter.pl?op=add_form&module=" + $(this).val() + "&branchcode=" + branchcode; |
435 |
}); |
436 |
|
437 |
$("#submit_form").click( function(event) { |
438 |
event.preventDefault(); |
439 |
var at_least_one_exists = 0; |
440 |
var are_valid = 1; |
441 |
$("fieldset.mtt").each( function(){ |
442 |
var title = $(this).find('input[name="title"]').val(); |
443 |
var content = $(this).find('textarea[name="content"]').val(); |
444 |
if ( |
445 |
( title.length == 0 && content.length > 0 ) |
446 |
|| ( title.length > 0 && content.length == 0 ) |
447 |
) { |
448 |
var mtt = $(this).find('input[name="message_transport_type"]').val(); |
449 |
var msg = _("Please specify title and content for %s"); |
450 |
msg = msg.replace( "%s", mtt ); |
451 |
at_least_one_exists = 1; |
452 |
alert(msg); |
453 |
return are_valid = false; |
454 |
} else if ( title.length > 0 && content.length > 0 ) { |
455 |
at_least_one_exists = 1; |
456 |
} |
457 |
} ); |
458 |
if ( ! at_least_one_exists ) { |
459 |
alert( _("Please fill at least one template.") ); |
460 |
return false; |
461 |
} |
462 |
if ( ! are_valid ) { |
463 |
return false; |
464 |
} |
465 |
|
466 |
// Test if code already exists in DB |
467 |
var new_lettercode = $("#code").val(); |
468 |
var new_branchcode = $("#branch").val(); |
469 |
[% IF ( add_form and code ) # IF edit %] |
470 |
if ( new_lettercode != '[% code %]' ) { |
471 |
[% END %] |
472 |
$.ajax({ |
473 |
data: { code: new_lettercode, branchcode: new_branchcode }, |
474 |
type: 'GET', |
475 |
url: '/cgi-bin/koha/svc/letters/', |
476 |
success: function (data) { |
477 |
if ( data.letters.length > 0 ) { |
478 |
if( new_branchcode == '' ) { |
479 |
alert( _("A default letter with the code '%s' already exists.").format(new_lettercode) ); |
480 |
} else { |
481 |
alert( _("A letter with the code '%s' already exists for '%s'.").format(new_lettercode, new_branchcode) ); |
482 |
} |
483 |
return false; |
484 |
} else { |
485 |
$("#add_notice").submit(); |
486 |
} |
487 |
}, |
488 |
}); |
489 |
[% IF ( add_form and code ) %] |
490 |
} else { |
491 |
$("#add_notice").submit(); |
492 |
} |
493 |
[% END %] |
494 |
}); |
495 |
|
496 |
var sms_limit = 160; |
497 |
$("#content_sms").on("keyup", function(){ |
498 |
var length = $(this).val().length; |
499 |
$("#sms_counter").html(length + "/" + sms_limit + _(" characters")); |
500 |
if ( length > sms_limit ) { |
501 |
$("#sms_counter").css("color", "red"); |
502 |
} else { |
503 |
$("#sms_counter").css("color", "black"); |
504 |
} |
505 |
}); |
506 |
$( ".transport-types" ).accordion({ collapsible: true, active:false, animate: 200 }); |
507 |
$(".insert").on("click",function(){ |
508 |
var containerid = $(this).data("containerid"); |
509 |
insertValueQuery( containerid ); |
510 |
}) |
511 |
|
512 |
$("#tabs").tabs(); |
513 |
|
514 |
$("#saveandcontinue").on("click",function(e){ |
515 |
e.preventDefault(); |
516 |
$("#redirect").val("just_save"); |
517 |
$("#submit_form").click(); |
518 |
}); |
519 |
|
520 |
}); |
521 |
[% IF add_form or copy_form %] |
522 |
function cancel(f) { |
523 |
$('#op').val(""); |
524 |
f.method = "get"; |
525 |
f.submit(); |
526 |
} |
527 |
|
528 |
function isNotNull(f,noalert) { |
529 |
if (f.value.length ==0) { |
530 |
return false; |
531 |
} |
532 |
return true; |
533 |
} |
534 |
|
535 |
function isNum(v,maybenull) { |
536 |
var n = new Number(v.value); |
537 |
if (isNaN(n)) { |
538 |
return false; |
539 |
} |
540 |
if (maybenull==0 && v.value==''){ |
541 |
return false; |
542 |
} |
543 |
return true; |
544 |
} |
545 |
function insertValueQuery(containerid) { |
546 |
var fieldset = $("#" + containerid); |
547 |
var myQuery = $(fieldset).find('textarea[name="content"]'); |
548 |
var myListBox = $(fieldset).find('select[name="SQLfieldname"]'); |
549 |
|
550 |
if($(myListBox).find('option').length > 0) { |
551 |
$(myListBox).find('option').each( function (){ |
552 |
if ( $(this).attr('selected') && $(this).val().length > 0 ) { |
553 |
$(myQuery).insertAtCaret("<<" + $(this).val() + ">>"); |
554 |
} |
555 |
}); |
556 |
} |
557 |
} |
558 |
[% END %] |
559 |
</script> |
560 |
[% END %] |
561 |
|
558 |
[% INCLUDE 'intranet-bottom.inc' %] |
562 |
[% INCLUDE 'intranet-bottom.inc' %] |