Bug 11742: A letter code should be unique.
[koha_fer] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / letter.tt
index 749d480..34df1e7 100644 (file)
@@ -1,26 +1,95 @@
+[% USE Koha %]
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Tools &rsaquo; Notices[% IF ( add_form ) %][% IF ( modify ) %] &rsaquo; Modify notice[% ELSE %] &rsaquo; Add notice[% END %][% END %][% IF ( add_validate ) %] &rsaquo; Notice added[% END %][% IF ( delete_confirm ) %] &rsaquo; Confirm Deletion[% END %]</title>
+<title>Koha &rsaquo; Tools &rsaquo; Notices[% IF ( add_form or copy_form ) %][% IF ( modify ) %] &rsaquo; Modify notice[% ELSE %] &rsaquo; Add notice[% END %][% END %][% IF ( add_validate or copy_validate) %] &rsaquo; Notice added[% END %][% IF ( delete_confirm ) %] &rsaquo; Confirm deletion[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
-       <script type="text/javascript">
-       //<![CDATA[
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+[% INCLUDE 'datatables.inc' %]
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.insertatcaret.js"></script>
+<script type="text/javascript">
+//<![CDATA[
 $(document).ready(function() {
-       $("#lettert:has(tbody tr)").tablesorter({
-               widgets : ['zebra'],
-               sortList: [[0,0]],
-               headers: { 3: {sorter:false},4: { sorter: false }}
-       }); 
-
-    $('#branch').change(function() {
+    $("#lettert:has(tbody tr)").dataTable($.extend(true, {}, dataTablesDefaults, {
+        "sDom": 't',
+        "aoColumnDefs": [
+            { "aTargets": [ -1,-2, -3 ], "bSortable": false, "bSearchable": false }
+        ],
+        "bPaginate": false
+    }));
+    [% IF no_op_set %]
+      $('#branch').change(function() {
             $('#op').val("");
             $('#selectlibrary').submit();
-    });
-    $('#newnotice').click(function() {
+      });
+      $('#newnotice').click(function() {
             $('#op').val("add_form");
             return true;
+      });
+    [% END %]
+
+    $("#submit_form").click( function(event) {
+        event.preventDefault();
+        var at_least_one_exists = 0;
+        $("fieldset.mtt").each( function(){
+            var title = $(this).find('input[name="title"]').val();
+            var content = $(this).find('textarea[name="content"]').val();
+            if (
+                    ( title.length == 0 && content.length > 0 )
+                 || ( title.length > 0 && content.length == 0 )
+            ) {
+                var mtt = $(this).find('input[name="message_transport_type"]').val();
+                var msg = _("Please specify title and content for %s");
+                msg = msg.replace( "%s", mtt );
+                at_least_one_exists = 1;
+                alert(msg)
+                return false;
+            } else if ( title.length > 0 && content.length > 0 ) {
+                at_least_one_exists = 1;
+            }
+        } );
+        if ( ! at_least_one_exists ) {
+            alert( _("Please fill at least one template.") );
+            return false;
+        }
+
+        // Test if code already exists in DB
+        var new_lettercode = $("#code").val();
+        [% IF copy_form %]
+          if ( new_lettercode == '[% code %]' ) {
+            alert( _("Please change the code.") );
+            return false;
+          }
+        [% END %]
+        if ( new_lettercode != '[% code %]' ) {
+          $.ajax({
+            data: { code: new_lettercode },
+            type: 'GET',
+            url: '/cgi-bin/koha/svc/letters/',
+            success: function (data) {
+              if ( data.letters.length > 0 ) {
+                alert( _("This letter code is already used for another letter.") );
+                return false;
+              } else {
+                $("#add_notice").submit();
+              }
+            },
+          });
+        } else {
+          $("#add_notice").submit();
+        }
+    });
+
+    var sms_limit = 160;
+    $("#content_sms").on("keyup", function(){
+        var length = $(this).val().length;
+        $("#sms_counter").html(length + "/" + sms_limit + _(" characters"));
+        if ( length  > sms_limit ) {
+            $("#sms_counter").css("color", "red");
+        } else {
+            $("#sms_counter").css("color", "black");
+        }
     });
 }); 
-[% IF ( add_form ) %]
+[% IF add_form or copy_form %]
        
     function cancel(f) {
         $('#op').val("");
@@ -34,13 +103,7 @@ $(document).ready(function() {
                        }
                        return true;
                }
-       
-               function toUC(f) {
-                       var x=f.value.toUpperCase();
-                       f.value=x;
-                       return true;
-               }
-       
+
                function isNum(v,maybenull) {
                var n = new Number(v.value);
                if (isNaN(n)) {
@@ -51,86 +114,44 @@ $(document).ready(function() {
                }
                return true;
                }
-       
-               function isDate(f) {
-                       var t = Date.parse(f.value);
-                       if (isNaN(t)) {
-                               return false;
-                       }
-               }
-       
-               function Check(f) {
-                       var ok=1;
-                       var _alertString="";
-                       var alertString2;
-/*                     if (!(isNotNull(window.document.Aform.code))) {
-                               _alertString += "\n- " + _("Code missing");
-                       }*/
-/*                     if (!(isNotNull(window.document.Aform.name))) {
-                               _alertString += "\n- " + _("Name missing");
-                       }*/
-                       if (_alertString.length==0) {
-                               document.Aform.submit();
-                       } else {
-                               alertString2  = _("Form not submitted because of the following problem(s)");
-                               alertString2 += "\n------------------------------------------------------------------------------------\n";
-                               alertString2 += _alertString;
-                               alert(alertString2);
-                       }
-               }
-               // GPL code coming from PhpMyAdmin
-               function insertValueQuery() {
-                       var myQuery = document.Aform.content;
-                       var myListBox = document.Aform.SQLfieldname;
-               
-                       if(myListBox.options.length > 0) {
-                               var chaineAj = "";
-                               var NbSelect = 0;
-                               for(var i=0; i<myListBox.options.length; i++) {
-                                       if (myListBox.options[i].selected){
-                                               NbSelect++;
-                                               if (NbSelect > 1)
-                                                       chaineAj += ", ";
-                                               chaineAj += myListBox.options[i].value;
-                                       }
-                               }
-               
-                               //IE support
-                               if (document.selection) {
-                                       myQuery.focus();
-                                       sel = document.selection.createRange();
-                                       sel.text = chaineAj;
-                                       document.Aform.insert.focus();
-                               }
-                               //MOZILLA/NETSCAPE support
-                               else if (document.Aform.content.selectionStart || document.Aform.content.selectionStart == "0") {
-                                       var startPos = document.Aform.content.selectionStart;
-                                       var endPos = document.Aform.content.selectionEnd;
-                                       var chaineSql = document.Aform.content.value;
-                                       myQuery.value = chaineSql.substring(0, startPos) +'<<'+ chaineAj+'>>' + chaineSql.substring(endPos, chaineSql.length);
-                               } else {
-                                       myQuery.value += chaineAj;
-                               }
-                       }
-               }
+        function insertValueQuery(mtt_id) {
+            var fieldset = $("#" + mtt_id);
+            var myQuery = $(fieldset).find('textarea[name="content"]');
+            var myListBox = $(fieldset).find('select[name="SQLfieldname"]');
+
+            if($(myListBox).find('option').length > 0) {
+                var chaineAj = "";
+                var NbSelect = 0;
+                $(myListBox).find('option').each( function (){
+                    if ( $(this).attr('selected') ) {
+                        NbSelect++;
+                        if (NbSelect > 1)
+                            chaineAj += ", ";
+                        chaineAj += $(this).val();
+                    }
+                } );
+                $(myQuery).insertAtCaret("<<" + chaineAj + ">>");
+            }
+        }
        [% END %]
                //]]>
                </script>
 </head>
-<body>
+<body id="tools_letter" class="tools">
 [% 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 &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>
+<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 or copy_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 or copy_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 %]
+[% IF add_form or copy_form %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
    
    <div id="bd">
        <div id="yui-main">
        <div class="yui-b">
 
 [% IF ( no_op_set ) %]
-    <form method="get" action="?" id="selectlibrary">
+    <h1>Notices and Slips</h1>
+    <form method="get" action="/cgi-bin/koha/tools/letter.pl" id="selectlibrary">
       <input type="hidden" name="searchfield" value="[% searchfield %]" />
     [% UNLESS independant_branch %]
       <p>
@@ -143,83 +164,96 @@ $(document).ready(function() {
             </select>
       </p>
     [% END %]
-      <p>
-             <input type="submit" id="newnotice" value="New Notice" />
+      <div id="toolbar" class="btn-toolbar">
+          <button type="submit" class="btn btn-small" id="newnotice"><i class="icon-plus"></i> New notice</button>
         <input type="hidden" id="op" name="op" />
-      </p>
+      </div>
     </form>
 
                [% IF ( search ) %]
-               <p>You Searched for <b>[% searchfield %]</b></p>
+        <p>You searched for <b>[% searchfield %]</b></p>
                [% END %]
                [% IF ( letter && !independant_branch) %]
             [% select_for_copy = BLOCK %]
             <select name="branchcode">
                 [% FOREACH branchloo IN branchloop %]
-                <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
+                <option value="[% branchloo.value %]">Copy to [% branchloo.branchname %]</option>
                 [% END %]
             </select>
             [% END %]
         [% END %]
-        <table id="lettert">
-               <thead><tr>
-                       <th>Branch</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 %]
-        [% can_edit = lette.branchcode || !independant_branch %]
-        [% UNLESS ( loop.odd ) %]
-                       <tr class="highlight">
-        [% ELSE %]
-                       <tr>
-        [% END %]
-                               <td>[% lette.branchname || "(All libraries)" %]</td>
-                               <td>[% lette.module %]</td>
-                               <td>[% lette.code %]</td>
-                               <td>[% lette.name %]</td>
-                               <td>
-        [% 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 %]" />
+        [% IF letter %]
+          <table id="lettert">
+            <thead>
+              <tr>
+                <th>Library</th>
+                <th>Module</th>
+                <th>Code</th>
+                <th>Name</th>
+                <th>Copy notice</th>
+                <th>&nbsp;</th>
+                <th>&nbsp;</th>
+              </tr>
+            </thead>
+            <tbody>
+              [% FOREACH lette IN letter %]
+                [% can_edit = lette.branchcode || !independant_branch %]
+                <tr>
+                  <td>[% IF lette.branchname %][% lette.branchname %][% ELSE %](All libraries)[% END %]</td>
+                  <td>[% lette.module %]</td>
+                  <td>[% lette.code %]</td>
+                  <td>[% lette.name %]</td>
+                  <td style="white-space: nowrap">
+                    [% IF !independant_branch || !lette.branchcode %]
+                      <form method="post" action="/cgi-bin/koha/tools/letter.pl">
+                        <input type="hidden" name="op" value="copy_form" />
+                        <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 %]
+                        [% 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 && can_edit %]
-                                       <a href="/cgi-bin/koha/tools/letter.pl?op=delete_confirm&branchcode=[%lette.branchcode %]&module=[% lette.module %]&code=[% lette.code %]">Delete</a>
+                      </form>
+                    [% END %]
+                  </td>
+                  <td>
+                    [% IF can_edit %]
+                      <a href="/cgi-bin/koha/tools/letter.pl?op=add_form&amp;branchcode=[% lette.branchcode %]&amp;module=[% lette.module %]&amp;code=[% lette.code %]">Edit</a>
+                    [% END %]
+                  </td>
+                  <td>
+                    [% IF !lette.protected && can_edit %]
+                      <a href="/cgi-bin/koha/tools/letter.pl?op=delete_confirm&amp;branchcode=[%lette.branchcode %]&amp;module=[% lette.module %]&amp;code=[% lette.code %]">Delete</a>
+                    [% END %]
+                  </td>
+                </tr>
+              [% END %]
+            </tbody>
+          </table>
+        [% ELSE %]
+          <div class="dialog message">
+          [% IF ( branchcode ) %]
+             <p>There are no notices for this library.</p>
+          [% ELSE %]
+              <p>There are no notices.</p>
+          [% END %]
+          </div>
         [% END %]
-                               </td>
-                       </tr>
-    [% END %]
-        </tbody>
-               </table>
 [% END %]
 
        
-[% IF ( add_form ) %]
-       
-               <form action="?" name="Aform" method="post">
-               <input type="hidden" name="op" id="op" value="add_validate" />
+[% IF add_form or copy_form %]
+<h1>[% IF ( modify ) %]Modify notice[% ELSE %]Add notice[% END %]</h1>
+        <form id="add_notice" name="Aform" method="post" enctype="multipart/form-data" class="validate">
+        [% IF add_form %]
+          <input type="hidden" name="op" id="op" value="add_validate" />
+        [% ELSE %]
+          <input type="hidden" name="op" id="op" value="copy_validate" />
+        [% END %]
+
                <input type="hidden" name="checked" value="0" />
                [% IF ( modify ) %]
                <input type="hidden" name="add" value="0" />
@@ -227,14 +261,13 @@ $(document).ready(function() {
                <input type="hidden" name="add" value="1" />
                [% END %]
                <fieldset class="rows">
-               <legend>[% IF ( modify ) %]Modify notice[% ELSE %]Add notice[% END %]</legend>
-               <ol>
-                               <input type="hidden" name="oldbranchcode" value="[% branchcode %]" />
+            <input type="hidden" name="oldbranchcode" value="[% oldbranchcode %]" />
             [% IF independant_branch %]
                 <input type="hidden" name="branchcode" value="[% independant_branch %]" />
             [% ELSE %]
+               <ol>
                        <li>
-                               <label for="branchcode">Library:</label>
+                               <label for="branch">Library:</label>
                 <select name="branchcode" id="branch" style="width:20em;">
                     <option value="">All libraries</option>
                 [% FOREACH branchloo IN branchloop %]
@@ -246,87 +279,141 @@ $(document).ready(function() {
                        <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>
+                [% 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;">
+                [% ELSE %]
+                  <select name="module" id="module">
+                [% END %]
+                                    [% IF ( module == "catalogue" ) %]
+                                      <option value="catalogue" selected="selected">Catalog</option>
                                     [% ELSE %]
-                                    <option value="catalogue" >Catalog</option>
+                                      <option value="catalogue" >Catalog</option>
                                     [% END %]
-                                    [% IF ( circulation ) %]
-                                    <option value="circulation" selected="selected">Circulation</option>
+                                    [% IF ( module == "circulation" ) %]
+                                      <option value="circulation" selected="selected">Circulation</option>
                                     [% ELSE %]
-                                    <option value="circulation">Circulation</option>
+                                      <option value="circulation">Circulation</option>
                                     [% END %]
-                                    [% IF ( claimacquisition ) %]
-                                    <option value="claimacquisition" selected="selected">Claim Acquisition</option>
+                                    [% IF ( module == "claimacquisition" ) %]
+                                      <option value="claimacquisition" selected="selected">Claim acquisition</option>
                                     [% ELSE %]
-                                    <option value="claimacquisition">Claim Acquisition</option>
+                                      <option value="claimacquisition">Claim acquisition</option>
                                     [% END %]
-                                    [% IF ( claimissues ) %]
-                                    <option value="claimissues" selected="selected">Claim Serial Issue</option>
+                                    [% IF ( module == "claimissues" ) %]
+                                      <option value="claimissues" selected="selected">Claim serial issue</option>
                                     [% ELSE %]
-                                    <option value="claimissues">Claim Serial Issue</option>
+                                      <option value="claimissues">Claim serial issue</option>
                                     [% END %]
-                                    [% IF ( reserves ) %]
-                                    <option value="reserves" selected="selected">Holds</option>
+                                    [% IF ( module == "reserves" ) %]
+                                      <option value="reserves" selected="selected">Holds</option>
                                     [% ELSE %]
-                                    <option value="reserves">Holds</option>
+                                      <option value="reserves">Holds</option>
                                     [% END %]
-                                    [% IF ( members ) %]
-                                    <option value="members" selected="selected">Members</option>
+                                    [% IF ( module == "members" ) %]
+                                      <option value="members" selected="selected">Members</option>
                                     [% ELSE %]
-                                    <option value="members">Members</option>
+                                      <option value="members">Members</option>
                                     [% END %]
-                                    [% IF ( serial ) %]
-                                    <option value="serial" selected="selected">Serials (Routing List)</option>
+                                    [% IF ( module == "serial" ) %]
+                                      <option value="serial" selected="selected">Serials (routing list)</option>
                                     [% ELSE %]
-                                    <option value="serial">Serials (Routing List)</option>
+                                      <option value="serial">Serials (routing list)</option>
                                     [% END %]
-                                    [% IF ( suggestions ) %]
-                                    <option value="suggestions" selected="selected">Suggestions</option>
+                                    [% IF ( module == "suggestions" ) %]
+                                      <option value="suggestions" selected="selected">Suggestions</option>
                                     [% ELSE %]
-                                    <option value="suggestions">Suggestions</option>
+                                      <option value="suggestions">Suggestions</option>
                                     [% END %]
-                               </select>
-                       </li>
-                       <li>
-                               <span class="label">Code:</span>[% IF ( adding ) %]<input type="text" id="code" name="code" size="20" maxlength="20" />[% ELSE %]<input type="hidden" id="code" name="code" value="[% code %]" />[% code %][% END %]
-                       </li>
-               <li>
-                       <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>
-                       <label for="SQLfieldname">Message Body:</label>
-               </li>
-               <li>
-               <table>
-               <tr><td><select name="SQLfieldname" id="SQLfieldname" size="9">
-                       [% FOREACH SQLfieldnam IN SQLfieldname %]
-                               <option value="[% SQLfieldnam.value %]">[% SQLfieldnam.text %]</option>
-                       [% END %]
-               </select></td><td><input type="button" name="insert" value="&gt;&gt;" onclick="insertValueQuery()" title="Insert" /></td><td><textarea name="content" cols="80" rows="15">[% content %]</textarea></td></tr></table>
+                </select>
+            </li>
+            <li>
+              <label for="code" class="required">Code:</label>
+              <input type="text" id="code" name="code" size="20" maxlength="20" value="[% code %]" required="required"/>
+              <span class="required">Required</span>
+              [% IF copying %]
+                You must change this code to reflect the copy.
+              [% END %]
+              <input type="hidden" id="code" name="oldcode" value="[% oldcode %]" />
+            </li>
+            <li>
+              <label for="name" class="required">Name:</label>
+              <input type="text" id="name" name="name" size="60" value="[% letter_name %]" required="required" />
+              <span class="required">Required</span>
+          </li>
 
-               </li>
-               </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>
+        [% FOREACH letter IN letters %]
+          <li>
+            [% IF letter.message_transport_type == "sms" and not Koha.Preference("SMSSendDriver") %]
+              <fieldset class="rows mtt" id="[% letter.message_transport_type %]" disabled="disabled">
+                <div class="dialog message">You should enable the SMSSendDriver preference to use the SMS templates.</div>
+            [% ELSIF letter.message_transport_type == "phone" and not Koha.Preference("TalkingTechItivaPhoneNotification") %]
+              <fieldset class="rows mtt" id="[% letter.message_transport_type %]" disabled="disabled">
+                <div class="dialog message">You should enable the TalkingTechItivaPhoneNotification preference to use the phone templates.</div>
+            [% ELSE %]
+              <fieldset class="rows mtt" id="[% letter.message_transport_type %]">
+            [% END %]
+              <legend>
+                [% SWITCH letter.message_transport_type %]
+                [% CASE 'email' %]
+                  Email
+                [% CASE 'print' %]
+                  Print
+                [% CASE 'sms' %]
+                  SMS
+                [% CASE 'feed' %]
+                  Feed
+                [% CASE 'phone' %]
+                  Phone
+                [% CASE %]
+                  [% letter.message_transport_type %]
+                [% END %]
+              </legend>
+              <ol>
+                <li>
+                  <input type="hidden" name="message_transport_type" value="[% letter.message_transport_type %]" />
+                  <label for="is_html_[% letter.message_transport_type %]">HTML message:</label>
+                  [% IF letter.is_html %]
+                    <input type="checkbox" name="is_html_[% letter.message_transport_type %]" id="is_html_[% letter.message_transport_type %]" value="1" checked="checked" />
+                  [% ELSE %]
+                    <input type="checkbox" name="is_html_[% letter.message_transport_type %]" id="is_html_[% letter.message_transport_type %]" value="1" />
+                  [% END %]
+                </li>
+                <li>
+                  <label for="title">Message subject:</label><input type="text" id="title" name="title" size="60" value="[% letter.title %]" />
+                </li>
+                <li>
+                  <label for="SQLfieldname">Message body:</label>
+                  [% IF letter.message_transport_type == 'sms' %]
+                    <span id="sms_counter">[% IF letter.content.length > 0 %][% letter.content.length %][% ELSE %]0[% END %]/160 characters</span>
+                  [% END %]
+                  <table>
+                    <tr>
+                      <td>
+                        <select name="SQLfieldname" multiple="multiple" size="9">
+                          [% FOREACH SQLfieldnam IN SQLfieldname %]
+                            <option value="[% SQLfieldnam.value %]">[% SQLfieldnam.text %]</option>
+                          [% END %]
+                        </select>
+                      </td>
+                      <td><input type="button" name="insert" value="&gt;&gt;" onclick="insertValueQuery('[% letter.message_transport_type %]')" title="Insert" /></td>
+                      <td><textarea name="content" id="content_[% letter.message_transport_type %]" cols="80" rows="15">[% letter.content %]</textarea></td>
+                    </tr>
+                  </table>
+                </li>
+              </ol>
+            </fieldset>
+          </li>
+        [% END %]
+        </ol>
+
+        [% IF code.search('DGST') %] <span class="overdue">Warning, this is a template for a Digest, as such, any references to branch data ( e.g. branches.branchname ) will refer to the borrower's home branch.</span> [% END %]
+        </fieldset>
+        <fieldset class="action"><input type="submit" id="submit_form" value="Submit" class="button" /> <a class="cancel" href="/cgi-bin/koha/tools/letter.pl">Cancel</a></fieldset>
       <input type="hidden" name="searchfield" value="[% searchfield %]" />
-               </form>
+    </form>
 [% END %]
-       
-[% IF ( add_validate ) %]
+
+[% IF ( add_validate or copy_validate) %]
        Data recorded
        <form action="[% action %]" method="post">
        <input type="submit" value="OK" />
@@ -334,11 +421,11 @@ $(document).ready(function() {
 [% END %]
        
 [% IF ( delete_confirm ) %]
-       <div class="dialog alert"><h3>Delete Notice?</h3>
+    <div class="dialog alert"><h3>Delete notice?</h3>
        <table>
         <thead>
                <tr>
-                       <th>Branch</th>
+                       <th>Library</th>
                        <th>Module</th>
                        <th>Code</th>
                        <th>Name</th>
@@ -356,11 +443,12 @@ $(document).ready(function() {
                <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" />
+        <input type="hidden" name="message_transport_type" value="*" />
+                <input type="submit" value="Yes, delete" class="approve" />
                                </form>
 
                                <form action="[% action %]" method="get">
-                                       <input type="submit" value="No, Do Not Delete" class="deny" />
+                    <input type="submit" value="No, do not delete" class="deny" />
                                </form>
                </div>
 
@@ -375,7 +463,7 @@ $(document).ready(function() {
 
 </div>
 </div>
-[% UNLESS ( add_form ) %]
+[% UNLESS add_form or copy_form %]
     <div class="yui-b noprint">
         [% INCLUDE 'tools-menu.inc' %]
     </div>