<?php 
if (session_status() === PHP_SESSION_NONE){session_start();}
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);


$str_data = file_get_contents("api/zyx.json");
$data = json_decode($str_data, true);
 

$res = $_GET['update'];

//$id = $row['id'];
$addtion_app_name = $data["private_menu"][$res]["addtion_app_name"];
$addtion_app_pkg = $data["private_menu"][$res]["addtion_app_pkg"];
$addtion_app_icon = $data["private_menu"][$res]["addtion_app_icon"];
$addtion_app_url = $data["private_menu"][$res]["addtion_app_url"];
$addtion_app_status = $data["private_menu"][$res]["addtion_app_status"];


if(isset($_POST['submit'])){
    $jsonData = file_get_contents("./api/zyx.json");
$arrayData = json_decode($jsonData, true);
$replacementData = array('private_menu' =>  array($res =>array(
	"addtion_app_name"             => $_POST["addtion_app_name"],
    "addtion_app_pkg"               => $_POST["addtion_app_pkg"],
    "addtion_app_icon"           => $_POST["addtion_app_icon"],
    "addtion_app_url"                 => $_POST["addtion_app_url"],
    "addtion_app_status"    => $_POST["addtion_app_status"])))
    ;
    $newArrayData = array_replace_recursive($arrayData, $replacementData);
$newJsonData = json_encode($newArrayData, JSON_PRETTY_PRINT);
file_put_contents("./api/zyx.json", $newJsonData);

header("Location: appstore.php");
}
include ('includes/header.php');

?>

<!-- Begin Page Content -->
        <div class="container-fluid">

          <!-- Page Heading -->
          <h1 class="h3 mb-1 text-gray-800"> Update Appstore Apps</h1>

              <!-- Custom codes -->
                <div class="card border-left-primary alert-primary shadow h-100 card shadow mb-4">
                <div class="card-header py-3">
                <h6 class="m-0 font-weight-bold text-primary"><i class="fa fa-android"></i> Enter Apk Details</h6>
                </div>
                
                <div class="card-body">
                    <?
echo "                  <form  method=\"post\">\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Update App_Name</label>\n";
echo "						   <input type=\"hidden\" name=\"id\" value=\"$res\">\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"addtion_app_name\" value=\"$addtion_app_name\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Update App_Package_Name</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"addtion_app_pkg\" value=\"$addtion_app_pkg\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Update App_Icon</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"addtion_app_icon\" value=\"$addtion_app_icon\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">Upadte_App_Url</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"addtion_app_url\" value=\"$addtion_app_url\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <div class=\"form-group\">\n";
echo "                          <label class=\"bmd-label-floating\">App_Status Visibile In Appstore</label>\n";
echo "                          <input type=\"text\" class=\"form-control\" name=\"addtion_app_status\" value=\"$addtion_app_status\">\n";
echo "                        </div>\n";
echo "                      </div>\n";
echo "                      <div>\n";
echo "                        <br><button type=\"submit\" name=\"submit\" class=\"btn btn-primary pull-right\">Submit</button>\n";
echo "				</form>\n";
echo "				</div>\n";
echo "              </div>\n";
echo "            </div>\n";
echo "          </div>\n";
echo "    <br><br><br>\n";
include ('includes/footer.php');
echo "</body>\n";
echo "\n";
echo "</html>\n";
