]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/EditView/SubpanelQuickCreate.php
Release 6.4.1
[Github/sugarcrm.git] / include / EditView / SubpanelQuickCreate.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 require_once('include/EditView/EditView2.php');
39 /**
40  * Quick create form in the subpanel
41  * @api
42  */
43 class SubpanelQuickCreate{
44         var $defaultProcess = true;
45
46         function SubpanelQuickCreate($module, $view='QuickCreate', $proccessOverride = false){
47         //treat quickedit and quickcreate views as the same
48         if($view == 'QuickEdit') {$view = 'QuickCreate';}
49
50                 // locate the best viewdefs to use: 1. custom/module/quickcreatedefs.php 2. module/quickcreatedefs.php 3. custom/module/editviewdefs.php 4. module/editviewdefs.php
51                 $base = 'modules/' . $module . '/metadata/';
52                 $source = 'custom/' . $base . strtolower($view) . 'defs.php';
53                 if (!file_exists( $source))
54                 {
55                         $source = $base . strtolower($view) . 'defs.php';
56                         if (!file_exists($source))
57                         {
58                                 //if our view does not exist default to EditView
59                                 $view = 'EditView';
60                                 $source = 'custom/' . $base . 'editviewdefs.php';
61                                 if (!file_exists($source))
62                                 {
63                                         $source = $base . 'editviewdefs.php';
64                                 }
65                         }
66                 }
67
68                 $this->ev = new EditView();
69                 $this->ev->view = $view;
70                 $this->ev->ss = new Sugar_Smarty();
71                 //$_REQUEST['return_action'] = 'SubPanelViewer';
72
73         $class = $GLOBALS['beanList'][$module];
74         $bean = new $class();
75         if(!empty($_REQUEST['record'])) {
76             $bean->retrieve($_REQUEST['record']);
77         }
78                 $this->ev->setup($module, $bean, $source);
79                 unset($bean);
80
81                 // Bug 49219 - Check empty before set defaults, or the settings from viewdefs above will be overridden.
82                 if (!isset($this->ev->defs['templateMeta']['form']['headerTpl']))
83         {
84             $this->ev->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl';
85         }
86
87                 if (!isset($this->ev->defs['templateMeta']['form']['footerTpl']))
88         {
89             $this->ev->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl';
90         }
91                 // Comment below, breaks many out of the box viewdefs
92                 /*if (empty($this->ev->defs['templateMeta']['form']['buttons'])) $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');*/
93                 $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');
94                 
95             //Load the parent view class if it exists.  Check for custom file first
96         loadParentView('edit');
97
98                 $viewEditSource = 'modules/'.$module.'/views/view.edit.php';
99                 if (file_exists('custom/'. $viewEditSource)) {
100                         $viewEditSource = 'custom/'. $viewEditSource;
101                 }
102
103                 if(file_exists($viewEditSource) && !$proccessOverride) {
104             include($viewEditSource);
105             $c = $module . 'ViewEdit';
106
107             $customClass = 'Custom' . $c;
108             if(class_exists($customClass)) {
109                 $c = $customClass;
110             }
111
112             if(class_exists($c)) {
113                     $view = new $c;
114                     if($view->useForSubpanel) {
115                         $this->defaultProcess = false;
116
117                         //Check if we shold use the module's QuickCreate.tpl file
118                         if($view->useModuleQuickCreateTemplate && file_exists('modules/'.$module.'/tpls/QuickCreate.tpl')) {
119                            $this->ev->defs['templateMeta']['form']['headerTpl'] = 'modules/'.$module.'/tpls/QuickCreate.tpl';
120                         }
121
122                             $view->ev = & $this->ev;
123                             $view->ss = & $this->ev->ss;
124                                         $class = $GLOBALS['beanList'][$module];
125                                         if(!empty($GLOBALS['beanFiles'][$class])){
126                                                 require_once($GLOBALS['beanFiles'][$class]);
127                                                 $bean = new $class();
128                                                 $view->bean = $bean;
129                                         }
130                                         $this->ev->formName = 'form_Subpanel'.$this->ev->view .'_'.$module;
131                                         $view->showTitle = false; // Do not show title since this is for subpanel
132                             $view->display();
133                     }
134             }
135                 } //if
136
137                 if($this->defaultProcess && !$proccessOverride) {
138                    $this->process($module);
139                 }
140         }
141
142         function process($module){
143         $form_name = 'form_Subpanel'.$this->ev->view .'_'.$module;
144         $this->ev->formName = $form_name;
145         $this->ev->process(true, $form_name);
146                 echo $this->ev->display(false, true);
147         }
148 }
149 ?>