"Fossies" - the Fresh Open Source Software Archive

Member "koha-19.11.15/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt" (23 Feb 2021, 19816 Bytes) of package /linux/misc/koha-19.11.15.tar.gz:


The requested HTML page contains a <FORM> tag that is unusable on "Fossies" in "automatic" (rendered) mode so that page is shown as HTML source code (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 [% USE raw %]
    2 [% USE Asset %]
    3 [% USE Koha %]
    4 [% USE Branches %]
    5 [% USE AuthorisedValues %]
    6 [% USE Price %]
    7 [% SET footerjs = 1 %]
    8 [% INCLUDE 'doc-head-open.inc' %]
    9 <title>Koha &rsaquo; Patrons &rsaquo;
   10     [% IF type == 'WRITEOFF' %]
   11         Write off an amount for [% patron.firstname | html %] [% patron.surname | html %]
   12     [% ELSE %]
   13         Collect fine payment for [% patron.firstname | html %] [% patron.surname | html %]
   14     [% END %]
   15 </title>
   16 [% INCLUDE 'doc-head-close.inc' %]
   17 </head>
   18 
   19 <body id="pat_paycollect" class="pat">
   20 [% INCLUDE 'header.inc' %]
   21 [% INCLUDE 'patron-search.inc' %]
   22 <div id="breadcrumbs">
   23     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
   24     <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> &rsaquo;
   25     <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]">Pay fines for [% patron.firstname | html %] [% patron.surname | html %]</a> &rsaquo;
   26     [% IF    ( pay_individual )      %]Pay an individual fine
   27     [% ELSIF ( writeoff_individual ) %]Write off an individual fine
   28     [% ELSE %]
   29         [% IF ( selected_accts ) %]
   30             [% IF type == 'writeoff' %]Write off an amount toward selected fines
   31             [% ELSE                  %]Pay an amount toward selected fines
   32             [% END %]
   33         [% ELSE                      %]Pay an amount toward all fines
   34         [% END %]
   35     [% END %]
   36 </div>
   37 
   38 <div class="main container-fluid">
   39     <div class="row">
   40         <div class="col-sm-10 col-sm-push-2">
   41             <main>
   42 
   43 [% INCLUDE 'members-toolbar.inc' borrowernumber=patron.borrowernumber %]
   44 
   45 
   46 <!-- The manual invoice and credit buttons -->
   47 <div class="statictabs">
   48 <ul>
   49     <li>
   50     <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | uri %]">Transactions</a>
   51     </li>
   52     <li class="active">
   53     <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Make a payment</a>
   54     </li>
   55     <li>
   56     <a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual invoice</a>
   57     </li>
   58     <li>
   59     <a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual credit</a>
   60     </li>
   61 </ul>
   62 <div class="tabs-container">
   63 [% IF ( error_over ) %]
   64     <div id="error_message" class="dialog alert">
   65     You must pay a value less than or equal to [% total_due | format('%.2f') %].
   66     </div>
   67 [% END %]
   68 [% IF ( error_under ) %]
   69     <div id="error_message" class="dialog alert">
   70     You must collect a value greater than or equal to [% total_paid | format('%.2f') %].
   71     </div>
   72 [% END %]
   73 
   74 [% IF ( pay_individual ) %]
   75     [% IF ( error_registers ) %]
   76     <div id="error_message" class="dialog alert">
   77         You must have at least one cash register associated with this branch before you can record payments.
   78     </div>
   79     [% ELSE %]
   80 
   81     <form name="payindivfine" id="payindivfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
   82     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
   83     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
   84     <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual | html %]" />
   85     <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber | html %]" />
   86     <input type="hidden" name="description" id="description" value="[% description | html %]" />
   87     <input type="hidden" name="debit_type_code" id="debit_type_code" value="[% debit_type_code | html %]" />
   88     <input type="hidden" name="amount" id="amount" value="[% amount | html %]" />
   89     <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding | html %]" />
   90     <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id | html %]" />
   91     <input type="hidden" name="title" id="title" value="[% title | html %]" />
   92     <input type="hidden" name="change_given" id="change_given" />
   93 
   94 <fieldset class="rows">
   95     <legend>Pay an individual fine</legend>
   96     <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note | html %]" />
   97     <table>
   98     <thead><tr>
   99             <th>Description</th>
  100             <th>Account type</th>
  101             <th>Amount</th>
  102             <th>Amount outstanding</th>
  103         </tr></thead>
  104     <tfoot>
  105         <tr><td colspan="3">Total amount payable:</td><td>[% amountoutstanding | format('%.2f') %]</td></tr>
  106     </tfoot>
  107     <tbody><tr>
  108             <td>
  109                 [% individual_description | html %]
  110             </td>
  111             <td>[% debit_type_code | html %]</td>
  112             <td class="debit">[% amount | format('%.2f') %]</td>
  113             <td class="debit">[% amountoutstanding | format('%.2f') %]</td>
  114         </tr></tbody>
  115 </table>
  116 
  117 <ol>
  118 
  119     <li>
  120         <label for="paid">Amount being paid: </label>
  121         <input name="paid" id="paid" type="text" step="0.01" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
  122     </li>
  123     <li>
  124         <label for="collected">Collected from patron: </label>
  125         <input name="collected" id="collected" type="text" step="0.01" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
  126     </li>
  127     <li>
  128         <label>Change to give: </label>
  129         <span id="change">0.00</span>
  130     </li>
  131     [% SET payment_types = [] %]
  132     [% FOR pt IN AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
  133         [% NEXT IF pt.authorised_value.grep("^SIP[[:digit:]]{2}$").size() %]
  134         [% payment_types.push(pt) %]
  135     [% END %]
  136     [% IF payment_types.size > 0 %]
  137         <li>
  138             <label for="payment_type">Payment type: </label>
  139             <select name="payment_type" id="payment_type">
  140                 <option value=""></option>
  141                 [% FOREACH pt IN payment_types %]
  142                     <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
  143                 [% END %]
  144             </select>
  145         </li>
  146     [% END %]
  147     [% IF Koha.Preference('UseCashRegisters') %]
  148     <li>
  149         <label for="cash_register">Cash register: </label>
  150         <select name="cash_register" id="cash_register">
  151             [% FOREACH register IN registers %]
  152               [% IF register.id == registerid %]
  153             <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
  154               [% ELSE %]
  155             <option value="[% register.id | html %]">[% register.name | html %]</option>
  156               [% END %]
  157             [% END %]
  158         </select>
  159     </li>
  160     [% END %]
  161 </ol>
  162 </fieldset>
  163 
  164         <div class="action">
  165             <input type="submit" name="submitbutton" value="Confirm" />
  166             <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
  167         </div>
  168     </form>
  169     [% END %]
  170 [% ELSIF ( writeoff_individual ) %]
  171     <form name="woindivfine" id="woindivfine" action="/cgi-bin/koha/members/pay.pl" method="post" >
  172     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
  173     <fieldset class="rows">
  174     <legend>Write off an individual fine</legend>
  175     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
  176     <input type="hidden" name="pay_individual" id="pay_individual" value="[% pay_individual | html %]" />
  177     <input type="hidden" name="itemnumber" id="itemnumber" value="[% itemnumber | html %]" />
  178     <input type="hidden" name="description" id="description" value="[% description | html %]" />
  179     <input type="hidden" name="debit_type_code" id="debit_type_code" value="[% debit_type_code | html %]" />
  180     <input type="hidden" name="amount" id="amount" value="[% amount | html %]" />
  181     <input type="hidden" name="accountlines_id" id="accountlines_id" value="[% accountlines_id | html %]" />
  182     <input type="hidden" name="title" id="title" value="[% title | html %]" />
  183     <input type="hidden" name="payment_note" id="payment_note" value="[% payment_note | html %]" />
  184     <input type="hidden" name="amountoutstanding" id="amountoutstanding" value="[% amountoutstanding | html %]" />
  185     <input type="hidden" name="confirm_writeoff" id="confirm_writeoff" value="1" />
  186     <input type="hidden" name="change_given" id="change_given" />
  187     <table>
  188     <thead><tr>
  189             <th>Description</th>
  190             <th>Account type</th>
  191             <th>Amount</th>
  192             <th>Amount outstanding</th>
  193         </tr></thead>
  194     <tfoot><tr><td colspan="3">Total amount outstanding:</td><td>[% amountoutstanding | format('%.2f') %]</td></tr></tfoot>
  195     <tbody><tr>
  196             <td>[% individual_description | html %]</td>
  197             <td>[% debit_type_code | html %]</td>
  198             <td class="debit">[% amount | format('%.2f') %]</td>
  199             <td class="debit">[% amountoutstanding | format('%.2f') %]</td>
  200         </tr></tbody>
  201     </table>
  202 
  203             <ol>
  204                 <li>
  205                     <label for="amountwrittenoff">Writeoff amount: </label>
  206                     <!-- default to writing off all -->
  207                     <input name="amountwrittenoff" id="amountwrittenoff" value="[% amountoutstanding | $Price on_editing => 1 %]" type="text" />
  208                 </li>
  209             </ol>
  210         </fieldset>
  211         <div class="action">
  212             <input type="submit" value="Write off this charge" />
  213             <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
  214         </div>
  215     </form>
  216 [% ELSE %]
  217     [% IF ( error_registers && type != 'writeoff' ) %]
  218     <div id="error_message" class="dialog alert">
  219         You must have at least one cash register associated with this branch before you can record payments.
  220     </div>
  221     [% ELSE %]
  222 
  223     <form name="payfine" id="payfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
  224     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
  225     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
  226     <input type="hidden" name="selected_accts" id="selected_accts" value="[% selected_accts | html %]" />
  227     <input type="hidden" name="total" id="total" value="[% total | html %]" />
  228     <input type="hidden" name="type" value="[% type | html %]" />
  229     <input type="hidden" name="change_given" id="change_given" />
  230 
  231     <fieldset class="rows">
  232     [% IF ( selected_accts ) %]
  233         [% IF type == 'WRITEOFF' %]
  234             <legend>Write off an amount toward selected fines</legend>
  235         [% ELSE %]
  236             <legend>Pay an amount toward selected fines</legend>
  237         [% END %]
  238     [% ELSE %]
  239         <legend>Pay an amount toward all fines</legend>
  240     [% END %]
  241 
  242     <ol>
  243         <li>
  244             <span class="label">Total amount outstanding: </span>
  245             <span class="debit">[% total | format('%.2f') %]</span>
  246         </li>
  247     <li>
  248         [% IF type == 'WRITEOFF' %]
  249             <label for="paid">Writeoff amount: </label>
  250         [% ELSE %]
  251             <label for="paid">Amount being paid: </label>
  252         [% END %]
  253         <input name="paid" id="paid" type="text" step="0.01" value="[% total | $Price on_editing => 1 %]"/>
  254     </li>
  255     [% IF type != 'WRITEOFF' %]
  256         <li>
  257             <label for="collected">Collected from patron: </label>
  258             <input name="collected" id="collected" type="text" step="0.01" value="[% total | $Price on_editing => 1 %]"/>
  259         </li>
  260         <li>
  261             <label>Change to give: </label>
  262             <span id="change">0.00</span>
  263         </li>
  264     [% SET payment_types = [] %]
  265     [% FOR pt IN AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
  266         [% NEXT IF pt.authorised_value.grep("^SIP[[:digit:]]{2}$").size() %]
  267         [% payment_types.push(pt) %]
  268     [% END %]
  269     [% IF payment_types.size > 0 %]
  270         <li>
  271             <label for="payment_type">Payment type: </label>
  272             <select name="payment_type" id="payment_type">
  273                 <option value=""></option>
  274                 [% FOREACH pt IN payment_types %]
  275                     <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
  276                 [% END %]
  277             </select>
  278         </li>
  279     [% END %]
  280 
  281     [% IF Koha.Preference('UseCashRegisters') %]
  282     <li>
  283         <label for="cash_register">Cash register: </label>
  284         <select name="cash_register" id="cash_register">
  285             [% FOREACH register IN registers %]
  286               [% IF register.id == registerid %]
  287             <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
  288               [% ELSE %]
  289             <option value="[% register.id | html %]">[% register.name | html %]</option>
  290               [% END %]
  291             [% END %]
  292         </select>
  293     </li>
  294     [% END %]
  295     [% END %]
  296 
  297     <li>
  298         <label for="selected_accts_notes">Note: </label>
  299         <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes | html %]</textarea>
  300     </li>
  301     </ol>
  302     </fieldset>
  303     <div class="action">
  304         <input type="submit" name="submitbutton" value="Confirm" />
  305         <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
  306     </div>
  307     </form>
  308     [% END %]
  309 [% END %]
  310 </div></div>
  311 
  312             </main>
  313         </div> <!-- /.col-sm-10.col-sm-push-2 -->
  314 
  315         <div class="col-sm-2 col-sm-pull-10">
  316             <aside>
  317                 [% INCLUDE 'circ-menu.inc' %]
  318             </aside>
  319         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
  320      </div> <!-- /.row -->
  321 
  322 <!-- Modal -->
  323 <div id="confirm_change_form" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
  324     <div class="modal-dialog">
  325         <div class="modal-content">
  326             <div class="modal-header">
  327                 <h3>The amount collected is more than the outstanding charge</h3>
  328             </div>
  329             <div class="modal-body">
  330                 <p>The amount collected from the patron is higher than the amount to be paid.</p>
  331                 <p>The change to give is <b><span id="modal_change">0.00</span></b>.</p>
  332                 <p>Confirm this payment?</p>
  333             </div>
  334             <div class="modal-footer">
  335                 <button class="btn btn-default approve" id="modal_submit" type="button"><i class="fa fa-check"></i> Yes</button>
  336                 <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> No</button>
  337             </div>
  338         </div>
  339     </div>
  340 </div>
  341 
  342 [% MACRO jsinclude BLOCK %]
  343     [% INCLUDE 'str/members-menu.inc' %]
  344     [% Asset.js("js/members-menu.js") | $raw %]
  345     <script>
  346         $(document).ready(function() {
  347             [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
  348                 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');
  349             [% END %]
  350 
  351             var forms = $('#payindivfine, #payfine');
  352             var change = $('#change')[0];
  353 
  354             $('#payindivfine, #payfine').preventDoubleFormSubmit();
  355             $("#paid, #collected").on("change",function() {
  356                 moneyFormat( this );
  357                 if (change != undefined) {
  358                     updateChangeValues();
  359                 }
  360             });
  361 
  362             if (change != undefined) {
  363                 forms.on("submit", function(e) {
  364                     if (change.innerHTML > 0.00) {
  365                         e.preventDefault();
  366                         $("#confirm_change_form").modal("show");
  367                     } else {
  368                         return true;
  369                     }
  370                 });
  371             }
  372 
  373             $("#confirm_change_form").on("hidden.bs.modal", function(){
  374                 // remove class added by preventDoubleFormSubmit if necessary
  375                 $("body, form input[type='submit'], form button[type='submit'], form a").removeClass('waiting');
  376             });
  377 
  378             $('#modal_submit').click(function() {
  379                 forms[0].submit();
  380             });
  381 
  382             $( "#payindivfine, #payfine" ).validate({
  383                 rules: {
  384                     paid: { required: true },
  385                     collected: {
  386                         required: true
  387                     }
  388                 }
  389             });
  390         });
  391 
  392         prevent_default = 1;
  393         $('#woindivfine').on('submit', function(e){
  394             if ( prevent_default ) {
  395                 e.preventDefault();
  396 
  397                 let amount_outstanding = parseFloat( $('#amountoutstanding').attr('value') );
  398                 let amount_writeoff = parseFloat( $('#amountwrittenoff').attr('value') );
  399                 if ( amount_writeoff > amount_outstanding ) {
  400                     alert(_("You are attemping to writeoff more than the value of the fee."));
  401                     $('#woindivfine').beenSubmitted = false;
  402                 } else {
  403                     prevent_default = 0;
  404                     $('#woindivfine').preventDoubleFormSubmit();
  405                     $('#woindivfine').submit();
  406                 }
  407             }
  408         });
  409 
  410         function moneyFormat(textObj) {
  411             var newValue = textObj.value;
  412             var decAmount = "";
  413             var dolAmount = "";
  414             var decFlag   = false;
  415             var aChar     = "";
  416 
  417             for(i=0; i < newValue.length; i++) {
  418                 aChar = newValue.substring(i, i+1);
  419                 if (aChar >= "0" && aChar <= "9") {
  420                     if(decFlag) {
  421                         decAmount = "" + decAmount + aChar;
  422                     }
  423                     else {
  424                         dolAmount = "" + dolAmount + aChar;
  425                     }
  426                 }
  427                 if (aChar == ".") {
  428                     if (decFlag) {
  429                         dolAmount = "";
  430                         break;
  431                     }
  432                     decFlag = true;
  433                 }
  434             }
  435 
  436             if (dolAmount == "") {
  437                 dolAmount = "0";
  438             }
  439         // Strip leading 0s
  440             if (dolAmount.length > 1) {
  441                 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
  442                     dolAmount = dolAmount.substring(1,dolAmount.length);
  443                 }
  444             }
  445             if (decAmount.length > 2) {
  446                 decAmount = decAmount.substring(0,2);
  447             }
  448         // Pad right side
  449             if (decAmount.length == 1) {
  450                decAmount = decAmount + "0";
  451             }
  452             if (decAmount.length == 0) {
  453                decAmount = decAmount + "00";
  454             }
  455 
  456             textObj.value = dolAmount + "." + decAmount;
  457         }
  458 
  459         function updateChangeValues() {
  460             var change = $('#change')[0];
  461             change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
  462             if (change.innerHTML <= 0) {
  463                 var paid = $('#paid')[0];
  464                 moneyFormat(paid);
  465                 $('#collected').rules( "add", { min: Number(paid.value) });
  466                 $( "#payindivfine, #payfine" ).valid();
  467                 change.innerHTML = "0.00";
  468                 $('input[name="change_given"]').val('0.00');
  469             } else {
  470                 change.value = change.innerHTML;
  471                 moneyFormat(change);
  472                 change.innerHTML = change.value;
  473                 $('input[name="change_given"]').val(change.value);
  474             }
  475 
  476             $('#modal_change').html(change.innerHTML);
  477         }
  478     </script>
  479 [% END %]
  480 
  481 [% INCLUDE 'intranet-bottom.inc' %]