Bug 31095: Remove GetDebarments from members/memberentry.pl
[koha-ffzg.git] / koha-tmpl / intranet-tmpl / prog / en / includes / borrower_debarments.inc
index a9d80cd..c6b7dff 100644 (file)
@@ -1,32 +1,7 @@
-<script type="text/javascript">
-   //<![CDATA[
-        $(document).ready(function(e){
-            $("div#reldebarments .remove_restriction").on("click",function(){
-                return confirm(_("Remove restriction?"));
-            });
-            var mrform = $("#manual_restriction_form");
-            var mrlink = $("#add_manual_restriction");
-            mrform.hide();
-            mrlink.on("click",function(e){
-                $(this).hide();
-                mrform.show();
-                e.preventDefault();
-            });
-            $("#cancel_manual_restriction").on("click",function(e){
-                mrlink.show();
-                mrform.hide();
-                e.preventDefault();
-            });
-            $(".clear-date").on("click",function(e){
-                e.preventDefault();
-                var fieldID = this.id.replace("clear-date-","");
-                $("#" + fieldID).val("");
-            });
-        })
-    //]]>
-</script>
-
-<div id="reldebarments">
+[% USE raw %]
+[% USE Koha %]
+[% PROCESS 'patron_restrictions.inc' %]
+<div id="reldebarments" role="tabpanel" class="tab-pane">
     [% IF ( not debarments.defined || debarments.size < 1 ) %]
         <p>Patron is currently unrestricted.</p>
     [% ELSE %]
                      <th>Type</th>
                      <th>Comment</th>
                      <th>Expiration</th>
-                     [% IF CAN_user_borrowers && CAN_user_circulate_manage_restrictions %]
+                     <th>Created</th>
+                     [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %]
                          <th>&nbsp;</th>
                      [% END %]
                 </tr>
             </thead>
             <tbody>
                 [% FOREACH d IN debarments %]
+                    [% dtype = d.type %]
                     <tr>
                         <td>
-                            [% SWITCH d.type %]
-                                [% CASE 'MANUAL' %]
-                                    Manual
-                                [% CASE 'OVERDUES' %]
-                                    Overdues
-                                [% CASE 'SUSPENSION' %]
-                                    Suspension
-                                [% CASE 'DISCHARGE' %]
-                                    Discharge
-                            [% END %]
+                            [% PROCESS restriction_type_description restriction=restriction_types.$dtype %]
                         </td>
                         <td>
-                           [% IF d.comment.search('OVERDUES_PROCESS') %]
-                               Restriction added by overdues process [% d.comment.remove('OVERDUES_PROCESS ') %]
-                           [% ELSE %]
-                               [% d.comment %]
-                           [% END %]
-                       </td>
-                        <td>[% IF d.expiration %] [% d.expiration | $KohaDates %] [% ELSE %] <i>Indefinite</i> [% END %]</td>
-                        [% IF CAN_user_borrowers && CAN_user_circulate_manage_restrictions %]
+                            [% IF d.comment.search('OVERDUES_PROCESS') %]
+                                <span>Restriction added by overdues process [% d.comment.remove('OVERDUES_PROCESS ') | $raw %]</span>
+                            [% ELSE %]
+                                [% d.comment | $raw %]
+                            [% END %]
+                        </td>
+                        <td>[% IF d.expiration %] [% d.expiration | $KohaDates %] [% ELSE %] <em>Indefinite</em> [% END %]</td>
+                        <td>[% d.created | $KohaDates %]</td>
+                        [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %]
                             <td>
-                                <a class="remove_restriction btn btn-mini" href="/cgi-bin/koha/members/mod_debarment.pl?borrowernumber=[% borrowernumber %]&amp;borrower_debarment_id=[% d.borrower_debarment_id %]&amp;action=del">
+                                <a class="remove_restriction btn btn-default btn-xs" href="/cgi-bin/koha/members/mod_debarment.pl?borrowernumber=[% patron.borrowernumber | html %]&amp;borrower_debarment_id=[% d.borrower_debarment_id | html %]&amp;action=del">
                                     <i class="fa fa-trash"></i> Remove
                                 </a>
                             </td>
             </tbody>
         </table>
     [% END %]
-    [% IF CAN_user_borrowers && CAN_user_circulate_manage_restrictions %]
+    [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %]
         <p><a href="#" id="add_manual_restriction"><i class="fa fa-plus"></i> Add manual restriction</a></p>
         <form method="post" action="/cgi-bin/koha/members/mod_debarment.pl" class="clearfix">
-            <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
+            <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
             <input type="hidden" name="action" value="add" />
             <fieldset class="rows" id="manual_restriction_form">
-                <legend><i class="fa fa-ban"></i> Add manual restriction</legend>
+                <legend>Add manual restriction</legend>
                 <ol>
+                    [% IF Koha.Preference('PatronRestrictionTypes') %]
+                    <li>
+                        <label for="debarred_type">Type:</label>
+                        <select name="debarred_type">
+                            [% FOREACH code IN restriction_types.keys %]
+                                [% IF !restriction_types.$code.is_system %]
+                                   [% IF restriction_types.$code.is_default %]
+                                   <option value="[% code | html %]" selected>[% PROCESS restriction_type_description restriction=restriction_types.$code %]</option>
+                                   [% ELSE %]
+                                   <option value="[% code | html %]">[% PROCESS restriction_type_description restriction=restriction_types.$code %]</option>
+                                   [% END %]
+                                [% END %]
+                            [% END %]
+                        </select>
+                    </li>
+                    [% END %]
                     <li><label for="rcomment">Comment:</label> <input type="text" id="rcomment" name="comment" /></li>
-                    <li><label for="rexpiration">Expiration:</label> <input name="expiration" id="rexpiration" size="10" readonly="readonly" value="" class="datepicker" />
-                        <a href="#" class="clear-date" id="clear-date-rexpiration">Clear date</a></li>
+                    <li>
+                        <label for="rexpiration">Expiration:</label>
+                        <input name="expiration" id="rexpiration" size="20" value="" class="flatpickr" data-flatpickr-futuredate="true" type="text" />
+                    </li>
                 </ol>
             <fieldset class="action"><input type="submit" value="Add restriction" /> <a href="#" class="cancel" id="cancel_manual_restriction">Cancel</a></fieldset>
             </fieldset>