summaryrefslogtreecommitdiff
path: root/UI/rc-till-closing.html
blob: 2052e4651d275d060154bfe972a818e0a9b191e9 (plain)
  1. <?lsmb INCLUDE 'ui-header.html' ?>
  2. <?lsmb PROCESS elements.html ?>
  3. <body>
  4. <script type='text/javascript'>
  5. function money_round(m){
  6. var r;
  7. r = Math.round(m * 100)/100;
  8. return r;
  9. }
  10. function custom_calc_total(){
  11. <?lsmb sub_sum = []; round_line = [];
  12. FOREACH unit IN units;
  13. sub_sum.push("document.forms[0].sub_${unit.unit_name}.value * 1");
  14. round_line.push("document.forms[0].sub_${unit.unit_name}.value = money_round(document.forms[0].sub_${unit.unit_name}.value);");
  15. ?>
  16. document.forms[0].sub_<?lsmb unit.unit_name ?>.value = document.forms[0].calc_<?lsmb unit.unit_name ?>.value * <?lsmb unit.unit ?>;
  17. <?lsmb END ?>
  18. document.forms[0].sub_sub.value = <?lsmb sub_sum.join(' + ') ?>
  19. <?lsmb round_line.join(' ') ?>
  20. document.forms[0].sub_sub.value =
  21. money_round(document.forms[0].sub_sub.value);
  22. document.forms[0].amount_cash.value = money_round(
  23. document.forms[0].sub_sub.value - <?lsmb pos.till_cash ?>);
  24. check_errors();
  25. }
  26. function check_errors(){
  27. var cumulative_error = 0;
  28. var source_error = 0;
  29. var err_cell;
  30. <?lsmb FOREACH source IN sources; s = source.source ?>
  31. source_error = money_round(
  32. document.forms[0].amount_<?lsmb s ?>.value -
  33. document.forms[0].expected_<?lsmb s ?>.value
  34. );
  35. cumulative_error = cumulative_error + source_error;
  36. err_cell = document.getElementById('error_<?lsmb s ?>');
  37. err_cell.innerHTML = '<?lsmb pos.curren ?>' + source_error;
  38. <?lsmb END ?>
  39. alert('<?lsmb text('Cumulative Error:') ?> ' + money_round(cumulative_error));
  40. }
  41. </script>
  42. <form method="post" action="<?lsmb form.script ?>">
  43. <table width="100%">
  44. <tr>
  45. <th class="listtop"><?lsmb form.title ?></th>
  46. </tr>
  47. </table>
  48. <table width="100%">
  49. <tr><?lsmb FOREACH column IN columns ?>
  50. <td class="listheading"><?lsmb text(column) ?></td>
  51. <?lsmb END ?></tr>
  52. <?lsmb FOREACH source IN sources ?><tr class="listrow<?lsmb source.i ?>">
  53. <td><?lsmb source.label ?></td>
  54. <td><?lsmb PROCESS input element_data={name => "amount_${source.source}"} ?></td>
  55. <td><?lsmb source.currenamount ?></td>
  56. <td id="error_<?lsmb source.source ?>"></td>
  57. </tr><?lsmb END ?><tr><td colspan="4">
  58. <table>
  59. <?lsmb FOREACH unit IN units ?><tr>
  60. <td><?lsmb PROCESS input element_data=unit.quantity ?></td>
  61. <th>X <?lsmb unit.currenunit ?> = </th>
  62. <td><?lsmb PROCESS input element_data=unit.value ?></td>
  63. </tr><?lsmb END ?>
  64. <tr>
  65. <td>&nbsp;</td>
  66. <th><?lsmb text('Subtotal:') ?></th>
  67. <td><?lsmb PROCESS input element_data={name => 'sub_sub' value => form.sub_sub} ?></td>
  68. </tr>
  69. </table></td></tr>
  70. </table>
  71. <?lsmb FOREACH hidden IN hiddens.keys;
  72. PROCESS input element_data={
  73. type => 'hidden',
  74. name => hidden,
  75. value => hiddens.item(hidden)
  76. }; END ?>
  77. <?lsmb FOREACH button IN buttons; PROCESS button element_data=button; END ?>
  78. </form>
  79. </body>
  80. </html>