pay.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. <?php
  48. if ($conf->global->TAKEPOS_NUMPAD==0) print "var received='';";
  49. else print "var received=0;";
  50. ?>
  51. function addreceived(price)
  52. {
  53. <?php
  54. if ($conf->global->TAKEPOS_NUMPAD==0) print 'received+=String(price);';
  55. else print 'received+=parseFloat(price);';
  56. ?>
  57. $('#change1').html(parseFloat(received).toFixed(2));
  58. if (parseFloat(received)><?php echo $invoice->total_ttc;?>)
  59. {
  60. var change=parseFloat(parseFloat(received)-<?php echo $invoice->total_ttc;?>);
  61. $('#change2').html(change.toFixed(2));
  62. }
  63. }
  64. function reset()
  65. {
  66. received=0;
  67. addreceived(0);
  68. $('#change2').html(received.toFixed(2));
  69. }
  70. function Validate(payment){
  71. parent.$("#poslines").load("invoice.php?place=<?php echo $place;?>&action=valid&pay="+payment, function() {
  72. parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
  73. parent.$.colorbox.close();
  74. });
  75. }
  76. </script>
  77. </head>
  78. <body>
  79. <div style="position:absolute; top:2%; left:5%; height:36%; width:91%;">
  80. <center>
  81. <div style="width:40%; background-color:#222222; border-radius:8px; margin-bottom: 4px;">
  82. <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>
  83. </div>
  84. <div style="width:40%; background-color:#333333; border-radius:8px; margin-bottom: 4px;">
  85. <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>
  86. </div>
  87. <div style="width:40%; background-color:#333333; border-radius:8px; margin-bottom: 4px;">
  88. <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>
  89. </div>
  90. </center>
  91. </div>
  92. <div style="position:absolute; top:40%; left:5%; height:55%; width:91%;">
  93. <?php
  94. $numpad=$conf->global->TAKEPOS_NUMPAD;
  95. ?>
  96. <button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "7"; else print "10";?>);"><?php if ($numpad==0) print "7"; else print "10";?></button>
  97. <button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "8"; else print "20";?>);"><?php if ($numpad==0) print "8"; else print "20";?></button>
  98. <button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "9"; else print "50";?>);"><?php if ($numpad==0) print "9"; else print "50";?></button>
  99. <button type="button" <?php if ($placeid==0) echo "disabled";?> class="calcbutton2" onclick="Validate('cash');"><?php echo $langs->trans("Cash"); ?></button>
  100. <button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "4"; else print "1";?>);"><?php if ($numpad==0) print "4"; else print "1";?></button>
  101. <button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "5"; else print "2";?>);"><?php if ($numpad==0) print "5"; else print "2";?></button>
  102. <button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "6"; else print "5";?>);"><?php if ($numpad==0) print "6"; else print "5";?></button>
  103. <button type="button" <?php if ($placeid==0) echo "disabled";?> class="calcbutton2" onclick="Validate('card');"><?php echo $langs->trans("PaymentTypeCB"); ?></button>
  104. <button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "1"; else print "0.10";?>);"><?php if ($numpad==0) print "1"; else print "0.10";?></button>
  105. <button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "2"; else print "0.20";?>);"><?php if ($numpad==0) print "2"; else print "0.20";?></button>
  106. <button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "3"; else print "0.50";?>);"><?php if ($numpad==0) print "3"; else print "0.50";?></button>
  107. <button type="button" <?php if ($placeid==0) echo "disabled";?> class="calcbutton2" onclick="Validate('cheque');"><?php echo $langs->trans("Cheque"); ?></button>
  108. <button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "0"; else print "0.01";?>);"><?php if ($numpad==0) print "0"; else print "0.01";?></button>
  109. <button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "'000'"; else print "0.02";?>);"><?php if ($numpad==0) print "000"; else print "0.02";?></button>
  110. <button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "'.'"; else print "0.05";?>);"><?php if ($numpad==0) print "."; else print "0.05";?></button>
  111. <button type="button" class="calcbutton3" onclick="reset();"><span style='font-size: 150%;'>C</span></button>
  112. <button type="button" class="calcbutton3" onclick="parent.$.colorbox.close();"><span id="printtext"><?php echo $langs->trans("GoBack"); ?></span></button>
  113. </div>
  114. </body>
  115. </html>