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