Subversion Repositories computer_asset_manager_v1

Rev

Rev 48 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

<?php

  /*
   * This is the callable library for the license module.
   * routines are assumed to be called from other modules, returning 
   * HTML data.
   * All routines will receive one array containing the parameters to
   * be used. Parameters may be
   * client_id - A client_id to be used for queries
   * device_id - A device_id to be used for queries
   * site_id   - A site_id to be used for queries
   * htmlDirectory - the HTML path to the module
   */
   
   function licenseView ( $parameters ) {
      // this is an array containing the columns we will display in the
      // query. The query will be generated as
      // select $key '$value', $key '$value
      $reportColumns = array( 
            'license_id' => 'ID',
            'license_product.name' => 'Product',
            'license.license' => 'License',
            'license.added_date' => 'Installed',
            'device_id' => 'Machine',
            );
      // first, let's remove any fields from $report_columns which are 
      // listed in the $parameters, and add them to the where clause
      $whereClause = array( 'license.removed_date is null' );
      foreach ( $parameters as $key => $value ) {
         if ( isset( $reportColumns[ $key ] ) ) {
            unset( $reportColumns[ $key ] );
            $whereClause[] = "$key = $value";
         }
      }
      $columnList = array();
      foreach ( $reportColumns as $key => $value ) {
         $columnList[] = "$key '$value'";
      }
      $query = 'select ' . implode( ',', $columnList );
      $query .= 'from
                  license join license_product using (license_product_id)
                  left outer join device using (device_id)
                  join client using ( client_id )';
      $query .= ' where ' . implode ( ' and ', $whereClause );
      return queryToTable( $query );
   }

?>