<?php
# entry include for invoice app
?>
<p><hr><H1 align="center"><font color="red"><i>Invoice Entry Screen</i></font></H1>


<form action="invoice.php" method="POST" enctype="text">

<?php
# date and invoice number
?>
<big><b>Date and Invoice Information</b></big><br>
<table cols=2>
  <tr>
    <td><b>Date:</b>&nbsp;
      <input type="text" name="month" value="<?php echo $month; ?>" size=2>
      <input type="text" name="day" value="<?php echo $day; ?>" size=2>
      <input type="text" name="year" value="<?php echo $year; ?>" size=4>
    </td>
    <td><b>Transaction type:</b>

      <?php
      # radio selection carried over from previous screen
      switch($transaction)
      {
        case 'Invoice':
          $invoicechecked = 'checked';
          break;
        case 'Estimate':
          $estimatechecked = 'checked';
          break;
        case 'Proposal':
          $proposalchecked = 'checked';
          break;
      };
      ?>
      &nbsp;<input type=radio name="transaction" <?php echo $invoicechecked ?> value="Invoice"> Invoice
      &nbsp;<input type=radio name="transaction" <?php echo $estimatechecked ?> value="Estimate"> Estimate
      &nbsp;<input type=radio name="transaction" <?php echo $proposalchecked ?> value="Proposal"> Proposal
    </td>
  </tr>
  <tr>
    <td><input type=checkbox name="today" value="true"> The work is being completed today. </td>
    <td_&nbsp;  </td>
  </tr>
    <tr>
    <td>&nbsp;  </td>
    <td>&nbsp;  </td>
  </tr>
  <tr>
    <td><b>Invoice Number:</b>&nbsp;
    <input type="text" name="invoicenumber" value="<?php echo $invoicenumber?>" size=8>  </td>
    <td>  </td>
</table>

<?php
#
# company info
?>
<p><big><b>Company Information</b></big><br>
<table>
  <tr>
    <td><b>Company Name:</b> </td>
    <td><input type="text" name="company" size=30 value="<?php echo $company; ?>">  </td>
    <td><b>Job Number / Purchase Order:</b>  </td>
    <td><input type="text" name="jobnumber"  value="<?php echo $jobnumber; ?>">  </td>
  </tr>
  <tr>
    <td><b>Street:</b>  </td>
    <td><input type="text" name="street" size=30 value="<?php echo $street; ?>">  </td>
    <td><b>Location / Store Number:</b>  </td>
    <td><input type="text" name="location"  value="<?php echo $location; ?>">  </td>
  </tr>
  <tr>
    <td><b>Building Number:</b>  </td>
    <td><input type="text" name="building" size=10 value="<?php echo $building; ?>">  </td>
    <td>  </td>
    <td>  </td>
  </tr>
  <tr>
    <td><b>Suite:</b>  </td>
    <td><input type="text" name="suite" size=10 value="<?php echo $suite; ?>">  </td>
    <td>  </td>
    <td>  </td>
  </tr>
  <tr>
    <td><b>City:</b>  </td>
    <td><input type="text" name="city" size=30 value="<?php echo $city; ?>">  </td>
    <td>  </td>
    <td>  </td>
  </tr>
  <tr>
    <td><b>State:</b>  </td>
    <td><input type="text" name="state" size=2 value="<?php echo $state; ?>">  </td>
    <td>  </td>
    <td>  </td>
  </tr>
  <tr>
    <td><b>Zip Code:</b>  </td>
    <td><input type="text" name="zip" size=7 value="<?php echo $zip; ?>">  </td>
    <td>  </td>
    <td>  </td>
  </tr>
  <tr>
    <td><b>Attention:</b>  </td>
    <td><input type="text" name="attention" size=30 value="<?php echo $attention; ?>">  </td>
    <td>  </td>
    <td>  </td>
  </tr>
  <tr>
    <td><b>Phone Number:</b>  </td>
    <td>(&nbsp;<input type="text" name="phonearea" size=3 value="<?php echo $phonearea; ?>">&nbsp;)&nbsp;
    <input type="text" name="phonex" size=3 value="<?php echo $phonex; ?>">&nbsp;&nbsp;-&nbsp;
    <input type="text" name="phonedigits" size=4 value="<?php echo $phonedigits; ?>">  </td>
    <td>  </td>
    <td>  </td>
  </tr>
  <tr>
    <td><b>Fax:</b>  </td>
    <td>(&nbsp;<input type="text" name="faxarea" size=3 value="<?php echo $faxarea; ?>">&nbsp;)&nbsp;
    <input type="text" name="faxex" size=3 value="<?php echo $faxex; ?>">&nbsp;&nbsp;-&nbsp;
    <input type="text" name="faxdigits" size=4 value="<?php echo $faxdigits; ?>">  </td>
    <td>  </td>
    <td>  </td>
  </tr>
