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 >
2016-11-11 01:15:41 +01:00
* Copyright ( C ) 2005 - 2016 Laurent Destailleur < eldy @ uers . sourceforge . net >
2016-02-08 12:20:40 +01:00
* Copyright ( C ) 2005 - 2016 Regis Houssin < regis . houssin @ capnetworks . com >
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
2011-08-03 02:45:22 +02:00
* along with this program . If not , see < http :// 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
2013-03-24 19:00:58 +01:00
if ( ! defined ( 'NOSTYLECHECK' )) define ( 'NOSTYLECHECK' , '1' );
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
2018-05-26 20:32:23 +02:00
// Load translation files required by the page
2005-01-14 20:24:00 +01:00
$langs -> load ( " mails " );
2012-06-15 13:58:18 +02:00
if ( ! $user -> rights -> mailing -> lire || ( empty ( $conf -> global -> EXTERNAL_USERS_ARE_AUTHORIZED ) && $user -> societe_id > 0 )) accessforbidden ();
2005-04-07 01:49:06 +02:00
2012-03-23 20:03:57 +01:00
$id = ( GETPOST ( 'mailid' , 'int' ) ? GETPOST ( 'mailid' , 'int' ) : GETPOST ( 'id' , 'int' ));
$action = GETPOST ( 'action' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
2012-06-13 21:45:47 +02:00
$urlfrom = GETPOST ( 'urlfrom' );
2012-06-14 20:08:46 +02:00
2012-03-23 20:03:57 +01:00
$object = new Mailing ( $db );
2012-06-13 09:26:29 +02:00
$result = $object -> fetch ( $id );
2012-03-23 20:03:57 +01:00
2012-06-13 09:26:29 +02:00
$extrafields = new ExtraFields ( $db );
2013-04-01 19:43:26 +02:00
// fetch optionals attributes and labels
2013-04-26 10:29:14 +02:00
$extralabels = $extrafields -> fetch_name_optionals_label ( $object -> table_element );
2013-04-01 19:43:26 +02:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2014-10-06 07:20:58 +02:00
$hookmanager -> initHooks ( array ( 'mailingcard' , 'globalcard' ));
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)
2016-03-05 12:20:58 +01:00
$object -> substitutionarray = FormMail :: getAvailableSubstitKey ( 'emailing' );
2017-09-22 14:34:31 +02:00
// Set $object->substitutionarrayfortest
$signature = (( ! empty ( $user -> signature ) && empty ( $conf -> global -> MAIN_MAIL_DO_NOT_USE_SIGN )) ? $user -> signature : '' );
$targetobject = null ; // Not defined with mass emailing
$parameters = array ( 'mode' => 'emailing' );
$substitutionarray = FormMail :: getAvailableSubstitKey ( 'emailing' , $targetobject );
$object -> substitutionarrayfortest = $substitutionarray ;
2013-11-16 13:00:21 +01:00
2014-11-29 13:50:41 +01:00
// List of sending methods
$listofmethods = array ();
$listofmethods [ 'mail' ] = 'PHP mail function' ;
//$listofmethods['simplemail']='Simplemail class';
$listofmethods [ 'smtps' ] = 'SMTP/SMTPS socket library' ;
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
*/
2012-06-15 11:20:09 +02:00
$parameters = array ();
2012-06-13 09:26:29 +02:00
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2014-09-28 03:41:32 +02:00
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2012-06-13 09:26:29 +02:00
2015-01-18 17:13:42 +01:00
if ( empty ( $reshook ))
2008-11-10 15:20:02 +01:00
{
2015-01-17 19:28:27 +01:00
// Action clone object
if ( $action == 'confirm_clone' && $confirm == 'yes' )
2008-11-10 15:20:02 +01:00
{
2015-01-17 19:28:27 +01:00
if ( empty ( $_REQUEST [ " clone_content " ]) && empty ( $_REQUEST [ " clone_receivers " ]))
2008-11-10 15:20:02 +01:00
{
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> trans ( " NoCloneOptionsSpecified " ), null , 'errors' );
2008-11-10 15:20:02 +01:00
}
2008-11-20 22:30:23 +01:00
else
{
2015-01-17 19:28:27 +01:00
$result = $object -> createFromClone ( $object -> id , $_REQUEST [ " clone_content " ], $_REQUEST [ " clone_receivers " ]);
if ( $result > 0 )
{
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . '?id=' . $result );
exit ;
}
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
}
2015-01-17 19:28:27 +01:00
$action = '' ;
2008-11-10 15:20:02 +01:00
}
2015-01-17 19:28:27 +01:00
// Action send emailing for everybody
if ( $action == 'sendallconfirmed' && $confirm == 'yes' )
2008-02-29 17:26:38 +01:00
{
2015-01-17 19:28:27 +01:00
if ( empty ( $conf -> global -> MAILING_LIMIT_SENDBYWEB ))
2008-02-29 17:26:38 +01:00
{
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' );
2015-01-17 19:28:27 +01:00
$action = '' ;
2008-02-29 17:26:38 +01:00
}
2015-01-17 19:28:27 +01:00
else if ( $conf -> global -> MAILING_LIMIT_SENDBYWEB < 0 )
2008-02-29 17:26:38 +01:00
{
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> trans ( " NotEnoughPermissions " ), null , 'warnings' );
2015-01-17 19:28:27 +01:00
$action = '' ;
}
else
2008-02-29 17:26:38 +01:00
{
2015-05-18 22:25:51 +02:00
$upload_dir = $conf -> mailing -> dir_output . " / " . get_exdir ( $object -> id , 2 , 0 , 1 , $object , 'mailing' );
2008-02-29 17:26:38 +01:00
2015-01-17 19:28:27 +01:00
if ( $object -> statut == 0 )
2009-05-06 15:39:43 +02:00
{
2015-01-17 19:28:27 +01:00
dol_print_error ( '' , 'ErrorMailIsNotValidated' );
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 ;
$replyto = $object -> email_replyto ;
$errorsto = $object -> email_errorsto ;
// Le message est-il en html
$msgishtml =- 1 ; // Unknown by default
if ( preg_match ( '/[\s\t]*<html>/i' , $message )) $msgishtml = 1 ;
// Warning, we must not use begin-commit transaction here
// because we want to save update for each mail sent.
$nbok = 0 ; $nbko = 0 ;
// On choisit les mails non deja envoyes pour ce mailing (statut=0)
// ou envoyes en erreur (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 " ;
$sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = " . $object -> id ;
2018-01-29 12:58:33 +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 );
2015-01-17 19:28:27 +01:00
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql ); // nb of possible recipients
2008-08-04 01:45:53 +02:00
2015-01-17 19:28:27 +01:00
if ( $num )
2009-05-06 15:39:43 +02:00
{
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
2015-01-17 19:28:27 +01:00
$now = dol_now ();
2009-01-25 23:04:55 +01:00
2015-01-17 19:28:27 +01:00
// Positionne date debut envoi
2015-02-01 13:26:30 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " mailing SET date_envoi=' " . $db -> idate ( $now ) . " ' WHERE rowid= " . $object -> id ;
2015-01-17 19:28:27 +01:00
$resql2 = $db -> query ( $sql );
if ( ! $resql2 )
2014-01-15 17:21:13 +01:00
{
2015-01-17 19:28:27 +01:00
dol_print_error ( $db );
2010-04-17 15:23:50 +02:00
}
2015-01-17 19:28:27 +01:00
// Loop on each email and send it
$i = 0 ;
2009-01-25 23:04:55 +01:00
2015-01-17 19:28:27 +01:00
while ( $i < $num && $i < $conf -> global -> MAILING_LIMIT_SENDBYWEB )
2008-02-29 17:26:38 +01:00
{
2017-09-15 13:43:16 +02:00
// Here code is common with same loop ino mailing-send.php
2015-01-17 19:28:27 +01:00
$res = 1 ;
2017-09-15 13:43:16 +02:00
$now = dol_now ();
2015-01-17 19:28:27 +01:00
$obj = $db -> fetch_object ( $resql );
// sendto en RFC2822
$sendto = str_replace ( ',' , ' ' , dolGetFirstLastname ( $obj -> firstname , $obj -> lastname )) . " < " . $obj -> email . " > " ;
// Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ...
$other = explode ( ';' , $obj -> other );
$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
2016-02-08 12:31:40 +01:00
$signature = (( ! empty ( $user -> signature ) && empty ( $conf -> global -> MAIN_MAIL_DO_NOT_USE_SIGN )) ? $user -> signature : '' );
2016-02-08 12:20:40 +01:00
2017-09-22 14:34:31 +02:00
$targetobject = null ; // Not defined with mass emailing
$parameters = array ( 'mode' => 'emailing' );
2017-10-09 14:51:42 +02: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
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$substitutionarray [ '__ID__' ] = $obj -> source_id ;
$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 ;
2017-10-13 10:35:21 +02:00
$substitutionarray [ '__USER_SIGNATURE__' ] = $signature ; // Signature is empty when ran from command line or taken from user in parameter)
$substitutionarray [ '__SIGNATURE__' ] = $signature ; // For backward compatibility
2017-09-22 14:34:31 +02:00
$substitutionarray [ '__CHECK_READ__' ] = '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $obj -> tag . '&securitykey=' . urlencode ( $conf -> global -> MAILING_EMAIL_UNSUBSCRIBE_KEY ) . '" 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=' . $obj -> tag . '&unsuscrib=1&securitykey=' . urlencode ( $conf -> global -> MAILING_EMAIL_UNSUBSCRIBE_KEY ) . '" target="_blank">' . $langs -> trans ( " MailUnsubcribe " ) . '</a>' ;
2017-09-15 13:43:16 +02:00
$onlinepaymentenabled = 0 ;
if ( ! empty ( $conf -> paypal -> enabled )) $onlinepaymentenabled ++ ;
if ( ! empty ( $conf -> paybox -> enabled )) $onlinepaymentenabled ++ ;
if ( ! empty ( $conf -> stripe -> enabled )) $onlinepaymentenabled ++ ;
if ( $onlinepaymentenabled && ! empty ( $conf -> global -> PAYMENT_SECURITY_TOKEN ))
{
$substitutionarray [ '__SECUREKEYPAYMENT__' ] = dol_hash ( $conf -> global -> PAYMENT_SECURITY_TOKEN , 2 );
2017-09-22 14:34:31 +02:00
if ( empty ( $conf -> global -> PAYMENT_SECURITY_TOKEN_UNIQUE ))
{
$substitutionarray [ '__SECUREKEYPAYMENT_MEMBER__' ] = dol_hash ( $conf -> global -> PAYMENT_SECURITY_TOKEN , 2 );
$substitutionarray [ '__SECUREKEYPAYMENT_ORDER__' ] = dol_hash ( $conf -> global -> PAYMENT_SECURITY_TOKEN , 2 );
$substitutionarray [ '__SECUREKEYPAYMENT_INVOICE__' ] = dol_hash ( $conf -> global -> PAYMENT_SECURITY_TOKEN , 2 );
$substitutionarray [ '__SECUREKEYPAYMENT_CONTRACTLINE__' ] = dol_hash ( $conf -> global -> PAYMENT_SECURITY_TOKEN , 2 );
}
else
{
$substitutionarray [ '__SECUREKEYPAYMENT_MEMBER__' ] = dol_hash ( $conf -> global -> PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj -> source_id , 2 );
$substitutionarray [ '__SECUREKEYPAYMENT_ORDER__' ] = dol_hash ( $conf -> global -> PAYMENT_SECURITY_TOKEN . 'order' . $obj -> source_id , 2 );
$substitutionarray [ '__SECUREKEYPAYMENT_INVOICE__' ] = dol_hash ( $conf -> global -> PAYMENT_SECURITY_TOKEN . 'invoice' . $obj -> source_id , 2 );
$substitutionarray [ '__SECUREKEYPAYMENT_CONTRACTLINE__' ] = dol_hash ( $conf -> global -> PAYMENT_SECURITY_TOKEN . 'contractline' . $obj -> source_id , 2 );
}
2017-09-15 13:43:16 +02:00
}
2018-05-12 11:23:40 +02:00
/* For backward compatibility, deprecated */
2015-01-17 19:28:27 +01:00
if ( ! empty ( $conf -> paypal -> enabled ) && ! empty ( $conf -> global -> PAYPAL_SECURITY_TOKEN ))
{
$substitutionarray [ '__SECUREKEYPAYPAL__' ] = dol_hash ( $conf -> global -> PAYPAL_SECURITY_TOKEN , 2 );
2016-03-05 12:20:58 +01:00
2015-01-17 19:28:27 +01:00
if ( empty ( $conf -> global -> PAYPAL_SECURITY_TOKEN_UNIQUE )) $substitutionarray [ '__SECUREKEYPAYPAL_MEMBER__' ] = dol_hash ( $conf -> global -> PAYPAL_SECURITY_TOKEN , 2 );
else $substitutionarray [ '__SECUREKEYPAYPAL_MEMBER__' ] = dol_hash ( $conf -> global -> PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj -> source_id , 2 );
2016-03-05 12:20:58 +01:00
if ( empty ( $conf -> global -> PAYPAL_SECURITY_TOKEN_UNIQUE )) $substitutionarray [ '__SECUREKEYPAYPAL_ORDER__' ] = dol_hash ( $conf -> global -> PAYPAL_SECURITY_TOKEN , 2 );
else $substitutionarray [ '__SECUREKEYPAYPAL_ORDER__' ] = dol_hash ( $conf -> global -> PAYPAL_SECURITY_TOKEN . 'order' . $obj -> source_id , 2 );
2017-06-07 16:44:04 +02:00
2016-03-05 12:20:58 +01:00
if ( empty ( $conf -> global -> PAYPAL_SECURITY_TOKEN_UNIQUE )) $substitutionarray [ '__SECUREKEYPAYPAL_INVOICE__' ] = dol_hash ( $conf -> global -> PAYPAL_SECURITY_TOKEN , 2 );
else $substitutionarray [ '__SECUREKEYPAYPAL_INVOICE__' ] = dol_hash ( $conf -> global -> PAYPAL_SECURITY_TOKEN . 'invoice' . $obj -> source_id , 2 );
2017-06-07 16:44:04 +02:00
2016-03-05 12:20:58 +01:00
if ( empty ( $conf -> global -> PAYPAL_SECURITY_TOKEN_UNIQUE )) $substitutionarray [ '__SECUREKEYPAYPAL_CONTRACTLINE__' ] = dol_hash ( $conf -> global -> PAYPAL_SECURITY_TOKEN , 2 );
else $substitutionarray [ '__SECUREKEYPAYPAL_CONTRACTLINE__' ] = dol_hash ( $conf -> global -> PAYPAL_SECURITY_TOKEN . 'contractline' . $obj -> source_id , 2 );
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
2015-01-17 19:28:27 +01:00
complete_substitutions_array ( $substitutionarray , $langs );
$newsubject = make_substitutions ( $subject , $substitutionarray );
$newmessage = make_substitutions ( $message , $substitutionarray );
$arr_file = array ();
$arr_mime = array ();
$arr_name = array ();
$arr_css = array ();
$listofpaths = dol_dir_list ( $upload_dir , 'all' , 0 , '' , '' , 'name' , SORT_ASC , 0 );
if ( count ( $listofpaths ))
{
foreach ( $listofpaths as $key => $val )
{
$arr_file [] = $listofpaths [ $key ][ 'fullname' ];
$arr_mime [] = dol_mimetype ( $listofpaths [ $key ][ 'name' ]);
$arr_name [] = $listofpaths [ $key ][ 'name' ];
}
}
2009-01-25 23:04:55 +01:00
2015-01-17 19:28:27 +01:00
// Fabrication du mail
2017-11-21 11:15:33 +01:00
$trackid = 'emailing-' . $obj -> fk_mailing . '-' . $obj -> rowid ;
2017-04-11 10:57:17 +02:00
$mail = new CMailFile ( $newsubject , $sendto , $from , $newmessage , $arr_file , $arr_mime , $arr_name , '' , '' , 0 , $msgishtml , $errorsto , $arr_css , $trackid , '' , 'emailing' );
2009-01-25 23:04:55 +01:00
2015-01-17 19:28:27 +01:00
if ( $mail -> error )
{
$res = 0 ;
}
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
if ( $res )
2009-05-06 15:39:43 +02:00
{
2015-01-17 19:28:27 +01:00
$res = $mail -> sendfile ();
2009-05-06 15:39:43 +02:00
}
2015-01-17 19:28:27 +01:00
if ( $res )
2012-04-04 14:45:48 +02:00
{
2015-01-17 19:28:27 +01:00
// Mail successful
$nbok ++ ;
2012-04-05 21:02:00 +02:00
2015-01-18 17:13:42 +01:00
dol_syslog ( " comm/mailing/card.php: ok for # " . $i . ( $mail -> error ? ' - ' . $mail -> error : '' ), LOG_DEBUG );
2012-04-05 21:02:00 +02:00
2015-01-17 19:28:27 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " mailing_cibles " ;
2015-02-01 13:26:30 +01:00
$sql .= " SET statut=1, date_envoi=' " . $db -> idate ( $now ) . " ' WHERE rowid= " . $obj -> rowid ;
2015-01-17 19:28:27 +01:00
$resql2 = $db -> query ( $sql );
if ( ! $resql2 )
{
dol_print_error ( $db );
}
else
{
//if cheack read is use then update prospect contact status
if ( strpos ( $message , '__CHECK_READ__' ) !== false )
2012-04-04 14:45:48 +02:00
{
2015-01-17 19:28:27 +01:00
//Update status communication of thirdparty prospect
$sql = " UPDATE " . MAIN_DB_PREFIX . " societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM " . MAIN_DB_PREFIX . " mailing_cibles WHERE rowid= " . $obj -> rowid . " ) " ;
2015-01-18 17:13:42 +01:00
dol_syslog ( " card.php: set prospect thirdparty status " , LOG_DEBUG );
2015-01-17 19:28:27 +01:00
$resql2 = $db -> query ( $sql );
if ( ! $resql2 )
{
dol_print_error ( $db );
}
//Update status communication of contact prospect
$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= " . $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
$resql2 = $db -> query ( $sql );
if ( ! $resql2 )
{
dol_print_error ( $db );
}
2012-04-04 14:45:48 +02:00
}
}
2012-04-05 21:02:00 +02:00
2015-01-21 00:05:19 +01:00
if ( ! empty ( $conf -> global -> MAILING_DELAY ))
{
sleep ( $conf -> global -> MAILING_DELAY );
}
2012-04-05 21:02:00 +02:00
2015-01-21 00:05:19 +01:00
//test if CHECK READ change statut prospect contact
2015-01-17 19:28:27 +01:00
}
else
{
// Mail failed
$nbko ++ ;
2009-05-06 15:39:43 +02:00
2015-01-18 17:13:42 +01:00
dol_syslog ( " comm/mailing/card.php: error for # " . $i . ( $mail -> error ? ' - ' . $mail -> error : '' ), LOG_WARNING );
2009-05-06 15:39:43 +02:00
2015-01-17 19:28:27 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " mailing_cibles " ;
2016-11-11 14:03:57 +01:00
$sql .= " SET statut=-1, error_text=' " . $db -> escape ( $mail -> error ) . " ', date_envoi=' " . $db -> idate ( $now ) . " ' WHERE rowid= " . $obj -> rowid ;
2015-01-17 19:28:27 +01:00
$resql2 = $db -> query ( $sql );
if ( ! $resql2 )
{
dol_print_error ( $db );
}
2009-05-06 15:39:43 +02:00
}
2015-01-17 19:28:27 +01:00
$i ++ ;
}
}
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
if ( $nbko > 0 )
2012-11-14 18:58:55 +01:00
{
2015-01-17 19:28:27 +01:00
$statut = 2 ; // Status 'sent partially' (because at least one error)
2015-11-06 09:36:16 +01:00
if ( $nbok > 0 ) setEventMessages ( $langs -> transnoentitiesnoconv ( " EMailSentToNRecipients " , $nbok ), null , 'mesgs' );
2015-11-07 21:56:21 +01:00
else setEventMessages ( $langs -> transnoentitiesnoconv ( " EMailSentToNRecipients " , $nbok ), null , 'mesgs' );
2012-11-14 18:58:55 +01:00
}
else
{
2015-01-17 19:28:27 +01:00
if ( $nbok >= $num )
{
$statut = 3 ; // Send to everybody
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> transnoentitiesnoconv ( " EMailSentToNRecipients " , $nbok ), null , 'mesgs' );
2015-01-17 19:28:27 +01:00
}
else
{
$statut = 2 ; // Status 'sent partially' (because not send to everybody)
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> transnoentitiesnoconv ( " EMailSentToNRecipients " , $nbok ), null , 'mesgs' );
2015-01-17 19:28:27 +01:00
}
2012-11-14 18:58:55 +01:00
}
2009-05-06 15:39:43 +02:00
2015-01-17 19:28:27 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " mailing SET statut= " . $statut . " WHERE rowid= " . $object -> id ;
2015-01-18 17:13:42 +01:00
dol_syslog ( " comm/mailing/card.php: update global status " , LOG_DEBUG );
2015-01-17 19:28:27 +01:00
$resql2 = $db -> query ( $sql );
if ( ! $resql2 )
{
dol_print_error ( $db );
}
}
else
2009-05-06 15:39:43 +02:00
{
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
}
2012-06-17 18:40:45 +02:00
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
if ( $action == 'send' && empty ( $_POST [ " cancel " ]))
2006-11-01 16:50:17 +01:00
{
2015-01-17 19:28:27 +01:00
$error = 0 ;
2011-03-23 20:30:37 +01:00
2015-05-18 22:25:51 +02:00
$upload_dir = $conf -> mailing -> dir_output . " / " . get_exdir ( $object -> id , 2 , 0 , 1 , $object , 'mailing' );
2005-09-10 17:56:12 +02:00
2015-01-17 19:28:27 +01:00
$object -> sendto = $_POST [ " sendto " ];
if ( ! $object -> sendto )
2009-05-06 15:39:43 +02:00
{
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> trans ( " MailTo " )), null , 'errors' );
2015-01-17 19:28:27 +01:00
$error ++ ;
2009-05-06 15:39:43 +02:00
}
2015-01-17 19:28:27 +01:00
if ( ! $error )
2009-05-06 15:39:43 +02:00
{
2015-01-17 19:28:27 +01:00
// Le message est-il en html
$msgishtml =- 1 ; // Inconnu par defaut
if ( preg_match ( '/[\s\t]*<html>/i' , $object -> body )) $msgishtml = 1 ;
2017-09-22 14:34:31 +02:00
// other are set at begin of page
$object -> substitutionarrayfortest [ '__EMAIL__' ] = $object -> sendto ;
$object -> substitutionarrayfortest [ '__MAILTOEMAIL__' ] = '<a href="mailto:' . $object -> sendto . '">' . $object -> sendto . '</a>' ;
2017-08-28 12:49:57 +02:00
2015-01-17 19:28:27 +01:00
// Pratique les substitutions sur le sujet et message
2017-09-22 14:34:31 +02:00
complete_substitutions_array ( $object -> substitutionarrayfortest , $langs );
2015-01-17 19:28:27 +01:00
$tmpsujet = make_substitutions ( $object -> sujet , $object -> substitutionarrayfortest );
$tmpbody = make_substitutions ( $object -> body , $object -> substitutionarrayfortest );
$arr_file = array ();
$arr_mime = array ();
$arr_name = array ();
$arr_css = array ();
// Ajout CSS
if ( ! empty ( $object -> bgcolor )) $arr_css [ 'bgcolor' ] = ( preg_match ( '/^#/' , $object -> bgcolor ) ? '' : '#' ) . $object -> bgcolor ;
if ( ! empty ( $object -> bgimage )) $arr_css [ 'bgimage' ] = $object -> bgimage ;
// Attached files
$listofpaths = dol_dir_list ( $upload_dir , 'all' , 0 , '' , '' , 'name' , SORT_ASC , 0 );
if ( count ( $listofpaths ))
{
foreach ( $listofpaths as $key => $val )
{
$arr_file [] = $listofpaths [ $key ][ 'fullname' ];
$arr_mime [] = dol_mimetype ( $listofpaths [ $key ][ 'name' ]);
$arr_name [] = $listofpaths [ $key ][ 'name' ];
}
}
2009-05-06 15:39:43 +02:00
2017-04-11 10:57:17 +02:00
$trackid = 'emailingtest' ;
$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' );
2005-01-05 16:26:05 +01:00
2015-01-17 19:28:27 +01:00
$result = $mailfile -> sendfile ();
if ( $result )
{
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> trans ( " MailSuccessfulySent " , $mailfile -> getValidAddress ( $object -> email_from , 2 ), $mailfile -> getValidAddress ( $object -> sendto , 2 )), null , 'mesgs' );
2015-01-17 19:28:27 +01:00
}
else
{
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> trans ( " ResultKo " ) . '<br>' . $mailfile -> error . ' ' . $result , null , 'errors' );
2015-01-17 19:28:27 +01:00
}
2010-04-17 11:47:25 +02:00
2015-01-17 19:28:27 +01:00
$action = '' ;
2010-04-17 11:47:25 +02:00
}
}
2015-01-17 19:28:27 +01:00
// Action add emailing
if ( $action == 'add' )
2010-04-17 15:23:50 +02:00
{
2014-07-20 02:32:13 +02:00
$mesgs = array ();
2015-01-17 19:28:27 +01:00
$object -> email_from = trim ( $_POST [ " from " ]);
$object -> email_replyto = trim ( $_POST [ " replyto " ]);
$object -> email_errorsto = trim ( $_POST [ " errorsto " ]);
$object -> titre = trim ( $_POST [ " titre " ]);
2012-03-23 20:03:57 +01:00
$object -> sujet = trim ( $_POST [ " sujet " ]);
2017-09-01 13:09:13 +02:00
$object -> body = trim ( $_POST [ " bodyemail " ]);
2012-03-23 20:03:57 +01:00
$object -> bgcolor = trim ( $_POST [ " bgcolor " ]);
$object -> bgimage = trim ( $_POST [ " bgimage " ]);
2010-04-17 15:23:50 +02:00
2015-01-18 17:13:42 +01:00
if ( ! $object -> titre ) {
$mesgs [] = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailTitle " ));
}
2014-07-20 02:32:13 +02:00
if ( ! $object -> sujet ) {
$mesgs [] = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailTopic " ));
}
2015-01-18 17:13:42 +01:00
if ( ! $object -> body ) {
2014-07-20 02:32:13 +02:00
$mesgs [] = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailMessage " ));
}
2010-04-17 15:23:50 +02:00
2014-07-20 02:32:13 +02:00
if ( ! count ( $mesgs ))
2010-04-17 15:23:50 +02:00
{
2015-01-17 19:28:27 +01:00
if ( $object -> create ( $user ) >= 0 )
2010-04-17 15:23:50 +02:00
{
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 ;
2010-04-17 15:23:50 +02:00
}
2015-11-06 09:36:16 +01:00
setEventMessages ( $mesg , $mesgs , 'errors' );
2015-01-17 19:28:27 +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
2015-01-18 17:13:42 +01:00
if ( $action == 'settitre' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto' )
2010-04-17 15:23:50 +02:00
{
2015-05-18 22:25:51 +02:00
$upload_dir = $conf -> mailing -> dir_output . " / " . get_exdir ( $object -> id , 2 , 0 , 1 , $object , 'mailing' );
2015-01-17 19:28:27 +01:00
if ( $action == 'settitre' ) $object -> titre = trim ( GETPOST ( 'titre' , 'alpha' ));
else if ( $action == 'setemail_from' ) $object -> email_from = trim ( GETPOST ( 'email_from' , 'alpha' ));
else if ( $action == 'setemail_replyto' ) $object -> email_replyto = trim ( GETPOST ( 'email_replyto' , 'alpha' ));
else if ( $action == 'setemail_errorsto' ) $object -> email_errorsto = trim ( GETPOST ( 'email_errorsto' , 'alpha' ));
2015-01-18 17:13:42 +01:00
else if ( $action == 'settitre' && empty ( $object -> titre )) {
$mesg = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailTitle " ));
}
else if ( $action == 'setfrom' && empty ( $object -> email_from )) {
$mesg = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailFrom " ));
}
2015-01-17 19:28:27 +01:00
if ( ! $mesg )
{
if ( $object -> update ( $user ) >= 0 )
{
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' );
2015-01-17 19:28:27 +01:00
$action = " " ;
2010-04-17 15:23:50 +02:00
}
2015-01-17 19:28:27 +01:00
/*
* Add file in email form
*/
if ( ! empty ( $_POST [ 'addfile' ]))
2012-06-15 11:20:09 +02:00
{
2015-05-18 22:25:51 +02: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' ;
// Set tmp user directory
dol_add_file_process ( $upload_dir , 0 , 0 );
$action = " edit " ;
2012-06-15 11:20:09 +02:00
}
2015-01-17 19:28:27 +01:00
// Action remove file
if ( ! empty ( $_POST [ " removedfile " ]))
2012-06-15 11:20:09 +02:00
{
2015-05-18 22:25:51 +02: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' ;
2015-11-05 03:02:31 +01:00
dol_remove_file_process ( $_POST [ 'removedfile' ], 0 , 0 ); // We really delete file linked to mailing
2015-01-17 19:28:27 +01:00
$action = " edit " ;
2005-01-05 16:26:05 +01:00
}
2015-01-17 19:28:27 +01:00
// Action update emailing
if ( $action == 'update' && empty ( $_POST [ " removedfile " ]) && empty ( $_POST [ " cancel " ]))
2012-06-15 11:20:09 +02:00
{
2015-01-17 19:28:27 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
$isupload = 0 ;
2012-06-15 11:20:09 +02:00
2015-01-17 19:28:27 +01:00
if ( ! $isupload )
2012-06-15 11:20:09 +02:00
{
2015-01-18 17:13:42 +01:00
$mesgs = array ();
2015-01-17 19:28:27 +01:00
$object -> sujet = trim ( $_POST [ " sujet " ]);
2017-09-01 13:09:13 +02:00
$object -> body = trim ( $_POST [ " bodyemail " ]);
2015-01-17 19:28:27 +01:00
$object -> bgcolor = trim ( $_POST [ " bgcolor " ]);
$object -> bgimage = trim ( $_POST [ " bgimage " ]);
2015-01-18 17:13:42 +01:00
if ( ! $object -> sujet ) {
$mesgs [] = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailTopic " ));
}
if ( ! $object -> body ) {
$mesgs [] = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " MailMessage " ));
}
2015-01-17 19:28:27 +01:00
2015-01-18 17:13:42 +01:00
if ( ! count ( $mesgs ))
2015-01-17 19:28:27 +01:00
{
if ( $object -> update ( $user ) >= 0 )
{
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
exit ;
}
2015-01-18 17:13:42 +01:00
$mesgs [] = $object -> error ;
2015-01-17 19:28:27 +01:00
}
2015-11-06 09:36:16 +01:00
setEventMessages ( $mesg , $mesgs , 'errors' );
2015-01-17 19:28:27 +01:00
$action = " edit " ;
2012-06-15 11:20:09 +02:00
}
2015-01-17 19:28:27 +01:00
else
{
$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
2015-01-17 19:28:27 +01:00
// Action confirmation validation
if ( $action == 'confirm_valid' && $confirm == 'yes' )
{
if ( $object -> id > 0 )
2012-06-15 11:20:09 +02:00
{
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 ;
}
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
2017-01-29 15:31:22 +01:00
// Action confirmation validation
if ( $action == 'confirm_settodraft' && $confirm == 'yes' )
{
if ( $object -> id > 0 )
{
$result = $object -> setStatut ( 0 );
if ( $result > 0 )
{
//setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs');
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
exit ;
}
else
{
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
else
{
dol_print_error ( $db );
}
}
2015-01-17 19:28:27 +01:00
// Resend
if ( $action == 'confirm_reset' && $confirm == 'yes' )
2012-06-15 11:20:09 +02:00
{
2015-01-17 19:28:27 +01:00
if ( $object -> id > 0 )
{
$db -> begin ();
$result = $object -> valid ( $user );
if ( $result > 0 )
{
$result = $object -> reset_targets_status ( $user );
}
if ( $result > 0 )
{
$db -> commit ();
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
exit ;
}
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 ();
}
}
else
{
dol_print_error ( $db );
}
2005-01-05 16:26:05 +01:00
}
2015-01-17 19:28:27 +01:00
// Action confirmation suppression
if ( $action == 'confirm_delete' && $confirm == 'yes' )
2012-06-13 21:45:47 +02:00
{
2015-01-17 19:28:27 +01:00
if ( $object -> delete ( $object -> id ))
{
2015-01-18 17:13:42 +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
2015-01-17 19:28:27 +01:00
if ( ! empty ( $_POST [ " cancel " ]))
{
$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
2009-08-24 19:11:30 +02:00
$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing' ;
2017-09-01 13:09:13 +02:00
llxHeader ( '' , $langs -> trans ( " Mailing " ), $help_url , '' , 0 , 0 ,
array (
'/includes/ace/ace.js' ,
'/includes/ace/ext-statusbar.js' ,
'/includes/ace/ext-language_tools.js' ,
//'/includes/ace/ext-chromevox.js'
), array ());
2008-05-28 00:30:52 +02:00
2012-03-23 20:03:57 +01:00
if ( $action == 'create' )
2005-01-05 16:26:05 +01:00
{
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 " ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ '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
2016-11-11 02:18:48 +01:00
$htmltext = '<i>' . $langs -> trans ( " FollowingConstantsWillBeSubstituted " ) . ':<br>' ;
foreach ( $object -> substitutionarray as $key => $val )
{
$htmltext .= $key . ' = ' . $langs -> trans ( $val ) . '<br>' ;
}
$htmltext .= '</i>' ;
2017-02-17 17:11:14 +01:00
2017-06-07 16:44:04 +02:00
2017-02-17 17:11:14 +01:00
$availablelink = $form -> textwithpicto ( $langs -> trans ( " AvailableVariables " ), $htmltext , 1 , 'help' , '' , 0 , 2 , 'availvar' );
//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
2017-02-17 17:11:14 +01:00
print load_fiche_titre ( $langs -> trans ( " NewMailing " ), $availablelink , 'title_generic' );
2005-01-05 16:26:05 +01:00
2015-05-22 15:29:19 +02:00
dol_fiche_head ();
2009-05-06 15:39:43 +02:00
print '<table class="border" width="100%">' ;
2017-02-17 13:16:29 +01:00
print '<tr><td class="fieldrequired titlefieldcreate">' . $langs -> trans ( " MailTitle " ) . '</td><td><input class="flat minwidth300" name="titre" value="' . dol_escape_htmltag ( GETPOST ( 'titre' )) . '"></td></tr>' ;
2016-12-18 13:04:24 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " MailFrom " ) . '</td><td><input class="flat minwidth200" name="from" value="' . $conf -> global -> MAILING_EMAIL_FROM . '"></td></tr>' ;
print '<tr><td>' . $langs -> trans ( " MailErrorsTo " ) . '</td><td><input class="flat minwidth200" name="errorsto" value="' . ( ! empty ( $conf -> global -> MAILING_EMAIL_ERRORSTO ) ? $conf -> global -> MAILING_EMAIL_ERRORSTO : $conf -> global -> MAIN_MAIL_ERRORS_TO ) . '"></td></tr>' ;
2012-06-17 18:40:45 +02:00
2012-06-15 11:20:09 +02:00
// Other attributes
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-06-11 10:37:58 +02:00
print $hookmanager -> resPrint ;
2018-04-13 13:37:43 +02:00
if ( empty ( $reshook ))
2012-06-15 11:20:09 +02:00
{
2013-04-01 19:43:26 +02:00
print $object -> showOptionals ( $extrafields , 'edit' );
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>' ;
print '</br><br>' ;
print '<table class="border" width="100%">' ;
2017-02-17 13:16:29 +01:00
print '<tr><td class="fieldrequired titlefieldcreate">' . $langs -> trans ( " MailTopic " ) . '</td><td><input class="flat minwidth200 quatrevingtpercent" name="sujet" value="' . dol_escape_htmltag ( GETPOST ( 'sujet' )) . '"></td></tr>' ;
2016-07-06 22:28:13 +02:00
print '<tr><td>' . $langs -> trans ( " BackgroundColorByDefault " ) . '</td><td colspan="3">' ;
2017-09-15 11:24:32 +02:00
print $htmlother -> selectColor ( $_POST [ 'bgcolor' ], 'bgcolor' , '' , 0 );
2009-05-19 15:27:44 +02:00
print '</td></tr>' ;
2016-11-11 02:18:48 +01:00
print '</table>' ;
2017-06-07 16:44:04 +02:00
2016-11-11 02:18:48 +01:00
print '<div style="padding-top: 10px">' ;
2009-05-06 15:39:43 +02:00
// Editeur wysiwyg
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2017-09-01 13:09:13 +02:00
$doleditor = new DolEditor ( 'bodyemail' , GETPOST ( 'bodyemail' , 'none' ), '' , 600 , 'dolibarr_mailings' , '' , true , true , $conf -> global -> FCKEDITOR_ENABLE_MAILING , 20 , '90%' );
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
2015-05-22 15:29:19 +02:00
dol_fiche_end ();
print '<div class="center"><input type="submit" class="button" value="' . $langs -> trans ( " CreateMailing " ) . '"></div>' ;
2010-02-21 20:35:58 +01:00
2009-05-06 15:39:43 +02:00
print '</form>' ;
2005-01-05 16:26:05 +01:00
}
else
{
2012-06-13 09:26:29 +02:00
if ( $object -> id > 0 )
2009-05-06 15:39:43 +02:00
{
2015-05-18 22:25:51 +02: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
2017-01-29 15:31:22 +01:00
// Confirmation back to draft
if ( $action == 'settodraft' )
{
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( " SetToDraft " ), $langs -> trans ( " ConfirmUnvalidateEmailing " ), " confirm_settodraft " , '' , '' , 1 );
}
// Confirmation validation of mailing
2012-03-23 20:03:57 +01:00
if ( $action == 'valid' )
2009-05-06 15:39:43 +02:00
{
2016-03-25 15:53:44 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( " ValidMailing " ), $langs -> trans ( " ConfirmValidMailing " ), " confirm_valid " , '' , '' , 1 );
2009-05-06 15:39:43 +02:00
}
// Confirm reset
2012-03-23 20:03:57 +01:00
else if ( $action == 'reset' )
2009-05-06 15:39:43 +02:00
{
2016-03-25 15:53:44 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( " ResetMailing " ), $langs -> trans ( " ConfirmResetMailing " , $object -> ref ), " confirm_reset " , '' , '' , 2 );
2009-05-06 15:39:43 +02:00
}
// Confirm delete
2012-03-23 20:03:57 +01:00
else if ( $action == 'delete' )
2009-05-06 15:39:43 +02:00
{
2016-03-25 15:53:44 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id . ( ! empty ( $urlfrom ) ? '&urlfrom=' . urlencode ( $urlfrom ) : '' ), $langs -> trans ( " DeleteAMailing " ), $langs -> trans ( " ConfirmDeleteMailing " ), " confirm_delete " , '' , '' , 1 );
2009-05-06 15:39:43 +02:00
}
2012-05-09 17:15:44 +02:00
2017-09-01 13:09:13 +02:00
if ( $action != 'edit' && $action != 'edithtml' )
2009-05-06 15:39:43 +02:00
{
2017-04-17 13:02:40 +02:00
dol_fiche_head ( $head , 'card' , $langs -> trans ( " Mailing " ), - 1 , 'email' );
2009-05-06 15:39:43 +02:00
/*
* Mailing en mode visu
*/
2012-03-23 20:03:57 +01:00
if ( $action == 'sendall' )
2008-02-29 17:26:38 +01:00
{
2010-12-13 19:40:04 +01:00
// Define message to recommand from command line
2017-04-18 01:39:06 +02:00
$sendingmode = $conf -> global -> EMAILING_MAIL_SENDMODE ;
if ( empty ( $sendingmode )) $sendingmode = $conf -> global -> MAIN_MAIL_SENDMODE ;
2014-11-29 13:50:41 +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).
2017-01-13 15:32:20 +01:00
// MAILING_LIMIT_SENDBYCLI may be defined ot not (-1=forbidden, 0 or undefined=no limit).
2014-11-29 13:50:41 +01:00
if ( ! empty ( $conf -> global -> MAILING_NO_USING_PHPMAIL ) && $sendingmode == 'mail' )
{
// 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.
2014-11-29 13:50:41 +01:00
$linktoadminemailbefore = '<a href="' . DOL_URL_ROOT . '/admin/mails.php">' ;
$linktoadminemailend = '</a>' ;
2015-11-06 09:36:16 +01:00
setEventMessages ( $langs -> trans ( " MailSendSetupIs " , $listofmethods [ $sendingmode ]), null , 'warnings' );
setEventMessages ( $langs -> trans ( " MailSendSetupIs2 " , $linktoadminemailbefore , $linktoadminemailend , $langs -> transnoentitiesnoconv ( " MAIN_MAIL_SENDMODE " ), $listofmethods [ 'smtps' ]), null , 'warnings' );
if ( ! empty ( $conf -> global -> MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS )) setEventMessages ( $langs -> trans ( " MailSendSetupIs3 " , $conf -> global -> MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS ), null , 'warnings' );
2014-11-29 13:50:41 +01:00
$_GET [ " action " ] = '' ;
}
2018-01-26 15:12:40 +01:00
else if ( $conf -> global -> MAILING_LIMIT_SENDBYWEB < 0 )
2008-02-29 17:26:38 +01:00
{
2017-01-13 15:32:20 +01:00
if ( ! empty ( $conf -> global -> MAILING_LIMIT_WARNING_PHPMAIL ) && $sendingmode == 'mail' ) setEventMessages ( $langs -> transnoentitiesnoconv ( $conf -> global -> MAILING_LIMIT_WARNING_PHPMAIL ), null , 'warnings' );
if ( ! empty ( $conf -> global -> MAILING_LIMIT_WARNING_NOPHPMAIL ) && $sendingmode != 'mail' ) 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.
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' );
2016-12-17 14:47:06 +01:00
if ( $conf -> file -> mailing_limit_sendbyweb != '-1' ) // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed ot increase it.
2016-12-16 13:46:39 +01:00
{
setEventMessages ( $langs -> trans ( " MailingNeedCommand2 " ), null , 'warnings' ); // You can send online with constant...
}
2009-05-06 15:39:43 +02:00
$_GET [ " action " ] = '' ;
2008-02-29 17:26:38 +01:00
}
else
{
2017-01-13 15:32:20 +01:00
if ( ! empty ( $conf -> global -> MAILING_LIMIT_WARNING_PHPMAIL ) && $sendingmode == 'mail' ) setEventMessages ( $langs -> transnoentitiesnoconv ( $conf -> global -> MAILING_LIMIT_WARNING_PHPMAIL ), null , 'warnings' );
if ( ! empty ( $conf -> global -> MAILING_LIMIT_WARNING_NOPHPMAIL ) && $sendingmode != 'mail' ) 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
$text = '' ;
if ( $conf -> global -> MAILING_LIMIT_SENDBYCLI >= 0 )
2010-12-27 15:54:27 +01:00
{
$text .= $langs -> trans ( " MailingNeedCommand " );
2015-04-18 16:39:53 +02:00
$text .= '<br><textarea cols="60" rows="' . ROWS_2 . '" wrap="soft">php ./scripts/emailings/mailing-send.php ' . $object -> id . ' ' . $user -> login . '</textarea>' ;
2010-12-27 15:54:27 +01:00
$text .= '<br><br>' ;
}
2010-12-13 19:40:04 +01:00
$text .= $langs -> trans ( 'ConfirmSendingEmailing' ) . '<br>' ;
2009-08-26 11:50:00 +02:00
$text .= $langs -> trans ( 'LimitSendingEmailing' , $conf -> global -> MAILING_LIMIT_SENDBYWEB );
2016-12-26 12:30:59 +01:00
print $form -> formconfirm ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $langs -> trans ( 'SendMailing' ), $text , 'sendallconfirmed' , $formquestion , '' , 1 , 300 );
2008-02-29 17:26:38 +01:00
}
}
2005-02-12 00:41:42 +01:00
2014-09-18 20:33:37 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/comm/mailing/list.php">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2012-07-28 21:49:47 +02:00
2016-11-11 01:55:53 +01:00
$morehtmlright = '' ;
2018-01-29 12:46:07 +01:00
$nbtry = $nbok = 0 ;
if ( $object -> statut == 2 || $object -> statut == 3 )
{
$nbtry = $object -> countNbOfTargets ( 'alreadysent' );
$nbko = $object -> countNbOfTargets ( 'alreadysentko' );
$morehtmlright .= ' (' . $nbtry . '/' . $object -> nbemail ;
if ( $nbko ) $morehtmlright .= ' - ' . $nbko . ' ' . $langs -> trans ( " Error " );
$morehtmlright .= ') ' ;
}
2017-06-07 16:44:04 +02:00
2016-11-11 01:55:53 +01:00
dol_banner_tab ( $object , 'id' , $linkback , 1 , 'rowid' , 'ref' , '' , '' , 0 , '' , $morehtmlright );
2017-04-17 13:02:40 +02:00
print '<div class="fichecenter">' ;
2016-11-11 01:55:53 +01:00
print '<div class="underbanner clearboth"></div>' ;
2017-06-07 16:44:04 +02:00
2016-11-11 01:15:41 +01:00
print '<table class="border" width="100%">' ;
2010-04-17 11:47:25 +02:00
// Description
2016-11-11 01:55:53 +01:00
print '<tr><td class="titlefield">' . $form -> editfieldkey ( " MailTitle " , 'titre' , $object -> titre , $object , $user -> rights -> mailing -> creer && $object -> statut < 3 , 'string' ) . '</td><td colspan="3">' ;
2016-03-25 15:53:44 +01:00
print $form -> editfieldval ( " MailTitle " , 'titre' , $object -> titre , $object , $user -> rights -> mailing -> creer && $object -> statut < 3 , 'string' );
2010-04-17 11:47:25 +02:00
print '</td></tr>' ;
// From
2016-03-25 15:53:44 +01:00
print '<tr><td>' . $form -> editfieldkey ( " MailFrom " , 'email_from' , $object -> email_from , $object , $user -> rights -> mailing -> creer && $object -> statut < 3 , 'string' ) . '</td><td colspan="3">' ;
print $form -> editfieldval ( " MailFrom " , 'email_from' , $object -> email_from , $object , $user -> rights -> mailing -> creer && $object -> statut < 3 , 'string' );
2009-05-25 00:01:19 +02:00
print '</td></tr>' ;
2009-07-29 20:41:39 +02:00
// Errors to
2016-03-25 15:53:44 +01:00
print '<tr><td>' . $form -> editfieldkey ( " MailErrorsTo " , 'email_errorsto' , $object -> email_errorsto , $object , $user -> rights -> mailing -> creer && $object -> statut < 3 , 'string' ) . '</td><td colspan="3">' ;
print $form -> editfieldval ( " MailErrorsTo " , 'email_errorsto' , $object -> email_errorsto , $object , $user -> rights -> mailing -> creer && $object -> statut < 3 , 'string' );
2009-05-25 00:01:19 +02:00
print '</td></tr>' ;
2017-06-07 16:44:04 +02:00
2009-07-29 20:41:39 +02:00
// Nb of distinct emails
2013-03-24 19:00:58 +01:00
print '<tr><td>' ;
2009-08-26 11:50:00 +02:00
print $langs -> trans ( " TotalNbOfDistinctRecipients " );
print '</td><td colspan="3">' ;
2018-01-26 15:12:40 +01:00
$nbemail = ( $object -> nbemail ? $object -> nbemail : 0 );
if ( is_numeric ( $nbemail ))
2009-08-26 11:50:00 +02:00
{
2016-12-26 12:30:59 +01:00
$text = '' ;
2018-01-29 12:46:07 +01:00
if (( ! empty ( $conf -> global -> MAILING_LIMIT_SENDBYWEB ) && $conf -> global -> MAILING_LIMIT_SENDBYWEB < $nbemail ) && ( $object -> statut == 1 || ( $object -> statut == 2 && $nbtry < $nbemail )))
2016-12-26 12:30:59 +01:00
{
if ( $conf -> global -> MAILING_LIMIT_SENDBYWEB > 0 )
{
$text .= $langs -> trans ( 'LimitSendingEmailing' , $conf -> global -> MAILING_LIMIT_SENDBYWEB );
}
else
{
2018-01-26 15:12:40 +01:00
$text .= $langs -> trans ( 'SendingFromWebInterfaceIsNotAllowed' );
2016-12-26 12:30:59 +01:00
}
}
2018-01-26 15:12:40 +01:00
if ( empty ( $nbemail )) $nbemail .= ' ' . img_warning ( '' ) . ' <font class="warning">' . $langs -> trans ( " NoTargetYet " ) . '</font>' ;
2016-12-26 12:30:59 +01:00
if ( $text )
{
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
2012-06-15 11:20:09 +02:00
// Other attributes
2017-06-07 16:44:04 +02:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2009-05-06 15:39:43 +02:00
print '</table>' ;
2005-02-12 00:41:42 +01:00
2009-05-06 15:39:43 +02:00
print " </div> " ;
2017-06-07 16:44:04 +02:00
2017-04-17 13:02:40 +02:00
dol_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
2012-03-23 20:03:57 +01:00
if ( $action == 'clone' )
2008-11-10 15:20:02 +01:00
{
2008-11-20 22:30:23 +01:00
// Create an array for form
2008-11-10 15:20:02 +01:00
$formquestion = array (
2008-11-20 22:30:23 +01:00
'text' => $langs -> trans ( " ConfirmClone " ),
2009-05-06 15:39:43 +02:00
array ( 'type' => 'checkbox' , 'name' => 'clone_content' , 'label' => $langs -> trans ( " CloneContent " ), 'value' => 1 ),
2014-04-28 17:18:11 +02:00
array ( 'type' => 'checkbox' , 'name' => 'clone_receivers' , 'label' => $langs -> trans ( " CloneReceivers " ), 'value' => 0 )
2008-11-10 15:20:02 +01:00
);
// Paiement incomplet. On demande si motif = escompte ou autre
2016-03-25 15:53:44 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'CloneEMailing' ), $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
2009-05-06 15:39:43 +02:00
/*
* Boutons d ' action
*/
2010-04-17 11:47:25 +02:00
2018-03-02 11:18:29 +01:00
if ( GETPOST ( 'cancel' , 'alpha' ) || $confirm == 'no' || $action == '' || in_array ( $action , array ( 'settodraft' , 'valid' , 'delete' , 'sendall' , 'clone' , 'test' )))
2009-05-06 15:39:43 +02:00
{
print " \n \n <div class= \" tabsAction \" > \n " ;
2005-02-12 00:41:42 +01:00
2017-01-29 15:31:22 +01:00
if (( $object -> statut == 1 ) && ( $user -> rights -> mailing -> valider || $object -> fk_user_valid == $user -> id ))
{
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=settodraft&id=' . $object -> id . '">' . $langs -> trans ( " SetToDraft " ) . '</a>' ;
}
2016-07-31 16:24:32 +02:00
if (( $object -> statut == 0 || $object -> statut == 1 ) && $user -> rights -> mailing -> creer )
2009-05-06 15:39:43 +02:00
{
2017-09-15 11:19:56 +02:00
if ( ! empty ( $conf -> fckeditor -> enabled ) && ! empty ( $conf -> global -> FCKEDITOR_ENABLE_MAILING ))
{
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=edit&id=' . $object -> id . '">' . $langs -> trans ( " EditWithEditor " ) . '</a>' ;
}
else
{
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=edit&id=' . $object -> id . '">' . $langs -> trans ( " EditWithTextEditor " ) . '</a>' ;
}
2017-09-01 13:09:13 +02:00
if ( ! empty ( $conf -> use_javascript_ajax )) print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=edithtml&id=' . $object -> id . '">' . $langs -> trans ( " EditHTMLSource " ) . '</a>' ;
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
2012-06-15 11:20:09 +02:00
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && ! $user -> rights -> mailing -> mailing_advance -> send )
{
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NotEnoughPermissions " )) . '">' . $langs -> trans ( " TestMailing " ) . '</a>' ;
}
else
2012-06-13 21:45:47 +02:00
{
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=test&id=' . $object -> id . '">' . $langs -> trans ( " TestMailing " ) . '</a>' ;
}
2005-02-12 00:41:42 +01:00
2012-03-23 20:03:57 +01:00
if ( $object -> statut == 0 )
2009-05-06 15:39:43 +02:00
{
2012-03-23 20:03:57 +01:00
if ( $object -> nbemail <= 0 )
2010-07-15 10:42:05 +02:00
{
2011-11-21 13:17:14 +01:00
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NoTargetYet " )) . '">' . $langs -> trans ( " ValidMailing " ) . '</a>' ;
2010-07-15 10:42:05 +02:00
}
2010-07-15 10:46:33 +02:00
else if ( empty ( $user -> rights -> mailing -> valider ))
2010-07-11 13:36:35 +02:00
{
2011-11-21 13:17:14 +01:00
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NotEnoughPermissions " )) . '">' . $langs -> trans ( " ValidMailing " ) . '</a>' ;
2010-07-11 13:36:35 +02:00
}
else
{
2012-03-23 20:03:57 +01:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=valid&id=' . $object -> id . '">' . $langs -> trans ( " ValidMailing " ) . '</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
2012-03-23 20:03:57 +01:00
if (( $object -> statut == 1 || $object -> statut == 2 ) && $object -> nbemail > 0 && $user -> rights -> mailing -> valider )
2009-05-06 15:39:43 +02:00
{
2018-01-26 15:12:40 +01:00
if ( $conf -> global -> MAILING_LIMIT_SENDBYWEB < 0 )
{
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " SendingFromWebInterfaceIsNotAllowed " )) . '">' . $langs -> trans ( " SendMailing " ) . '</a>' ;
}
else if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && ! $user -> rights -> mailing -> mailing_advance -> send )
2011-01-21 11:58:05 +01:00
{
2011-11-21 13:17:14 +01:00
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NotEnoughPermissions " )) . '">' . $langs -> trans ( " SendMailing " ) . '</a>' ;
2011-01-21 11:58:05 +01: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
2009-05-06 15:39:43 +02:00
if ( $user -> rights -> 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
2012-03-23 20:03:57 +01:00
if (( $object -> statut == 2 || $object -> statut == 3 ) && $user -> rights -> mailing -> valider )
2009-05-06 15:39:43 +02:00
{
2012-06-13 21:45:47 +02:00
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && ! $user -> rights -> mailing -> mailing_advance -> send )
{
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NotEnoughPermissions " )) . '">' . $langs -> trans ( " ResetMailing " ) . '</a>' ;
}
else
{
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
2012-03-23 20:03:57 +01:00
if (( $object -> statut <= 1 && $user -> rights -> mailing -> creer ) || $user -> rights -> mailing -> supprimer )
2009-05-06 15:39:43 +02:00
{
2012-06-14 20:08:46 +02:00
if ( $object -> statut > 0 && ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && ! $user -> rights -> mailing -> mailing_advance -> delete ))
{
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> transnoentitiesnoconv ( " NotEnoughPermissions " )) . '">' . $langs -> trans ( " DeleteMailing " ) . '</a>' ;
}
else
{
print '<a class="butActionDelete" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=delete&id=' . $object -> id . ( ! empty ( $urlfrom ) ? '&urlfrom=' . $urlfrom : '' ) . '">' . $langs -> trans ( " DeleteMailing " ) . '</a>' ;
}
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
2007-05-26 17:05:49 +02:00
// Affichage formulaire de TEST
2012-03-23 20:03:57 +01:00
if ( $action == 'test' )
2009-05-06 15:39:43 +02:00
{
2017-06-11 11:40:01 +02:00
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>' ;
print load_fiche_titre ( $langs -> trans ( " TestMailing " ));
2009-05-06 15:39:43 +02:00
2018-03-02 11:18:29 +01:00
dol_fiche_head ( null , '' , '' , - 1 );
// Create l'objet formulaire mail
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 ;
2009-05-06 15:39:43 +02:00
$formmail -> withsubstit = 1 ;
$formmail -> withfrom = 0 ;
$formmail -> withto = $user -> email ? $user -> email : 1 ;
$formmail -> withtocc = 0 ;
2009-10-14 18:13:20 +02:00
$formmail -> withtoccc = $conf -> global -> MAIN_EMAIL_USECCC ;
2009-05-06 15:39:43 +02:00
$formmail -> withtopic = 0 ;
$formmail -> withtopicreadonly = 1 ;
$formmail -> withfile = 0 ;
$formmail -> withbody = 0 ;
$formmail -> withbodyreadonly = 1 ;
$formmail -> withcancel = 1 ;
$formmail -> withdeliveryreceipt = 0 ;
// Tableau des substitutions
2012-06-13 09:26:29 +02:00
$formmail -> substit = $object -> substitutionarrayfortest ;
2009-05-06 15:39:43 +02:00
// Tableau des parametres complementaires du post
$formmail -> param [ " action " ] = " send " ;
2017-09-22 14:34:31 +02:00
$formmail -> param [ " models " ] = 'none' ;
2012-03-23 20:03:57 +01:00
$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
dol_fiche_end ();
print dol_set_focus ( '#sendto' );
2009-05-06 15:39:43 +02:00
}
2015-07-04 03:28:52 +02:00
2016-11-11 01:55:53 +01:00
$htmltext = '<i>' . $langs -> trans ( " FollowingConstantsWillBeSubstituted " ) . ':<br>' ;
2016-11-11 01:15:41 +01:00
foreach ( $object -> substitutionarray as $key => $val )
{
$htmltext .= $key . ' = ' . $langs -> trans ( $val ) . '<br>' ;
}
$htmltext .= '</i>' ;
2017-06-07 16:44:04 +02:00
2016-11-11 01:15:41 +01:00
// Print mail content
2018-01-12 20:50:18 +01:00
print load_fiche_titre ( $langs -> trans ( " EMail " ), $form -> textwithpicto ( '<span class="hideonsmartphone">' . $langs -> trans ( " AvailableVariables " ) . '</span>' , $htmltext , 1 , 'help' , '' , 0 , 2 , 'emailsubstitionhelp' ), 'title_generic' );
2017-06-07 16:44:04 +02:00
2017-05-06 20:43:14 +02:00
dol_fiche_head ( '' , '' , '' , - 1 );
2017-06-07 16:44:04 +02:00
2018-03-02 11:18:29 +01:00
print '<table class="bordernooddeven" width="100%">' ;
2010-04-17 11:47:25 +02:00
// Subject
2016-07-06 22:28:13 +02:00
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
2011-11-21 13:17:14 +01:00
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 )
2010-04-17 15:23:50 +02:00
{
2011-11-21 13:17:14 +01:00
print img_mime ( $listofpaths [ $key ][ 'name' ]) . ' ' . $listofpaths [ $key ][ 'name' ];
print '<br>' ;
2010-04-17 15:23:50 +02:00
}
2011-11-21 13:17:14 +01:00
}
else
{
2017-03-11 02:36:22 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " NoAttachedFiles " ) . '</span><br>' ;
2011-11-21 13:17:14 +01:00
}
print '</td></tr>' ;
2010-04-17 11:47:25 +02:00
2011-06-11 04:25:05 +02:00
// Background color
2012-06-13 21:45:47 +02:00
/* print '<tr><td width="15%">' . $langs -> trans ( " BackgroundColorByDefault " ) . '</td><td colspan="3">' ;
2017-09-15 11:24:32 +02:00
print $htmlother -> selectColor ( $object -> bgcolor , 'bgcolor' , '' , 0 );
2011-06-11 04:25:05 +02:00
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
2011-06-11 04:25:05 +02:00
// Message
2017-09-15 11:24:32 +02:00
print '<div style="padding-top: 10px; background: ' . ( $object -> bgcolor ? ( preg_match ( '/^#/' , $object -> bgcolor ) ? '' : '#' ) . $object -> bgcolor : 'white' ) . '">' ;
2017-09-15 11:28:21 +02:00
if ( empty ( $object -> bgcolor ) || strtolower ( $object -> bgcolor ) == 'ffffff' ) // CKEditor does not apply the color of the div into its content area
2013-03-24 19:00:58 +01:00
{
2014-03-08 13:46:17 +01:00
$readonly = 1 ;
2013-03-30 14:27:13 +01:00
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2017-09-15 11:19:56 +02:00
$doleditor = new DolEditor ( 'bodyemail' , $object -> body , '' , 600 , 'dolibarr_mailings' , '' , false , true , empty ( $conf -> global -> FCKEDITOR_ENABLE_MAILING ) ? 0 : 1 , 20 , '90%' , $readonly );
2013-03-24 19:00:58 +01:00
$doleditor -> Create ();
}
else print dol_htmlentitiesbr ( $object -> body );
2016-11-11 01:15:41 +01:00
print '</div>' ;
2015-07-04 03:28:52 +02:00
dol_fiche_end ();
2017-06-07 16:44:04 +02:00
2009-05-06 15:39:43 +02:00
}
else
{
/*
2017-09-01 13:09:13 +02:00
* Mailing en mode edition ( CKeditor or HTML source )
2009-05-06 15:39:43 +02:00
*/
2017-06-07 16:44:04 +02:00
2017-04-17 13:02:40 +02:00
dol_fiche_head ( $head , 'card' , $langs -> trans ( " Mailing " ), - 1 , 'email' );
2017-06-07 16:44:04 +02:00
2016-05-06 12:15:44 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/comm/mailing/list.php">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2016-11-11 01:55:53 +01:00
$morehtmlright = '' ;
if ( $object -> statut == 2 ) $morehtmlright .= ' (' . $object -> countNbOfTargets ( 'alreadysent' ) . '/' . $object -> nbemail . ') ' ;
2017-06-07 16:44:04 +02:00
2016-11-11 01:55:53 +01:00
dol_banner_tab ( $object , 'id' , $linkback , 1 , 'rowid' , 'ref' , '' , '' , 0 , '' , $morehtmlright );
2017-06-07 16:44:04 +02:00
2017-04-17 13:02:40 +02:00
print '<div class="fichecenter">' ;
2016-11-11 01:55:53 +01:00
print '<div class="underbanner clearboth"></div>' ;
2016-11-11 01:15:41 +01:00
print '<table class="border" width="100%">' ;
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
// Topic
2016-11-11 01:55:53 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " MailTitle " ) . '</td><td colspan="3">' . $object -> titre . '</td></tr>' ;
2012-05-09 17:15:44 +02:00
// From
2016-11-11 01:55:53 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " MailFrom " ) . '</td><td colspan="3">' . dol_print_email ( $object -> email_from , 0 , 0 , 0 , 0 , 1 ) . '</td></tr>' ;
2012-05-09 17:15:44 +02:00
// To
2016-05-06 12:15:44 +02:00
print '<tr><td>' . $langs -> trans ( " MailErrorsTo " ) . '</td><td colspan="3">' . dol_print_email ( $object -> email_errorsto , 0 , 0 , 0 , 0 , 1 ) . '</td></tr>' ;
2010-04-17 11:47:25 +02:00
// Nb 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 " );
print '</td><td colspan="3">' ;
2018-01-26 15:12:40 +01:00
$nbemail = ( $object -> nbemail ? $object -> nbemail : 0 );
if ( is_numeric ( $nbemail ))
2010-04-17 11:47:25 +02:00
{
2018-01-26 15:12:40 +01:00
$text = '' ;
if (( ! empty ( $conf -> global -> MAILING_LIMIT_SENDBYWEB ) && $conf -> global -> MAILING_LIMIT_SENDBYWEB < $nbemail ) && ( $object -> statut == 1 || $object -> statut == 2 ))
{
if ( $conf -> global -> MAILING_LIMIT_SENDBYWEB > 0 )
{
$text .= $langs -> trans ( 'LimitSendingEmailing' , $conf -> global -> MAILING_LIMIT_SENDBYWEB );
}
else
{
$text .= $langs -> trans ( 'SendingFromWebInterfaceIsNotAllowed' );
}
}
if ( empty ( $nbemail )) $nbemail .= ' ' . img_warning ( '' ) . ' <font class="warning">' . $langs -> trans ( " NoTargetYet " ) . '</font>' ;
if ( $text )
{
print $form -> textwithpicto ( $nbemail , $text , 1 , 'warning' );
}
else
{
print $nbemail ;
}
2010-04-17 11:47:25 +02:00
}
print '</td></tr>' ;
2012-06-17 18:40:45 +02:00
2012-06-15 11:20:09 +02:00
// Other attributes
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-06-11 10:37:58 +02:00
print $hookmanager -> resPrint ;
2018-04-13 14:15:33 +02:00
if ( empty ( $reshook ))
2012-06-15 11:20:09 +02:00
{
2013-04-01 19:43:26 +02:00
print $object -> showOptionals ( $extrafields , 'edit' );
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>' ;
2016-02-08 12:20:40 +01:00
2015-11-05 03:02:31 +01:00
dol_fiche_end ();
2016-02-08 12:20:40 +01:00
2010-04-17 11:47:25 +02:00
2016-11-11 01:15:41 +01:00
print " <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 " ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ '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
2016-11-11 01:55:53 +01:00
$htmltext = '<i>' . $langs -> trans ( " FollowingConstantsWillBeSubstituted " ) . ':<br>' ;
2016-11-11 01:15:41 +01:00
foreach ( $object -> substitutionarray as $key => $val )
{
$htmltext .= $key . ' = ' . $langs -> trans ( $val ) . '<br>' ;
}
$htmltext .= '</i>' ;
2017-06-07 16:44:04 +02:00
2010-04-17 11:47:25 +02:00
// Print mail content
2017-03-11 02:36:22 +01:00
print load_fiche_titre ( $langs -> trans ( " EMail " ), $form -> textwithpicto ( $langs -> trans ( " AvailableVariables " ), $htmltext , 1 , 'help' , '' , 0 , 2 , 'emailsubstitionhelp' ), 'title_generic' );
2015-11-05 03:02:31 +01:00
2017-09-01 13:09:13 +02:00
dol_fiche_head ( null , '' , '' , - 1 );
2017-06-07 16:44:04 +02:00
2018-03-02 11:18:29 +01:00
print '<table class="bordernooddeven" width="100%">' ;
2009-05-06 15:39:43 +02:00
2011-06-11 04:25:05 +02:00
// Subject
2016-11-11 01:15:41 +01:00
print '<tr><td class="fieldrequired titlefield">' . $langs -> trans ( " MailTopic " ) . '</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
2016-07-06 22:28:13 +02: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
2011-11-21 13:17:14 +01:00
$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 );
2017-09-01 13:09:13 +02:00
2011-11-21 13:17:14 +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" language="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 )
2010-04-17 15:23:50 +02:00
{
2011-11-21 13:17:14 +01:00
$out .= '<div id="attachfile_' . $key . '">' ;
$out .= img_mime ( $listofpaths [ $key ][ 'name' ]) . ' ' . $listofpaths [ $key ][ 'name' ];
2014-01-13 10:10:17 +01:00
$out .= ' <input type="image" style="border: 0px;" src="' . img_picto ( $langs -> trans ( " Search " ), 'delete.png' , '' , '' , 1 ) . '" value="' . ( $key + 1 ) . '" class="removedfile" id="removedfile_' . $key . '" name="removedfile_' . $key . '" />' ;
2011-11-21 13:17:14 +01:00
$out .= '<br></div>' ;
2010-04-17 15:23:50 +02:00
}
2011-11-21 13:17:14 +01:00
}
else
{
$out .= $langs -> trans ( " NoAttachedFiles " ) . '<br>' ;
}
// Add link to add file
$out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="' . $langs -> trans ( " Upload " ) . '" />' ;
$out .= ' ' ;
$out .= '<input type="submit" class="button" id="' . $addfileaction . '" name="' . $addfileaction . '" value="' . $langs -> trans ( " MailingAddFile " ) . '" />' ;
print $out ;
print '</td></tr>' ;
2010-04-17 11:47:25 +02:00
2011-06-11 04:25:05 +02:00
// Background color
2016-07-06 22:28:13 +02:00
print '<tr><td>' . $langs -> trans ( " BackgroundColorByDefault " ) . '</td><td colspan="3">' ;
2017-09-15 11:24:32 +02:00
print $htmlother -> selectColor ( $object -> bgcolor , 'bgcolor' , '' , 0 );
2009-05-19 15:27:44 +02:00
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
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
if ( $action == 'edit' )
{
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
$doleditor = new DolEditor ( 'bodyemail' , $object -> body , '' , 600 , 'dolibarr_mailings' , '' , true , true , $conf -> global -> FCKEDITOR_ENABLE_MAILING , 20 , '90%' );
$doleditor -> Create ();
}
if ( $action == 'edithtml' )
{
// Editor HTML source
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
$doleditor = new DolEditor ( 'bodyemail' , $object -> body , '' , 600 , 'dolibarr_mailings' , '' , true , true , 'ace' , 20 , '90%' );
$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
2015-11-05 03:02:31 +01:00
dol_fiche_end ();
2016-02-08 12:20:40 +01:00
2015-11-05 03:02:31 +01:00
print '<div class="center">' ;
2017-09-01 13:09:13 +02:00
print '<input type="submit" class="button buttonforacesave" value="' . $langs -> trans ( " Save " ) . '" name="save">' ;
2014-11-25 20:13:43 +01:00
print ' ' ;
2009-07-06 22:53:41 +02:00
print '<input type="submit" class="button" 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
}
}
2009-05-20 13:20:49 +02:00
else
{
2012-03-23 20:03:57 +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
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-03-23 20:03:57 +01:00
$db -> close ();