<?php 
error_reporting(0);
ini_set(“display_errors”, 0 );
include "protege_professor.php";
$idempreendimento = $_GET["idempreendimento"];
?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->


<head>
	<meta charset="utf-8" />
	<title>Immobile | Business</title>
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
	<meta content="" name="description" />
	<meta content="" name="author" />
	
	<!-- ================== BEGIN BASE CSS STYLE ================== -->
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
    <link href="https://immobilebusiness.com.br/admin/assets/plugins/jquery-ui/themes/base/minified/jquery-ui.min.css" rel="stylesheet" />
    <link href="https://immobilebusiness.com.br/admin/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="https://immobilebusiness.com.br/admin/assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <link href="https://immobilebusiness.com.br/admin/assets/css/animate.min.css" rel="stylesheet" />
    <link href="https://immobilebusiness.com.br/admin/assets/css/style.min.css" rel="stylesheet" />
    <link href="https://immobilebusiness.com.br/admin/assets/css/style-responsive.min.css" rel="stylesheet" />
    <link href="https://immobilebusiness.com.br/admin/assets/css/theme/default.css" rel="stylesheet" id="theme" />
    <!-- ================== END BASE CSS STYLE ================== -->
    
    <!-- ================== BEGIN PAGE LEVEL STYLE ================== -->
    <link href="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/media/css/dataTables.bootstrap.min.css" rel="stylesheet" />
    <link href="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/extensions/Buttons/css/buttons.bootstrap.min.css" rel="stylesheet" />
    <link href="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/extensions/Responsive/css/responsive.bootstrap.min.css" rel="stylesheet" />
    <!-- ================== END PAGE LEVEL STYLE ================== -->
    
    <!-- ================== BEGIN BASE JS ================== -->
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/pace/pace.min.js"></script>

 

<script type="text/javascript">
  
   function verificaStatus(nome){
                   if(nome.form.tudo.checked == 0)
                   {
                      nome.form.tudo.checked = 1;
                      marcarTodos(nome);
                 }
                 else
                 {
                      nome.form.tudo.checked = 0;
                      desmarcarTodos(nome);
                 }
            }

            function marcarTodos(nome){
              for (i=0;i<nome.form.elements.length;i++)
                 if(nome.form.elements[i].type == "checkbox")
                    nome.form.elements[i].checked=0
          }

          function desmarcarTodos(nome){
            for (i=0;i<nome.form.elements.length;i++)
               if(nome.form.elements[i].type == "checkbox")
                  nome.form.elements[i].checked=1
        }





         function lote_massa(id){

         document.nome.action = "lote_massa.php?acao="+id;
         document.nome.submit();

    }

     function remove_lote(){

         document.nome.action = "remove_lote.php";
         document.nome.submit();

    }

</script>

 

