Support start and end date on prices

This commit is contained in:
Gunnar Skjold
2024-01-06 18:58:50 +01:00
parent bad107926c
commit 48ab87ba50
7 changed files with 130 additions and 54 deletions

View File

@@ -1145,7 +1145,11 @@ void AmsWebServer::priceConfigJson() {
p.direction,
days.c_str(),
hours.c_str(),
p.value / 100.0,
p.value / 10000.0,
p.start_month,
p.start_dayofmonth,
p.end_month,
p.end_dayofmonth,
i == pc.size()-1 ? "" : ","
);
server.sendContent(buf);
@@ -1717,7 +1721,7 @@ void AmsWebServer::handleSave() {
snprintf_P(buf, BufferSize, PSTR("rd%d"), i);
pc.direction = server.arg(buf).toInt();
snprintf_P(buf, BufferSize, PSTR("rv%d"), i);
pc.value = server.arg(buf).toFloat() * 100;
pc.value = server.arg(buf).toFloat() * 10000;
snprintf_P(buf, BufferSize, PSTR("rn%d"), i);
String name = server.arg(buf);
strcpy(pc.name, name.c_str());
@@ -1746,6 +1750,18 @@ void AmsWebServer::handleSave() {
h++;
}
snprintf_P(buf, BufferSize, PSTR("rsm%d"), i);
pc.start_month = server.arg(buf).toInt();
snprintf_P(buf, BufferSize, PSTR("rsd%d"), i);
pc.start_dayofmonth = server.arg(buf).toInt();
snprintf_P(buf, BufferSize, PSTR("rem%d"), i);
pc.end_month = server.arg(buf).toInt();
snprintf_P(buf, BufferSize, PSTR("red%d"), i);
pc.end_dayofmonth = server.arg(buf).toInt();
ps->setPriceConfig(i, pc);
}
ps->save();