55 |
rodolico |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
function documentsView( $parameters ) {
|
|
|
4 |
if ( isset( $parameters['device_id'] ) ) {
|
|
|
5 |
$where = "owner_type = 'd' and owner_id = $parameters[device_id]";
|
56 |
rodolico |
6 |
$join = 'join device on (device.device_id = document.owner_id)';
|
55 |
rodolico |
7 |
} elseif ( isset( $parameters['site_id'] ) ) {
|
|
|
8 |
$where = "owner_type = 's' and owner_id = $parameters[site_id]";
|
56 |
rodolico |
9 |
$join = 'join site on (site.site_id = document.owner_id)';
|
55 |
rodolico |
10 |
} elseif ( isset( $parameters['client_id'] ) ) {
|
|
|
11 |
$where = "owner_type = 'c' and owner_id = $parameters[client_id]";
|
56 |
rodolico |
12 |
$join = 'join client on (client.client_id = document.owner_id)';
|
55 |
rodolico |
13 |
} else {
|
|
|
14 |
return null;
|
|
|
15 |
}
|
56 |
rodolico |
16 |
$nameField = queryHTMLLink( 'modules/documents/display.php?document_id=', 'document.document_id', 'document.name' );
|
|
|
17 |
//concat( '<a href=\"', document.document_id, '\"', 'target=\"_blank\">', document.name, '</a>')
|
55 |
rodolico |
18 |
$query = "select
|
56 |
rodolico |
19 |
document.document_id 'ID',\n
|
|
|
20 |
$nameField 'Name',
|
55 |
rodolico |
21 |
document.description 'Description',
|
56 |
rodolico |
22 |
document_mime_type.mime_type 'MIME',
|
55 |
rodolico |
23 |
document.added_date 'Added'
|
|
|
24 |
from document
|
56 |
rodolico |
25 |
left outer join document_mime_type using (document_mime_type_id)
|
55 |
rodolico |
26 |
$join
|
|
|
27 |
where
|
|
|
28 |
$where
|
|
|
29 |
order by document.name, document.added_date";
|
56 |
rodolico |
30 |
file_put_contents( '/home/rodolico/www/web/computer_asset_manager_v1/modules/documents/queryout.sql', $query );
|
|
|
31 |
//print '<pre>' . print_r($query) . '</pre>';
|
|
|
32 |
return queryToTable( $query );
|
55 |
rodolico |
33 |
// put it into some kind of table. NOTE: description should be on mouseover
|
|
|
34 |
return null;
|
|
|
35 |
}
|
|
|
36 |
|
56 |
rodolico |
37 |
function queryHTMLLink ( $url, $hrefLink, $hrefDisplay ) {
|
|
|
38 |
return "concat( '<a href=\"', '$url', $hrefLink, '\"', 'target=\"_blank\">', $hrefDisplay, '</a>')";
|
|
|
39 |
}
|
|
|
40 |
|
55 |
rodolico |
41 |
?>
|