]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Documents/views/view.edit.php
Release 6.4.0
[Github/sugarcrm.git] / modules / Documents / views / view.edit.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3
4 /*********************************************************************************
5  * SugarCRM Community Edition is a customer relationship management program developed by
6  * SugarCRM, Inc. Copyright (C) 2004-2011 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 class DocumentsViewEdit extends ViewEdit
41 {
42
43     /**
44      * @see SugarView::ViewEdit()
45      */
46      function DocumentsViewEdit(){
47          parent::ViewEdit();
48          $this->useForSubpanel = true;
49      }
50
51         /**
52          * @see SugarView::display()
53          */
54         public function display()
55         {
56                 global $app_list_strings, $mod_strings;
57
58                 $load_signed=false;
59                 if ((isset($_REQUEST['load_signed_id']) && !empty($_REQUEST['load_signed_id']))) {
60
61                         $load_signed=true;
62                         if (isset($_REQUEST['record'])) {
63                                 $this->bean->related_doc_id=$_REQUEST['record'];
64                         }
65                         if (isset($_REQUEST['selected_revision_id'])) {
66                                 $this->bean->related_doc_rev_id=$_REQUEST['selected_revision_id'];
67                         }
68
69                         $this->bean->id=null;
70                         $this->bean->document_name=null;
71                         $this->bean->filename=null;
72                         $this->bean->is_template=0;
73                 } //if
74
75                 if (!empty($this->bean->id) ||
76             (empty($this->bean->id) && !empty($_REQUEST['record']) && !empty($_REQUEST['action']) && strtolower($_REQUEST['action'])=='quickedit')
77         ) {
78                         $this->ss->assign("FILE_OR_HIDDEN", "hidden");
79                         if (!$this->ev->isDuplicate) {
80                                 $this->ss->assign("DISABLED", "disabled");
81                         }
82                 } else {
83                         $this->bean->revision = 1;
84                     $this->ss->assign("FILE_OR_HIDDEN", "file");
85                 }
86
87                 $popup_request_data = array(
88                         'call_back_function' => 'document_set_return',
89                         'form_name' => 'EditView',
90                         'field_to_name_array' => array(
91                                 'id' => 'related_doc_id',
92                                 'document_name' => 'related_document_name',
93                                 ),
94                         );
95                 $json = getJSONobj();
96                 $this->ss->assign('encoded_document_popup_request_data', $json->encode($popup_request_data));
97
98
99                 //get related document name.
100                 if (!empty($this->bean->related_doc_id)) {
101                         $this->ss->assign("RELATED_DOCUMENT_NAME",Document::get_document_name($this->bean->related_doc_id));
102                         $this->ss->assign("RELATED_DOCUMENT_ID",$this->bean->related_doc_id);
103                         if (!empty($this->bean->related_doc_rev_id)) {
104                                 $this->ss->assign("RELATED_DOCUMENT_REVISION_OPTIONS", get_select_options_with_id(DocumentRevision::get_document_revisions($this->bean->related_doc_id), $this->bean->related_doc_rev_id));
105                         } else {
106                                 $this->ss->assign("RELATED_DOCUMENT_REVISION_OPTIONS", get_select_options_with_id(DocumentRevision::get_document_revisions($this->bean->related_doc_id), ''));
107                         }
108                 } else {
109                         $this->ss->assign("RELATED_DOCUMENT_REVISION_DISABLED", "disabled");
110                 }
111
112
113                 //set parent information in the form.
114                 if (isset($_REQUEST['parent_id'])) {
115                         $this->ss->assign("PARENT_ID",$_REQUEST['parent_id']);
116                 } //if
117
118                 if (isset($_REQUEST['parent_name'])) {
119                         $this->ss->assign("PARENT_NAME", $_REQUEST['parent_name']);
120
121                         if (!empty($_REQUEST['parent_type'])) {
122                                 switch (strtolower($_REQUEST['parent_type'])) {
123
124                                         case "contracts" :
125                                                 $this->ss->assign("LBL_PARENT_NAME",$mod_strings['LBL_CONTRACT_NAME']);
126                                                 break;
127
128                                         //todo remove leads case.
129                                         case "leads" :
130                                                 $this->ss->assign("LBL_PARENT_NAME",$mod_strings['LBL_CONTRACT_NAME']);
131                                                 break;
132                                 } //switch
133                         } //if
134                 } //if
135
136                 if (isset($_REQUEST['parent_type'])) {
137                         $this->ss->assign("PARENT_TYPE",$_REQUEST['parent_type']);
138                 }
139
140                 if ($load_signed) {
141                         $this->ss->assign("RELATED_DOCUMENT_REVISION_DISABLED", "disabled");
142                         $this->ss->assign("RELATED_DOCUMENT_BUTTON_AVAILABILITY", "hidden");
143                         $this->ss->assign("LOAD_SIGNED_ID",$_REQUEST['load_signed_id']);
144                 } else {
145                         $this->ss->assign("RELATED_DOCUMENT_BUTTON_AVAILABILITY", "button");
146                 } //if-else
147
148                 parent::display();
149         }
150
151         /**
152          * @see SugarView::_getModuleTitleParams()
153          */
154         protected function _getModuleTitleParams($browserTitle = false)
155         {
156         $params = array();
157         $params[] = $this->_getModuleTitleListParam($browserTitle);
158         if(!empty($this->bean->id)){
159                         $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->document_name."</a>";
160                         $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
161                 }else{
162                         $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL'];
163                 }
164
165                 return $params;
166     }
167
168 }