| 47 | rodolico | 1 | <?php 
 | 
        
           |  |  | 2 |    include_once( '../../header.php' );
 | 
        
           | 86 | rodolico | 3 |    include_once( './functions.php' );
 | 
        
           |  |  | 4 |    include_once( '../../includes/functions.php' );
 | 
        
           | 47 | rodolico | 5 |    define( DEBUG, true );
 | 
        
           |  |  | 6 |    if ( isset( $_POST["submit"] ) && $_POST["submit"] == 'Save Modifications' ) {
 | 
        
           | 51 | rodolico | 7 |       $str = overwriteLicense( $_REQUEST['license_id'], $_REQUEST['client_id'], $_REQUEST['device_id'], $_REQUEST['license_product_id'], $_REQUEST['license'], $_REQUEST['added_date'], $_REQUEST['removed_date'], true  );
 | 
        
           | 47 | rodolico | 8 |       header('Location: index.html');
 | 
        
           |  |  | 9 |    }
 | 
        
           |  |  | 10 |    // make them go back to the index page if they access this directly
 | 
        
           |  |  | 11 |    if ( ! isset( $_REQUEST[ 'license_id'] ) ) header('Location: index.html');
 | 
        
           |  |  | 12 |    $adding = $_REQUEST[ 'license_id'] == -1;
 | 
        
           |  |  | 13 |    if ( ! $adding ) {
 | 
        
           |  |  | 14 |       $currentLicense = queryDatabaseExtended( 'select * from license where license_id = ' . makeSafeSQLValue( $_REQUEST['license_id'] ) );
 | 
        
           |  |  | 15 |       $currentLicense = $currentLicense['data'][0];
 | 
        
           |  |  | 16 |    }
 | 
        
           |  |  | 17 | ?>
 | 
        
           |  |  | 18 | <?xml version="1.0" encoding="utf-8"?>
 | 
        
           |  |  | 19 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
 | 
        
           |  |  | 20 | <html xmlns="http://www.w3.org/1999/xhtml">
 | 
        
           |  |  | 21 |    <head>
 | 
        
           |  |  | 22 |       <title>Computer Asset Management Program - License - Edit</title>
 | 
        
           |  |  | 23 |       <link rel="stylesheet" type="text/css" href="../../camp.css">
 | 
        
           |  |  | 24 |    </head>
 | 
        
           |  |  | 25 |    <body>
 | 
        
           |  |  | 26 |       <?php include_once('../../menu.php'); ?>
 | 
        
           |  |  | 27 |       <div id="content">
 | 
        
           | 51 | rodolico | 28 |          <?php print $str; ?>
 | 
        
           |  |  | 29 |          <?php if ( $adding ) { # we are adding ?>
 | 
        
           |  |  | 30 |             <h1 align='center'>Adding new license</h1>
 | 
        
           |  |  | 31 |             <h2 align='center'>Warning: Inputs not validated. Use Caution</h2>
 | 
        
           |  |  | 32 |          <?php } else { ?>
 | 
        
           |  |  | 33 |             <h1 align='center'>Warning: Edits are not validated. Use Caution.</h1>
 | 
        
           |  |  | 34 |             <h2 align='center'>Only use this to correct mistakes, not to move a license</h2>
 | 
        
           |  |  | 35 |       <?php } // if..else
 | 
        
           |  |  | 36 |             if ( DEBUG ) { print '<pre>'; print_r( $currentLicense ); print '</pre>'; } ?>
 | 
        
           | 47 | rodolico | 37 |       <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">
 | 
        
           | 51 | rodolico | 38 |          <input type='hidden' name='license_id' value='<?php print $adding ? 'null' : $_REQUEST[ 'license_id']; ?>' />
 | 
        
           | 47 | rodolico | 39 |          <table border='1'>
 | 
        
           |  |  | 40 |             <tr>
 | 
        
           |  |  | 41 |                <td>Client</td>
 | 
        
           |  |  | 42 |                <td>
 | 
        
           |  |  | 43 |                   <select name='client_id'>
 | 
        
           | 86 | rodolico | 44 |                   <?php print queryToSelect( getClients() , $adding ? '' : $currentLicense['client_id'] ); ?>
 | 
        
           | 47 | rodolico | 45 |                   </select>
 | 
        
           |  |  | 46 |                </td>
 | 
        
           |  |  | 47 |             </tr>
 | 
        
           |  |  | 48 |             <tr>
 | 
        
           |  |  | 49 |                <td>Machine</td>
 | 
        
           |  |  | 50 |                <td>
 | 
        
           |  |  | 51 |                   <select name='device_id'>
 | 
        
           |  |  | 52 |                   <?php 
 | 
        
           |  |  | 53 |                   if ( $adding || ! $currentLicense['device_id'] )
 | 
        
           |  |  | 54 |                      print "<option value=-1 selected>Available</option>\n";
 | 
        
           |  |  | 55 |                   else {
 | 
        
           |  |  | 56 |                      print "<option value=-1>Available</option>\n";
 | 
        
           |  |  | 57 |                   }
 | 
        
           | 86 | rodolico | 58 |                   print queryToSelect( getAllDevices() , $adding ? '' : $currentLicense['device_id']); ?>
 | 
        
           | 47 | rodolico | 59 |                   </select>
 | 
        
           |  |  | 60 |                </td>
 | 
        
           |  |  | 61 |             </tr>
 | 
        
           |  |  | 62 |             <tr>
 | 
        
           |  |  | 63 |                <td>Product</td>
 | 
        
           |  |  | 64 |                <td>
 | 
        
           |  |  | 65 |                   <select name='license_product_id'>
 | 
        
           |  |  | 66 |                   <?php print queryToSelect( 'select license_product_id,name from license_product order by name', $adding ? '' : $currentLicense['license_product_id']); ?>
 | 
        
           |  |  | 67 |                   </select>
 | 
        
           |  |  | 68 |                </td>
 | 
        
           |  |  | 69 |             </tr>
 | 
        
           |  |  | 70 |             <tr>
 | 
        
           |  |  | 71 |                <td>License</td>
 | 
        
           |  |  | 72 |                <td>
 | 
        
           |  |  | 73 |                   <textarea name='license' cols="50" rows="2"><?php print $adding ? '' : $currentLicense['license']; ?></textarea>
 | 
        
           |  |  | 74 |                </td>
 | 
        
           |  |  | 75 |             </tr>
 | 
        
           |  |  | 76 |             <tr>
 | 
        
           |  |  | 77 |                <td>Added Date (YYYY-MM-DD)</td>
 | 
        
           |  |  | 78 |                <td>
 | 
        
           |  |  | 79 |                   <input type=text name='added_date' value='<?php print $adding ? '' : $currentLicense['added_date']; ?>' />
 | 
        
           |  |  | 80 |                </td>
 | 
        
           |  |  | 81 |             </tr>
 | 
        
           |  |  | 82 |             <tr>
 | 
        
           |  |  | 83 |                <td>Removed Date (YYYY-MM-DD)</td>
 | 
        
           |  |  | 84 |                <td>
 | 
        
           |  |  | 85 |                   <input type=text name='removed_date' value='<?php print $adding ? '' : $currentLicense['removed_date']; ?>' />
 | 
        
           |  |  | 86 |                </td>
 | 
        
           |  |  | 87 |             </tr>
 | 
        
           |  |  | 88 |             <tr>
 | 
        
           |  |  | 89 |                <td colspan='2' align='center'><input type="submit" value="Save Modifications" name="submit"></td>
 | 
        
           |  |  | 90 |             </tr>
 | 
        
           |  |  | 91 |          </table>
 | 
        
           |  |  | 92 |       </div>
 | 
        
           |  |  | 93 |    </body>
 | 
        
           |  |  | 94 | </html>
 |