Advertisement
businessdad

Codeable - Basic PERT Estimate Tool

Mar 8th, 2017
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.83 KB | None | 0 0
  1. <style type="text/css">
  2.     body {
  3.         font-family: Helvetica;
  4.     }
  5.     .section {
  6.         border: 1px solid silver;
  7.         margin-bottom: 0.5em;
  8.         padding: 0 0.5em 0.5em;
  9.     }
  10.     .field {
  11.         margin-top: 0.5em;
  12.     }
  13.     .label {
  14.         display: inline-block;
  15.         width: 10em;
  16.     }
  17.     .description {
  18.         font-size: 95%;
  19.         margin-top: 4px;
  20.         margin-bottom: 0;
  21.     }
  22. </style>
  23. <script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
  24. <script type="text/javascript">
  25.     jQuery(document).ready(function($) {
  26.         function round(value, step) {
  27.             step || (step = 1.0);
  28.             var inv = 1.0 / step;
  29.             return Math.round(value * inv) / inv;
  30.         }
  31.  
  32.         $('#estimator').on('submit', function(e) {
  33.             e.stopPropagation();
  34.             var optimistic = parseFloat($('#optimistic_estimate').val());
  35.             var likely = parseFloat($('#likely_estimate').val());
  36.             var pessimistic = parseFloat($('#pessimistic_estimate').val());
  37.  
  38.             var estimate_hours = (optimistic + 4 * likely + pessimistic) / 6;
  39.             var estimate = estimate_hours * $('#hourly_rate').val();
  40.             var estimate_with_fees = estimate / (1 - ($('#contractor_fee').val() / 100));
  41.  
  42.             $('#estimate_hours').val(round(estimate_hours, 0.5));
  43.             $('#estimate').val(Math.round(estimate_with_fees * 100) / 100);
  44.             return false;
  45.         });
  46.     });
  47. </script>
  48. <h2>PERT Estimator</h2>
  49. <form id="estimator">
  50.     <div id="estimates" class="section">
  51.         <div class="field">
  52.             <span class="label">Optimistic value: </span><input id="optimistic_estimate" type="number" step="0.25" min="1" />
  53.         </div>
  54.         <div class="field">
  55.             <span class="label">Most likely value: </span><input id="likely_estimate" type="number" step="0.25" min="1" />
  56.         </div>
  57.         <div class="field">
  58.             <span class="label">Pessimistic value: </span><input id="pessimistic_estimate" type="number" step="0.25" min="1" />
  59.         </div>
  60.         <div class="field">
  61.             <span class="label">Hourly rate: </span><input id="hourly_rate" type="number" value="80" />
  62.         </div>
  63.     </div>
  64.  
  65.     <div id="fees" class="section">
  66.         <div class="field">
  67.             <span class="label">Contractor fee (%): </span><input id="contractor_fee" type="number" step="0.01" value="10" />
  68.             <p class="description">
  69.                 This fee will be added to the estimate, so that it can be passed on to the client.
  70.                 If your hourly rate already takes the Contractor Fee into account, you can set this to zero.</p>
  71.         </div>
  72.     </div>
  73.  
  74.     <div id="totals" class="section">
  75.         <div class="field">
  76.             <span class="label">PERT Estimate (hours): </span><input id="estimate_hours" type="number" value="" readonly="readonly"/>
  77.         </div>
  78.         <div class="field">
  79.             <span class="label">Estimate for client (including fees): </span><input id="estimate" type="number" value="" readonly="readonly"/>
  80.         </div>
  81.     </div>
  82.  
  83.     <button id="calculate" type="submit">Calculate</button>
  84.     <button id="reset_estimates" type="button">Reset estimates</button>
  85. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement