send.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
  3. * Copyright (C) 2020 Andreu Bisquerra Gaya <jove@bisquerra.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/takepos/send.php
  20. * \ingroup takepos
  21. * \brief Page with the content of the popup to enter payments
  22. */
  23. //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language
  24. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
  25. //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
  26. //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
  27. if (!defined('NOCSRFCHECK')) {
  28. define('NOCSRFCHECK', '1');
  29. }
  30. if (!defined('NOTOKENRENEWAL')) {
  31. define('NOTOKENRENEWAL', '1');
  32. }
  33. if (!defined('NOREQUIREMENU')) {
  34. define('NOREQUIREMENU', '1');
  35. }
  36. if (!defined('NOREQUIREHTML')) {
  37. define('NOREQUIREHTML', '1');
  38. }
  39. if (!defined('NOREQUIREAJAX')) {
  40. define('NOREQUIREAJAX', '1');
  41. }
  42. require '../main.inc.php'; // Load $user and permissions
  43. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  44. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  45. $facid = GETPOST('facid', 'int');
  46. $action = GETPOST('action', 'aZ09');
  47. $email = GETPOST('email', 'alpha');
  48. if (empty($user->rights->takepos->run)) {
  49. accessforbidden();
  50. }
  51. $langs->loadLangs(array("main", "bills", "cashdesk"));
  52. $invoice = new Facture($db);
  53. $invoice->fetch($facid);
  54. $customer = new Societe($db);
  55. $customer->fetch($invoice->socid);
  56. if ($action == "send") {
  57. include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
  58. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
  59. $formmail = new FormMail($db);
  60. $outputlangs = new Translate('', $conf);
  61. $model_id = $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE;
  62. $arraydefaultmessage = $formmail->getEMailTemplate($db, 'facture_send', $user, $outputlangs, $model_id);
  63. $subject = $arraydefaultmessage->topic;
  64. ob_start(); // turn on output receipt
  65. include 'receipt.php';
  66. $receipt = ob_get_contents(); // get the contents of the output buffer
  67. ob_end_clean();
  68. $msg = "<html>".$arraydefaultmessage->content."<br>".$receipt."</html>";
  69. $sendto = $email;
  70. $from = $mysoc->email;
  71. $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1);
  72. if ($mail->error || $mail->errors) {
  73. setEventMessages($mail->error, $mail->errors, 'errors');
  74. } else {
  75. $result = $mail->sendfile();
  76. }
  77. exit;
  78. }
  79. $arrayofcss = array('/takepos/css/pos.css.php');
  80. $arrayofjs = array();
  81. top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
  82. ?>
  83. </head>
  84. <body class="center">
  85. <script>
  86. function SendMail() {
  87. $.ajax({
  88. type: "GET",
  89. data: { token: '<?php echo currentToken(); ?>' },
  90. url: "<?php print DOL_URL_ROOT.'/takepos/send.php?action=send&facid='.$facid.'&email='; ?>" + $("#email"). val(),
  91. });
  92. parent.$.colorbox.close();
  93. }
  94. </script>
  95. <div class="center">
  96. <center>
  97. <center>
  98. <input type="email" id="email" name="email" style="width:60%;font-size: 200%;" value="<?php echo $customer->email; ?>"></center>
  99. </center>
  100. </div>
  101. <br>
  102. <div class="center">
  103. <button type="button" class="calcbutton" onclick="SendMail()"><?php print $langs->trans("SendTicket"); ?></button>
  104. </div>
  105. </body>
  106. </html>