Bug 21526: Use the 'url' filter when needed
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / aqbudgetperiods.tt
index 2ec02bc..498486c 100644 (file)
@@ -10,7 +10,7 @@
         </a>
         <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetmenu_[% block_budget.budget_period_id | html %]">
               <li>
-                  <a href="[% script_name | html %]?op=add_form&amp;budget_period_id=[% block_budget.budget_period_id | html %]"><i class="fa fa-pencil"></i> Edit</a>
+                  <a href="[% script_name | url %]?op=add_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-pencil"></i> Edit</a>
               </li>
               [% IF block_budget.count %]
                   <li class="disabled">
                   </li>
               [% ELSE %]
                   <li>
-                      <a href="[% script_name | html %]?op=delete_confirm&amp;budget_period_id=[% block_budget.budget_period_id | html %]"><i class="fa fa-trash"></i> Delete</a>
+                      <a href="[% script_name | url %]?op=delete_confirm&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-trash"></i> Delete</a>
                   </li>
               [% END %]
               <li>
-                  <a href="[% script_name | html %]?op=duplicate_form&amp;budget_period_id=[% block_budget.budget_period_id | html %]"><i class="fa fa-copy"></i> Duplicate</a>
+                  <a href="[% script_name | url %]?op=duplicate_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-copy"></i> Duplicate</a>
               </li>
               <li>
-                  <a href="[% script_name | html %]?op=close_form&amp;budget_period_id=[% block_budget.budget_period_id | html %]"><i class="fa fa-times-circle"></i> Close</a>
+                  <a href="[% script_name | url %]?op=close_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-times-circle"></i> Close</a>
               </li>
               <li>
-                  <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_period_id=[% block_budget.budget_period_id | html %]"><i class="fa fa-plus"></i> Add fund</a>
+                  <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-plus"></i> Add fund</a>
               </li>
         </ul>
     </div>
     [% END %]
     [% IF close_form %]
         <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a> &rsaquo;
-        <span>Close budget <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | html %]">[% budget_period_description | html %]</a></span>
+        <span>Close budget <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]">[% budget_period_description | html %]</a></span>
     [% END %]
     [% IF closed %]
         <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a> &rsaquo;
-        <span>Budget <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | html %]">[% budget_period_description | html %]</a> closed</span>
+        <span>Budget <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]">[% budget_period_description | html %]</a> closed</span>
     [% END %]
     [% IF ( else ) %]
         <span>Budgets administration</span>
         <div class="col-sm-10 col-sm-push-2">
             <main>
 
-[% UNLESS close_form OR closed%]
+[% UNLESS close_form OR closed OR duplicate_form %]
   [% INCLUDE 'budgets-admin-toolbar.inc' %]
 [% END %]
 
 [% IF ( duplicate_form ) %]
 <h3>Duplicate budget</h3>
-<form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" name="f" method="post">
+<form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" id="add_modify_budget" name="f" method="post">
     <fieldset class="rows">
     <input type="hidden" name="op" value="duplicate_budget" />
     <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
     <li>
     <label class="required" for="from">Start date: </label>
     <input type="text" size="10" id="from" name="budget_period_startdate" value="[% budget_period_startdate | $KohaDates %]" class="datepickerfrom" />
-                               <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
+        <span class="required">Required</span>
+        <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
     </li>
     <li>
 
     <label class="required" for="to">End date: </label>
     <input type="text" size="10" id="to" name="budget_period_enddate" value="[% budget_period_enddate | $KohaDates %]" class="datepickerto" />
-                               <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
+        <span class="required">Required</span>
+        <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
     </li>
 
     <li>
     <label class="required" for="budget_period_description">Description</label>
     <input type="text" id="budget_period_description" name="budget_period_description" value="[% budgetperiod.budget_period_description | html %]" />
+        <span class="required">Required</span>
     </li>
 
     <li>
     </fieldset>
 
     <fieldset class="action">
-        <input type="button" value="Save Changes"  onclick="CheckDuplicateForm(this.form)" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | html %]">Cancel</a>
+        <input type="submit" value="Save" />
+        <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | html %]">Cancel</a>
     </fieldset>
 
 </form>
     [% ELSE %]
         <h3>Add budget</h3>
        [% END %]