</table>

<?php
# problem and work performed
#
# let's get rid of the slashes here so I don't have to do it twice below
$problem = stripslashes($problem);
$work = stripslashes($work);
?>
<p><big><b>Problem Reported</big></b>
<br><textarea name="problem" value="<?php echo $problem; ?>" cols="80" rows="5"><?php echo $problem; ?></textarea>

<p><big><b>Description of work performed</big></b>
<br><textarea name="work" value="<?php echo $work; ?>" cols="80" rows="5"><?php echo $work; ?></textarea>

<br><b>Technician:</b> <input type="tech" name="tech" value="<?php echo $tech; ?>">

<?php
# materials used
# need an array here
# also need mechanism to add more fields if needed (check box)
?>
<p><big><b>Materials Used</big></b>
<table BORDER WIDTH="100%">
  <tr>
    <th>
      Quantity
    </td>
    <th>
      Item
    </td>
    <th>
      Unit Price
    </td>
    <th>
      Extended Price
    </td>
  </tr>

  <?php
  # loop places parts into an array
  for ($item=1; $item <= 20; $item++) {
    echo "
    <tr>
      <td><div align=center><input type=\"text\" name=\"parts[quantity][$item]\"
        size=4 value=\"" . $parts["quantity"][$item] . "\"></div>  </td>
      <td><div align=left><input type=\"text\" name=\"parts[description][$item]\"
        size=60 value=\"" . $parts["description"][$item] . "\"></div>  </td>
      <td><div align=right><input type=\"text\" name=\"parts[price][$item]\"
        size=7 value=\"" . $parts["price"][$item] . "\">  </td>
      <td><div align=right>\$" . number_format($parts["extended"][$item],2) . "</div>  </td>
    </tr>";
  }
  ?>


  <tr>
    <td><div align=center><input type="text" name="hours" size=4 value="<?php echo $hours; ?>"></div>  </td>
    <td><div align=right><b>Tier:</b>
    &nbsp;<input type=radio name="tier" <?php echo $tier1checked; ?> value="1">1
    &nbsp;<input type=radio name="tier" <?php echo $tier2checked; ?> value="2">2
    &nbsp;<input type=radio name="tier" <?php echo $tier3checked; ?> value="3">3
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;labor @ $<?php echo $rate; ?> per hour</div>  </td>

    <td><div align=right>$<?php echo number_format($rate,2); ?></div>  </td>
    <td><div align=right>$<?php echo number_format($labor,2); ?></div>  </td>
  </tr>

  <tr>
    <td>  </td>
    <td>  </td>
    <td><div align=right><b>Subtotal:</b></div>  </td>
    <td><div align=right>$<?php echo number_format($subtotal,2); ?></div>  </td>
  </tr>
  <tr>
    <td>  </td>
    <td>  </td>
    <td><div align=right><b>Sales Tax: </b><input type="text" name="taxrate" size=4 value="<?php echo $taxrate; ?>">%</div>  </td>
    <td><div align=right>$<?php echo number_format($salestax,2); ?></div>  </td>
  </tr>
  <tr>
    <td>  </td>
    <td>  </td>
     <td>
      <div align=right><b>Total:</b></div>
    </td>
    <td>
      <div align=right>$<?php echo number_format($grandtotal,2); ?></div>
    </td>
  </tr>
</table>


<p><input type=checkbox name="verified" value="true"> All data has been verified.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type=submit name="action" value="Submit">
</form>

<?php
# that's it for now
#
?>




