Files
crm.twinpol.com/modules/EcmDocuments/SendEmail.php
2025-05-12 15:44:39 +00:00

227 lines
12 KiB
PHP
Executable File

<?
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="--------<br>".$odKogo."<br><a href='mailto:".$mail_fromaddress."'>".$mail_fromaddress."</a>";
else $sig=nl2br($r['signature_html']);
$imie="Celtic"; //imie nadawcy
$tresc=nl2br($_POST['text'])."<br>".$_POST['link']."<br><br>".$sig;
$temat=$_POST['subject'];
//$tresc.="<br><br>--------<br>".$odKogo."<br><a href='mailto:support@more7.com'>support@more7.com</a>";
//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";
}
?>
<!--
/*********************************************************************************
* The contents of this file are subject to the SugarCRM Public License Version
* 1.1.3 ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* All copies of the Covered Code must include on each user interface screen:
* (i) the "Powered by SugarCRM" logo and
* (ii) the SugarCRM copyright notice
* in the same form as they appear in the distribution. See full license for
* requirements.
*
* The Original Code is: SugarCRM Open Source
* The Initial Developer of the Original Code is SugarCRM, Inc.
* Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
* All Rights Reserved.
* Contributor(s): ______________________________________.
********************************************************************************/
-->
<script type="text/javascript" src="../../include/javascript/cookie.js?s=4.5.0g&c="></script><link rel="stylesheet" type="text/css" media="all" href="../../themes/Sugar/calendar-win2k-cold-1.css?s=4.5.0g&c="><script>jscal_today = 1.195210724E+012; if(typeof app_strings == "undefined") app_strings = new Array();</script><script type="text/javascript" src="../../jscalendar/calendar.js?s=4.5.0g&c="></script><script type="text/javascript" src="../../jscalendar/lang/calendar-en.js?s=4.5.0g&c="></script><script type="text/javascript" src="../../jscalendar/calendar-setup_3.js?s=4.5.0g&c="></script><script src="../../include/javascript/yui/YAHOO.js?s=4.5.0g&c="></script><script src="../../include/javascript/yui/log.js?s=4.5.0g&c="></script><script src="../../include/javascript/yui/dom.js?s=4.5.0g&c="></script><script src="../../include/javascript/yui/event.js?s=4.5.0g&c="></script><script src="../../include/javascript/yui/animation.js?s=4.5.0g&c="></script><script src="../../include/javascript/yui/connection.js?s=4.5.0g&c="></script><script src="../../include/javascript/yui/dragdrop.js?s=4.5.0g&c="></script><script src="../../include/javascript/yui/ygDDList.js?s=4.5.0g&c="></script><script type="text/javascript" src="../../include/javascript/sugar_3.js?s=4.5.0g&c="></script><script type="text/javascript">
var time_reg_format = '([0-9]{1,2}):([0-9]{1,2})';
var date_reg_format = '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})';
var date_reg_positions = {'Y': 1,'m': 2,'d': 3};
var time_separator = ':';
var cal_date_format = '%Y-%m-%d';
var time_offset = 0;
</script><script type="text/javascript" src="../../cache/jsLanguage/en_us.js?s=4.5.0g&c=&j=3"></script><script type="text/javascript" src="../../cache/jsLanguage/Contracts/en_us.js?s=4.5.0g&c=&j=3"></script>
<?
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();
}
?>
</body>
<!DOCTYPE html PUBLIC "-//W3C//DTD html 4.01 Transitional//EN">
<html >
<style type="text/css">
<!--
body {
margin-left: 20px;
margin-top: 20px;
margin-right: 20px;
margin-bottom: 20px;
}
-->
</style><head >
<link REL="SHORTCUT ICON" HREF="include/images/sugar_icon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Celtic CRM</title>
<link rel="stylesheet" type="text/css" href="../../themes/Sugar/navigation.css?s=4.5.0g&c=" />
<link rel="stylesheet" type="text/css" href="../../themes/Sugar/style.css?s=4.5.0g&c=" />
<link rel="stylesheet" type="text/css" href="../../themes/Sugar/colors.sugar.css?s=4.5.0g&c=" />
<link rel="stylesheet" type="text/css" href="../../themes/Sugar/fonts.normal.css?s=4.5.0g&c=" />
<link href="../../themes/Sugar/colors.sugar.css?s=4.5.0g&c=" rel="stylesheet" type="text/css" title="color:sugar" />
<link href="../../themes/Sugar/colors.blue.css?s=4.5.0g&c=" rel="alternate stylesheet" type="text/css" title="color:blue" />
<link href="../../themes/Sugar/colors.green.css?s=4.5.0g&c=" rel="alternate stylesheet" type="text/css" title="color:green" />
<link href="../../themes/Sugar/colors.purple.css?s=4.5.0g&c=" rel="alternate stylesheet" type="text/css" title="color:purple" />
<link href="../../themes/Sugar/colors.ocher.css?s=4.5.0g&c=" rel="alternate stylesheet" type="text/css" title="color:ocher" />
<link href="../../themes/Sugar/fonts.normal.css?s=4.5.0g&c=" rel="stylesheet" type="text/css" title="font:normal" />
<link href="../../themes/Sugar/fonts.larger.css?s=4.5.0g&c=" rel="alternate stylesheet" type="text/css" title="font:larger" />
<link href="../../themes/Sugar/fonts.largest.css?s=4.5.0g&c=" rel="alternate stylesheet" type="text/css" title="font:largest" />
<script language="javascript" src="../../themes/Sugar/menu.js?s=4.5.0g&c="></script>
<script language="javascript" src="../../themes/Sugar/cookie.js?s=4.5.0g&c="></script>
<script language="javascript" src="../../themes/Sugar/style.js?s=4.5.0g&c="></script>
</head>
<body onLoad="<?if($ok=="ok")print "window.close();"?>">
<script type="text/javascript" src="../../include/javascript/popup_parent_helper.js?s=4.5.0g&c="></script>
<form name="EditView" method="POST" enctype="multipart/form-data" action="SendEmail.php?mod=<?print $_REQUEST['mod'];?>&record=<?print $_REQUEST['record'];?>">
<table width='100%' cellpadding='0' cellspacing='0' border='0' class='moduleTitle'><tr><td valign='top'>
<h2>EcmDocuments: Send Information</h2></td>
</tr></table>
<div style="padding-top: 2px">
<input name="send" type="submit" class="button" id="send" title="save" value="Send">
<input name="cancel" type="button" class="button" id="cancel" title="cancel" value="Cancel" onClick="window.close();">
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
<tr>
<td rowspan="2" valign="top" class="dataLabel"><strong>E-mail</strong></td>
<td rowspan="2" valign="top" class="dataField"><input type="hidden" name="email"><select name="user[]" size="6" multiple="multiple">
<?
$z="select id,email1,first_name,last_name,user_name from users where deleted='0' and email1 IS NOT NULL order by user_name asc";
$w=mysql_query($z);
while($r=mysql_fetch_array($w))
{
print "<option value='".$r['id']."'>".$r['first_name']." ".$r['last_name']."</option>";
}
?>
</select></td>
<td valign="top" class="dataLabel"><strong>Subject</strong></td>
<td valign="top" class="dataField"><textarea name="subject" cols="80" rows="2" id="subject">New Document in CRM (for your information)</textarea></td>
</tr>
<tr>
<td valign="top" class="dataLabel"><strong>Text</strong></td>
<td valign="top" class="dataField"><p>
<textarea name="text" cols="80" rows="10" id="text"><?
$ro=mysql_fetch_array(mysql_query("select first_name,last_name from users where id='".$_SESSION['authenticated_user_id']."'"));
print $ro['first_name']." ".$ro['last_name'];
?> would like to inform you about a new document in CRM.
This document was assigned to <?
$row=mysql_fetch_array(mysql_query("select assigned_user_id from ecmcorrespondenceins where id='".$_REQUEST['record']."'"));
$assigned_user=$row['assigned_user_id'];
$ro=mysql_fetch_array(mysql_query("select first_name,last_name from users where id='".$assigned_user."'"));
print $ro['first_name']." ".$ro['last_name'];
?>.</textarea>
<textarea name="link" readonly cols="80" rows="2" id="link"><a href='http://192.168.1.200/test/index.php?module=<?print $_REQUEST['mod'];?>&action=DetailView&amp;record=<?print $_REQUEST['record'];?>'>http://192.168.1.200/test/index.php?module=<?print $_REQUEST['mod'];?>&action=DetailView&amp;record=<?print $_REQUEST['record'];?></a></textarea>
<br>
<div style="display:block;" name="signature" cols="80" rows="6" id="signature"><?
$r=mysql_fetch_array(mysql_query("select signature_html,id from users_signatures where user_id='".$_SESSION['authenticated_user_id']."'"));
print $htmlarea_src;
$sig_id=$r['id'];
?></div>
<input type="hidden" id="signature_id" name="signature_id" value="<?print $sig_id;?>">
<!--<input type="button" value="Footer" onClick="window.open('../../index.php?module=Users&action=PopupEditView&the_user_id=<?print $_SESSION['authenticated_user_id'];?>&record=<?print $sig_id;?>','Podglad','resizable=yes,scrollbars=yes,status=no,height=500,width=800');">--></p>
</td>
<!-- BEGIN: pro -->
<!-- END: pro -->
<!-- BEGIN: open_source -->
<!-- END: open_source -->
</tr>
</table>
<input type="hidden" name="numusers" value="<?print $i;?>" />
<div style="padding-top: 2px">
<input name="send" type="submit" class="button" id="send" title="save" value="Send" >
<input name="cancel" type="button" class="button" id="cancel" title="cancel" value="Cancel" onClick="window.close();">
</div>
</form>
</html>
<!-- END: main -->
<? mysql_close($sql);?>