Created
August 17, 2020 16:44
-
-
Save Pross/192abd46cde729109854409295596e60 to your computer and use it in GitHub Desktop.
examples:[form1]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_shortcode( 'form1', function( $atts ) { | |
$rst = ( isset( $atts['rst'] ) ) ? $atts['rst'] : '9.00'; | |
$msp = ( isset( $atts['msp'] ) ) ? $atts['msp'] : '16.00'; | |
ob_start(); | |
?> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-route.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-resource.js"></script> | |
<div id="rst_calc_main" ng-app="rstApp" ng-controller="rstCtrl"> | |
<div class="table-responsive"></div> | |
<table class="table table-responsiv tripcal"> | |
<thead> | |
<tr> | |
<th class="col-md-3"><span class="hidden">Header</span></th> | |
<th class="col-md-3">To + From RST</th> | |
<th class="col-md-3">To + From MSP</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr class="airfare"> | |
<td class="text-right">Input your Airfare</td> | |
<td class="bg_1r col1"><label class="hidden" for="to_rst">To RST</label><input ng-model="calculator.airfare.rst" class="form-control" type="number" min="0" max="99999" step="0.01" id="to_rst" value="100" /></td> | |
<td class="bg_1g col2"><label class="hidden" for="to_msp">To MSP</label><input ng-model="calculator.airfare.msp" class="form-control" type="number" min="0" max="99999" step="0.01" id="to_msp" value="100" /></td> | |
</tr> | |
<tr class="mileage"> | |
<td class="text-right">Mileage</td> | |
<td class="bg_2r col1">$0.00</td> | |
<td class="bg_2g col2">{{calculator.distance * calculator.mileage | currency}}</td> | |
</tr> | |
<tr class="traveltime"> | |
<td class="text-right">Travel Time</td> | |
<td class="bg_3r col1">$0.00</td> | |
<td class="bg_3g col2">{{calculator.distance / 65 * calculator.hourly | currency}}</td> | |
</tr> | |
<tr class="parkeing"> | |
<td class="text-right">How Many Days Parking</td> | |
<td class="bg_4r col1"><label class="hidden" for="formctrl1">Parking Days RST</label><input type="number" min="1" max="999" class="form-control" id="formctrl1" value="5" ng-model="calculator.parking_days.rst"></td> | |
<td class="bg_4g col2"><label class="hidden" for="formctrl2">Parking Days MSP</label><input type="number" min="1" max="999" class="form-control" id="formctrl2" value="5" ng-model="calculator.parking_days.msp"></td> | |
</tr> | |
<tr class="totalcost"> | |
<td class="text-right">Estimated Total Cost</td> | |
<td class="bg_5r col1">{{calculator.total('rst') | currency}}</td> | |
<td class="bg_5g col2">{{calculator.total('msp') | currency}}</td> | |
</tr> | |
</tbody> | |
<tfoot> | |
<tr> | |
<td colspan="3" class="notes"> | |
<p>Mileage based on {{calculator.distance}} miles round-trip to MSP at the 2019 IRS rate of {{calculator.mileage | currency}}/mile. Travel time assumes an average speed of 65 miles per hour and is valued at {{calculator.hourly | currency}}/hr. Parking rates are based on $9/day for 1-6 days (free on the 7th day) at RST and $16/day at MSP (Value lot, regular rate).</p> | |
<p> <a style="cursor: pointer;" ng-click="calculator.show_options = true">Change these values</a></p> | |
</td> | |
</tr> | |
</tfoot> | |
</table> | |
<div ng-show="calculator.show_options"> | |
<fieldset> | |
<legend>Calculator Options</legend> | |
<table> | |
<tr> | |
<td colspan="2">Enter Mileage Value (default {{calculator.mileage | currency}}):</td> | |
<td><label class="hidden" for="mileage">Mileage</label><input ng-model="calculator.mileage" id="mileage" type="number" min="0" max="9999" step="0.01" class="form-control input-sm"></td> | |
</tr> | |
<tr> | |
<td colspan="2">Enter Hourly Rate (default 20.00):</td> | |
<td> | |
<label class="hidden" for="hourly">Hourly</label><input ng-model="calculator.hourly" id="hourly" type="number" min="0" max="9999" step="0.01" class="form-control input-sm"> | |
</td> | |
</tr> | |
<tr> | |
<td colspan="2">Distance in roundtrip miles between airports (default 170 miles):</td> | |
<td> | |
<label class="hidden" for="distance">Distance</label><input ng-model="calculator.distance" id="distance" type="number" min="0" max="9999" step="1" class="form-control input-sm"> | |
</td> | |
</tr> | |
<tr> | |
<td colspan="2"><strong>Enter Daily Parking Rates:</strong></td> | |
<td></td> | |
</tr> | |
<tr> | |
<td></td> | |
<td>RST (default $9.00):</td> | |
<td><label class="hidden" for="parking">Parking RST</label><input ng-model="calculator.parking.rst" id="parking" type="number" min="0" max="9999" step="0.01" class="form-control input-sm"></td> | |
</tr> | |
<tr> | |
<td></td> | |
<td>MSP (default $16.00):</td> | |
<td><label class="hidden" for="parkingmsp">Parking MSP</label><input ng-model="calculator.parking.msp" id="parkingmsp" type="number" min="0" max="9999" step="0.01" class="form-control input-sm"></td> | |
</tr> | |
</table> | |
<p class="notes"><a href="#" ng-click="calculator.show_options = false" class="btn btn-default btn-success">Close Options</a></p> | |
</fieldset> | |
</div> | |
</div> | |
<script> | |
angular.module('rstApp', []) | |
.controller('rstCtrl', ['$scope', function($scope){ | |
$scope.calculator = { | |
mileage: 0.58, | |
hourly: 20.00, | |
distance: 170, | |
parking: { | |
rst: <?php echo $rst; ?>, | |
msp: <?php echo $msp; ?> | |
}, | |
parking_days: { | |
rst: 5, | |
msp: 5 | |
}, | |
airfare: { | |
rst: 200.00, | |
msp: 200.00 | |
}, | |
total: function(which){ | |
if (which == 'rst'){ | |
var parking_cost = this.parking_days.rst * (+this.parking.rst) - (Math.floor(this.parking_days.rst / 7) * this.parking.rst); | |
return (parking_cost) + (+this.airfare.rst); | |
} | |
if (which == 'msp'){ | |
var parking_cost = this.parking_days.msp * (+this.parking.msp); | |
return (parking_cost) + (this.distance * +this.mileage) + ((this.distance * +1/65) * +this.hourly) + (+this.airfare.msp); | |
} | |
return 0; | |
}, | |
show_options: false | |
}; | |
}]); | |
</script> | |
<?php | |
return ob_get_clean(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment