]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/EditView/SubpanelQuickEdit.php
Release 6.5.0
[Github/sugarcrm.git] / include / EditView / SubpanelQuickEdit.php
1 <?php
2 //FILE SUGARCRM flav=pro || flav=sales
3 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
4 /*********************************************************************************
5  * SugarCRM Community Edition is a customer relationship management program developed by
6  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
7  * 
8  * This program is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Affero General Public License version 3 as published by the
10  * Free Software Foundation with the addition of the following permission added
11  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
12  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
13  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14  * 
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
18  * details.
19  * 
20  * You should have received a copy of the GNU Affero General Public License along with
21  * this program; if not, see http://www.gnu.org/licenses or write to the Free
22  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23  * 02110-1301 USA.
24  * 
25  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
26  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27  * 
28  * The interactive user interfaces in modified source and object code versions
29  * of this program must display Appropriate Legal Notices, as required under
30  * Section 5 of the GNU Affero General Public License version 3.
31  * 
32  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
33  * these Appropriate Legal Notices must retain the display of the "Powered by
34  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
35  * technical reasons, the Appropriate Legal Notices must display the words
36  * "Powered by SugarCRM".
37  ********************************************************************************/
38
39
40 require_once('include/EditView/EditView2.php');
41 /**
42  * Quick edit form in the subpanel
43  * @api
44  */
45 class SubpanelQuickEdit{
46         var $defaultProcess = true;
47
48         function SubpanelQuickEdit($module, $view='QuickEdit', $proccessOverride = false){
49         //treat quickedit and quickcreate views as the same
50         if($view == 'QuickEdit') {$view = 'QuickCreate';}
51
52                 // locate the best viewdefs to use: 1. custom/module/quickcreatedefs.php 2. module/quickcreatedefs.php 3. custom/module/editviewdefs.php 4. module/editviewdefs.php
53                 $base = 'modules/' . $module . '/metadata/';
54                 $source = 'custom/' . $base . strtolower($view) . 'defs.php';
55                 if (!file_exists( $source))
56                 {
57                         $source = $base . strtolower($view) . 'defs.php';
58                         if (!file_exists($source))
59                         {
60                                 //if our view does not exist default to EditView
61                                 $view = 'EditView';
62                                 $source = 'custom/' . $base . 'editviewdefs.php';
63                                 if (!file_exists($source))
64                                 {
65                                         $source = $base . 'editviewdefs.php';
66                                 }
67                         }
68                 }
69
70
71                 $this->ev = new EditView();
72                 $this->ev->view = $view;
73                 $this->ev->ss = new Sugar_Smarty();
74                 //$_REQUEST['return_action'] = 'SubPanelViewer';
75
76
77
78         //retrieve bean if id or record is passed in
79         if (isset($_REQUEST['record']) || isset($_REQUEST['id'])){
80             global $beanList;
81             $bean = $beanList[$module];
82             $this->ev->focus = new $bean();
83
84             if (isset($_REQUEST['record']) && empty($_REQUEST['id'])){
85                 $_REQUEST['id'] = $_REQUEST['record'];
86             }
87             $this->ev->focus->retrieve($_REQUEST['record']);
88             //call setup with focus passed in
89                     $this->ev->setup($module, $this->ev->focus, $source);
90         }else{
91             //no id, call setup on new bean
92                     $this->ev->setup($module, null, $source);
93         }
94
95             $this->ev->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl';
96                 $this->ev->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl';
97                 $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');
98         $this->ev->defs['templateMeta']['form']['hideAudit'] = true;
99
100
101                 $viewEditSource = 'modules/'.$module.'/views/view.edit.php';
102                 if (file_exists('custom/'. $viewEditSource)) {
103                         $viewEditSource = 'custom/'. $viewEditSource;
104                 }
105
106                 if(file_exists($viewEditSource) && !$proccessOverride) {
107             include($viewEditSource);
108             $c = $module . 'ViewEdit';
109
110             if(class_exists($c)) {
111                     $view = new $c;
112                     if($view->useForSubpanel) {
113                         $this->defaultProcess = false;
114
115                         //Check if we should use the module's QuickCreate.tpl file.
116                         if($view->useModuleQuickCreateTemplate && file_exists('modules/'.$module.'/tpls/QuickCreate.tpl')) {
117                            $this->ev->defs['templateMeta']['form']['headerTpl'] = 'modules/'.$module.'/tpls/QuickCreate.tpl';
118                         }
119
120                             $view->ev = & $this->ev;
121                             $view->ss = & $this->ev->ss;
122                                         $class = $GLOBALS['beanList'][$module];
123                                         if(!empty($GLOBALS['beanFiles'][$class])){
124                                                 require_once($GLOBALS['beanFiles'][$class]);
125                                                 $bean = new $class();
126                                                 $view->bean = $bean;
127                                         }
128                                         $this->ev->formName = 'form_Subpanel'.$this->ev->view .'_'.$module;
129                                         $view->showTitle = false; // Do not show title since this is for subpanel
130                             $view->display();
131                     }
132             }
133                 } //if
134
135                 if($this->defaultProcess && !$proccessOverride) {
136                    $this->process($module);
137                 }
138         }
139
140         function process($module){
141         $form_name = 'form_Subpanel'.$this->ev->view .'_'.$module;
142         $this->ev->formName = $form_name;
143         $this->ev->process(true, $form_name);
144                 echo $this->ev->display(false, true);
145         }
146 }
147 ?>