| 42 | rodolico | 1 | drop table if exists license;
 | 
        
           | 41 | rodolico | 2 | create table license (
 | 
        
           |  |  | 3 |    license_id int unsigned not null auto_increment,
 | 
        
           |  |  | 4 |    client_id  int unsigned null comment 'link to client table',
 | 
        
           |  |  | 5 |    device_id   int unsigned null comment 'link to device table',
 | 
        
           |  |  | 6 |    license text not null comment 'the actual license text',
 | 
        
           |  |  | 7 |    license_product_id int unsigned not null references license_product(license_product_id),
 | 
        
           |  |  | 8 |    added_date date default null comment 'date the license used on this machine',
 | 
        
           |  |  | 9 |    removed_date date default null comment 'date license removed from this machine',
 | 
        
           |  |  | 10 |    primary key (license_id)
 | 
        
           |  |  | 11 | ) comment 'Holds the license and links to machine installed on' ;
 | 
        
           |  |  | 12 |   | 
        
           | 42 | rodolico | 13 | drop table if exists license_product;
 | 
        
           | 41 | rodolico | 14 | create table license_product (
 | 
        
           |  |  | 15 |    license_product_id int unsigned not null auto_increment,
 | 
        
           |  |  | 16 |    name text comment 'name of the license',
 | 
        
           |  |  | 17 |    primary key ( license_product_id )
 | 
        
           |  |  | 18 | ) comment 'a list of all products we track license for';
 | 
        
           |  |  | 19 |   | 
        
           | 42 | rodolico | 20 | delete from _system where key_name = 'Licenses';
 | 
        
           |  |  | 21 | insert into _system ( group_name,key_name,theValue,added_date) values ( 'Modules', 'Licenses', 'modules/license/', now() );
 | 
        
           |  |  | 22 | delete from menu 
 | 
        
           |  |  | 23 | where 
 | 
        
           |  |  | 24 |    menu.parent_id in 
 | 
        
           |  |  | 25 |       ( select menu_id 
 | 
        
           |  |  | 26 |         from ( 
 | 
        
           |  |  | 27 |            select distinct a.menu_id as menu_id 
 | 
        
           |  |  | 28 |            from menu a join menu b on a.menu_id = b.menu_id 
 | 
        
           |  |  | 29 |            where a.caption = 'Licenses' 
 | 
        
           |  |  | 30 |            ) 
 | 
        
           |  |  | 31 |       as c );
 | 
        
           |  |  | 32 | delete from menu where caption = 'Licenses';
 | 
        
           |  |  | 33 | insert into menu( url, caption, parent_id) values ('/modules/license/', 'Licenses', null);
 | 
        
           | 43 | rodolico | 34 | insert into menu( url,caption,parent_id) select '/modules/license/bulk_load.html','Bulk Load',menu_id from menu where caption = 'Licenses';
 | 
        
           |  |  | 35 | insert into menu( url,caption,parent_id) select '/modules/license/add_edit.html','Edit',menu_id from menu where caption = 'Licenses';
 | 
        
           | 42 | rodolico | 36 |   | 
        
           | 46 | rodolico | 37 | create or replace view view_device_systems as select * from device where device_type_id in (select device_type_id from device_type where show_as_system = 'Y');
 | 
        
           | 42 | rodolico | 38 |   | 
        
           |  |  | 39 | /* DO NOT RUN BELOW THIS LINE */
 | 
        
           |  |  | 40 |   | 
        
           | 41 | rodolico | 41 | select 
 | 
        
           | 42 | rodolico | 42 |    license_product.name 'Product',
 | 
        
           | 41 | rodolico | 43 |    license.license 'License',
 | 
        
           | 42 | rodolico | 44 |    ifnull(device.name,'--- Available ---') 'Installed On',
 | 
        
           |  |  | 45 |    client.name 'Client'
 | 
        
           | 41 | rodolico | 46 | from
 | 
        
           |  |  | 47 |    license join license_product using (license_product_id)
 | 
        
           |  |  | 48 |    left outer join device using (device_id)
 | 
        
           | 42 | rodolico | 49 |    join client using ( client_id )
 | 
        
           | 41 | rodolico | 50 | order by license_product.name, device.name;
 | 
        
           |  |  | 51 |   |