1 |
<?php |
2 |
// Load globals |
3 |
require_once ("global_vars.php"); |
4 |
|
5 |
// Includes |
6 |
require_once ($GLOBAL_ADMIN_INC."sessionClass.php"); |
7 |
require_once ($GLOBAL_ADMIN_INC."accessClass.php"); |
8 |
require_once ($GLOBAL_ADMIN_INC."db_connect.php"); |
9 |
require_once ($GLOBAL_ADMIN_INC."app_controls.php"); |
10 |
|
11 |
|
12 |
// HTML header |
13 |
printf("<HTML>\n"); |
14 |
printf("<HEAD>\n"); |
15 |
printf("<title>Information Type Drilldown</title>\n"); |
16 |
printf("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n", $GLOBAL_ADMIN_CSS); |
17 |
printf("</HEAD>\n"); |
18 |
|
19 |
|
20 |
// Default access settings |
21 |
$sess_time_human = ""; |
22 |
$sess_staff_account = ""; |
23 |
$sess_staff_id = 0; |
24 |
$sess_access_level = 0; |
25 |
$sess_access = ""; |
26 |
$sess_last_name = ""; |
27 |
$sess_first_name = ""; |
28 |
|
29 |
|
30 |
// Page header |
31 |
require_once ($GLOBAL_ADMIN_HEADER); |
32 |
|
33 |
|
34 |
// Collect access information |
35 |
if(isset($libsession)) { |
36 |
|
37 |
// Fetch session information |
38 |
$sessionClass = new sessionClass("", $libsession, "", ""); |
39 |
$accessClass = new accessClass($sessionClass); |
40 |
|
41 |
// Load user session variables |
42 |
$sess_time_human = $sessionClass->time_human; |
43 |
$sess_staff_account = $sessionClass->staff_account; |
44 |
$sess_access_level = $accessClass->access_level; |
45 |
$sess_access = $accessClass->access; |
46 |
$sess_last_name = $accessClass->last_name; |
47 |
$sess_first_name = $accessClass->first_name; |
48 |
|
49 |
} |
50 |
|
51 |
// If the cookie is set and access level is appropriate |
52 |
if(isset($libsession) && $sess_access_level >= 20) { |
53 |
|
54 |
|
55 |
// Fetch the information type descr. field |
56 |
$infotype = lookupField("infotype", "infotype_id", $infotype_id, "infotype"); |
57 |
|
58 |
printf("<center>\n"); |
59 |
printf("<h3>Information Type '%s' (#%d) used on the following RQS Pages:</h3>", $infotype, $infotype_id); |
60 |
|
61 |
/************************* |
62 |
** RQS Usage Drilldowns ** |
63 |
*************************/ |
64 |
|
65 |
printf("<table width = \"75%%\" border=\"1\"><tr>\n"); |
66 |
printf("<td width=\"40%%\" class=\"cellPlain\">RQS Subject Page(s)</td>\n"); |
67 |
printf("<td width=\"20%%\" class=\"cellPlain\">Resource</td>\n"); |
68 |
printf("<td width=\"20%%\" class=\"cellPlain\">Edit</td>\n"); |
69 |
printf("</tr>\n"); |
70 |
|
71 |
// Build the query |
72 |
$sql = "SELECT DISTINCT |
73 |
i.infotype, |
74 |
s.subject, |
75 |
s.subject_id, |
76 |
r.title |
77 |
|
78 |
FROM |
79 |
infotype i |
80 |
LEFT JOIN res_sub_infotype rsi using (infotype_id) |
81 |
LEFT JOIN subject s on rsi.subject_id = s.subject_id |
82 |
LEFT JOIN resource r on rsi.resource_id = r.resource_id |
83 |
|
84 |
WHERE s.subject_id > 0 AND i.infotype_id = " |
85 |
. $infotype_id |
86 |
. " ORDER BY s.subject"; |
87 |
|
88 |
// Initialize counter |
89 |
$rowcount = 0; |
90 |
|
91 |
$rs = xx_tryquery($sql); |
92 |
|
93 |
// Cycle through the result set |
94 |
while ( $row = xx_fetch_array ($rs, xx_ASSOC)) { |
95 |
$subject = Trim($row["subject"]); |
96 |
$subject_id = Trim($row["subject_id"]); |
97 |
$title = Trim($row["title"]); |
98 |
|
99 |
// Make every other row colored |
100 |
if ($rowcount % 2 == 0) $color = " class=\"backLight\" "; |
101 |
else $color = ""; |
102 |
|
103 |
// New row |
104 |
printf("<tr>\n"); |
105 |
printf("<td %s>%s</td>\n", $color, $subject); |
106 |
printf("<td %s>%s</td>\n", $color, $title); |
107 |
printf("<td %s><a href=\"subject_builder.phtml?subject_id=%d\">Edit</a></td>\n", $color, $subject_id); |
108 |
printf("</tr>\n"); |
109 |
|
110 |
// Increment counter |
111 |
$rowcount++; |
112 |
} |
113 |
|
114 |
/***************************** |
115 |
** Summary of Resource uses ** |
116 |
*****************************/ |
117 |
|
118 |
printf("<tr><td colspan=\"2\" align=\"right\" class=\"backLight\">Total RQS Uses:</td>\n"); |
119 |
if (xx_num_rows($rs) == 0) printf("<td class=\"backLight\">(None)</td>\n"); |
120 |
else printf("<td class=\"backLight\">%d</td>\n", xx_num_rows($rs)); |
121 |
printf("</tr>\n"); |
122 |
|
123 |
// Close table |
124 |
printf("</table><br><br>\n"); |
125 |
|
126 |
// Resources with this base infotype |
127 |
printf("<h3>Information Type '%s' (#%d) is associated with the following Resources:</h3>", $infotype, $infotype_id); |
128 |
printf("<table width = \"75%%\" border=\"1\"><tr>\n"); |
129 |
printf("<td width=\"80%%\" class=\"cellPlain\">Resource</td>\n"); |
130 |
printf("<td width=\"20%%\" class=\"cellPlain\">Edit</td>\n"); |
131 |
printf("</tr>\n"); |
132 |
|
133 |
// Build the query |
134 |
$sql = "SELECT |
135 |
r.resource_id, |
136 |
r.title |
137 |
|
138 |
FROM |
139 |
resource r |
140 |
|
141 |
WHERE r.infotype_id = " |
142 |
. $infotype_id |
143 |
. " ORDER BY r.title"; |
144 |
|
145 |
// Initialize counter |
146 |
$rowcount = 0; |
147 |
|
148 |
$rs = xx_tryquery($sql); |
149 |
|
150 |
// Cycle through the result set |
151 |
while ( $row = xx_fetch_array ($rs, xx_ASSOC)) { |
152 |
$resource_id = Trim($row["resource_id"]); |
153 |
$title = Trim($row["title"]); |
154 |
|
155 |
// Make every other row colored |
156 |
if ($rowcount % 2 == 0) $color = " class=\"backLight\" "; |
157 |
else $color = ""; |
158 |
|
159 |
// New row |
160 |
printf("<tr>\n"); |
161 |
printF("<td %s>%s</td>\n", $color, $title); |
162 |
printf("<td %s><a href=\"operation.phtml?operation=Edit&table=resource&key_id=%d\">Edit</a></td>\n", $color, $resource_id); |
163 |
printf("</tr>\n"); |
164 |
|
165 |
// Increment counter |
166 |
$rowcount++; |
167 |
} |
168 |
|
169 |
// Summary of occurences in resources |
170 |
printf("<tr><td align=\"right\" class=\"backLight\">Total associated Resources:</td>\n"); |
171 |
if (xx_num_rows($rs) == 0) printf("<td class=\"backLight\">(None)</td>\n"); |
172 |
else printf("<td class=\"backLight\">%d</td>\n", xx_num_rows($rs)); |
173 |
printf("</tr>\n"); |
174 |
|
175 |
// Close table |
176 |
printf("</table><br><br>\n"); |
177 |
|
178 |
// Link to return to admin console |
179 |
adminReturn($sess_access_level); |
180 |
|
181 |
} // logged in |
182 |
|
183 |
// No access page |
184 |
else require_once ($GLOBAL_NO_ACCESS); |
185 |
|
186 |
|
187 |
// Page footer |
188 |
require_once ($GLOBAL_ADMIN_FOOTER); |
189 |
?> |
190 |
|
191 |
</body> |
192 |
</html> |
193 |
|