| Linux premium274.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64 Path : /home/whagcoha/mos.bacohtcc.com/ |
| Current File : /home/whagcoha/mos.bacohtcc.com/adsolar.php |
<?php
if ((!isset($_SESSION['gen256'])) ) {
echo "<script>
window.open('login.php','_self');
</script>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Advanced Solar Calculator</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
</head>
<body class="bg-light">
<div class="container mt-4">
<h3 class="mb-4">Solar Installation Calculator</h3>
<div class="card mb-4">
<div class="card-body">
<h5>Add Appliances</h5>
<div class="row">
<div class="col-md-3">
<input type="text" id="appliance" class="form-control" placeholder="Appliance">
</div>
<div class="col-md-2">
<input type="number" id="watts" class="form-control" placeholder="Watts">
</div>
<div class="col-md-2">
<input type="number" id="qty" class="form-control" placeholder="Qty">
</div>
<div class="col-md-2">
<input type="number" id="hours" class="form-control" placeholder="Hours/day">
</div>
<div class="col-md-3">
<button class="btn btn-success w-100" onclick="addAppliance()">Add Appliance</button>
</div>
</div>
</div>
</div>
<div class="card mb-4">
<div class="card-body">
<table class="table table-bordered">
<thead>
<tr>
<th>Appliance</th>
<th>Watts</th>
<th>Qty</th>
<th>Hours</th>
<th>Daily Wh</th>
</tr>
</thead>
<tbody id="applianceTable"></tbody>
</table>
</div>
</div>
<div class="card mb-4">
<div class="card-body">
<div class="row">
<div class="col-md-3">
<label>Battery Voltage</label>
<select id="voltage" class="form-control">
<option value="12">12V</option>
<option value="24">24V</option>
<option value="48">48V</option>
</select>
</div>
<div class="col-md-3">
<label>Battery Size (Ah)</label>
<input type="number" id="batteryAh" class="form-control" value="200">
</div>
<div class="col-md-3">
<label>Panel Watt</label>
<input type="number" id="panelW" class="form-control" value="550">
</div>
<div class="col-md-3">
<label>Battery Type</label>
<select id="batteryType" class="form-control">
<option value="0.5">Lead Acid</option>
<option value="0.9">Lithium</option>
</select>
</div>
</div>
<br>
<button class="btn btn-primary w-100" onclick="calculateSystem()">Calculate System</button>
</div>
</div>
<div class="card">
<div class="card-body">
<h5>Results</h5>
<p>Total Load: <b id="totalLoad"></b></p>
<p>Daily Energy Use: <b id="dailyEnergy"></b></p>
<p>Recommended Inverter Size: <b id="inverter"></b></p>
<p>Battery Capacity Needed: <b id="batteryCapacity"></b></p>
<p>Number of Batteries: <b id="batteryCount"></b></p>
<p>Solar Panel Capacity: <b id="panelCapacity"></b></p>
<p>Number of Panels: <b id="panelCount"></b></p>
<p>Battery Wiring Suggestion: <b id="batteryWiring"></b></p>
<button class="btn btn-dark" onclick="generatePDF()">Generate Quotation PDF</button>
</div>
</div>
</div>
<script>
let appliances = [];
function addAppliance(){
let name = document.getElementById("appliance").value;
let watts = Number(document.getElementById("watts").value);
let qty = Number(document.getElementById("qty").value);
let hours = Number(document.getElementById("hours").value);
let energy = watts * qty * hours;
appliances.push({name, watts, qty, hours, energy});
renderTable();
}
function renderTable(){
let table = document.getElementById("applianceTable");
table.innerHTML = "";
appliances.forEach(a => {
table.innerHTML += `
<tr>
<td>${a.name}</td>
<td>${a.watts}</td>
<td>${a.qty}</td>
<td>${a.hours}</td>
<td>${a.energy}</td>
</tr>
`;
});
}
function calculateSystem(){
let voltage = Number(document.getElementById("voltage").value);
let batteryAh = Number(document.getElementById("batteryAh").value);
let panelW = Number(document.getElementById("panelW").value);
let dod = Number(document.getElementById("batteryType").value);
let totalLoad = 0;
let dailyEnergy = 0;
appliances.forEach(a=>{
totalLoad += a.watts * a.qty;
dailyEnergy += a.energy;
});
let inverter = totalLoad * 1.25;
let batteryWh = voltage * batteryAh;
let batteryNeededWh = dailyEnergy / dod;
let batteryCount = batteryNeededWh / batteryWh;
let solarRequired = dailyEnergy * 1.3;
let panelCount = solarRequired / panelW;
document.getElementById("totalLoad").innerText = totalLoad + " W";
document.getElementById("dailyEnergy").innerText = dailyEnergy + " Wh ("+(dailyEnergy/1000).toFixed(2)+" kWh)";
document.getElementById("inverter").innerText = Math.ceil(inverter)+" W";
document.getElementById("batteryCapacity").innerText = Math.ceil(batteryNeededWh)+" Wh";
document.getElementById("batteryCount").innerText = Math.ceil(batteryCount);
document.getElementById("panelCapacity").innerText = Math.ceil(solarRequired)+" W";
document.getElementById("panelCount").innerText = Math.ceil(panelCount);
let wiring = "";
if(voltage==12) wiring = "Parallel battery connection";
if(voltage==24) wiring = "2 batteries in series per bank";
if(voltage==48) wiring = "4 batteries in series per bank";
document.getElementById("batteryWiring").innerText = wiring;
}
function generatePDF(){
const { jsPDF } = window.jspdf;
let doc = new jsPDF();
doc.text("Solar Installation Quote",20,20);
let y = 40;
appliances.forEach(a=>{
doc.text(`${a.name} - ${a.watts}W x${a.qty}`,20,y);
y += 10;
});
doc.save("solar_quote.pdf");
}
</script>
</body>
</html>