Subversion Repositories computer_asset_manager_v1

Rev

Rev 55 | Rev 58 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

<?php

   function documentsView( $parameters ) {
      if ( isset( $parameters['device_id'] ) ) {
         $where = "owner_type = 'd' and owner_id = $parameters[device_id]";
         $join = 'join device on (device.device_id = document.owner_id)';
      } elseif ( isset( $parameters['site_id'] ) ) {
         $where = "owner_type = 's' and owner_id = $parameters[site_id]";
         $join = 'join site on (site.site_id = document.owner_id)';
      } elseif ( isset( $parameters['client_id'] ) ) {
         $where = "owner_type = 'c' and owner_id = $parameters[client_id]";
         $join = 'join client on (client.client_id = document.owner_id)';
      } else {
         return null;
      }
      $nameField = queryHTMLLink( 'modules/documents/display.php?document_id=', 'document.document_id', 'document.name' );
      //concat( '<a href=\"', document.document_id, '\"', 'target=\"_blank\">', document.name, '</a>')      
      $query = "select 
                   document.document_id 'ID',\n
                   $nameField 'Name', 
                   document.description 'Description', 
                   document_mime_type.mime_type 'MIME', 
                   document.added_date 'Added'
                from document 
                     left outer join document_mime_type using (document_mime_type_id)
                     $join
                where
                   $where
                order by document.name, document.added_date";
      file_put_contents( '/home/rodolico/www/web/computer_asset_manager_v1/modules/documents/queryout.sql', $query );
      //print '<pre>' . print_r($query) . '</pre>';
      return queryToTable( $query );
      // put it into some kind of table. NOTE: description should be on mouseover
      return null;
   }
   
   function queryHTMLLink ( $url, $hrefLink, $hrefDisplay ) {
      return "concat( '<a href=\"', '$url', $hrefLink, '\"', 'target=\"_blank\">', $hrefDisplay, '</a>')";
   }

?>