pay.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
  18. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
  19. //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
  20. //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
  21. if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
  22. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
  23. if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
  24. if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
  25. if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
  26. $_GET['theme']="md"; // Force theme. MD theme provides better look and feel to TakePOS
  27. require '../main.inc.php'; // Load $user and permissions
  28. require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
  29. $place = GETPOST('place','int');
  30. /*
  31. * View
  32. */
  33. $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS-".$place.")'";
  34. $resql = $db->query($sql);
  35. $row = $db->fetch_array ($resql);
  36. $placeid=$row[0];
  37. if (! $placeid) $placeid=0; // Invoice not exist
  38. else{
  39. $invoice = new Facture($db);
  40. $invoice->fetch($placeid);
  41. }
  42. top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
  43. $langs->loadLangs(array("main", "bills", "cashdesk"));
  44. ?>
  45. <link rel="stylesheet" href="css/pos.css">
  46. <script>
  47. var received=0;
  48. function addreceived(price)
  49. {
  50. received+=parseFloat(price);
  51. $('#change1').html(received.toFixed(2));
  52. if (received><?php echo $invoice->total_ttc;?>)
  53. {
  54. var change=parseFloat(received-<?php echo $invoice->total_ttc;?>);
  55. $('#change2').html(change.toFixed(2));
  56. }
  57. }
  58. function reset()
  59. {
  60. received=0;
  61. addreceived(0);
  62. $('#change2').html(received.toFixed(2));
  63. }
  64. function Validate(payment){
  65. parent.$("#poslines").load("invoice.php?place=<?php echo $place;?>&action=valid&pay="+payment, function() {
  66. parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
  67. parent.$.colorbox.close();
  68. });
  69. }
  70. </script>
  71. </head>
  72. <body>
  73. <div style="position:absolute; top:2%; left:5%; height:36%; width:91%;">
  74. <center>
  75. <div style="width:40%; background-color:#222222; border-radius:8px; margin-bottom: 4px;">
  76. <center><span style='font-family: digital; font-size: 280%;'><font color="white"><?php echo $langs->trans('TotalTTC');?>: </font><font color="red"><span id="totaldisplay"><?php echo price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) ?></span></span></center>
  77. </div>
  78. <div style="width:40%; background-color:#333333; border-radius:8px; margin-bottom: 4px;">
  79. <center><span style='font-family: digital; font-size: 250%;'><font color="white"><?php echo $langs->trans("AlreadyPaid"); ?>: </font><font color="red"><span id="change1"><?php echo price(0) ?></span></center>
  80. </div>
  81. <div style="width:40%; background-color:#333333; border-radius:8px; margin-bottom: 4px;">
  82. <center><span style='font-family: digital; font-size: 250%;'><font color="white"><?php echo $langs->trans("Change"); ?>: </font><font color="red"><span id="change2"><?php echo price(0) ?></span></span></center>
  83. </div>
  84. </center>
  85. </div>
  86. <div style="position:absolute; top:40%; left:5%; height:55%; width:91%;">
  87. <button type="button" class="calcbutton" onclick="addreceived(10);">10</button>
  88. <button type="button" class="calcbutton" onclick="addreceived(20);">20</button>
  89. <button type="button" class="calcbutton" onclick="addreceived(50);">50</button>
  90. <button type="button" <?php if ($placeid==0) echo "disabled";?> class="calcbutton2" onclick="Validate('cash');"><?php echo $langs->trans("Cash"); ?></button>
  91. <button type="button" class="calcbutton" onclick="addreceived(1);">1</button>
  92. <button type="button" class="calcbutton" onclick="addreceived(2);">2</button>
  93. <button type="button" class="calcbutton" onclick="addreceived(5);">5</button>
  94. <button type="button" <?php if ($placeid==0) echo "disabled";?> class="calcbutton2" onclick="Validate('card');"><?php echo $langs->trans("PaymentTypeCB"); ?></button>
  95. <button type="button" class="calcbutton" onclick="addreceived(0.10);">0.10</button>
  96. <button type="button" class="calcbutton" onclick="addreceived(0.20);">0.20</button>
  97. <button type="button" class="calcbutton" onclick="addreceived(0.50);">0.50</button>
  98. <button type="button" class="calcbutton2" onclick="Validate('cheque');"><?php echo $langs->trans("Cheque"); ?></button>
  99. <button type="button" class="calcbutton" onclick="addreceived(0.01);">0.01</button>
  100. <button type="button" class="calcbutton" onclick="addreceived(0.02);">0.02</button>
  101. <button type="button" class="calcbutton" onclick="addreceived(0.05);">0.05</button>
  102. <button type="button" class="calcbutton3" onclick="reset();"><span style='font-size: 150%;'>C</span></button>
  103. <button type="button" class="calcbutton3" onclick="parent.$.colorbox.close();"><span id="printtext"><?php echo $langs->trans("GoBack"); ?></span></button>
  104. </div>
  105. </body>
  106. </html>