<?php
/**
*
* @ This file is created by http://DeZender.Net
* @ deZender (PHP7 Decoder for SourceGuardian Encoder)
*
* @ Version			:	5.0.1.0
* @ Author			:	DeZender
* @ Release on		:	22.04.2022
* @ Official site	:	http://DeZender.Net
*
*/

$jsondata = file_get_contents("./api/json/r3alm_xcdata.json");
$data = json_decode($jsondata, true);
$json = $data["app"];
$mnt_message = $json["mnt_message"];
$mnt_expire = $json["mnt_expire"];
$mnt_act = $json["mnt_status"] == "ACTIVE" ? "selected" : "";
$mnt_ina = $json["mnt_status"] == "INACTIVE" ? "selected" : "";
$message = "<div class=\"alert alert-primary\" id=\"flash-msg\"><h4><i class=\"icon fa fa-check\"></i>Items Updated!</h4></div>";
if (isset($_POST["submit"])) {
    $jsonData = file_get_contents("./api/json/r3alm_xcdata.json");
    $arrayData = json_decode($jsonData, true);
    $replacementData = ["app" => ["mnt_status" => $_POST["mnt_status"], "mnt_message" => $_POST["mnt_message"], "mnt_expire" => $_POST["mnt_expire"]]];
    $newArrayData = array_replace_recursive($arrayData, $replacementData);
    $newJsonData = json_encode($newArrayData, JSON_UNESCAPED_UNICODE);
    file_put_contents("./api/json/r3alm_xcdata.json", $newJsonData);
    header("Location: maintenance.php?message=" . $message);
}
include "includes/header.php";
echo " <!-- Begin Page Content -->\n        <div class=\"container-fluid\">\n\n";
if (isset($_GET["message"])) {
    echo $_GET["message"];
}
echo "          <!-- Content Row -->\n          <div class=\"row\">\n\n            <!-- First Column -->\n            <div class=\"col-lg-12\">\n\n              <!-- Custom codes -->\n                <div class=\"card text-text-primary\">\n                <div class=\"card-header bg-primary py-3\">\n                <center><h4 align=\"center\" class=\"m-0 text-white\"><i class=\"fa fa-tachometer-alt\"\n                                    style=\"font-size:20px\">&nbsp;&nbsp;</i> Edit Maintenance Message</h4>\n                        \n\t\t\t\t\t\t</center>\n\n            </div>\n                <div class=\"card-body\">\n                            <form method=\"post\">\n                            <div class=\"form-group \">\n                            <label class=\"control-label  text-primary\" for=\"mnt_message\">\n                            <strong>Maintenance Message</strong>\n                            </label>\n                            <div class=\"input-group\">\n";
echo "                            <input class=\"form-control text-primary\" id=\"description\" name=\"mnt_message\" value=\"" . $mnt_message . "\" type=\"text\"/>" . "\n";
echo "                            </div>\n                            </div>\n                            <div class=\"form-group \">\n                            <label class=\"control-label requiredField text-primary\" for=\"mnt_status\" >\n                            <strong>Status</strong>\n                            </label>\n                            <select class=\"select form-control text-primary\" id=\"select\" name=\"mnt_status\">\n";
echo "\t\t\t\t\t\t\t   <option value=\"INACTIVE\"" . $mnt_ina . ">INACTIVE</option>" . "\n";
echo "                            <option value=\"ACTIVE\"" . $mnt_act . ">ACTIVE</option>" . "\n";
echo "                            </select>\n                            </div>\n                            <div class=\"form-group \">\n                            <label class=\"control-label  text-primary\" for=\"message\">\n                            <strong>Expiration:</strong>\n                            </label>\n                            <div class=\"input-group\">\n";
echo "                            <input type=\"text\" class=\"form-control text-primary\" name=\"mnt_expire\" id=\"datetimepicker\" value=\"" . $mnt_expire . "\">" . "\n";
echo "                            </div>\n                            </div>\n                            <div class=\"form-group\">\n                            <div>\n                        <button class=\"btn btn-success btn-icon-split\" name=\"submit\" type=\"submit\">\n                        <span class=\"icon text-white-50\"><i class=\"fas fa-check\"></i></span><span class=\"text\">Submit</span>\n                        </button>\n                            </div>\n                            </div>\n                            </form>\n                </div>\n              </div>\n            </div>\n            </div>\n            </div>\n\n    <br><br><br>";
include "includes/footer.php";
require "includes/r3alm.php";
echo "</body>\n";

?>