header('Content-type: text/html; charset=utf-8');
session_start();
error_reporting(E_ALL);
require_once("../../config.php");
require_once("dirstree.php");
require_once("guid.php");
$sql=mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
mysql_select_db($sugar_config['dbconfig']['db_name']);
mysql_query("set names utf8");
mysql_query("set charaecterset utf8");
if($_POST['send'] && $_POST['subject'] && $_POST['text'])
{
$user=$_POST['user'];
if($_POST['signature'])
{
mysql_query("update users_signatures set signature_html='".$_POST['signature']."' where id='".$_POST['signature_id']."' and user_id='".$_SESSION['authenticated_user_id']."'");
}
$doKogo="";
foreach($user as $u)
{
$r=mysql_fetch_array(mysql_query("select email1 from users where id='".$u."'"));
if($r['email1'])$mail=$r['email1'];
else $mail="";
if($mail)$doKogo.=$mail.";";
}
$w=mysql_query("SELECT contents FROM user_preferences WHERE assigned_user_id='".$_SESSION['authenticated_user_id']."' AND category='global' AND deleted = 0");
$r=mysql_fetch_array($w);
if(!isset($user)) $user = $GLOBALS['current_user'];
$mailg=unserialize(base64_decode($r['contents']));
if($mailg['mail_fromaddress'])$mail_fromaddress=$mailg['mail_fromaddress'];
$r=mysql_fetch_array(mysql_query("select first_name,last_name from users where id='".$_SESSION['authenticated_user_id']."'"));
$mail_fromname=$r['first_name']." ".$r['last_name'];
if($mail_fromname==" ")$mail_fromname="Celtic CRM";
if(!$mail_fromaddress)$mail_fromaddress="crm@celtic.pl";
$odKogo=$mail_fromname." <".$mail_fromaddress.">"; // e-mail nadawcy
$r=mysql_fetch_array(mysql_query("select signature_html,id from users_signatures where user_id='".$_SESSION['authenticated_user_id']."'"));
if($r['signature_html']=="")$sig="--------
".$odKogo."
".$mail_fromaddress."";
else $sig=nl2br($r['signature_html']);
$imie="Celtic"; //imie nadawcy
$tresc=nl2br($_POST['text'])."
".$_POST['link']."
".$sig;
$temat=$_POST['subject'];
//$tresc.="
--------
".$odKogo."
support@more7.com";
//konwertowanie z utf-8 na iso 8859-2
$tresc = stripslashes($tresc);
$tresc = strtr($tresc, "\xA5\x8C\x8F\xB9\x9C\x9F", "\xA1\xA6\xAC\xB1\xB6\xBC");
$temat = stripslashes($temat);
$temat = strtr($temat, "\xA5\x8C\x8F\xB9\x9C\x9F", "\xA1\xA6\xAC\xB1\xB6\xBC");
//wysylanie maila
if(mailashtml($doKogo,$temat,$tresc,$odKogo))
{
$to_name="";
foreach($user as $u)
{
$r=mysql_fetch_array(mysql_query("select user_name from users where id='".$u."'"));
if($r['user_name'])
{
$to_name.=$r['user_name']."||";
}
}
$zz="insert into ecminform_history values('".create_guid()."','EcmCorrespondenceIns','".$_REQUEST['record']."','".$_SESSION['authenticated_user_id']."','".$to_name."','".date("Y-m-d H:i:s")."')";
mysql_query($zz);
$ok="ok";
}
else $ok="false";
}
?>
if(file_exists('include/FCKeditor/fckeditor.php')) {
include('include/FCKeditor/FCKeditor_Sugar.php') ;
ob_start();
$instancename = 'signature';
$oFCKeditor = new FCKeditor_Sugar($instancename) ;
$oFCKeditor->Width = 590;
$oFCKeditor->Height = 800;
if(!empty($focus->body)) {
$oFCKeditor->Value = $focus->body;
}
else $oFCKeditor->Value="";
$oFCKeditor->Create() ;
$htmlarea_src = ob_get_contents();
ob_end_clean();
}
?>