dolibarr  16.0.5
send.php
Go to the documentation of this file.
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 
25 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language
26 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
27 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
28 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
29 if (!defined('NOCSRFCHECK')) {
30  define('NOCSRFCHECK', '1');
31 }
32 if (!defined('NOTOKENRENEWAL')) {
33  define('NOTOKENRENEWAL', '1');
34 }
35 if (!defined('NOREQUIREMENU')) {
36  define('NOREQUIREMENU', '1');
37 }
38 if (!defined('NOREQUIREHTML')) {
39  define('NOREQUIREHTML', '1');
40 }
41 if (!defined('NOREQUIREAJAX')) {
42  define('NOREQUIREAJAX', '1');
43 }
44 
45 require '../main.inc.php'; // Load $user and permissions
46 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
47 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
48 
49 $facid = GETPOST('facid', 'int');
50 $action = GETPOST('action', 'aZ09');
51 $email = GETPOST('email', 'alpha');
52 
53 if (empty($user->rights->takepos->run)) {
55 }
56 
57 $langs->loadLangs(array("main", "bills", "cashdesk"));
58 
59 $invoice = new Facture($db);
60 $invoice->fetch($facid);
61 $customer = new Societe($db);
62 $customer->fetch($invoice->socid);
63 
64 if ($action == "send") {
65  include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
66  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
67  $formmail = new FormMail($db);
68  $outputlangs = new Translate('', $conf);
69  $model_id = $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE;
70  $arraydefaultmessage = $formmail->getEMailTemplate($db, 'facture_send', $user, $outputlangs, $model_id);
71  $subject = $arraydefaultmessage->topic;
72 
73  ob_start(); // turn on output receipt
74  include 'receipt.php';
75  $receipt = ob_get_contents(); // get the contents of the output buffer
76  ob_end_clean();
77 
78  $msg = "<html>".$arraydefaultmessage->content."<br>".$receipt."</html>";
79  $sendto = $email;
80  $from = $mysoc->email;
81  $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1);
82  if ($mail->error || $mail->errors) {
83  setEventMessages($mail->error, $mail->errors, 'errors');
84  } else {
85  $result = $mail->sendfile();
86  }
87  exit;
88 }
89 $arrayofcss = array('/takepos/css/pos.css.php');
90 $arrayofjs = array();
91 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
92 ?>
93 </head>
94 <body class="center">
95 
96 <script>
97 function SendMail() {
98  $.ajax({
99  type: "GET",
100  data: { token: '<?php echo currentToken(); ?>' },
101  url: "<?php print DOL_URL_ROOT.'/takepos/send.php?action=send&facid='.$facid.'&email='; ?>" + $("#email"). val(),
102  });
103  parent.$.colorbox.close();
104 }
105 
106 </script>
107 
108 <div class="center">
109 <center>
110 <center>
111 <input type="email" id="email" name="email" style="width:60%;font-size: 200%;" value="<?php echo $customer->email; ?>"></center>
112 </center>
113 </div>
114 <br>
115 <div class="center">
116 
117 <button type="button" class="calcbutton" onclick="SendMail()"><?php print $langs->trans("SendTicket"); ?></button>
118 
119 </div>
120 
121 </body>
122 </html>
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
Translate
Class to manage translations.
Definition: translate.class.php:30
top_htmlhead
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
Definition: main.inc.php:1482
CMailFile
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Definition: CMailFile.class.php:38
name
$conf db name
Definition: repair.php:122
Facture
Class to manage invoices.
Definition: facture.class.php:60
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
FormMail
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Definition: html.formmail.class.php:38
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119