dolibarr  13.0.2
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')) define('NOCSRFCHECK', '1');
30 if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
31 if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
32 if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
33 if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
34 
35 require '../main.inc.php'; // Load $user and permissions
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
38 
39 $facid = GETPOST('facid', 'int');
40 $action = GETPOST('action', 'aZ09');
41 $email = GETPOST('email', 'alpha');
42 
43 if (empty($user->rights->takepos->run)) {
45 }
46 
47 $langs->loadLangs(array("main", "bills", "cashdesk"));
48 
49 $invoice = new Facture($db);
50 $invoice->fetch($facid);
51 $customer = new Societe($db);
52 $customer->fetch($invoice->socid);
53 
54 if ($action == "send")
55 {
56  include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
57  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
58  $formmail = new FormMail($db);
59  $outputlangs = new Translate('', $conf);
60  $model_id = $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE;
61  $arraydefaultmessage = $formmail->getEMailTemplate($db, 'facture_send', $user, $outputlangs, $model_id);
62  $subject = $arraydefaultmessage->topic;
63 
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 
69  $msg = "<html>".$arraydefaultmessage->content."<br>".$receipt."</html>";
70  $sendto = $email;
71  $from = $mysoc->email;
72  $mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1);
73  if ($mail->error || $mail->errors) {
74  setEventMessages($mail->error, $mail->errors, 'errors');
75  } else {
76  $result = $mail->sendfile();
77  }
78  exit;
79 }
80 $arrayofcss = array('/takepos/css/pos.css.php');
81 $arrayofjs = array();
82 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
83 ?>
84 </head>
85 <body class="center">
86 
87 <script>
88 function SendMail() {
89  $.ajax({
90  type: "GET",
91  url: "<?php print dol_buildpath('/takepos/send.php', 1).'?action=send&facid='.$facid.'&email='; ?>" + $("#email"). val(),
92  });
93  parent.$.colorbox.close();
94 }
95 
96 </script>
97 
98 <div class="center">
99 <center>
100 <center>
101 <input type="email" id="email" name="email" style="width:60%;font-size: 200%;" value="<?php echo $customer->email; ?>"></center>
102 </center>
103 </div>
104 <br>
105 <div class="center">
106 
107 <button type="button" class="calcbutton" onclick="SendMail()"><?php print $langs->trans("SendTicket"); ?></button>
108 
109 </div>
110 
111 </body>
112 </html>
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Classe permettant la generation du formulaire html d&#39;envoi de mail unitaire Usage: $formail = new For...
top_htmlhead($head, $title= '', $disablejs=0, $disablehead=0, $arrayofjs= '', $arrayofcss= '', $disablejmobile=0, $disablenofollow=0)
Ouput html header of a page.
Definition: main.inc.php:1280
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto); $mailfile-&gt;sendfile();.
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 ...
Class to manage translations.
print
Draft customers invoices.
Definition: index.php:89
Class to manage invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105