Subversion Repositories computer_asset_manager_v1

Rev

Rev 56 | 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 = documents.owner_id)';
      } elseif ( isset( $parameters['site_id'] ) ) {
         $where = "owner_type = 's' and owner_id = $parameters[site_id]";
         $join = 'join site on (site.site_id = documents.owner_id)';
      } elseif ( isset( $parameters['client_id'] ) ) {
         $where = "owner_type = 'c' and owner_id = $parameters[client_id]";
         $join = 'join client on (client.client_id = documents.owner_id)';
      } else {
         return null;
      }
      $query = "select 
                   document.document_id 'ID', 
                   document.name 'Name', 
                   document.description 'Description', 
                   document.mime_type 'MIME', 
                   document.added_date 'Added'
                from document 
                     join document_mime_type using (document_mime_type_id)
                     $join
                where
                   $where
                order by document.name, document.added_date";
      // run the query
      // put it into some kind of table. NOTE: description should be on mouseover
      return null;
   }
   
?>