<?php

Include("includes/con_cliente.php");

 require_once('connection.php');
    session_start();

    if(isset($_SESSION['User']))
    {
        $query="select * from tbusuario where nomeuser='".$_SESSION['User']."'";
        $result=mysqli_query($con,$query);
        $resultado = mysqli_fetch_assoc($result);
        $r_resultado = $resultado;
        //echo $resultado["nome"] .'<br>';
    }
    else
    {
        header("location:index.php");
    }
?>





<html>
 <head>

    	<meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <title>Sistema SCA - Grupo BRO</title>

        <link rel="stylesheet" href="node_modules/bootstrap/compiler/bootstrap.css">
        <link rel="stylesheet" href="node_modules/bootstrap/compiler/styler.css">

        <!--<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" /> -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
        <link rel="stylesheet" href="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/build/css/bootstrap-datetimepicker.css" />

        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.js"></script>
        <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/src/js/bootstrap-datetimepicker.js"></script>


 </head>
    <body >

        <nav class="navbar fixed-top navbar-expand-lg navbar-dark" style="background-color: #3333ff;">
          <!--<a class="navbar-brand" href="#">SCA</a> -->
          <a class="navbar-brand" href="menu.php">
                <img src="img/logomarca.png" width="50" height="40" class="d-inline-block align-center" alt="">
                SCA - Controle de Veículos - Relação de Veículos
          </a>

          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>

          </button>
          <div class="collapse navbar-collapse" id="navbarTogglerDemo02">
            <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
            </ul>
            <form class="form-inline my-2 my-lg-0">
                <button type="button" class="btn btn-primary btn-sm" href="cv.php" style = "margin:2px;">
                <a href="lstvservicos.php" style="color:inherit"> Serviços </a></button>
              <button type="button" class="btn btn-primary btn-sm" href="cv.php" style = "margin:2px;">
                <a href="cv.php" style="color:inherit"> Novo </a></button>
              <button type="button" class="btn btn-primary btn-sm" href="cv.php" style = "margin:2px;">
                <a href="lstveiculos.php" style="color:inherit"> Alterar </a></button>
              <button class="btn btn-primary btn-sm my-2 my-sm-0">
                <a href="m.php" style="color:inherit"> Sair </a></button>
            </form>
          </div>
        </nav>

    	

<script type="text/javascript">
    $(function () {
        $('#datetimepicker6').datetimepicker({
            format: 'L'
        });
        $('#datetimepicker7').datetimepicker({
            format: 'L'

        });
        
    });
</script>




        <?php
        $connect = mysqli_connect('127.0.0.1', 'root', 'fcf2778@', 'administrativo');
        if(mysqli_connect_errno($connect)){
        echo 'Falha ao conectar com o Banco de Dados !'.mysqli_connect_error();}


        $result= mysqli_query($connect, "SELECT tbveiculos.vplaca, tbveiculos.vmarca, tbveiculos.vmodelo, tbveiculos.vkmatual, Count(tbservicos.srvstatus) AS srvstatus
                                        FROM tbservicos RIGHT JOIN tbveiculos ON tbservicos.srvplaca = tbveiculos.vplaca
                                        GROUP BY tbveiculos.vplaca, tbveiculos.vmarca, tbveiculos.vmodelo, tbveiculos.vkmatual, tbveiculos.vicativo
                                        HAVING (((tbveiculos.vicativo)='Ativo'))");


        


        $carcolor = '#87CEFA';
        ?>
        




    <div style="margin-top: 7rem">    
        <div class="row mb-5 mx-5">
            <?php while($rows = mysqli_fetch_array($result)): ?>
            <div class="col-sm-2 my-2">
                
                <!--<div class="card-body border border-dark rounded" style="background-color: #87CEFA;"> -->
                <!--<div class="card-body border border-dark rounded" style="background-color: <?php echo $carcolor;?>;"> -->
                <div class="card-body border border-dark rounded"<?php if ($rows['srvstatus'] <> '0') {echo ' style="background-color:#EEE8AA;"';}?>style="background-color: <?php echo $carcolor;?>;">
                    <h4 class="card-title bg-gradient-secondary text-center rounded"><?php echo $rows['vplaca']; ?></h4>
                    <h6 class="card-subtitle mb-2 text-muted"><?php echo $rows['vmarca']; ?></h6>
                    <h8 class="card-subtitle mb-2 text-muted"><?php echo $rows['vmodelo']; ?></h8>
                    <p class="card-text">Km Atual: <?php echo $rows['vkmatual']; ?></p>
                    <!--<a> <?php echo $rows['srvstatus']; ?></a> -->
                    <!--<input name="txtplaca" value="<?php echo $rows['srvstatus']; ?>"> -->
                    <button class="btn btn-outline-secondary" type="Serviço">
                        <a href="srvnovo.php?id=<?php echo $rows['vplaca']; ?>" style="color:inherit">Solicitar Serviço</a>
                           
                    </button>
                    
                </div>
            </div>
            <?php endwhile; ?>
        </div>
    </div>

            
    <script src="js/jquery.js"></script> 
    <script src="js/bootstrap.min.js"></script>

    </body>
    <footer class="page-footer font-small text-primary "style="margin-top: 6rem">
          <div class="footer-copyright text-center py-3">© 2019 Copyright: Brasil Ortopedia
          </div>
    </footer>

        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>


</html>