-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStandardFilter.php
169 lines (151 loc) · 6.14 KB
/
StandardFilter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
********************************************************************************/
require_once('modules/CustomView/CustomView.php');
if(isset($_REQUEST["record"]) == false || $_REQUEST["record"]=='')
{
$oReport = new Reports();
$primarymodule = vtlib_purify($_REQUEST["primarymodule"]);
$BLOCK1 = getPrimaryStdFilterHTML($primarymodule);
if(!empty($ogReport->related_modules[$primarymodule])) {
foreach($ogReport->related_modules[$primarymodule] as $key=>$value){
$BLOCK1 .= getSecondaryStdFilterHTML($_REQUEST["secondarymodule_".$value]);
}
}
$report_std_filter->assign("BLOCK1_STD",$BLOCK1);
$BLOCKJS = $oReport->getCriteriaJS();
$report_std_filter->assign("BLOCKJS_STD",$BLOCKJS);
$BLOCKCRITERIA = $oReport->getSelectedStdFilterCriteria();
$report_std_filter->assign("BLOCKCRITERIA_STD",$BLOCKCRITERIA);
}elseif(isset($_REQUEST["record"]) == true)
{
//added to fix the ticket #5117
global $current_user;
require('user_privileges/user_privileges_'.$current_user->id.'.php');
$reportid = vtlib_purify($_REQUEST["record"]);
$oReport = new Reports($reportid);
$oReport->getSelectedStandardCriteria($reportid);
$oRep = new Reports();
$secondarymodule = '';
$secondarymodules =Array();
if(!empty($oRep->related_modules[$oReport->primodule])) {
foreach($oRep->related_modules[$oReport->primodule] as $key=>$value){
if(isset($_REQUEST["secondarymodule_".$value]))$secondarymodules []= $_REQUEST["secondarymodule_".$value];
}
}
$secondarymodule = implode(":",$secondarymodules);
if($secondarymodule!='')
$oReport->secmodule = $secondarymodule;
$BLOCK1 = getPrimaryStdFilterHTML($oReport->primodule,$oReport->stdselectedcolumn);
$BLOCK1 .= getSecondaryStdFilterHTML($oReport->secmodule,$oReport->stdselectedcolumn);
//added to fix the ticket #5117
$selectedcolumnvalue = '"'. $oReport->stdselectedcolumn . '"';
if (!$is_admin && isset($oReport->stdselectedcolumn) && strpos($BLOCK1, $selectedcolumnvalue) === false)
$BLOCK1 .= "<option selected value='Not Accessible'>".$app_strings['LBL_NOT_ACCESSIBLE']."</option>";
$report_std_filter->assign("BLOCK1_STD",$BLOCK1);
$BLOCKJS = $oReport->getCriteriaJS();
$report_std_filter->assign("BLOCKJS_STD",$BLOCKJS);
$BLOCKCRITERIA = $oReport->getSelectedStdFilterCriteria($oReport->stdselectedfilter);
$report_std_filter->assign("BLOCKCRITERIA_STD",$BLOCKCRITERIA);
if(isset($oReport->startdate) && isset($oReport->enddate)) {
$report_std_filter->assign("STARTDATE_STD", DateTimeField::convertToUserFormat($oReport->startdate));
$report_std_filter->assign("ENDDATE_STD", DateTimeField::convertToUserFormat($oReport->enddate));
} else {
$report_std_filter->assign("STARTDATE_STD",$oReport->startdate);
$report_std_filter->assign("ENDDATE_STD",$oReport->enddate);
}
}
/** Function to get the HTML strings for the primarymodule standard filters
* @ param $module : Type String
* @ param $selected : Type String(optional)
* This Returns a HTML combo srings
*/
function getPrimaryStdFilterHTML($module,$selected="")
{
global $app_list_strings;
global $ogReport;
global $current_language;
$ogReport->oCustomView=new CustomView();
$result = $ogReport->oCustomView->getStdCriteriaByModule($module);
$mod_strings = return_module_language($current_language,$module);
if(isset($result))
{
foreach($result as $key=>$value)
{
if(isset($mod_strings[$value]))
{
if($key == $selected)
{
$shtml .= "<option selected value=\"".$key."\">".getTranslatedString($module,$module)." - ".getTranslatedString($value,$secmodule[$i])."</option>";
}else
{
$shtml .= "<option value=\"".$key."\">".getTranslatedString($module,$module)." - ".getTranslatedString($value,$secmodule[$i])."</option>";
}
}else
{
if($key == $selected)
{
$shtml .= "<option selected value=\"".$key."\">".getTranslatedString($module,$module)." - ".$value."</option>";
}else
{
$shtml .= "<option value=\"".$key."\">".getTranslatedString($module,$module)." - ".$value."</option>";
}
}
}
}
return $shtml;
}
/** Function to get the HTML strings for the secondary standard filters
* @ param $module : Type String
* @ param $selected : Type String(optional)
* This Returns a HTML combo srings for the secondary modules
*/
function getSecondaryStdFilterHTML($module,$selected="")
{
global $app_list_strings;
global $ogReport;
global $current_language;
$ogReport->oCustomView=new CustomView();
if($module != "")
{
$secmodule = explode(":",$module);
for($i=0;$i < count($secmodule) ;$i++)
{
$result = $ogReport->oCustomView->getStdCriteriaByModule($secmodule[$i]);
$mod_strings = return_module_language($current_language,$secmodule[$i]);
if(isset($result))
{
foreach($result as $key=>$value)
{
if(isset($mod_strings[$value]))
{
if($key == $selected)
{
$shtml .= "<option selected value=\"".$key."\">".getTranslatedString($secmodule[$i],$secmodule[$i])." - ".getTranslatedString($value,$secmodule[$i])."</option>";
}else
{
$shtml .= "<option value=\"".$key."\">".getTranslatedString($secmodule[$i],$secmodule[$i])." - ".getTranslatedString($value,$secmodule[$i])."</option>";
}
}else
{
if($key == $selected)
{
$shtml .= "<option selected value=\"".$key."\">".getTranslatedString($secmodule[$i],$secmodule[$i])." - ".$value."</option>";
}else
{
$shtml .= "<option value=\"".$key."\">".getTranslatedString($secmodule[$i],$secmodule[$i])." - ".$value."</option>";
}
}
}
}
}
}
return $shtml;
}
?>