Bug 20166: Untranslatable course reserves delete prompt
[srvgit] / koha-tmpl / intranet-tmpl / prog / en / modules / course_reserves / course-details.tt
index e07cbe5..bdddeb5 100644 (file)
@@ -1,44 +1,12 @@
 [% USE AuthorisedValues %]
 [% USE ItemTypes %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Course reserves &rsaquo; Course details for [% course.course_name %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 
-<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-    $(document).ready(function(){
-        $("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, {
-            "sPaginationType": "four_button",
-            "aoColumnDefs": [
-                { 'bSortable': false, 'aTargets': [ 'NoSort' ] },
-                { 'sType': "anti-the", 'aTargets' : [ 'antithe'] }
-            ]
-        }));
-
-        $(".delete_item").click(function(){
-            return confirmDelete(_("Are you sure you want to remove this item from the course?"));
-        });
-
-        $("#delete_course").click(function(){
-            return confirm( _("Are you sure you want to delete this course?") );
-        });
-        $(".disabled").tooltip().on("click", function(e){
-            e.preventDefault();
-            if( $(this).hasClass("checkedout") ){
-                alert(_("This item cannot be removed. It is checked out"));
-            }
-            if( $(this).hasClass("itemlost") ) {
-                alert(_("This item cannot be removed. It is lost"));
-            }
-        });
-    });
-
-//]]>
-</script>
-
+<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
 </head>
 
 <body id="courses_course_details" class="course">
                                     [% IF CAN_user_coursereserves_delete_reserves %]
                                         [% IF cr.item.onloan %]
                                             <a class="btn btn-default btn-xs disabled checkedout delete_item" href="#" data-toggle="tooltip" data-placement="left" title="This item is checked out">
-                                        [% ELSIF cr.item.itemlost %]
-                                            <a class="btn btn-default btn-xs disabled itemlost delete_item" href="#" data-toggle="tooltip" data-placement="left" title="This item is lost">
                                         [% ELSE %]
                                             <a class="btn btn-default btn-xs delete_item" href="course-details.pl?course_id=[% course.course_id %]&amp;action=del_reserve&amp;cr_id=[% cr.cr_id %]">
                                         [% END %]
         </div>
     </div>
 
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript">
+        $(document).ready(function(){
+            $("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "sPaginationType": "four_button",
+                "aoColumnDefs": [
+                    { 'bSortable': false, 'aTargets': [ 'NoSort' ] },
+                    { 'sType': "anti-the", 'aTargets' : [ 'antithe'] }
+                ]
+            }));
+
+            $(".delete_item").click(function(){
+                return confirmDelete(_("Are you sure you want to remove this item from the course?"));
+            });
+
+            $("#delete_course").click(function(){
+                [% SET count = course_reserves.size || 0 %]
+                [% IF count == 1 %]
+                    return confirmDelete(_("Are you sure you want to delete this course? There is %s attached item.").format([% count %]) );
+                [% ELSIF count > 1 %]
+                    return confirmDelete(_("Are you sure you want to delete this course? There are %s attached items.").format([% count %]) );
+                [% ELSE %]
+                    return confirmDelete(_("Are you sure you want to delete this course?"));
+                [% END %]
+            });
+            $(".disabled").tooltip().on("click", function(e){
+                e.preventDefault();
+                if( $(this).hasClass("checkedout") ){
+                    alert(_("This item cannot be removed. It is checked out"));
+                }
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]