This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
include ('modules/MailMerge/index.php');
?>

39
modules/MailMerge/EditView.php Executable file
View File

@@ -0,0 +1,39 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
include ('modules/MailMerge/index.php');
?>

152
modules/MailMerge/MailMerge.php Executable file
View File

@@ -0,0 +1,152 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
class MailMerge
{
var $mm_data_dir;
var $obj;
var $datasource_file = 'ds.doc';
var $header_file = 'header.doc';
var $fieldcnt;
var $rowcnt;
var $template;
var $visible = false;
var $list;
var $fieldList;
function MailMerge($list = NULL, $fieldList = null, $data_dir = 'data') {
// this is the path to your data dir.
$this->mm_data_dir = $data_dir;
$this->list = $list;
$this->fieldList = $fieldList;
}
function Execute() {
$this->Initialize();
if( count( $this->list ) > 0 ) {
if(isset($this->template)) {
$this->CreateHeaderFile();
$this->CreateDataSource();
$file = $this->CreateDocument($this->template);
return $file;
}
} else return '';
}
function Template($template = NULL) {
if(is_array($template)) $this->template = $template;
}
function CleanUp() {
//remove the temp files
unlink($this->mm_data_dir.'/Temp/'.$this->datasource_file);
unlink($this->mm_data_dir.'/Temp/'.$this->header_file);
rmdir($this->mm_data_dir);
rmdir($this->mm_data_dir.'/Temp/');
$this->Quit();
}
function CreateHeaderFile() {
$this->obj->Documents->Add();
$this->obj->ActiveDocument->Tables->Add($this->obj->Selection->Range,1,$this->fieldcnt);
foreach($this->fieldList as $key => $value) {
$this->obj->Selection->TypeText($key);
$this->obj->Selection->MoveRight();
}
$this->obj->ActiveDocument->SaveAs($this->mm_data_dir.'/Temp/'.$this->header_file);
$this->obj->ActiveDocument->Close();
}
function CreateDataSource() {
$this->obj->Documents->Add();
$this->obj->ActiveDocument->Tables->Add($this->obj->Selection->Range,$this->rowcnt,$this->fieldcnt);
for($i = 0; $i < $this->rowcnt; $i++) {
foreach($this->fieldList as $field => $value)
{
$this->obj->Selection->TypeText($this->list[$i]->$field);
$this->obj->Selection->MoveRight();
}
}
$this->obj->ActiveDocument->SaveAs($this->mm_data_dir.'/Temp/'.$this->datasource_file);
$this->obj->ActiveDocument->Close();
}
function CreateDocument($template) {
//$this->obj->Documents->Open($this->mm_data_dir.'/Templates/'.$template[0].'.dot');
$this->obj->Documents->Open($template[0]);
$this->obj->ActiveDocument->MailMerge->OpenHeaderSource($this->mm_data_dir.'/Temp/'.$this->header_file);
$this->obj->ActiveDocument->MailMerge->OpenDataSource($this->mm_data_dir.'/Temp/'.$this->datasource_file);
$this->obj->ActiveDocument->MailMerge->Execute();
$this->obj->ActiveDocument->SaveAs($this->mm_data_dir.'/'.$template[1].'.doc');
//$this->obj->Documents[$template[0]]->Close();
//$this->obj->Documents[$template[1].'.doc']->Close();
$this->obj->ActiveDocument->Close();
return $template[1].'.doc';
}
function Initialize() {
$this->rowcnt = count($this->list);
$this->fieldcnt = count($this->fieldList);
$this->obj = new COM("word.application") or die("Unable to instanciate Word");
$this->obj->Visible = $this->visible;
//try to make the temp dir
sugar_mkdir($this->mm_data_dir);
sugar_mkdir($this->mm_data_dir.'/Temp/');
}
function Quit() {
$this->obj->Quit();
}
function SetDataList($list = NULL) {
if(is_array($list)) $this->list = $list;
}
function SetFieldList($list = NULL) {
if(is_array($list)) $this->fieldList = $list;
}
}
?>

50
modules/MailMerge/Menu.php Executable file
View File

@@ -0,0 +1,50 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: TODO To be written.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
global $mod_strings;
$module_menu = Array(
Array("index.php?module=MailMerge&action=index&reset=true", $mod_strings['LNK_NEW_MAILMERGE'],"MailMerge"),
Array("index.php?module=Documents&action=EditView&return_module=MailMerge&return_action=EditView", $mod_strings['LNK_UPLOAD_TEMPLATE'],"MailMerge"),
);
?>

62
modules/MailMerge/Merge.html Executable file
View File

@@ -0,0 +1,62 @@
<!--
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
-->
<!-- BEGIN: main -->
<form name="MailMerge" method="POST" action="index.php">
<p>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<th align="left" scope="row" colspan="2"><h4 class="">{MOD.LBL_STEP_5}</h4></th>
</tr>
<tr><td>&nbsp;</td></tr>
</table>
</p>
<p><table width="100%" cellpadding="2" cellspacing="0" border="0"><tr>
<td align="right">
<input title="{MOD.LBL_START}" accessKey="" class="button" type="button" name="button" value=" {MOD.LBL_START}" onClick="document.location.href='{MAILMERGE_REDIRECT_URL}'"></td>
</tr>
</table> </p>
</form>
<iframe src='index.php?entryPoint=mm_get_doc' frameborder=0 width='0px' height='0px'>
</iframe>
<!-- END: main -->

170
modules/MailMerge/Merge.php Executable file
View File

