Exemple #1
0
function mailSchedule(Expo $expo, Worker $worker)
{
    $savList = ShiftAssignmentView::selectWorker($expo->expoid, $worker->workerid);
    $paramNames = array("FIRSTNAME", "EXPONAME");
    $params = array("FIRSTNAME" => $worker->firstName, "EXPONAME" => $expo->title);
    $body = "Hello FIRSTNAME,\n\nYour schedule for EXPONAME is:\n";
    $body .= sprintfSchedule($savList);
    $body .= "\n\nSincerely,\nThe " . SITE_NAME . " Team";
    $form = new FormMail($expo->title . " Schedule", $paramNames, $body);
    $form->sendForm($worker->email, $params);
}
Exemple #2
0
 /**
  * This is the base function for sending mail;
  * it looks up the form, and fills in the params,
  * then calls mail.
  */
 public function sendForm($to, array $params = NULL)
 {
     try {
         $sendBody = $this->body;
         if (!is_null($params)) {
             if (count($this->paramNames) != count($params)) {
                 logMessage('FormMail.sendForm(' . $to . ')', 'params do not match');
             }
             $sendBody = $this->body;
             foreach ($this->paramNames as $param) {
                 $sendBody = str_replace($param, $params[$param], $sendBody);
             }
         }
         FormMail::send($to, $this->subject, $sendBody);
     } catch (Exception $ex) {
         logMessage('FormMail.sendForm(' . $to . ')', $ex->getMessage());
     }
 }
Exemple #3
0
             print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")) . '">' . $langs->trans("DeleteMailing") . '</a>';
         } else {
             print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?action=delete&amp;id=' . $object->id . (!empty($urlfrom) ? '&urlfrom=' . $urlfrom : '') . '">' . $langs->trans("DeleteMailing") . '</a>';
         }
     }
     print '<br><br></div>';
 }
 if (!empty($mesgembedded)) {
     dol_htmloutput_mesg($mesgembedded, '', 'warning', 1);
 }
 // Affichage formulaire de TEST
 if ($action == 'test') {
     print_titre($langs->trans("TestMailing"));
     // Create l'objet formulaire mail
     include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
     $formmail = new FormMail($db);
     $formmail->fromname = $object->email_from;
     $formmail->frommail = $object->email_from;
     $formmail->withsubstit = 1;
     $formmail->withfrom = 0;
     $formmail->withto = $user->email ? $user->email : 1;
     $formmail->withtocc = 0;
     $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
     $formmail->withtopic = 0;
     $formmail->withtopicreadonly = 1;
     $formmail->withfile = 0;
     $formmail->withbody = 0;
     $formmail->withbodyreadonly = 1;
     $formmail->withcancel = 1;
     $formmail->withdeliveryreceipt = 0;
     // Tableau des substitutions
Exemple #4
0

    /*
     * Action presend
     */
    if ($action == 'presend')
    {
        $ref = dol_sanitizeFileName($object->ref);
        $file = $conf->ficheinter->dir_output . '/' . $ref . '/' . $ref . '.pdf';

        print '<br>';
        print_titre($langs->trans('SendInterventionByMail'));

        // Create form object
        include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
        $formmail = new FormMail($db);
        $formmail->fromtype = 'user';
        $formmail->fromid   = $user->id;
        $formmail->fromname = $user->getFullName($langs);
        $formmail->frommail = $user->email;
        $formmail->withfrom=1;
        $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"];
        $formmail->withtosocid=$societe->id;
        $formmail->withtocc=1;
        $formmail->withtoccsocid=0;
        $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
        $formmail->withtocccsocid=0;
        $formmail->withtopic=$langs->trans('SendInterventionRef','__FICHINTERREF__');
        $formmail->withfile=2;
        $formmail->withbody=1;
        $formmail->withdeliveryreceipt=1;
$message = swwat_parse_string(html_entity_decode($_POST[PARAM_MESSAGE]));
$list = $_POST[PARAM_LIST_INDEX];
if (!is_null($list) && ($typeFlag && (!is_null($subject) || !is_null($message)) || !$typeFlag && !is_null($message))) {
    if (!$typeFlag) {
        $subject = "";
        // ensure blank
        $message = substr($message, 0, 160);
    }
    $workerList = $_SESSION[PARAM_LIST];
    for ($k = 0; $k < count($list); $k++) {
        try {
            $listIndex = swwat_parse_number(html_entity_decode($list[$k]), FALSE);
            $worker = $workerList[$listIndex];
            $to = $typeFlag ? $worker->email : $worker->smsemail;
            if (!is_null($to) && strlen($to) > 0) {
                FormMail::send($to, $subject, $message);
            } else {
                /* continue to process list */
                logMessage("SendMessageAction", "failure with to field:" . $to . " index:" . $k . " value:" . $list[$k]);
            }
        } catch (ParseSWWATException $pe) {
            /* continue to process list */
            logMessage("SendMessageAction", "failure with index:" . $k . " value:" . $list[$k]);
        }
    }
    // $k
}
// all null
// return to whence we came
if (is_null(getStationCurrent())) {
    if (is_null(getExpoCurrent())) {
Exemple #6
0
     } else {
         $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port);
         if ($mail->error) {
             $errormsg .= ' - ' . $mail->error;
         }
         setEventMessage($errormsg, 'errors');
     }
     print '<br>';
 }
 // Show email send test form
 if ($action == 'test' || $action == 'testhtml') {
     print '<br>';
     print_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
     // Cree l'objet formulaire mail
     include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
     $formmail = new FormMail($db);
     $formmail->fromname = isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM;
     $formmail->frommail = isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM;
     $formmail->withfromreadonly = 0;
     $formmail->withsubstit = 0;
     $formmail->withfrom = 1;
     $formmail->witherrorsto = 1;
     $formmail->withto = !empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1);
     $formmail->withtocc = !empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1;
     // ! empty to keep field if empty
     $formmail->withtoccc = !empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1;
     // ! empty to keep field if empty
     $formmail->withtopic = isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test");
     $formmail->withtopicreadonly = 0;
     $formmail->withfile = 2;
     $formmail->withbody = isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"));
Exemple #7
0
    accessforbidden();
}
$upload_dir = $conf->admin->dir_temp;
/*
 * Actions
 */
