| @@ -1,7 +1,7 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
| <project version="4"> | <project version="4"> | ||||
| <component name="ProjectTasksOptions"> | <component name="ProjectTasksOptions"> | ||||
| <TaskOptions isEnabled="true"> | |||||
| <TaskOptions isEnabled="false"> | |||||
| <option name="arguments" value="$FileName$:$FileNameWithoutExtension$.css" /> | <option name="arguments" value="$FileName$:$FileNameWithoutExtension$.css" /> | ||||
| <option name="checkSyntaxErrors" value="true" /> | <option name="checkSyntaxErrors" value="true" /> | ||||
| <option name="description" /> | <option name="description" /> | ||||
| @@ -225,20 +225,21 @@ function onCreateWorksheet() { | |||||
| e.preventDefault(); | e.preventDefault(); | ||||
| let result = window.confirm("Sie nutzen hiermit einen Ihrer Durchgänge."); | let result = window.confirm("Sie nutzen hiermit einen Ihrer Durchgänge."); | ||||
| if (result) { | if (result) { | ||||
| // TODO: DANIEL | |||||
| // $.ajax({ | |||||
| // url: "/create-worksheet", | |||||
| // method: "post", | |||||
| // data: $('#form-risk').serializeArray(), | |||||
| // success: function (data) { | |||||
| // console.log(data); | |||||
| // window.location = "/worksheet/" + data; | |||||
| // }, | |||||
| // error: function (xhr, msg, three) { | |||||
| // messageBox(false, "Fehler bei der Anfrage."); | |||||
| // }, | |||||
| // dataType: "json" | |||||
| // }); | |||||
| $.ajax({ | |||||
| url: "/create-worksheet", | |||||
| method: "post", | |||||
| data: { | |||||
| asset: $('#asset').val() | |||||
| }, | |||||
| success: function (data) { | |||||
| console.log(data); | |||||
| window.location = "/worksheet/" + data; | |||||
| }, | |||||
| error: function (xhr, msg, three) { | |||||
| messageBox(false, "Fehler bei der Anfrage."); | |||||
| }, | |||||
| dataType: "json" | |||||
| }); | |||||
| } | } | ||||
| }); | }); | ||||
| } | } | ||||
| @@ -131,30 +131,54 @@ class UserController extends AbstractController | |||||
| return new JsonResponse(null, JsonResponse::HTTP_BAD_REQUEST); | return new JsonResponse(null, JsonResponse::HTTP_BAD_REQUEST); | ||||
| } | } | ||||
| $params = $request->request->all(); | $params = $request->request->all(); | ||||
| $benchMark = $em->getRepository(DinAssetBenchmark::class)->find($params['benchmark']); | |||||
| $calculation = $calculatorService->calculateRisk($benchMark, $params); | |||||
| $benchmark = $em->getRepository(DinAssetBenchmark::class)->find($params['benchmark']); | |||||
| /** @var DinAsset $asset */ | /** @var DinAsset $asset */ | ||||
| $asset = $benchmark->getDinAsset(); | |||||
| $asset = $em->getRepository(DinAsset::class)->find($params['asset']); | |||||
| if ($asset === null) { | |||||
| return new JsonResponse(null, JsonResponse::HTTP_BAD_REQUEST); | |||||
| } | |||||
| $assetTasks = $asset->getTasks(); | $assetTasks = $asset->getTasks(); | ||||
| $em->getConnection()->beginTransaction(); | |||||
| $failureProbability = null; | |||||
| $failureDamage = null; | |||||
| $maintenanceAdvantage = null; | |||||
| $inspectionAdvantage = null; | |||||
| $cycle = null; | |||||
| $bandwidth = null; | |||||
| $recCycleMaintenance = null; | |||||
| $recCycleInspection = null; | |||||
| $costDiffCurRecPercentage = null; | |||||
| $costDiffCurCycleRecCycle = null; | |||||
| if (array_key_exists('benchmark', $params)) { | |||||
| $benchMark = $em->getRepository(DinAssetBenchmark::class)->find($params['benchmark']); | |||||
| $calculation = $calculatorService->calculateRisk($benchMark, $params); | |||||
| $failureProbability = Utils::$riskFailure[$params['failure']][0]; | |||||
| $failureDamage = Utils::$riskCosts[$params['costs']][0]; | |||||
| $maintenanceAdvantage = $params['maintenance']; | |||||
| $inspectionAdvantage = $params['inspection']; | |||||
| $cycle = $params['cycle']; | |||||
| $bandwidth = $benchMark->getBandwidth(); | |||||
| $recCycleMaintenance = $calculation['recCycleMaintenance']; | |||||
| $recCycleInspection = $calculation['recCycleInspection']; | |||||
| $costDiffCurRecPercentage = $calculation['costDiffCurRecPercentage']; | |||||
| $costDiffCurCycleRecCycle = $calculation['costDiffCurCycleRecCycle']; | |||||
| } | |||||
| $em->getConnection()->beginTransaction(); | |||||
| try { | try { | ||||
| $worksheet = new UserWorksheet($user); | $worksheet = new UserWorksheet($user); | ||||
| $worksheet->setDinNumber($asset->getDinNumber()); | $worksheet->setDinNumber($asset->getDinNumber()); | ||||
| $worksheet->setDinAssetName($asset->getName()); | $worksheet->setDinAssetName($asset->getName()); | ||||
| $worksheet->setFailureProbability(Utils::$riskFailure[$params['failure']][0]); | |||||
| $worksheet->setFailureDamage(Utils::$riskCosts[$params['costs']][0]); | |||||
| $worksheet->setMaintenanceAdvantage($params['maintenance']); | |||||
| $worksheet->setInspectionAdvantage($params['inspection']); | |||||
| $worksheet->setUserCycleMonths($params['cycle']); | |||||
| $worksheet->setBandwidth($benchmark->getBandwidth()); | |||||
| $worksheet->setRecMaintenanceCycleMonths($calculation['recCycleMaintenance']); | |||||
| $worksheet->setRecInspectionCycleMonths($calculation['recCycleInspection']); | |||||
| $worksheet->setDeviationPercentage($calculation['costDiffCurRecPercentage']); | |||||
| $worksheet->setDeviationCosts($calculation['costDiffCurCycleRecCycle']); | |||||
| $worksheet->setFailureProbability($failureProbability); | |||||
| $worksheet->setFailureDamage($failureDamage); | |||||
| $worksheet->setMaintenanceAdvantage($maintenanceAdvantage); | |||||
| $worksheet->setInspectionAdvantage($inspectionAdvantage); | |||||
| $worksheet->setUserCycleMonths($cycle); | |||||
| $worksheet->setBandwidth($bandwidth); | |||||
| $worksheet->setRecMaintenanceCycleMonths($recCycleMaintenance); | |||||
| $worksheet->setRecInspectionCycleMonths($recCycleInspection); | |||||
| $worksheet->setDeviationPercentage($costDiffCurRecPercentage); | |||||
| $worksheet->setDeviationCosts($costDiffCurCycleRecCycle); | |||||
| $em->persist($worksheet); | $em->persist($worksheet); | ||||
| $em->flush(); | $em->flush(); | ||||
| @@ -40,12 +40,12 @@ class UserWorksheet | |||||
| protected $dinAssetName; | protected $dinAssetName; | ||||
| /** | /** | ||||
| * @ORM\Column(type="string", nullable=false) | |||||
| * @ORM\Column(type="string", nullable=true) | |||||
| */ | */ | ||||
| protected $failureProbability; | protected $failureProbability; | ||||
| /** | /** | ||||
| * @ORM\Column(type="string", nullable=false) | |||||
| * @ORM\Column(type="string", nullable=true) | |||||
| */ | */ | ||||
| protected $failureDamage; | protected $failureDamage; | ||||
| @@ -60,7 +60,7 @@ class UserWorksheet | |||||
| protected $inspectionAdvantage; | protected $inspectionAdvantage; | ||||
| /** | /** | ||||
| * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true}) | |||||
| * @ORM\Column(type="smallint", nullable=true, options={"unsigned" = true}) | |||||
| */ | */ | ||||
| protected $userCycleMonths; | protected $userCycleMonths; | ||||
| @@ -70,22 +70,22 @@ class UserWorksheet | |||||
| protected $bandwidth; | protected $bandwidth; | ||||
| /** | /** | ||||
| * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true}) | |||||
| * @ORM\Column(type="smallint", nullable=true, options={"unsigned" = true}) | |||||
| */ | */ | ||||
| protected $recMaintenanceCycleMonths; | protected $recMaintenanceCycleMonths; | ||||
| /** | /** | ||||
| * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true}) | |||||
| * @ORM\Column(type="smallint", nullable=true, options={"unsigned" = true}) | |||||
| */ | */ | ||||
| protected $recInspectionCycleMonths; | protected $recInspectionCycleMonths; | ||||
| /** | /** | ||||
| * @ORM\Column(type="decimal", precision=10, scale=2)) | |||||
| * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true) | |||||
| */ | */ | ||||
| protected $deviationCosts; | protected $deviationCosts; | ||||
| /** | /** | ||||
| * @ORM\Column(type="decimal", precision=10, scale=2)) | |||||
| * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true) | |||||
| */ | */ | ||||
| protected $deviationPercentage; | protected $deviationPercentage; | ||||
| @@ -14,7 +14,7 @@ | |||||
| {#{{ encore_entry_script_tags('app') }}#} | {#{{ encore_entry_script_tags('app') }}#} | ||||
| <script src="/assets/js/jquery-3.6.0.min.js"></script> | <script src="/assets/js/jquery-3.6.0.min.js"></script> | ||||
| <script src="/assets/js/jquery.serializeObject.js"></script> | <script src="/assets/js/jquery.serializeObject.js"></script> | ||||
| <script src="/assets/js/my-bim-score.js"></script> | |||||
| <script src="/assets/js/mpp-tool.js"></script> | |||||
| {% endblock %} | {% endblock %} | ||||
| </head> | </head> | ||||
| <body> | <body> | ||||
| @@ -4,11 +4,11 @@ | |||||
| <table class="mini-table"> | <table class="mini-table"> | ||||
| <tr> | <tr> | ||||
| <td><span>Wie hoch ist die Ausfallwahrscheinlichkeit?</span></td> | <td><span>Wie hoch ist die Ausfallwahrscheinlichkeit?</span></td> | ||||
| <td>{{ worksheet.failureProbability }}</td> | |||||
| <td>{% if worksheet.failureProbability is not null %}{{ worksheet.failureProbability }}{% else %}-{% endif %}</td> | |||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td><span>Wie hoch ist der Schaden bei Ausfall?</span></td> | <td><span>Wie hoch ist der Schaden bei Ausfall?</span></td> | ||||
| <td>{{ worksheet.failureDamage }}</td> | |||||
| <td>{% if worksheet.failureDamage is not null %}{{ worksheet.failureDamage }}{% else %}-{% endif %}</td> | |||||
| </tr> | </tr> | ||||
| </table> | </table> | ||||
| @@ -28,7 +28,7 @@ | |||||
| <table class="mini-table"> | <table class="mini-table"> | ||||
| <tr> | <tr> | ||||
| <td><span>Aktueller Zyklus (in Monaten)</span></td> | <td><span>Aktueller Zyklus (in Monaten)</span></td> | ||||
| <td>{{ worksheet.userCycleMonths }}</td> | |||||
| <td>{% if worksheet.userCycleMonths is not null %}{{ worksheet.userCycleMonths }}{% else %}-{% endif %}</td> | |||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td><span>Größencluster</span></td> | <td><span>Größencluster</span></td> | ||||
| @@ -40,19 +40,19 @@ | |||||
| <table class="mini-table"> | <table class="mini-table"> | ||||
| <tr> | <tr> | ||||
| <td><span>Empfehlung Wartung (in Monaten)</span></td> | <td><span>Empfehlung Wartung (in Monaten)</span></td> | ||||
| <td>{{ worksheet.recMaintenanceCycleMonths }}</td> | |||||
| <td>{% if worksheet.recMaintenanceCycleMonths is not null %}{{ worksheet.recMaintenanceCycleMonths }}{% else %}-{% endif %}</td> | |||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td><span>Empfehlung Inspektion (in Monaten)</span></td> | <td><span>Empfehlung Inspektion (in Monaten)</span></td> | ||||
| <td>{{ worksheet.recInspectionCycleMonths }}</td> | |||||
| <td>{% if worksheet.recInspectionCycleMonths is not null %}{{ worksheet.recInspectionCycleMonths }}{% else %}-{% endif %}</td> | |||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td><span>Einsparpotential p.a. (%)</span></td> | <td><span>Einsparpotential p.a. (%)</span></td> | ||||
| <td>{{ worksheet.deviationPercentage * 100 }}%</td> | |||||
| <td>{% if worksheet.deviationPercentage is not null %}{{ worksheet.deviationPercentage * 100 }}%{% else %}-{% endif %}</td> | |||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td><span>Einsparpotential p.a. (€)</span></td> | <td><span>Einsparpotential p.a. (€)</span></td> | ||||
| <td>{{ worksheet.deviationCosts | replace({'.': ','}) }} €</td> | |||||
| <td>{% if worksheet.deviationCosts is not null %}{{ worksheet.deviationCosts | replace({'.': ','}) }}€{% else %}-{% endif %}</td> | |||||
| </tr> | </tr> | ||||
| </table> | </table> | ||||