2012-08-22 23:27:53 +02:00
< ? php
2012-03-23 20:03:57 +01:00
/* Copyright ( C ) 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2024-01-14 12:26:37 +01:00
* Copyright ( C ) 2005 - 2019 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2016 Regis Houssin < regis . houssin @ inodbox . com >
2021-05-08 09:20:59 +02:00
* Copyright ( C ) 2021 Waël Almoman < info @ almoman . com >
2024-09-05 16:05:37 +02:00
* Copyright ( C ) 2024 MDW < mdeweerd @ users . noreply . github . com >
* Copyright ( C ) 2024 Frédéric France < frederic . france @ free . fr >
2005-01-05 16:26:05 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2005-01-05 16:26:05 +01:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2005-01-05 16:26:05 +01:00
*/
2005-04-07 01:49:06 +02:00
/**
2014-09-18 21:18:25 +02:00
* \file htdocs / comm / mailing / card . php
2009-04-05 22:14:49 +02:00
* \ingroup mailing
2009-05-16 18:51:09 +02:00
* \brief Fiche mailing , onglet general
2009-04-05 22:14:49 +02:00
*/
2005-01-14 20:24:00 +01:00
2020-11-27 20:20:04 +01:00
if ( ! defined ( 'NOSTYLECHECK' )) {
define ( 'NOSTYLECHECK' , '1' );
}
2013-03-24 19:00:58 +01:00
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/emailing.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/mailing.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2016-03-05 12:20:58 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2005-01-05 16:26:05 +01:00
2024-11-04 23:53:20 +01:00
/**
* @ var Conf $conf
* @ var DoliDB $db
* @ var HookManager $hookmanager
* @ var Translate $langs
* @ var User $user
*/
2018-05-26 20:32:23 +02:00
// Load translation files required by the page
2023-04-23 21:45:47 +02:00
$langs -> loadLangs ( array ( " mails " , " admin " ));
2005-01-14 20:24:00 +01:00
Fix: GETPOST(...,'int') to GETPOSTINT(...) (#28448)
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: Update spelling exceptions
* Qual: Ignore Phan Notice
2024-02-27 14:05:53 +01:00
$id = ( GETPOSTINT ( 'mailid' ) ? GETPOSTINT ( 'mailid' ) : GETPOSTINT ( 'id' ));
2023-02-21 13:37:27 +01:00
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2020-04-10 10:59:32 +02:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
2023-02-21 13:37:27 +01:00
$cancel = GETPOST ( 'cancel' , 'aZ09' );
2020-04-10 10:59:32 +02:00
$urlfrom = GETPOST ( 'urlfrom' );
2023-04-08 13:29:30 +02:00
$backtopageforcancel = GETPOST ( 'backtopageforcancel' );
2012-06-14 20:08:46 +02:00
2024-06-30 21:02:50 +02:00
// Initialize a technical objects
2020-04-10 10:59:32 +02:00
$object = new Mailing ( $db );
2023-02-21 13:37:27 +01:00
$extrafields = new ExtraFields ( $db );
2023-04-08 13:29:30 +02:00
$hookmanager -> initHooks ( array ( 'mailingcard' , 'globalcard' ));
2012-03-23 20:03:57 +01:00
2023-02-21 13:37:27 +01:00
// Fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2013-04-01 19:43:26 +02:00
2023-04-08 13:29:30 +02:00
// Load object
2024-06-30 21:02:50 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php' ; // Must be 'include', not 'include_once'.
2012-03-23 20:03:57 +01:00
2014-05-17 19:02:47 +02:00
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
2019-11-13 19:35:39 +01:00
$object -> substitutionarray = FormMail :: getAvailableSubstitKey ( 'emailing' );
2017-09-22 14:34:31 +02:00
// Set $object->substitutionarrayfortest
2023-11-27 11:39:32 +01:00
$signature = (( ! empty ( $user -> signature ) && ! getDolGlobalString ( 'MAIN_MAIL_DO_NOT_USE_SIGN' )) ? $user -> signature : '' );
2017-09-22 14:34:31 +02:00
2019-11-13 19:35:39 +01:00
$targetobject = null ; // Not defined with mass emailing
2017-09-22 14:34:31 +02:00
2024-03-11 12:58:51 +01:00
$parameters = array ( 'mode' => 'emailing' );
2019-11-13 19:35:39 +01:00
$substitutionarray = FormMail :: getAvailableSubstitKey ( 'emailing' , $targetobject );
2017-09-22 14:34:31 +02:00
$object -> substitutionarrayfortest = $substitutionarray ;
2013-11-16 13:00:21 +01:00
2014-11-29 13:50:41 +01:00
// List of sending methods
2019-11-13 19:35:39 +01:00
$listofmethods = array ();
2023-04-23 21:42:05 +02:00
//$listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup');
2019-11-13 19:35:39 +01:00
$listofmethods [ 'mail' ] = 'PHP mail function' ;
2023-04-23 21:42:05 +02:00
//$listofmethods['simplemail']='Simplemail class';
2019-11-13 19:35:39 +01:00
$listofmethods [ 'smtps' ] = 'SMTP/SMTPS socket library' ;
2023-04-23 21:42:05 +02:00
if ( version_compare ( phpversion (), '7.0' , '>=' )) {
$listofmethods [ 'swiftmailer' ] = 'Swift Mailer socket library' ;
}
2014-11-29 13:50:41 +01:00
2021-03-29 22:43:39 +02:00
// Security check
2023-11-27 11:39:32 +01:00
if ( ! $user -> hasRight ( 'mailing' , 'lire' ) || ( ! getDolGlobalString ( 'EXTERNAL_USERS_ARE_AUTHORIZED' ) && $user -> socid > 0 )) {
2021-03-29 22:43:39 +02:00
accessforbidden ();
}
2023-04-08 17:16:22 +02:00
if ( empty ( $action ) && empty ( $object -> id )) {
accessforbidden ( 'Object not found' );
}
2014-11-29 13:50:41 +01:00
2022-10-23 20:45:27 +02:00
$upload_dir = $conf -> mailing -> dir_output . " / " . get_exdir ( $object -> id , 2 , 0 , 1 , $object , 'mailing' );
2024-04-04 19:47:19 +02:00
//$permissiontoread = $user->hasRight('maling', 'read');
$permissiontocreate = $user -> hasRight ( 'mailing' , 'creer' );
$permissiontovalidatesend = $user -> hasRight ( 'mailing' , 'valider' );
$permissiontodelete = $user -> hasRight ( 'mailing' , 'supprimer' );
2005-01-14 20:24:00 +01:00
2012-06-15 11:20:09 +02:00
/*
* Actions
2012-06-13 09:26:29 +02:00
*/
2019-11-13 19:35:39 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2020-11-27 20:20:04 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2012-06-13 09:26:29 +02:00
2020-11-27 20:20:04 +01:00
if ( empty ( $reshook )) {
2023-02-20 19:32:15 +01:00
$error = 0 ;
$backurlforlist = DOL_URL_ROOT . '/comm/mailing/list.php' ;
if ( empty ( $backtopage ) || ( $cancel && empty ( $id ))) {
if ( empty ( $backtopage ) || ( $cancel && strpos ( $backtopage , '__ID__' ))) {
if ( empty ( $id ) && (( $action != 'add' && $action != 'create' ) || $cancel )) {
$backtopage = $backurlforlist ;
} else {
$backtopage = DOL_URL_ROOT . '/comm/mailing/card.php?id=' . (( ! empty ( $id ) && $id > 0 ) ? $id : '__ID__' );
}
}
}
if ( $cancel ) {
/*var_dump($cancel);var_dump($backtopage);var_dump($backtopageforcancel);exit;*/
if ( ! empty ( $backtopageforcancel )) {
header ( " Location: " . $backtopageforcancel );
exit ;
} elseif ( ! empty ( $backtopage )) {
header ( " Location: " . $backtopage );
exit ;
}
$action = '' ;
}
2015-01-17 19:28:27 +01:00
// Action clone object
2024-04-04 19:47:19 +02:00
if ( $action == 'confirm_clone' && $confirm == 'yes' && $permissiontocreate ) {
2020-11-27 20:20:04 +01:00
if ( ! GETPOST ( " clone_content " , 'alpha' ) && ! GETPOST ( " clone_receivers " , 'alpha' )) {
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> trans ( " NoCloneOptionsSpecified " ), null , 'errors' );
2020-05-21 15:05:19 +02:00
} else {
2020-04-03 02:29:10 +02:00
$result = $object -> createFromClone ( $user , $object -> id , GETPOST ( " clone_content " , 'alpha' ), GETPOST ( " clone_receivers " , 'alpha' ));
2020-11-27 20:20:04 +01:00
if ( $result > 0 ) {
2015-01-17 19:28:27 +01:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . '?id=' . $result );
exit ;
2020-05-21 15:05:19 +02:00
} else {
2015-11-06 09:36:16 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-01-17 19:28:27 +01:00
}
2008-11-20 22:30:23 +01:00
}
2020-10-31 14:32:18 +01:00
$action = '' ;
2008-11-10 15:20:02 +01:00
}
2015-01-17 19:28:27 +01:00
// Action send emailing for everybody
2024-04-04 19:47:19 +02:00
if ( $action == 'sendallconfirmed' && $confirm == 'yes' && $permissiontovalidatesend ) {
2023-11-27 11:39:32 +01:00
if ( ! getDolGlobalString ( 'MAILING_LIMIT_SENDBYWEB' )) {
2015-02-15 15:01:28 +01:00
// As security measure, we don't allow send from the GUI
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> trans ( " MailingNeedCommand " ), null , 'warnings' );
setEventMessages ( '<textarea cols="70" rows="' . ROWS_2 . '" wrap="soft">php ./scripts/emailings/mailing-send.php ' . $object -> id . '</textarea>' , null , 'warnings' );
setEventMessages ( $langs -> trans ( " MailingNeedCommand2 " ), null , 'warnings' );
2019-11-13 19:35:39 +01:00
$action = '' ;
2023-11-27 12:24:18 +01:00
} elseif ( getDolGlobalInt ( 'MAILING_LIMIT_SENDBYWEB' ) < 0 ) {
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> trans ( " NotEnoughPermissions " ), null , 'warnings' );
2019-11-13 19:35:39 +01:00
$action = '' ;
2020-05-21 15:05:19 +02:00
} else {
2024-02-09 15:58:49 +01:00
if ( $object -> status == 0 ) {
2024-01-20 09:22:38 +01:00
dol_print_error ( null , 'ErrorMailIsNotValidated' );
2015-01-17 19:28:27 +01:00
exit ;
}
2012-04-05 21:02:00 +02:00
2015-01-17 19:28:27 +01:00
$id = $object -> id ;
$subject = $object -> sujet ;
$message = $object -> body ;
$from = $object -> email_from ;
2021-02-23 18:59:19 +01:00
$replyto = $object -> email_replyto ;
2015-01-17 19:28:27 +01:00
$errorsto = $object -> email_errorsto ;
2020-10-14 18:26:05 +02:00
// Is the message in html
2019-11-13 19:35:39 +01:00
$msgishtml = - 1 ; // Unknown by default
2020-11-27 20:20:04 +01:00
if ( preg_match ( '/[\s\t]*<html>/i' , $message )) {
$msgishtml = 1 ;
}
2015-01-17 19:28:27 +01:00
// Warning, we must not use begin-commit transaction here
// because we want to save update for each mail sent.
2023-12-04 12:01:45 +01:00
$nbok = 0 ;
$nbko = 0 ;
2015-01-17 19:28:27 +01:00
2020-10-14 18:26:05 +02:00
// We choose mails not already sent for this mailing (statut=0)
// or sent in error (statut=-1)
2017-11-21 11:15:33 +01:00
$sql = " SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag " ;
2015-01-17 19:28:27 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " mailing_cibles as mc " ;
2021-03-30 17:53:25 +02:00
$sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = " . (( int ) $object -> id );
2019-11-13 19:35:39 +01:00
$sql .= " ORDER BY mc.statut DESC " ; // first status 0, then status -1
2015-01-17 19:28:27 +01:00
2015-01-18 17:13:42 +01:00
dol_syslog ( " card.php: select targets " , LOG_DEBUG );
2019-11-13 19:35:39 +01:00
$resql = $db -> query ( $sql );
2020-11-27 20:20:04 +01:00
if ( $resql ) {
2020-10-14 18:26:05 +02:00
$num = $db -> num_rows ( $resql ); // Number of possible recipients
2008-08-04 01:45:53 +02:00
2020-11-27 20:20:04 +01:00
if ( $num ) {
2015-01-18 17:13:42 +01:00
dol_syslog ( " comm/mailing/card.php: nb of targets = " . $num , LOG_DEBUG );
2009-01-25 23:04:55 +01:00
2019-11-13 19:35:39 +01:00
$now = dol_now ();
2009-01-25 23:04:55 +01:00
2020-10-14 18:26:05 +02:00
// Positioning date of start sending
2021-08-27 16:33:03 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " mailing SET date_envoi=' " . $db -> idate ( $now ) . " ' WHERE rowid= " . (( int ) $object -> id );
2019-11-13 19:35:39 +01:00
$resql2 = $db -> query ( $sql );
2020-11-27 20:20:04 +01:00
if ( ! $resql2 ) {
2015-01-17 19:28:27 +01:00
dol_print_error ( $db );
2010-04-17 15:23:50 +02:00
}
2021-05-11 20:30:57 +02:00
$thirdpartystatic = new Societe ( $db );
2015-01-17 19:28:27 +01:00
// Loop on each email and send it
2023-02-25 04:05:18 +01:00
$iforemailloop = 0 ;
2009-01-25 23:04:55 +01:00
2023-02-25 04:05:18 +01:00
while ( $iforemailloop < $num && $iforemailloop < $conf -> global -> MAILING_LIMIT_SENDBYWEB ) {
2017-09-15 13:43:16 +02:00
// Here code is common with same loop ino mailing-send.php
2019-11-13 19:35:39 +01:00
$res = 1 ;
$now = dol_now ();
2015-01-17 19:28:27 +01:00
$obj = $db -> fetch_object ( $resql );
// sendto en RFC2822
2019-01-27 11:55:16 +01:00
$sendto = str_replace ( ',' , ' ' , dolGetFirstLastname ( $obj -> firstname , $obj -> lastname )) . " < " . $obj -> email . " > " ;
2015-01-17 19:28:27 +01:00
// Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ...
2019-11-13 19:35:39 +01:00
$other = explode ( ';' , $obj -> other );
2023-12-04 12:01:45 +01:00
$tmpfield = explode ( '=' , $other [ 0 ], 2 );
$other1 = ( isset ( $tmpfield [ 1 ]) ? $tmpfield [ 1 ] : $tmpfield [ 0 ]);
$tmpfield = explode ( '=' , $other [ 1 ], 2 );
$other2 = ( isset ( $tmpfield [ 1 ]) ? $tmpfield [ 1 ] : $tmpfield [ 0 ]);
$tmpfield = explode ( '=' , $other [ 2 ], 2 );
$other3 = ( isset ( $tmpfield [ 1 ]) ? $tmpfield [ 1 ] : $tmpfield [ 0 ]);
$tmpfield = explode ( '=' , $other [ 3 ], 2 );
$other4 = ( isset ( $tmpfield [ 1 ]) ? $tmpfield [ 1 ] : $tmpfield [ 0 ]);
$tmpfield = explode ( '=' , $other [ 4 ], 2 );
$other5 = ( isset ( $tmpfield [ 1 ]) ? $tmpfield [ 1 ] : $tmpfield [ 0 ]);
2017-09-22 14:34:31 +02:00
2023-11-27 11:39:32 +01:00
$signature = (( ! empty ( $user -> signature ) && ! getDolGlobalString ( 'MAIN_MAIL_DO_NOT_USE_SIGN' )) ? $user -> signature : '' );
2016-02-08 12:20:40 +01:00
2024-03-11 12:58:51 +01:00
$parameters = array ( 'mode' => 'emailing' );
2020-10-31 14:32:18 +01:00
$substitutionarray = getCommonSubstitutionArray ( $langs , 0 , array ( 'object' , 'objectamount' ), $targetobject ); // Note: On mass emailing, this is null because be don't know object
2017-09-22 14:34:31 +02:00
2020-10-31 14:32:18 +01:00
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
2017-09-22 14:34:31 +02:00
$substitutionarray [ '__ID__' ] = $obj -> source_id ;
2021-05-11 12:33:35 +02:00
if ( $obj -> source_type == " thirdparty " ) {
2021-05-11 20:30:57 +02:00
$result = $thirdpartystatic -> fetch ( $obj -> source_id );
2021-05-11 12:33:35 +02:00
2021-05-11 20:30:57 +02:00
if ( $result > 0 ) {
$substitutionarray [ '__THIRDPARTY_CUSTOMER_CODE__' ] = $thirdpartystatic -> code_client ;
2022-01-11 13:31:16 +01:00
} else {
$substitutionarray [ '__THIRDPARTY_CUSTOMER_CODE__' ] = '' ;
2021-05-11 20:30:57 +02:00
}
2021-05-11 12:33:35 +02:00
}
2017-09-22 14:34:31 +02:00
$substitutionarray [ '__EMAIL__' ] = $obj -> email ;
$substitutionarray [ '__LASTNAME__' ] = $obj -> lastname ;
$substitutionarray [ '__FIRSTNAME__' ] = $obj -> firstname ;
$substitutionarray [ '__MAILTOEMAIL__' ] = '<a href="mailto:' . $obj -> email . '">' . $obj -> email . '</a>' ;
$substitutionarray [ '__OTHER1__' ] = $other1 ;
$substitutionarray [ '__OTHER2__' ] = $other2 ;
$substitutionarray [ '__OTHER3__' ] = $other3 ;
$substitutionarray [ '__OTHER4__' ] = $other4 ;
$substitutionarray [ '__OTHER5__' ] = $other5 ;
2019-11-13 19:35:39 +01:00
$substitutionarray [ '__USER_SIGNATURE__' ] = $signature ; // Signature is empty when ran from command line or taken from user in parameter)
2022-09-10 15:55:36 +02:00
$substitutionarray [ '__SENDEREMAIL_SIGNATURE__' ] = $signature ; // Signature is empty when ran from command line or taken from user in parameter)
2023-06-09 11:53:39 +02:00
$substitutionarray [ '__CHECK_READ__' ] = '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . urlencode ( $obj -> tag ) . '&securitykey=' . dol_hash ( getDolGlobalString ( 'MAILING_EMAIL_UNSUBSCRIBE_KEY' ) . '-' . $obj -> tag . '-' . $obj -> email . '-' . $obj -> rowid , " md5 " ) . '&email=' . urlencode ( $obj -> email ) . '&mtid=' . (( int ) $obj -> rowid ) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>' ;
$substitutionarray [ '__UNSUBSCRIBE__' ] = '<a href="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-unsubscribe.php?tag=' . urlencode ( $obj -> tag ) . '&unsuscrib=1&securitykey=' . dol_hash ( getDolGlobalString ( 'MAILING_EMAIL_UNSUBSCRIBE_KEY' ) . '-' . $obj -> tag . '-' . $obj -> email . '-' . $obj -> rowid , " md5 " ) . '&email=' . urlencode ( $obj -> email ) . '&mtid=' . (( int ) $obj -> rowid ) . '" target="_blank" rel="noopener noreferrer">' . $langs -> trans ( " MailUnsubcribe " ) . '</a>' ;
$substitutionarray [ '__UNSUBSCRIBE_URL__' ] = DOL_MAIN_URL_ROOT . '/public/emailing/mailing-unsubscribe.php?tag=' . urlencode ( $obj -> tag ) . '&unsuscrib=1&securitykey=' . dol_hash ( getDolGlobalString ( 'MAILING_EMAIL_UNSUBSCRIBE_KEY' ) . '-' . $obj -> tag . '-' . $obj -> email . '-' . $obj -> rowid , " md5 " ) . '&email=' . urlencode ( $obj -> email ) . '&mtid=' . (( int ) $obj -> rowid );
2017-09-22 14:34:31 +02:00
2017-09-15 13:43:16 +02:00
$onlinepaymentenabled = 0 ;
2022-09-25 21:58:40 +02:00
if ( isModEnabled ( 'paypal' )) {
2020-11-27 20:20:04 +01:00
$onlinepaymentenabled ++ ;
}
2022-09-25 21:58:40 +02:00
if ( isModEnabled ( 'paybox' )) {
2020-11-27 20:20:04 +01:00
$onlinepaymentenabled ++ ;
}
2022-09-25 21:58:40 +02:00
if ( isModEnabled ( 'stripe' )) {
2020-11-27 20:20:04 +01:00
$onlinepaymentenabled ++ ;
}
2023-11-27 11:39:32 +01:00
if ( $onlinepaymentenabled && getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN' )) {
2021-05-04 00:58:29 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/payments.lib.php' ;
2021-05-04 21:57:59 +02:00
$substitutionarray [ '__ONLINEPAYMENTLINK_MEMBER__' ] = getHtmlOnlinePaymentLink ( 'member' , $obj -> source_id );
$substitutionarray [ '__ONLINEPAYMENTLINK_DONATION__' ] = getHtmlOnlinePaymentLink ( 'donation' , $obj -> source_id );
$substitutionarray [ '__ONLINEPAYMENTLINK_ORDER__' ] = getHtmlOnlinePaymentLink ( 'order' , $obj -> source_id );
$substitutionarray [ '__ONLINEPAYMENTLINK_INVOICE__' ] = getHtmlOnlinePaymentLink ( 'invoice' , $obj -> source_id );
$substitutionarray [ '__ONLINEPAYMENTLINK_CONTRACTLINE__' ] = getHtmlOnlinePaymentLink ( 'contractline' , $obj -> source_id );
2021-05-04 00:58:29 +02:00
2024-09-05 16:05:37 +02:00
$substitutionarray [ '__SECUREKEYPAYMENT__' ] = dol_hash ( getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN' ), '2' );
2023-11-27 11:39:32 +01:00
if ( ! getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN_UNIQUE' )) {
2024-09-05 16:05:37 +02:00
$substitutionarray [ '__SECUREKEYPAYMENT_MEMBER__' ] = dol_hash ( getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN' ), '2' );
$substitutionarray [ '__SECUREKEYPAYMENT_DONATION__' ] = dol_hash ( getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN' ), '2' );
$substitutionarray [ '__SECUREKEYPAYMENT_ORDER__' ] = dol_hash ( getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN' ), '2' );
$substitutionarray [ '__SECUREKEYPAYMENT_INVOICE__' ] = dol_hash ( getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN' ), '2' );
$substitutionarray [ '__SECUREKEYPAYMENT_CONTRACTLINE__' ] = dol_hash ( getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN' ), '2' );
2020-05-21 15:05:19 +02:00
} else {
2024-09-05 16:05:37 +02:00
$substitutionarray [ '__SECUREKEYPAYMENT_MEMBER__' ] = dol_hash ( getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN' ) . 'member' . $obj -> source_id , '2' );
$substitutionarray [ '__SECUREKEYPAYMENT_DONATION__' ] = dol_hash ( getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN' ) . 'donation' . $obj -> source_id , '2' );
$substitutionarray [ '__SECUREKEYPAYMENT_ORDER__' ] = dol_hash ( getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN' ) . 'order' . $obj -> source_id , '2' );
$substitutionarray [ '__SECUREKEYPAYMENT_INVOICE__' ] = dol_hash ( getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN' ) . 'invoice' . $obj -> source_id , '2' );
$substitutionarray [ '__SECUREKEYPAYMENT_CONTRACTLINE__' ] = dol_hash ( getDolGlobalString ( 'PAYMENT_SECURITY_TOKEN' ) . 'contractline' . $obj -> source_id , '2' );
2017-09-22 14:34:31 +02:00
}
2017-09-15 13:43:16 +02:00
}
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MEMBER_ENABLE_PUBLIC' )) {
2022-08-28 13:47:36 +02:00
$substitutionarray [ '__PUBLICLINK_NEWMEMBERFORM__' ] = '<a target="_blank" rel="noopener noreferrer" href="' . DOL_MAIN_URL_ROOT . '/public/members/new.php' . (( isModEnabled ( 'multicompany' )) ? '?entity=' . $conf -> entity : '' ) . '">' . $langs -> trans ( 'BlankSubscriptionForm' ) . '</a>' ;
2021-05-07 17:09:59 +02:00
}
2018-05-12 11:23:40 +02:00
/* For backward compatibility, deprecated */
2023-11-27 11:39:32 +01:00
if ( isModEnabled ( 'paypal' ) && getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN' )) {
2024-09-05 16:05:37 +02:00
$substitutionarray [ '__SECUREKEYPAYPAL__' ] = dol_hash ( getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN' ), '2' );
2016-03-05 12:20:58 +01:00
2023-11-27 11:39:32 +01:00
if ( ! getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN_UNIQUE' )) {
2024-09-05 16:05:37 +02:00
$substitutionarray [ '__SECUREKEYPAYPAL_MEMBER__' ] = dol_hash ( getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN' ), '2' );
2020-11-27 20:20:04 +01:00
} else {
2024-09-05 16:05:37 +02:00
$substitutionarray [ '__SECUREKEYPAYPAL_MEMBER__' ] = dol_hash ( getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN' ) . 'membersubscription' . $obj -> source_id , '2' );
2020-11-27 20:20:04 +01:00
}
2016-03-05 12:20:58 +01:00
2023-11-27 11:39:32 +01:00
if ( ! getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN_UNIQUE' )) {
2024-09-05 16:05:37 +02:00
$substitutionarray [ '__SECUREKEYPAYPAL_ORDER__' ] = dol_hash ( getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN' ), '2' );
2020-11-27 20:20:04 +01:00
} else {
2024-09-05 16:05:37 +02:00
$substitutionarray [ '__SECUREKEYPAYPAL_ORDER__' ] = dol_hash ( getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN' ) . 'order' . $obj -> source_id , '2' );
2020-11-27 20:20:04 +01:00
}
2017-06-07 16:44:04 +02:00
2023-11-27 11:39:32 +01:00
if ( ! getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN_UNIQUE' )) {
2024-09-05 16:05:37 +02:00
$substitutionarray [ '__SECUREKEYPAYPAL_INVOICE__' ] = dol_hash ( getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN' ), '2' );
2020-11-27 20:20:04 +01:00
} else {
2024-09-05 16:05:37 +02:00
$substitutionarray [ '__SECUREKEYPAYPAL_INVOICE__' ] = dol_hash ( getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN' ) . 'invoice' . $obj -> source_id , '2' );
2020-11-27 20:20:04 +01:00
}
2017-06-07 16:44:04 +02:00
2023-11-27 11:39:32 +01:00
if ( ! getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN_UNIQUE' )) {
2024-09-05 16:05:37 +02:00
$substitutionarray [ '__SECUREKEYPAYPAL_CONTRACTLINE__' ] = dol_hash ( getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN' ), '2' );
2020-11-27 20:20:04 +01:00
} else {
2024-09-05 16:05:37 +02:00
$substitutionarray [ '__SECUREKEYPAYPAL_CONTRACTLINE__' ] = dol_hash ( getDolGlobalString ( 'PAYPAL_SECURITY_TOKEN' ) . 'contractline' . $obj -> source_id , '2' );
2020-11-27 20:20:04 +01:00
}
2015-01-17 19:28:27 +01:00
}
2017-04-17 13:02:40 +02:00
//$substitutionisok=true;
2017-09-22 14:34:31 +02:00
2020-10-31 14:32:18 +01:00
complete_substitutions_array ( $substitutionarray , $langs );
2019-11-13 19:35:39 +01:00
$newsubject = make_substitutions ( $subject , $substitutionarray );
2021-05-07 09:19:44 +02:00
$newmessage = make_substitutions ( $message , $substitutionarray , null , 0 );
$moreinheader = '' ;
2023-02-23 20:40:46 +01:00
if ( preg_match ( '/__UNSUBSCRIBE_(_|URL_)/' , $message )) {
2021-05-12 09:21:28 +02:00
$moreinheader = " List-Unsubscribe: <__UNSUBSCRIBE_URL__> \n " ;
$moreinheader = make_substitutions ( $moreinheader , $substitutionarray );
2021-05-07 09:19:44 +02:00
}
2015-01-17 19:28:27 +01:00
$arr_file = array ();
$arr_mime = array ();
$arr_name = array ();
$arr_css = array ();
2019-11-13 19:35:39 +01:00
$listofpaths = dol_dir_list ( $upload_dir , 'all' , 0 , '' , '' , 'name' , SORT_ASC , 0 );
2020-11-27 20:20:04 +01:00
if ( count ( $listofpaths )) {
foreach ( $listofpaths as $key => $val ) {
2019-11-13 19:35:39 +01:00
$arr_file [] = $listofpaths [ $key ][ 'fullname' ];
$arr_mime [] = dol_mimetype ( $listofpaths [ $key ][ 'name' ]);
$arr_name [] = $listofpaths [ $key ][ 'name' ];
2015-01-17 19:28:27 +01:00
}
}
2009-01-25 23:04:55 +01:00
2020-10-14 18:26:05 +02:00
// Mail making
2019-11-13 19:35:39 +01:00
$trackid = 'emailing-' . $obj -> fk_mailing . '-' . $obj -> rowid ;
2022-10-23 20:45:27 +02:00
$upload_dir_tmp = $upload_dir ;
2024-04-04 18:49:31 +02:00
$mail = new CMailFile ( $newsubject , $sendto , $from , $newmessage , $arr_file , $arr_mime , $arr_name , '' , '' , 0 , $msgishtml , $errorsto , $arr_css , $trackid , $moreinheader , 'emailing' , $replyto , $upload_dir_tmp );
2009-01-25 23:04:55 +01:00
2020-11-27 20:20:04 +01:00
if ( $mail -> error ) {
2019-11-13 19:35:39 +01:00
$res = 0 ;
2015-01-17 19:28:27 +01:00
}
2017-04-17 13:02:40 +02:00
/* if ( ! $substitutionisok )
2015-01-17 19:28:27 +01:00
{
$mail -> error = 'Some substitution failed' ;
$res = 0 ;
2017-04-17 13:02:40 +02:00
} */
2008-02-29 17:26:38 +01:00
2015-01-17 19:28:27 +01:00
// Send mail
2020-11-27 20:20:04 +01:00
if ( $res ) {
2019-11-13 19:35:39 +01:00
$res = $mail -> sendfile ();
2009-05-06 15:39:43 +02:00
}
2015-01-17 19:28:27 +01:00
2020-11-27 20:20:04 +01:00
if ( $res ) {
2015-01-17 19:28:27 +01:00
// Mail successful
$nbok ++ ;
2012-04-05 21:02:00 +02:00
2023-02-25 04:05:18 +01:00
dol_syslog ( " comm/mailing/card.php: ok for # " . $iforemailloop . ( $mail -> error ? ' - ' . $mail -> error : '' ), LOG_DEBUG );
2012-04-05 21:02:00 +02:00
2019-11-13 19:35:39 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " mailing_cibles " ;
2021-04-25 15:55:36 +02:00
$sql .= " SET statut=1, date_envoi = ' " . $db -> idate ( $now ) . " ' WHERE rowid= " . (( int ) $obj -> rowid );
2019-11-13 19:35:39 +01:00
$resql2 = $db -> query ( $sql );
2020-11-27 20:20:04 +01:00
if ( ! $resql2 ) {
2015-01-17 19:28:27 +01:00
dol_print_error ( $db );
2020-05-21 15:05:19 +02:00
} else {
2023-02-23 15:50:57 +01:00
//if check read is use then update prospect contact status
2020-11-27 20:20:04 +01:00
if ( strpos ( $message , '__CHECK_READ__' ) !== false ) {
2015-01-17 19:28:27 +01:00
//Update status communication of thirdparty prospect
2021-05-11 21:13:52 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM " . MAIN_DB_PREFIX . " mailing_cibles WHERE rowid= " . (( int ) $obj -> rowid ) . " ) " ;
2015-01-18 17:13:42 +01:00
dol_syslog ( " card.php: set prospect thirdparty status " , LOG_DEBUG );
2019-11-13 19:35:39 +01:00
$resql2 = $db -> query ( $sql );
2020-11-27 20:20:04 +01:00
if ( ! $resql2 ) {
2015-01-17 19:28:27 +01:00
dol_print_error ( $db );
}
2020-10-31 14:32:18 +01:00
//Update status communication of contact prospect
2021-05-11 21:13:52 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM " . MAIN_DB_PREFIX . " socpeople AS sc INNER JOIN " . MAIN_DB_PREFIX . " mailing_cibles AS mc ON mc.rowid= " . (( int ) $obj -> rowid ) . " AND mc.source_type = 'contact' AND mc.source_id = sc.rowid) " ;
2015-01-18 17:13:42 +01:00
dol_syslog ( " card.php: set prospect contact status " , LOG_DEBUG );
2015-01-17 19:28:27 +01:00
2019-11-13 19:35:39 +01:00
$resql2 = $db -> query ( $sql );
2020-11-27 20:20:04 +01:00
if ( ! $resql2 ) {
2015-01-17 19:28:27 +01:00
dol_print_error ( $db );
}
2012-04-04 14:45:48 +02:00
}
}
2012-04-05 21:02:00 +02:00
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MAILING_DELAY' )) {
2022-12-13 15:25:52 +01:00
dol_syslog ( " Wait a delay of MAILING_DELAY= " . (( float ) $conf -> global -> MAILING_DELAY ));
2024-03-18 22:05:48 +01:00
usleep (( int ) (( float ) $conf -> global -> MAILING_DELAY * 1000000 ));
2020-10-31 14:32:18 +01:00
}
2012-04-05 21:02:00 +02:00
2020-10-31 14:32:18 +01:00
//test if CHECK READ change statut prospect contact
2020-05-21 15:05:19 +02:00
} else {
2015-01-17 19:28:27 +01:00
// Mail failed
$nbko ++ ;
2009-05-06 15:39:43 +02:00
2023-02-25 04:05:18 +01:00
dol_syslog ( " comm/mailing/card.php: error for # " . $iforemailloop . ( $mail -> error ? ' - ' . $mail -> error : '' ), LOG_WARNING );
2009-05-06 15:39:43 +02:00
2019-11-13 19:35:39 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " mailing_cibles " ;
2024-11-09 15:48:14 +01:00
$sql .= " SET statut=-1, error_text=' " . $db -> escape ( dol_trunc ( $mail -> error , 250 )) . " ', date_envoi=' " . $db -> idate ( $now ) . " ' WHERE rowid= " . (( int ) $obj -> rowid );
2019-11-13 19:35:39 +01:00
$resql2 = $db -> query ( $sql );
2020-11-27 20:20:04 +01:00
if ( ! $resql2 ) {
2015-01-17 19:28:27 +01:00
dol_print_error ( $db );
}
2009-05-06 15:39:43 +02:00
}
2023-02-25 04:05:18 +01:00
$iforemailloop ++ ;
2015-01-17 19:28:27 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> transnoentitiesnoconv ( " NoMoreRecipientToSendTo " ), null , 'mesgs' );
2009-05-06 15:39:43 +02:00
}
2015-01-17 19:28:27 +01:00
// Loop finished, set global statut of mail
2020-11-27 20:20:04 +01:00
if ( $nbko > 0 ) {
2019-11-13 19:35:39 +01:00
$statut = 2 ; // Status 'sent partially' (because at least one error)
2024-03-11 12:58:51 +01:00
setEventMessages ( $langs -> transnoentitiesnoconv ( " EMailSentToNRecipients " , $nbok ), null , 'mesgs' );
2020-05-21 15:05:19 +02:00
} else {
2020-11-27 20:20:04 +01:00
if ( $nbok >= $num ) {
2019-11-13 19:35:39 +01:00
$statut = 3 ; // Send to everybody
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:35:39 +01:00
$statut = 2 ; // Status 'sent partially' (because not send to everybody)
2015-01-17 19:28:27 +01:00
}
2024-03-11 12:58:51 +01:00
setEventMessages ( $langs -> transnoentitiesnoconv ( " EMailSentToNRecipients " , $nbok ), null , 'mesgs' );
2012-11-14 18:58:55 +01:00
}
2009-05-06 15:39:43 +02:00
2021-04-25 15:55:36 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " mailing SET statut= " . (( int ) $statut ) . " WHERE rowid = " . (( int ) $object -> id );
2015-01-18 17:13:42 +01:00
dol_syslog ( " comm/mailing/card.php: update global status " , LOG_DEBUG );
2019-11-13 19:35:39 +01:00
$resql2 = $db -> query ( $sql );
2020-11-27 20:20:04 +01:00
if ( ! $resql2 ) {
2015-01-17 19:28:27 +01:00
dol_print_error ( $db );
}
2020-05-21 15:05:19 +02:00
} else {
2015-01-17 19:28:27 +01:00
dol_syslog ( $db -> error ());
2009-05-06 15:39:43 +02:00
dol_print_error ( $db );
2008-08-04 01:45:53 +02:00
}
2021-06-04 12:27:50 +02:00
$object -> fetch ( $id );
2015-01-17 19:28:27 +01:00
$action = '' ;
}
2008-02-29 17:26:38 +01:00
}
2010-04-17 15:23:50 +02:00
2015-01-17 19:28:27 +01:00
// Action send test emailing
2024-04-04 19:47:19 +02:00
if ( $action == 'send' && ! $cancel && $permissiontovalidatesend ) {
2019-11-13 19:35:39 +01:00
$error = 0 ;
2011-03-23 20:30:37 +01:00
2019-11-13 19:35:39 +01:00
$upload_dir = $conf -> mailing -> dir_output . " / " . get_exdir ( $object -> id , 2 , 0 , 1 , $object , 'mailing' );
2005-09-10 17:56:12 +02:00
2021-03-25 16:59:47 +01:00
$object -> sendto = GETPOST ( " sendto " , 'alphawithlgt' );
2020-11-27 20:20:04 +01:00
if ( ! $object -> sendto ) {
2019-05-29 09:51:45 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " MailTo " )), null , 'errors' );
2015-01-17 19:28:27 +01:00
$error ++ ;
2009-05-06 15:39:43 +02:00
}
2020-11-27 20:20:04 +01:00
if ( ! $error ) {
2020-10-14 18:26:05 +02:00
// Is the message in html
2024-01-14 12:26:37 +01:00
$msgishtml = - 1 ; // Unknown = autodetect by default
2020-11-27 20:20:04 +01:00
if ( preg_match ( '/[\s\t]*<html>/i' , $object -> body )) {
$msgishtml = 1 ;
}
2015-01-17 19:28:27 +01:00
2023-11-27 11:39:32 +01:00
$signature = (( ! empty ( $user -> signature ) && ! getDolGlobalString ( 'MAIN_MAIL_DO_NOT_USE_SIGN' )) ? $user -> signature : '' );
2023-02-23 13:50:25 +01:00
2024-03-11 12:58:51 +01:00
$parameters = array ( 'mode' => 'emailing' );
2023-02-23 13:50:25 +01:00
$substitutionarray = getCommonSubstitutionArray ( $langs , 0 , array ( 'object' , 'objectamount' ), $targetobject ); // Note: On mass emailing, this is null because be don't know object
2017-09-22 14:34:31 +02:00
// other are set at begin of page
2023-02-23 13:50:25 +01:00
$substitutionarray [ '__EMAIL__' ] = $object -> sendto ;
$substitutionarray [ '__MAILTOEMAIL__' ] = '<a href="mailto:' . $object -> sendto . '">' . $object -> sendto . '</a>' ;
2024-09-18 03:27:25 +02:00
$substitutionarray [ '__CHECK_READ__' ] = '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=undefinedintestmode&securitykey=' . dol_hash ( getDolGlobalString ( 'MAILING_EMAIL_UNSUBSCRIBE_KEY' ) . " -undefinedintestmode- " . $object -> sendto . " -0 " , 'md5' ) . '&email=' . urlencode ( $object -> sendto ) . '&mtid=0" width="1" height="1" style="width:1px;height:1px" border="0"/>' ;
$substitutionarray [ '__UNSUBSCRIBE__' ] = '<a href="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-unsubscribe.php?tag=undefinedintestmode&unsuscrib=1&securitykey=' . dol_hash ( getDolGlobalString ( 'MAILING_EMAIL_UNSUBSCRIBE_KEY' ) . " -undefinedintestmode- " . $object -> sendto . " -0 " , 'md5' ) . '&email=' . urlencode ( $object -> sendto ) . '&mtid=0" target="_blank" rel="noopener noreferrer">' . $langs -> trans ( " MailUnsubcribe " ) . '</a>' ;
$substitutionarray [ '__UNSUBSCRIBE_URL__' ] = DOL_MAIN_URL_ROOT . '/public/emailing/mailing-unsubscribe.php?tag=undefinedintestmode&unsuscrib=1&securitykey=' . dol_hash ( getDolGlobalString ( 'MAILING_EMAIL_UNSUBSCRIBE_KEY' ) . " -undefinedintestmode- " . $object -> sendto . " -0 " , 'md5' ) . '&email=' . urlencode ( $object -> sendto ) . '&mtid=0' ;
2017-08-28 12:49:57 +02:00
2020-10-14 18:26:05 +02:00
// Subject and message substitutions
2023-02-23 13:50:25 +01:00
complete_substitutions_array ( $substitutionarray , $langs , $targetobject );
$tmpsujet = make_substitutions ( $object -> sujet , $substitutionarray );
$tmpbody = make_substitutions ( $object -> body , $substitutionarray );
2015-01-17 19:28:27 +01:00
$arr_file = array ();
$arr_mime = array ();
$arr_name = array ();
$arr_css = array ();
2020-10-31 14:32:18 +01:00
// Add CSS
2020-11-27 20:20:04 +01:00
if ( ! empty ( $object -> bgcolor )) {
$arr_css [ 'bgcolor' ] = ( preg_match ( '/^#/' , $object -> bgcolor ) ? '' : '#' ) . $object -> bgcolor ;
}
if ( ! empty ( $object -> bgimage )) {
$arr_css [ 'bgimage' ] = $object -> bgimage ;
}
2015-01-17 19:28:27 +01:00
2020-10-31 14:32:18 +01:00
// Attached files
2019-11-13 19:35:39 +01:00
$listofpaths = dol_dir_list ( $upload_dir , 'all' , 0 , '' , '' , 'name' , SORT_ASC , 0 );
2020-11-27 20:20:04 +01:00
if ( count ( $listofpaths )) {
foreach ( $listofpaths as $key => $val ) {
2019-11-13 19:35:39 +01:00
$arr_file [] = $listofpaths [ $key ][ 'fullname' ];
$arr_mime [] = dol_mimetype ( $listofpaths [ $key ][ 'name' ]);
$arr_name [] = $listofpaths [ $key ][ 'name' ];
2015-01-17 19:28:27 +01:00
}
}
2009-05-06 15:39:43 +02:00
2022-09-12 10:26:20 +02:00
$trackid = 'emailing-test' ;
2022-10-23 20:45:27 +02:00
$upload_dir_tmp = $upload_dir ;
2024-10-19 01:16:51 +02:00
$mailfile = new CMailFile ( $tmpsujet , $object -> sendto , $object -> email_from , $tmpbody , $arr_file , $arr_mime , $arr_name , '' , '' , 0 , $msgishtml , $object -> email_errorsto , $arr_css , $trackid , '' , 'emailing' , $object -> email_replyto , $upload_dir_tmp );
2005-01-05 16:26:05 +01:00
2019-11-13 19:35:39 +01:00
$result = $mailfile -> sendfile ();
2020-11-27 20:20:04 +01:00
if ( $result ) {
2019-01-27 11:55:16 +01:00
setEventMessages ( $langs -> trans ( " MailSuccessfulySent " , $mailfile -> getValidAddress ( $object -> email_from , 2 ), $mailfile -> getValidAddress ( $object -> sendto , 2 )), null , 'mesgs' );
2019-05-21 21:16:06 +02:00
$action = '' ;
2020-05-21 15:05:19 +02:00
} else {
2024-03-11 14:01:28 +01:00
setEventMessages ( $langs -> trans ( " ResultKo " ) . '<br>' . $mailfile -> error . ' ' . json_encode ( $result ), null , 'errors' );
2019-05-21 21:16:06 +02:00
$action = 'test' ;
2015-01-17 19:28:27 +01:00
}
2010-04-17 11:47:25 +02:00
}
}
2024-09-18 03:27:25 +02:00
$mesgs = array ();
2015-01-17 19:28:27 +01:00
// Action add emailing
2024-04-04 19:47:19 +02:00
if ( $action == 'add' && $permissiontocreate ) {
2024-02-09 15:58:49 +01:00
$object -> messtype = ( string ) GETPOST ( " messtype " );
2024-02-25 20:41:58 +01:00
if ( $object -> messtype == 'sms' ) {
$object -> email_from = ( string ) GETPOST ( " from_phone " , 'alphawithlgt' ); // Must allow 'name <email>'
} else {
$object -> email_from = ( string ) GETPOST ( " from " , 'alphawithlgt' ); // Must allow 'name <email>'
}
2022-01-19 15:20:10 +01:00
$object -> email_replyto = ( string ) GETPOST ( " replyto " , 'alphawithlgt' ); // Must allow 'name <email>'
$object -> email_errorsto = ( string ) GETPOST ( " errorsto " , 'alphawithlgt' ); // Must allow 'name <email>'
2020-11-27 20:20:04 +01:00
$object -> title = ( string ) GETPOST ( " title " );
$object -> sujet = ( string ) GETPOST ( " sujet " );
$object -> body = ( string ) GETPOST ( " bodyemail " , 'restricthtml' );
2023-09-08 15:25:50 +02:00
$object -> bgcolor = preg_replace ( '/^#/' , '' , ( string ) GETPOST ( " bgcolor " ));
2020-11-27 20:20:04 +01:00
$object -> bgimage = ( string ) GETPOST ( " bgimage " );
2010-04-17 15:23:50 +02:00
2020-10-07 17:41:36 +02:00
if ( ! $object -> title ) {
2019-01-27 11:55:16 +01:00
$mesgs [] = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailTitle " ));
2015-01-18 17:13:42 +01:00
}
2024-02-09 15:58:49 +01:00
if ( $object -> messtype != 'sms' && ! $object -> sujet ) {
2019-01-27 11:55:16 +01:00
$mesgs [] = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailTopic " ));
2014-07-20 02:32:13 +02:00
}
2019-11-13 19:35:39 +01:00
if ( ! $object -> body ) {
2019-01-27 11:55:16 +01:00
$mesgs [] = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailMessage " ));
2014-07-20 02:32:13 +02:00
}
2010-04-17 15:23:50 +02:00
2020-11-27 20:20:04 +01:00
if ( ! count ( $mesgs )) {
if ( $object -> create ( $user ) >= 0 ) {
2012-08-31 05:58:38 +02:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
2010-04-17 15:23:50 +02:00
exit ;
}
2015-01-18 17:13:42 +01:00
$mesgs [] = $object -> error ;
2022-11-16 10:48:25 +01:00
$mesgs = array_merge ( $mesgs , $object -> errors );
2010-04-17 15:23:50 +02:00
}
2022-11-16 11:05:39 +01:00
setEventMessages ( '' , $mesgs , 'errors' );
2019-11-13 19:35:39 +01:00
$action = " create " ;
2010-04-17 15:23:50 +02:00
}
2015-01-17 19:28:27 +01:00
// Action update description of emailing
2024-04-04 19:47:19 +02:00
if (( $action == 'settitle' || $action == 'setemail_from' || $action == 'setemail_replyto' || $action == 'setreplyto' || $action == 'setemail_errorsto' || $action == 'setevenunsubscribe' ) && $permissiontovalidatesend ) {
2019-11-13 19:35:39 +01:00
$upload_dir = $conf -> mailing -> dir_output . " / " . get_exdir ( $object -> id , 2 , 0 , 1 , $object , 'mailing' );
2015-01-17 19:28:27 +01:00
2024-08-31 17:23:13 +02:00
if ( $action == 'settitle' ) { // Test on permission already done
2020-11-27 20:20:04 +01:00
$object -> title = trim ( GETPOST ( 'title' , 'alpha' ));
2024-08-31 17:23:13 +02:00
} elseif ( $action == 'setemail_from' ) { // Test on permission already done
2022-01-19 15:20:10 +01:00
$object -> email_from = trim ( GETPOST ( 'email_from' , 'alphawithlgt' )); // Must allow 'name <email>'
2024-08-31 17:23:13 +02:00
} elseif ( $action == 'setemail_replyto' ) { // Test on permission already done
2022-01-19 15:20:10 +01:00
$object -> email_replyto = trim ( GETPOST ( 'email_replyto' , 'alphawithlgt' )); // Must allow 'name <email>'
2024-08-31 17:23:13 +02:00
} elseif ( $action == 'setemail_errorsto' ) { // Test on permission already done
2022-01-19 15:20:10 +01:00
$object -> email_errorsto = trim ( GETPOST ( 'email_errorsto' , 'alphawithlgt' )); // Must allow 'name <email>'
2024-08-31 17:23:13 +02:00
} elseif ( $action == 'settitle' && empty ( $object -> title )) { // Test on permission already done
2019-01-27 23:31:37 +01:00
$mesg = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailTitle " ));
2024-08-31 17:23:13 +02:00
} elseif ( $action == 'setfrom' && empty ( $object -> email_from )) { // Test on permission already done
2019-01-27 23:31:37 +01:00
$mesg = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailFrom " ));
2024-08-31 17:23:13 +02:00
} elseif ( $action == 'setevenunsubscribe' ) { // Test on permission already done
2023-04-08 13:29:30 +02:00
$object -> evenunsubscribe = ( GETPOST ( 'evenunsubscribe' ) ? 1 : 0 );
2015-01-18 17:13:42 +01:00
}
2015-01-17 19:28:27 +01:00
2020-11-27 20:20:04 +01:00
if ( ! $mesg ) {
2023-04-08 13:29:30 +02:00
$result = $object -> update ( $user );
if ( $result >= 0 ) {
2015-01-17 19:28:27 +01:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
exit ;
}
2015-01-18 17:13:42 +01:00
$mesg = $object -> error ;
2015-01-17 19:28:27 +01:00
}
2015-11-06 09:36:16 +01:00
setEventMessages ( $mesg , $mesgs , 'errors' );
2019-11-13 19:35:39 +01:00
$action = " " ;
2010-04-17 15:23:50 +02:00
}
2015-01-17 19:28:27 +01:00
/*
2021-04-04 17:05:01 +02:00
* Action of adding a file in email form
2015-01-17 19:28:27 +01:00
*/
2024-04-04 19:47:19 +02:00
if ( GETPOST ( 'addfile' ) && $permissiontocreate ) {
2019-11-13 19:35:39 +01:00
$upload_dir = $conf -> mailing -> dir_output . " / " . get_exdir ( $object -> id , 2 , 0 , 1 , $object , 'mailing' );
2015-01-17 19:28:27 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2020-10-31 14:32:18 +01:00
// Set tmp user directory
2021-04-04 17:05:01 +02:00
dol_add_file_process ( $upload_dir , 0 , 0 , 'addedfile' , '' , null , '' , 0 );
2015-01-17 19:28:27 +01:00
2019-11-13 19:35:39 +01:00
$action = " edit " ;
2012-06-15 11:20:09 +02:00
}
2015-01-17 19:28:27 +01:00
2020-10-14 18:26:05 +02:00
// Action of file remove
2024-04-04 19:47:19 +02:00
if ( GETPOST ( " removedfile " ) && $permissiontocreate ) {
2019-11-13 19:35:39 +01:00
$upload_dir = $conf -> mailing -> dir_output . " / " . get_exdir ( $object -> id , 2 , 0 , 1 , $object , 'mailing' );
2015-01-17 19:28:27 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2021-04-04 17:05:01 +02:00
dol_remove_file_process ( GETPOST ( 'removedfile' ), 0 , 0 ); // We really delete file linked to mailing
2015-01-17 19:28:27 +01:00
2019-11-13 19:35:39 +01:00
$action = " edit " ;
2005-01-05 16:26:05 +01:00
}
2020-10-14 18:26:05 +02:00
// Action of emailing update
2024-04-04 19:47:19 +02:00
if ( $action == 'update' && ! GETPOST ( " removedfile " ) && ! $cancel && $permissiontocreate ) {
2015-01-17 19:28:27 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2019-11-13 19:35:39 +01:00
$isupload = 0 ;
2012-06-15 11:20:09 +02:00
2020-11-27 20:20:04 +01:00
if ( ! $isupload ) {
2015-01-18 17:13:42 +01:00
$mesgs = array ();
2024-02-09 15:58:49 +01:00
//$object->messtype = (string) GETPOST("messtype"); // We must not be able to change the messtype
2020-11-27 20:20:04 +01:00
$object -> sujet = ( string ) GETPOST ( " sujet " );
$object -> body = ( string ) GETPOST ( " bodyemail " , 'restricthtml' );
2023-09-08 15:25:50 +02:00
$object -> bgcolor = preg_replace ( '/^#/' , '' , ( string ) GETPOST ( " bgcolor " ));
2020-11-27 20:20:04 +01:00
$object -> bgimage = ( string ) GETPOST ( " bgimage " );
2015-01-17 19:28:27 +01:00
2024-02-09 15:58:49 +01:00
if ( $object -> messtype != 'sms' && ! $object -> sujet ) {
2019-01-27 11:55:16 +01:00
$mesgs [] = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailTopic " ));
2015-01-18 17:13:42 +01:00
}
2019-11-13 19:35:39 +01:00
if ( ! $object -> body ) {
2019-01-27 11:55:16 +01:00
$mesgs [] = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailMessage " ));
2015-01-18 17:13:42 +01:00
}
2015-01-17 19:28:27 +01:00
2020-11-27 20:20:04 +01:00
if ( ! count ( $mesgs )) {
if ( $object -> update ( $user ) >= 0 ) {
2015-01-17 19:28:27 +01:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
exit ;
}
2019-11-13 19:35:39 +01:00
$mesgs [] = $object -> error ;
2022-11-16 10:48:25 +01:00
$mesgs = array_merge ( $mesgs , $object -> errors );
2015-01-17 19:28:27 +01:00
}
2022-11-16 11:05:39 +01:00
setEventMessages ( '' , $mesgs , 'errors' );
2019-11-13 19:35:39 +01:00
$action = " edit " ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:35:39 +01:00
$action = " edit " ;
2012-06-15 11:20:09 +02:00
}
2015-01-17 19:28:27 +01:00
}
2012-06-15 11:20:09 +02:00
2020-10-14 18:26:05 +02:00
// Action of validation confirmation
2024-04-04 19:47:19 +02:00
if ( $action == 'confirm_valid' && $confirm == 'yes' && $permissiontovalidatesend ) {
2020-11-27 20:20:04 +01:00
if ( $object -> id > 0 ) {
2015-01-17 19:28:27 +01:00
$object -> valid ( $user );
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> trans ( " MailingSuccessfullyValidated " ), null , 'mesgs' );
2012-08-31 05:58:38 +02:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
2012-06-15 11:20:09 +02:00
exit ;
2020-05-21 15:05:19 +02:00
} else {
2015-01-17 19:28:27 +01:00
dol_print_error ( $db );
2012-06-15 11:20:09 +02:00
}
}
2015-01-17 19:28:27 +01:00
2020-10-14 18:26:05 +02:00
// Action of validation confirmation
2024-04-04 19:47:19 +02:00
if ( $action == 'confirm_settodraft' && $confirm == 'yes' && $permissiontocreate ) {
2020-11-27 20:20:04 +01:00
if ( $object -> id > 0 ) {
2017-01-29 15:31:22 +01:00
$result = $object -> setStatut ( 0 );
2020-11-27 20:20:04 +01:00
if ( $result > 0 ) {
2020-10-31 14:32:18 +01:00
//setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs');
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
exit ;
} else {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2020-05-21 15:05:19 +02:00
} else {
2017-01-29 15:31:22 +01:00
dol_print_error ( $db );
}
}
2015-01-17 19:28:27 +01:00
// Resend
2024-04-04 19:47:19 +02:00
if ( $action == 'confirm_reset' && $confirm == 'yes' && $permissiontocreate ) {
2020-11-27 20:20:04 +01:00
if ( $object -> id > 0 ) {
2015-01-17 19:28:27 +01:00
$db -> begin ();
2019-11-13 19:35:39 +01:00
$result = $object -> valid ( $user );
2020-11-27 20:20:04 +01:00
if ( $result > 0 ) {
2019-11-13 19:35:39 +01:00
$result = $object -> reset_targets_status ( $user );
2015-01-17 19:28:27 +01:00
}
2020-11-27 20:20:04 +01:00
if ( $result > 0 ) {
2015-01-17 19:28:27 +01:00
$db -> commit ();
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
exit ;
2020-05-21 15:05:19 +02:00
} else {
2015-11-06 09:36:16 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-01-17 19:28:27 +01:00
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2015-01-17 19:28:27 +01:00
dol_print_error ( $db );
}
2005-01-05 16:26:05 +01:00
}
2020-10-14 18:26:05 +02:00
// Action of delete confirmation
2024-04-04 19:47:19 +02:00
if ( $action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete ) {
2023-02-20 19:25:29 +01:00
if ( $object -> delete ( $user )) {
2019-11-13 19:35:39 +01:00
$url = ( ! empty ( $urlfrom ) ? $urlfrom : 'list.php' );
2015-01-17 19:28:27 +01:00
header ( " Location: " . $url );
exit ;
}
2009-05-06 15:39:43 +02:00
}
2005-01-05 16:26:05 +01:00
2021-03-25 16:59:47 +01:00
if ( $cancel ) {
2015-01-17 19:28:27 +01:00
$action = '' ;
}
2005-01-05 16:26:05 +01:00
}
2005-02-12 00:41:42 +01:00
2005-01-05 16:26:05 +01:00
/*
2008-05-28 00:30:52 +02:00
* View
2005-01-05 16:26:05 +01:00
*/
2015-01-18 17:13:42 +01:00
$form = new Form ( $db );
$htmlother = new FormOther ( $db );
2012-06-13 09:26:29 +02:00
2019-11-13 19:35:39 +01:00
$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing' ;
2020-11-27 20:20:04 +01:00
llxHeader (
'' ,
$langs -> trans ( " Mailing " ),
$help_url ,
'' ,
0 ,
0 ,
2017-09-01 13:09:13 +02:00
array (
2020-11-27 20:20:04 +01:00
'/includes/ace/src/ace.js' ,
'/includes/ace/src/ext-statusbar.js' ,
'/includes/ace/src/ext-language_tools.js' ,
//'/includes/ace/src/ext-chromevox.js'
),
array ()
);
2023-04-08 17:16:22 +02:00
2024-08-31 17:23:13 +02:00
if ( $action == 'create' ) { // aaa
2008-11-10 15:20:02 +01:00
// EMailing in creation mode
2012-03-23 20:03:57 +01:00
print '<form name="new_mailing" action="' . $_SERVER [ 'PHP_SELF' ] . '" method="POST">' . " \n " ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2009-05-06 15:39:43 +02:00
print '<input type="hidden" name="action" value="add">' ;
2005-02-12 00:41:42 +01:00
2023-04-08 13:29:30 +02:00
$htmltext = '<i>' . $langs -> trans ( " FollowingConstantsWillBeSubstituted " ) . ':<br><br><span class="small">' ;
2020-11-27 20:20:04 +01:00
foreach ( $object -> substitutionarray as $key => $val ) {
2019-11-13 19:35:39 +01:00
$htmltext .= $key . ' = ' . $langs -> trans ( $val ) . '<br>' ;
2016-11-11 02:18:48 +01:00
}
2023-04-08 13:29:30 +02:00
$htmltext .= '</span></i>' ;
2017-02-17 17:11:14 +01:00
2017-06-07 16:44:04 +02:00
2024-02-09 15:58:49 +01:00
$availablelink = $form -> textwithpicto ( '<span class="opacitymedium">' . $langs -> trans ( " AvailableVariables " ) . '</span>' , $htmltext , 1 , 'helpclickable' , '' , 0 , 2 , 'availvar' );
2017-02-17 17:11:14 +01:00
//print '<a href="javascript:document_preview(\''.DOL_URL_ROOT.'/admin/modulehelp.php?id='.$objMod->numero.'\',\'text/html\',\''.dol_escape_js($langs->trans("Module")).'\')">'.img_picto($langs->trans("ClickToShowDescription"), $imginfo).'</a>';
2017-06-07 16:44:04 +02:00
2016-11-11 02:18:48 +01:00
// Print mail form
2020-05-11 19:00:27 +02:00
print load_fiche_titre ( $langs -> trans ( " NewMailing " ), $availablelink , 'object_email' );
2005-01-05 16:26:05 +01:00
2025-01-23 01:29:29 +01:00
print dol_get_fiche_head ( array (), '' , '' , 0 , '' , 0 , '' , '' );
2015-05-22 15:29:19 +02:00
2019-05-21 21:36:48 +02:00
print '<table class="border centpercent">' ;
2022-10-22 14:43:22 +02:00
2020-10-22 20:01:59 +02:00
print '<tr><td class="fieldrequired titlefieldcreate">' . $langs -> trans ( " MailTitle " ) . '</td><td><input class="flat minwidth300" name="title" value="' . dol_escape_htmltag ( GETPOST ( 'title' )) . '" autofocus="autofocus"></td></tr>' ;
2022-10-22 14:43:22 +02:00
2024-02-09 15:58:49 +01:00
if ( getDolGlobalInt ( 'EMAILINGS_SUPPORT_ALSO_SMS' )) {
$arrayoftypes = array ( " email " => " Email " , " sms " => " SMS " );
print '<tr><td class="fieldrequired titlefieldcreate">' . $langs -> trans ( " Type " ) . '</td><td>' ;
print $form -> selectarray ( 'messtype' , $arrayoftypes , ( GETPOSTISSET ( 'messtype' ) ? GETPOST ( 'messtype' ) : 'email' ), 0 , 0 );
print ' < script >
$ ( document ) . ready ( function () {
jQuery ( " #messtype " ) . on ( " change " , function () {
console . log ( " We change the message ttpe " );
if ( jQuery ( " #messtype " ) . val () == " email " ) {
jQuery ( " .fieldsforsms " ) . hide ();
jQuery ( " .fieldsforemail " ) . show ();
}
if ( jQuery ( " #messtype " ) . val () == " sms " ) {
jQuery ( " .fieldsforsms " ) . show ();
jQuery ( " .fieldsforemail " ) . hide ();
}
});
jQuery ( " #messtype " ) . change ();
})
</ script > ' ;
2022-10-22 14:43:22 +02:00
2024-02-09 15:58:49 +01:00
print '</td></tr>' ;
}
print '</table>' ;
2025-01-23 01:29:29 +01:00
print '<br>' ;
2024-02-09 15:58:49 +01:00
print '<table class="border centpercent">' ;
2025-01-23 01:29:29 +01:00
print '<tr class="fieldsforemail"><td class="fieldrequired titlefieldcreate">' . $langs -> trans ( " MailFrom " ) . '</td>' ;
print '<td>' . img_picto ( '' , 'email' , 'class="pictofixedwidth"' ) . '<input class="flat minwidth200" name="from" value="' . ( GETPOSTISSET ( 'from' ) ? GETPOST ( 'from' ) : getDolGlobalString ( 'MAILING_EMAIL_FROM' )) . '"></td></tr>' ;
2024-02-25 20:41:58 +01:00
2025-01-23 01:29:29 +01:00
print '<tr class="fieldsforsms hidden"><td class="fieldrequired titlefieldcreate">' . $langs -> trans ( " PhoneFrom " ) . '</td>' ;
print '<td>' . img_picto ( '' , 'email' , 'class="pictofixedwidth"' ) . '<input class="flat minwidth200" name="fromphone" value="' . ( GETPOSTISSET ( 'fromphone' ) ? GETPOST ( 'fromphone' ) : getDolGlobalString ( 'MAILING_SMS_FROM' )) . '" placeholder="+123..."></td></tr>' ;
2024-02-09 15:58:49 +01:00
2025-01-23 01:29:29 +01:00
print '<tr class="fieldsforemail"><td>' . $langs -> trans ( " MailErrorsTo " ) . '</td>' ;
print '<td>' . img_picto ( '' , 'email' , 'class="pictofixedwidth"' ) . '<input class="flat minwidth200" name="errorsto" value="' . getDolGlobalString ( 'MAILING_EMAIL_ERRORSTO' , getDolGlobalString ( 'MAIN_MAIL_ERRORS_TO' )) . '"></td></tr>' ;
2012-06-17 18:40:45 +02:00
2025-01-23 01:29:29 +01:00
print '<tr class="fieldsforemail"><td>' . $langs -> trans ( " MailReply " ) . '</td>' ;
print '<td>' . img_picto ( '' , 'email' , 'class="pictofixedwidth"' ) . '<input class="flat minwidth200" name="replyto" value="' . getDolGlobalString ( 'MAILING_EMAIL_REPLYTO' , getDolGlobalString ( 'MAIN_MAIL_REPLY_TO' )) . '"></td></tr>' ;
2024-10-19 01:16:51 +02:00
2012-06-15 11:20:09 +02:00
// Other attributes
2019-11-13 19:35:39 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2020-10-31 14:32:18 +01:00
print $hookmanager -> resPrint ;
2020-11-27 20:20:04 +01:00
if ( empty ( $reshook )) {
2021-10-08 15:58:08 +02:00
print $object -> showOptionals ( $extrafields , 'create' );
2012-06-13 09:26:29 +02:00
}
2012-06-17 18:40:45 +02:00
2010-04-17 11:47:25 +02:00
print '</table>' ;
2025-01-23 01:29:29 +01:00
print '<br>' ;
2010-04-17 11:47:25 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">' ;
2024-07-31 19:12:40 +02:00
print '<tr class="fieldsforemail"><td class="fieldrequired titlefieldcreate">' . $langs -> trans ( " MailTopic " ) . '</td><td><input id="sujet" class="flat minwidth200 quatrevingtpercent" name="sujet" value="' . dol_escape_htmltag ( GETPOST ( 'sujet' , 'alphanohtml' )) . '"></td></tr>' ;
2024-02-09 15:58:49 +01:00
print '<tr class="fieldsforemail"><td>' . $langs -> trans ( " BackgroundColorByDefault " ) . '</td><td colspan="3">' ;
2022-02-22 23:44:56 +01:00
print $htmlother -> selectColor ( GETPOST ( 'bgcolor' ), 'bgcolor' , '' , 0 );
2009-05-19 15:27:44 +02:00
print '</td></tr>' ;
2016-11-11 02:18:48 +01:00
2024-03-11 15:23:26 +01:00
$formmail = new FormMail ( $db );
$formmail -> withfckeditor = 1 ;
2024-10-14 23:38:14 +02:00
$formmail -> withlayout = 'emailing' ;
2024-06-18 09:54:11 +02:00
$formmail -> withaiprompt = 'html' ;
2024-03-11 15:23:26 +01:00
2024-10-15 00:07:08 +02:00
print '<tr class="fieldsforemail"><td></td><td class="tdtop"></td></tr>' ;
2024-04-24 11:26:08 +02:00
print '<tr class="fieldsforemail"><td></td><td class="tdtop">' ;
2024-03-11 15:23:26 +01:00
$out = '' ;
2024-10-14 23:38:14 +02:00
$showlinktolayout = ( $formmail -> withfckeditor ? $formmail -> withlayout : '' );
2024-04-24 11:26:08 +02:00
$showlinktolayoutlabel = $langs -> trans ( " FillMessageWithALayout " );
2024-04-24 13:07:47 +02:00
$showlinktoai = ( $formmail -> withaiprompt && isModEnabled ( 'ai' )) ? 'textgenerationemail' : '' ;
2024-04-24 11:26:08 +02:00
$showlinktoailabel = $langs -> trans ( " FillMessageWithAIContent " );
$formatforouput = 'html' ;
$htmlname = 'bodyemail' ;
// Fill $out
include DOL_DOCUMENT_ROOT . '/core/tpl/formlayoutai.tpl.php' ;
2024-03-11 15:23:26 +01:00
print $out ;
2024-04-24 11:26:08 +02:00
2024-03-11 15:23:26 +01:00
print '</td></tr>' ;
2016-11-11 02:18:48 +01:00
print '</table>' ;
2017-06-07 16:44:04 +02:00
2024-10-15 00:07:08 +02:00
2016-11-11 02:18:48 +01:00
print '<div style="padding-top: 10px">' ;
2020-10-14 18:26:05 +02:00
// wysiwyg editor
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2025-01-23 01:29:29 +01:00
$doleditor = new DolEditor ( 'bodyemail' , GETPOST ( 'bodyemail' , 'restricthtmlallowunvalid' ), '' , 600 , 'dolibarr_mailings' , '' , true , - 1 , getDolGlobalInt ( 'FCKEDITOR_ENABLE_MAILING' ), 20 , '100%' );
2010-09-02 20:51:47 +02:00
$doleditor -> Create ();
2016-11-11 02:18:48 +01:00
print '</div>' ;
2017-06-07 16:44:04 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2015-05-22 15:29:19 +02:00
2024-02-09 15:58:49 +01:00
print $form -> buttonsSaveCancel ( " Create " , 'Cancel' );
2010-02-21 20:35:58 +01:00
2009-05-06 15:39:43 +02:00
print '</form>' ;
2020-05-21 15:05:19 +02:00
} else {
2020-11-27 20:20:04 +01:00
if ( $object -> id > 0 ) {
2019-11-13 19:35:39 +01:00
$upload_dir = $conf -> mailing -> dir_output . " / " . get_exdir ( $object -> id , 2 , 0 , 1 , $object , 'mailing' );
2010-04-17 15:23:50 +02:00
2012-03-23 20:03:57 +01:00
$head = emailing_prepare_head ( $object );
2009-07-29 20:41:39 +02:00
2020-11-27 20:20:04 +01:00
if ( $action == 'settodraft' ) {
// Confirmation back to draft
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( " SetToDraft " ), $langs -> trans ( " ConfirmUnvalidateEmailing " ), " confirm_settodraft " , '' , '' , 1 );
2020-11-27 20:20:04 +01:00
} elseif ( $action == 'valid' ) {
// Confirmation of mailing validation
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( " ValidMailing " ), $langs -> trans ( " ConfirmValidMailing " ), " confirm_valid " , '' , '' , 1 );
2020-11-27 20:20:04 +01:00
} elseif ( $action == 'reset' ) {
// Confirm reset
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( " ResetMailing " ), $langs -> trans ( " ConfirmResetMailing " , $object -> ref ), " confirm_reset " , '' , '' , 2 );
2020-11-27 20:20:04 +01:00
} elseif ( $action == 'delete' ) {
// Confirm delete
2024-03-02 16:52:12 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id . ( ! empty ( $urlfrom ) ? '&urlfrom=' . urlencode ( $urlfrom ) : '' ), $langs -> trans ( " DeleteMailing " ), $langs -> trans ( " ConfirmDeleteMailing " ), " confirm_delete " , '' , '' , 1 );
2009-05-06 15:39:43 +02:00
}
2024-03-11 12:58:51 +01:00
if ( $action != 'edit' && $action != 'edittxt' && $action != 'edithtml' ) {
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'card' , $langs -> trans ( " Mailing " ), - 1 , 'email' );
2017-04-17 13:02:40 +02:00
2024-08-31 17:23:13 +02:00
// View mode mailing
2020-11-27 20:20:04 +01:00
if ( $action == 'sendall' ) {
2024-01-14 12:26:37 +01:00
// Define message to recommend from command line
2024-01-05 04:18:53 +01:00
$sendingmode = getDolGlobalString ( 'EMAILING_MAIL_SENDMODE' );
2020-11-27 20:20:04 +01:00
if ( empty ( $sendingmode )) {
2024-01-05 04:18:53 +01:00
$sendingmode = getDolGlobalString ( 'MAIN_MAIL_SENDMODE' );
2020-11-27 20:20:04 +01:00
}
if ( empty ( $sendingmode )) {
$sendingmode = 'mail' ; // If not defined, we use php mail function
}
2010-12-13 19:40:04 +01:00
2016-12-26 12:30:59 +01:00
// MAILING_NO_USING_PHPMAIL may be defined or not.
// MAILING_LIMIT_SENDBYWEB is always defined to something != 0 (-1=forbidden).
2024-01-14 12:26:37 +01:00
// MAILING_LIMIT_SENDBYCLI may be defined or not (-1=forbidden, 0 or undefined=no limit).
// MAILING_LIMIT_SENDBYDAY may be defined or not (0 or undefined=no limit).
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MAILING_NO_USING_PHPMAIL' ) && $sendingmode == 'mail' ) {
2014-11-29 13:50:41 +01:00
// EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent.
2016-12-17 14:47:06 +01:00
// You ensure that every user is using its own SMTP server when using the mass emailing module.
2020-04-10 10:59:32 +02:00
$linktoadminemailbefore = '<a href="' . DOL_URL_ROOT . '/admin/mails_emailing.php">' ;
$linktoadminemailend = '</a>' ;
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> trans ( " MailSendSetupIs " , $listofmethods [ $sendingmode ]), null , 'warnings' );
2022-07-13 14:00:19 +02:00
$messagetoshow = $langs -> trans ( " MailSendSetupIs2 " , '{s1}' , '{s2}' , '{s3}' , '{s4}' );
$messagetoshow = str_replace ( '{s1}' , $linktoadminemailbefore , $messagetoshow );
$messagetoshow = str_replace ( '{s2}' , $linktoadminemailend , $messagetoshow );
$messagetoshow = str_replace ( '{s3}' , $langs -> transnoentitiesnoconv ( " MAIN_MAIL_SENDMODE " ), $messagetoshow );
$messagetoshow = str_replace ( '{s4}' , $listofmethods [ 'smtps' ], $messagetoshow );
setEventMessages ( $messagetoshow , null , 'warnings' );
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS' )) {
2024-01-05 04:18:53 +01:00
setEventMessages ( $langs -> trans ( " MailSendSetupIs3 " , getDolGlobalString ( 'MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS' )), null , 'warnings' );
2020-11-27 20:20:04 +01:00
}
2024-03-28 17:10:22 +01:00
$action = '' ;
2023-11-27 12:24:18 +01:00
} elseif ( getDolGlobalInt ( 'MAILING_LIMIT_SENDBYWEB' ) < 0 ) {
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MAILING_LIMIT_WARNING_PHPMAIL' ) && $sendingmode == 'mail' ) {
2020-11-27 20:20:04 +01:00
setEventMessages ( $langs -> transnoentitiesnoconv ( $conf -> global -> MAILING_LIMIT_WARNING_PHPMAIL ), null , 'warnings' );
}
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MAILING_LIMIT_WARNING_NOPHPMAIL' ) && $sendingmode != 'mail' ) {
2020-11-27 20:20:04 +01:00
setEventMessages ( $langs -> transnoentitiesnoconv ( $conf -> global -> MAILING_LIMIT_WARNING_NOPHPMAIL ), null , 'warnings' );
}
2017-06-07 16:44:04 +02:00
2016-12-17 14:47:06 +01:00
// The feature is forbidden from GUI, we show just message to use from command line.
2020-10-31 14:32:18 +01:00
setEventMessages ( $langs -> trans ( " MailingNeedCommand " ), null , 'warnings' );
2015-11-06 09:36:16 +01:00
setEventMessages ( '<textarea cols="60" rows="' . ROWS_1 . '" wrap="soft">php ./scripts/emailings/mailing-send.php ' . $object -> id . '</textarea>' , null , 'warnings' );
2024-01-14 12:26:37 +01:00
if ( $conf -> file -> mailing_limit_sendbyweb != '-1' ) { // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed to increase it.
2020-10-31 14:32:18 +01:00
setEventMessages ( $langs -> trans ( " MailingNeedCommand2 " ), null , 'warnings' ); // You can send online with constant...
2016-12-16 13:46:39 +01:00
}
2024-03-28 17:10:22 +01:00
$action = '' ;
2020-05-21 15:05:19 +02:00
} else {
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MAILING_LIMIT_WARNING_PHPMAIL' ) && $sendingmode == 'mail' ) {
2020-11-27 20:20:04 +01:00
setEventMessages ( $langs -> transnoentitiesnoconv ( $conf -> global -> MAILING_LIMIT_WARNING_PHPMAIL ), null , 'warnings' );
}
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MAILING_LIMIT_WARNING_NOPHPMAIL' ) && $sendingmode != 'mail' ) {
2020-11-27 20:20:04 +01:00
setEventMessages ( $langs -> transnoentitiesnoconv ( $conf -> global -> MAILING_LIMIT_WARNING_NOPHPMAIL ), null , 'warnings' );
}
2020-10-31 14:32:18 +01:00
$text = '' ;
2022-07-13 01:01:44 +02:00
2024-01-08 11:11:20 +01:00
if ( getDolGlobalInt ( 'MAILING_LIMIT_SENDBYDAY' ) > 0 ) {
$text .= $langs -> trans ( 'WarningLimitSendByDay' , getDolGlobalInt ( 'MAILING_LIMIT_SENDBYDAY' ));
2020-10-31 14:32:18 +01:00
$text .= '<br><br>' ;
}
$text .= $langs -> trans ( 'ConfirmSendingEmailing' ) . '<br>' ;
2024-01-05 04:18:53 +01:00
$text .= $langs -> trans ( 'LimitSendingEmailing' , getDolGlobalString ( 'MAILING_LIMIT_SENDBYWEB' ));
2022-07-13 01:01:44 +02:00
2023-11-27 12:24:18 +01:00
if ( ! isset ( $conf -> global -> MAILING_LIMIT_SENDBYCLI ) || getDolGlobalInt ( 'MAILING_LIMIT_SENDBYCLI' ) >= 0 ) {
2022-07-13 01:01:44 +02:00
$text .= '<br><br>' ;
2024-06-18 14:04:59 +02:00
$text .= '<u>' . $langs -> trans ( " AdvancedAlternative " ) . ':</u> ' . $langs -> trans ( " MailingNeedCommand " );
2023-02-25 02:55:28 +01:00
$text .= '<br><textarea class="quatrevingtpercent" rows="' . ROWS_2 . '" wrap="soft" disabled>php ./scripts/emailings/mailing-send.php ' . $object -> id . ' ' . $user -> login . '</textarea>' ;
2022-07-13 01:01:44 +02:00
}
2023-02-25 02:53:34 +01:00
print $form -> formconfirm ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $langs -> trans ( 'SendMailing' ), $text , 'sendallconfirmed' , '' , '' , 1 , 380 , 660 , 0 , $langs -> trans ( " Confirm " ), $langs -> trans ( " Cancel " ));
2008-02-29 17:26:38 +01:00
}
}
2005-02-12 00:41:42 +01:00
2018-09-23 16:09:25 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/comm/mailing/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2012-07-28 21:49:47 +02:00
2023-02-23 12:08:43 +01:00
$morehtmlref = '<div class="refidno">' ;
// Ref customer
$morehtmlref .= $form -> editfieldkey ( " " , 'title' , $object -> title , $object , $user -> hasRight ( 'mailing' , 'creer' ), 'string' , '' , 0 , 1 );
$morehtmlref .= $form -> editfieldval ( " " , 'title' , $object -> title , $object , $user -> hasRight ( 'mailing' , 'creer' ), 'string' , '' , null , null , '' , 1 );
$morehtmlref .= '</div>' ;
2024-03-12 19:49:52 +01:00
$morehtmlstatus = '' ;
2018-01-29 12:46:07 +01:00
$nbtry = $nbok = 0 ;
2024-02-09 15:58:49 +01:00
if ( $object -> status == 2 || $object -> status == 3 ) {
2018-01-29 12:46:07 +01:00
$nbtry = $object -> countNbOfTargets ( 'alreadysent' );
$nbko = $object -> countNbOfTargets ( 'alreadysentko' );
2024-03-12 19:49:52 +01:00
$morehtmlstatus .= ' (' . $nbtry . '/' . $object -> nbemail ;
2020-11-27 20:20:04 +01:00
if ( $nbko ) {
2024-03-12 19:49:52 +01:00
$morehtmlstatus .= ' - ' . $nbko . ' ' . $langs -> trans ( " Error " );
2020-11-27 20:20:04 +01:00
}
2024-03-12 19:49:52 +01:00
$morehtmlstatus .= ') ' ;
2018-01-29 12:46:07 +01:00
}
2017-06-07 16:44:04 +02:00
2024-03-12 19:49:52 +01:00
dol_banner_tab ( $object , 'id' , $linkback , 1 , 'rowid' , 'ref' , $morehtmlref , '' , 0 , '' , $morehtmlstatus );
2017-04-17 13:02:40 +02:00
print '<div class="fichecenter">' ;
2023-04-08 13:29:30 +02:00
print '<div class="fichehalfleft">' ;
2016-11-11 01:55:53 +01:00
print '<div class="underbanner clearboth"></div>' ;
2023-04-08 13:29:30 +02:00
print '<table class="border centpercent tableforfield">' . " \n " ;
2010-04-17 11:47:25 +02:00
// From
2023-02-23 13:50:25 +01:00
print '<tr><td class="titlefield">' ;
2024-02-09 15:58:49 +01:00
print $form -> editfieldkey ( " MailFrom " , 'email_from' , $object -> email_from , $object , $user -> hasRight ( 'mailing' , 'creer' ) && $object -> status < $object :: STATUS_SENTCOMPLETELY , 'string' );
2019-10-02 14:44:38 +02:00
print '</td><td>' ;
2024-02-09 15:58:49 +01:00
print $form -> editfieldval ( " MailFrom " , 'email_from' , $object -> email_from , $object , $user -> hasRight ( 'mailing' , 'creer' ) && $object -> status < $object :: STATUS_SENTCOMPLETELY , 'string' );
2019-12-13 15:52:08 +01:00
$email = CMailFile :: getValidAddress ( $object -> email_from , 2 );
2019-12-13 16:29:58 +01:00
if ( $email && ! isValidEmail ( $email )) {
2019-12-13 15:52:08 +01:00
$langs -> load ( " errors " );
print img_warning ( $langs -> trans ( " ErrorBadEMail " , $email ));
2020-10-22 20:01:59 +02:00
} elseif ( $email && ! isValidMailDomain ( $email )) {
$langs -> load ( " errors " );
print img_warning ( $langs -> trans ( " ErrorBadMXDomain " , $email ));
2019-12-13 15:52:08 +01:00
}
2020-10-22 20:01:59 +02:00
2009-05-25 00:01:19 +02:00
print '</td></tr>' ;
2009-07-29 20:41:39 +02:00
// Errors to
2024-02-09 15:58:49 +01:00
if ( $object -> messtype != 'sms' ) {
print '<tr><td>' ;
print $form -> editfieldkey ( " MailErrorsTo " , 'email_errorsto' , $object -> email_errorsto , $object , $user -> hasRight ( 'mailing' , 'creer' ) && $object -> status < $object :: STATUS_SENTCOMPLETELY , 'string' );
print '</td><td>' ;
print $form -> editfieldval ( " MailErrorsTo " , 'email_errorsto' , $object -> email_errorsto , $object , $user -> hasRight ( 'mailing' , 'creer' ) && $object -> status < $object :: STATUS_SENTCOMPLETELY , 'string' );
2024-06-12 14:56:45 +02:00
$emailarray = CMailFile :: getArrayAddress ( $object -> email_errorsto );
foreach ( $emailarray as $email => $name ) {
if ( $name != $email ) {
print dol_escape_htmltag ( $name ) . ' <' . $email ;
print '>' ;
if ( $email && ! isValidEmail ( $email )) {
$langs -> load ( " errors " );
print img_warning ( $langs -> trans ( " ErrorBadEMail " , $email ));
} elseif ( $email && ! isValidMailDomain ( $email )) {
$langs -> load ( " errors " );
print img_warning ( $langs -> trans ( " ErrorBadMXDomain " , $email ));
}
} else {
print dol_print_email ( $object -> email_errorsto , 0 , 0 , 0 , 0 , 1 );
2024-04-04 19:47:19 +02:00
}
2024-02-09 15:58:49 +01:00
}
print '</td></tr>' ;
2019-12-13 15:52:08 +01:00
}
2017-06-07 16:44:04 +02:00
2024-04-04 18:51:03 +02:00
// Reply to
2024-04-04 18:49:31 +02:00
if ( $object -> messtype != 'sms' ) {
print '<tr><td>' ;
print $form -> editfieldkey ( " MailReply " , 'email_replyto' , $object -> email_replyto , $object , $user -> hasRight ( 'mailing' , 'creer' ) && $object -> status < $object :: STATUS_SENTCOMPLETELY , 'string' );
print '</td><td>' ;
print $form -> editfieldval ( " MailReply " , 'email_replyto' , $object -> email_replyto , $object , $user -> hasRight ( 'mailing' , 'creer' ) && $object -> status < $object :: STATUS_SENTCOMPLETELY , 'string' );
$email = CMailFile :: getValidAddress ( $object -> email_replyto , 2 );
2024-04-04 19:47:19 +02:00
if ( $action != 'editemail_replyto' ) {
if ( $email && ! isValidEmail ( $email )) {
$langs -> load ( " errors " );
print img_warning ( $langs -> trans ( " ErrorBadEMail " , $email ));
} elseif ( $email && ! isValidMailDomain ( $email )) {
$langs -> load ( " errors " );
print img_warning ( $langs -> trans ( " ErrorBadMXDomain " , $email ));
}
2024-04-04 18:49:31 +02:00
}
print '</td></tr>' ;
}
2023-04-08 17:16:22 +02:00
print '</table>' ;
print '</div>' ;
print '<div class="fichehalfright">' ;
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border centpercent tableforfield">' ;
2020-10-14 18:26:05 +02:00
// Number of distinct emails
2024-02-09 15:58:49 +01:00
print '<tr><td>' ;
2009-08-26 11:50:00 +02:00
print $langs -> trans ( " TotalNbOfDistinctRecipients " );
2023-04-09 13:09:39 +02:00
print '</td><td>' ;
2019-11-13 19:35:39 +01:00
$nbemail = ( $object -> nbemail ? $object -> nbemail : 0 );
2020-11-27 20:20:04 +01:00
if ( is_numeric ( $nbemail )) {
2020-10-31 14:32:18 +01:00
$text = '' ;
2024-06-12 14:56:45 +02:00
if (( getDolGlobalString ( 'MAILING_LIMIT_SENDBYWEB' ) && getDolGlobalInt ( 'MAILING_LIMIT_SENDBYWEB' ) < $nbemail ) && ( $object -> status == 1 || ( $object -> status == 2 && $nbtry < $nbemail ))) {
2023-11-27 12:24:18 +01:00
if ( getDolGlobalInt ( 'MAILING_LIMIT_SENDBYWEB' ) > 0 ) {
2024-06-12 14:56:45 +02:00
$text .= $langs -> trans ( 'LimitSendingEmailing' , getDolGlobalString ( 'MAILING_LIMIT_SENDBYWEB' ));
2020-10-31 14:32:18 +01:00
} else {
$text .= $langs -> trans ( 'SendingFromWebInterfaceIsNotAllowed' );
}
}
2020-11-27 20:20:04 +01:00
if ( empty ( $nbemail )) {
2021-10-05 09:10:37 +02:00
$nbemail .= ' ' . img_warning ( '' ) . ' <span class="warning">' . $langs -> trans ( " NoTargetYet " ) . '</span>' ;
2020-11-27 20:20:04 +01:00
}
if ( $text ) {
2020-10-31 14:32:18 +01:00
print $form -> textwithpicto ( $nbemail , $text , 1 , 'warning' );
} else {
print $nbemail ;
}
2009-08-26 11:50:00 +02:00
}
print '</td></tr>' ;
2012-06-17 18:40:45 +02:00
2023-04-23 21:42:05 +02:00
print '<tr><td>' ;
print $langs -> trans ( " MAIN_MAIL_SENDMODE " );
print '</td><td>' ;
2024-02-09 15:58:49 +01:00
if ( $object -> messtype != 'sms' ) {
if ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE_EMAILING' ) && getDolGlobalString ( 'MAIN_MAIL_SENDMODE_EMAILING' ) != 'default' ) {
$text = $listofmethods [ getDolGlobalString ( 'MAIN_MAIL_SENDMODE_EMAILING' )];
} elseif ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' )) {
$text = $listofmethods [ getDolGlobalString ( 'MAIN_MAIL_SENDMODE' )];
} else {
$text = $listofmethods [ 'mail' ];
2023-04-23 21:42:05 +02:00
}
2024-02-09 15:58:49 +01:00
print $text ;
if ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE_EMAILING' ) != 'default' ) {
2025-01-23 01:29:29 +01:00
if ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE_EMAILING' ) && getDolGlobalString ( 'MAIN_MAIL_SENDMODE_EMAILING' ) != 'mail' ) {
2024-03-27 19:44:59 +01:00
print ' <span class="opacitymedium">(' . getDolGlobalString ( 'MAIN_MAIL_SMTP_SERVER_EMAILING' , getDolGlobalString ( 'MAIN_MAIL_SMTP_SERVER' )) . ')</span>' ;
2024-02-09 15:58:49 +01:00
}
} elseif ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' ) != 'mail' && getDolGlobalString ( 'MAIN_MAIL_SMTP_SERVER' )) {
print ' <span class="opacitymedium">(' . getDolGlobalString ( 'MAIN_MAIL_SMTP_SERVER' ) . ')</span>' ;
}
} else {
print 'SMS ' ;
2023-04-23 21:42:05 +02:00
print ' <span class="opacitymedium">(' . getDolGlobalString ( 'MAIN_MAIL_SMTP_SERVER' ) . ')</span>' ;
}
print '</td></tr>' ;
2023-04-08 13:29:30 +02:00
// Other attributes. Fields from hook formObjectOptions and Extrafields.
2019-11-13 19:35:39 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2009-05-06 15:39:43 +02:00
print '</table>' ;
2023-04-08 13:29:30 +02:00
print '</div>' ;
print '</div>' ;
2005-02-12 00:41:42 +01:00
2023-04-08 13:29:30 +02:00
print '<div class="clearboth"></div>' ;
2017-06-07 16:44:04 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2009-01-25 23:04:55 +01:00
2017-06-07 16:44:04 +02:00
2009-05-06 15:39:43 +02:00
// Clone confirmation
2020-11-27 20:20:04 +01:00
if ( $action == 'clone' ) {
2008-11-20 22:30:23 +01:00
// Create an array for form
2019-11-13 19:35:39 +01:00
$formquestion = array (
2008-11-20 22:30:23 +01:00
'text' => $langs -> trans ( " ConfirmClone " ),
2024-03-12 21:31:53 +01:00
0 => array ( 'type' => 'checkbox' , 'name' => 'clone_content' , 'label' => $langs -> trans ( " CloneContent " ), 'value' => 1 ),
1 => array ( 'type' => 'checkbox' , 'name' => 'clone_receivers' , 'label' => $langs -> trans ( " CloneReceivers " ), 'value' => 0 )
2008-11-10 15:20:02 +01:00
);
2020-10-14 18:26:05 +02:00
// Incomplete payment. On demande si motif = escompte ou autre
2019-03-12 19:44:59 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'ToClone' ), $langs -> trans ( 'ConfirmCloneEMailing' , $object -> ref ), 'confirm_clone' , $formquestion , 'yes' , 2 , 240 );
2008-11-10 15:20:02 +01:00
}
2009-01-25 23:04:55 +01:00
2023-04-08 13:29:30 +02:00
// Actions Buttons
if ( GETPOST ( 'cancel' , 'alpha' ) || $confirm == 'no' || $action == '' || in_array ( $action , array ( 'settodraft' , 'valid' , 'delete' , 'sendall' , 'clone' , 'test' , 'editevenunsubscribe' ))) {
2009-05-06 15:39:43 +02:00
print " \n \n <div class= \" tabsAction \" > \n " ;
2005-02-12 00:41:42 +01:00
2024-02-09 15:58:49 +01:00
if (( $object -> status == 1 ) && ( $user -> hasRight ( 'mailing' , 'valider' ) || $object -> user_validation_id == $user -> id )) {
2021-09-19 18:03:38 +02:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=settodraft&token=' . newToken () . '&id=' . $object -> id . '">' . $langs -> trans ( " SetToDraft " ) . '</a>' ;
2017-01-29 15:31:22 +01:00
}
2024-02-09 15:58:49 +01:00
if (( $object -> status == 0 || $object -> status == 1 || $object -> status == 2 ) && $user -> hasRight ( 'mailing' , 'creer' )) {
2024-12-29 19:45:13 +01:00
if ( isModEnabled ( 'fckeditor' ) && getDolGlobalInt ( 'FCKEDITOR_ENABLE_MAILING' ) && $object -> messtype != 'sms' ) {
2024-06-18 09:58:20 +02:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=edit&token=' . newToken () . '&id=' . $object -> id . '">' . $langs -> trans ( " Edit " ) . '</a>' ;
2020-05-21 15:05:19 +02:00
} else {
2024-02-09 15:58:49 +01:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=edittxt&token=' . newToken () . '&id=' . $object -> id . '">' . $langs -> trans ( " EditWithTextEditor " ) . '</a>' ;
2017-09-15 11:19:56 +02:00
}
2017-09-01 13:09:13 +02:00
2024-02-09 15:58:49 +01:00
if ( ! getDolGlobalInt ( 'EMAILINGS_SUPPORT_ALSO_SMS' )) {
if ( ! empty ( $conf -> use_javascript_ajax )) {
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=edithtml&token=' . newToken () . '&id=' . $object -> id . '">' . $langs -> trans ( " EditHTMLSource " ) . '</a>' ;
}
2020-11-27 20:20:04 +01:00
}
2009-05-06 15:39:43 +02:00
}
2005-02-12 00:41:42 +01:00
2014-09-18 21:18:25 +02:00
//print '<a class="butAction" href="card.php?action=test&id='.$object->id.'">'.$langs->trans("PreviewMailing").'</a>';
2012-06-17 18:40:45 +02:00
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MAIN_USE_ADVANCED_PERMS' ) && ! $user -> hasRight ( 'mailing' , 'mailing_advance' , 'send' )) {
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NotEnoughPermissions " )) . '">' . $langs -> trans ( " TestMailing " ) . '</a>' ;
2020-05-21 15:05:19 +02:00
} else {
2021-09-19 18:03:38 +02:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=test&token=' . newToken () . '&id=' . $object -> id . '">' . $langs -> trans ( " TestMailing " ) . '</a>' ;
2012-06-13 21:45:47 +02:00
}
2005-02-12 00:41:42 +01:00
2024-02-09 15:58:49 +01:00
if ( $object -> status == 0 ) {
2020-11-27 20:20:04 +01:00
if ( $object -> nbemail <= 0 ) {
2024-02-09 15:58:49 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NoTargetYet " )) . '">' . $langs -> trans ( " Validate " ) . '</a>' ;
2023-10-10 09:14:30 +02:00
} elseif ( ! $user -> hasRight ( 'mailing' , 'valider' )) {
2024-02-09 15:58:49 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NotEnoughPermissions " )) . '">' . $langs -> trans ( " Validate " ) . '</a>' ;
2020-05-21 15:05:19 +02:00
} else {
2024-02-09 15:58:49 +01:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=valid&id=' . $object -> id . '">' . $langs -> trans ( " Validate " ) . '</a>' ;
2010-07-11 13:36:35 +02:00
}
2009-05-06 15:39:43 +02:00
}
2005-02-12 00:41:42 +01:00
2024-02-09 15:58:49 +01:00
if (( $object -> status == 1 || $object -> status == 2 ) && $object -> nbemail > 0 && $user -> hasRight ( 'mailing' , 'valider' )) {
2023-11-27 12:24:18 +01:00
if ( getDolGlobalInt ( 'MAILING_LIMIT_SENDBYWEB' ) < 0 ) {
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " SendingFromWebInterfaceIsNotAllowed " )) . '">' . $langs -> trans ( " SendMailing " ) . '</a>' ;
2023-11-27 11:39:32 +01:00
} elseif ( getDolGlobalString ( 'MAIN_USE_ADVANCED_PERMS' ) && ! $user -> hasRight ( 'mailing' , 'mailing_advance' , 'send' )) {
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NotEnoughPermissions " )) . '">' . $langs -> trans ( " SendMailing " ) . '</a>' ;
2020-05-21 15:05:19 +02:00
} else {
2012-03-23 20:03:57 +01:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=sendall&id=' . $object -> id . '">' . $langs -> trans ( " SendMailing " ) . '</a>' ;
2011-01-21 11:58:05 +01:00
}
2009-05-06 15:39:43 +02:00
}
2005-02-15 22:17:36 +01:00
2022-10-22 14:43:22 +02:00
if ( $user -> hasRight ( 'mailing' , 'creer' )) {
2012-03-23 20:03:57 +01:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=clone&object=emailing&id=' . $object -> id . '">' . $langs -> trans ( " ToClone " ) . '</a>' ;
2009-05-06 15:39:43 +02:00
}
2008-11-10 15:20:02 +01:00
2024-02-09 15:58:49 +01:00
if (( $object -> status == 2 || $object -> status == 3 ) && $user -> hasRight ( 'mailing' , 'valider' )) {
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MAIN_USE_ADVANCED_PERMS' ) && ! $user -> hasRight ( 'mailing' , 'mailing_advance' , 'send' )) {
2018-11-13 21:40:17 +01:00
print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NotEnoughPermissions " )) . '">' . $langs -> trans ( " ResetMailing " ) . '</a>' ;
2020-05-21 15:05:19 +02:00
} else {
2012-06-13 21:45:47 +02:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=reset&id=' . $object -> id . '">' . $langs -> trans ( " ResetMailing " ) . '</a>' ;
}
2009-05-06 15:39:43 +02:00
}
2009-02-18 22:48:07 +01:00
2024-02-09 15:58:49 +01:00
if (( $object -> status <= 1 && $user -> hasRight ( 'mailing' , 'creer' )) || $user -> hasRight ( 'mailing' , 'supprimer' )) {
if ( $object -> status > 0 && ( getDolGlobalString ( 'MAIN_USE_ADVANCED_PERMS' ) && ! $user -> hasRight ( 'mailing' , 'mailing_advance' , 'delete' ))) {
print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NotEnoughPermissions " )) . '">' . $langs -> trans ( " Delete " ) . '</a>' ;
2020-05-21 15:05:19 +02:00
} else {
2024-02-09 15:58:49 +01:00
print '<a class="butActionDelete" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=delete&token=' . newToken () . '&id=' . $object -> id . ( ! empty ( $urlfrom ) ? '&urlfrom=' . $urlfrom : '' ) . '">' . $langs -> trans ( " Delete " ) . '</a>' ;
2012-06-14 20:08:46 +02:00
}
2009-05-06 15:39:43 +02:00
}
2005-02-12 00:41:42 +01:00
2016-05-06 12:15:44 +02:00
print '</div>' ;
2009-05-06 15:39:43 +02:00
}
2005-02-12 00:41:42 +01:00
2020-10-14 18:26:05 +02:00
// Display of the TEST form
2020-11-27 20:20:04 +01:00
if ( $action == 'test' ) {
2020-10-31 14:32:18 +01:00
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>' ;
print load_fiche_titre ( $langs -> trans ( " TestMailing " ));
2009-05-06 15:39:43 +02:00
2024-09-18 02:45:54 +02:00
print dol_get_fiche_head ([], '' , '' , - 1 );
2018-03-02 11:18:29 +01:00
2020-10-31 14:32:18 +01:00
// Create mail form object
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php' ;
2009-05-06 15:39:43 +02:00
$formmail = new FormMail ( $db );
2012-03-23 20:03:57 +01:00
$formmail -> fromname = $object -> email_from ;
$formmail -> frommail = $object -> email_from ;
2024-03-11 12:58:51 +01:00
$formmail -> withsubstit = 0 ;
2019-11-13 19:35:39 +01:00
$formmail -> withfrom = 0 ;
$formmail -> withto = $user -> email ? $user -> email : 1 ;
$formmail -> withtocc = 0 ;
2024-01-05 04:18:53 +01:00
$formmail -> withtoccc = getDolGlobalString ( 'MAIN_EMAIL_USECCC' );
2019-11-13 19:35:39 +01:00
$formmail -> withtopic = 0 ;
$formmail -> withtopicreadonly = 1 ;
$formmail -> withfile = 0 ;
2024-10-14 23:38:14 +02:00
$formmail -> withlayout = '' ;
2024-03-12 10:01:39 +01:00
$formmail -> withaiprompt = '' ;
2019-11-13 19:35:39 +01:00
$formmail -> withbody = 0 ;
$formmail -> withbodyreadonly = 1 ;
$formmail -> withcancel = 1 ;
$formmail -> withdeliveryreceipt = 0 ;
2020-10-14 18:26:05 +02:00
// Table of substitutions
2019-11-13 19:35:39 +01:00
$formmail -> substit = $object -> substitutionarrayfortest ;
2020-10-14 18:26:05 +02:00
// Table of post's complementary params
2019-11-13 19:35:39 +01:00
$formmail -> param [ " action " ] = " send " ;
$formmail -> param [ " models " ] = 'none' ;
$formmail -> param [ " mailid " ] = $object -> id ;
$formmail -> param [ " returnurl " ] = $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id ;
2009-05-06 15:39:43 +02:00
2014-02-19 20:23:02 +01:00
print $formmail -> get_form ();
2009-01-25 23:04:55 +01:00
2009-05-06 15:39:43 +02:00
print '<br>' ;
2018-03-02 11:18:29 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2018-03-02 11:18:29 +01:00
2022-05-19 13:08:00 +02:00
dol_set_focus ( '#sendto' );
2009-05-06 15:39:43 +02:00
}
2015-07-04 03:28:52 +02:00
2022-11-29 01:24:04 +01:00
$htmltext = '<i>' . $langs -> trans ( " FollowingConstantsWillBeSubstituted " ) . ':<br><br><span class="small">' ;
2020-11-27 20:20:04 +01:00
foreach ( $object -> substitutionarray as $key => $val ) {
2019-11-13 19:35:39 +01:00
$htmltext .= $key . ' = ' . $langs -> trans ( $val ) . '<br>' ;
2016-11-11 01:15:41 +01:00
}
2022-11-29 01:24:04 +01:00
$htmltext .= '</span></i>' ;
2017-06-07 16:44:04 +02:00
2016-11-11 01:15:41 +01:00
// Print mail content
2022-11-29 01:24:04 +01:00
print load_fiche_titre ( $langs -> trans ( " EMail " ), $form -> textwithpicto ( '<span class="opacitymedium hideonsmartphone">' . $langs -> trans ( " AvailableVariables " ) . '</span>' , $htmltext , 1 , 'helpclickable' , '' , 0 , 3 , 'emailsubstitionhelp' ), 'generic' );
2017-06-07 16:44:04 +02:00
2024-09-18 02:45:54 +02:00
print dol_get_fiche_head ([], '' , '' , - 1 );
2017-06-07 16:44:04 +02:00
2022-11-29 01:24:04 +01:00
print '<table class="bordernooddeven tableforfield centpercent">' ;
2010-04-17 11:47:25 +02:00
// Subject
2024-02-09 15:58:49 +01:00
if ( $object -> messtype != 'sms' ) {
print '<tr><td class="titlefield">' . $langs -> trans ( " MailTopic " ) . '</td><td colspan="3">' . $object -> sujet . '</td></tr>' ;
}
2010-04-17 11:47:25 +02:00
2011-06-11 04:25:05 +02:00
// Joined files
2024-02-09 15:58:49 +01:00
if ( $object -> messtype != 'sms' ) {
print '<tr><td>' . $langs -> trans ( " MailFile " ) . '</td><td colspan="3">' ;
// List of files
$listofpaths = dol_dir_list ( $upload_dir , 'all' , 0 , '' , '' , 'name' , SORT_ASC , 0 );
if ( count ( $listofpaths )) {
foreach ( $listofpaths as $key => $val ) {
print img_mime ( $listofpaths [ $key ][ 'name' ]) . ' ' . $listofpaths [ $key ][ 'name' ];
print '<br>' ;
}
} else {
print '<span class="opacitymedium">' . $langs -> trans ( " NoAttachedFiles " ) . '</span><br>' ;
2010-04-17 15:23:50 +02:00
}
2024-02-09 15:58:49 +01:00
print '</td></tr>' ;
2011-11-21 13:17:14 +01:00
}
2010-04-17 11:47:25 +02:00
2020-10-31 14:32:18 +01:00
// Background color
/* print '<tr><td width="15%">' . $langs -> trans ( " BackgroundColorByDefault " ) . '</td><td colspan="3">' ;
2020-11-27 20:20:04 +01:00
print $htmlother -> selectColor ( $object -> bgcolor , 'bgcolor' , '' , 0 );
print '</td></tr>' ; */
2017-06-07 16:44:04 +02:00
2016-11-11 01:15:41 +01:00
print '</table>' ;
2017-06-07 16:44:04 +02:00
2020-10-31 14:32:18 +01:00
// Message
2019-11-13 19:35:39 +01:00
print '<div style="padding-top: 10px; background: ' . ( $object -> bgcolor ? ( preg_match ( '/^#/' , $object -> bgcolor ) ? '' : '#' ) . $object -> bgcolor : 'white' ) . '">' ;
2020-11-27 20:20:04 +01:00
if ( empty ( $object -> bgcolor ) || strtolower ( $object -> bgcolor ) == 'ffffff' ) { // CKEditor does not apply the color of the div into its content area
2019-11-13 19:35:39 +01:00
$readonly = 1 ;
2020-10-14 18:26:05 +02:00
// wysiwyg editor
2013-03-30 14:27:13 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2025-01-23 01:29:29 +01:00
$doleditor = new DolEditor ( 'bodyemail' , $object -> body , '' , 600 , 'dolibarr_mailings' , '' , false , - 1 , getDolGlobalInt ( 'FCKEDITOR_ENABLE_MAILING' ), 20 , '100%' , $readonly );
2013-03-24 19:00:58 +01:00
$doleditor -> Create ();
2020-11-27 20:20:04 +01:00
} else {
print dol_htmlentitiesbr ( $object -> body );
}
2016-11-11 01:15:41 +01:00
print '</div>' ;
2015-07-04 03:28:52 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2020-05-21 15:05:19 +02:00
} else {
2009-05-06 15:39:43 +02:00
/*
2020-10-14 18:26:05 +02:00
* Edition mode mailing ( CKeditor or HTML source )
2009-05-06 15:39:43 +02:00
*/
2017-06-07 16:44:04 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'card' , $langs -> trans ( " Mailing " ), - 1 , 'email' );
2017-06-07 16:44:04 +02:00
2019-12-05 15:22:06 +01:00
$linkback = '<a href="' . DOL_URL_ROOT . '/comm/mailing/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2016-05-06 12:15:44 +02:00
2023-04-08 13:29:30 +02:00
$morehtmlref = '<div class="refidno">' ;
// Ref customer
$morehtmlref .= $form -> editfieldkey ( " " , 'title' , $object -> title , $object , $user -> hasRight ( 'mailing' , 'creer' ), 'string' , '' , 0 , 1 );
$morehtmlref .= $form -> editfieldval ( " " , 'title' , $object -> title , $object , $user -> hasRight ( 'mailing' , 'creer' ), 'string' , '' , null , null , '' , 1 );
$morehtmlref .= '</div>' ;
2024-03-12 19:49:52 +01:00
$morehtmlstatus = '' ;
2023-04-08 13:29:30 +02:00
$nbtry = $nbok = 0 ;
2024-02-09 15:58:49 +01:00
if ( $object -> status == 2 || $object -> status == 3 ) {
2023-04-08 13:29:30 +02:00
$nbtry = $object -> countNbOfTargets ( 'alreadysent' );
$nbko = $object -> countNbOfTargets ( 'alreadysentko' );
2024-03-12 19:49:52 +01:00
$morehtmlstatus .= ' (' . $nbtry . '/' . $object -> nbemail ;
2023-04-08 13:29:30 +02:00
if ( $nbko ) {
2024-03-12 19:49:52 +01:00
$morehtmlstatus .= ' - ' . $nbko . ' ' . $langs -> trans ( " Error " );
2023-04-08 13:29:30 +02:00
}
2024-03-12 19:49:52 +01:00
$morehtmlstatus .= ') ' ;
2020-11-27 20:20:04 +01:00
}
2017-06-07 16:44:04 +02:00
2024-03-12 19:49:52 +01:00
dol_banner_tab ( $object , 'id' , $linkback , 1 , 'rowid' , 'ref' , $morehtmlref , '' , 0 , '' , $morehtmlstatus );
2017-06-07 16:44:04 +02:00
2017-04-17 13:02:40 +02:00
print '<div class="fichecenter">' ;
2023-04-08 13:29:30 +02:00
print '<div class="fichehalfleft">' ;
2016-11-11 01:55:53 +01:00
print '<div class="underbanner clearboth"></div>' ;
2023-04-08 13:29:30 +02:00
print '<table class="border centpercent tableforfield">' ;
2016-11-11 01:15:41 +01:00
2016-11-11 01:55:53 +01:00
/*
2016-07-06 22:28:13 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Ref " ) . '</td>' ;
2016-05-06 12:15:44 +02:00
print '<td colspan="3">' ;
print $form -> showrefnav ( $object , 'id' , $linkback );
print '</td></tr>' ;
2016-11-11 01:55:53 +01:00
*/
2017-06-07 16:44:04 +02:00
2012-05-09 17:15:44 +02:00
// From
2024-02-09 15:58:49 +01:00
print '<tr><td class="titlefield">' ;
print $langs -> trans ( " MailFrom " );
print '</td><td>' . dol_print_email ( $object -> email_from , 0 , 0 , 0 , 0 , 1 ) . '</td></tr>' ;
2012-05-09 17:15:44 +02:00
// To
2024-02-09 15:58:49 +01:00
if ( $object -> messtype != 'sms' ) {
print '<tr><td>' . $langs -> trans ( " MailErrorsTo " ) . '</td><td>' . dol_print_email ( $object -> email_errorsto , 0 , 0 , 0 , 0 , 1 ) . '</td></tr>' ;
2024-10-19 01:16:51 +02:00
print '<tr><td>' . $langs -> trans ( " MailReply " ) . '</td><td>' . dol_print_email ( $object -> email_replyto , 0 , 0 , 0 , 0 , 1 ) . '</td></tr>' ;
2024-02-09 15:58:49 +01:00
}
2010-04-17 11:47:25 +02:00
2023-04-08 17:16:22 +02:00
print '</table>' ;
print '</div>' ;
print '<div class="fichehalfright">' ;
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border centpercent tableforfield">' ;
2020-10-14 18:26:05 +02:00
// Number of distinct emails
2016-05-06 12:15:44 +02:00
print '<tr><td>' ;
2010-04-17 11:47:25 +02:00
print $langs -> trans ( " TotalNbOfDistinctRecipients " );
2023-04-23 21:42:05 +02:00
print '</td><td>' ;
2019-11-13 19:35:39 +01:00
$nbemail = ( $object -> nbemail ? $object -> nbemail : 0 );
2020-11-27 20:20:04 +01:00
if ( is_numeric ( $nbemail )) {
2019-11-13 19:35:39 +01:00
$text = '' ;
2024-02-09 15:58:49 +01:00
if (( getDolGlobalString ( 'MAILING_LIMIT_SENDBYWEB' ) && $conf -> global -> MAILING_LIMIT_SENDBYWEB < $nbemail ) && ( $object -> status == 1 || $object -> status == 2 )) {
2023-11-27 12:24:18 +01:00
if ( getDolGlobalInt ( 'MAILING_LIMIT_SENDBYWEB' ) > 0 ) {
2024-01-05 04:18:53 +01:00
$text .= $langs -> trans ( 'LimitSendingEmailing' , getDolGlobalString ( 'MAILING_LIMIT_SENDBYWEB' ));
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:35:39 +01:00
$text .= $langs -> trans ( 'SendingFromWebInterfaceIsNotAllowed' );
2018-01-26 15:12:40 +01:00
}
}
2020-11-27 20:20:04 +01:00
if ( empty ( $nbemail )) {
2021-10-05 09:10:37 +02:00
$nbemail .= ' ' . img_warning ( '' ) . ' <span class="warning">' . $langs -> trans ( " NoTargetYet " ) . '</span>' ;
2020-11-27 20:20:04 +01:00
}
if ( $text ) {
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( $nbemail , $text , 1 , 'warning' );
2020-05-21 15:05:19 +02:00
} else {
2018-01-26 15:12:40 +01:00
print $nbemail ;
}
2010-04-17 11:47:25 +02:00
}
print '</td></tr>' ;
2012-06-17 18:40:45 +02:00
2023-04-23 21:42:05 +02:00
print '<tr><td>' ;
print $langs -> trans ( " MAIN_MAIL_SENDMODE " );
print '</td><td>' ;
if ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE_EMAILING' ) && getDolGlobalString ( 'MAIN_MAIL_SENDMODE_EMAILING' ) != 'default' ) {
$text = $listofmethods [ getDolGlobalString ( 'MAIN_MAIL_SENDMODE_EMAILING' )];
} elseif ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' )) {
$text = $listofmethods [ getDolGlobalString ( 'MAIN_MAIL_SENDMODE' )];
} else {
$text = $listofmethods [ 'mail' ];
}
print $text ;
if ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE_EMAILING' ) != 'default' ) {
if ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE_EMAILING' ) != 'mail' ) {
print ' <span class="opacitymedium">(' . getDolGlobalString ( 'MAIN_MAIL_SMTP_SERVER_EMAILING' ) . ')</span>' ;
}
} elseif ( getDolGlobalString ( 'MAIN_MAIL_SENDMODE' ) != 'mail' && getDolGlobalString ( 'MAIN_MAIL_SMTP_SERVER' )) {
print ' <span class="opacitymedium">(' . getDolGlobalString ( 'MAIN_MAIL_SMTP_SERVER' ) . ')</span>' ;
}
print '</td></tr>' ;
2012-06-15 11:20:09 +02:00
// Other attributes
2019-11-13 19:35:39 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2020-10-31 14:32:18 +01:00
print $hookmanager -> resPrint ;
2020-11-27 20:20:04 +01:00
if ( empty ( $reshook )) {
2019-11-16 14:38:05 +01:00
print $object -> showOptionals ( $extrafields , 'edit' , $parameters );
2012-06-13 09:26:29 +02:00
}
2010-04-17 11:47:25 +02:00
print '</table>' ;
2017-04-17 13:02:40 +02:00
print '</div>' ;
2023-04-08 13:29:30 +02:00
print '</div>' ;
2016-02-08 12:20:40 +01:00
2023-04-08 13:29:30 +02:00
print '<div class="clearboth"></div>' ;
2016-02-08 12:20:40 +01:00
2023-04-08 13:29:30 +02:00
print dol_get_fiche_end ();
2016-02-08 12:20:40 +01:00
2010-04-17 11:47:25 +02:00
2023-04-08 13:29:30 +02:00
print " <br><br> \n " ;
2017-06-07 16:44:04 +02:00
2014-09-18 21:18:25 +02:00
print '<form name="edit_mailing" action="card.php" method="post" enctype="multipart/form-data">' . " \n " ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2009-05-06 15:39:43 +02:00
print '<input type="hidden" name="action" value="update">' ;
2012-03-23 20:03:57 +01:00
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
2017-06-07 16:44:04 +02:00
2023-04-08 13:29:30 +02:00
$htmltext = '<i>' . $langs -> trans ( " FollowingConstantsWillBeSubstituted " ) . ':<br><br><span class="small">' ;
2020-11-27 20:20:04 +01:00
foreach ( $object -> substitutionarray as $key => $val ) {
2019-11-13 19:35:39 +01:00
$htmltext .= $key . ' = ' . $langs -> trans ( $val ) . '<br>' ;
2016-11-11 01:15:41 +01:00
}
2023-04-08 13:29:30 +02:00
$htmltext .= '</span></i>' ;
2017-06-07 16:44:04 +02:00
2010-04-17 11:47:25 +02:00
// Print mail content
2023-04-08 13:29:30 +02:00
print load_fiche_titre ( $langs -> trans ( " EMail " ), '<span class="opacitymedium">' . $form -> textwithpicto ( $langs -> trans ( " AvailableVariables " ) . '</span>' , $htmltext , 1 , 'help' , '' , 0 , 2 , 'emailsubstitionhelp' ), 'generic' );
2015-11-05 03:02:31 +01:00
2024-09-18 02:45:54 +02:00
print dol_get_fiche_head ([], '' , '' , - 1 );
2017-06-07 16:44:04 +02:00
2023-04-08 13:29:30 +02:00
print '<table class="bordernooddeven centpercent">' ;
2009-05-06 15:39:43 +02:00
2011-06-11 04:25:05 +02:00
// Subject
2024-02-09 15:58:49 +01:00
if ( $object -> messtype != 'sms' ) {
print '<tr><td class="fieldrequired titlefield">' ;
print $langs -> trans ( " MailTopic " );
print '</td><td colspan="3"><input class="flat quatrevingtpercent" type="text" name="sujet" value="' . $object -> sujet . '"></td></tr>' ;
}
2010-04-17 11:47:25 +02:00
2019-11-13 19:35:39 +01:00
$trackid = '' ; // TODO To avoid conflicts with 2 mass emailing, we should set a trackid here, even if we use another one into email header.
2016-06-24 16:10:52 +02:00
dol_init_file_process ( $upload_dir , $trackid );
2011-12-17 13:51:31 +01:00
2011-06-11 04:25:05 +02:00
// Joined files
2024-02-09 15:58:49 +01:00
if ( $object -> messtype != 'sms' ) {
$addfileaction = 'addfile' ;
print '<tr><td>' . $langs -> trans ( " MailFile " ) . '</td>' ;
print '<td colspan="3">' ;
// List of files
$listofpaths = dol_dir_list ( $upload_dir , 'all' , 0 , '' , '' , 'name' , SORT_ASC , 0 );
2024-03-18 12:18:06 +01:00
$out = '' ;
2024-02-09 15:58:49 +01:00
// TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
$out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">' . " \n " ;
$out .= '<script type="text/javascript">' ;
$out .= 'jQuery(document).ready(function () {' ;
$out .= ' jQuery(".removedfile").click(function() {' ;
$out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());' ;
$out .= ' });' ;
$out .= '})' ;
$out .= '</script>' . " \n " ;
if ( count ( $listofpaths )) {
foreach ( $listofpaths as $key => $val ) {
$out .= '<div id="attachfile_' . $key . '">' ;
$out .= img_mime ( $listofpaths [ $key ][ 'name' ]) . ' ' . $listofpaths [ $key ][ 'name' ];
2024-09-25 22:21:31 +02:00
$out .= ' <input type="image" style="border: 0px;" src="' . img_picto ( $langs -> trans ( " Search " ), 'delete.png' , '' , 0 , 1 ) . '" value="' . ( $key + 1 ) . '" class="removedfile" id="removedfile_' . $key . '" name="removedfile_' . $key . '" />' ;
2024-02-09 15:58:49 +01:00
$out .= '<br></div>' ;
}
} else {
//$out .= '<span class="opacitymedium">'.$langs->trans("NoAttachedFiles").'</span><br>';
}
2017-09-01 13:09:13 +02:00
2024-02-09 15:58:49 +01:00
// Add link to add file
$maxfilesizearray = getMaxFileSizeArray ();
$maxmin = $maxfilesizearray [ 'maxmin' ];
if ( $maxmin > 0 ) {
$out .= '<input type="hidden" name="MAX_FILE_SIZE" value="' . ( $maxmin * 1024 ) . '">' ; // MAX_FILE_SIZE must precede the field type=file
2010-04-17 15:23:50 +02:00
}
2024-02-09 15:58:49 +01:00
$out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="' . $langs -> trans ( " Upload " ) . '" />' ;
$out .= ' ' ;
$out .= '<input type="submit" class="button smallpaddingimp" id="' . $addfileaction . '" name="' . $addfileaction . '" value="' . $langs -> trans ( " MailingAddFile " ) . '" />' ;
print $out ;
print '</td></tr>' ;
// Background color
print '<tr><td>' . $langs -> trans ( " BackgroundColorByDefault " ) . '</td><td colspan="3">' ;
print $htmlother -> selectColor ( $object -> bgcolor , 'bgcolor' , '' , 0 );
print '</td></tr>' ;
2011-11-21 13:17:14 +01:00
}
2022-10-23 20:45:27 +02:00
2016-11-11 01:15:41 +01:00
print '</table>' ;
2017-06-07 16:44:04 +02:00
2023-04-08 13:29:30 +02:00
2011-06-11 04:25:05 +02:00
// Message
2016-11-11 01:15:41 +01:00
print '<div style="padding-top: 10px">' ;
2017-09-01 13:09:13 +02:00
2020-11-27 20:20:04 +01:00
if ( $action == 'edit' ) {
2020-10-14 18:26:05 +02:00
// wysiwyg editor
2017-09-01 13:09:13 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2025-01-23 01:29:29 +01:00
$doleditor = new DolEditor ( 'bodyemail' , $object -> body , '' , 600 , 'dolibarr_mailings' , '' , true , - 1 , getDolGlobalInt ( 'FCKEDITOR_ENABLE_MAILING' ), 20 , '100%' );
2017-09-01 13:09:13 +02:00
$doleditor -> Create ();
}
2024-02-09 15:58:49 +01:00
if ( $action == 'edittxt' ) {
// wysiwyg editor
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2025-01-23 01:29:29 +01:00
$doleditor = new DolEditor ( 'bodyemail' , $object -> body , '' , 600 , 'dolibarr_mailings' , '' , true , - 1 , 0 , 20 , '100%' );
2024-02-09 15:58:49 +01:00
$doleditor -> Create ();
}
2020-11-27 20:20:04 +01:00
if ( $action == 'edithtml' ) {
2020-10-14 18:26:05 +02:00
// HTML source editor
2017-09-01 13:09:13 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2025-01-23 01:29:29 +01:00
$doleditor = new DolEditor ( 'bodyemail' , $object -> body , '' , 600 , 'dolibarr_mailings' , '' , true , - 1 , 'ace' , 20 , '100%' );
2017-09-01 13:09:13 +02:00
$doleditor -> Create ( 0 , '' , false , 'HTML Source' , 'php' );
}
2016-11-11 01:15:41 +01:00
print '</div>' ;
2009-05-06 15:39:43 +02:00
2013-03-24 19:00:58 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2016-02-08 12:20:40 +01:00
2015-11-05 03:02:31 +01:00
print '<div class="center">' ;
2020-11-19 20:23:38 +01:00
print '<input type="submit" class="button buttonforacesave button-save" value="' . $langs -> trans ( " Save " ) . '" name="save">' ;
2022-11-23 20:31:26 +01:00
print ' ' ;
2020-11-23 15:12:52 +01:00
print '<input type="submit" class="button button-cancel" value="' . $langs -> trans ( " Cancel " ) . '" name="cancel">' ;
2014-11-25 20:13:43 +01:00
print '</div>' ;
2009-05-06 15:39:43 +02:00
2010-04-17 11:47:25 +02:00
print '</form>' ;
print '<br>' ;
2009-05-06 15:39:43 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
dol_print_error ( $db , $object -> error );
2009-05-20 13:20:49 +02:00
}
2005-02-12 00:41:42 +01:00
}
2005-01-05 16:26:05 +01:00
2018-07-29 17:17:29 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-03-23 20:03:57 +01:00
$db -> close ();