if ($_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) {
    require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
    $result = dol_mkdir($upload_dir);
    // Create dir if not exists
    if ($result >= 0) {
        $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']), 1, 0, $_FILES['userfile']['error']);
        if (is_numeric($resupload) && $resupload > 0) {
            $mesg = '<div class="ok">' . $langs->trans("FileTransferComplete") . '</div>';
            include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
            $formmail = new FormMail($db);
            $formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'], $_FILES['addedfile']['name'], $_FILES['addedfile']['type']);
        } else {
            $langs->load("errors");
            if ($resupload < 0) {
                $mesg = '<div class="error">' . $langs->trans("ErrorFileNotUploaded") . '</div>';
            } else {
                if (preg_match('/ErrorFileIsInfectedWithAVirus.(.*)/', $resupload, $reg)) {
                    $mesg = '<div class="error">' . $langs->trans("ErrorFileIsInfectedWithAVirus");
                    $mesg .= '<br>' . $langs->trans("Information") . ': ' . $langs->trans($reg[1]);
                    $mesg .= '</div>';
                } else {
                    $mesg = '<div class="error">' . $langs->trans($resupload) . '</div>';
                }
            }
        }
 /** Overloading the doActions function : replacing the parent's function with the one below 
  *  @param      parameters  meta datas of the hook (context, etc...) 
  *  @param      object             the object you want to process (an invoice if you are in invoice module, a propale in propale's module, etc...) 
  *  @param      action             current action (if set). Generally create or edit or null 
  *  @return       void 
  */
 function doActions($parameters, &$object, &$action, $hookmanager)
 {
     global $langs, $user, $db;
     if ($action == "send") {
         switch ($parameters['context']) {
             case 'propalcard':
                 if (!GETPOST('addfile') && !GETPOST('removedfile') && !GETPOST('cancel')) {
                     $langs->load('mails');
                     $result = $object->fetch(GETPOST("id"));
                     $result = $object->fetch_thirdparty();
                     if ($result > 0) {
                         if (GETPOST('sendto')) {
                             // Le destinataire a ete fourni via le champ libre
                             $sendto = GETPOST('sendto');
                             $sendtoid = 0;
                         } elseif (GETPOST('receiver') != '-1') {
                             // Recipient was provided from combo list
                             if (GETPOST('receiver') == 'thirdparty') {
                                 // Id of third party
                                 $sendto = $object->client->email;
                                 $sendtoid = 0;
                             } else {
                                 // Id du contact
                                 $sendto = $object->client->contact_get_property(GETPOST('receiver'), 'email');
                                 $sendtoid = GETPOST('receiver');
                             }
                         }
                         if (dol_strlen($sendto)) {
                             $langs->load("commercial");
                             $from = GETPOST('fromname') . ' <' . GETPOST('frommail') . '>';
                             $replyto = GETPOST('replytoname') . ' <' . GETPOST('replytomail') . '>';
                             $message = GETPOST('message');
                             $sendtocc = GETPOST('sendtocc');
                             $deliveryreceipt = GETPOST('deliveryreceipt');
                             if (GETPOST('action') == 'send') {
                                 if (dol_strlen(GETPOST('subject'))) {
                                     $subject = GETPOST('subject');
                                 } else {
                                     $subject = $langs->transnoentities('Propal') . ' ' . $object->ref;
                                 }
                                 $actiontypecode = 'AC_PROP';
                                 $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n";
                                 if ($message) {
                                     $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n";
                                     $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n";
                                     $actionmsg .= $message;
                                 }
                                 $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode);
                             }
                             // Create form object
                             include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
                             $formmail = new FormMail($db);
                             $attachedfiles = $formmail->get_attached_files();
                             $filepath = $attachedfiles['paths'];
                             $filename = $attachedfiles['names'];
                             $mimetype = $attachedfiles['mimes'];
                             // Envoi de la propal
                             require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
                             $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt);
                             if (!$mailfile->error) {
                                 $mailfile->message = stripslashes($mailfile->message);
                                 $msg_prepared = $mailfile->headers . $mailfile->eol;
                                 $msg_prepared .= $mailfile->subject . $mailfile->eol;
                                 $msg_prepared .= $mailfile->message . $mailfile->eol;
                                 $object->msg_imap_result = store_email_into_folder($msg_prepared);
                             }
                         }
                     }
                 }
                 break;
             case 'ordercard':
                 if (!GETPOST('addfile') && !GETPOST('removedfile') && !GETPOST('cancel')) {
                     $langs->load('mails');
                     $result = $object->fetch(GETPOST("id"));
                     $result = $object->fetch_thirdparty();
                     if ($result > 0) {
                         if (GETPOST('sendto')) {
                             // Le destinataire a ete fourni via le champ libre
                             $sendto = GETPOST('sendto');
                             $sendtoid = 0;
                         } elseif (GETPOST('receiver') != '-1') {
                             // Recipient was provided from combo list
                             if (GETPOST('receiver') == 'thirdparty') {
                                 // Id of third party
                                 $sendto = $object->client->email;
                                 $sendtoid = 0;
                             } else {
                                 // Id du contact
                                 $sendto = $object->client->contact_get_property(GETPOST('receiver'), 'email');
                                 $sendtoid = GETPOST('receiver');
                             }
                         }
                         if (dol_strlen($sendto)) {
                             $langs->load("commercial");
                             $from = GETPOST('fromname') . ' <' . GETPOST('frommail') . '>';
                             $replyto = GETPOST('replytoname') . ' <' . GETPOST('replytomail') . '>';
                             $message = GETPOST('message');
                             $sendtocc = GETPOST('sendtocc');
                             $deliveryreceipt = GETPOST('deliveryreceipt');
                             if (GETPOST('action') == 'send') {
                                 if (dol_strlen(GETPOST('subject'))) {
                                     $subject = GETPOST('subject');
                                 } else {
                                     $subject = $langs->transnoentities('Propal') . ' ' . $object->ref;
                                 }
                                 $actiontypecode = 'AC_PROP';
                                 $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n";
                                 if ($message) {
                                     $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n";
                                     $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n";
                                     $actionmsg .= $message;
                                 }
                                 $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode);
                             }
                             // Create form object
                             include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
                             $formmail = new FormMail($db);
                             $attachedfiles = $formmail->get_attached_files();
                             $filepath = $attachedfiles['paths'];
                             $filename = $attachedfiles['names'];
                             $mimetype = $attachedfiles['mimes'];
                             // Envoi de la propal
                             require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
                             $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt);
                             if (!$mailfile->error) {
                                 $mailfile->message = stripslashes($mailfile->message);
                                 $msg_prepared = $mailfile->headers . $mailfile->eol;
                                 $msg_prepared .= $mailfile->subject . $mailfile->eol;
                                 $msg_prepared .= $mailfile->message . $mailfile->eol;
                                 $object->msg_imap_result = store_email_into_folder($msg_prepared);
                             }
                         }
                     }
                 }
                 break;
             case 'invoicecard':
                 if (!GETPOST('addfile') && !GETPOST('removedfile') && !GETPOST('cancel')) {
                     $langs->load('mails');
                     $result = $object->fetch(GETPOST("id"));
                     $result = $object->fetch_thirdparty();
                     if ($result > 0) {
                         if (GETPOST('sendto')) {
                             // Le destinataire a ete fourni via le champ libre
                             $sendto = GETPOST('sendto');
                             $sendtoid = 0;
                         } elseif (GETPOST('receiver') != '-1') {
                             // Recipient was provided from combo list
                             if (GETPOST('receiver') == 'thirdparty') {
                                 // Id of third party
                                 $sendto = $object->client->email;
                                 $sendtoid = 0;
                             } else {
                                 // Id du contact
                                 $sendto = $object->client->contact_get_property(GETPOST('receiver'), 'email');
                                 $sendtoid = GETPOST('receiver');
                             }
                         }
                         if (dol_strlen($sendto)) {
                             $langs->load("commercial");
                             $from = GETPOST('fromname') . ' <' . GETPOST('frommail') . '>';
                             $replyto = GETPOST('replytoname') . ' <' . GETPOST('replytomail') . '>';
                             $message = GETPOST('message');
                             $sendtocc = GETPOST('sendtocc');
                             $deliveryreceipt = GETPOST('deliveryreceipt');
                             if (GETPOST('action') == 'send') {
                                 if (dol_strlen(GETPOST('subject'))) {
                                     $subject = GETPOST('subject');
                                 } else {
                                     $subject = $langs->transnoentities('Propal') . ' ' . $object->ref;
                                 }
                                 $actiontypecode = 'AC_PROP';
                                 $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n";
                                 if ($message) {
                                     $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n";
                                     $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n";
                                     $actionmsg .= $message;
                                 }
                                 $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode);
                             }
                             // Create form object
                             include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
                             $formmail = new FormMail($db);
                             $attachedfiles = $formmail->get_attached_files();
                             $filepath = $attachedfiles['paths'];
                             $filename = $attachedfiles['names'];
                             $mimetype = $attachedfiles['mimes'];
                             // Envoi de la propal
                             require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
                             $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt);
                             if (!$mailfile->error) {
                                 $mailfile->message = stripslashes($mailfile->message);
                                 $msg_prepared = $mailfile->headers . $mailfile->eol;
                                 $msg_prepared .= $mailfile->subject . $mailfile->eol;
                                 $msg_prepared .= $mailfile->message . $mailfile->eol;
                                 $object->msg_imap_result = store_email_into_folder($msg_prepared);
                             }
                         }
                     }
                 }
                 break;
             case 'ordersuppliercard':
                 if (!GETPOST('addfile') && !GETPOST('removedfile') && !GETPOST('cancel')) {
                     $langs->load('mails');
                     $result = $object->fetch(GETPOST("id"));
                     $result = $object->fetch_thirdparty();
                     if ($result > 0) {
                         if (GETPOST('sendto')) {
                             // Le destinataire a ete fourni via le champ libre
                             $sendto = GETPOST('sendto');
                             $sendtoid = 0;
                         } elseif (GETPOST('receiver') != '-1') {
                             // Recipient was provided from combo list
                             if (GETPOST('receiver') == 'thirdparty') {
                                 // Id of third party
                                 $sendto = $object->client->email;
                                 $sendtoid = 0;
                             } else {
                                 // Id du contact
                                 $sendto = $object->client->contact_get_property(GETPOST('receiver'), 'email');
                                 $sendtoid = GETPOST('receiver');
                             }
                         }
                         if (dol_strlen($sendto)) {
                             $langs->load("commercial");
                             $from = GETPOST('fromname') . ' <' . GETPOST('frommail') . '>';
                             $replyto = GETPOST('replytoname') . ' <' . GETPOST('replytomail') . '>';
                             $message = GETPOST('message');
                             $sendtocc = GETPOST('sendtocc');
                             $deliveryreceipt = GETPOST('deliveryreceipt');
                             if ($_POST['action'] == 'send') {
                                 if (dol_strlen(GETPOST('subject'))) {
                                     $subject = GETPOST('subject');
                                 } else {
                                     $subject = $langs->transnoentities('Propal') . ' ' . $object->ref;
                                 }
                                 $actiontypecode = 'AC_PROP';
                                 $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n";
                                 if ($message) {
                                     $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n";
                                     $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n";
                                     $actionmsg .= $message;
                                 }
                                 $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode);
                             }
                             // Create form object
                             include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
                             $formmail = new FormMail($db);
                             $attachedfiles = $formmail->get_attached_files();
                             $filepath = $attachedfiles['paths'];
                             $filename = $attachedfiles['names'];
                             $mimetype = $attachedfiles['mimes'];
                             // Envoi de la propal
                             require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
                             $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt);
                             if (!$mailfile->error) {
                                 $mailfile->message = stripslashes($mailfile->message);
                                 $msg_prepared = $mailfile->headers . $mailfile->eol;
                                 $msg_prepared .= $mailfile->subject . $mailfile->eol;
                                 $msg_prepared .= $mailfile->message . $mailfile->eol;
                                 $object->msg_imap_result = store_email_into_folder($msg_prepared);
                             }
                         }
                     }
                 }
                 break;
             case 'invoicesuppliercard':
                 if (!GETPOST('addfile') && !GETPOST('removedfile') && !GETPOST('cancel')) {
                     $langs->load('mails');
                     $result = $object->fetch(GETPOST("id"));
                     $result = $object->fetch_thirdparty();
                     if ($result > 0) {
                         if (GETPOST('sendto')) {
                             // Le destinataire a ete fourni via le champ libre
                             $sendto = GETPOST('sendto');
                             $sendtoid = 0;
                         } elseif (GETPOST('receiver') != '-1') {
                             // Recipient was provided from combo list
                             if (GETPOST('receiver') == 'thirdparty') {
                                 // Id of third party
                                 $sendto = $object->client->email;
                                 $sendtoid = 0;
                             } else {
                                 // Id du contact
                                 $sendto = $object->client->contact_get_property(GETPOST('receiver'), 'email');
                                 $sendtoid = GETPOST('receiver');
                             }
                         }
                         if (dol_strlen($sendto)) {
                             $langs->load("commercial");
                             $from = GETPOST('fromname') . ' <' . GETPOST('frommail') . '>';
                             $replyto = GETPOST('replytoname') . ' <' . GETPOST('replytomail') . '>';
                             $message = GETPOST('message');
                             $sendtocc = GETPOST('sendtocc');
                             $deliveryreceipt = GETPOST('deliveryreceipt');
                             if (GETPOST('action') == 'send') {
                                 if (dol_strlen(GETPOST('subject'))) {
                                     $subject = GETPOST('subject');
                                 } else {
                                     $subject = $langs->transnoentities('Propal') . ' ' . $object->ref;
                                 }
                                 $actiontypecode = 'AC_PROP';
                                 $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n";
                                 if ($message) {
                                     $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n";
                                     $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n";
                                     $actionmsg .= $message;
                                 }
                                 $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode);
                             }
                             // Create form object
                             include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
                             $formmail = new FormMail($db);
                             $attachedfiles = $formmail->get_attached_files();
                             $filepath = $attachedfiles['paths'];
                             $filename = $attachedfiles['names'];
                             $mimetype = $attachedfiles['mimes'];
                             // Envoi de la propal
                             require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
                             $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt);
                             if (!$mailfile->error) {
                                 $mailfile->message = stripslashes($mailfile->message);
                                 $msg_prepared = $mailfile->headers . $mailfile->eol;
                                 $msg_prepared .= $mailfile->subject . $mailfile->eol;
                                 $msg_prepared .= $mailfile->message . $mailfile->eol;
                                 $object->msg_imap_result = store_email_into_folder($msg_prepared);
                             }
                         }
                     }
                 }
                 break;
         }
     }
 }
