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