<?php 
require_once ("includes/topo.php");  

$query = $pdo->query("SELECT * FROM config");
$config_visu = $query->fetchAll(PDO::FETCH_ASSOC);
$total_reg = @count($config_visu);

?>

<div class="content-body">
    <div class="container-fluid">
        <div class="row">
            <div class="col-xl-12">
                <div class="row">
                    
                    <div class="col-xl-9 col-lg-8">
                        <div class="card">
                            <div class="card-header">
                                <h4 class="card-title">Configurações</h4>
                                
                            </div>
                            <div class="card-body">
                                <div class="basic-form">
                                    <form action="class_update_config.php" method="post">

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">Nome site</label>
                                            <div class="col-sm-9">
                                                <input type="text" name="nome_site" class="form-control" value="<?php echo $config_visu[0]['nome_site'] ?>" placeholder="" Required>
                                                
                                            </div>
                                        </div>

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">Endereço</label>
                                            <div class="col-sm-9">
                                                <input type="text" name="endereco" class="form-control" value="<?php echo $config_visu[0]['endereco'] ?>" placeholder="Endereço" Required>
                                                
                                            </div>
                                        </div>

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">CEP</label>
                                            <div class="col-sm-9">
                                                <input type="text" name="cep" class="form-control" value="<?php echo $config_visu[0]['cep'] ?>" placeholder="CEP" Required>
                                                
                                            </div>
                                        </div>

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">Cidade</label>
                                            <div class="col-sm-9">
                                                <input type="text" name="cidade" class="form-control" value="<?php echo $config_visu[0]['cidade'] ?>" placeholder="Cidade" Required>
                                                
                                            </div>
                                        </div>

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">Telefone</label>
                                            <div class="col-sm-9">
                                                <input type="text" name="telefone" class="form-control" value="<?php echo $config_visu[0]['telefone'] ?>" placeholder="Telefone" Required>
                                                
                                            </div>
                                        </div>

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">Whatsapp número</label>
                                            <div class="col-sm-9">

                                                <div class="input-group mb-3 input-success-o">
                                                    <span class="input-group-text"><i class="bi bi-whatsapp"></i></span>
                                                    <input name="whatsapp_numero" type="text" class="form-control" value="<?php echo $config_visu[0]['whatsapp_numero'] ?>" placeholder="Número do WhatsApp">
                                                </div>

                                            </div>
                                        </div>

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">WhatsApp link</label>
                                            <div class="col-sm-9">
                                                <div class="input-group mb-3  input-success"><span class="input-group-text"><i class="bi bi-whatsapp"></i></span>
                                                    <span class="input-group-text border-0"> https://api.whatsapp.com/send?phone=55</span>
                                                    
                                                    <input type="text" name="whatsapp_link" class="form-control" value="<?php echo $config_visu[0]['whatsapp_link'] ?>" placeholder="64980000000">
                                                </div>

                                            </div>
                                        </div>

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">E-mail</label>
                                            <div class="col-sm-9">
                                                <div class="input-group mb-3 input-success-o">
                                                    <span class="input-group-text">@</span>
                                                    <input type="email" name="email" class="form-control" value="<?php echo $config_visu[0]['email'] ?>" placeholder="E-mail" required>
                                                </div>

                                            </div>
                                        </div>

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">Facebook</label>
                                            <div class="col-sm-9">
                                                <input type="text" name="facebook" class="form-control" value="<?php echo $config_visu[0]['facebook'] ?>" placeholder="Facebook" Required>
                                                
                                            </div>
                                        </div>

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">Instagram</label>
                                            <div class="col-sm-9">
                                                <input type="text" name="instagram" class="form-control" value="<?php echo $config_visu[0]['instagram'] ?>" placeholder="Instagram" Required>
                                                
                                            </div>
                                        </div>

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">Meta tags</label>
                                            <div class="col-sm-9">
                                                <input type="text" name="meta_tags" class="form-control" value="<?php echo $config_visu[0]['meta_tags'] ?>" placeholder="Meta tags" Required>
                                                
                                            </div>
                                        </div>

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">Meta descriptions</label>
                                            <div class="col-sm-9">
                                                <input type="text" name="meta_descriptions" class="form-control" value="<?php echo $config_visu[0]['meta_descriptions'] ?>" placeholder="Meta descriptions" Required>
                                                
                                            </div>
                                        </div>

                                        <div class="mb-3 row">
                                            <label class="col-sm-3 col-form-label">Google maps</label>
                                            <div class="col-sm-9">
                                                <input type="text" name="google_maps" class="form-control" value="<?php echo $config_visu[0]['google_maps'] ?>" placeholder="Google maps" Required>
                                                
                                            </div>
                                        </div>

                                        
                                        
                                        
                                        
                                        <div class="mb-3 row">
                                            <div class="col-sm-10">
                                                <button type="submit" class="btn btn-primary">Atualizar</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
					</div>


                    <div class="col-xl-3 col-lg-4">
						<div class="clearfix">
							<div class="card card-bx profile-card author-profile m-b30">
								<div class="card-body">
									<div class="p-5">
										<div class="author-profile">
                                            <div>
												<h4 class="title">Logo principal:</h4>
											</div>
											<div class="col-md-12">
												<img src="images/logos/<?php echo $config_visu[0]['logo'] ?>" width="100%" alt="">   
											</div>
                                            <hr>
                                            <form method="post" action="atualizar_logos.php?logo=1" enctype="multipart/form-data">

                                                <input class="form-control" name="logo" type="file" id="formFile" Required>
                                                <input type="submit" class="btn btn-outline-primary btn-xs alinhatopbotao" value="Atualizar logo">
                                            </form>

                                            <hr>
                                            <div>
												<h4 class="title">Logo 2:</h4>
											</div>
                                            <div class="col-md-12">
												<img src="images/logos/<?php echo $config_visu[0]['logo_secundario'] ?>" width="100%" alt="">   
											</div>
                                            <hr>
                                            <form method="post" action="atualizar_logos.php?logo=2" enctype="multipart/form-data">

                                                <input class="form-control" name="logo_secundario" type="file" id="formFile" Required>
                                                <input type="submit" class="btn btn-outline-primary btn-xs alinhatopbotao" value="Atualizar Logo 2">
                                            </form>

                                            <hr>
                                            <div>
												<h4 class="title">Favicon:</h4>
											</div>
                                            <div class="col-md-12">
												<img src="images/logos/<?php echo $config_visu[0]['favicon'] ?>" width="30%" alt="">   
											</div>
                                            <hr>
                                            <form method="post" action="atualizar_logos.php?logo=3" enctype="multipart/form-data">

                                                <input class="form-control" name="favicon" type="file" id="formFile" Required>
                                                <input type="submit" class="btn btn-outline-primary btn-xs alinhatopbotao" value="Atualizar Favicon">
                                            </form>

                                            <hr>
                                            <div>
												<h4 class="title">Imagem topo páginas:</h4>
											</div>
                                            <div class="col-md-12">
												<img src="images/logos/<?php echo $config_visu[0]['img_topo'] ?>" width="100%" alt="">   
											</div>
                                            <hr>
                                            <form method="post" action="atualizar_logos.php?imgtopo=4" enctype="multipart/form-data">

                                                <input class="form-control" name="img_topo" type="file" id="formFile" Required>
                                                <input type="submit" class="btn btn-outline-primary btn-xs alinhatopbotao" value="Atualizar imagem topo">
                                            </form>

                                            <!--
                                            <hr>
                                            <div>
												<h4 class="title">Imagem fundo Serviços HOME:</h4>
                                                <p>Imagem de fundo que representa o módulo Conheça nossos serviços.</p>
											</div>
                                            <div class="col-md-12">
												<img src="images/logos/<?php echo $config_visu[0]['img_home1'] ?>" width="100%" alt="">   
											</div>
                                            <hr>
                                            <form method="post" action="atualizar_logos.php?imghome1=5" enctype="multipart/form-data">

                                                <input class="form-control" name="img_home1" type="file" id="formFile" Required>
                                                <input type="submit" class="btn btn-outline-primary btn-xs alinhatopbotao" value="Atualizar imagem">
                                            </form>
                                            -->

										</div>
									</div>
									
								</div>
								
							</div>
						</div>
					</div>


                
                </div>
            </div>
            
        </div>
    </div>
</div>

<?php require_once ("includes/rodape.php");  ?>

<?php if(!empty($_GET['atualizado']) == "ok" ) { ?>           		
<script>
	window.onload = function() {
		swal({
			title: 'Sucesso',
			text: ("Configurações atualizadas!"),
			type: 'success',
			confirmButtonText: 'Fechar'
		})
	};
</script>
<?php } ?>

<?php if(!empty($_GET['imagem']) == "ok" ) { ?>           		
<script>
	window.onload = function() {
		swal({
			title: 'Sucesso',
			text: ("Imagem enviada com sucesso!"),
			type: 'success',
			confirmButtonText: 'Fechar'
		})
	};
</script>
<?php } ?>