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-2011 SugarCRM Inc.
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.
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
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
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.
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.
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 ********************************************************************************/
40 require_once('include/EditView/EditView2.php');
42 * Quick edit form in the subpanel
45 class SubpanelQuickEdit{
46 var $defaultProcess = true;
48 function SubpanelQuickEdit($module, $view='QuickEdit', $proccessOverride = false){
49 //treat quickedit and quickcreate views as the same
50 if($view == 'QuickEdit') {$view = 'QuickCreate';}
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))
57 $source = $base . strtolower($view) . 'defs.php';
58 if (!file_exists($source))
60 //if our view does not exist default to EditView
62 $source = 'custom/' . $base . 'editviewdefs.php';
63 if (!file_exists($source))
65 $source = $base . 'editviewdefs.php';
71 $this->ev = new EditView();
72 $this->ev->view = $view;
73 $this->ev->ss = new Sugar_Smarty();
74 //$_REQUEST['return_action'] = 'SubPanelViewer';
78 //retrieve bean if id or record is passed in
79 if (isset($_REQUEST['record']) || isset($_REQUEST['id'])){
81 $bean = $beanList[$module];
82 $this->ev->focus = new $bean();
84 if (isset($_REQUEST['record']) && empty($_REQUEST['id'])){
85 $_REQUEST['id'] = $_REQUEST['record'];
87 $this->ev->focus->retrieve($_REQUEST['record']);
88 //call setup with focus passed in
89 $this->ev->setup($module, $this->ev->focus, $source);
91 //no id, call setup on new bean
92 $this->ev->setup($module, null, $source);
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;
101 $viewEditSource = 'modules/'.$module.'/views/view.edit.php';
102 if (file_exists('custom/'. $viewEditSource)) {
103 $viewEditSource = 'custom/'. $viewEditSource;
106 if(file_exists($viewEditSource) && !$proccessOverride) {
107 include($viewEditSource);
108 $c = $module . 'ViewEdit';
110 if(class_exists($c)) {
112 if($view->useForSubpanel) {
113 $this->defaultProcess = false;
115 //Check if we shold 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';
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();
128 $this->ev->formName = 'form_Subpanel'.$this->ev->view .'_'.$module;
129 $view->showTitle = false; // Do not show title since this is for subpanel
135 if($this->defaultProcess && !$proccessOverride) {
136 $this->process($module);
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);