<?php 
$jsondata = file_get_contents("./api/main.json");
$data = json_decode($jsondata, true);
$json = $data['app'];
$message = '<div class="alert alert-success" id="flash-msg"><h4><i class="icon fa fa-check"></i>Items Updated!</h4></div>';
if(isset($_POST['submit'])){
$jsonData = file_get_contents("./api/main.json");  
$arrayData = json_decode($jsonData, true);
$replacementData = array('app' => array(
        "login_type"       	   =>	$_POST["login_type"],
		"btn_pr"          	   =>	$_POST["btn_pr"],
		"btn_rec"              =>	$_POST["btn_rec"],
        "btn_vpn"              =>	$_POST["btn_vpn"],
        "btn_noti"             =>	$_POST["btn_noti"],
        "btn_update"           =>	$_POST["btn_update"],
		"show_expire"      	   =>	$_POST["show_expire"]));
$newArrayData = array_replace_recursive($arrayData, $replacementData);
$newJsonData = json_encode($newArrayData, JSON_UNESCAPED_UNICODE);
file_put_contents("./api/main.json", $newJsonData);
header("Location: extra.php?message=$message");
		}
$jsondata = file_get_contents("./api/main.json");
$data = json_decode($jsondata, true);
$json = $data['app'];
if(isset($_POST['submit_support'])){
$jsonData = file_get_contents("./api/main.json");  
$arrayData = json_decode($jsonData, true);
$replacementData = array('app' => array(
		"show_cat_count"       =>	$_POST["show_cat_count"],
		"load_last_channel"    =>	$_POST["load_last_channel"],
        "login_logo"           =>	$_POST["login_logo"],
		"logs"    		       =>	$_POST["logs"],
		"all_cat"              =>	$_POST["all_cat"],
		"btn_login_settings"   =>	$_POST["btn_login_settings"],
        "agent"                =>	$_POST["agent"]));
$newArrayData = array_replace_recursive($arrayData, $replacementData);
$newJsonData = json_encode($newArrayData, JSON_UNESCAPED_UNICODE);
file_put_contents("./api/main.json", $newJsonData);
header("Location: extra.php?message=$message");
		}
		 
