Subversion Repositories computer_asset_manager_v1

Rev

Rev 61 | 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
      }
63 rodolico 16
      $nameField = queryHTMLLink( 'modules/file/display.php?file_id=', 'file.file_id', 'file.name', true );
17
      $deleteField = queryHTMLLink( 'modules/file/delete.php?file_id=', 'file.file_id', "'Delete'" );
18
      $editField = queryHTMLLink( 'modules/file/upload_file.html?file_id=', 'file.file_id', "'Edit'" );
59 rodolico 19
      //concat( '<a href=\"', file.file_id, '\"', 'target=\"_blank\">', file.name, '</a>')      
55 rodolico 20
      $query = "select 
59 rodolico 21
                   file.file_id 'ID',\n
56 rodolico 22
                   $nameField 'Name', 
59 rodolico 23
                   file.description 'Description', 
24
                   file_mime_type.mime_type 'MIME', 
63 rodolico 25
                   file.added_date 'Added',
26
                   concat( $deleteField, ' ', $editField ) 'Action'
59 rodolico 27
                from file 
28
                     left outer join file_mime_type using (file_mime_type_id)
55 rodolico 29
                     $join
30
                where
31
                   $where
63 rodolico 32
                   and file.removed_date is null
59 rodolico 33
                order by file.name, file.added_date";
61 rodolico 34
      //file_put_contents( '/home/rodolico/www/web/computer_asset_manager_v1/modules/file/queryout.sql', $query );
56 rodolico 35
      //print '<pre>' . print_r($query) . '</pre>';
63 rodolico 36
      //file_put_contents( '/home/rodolico/www/web/computer_asset_manager_v1/modules/file/table.html', queryToTable( $query ) );
56 rodolico 37
      return queryToTable( $query );
55 rodolico 38
   }
39
 
63 rodolico 40
   function queryHTMLLink ( $url, $hrefLink, $hrefDisplay, $newPage = false ) {
41
      return "concat( '<a href=\"', '$url', $hrefLink, '\"'," . ( $newPage ? " 'target=\"_blank\"', " : '' ) . "'>', $hrefDisplay, '</a>')";
56 rodolico 42
   }
43
 
55 rodolico 44
?>