Subversion Repositories computer_asset_manager_v1

Rev

Rev 59 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
55 rodolico 1
<?php
2
 
59 rodolico 3
   function filesView( $parameters ) {
55 rodolico 4
      if ( isset( $parameters['device_id'] ) ) {
5
         $where = "owner_type = 'd' and owner_id = $parameters[device_id]";
59 rodolico 6
         $join = 'join device on (device.device_id = file.owner_id)';
55 rodolico 7
      } elseif ( isset( $parameters['site_id'] ) ) {
8
         $where = "owner_type = 's' and owner_id = $parameters[site_id]";
59 rodolico 9
         $join = 'join site on (site.site_id = file.owner_id)';
55 rodolico 10
      } elseif ( isset( $parameters['client_id'] ) ) {
11
         $where = "owner_type = 'c' and owner_id = $parameters[client_id]";
59 rodolico 12
         $join = 'join client on (client.client_id = file.owner_id)';
55 rodolico 13
      } else {
14
         return null;
15
      }
59 rodolico 16
      $nameField = queryHTMLLink( 'modules/file/display.php?file_id=', 'file.file_id', 'file.name' );
17
      //concat( '<a href=\"', file.file_id, '\"', 'target=\"_blank\">', file.name, '</a>')      
55 rodolico 18
      $query = "select 
59 rodolico 19
                   file.file_id 'ID',\n
56 rodolico 20
                   $nameField 'Name', 
59 rodolico 21
                   file.description 'Description', 
22
                   file_mime_type.mime_type 'MIME', 
23
                   file.added_date 'Added'
24
                from file 
25
                     left outer join file_mime_type using (file_mime_type_id)
55 rodolico 26
                     $join
27
                where
28
                   $where
59 rodolico 29
                order by file.name, file.added_date";
61 rodolico 30
      //file_put_contents( '/home/rodolico/www/web/computer_asset_manager_v1/modules/file/queryout.sql', $query );
56 rodolico 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
?>