include ('includes/header.php');	
?>


            <div class="container pt-4 pb-5">
            <div class="row">
                <div class="col-md-6 col-12">

            <div class="card">
              <div class="card-header">
                  <i class="fa fa-sliders"></i> Opções extras</div>
            <div class="card-body">
                    
                        
                         <form method="post">
                                <div class="form ">
                                    <label class="control-label " for="select_filter_status">
                                    </label>
                                  </div>
					                <div class="form-group ">
                                    <label class="control-label requiredField" for="login_type" >
                                        <strong> Tipo de Login</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="login_type">
									    <option value="login"<?=$json['login_type']=='login'?'selected':'' ?>>Usuário / Senha</option>
                                        <option value="mac" <?=$json['login_type']=='mac'?'selected':'' ?>>Mac Address</option>
                                        <option value="activation" <?=$json['login_type']=='activation'?'selected':'' ?>>Codigo de Ativação</option>
									</select>                                </div>
									<div class="form-group ">
                                    <label class="control-label requiredField" for="btn_pr" >
                                        <strong> Mostrar botão de lembrete</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="btn_pr">
									    <option value="yes"<?=$json['btn_pr']=='yes'?'selected':'' ?>>Habilitado</option>
                                        <option value="no" <?=$json['btn_pr']=='no'?'selected':'' ?>>Desabilitado</option>
									</select>                                </div>
					 <form method="post">
									<div class="form-group ">
                                    <label class="control-label requiredField" for="btn_rec" >
                                        <strong> Mostrar botão de gravação</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="btn_rec">
									    <option value="Yes"<?=$json['btn_rec']=='Yes'?'selected':'' ?>>Habilitado</option>
                                        <option value="no" <?=$json['btn_rec']=='no'?'selected':'' ?>>Desabilitado</option>
									</select>                                </div>
					 <form method="post">
									<div class="form-group ">
                                    <label class="control-label requiredField" for="btn_vpn" >
                                        <strong> Mostrar botão VPN</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="btn_vpn">
									    <option value="Yes"<?=$json['btn_vpn']=='Yes'?'selected':'' ?>>Habilitado</option>
                                        <option value="no" <?=$json['btn_vpn']=='no'?'selected':'' ?>>Desabilitado</option>
									</select>                                </div>
					<form method="post">
									<div class="form-group ">
                                    <label class="control-label requiredField" for="btn_noti" >
                                        <strong> Mostrar botão de mensagem</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="btn_noti">
									    <option value="Yes"<?=$json['btn_noti']=='Yes'?'selected':'' ?>>Habilitado</option>
                                        <option value="no" <?=$json['btn_noti']=='no'?'selected':'' ?>>Desabilitado</option>
									</select>                                </div>
					<form method="post">
									<div class="form-group ">
                                    <label class="control-label requiredField" for="btn_update" >
                                        <strong> Mostrar botão de atualização</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="btn_update">
									    <option value="Yes"<?=$json['btn_update']=='Yes'?'selected':'' ?>>Habilitado</option>
                                        <option value="no" <?=$json['btn_update']=='no'?'selected':'' ?>>Desabilitado</option>
									</select>                                </div>
                                <form method="post">
									<div class="form-group ">
                                    <label class="control-label requiredField" for="show_expire" >
                                        <strong> Mostrar Sub Expiração</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="show_expire">
									    <option value="yes"<?=$json['show_expire']=='yes'?'selected':'' ?>>Habilitado</option>
                                        <option value="no" <?=$json['show_expire']=='no'?'selected':'' ?>>Desabilitado</option>
									</select>
                                    </div>
                                    </br>
								 <div class="form-group">
                                    <div>
                                     </div>   
                        <button class="btn btn-primary" name="submit" type="submit">
                                    <i class="fa fa-check"></i><strong> Atualizar as configurações do aplicativo</strong>
                        </button>
  </div>
                    </form>
                </div></div></div>
            <div class="col-md-6 col-12">

            <div class="card">
              <div class="card-header">
                  <i class="fa fa-sliders"></i> Opções extras</div>
            <div class="card-body">
					 <form method="post">
					     <div class="form-group ">
                                    <label class="control-label " for="select_filter_status">
                                    </label>
					                <div class="form-group ">
                                    <label class="control-label requiredField" for="login_logo" >
                                        <strong> Mostrar logotipo de login</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="login_logo">
									    <option value="Yes"<?=$json['login_logo']=='Yes'?'selected':'' ?>>Habilitado</option>
                                        <option value="no" <?=$json['login_logo']=='no'?'selected':'' ?>>Desabilitado</option>
									</select>                                </div>
					 <form method="post">
					                <div class="form-group ">
                                    <label class="control-label requiredField" for="logs" >
                                        <strong> Mostrar logs de aplicativos</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="logs">
									    <option value="Yes"<?=$json['logs']=='Yes'?'selected':'' ?>>Habilitado</option>
                                        <option value="no" <?=$json['logs']=='no'?'selected':'' ?>>Desabilitado</option>
									</select>                                </div>
					 <form method="post">
					                <div class="form-group ">
                                    <label class="control-label requiredField" for="all_cat" >
                                        <strong> Mostrar todas as categorias</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="all_cat">
									    <option value="Yes"<?=$json['all_cat']=='Yes'?'selected':'' ?>>Habilitado</option>
                                        <option value="No" <?=$json['all_cat']=='No'?'selected':'' ?>>Desabilitado</option>
									</select>                                </div>
					 <form method="post">
					                <div class="form-group ">
                                    <label class="control-label requiredField" for="show_cat_count" >
                                        <strong> Mostrar contagem de categorias</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="show_cat_count">
									    <option value="yes"<?=$json['show_cat_count']=='yes'?'selected':'' ?>>Habilitado</option>
                                        <option value="No" <?=$json['show_cat_count']=='No'?'selected':'' ?>>Desabilitado</option>
									</select>                                </div>
									<div class="form-group ">
                                    <label class="control-label " for="agent">
                                        <strong> Agente de usuário</strong>
                                    </label>
                                    <div class="input-group">
                                        <input class="form-control text-muted" name="agent"  value="<?=$json['agent']?>" type="text"/>
                                    </div>
                                </div>
					 <form method="post">
									<div class="form-group ">
                                    <label class="control-label requiredField" for="load_last_channel" >
                                        <strong> Carregar o último canal</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="load_last_channel">
									    <option value="Yes"<?=$json['load_last_channel']=='Yes'?'selected':'' ?>>Habilitado</option>
                                        <option value="No" <?=$json['load_last_channel']=='No'?'selected':'' ?>>Desabilitado</option>
									</select>
                                    </div>
                                    <div class="form-group ">
                                    <label class="control-label requiredField" for="btn_login_settings" >
                                        <strong> Mostrar configurações no login</strong>
                                    </label>
                                    <select class="select form-control text-muted" id="select" name="btn_login_settings">
									    <option value="Yes"<?=$json['btn_login_settings']=='Yes'?'selected':'' ?>>Habilitado</option>
                                        <option value="no" <?=$json['btn_login_settings']=='no'?'selected':'' ?>>Desabilitado</option>
									</select>
                                    </div>
                                    </br>
								 <div class="form-group">
                                    <div>
                                     </div>   
                        <button class="btn btn-primary" name="submit_support" type="submit">
                                    <i class="fa fa-check"></i><strong> Atualizar as configurações do aplicativo</strong>
                                </button>
                        </div>
                            </form>
                        </div>
                    </div>
                    </div>

              <?php include ('includes/footer.php');?>
  <script> 
$(document).ready(function () {
    $("#flash-msg").delay(3000).fadeOut("slow");
});
  </script>
</body>
