0
0
Fork 0
mirror of https://github.com/salesagility/SuiteCRM.git synced 2025-03-13 21:13:21 +00:00
salesagility_SuiteCRM/modules/Campaigns/WebToLeadCreation.php

177 lines
6.3 KiB
PHP
Raw Normal View History

2013-09-23 19:30:44 +00:00
<?php
2017-10-16 12:42:26 +00:00
/**
*
2013-09-23 19:30:44 +00:00
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
2017-10-16 12:42:26 +00:00
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
* Copyright (C) 2011 - 2018 SalesAgility Ltd.
2014-07-07 15:33:23 +00:00
*
2013-09-23 19:30:44 +00:00
* 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.
2014-07-07 15:33:23 +00:00
*
2013-09-23 19:30:44 +00:00
* 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
2017-10-16 12:42:26 +00:00
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
2013-09-23 19:30:44 +00:00
* details.
2014-07-07 15:33:23 +00:00
*
2013-09-23 19:30:44 +00:00
* 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.
2014-07-07 15:33:23 +00:00
*
2013-09-23 19:30:44 +00:00
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
2014-07-07 15:33:23 +00:00
*
2013-09-23 19:30:44 +00:00
* 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.
2014-07-07 15:33:23 +00:00
*
2013-09-23 19:30:44 +00:00
* 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
2014-07-07 15:33:23 +00:00
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
2017-10-16 12:42:26 +00:00
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
*/
2013-09-23 19:30:44 +00:00
2018-08-03 16:50:48 +00:00
/*********************************************************************************
2017-10-16 12:42:26 +00:00
* Description: WebToLeadCreation
2013-09-23 19:30:44 +00:00
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
2018-08-03 16:50:48 +00:00
********************************************************************************/
2013-09-23 19:30:44 +00:00
2017-10-16 12:42:26 +00:00
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
2013-09-23 19:30:44 +00:00
use SuiteCRM\Utility\SuiteValidator;
2017-10-16 12:42:26 +00:00
require_once 'include/EditView/EditView2.php';
2013-09-23 19:30:44 +00:00
2017-10-16 12:42:26 +00:00
require_once 'modules/Campaigns/utils.php';
2013-09-23 19:30:44 +00:00
2016-03-25 09:02:40 +00:00
global $mod_strings, $app_list_strings, $app_strings, $current_user, $import_bean_map,$import_file_name, $theme;
2013-09-23 19:30:44 +00:00
2018-07-19 10:16:53 +00:00
$xtpl=new XTemplate('modules/Campaigns/WebToLeadCreation.html');
2013-09-23 19:30:44 +00:00
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
2018-07-12 10:40:10 +00:00
if (isset($_REQUEST['module'])) {
2013-09-23 19:30:44 +00:00
$xtpl->assign("MODULE", $_REQUEST['module']);
}
2018-07-12 10:40:10 +00:00
if (isset($_REQUEST['return_module'])) {
2013-09-23 19:30:44 +00:00
$xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
}
2018-07-12 10:40:10 +00:00
if (isset($_REQUEST['return_id'])) {
2013-09-23 19:30:44 +00:00
$xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
}
2018-07-12 10:40:10 +00:00
if (isset($_REQUEST['return_id'])) {
2013-09-23 19:30:44 +00:00
$xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
}
2018-07-12 10:40:10 +00:00
if (isset($_REQUEST['record'])) {
2013-09-23 19:30:44 +00:00
$xtpl->assign("RECORD", $_REQUEST['record']);
}
global $theme;
global $currentModule;
$ev = new EditView;
2016-03-25 09:02:40 +00:00
$subclasses = getListOfExtendingClasses("Person");
$beanList = filterFieldsFromBeans($subclasses);
2023-06-01 13:26:16 +00:00
$xtpl->assign("BEAN_LIST", json_encode($beanList));
2016-03-25 09:02:40 +00:00
$personTypeList = "<select id='personTypeSelect'>";
2023-06-01 13:10:03 +00:00
if ((is_countable($beanList) ? count($beanList) : 0) > 0) {
2016-03-25 09:02:40 +00:00
$count=0;
2018-07-12 10:40:10 +00:00
foreach ($beanList as $b) {
2016-03-25 09:02:40 +00:00
$personTypeList.="<option value='".$count."'>".$b->name."</option>";
$count++;
}
2018-07-12 10:40:10 +00:00
} else {
2016-03-25 09:02:40 +00:00
$personTypeList.="<option value='noPerson'>No matching types</option>";
}
2013-09-23 19:30:44 +00:00
$site_url = $sugar_config['site_url'];
2016-03-25 09:02:40 +00:00
$web_post_url = $site_url.'/index.php?entryPoint=WebToPersonCapture';
2013-09-23 19:30:44 +00:00
$json = getJSONobj();
// Users Popup
$popup_request_data = array(
2018-07-19 10:46:21 +00:00
'call_back_function' => 'set_return',
'form_name' => 'WebToLeadCreation',
'field_to_name_array' => array(
'id' => 'assigned_user_id',
'user_name' => 'assigned_user_name',
),
);
2013-09-23 19:30:44 +00:00
$xtpl->assign('encoded_users_popup_request_data', $json->encode($popup_request_data));
//Campaigns popup
$popup_request_data = array(
2018-07-19 10:46:21 +00:00
'call_back_function' => 'set_return',
'form_name' => 'WebToLeadCreation',
'field_to_name_array' => array(
'id' => 'campaign_id',
'name' => 'campaign_name',
),
2013-09-23 19:30:44 +00:00
);
$encoded_users_popup_request_data = $json->encode($popup_request_data);
2018-07-16 15:17:46 +00:00
$xtpl->assign('encoded_campaigns_popup_request_data', $json->encode($popup_request_data));
2013-09-23 19:30:44 +00:00
$field_defs_js = "var field_defs = {'Contacts':[";
2018-07-16 15:17:46 +00:00
$xtpl->assign("WEB_POST_URL", $web_post_url);
2016-03-25 09:02:40 +00:00
2017-10-16 12:42:26 +00:00
if (!empty($focus)) {
if (empty($focus->assigned_user_id) && empty($focus->id)) {
$focus->assigned_user_id = $current_user->id;
}
if (empty($focus->assigned_name) && empty($focus->id)) {
$focus->assigned_user_name = $current_user->user_name;
}
$xtpl->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
$xtpl->assign("ASSIGNED_USER_ID", $focus->assigned_user_id);
} else {
$xtpl->assign("ASSIGNED_USER_NAME", $current_user->user_name);
$xtpl->assign("ASSIGNED_USER_ID", $current_user->id);
}
2016-03-25 09:02:40 +00:00
2018-07-16 15:17:46 +00:00
$xtpl->assign("REDIRECT_URL_DEFAULT", 'http://');
2016-03-25 09:02:40 +00:00
$isValidator = new SuiteValidator();
if (isset($_REQUEST['campaign_id']) && $isValidator->isValidId($_REQUEST['campaign_id'])) {
Replace explicit bean instantiations in files 411 - 420 - File: '... /modules/Campaigns/Charts1.php' - Replaced 1 occurrence(s) of 'new Campaign()' - File: '... /modules/Campaigns/WebToLeadCreation.php' - Replaced 1 occurrence(s) of 'new Campaign()' - File: '... /modules/Campaigns/EmailQueue.php' - Replaced 1 occurrence(s) of 'new ProspectList()' - Replaced 1 occurrence(s) of 'new Campaign()' - Replaced 1 occurrence(s) of 'new EmailMan()' - File: '... /modules/Campaigns/GenerateWebToLeadForm.php' - Replaced 1 occurrence(s) of 'new FieldsMetaData()' - File: '... /modules/Campaigns/WizardMarketingSave.php' - Replaced 1 occurrence(s) of 'new EmailMarketing()' - File: '... /modules/Campaigns/RoiDetailView.php' - Replaced 1 occurrence(s) of 'new Campaign()' - Replaced 1 occurrence(s) of 'new Currency()' - File: '... /modules/Campaigns/WebToPersonCapture.php' - Replaced 1 occurrence(s) of 'new Campaign()' - Replaced 1 occurrence(s) of 'new EmailMarketing()' - Replaced 1 occurrence(s) of 'new CampaignLog()' - Replaced 1 occurrence(s) of 'new EmailMan()' - Replaced 1 occurrence(s) of 'new User()' - Replaced 1 occurrence(s) of 'new EmailAddress()' - File: '... /modules/Campaigns/Dashlets/TopCampaignsDashlet/TopCampaignsDashlet.php' - Replaced 1 occurrence(s) of 'new Opportunity()' - File: '... /modules/Campaigns/Subscriptions.php' - Replaced 1 occurrence(s) of 'new Lead()' - Replaced 1 occurrence(s) of 'new Prospect()' - Replaced 1 occurrence(s) of 'new Contact()' - File: '... /modules/Campaigns/Schedule.php' - Replaced 1 occurrence(s) of 'new Campaign()' - Replaced 3 occurrence(s) of 'new EmailMarketing()'
2020-01-22 13:51:36 +00:00
$campaign = BeanFactory::newBean('Campaigns');
2018-07-12 10:40:10 +00:00
if ($campaign) {
$campaign->retrieve($_REQUEST['campaign_id']);
$xtpl->assign('CAMPAIGN_ID', $campaign->id);
$xtpl->assign('CAMPAIGN_NAME', $campaign->name);
}
}
2016-03-25 09:02:40 +00:00
$xtpl->parse("main");
$xtpl->out("main");
//This is a generic method to allow for returning all of the sub-classes of a particular class
//This is used to allow for us to pass in person and get [Lead,Contact,Prospect,...]
function getListOfExtendingClasses($superclass)
{
$subclasses = array();
2018-07-12 10:40:10 +00:00
foreach ($GLOBALS['moduleList'] as $mod) {
2016-03-25 09:02:40 +00:00
$item = BeanFactory::getBean($mod);
2018-07-16 15:17:46 +00:00
if ($item && is_subclass_of($item, $superclass)) {
2016-03-25 09:02:40 +00:00
$subclasses[] = $item;
2018-07-12 10:40:10 +00:00
}
2016-05-18 11:36:29 +00:00
}
2016-03-25 09:02:40 +00:00
return $subclasses;
2016-05-18 11:36:29 +00:00
}