]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/ProspectLists/ProspectListFormBase.php
Release 6.5.0
[Github/sugarcrm.git] / modules / ProspectLists / ProspectListFormBase.php
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-2012 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38 /*********************************************************************************
39
40  * Description:  Base Form For Notes
41  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42  * All Rights Reserved.
43  * Contributor(s): ______________________________________..
44  ********************************************************************************/
45
46
47 class ProspectListFormBase {
48
49
50 function getForm($prefix, $mod='', $form=''){
51         
52         if(!ACLController::checkAccess('ProspectLists', 'edit', true)){
53                 return '';
54         }
55         
56         if(!empty($mod)){
57                 global $current_language;
58                 $mod_strings = return_module_language($current_language, $mod);
59         } else {
60                 global $mod_strings;
61         }
62         global $app_strings,$current_user;
63         
64         $lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE'];
65         $lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY'];
66         $lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL'];
67         $user_id = $current_user->id;
68
69
70         $the_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
71         $the_form .= <<<EOQ
72                 <form name="${prefix}ProspectListSave" onSubmit="return check_form('${prefix}ProspectListSave');" method="POST" action="index.php">
73                         <input type="hidden" name="${prefix}module" value="ProspectLists">
74                         <input type="hidden" name="${prefix}action" value="Save">
75                         <input type="hidden" name="assigned_user_id" value='${user_id}'>
76 EOQ;
77
78         $the_form .= $this->getFormBody($prefix, $mod, $prefix."ProspectListSave");
79         $the_form .= <<<EOQ
80                 <p><input title="$lbl_save_button_title" accessKey="$lbl_save_button_key" class="button" type="submit" name="button" value="  $lbl_save_button_label  " ></p>
81                 </form>
82
83 EOQ;
84
85         $the_form .= get_left_form_footer();
86         $the_form .= get_validate_record_js();
87
88         return $the_form;       
89 }
90
91 function getFormBody($prefix, $mod='',$formname='', $size='30',$script=true) {
92         if(!ACLController::checkAccess('ProspectLists', 'edit', true)){
93                 return '';
94         }
95         global $mod_strings;
96         $temp_strings = $mod_strings;
97         if(!empty($mod)){
98                 global $current_language;
99                 $mod_strings = return_module_language($current_language, $mod);
100         }
101         global $app_strings;
102         global $current_user;
103         global $app_list_strings;
104         
105         $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
106         $lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE'];
107         $lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY'];
108         $lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL'];
109         $user_id = $current_user->id;
110
111         $list_options=get_select_options_with_id($app_list_strings['prospect_list_type_dom'], 'default');
112         
113         $lbl_prospect_list_name = $mod_strings['LBL_PROSPECT_LIST_NAME'];
114         $lbl_list_type = $mod_strings['LBL_LIST_TYPE'];
115         
116         $form = <<<EOQ
117                         <p><input type="hidden" name="record" value="">
118                         $lbl_prospect_list_name&nbsp;<span class="required">$lbl_required_symbol</span><br>
119                         <input name='name' type="text" value=""><br>
120                         $lbl_list_type&nbsp;<span class="required">$lbl_required_symbol</span><br>
121                         <select name="list_type">$list_options</select></p>
122 EOQ;
123
124         
125         
126         $javascript = new javascript();
127         $javascript->setFormName($formname);
128         $javascript->setSugarBean(new ProspectList());
129         $javascript->addRequiredFields($prefix);
130         $form .=$javascript->getScript();
131         $mod_strings = $temp_strings;
132         return $form;
133 }
134
135         function handleSave($prefix,$redirect=true, $useRequired=false){
136                 
137                 
138                 require_once('include/formbase.php');
139         
140                 
141                 $focus = new ProspectList();
142                 if($useRequired &&  !checkRequired($prefix, array_keys($focus->required_fields))){
143                         return null;
144                 }
145                 $focus = populateFromPost($prefix, $focus);
146                 if(!$focus->ACLAccess('Save')){
147                         ACLController::displayNoAccess(true);
148                         sugar_cleanup(true);
149                 }
150                 if(empty($focus->name)){
151                         return null;
152                 }       
153         if ( !isset($focus->assigned_user_id) || $focus->assigned_user_id == '' )
154             $focus->assigned_user_id = $GLOBALS['current_user']->id;
155         
156                 $return_id = $focus->save();
157                 if($redirect){
158                         $GLOBALS['log']->debug("Saved record with id of ".$return_id);
159                         handleRedirect($return_id, "ProspectLists");
160                 } else { 
161                         return $focus;
162                 }
163         }
164 }
165 ?>