Main Koha release repository https://koha-community.org
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

494 linhas
21 KiB

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