<?php 
   
// load any scripts we need before starting our session.
   
$PATH='scripts/';  
   require_once 
$PATH."Parameters.php";
   require_once  
"Loader.php";
   require_once  
$PATH."DisplayFunctions.php"
   
//
   // we always start a new session at the home page
   // sessionId is a variable registered globally with the session by the home page
   
session_start();
   
   if( ! isset( 
$_SESSION"sessionId" ] ) ){
         
// redirect to home page if no session started
         
header"Location: /vwc/index.php" ); 
         exit;
   }  
 
    
// otherwise, jam error checking on to full and continue..
    
error_reporting E_ALL ); 
    echo 
'<?xml version="1.0" encoding="UTF-8"?>'."\n";
   
    
$invalid = array();  
    
$sys2 $_SESSION'sys2' ]; 
 
    if( isset( 
$_GET'vat' ] ) ){
      
//new Parameters();
      //$submit = $_GET[ 'submit' ];
      
if( isset( $_GET['Defaults'] )){
        
$sys2 = new Parameters();  
        
$_SESSION'sys2' ] = $sys2;   
        
//echo '<p>reset to defaults</p>';
      
} else {
        
// set changes and run if nothing invalid
        
$vat $_GET'vat' ];
        
$br $_GET'br' ];
        
$pa $_GET'pa' ];
        
$base $_GET'base' ];

        
$brcheck checkNumber$base'base rate'0.516.0 );
        if( 
strlen$brcheck ) > ) {
            
$invalid['base' ] = $brcheck;
        } else {
            
$sys2->macro->baseRate $base;  
        }
        
        
$brcheck checkNumber$pa'Personal Allowance'0.020000.0 );
        if( 
strlen$brcheck ) > ) {
            
$invalid'pa' ] = $brcheck;
        } else {
            
$sys2->personalAllowance $pa;
        }
        
        
$brcheck checkNumber$vat'VAT'0.040.0 );
        if( 
strlen$brcheck ) > ) {
            
$invalid'vat' ] = $brcheck;
        } else {
             
$sys2->vatStd $vat;
        }
        
$brcheck checkNumber$br'Basic Rate'0.054.0 );
        
//echo 'brcheck br ='. $brcheck;
        
if( strlen$brcheck ) > ){
            
$invalid'br' ] = $brcheck;
        } else {
            
$sys2->itRates[1] = $br;
        }
      }
      if( 
count$invalid ) == ){
          
$_SESSION'sys2' ] = $sys2;     
          
runModel();
      }
      
//echo '<p>$sys2->->personalAllowance'.$sys2->personalAllowance.' itbasic'.$sys2->itRates[1]."</p>\n";
   

   
    
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="author" content="Graham Stark" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="robots" content="all" />
<title>VWC - Quick Run Page</title>

<link type="text/css" href="/vwc/styles/lurid.css" rel="alternate stylesheet" title="Lurid"/>
<link type="text/css" href="/vwc/styles/lurid-tables.css" rel="alternate stylesheet" title="Lurid"/>
<link type="text/css" href="/vwc/styles/calm.css" rel="stylesheet" title="Calm"/>
<link type="text/css" href="/vwc/styles/calm-tables.css" rel="stylesheet" title="Calm"/>
<link type="text/css" href="/vwc/styles/storm.css" rel="alternate stylesheet" title="Storm"/>
<link type="text/css" href="/vwc/styles/storm-tables.css" rel="alternate stylesheet" title="Storm"/>
<link  rel="stylesheet" href="/vwc/styles/print.css" type="text/css" media="print"/>

<link  rel="stylesheet" href="/widerdemo/styles/print.css" type="text/css" media="print"/>

<script type="text/javascript" src="js/styleswitch.js"></script>
</head>
<body>
<div class="mainbody">
<div class="header">
<h1>Virtual Chancellor</h1>
</div>
<?php echo drawMainMenu('quick'); ?>

<div class="contents">
<h3>Quick Run</h3>
<p>
Here, you can make changes to four key economic variables. Pressing the "Submit" button runs the model; a summary of your changes appears in the right-hand
box, and detailed results are available in the "View Results" link on the menu above.
</p>
<p>
If you go to the "Change Parameters" link on the main menu you can make much more detailed changes to taxation and spending.
</p>

<form action="<?php echo $_SERVER['PHP_SELF'?>" method="get">
<table>
  <tbody>     
     <tr class="tableRowEven">
        <td align="right">Personal Allowance</td>
        <td align="left">
           <input size="8" type="text" value='<?php echo sprintf"%.0f"$sys2->personalAllowance ?>' name="pa"/>
           <?php
               
if( array_key_exists'pa'$invalid )){
                  echo 
'<br/><span class="error">'.$invalid['pa']."</span>\n";
               }
            
?>   
        </td>
        <td align="right">Income Tax Basic Rate</td>
        <td align="left">
            <input size="4" type="text" value='<?php echo sprintf"%.0f"$sys2->itRates[1] ) ?>' name="br"/>
            <?php
               
if( array_key_exists'br'$invalid )){
                  echo 
'<br/><span class="error">'.$invalid['br']."</span>\n";
               }
            
?>
        </td>
      </tr>
      <tr class="tableRowOdd" >
        <td align="right">VAT Standard Rate</td>
        <td align="left">
            <input size="4" type="text" value='<?php echo sprintf"%.1f"$sys2->vatStd ?>' name="vat"/>
            <?php
               
if( array_key_exists'vat'$invalid )){
                  echo 
'<br/><span class="error">'.$invalid['vat']."</span>\n";
               }
            
?>       
        </td>
        <td align="right">Base Rate of Interest</td>
        <td align="left">
           <input size="4" type="text" value='<?php echo sprintf"%.2f"$sys2->macro->baseRate ?>' name="base"/>
           <?php
               
if( array_key_exists'base'$invalid )){
                  echo 
'<br/><span class="error">'.$invalid['base']."</span>\n";
               }
            
?>     
         </td>
      </tr>
      <tr class="tableRowEven">
        <td colspan="4" align="left">
        <table>
            <tr>
                <td>Run the Model</td><td>
                <input type="submit" name="Submit" value="Submit"/></td>
                <td>...reset everything on this page</td>
                <td><input type="reset" value="Reset"/></td>
                <td>.. or set everthing back to defaults</td>
                <td><input name="Defaults" type="submit" value="Defaults"/></td>
             </tr>
          </table>
          </td>
      </tr>
     
    </tbody>
    </table>
   </form>
  
 </div>

  <?php echo drawFooter'quick'); ?>
</div>
   <?php echo drawLHSArea( ); ?>

</body>
</html>