[Solved] PHP Script within CMS Made Simple?
Posted: Tue Aug 03, 2010 11:31 pm
We have a simple script that I wrote that performs an estimate bill calculation. Is there a way to get this snippet of PHP in a page in CMS Made Simple?
Example can be found at: http://wcecnet.net/viewpage.php?page_id=6
The code is below:
Any ideas or help would be greatly appreciated to help get us ported over to CMSMS.
Example can be found at: http://wcecnet.net/viewpage.php?page_id=6
The code is below:
Code: Select all
<?PHP
include("rate_factors.php");
$beginrdg = isset($_POST['begin_rdg']) ? $_POST['begin_rdg'] : "";
$endrdg = isset($_POST['end_rdg']) ? $_POST['end_rdg'] : "";
?>
<style type="text/css">
<!--
.style2 {font-size: 10px}
-->
</style>
<br><br>
<table width=650 align=center><tr><td colspan=2 class=style2><b><font color=red>The following form is used to give an estimated bill based on meter readings you provide. It will present to you an estimate of what your bill may be, and should not be used as an actual statement. The calculation factors for upcoming months are normally updated near the 15th of each month. If you are receiving any additional services you must add these as well as any applicable taxes.</font> </b><br><br></td></tr><tr><td valign=top class=style2><a href=viewpage.php?page_id=7> Click here to Calculate Small General Service Rates</a><br><br><br><br>
<b>Residential Rates: </b> Current as of <? $today_month1 = date ("n-d-Y", mktime(0, 0, 0, date("m"), date("d"), date("Y")));
echo $today_month1; ?>:<br>
<form action="<? echo $_SERVER['../PHP_SELF'] ?>" method="POST" class="style2">
Current Reading:   <input type="text" name="end_rdg" value ="<?PHP echo $endrdg; ?>"><br><br>
Previous Reading: <input type="text" name="begin_rdg" value="<?PHP echo $beginrdg; ?>">
<br><br>
<input name="securitylight" type="checkbox" id="securitylight" value="<?php echo $sl; ?>">
Security Light
<br>
<input name="lmwh" type="checkbox" id="lmwh" value="<?php echo $lmwh; ?>">
Load Management (Water Heater)
<br>
<input name="lmac" type="checkbox" id="lmac" value="<?php echo $lmac; ?>">
Load Management (Air Conditioning or Heat)
<br><br>
<input type="submit" name="submit" value="submit">
<input type="reset">
</form>
</td>
<td class="style2" align=center>
<?php
if (isset($_POST['submit']))
{
$res_kwh = $endrdg - $beginrdg;
$lmwh = $_REQUEST['lmwh'];
$lmac = $_REQUEST['lmac'];
$totallm = $lmwh + $lmac;
$res_gcrf = $res_kwh * $res_gcrfvalue;
$res_gen = $res_kwh * $res_generation;
$res_totalgen = $res_gen + $res_gcrf + $totallm;
$res_genkwh = $res_totalgen / $res_kwh;
$sl = $_REQUEST['securitylight'];
$res_totaltdcrf = $res_kwh * $res_tdcrf;
$res_trans = $res_kwh * $res_transmission;
$res_totaltrans = $res_trans + $res_totaltdcrf;
$res_transkwh = $res_trans / $res_kwh;
$res_netkwh = $res_kwh - $res_kwhgiven;
$res_overkwh = $res_netkwh * $res_wcecover;
$res_underkwh = $res_kwhgiven * $res_wcecunder;
$res_totalwcec = $res_overkwh + $res_underkwh + $res_customercharge;
$res_total = $res_totalgen + $res_totaltrans + $res_totalwcec + $sl;
$res_lesssl = $res_totalgen + $res_totaltrans + $res_totalwcec;
$res_kwhcost = $res_lesssl / $res_kwh;
$res_wceckwh = $res_totalwcec / $res_kwh;
?>
<div id=billingblock style="display:">
<?
echo "Your total KWH:<b>\n ". sprintf("%.02f", $res_kwh) . "<br><br></b>\n";
echo "GCRF: \$ ". sprintf("%.02f", $res_gcrf) . "<br>\n";
echo "Generation: \$ ". sprintf("%.02f", $res_gen) . "<br>\n";
echo "Load Management Credit: \$ ". sprintf("%.02f", $totallm) . "<br>\n";
echo "<u>Generation / kwh: \n $ ". sprintf("%.03f", $res_genkwh) . "<br></u>\n";
echo "Total Generation: <b>\n $ ". sprintf("%.02f", $res_totalgen) . "<br></b><br><br>\n";
echo "TDCRF: \$ ". sprintf("%.02f", $res_totaltdcrf) . "<br>\n";
echo "Transmission: \$ ". sprintf("%.02f", $res_trans) . "<br>\n";
echo "<u>Transmission / kwh: \n $ ". sprintf("%.03f", $res_transkwh) . "<br></u>\n";
echo "Total Transmission: <b>\n \$ ". sprintf("%.02f", $res_totaltrans) . "<br><br></b>\n";
echo "Charge for 475 kwh: \$ ". sprintf("%.02f", $res_underkwh) . "<br>\n";
echo "Charge for kwh over 475: \$ ". sprintf("%.02f", $res_overkwh) . "<br>\n";
echo "Customer Charge: \$ ". sprintf("%.02f", $res_customercharge) . "<br>\n";
echo "<u>WCEC / kwh: \n\$ ". sprintf("%.03f", $res_wceckwh) . "<br></u>\n";
echo "Total WCEC Charge: <b>\n\$ ". sprintf("%.02f", $res_totalwcec) . "<br><br></b>\n";
echo "Security Light: \$ ". sprintf("%.02f", $sl) . "<br><br>\n";
echo "Your Final Bill Estimate: <b><u>\n \$ ". sprintf("%.02f", $res_total) . "<br><br></u></b>\n";
echo "Total cost / kwh: <b>\n \$ ". sprintf("%.03f", $res_kwhcost) . "<br><br></b>\n";
}
?>
<__script__ language='javascript'> function SwitchMember(myObj){ if (myObj.checked){ document.getElementById('billingblock').style.display="none";
}else{
document.getElementById('billingblockmember').style.display="none";
} }</__script>
<?
if (isset($_POST['submit'])) {
echo "<br><br><input type=checkbox name=member style=\"position:relative; left:2px; top:4px\" onClick='SwitchMember(this)';> Clear Output ";
} ?>
</div>
<div id=billingblockmember style="display:">
</td></tr>
</table><br><br>