Exemple #9
0
 if (!$file || !is_readable($file)) {
     $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
     if ($result <= 0) {
         dol_print_error($db, $object->error, $object->errors);
         exit;
     }
     $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/') . '[^\\-]+');
     $file = $fileparams['fullname'];
 }
 print '<div class="clearboth"></div>';
 print '<br>';
 print load_fiche_titre($langs->trans($titreform));
 // Cree l'objet formulaire mail
 dol_fiche_head();
 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
 $formmail = new FormMail($db);
 $formmail->param['langsmodels'] = empty($newlang) ? $langs->defaultlang : $newlang;
 $formmail->fromtype = 'user';
 $formmail->fromid = $user->id;
 $formmail->fromname = $user->getFullName($langs);
 $formmail->frommail = $user->email;
 if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && $conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1) {
     $formmail->trackid = 'inv' . $object->id;
 }
 if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && $conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2) {
     include DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     $formmail->frommail = dolAddEmailTrackId($formmail->frommail, 'inv' . $object->id);
 }
 $formmail->withfrom = 1;
 $liste = array();
 foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) {
Exemple #10
0
				if (($mil->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer)
				{
					print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&amp;id='.$mil->id.'">'.$langs->trans("DeleteMailing").'</a>';
				}

				print '<br><br></div>';
			}

			// Affichage formulaire de TEST
			if ($_GET["action"] == 'test')
			{
				print_titre($langs->trans("TestMailing"));

				// Create l'objet formulaire mail
				include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
				$formmail = new FormMail($db);
				$formmail->fromname = $mil->email_from;
				$formmail->frommail = $mil->email_from;
				$formmail->withsubstit=1;
				$formmail->withfrom=0;
				$formmail->withto=$user->email?$user->email:1;
				$formmail->withtocc=0;
				$formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
				$formmail->withtopic=0;
				$formmail->withtopicreadonly=1;
				$formmail->withfile=0;
				$formmail->withbody=0;
				$formmail->withbodyreadonly=1;
				$formmail->withcancel=1;
				$formmail->withdeliveryreceipt=0;
				// Tableau des substitutions
// create data array
// loop over array of emails
foreach ($email_array as $email) {
    $messages = $messagedata[$email];
    $subject = $messages[0]->expo . " Reminder";
    $message = "Dear " . $messages[0]->workerName . ",\n\n";
    if (PARAM_ANTEREMINDER_TIME == 1) {
        $message .= "This message is to remind you that your upcoming shift assignment for " . PARAM_ANTEREMINDER_TIME . " day from now is:\n\n";
    } else {
        $message .= "This message is to remind you that your upcoming shift assignment for " . PARAM_ANTEREMINDER_TIME . " days from now is:\n\n";
    }
    $message .= "Expo: " . $messages[0]->expo . "\n\n";
    $body = $message;
    foreach ($messages as $message) {
        $body .= "Station: " . $message->station . "\n";
        $shift = explode(';', swwat_format_shift($message->startTime, $message->stopTime));
        $body .= "Time: " . $shift[0] . " (" . $shift[1] . ")\n";
    }
    // $message
    //START SIGNATURE BLOCK
    $message .= "\n\n Your participation in the conference is appreciated.";
    //    $message .= "\n\n Please notify us at zzz-xxx-yyyy if unable to make your shift.";
    $message .= "\n\n Thank you,";
    $message .= "\n\n Your " . SITE_NAME . " Team";
    // ENDIT SIGNATURE BLOCK
    FormMail::send($email, $subject, $body);
    logMessage("SendMessagesCron", "email sent to " . $email);
}
// $email
ReminderSent::insert(swwat_format_isodate($targtag));
logMessage("SendMessagesCron", "Date: " . swwat_format_isodate($targtag) . " written to database.");
Exemple #12
0
/**
 * Remove an uploaded file (for example after submitting a new file a mail form).
 * All information used are in db, conf, langs, user and _FILES.
 * @param	filenb					File nb to delete
 * @param	donotupdatesession		1=Do not edit _SESSION variable
 * @param   donotdeletefile         1=Do not delete physically file
 * @return	string					Message with result of upload and store.
 */
function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=0)
{
	global $db,$user,$conf,$langs,$_FILES;

	$mesg='';

	$keytodelete=$filenb;
	$keytodelete--;

	$listofpaths=array();
	$listofnames=array();
	$listofmimes=array();
	if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]);
	if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]);
	if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]);

	if ($keytodelete >= 0)
	{
		$pathtodelete=$listofpaths[$keytodelete];
		$filetodelete=$listofnames[$keytodelete];
		if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete,1);
		else $result=0;
		if ($result >= 0)
		{
			if (empty($donotdeletefile))
			{
			    $langs->load("other");
			    $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",$filetodelete).'</div>';
    			//print_r($_FILES);
			}
			if (empty($donotupdatesession))
			{
				include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
				$formmail = new FormMail($db);
				$formmail->remove_attached_files($keytodelete);
			}
		}
	}

	return $mesg;
}
<?php

// $Id: WorkerLoginResetAction.php 1345 2012-08-21 15:40:38Z preston $ Copyright (c) ConSked, LLC. All Rights Reserved.
include 'util/authenticate.php';
require_once 'properties/constants.php';
require_once 'db/WorkerLogin.php';
require_once 'util/log.php';
require_once 'util/mail.php';
require_once 'util/session.php';
require_once 'swwat/gizmos/parse.php';
/**
 * This Controller is used by the WorkerLoginPage's reset button (typically used by the Worker themselves)
 * vs. the WorkerViewPage's reset button (typically used by an Organizer)
 */
$email = swwat_parse_string(html_entity_decode($_POST[PARAM_EMAIL]), true);
if (is_null($email)) {
    throw new LoginException('username required');
}
try {
    $password = WorkerLogin::password_reset($email);
    FormMail::sendPasswordReset($email, $password);
    $password = NULL;
} catch (Exception $ex) {
    logMessage('WorkerLoginResetAction error', $ex->getMessage());
}
$password = NULL;
// in all cases; redirect back to Login page
header('Location: WorkerLoginPage.php');
include 'WorkerLoginPage.php';
         } else {
             print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?action=delete&amp;id=' . $object->id . (!empty($urlfrom) ? '&urlfrom=' . $urlfrom : '') . '">' . $langs->trans("DeleteMailing") . '</a>';
         }
     }
     print '<br><br></div>';
 }
 if (!empty($mesgembedded)) {
     dol_htmloutput_mesg($mesgembedded, '', 'warning', 1);
     print '<br>';
 }
 // Affichage formulaire de TEST
 if ($action == 'test') {
     print_titre($langs->trans("TestMailing"));
     // Create l'objet formulaire mail
     include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
     $formmail = new FormMail($db);
     $formmail->fromname = $object->email_from;
     $formmail->frommail = $object->email_from;
     $formmail->withsubstit = 1;
     $formmail->withfrom = 0;
     $formmail->withto = $user->email ? $user->email : 1;
     $formmail->withtocc = 0;
     $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
     $formmail->withtopic = 0;
     $formmail->withtopicreadonly = 1;
     $formmail->withfile = 0;
     $formmail->withbody = 0;
     $formmail->withbodyreadonly = 1;
     $formmail->withcancel = 1;
     $formmail->withdeliveryreceipt = 0;
     // Tableau des substitutions
Exemple #15
0
		}

		$formmail->show_form('addfile','removefile');

		print '<br>';
	}

	// Affichage formulaire de TEST HTML
	if ($_GET["action"] == 'testhtml')
	{
		print '<br>';
		print_titre($langs->trans("DoTestSendHTML"));

		// Cree l'objet formulaire mail
		include_once(DOL_DOCUMENT_ROOT."/core/class/html.formmail.class.php");
		$formmail = new FormMail($db);
		$formmail->fromname = (isset($_POST['fromname'])?$_POST['fromname']:$conf->global->MAIN_MAIL_EMAIL_FROM);
		$formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM);
		$formmail->withfromreadonly=0;
		$formmail->withsubstit=0;
		$formmail->withfrom=1;
		$formmail->witherrorsto=1;
		$formmail->withto=(! empty($_POST['sendto'])?$_POST['sendto']:($user->email?$user->email:1));
        $formmail->withtocc=(! empty($_POST['sendtocc'])?$_POST['sendtocc']:1);       // ! empty to keep field if empty
        $formmail->withtoccc=(! empty($_POST['sendtoccc'])?$_POST['sendtoccc']:1);    // ! empty to keep field if empty
		$formmail->withtopic=(isset($_POST['subject'])?$_POST['subject']:$langs->trans("Test"));
		$formmail->withtopicreadonly=0;
		$formmail->withfile=2;
		$formmail->withbody=(isset($_POST['message'])?$_POST['message']:$langs->trans("PredefinedMailTestHtml"));
		//$formmail->withbody='Test <b>aaa</b> __LOGIN__';
		$formmail->withbodyreadonly=0;
