31if (!defined(
'NOTOKENRENEWAL')) {
32 define(
'NOTOKENRENEWAL',
'1');
34if (!defined(
'NOREQUIREMENU')) {
35 define(
'NOREQUIREMENU',
'1');
37if (!defined(
'NOREQUIREHTML')) {
38 define(
'NOREQUIREHTML',
'1');
40if (!defined(
'NOREQUIREAJAX')) {
41 define(
'NOREQUIREAJAX',
'1');
45require
'../main.inc.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
57$action =
GETPOST(
'action',
'aZ09');
58$email =
GETPOST(
'email',
'alpha');
60if (!$user->hasRight(
'takepos',
'run')) {
64$langs->loadLangs(array(
"main",
"bills",
"cashdesk"));
67$invoice->fetch($facid);
69$customer->fetch($invoice->socid);
78if ($action ==
"send" && $user->hasRight(
'takepos',
'run')) {
81 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
82 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
86 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'facture_send', $user, $outputlangs, $model_id);
89 $subject = $arraydefaultmessage->topic;
101 include DOL_DOCUMENT_ROOT.
'/takepos/receipt.php';
102 $receipt = ob_get_contents();
105 if ($arraydefaultmessage->joinfiles == 1 && !empty($invoice->last_main_doc)) {
109 $joinFile[] = DOL_DATA_ROOT.
'/'.$invoice->last_main_doc;
110 $joinFileName[] = basename($invoice->last_main_doc);
111 $joinFileMime[] = dol_mimetype(DOL_DATA_ROOT.
'/'.$invoice->last_main_doc);
121 $msg .= $arraydefaultmessage->content;
129 $mail =
new CMailFile($subject, $sendto, $from, $msg, $joinFile, $joinFileMime, $joinFileName,
'',
'', 0, 1,
'',
'',
'',
'',
'',
'', DOL_DATA_ROOT.
'/documents/takepos/temp');
131 if ($mail->error || !empty($mail->errors)) {
134 print
'Failed to send email: '.$mail->error;
136 http_response_code(500);
138 $result = $mail->sendfile();
140 $triggersendname =
'BILL_SENTBYMAIL';
142 $object->context[
'email_from'] = $from;
143 $object->context[
'email_to'] = $sendto;
144 $object->context[
'email_msgid'] = $mail->msgid;
148 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture SET email_sent_counter = email_sent_counter + 1";
149 $sql .=
" WHERE rowid = ".((int)
$object->id);
151 $resql =
$db->query($sql);
153 $object->email_sent_counter += 1;
157 $result =
$object->call_trigger($triggersendname, $user);
166 print
'Mail successfully sent to '.$sendto.
' with subject '.$subject;
168 print
'If template ask to join file, it may include the file '.implode(
',', $joinFile);
170 http_response_code(500);
173 print
'Failed to send email: '.$mail->error;
175 http_response_code(500);
187$arrayofcss = array(
'/takepos/css/pos.css.php');
200 data: { token:
'<?php echo currentToken(); ?>' },
201 url:
'<?php print DOL_URL_ROOT.'/takepos/send.php?action=send&token=
'.newToken().'&facid=
'.((int) $facid).'&
email=
'; ?>' + $(
"#email").val(),
202 success:
function(response) {
203 console.log(
"Email sent");
206 error:
function(xhr,
status, error) {
207 console.log(
"Failed to send email");
208 alert(
"Failed to send email : " + error);
211 parent.$.colorbox.close();
219<input
type=
"email" id=
"email" name=
"email" style=
"width:60%;font-size: 200%;" value=
"<?php echo $customer->email; ?>"></center>
225<
button type=
"button" class=
"calcbutton" onclick=
"SendMail()"><?php print $langs->trans(
"SendTicket"); ?></
button>
if(! $sortfield) if(! $sortorder) $object
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
$conf db name
Only used if Module[ID]Name translation string is not found.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.