]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Audit/Popup_picker.php
Release 6.4.0
[Github/sugarcrm.git] / modules / Audit / Popup_picker.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-2011 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
39
40
41
42
43 require_once("include/upload_file.php");
44
45 require_once('include/utils/db_utils.php');
46 require_once('modules/Audit/Audit.php');
47
48 global $beanList, $beanFiles, $currentModule, $focus, $action, $app_strings, $app_list_strings, $current_language, $timedate, $mod_strings;
49 //we don't want the parent module's string file, but rather the string file specifc to this subpanel
50
51
52
53 $bean = $beanList[$_REQUEST['module_name']];
54 require_once($beanFiles[$bean]);
55 $focus = new $bean;
56
57 class Popup_Picker
58 {
59
60
61         /*
62          *
63          */
64         function Popup_Picker()
65         {
66
67         }
68
69         /**
70          *
71          */
72         function process_page()
73         {
74                 global $theme;
75                 global $focus;
76                 global $mod_strings;
77                 global $app_strings;
78                 global $app_list_strings;
79                 global $currentModule;
80                 global $odd_bg;
81                 global $even_bg;
82                 
83         global $audit;
84         global $current_language;
85                 
86                 $audit_list =  Audit::get_audit_list();
87         $xtpl=new XTemplate ('modules/Audit/Popup_picker.html');
88                 
89                 $xtpl->assign('MOD', $mod_strings);
90                 $xtpl->assign('APP', $app_strings);
91                 insert_popup_header($theme);
92
93                 //output header
94                 echo "<table width='100%' cellpadding='0' cellspacing='0'><tr><td>";
95                 $mod_strings = return_module_language($current_language, $focus->module_dir);
96                 
97                 $printImageURL = SugarThemeRegistry::current()->getImageURL('print.gif');
98                 $titleExtra = <<<EOHTML
99 <a href="javascript:void window.open('index.php?{$GLOBALS['request_string']}','printwin','menubar=1,status=0,resizable=1,scrollbars=1,toolbar=0,location=1')" class='utilsLink'>
100 <!--not_in_theme!--><img src="{$printImageURL}" alt="{$GLOBALS['app_strings']['LNK_PRINT']}"></a>
101 <a href="javascript:void window.open('index.php?{$GLOBALS['request_string']}','printwin','menubar=1,status=0,resizable=1,scrollbars=1,toolbar=0,location=1')" class='utilsLink'>
102 {$GLOBALS['app_strings']['LNK_PRINT']}
103 </a>
104 EOHTML;
105                 
106                 $params = array();
107                 $params[] = translate('LBL_MODULE_NAME', $focus->module_dir);
108                 $params[] = $focus->get_summary_text();
109                 $params[] = translate('LBL_CHANGE_LOG', 'Audit');
110                 echo str_replace('</div>',"<span class='utils'>$titleExtra</span></div>",getClassicModuleTitle($focus->module_dir, $params, false));
111                 
112                 $oddRow = true;
113                 $audited_fields = $focus->getAuditEnabledFieldDefinitions();
114                 asort($audited_fields);
115                 $fields = '';
116                 $field_count = count($audited_fields);
117                 $start_tag = "<table><tr><td >";
118                 $end_tag = "</td></tr></table>";
119                 
120                 if($field_count > 0)
121                 {
122                         $index = 0;
123                 foreach($audited_fields as $key=>$value)
124                         {
125                                 $index++;
126                                 $vname = '';
127                                 if(isset($value['vname']))
128                                         $vname = $value['vname'];
129                                 else if(isset($value['label']))
130                                         $vname = $value['label'];
131                                 $fields .= str_replace(':', '', translate($vname, $focus->module_dir));
132
133                         if($index < $field_count)
134                         {
135                                 $fields .= ", ";
136                         }
137                 }
138                 
139                 echo $start_tag.translate('LBL_AUDITED_FIELDS', 'Audit').$fields.$end_tag;
140         }
141         else
142         {
143                 echo $start_tag.translate('LBL_AUDITED_FIELDS', 'Audit').$end_tag;
144         }
145
146                 foreach($audit_list as $audit)
147                 {
148                         if(empty($audit['before_value_string']) && empty($audit['after_value_string']))
149                         {
150                                 $before_value = $audit['before_value_text'];
151                                 $after_value = $audit['after_value_text'];
152             }
153             else {
154                                 $before_value = $audit['before_value_string'];
155                                 $after_value = $audit['after_value_string'];
156                         }
157
158             // Let's run the audit data through the sugar field system
159             if(isset($audit['data_type'])){
160                 require_once('include/SugarFields/SugarFieldHandler.php');
161                 $vardef = array('name'=>'audit_field','type'=>$audit['data_type']);
162                 $field = SugarFieldHandler::getSugarField($audit['data_type']);
163                 $before_value = $field->getChangeLogSmarty(array($vardef['name']=>$before_value), $vardef, array(), $vardef['name']);
164                 $after_value = $field->getChangeLogSmarty(array($vardef['name']=>$after_value), $vardef, array(), $vardef['name']);
165             }
166
167             $activity_fields = array(
168                 'ID' => $audit['id'],
169                             'NAME' => $audit['field_name'],
170                 'BEFORE_VALUE' => $before_value,
171                 'AFTER_VALUE' => $after_value,
172                 'CREATED_BY' => $audit['created_by'],
173                 'DATE_CREATED' => $audit['date_created'],
174                         );
175
176                         $xtpl->assign("ACTIVITY", $activity_fields);
177
178                         if($oddRow)
179                         {
180                         //todo move to themes
181                                 $xtpl->assign("ROW_COLOR", 'oddListRow');
182                                 $xtpl->assign("BG_COLOR", $odd_bg);
183                 }
184                 else
185                 {
186                         //todo move to themes
187                                 $xtpl->assign("ROW_COLOR", 'evenListRow');
188                                 $xtpl->assign("BG_COLOR", $even_bg);
189                 }
190                         $oddRow = !$oddRow;
191
192                         $xtpl->parse("audit.row");
193                 // Put the rows in.
194         }//end foreach
195
196                 $xtpl->parse("audit");
197                 $xtpl->out("audit");
198                 insert_popup_footer();
199     }
200 } // end of class Popup_Picker
201 ?>