-<form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" name="f" method="post">
+<form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" id="add_modify_budget" name="f" method="post">
     <fieldset class="rows">
     <!-- ################################################################################# -->
     <!-- display information about the budget period that must be added or modified -->
     <li>
     <label class="required" for="from">Start date: </label>
     <input type="text" size="10" id="from" name="budget_period_startdate" value="[% budget_period_startdate | $KohaDates %]" class="datepickerfrom" />
-                               <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
+        <span class="required">Required</span>
+        <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
     </li>
     <li>
 
     <label class="required" for="to">End date: </label>
     <input type="text" size="10" id="to" name="budget_period_enddate" value="[% budget_period_enddate | $KohaDates %]" class="datepickerto" />
-                               <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
+        <span class="required">Required</span>
+        <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
     </li>
 
     <li>
         <label class="required" for="budget_period_description">Description: </label>
         <input type="text" id="budget_period_description" name="budget_period_description"
         size="48" maxlength="80" value="[% budget_period_description | html %]" />
+            <span class="required">Required</span>
     </li>
 
     <li>
     <fieldset class="action">
         <!-- "save changes" button -->
         <!-- ###################################### -->
-        <input type="button" value="Save"  onclick="Check(this.form)" />
-        <!--             <input type="submit" value="Save Changes"  />  -->
+        <input type="submit" value="Save" />
         [% IF ( budget_period_id ) %]
-            <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | html %]" class="cancel">Cancel</a>
+            <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]" class="cancel">Cancel</a>
         [% ELSE %]
             <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl" class="cancel">Cancel</a>
         [% END %]
     <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Back</a>
   [% ELSE %]
     <h3>The unreceived orders from the following funds will be moved</h3>
-      Fund list of budget <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | html %]">[% budget_period_description | html %]</a>:
+      Fund list of budget <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]">[% budget_period_description | html %]</a>:
     <table id="budgeth">
       <thead>
         <tr>
             [% IF r.orders_moved.size > 0 %]
               [% FOR order IN r.orders_moved %]
                 <tr>
-                  <td>[% r.budget.budget_name | html %] (id=[% r.budget.budget_id | html %]) Amount=[% r.budget.budget_amount | $Price | html %][% IF r.unspent_moved %] ([% r.unspent_moved | $Price | html %] remaining has been moved)[% END %]</td>
+                  <td>[% r.budget.budget_name | html %] (id=[% r.budget.budget_id | html %]) Amount=[% r.budget.budget_amount | $Price %][% IF r.unspent_moved %] ([% r.unspent_moved | $Price %] remaining has been moved)[% END %]</td>
                   <td>[% order.basketname | html %]</td>
                   <td>[% order.ordernumber | html %]</td>
                   <td>Moved!</td>
           [% ELSE %]
             [% IF r.error == 'budget_code_not_exists' %]
               <tr>
-                <td>[% r.budget.budget_id | html %] [% r.budget.budget_amount | $Price | html %][% IF r.unspent_moved %] ([% r.unspent_moved | $Price | html %] remaining has been moved)[% END %]</td>
+                <td>[% r.budget.budget_id | html %] [% r.budget.budget_amount | $Price %][% IF r.unspent_moved %] ([% r.unspent_moved | $Price %] remaining has been moved)[% END %]</td>
                 <td></td>
                 <td></td>
                 <td>This fund code does not exist in the destination budget.</td>
           <tbody>
               [% FOREACH period_active IN period_active_loop %]
                 <tr>
-                <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% period_active.budget_period_id | html %]" title="View funds for [% period_active.budget_period_description | html %]">[% period_active.budget_period_description | html %]</a></td>
+                <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% period_active.budget_period_id | uri %]" title="View funds for [% period_active.budget_period_description | html %]">[% period_active.budget_period_description | html %]</a></td>
                 <td><span title="[% period_active.budget_period_startdate | html %]">[% period_active.budget_period_startdate | $KohaDates %]</span></td>
                 <td><span title="[% period_active.budget_period_enddate | html %]">[% period_active.budget_period_enddate | $KohaDates %]</span></td>
                 <td>
                     <span style="color:green;">Locked</span>&nbsp;
                   [% END %]
                 </td>
