|
1
|
|
|
<?php |
|
2
|
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3
|
|
|
/********************************************************************************* |
|
4
|
|
|
* SugarCRM Community Edition is a customer relationship management program developed by |
|
5
|
|
|
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
|
6
|
|
|
|
|
7
|
|
|
* SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
|
8
|
|
|
* Copyright (C) 2011 - 2014 Salesagility Ltd. |
|
9
|
|
|
* |
|
10
|
|
|
* This program is free software; you can redistribute it and/or modify it under |
|
11
|
|
|
* the terms of the GNU Affero General Public License version 3 as published by the |
|
12
|
|
|
* Free Software Foundation with the addition of the following permission added |
|
13
|
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
|
14
|
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
|
15
|
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
|
16
|
|
|
* |
|
17
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
18
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
19
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
|
20
|
|
|
* details. |
|
21
|
|
|
* |
|
22
|
|
|
* You should have received a copy of the GNU Affero General Public License along with |
|
23
|
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free |
|
24
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
25
|
|
|
* 02110-1301 USA. |
|
26
|
|
|
* |
|
27
|
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
|
28
|
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
|
29
|
|
|
* |
|
30
|
|
|
* The interactive user interfaces in modified source and object code versions |
|
31
|
|
|
* of this program must display Appropriate Legal Notices, as required under |
|
32
|
|
|
* Section 5 of the GNU Affero General Public License version 3. |
|
33
|
|
|
* |
|
34
|
|
|
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
|
35
|
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by |
|
36
|
|
|
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
|
37
|
|
|
* reasonably feasible for technical reasons, the Appropriate Legal Notices must |
|
38
|
|
|
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
|
39
|
|
|
********************************************************************************/ |
|
40
|
|
|
|
|
41
|
|
|
/********************************************************************************* |
|
42
|
|
|
|
|
43
|
|
|
* Description: TODO: To be written. |
|
44
|
|
|
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. |
|
45
|
|
|
* All Rights Reserved. |
|
46
|
|
|
* Contributor(s): ______________________________________.. |
|
47
|
|
|
********************************************************************************/ |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
require_once('include/EditView/EditView2.php'); |
|
51
|
|
|
|
|
52
|
|
|
require_once('modules/Campaigns/utils.php'); |
|
53
|
|
|
|
|
54
|
|
|
global $mod_strings, $app_list_strings, $app_strings, $current_user, $import_bean_map,$import_file_name, $theme; |
|
55
|
|
|
|
|
56
|
|
|
$xtpl=new XTemplate ('modules/Campaigns/WebToLeadCreation.html'); |
|
57
|
|
|
$xtpl->assign("MOD", $mod_strings); |
|
58
|
|
|
$xtpl->assign("APP", $app_strings); |
|
59
|
|
|
if(isset($_REQUEST['module'])) |
|
60
|
|
|
{ |
|
61
|
|
|
$xtpl->assign("MODULE", $_REQUEST['module']); |
|
62
|
|
|
} |
|
63
|
|
|
if(isset($_REQUEST['return_module'])) |
|
64
|
|
|
{ |
|
65
|
|
|
$xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']); |
|
66
|
|
|
} |
|
67
|
|
|
if(isset($_REQUEST['return_id'])) |
|
68
|
|
|
{ |
|
69
|
|
|
$xtpl->assign("RETURN_ID", $_REQUEST['return_id']); |
|
70
|
|
|
} |
|
71
|
|
|
if(isset($_REQUEST['return_id'])) |
|
72
|
|
|
{ |
|
73
|
|
|
$xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']); |
|
74
|
|
|
} |
|
75
|
|
|
if(isset($_REQUEST['record'])) |
|
76
|
|
|
{ |
|
77
|
|
|
$xtpl->assign("RECORD", $_REQUEST['record']); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
global $theme; |
|
81
|
|
|
global $currentModule; |
|
82
|
|
|
|
|
83
|
|
|
$ev = new EditView; |
|
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
$subclasses = getListOfExtendingClasses("Person"); |
|
86
|
|
|
|
|
87
|
|
|
$beanList = filterFieldsFromBeans($subclasses); |
|
88
|
|
|
|
|
89
|
|
|
$xtpl->assign("BEAN_LIST",json_encode($beanList)); |
|
90
|
|
|
|
|
91
|
|
|
$personTypeList = "<select id='personTypeSelect'>"; |
|
92
|
|
|
if(count($beanList) > 0) |
|
93
|
|
|
{ |
|
94
|
|
|
$count=0; |
|
95
|
|
|
foreach($beanList as $b) |
|
96
|
|
|
{ |
|
97
|
|
|
$personTypeList.="<option value='".$count."'>".$b->name."</option>"; |
|
98
|
|
|
$count++; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
else |
|
102
|
|
|
{ |
|
103
|
|
|
$personTypeList.="<option value='noPerson'>No matching types</option>"; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
$site_url = $sugar_config['site_url']; |
|
107
|
|
|
$web_post_url = $site_url.'/index.php?entryPoint=WebToPersonCapture'; |
|
108
|
|
|
$json = getJSONobj(); |
|
109
|
|
|
// Users Popup |
|
110
|
|
|
$popup_request_data = array( |
|
111
|
|
|
'call_back_function' => 'set_return', |
|
112
|
|
|
'form_name' => 'WebToLeadCreation', |
|
113
|
|
|
'field_to_name_array' => array( |
|
114
|
|
|
'id' => 'assigned_user_id', |
|
115
|
|
|
'user_name' => 'assigned_user_name', |
|
116
|
|
|
), |
|
117
|
|
|
); |
|
118
|
|
|
$xtpl->assign('encoded_users_popup_request_data', $json->encode($popup_request_data)); |
|
119
|
|
|
|
|
120
|
|
|
//Campaigns popup |
|
121
|
|
|
$popup_request_data = array( |
|
122
|
|
|
'call_back_function' => 'set_return', |
|
123
|
|
|
'form_name' => 'WebToLeadCreation', |
|
124
|
|
|
'field_to_name_array' => array( |
|
125
|
|
|
'id' => 'campaign_id', |
|
126
|
|
|
'name' => 'campaign_name', |
|
127
|
|
|
), |
|
128
|
|
|
); |
|
129
|
|
|
$encoded_users_popup_request_data = $json->encode($popup_request_data); |
|
130
|
|
|
$xtpl->assign('encoded_campaigns_popup_request_data' , $json->encode($popup_request_data)); |
|
131
|
|
|
|
|
132
|
|
|
$field_defs_js = "var field_defs = {'Contacts':["; |
|
133
|
|
|
|
|
134
|
|
|
$xtpl->assign("WEB_POST_URL",$web_post_url); |
|
135
|
|
|
|
|
136
|
|
|
if (empty($focus->assigned_user_id) && empty($focus->id)) $focus->assigned_user_id = $current_user->id; |
|
137
|
|
|
if (empty($focus->assigned_name) && empty($focus->id)) $focus->assigned_user_name = $current_user->user_name; |
|
138
|
|
|
$xtpl->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name); |
|
139
|
|
|
$xtpl->assign("ASSIGNED_USER_ID", $focus->assigned_user_id ); |
|
140
|
|
|
|
|
141
|
|
|
$xtpl->assign("REDIRECT_URL_DEFAULT",'http://'); |
|
142
|
|
|
|
|
143
|
|
|
$xtpl->parse("main"); |
|
144
|
|
|
$xtpl->out("main"); |
|
145
|
|
|
|
|
146
|
|
|
|
|
147
|
|
|
function filterFieldsFromBeans($beans) |
|
148
|
|
|
{ |
|
149
|
|
|
global $app_strings; |
|
150
|
|
|
$formattedBeans = array(); |
|
151
|
|
|
foreach($beans as $b) |
|
152
|
|
|
{ |
|
153
|
|
|
$formattedFields = array(); |
|
154
|
|
|
//bug: 47574 - make sure, that webtolead_email1 field has same required attribute as email1 field |
|
155
|
|
|
if(isset($b->field_defs['webtolead_email1']) && isset($b->field_defs['email1']) && isset($b->field_defs['email1']['required'])){ |
|
156
|
|
|
$b->field_defs['webtolead_email1']['required'] = $b->field_defs['email1']['required']; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
foreach($b->field_defs as $field_def) |
|
160
|
|
|
{ |
|
161
|
|
|
$email_fields = false; |
|
162
|
|
|
if($field_def['name']== 'email1' || $field_def['name']== 'email2') |
|
163
|
|
|
{ |
|
164
|
|
|
$email_fields = true; |
|
165
|
|
|
} |
|
166
|
|
|
if($field_def['name']!= 'account_name'){ |
|
167
|
|
|
if( ( $field_def['type'] == 'relate' && empty($field_def['custom_type']) ) |
|
168
|
|
|
|| $field_def['type'] == 'assigned_user_name' || $field_def['type'] =='link' || $field_def['type'] =='function' |
|
169
|
|
|
|| (isset($field_def['source']) && $field_def['source']=='non-db' && !$email_fields) || $field_def['type'] == 'id') |
|
170
|
|
|
{ |
|
171
|
|
|
continue; |
|
172
|
|
|
} |
|
173
|
|
|
} |
|
174
|
|
|
if($field_def['name']== 'deleted' || $field_def['name']=='converted' || $field_def['name']=='date_entered' |
|
175
|
|
|
|| $field_def['name']== 'date_modified' || $field_def['name']=='modified_user_id' |
|
176
|
|
|
|| $field_def['name']=='assigned_user_id' || $field_def['name']=='created_by' |
|
177
|
|
|
|| $field_def['name']=='team_id') |
|
178
|
|
|
{ |
|
179
|
|
|
continue; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
//If the field is hidden in the studio settings, then do not show |
|
183
|
|
|
if(isset($field_def['studio']) && isset($field_def['studio']['editview']) && $field_def['studio']['editview']=== false ) |
|
184
|
|
|
{ |
|
185
|
|
|
continue; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
|
|
189
|
|
|
$field_def['vname'] = preg_replace('/:$/','',translate($field_def['vname'],'Leads')); |
|
190
|
|
|
|
|
191
|
|
|
//$cols_name = "{'".$field_def['vname']."'}"; |
|
192
|
|
|
$col_arr = array(); |
|
193
|
|
|
if((isset($field_def['required']) && $field_def['required'] != null && $field_def['required'] != 0) |
|
194
|
|
|
|| $field_def['name']=='last_name' |
|
195
|
|
|
){ |
|
196
|
|
|
$cols_name=$field_def['vname'].' '.$app_strings['LBL_REQUIRED_SYMBOL']; |
|
197
|
|
|
$col_arr[0]=$cols_name; |
|
198
|
|
|
$col_arr[1]=$field_def['name']; |
|
199
|
|
|
$col_arr[2]=true; |
|
200
|
|
|
} |
|
201
|
|
|
else{ |
|
202
|
|
|
$cols_name=$field_def['vname']; |
|
203
|
|
|
$col_arr[0]=$cols_name; |
|
204
|
|
|
$col_arr[1]=$field_def['name']; |
|
205
|
|
|
} |
|
206
|
|
|
if (! in_array($cols_name, $formattedFields)) |
|
207
|
|
|
{ |
|
208
|
|
|
array_push($formattedFields,$col_arr); |
|
209
|
|
|
} |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
$holder = new stdClass(); |
|
213
|
|
|
$holder->name = $b->object_name; |
|
214
|
|
|
$holder->fields = $formattedFields; |
|
215
|
|
|
$holder->moduleKnownAs = translate($b->module_name,'LBL_MODULE_NAME'); |
|
216
|
|
|
$holder->moduleDir = $b->module_dir; |
|
217
|
|
|
$holder->moduleName = $b->module_name; |
|
218
|
|
|
$formattedBeans[] = $holder; |
|
219
|
|
|
|
|
220
|
|
|
} |
|
221
|
|
|
return $formattedBeans; |
|
222
|
|
|
|
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
|
|
226
|
|
|
|
|
227
|
|
|
//This is a generic method to allow for returning all of the sub-classes of a particular class |
|
228
|
|
|
//This is used to allow for us to pass in person and get [Lead,Contact,Prospect,...] |
|
229
|
|
|
function getListOfExtendingClasses($superclass) |
|
230
|
|
|
{ |
|
231
|
|
|
$subclasses = array(); |
|
232
|
|
|
foreach($GLOBALS['moduleList'] as $mod) |
|
233
|
|
|
{ |
|
234
|
|
|
$item = BeanFactory::getBean($mod); |
|
235
|
|
|
if($item && is_subclass_of($item,$superclass)) |
|
236
|
|
|
$subclasses[] = $item; |
|
237
|
|
|
} |
|
238
|
|
|
return $subclasses; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
|
This class, trait or interface has been deprecated.