]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Documents/views/view.edit.php
Release 6.1.4
[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 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
41  * Description: This file is used to override the default Meta-data EditView behavior
42  * to provide customization specific to the Calls module.
43  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
44  * All Rights Reserved.
45  * Contributor(s): ______________________________________..
46  ********************************************************************************/
47
48 require_once('include/MVC/View/views/view.edit.php');
49
50 class DocumentsViewEdit extends ViewEdit 
51 {
52         /**
53          * @see SugarView::display()
54          */
55         public function display() 
56         {
57                 global $app_list_strings, $mod_strings;
58                 /*
59                 $this->bean->category_name = $app_list_strings['document_category_dom'][$this->bean->category_id];
60             $this->bean->subcategory_name = $app_list_strings['document_subcategory_dom'][$this->bean->subcategory_id];
61             if(isset($this->bean->status_id)) {
62             $this->bean->status = $app_list_strings['document_status_dom'][$this->bean->status_id];
63             }
64         $this->bean->related_doc_name = Document::get_document_name($this->bean->related_doc_id);
65         $this->bean->related_doc_rev_number = DocumentRevision::get_document_revision_name($this->bean->related_doc_rev_id);
66         $this->bean->save_file = basename($this->bean->file_url_noimage);
67         */
68                 $load_signed=false;
69                 if ((isset($_REQUEST['load_signed_id']) && !empty($_REQUEST['load_signed_id']))) {
70                         
71                         $load_signed=true;
72                         if (isset($_REQUEST['record'])) {
73                                 $this->bean->related_doc_id=$_REQUEST['record'];
74                         }
75                         if (isset($_REQUEST['selected_revision_id'])) { 
76                                 $this->bean->related_doc_rev_id=$_REQUEST['selected_revision_id'];
77                         }
78                         
79                         $this->bean->id=null;
80                         $this->bean->document_name=null;
81                         $this->bean->filename=null;
82                         $this->bean->is_template=0;
83                 } //if
84                 
85                 if (!empty($this->bean->id)) {
86                         $this->ss->assign("FILE_OR_HIDDEN", "hidden");
87                         if (!$this->ev->isDuplicate) {
88                                 $this->ss->assign("DISABLED", "disabled");
89                         }
90                 } else {
91                         global $timedate;
92                     $format = $timedate->get_cal_date_format();
93                     $format = str_replace('%', '', $format);
94                     $this->bean->active_date = date($format);
95                         $this->bean->revision = 1;
96                     $this->ss->assign("FILE_OR_HIDDEN", "file");
97                 }               
98
99                 $popup_request_data = array(
100                         'call_back_function' => 'document_set_return',
101                         'form_name' => 'EditView',
102                         'field_to_name_array' => array(
103                                 'id' => 'related_doc_id',
104                                 'document_name' => 'related_document_name',
105                                 ),
106                         );
107                 $json = getJSONobj();
108                 $this->ss->assign('encoded_document_popup_request_data', $json->encode($popup_request_data));
109
110
111                 //get related document name.
112                 if (!empty($this->bean->related_doc_id)) {
113                         $this->ss->assign("RELATED_DOCUMENT_NAME",Document::get_document_name($this->bean->related_doc_id));
114                         $this->ss->assign("RELATED_DOCUMENT_ID",$this->bean->related_doc_id);
115                         if (!empty($this->bean->related_doc_rev_id)) {
116                                 $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));
117                         } else {
118                                 $this->ss->assign("RELATED_DOCUMENT_REVISION_OPTIONS", get_select_options_with_id(DocumentRevision::get_document_revisions($this->bean->related_doc_id), ''));  
119                         }
120                 } else {
121                         $this->ss->assign("RELATED_DOCUMENT_REVISION_DISABLED", "disabled");    
122                 }
123
124
125                 //set parent information in the form.
126                 if (isset($_REQUEST['parent_id'])) {
127                         $this->ss->assign("PARENT_ID",$_REQUEST['parent_id']);  
128                 } //if
129                 
130                 if (isset($_REQUEST['parent_name'])) {
131                         $this->ss->assign("PARENT_NAME", $_REQUEST['parent_name']);
132                         
133                         if (!empty($_REQUEST['parent_type'])) {
134                                 switch (strtolower($_REQUEST['parent_type'])) {
135                                 
136                                         case "contracts" :
137                                                 $this->ss->assign("LBL_PARENT_NAME",$mod_strings['LBL_CONTRACT_NAME']);
138                                                 break;
139                                         
140                                         //todo remove leads case.
141                                         case "leads" :
142                                                 $this->ss->assign("LBL_PARENT_NAME",$mod_strings['LBL_CONTRACT_NAME']);
143                                                 break;
144                                 } //switch
145                         } //if
146                 } //if
147                         
148                 if (isset($_REQUEST['parent_type'])) {
149                         $this->ss->assign("PARENT_TYPE",$_REQUEST['parent_type']);      
150                 }
151
152                 if ($load_signed) {
153                         $this->ss->assign("RELATED_DOCUMENT_REVISION_DISABLED", "disabled");    
154                         $this->ss->assign("RELATED_DOCUMENT_BUTTON_AVAILABILITY", "hidden");    
155                         $this->ss->assign("LOAD_SIGNED_ID",$_REQUEST['load_signed_id']);
156                 } else {
157                         $this->ss->assign("RELATED_DOCUMENT_BUTTON_AVAILABILITY", "button");    
158                 } //if-else
159
160                 parent::display();
161         }
162         
163         /**
164          * @see SugarView::_getModuleTitleParams()
165          */
166         protected function _getModuleTitleParams()
167         {
168         $params = array();
169         $params[] = $this->_getModuleTitleListParam();
170         if(!empty($this->bean->id)){
171                         $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>".$this->bean->document_name."</a>";
172                         $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL'];
173                 }else{
174                         $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL'];
175                 }
176                 
177                 return $params;
178     }
179 }