Bug 23049: Update existing code to use debit_type
[srvgit] / koha-tmpl / intranet-tmpl / prog / en / modules / members / paycollect.tt
index f92f091..bc0cefa 100644 (file)
 [% END %]
 
 [% IF ( pay_individual ) %]
+    [% IF ( error_registers ) %]
+    <div id="error_message" class="dialog alert">
+        You must have at least one cash register associated with this branch before you can record payments.
+    </div>
+    [% ELSE %]
+
     <form name="payindivfine" id="payindivfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
     <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual | html %]" />
     <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber | html %]" />
     <input type="hidden" name="description" id="description" value="[% description | html %]" />
-    <input type="hidden" name="accounttype" id="accounttype" value="[% accounttype | html %]" />
+    <input type="hidden" name="debit_type_code" id="debit_type_code" value="[% debit_type_code | html %]" />
     <input type="hidden" name="amount" id="amount" value="[% amount | html %]" />
     <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding | html %]" />
     <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id | html %]" />
     <input type="hidden" name="title" id="title" value="[% title | html %]" />
+    <input type="hidden" name="change_given" id="change_given" />
 
 <fieldset class="rows">
     <legend>Pay an individual fine</legend>
@@ -90,7 +97,7 @@
             <td>
                 [% individual_description | html %]
             </td>
-            <td>[% accounttype | html %]</td>
+            <td>[% debit_type_code | html %]</td>
             <td class="debit">[% amount | format('%.2f') %]</td>
             <td class="debit">[% amountoutstanding | format('%.2f') %]</td>
         </tr></tbody>
 
     <li>
         <label for="paid">Amount being paid: </label>
-        <input name="paid" id="paid" value="[% amountoutstanding | $Price %]"/>
+        <input name="paid" id="paid" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
     </li>
     <li>
         <label for="collected">Collected from patron: </label>
-        <input id="collected" value="[% amountoutstanding | $Price %]"/>
+        <input id="collected" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
     </li>
     <li>
         <label>Change to give: </label>
             </select>
         </li>
     [% END %]
+    [% IF Koha.Preference('UseCashRegisters') %]
+    <li>
+        <label for="cash_register">Cash register: </label>
+        <select name="cash_register" id="cash_register">
+            [% FOREACH register IN registers %]
+              [% IF register.id == registerid %]
+            <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
+              [% ELSE %]
+            <option value="[% register.id | html %]">[% register.name | html %]</option>
+              [% END %]
+            [% END %]
+        </select>
+    </li>
+    [% END %]
 </ol>
 </fieldset>
 
             <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
         </div>
     </form>
+    [% END %]
 [% ELSIF ( writeoff_individual ) %]
     <form name="woindivfine" id="woindivfine" action="/cgi-bin/koha/members/pay.pl" method="post" >
     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
     <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual | html %]" />
     <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber | html %]" />
     <input type="hidden" name="description" id="description" value="[% description | html %]" />
-    <input type="hidden" name="accounttype" id="accounttype" value="[% accounttype | html %]" />
+    <input type="hidden" name="debit_type_code" id="debit_type_code" value="[% debit_type_code | html %]" />
     <input type="hidden" name="amount" id="amount" value="[% amount | html %]" />
     <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id | html %]" />
     <input type="hidden" name="title" id="title" value="[% title | html %]" />
     <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note | html %]" />
     <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding | html %]" />
     <input type="hidden" name="confirm_writeoff" id="confirm_writeoff" value="1" />
+    <input type="hidden" name="change_given" id="change_given" />
     <table>
     <thead><tr>
             <th>Description</th>
     <tfoot><tr><td colspan="3">Total amount outstanding:</td><td>[% amountoutstanding | format('%.2f') %]</td></tr></tfoot>
     <tbody><tr>
             <td>[% description | html %] [% title | html %]</td>
-            <td>[% accounttype | html %]</td>
+            <td>[% debit_type_code | html %]</td>
             <td class="debit">[% amount | format('%.2f') %]</td>
             <td class="debit">[% amountoutstanding | format('%.2f') %]</td>
         </tr></tbody>
         </div>
     </form>
 [% ELSE %]
+    [% IF ( error_registers && type != 'writeoff' ) %]
+    <div id="error_message" class="dialog alert">
+        You must have at least one cash register associated with this branch before you can record payments.
+    </div>
+    [% ELSE %]
 
     <form name="payfine" id="payfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
     <input type="hidden" name="selected_accts" id="selected_accts" value="[% selected_accts | html %]" />
     <input type="hidden" name="total" id="total" value="[% total | html %]" />
     <input type="hidden" name="type" value="[% type | html %]" />
+    <input type="hidden" name="change_given" id="change_given" />
 
     <fieldset class="rows">
     [% IF ( selected_accts ) %]
         </li>
     <li>
         <label for="paid">Amount paid :</label>
-        <input name="paid" id="paid" value="[% total | $Price %]"/>
+        <input name="paid" id="paid" value="[% total | $Price on_editing => 1 %]"/>
     </li>
     <li>
         [% IF type == 'writeoff' %]
         [% ELSE %]
             <label for="collected">Collect from patron: </label>
         [% END %]
-        <input id="collected" value="[% total | $Price %]"/>
+        <input id="collected" value="[% total | $Price on_editing => 1 %]"/>
     </li>
     <li>
         <label>Change to give: </label>
         <span id="change">0.00</span>
     </li>
+
+    [% IF type != 'writeoff' %]
     [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
     [% IF payment_types %]
         <li>
             </select>
         </li>
     [% END %]
+
+    [% IF Koha.Preference('UseCashRegisters') %]
+    <li>
+        <label for="cash_register">Cash register: </label>
+        <select name="cash_register" id="cash_register">
+            [% FOREACH register IN registers %]
+              [% IF register.id == registerid %]
+            <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
+              [% ELSE %]
+            <option value="[% register.id | html %]">[% register.name | html %]</option>
+              [% END %]
+            [% END %]
+        </select>
+    </li>
+    [% END %]
+    [% END %]
+
     <li>
         <label for="selected_accts_notes">Note: </label>
         <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes | html %]</textarea>
         <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
     </div>
     </form>
+    [% END %]
 [% END %]
 </div></div>
 
     [% Asset.js("js/members-menu.js") | $raw %]
     <script>
         $(document).ready(function() {
+            [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
+                window.open('/cgi-bin/koha/members/printfeercpt.pl?action=print&accountlines_id=[% payment_id | html %]&change_given=[% change_given | html %]&borrowernumber=[% patron.borrowernumber | html %]', '_blank');
+            [% END %]
+
             var forms = $('#payindivfine, #payfine');
             var change = $('#change')[0];
 
             change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
             if (change.innerHTML <= 0) {
                 change.innerHTML = "0.00";
+                $('input[name="change_given"]').val('0.00');
             } else {
                 change.value = change.innerHTML;
                 moneyFormat(change);
                 change.innerHTML = change.value;
+                $('input[name="change_given"]').val(change.value);
             }
 
             $('#modal_change').html(change.innerHTML);