Bug 6027 - Delete biblios if deleting all their items in batch deletion
[koha_gimpoz] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / letter.tt
index 1ec73c5..fd0aa92 100644 (file)
@@ -5,14 +5,29 @@
        <script type="text/javascript">
        //<![CDATA[
 $(document).ready(function() {
-       $("#lettert").tablesorter({
+       $("#lettert:has(tbody tr)").tablesorter({
                widgets : ['zebra'],
                sortList: [[0,0]],
                headers: { 3: {sorter:false},4: { sorter: false }}
        }); 
+
+    $('#branch').change(function() {
+            $('#op').val("");
+            $('#selectlibrary').submit();
+    });
+    $('#newnotice').click(function() {
+            $('#op').val("add_form");
+            return true;
+    });
 }); 
 [% IF ( add_form ) %]
        
+    function cancel(f) {
+        $('#op').val("");
+        f.method = "get";
+        f.submit();
+    }
+
                function isNotNull(f,noalert) {
                        if (f.value.length ==0) {
        return false;
@@ -106,7 +121,7 @@ $(document).ready(function() {
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'letters-search.inc' %]
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% IF ( add_form ) %][% IF ( modify ) %]<a href="/cgi-bin/koha/tools/letter.pl">Notices</a> &rsaquo; Modify notice[% ELSE %] <a href="/cgi-bin/koha/tools/letter.pl">Notices</a> &rsaquo; Add notice[% END %][% ELSE %][% IF ( add_validate ) %] <a href="/cgi-bin/koha/tools/letter.pl">Notices</a> &rsaquo; Notice added[% ELSE %][% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/tools/letter.pl">Notices</a> &rsaquo; Confirm Deletion[% ELSE %]Notices[% END %][% END %][% END %]</div>
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% IF ( add_form ) %][% IF ( modify ) %]<a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Modify notice[% ELSE %] <a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Add notice[% END %][% ELSE %][% IF ( add_validate ) %] <a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Notice added[% ELSE %][% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Confirm Deletion[% ELSE %]Notices &amp; Slips[% END %][% END %][% END %]</div>
 
 [% IF ( add_form ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
    
@@ -114,65 +129,97 @@ $(document).ready(function() {
        <div id="yui-main">
        <div class="yui-b">
 
-       [% IF ( no_op_set ) %]
-<div id="toolbar">
-       <script type="text/javascript">
-       //<![CDATA[
-       // prepare DOM for YUI Toolbar
-        $(document).ready(function() {
-           yuiToolbar();
-        });
-       // YUI Toolbar Functions
-       function yuiToolbar() {
-           new YAHOO.widget.Button("newnotice");
-       }
-       //]]>
-       </script>
-       <ul class="toolbar">
-       <li><a id="newnotice" href="/cgi-bin/koha/tools/letter.pl?op=add_form">New Notice</a></li>
-</ul></div>
-               
+[% IF ( no_op_set ) %]
+    <form method="get" action="?" id="selectlibrary">
+      <input type="hidden" name="searchfield" value="[% searchfield %]" />
+    [% UNLESS independant_branch %]
+      <p>
+        Select a library :
+            <select name="branchcode" id="branch" style="width:20em;">
+                <option value="">All libraries</option>
+            [% FOREACH branchloo IN branchloop %]
+                [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
+            [% END %]
+            </select>
+      </p>
+    [% END %]
+      <p>
+             <input type="submit" id="newnotice" value="New Notice" />
+        <input type="hidden" id="op" name="op" />
+      </p>
+    </form>
+
                [% IF ( search ) %]
                <p>You Searched for <b>[% searchfield %]</b></p>
                [% END %]
-               [% IF ( letter ) %]<table id="lettert">
+               [% IF ( letter && !independant_branch) %]
+            [% select_for_copy = BLOCK %]
+            <select name="branchcode">
+                [% FOREACH branchloo IN branchloop %]
+                <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
+                [% END %]
+            </select>
+            [% END %]
+        [% END %]
+        <table id="lettert">
                <thead><tr>
+                       <th>Library</th>
                        <th>Module</th>
                        <th>Code</th>
                        <th>Name</th>
                        <th>&nbsp;</th>
                        <th>&nbsp;</th>
+                       <th>&nbsp;</th>
                </tr></thead>
-               <tbody>[% FOREACH lette IN letter %]
-               [% UNLESS ( loop.odd ) %]
+               <tbody>
+    [% FOREACH lette IN letter %]
+        [% can_edit = lette.branchcode || !independant_branch %]
+        [% UNLESS ( loop.odd ) %]
                        <tr class="highlight">
-               [% ELSE %]
+        [% ELSE %]
                        <tr>
-               [% END %]
+        [% END %]
+                               <td>[% lette.branchname || "(All libraries)" %]</td>
                                <td>[% lette.module %]</td>
                                <td>[% lette.code %]</td>
                                <td>[% lette.name %]</td>
                                <td>
-                                       <a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;module=[% lette.module %]&amp;code=[% lette.code %]">Edit</a>
+        [% IF can_edit %]
+                                       <a href="/cgi-bin/koha/tools/letter.pl?op=add_form&branchcode=[% lette.branchcode %]&module=[% lette.module %]&code=[% lette.code %]">Edit</a>
+        [% END %]
+                               </td>
+                               <td>
+        [% IF !independant_branch || !lette.branchcode %]
+                    <form method="post" action="?">
+                        <input type="hidden" name="op" value="copy" />
+                                       <input type="hidden" name="oldbranchcode" value="[% lette.branchcode %]" />
+                        <input type="hidden" name="module" value="[% lette.module %]" />
+                        <input type="hidden" name="code" value="[% lette.code %]" />
+            [% IF independant_branch %]
+                        <input type="hidden" name="branchcode" value="[% independant_branch %]" />
+            [% ELSE %]
+                        [% select_for_copy %]
+            [% END %]
+                        <input type="submit" value="Copy" />
+                    </form>
+        [% END %]
                                </td>
                                <td>
-                                       [% IF ( lette.protected ) %]
-                                       -
-                                       [% ELSE %]
-                                       <a href="/cgi-bin/koha/tools/letter.pl?op=delete_confirm&amp;module=[% lette.module %]&amp;code=[% lette.code %]">Delete</a>
-                                       [% END %]
+        [% IF !lette.protected && can_edit %]
+                                       <a href="/cgi-bin/koha/tools/letter.pl?op=delete_confirm&branchcode=[%lette.branchcode %]&module=[% lette.module %]&code=[% lette.code %]">Delete</a>
+        [% END %]
                                </td>
                        </tr>
-               [% END %]</tbody>
+    [% END %]
+        </tbody>
                </table>
-               [% END %]
+[% END %]
 
-       [% END %]
        
-       [% IF ( add_form ) %]
+[% IF ( add_form ) %]
        
-               <form action="/cgi-bin/koha/tools/letter.pl" name="Aform" method="post">
-               <input type="hidden" name="op" value="add_validate" />
+               <form action="?" name="Aform" method="post">
+               <input type="hidden" name="op" id="op" value="add_validate" />
                <input type="hidden" name="checked" value="0" />
                [% IF ( modify ) %]
                <input type="hidden" name="add" value="0" />
@@ -182,8 +229,23 @@ $(document).ready(function() {
                <fieldset class="rows">
                <legend>[% IF ( modify ) %]Modify notice[% ELSE %]Add notice[% END %]</legend>
                <ol>
+                               <input type="hidden" name="oldbranchcode" value="[% branchcode %]" />
+            [% IF independant_branch %]
+                <input type="hidden" name="branchcode" value="[% independant_branch %]" />
+            [% ELSE %]
+                       <li>
+                               <label for="branchcode">Library:</label>
+                <select name="branchcode" id="branch" style="width:20em;">
+                    <option value="">All libraries</option>
+                [% FOREACH branchloo IN branchloop %]
+                    [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
+                [% END %]
+                </select>
+                       </li>
+            [% END %]
                        <li>
                                <label for="module">Koha module:</label>
+                               <input type="hidden" name="oldmodule" value="[% module %]" />
                [% IF ( modify ) %]<select name="module" id="module">[% END %] [% IF ( adding ) %] <select name="module" id="module" onchange="javascript:window.location.href = unescape(window.location.pathname)+'?op=add_form&amp;module='+this.value+'&amp;content='+window.document.forms['Aform'].elements['content'].value;">[% END %]
                                     [% IF ( catalogue ) %]
                                     <option value="catalogue" selected="selected">Catalog</option>
@@ -234,6 +296,14 @@ $(document).ready(function() {
                        <label for="name">Name:</label><input type="text" id="name" name="name" size="60" value="[% name %]" />
                </li>
                <li>
+                       <label for="is_html">HTML Message:</label>
+      [% IF is_html %]
+      <input type="checkbox" id="is_html" name="is_html" value="1" checked />
+      [% ELSE %]
+      <input type="checkbox" id="is_html" name="is_html" value="1" />
+      [% END %]
+               </li>
+               <li>
                        <label for="title">Message Subject:</label><input type="text" id="title" name="title" size="60" value="[% title %]" />
                </li>
                <li>
@@ -251,27 +321,31 @@ $(document).ready(function() {
                </ol>
                </fieldset>
                <fieldset class="action"><input type="button" value="Submit" onclick="Check(this.form)" class="button" /></fieldset>
+               <fieldset class="action"><input type="button" value="Cancel" onclick="cancel(this.form)" class="button" /></fieldset>
+      <input type="hidden" name="searchfield" value="[% searchfield %]" />
                </form>
-       [% END %]
+[% END %]
        
-       [% IF ( add_validate ) %]
+[% IF ( add_validate ) %]
        Data recorded
        <form action="[% action %]" method="post">
        <input type="submit" value="OK" />
        </form>
-       [% END %]
+[% END %]
        
-       [% IF ( delete_confirm ) %]
+[% IF ( delete_confirm ) %]
        <div class="dialog alert"><h3>Delete Notice?</h3>
        <table>
         <thead>
                <tr>
+                       <th>Library</th>
                        <th>Module</th>
                        <th>Code</th>
                        <th>Name</th>
                </tr>
         </thead>
                <tr>
+                       <td>[% branchname %]</td>
                        <td>[% module %]</td>
             <td>[% code %]</td>
                        <td>[% name %]</td>
@@ -279,6 +353,7 @@ $(document).ready(function() {
        </table>
                <form action="[% action %]" method="post">
                <input type="hidden" name="op" value="delete_confirmed">
+               <input type="hidden" name="branchcode" value="[% branchcode %]" />
                <input type="hidden" name="code" value="[% code %]" />
                <input type="hidden" name="module" value="[% module %]" />
                                <input type="submit" value="Yes, Delete" class="approve" />
@@ -289,14 +364,14 @@ $(document).ready(function() {
                                </form>
                </div>
 
-       [% END %]
+[% END %]
        
-       [% IF ( delete_confirmed ) %]
+[% IF ( delete_confirmed ) %]
        Data deleted
        <form action="[% action %]" method="post">
        <input type="submit" value="OK" />
        </form>
-       [% END %]
+[% END %]
 
 </div>
 </div>