</head>
<body>
 
	<!-- begin #page-loader -->
	<div id="page-loader" class="fade in"><span class="spinner"></span></div>
	<!-- end #page-loader -->
	
	<!-- begin #page-container -->
	<div id="page-container" class="fade page-sidebar-fixed page-header-fixed">
		<!-- begin #header -->
	

		
	<?php include "topo.php"


   ?>
		
		<!-- begin #content -->
		<div id="content" class="content">
			     <ol class="breadcrumb pull-right">

        <li>
            <div class="btn-group m-r-5 m-b-5">
              <a href="#excluir_quadra" data-toggle="modal" class="btn btn-danger dropdown-toggle" aria-expanded="false">Excluir Quadra</a>
              
            </div>
      </li>


        <li>
            <div class="btn-group m-r-5 m-b-5">
              <a href="#" onclick="remove_lote()" class="btn btn-danger dropdown-toggle" aria-expanded="false">Excluir Lote</a>
              
            </div>
      </li>
        
     

      <li>
            <div class="btn-group m-r-5 m-b-5">
              <a href="javascript:;" data-toggle="dropdown" class="btn btn-success dropdown-toggle" aria-expanded="false">Alterar Preço <span class="caret"></span></a>
              <ul class="dropdown-menu">              
                <li><a href="#alterar_preco" data-toggle="modal">Percentual</a></li>
                <li><a href="#alterar_preco_real" data-toggle="modal">Valor R$ </a></li>
           
              </ul>
            </div>
      </li>

      <li>
            <div class="btn-group m-r-5 m-b-5">
              <a href="javascript:;" data-toggle="dropdown" class="btn btn-success dropdown-toggle" aria-expanded="false">Alterar Status <span class="caret"></span></a>
              <ul class="dropdown-menu">              
                <li><a href="#" onclick="lote_massa(1)">Marcar Disponivel</a></li>
                <li><a href="#" onclick="lote_massa(0)">Marcar Reservado</a></li>
                <li><a href="#" onclick="lote_massa(2)">Marcar Vendido</a></li>
                <li><a href="#" onclick="lote_massa(3)">Marcar Bloqueado</a></li>
              </ul>
            </div>
      </li>



      </ol>
			<!-- begin page-header -->
			<h1 class="page-header">Cadastro Quadra, Lote | Empreendimento: <?php echo " $descricao"; ?> </h1>
			<!-- end page-header -->

			<!-- begin row -->
			<div class="row">
        <!-- begin col-6 -->
        <div class="col-md-12">
         <!-- begin panel -->
         <div class="panel panel-inverse" data-sortable-id="form-plugins-11">
          <div class="panel-heading">
            <div class="panel-heading-btn">
              <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
              <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-repeat"></i></a>
              <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
              <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-danger" data-click="panel-remove"><i class="fa fa-times"></i></a>
            </div>
            <h4 class="panel-title">Informações</h4>                            
          </div><br>

          <div class="panel-body panel-form">
            <form action="cadastro_quadra.php?idempreendimento=<?php echo $idempreendimento ?>" method="POST">  
              <div class="col-md-6 form-group">
                    <label class="control-label">Quadra</label>
                    <select name="busca_quadra" id="busca_quadra" class="form-control">
                      <option value="">Escolha</option>
                      <?php
                          include "conexao.php";

                              $query_amigo = "SELECT * FROM produto
                                              WHERE empreendimento_idempreendimento = $idempreendimento order by CAST(quadra as UNSIGNED) Asc";
                              $executa_query = mysqli_query($db, $query_amigo) or die("Erro ao listar empreendimento");


                               while ($buscar_amigo = mysqli_fetch_assoc($executa_query)) { //--verifica se são amigos

                                              $quadra     = $buscar_amigo['quadra'];
                                              $idproduto  = $buscar_amigo["idproduto"];

                        ?>
                        <option value="<?php echo "$idproduto" ?>"> <?php echo "$quadra" ?> </option>
                      <?php } ?>
                    </select>
              </div><br>
              <div class="col-md-12" style="text-align: left !important">
                <input type="submit" name="consultar" value="Consultar" class="btn btn-primary">
              </div><br>
              <div class="col-md-12" style="text-align: right !important">
                <a href="#nova_quadra" data-toggle="modal"><button name="botao" class="btn btn-sm btn-success" value="Consultar" />Nova Quadra</button></a>
                <a href="#novo_lote" data-toggle="modal"><button name="botao" class="btn btn-sm btn-primary" value="Consultar" />Novo Lote</button></a>
              </div><br>
            </form>

          </div>
        </div>
        <!-- end panel -->
      </div>




           
   <?php if(isset($_POST["busca_quadra"])){ 
    $busca_quadra = $_POST["busca_quadra"];
    ?> 	
   
   <div class="col-md-12">
    <!-- begin panel -->
    <div class="panel panel-inverse">
      <div class="panel-heading">
        <div class="panel-heading-btn">
          <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
          <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-repeat"></i></a>
          <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
          <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-danger" data-click="panel-remove"><i class="fa fa-times"></i></a>
        </div>
        <h4 class="panel-title">Lotes Cadastrados</h4>
      </div>

      <div class="panel-body">
         <form action="#" method="POST" id="nome" name="nome">
          <input type="hidden" name="idempreendimento" value="<?php echo $idempreendimento ?>">
        <table id="data-table" class="table table-striped table-bordered">
          <thead>
            <tr>
            <th><input id="sel-tudo1" type='checkbox' name='tudo' onclick="verificaStatus(this)" /></th>

              <th>ID Lote</th>
              <th>Quadra</th>
              <th>Lote</th>
              <th>M2</th>
              <th>Status</th>
              <th>Valor</th>
              <th>Motivo Bloqueio</th>
              <th>Observação</th>
              <th></th>
             

            </tr>
          </thead>
          <tbody>

            <?php 
            $where = "idlote > 0 AND empreendimento_idempreendimento = $idempreendimento";
            if($busca_quadra == '' or $busca_quadra == 0){
              $where .= "";
            }else{
              $where .=" AND produto_idproduto = ".$busca_quadra;
            }

            include "conexao.php";
            $query_slide = mysqli_query($db, "SELECT * FROM lote
              INNER join produto on produto.idproduto = lote.produto_idproduto
              where $where
              order by idlote desc"); 


            while ($buscar_slide = mysqli_fetch_assoc($query_slide)) {//--While categoria
             $idlote      = $buscar_slide["idlote"];
             $quadra      = $buscar_slide["quadra"];
             $lote        = $buscar_slide["lote"];
             $m2          = $buscar_slide["m2"];
             $status          = $buscar_slide["status"];
             $valor       = $buscar_slide["valor"];

             $matricula           = $buscar_slide["matricula"];
             $cadastro_prefeitura = $buscar_slide["cadastro_prefeitura"];
             $confrontacao        = $buscar_slide["confrontacao"];
             $endereco            = $buscar_slide["endereco"];
             $motivo_bloqueio     = $buscar_slide["motivo_bloqueio"];

             $idproduto       = $buscar_slide["produto_idproduto"];
             $obs_lote       = $buscar_slide["obs_lote"];


             if($status == 0){
              $status_desc = '<span class="label label-warning">Reservado</span>';
            }
            if($status == 1){
              $status_desc = '<span class="label label-success">Disponivel</span>';
            }
            if($status == 2){
              $status_desc = '<span class="label label-danger">Vendido</span>';
            }
            if($status == 3){
              $status_desc = '<span class="label label-inverse">Bloqueado</span>';
            }

            ?> 

            <tr class="odd gradeX">
              <td><input type="checkbox" name="lote_ids[]" value='<?php echo  $idlote ?>'></td>
              <td><?php echo "$idlote" ?></td>
              <td><?php echo "$quadra" ?></td>
              <td><?php echo "$lote" ?></td>
              <td><?php echo "$m2" ?></td>
              <td><?php echo "$status_desc" ?></td>
              <td><?php echo 'R$ ' . number_format($valor, 2, ',', '.');  ?> </td>
              <td><?php echo "$motivo_bloqueio" ?></td>
              <td><?php echo "$obs_lote" ?></td>
              <td><?php echo "$obs_lote" ?></td>
              <td><a href="editar_lote.php?lote=<?php echo $idlote ?>&idproduto=<?php echo $idproduto ?>">  <span class="label label-warning">Editar Lote</span></a></td>

                                   



            </tr>

          <?php } ?>









        </tbody>

      </table>
          <div class="modal modal-message fade" id="alterar_preco" style="display: none;">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
              <h4 class="modal-title">Ajuste de preço</h4>
            </div>
              <div class="modal-body">
                <div class="form-group">Informe o percentual de reajuste %:
                  <input type="text" name="percen_reajuste" id="percen_reajuste" class="form-control">
                </div>
              </div>
              <div class="modal-footer">
                <input type="submit" name="cadastro_percentual" value="Alterar Preço" class="btn btn-success" />
              </div>
           
          </div>
        </div>
      </div>




                <div class="modal modal-message fade" id="alterar_preco_real" style="display: none;">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
              <h4 class="modal-title">Ajuste de preço</h4>
            </div>
              <div class="modal-body">
                <div class="form-group">Informe o novo valor em R$ :
                  <input type="text" name="percen_reajuste_real" id="percen_reajuste_real" class="form-control">
                </div>
              </div>
              <div class="modal-footer">
                <input type="submit" name="cadastro_real" value="Alterar Preço" class="btn btn-success" />
              </div>
           
          </div>
        </div>
      </div>

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

</div>
<?php } ?>




            </div>
            <!-- end row -->
     <div class="modal  fade" id="excluir_quadra" role="dialog" style="display: none;">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
               <ul class="nav nav-tabs quadra" style="margin-left: -15px; margin-right: -15px;">  
              <button type="button" style="color: white; opacity: 2; margin-bottom: 10px; margin-right: 15px; margin-top: 15px;" class="close" data-dismiss="modal" aria-hidden="true">×</button>
              <h5 class="modal-title" style="color: white; margin-left: 15px; margin-top: 10px; opacity: 2;">Selecione as quadras para excluir</h5>
            </div>
            <form class="form-action" action="cadastro_quadra.php?idempreendimento=<?php echo $idempreendimento ?>" method="POST" enctype="multipart/form-data">
              <div class="modal-body">
                 <table id="data-table" class="table table-striped table-bordered">
          <thead>
            <tr>
            <th><input id="sel-tudo1" type='checkbox' name='tudo' onclick="verificaStatusq(this)" /></th>

            
              <th>Quadra</th>   

            </tr>
          </thead>
          <tbody>

            <?php 
           
            include "conexao.php";
            $query_produto = mysqli_query($db, "SELECT * FROM produto where empreendimento_idempreendimento = $idempreendimento order by quadra Asc"); 


            while ($buscar_produto = mysqli_fetch_assoc($query_produto)) {//--While categoria
             $idproduto      = $buscar_produto["idproduto"];
             $quadra         = $buscar_produto["quadra"];
              

              $query_produto_lote = mysqli_query($db, "SELECT idlote FROM lote where produto_idproduto = $idproduto"); 
              $total_produto = mysqli_num_rows($query_produto_lote);

              if($total_produto == '0'){
            ?> 

            <tr class="odd gradeX">
              <td><input type="checkbox" name="produto_ids[]" value='<?php echo  $idproduto ?>'></td>
              <td><?php echo "$quadra" ?></td>
               
            </tr>

          <?php } }?>

        </tbody>

      </table>
              </div>
              <div class="modal-footer">
                <input type="submit" name="confirma_excluir" value="Confirmar Exclusão" class="btn btn-danger" />
              </div>
            </form>
          </div>
        </div>
      </div>

<!--
      <div class="modal modal-message fade" id="nova_quadra" style="display: none;">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
              <h4 class="modal-title">Nova Quadra</h4>
            </div>
            <form class="form-action" action="cadastro_quadra.php?idempreendimento=<?php echo $idempreendimento ?>&quadra=1" method="POST" enctype="multipart/form-data">
              <div class="modal-body">
                <div class="form-group">Sigla:
                  <input type="text" name="quadra" class="form-control">
                </div>
              </div>
              <div class="modal-footer">
                <input type="submit" name="cadastrar" value="Cadastrar Quadra" class="btn btn-success" />
              </div>
            </form>
          </div>
        </div>
      </div>


-->


                                       <!--    MODAL QUADRA     --> 

<div class="modal fade" id="nova_quadra" role="dialog" style="display: none;">  
   <div class="modal-dialog">                                         
        <div class="modal-content">                                         
             <button type="button" style="color: white; opacity: 2; margin-bottom: 10px; margin-right: 15px;"  class="close" data-dismiss="modal" aria-hidden="true">×</button>
             <style>

              .quadra{
                background-color: #1a2229;
                margin-top: -30px;
              }
              .quadra_mod{
                color: white;
                font-weight: bold;
              }
              .quadra_mod:hover{
               color: black;
               font-weight: bold;0
             }                                         
           </style>
           <div class="modal-header">
            <!-- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> -->
            <ul class="nav nav-tabs quadra" style="margin-left: -15px; margin-right: -15px">  
              <h4 class="modal-title" style="color: white; margin-left: 15px; margin-top: 10px; opacity: 2;">Nova Quadra</h4>   
            </ul>
          </div>
           <div class="modal-body">  
            <!-- <div class="tab-content"> -->
              <div id="cadastrar" class="tab-pane fade in active">
                <form class="form-action" id="form_cadast_quadra" action="cadastro_quadra.php?idempreendimento=<?php echo $idempreendimento ?>&quadra=1" method="POST" enctype="multipart/form-data">
                 
                    <div class="row">             
                      <div class="form-group col-md-10">
                        <label>Sigla :</label>
                        <div class="controls">
                          <input type="text" class="form-control" id="nova_quadra"  name="quadra" placeholder="Sigla da Nova Quadra" />
                        </div>
                      </div>           
                    </div>      
                </form>
              </div>
            <!-- </div> -->
          </div>
        <div class="modal-footer" style="height: 75px; padding: 20px;">
          <input type="submit" id="cadastro_quadra_btn"  name="cadastrar" value="Cadastrar Quadra" class="btn btn-success" />
        </div>
      </div>
  </div>
</div>


                                          <!--    MODAL LOTE     --> 


        <div class="modal fade col-md-12" id="novo_lote" style="display: none;">  
            <div class="modal-dialog modal-lg">  
                <div class="modal-content">
                   <button type="button" style="color: white; opacity: 2; margin-bottom: 10px; margin-right: 15px;"  class="close" data-dismiss="modal" aria-hidden="true">×</button> 
                  <style>
                    .lote{
                      background-color: #1a2229;
                      margin-top: -30px;
                    }
                    .lote_mod{
                      color: white;
                      font-weight: bold;
                    }
                    .lote_mod:hover{
                     color: black;
                     font-weight: bold;
                    }                                       
                   </style>
                     <div class="modal-header" style="border-style: hidden;">
                      <!-- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> -->
                       <ul class="nav nav-tabs lote" style="margin-left: -15px; margin-right: -15px">  
                      <h4 class="modal-title" style="color: white; margin-left: 15px; margin-top: 10px; opacity: 2;">Novo Lote</h4>   
                    </ul>
                    </div>

                  <div class="modal-body">                  
                           <form class="form-action" id="form_cadastra_lote" action="cadastro_quadra.php?idempreendimento=<?php echo $idempreendimento ?>" method="POST" enctype="multipart/form-data">

                              <div class="col-md-6">
                              <label class="control-label">Quadra:</label>

                                  <select name="quadra_id" id="quadra_id" class="form-control" required="">
                                    <option value="">Escolha</option>
                                    <?php

                                    include "conexao.php";

                                    $query_amigo = "SELECT * FROM produto
                                    WHERE empreendimento_idempreendimento = $idempreendimento order by CAST(quadra as UNSIGNED) Asc";
                                    $executa_query = mysqli_query($db, $query_amigo) or die("Erro ao listar empreendimento");


                                    while ($buscar_amigo = mysqli_fetch_assoc($executa_query)) { //--verifica se são amigos

                                      $quadra  = $buscar_amigo['quadra'];
                                      $idproduto = $buscar_amigo["idproduto"];

                                      ?>
                                      <option value="<?php echo "$idproduto" ?>"> <?php echo "$quadra" ?> </option>

                                    <?php } ?>

                                  </select>
                              </div> 
                              <div class="form-group col-md-6">
                                  <label class="control-label">Lote</label>
                                  <input type="text" name="lote" class="form-control" required="">
                              </div>

                              <div class="form-group col-md-6">
                                  <label class="control-label">M²</label>
                                  <input type="text" name="m2" class="form-control" required="">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">Valor</label>
                                  <input type="text" name="valor" id="valor_inicial2" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">Endereço</label>
                                  <input type="text" name="endereco_lote" id="endereco_lote" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">Matricula</label>
                                  <input type="text" name="matricula" id="matricula" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">Cadastro Prefeitura</label>
                                  <input type="text" name="cad_pre" id="cad_pre" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">Frente</label>
                                  <input type="text" name="frente" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">Fundo</label>
                                  <input type="text" name="fundo" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">Direito</label>
                                  <input type="text" name="direito" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">Esquerdo</label>
                                  <input type="text" name="esquerdo" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">M. Outros</label>
                                  <input type="text" name="moutros" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">C. Frente</label>
                                  <input type="text" name="cfrente" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">C. Fundo</label>
                                  <input type="text" name="cfundo" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">C. Direito</label>
                                  <input type="text" name="cdireito" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">C. Esquerdo</label>
                                  <input type="text" name="cesquerdo" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">C. Outros</label>
                                  <input type="text" name="coutros" class="form-control">
                              </div>
                              <div class="form-group col-md-6">
                                  <label class="control-label">Observação</label>
                                  <textarea class="form-control" name="obs_lote" rows="5" cols="5"></textarea>   
                              </div>
                          </form>

                         
                  </div>

                   <div class="modal-footer" style="border-style: hidden;">
                      <input type="submit" name="cadastrar" value="Cadastrar Lote" form="form_cadastra_lote" class="btn btn-success" />
                    </div> 
                </div>
            </div>
                           
		
	
     
		
		<!-- begin scroll to top btn -->
		<a href="javascript:;" class="btn btn-icon btn-circle btn-success btn-scroll-to-top fade" data-click="scroll-top"><i class="fa fa-angle-up"></i></a>
		<!-- end scroll to top btn -->
	</div>
	<!-- end page container -->
	
<script src="https://immobilebusiness.com.br/admin/assets/plugins/jquery/jquery-1.9.1.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

<script src="https://immobilebusiness.com.br/admin/assets/js/jquery.maskMoney.js" type="text/javascript"></script>

 <script type="text/javascript">
$(function(){
$("#percen_reajuste").maskMoney({symbol:'', 
showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
 })

$(function(){
$("#percen_reajuste_real").maskMoney({symbol:'R$ ', 
showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
 })

$(function(){
$("#valor_inicial2").maskMoney({symbol:'R$ ', 
showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
 })

$(function(){
$("#valor_aluguel2").maskMoney({symbol:'R$ ', 
showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
 })
</script>


    <!-- ================== BEGIN BASE JS ================== -->
  
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/jquery/jquery-migrate-1.1.0.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/jquery-ui/ui/minified/jquery-ui.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/bootstrap/js/bootstrap.min.js"></script>
    <!--[if lt IE 9]>
        <script src="https://immobilebusiness.com.br/admin/assets/crossbrowserjs/html5shiv.js"></script>
        <script src="https://immobilebusiness.com.br/admin/assets/crossbrowserjs/respond.min.js"></script>
        <script src="https://immobilebusiness.com.br/admin/assets/crossbrowserjs/excanvas.min.js"></script>
    <![endif]-->
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/jquery-cookie/jquery.cookie.js"></script>
    <!-- ================== END BASE JS ================== -->
    
    <!-- ================== BEGIN PAGE LEVEL JS ================== -->
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/media/js/jquery.dataTables.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/media/js/dataTables.bootstrap.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/extensions/Buttons/js/dataTables.buttons.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/extensions/Buttons/js/buttons.bootstrap.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/extensions/Buttons/js/buttons.flash.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/extensions/Buttons/js/jszip.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/extensions/Buttons/js/pdfmake.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/extensions/Buttons/js/vfs_fonts.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/extensions/Buttons/js/buttons.html5.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/extensions/Buttons/js/buttons.print.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/plugins/DataTables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/js/table-manage-buttons.demo.min.js"></script>
    <script src="https://immobilebusiness.com.br/admin/assets/js/apps.min.js"></script>
    <!-- ================== END PAGE LEVEL JS ================== -->
    
    <script>
        $(document).ready(function() {
            App.init();
            TableManageButtons.init();
        });
    </script>
<?php
    if(isset($_POST["confirma_excluir"])){
  $produto_ids    = $_POST["produto_ids"]; 
  include "conexao.php";
  foreach ($produto_ids as $id) {
    $deleta_quadra = mysqli_query($db, "DELETE FROM produto WHERE idproduto = $id");
  }
  ?><script>swal("Ok", "Quadra Excluida com Sucesso!", "success")</script><?php
}

if(isset($_POST["cadastro_percentual"])){
  $lote_ids    = $_POST["lote_ids"];   
  $percen_reajuste = $_POST["percen_reajuste"];
  $percen_reajuste = str_replace(",", ".", $percen_reajuste);
  $percen_reajuste = $percen_reajuste / 100;
  include "conexao.php";
  foreach ($lote_ids as $id) {
    $ajusta = "UPDATE lote set valor = (valor + (valor * '$percen_reajuste')) WHERE idlote = $id";
    $executa_ajuste = mysqli_query($db, $ajusta);

  }

  ?><script>swal("Ok", "Reajuste feito com Sucesso!", "success")</script><?php
 
}

if(isset($_POST["cadastro_real"])){
  $lote_ids    = $_POST["lote_ids"];   
  $percen_reajuste_real = $_POST["percen_reajuste_real"];
  $percen_reajuste_real = str_replace("R$", "", $percen_reajuste_real);
  $percen_reajuste_real = str_replace(".", "",  $percen_reajuste_real);
  $percen_reajuste_real = str_replace(",", ".", $percen_reajuste_real);
  include "conexao.php";
  foreach ($lote_ids as $id) {
    $ajusta = "UPDATE lote set valor = '$percen_reajuste_real' WHERE idlote = $id";
    $executa_ajuste = mysqli_query($db, $ajusta);

  }
  ?><script>swal("Ok", "Reajuste feito com Sucesso!", "success")</script><?php
 
}


if(isset($_POST["quadra"])){
  $quadra = $_POST["quadra"];
  include "conexao.php";
  $insere = "INSERT INTO produto (empreendimento_idempreendimento, quadra) values ('$idempreendimento', '$quadra')";
  $grava_insere = mysqli_query($db, $insere);

  ?><script>swal("Ok", "Cadastro feito com Sucesso!", "success")</script><?php
}


if(isset($_POST["lote"])){

  // echo "<pre>";
  // print_r($_POST);
  // echo "</pre>";
 
  $quadra_id     = $_POST["quadra_id"];
  
  $lote          = $_POST["lote"];
  $m2            = $_POST["m2"];
  $valor         = $_POST["valor"];

  $frente        = $_POST["frente"];
  $fundo         = $_POST["fundo"];
  $direito       = $_POST["direito"];
  $esquerdo      = $_POST["esquerdo"];
  $moutros       = $_POST["moutros"];
  $cfrente       = $_POST["cfrente"];
  $cfundo        = $_POST["cfundo"];
  $cesquerdo     = $_POST["cesquerdo"];
  $cdireito      = $_POST["cdireito"];
  $coutros       = $_POST["coutros"];
  $obs_lote      = $_POST["obs_lote"];

  $cad_pre       = $_POST["cad_pre"];
  $matricula     = $_POST["matricula"];
  $endereco_lote = $_POST["endereco_lote"];



  $valor_inicial2 = str_replace("R$","", $valor);
  $valor_inicial3 = str_replace(".","", $valor_inicial2);
  $valor_inicial4 = str_replace(",",".", $valor_inicial3); 


   include "conexao.php";
  
  $inserir = "INSERT INTO lote(lote, m2, valor, produto_idproduto, status, frente, fundo, direita, esquerda, moutros, mfrente, mfundo, mle, mld, coutros, obs_lote, endereco, matricula, cadastro_prefeitura)values('$lote','$m2','$valor_inicial4','$quadra_id','1', '$frente', '$fundo', '$direito', '$esquerdo', '$moutros', '$cfrente', '$cfundo', '$cesquerdo', '$cdireito', '$coutros', '$obs_lote', '$endereco_lote', '$matricula', '$cad_pre')";
  $insert = mysqli_query($db, $inserir);

  ?><script>swal("Ok", "Cadastro feito com Sucesso!", "success")</script><?php

}


?>
<script type="text/javascript">
  
$(document).on('click','#cadastro_quadra_btn',function(){

   document.getElementById('form_cadast_quadra').submit();

})


</script>
</body>

</html>
