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$result = $invoice->fetch($facid);
69if ($result <= 0 || $invoice->module_source !=
'takepos' || !in_array($invoice->entity, explode(
',',
getEntity(
'invoice')))) {
74$customer->fetch($invoice->socid);
83if ($action ==
"send" && $user->hasRight(
'takepos',
'run')) {
86 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
87 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
91 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'facture_send', $user, $outputlangs, $model_id);
94 $subject = $arraydefaultmessage->topic;
106 include DOL_DOCUMENT_ROOT.
'/takepos/receipt.php';
107 $receipt = ob_get_contents();
110 if ($arraydefaultmessage->joinfiles == 1 && !empty($invoice->last_main_doc)) {
114 $joinFile[] = DOL_DATA_ROOT.
'/'.$invoice->last_main_doc;
115 $joinFileName[] = basename($invoice->last_main_doc);
116 $joinFileMime[] =
dol_mimetype(DOL_DATA_ROOT.
'/'.$invoice->last_main_doc);
122 $email_from =
$mysoc->email;
126 $msg .= $arraydefaultmessage->content;
134 $mail =
new CMailFile($subject, $sendto, $email_from, $msg, $joinFile, $joinFileMime, $joinFileName,
'',
'', 0, 1,
'',
'',
'',
'',
'',
'', DOL_DATA_ROOT.
'/documents/takepos/temp');
136 if ($mail->error || !empty($mail->errors)) {
137 setEventMessages($mail->error, $mail->errors,
'errors');
139 print
'Failed to send email: '.$mail->error;
141 http_response_code(500);
143 $result = $mail->sendfile();
145 $triggersendname =
'BILL_SENTBYMAIL';
147 $object->context[
'email_from'] = $email_from;
148 $object->context[
'email_to'] = $sendto;
149 $object->context[
'email_msgid'] = $mail->msgid;
153 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture SET email_sent_counter = email_sent_counter + 1";
154 $sql .=
" WHERE rowid = ".((int)
$object->id);
156 $resql = $db->query($sql);
158 $object->email_sent_counter += 1;
162 $result =
$object->call_trigger($triggersendname, $user);
171 print
'Mail successfully sent to '.$sendto.
' with subject '.$subject;
173 print
'If template ask to join file, it may include the file '.implode(
',', $joinFile);
175 http_response_code(500);
178 print
'Failed to send email: '.$mail->error;
180 http_response_code(500);
192$arrayofcss = array(
'/takepos/css/pos.css.php');
205 data: { token:
'<?php echo currentToken(); ?>' },
206 url:
'<?php print DOL_URL_ROOT.'/takepos/send.php?action=send&token=
'.newToken().'&facid=
'.((int) $facid).'&
email=
'; ?>' + $(
"#email").val(),
207 success:
function(response) {
208 console.log(
"Email sent");
211 error:
function(xhr,
status, error) {
212 console.log(
"Failed to send email");
213 alert(
"Failed to send email : " + error);
216 parent.$.colorbox.close();
224<input
type=
"email" id=
"email" name=
"email" style=
"width:60%;font-size: 200%;" value=
"<?php echo $customer->email; ?>"></center>
230<
button type=
"button" class=
"calcbutton" onclick=
"SendMail()"><?php print $langs->trans(
"SendTicket"); ?></
button>
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
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").
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
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.
$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.