| 1 | rodolico | 1 | <?php
 | 
        
           |  |  | 2 | define ( MAX_INPUT_FIELD_DISPLAY, 40 ); // this is the maximum input field size
 | 
        
           |  |  | 3 | define ( IMAGE_DIRECTORY, '/pictures/' );  // relative URL where pictures are stored
 | 
        
           |  |  | 4 | define ( EDIT_IMAGE_HEIGHT, 100 );         // height for thumbnail of pictuers
 | 
        
           |  |  | 5 | define ( MAX_UPLOAD_FILE_SIZE, 1024*1024*10 ); // 10 meg
 | 
        
           |  |  | 6 | define (DEFAULT_TEXTAREA_HEIGHT, 5 );
 | 
        
           |  |  | 7 | define ( DEFAULT_TABLE, 'client');
 | 
        
           |  |  | 8 | global $DATABASE_DEFINITION;
 | 
        
           |  |  | 9 |   | 
        
           |  |  | 10 | $DATABASE_DEFINITION = array(
 | 
        
           |  |  | 11 |    /* Basically a configuration file equivilent to a windows INI  */
 | 
        
           |  |  | 12 |    '_system' => array( 
 | 
        
           |  |  | 13 |       'table name' => '_system',
 | 
        
           |  |  | 14 |       'key field' => '_system_id ',
 | 
        
           |  |  | 15 |       'display name' => 'System Control',
 | 
        
           |  |  | 16 |       'display columns' => array('_system_id','group_name','key_name','theValue'),
 | 
        
           |  |  | 17 |       'display query' => 'select _system_id,group_name,theValue,key_name,added_date from _system',
 | 
        
           |  |  | 18 |       'field info' => array(
 | 
        
           |  |  | 19 |          /* date record was closed */
 | 
        
           |  |  | 20 |          'removed_date' => array('type' => 'datetime', 'required' => false, 'default'=>'null' ),
 | 
        
           |  |  | 21 |          '_system_id' => array('keyfield' => true , 'required' => true , 'readonly' => true , 'type' => 'int'),
 | 
        
           |  |  | 22 |          /* used to group keys together */
 | 
        
           |  |  | 23 |          'group_name' => array('required' => true , 'type' => 'string' , 'width' => 64),
 | 
        
           |  |  | 24 |          /* the actual value of this entry */
 | 
        
           |  |  | 25 |          'theValue' => array('type' => 'text'),
 | 
        
           |  |  | 26 |          /* date record was added */
 | 
        
           |  |  | 27 |          'added_date' => array('required' => true , 'type' => 'datetime'),
 | 
        
           |  |  | 28 |          /* key into this value */
 | 
        
           |  |  | 29 |          'key_name' => array('required' => true , 'type' => 'string' , 'width' => 64)
 | 
        
           |  |  | 30 |       )
 | 
        
           |  |  | 31 |    ),
 | 
        
           |  |  | 32 |    /* These are attributes that can be applied to a device */
 | 
        
           |  |  | 33 |    'attrib' => array( 
 | 
        
           |  |  | 34 |       'table name' => 'attrib',
 | 
        
           |  |  | 35 |       'key field' => 'attrib_id',
 | 
        
           |  |  | 36 |       'display name' => 'Device Attributes',
 | 
        
           |  |  | 37 |       'display columns' => array('name'),
 | 
        
           |  |  | 38 |       'display query' => 'select attrib.attrib_id,name from attrib',
 | 
        
           |  |  | 39 |       'field info' => array(
 | 
        
           |  |  | 40 |          /* date record was deleted/supserceded */
 | 
        
           |  |  | 41 |          'removed_date' => array('type' => 'datetime', 'required' => false, 'default'=>'null' ),
 | 
        
           |  |  | 42 |          /* the visible displayed name */
 | 
        
           |  |  | 43 |          'name' => array('required' => true , 'type' => 'string' , 'width' => 64),
 | 
        
           |  |  | 44 |          /* date record was added */
 | 
        
           |  |  | 45 |          'added_date' => array('required' => true , 'type' => 'datetime'),
 | 
        
           |  |  | 46 |          'attrib_id' => array('keyfield' => true , 'required' => true , 'readonly' => true , 'type' => 'int' , 'width' => 10)
 | 
        
           |  |  | 47 |       )
 | 
        
           |  |  | 48 |    ),
 | 
        
           |  |  | 49 |    /* information on a particular client */
 | 
        
           |  |  | 50 |    'client' => array( 
 | 
        
           |  |  | 51 |       'table name' => 'client',
 | 
        
           |  |  | 52 |       'key field' => 'client_id',
 | 
        
           |  |  | 53 |       'display name' => 'Clients',
 | 
        
           |  |  | 54 |       'display columns' => array('name','added_date'),
 | 
        
           |  |  | 55 |       'display query' => 'select client.client_id,name,added_date from client',
 | 
        
           |  |  | 56 |       'field info' => array(
 | 
        
           |  |  | 57 |          /* date record was deleted/supserceded */
 | 
        
           |  |  | 58 |          'removed_date' => array('type' => 'datetime', 'required' => false, 'default'=>'null' ),
 | 
        
           |  |  | 59 |          /* These are internal notes visible only to us */
 | 
        
           |  |  | 60 |          'internal_notes' => array('type' => 'text'),
 | 
        
           |  |  | 61 |          /* world visible notes on the client */
 | 
        
           |  |  | 62 |          'notes' => array('type' => 'text'),
 | 
        
           |  |  | 63 |          /* the visible displayed name */
 | 
        
           |  |  | 64 |          'name' => array('required' => true , 'type' => 'string' , 'width' => 64),
 | 
        
           |  |  | 65 |          'client_id' => array('keyfield' => true , 'required' => true , 'readonly' => true , 'type' => 'int' , 'width' => 10),
 | 
        
           |  |  | 66 |          /* date record was added */
 | 
        
           |  |  | 67 |          'added_date' => array('required' => true , 'type' => 'datetime')
 | 
        
           |  |  | 68 |       )
 | 
        
           |  |  | 69 |    ),
 | 
        
           |  |  | 70 |    /* information on a site which is tied to a client */
 | 
        
           |  |  | 71 |    'site' => array( 
 | 
        
           |  |  | 72 |       'table name' => 'site',
 | 
        
           |  |  | 73 |       'key field' => 'site_id',
 | 
        
           |  |  | 74 |       'display name' => 'Sites',
 | 
        
           |  |  | 75 |       'display columns' => array('Client', 'Site'),
 | 
        
           |  |  | 76 |       'display query' => 'select site.site_id,client.name Client,site.name Site from site join client using (client_id) order by client.name',
 | 
        
           |  |  | 77 |       'field info' => array(
 | 
        
           |  |  | 78 |          /* date record was deleted/supserceded */
 | 
        
           |  |  | 79 |          'removed_date' => array('type' => 'datetime', 'required' => false, 'default'=>'null' ),
 | 
        
           |  |  | 80 |          /* Just a place to record some notes */
 | 
        
           |  |  | 81 |          'notes' => array('type' => 'text'),
 | 
        
           |  |  | 82 |          /* the visible displayed name */
 | 
        
           |  |  | 83 |          'name' => array('required' => true , 'type' => 'string' , 'width' => 64),
 | 
        
           |  |  | 84 |          'client_id' => array('type' => 'lookup', 'table' => 'client', 'keyfield' => 'client_id', 'display_field' => 'name'),
 | 
        
           |  |  | 85 |          'site_id' => array('keyfield' => true , 'required' => true , 'readonly' => true , 'type' => 'int' , 'width' => 10),
 | 
        
           |  |  | 86 |          /* date record was added */
 | 
        
           |  |  | 87 |          'added_date' => array('required' => true , 'type' => 'datetime')
 | 
        
           |  |  | 88 |       )
 | 
        
           |  |  | 89 |    ),
 | 
        
           |  |  | 90 |    /* information on an individual device computer router print */
 | 
        
           |  |  | 91 |    'device' => array( 
 | 
        
           |  |  | 92 |       'table name' => 'device',
 | 
        
           |  |  | 93 |       'display name' => 'Devices',
 | 
        
           |  |  | 94 |       'key field' => 'device_id',
 | 
        
           |  |  | 95 |       'display columns' => array('Type','Device','Parent'),
 | 
        
           |  |  | 96 |       'display query' => 'select device.device_id,device.name Device, device_type.name Type, parent.name Parent 
 | 
        
           |  |  | 97 |                           from device left outer join device parent on device.part_of = parent.device_id 
 | 
        
           |  |  | 98 |                                join device_type on device.device_type_id = device_type.device_type_id
 | 
        
           |  |  | 99 |                           order by device_type.show_as_system desc, device_type.name, device.name',
 | 
        
           |  |  | 100 |       'field info' => array(
 | 
        
           |  |  | 101 |          'part_of' => array('type' => 'lookup', 'table' => 'device', 'keyfield' => 'device_id', 'display_field' => 'name', 'null_ok' => true ),
 | 
        
           |  |  | 102 |          /* date record was deleted/supserceded */
 | 
        
           |  |  | 103 |          'removed_date' => array('type' => 'datetime', 'required' => false, 'default'=>'null' ),
 | 
        
           |  |  | 104 |          'device_type_id' => array('type' => 'lookup', 'table' => 'device_type', 'keyfield' => 'device_type_id', 'display_field' => 'name'),
 | 
        
           |  |  | 105 |          /* the visible displayed name */
 | 
        
           |  |  | 106 |          'name' => array('required' => true , 'type' => 'string' , 'width' => 255),
 | 
        
           |  |  | 107 |          'site_id' => array('type' => 'lookup', 'table' => 'site', 'keyfield' => 'site_id', 'display_field' => 'name'),
 | 
        
           |  |  | 108 |          'device_id' => array('keyfield' => true , 'required' => true , 'readonly' => true , 'type' => 'int' , 'width' => 10),
 | 
        
           |  |  | 109 |          /* Just a place to record some notes */
 | 
        
           |  |  | 110 |          'notes' => array('type' => 'text'),
 | 
        
           | 37 | rodolico | 111 |          /* Just a place to record some notes */
 | 
        
           |  |  | 112 |          'restrictions' => array('type' => 'text'),
 | 
        
           | 1 | rodolico | 113 |          /* date record was added */
 | 
        
           |  |  | 114 |          'added_date' => array('required' => true , 'type' => 'datetime')
 | 
        
           |  |  | 115 |       )
 | 
        
           |  |  | 116 |    ),
 | 
        
           |  |  | 117 |    /* links devices and their attributes together */
 | 
        
           |  |  | 118 |    'device_attrib' => array( 
 | 
        
           |  |  | 119 |       'table name' => 'device_attrib',
 | 
        
           |  |  | 120 |       'key field' => 'device_attrib_id',
 | 
        
           |  |  | 121 |       'display name' => 'Attributes for Devices',
 | 
        
           |  |  | 122 |       'display columns' => array('Device','Attribute','Value'),
 | 
        
           |  |  | 123 |       'display query' => 'select device_attrib.device_attrib_id,device.name Device,attrib.name Attribute,device_attrib.value Value 
 | 
        
           |  |  | 124 |                           from device_attrib join device using (device_id) 
 | 
        
           |  |  | 125 |                                join device_type using (device_type_id) 
 | 
        
           |  |  | 126 |                                join attrib using (attrib_id) 
 | 
        
           |  |  | 127 |                           order by device_type.show_as_system desc, device.name,attrib.name',
 | 
        
           |  |  | 128 |       'field info' => array(
 | 
        
           |  |  | 129 |          'removed_date' => array('type' => 'datetime', 'required' => false, 'default'=>'null' ),
 | 
        
           |  |  | 130 |          /* The actual value of this attribute. */
 | 
        
           |  |  | 131 |          'value' => array('type' => 'text'),
 | 
        
           |  |  | 132 |          'device_id' => array('type' => 'lookup', 'table' => 'device', 'keyfield' => 'device_id', 'display_field' => 'name'),
 | 
        
           |  |  | 133 |          'device_attrib_id' => array('keyfield' => true , 'required' => true , 'readonly' => true , 'type' => 'int'),
 | 
        
           |  |  | 134 |          /* date record was added */
 | 
        
           |  |  | 135 |          'added_date' => array('required' => true , 'type' => 'datetime'),
 | 
        
           |  |  | 136 |          'attrib_id' => array('type' => 'lookup', 'table' => 'attrib', 'keyfield' => 'attrib_id', 'display_field' => 'name')
 | 
        
           |  |  | 137 |       )
 | 
        
           |  |  | 138 |    ),
 | 
        
           |  |  | 139 |    /* simply a list of device types ie computer printer whatever */
 | 
        
           |  |  | 140 |    'device_type' => array( 
 | 
        
           |  |  | 141 |       'table name' => 'device_type',
 | 
        
           |  |  | 142 |       'key field' => 'device_type_id',
 | 
        
           |  |  | 143 |       'display name' => 'Device Types',
 | 
        
           |  |  | 144 |       'display columns' => array('System','Name'),
 | 
        
           |  |  | 145 |       'display query' => 'select removed_date,device_type_id,name Name,added_date,show_as_system System from device_type',
 | 
        
           |  |  | 146 |       'field info' => array(
 | 
        
           |  |  | 147 |          /* date record was deleted/supserceded */
 | 
        
           |  |  | 148 |          'removed_date' => array('type' => 'datetime', 'required' => false, 'default'=>'null' ),
 | 
        
           |  |  | 149 |          'device_type_id' => array('keyfield' => true , 'required' => true , 'readonly' => true , 'type' => 'int' , 'width' => 10),
 | 
        
           |  |  | 150 |          /* the visible displayed name */
 | 
        
           |  |  | 151 |          'name' => array('required' => true , 'type' => 'string' , 'width' => 64),
 | 
        
           |  |  | 152 |          /* date record was added */
 | 
        
           |  |  | 153 |          'added_date' => array('required' => true , 'type' => 'datetime'),
 | 
        
           |  |  | 154 |          'show_as_system' => array('default' => 'Y' , 'type' => 'bool' , 'width' => 1)
 | 
        
           |  |  | 155 |       )
 | 
        
           |  |  | 156 |    ),
 | 
        
           |  |  | 157 |    /* table for logging into the the maintenance system */
 | 
        
           |  |  | 158 |    'login' => array( 
 | 
        
           |  |  | 159 |       'table name' => 'login',
 | 
        
           |  |  | 160 |       'key field' => 'login_id',
 | 
        
           |  |  | 161 |       'display name' => 'Login',
 | 
        
           |  |  | 162 |       'display columns' => array('email','Restrictions','Added'),
 | 
        
           |  |  | 163 |       'display query' => 'select removed_date Removed,where_clause Restrictions,email,added_date Added,login_id from login',
 | 
        
           |  |  | 164 |       'field info' => array(
 | 
        
           |  |  | 165 |          /* date record was closed */
 | 
        
           |  |  | 166 |          'removed_date' => array('type' => 'datetime', 'required' => false, 'default'=>'null' ),
 | 
        
           |  |  | 167 |          /* the encrypted password of the user */
 | 
        
           |  |  | 168 |          'pass' => array('type' => 'string' , 'width' => 32),
 | 
        
           |  |  | 169 |          /* clause that limits what a user can see */
 | 
        
           |  |  | 170 |          'where_clause' => array('type' => 'text'),
 | 
        
           |  |  | 171 |          /* email address used as login id */
 | 
        
           |  |  | 172 |          'email' => array('required' => true , 'type' => 'string' , 'width' => 64),
 | 
        
           |  |  | 173 |          /* date record was added */
 | 
        
           |  |  | 174 |          'added_date' => array('required' => true , 'type' => 'datetime'),
 | 
        
           |  |  | 175 |          'login_id' => array('keyfield' => true , 'required' => true , 'readonly' => true , 'type' => 'int' , 'width' => 10)
 | 
        
           |  |  | 176 |       )
 | 
        
           |  |  | 177 |    ),
 | 
        
           |  |  | 178 |    /* We keep the entire menu structure here so modules can modify it */
 | 
        
           |  |  | 179 |    'menu' => array( 
 | 
        
           |  |  | 180 |       'table name' => 'menu',
 | 
        
           |  |  | 181 |       'key field' => 'menu_id',
 | 
        
           |  |  | 182 |       'display name' => 'System Menu',
 | 
        
           |  |  | 183 |       'display columns' => array('parent_id','caption','menu_id','url'),
 | 
        
           |  |  | 184 |       'display query' => 'select parent_id,caption,menu_id,url from menu',
 | 
        
           |  |  | 185 |       'field info' => array(
 | 
        
           |  |  | 186 |          'parent_id' => array('type' => 'lookup', 'table' => 'menu', 'keyfield' => 'menu_id', 'display_field' => 'name'),
 | 
        
           |  |  | 187 |          /* The actual caption displayed */
 | 
        
           |  |  | 188 |          'caption' => array('required' => true , 'type' => 'string' , 'width' => 20),
 | 
        
           |  |  | 189 |          'menu_id' => array('keyfield' => true , 'required' => true , 'readonly' => true , 'type' => 'int'),
 | 
        
           |  |  | 190 |          /* the url of the page/script to call or null if this contains sub-options */
 | 
        
           |  |  | 191 |          'url' => array('type' => 'string' , 'width' => 120)
 | 
        
           |  |  | 192 |       )
 | 
        
           |  |  | 193 |    ),
 | 
        
           |  |  | 194 |    /* holds definition for report */
 | 
        
           |  |  | 195 |    'report' => array( 
 | 
        
           |  |  | 196 |       'table name' => 'report',
 | 
        
           |  |  | 197 |       'key field' => 'report_id',
 | 
        
           |  |  | 198 |       'display name' => 'Reports',
 | 
        
           |  |  | 199 |       'display columns' => array( 'name','screen_report'),
 | 
        
           |  |  | 200 |       'display query' => 'select screen_report,query,name,report_id,parameters from report',
 | 
        
           |  |  | 201 |       'field info' => array(
 | 
        
           |  |  | 202 |          /* Each screen can be assigned a bit and this will show up on a screen */
 | 
        
           |  |  | 203 |          'screen_report' => array('type' => 'int'),
 | 
        
           |  |  | 204 |          /* Query to be executed */
 | 
        
           |  |  | 205 |          'query' => array('required' => true , 'type' => 'text'),
 | 
        
           |  |  | 206 |          /* Display Name of Report */
 | 
        
           |  |  | 207 |          'name' => array('required' => true , 'type' => 'string' , 'width' => 64),
 | 
        
           |  |  | 208 |          'report_id' => array('keyfield' => true , 'required' => true , 'readonly' => true , 'type' => 'int'),
 | 
        
           |  |  | 209 |          /* All parameters used in above */
 | 
        
           |  |  | 210 |          'parameters' => array('type' => 'text')
 | 
        
           |  |  | 211 |       )
 | 
        
           |  |  | 212 |    )
 | 
        
           |  |  | 213 | );
 | 
        
           |  |  | 214 | ?>
 |