Exemple #16
0
     $formactions = new FormActions($db);
     $somethingshown = $formactions->showactions($object, 'shipping', $socid);
     print '</td></tr></table>';
 }
 /*
  * Action presend
  *
  */
 if ($action == 'presend') {
     $ref = dol_sanitizeFileName($object->ref);
     $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf';
     print '<br>';
     print_titre($langs->trans('SendShippingByEMail'));
     // Cree l'objet formulaire mail
     include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
     $formmail = new FormMail($db);
     $formmail->fromtype = 'user';
     $formmail->fromid = $user->id;
     $formmail->fromname = $user->getFullName($langs);
     $formmail->frommail = $user->email;
     $formmail->withfrom = 1;
     $formmail->withto = empty($_POST["sendto"]) ? 1 : $_POST["sendto"];
     $formmail->withtosocid = $soc->id;
     $formmail->withtocc = 1;
     $formmail->withtoccsocid = 0;
     $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
     $formmail->withtocccsocid = 0;
     $formmail->withtopic = $langs->trans('SendShippingRef', '__SHIPPINGREF__');
     $formmail->withfile = 2;
     $formmail->withbody = 1;
     $formmail->withdeliveryreceipt = 1;
/**
 * Remove an uploaded file (for example after submitting a new file a mail form).
 * All information used are in db, conf, langs, user and _FILES.
 *
 * @param	int		$filenb					File nb to delete
 * @param	int		$donotupdatesession		1=Do not edit _SESSION variable
 * @param   int		$donotdeletefile        1=Do not delete physically file
 * @return	void
 */
function dol_remove_file_process($filenb, $donotupdatesession = 0, $donotdeletefile = 1)
{
    global $db, $user, $conf, $langs, $_FILES;
    $keytodelete = $filenb;
    $keytodelete--;
    $listofpaths = array();
    $listofnames = array();
    $listofmimes = array();
    if (!empty($_SESSION["listofpaths"])) {
        $listofpaths = explode(';', $_SESSION["listofpaths"]);
    }
    if (!empty($_SESSION["listofnames"])) {
        $listofnames = explode(';', $_SESSION["listofnames"]);
    }
    if (!empty($_SESSION["listofmimes"])) {
        $listofmimes = explode(';', $_SESSION["listofmimes"]);
    }
    if ($keytodelete >= 0) {
        $pathtodelete = $listofpaths[$keytodelete];
        $filetodelete = $listofnames[$keytodelete];
        if (empty($donotdeletefile)) {
            $result = dol_delete_file($pathtodelete, 1);
        } else {
            $result = 0;
        }
        if ($result >= 0) {
            if (empty($donotdeletefile)) {
                $langs->load("other");
                setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
            }
            if (empty($donotupdatesession)) {
                include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
                $formmail = new FormMail($db);
                $formmail->remove_attached_files($keytodelete);
            }
        }
    }
}
 $deliveryreceipt = $_POST['deliveryreceipt'];
 if ($action == 'send' || $action == 'relance') {
     if (dol_strlen($_POST['subject'])) {
         $subject = $_POST['subject'];
     }
     $actionmsg2 = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n";
     if ($message) {
         $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n";
         $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n";
         $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n";
         $actionmsg .= $message;
     }
 }
 // Create form object
 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
 $formmail = new FormMail($db);
 $attachedfiles = $formmail->get_attached_files();
 $filepath = $attachedfiles['paths'];
 $filename = $attachedfiles['names'];
 $mimetype = $attachedfiles['mimes'];
 // Send mail
 require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
 $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
 if ($mailfile->error) {
     $mesgs[] = '<div class="error">' . $mailfile->error . '</div>';
 } else {
     $result = $mailfile->sendfile();
     if ($result) {
         $error = 0;
         // Initialisation donnees
         $object->socid = $sendtosocid;
        logMessage("RegistrationAction", "delete registration for worker:{$worker->workerid} failure " . $ex->getMessage());
        // but ignore and continue
    }
}
// $registration
$expoArray = array();
try {
    $expoArray = Expo::selectMultiple();
} catch (PDOException $ex) {
    logMessage("RegistrationAction", "selecting expo list " . $ex->getMessage());
    // but ignore and continue
}
foreach ($expoArray as $expo) {
    if ($expo->newUserAddedOnRegistration && !$expo->isPast()) {
        if (!$worker->isAssignedToExpo($expo->expoid)) {
            try {
                $worker->assignToExpo($expo->expoid);
            } catch (PDOException $ex) {
                logMessage("RegistrationAction", "assign worker:{$worker->workerid} failure " . $ex->getMessage());
                // but ignore and continue
            }
        }
    }
}
//Send out a confirmation e-mail
$welcomeForm = new FormMail(SITE_NAME . " Registration Confirmation", array("FIRSTNAME", "LOGINURL"), "Hello FIRSTNAME,\nWelcome to " . SITE_NAME . "!\n\n" . "If you forget your password, simply enter your e-mail address on the login page and click the \"Reset Password\" button.\n\n" . "Login Page: LOGINURL." . "\n\nSincerely,\nThe " . SITE_NAME . " Team");
$welcomeForm->sendForm($worker->email, array("FIRSTNAME" => $worker->firstName, "LOGINURL" => LOGIN_URL));
$_SESSION[AUTHENTICATED_TEMP] = $worker;
$_SESSION[AUTHENTICATED] = $worker;
header('Location: WorkerLoginChangePage.php');
include 'WorkerLoginChangePage.php';