-                <td class="data">[% period_active.budget_period_total | $Price | html %]</td>
+                <td class="data">[% period_active.budget_period_total | $Price %]</td>
                 <td>
                     [% PROCESS action_menu block_budget=period_active %]
                 </td>
           <tbody>
               [% FOREACH period_loo IN period_inactive_loop %]
                   <tr>
-                  <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% period_loo.budget_period_id | html %]" title="View funds for [% period_loo.budget_period_description | html %]">[% period_loo.budget_period_description | html %]</a></td>
+                  <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% period_loo.budget_period_id | uri %]" title="View funds for [% period_loo.budget_period_description | html %]">[% period_loo.budget_period_description | html %]</a></td>
                   <td><span title="[% period_loo.budget_period_startdate | html %]">[% period_loo.budget_period_startdate | $KohaDates %]</span></td>
                   <td><span title="[% period_loo.budget_period_enddate | html %]">[% period_loo.budget_period_enddate | $KohaDates %]</span></td>
                   <td> [% IF ( period_loo.budget_period_locked ) %]<span style="color:green;">Locked</span>&nbsp;[% ELSE %][% END %] </td>
-                  <td class="data">[% period_loo.budget_period_total | $Price | html %]</td>
+                  <td class="data">[% period_loo.budget_period_total | $Price %]</td>
                   <td>
                         [% PROCESS action_menu block_budget=period_loo %]
                   </td>
     [% END %]
     [% Asset.js("js/acq.js") | $raw %]
     <script>
-    // #################################################################################
-    // Javascript
-    // #################################################################################
-        function CheckDuplicateForm(f){
-            var ok=1;
-            var _alertString="";
-            var alertString="";
-            if(!(isNotNull(f.budget_period_startdate,1))){
-              _alertString += "\n- " + _("Start date missing");
-            }
-            if (!(isNotNull(f.budget_period_enddate,1))){
-              _alertString += "\n- " + _("End date missing");
-            }
-            if( f.budget_period_startdate > f.budget_period_enddate ) {
-              _alertString += "\n- " + _("Start date must be before end date");
-            }
-            if (!(isNotNull(f.budget_period_description,1))){
-              _alertString += "\n- " + _("Budget description missing");
-            }
-
-            if(_alertString.length==0){
-              f.submit();
-            } else {
-              alertString += _("Form not submitted because of the following problem(s)");
-              alertString += "\n-----------------------------------------\n";
-              alertString += _alertString;
-              alert(alertString);
-            }
-        }
-        function Check(f) {
-            var ok=1;
-            var _alertString="";
-            var alertString2;
-
-            if (!(isNotNull(f.budget_period_startdate,1))) {
-                    _alertString += "\n- " + _("Start date missing");
-            }
-
-            if (!(isNotNull(f.budget_period_enddate,1))) {
-                    _alertString += "\n- " + _("End date missing");
-            }
-
-            if ( f.budget_period_startdate >   f.budget_period_enddate )  {
-                    _alertString += "\n- " + _("Start date must be before end date");
-            }
-
-            if (!(isNotNull(f.budget_period_description,1))) {
-                    _alertString += "\n- " + _("Description missing");
-            }
-
-            if (!(isNum(f.budget_period_total))) {
-                    _alertString += "\n- " + _("Amount must be a valid number, or empty");
-            }
-
-            if (_alertString.length==0) {
-                    f.submit();
-            } else {
-                    alertString2  = _("Form not submitted because of the following problem(s)");
-                    alertString2 += "\n------------------------------------------------------------------------------------\n";
-                    alertString2 += _alertString;
-                    alert(alertString2);
-            }
-        }
-
         $(document).ready(function() {
             var tabs = $('#budgetsTabs').tabs();
             [% IF ( tab ) %]
                 "sPaginationType": "full_numbers"
               }));
             [% END %]
+            $("#add_modify_budget").validate({
+                rules: {
+                    budget_period_startdate: "required",
+                    budget_period_enddate: {
+                        required: true,
+                        date_on_or_after: "#from"
+                    },
+                    budget_period_description: "required",
+                    budget_period_total: {
+                        number: true
+                    }
+                },
+                messages: {
+                    budget_period_enddate: {
+                        date_on_or_after: _("Budget end date must be on or after budget start date")
+                    }
+                }
+            });
         });
     </script>
 [% END %]