@@ -0,0 +1,170 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*
* Created on Oct 7, 2005
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
require_once('soap/SoapHelperFunctions.php');
require_once('modules/MailMerge/MailMerge.php');
require_once('include/upload_file.php');
global $beanList, $beanFiles;
global $app_strings;
global $app_list_strings;
global $mod_strings;
$xtpl = new XTemplate('modules/MailMerge/Merge.html');
$module = $_SESSION['MAILMERGE_MODULE'];
$document_id = $_SESSION['MAILMERGE_DOCUMENT_ID'];
$selObjs = urldecode($_SESSION['SELECTED_OBJECTS_DEF']);
$relObjs = (isset($_SESSION['MAILMERGE_RELATED_CONTACTS']) ? $_SESSION['MAILMERGE_RELATED_CONTACTS'] : '');
$relModule = '';
if(!empty($_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO'])){
$relModule = $_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO'];
}
if($_SESSION['MAILMERGE_MODULE'] == null)
{
sugar_die("Error during Mail Merge process. Please try again.");
}
$_SESSION['MAILMERGE_MODULE'] = null;
$_SESSION['MAILMERGE_DOCUMENT_ID'] = null;
$_SESSION['SELECTED_OBJECTS_DEF'] = null;
$_SESSION['MAILMERGE_SKIP_REL'] = null;
$_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO'] = null;
$item_ids = array();
parse_str(stripslashes(html_entity_decode($selObjs, ENT_QUOTES)),$item_ids);
if($module == 'CampaignProspects'){
$module = 'Prospects';
if(!empty($_SESSION['MAILMERGE_CAMPAIGN_ID'])){
$targets = array_keys($item_ids);
require_once('modules/Campaigns/utils.php');
campaign_log_mail_merge($_SESSION['MAILMERGE_CAMPAIGN_ID'],$targets);
}
}
$class_name = $beanList[$module];
$includedir = $beanFiles[$class_name];
require_once($includedir);
$seed = new $class_name();
$fields = get_field_list($seed);
$document = new DocumentRevision();//new Document();
$document->retrieve($document_id);
if(!empty($relModule)){
$rel_class_name = $beanList[$relModule ];
require_once($beanFiles[$rel_class_name]);
$rel_seed = new $rel_class_name();
}
global $sugar_config;
$filter = array();
if(array_key_exists('mailmerge_filter', $sugar_config)){
// $filter = $sugar_config['mailmerge_filter'];
}
array_push($filter, 'link');
$merge_array = array();
$merge_array['master_module'] = $module;
$merge_array['related_module'] = $relModule;
//rrs log merge
$ids = array();
foreach($item_ids as $key=>$value)
{
if(!empty($relObjs[$key])){
$ids[$key] = $relObjs[$key];
}else{
$ids[$key] = '';
}
}//rof
$merge_array['ids'] = $ids;
$dataDir = getcwd()."/{$GLOBALS['sugar_config']['cache_dir']}MergedDocuments/";
if(!file_exists($dataDir))
{
sugar_mkdir($dataDir);
}
srand((double)microtime()*1000000);
$mTime = microtime();
$dataFileName = 'sugardata'.$mTime.'.php';
write_array_to_file('merge_array', $merge_array, $dataDir.$dataFileName);
//Save the temp file so we can remove when we are done
$_SESSION['MAILMERGE_TEMP_FILE_'.$mTime] = $dataDir.$dataFileName;
$site_url = $sugar_config['site_url'];
$templateFile = $site_url.'/'.UploadFile::get_url(from_html($document->filename),$document->id);
$dataFile =$dataFileName;
$redirectUrl = 'index.php?action=index&step=5&module=MailMerge&mtime='.$mTime;
$startUrl = 'index.php?action=index&module=MailMerge&reset=true';
$relModule = trim($relModule);
$contents = "SUGARCRM_MAIL_MERGE_TOKEN#$templateFile#$dataFile#$module#$relModule";
$rtfFileName = 'sugartokendoc'.$mTime.'.doc';
$fp = sugar_fopen($dataDir.$rtfFileName, 'w');
fwrite($fp, $contents);
fclose($fp);
$_SESSION['mail_merge_file_location'] = $GLOBALS['sugar_config']['cache_dir'].'MergedDocuments/'.$rtfFileName;
$_SESSION['mail_merge_file_name'] = $rtfFileName;
$xtpl->assign("MAILMERGE_FIREFOX_URL", $site_url .'/'.$GLOBALS['sugar_config']['cache_dir'].'MergedDocuments/'.$rtfFileName);
$xtpl->assign("MAILMERGE_START_URL", $startUrl);
$xtpl->assign("MAILMERGE_TEMPLATE_FILE", $templateFile);
$xtpl->assign("MAILMERGE_DATA_FILE", $dataFile);
$xtpl->assign("MAILMERGE_MODULE", $module);
$xtpl->assign("MAILMERGE_REL_MODULE", $relModule);
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
$xtpl->assign("MAILMERGE_REDIRECT_URL", $redirectUrl);
$xtpl->parse("main");
$xtpl->out("main");
?>

89
modules/MailMerge/Save.php Executable file
View File

@@ -0,0 +1,89 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*
* Created on Oct 7, 2005
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
require_once('soap/SoapHelperFunctions.php');
require_once('modules/MailMerge/MailMerge.php');
global $beanList, $beanFiles;
$module = $_POST['mailmerge_module'];
$document_id = $_POST['document_id'];
$selObjs = urldecode($_POST['selected_objects_def']);
$item_ids = array();
parse_str($selObjs,$item_ids);
$class_name = $beanList[$module];
$includedir = $beanFiles[$class_name];
require_once($includedir);
$seed = new $class_name();
$fields = get_field_list($seed);
$document = new Document();
$document->retrieve($document_id);
$items = array();
foreach($item_ids as $key=>$value)
{
$seed->retrieve($key);
$items[] = $seed;
}
ini_set('max_execution_time', 600);
ini_set('error_reporting', 'E_ALL');
$dataDir = getcwd()."\\MergedDocuments\\";
$fileName = getcwd()."\\".$document->file_url_noimage;
list($outfile, $ext) = preg_split('/[.]/', $document->filename);
$mm = new MailMerge(null, null, $dataDir);
$mm->SetDataList($items);
$mm->SetFieldList($fields);
$mm->Template(array($fileName, $outfile));
$file = $mm->Execute();
$mm->CleanUp();
header("Location: index.php?module=MailMerge&action=Step4&file=".urlencode($file));
?>

156
modules/MailMerge/Step1.html Executable file
View File

@@ -0,0 +1,156 @@
<!--
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* {APP.LBL_CURRENCY_SYM}Header: /cvsroot/sugarcrm/sugarcrm/modules/Contacts/EditView.html,v 1.22 2004/07/16 04:04:42 sugarclint Exp {APP.LBL_CURRENCY_SYM}
********************************************************************************/
-->
<!-- BEGIN: main -->
<form enctype="multipart/form-data" name="MailMerge" method="POST" action="index.php">
<input type="hidden" name="module" value="MailMerge">
<input type="hidden" name="step" id="step" value="{STEP}">
<input type="hidden" name="action" value="index">
<input type="hidden" name="return_module" value="{RETURN_MODULE}">
<input type="hidden" name="return_id" value="{RETURN_ID}">
<input type="hidden" name="return_action" value="{RETURN_ACTION}">
<input type="hidden" name="record" value="{RECORD}">
<input type="hidden" name="selected_objects" value="{SELECTED_OBJECTS}">
<input type="hidden" name="selected_objects_def" value="{SELECTED_OBJECTS_DEF}">
<p>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view">
<tr>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<th align="left" scope="row" colspan="5"><h4 class="">{MOD.LBL_STEP_1}</h4></th>
</tr>
<tr><td width="5%"><slot>&nbsp;</slot></td></tr>
<tr>
<td scope="row" width="20%"><slot>{MODULE_SELECT}</slot>
</td>
<td ><slot><select tabindex='2' name='mailmerge_module' id='mailmerge_module'" style="width: 100px;" onChange="javascript:clearSpan();">{MAILMERGE_MODULE_OPTIONS}</select></slot></td>
<td align="right" colspan='2'><slot><em>{ADDIN_NOTICE}</em></slot></td>
</tr>
<tr>
<td >&nbsp;&nbsp;<slot><em><span id="numObjects">{MAILMERGE_NUM_SELECTED_OBJECTS}</span></em></slot></td>
<td ><slot>&nbsp;</slot></td>
<td ><slot>&nbsp;</slot></td>
<td ><slot>&nbsp;</slot></td>
</tr>
<tr>
<td ><slot>&nbsp;</slot></td>
<td ><slot>&nbsp;</slot></td>
<td ><slot>&nbsp;</slot></td>
<td ><slot>&nbsp;</slot></td>
</tr>
<tr>
<td scope="row" width="5%"><slot>{MOD.LBL_MAILMERGE_TEMPLATES}</slot></td>
<td ><slot><select id="document_id" name="document_id" style="width: 200px;">{MAILMERGE_TEMPLATES}</select></slot></td>
<td><slot>&nbsp;</slot></td>
<td align="right"><slot>&nbsp;</slot></td>
</tr>
<tr><td colspan"4"><slot>&nbsp;</slot></td></tr>
</table>
</td>
</tr>
</table>
</p>
<p><table width="100%" cellpadding="2" cellspacing="0" border="0"><tr>
<td align="right">
<input title="{MOD.LBL_NEXT}" accessKey="" class="button" type="submit" id="btnNext" name="button" value=" {MOD.LBL_NEXT}" onClick="return validateForm();" {DISABLE_NEXT_BUTTON}></td>
</tr>
</table> </p>
</form>
{JAVASCRIPT}
<script type="text/javascript" src="include/JSON.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="include/jsolait/init.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript">{JSON_CONFIG_JAVASCRIPT}</script>
<script type="text/javascript" src="include/javascript/jsclass_base.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="include/javascript/jsclass_async.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<script>
var mOffset = 0;
var max = 10;
//browserCheck();
function browserCheck()
{
if(document.layers)
{
button = document.getElementById("btnNext");
button.disabled = true;
alert("This requires IE 6.0 or greater for Windows.");
}
else if(document.layers || (!document.all && document.getElementById))
{
button = document.getElementById("btnNext");
button.disabled = true;
alert("This requires IE 6.0 or greater for Windows.");
}
}
function clearSpan()
{
document.getElementById("numObjects").innerHTML = "";
document.getElementById("step").value = "2";
}
function validateForm()
{
var templates = document.getElementById("document_id");
for (i=0;i<templates.options.length;i++)
{
if(templates[i].selected)
{
if(templates[i].value != "None")
{
return true;
}
}
}
alert("Please select a template.");
return false;
}
function disableModuleDropDown(){
var selectBox = document.getElementById("mailmerge_module");
selectBox.disabled = true;
}
{MAILMERGE_DISABLE_DROP_DOWN}
</script>
<!-- END: main -->

279
modules/MailMerge/Step1.php Executable file
View File

@@ -0,0 +1,279 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*
* Created on Oct 4, 2005
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
require_once('modules/MailMerge/modules_array.php');
require_once('include/json_config.php');
$json_config = new json_config();
global $app_strings;
global $app_list_strings;
global $mod_strings;
global $current_user;
global $beanList, $beanFiles;
global $sugar_version, $sugar_config;
$xtpl = new XTemplate('modules/MailMerge/Step1.html');
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
$xtpl->assign('JSON_CONFIG_JAVASCRIPT', $json_config->get_static_json_server(false, true));
if($_SESSION['MAILMERGE_MODULE'] == 'Campaigns' || $_SESSION['MAILMERGE_MODULE'] == 'CampaignProspects'){
$modules_array['Campaigns'] = 'Campaigns';
}
$module_list = $modules_array;
if(isset($_REQUEST['reset']) && $_REQUEST['reset'])
{
$_SESSION['MAILMERGE_MODULE'] = null;
$_SESSION['MAILMERGE_DOCUMENT_ID'] = null;
$_SESSION['SELECTED_OBJECTS_DEF'] = null;
$_SESSION['MAILMERGE_SKIP_REL'] = null;
$_SESSION['MAILMERGE_RECORD'] = null;
$_SESSION['MAILMERGE_RECORDS'] = null;
$_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO'] = null;
}
$fromListView = false;
if(!empty($_REQUEST['record']))
{
$_SESSION['MAILMERGE_RECORD'] = $_REQUEST['record'];
}
else if(isset($_REQUEST['uid'])) {
$_SESSION['MAILMERGE_RECORD'] = explode(',', $_REQUEST['uid']);
}
else if(isset($_REQUEST['entire']) && $_REQUEST['entire'] == 'true') {
// do entire list
$focus = 0;
$bean = $beanList[ $_SESSION['MAILMERGE_MODULE']];
require_once($beanFiles[$bean]);
$focus = new $bean;
if(isset($_SESSION['export_where']) && !empty($_SESSION['export_where'])) { // bug 4679
$where = $_SESSION['export_where'];
} else {
$where = '';
}
$beginWhere = substr(trim($where), 0, 5);
if ($beginWhere == "where")
$where = substr(trim($where), 5, strlen($where));
$query = $focus->create_export_query($order_by,$where);
$result = $db->query($query,true,"Error mail merging {$_SESSION['MAILMERGE_MODULE']}: "."<BR>$query");
$new_arr = array();
while($val = $db->fetchByAssoc($result,-1,false))
{
array_push($new_arr, $val['id']);
}
$_SESSION['MAILMERGE_RECORD'] = $new_arr;
}
else if(isset($_SESSION['MAILMERGE_RECORDS']))
{
$fromListView = true;
$_SESSION['MAILMERGE_RECORD'] = $_SESSION['MAILMERGE_RECORDS'];
$_SESSION['MAILMERGE_RECORDS'] = null;
}
$rModule = '';
if(isset($_SESSION['MAILMERGE_RECORD']))
{
if(!empty($_POST['return_module']) && $_POST['return_module'] != "MailMerge")
{
$rModule = $_POST['return_module'];
}
else if($fromListView)
{
$rModule = $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'];
$_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = null;
}
else
{
$rModule = $_SESSION['MAILMERGE_MODULE'];
}
if($rModule == 'CampaignProspects'){
$rModule = 'Campaigns';
}
$_SESSION['MAILMERGE_MODULE'] = $rModule;
if(!empty($rModule) && $rModule != "MailMerge")
{
$class_name = $beanList[$rModule];
$includedir = $beanFiles[$class_name];
require_once($includedir);
$seed = new $class_name();
$selected_objects = '';
foreach($_SESSION['MAILMERGE_RECORD'] as $record_id)
{
if($rModule == 'Campaigns'){
$prospect = new Prospect();
$prospect_module_list = array('leads', 'contacts', 'prospects', 'users');
foreach($prospect_module_list as $mname){
$pList = $prospect->retrieveTargetList("campaigns.id = '$record_id' AND related_type = #$mname#", array('id', 'first_name', 'last_name'));
foreach($pList['list'] as $bean){
$selected_objects .= $bean->id.'='.str_replace("&", "##", $bean->name).'&';
}
}
}else{
$seed->retrieve($record_id);
$selected_objects .= $record_id.'='.str_replace("&", "##", $seed->name).'&';
}
}
if($rModule != 'Contacts'
&& $rModule != 'Leads' && $rModule != 'Products' && $rModule != 'Campaigns' && $rModule != 'Projects'
)
{
$_SESSION['MAILMERGE_SKIP_REL'] = false;
$xtpl->assign("STEP", "2");
$xtpl->assign("SELECTED_OBJECTS", $selected_objects);
$_SESSION['SELECTED_OBJECTS_DEF'] = $selected_objects;
}
else
{
$_SESSION['MAILMERGE_SKIP_REL'] = true;
$xtpl->assign("STEP", "2");
$_SESSION['SELECTED_OBJECTS_DEF'] = $selected_objects;
}
}
else
{
$xtpl->assign("STEP", "2");
}
}
else
{
$xtpl->assign("STEP", "2");
}
$modules = $module_list;
$func = "";
if($rModule == 'Campaigns'){
$func = "disableModuleDropDown();";
}
$xtpl->assign("MAILMERGE_DISABLE_DROP_DOWN", $func);
$xtpl->assign("MAILMERGE_MODULE_OPTIONS", get_select_options_with_id($modules, $_SESSION['MAILMERGE_MODULE']));
$xtpl->assign("MAILMERGE_TEMPLATES", get_select_options_with_id(getDocumentRevisions(), '0'));
if(isset($_SESSION['MAILMERGE_MODULE'])){
$module_select_text = $mod_strings['LBL_MAILMERGE_SELECTED_MODULE'];
$xtpl->assign("MAILMERGE_NUM_SELECTED_OBJECTS",count($_SESSION['MAILMERGE_RECORD'])." ".$_SESSION['MAILMERGE_MODULE']." Selected");
}
else{
$module_select_text = $mod_strings['LBL_MAILMERGE_MODULE'];
}
$xtpl->assign("MODULE_SELECT", $module_select_text);
if($_SESSION['MAILMERGE_MODULE'] == 'Campaigns'){
$_SESSION['MAILMERGE_MODULE'] = 'CampaignProspects';
}
$admin = new Administration();
$admin->retrieveSettings();
$user_merge = $current_user->getPreference('mailmerge_on');
if ($user_merge != 'on' || !isset($admin->settings['system_mailmerge_on']) || !$admin->settings['system_mailmerge_on']){
$xtpl->assign("ADDIN_NOTICE", $mod_strings['LBL_ADDIN_NOTICE']);
$xtpl->assign("DISABLE_NEXT_BUTTON", "disabled");
}
$xtpl->parse("main");
$xtpl->out("main");
function get_user_module_list($user){
global $app_list_strings, $current_language;
$app_list_strings = return_app_list_strings_language($current_language);
$modules = query_module_access_list($user);
global $modInvisList, $modInvisListActivities;
if(isset($modules['Calendar']) || $modules['Activities']){
foreach($modInvisListActivities as $invis){
$modules[$invis] = $invis;
}
}
return $modules;
}
function getDocumentRevisions()
{
$document = new Document();
$currentDate = gmdate($GLOBALS['timedate']->get_db_date_time_format());
if ($document->db->dbType=="mysql") {
$empty_date=db_convert("'0000-00-00'", 'datetime');
}
else {
$empty_date=db_convert("'1970-01-01 00:00:00'", 'datetime');
}
$query = "SELECT revision, document_name, document_revisions.id FROM document_revisions
LEFT JOIN documents on documents.id = document_revisions.document_id WHERE ((active_date <= ".db_convert("'".$currentDate."'", 'datetime')." AND exp_date > ".db_convert("'".$currentDate."'", 'datetime').") OR (active_date is NULL) or (active_date = ".$empty_date.") or (active_date <= ".db_convert("'".$currentDate."'", 'datetime')." AND ((exp_date = ".$empty_date.") OR (exp_date is NULL)))) AND is_template = 1 AND template_type = 'mailmerge' AND documents.deleted = 0 ORDER BY document_name";
$result = $document->db->query($query,true,"Error retrieving $document->object_name list: ");
$list = Array();
$list['None'] = 'None';
while(($row = $document->db->fetchByAssoc($result)) != null)
{
$revision = null;
$docName = $row['document_name'];
$revision = $row['revision'];
if(!empty($revision));
{
$docName .= " (rev. ".$revision.")";
}
$list[$row['id']] = $docName;
}
return $list;
}
?>

382
modules/MailMerge/Step2.html Executable file
View File

@@ -0,0 +1,382 @@
<!--
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* {APP.LBL_CURRENCY_SYM}Header: /cvsroot/sugarcrm/sugarcrm/modules/Contacts/EditView.html,v 1.22 2004/07/16 04:04:42 sugarclint Exp {APP.LBL_CURRENCY_SYM}
********************************************************************************/
-->
<!-- BEGIN: main -->
<!-- BEGIN: error -->
<span class="error">{ERROR}</span>
<!-- END: error -->
<form enctype="multipart/form-data" name="MailMerge" method="POST" action="index.php">
<input type="hidden" name="module" value="MailMerge">
<input type="hidden" name="step" id="step" value="{STEP}">
<input type="hidden" name="action" value="index">
<input type="hidden" name="return_module" value="{RETURN_MODULE}">
<input type="hidden" name="return_id" value="{RETURN_ID}">
<input type="hidden" name="return_action" value="{RETURN_ACTION}">
<input type="hidden" name="selected_objects" id="selected_objects">
<p>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<th align="left" scope="row" colspan="2"><h4 class="">{MAIL_MERGE_HEADER_STEP_2}</h4></th>
</tr>
<tr><td><slot>&nbsp;</slot></td></tr>
<tr>
<td><input type='text' id="searchText" name="searchText"></td>
<td><input type="button" id="searchSubmit" value="Search" onClick="search();" class='button'></td>
</tr>
<tr><td>{MAIL_MERGE_CAMPAIGN_PROSPECT_SELECTOR}</td></tr>
</table>
<table>
<tr>
<td>
{MAILMERGE_PREV}
<span id="result_count"></span>
{MAILMERGE_NEXT}
</td>
</tr>
<tr>
<td colspan='1'>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td scope="row">Available
<table>
<tr>
<td><slot><select id="display_objs" name="display_objs[]" size="10" multiple="multiple" ></select></slot></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td>
{MAILMERGE_LEFT_TO_RIGHT}
<br>
{MAILMERGE_RIGHT_TO_LEFT}
</td>
<td colspan='1'>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td scope="row">Selected
<table>
<tr>
<td><slot><select id="selected_objs" name="selected_objs[]" size="10" multiple="multiple" >{MAILMERGE_PRESELECTED_OBJECTS}</select></slot></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr><td>{MAIL_MERGE_CONTAINS_CONTACT_INFO}</td></tr>
</table>
</p>
<p><table width="100%" cellpadding="2" cellspacing="0" border="0"><tr>
<td align="left"><input id="prevButton" title="{MOD.LBL_BACK}" accessKey="" class="button" type="submit" name="button" value=" {MOD.LBL_BACK} " onclick="this.form.step.value='1'; return true;"></td>
<td align="right"><input id="nextButton" title="{MOD.LBL_NEXT}" accessKey="" class="button" type="submit" name="button" value=" {MOD.LBL_NEXT} " onclick="set_selected_items();return validateForm();"></td>
</tr>
</table> </p>
</form>
{JAVASCRIPT}
<script type="text/javascript" src="include/JSON.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="include/jsolait/init.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript">{JSON_CONFIG_JAVASCRIPT}</script>
<script type="text/javascript" src="include/javascript/jsclass_base.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<script type="text/javascript" src="include/javascript/jsclass_async.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
<script>
var module = "{MAILMERGE_MODULE}";
var mOffset = 0;
var max = 20;
var mWhere = "{MAILMERGE_WHERE}";
var orderBy = '';
function ResponseObj()
{
}
ResponseObj.prototype.response = function (result)
{
var prevButton = document.getElementById("prevButton");
var nextButton = document.getElementById("nextButton");
var prevItems = document.getElementById("prevItems");
var nextItems= document.getElementById("nextItems");
var dispCount = max;
var dispMin = mOffset;
if(result.result_count < max)
{
dispCount = result.result_count;
nextItems.disabled = true;
}
if(result.result_count - max == mOffset)
{
nextItems.disabled = true;
}
else
{
nextItems.disabled = false;
}
if(mOffset == 0)
{
prevItems.disabled = true;
}
else
{
prevItems.disabled = false;
}
if(result.result_count > 0)
{
dispMin = mOffset + 1;
}
var spanText = "("+(dispMin) + " - " +(mOffset+dispCount) + " of " + result.result_count+")";
document.getElementById("result_count").innerHTML = spanText;
var displayObjs = document.getElementById("display_objs");
displayObjs.options.length = 0;
var isLeadOrContact = false;
if(module == 'Contacts' || module == 'Leads' || module == 'CampaignProspects')
{
isLeadOrContact = true;
}
for (i = 0; i < result.entry_list.length; i++)
{
var id = '';
var name = '';
var name1 = '';
var name2 = '';
id = result.entry_list[i]['name_value_list'].id.value;
if(isLeadOrContact)
{
name1 = result.entry_list[i]['name_value_list'].first_name.value;
name2 = result.entry_list[i]['name_value_list'].last_name.value;
}
else
{
name1 = '';
name2 = result.entry_list[i]['name_value_list'].name.value;
}
name = name1 + ' ' + name2;
displayObjs.options[displayObjs.length] = new Option(name, id);
}
prevButton.disabled = false;
nextButton.disabled = false;
}
function increaseOffset()
{
mOffset += 20;
}
function decreaseOffset()
{
mOffset -= 20;
}
function getObjects()
{
var prevButton = document.getElementById("prevButton");
var nextButton = document.getElementById("nextButton");
prevButton.disabled = true;
nextButton.disabled = true;
getOrderBy();
//rrs
//mWhere = "campaigns.id = '9be5dd91-d20b-c5fd-1769-4554d8eede05'";
query = {"module":module, "offset":mOffset, "where":mWhere, "max":max, "order_by":orderBy};
req_id = global_rpcClient.call_method('get_objects_from_module',query);
var res = new ResponseObj();
global_request_registry[req_id] = [ res,'response'];
}
function moveRight()
{
var displayObjs = document.getElementById("display_objs");
var selObjs = document.getElementById("selected_objs");
for (i=0;i<displayObjs.options.length;i++)
{
if(displayObjs[i].selected)
{
var current = displayObjs.options[i];
selObjs.options.add(new Option(current.text, current.value));
}
}
//remove them now
for (i = displayObjs.length - 1; i>=0; i--) {
try
{
if(displayObjs.options[i].selected)
{
displayObjs.remove(i);
}
}
catch(e){}
}
}
function moveLeft()
{
var selObjs = document.getElementById("selected_objs");
var displayObjs = document.getElementById("display_objs");
for (i=0;i<selObjs.options.length;i++)
{
if(selObjs[i].selected)
{
var current = selObjs.options[i];
displayObjs.options.add(new Option(current.text, current.value));
}
}
for (i = selObjs.length - 1; i>=0; i--) {
try
{
if(selObjs.options[i].selected)
{
selObjs.remove(i);
}
}
catch(e){}
}
}
function set_selected_items()
{
var selObjs = document.getElementById("selected_objs");
var containsContactInfo = document.getElementById("contains_contact_info");
var step = document.getElementById("step");
var selected_objects = '';
for(i=0; i < selObjs.options.length ;i++)
{
selected_objects += selObjs.options[i].value+"="+selObjs.options[i].text.replace(/&/g, "##")+"&";
}
document.MailMerge.selected_objects.value = selected_objects;
//BEGIN CHANGE 38959 -- raagaard
if(containsContactInfo != null && containsContactInfo.options[containsContactInfo.selectedIndex].value)
//END CHANGE 38959 -- raagaard
{
step.value = "3";
}
else
{
step.value = "4";
}
}
function search(searchText)
{
var searchInput = document.getElementById("searchText");
searchText = searchInput.value;
var where = '';
if(searchText != '')
{
if(module == 'Contacts' || module == 'Leads')
{
where = module+".first_name like '%"+searchText+"%' OR "+module+".last_name like '%"+searchText+"%'";
}
else if(module == 'CampaignProspects'){
var prospectType = document.getElementById("campaign_prospect_type");
var lmodule = prospectType.value.toLowerCase();
var campign_where = "{MAILMERGE_WHERE}";
where = lmodule+".first_name like '%"+searchText+"%' OR "+lmodule+".last_name like '%"+searchText+"%'";
if(campign_where)
where += " AND "+campign_where ;
where += " AND related_type = #"+lmodule+"#"
}
else
{
where = module+".name like '"+searchText+"%'";
}
}
mWhere = where.toLowerCase();
getObjects();
}
function getOrderBy()
{
var order = '';
if(module == 'Contacts' || module == 'Leads')
{
order = module+".last_name";
}
else
{
order = module+".name";
}
orderBy = order.toLowerCase();
}
function validateForm()
{
var selObjs = document.getElementById("selected_objs");
if(selObjs.options.length > 0)
{
return true;
}
else
{
alert("Please select at least one item.");
return false;
}
}
if({MAILMERGE_GET_OBJECTS}){
getObjects();
}
</script>
<!-- END: main -->

169
modules/MailMerge/Step2.php Executable file
View File

@@ -0,0 +1,169 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*
* Created on Oct 4, 2005
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
//require_once('include/utils.php');
require_once('include/json_config.php');
$json_config = new json_config();
global $app_strings;
global $app_list_strings;
global $mod_strings;
global $current_user;
global $theme;
global $sugar_version, $sugar_config;
$xtpl = new XTemplate('modules/MailMerge/Step2.html');
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
$xtpl->assign('JSON_CONFIG_JAVASCRIPT', $json_config->get_static_json_server(false, true));
if(isset($_POST['mailmerge_module']))
{
$_SESSION['MAILMERGE_MODULE'] = $_POST['mailmerge_module'];
if($_SESSION['MAILMERGE_MODULE'] == 'Campaigns'){
$_SESSION['MAILMERGE_MODULE'] = 'CampaignProspects';
}
if($_SESSION['MAILMERGE_MODULE'] == 'Contacts' || $_SESSION['MAILMERGE_MODULE'] == 'Leads'|| $_SESSION['MAILMERGE_MODULE'] == 'CampaignProspects')
{
$_SESSION['MAILMERGE_SKIP_REL'] = true;
}
}
$step_txt = "Step 2: ";
if(!empty($_SESSION['SELECTED_OBJECTS_DEF'])){
$selObjs = $_SESSION['SELECTED_OBJECTS_DEF'];
$sel_obj = array();
parse_str($selObjs,$sel_obj);
$idArray = array();
$_SESSION['MAILMERGE_WHERE'] = "";
foreach($sel_obj as $key => $value){
$value = str_replace("##", "&", $value);
$idArray[$key] = $value;
if($_SESSION['MAILMERGE_MODULE'] == 'CampaignProspects'){
if(isset($_POST['mailmerge_module']) && $_POST['mailmerge_module'] == 'Campaigns'){
$where = "campaigns.id = '$key'";
$_SESSION['MAILMERGE_WHERE'] = $where;
$_SESSION['MAILMERGE_CAMPAIGN_ID'] = $key;
$idArray = array();
break;
}
}
}
$xtpl->assign("MAILMERGE_WHERE", $_SESSION['MAILMERGE_WHERE']);
$xtpl->assign("MAILMERGE_PRESELECTED_OBJECTS", get_select_options_with_id($idArray, '0'));
$step_txt .= "Refine list of ".$_SESSION['MAILMERGE_MODULE']." to merge.";
$xtpl->assign("MAILMERGE_GET_OBJECTS", 0);
}
else
{
$step_txt .= "Select list of ".$_SESSION['MAILMERGE_MODULE']." to merge.";
$xtpl->assign("MAILMERGE_GET_OBJECTS", 1);
}
if(isset($_SESSION['MAILMERGE_SKIP_REL']) && $_SESSION['MAILMERGE_SKIP_REL'])
{
$xtpl->assign("STEP", "4");
}
else
{
$selected = '';
if(isset($_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO']) && $_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO']){
$selected = $_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO'];
}
$xtpl->assign("STEP", "3");
//$xtpl->assign("MAIL_MERGE_CONTAINS_CONTACT_INFO", '<table><tr><td><input id="contains_contact_info" name="contains_contact_info" class="checkbox" type="checkbox" '.$checked.'/></td><td>'.$mod_strings['LBL_CONTAINS_CONTACT_INFO'].'</td></tr></table>');
$rel_options = array(""=>"--None--", "Contacts"=>"Contacts");
if($_SESSION['MAILMERGE_MODULE'] == "Accounts"){
$rel_options["Opportunities"] = "Opportunities";
}
elseif($_SESSION['MAILMERGE_MODULE'] == "Opportunities"){
$rel_options["Accounts"] = "Accounts";
}
$xtpl->assign("MAIL_MERGE_CONTAINS_CONTACT_INFO", '<table><tr><td>'.$mod_strings['LBL_CONTAINS_CONTACT_INFO'].'</td><td><select id="contains_contact_info" name="contains_contact_info">'.get_select_options_with_id($rel_options, $selected).'</select></td></tr></table>');
}
$xtpl->assign("MAILMERGE_MODULE", $_SESSION['MAILMERGE_MODULE']);
$xtpl->assign("MAILMERGE_PREV", SugarThemeRegistry::current()->getImage('previous','border="0" style="margin-left: 1px;" alt="Previous" id="prevItems" onClick="decreaseOffset();getObjects();"'));
$xtpl->assign("MAILMERGE_NEXT", SugarThemeRegistry::current()->getImage('next','border="0" style="margin-left: 1px;" alt="Next" id="nextItems" onClick="increaseOffset();getObjects();"'));
$xtpl->assign("MAILMERGE_RIGHT_TO_LEFT", SugarThemeRegistry::current()->getImage('leftarrow_big','border="0" style="margin-left: 1px;" alt="Remove Item(s)" onClick="moveLeft();"'));
$xtpl->assign("MAILMERGE_LEFT_TO_RIGHT", SugarThemeRegistry::current()->getImage('rightarrow_big','border="0" style="margin-left: 1px;" alt="Add Item(s)" onClick="moveRight();"'));
$xtpl->assign("MAIL_MERGE_HEADER_STEP_2", $step_txt);
if($_SESSION['MAILMERGE_MODULE'] == 'CampaignProspects'){
$rel_options = array("Contacts"=>"Contacts", "Leads" => "Leads", "Prospects" => "Prospects", "Users"=>"Users");
$xtpl->assign("MAIL_MERGE_CAMPAIGN_PROSPECT_SELECTOR", '<select id="campaign_prospect_type" name="campaign_prospect_type">'.get_select_options_with_id($rel_options, 'Prospects').'</select>');
}
if(!empty($_POST['document_id']))
{
$_SESSION['MAILMERGE_DOCUMENT_ID'] = $_POST['document_id'];
}
$xtpl->parse("main");
$xtpl->out("main");
function displaySelectionBox($objectList)
{
$html = '<select id="display_objs" name="display_objs[]" size="10" multiple="multiple" size="10" >';
foreach($objectList as $key=>$value)
{
$html .= '<option value="'.$key.'">'.$value.'</option>';
}
$html .= '</select>';
return $html;
}
?>

97
modules/MailMerge/Step3.html Executable file
View File

@@ -0,0 +1,97 @@
<!--
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* {APP.LBL_CURRENCY_SYM}Header: /cvsroot/sugarcrm/sugarcrm/modules/Contacts/EditView.html,v 1.22 2004/07/16 04:04:42 sugarclint Exp {APP.LBL_CURRENCY_SYM}
********************************************************************************/
-->
<!-- BEGIN: main -->
<!-- BEGIN: error -->
<span class="error">{ERROR}</span>
<!-- END: error -->
<form enctype="multipart/form-data" name="EditView" method="POST" action="index.php">
<input type="hidden" name="module" value="MailMerge">
<input type="hidden" name="step" value="4">
<input type="hidden" name="action" value="index">
<input type="hidden" name="return_module" value="{RETURN_MODULE}">
<input type="hidden" name="return_id" value="{RETURN_ID}">
<input type="hidden" name="return_action" value="{RETURN_ACTION}">
<input type="hidden" name="selected_objects_def" value="{MAILMERGE_SELECTED_OBJECTS_DEF}">
<p>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view">
<tr>
<th align="left" scope="row" colspan="2"><h4 class="">{STEP_NUM}&nbsp;{STEP3_HEADER}</h4></th>
</tr>
<tr>
<td>
<em>Use the selections below to identify the related information you would like to display in your merged document. Skip this step if your template document contains no related information.</em>
</td></tr>
<tr>
<td>
<!-- BEGIN: items -->
<table cellpadding="0" cellspacing="0" width="100%" border="0" class="list view">
<tr height="20" >
<td width="28%" >{MOD.LBL_LIST_NAME}</td>
<td width="45%" >{STEP3_HEADER}</td>
</tr>
<!-- BEGIN: row -->
<tr height="20" class="{ROW_COLOR}S1">
<td valign="top">{MAILMERGE.NAME}</td>
<td valign="top"><input name='rel_type_{MAILMERGE.CODE}' type="hidden" value="{MAILMERGE.REL_MODULE}"><input name='rel_id_{MAILMERGE.CODE}' type="hidden" value='{MAILMERGE.CONTACT_ID}'><input name='rel_name_{MAILMERGE.CODE}' tabindex='0' readonly type='text' value='{MAILMERGE.CONTACT_NAME}'>{MAILMERGE.CHANGE_RELATIONSHIP}</td>
</tr>
<tr>
<td colspan="1" valign=TOP bgcolor="{BG_COLOR}" class="{ROW_COLOR}S1"></td>
<td colspan="1" valign=TOP bgcolor="{BG_COLOR}" class="{ROW_COLOR}S1"></td>
</tr>
<tr><td colspan="2" class="listViewHRS1"></td></tr>
<!-- END: row -->
</table>
<!-- END: items -->
</td>
</tr>
</table>
</p>
<p><table width="100%" cellpadding="2" cellspacing="0" border="0"><tr>
<td align="left"><input title="{MOD.LBL_BACK}" accessKey="" class="button" type="submit" name="button" value=" {MOD.LBL_BACK} " onclick="this.form.action.value='index'; this.form.step.value='{PREV_STEP}'; return true;"></td>
<td align="right"><input title="{MOD.LBL_FINISH}" accessKey="" class="button" type="submit" name="button" value=" {MOD.LBL_NEXT} "></td>
</tr>
</table> </p>
</form>
{JAVASCRIPT}
<!-- END: main -->

248
modules/MailMerge/Step3.php Executable file
View File

@@ -0,0 +1,248 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*
* Created on Oct 4, 2005
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
require_once ('include/JSON.php');
require_once('modules/MailMerge/modules_array.php');
global $app_strings;
global $app_list_strings;
global $mod_strings;
global $current_user;
global $odd_bg;
global $even_bg;
global $sugar_version, $sugar_config;
global $locale;
$xtpl = new XTemplate('modules/MailMerge/Step3.html');
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
if(!isset($_SESSION['MAILMERGE_MODULE']))
{
if(isset($_POST['mailmerge_module']))
{
$_SESSION['MAILMERGE_MODULE'] = $_POST['mailmerge_module'];
}
}
if(isset($_POST['contains_contact_info'])){
$_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO'] = $_POST['contains_contact_info'];
}
if(!isset($_SESSION["MAILMERGE_DOCUMENT_ID"]))
{
if(!empty($_POST['document_id']))
{
$_SESSION['MAILMERGE_DOCUMENT_ID'] = $_POST['document_id'];
}
}
$document_id = $_SESSION["MAILMERGE_DOCUMENT_ID"];
$document = new Document();
$document->retrieve($document_id);
$_SESSION["MAILMERGE_TEMPLATE"] = $document->document_name;
if(!empty($_POST['selected_objects']))
{
$selObjs = urldecode($_POST['selected_objects']);
$_SESSION['SELECTED_OBJECTS_DEF'] = $selObjs;
}
else
{
$selObjs = $_SESSION['SELECTED_OBJECTS_DEF'];
}
$sel_obj = array();
parse_str(html_entity_decode($selObjs, ENT_QUOTES),$sel_obj);
$step_num = 3;
if(isset($_SESSION['MAILMERGE_RECORD']))
{
$xtpl->assign("PREV_STEP", '2');
$step_num = 3;
//$xtpl->assign("RECORD", $_SESSION['MAILMERGE_RECORD']);
}
else
{
$xtpl->assign("PREV_STEP", '2');
}
$xtpl->assign("STEP_NUM", "Step ".$step_num.":");
$popup_request_data = array ('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array ('id' => 'rel_id', 'name' => 'rel_name',),);
$json = getJSONobj();
// must urlencode to put into the filter request string
// because IE gets an out of memory error when it is passed
// as the usual object literal
$encoded_popup_request_data = urlencode($json->encode($popup_request_data));
$modules = $modules_array;
$xtpl->assign("MAILMERGE_MODULE_OPTIONS", get_select_options_with_id($modules, '0'));
$change_parent_button = "<input title='".$app_strings['LBL_SELECT_BUTTON_TITLE']."' tabindex='2' accessKey='".$app_strings['LBL_SELECT_BUTTON_KEY']."' type='button' class='button' value='".$app_strings['LBL_SELECT_BUTTON_LABEL']."' name='button' onclick='open_popup(document.EditView.rel_type.value, 600, 400, \"&request_data=$encoded_popup_request_data\", true, false, {});' />";
$change_parent_button = "<input title='".$app_strings['LBL_SELECT_BUTTON_TITLE']."' tabindex='2' accessKey='".$app_strings['LBL_SELECT_BUTTON_KEY']."' type='button' class='button' value='".$app_strings['LBL_SELECT_BUTTON_LABEL']."' name='button' onclick='open_popup(document.EditView.parent_type.value, 600, 400, \"&request_data=$encoded_popup_request_data\", true, false, {});' />";
$xtpl->assign("CHANGE_PARENT_BUTTON", $change_parent_button);
$relModule = $_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO'];
$xtpl->assign("STEP3_HEADER", "Set ".get_singular_bean_name($relModule)." Association");
$select = "Select id, name from contacts";
$selQuery = array ('Contacts'=>array('Accounts' => 'SELECT contacts.* FROM contacts LEFT JOIN accounts_contacts ON contacts.id=accounts_contacts.contact_id AND (accounts_contacts.deleted is NULL or accounts_contacts.deleted=0)',
'Contacts' => '',
'Opportunities' => 'SELECT contacts.* FROM contacts LEFT JOIN opportunities_contacts ON contacts.id=opportunities_contacts.contact_id AND (opportunities_contacts.deleted is NULL or opportunities_contacts.deleted=0)',
'Leads' => '',
'Cases' => 'SELECT contacts.* FROM contacts LEFT JOIN contacts_cases ON contacts.id=contacts_cases.contact_id AND (contacts_cases.deleted is NULL or contacts_cases.deleted=0)',
'Bugs' => 'SELECT contacts.* FROM contacts LEFT JOIN contacts_bugs ON contacts.id=contacts_bugs.contact_id AND (contacts_bugs.deleted is NULL or contacts_bugs.deleted=0)',
'Quotes' => 'SELECT contacts.* FROM contacts LEFT JOIN quotes_contacts ON contacts.id=quotes_contacts.contact_id AND (quotes_contacts.deleted is NULL or quotes_contacts.deleted=0)'),
'Opportunities'=>array("Accounts"=>'SELECT opportunities.id, opportunities.name FROM opportunities LEFT JOIN accounts_opportunities ON opportunities.id = accounts_opportunities.opportunity_id AND (accounts_opportunities.deleted is NULL or accounts_opportunities.deleted=0)'),
'Accounts'=>array("Opportunities"=>'SELECT accounts.id, accounts.name FROM accounts LEFT JOIN accounts_opportunities ON accounts.id = accounts_opportunities.account_id AND (accounts_opportunities.deleted is NULL or accounts_opportunities.deleted=0)'),
);
$whereQuery = array('Contacts' => array('Accounts' => 'accounts_contacts.contact_id = contacts.id AND accounts_contacts.account_id = ',
'Contacts' => '',
'Opportunities' => 'opportunities_contacts.contact_id = contacts.id AND opportunities_contacts.opportunity_id = ',
'Leads' => '',
'Cases' => 'contacts_cases.contact_id = contacts.id AND contacts_cases.case_id = ',
'Bugs' => 'contacts_bugs.contact_id = contacts.id AND contacts_bugs.bug_id = ',
'Quotes' => 'quotes_contacts.contact_id = contacts.id AND quotes_contacts.quote_id = '),
'Opportunities'=>array('Accounts'=>'accounts_opportunities.opportunity_id = opportunities.id AND accounts_opportunities.account_id = '),
'Accounts'=>array('Opportunities'=>'accounts_opportunities.account_id = accounts.id AND accounts_opportunities.opportunity_id = '),
);
$contact = new Contact();
global $beanList, $beanFiles;
$class_name = $beanList[$relModule ];
require_once($beanFiles[$class_name]);
$seed = new $class_name();
if(isset($_SESSION['MAILMERGE_SKIP_REL']) && $_SESSION['MAILMERGE_SKIP_REL'])
{
$disabled = 'disabled';
}
else
{
$disabled = '';
}
$oddRow = true;
foreach($sel_obj as $key => $value)
{
$value = str_replace("##", "&", $value);
$value = stripslashes($value);
$code = str_replace('-', '', $key);
$popup_request_data = array ('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array ('id' => 'rel_id_'.$code, 'name' => 'rel_name_'.$code,),);
$encoded_popup_request_data = urlencode($json->encode($popup_request_data));
$select = $selQuery[$relModule][$_SESSION['MAILMERGE_MODULE']];
$where = $whereQuery[$relModule][$_SESSION['MAILMERGE_MODULE']];
if($relModule == "Contacts"){
$limitSelect = str_replace('contacts.*', 'contacts.first_name, contacts.last_name, contacts.id, contacts.date_entered', $select);
}
else{
$limitSelect = str_replace(strtolower($relModule).'.*', strtolower($relModule).'.name, '.strtolower($relModule).'.date_entered', $select);
}
$fullQuery = $limitSelect." WHERE ".$where."'".$key."' ORDER BY date_entered";
$result = $seed->db->limitQuery($fullQuery, 0, 1, true, "Error performing limit query");
$full_name = '';
$contact_id = '';
if($contact->db->getRowCount($result) > 0)
{
$row = $seed->db->fetchByAssoc($result, 0);
if($relModule == "Contacts"){
$full_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']);
}
else{
$full_name = $row['name'];
}
$contact_id = $row['id'];
}
$change_parent_button = "<input title='".$app_strings['LBL_SELECT_BUTTON_TITLE']."' tabindex='2' accessKey='".$app_strings['LBL_SELECT_BUTTON_KEY']."' type='button' class='button' value='".$app_strings['LBL_SELECT_BUTTON_LABEL']."' name='button' onclick='open_popup(document.EditView.rel_type_".$code.".value, 600, 400, \"&html=mail_merge&select=$select&where=$where&id=$key&request_data=$encoded_popup_request_data\", true, false, {});' $disabled/>";
$items = array(
'ID' => $key,
'NAME' => $value,
'CODE' => $code,
'TYPE_OPTIONS' => get_select_options_with_id($modules, '0'),
'CHANGE_RELATIONSHIP' => $change_parent_button,
'CONTACT_ID' => $contact_id,
'CONTACT_NAME' => $full_name,
'REL_MODULE' => $_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO'],
);
$xtpl->assign("MAILMERGE", $items);
if($oddRow)
{
//todo move to themes
$xtpl->assign("ROW_COLOR", 'oddListRow');
$xtpl->assign("BG_COLOR", $odd_bg);
}
else
{
//todo move to themes
$xtpl->assign("ROW_COLOR", 'evenListRow');
$xtpl->assign("BG_COLOR", $even_bg);
}
$oddRow = !$oddRow;
$xtpl->parse("main.items.row");
}
$xtpl->parse("main.items");
$xtpl->parse("main");
$xtpl->out("main");
?>

110
modules/MailMerge/Step4.html Executable file
View File

@@ -0,0 +1,110 @@
<!--
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* {APP.LBL_CURRENCY_SYM}Header: /cvsroot/sugarcrm/sugarcrm/modules/Contacts/EditView.html,v 1.22 2004/07/16 04:04:42 sugarclint Exp {APP.LBL_CURRENCY_SYM}
********************************************************************************/
-->
<!-- BEGIN: main -->
<!-- BEGIN: error -->
<span class="error">{ERROR}</span>
<!-- END: error -->
<form enctype="multipart/form-data" name="MailMerge" method="POST" action="index.php">
<input type="hidden" name="module" value="MailMerge">
<input type="hidden" name="step" value="5">
<input type="hidden" name="action" value="Merge">
<input type="hidden" name="return_module" value="{RETURN_MODULE}">
<input type="hidden" name="return_id" value="{RETURN_ID}">
<input type="hidden" name="return_action" value="{RETURN_ACTION}">
<input type="hidden" name="mailmerge_module" value="{MAILMERGE_MODULE}">
<input type="hidden" name="document_id" value="{MAILMERGE_DOCUMENT_ID}">
<input type="hidden" name="selected_objects_def" value="{MAILMERGE_SELECTED_OBJECTS_DEF}">
<input type="hidden" name="record" value="{RECORD}">
<p>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<th align="left" scope="row" colspan="2"><h4 class="">{STEP_NUM}&nbsp;{MOD.LBL_STEP_4}</h4></th>
</tr>
<tr><td><slot>&nbsp;</slot></td></tr>
<tr>
<td scope="row"><slot>{MOD.LBL_SELECTED_MODULE}</slot></td>
<td></td>
<td >
<slot>{MAILMERGE_MODULE}</slot>
</td>
</tr>
<tr>
<td scope="row"><slot>{MOD.LBL_SELECTED_TEMPLATE}</slot></td>
<td></td>
<td >
<slot>{MAILMERGE_TEMPLATE}</slot>
</td>
</tr>
<tr>
<td scope="row"><slot>{MOD.LBL_SELECTED_ITEMS}</slot></td>
<td></td>
<td >
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table>
<tr>
<td><slot><select id="selected_objs" name="selected_objs[]" size="10">{MAILMERGE_SELECTED_OBJECTS}</select></slot></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</p>
<p><table width="100%" cellpadding="2" cellspacing="0" border="0"><tr>
<td align="left"><input title="{MOD.LBL_BACK}" accessKey="" class="button" type="submit" name="button" value=" {MOD.LBL_BACK} " onclick="this.form.action.value='index'; this.form.step.value='{PREV_STEP}'; return true;"></td>
<td align="right"><input title="{MOD.LBL_FINISH}" accessKey="" class="button" type="submit" name="button" value=" {MOD.LBL_FINISH} "></td>
</tr>
</table> </p>
</form>
{JAVASCRIPT}
<!-- END: main -->

152
modules/MailMerge/Step4.php Executable file
View File

@@ -0,0 +1,152 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*
* Created on Oct 4, 2005
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
global $app_strings;
global $app_list_strings;
global $mod_strings;
global $current_user;
global $locale;
$xtpl = new XTemplate('modules/MailMerge/Step4.html');
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
if(!empty($_POST['document_id']))
{
$_SESSION['MAILMERGE_DOCUMENT_ID'] = $_POST['document_id'];
}
$document_id = $_SESSION['MAILMERGE_DOCUMENT_ID'];
$revision = new DocumentRevision();
$revision->retrieve($document_id);
//$document = new Document();
//$document->retrieve($document_id);
if(!empty($_POST['selected_objects']))
{
$selObjs = urldecode($_POST['selected_objects']);
$_SESSION['SELECTED_OBJECTS_DEF'] = $selObjs;
}
$selObjs = $_SESSION['SELECTED_OBJECTS_DEF'];
$sel_obj = array();
parse_str(stripslashes(html_entity_decode($selObjs, ENT_QUOTES)),$sel_obj);
foreach($sel_obj as $key=>$value)
{
$sel_obj[$key] = stripslashes($value);
}
$relArray = array();
//build relationship array
foreach($sel_obj as $key=>$value)
{
$id = 'rel_id_'.str_replace('-', '', $key);
if(isset($_POST[$id]) && !empty($_POST[$id]))
{
$relArray[$key] = $_POST[$id];
}
}
$builtArray = array();
if(count($relArray) > 0)
{
$_SESSION['MAILMERGE_RELATED_CONTACTS'] = $relArray;
$relModule = $_SESSION['MAILMERGE_CONTAINS_CONTACT_INFO'];
global $beanList, $beanFiles;
$class_name = $beanList[$relModule ];
require_once($beanFiles[$class_name]);
$seed = new $class_name();
foreach($sel_obj as $key=>$value)
{
$builtArray[$key] = $value;
if(isset($relArray[$key]))
{
$seed->retrieve($relArray[$key]);
$name = "";
if($relModule == "Contacts"){
$name = $locale->getLocaleFormattedName($seed->first_name,$seed->last_name);
}
else{
$name = $seed->name;
}
$builtArray[$key] = str_replace('##', '&', $value)." (".$name.")";
}
}
}
else
{
$builtArray = $sel_obj;
}
$xtpl->assign("MAILMERGE_MODULE", $_SESSION['MAILMERGE_MODULE']);
$xtpl->assign("MAILMERGE_DOCUMENT_ID", $document_id);
$xtpl->assign("MAILMERGE_TEMPLATE", $revision->filename." (rev. ".$revision->revision.")");
$xtpl->assign("MAILMERGE_SELECTED_OBJECTS", get_select_options_with_id($builtArray,'0'));
$xtpl->assign("MAILMERGE_SELECTED_OBJECTS_DEF", urlencode($selObjs));
$step_num = 4;
if(isset($_SESSION['MAILMERGE_SKIP_REL']) && $_SESSION['MAILMERGE_SKIP_REL'] || !isset($_SESSION['MAILMERGE_RELATED_CONTACTS']) || empty($_SESSION['MAILMERGE_RELATED_CONTACTS']))
{
$xtpl->assign("PREV_STEP", "2");
$step_num = 3;
}
else
{
$xtpl->assign("PREV_STEP", "3");
}
$xtpl->assign("STEP_NUM", "Step ".$step_num.":");
$xtpl->parse("main");
$xtpl->out("main");
?>

78
modules/MailMerge/Step5.html Executable file
View File

@@ -0,0 +1,78 @@
<!--
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* {APP.LBL_CURRENCY_SYM}Header: /cvsroot/sugarcrm/sugarcrm/modules/Contacts/EditView.html,v 1.22 2004/07/16 04:04:42 sugarclint Exp {APP.LBL_CURRENCY_SYM}
********************************************************************************/
-->
<!-- BEGIN: main -->
<!-- BEGIN: error -->
<span class="error">{ERROR}</span>
<!-- END: error -->
<form enctype="multipart/form-data" name="MailMerge" method="POST" action="index.php">
<input type="hidden" name="module" value="MailMerge">
<input type="hidden" name="step" value="1">
<input type="hidden" name="action" value="index">
<input type="hidden" name="return_module" value="{RETURN_MODULE}">
<input type="hidden" name="return_id" value="{RETURN_ID}">
<input type="hidden" name="return_action" value="{RETURN_ACTION}">
<p>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<th align="left" scope="row" colspan="2"><h4 class="">{MOD.LBL_STEP_5}</h4></th>
</tr>
<!--<tr>
<td scope="row"><slot>{MOD.LBL_MERGED_FILE}</slot></td>
<td ><slot><a href="{MAILMERGE_FILE_URL}">{MAILMERGE_FILE_NAME}</a></slot></td>
</tr>-->
<tr><td>&nbsp;</td></tr>
</table>
</p>
<p><table width="100%" cellpadding="2" cellspacing="0" border="0"><tr>
<td align="right">
<input title="{MOD.LBL_START}" accessKey="" class="button" type="submit" name="button" value=" {MOD.LBL_START}"></td>
</tr>
</table> </p>
</form>
{JAVASCRIPT}
<!-- END: main -->

59
modules/MailMerge/Step5.php Executable file
View File

@@ -0,0 +1,59 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*
* Created on Oct 4, 2005
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
if(!empty($_REQUEST['mtime']))
{
$mTime = $_REQUEST['mtime'];
$file = $_SESSION['MAILMERGE_TEMP_FILE_'.$mTime];
$rtfFile = 'sugartokendoc'.$mTime.'.doc';
unlink($file);
if(file_exists($rtfFile)){
unlink($rtfFile);
}
}
header("Location: index.php?module=MailMerge");
?>

62
modules/MailMerge/get_doc.php Executable file
View File

@@ -0,0 +1,62 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*
* Created on Oct 4, 2005
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
$local_location = $_SESSION['mail_merge_file_location'];
$name = $_SESSION['mail_merge_file_name'];
$download_location= $_SESSION['mail_merge_file_location'];
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-type: application/force-download");
header("Content-Length: " . filesize($local_location));
header("Content-disposition: attachment; filename=\"".$name."\";");
header("Expires: 0");
set_time_limit(0);
@ob_end_clean();
ob_start();
echo file_get_contents($download_location);
@ob_flush();
?>

58
modules/MailMerge/index.php Executable file
View File

@@ -0,0 +1,58 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: TODO: To be written.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
global $theme;
global $mod_strings;
global $current_language;
if(isset($_REQUEST['step']))
{
$step = $_REQUEST['step'];
}
else
{
$step = '1';
}
include ('modules/MailMerge/Step'. clean_string($step). '.php');
?>

View File

@@ -0,0 +1,78 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: Defines the English language pack for the base application.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
$mod_strings = array (
'LBL_STEP_1' => 'Step 1: Select Module and Template',
'LBL_MAILMERGE_MODULE' => 'Select Module: ',
'LBL_MAILMERGE_SELECTED_MODULE' => 'Selected Module: ',
'LBL_MAILMERGE_TEMPLATES' => 'Select Template: ',
'LBL_STEP_2' => 'Step 2: Select Objects to Merge',
'LBL_MAILMERGE_OBJECTS' => 'Select Objects: ',
'LBL_STEP_3' => 'Set Contact Association',
'LBL_STEP_4' => 'Review and Complete',
'LBL_SELECTED_MODULE' => 'Selected Module: ',
'LBL_SELECTED_TEMPLATE' => 'Selected Template: ',
'LBL_SELECTED_ITEMS' => 'Selected Items: ',
'LBL_STEP_5' => 'Mail Merge Complete',
'LBL_MERGED_FILE' => 'Merged File: ',
'LNK_NEW_MAILMERGE' => 'Begin Mail Merge',
'LNK_UPLOAD_TEMPLATE' => 'Upload Template',
'LBL_DOC_NAME' => 'Document Name:',
'LBL_FILENAME' => 'File Name:',
'LBL_DOC_VERSION' => 'Revision:',
'LBL_DOC_DESCRIPTION'=>'Description:',
'LBL_LIST_NAME' => 'Name',
'LBL_LIST_RELATIONSHIP' => 'Set Contact Relationship',
'LBL_FINISH' => 'Begin Merge',
'LBL_NEXT' => 'Next >',
'LBL_BACK' => '< Back',
'LBL_START' => 'Click Here to Continue',
'LBL_TEMPLATE_NOTICE' => 'Templates are Microsoft Word documents containing merge fields that have been uploaded and stored in the Documents module.',
'LBL_CONTAINS_CONTACT_INFO' => 'Selected template contains related ',
'LBL_ADDIN_NOTICE' => 'This requires the installation of Sugar Mail Merge add-in to Microsoft Word.',
'LBL_BROWSER_NOTICE' => 'You must be running IE 6.0 or greater to perform the actual merge.',
);
?>

View File

@@ -0,0 +1,68 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* 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-2005 SugarCRM, Inc.;
* All Rights Reserved.
* Contributor(s): ______________________________________.
********************************************************************************/
/*********************************************************************************
* pl_pl.lang.php,v for SugarCRM 4.5.1-->>
* Translator: Krzysztof Morawski
* All Rights Reserved.
* Any bugs report welcome: krzysiek<at>kmmgroup<dot>pl
* Contributor(s): ______________________________________..
********************************************************************************/
$mod_strings = array (
'LBL_STEP_1' => 'Krok 1: Wybierz moduł i szablon',
'LBL_MAILMERGE_MODULE' => 'Wybierz moduł: ',
'LBL_MAILMERGE_SELECTED_MODULE' => 'Wybrany moduł: ',
'LBL_MAILMERGE_TEMPLATES' => 'Wybierz szablon: ',
'LBL_STEP_2' => 'Krok 2: Wybierz obiekty do scalenia',
'LBL_MAILMERGE_OBJECTS' => 'Wybrane obiekty: ',
'LBL_STEP_3' => 'Ustaw przyłączenie kontaktów',
'LBL_STEP_4' => 'Przejrzyj i zakończ',
'LBL_SELECTED_MODULE' => 'Wybrane moduły: ',
'LBL_SELECTED_TEMPLATE' => 'Wybrane szablony: ',
'LBL_SELECTED_ITEMS' => 'Wybrane elementy: ',
'LBL_STEP_5' => 'Scalanie wiadomości zakończone',
'LBL_MERGED_FILE' => 'Scalony plik: ',
'LNK_NEW_MAILMERGE' => 'Rozpocznij scalanie wiadomości',
'LNK_UPLOAD_TEMPLATE' => 'Zaktualizuj szablon',
'LBL_DOC_NAME' => 'Nazwa dokumentu:',
'LBL_FILENAME' => 'Nazwa pliku:',
'LBL_DOC_VERSION' => 'Wydanie:',
'LBL_DOC_DESCRIPTION'=>'Opis:',
'LBL_LIST_NAME' => 'Nazwa',
'LBL_LIST_RELATIONSHIP' => 'Ustaw zależności kontaktów',
'LBL_FINISH' => 'Rozpocznij scalanie',
'LBL_NEXT' => 'Nastepny >',
'LBL_BACK' => '< Poprzedni',
'LBL_START' => 'Kliknij tutaj, aby kontynuować',
'LBL_TEMPLATE_NOTICE' => 'Szablony są dokumentami Worda, zawierającymi scalone pola, które mogą być załadowane i przechowywane w module "dokumenty".',
'LBL_CONTAINS_CONTACT_INFO' => 'Wybrane szablony zawieraja informacje o kontaktach.',
'LBL_ADDIN_NOTICE' => 'Wymagana jest instalacja dodatku Sugar Mail Merge do Worda',
'LBL_BROWSER_NOTICE' => 'Musisz używać przeglądarki IE 6.0 lub nowszej, aby przeprowadzić scalanie aktualizujące.',
);
?>

View File

@@ -0,0 +1,43 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* 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 Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
$modules_array = array('Accounts' => 'Accounts',
'Cases' => 'Cases',
'Contacts' => 'Contacts',
'Leads' => 'Leads',
'Opportunities' => 'Opportunities');
?>