diff --git a/app/CoreModule/Controls/PletackaChartControl/PletackaChartControl.latte b/app/CoreModule/Component/PletackaChartControl/PletackaChartControl.latte
similarity index 100%
rename from app/CoreModule/Controls/PletackaChartControl/PletackaChartControl.latte
rename to app/CoreModule/Component/PletackaChartControl/PletackaChartControl.latte
diff --git a/app/CoreModule/Controls/PletackaChartControl/PletackaChartControl.php b/app/CoreModule/Component/PletackaChartControl/PletackaChartControl.php
similarity index 97%
rename from app/CoreModule/Controls/PletackaChartControl/PletackaChartControl.php
rename to app/CoreModule/Component/PletackaChartControl/PletackaChartControl.php
index b2b8ee5c..3f5bc7d1 100644
--- a/app/CoreModule/Controls/PletackaChartControl/PletackaChartControl.php
+++ b/app/CoreModule/Component/PletackaChartControl/PletackaChartControl.php
@@ -2,7 +2,7 @@
declare(strict_types=1);
-namespace App\CoreModule\Controls\PletackaChartControl;
+namespace App\CoreModule\Component\PletackaChartControl;
use Nette;
use App\Forms\FormFactory;
@@ -179,7 +179,7 @@ public function renderDay( string $color, string $nameType, string $state, strin
break;
case "WORK_TIME":
- //$this->template->render(__DIR__ . '/PletackaChartControl.latte');
+ //$this->template->render(__DIR__ . '/StatusBubblesControl.latte');
echo "AHOJ";
break;
@@ -218,7 +218,7 @@ public function renderDay( string $color, string $nameType, string $state, strin
//
//
// // Render
-// $this->template->render(__DIR__ . '/PletackaChartControl.latte');
+// $this->template->render(__DIR__ . '/StatusBubblesControl.latte');
//
// }
// }
diff --git a/app/CoreModule/Controls/PletackaChartControl/PletackaChartControlFactory.php b/app/CoreModule/Component/PletackaChartControl/PletackaChartControlFactory.php
similarity index 88%
rename from app/CoreModule/Controls/PletackaChartControl/PletackaChartControlFactory.php
rename to app/CoreModule/Component/PletackaChartControl/PletackaChartControlFactory.php
index 057ecb35..48fb739a 100644
--- a/app/CoreModule/Controls/PletackaChartControl/PletackaChartControlFactory.php
+++ b/app/CoreModule/Component/PletackaChartControl/PletackaChartControlFactory.php
@@ -2,9 +2,8 @@
declare(strict_types=1);
-namespace App\CoreModule\Controls\PletackaChartControl;
+namespace App\CoreModule\Component\PletackaChartControl;
-//use App\CoreModule\Controls\PletackaChartControl;
use App\CoreModule\Model\ThisSensorManager;
use App\CoreModule\Model\ThisChartManager;
use App\CoreModule\Model\WorkShiftManager;
diff --git a/app/CoreModule/Component/StatusBubbblesControl/StatusBubblesControl.latte b/app/CoreModule/Component/StatusBubbblesControl/StatusBubblesControl.latte
new file mode 100644
index 00000000..17c7a994
--- /dev/null
+++ b/app/CoreModule/Component/StatusBubbblesControl/StatusBubblesControl.latte
@@ -0,0 +1,33 @@
+{block content}
+
{$textName}
+
diff --git a/app/CoreModule/Component/StatusBubbblesControl/StatusBubblesControl.php b/app/CoreModule/Component/StatusBubbblesControl/StatusBubblesControl.php
new file mode 100644
index 00000000..1494ee27
--- /dev/null
+++ b/app/CoreModule/Component/StatusBubbblesControl/StatusBubblesControl.php
@@ -0,0 +1,210 @@
+multiSensorsManager = $multiSensorsManager;
+ $this->thisSensorManager = $thisSensorManager;
+ $this->database = $database;
+ }
+
+ public function timeRemoveFirstNull($text)
+ {
+ if($text[0] == 0)
+ {
+ return $text[1];
+ }
+ else
+ {
+ return $text;
+ }
+ }
+
+ public function humanTime(int $timeSeconds)
+ {
+ if($timeSeconds>3600)
+ {
+ return $this->timeRemoveFirstNull(gmdate("h", $timeSeconds))." hod";
+ }
+ else
+ {
+ return $this->timeRemoveFirstNull(gmdate("i", $timeSeconds))." mim";
+ }
+ }
+
+ public function getCountFinishedTodayWS(int $number, DateTime $from, string $state)
+ {
+ return $this->database->table("A".$number)->where("time>? AND state = ?", $from, $state)->count();
+ }
+
+ public function getClassName(string $sting): string
+ {
+ return "bubble-".strtolower($sting);
+ }
+
+
+
+ public function prepareBubbleBox(int $number, DateTime $from): BubblesPretty
+ {
+ if($lastEvent = $this->thisSensorManager->getLastEvent($number))
+ {
+ $lastEventState = $lastEvent->state;
+
+ if($lastEvent->time>$from)
+ {
+ if($lastEventState == TimeBox::STOP)
+ {
+ $now = new DateTime();
+ return new BubblesPretty($lastEventState,
+ $this->humanTime($now->getTimestamp() - $lastEvent->time->getTimestamp()),
+ $this->getClassName($lastEventState));
+ }
+ else
+ {
+ $finishedPairs = floor($this->getCountFinishedTodayWS($number, $from, "FINISHED")/2);
+
+ if($finishedPairs>0)
+ {
+ if($lastEventState == TimeBox::OFF)
+ {
+ return new BubblesPretty($lastEventState, $finishedPairs." p", $this->getClassName($lastEventState));
+ }
+ else
+ {
+ return new BubblesPretty($lastEventState, $finishedPairs." p", $this->getClassName("finished"));
+ }
+ }
+ else
+ {
+ return new BubblesPretty("EMPTY");
+ }
+ }
+ }
+ else
+ {
+ return new BubblesPretty("EMPTY");
+ }
+
+ }
+ else
+ {
+ return new BubblesPretty("EMPTY");
+ }
+
+ }
+
+
+
+ public function renderDay()
+ {
+
+ }
+
+ public function render(array $roomAll, string $textName)
+ {
+ $chartData = array();
+ $counter = 0;
+
+ if(date("H")<14)
+ {
+ $from = new DateTime(date("Y-m-d 0:00:00"));
+ $to = new DateTime(date("Y-m-d 14:00:00"));
+ }
+ else
+ {
+ $from = new DateTime(date("Y-m-d 14:00:00"));
+ $to = new DateTime(date("Y-m-d 23:59:59"));
+ }
+ $now = new DateTime();
+
+// $from="2020-04-24 08:00:00"; //For testing
+// $to="2020-04-24 23:00:00";
+// $now = new DateTime("2020-04-24 22:30:00");
+
+ $allSensorNumbers = $this->multiSensorsManager->getAllSensorsName();
+ $bubblesAll = array();
+ $row = 0;
+ $empty = -1;
+
+// dump(new DateTime("Y-m-d 04:00:00"));
+
+
+ foreach($roomAll as $roomRow)
+ {
+ $bubblesRow = array();
+ foreach($roomRow as $roomSensorNumber)
+ {
+
+ if(array_key_exists($roomSensorNumber, $allSensorNumbers))
+ {
+ $bubbleBox = $this->prepareBubbleBox(intval($roomSensorNumber), $from);
+ $bubbleSensor = array($roomSensorNumber => $bubbleBox);
+ }
+ else
+ {
+ $bubbleSensor = array($empty=>null);
+ $empty--;
+ }
+ $bubblesRow += $bubbleSensor;
+ }
+ $bubblesAll[$row] = $bubblesRow;
+ $row++;
+ }
+ $this->template->bubblesAll = $bubblesAll;
+ $this->template->textName = $textName;
+
+// $allSensors = $this->multiSensorsManager->getAllSensorsEvents($roomSensorsArray, $from, $to, false);
+// dump($url = $this->link("core:ahoj"));
+
+ $this->template->render(__DIR__ . '/StatusBubblesControl.latte');
+ }
+
+ public function handleClick()
+ {
+ echo "OK";
+ }
+
+}
\ No newline at end of file
diff --git a/app/CoreModule/Component/StatusBubbblesControl/StatusBubblesControlFactory.php b/app/CoreModule/Component/StatusBubbblesControl/StatusBubblesControlFactory.php
new file mode 100644
index 00000000..f556d416
--- /dev/null
+++ b/app/CoreModule/Component/StatusBubbblesControl/StatusBubblesControlFactory.php
@@ -0,0 +1,44 @@
+multiSensorsManager = $multiSensorsManager;
+ $this->thisSensorManager = $thisSensorManager;
+ $this->database = $database;
+ }
+
+ public function create()
+ {
+ return new StatusBubblesControl($this->multiSensorsManager, $this->thisSensorManager, $this->database);
+ }
+}
\ No newline at end of file
diff --git a/app/CoreModule/Component/StatusNumbersControl/StatusNumbersControl.latte b/app/CoreModule/Component/StatusNumbersControl/StatusNumbersControl.latte
new file mode 100644
index 00000000..7ce2e49a
--- /dev/null
+++ b/app/CoreModule/Component/StatusNumbersControl/StatusNumbersControl.latte
@@ -0,0 +1,16 @@
+{block content}
+
+
+
+
Upleteno
+ {$numberBox->finished} p
+
+
+
Úspěšnost
+ {$numberBox->rating}%
+
+
+
Průměrná doba stání
+ {$numberBox->stopTimeStr}
+
+
diff --git a/app/CoreModule/Component/StatusNumbersControl/StatusNumbersControl.php b/app/CoreModule/Component/StatusNumbersControl/StatusNumbersControl.php
new file mode 100644
index 00000000..3c551e39
--- /dev/null
+++ b/app/CoreModule/Component/StatusNumbersControl/StatusNumbersControl.php
@@ -0,0 +1,205 @@
+multiSensorsManager = $multiSensorsManager;
+ $this->thisSensorManager = $thisSensorManager;
+ $this->database = $database;
+ $this->databaseSelectionManager = $databaseSelectionManager;
+ }
+
+ public function timeRemoveFirstNull($text)
+ {
+ if($text[0] == 0)
+ {
+ return $text[1];
+ }
+ else
+ {
+ return $text;
+ }
+ }
+
+ public function humanTime(int $timeSeconds)
+ {
+ if($timeSeconds>3600)
+ {
+ return $this->timeRemoveFirstNull(gmdate("h", $timeSeconds))." hod";
+ }
+ else
+ {
+ return $this->timeRemoveFirstNull(gmdate("i", $timeSeconds))." mim";
+ }
+ }
+
+ public function getCountFinishedTodayWS(int $number, DateTime $from, string $state)
+ {
+ return $this->database->table("A".$number)->where("time>? AND state = ?", $from, $state)->count();
+ }
+
+ public function getClassName(string $sting): string
+ {
+ return "bubble-".strtolower($sting);
+ }
+
+
+
+ public function prepareNumberBox(array $allSenNumbers, string $workShift, DateTime $selectionFrom, DateTime $timeboxTo): NumbersPretty
+ {
+ $selectionTo = new DateTime();
+ $selectionTo->setTime($selectionTo->format("H")-1, 0);
+ // One hour between times is generated in selection
+ $timeboxFrom = new DateTime();
+ $timeboxFrom->setTime(intval($timeboxFrom->format("H")), 0);
+ $numberBox = new NumbersPretty();
+ $sensorCount = 0;
+
+ foreach ($allSenNumbers as $sensorNumber)
+ {
+ $sensorNumberData = $this->databaseSelectionManager->getSelectionData($sensorNumber, DatabaseSelectionManager::HOUR,$workShift, $selectionFrom, $timeboxTo);
+ if($sensorNumberData->t_all)
+ {
+ $numberBox->state = true;
+ $numberBox->finished += $sensorNumberData->c_FINISHED;
+ $numberBox->stopTime += $sensorNumberData->t_stop;
+ $numberBox->workTime += $sensorNumberData->t_work;
+ $numberBox->allTime += $sensorNumberData->t_all;
+
+
+ $sensorEvents = $this->thisSensorManager->getAllEvents($sensorNumber, $timeboxFrom, $timeboxTo);
+
+ if($sensorEvents)
+ {
+ $previousEvent = $this->thisSensorManager->getPreviousEvent($sensorNumber, $sensorEvents);
+ $timebox = new TimeBox($sensorEvents, $timeboxFrom, $timeboxTo);
+ $stopTime = $timebox->stopTime($previousEvent);
+ $numberBox->stopTime += $stopTime;
+ $allTime = $timebox->allTime($previousEvent);
+ $numberBox->allTime += $allTime;
+ $numberBox->workTime += $timebox->workTime($allTime, $stopTime);
+
+ $numberBox->finished += $timebox->countEvents(TimeBox::FINISHED);
+ }
+ $sensorCount++;
+ }
+ }
+
+ if($numberBox->state)
+ {
+ $numberBox->finishedCountToPairs();
+ $numberBox->divideTimeVariablesByCount($sensorCount);
+
+ $numberBox->stopTimeStr = $this->humanTime($numberBox->stopTime);
+
+ $numberBox->rating = intval(($numberBox->workTime*100)/$numberBox->allTime);
+ }
+ else
+ {
+ $numberBox->stopTimeStr = "0 min";
+ }
+
+ return $numberBox;
+ }
+
+ public function render(array $rooms, string $workShift)
+ {
+ if(date("H")<14)
+ {
+ $from = new DateTime(date("Y-m-d 0:00:00"));
+ $to = new DateTime(date("Y-m-d 14:00:00"));
+ }
+ else
+ {
+ $from = new DateTime(date("Y-m-d 14:00:00"));
+ $to = new DateTime(date("Y-m-d 23:59:59"));
+ }
+ $now = new DateTime();
+
+ $allSensorNumbers = $this->multiSensorsManager->getAllSensorsName();
+ $numbersAllUsed = array();
+
+// $from="2020-04-24 08:00:00"; //For testing
+// $to="2020-04-24 23:00:00";
+// $now = new DateTime("2020-04-24 22:30:00");
+
+ foreach ($rooms as $room) {
+ foreach($room as $roomRow)
+ {
+// $bubblesRow = array();
+ foreach($roomRow as $roomSensorNumber)
+ {
+
+ if(array_key_exists($roomSensorNumber, $allSensorNumbers))
+ {
+ array_push($numbersAllUsed, $roomSensorNumber);
+ }
+ }
+
+ }
+ }
+
+ $numbersBox = $this->prepareNumberBox($numbersAllUsed, $workShift, $from, $to);
+ $this->template->numberBox = $numbersBox;
+ $this->template->render(__DIR__ . '/StatusNumbersControl.latte');
+ }
+
+ public function handleClick()
+ {
+ echo "OK";
+ }
+
+}
\ No newline at end of file
diff --git a/app/CoreModule/Component/StatusNumbersControl/StatusNumbersControlFactory.php b/app/CoreModule/Component/StatusNumbersControl/StatusNumbersControlFactory.php
new file mode 100644
index 00000000..34dea373
--- /dev/null
+++ b/app/CoreModule/Component/StatusNumbersControl/StatusNumbersControlFactory.php
@@ -0,0 +1,51 @@
+multiSensorsManager = $multiSensorsManager;
+ $this->thisSensorManager = $thisSensorManager;
+ $this->database = $database;
+ $this->databaseSelectionManager = $databaseSelectionManager;
+ }
+
+ public function create()
+ {
+ return new StatusNumbersControl($this->multiSensorsManager, $this->thisSensorManager, $this->database, $this->databaseSelectionManager);
+ }
+}
\ No newline at end of file
diff --git a/app/CoreModule/Model/ChartManager.php b/app/CoreModule/Model/ChartManager.php
index 2b213765..fbd5d869 100644
--- a/app/CoreModule/Model/ChartManager.php
+++ b/app/CoreModule/Model/ChartManager.php
@@ -73,66 +73,66 @@ public function zeroAdd($number)
*/
public function sensorsChartData($type, $interval, $from="2000-01-01 00:00:00" , $to="2100-01-01 00:00:00")
{
-
- $first = true;
-
- $chartData = array();
- $chartDataAvg = array();
-
- $sensorsNumber = $this->multiSensorsManager->getAllSensorsName();
-// dump($allSensors = $this->multiSensorsManager->getAllSensorsEvents($sensorsNumber, $from, $to));
-
-
-
- foreach($allSensors as $number => $data)
- {
- if(!empty($data["raw"]))
- {
- $sensor = new TimeBox($data["raw"], $data["from"], $data["to"]);//Create object TimeBox
-
- if($first)
- {
- $chartData += array("SENSORS" => 1);
- $chartData += array("ALL_EVENTS" => $sensor->countEvents());
- $chartData += array(TimeBox::FINISHED => $sensor->countEvents(TimeBox::FINISHED) );
- $chartData += array(TimeBox::STOP => $sensor->countEvents(TimeBox::STOP));
- $chartData += array(TimeBox::REWORK => $sensor->countEvents(TimeBox::REWORK));
- $chartData += array(TimeBox::ON => $sensor->countEvents(TimeBox::ON));
- $chartData += array(TimeBox::OFF => $sensor->countEvents(TimeBox::OFF));
- $chartData += array("ALL_TIME" => $sensor->allTime($data["previous"]));
- $chartData += array("STOP_TIME" => $sensor->stopTime($data["previous"]));
- $chartData += array("WORK_TIME" => $sensor->workTime($data["previous"]));
- $chartData += array("AVG_STOP_TIME" => $sensor->avgStopTime($data["previous"]));
- $chartData += array("AVG_WORK_TIME" => $sensor->avgWorkTime($data["previous"]));
- $first = false;
- }
- else
- {
- $chartData["SENSORS"] += 1;
- $chartData["ALL_EVENTS"] += $sensor->countEvents();
- $chartData["ALL_EVENTS"] += $sensor->countEvents();
- $chartData[TimeBox::FINISHED] += $sensor->countEvents(TimeBox::FINISHED);
- $chartData[TimeBox::STOP] += $sensor->countEvents(TimeBox::STOP);
- $chartData[TimeBox::REWORK] += $sensor->countEvents(TimeBox::REWORK);
- $chartData[TimeBox::ON] += $sensor->countEvents(TimeBox::ON);
- $chartData[TimeBox::OFF] += $sensor->countEvents(TimeBox::OFF);
- $chartData["ALL_TIME"] += $sensor->allTime($data["previous"]);
- $chartData["STOP_TIME"] += $sensor->stopTime($data["previous"]);
- $chartData["WORK_TIME"] += $sensor->workTime($data["previous"]);
- $chartData["AVG_STOP_TIME"] += $sensor->avgStopTime($data["previous"]);
- $chartData["AVG_WORK_TIME"] += $sensor->avgWorkTime($data["previous"]);
- }
-
-
-
-// $chartData += array("" => $sensor->);
-
- echo("");
-// break;
- }
- $chartData += array("DATA" => false);
- }
- return $chartData;
+//
+// $first = true;
+//
+// $chartData = array();
+// $chartDataAvg = array();
+//
+// $sensorsNumber = $this->multiSensorsManager->getAllSensorsName();
+//// dump($allSensors = $this->multiSensorsManager->getAllSensorsEvents($sensorsNumber, $from, $to));
+//
+//
+//
+// foreach($allSensors as $number => $data)
+// {
+// if(!empty($data["raw"]))
+// {
+// $sensor = new TimeBox($data["raw"], $data["from"], $data["to"]);//Create object TimeBox
+//
+// if($first)
+// {
+// $chartData += array("SENSORS" => 1);
+// $chartData += array("ALL_EVENTS" => $sensor->countEvents());
+// $chartData += array(TimeBox::FINISHED => $sensor->countEvents(TimeBox::FINISHED) );
+// $chartData += array(TimeBox::STOP => $sensor->countEvents(TimeBox::STOP));
+// $chartData += array(TimeBox::REWORK => $sensor->countEvents(TimeBox::REWORK));
+// $chartData += array(TimeBox::ON => $sensor->countEvents(TimeBox::ON));
+// $chartData += array(TimeBox::OFF => $sensor->countEvents(TimeBox::OFF));
+// $chartData += array("ALL_TIME" => $sensor->allTime($data["previous"]));
+// $chartData += array("STOP_TIME" => $sensor->stopTime($data["previous"]));
+// $chartData += array("WORK_TIME" => $sensor->workTime($data["previous"]));
+// $chartData += array("AVG_STOP_TIME" => $sensor->avgStopTime($data["previous"]));
+// $chartData += array("AVG_WORK_TIME" => $sensor->avgWorkTime($data["previous"]));
+// $first = false;
+// }
+// else
+// {
+// $chartData["SENSORS"] += 1;
+// $chartData["ALL_EVENTS"] += $sensor->countEvents();
+// $chartData["ALL_EVENTS"] += $sensor->countEvents();
+// $chartData[TimeBox::FINISHED] += $sensor->countEvents(TimeBox::FINISHED);
+// $chartData[TimeBox::STOP] += $sensor->countEvents(TimeBox::STOP);
+// $chartData[TimeBox::REWORK] += $sensor->countEvents(TimeBox::REWORK);
+// $chartData[TimeBox::ON] += $sensor->countEvents(TimeBox::ON);
+// $chartData[TimeBox::OFF] += $sensor->countEvents(TimeBox::OFF);
+// $chartData["ALL_TIME"] += $sensor->allTime($data["previous"]);
+// $chartData["STOP_TIME"] += $sensor->stopTime($data["previous"]);
+// $chartData["WORK_TIME"] += $sensor->workTime($data["previous"]);
+// $chartData["AVG_STOP_TIME"] += $sensor->avgStopTime($data["previous"]);
+// $chartData["AVG_WORK_TIME"] += $sensor->avgWorkTime($data["previous"]);
+// }
+//
+//
+//
+//// $chartData += array("" => $sensor->);
+//
+// echo("");
+//// break;
+// }
+// $chartData += array("DATA" => false);
+// }
+// return $chartData;
}
@@ -163,219 +163,219 @@ public function sensorsChartDataAvg($chartData)
public function sensorsChartHomepage()
{
- $first = true;
- $chartData = array();
-
- if(date("H")<14)
- {
- $from = date("Y-m-d 04:00:00");
- $to = date("Y-m-d 14:00:00");
- }
- else
- {
- $from = date("Y-m-d 14:00:00");
- $to = date("Y-m-d 23:59:00");
- }
-
-
-
-
-// $from="2020-05-05 00:00:00"; //For testing
-// $to="2020-05-05 10:00:00";
-
-// $from="2020-04-24 11:03:00"; //For testing
-// $to="2020-04-24 23:00:00";
-
- $sensorsName = $this->multiSensorsManager->getAllSensorsName();
- /*dump*/($allSensors = $this->multiSensorsManager->getAllSensorsEvents($sensorsName, $from, $to));
-
- $dataOk = false;
-
- foreach($allSensors as $number => $data)
- {
- if(!empty($data["raw"]))
- {
- $dataOk = true;
-
- $sensor = new TimeBox($data["raw"], $data["from"], $data["to"]);; //Create object TimeBox
-
- if($first)
- {
- $chartData += array("DATA" => true);
- $chartData += array("SENSORS" => 1);
- $chartData += array("ALL_EVENTS" => $sensor->countEvents());
- $chartData += array(TimeBox::FINISHED => $sensor->countEvents(TimeBox::FINISHED) );
- $chartData += array(TimeBox::STOP => $sensor->countEvents(TimeBox::STOP));
- $chartData += array(TimeBox::REWORK => $sensor->countEvents(TimeBox::REWORK));
- $chartData += array(TimeBox::ON => $sensor->countEvents(TimeBox::ON));
- $chartData += array(TimeBox::OFF => $sensor->countEvents(TimeBox::OFF));
- $chartData += array("ALL_TIME" => $sensor->allTime($data["previous"]));
- $chartData += array("STOP_TIME" => $sensor->stopTime($data["previous"]));
- $chartData += array("WORK_TIME" => $sensor->workTime($data["previous"]));
- $chartData += array("AVG_STOP_TIME" => $sensor->avgStopTime($data["previous"]));
- $chartData += array("AVG_WORK_TIME" => $sensor->avgWorkTime($data["previous"]));
- $chartData += array("ALL_SENSORS" => $allSensors);
-
- $first = false;
- }
- else
- {
- $chartData["SENSORS"] += 1;
- $chartData["ALL_EVENTS"] += $sensor->countEvents();
- $chartData[TimeBox::FINISHED] += $sensor->countEvents(TimeBox::FINISHED);
- $chartData[TimeBox::STOP] += $sensor->countEvents(TimeBox::STOP);
- $chartData[TimeBox::REWORK] += $sensor->countEvents(TimeBox::REWORK);
- $chartData[TimeBox::ON] += $sensor->countEvents(TimeBox::ON);
- $chartData[TimeBox::OFF] += $sensor->countEvents(TimeBox::OFF);
- $chartData["ALL_TIME"] += $sensor->allTime($data["previous"]);
- $chartData["STOP_TIME"] += $sensor->stopTime($data["previous"]);
- $chartData["WORK_TIME"] += $sensor->workTime($data["previous"]);
- $chartData["AVG_STOP_TIME"] += $sensor->avgStopTime($data["previous"]);
- $chartData["AVG_WORK_TIME"] += $sensor->avgWorkTime($data["previous"]);
- }
-
-
-
- echo("");
-
- }
- }
-
- if(!$dataOk)
- {
- $chartData += array("DATA" => false);
- }
-
- return $chartData;
+// $first = true;
+// $chartData = array();
+//
+// if(date("H")<14)
+// {
+// $from = date("Y-m-d 04:00:00");
+// $to = date("Y-m-d 14:00:00");
+// }
+// else
+// {
+// $from = date("Y-m-d 14:00:00");
+// $to = date("Y-m-d 23:59:00");
+// }
+//
+//
+//
+//
+//// $from="2020-05-05 00:00:00"; //For testing
+//// $to="2020-05-05 10:00:00";
+//
+//// $from="2020-04-24 11:03:00"; //For testing
+//// $to="2020-04-24 23:00:00";
+//
+// $sensorsName = $this->multiSensorsManager->getAllSensorsName();
+// /*dump*/($allSensors = $this->multiSensorsManager->getAllSensorsEvents($sensorsName, $from, $to));
+//
+// $dataOk = false;
+//
+// foreach($allSensors as $number => $data)
+// {
+// if(!empty($data["raw"]))
+// {
+// $dataOk = true;
+//
+// $sensor = new TimeBox($data["raw"], new DateTime($data["from"]), new DateTime($data["to"])); //Create object TimeBox
+//
+// if($first)
+// {
+// $chartData += array("DATA" => true);
+// $chartData += array("SENSORS" => 1);
+// $chartData += array("ALL_EVENTS" => $sensor->countEvents());
+// $chartData += array(TimeBox::FINISHED => $sensor->countEvents(TimeBox::FINISHED) );
+// $chartData += array(TimeBox::STOP => $sensor->countEvents(TimeBox::STOP));
+// $chartData += array(TimeBox::REWORK => $sensor->countEvents(TimeBox::REWORK));
+// $chartData += array(TimeBox::ON => $sensor->countEvents(TimeBox::ON));
+// $chartData += array(TimeBox::OFF => $sensor->countEvents(TimeBox::OFF));
+// $chartData += array("ALL_TIME" => $sensor->allTime($data["previous"]));
+// $chartData += array("STOP_TIME" => $sensor->stopTime($data["previous"]));
+// $chartData += array("WORK_TIME" => $sensor->workTime($data["previous"]));
+// $chartData += array("AVG_STOP_TIME" => $sensor->avgStopTime($data["previous"]));
+// $chartData += array("AVG_WORK_TIME" => $sensor->avgWorkTime($data["previous"]));
+// $chartData += array("ALL_SENSORS" => $allSensors);
+//
+// $first = false;
+// }
+// else
+// {
+// $chartData["SENSORS"] += 1;
+// $chartData["ALL_EVENTS"] += $sensor->countEvents();
+// $chartData[TimeBox::FINISHED] += $sensor->countEvents(TimeBox::FINISHED);
+// $chartData[TimeBox::STOP] += $sensor->countEvents(TimeBox::STOP);
+// $chartData[TimeBox::REWORK] += $sensor->countEvents(TimeBox::REWORK);
+// $chartData[TimeBox::ON] += $sensor->countEvents(TimeBox::ON);
+// $chartData[TimeBox::OFF] += $sensor->countEvents(TimeBox::OFF);
+// $chartData["ALL_TIME"] += $sensor->allTime($data["previous"]);
+// $chartData["STOP_TIME"] += $sensor->stopTime($data["previous"]);
+// $chartData["WORK_TIME"] += $sensor->workTime($data["previous"]);
+// $chartData["AVG_STOP_TIME"] += $sensor->avgStopTime($data["previous"]);
+// $chartData["AVG_WORK_TIME"] += $sensor->avgWorkTime($data["previous"]);
+// }
+//
+//
+//
+// echo("");
+//
+// }
+// }
+//
+// if(!$dataOk)
+// {
+// $chartData += array("DATA" => false);
+// }
+//
+// return $chartData;
}
public function sensorsChartBubbles($roomSensors)
{
- $chartData = array();
- $counter = 1;
-
- if(date("H")<14)
- {
- $from = date("Y-m-d 04:00:00");
- $to = date("Y-m-d 14:00:00");
- }
- else
- {
- $from = date("Y-m-d 14:00:00");
- $to = date("Y-m-d 23:59:00");
- }
- $now = new DateTime();
-
-
-
+// $chartData = array();
+// $counter = 1;
//
-// $from="2020-04-24 08:00:00"; //For testing
-// $to="2020-04-24 23:00:00";
-// $now = new DateTime("2020-04-24 22:30:00");
-
-// $from="2020-05-05 04:00:00"; //For testing
-// $to="2020-05-05 12:29:00";
-
- $sensorsName = $this->multiSensorsManager->getAllSensorsName();
- $roomSensorsArray = array();
-
- $coulmnsCounterLive = 0;
- $coulmnsCounter = 0;
-
- foreach($roomSensors as $sensorArr)
- {
- foreach($sensorArr as $sensor)
- {
- if(array_key_exists($sensor, $sensorsName))
- {
- array_push($roomSensorsArray, $sensor);
- }
-
- $coulmnsCounterLive++;
-
- }
- if($coulmnsCounterLive>$coulmnsCounter)
- $coulmnsCounter = $coulmnsCounterLive;
- $coulmnsCounterLive = 0;
- }
-
- /*dump*/($allSensors = $this->multiSensorsManager->getAllSensorsEvents($roomSensorsArray, $from, $to, false));
- echo "";
-// dump($allSensors);
-
- foreach($allSensors as $number => $data)
- {
- $sensorData = array();
-
- if(!empty($data["raw"]))
- {
-
-
- $sensor = new TimeBox($data["raw"], $data["from"], $data["to"]); //Create object TimeBox
-
- // $sensorData += array("SENSORS" => 1);
- // $chartData += array("ALL_EVENTS" => $sensor->countEvents());
- $sensorData += array(TimeBox::FINISHED => $sensor->countEvents(TimeBox::FINISHED) );
- // $chartData += array(TimeBox::STOP => $sensor->countEvents(TimeBox::STOP));
- // $chartData += array(TimeBox::REWORK => $sensor->countEvents(TimeBox::REWORK));
- // $chartData += array(TimeBox::ON => $sensor->countEvents(TimeBox::ON));
- // $chartData += array(TimeBox::OFF => $sensor->countEvents(TimeBox::OFF));
-// $chartData += array("ALL_TIME" => $sensor->allTime($data["previous"])[1]);
- $sensorData += array("STOP_TIME" => $sensor->lastStopTime($now));
-// $chartData += array("WORK_TIME" => $sensor->workTime($data["previous"])[1]);
- // $chartData += array("AVG_STOP_TIME" => $sensor->avgStopTime()[1]);
- // $chartData += array("AVG_WORK_TIME" => $sensor->avgWorkTime()[1]);
-
- $sensorData += array("LAST_STATE" => $data["last"]);
-// dump($data[array_key_last($data)]);
-
-// $s = $sensor->lastStopTime($now);
- echo"";
-
- }
- else
- {
- $sensorData += array(TimeBox::FINISHED => 0);
- $sensorData += array("STOP_TIME" => 0);
- $sensorData += array("LAST_STATE" => "OFF");
- }
- $sensorData += array("COUNTER" => $counter);
- $sensorData += array("COLUMN" => $coulmnsCounter);
- $sensorData += array("VISIBILITY" => "VISIBLY");
- $counter++;
-
- $chartData += array($number => $sensorData);
- }
-
-
- $sortChartData = array();
-
- $invisibleCounter = -1;
-
-
- foreach($roomSensors as $positionArr)
- {
- foreach($positionArr as $position)
- {
-
- if(array_key_exists($position, $chartData))
- {
- $sortChartData += array($position => $chartData[$position]);
- }
- else
- {
- $sortChartData += array($invisibleCounter => array("VISIBILITY" => "HIDDEN"));
- $sortChartData[$invisibleCounter] += array("COLUMN" => "12");
- $invisibleCounter--;
- }
-
-// $sortChartData += array($position => array("COLUMN" => $coulmnsCounter));
-
- }
- }
- return $sortChartData;
+// if(date("H")<14)
+// {
+// $from = new DateTime(date("Y-m-d 04:00:00"));
+// $to = new DateTime(date("Y-m-d 14:00:00"));
+// }
+// else
+// {
+// $from = new DateTime(date("Y-m-d 14:00:00"));
+// $to = new DateTime(date("Y-m-d 23:59:00"));
+// }
+// $now = new DateTime();
+//
+//
+//
+////
+//// $from="2020-04-24 08:00:00"; //For testing
+//// $to="2020-04-24 23:00:00";
+//// $now = new DateTime("2020-04-24 22:30:00");
+//
+//// $from="2020-05-05 04:00:00"; //For testing
+//// $to="2020-05-05 12:29:00";
+//
+// $sensorsName = $this->multiSensorsManager->getAllSensorsName();
+// $roomSensorsArray = array();
+//
+// $coulmnsCounterLive = 0;
+// $coulmnsCounter = 0;
+//
+// foreach($roomSensors as $sensorArr)
+// {
+// foreach($sensorArr as $sensor)
+// {
+// if(array_key_exists($sensor, $sensorsName))
+// {
+// array_push($roomSensorsArray, $sensor);
+// }
+//
+// $coulmnsCounterLive++;
+//
+// }
+// if($coulmnsCounterLive>$coulmnsCounter)
+// $coulmnsCounter = $coulmnsCounterLive;
+// $coulmnsCounterLive = 0;
+// }
+//
+// /*dump*/($allSensors = $this->multiSensorsManager->getAllSensorsEvents($roomSensorsArray, $from, $to, false));
+// echo "";
+//// dump($allSensors);
+//
+// foreach($allSensors as $number => $data)
+// {
+// $sensorData = array();
+//
+// if(!empty($data["raw"]))
+// {
+//
+//
+// $sensor = new TimeBox($data["raw"], $data["from"], $data["to"]); //Create object TimeBox
+//
+// // $sensorData += array("SENSORS" => 1);
+// // $chartData += array("ALL_EVENTS" => $sensor->countEvents());
+// $sensorData += array(TimeBox::FINISHED => $sensor->countEvents(TimeBox::FINISHED) );
+// // $chartData += array(TimeBox::STOP => $sensor->countEvents(TimeBox::STOP));
+// // $chartData += array(TimeBox::REWORK => $sensor->countEvents(TimeBox::REWORK));
+// // $chartData += array(TimeBox::ON => $sensor->countEvents(TimeBox::ON));
+// // $chartData += array(TimeBox::OFF => $sensor->countEvents(TimeBox::OFF));
+//// $chartData += array("ALL_TIME" => $sensor->allTime($data["previous"])[1]);
+// $sensorData += array("STOP_TIME" => $sensor->lastStopTime($now));
+//// $chartData += array("WORK_TIME" => $sensor->workTime($data["previous"])[1]);
+// // $chartData += array("AVG_STOP_TIME" => $sensor->avgStopTime()[1]);
+// // $chartData += array("AVG_WORK_TIME" => $sensor->avgWorkTime()[1]);
+//
+// $sensorData += array("LAST_STATE" => $data["last"]);
+//// dump($data[array_key_last($data)]);
+//
+//// $s = $sensor->lastStopTime($now);
+// echo"";
+//
+// }
+// else
+// {
+// $sensorData += array(TimeBox::FINISHED => 0);
+// $sensorData += array("STOP_TIME" => 0);
+// $sensorData += array("LAST_STATE" => "OFF");
+// }
+// $sensorData += array("COUNTER" => $counter);
+// $sensorData += array("COLUMN" => $coulmnsCounter);
+// $sensorData += array("VISIBILITY" => "VISIBLY");
+// $counter++;
+//
+// $chartData += array($number => $sensorData);
+// }
+//
+//
+// $sortChartData = array();
+//
+// $invisibleCounter = -1;
+//
+//
+// foreach($roomSensors as $positionArr)
+// {
+// foreach($positionArr as $position)
+// {
+//
+// if(array_key_exists($position, $chartData))
+// {
+// $sortChartData += array($position => $chartData[$position]);
+// }
+// else
+// {
+// $sortChartData += array($invisibleCounter => array("VISIBILITY" => "HIDDEN"));
+// $sortChartData[$invisibleCounter] += array("COLUMN" => "12");
+// $invisibleCounter--;
+// }
+//
+//// $sortChartData += array($position => array("COLUMN" => $coulmnsCounter));
+//
+// }
+// }
+// return $sortChartData;
}
diff --git a/app/CoreModule/Model/DatabaseSelectionManager.php b/app/CoreModule/Model/DatabaseSelectionManager.php
index 4752a741..eecf62c7 100644
--- a/app/CoreModule/Model/DatabaseSelectionManager.php
+++ b/app/CoreModule/Model/DatabaseSelectionManager.php
@@ -2,6 +2,7 @@
namespace App\CoreModule\Model;
+use App\Utils\DatabaseSelectionPretty;
use http\Exception;
use Nette;
use Nette\Database\Context;
@@ -227,7 +228,7 @@ public function createSelection(int $sNumber,string $selection, DateTime $from)
'workShift' => $ws,
't_stop' => $databaseOutput->t_stop,
't_work' => $databaseOutput->t_work,
-// 't_all' => $databaseOutput->t_all,
+ 't_all' => $databaseOutput->t_all,
'c_FINISHED' => $databaseOutput->c_FINISHED,
'c_STOP' => $databaseOutput->c_STOP,
]);
@@ -239,7 +240,7 @@ public function createSelection(int $sNumber,string $selection, DateTime $from)
$this->database->table($dbSelectionName)->where("time = ?", $from)->update([
't_stop' => $databaseOutput->t_stop,
't_work' => $databaseOutput->t_work,
-// 't_all' => $databaseOutput->t_all,
+ 't_all' => $databaseOutput->t_all,
'c_FINISHED' => $databaseOutput->c_FINISHED,
'c_STOP' => $databaseOutput->c_STOP,
]);
@@ -344,7 +345,7 @@ public function createSelections(object $sensors, string $selection, DateTime $f
return new Pretty(false, "", "No sensors");
$returnJson = array();
- $returnState = c231912a160deba03df5d6c6466234c808d203bftrue;
+ $returnState = true;
foreach ($sensors as $sensor)
{
@@ -370,6 +371,27 @@ public function createSelections(object $sensors, string $selection, DateTime $f
return new Pretty(false, $returnJson, "ERROR");
}
}
+
+
+ public function getSelectionData(int $number, string $selection, string $workShift, DateTime $from, DateTime $to): DatabaseSelectionPretty
+ {
+ $dsPretty = new DatabaseSelectionPretty($number);
+ $dsPretty->workShift = $workShift;
+
+ $dSelection = $this->database->table("A".$number."_".$selection)->where("time >= ? AND time <= ? AND workShift = ?", $from, $to, $workShift)->fetchAll();
+
+ foreach ($dSelection as $dRow)
+ {
+
+ $dsPretty->t_stop += $dRow->t_stop;
+ $dsPretty->t_work += $dRow->t_work;
+ $dsPretty->t_all += $dRow->t_all;
+ $dsPretty->c_FINISHED += $dRow->c_FINISHED;
+ $dsPretty->c_STOP += $dRow->c_STOP;
+ }
+
+ return $dsPretty;
+ }
}
diff --git a/app/CoreModule/Model/SensorsManager.php b/app/CoreModule/Model/SensorsManager.php
index d16b005b..b7f018be 100644
--- a/app/CoreModule/Model/SensorsManager.php
+++ b/app/CoreModule/Model/SensorsManager.php
@@ -145,6 +145,7 @@ public function addThisSensorSelection($sensorNumber, $selection)
workShift varchar(20) NOT NULL,
t_stop int(11) NOT NULL DEFAULT 0,
t_work int(11) NOT NULL DEFAULT 0,
+ t_all int(11) NOT NULL DEFAULT 0,
c_FINISHED int(11) NOT NULL DEFAULT 0,
c_STOP int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (id)
diff --git a/app/CoreModule/Model/ThisSensorManager.php b/app/CoreModule/Model/ThisSensorManager.php
index 90f611c7..24276df7 100644
--- a/app/CoreModule/Model/ThisSensorManager.php
+++ b/app/CoreModule/Model/ThisSensorManager.php
@@ -83,13 +83,18 @@ public function getAllEvents($sNumber, $from="2000-01-01 00:00:00" , $to="2100-0
return $this->database->table("A".$sNumber)->where("time >=? AND time <=?", $from, $to)->fetchAll();
}
- public function getPreviousEvent($sNumber, $events)
+ public function getPreviousEvent($sNumber, $events)
{
$previous = array_key_first($events)-1;
return $this->database->table("A".$sNumber)->where("id =?",$previous)->fetch();
}
+ public function getLastEvent(int $sNumber)
+ {
+ return $this->database->table("A".$sNumber)->order("id DESC")->fetch();
+ }
+
}
diff --git a/app/CoreModule/Presenters/HomepagePresenter.php b/app/CoreModule/Presenters/HomepagePresenter.php
index d3c271be..7038d2af 100644
--- a/app/CoreModule/Presenters/HomepagePresenter.php
+++ b/app/CoreModule/Presenters/HomepagePresenter.php
@@ -8,6 +8,8 @@
use App\CoreModule\Model\ChartManager;
use App\CoreModule\Model\RoomManager;
use App\CoreModule\Model\WorkShiftManager;
+use App\CoreModule\Component\StatusBubblesControl\StatusBubblesControlFactory;
+use App\CoreModule\Component\StatusNumbersControl\StatusNumbersControlFactory;
use Latte;
@@ -20,20 +22,45 @@ final class HomepagePresenter extends BasePresenter
private $chartManager;
private $roomManager;
private $workShiftManager;
-
-
- public function __construct(SensorsManager $sensorsManager, ChartManager $chartManager, RoomManager $roomManager, WorkShiftManager $workShiftManager)
+ /**
+ * @var StatusBubblesControlFactory
+ */
+ private $statusBubblesControlFactory;
+ /**
+ * @var StatusNumbersControlFactory
+ */
+ private $statusNumbersControlFactory;
+
+
+ public function __construct(SensorsManager $sensorsManager,
+ ChartManager $chartManager,
+ RoomManager $roomManager,
+ WorkShiftManager $workShiftManager,
+ StatusBubblesControlFactory $statusBubblesControlFactory,
+ StatusNumbersControlFactory $statusNumbersControlFactory)
{
$this->sensorsManager = $sensorsManager;
$this->chartManager = $chartManager;
$this->roomManager = $roomManager;
$this->workShiftManager = $workShiftManager;
- }
+ $this->statusBubblesControlFactory = $statusBubblesControlFactory;
+ $this->statusNumbersControlFactory = $statusNumbersControlFactory;
+ }
+
+
+ protected function createComponentStatusNumbers()
+ {
+ return $this->statusNumbersControlFactory->create();
+ }
+ protected function createComponentStatusBubbles()
+ {
+ return $this->statusBubblesControlFactory->create();
+ }
public function handleReloadBubbles(): void
{
- $this->redrawControl('sBubbles');
- $this->redrawControl('sPusInfo');
+// $this->redrawControl('sBubbles');
+// $this->redrawControl('sPusInfo');
}
public function renderDefault() : void
@@ -46,16 +73,19 @@ public function renderDefault() : void
($pletackyAll = $this->template->pletackyAll = $this->chartManager->sensorsChartHomepage());
// Big pletacka room
- $plBig = $this->roomManager->roomPletarnaBig;
- ($bubblesBig = $this->template->bubblesBig = $this->chartManager->sensorsChartBubbles($plBig));
+ $this->template->plBig = $plBig = $this->roomManager->roomPletarnaBig;
+// ($bubblesBig = $this->template->bubblesBig = $this->chartManager->sensorsChartBubbles($plBig));
// Small pletacka room
- $plSmall = $this->roomManager->roomPletarnaSmall;
- ($bubblesSmall = $this->template->bubblesSmall = $this->chartManager->sensorsChartBubbles($plSmall));
+ $this->template->plSmall = $plSmall = $this->roomManager->roomPletarnaSmall;
+// ($bubblesSmall = $this->template->bubblesSmall = $this->chartManager->sensorsChartBubbles($plSmall));
// $last = $pletackyAll["ALL_SENSORS"]["Pletacka1"];
// dump($last[array_key_last($last)]->state);
+// dump($url = $this->link("Homepage:default"));
+
+
}
diff --git a/app/CoreModule/Presenters/SensorsPresenter.php b/app/CoreModule/Presenters/SensorsPresenter.php
index e0cef529..29ab1899 100644
--- a/app/CoreModule/Presenters/SensorsPresenter.php
+++ b/app/CoreModule/Presenters/SensorsPresenter.php
@@ -4,6 +4,7 @@
namespace App\CoreModule\Presenters;
+use App\CoreModule\Component\PletackaChartControl\PletackaChartControlFactory;
use Nette;
use App\CoreModule\Model\SensorsManager;
use App\CoreModule\Model\ThisSensorManager;
@@ -12,7 +13,7 @@
use App\CoreModule\Model\WorkShiftManager;
use App\CoreModule\Forms\SensorsFormFactory;
use App\CoreModule\Forms\ThisSensorFormFactory;
-use App\CoreModule\Controls\PletackaChartControl\PletackaChartControlFactory;
+use App\CoreModule\Component\PletackaChartControl\PletackaChartControl;
use Nette\Http\Request;
use Nette\Application\UI\Form;
use Nette\Http\UrlScript;
@@ -55,15 +56,15 @@ final class SensorsPresenter extends BasePresenter
public function __construct(
- SensorsManager $sensorsManager,
- ThisSensorManager $thisSensorManager,
- Request $request,
- SensorsFormFactory $sensorsFormFactory,
- ThisSensorFormFactory $thisSensorFormFactory,
- ThisChartManager $thisChartManager,
- ChartManager $chartManager,
- WorkShiftManager $workShiftManager,
- PletackaChartControlFactory $pletackaChartControlFactory
+ SensorsManager $sensorsManager,
+ ThisSensorManager $thisSensorManager,
+ Request $request,
+ SensorsFormFactory $sensorsFormFactory,
+ ThisSensorFormFactory $thisSensorFormFactory,
+ ThisChartManager $thisChartManager,
+ ChartManager $chartManager,
+ WorkShiftManager $workShiftManager,
+ PletackaChartControlFactory $pletackaChartControlFactory
)
{
diff --git a/app/CoreModule/Presenters/TestPresenter.php b/app/CoreModule/Presenters/TestPresenter.php
index 9e9eecf1..5ff6ffd2 100644
--- a/app/CoreModule/Presenters/TestPresenter.php
+++ b/app/CoreModule/Presenters/TestPresenter.php
@@ -100,17 +100,17 @@ public function actionDebug($name)
// for($i = 10; $i<=19; $i++)
// {
// $sensors = $this->sensorsManager->getSensors();
-// //
+//// //
// dump($this->databaseSelectionManager->createSelections($sensors, DatabaseSelectionManager::HOUR, new DateTime("2020-10-30 ".$i.":02:32")));
-//
-// }
+////
+//// }
//// $this->databaseSelectionManager->createSelection(17, DatabaseSelectionManager::HOUR, DateTime::from("2020-10-29 11:02:32"));
// for($i = 1; $i<=23; $i++)
// if($i != 17)
// $this->sensorsManager->addNewSensor($i, "Pletacka - ".$i);
-//// $this->sensorsManager->deleteSensor($i);
-//
+// $this->sensorsManager->deleteSensor($i);
+
//
// if($returnMessage->state)
diff --git a/app/CoreModule/Presenters/templates/@layout.latte b/app/CoreModule/Presenters/templates/@layout.latte
index a947bff2..e83340c2 100644
--- a/app/CoreModule/Presenters/templates/@layout.latte
+++ b/app/CoreModule/Presenters/templates/@layout.latte
@@ -46,7 +46,7 @@
- Pletačka IoT
+ Pletačka IoT
diff --git a/app/CoreModule/Presenters/templates/Homepage/default.latte b/app/CoreModule/Presenters/templates/Homepage/default.latte
index 958fb484..cfe13228 100644
--- a/app/CoreModule/Presenters/templates/Homepage/default.latte
+++ b/app/CoreModule/Presenters/templates/Homepage/default.latte
@@ -1,27 +1,55 @@
{block title}Home{/block}
{block content}
+{**}
+{*
*}
+{* {$actualWS}*}
+{*
*}
+{* {snippet ssPusInfo}*}
+{* {include pusInfo $settings}*}
+{* {/snippet}*}
+{**}
+
{$actualWS}
{snippet sPusInfo}
- {include pusInfo $settings}
+ {control statusNumbers, array($plBig, $plSmall), $actualWS}
{/snippet}
+{**}
+
+{*
Aktualizovat*}
+{* {snippet sBubbles}*}
+{*
*}
+{*
*}
+{* {include bubbles $bubblesBig}*}
+{*
*}
+
+
+{*
*}
+{* {include bubbles $bubblesSmall}*}
+{*
*}
+{*
*}
+{* {/snippet}*}
+{*
*}
+
+
-
Aktualizovat
- {snippet sBubbles}
+
Aktualizovat
+ {snippet statusBubbles}
+
-
- {include bubbles $bubblesBig}
+
+ {control statusBubbles $plBig, "Velká pletárna"}
-
- {include bubbles $bubblesSmall}
+
+ {control statusBubbles $plSmall, "Malá pletárna"}
{/snippet}
diff --git a/app/CoreModule/Presenters/templates/components/bubbles.latte b/app/CoreModule/Presenters/templates/components/bubbles.latte
index 88ad318e..3b3a635f 100644
--- a/app/CoreModule/Presenters/templates/components/bubbles.latte
+++ b/app/CoreModule/Presenters/templates/components/bubbles.latte
@@ -1,25 +1,25 @@
{define bubbles $bubblesData}
-
+
{foreach $bubblesData as $number => $bubble}
{var myColumn = $bubble["COLUMN"]}
{first}
{/first}
{first $myColumn}{/first}
{if $bubble["VISIBILITY"] == "VISIBLY"}
{if $bubble["LAST_STATE"] == 'OFF'}
- {$number} |
- |
- |
+ {$number} |
+ |
+ |
{elseif $bubble["LAST_STATE"] == 'ON' or $bubble["LAST_STATE"] == 'FINISHED' or $bubble["LAST_STATE"] == 'REWORK'}
- {$number} |
- |
- {floor($bubble["FINISHED"]/2)}-P |
+ {$number} |
+ |
+ {floor($bubble["FINISHED"]/2)}-P |
{elseif $bubble["LAST_STATE"] == 'STOP'}
- {$number} |
- |
+ {$number} |
+ |
-
+
{* {gmdate("H:i:s", $bubble["STOP_TIME"])}H*}
{* {dump $bubble["STOP_TIME"]}*}
@@ -42,9 +42,9 @@
|
{/if}
{else}
- |
- |
- |
+ |
+ |
+ |
{/if}
{last $myColumn}
{/last}
diff --git a/app/CoreModule/TimeManagers/TimeBox.php b/app/CoreModule/TimeManagers/TimeBox.php
index c9932cc9..6f8c1d79 100644
--- a/app/CoreModule/TimeManagers/TimeBox.php
+++ b/app/CoreModule/TimeManagers/TimeBox.php
@@ -31,15 +31,17 @@ class TimeBox
private $tableSelection;
private $startTime;
+
private $endTime;
- /**
+
+ /**
* @brief Constructor
* @param Selection $tableSelection
* @param $startTime
* @param $endTime
*/
- public function __construct($tableSelection, String $startTime, String $endTime)
+ public function __construct($tableSelection, DateTime $startTime, DateTime $endTime)
{
//TODO change times to DateTime
$this->tableSelection = $tableSelection;
@@ -83,20 +85,20 @@ public function countEvents($state = NULL)
/**
* @brief Get all pletacka time
- * @param string $previousEvent
+ * @param $previousEvent
* @return int time in seconds
*/
public function allTime($previousEvent)
{
$time = 0;
+ $start = 0;
if($previousEvent)
{
$state = $previousEvent->state;
if($state != self::OFF)
{
$state = self::ON;
- $x = new DateTime($this->startTime);
- $start = $x->getTimestamp();
+ $this->startTime->getTimestamp();
}
else
{
@@ -142,11 +144,9 @@ public function allTime($previousEvent)
if($state != self::OFF)
{
- $y = new DateTime($this->endTime);
- $stop = $y->getTimestamp();
-
+ $this->endTime->getTimestamp();
// $stop = $this->tableSelection[array_key_last($this->tableSelection)]->time->getTimestamp();
- $time += $stop - $start;
+ $time += $this->endTime->getTimestamp() - $start;
}
return $time;
@@ -211,9 +211,7 @@ public function stopTime($previousEvent)
if($sState == self::REWORK)
{
- $x = new DateTime($this->endTime);
- $stop = $x->getTimestamp();
- $time += $stop-$start;
+ $time += $this->endTime->getTimestamp()-$start;
}
return $time;
}
@@ -259,50 +257,96 @@ public function lastStopTime(Nette\Utils\DateTime $now)
// return $time;
}
- /**
- * @brief Get work time
- * @param $previousEvent
- * @return int time in second
- */
- public function workTime($previousEvent)
- {
- $time = $this->allTime($previousEvent)-$this->stopTime($previousEvent);
- return $time;
- }
+// /**
+// * @brief Get work time
+// * @param $previousEvent
+// * @return int time in second
+// */
+// public function workTime($previousEvent)
+// {
+// $time = $this->allTime($previousEvent)-$this->stopTime($previousEvent);
+// return $time;
+// }
- /**
- * @brief Get average stop time
- * @param $previousEvent
- * @return int time in seconds
- */
- public function avgStopTime($previousEvent)
- {
- $count = $this->countEvents(self::STOP);
- if($count>0)
+ /**
+ * @brief Get work time
+ * @param int $allTime
+ * @param int $stopTime
+ * @return int time in second
+ */
+ public function workTime(int $allTime, int $stopTime)
+ {
+ return $allTime-$stopTime;
+ }
+
+// /**
+// * @brief Get average stop time
+// * @param $previousEvent
+// * @return int time in seconds
+// */
+// public function avgStopTime($previousEvent)
+// {
+// $count = $this->countEvents(self::STOP);
+//
+// if($count>0)
+// {
+// return ceil($this->stopTime($previousEvent)/$count);
+// }
+// else
+// return 0;
+//
+// }
+ /**
+ * @brief Get average stop time
+ * @param int $stopTime
+ * @param int $countEvents
+ * @return int time in seconds
+ */
+ public function avgStopTime(int $stopTime, int $countEvents)
+ {
+ if($countEvents>0)
{
- return ceil($this->stopTime($previousEvent)/$count);
+ return ceil($stopTime/$countEvents);
}
else
return 0;
}
- /**
- * @brief Get average work time
- * @param $previousEvent
- * @return int time in seconds
- */
- public function avgWorkTime($previousEvent)
- {
- $count = $this->countEvents(self::FINISHED);
- if($count>0)
- {
- return ceil($this->workTime($previousEvent)/$count);
- }
- else
- return 0;
- }
+// /**
+// * @brief Get average work time
+// * @param $previousEvent
+// * @return int time in seconds
+// */
+// public function avgWorkTime($previousEvent)
+// {
+// $count = $this->countEvents(self::FINISHED);
+//
+// if($count>0)
+// {
+// return ceil($this->workTime($previousEvent)/$count);
+// }
+// else
+// return 0;
+// }
+
+ /**
+ * @brief Get average work time
+ * @param int $workTime
+ * @param int $countEvents
+ * @return int time in seconds
+ */
+ public function avgWorkTime(int $workTime, int $countEvents)
+ {
+ if($countEvents>0)
+ {
+ return ceil($workTime/$countEvents);
+ }
+ else
+ return 0;
+
+ }
}
\ No newline at end of file
diff --git a/app/CoreModule/Utils/BubblesPretty.php b/app/CoreModule/Utils/BubblesPretty.php
new file mode 100644
index 00000000..fa54cb1a
--- /dev/null
+++ b/app/CoreModule/Utils/BubblesPretty.php
@@ -0,0 +1,28 @@
+state = $state;
+ $this->value = $value;
+ $this->class = $class;
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/CoreModule/Utils/DatabaseSelectionPretty.php b/app/CoreModule/Utils/DatabaseSelectionPretty.php
new file mode 100644
index 00000000..e663ba45
--- /dev/null
+++ b/app/CoreModule/Utils/DatabaseSelectionPretty.php
@@ -0,0 +1,58 @@
+number = $number;
+ $this->workShift = $workShift;
+ $this->t_stop = $t_stop;
+ $this->t_work = $t_work;
+ $this->t_all = $t_all;
+ $this->c_FINISHED = $c_FINISHED;
+ $this->c_STOP = $c_STOP;
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/CoreModule/Utils/NumbersPretty.php b/app/CoreModule/Utils/NumbersPretty.php
new file mode 100644
index 00000000..a171837e
--- /dev/null
+++ b/app/CoreModule/Utils/NumbersPretty.php
@@ -0,0 +1,69 @@
+finished = $finished;
+ $this->rating = $rating;
+ $this->stopTime = $stopTime;
+ $this->workTime = $workTime;
+ $this->allTime = $allTime;
+ $this->stopTimeStr = $stopTimeStr;
+ $this->state = $state;
+ }
+
+ public function divideTimeVariablesByCount(int $num)
+ {
+ $this->stopTime/=$num;
+ $this->workTime/=$num;
+ $this->allTime/=$num;
+ }
+
+ public function finishedCountToPairs()
+ {
+ $this->finished = intval($this->finished/2);
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/CoreModule/config/config.neon b/app/CoreModule/config/config.neon
index c4b65377..7f2a0dd9 100644
--- a/app/CoreModule/config/config.neon
+++ b/app/CoreModule/config/config.neon
@@ -47,4 +47,6 @@ services:
- App\CoreModule\Forms\SensorsFormFactory
- App\CoreModule\Forms\ThisSensorFormFactory
- App\CoreModule\Forms\WorkShiftFormFactory
- - App\CoreModule\Controls\PletackaChartControl\PletackaChartControlFactory
\ No newline at end of file
+ - App\CoreModule\Component\PletackaChartControl\PletackaChartControlFactory
+ - App\CoreModule\Component\StatusBubblesControl\StatusBubblesControlFactory
+ - App\CoreModule\Component\StatusNumbersControl\StatusNumbersControlFactory
\ No newline at end of file
diff --git a/app/Presenters/BasePresenter.php b/app/Presenters/BasePresenter.php
index 7b27ac83..13a3b03b 100644
--- a/app/Presenters/BasePresenter.php
+++ b/app/Presenters/BasePresenter.php
@@ -21,15 +21,6 @@ abstract class BasePresenter extends Presenter
{
protected $formFactory;
- private $sensorsManager;
- // private $request;
-
- // public function __construct(Nette\Application\Request $request)
- // {
- // $this->request = $request ;
- // }
-
-
protected function redrawAll()
{
$this->redrawControl('title');
diff --git a/git-updater.sh b/git-updater.sh
index 9bb8aa6a..bc50615e 100644
--- a/git-updater.sh
+++ b/git-updater.sh
@@ -9,6 +9,11 @@ do
git reset --hard origin/master
git clean -f
+# sudo chmod -R 777 temp/
+# sudo rm -Rd temp/
+# sudo chmod 777 git-updater.sh
+
+
# Restart your services here
while :
diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php
deleted file mode 100644
index 52a5c998..00000000
--- a/tests/ExampleTest.php
+++ /dev/null
@@ -1,41 +0,0 @@
-container = $container;
- }
-
-
- public function setUp()
- {
- }
-
-
- public function testSomething()
- {
- Assert::true(true);
- }
-}
-
-
-$container = \App\Bootstrap::bootForTests()
- ->createContainer();
-
-$test = new ExampleTest($container);
-$test->run();
diff --git a/www/checker/index.php b/www/checker/index.php
index 78dcfe55..626b3bc8 100644
--- a/www/checker/index.php
+++ b/www/checker/index.php
@@ -304,7 +304,7 @@ function iniFlag($var)
header('Content-Type: text/html; charset=utf-8');
-header('Cache-Controls: s-maxage=0, max-age=0, must-revalidate');
+header('Cache-Component: s-maxage=0, max-age=0, must-revalidate');
header('Expires: Mon, 23 Jan 1978 10:00:00 GMT');
/**
diff --git a/www/css/style.css b/www/css/style.css
index 4a6aa395..0ea53c84 100644
--- a/www/css/style.css
+++ b/www/css/style.css
@@ -31,7 +31,7 @@ div.success {
border-color: #c3e6cb;
}
-.bubble {
+.xbubble {
/*display: inline-block;*/
position: relative;
/*left: -10px;*/
@@ -45,7 +45,7 @@ div.success {
}
-.bubble-number{
+.xbubble-number{
color: white;
position: relative;
/*left: 10px;*/
@@ -54,7 +54,7 @@ div.success {
width: 100%;
}
-.bubble-text{
+.xbubble-text{
position: relative;
left: -85px;
top: 20px;
@@ -65,28 +65,28 @@ div.success {
-.bubble-off{
+.xbubble-off{
background-color: #6a6767;
}
-/*.bubble-text-off{*/
+/*.xbubble-text-off{*/
/* color: #6a6767;*/
/*}*/
-.bubble-ok{
+.xbubble-ok{
background-color: #1A7E1E;
}
-/*.bubble-text-ok{*/
+/*.xbubble-text-ok{*/
/* color: #1A7E1E;*/
/*}*/
-.bubble-stop{
+.xbubble-stop{
background-color: #f51026;
}
-/*.bubble-text-stop{*/
+/*.xbubble-text-stop{*/
/* color: #f51026;*/
/*}*/
-.bubble-brim{
+.xbubble-brim{
border: 5px solid red;
width: 100%;
max-width: 1000px;
@@ -94,6 +94,54 @@ div.success {
display: inline-block;
}
+/*///////////////////////////////////*/
+.bubble-border{
+ border: 5px solid red;
+}
+
+.bubble-number{
+ width: 90px;
+ display: table-cell;
+ vertical-align: middle;
+ color: white;
+ text-align: center;
+ /*position: relative;*/
+
+ /*width: 80%;*/
+ /*left: 10px;*/
+ /*top: 13px;*/
+ /*text-align: center;*/
+ /*width: 100%;*/
+}
+
+
+.bubble{
+ width: 90px;
+ height: 50px;
+ min-width: 70px;
+ text-align: center;
+ display: table-cell;
+ vertical-align: middle;
+
+ color: #ffffff;
+
+ border-radius: 15px!important;
+}
+
+.bubble-stop{
+ background-color: #f51026;
+}
+
+.bubble-off{
+ background-color: #6a6767;
+}
+
+.bubble-finished{
+ background-color: #1A7E1E;
+}
+
+/*///////////////////////////////////*/
+
.zoom {
transition: transform .2s;
}
@@ -111,7 +159,7 @@ div.success {
width: 100%;
}
-/*.bubble-hide{*/
+/*.xbubble-hide{*/
/* background-color: ;*/
/*}*/