| 1 | rodolico | 1 | <?php 
 | 
        
           | 20 | rodolico | 2 |    include_once( 'header.php' );
 | 
        
           |  |  | 3 |   | 
        
           |  |  | 4 |    //include_once( 'DBTemplate.class.php' );
 | 
        
           | 1 | rodolico | 5 | ?>
 | 
        
           |  |  | 6 | <?xml version="1.0" encoding="utf-8"?>
 | 
        
           |  |  | 7 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
        
           |  |  | 8 | <html xmlns="http://www.w3.org/1999/xhtml">
 | 
        
           |  |  | 9 | <head>
 | 
        
           |  |  | 10 |   <title>Daily Data - Computer Asset Management Program</title>
 | 
        
           |  |  | 11 |    <script language="javascript"> 
 | 
        
           |  |  | 12 |    function eToggle(anctag,darg) 
 | 
        
           |  |  | 13 |    {
 | 
        
           |  |  | 14 |      var ele = document.getElementById(darg);
 | 
        
           |  |  | 15 |      var text = document.getElementById(anctag);
 | 
        
           |  |  | 16 |      if(ele.style.display == "block") 
 | 
        
           |  |  | 17 |      {
 | 
        
           |  |  | 18 |        ele.style.display = "none";
 | 
        
           |  |  | 19 |        text.innerHTML = "Show " + darg;
 | 
        
           |  |  | 20 |      }
 | 
        
           |  |  | 21 |      else 
 | 
        
           |  |  | 22 |      {
 | 
        
           |  |  | 23 |       ele.style.display = "block";
 | 
        
           |  |  | 24 |       text.innerHTML = "Hide " + darg;
 | 
        
           |  |  | 25 |      }
 | 
        
           |  |  | 26 |    } 
 | 
        
           |  |  | 27 |    </script>
 | 
        
           |  |  | 28 |   <link rel="stylesheet" type="text/css" href="camp.css">
 | 
        
           |  |  | 29 | </head>
 | 
        
           |  |  | 30 | <body>
 | 
        
           |  |  | 31 | <?php 
 | 
        
           |  |  | 32 |    include_once('menu.php'); 
 | 
        
           |  |  | 33 | ?>
 | 
        
           |  |  | 34 | <div id="content">
 | 
        
           | 20 | rodolico | 35 |   | 
        
           | 22 | rodolico | 36 |    <form method="POST" enctype="multipart/form-data" name='search'>
 | 
        
           |  |  | 37 |       <table border="1" cellpadding="2" align="center">
 | 
        
           |  |  | 38 |          <tbody>
 | 
        
           |  |  | 39 |             <tr>
 | 
        
           |  |  | 40 |                <td align = 'center' colspan='2'>
 | 
        
           |  |  | 41 |                   Enter search phrase to find device<br />
 | 
        
           |  |  | 42 |                   Precede search phrase with <b>site:</b> or <b>client:</b><br />
 | 
        
           |  |  | 43 |                   to search for site or client<br />
 | 
        
           |  |  | 44 |                   This is a substring search!
 | 
        
           |  |  | 45 |                </td>
 | 
        
           |  |  | 46 |             </tr>
 | 
        
           |  |  | 47 |             <tr>
 | 
        
           |  |  | 48 |                <td>
 | 
        
           |  |  | 49 |                   Search
 | 
        
           |  |  | 50 |                </td>
 | 
        
           |  |  | 51 |                <td title='Enter substring to search for'>
 | 
        
           |  |  | 52 |                   <input type='text' name='searchfor' value=''>
 | 
        
           |  |  | 53 |                </td>
 | 
        
           |  |  | 54 |             </tr>
 | 
        
           |  |  | 55 |             <tr>
 | 
        
           |  |  | 56 |                <td colspan="2" align="center">
 | 
        
           |  |  | 57 |                   <input type="submit" name="search" value="Search">
 | 
        
           |  |  | 58 |                </td>
 | 
        
           |  |  | 59 |             </tr>
 | 
        
           |  |  | 60 |          </tbody>
 | 
        
           |  |  | 61 |       </table>
 | 
        
           |  |  | 62 |    </form>
 | 
        
           | 1 | rodolico | 63 | <?php
 | 
        
           | 22 | rodolico | 64 |    if ( isset( $_REQUEST['searchfor'] ) ) {
 | 
        
           |  |  | 65 |       print_r( doSearch( $_REQUEST['searchfor'] ) );
 | 
        
           |  |  | 66 |    }
 | 
        
           | 20 | rodolico | 67 |    print '<pre>' . print_r( $_SESSION, true ) . print '</pre>';
 | 
        
           |  |  | 68 |   | 
        
           |  |  | 69 |   | 
        
           |  |  | 70 |    /*global $DATABASE_DEFINITION;
 | 
        
           | 1 | rodolico | 71 |    $camp = new DBDatabase( 'camp', $DATABASE_DEFINITION );
 | 
        
           |  |  | 72 |    $whereClause = array('removed is null');
 | 
        
           |  |  | 73 |    $owners = $camp->getTable('owners');
 | 
        
           |  |  | 74 |    $owners->toArray( array( 'where' => array('removed is null') ) );
 | 
        
           |  |  | 75 |   | 
        
           |  |  | 76 |    DBTemplate::$templatePath = '/home/rodolico/www/web/camp/templates/';
 | 
        
           |  |  | 77 |    DBTemplate::$autoSave = true;
 | 
        
           |  |  | 78 |    $template = new DBTemplate( $owners, 'list' );
 | 
        
           |  |  | 79 |    //print "<pre>" . print_r( $template, true ) . "</pre>";
 | 
        
           |  |  | 80 |   | 
        
           |  |  | 81 |    try {
 | 
        
           |  |  | 82 |       $template->loadTemplate( 'list' );
 | 
        
           |  |  | 83 |    } catch ( EXCEPTION $e ) {
 | 
        
           |  |  | 84 |       print "<h3>" . $e->getMessage() . "</h3>";
 | 
        
           |  |  | 85 |    }
 | 
        
           |  |  | 86 |    print $template->process();
 | 
        
           |  |  | 87 |    print "<pre>" . print_r( $template, true ) . "</pre>";
 | 
        
           |  |  | 88 |   | 
        
           |  |  | 89 | /*
 | 
        
           |  |  | 90 |   | 
        
           |  |  | 91 |     $list = $owners->toHTML( 'list', 
 | 
        
           |  |  | 92 |             array(
 | 
        
           |  |  | 93 |                 'where' => $whereClause,
 | 
        
           |  |  | 94 |                 'order' => array('name'),
 | 
        
           |  |  | 95 |                 'link' => array('pre' => 'id=', 'value' => 'id', 'post' => '&action=view' )
 | 
        
           |  |  | 96 |              ) 
 | 
        
           |  |  | 97 |            );
 | 
        
           |  |  | 98 |     print $list;
 | 
        
           |  |  | 99 | */
 | 
        
           |  |  | 100 | /*    unset( $_SESSION['debug'] );
 | 
        
           |  |  | 101 |     include( 'Template.class.php' );
 | 
        
           |  |  | 102 |     $template = new SmartyTemplate;
 | 
        
           |  |  | 103 |     global $DATABASE_DEFINITION;
 | 
        
           |  |  | 104 |     $camp = new DBDatabase( 'camp', $DATABASE_DEFINITION );
 | 
        
           |  |  | 105 |     $ownersDisplay='all'; // assume we will display the owners list
 | 
        
           |  |  | 106 |     $whereClause = array('removed is null');
 | 
        
           |  |  | 107 |     $template->assign( 'owners', 
 | 
        
           |  |  | 108 |          $camp->getTable('owners')->toArray( 
 | 
        
           |  |  | 109 |            array(
 | 
        
           |  |  | 110 |               'where' => $whereClause,
 | 
        
           |  |  | 111 |               'order' => array('name'),
 | 
        
           |  |  | 112 |            ) 
 | 
        
           |  |  | 113 |          ) 
 | 
        
           |  |  | 114 |     );
 | 
        
           |  |  | 115 |   | 
        
           |  |  | 116 |     if ( isset( $_REQUEST['owner_id'] ) ) { // we have one owner selected
 | 
        
           |  |  | 117 |        $ownersDisplay = 'none'; // by default, close up the full owners list if we have one selected
 | 
        
           |  |  | 118 |        $whereClause[] = 'owners.id = ' .  $_REQUEST['owner_id'];
 | 
        
           |  |  | 119 |        $template->assign( 'owner', 
 | 
        
           |  |  | 120 |             $camp->getTable('owners')->toArray( 
 | 
        
           |  |  | 121 |               array(
 | 
        
           |  |  | 122 |                  'where' => $whereClause,
 | 
        
           |  |  | 123 |                  'order' => array('name'),
 | 
        
           |  |  | 124 |               ) 
 | 
        
           |  |  | 125 |             ) 
 | 
        
           |  |  | 126 |        );
 | 
        
           |  |  | 127 |        $equipmentDisplay = 'all';
 | 
        
           |  |  | 128 |        // grab all of the equipment owned by owner
 | 
        
           |  |  | 129 |        $whereClause = array('devices.removed is null',
 | 
        
           |  |  | 130 |                             'devices.owner_id=' . $_REQUEST['owner_id'],
 | 
        
           |  |  | 131 |                             'devices.device_type_id in (select id from device_types where system = 1)'
 | 
        
           |  |  | 132 |                            );
 | 
        
           |  |  | 133 |        $template->assign( 'equipment', 
 | 
        
           |  |  | 134 |             $camp->getTable('devices')->toArray( 
 | 
        
           |  |  | 135 |               array(
 | 
        
           |  |  | 136 |                  'where' => $whereClause,
 | 
        
           |  |  | 137 |                  'order' => array('name'),
 | 
        
           |  |  | 138 |               ) 
 | 
        
           |  |  | 139 |             ) 
 | 
        
           |  |  | 140 |        );
 | 
        
           |  |  | 141 |        if ( isset( $_REQUEST['device_id'] ) ) {
 | 
        
           |  |  | 142 |           $equipmentDisplay = 'none';
 | 
        
           |  |  | 143 |           $template->assign('device', 
 | 
        
           |  |  | 144 |               $camp->getTable('devices')->toArray( 
 | 
        
           |  |  | 145 |                 array(
 | 
        
           |  |  | 146 |                    'where' => array( 'devices.id = ' . $_REQUEST['device_id'] ),
 | 
        
           |  |  | 147 |                 ) 
 | 
        
           |  |  | 148 |               ) 
 | 
        
           |  |  | 149 |          );
 | 
        
           |  |  | 150 |          // get the subinformation on this device
 | 
        
           |  |  | 151 |          $template->assign( 'device_makeup',
 | 
        
           |  |  | 152 |             $camp->getTable('devices')->toArray(
 | 
        
           |  |  | 153 |                array(
 | 
        
           |  |  | 154 |                   'where' => array( 
 | 
        
           |  |  | 155 |                         'devices.parent_id=' . $_REQUEST['device_id'],
 | 
        
           |  |  | 156 |                         'devices.removed is null'
 | 
        
           |  |  | 157 |                         ),
 | 
        
           |  |  | 158 |                   'order' => array('device_types.name')
 | 
        
           |  |  | 159 |                )
 | 
        
           |  |  | 160 |             )
 | 
        
           |  |  | 161 |          );
 | 
        
           |  |  | 162 |          // get the attributes of the device also
 | 
        
           |  |  | 163 |          $template->assign( 'attributes',
 | 
        
           |  |  | 164 |             $camp->getTable('attributes_devices')->toArray(
 | 
        
           |  |  | 165 |                array(
 | 
        
           |  |  | 166 |                   'where' => array( 
 | 
        
           |  |  | 167 |                         'attributes_devices.device_id=' . $_REQUEST['device_id'],
 | 
        
           |  |  | 168 |                         'attributes_devices.removed is null'
 | 
        
           |  |  | 169 |                         ),
 | 
        
           |  |  | 170 |                   'order' => array( 'attributes.name' )
 | 
        
           |  |  | 171 |                   //'order by' => array('devices.name')
 | 
        
           |  |  | 172 |                )
 | 
        
           |  |  | 173 |             )
 | 
        
           |  |  | 174 |          );
 | 
        
           |  |  | 175 |       } // if device_id
 | 
        
           |  |  | 176 |       $template->assign( 'ownersDisplay', $ownersDisplay );
 | 
        
           |  |  | 177 |       $template->assign( 'equipmentDisplay', $equipmentDisplay );
 | 
        
           |  |  | 178 |    } // if there is a client id requested
 | 
        
           |  |  | 179 |    //$template->assign( 'debug', $_SESSION['debug']);
 | 
        
           |  |  | 180 |    //$template->debugging = true;
 | 
        
           |  |  | 181 |    //$template->display_errors = true;
 | 
        
           |  |  | 182 |    $template->display('owners_list.tpl');
 | 
        
           |  |  | 183 |   | 
        
           |  |  | 184 | */
 | 
        
           |  |  | 185 |   | 
        
           |  |  | 186 | ?>
 | 
        
           |  |  | 187 | </div>
 | 
        
           |  |  | 188 | </body>
 | 
        
           |  |  | 189 | </html>
 | 
        
           |  |  | 190 |   |