<?php 
error_reporting(0);
ini_set(“display_errors”, 0 );
include "protege_professor.php";

// echo "se tiver POST";
// echo "<pre>";
// print_r($_POST);
// echo "</pre>";
// echo "<br>";
// echo "se tiver GET";
// echo "<pre>";
// print_r($_GET);
// echo "</pre>"; die();






if(isset($_GET["add_descricao"])){
    include "conexao.php";

  // echo "<pre>";
  // print_r($_GET);
  // echo "</pre>"; die();
     $idusuario = $_SESSION['id_usuario'];
    $nome_descricao  = $_GET["nome_descricao"];

    $query = "INSERT INTO descr_parcelas (nome_descricao) VALUES('$nome_descricao')";
    $executa_query = mysqli_query($db, $query);

    $buscar_amigo = mysqli_fetch_assoc($executa_query);


    date_default_timezone_set('America/Sao_Paulo');              
    $data_log = date('d-m-Y H:i:s');         // data e hr no momento
    $nome_usuario = nome_user1($idusuario); //nome usuario sessao
    $descricao_log = "Usuário ".$nome_usuario ." cadastrou um novo tipo de parcela : ".$nome_descricao;
    grava_log($data_log,$idusuario,$descricao_log);
    //echo "cheguei aqui...;".$descricao_log; die();


}

      $idusuario = $_SESSION['id_usuario'];

//#########################################  Funcoes Grava Log   #############################################

function nome_user1($id){
            include "conexao.php";
                 $query_igpm = "SELECT nome_cli FROM cliente where idcliente = $id";

                 $executa_igpm = mysqli_query ($db, $query_igpm);


                   while ($buscar_amigoc = mysqli_fetch_assoc($executa_igpm)) {//--verifica se são amigos

                          $nome_cli        = $buscar_amigoc['nome_cli'];
                   }
                   return $nome_cli;

         } 


        function grava_log($data_log,$usuario_id,$descricao_log){
           include "conexao.php";
          
                $query_log = "insert into log (data_log,usuario_id,descricao_log) values('$data_log','$usuario_id','$descricao_log')";
                $executa_log = mysqli_query($db, $query_log);
                return 1;
        }

          
                   


//######################################### " FIM " Funcoes Grava Log   ######################################

?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![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>
   <!-- ================== END BASE JS ================== -->
</head>
<body>
  <script type="text/javascript">


    function reajustar(){

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

}


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
}

</script>
<!-- begin #page-loader -->
<div id="page-loader" class="fade"><span class="spinner"></span></div>
<!-- end #page-loader -->

<!-- begin #page-container -->
<div id="page-container" class="fade in page-sidebar-fixed page-header-fixed">


  <?php include "topo.php"; ?>



  <!-- begin #content -->
  <div id="content" class="content">
   <?php
   if(isset($_GET['att_descricao'])){
       include "conexao.php";

       $iddescr = $_GET['iddescr'];
       $nome_descricao  = $_GET["nome_descricao"];

       $query = "UPDATE descr_parcelas SET nome_descricao = '$nome_descricao' WHERE iddescr = '$iddescr'";
       $executa_query = mysqli_query($db, $query);

       $buscar_amigo = mysqli_fetch_assoc($executa_query);

 

       ?>
       <div class="alert alert-success fade in m-b-15">
            <strong><font><font>Sucesso! </font></font></strong><font><font>
                  Descrição Alterada. 
            </font></font><span class="close" data-dismiss="alert"><font><font>×</font></font></span>
      </div>
      <!-- begin breadcrumb -->
      <!-- end breadcrumb -->
      <!-- begin page-header -->
      <?php

      date_default_timezone_set('America/Sao_Paulo');              
      $data_log = date('d-m-Y H:i:s');         // data e hr no momento
      $nome_usuario = nome_user1($idusuario); //nome usuario sessao
      $descricao_log = "Usuário ".$nome_usuario ." alterou um novo tipo de parcela : ".$nome_descricao;
      grava_log($data_log,$idusuario,$descricao_log);
}

   if(isset($_GET['remover'])){
       include "conexao.php";

       $iddescr = $_GET['iddescr'];
       $nome_descricao  = $_GET["nome_descricao"];

       $query = "DELETE FROM descr_parcelas  WHERE iddescr = '$iddescr'";
       $executa_query = mysqli_query($db, $query);

       $buscar_amigo = mysqli_fetch_assoc($executa_query);
       ?>
       <div class="alert alert-danger fade in m-b-15">
            <strong><font><font>Sucesso! </font></font></strong><font><font>
                  Remoção Concluida. 
            </font></font><span class="close" data-dismiss="alert"><font><font>×</font></font></span>
      </div>
      <!-- begin breadcrumb -->
      <!-- end breadcrumb -->
      <!-- begin page-header -->
      <?php
      date_default_timezone_set('America/Sao_Paulo');              
      $data_log = date('d-m-Y H:i:s');         // data e hr no momento
      $nome_usuario = nome_user1($idusuario); //nome usuario sessao
      $descricao_log = "Usuário ".$nome_usuario ." excluiu o tipo de parcela : ".$nome_descricao;
      grava_log($data_log,$idusuario,$descricao_log);
}



if(isset($_GET['editar'])){
     ?>
     <h1 class="page-header">Editar Descrição Parcelas</h1>
     <?php
}else{
     ?>
     <h1 class="page-header">Descricao Parcelas</h1>
     <?php







}

?>
<!-- end page-header -->

<!-- begin row -->
<div class="row">
    <div class="col-md-12">
      <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>

      <?php
      if(isset($_GET['editar'])){
           ?>
           <h4 class="panel-title">Atualiza Descrição</h4>

           <?php
     }else{
           ?>
           <h4 class="panel-title">Insere Descrição</h4>

           <?php
     }

     ?>

</div>
<div class="panel-body">
  <form class="form-vertical form-bordered" name="myForm" method="GET" action="descricao_parcelas.php">
    <div class="row">
      <div class="form-group col-md-6 ">
        <?php
        if(isset($_GET['editar'])){
         ?>
         <label class="control-label">Altere a Descrição</label>

         <?php
   }else{
         ?>
         <label class="control-label">Descrição</label>

         <?php
   }

         if(isset($_GET['editar'])){
           $nome = $_GET['nome_descricao'];
           ?>
           <input type="text" name="nome_descricao" class="form-control" value="<?php echo $nome;?>" >


           <?php
     }else{
           ?>
           <input type="text" name="nome_descricao" class="form-control">

           <?php
     }

     ?>
</div>

<div class="form-group col-md-12">

     <?php
     if(isset($_GET['editar'])){
      $iddescr = $_GET['iddescr'];
      ?>
      <input type="hidden" type="text" name="iddescr" value="<?php echo $iddescr;?>">
      <input type="submit" class="btn btn-sm btn-success" name="att_descricao" value="Atualiza"  />

      <?php
}else{
 ?>
 <input type="submit" class="btn btn-sm btn-success" name="add_descricao" value="Adicionar" />

 <?php
}

?>






</div>
</div>

</form>

</div>
</div>

<br>
<br>

<div class="row">
 <?php if (in_array('33', $idrota)) { ?>
  <!-- begin col-10 -->
  <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">Descrições de Parcelas Cadastrados</h4>
</div>

<div class="panel-body">
  <table id="data-table" class="table table-striped table-bordered">
    <thead>
      <tr>
        <th>Nome</th>      
        <th>Ação</th>                                        
        <th> </th>
  </tr>
</thead>
<tbody>


      <?php


      include "conexao.php";


      $query_amigo = "SELECT * FROM descr_parcelas order by nome_descricao asc";
      $executa_query = mysqli_query ($db,$query_amigo) or die ("Erro ao listar Centro de cobrança");


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

              $iddescr             = $buscar_amigo["iddescr"];
              $nome_descricao              = $buscar_amigo["nome_descricao"];

              ?>


              <tr class="odd gradeX">
               <td><?php echo $nome_descricao ?></td>
               <td><a href="descricao_parcelas.php?iddescr=<?php echo $iddescr?>&nome_descricao=<?php echo $nome_descricao; ?>&editar=ok"><span class="label label-warning">Editar</span></a>&nbsp;&nbsp;&nbsp;
               <a href="descricao_parcelas.php?iddescr=<?php echo $iddescr?>&nome_descricao=<?php echo $nome_descricao; ?>&remover=ok"><span class="label label-danger">Remover</span></a></td>

         </tr>
   <?php } ?>
</tbody>
</table>
</div>
</div>
<!-- end panel -->
</div>
<!-- end col-10 -->


<?php } ?>


</div>
<!-- end row -->
</div>
<!-- end #content -->

<!-- end #content -->



<!-- 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 -->







<!-- ================== BEGIN BASE JS ================== -->
<script src="https://immobilebusiness.com.br/admin/assets/plugins/jquery/jquery-1.9.1.min.js"></script>
<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/ui-modal-notification.demo.min.js"></script>
	<script src="https://immobilebusiness.com.br/admin/assets/js/apps.min.js"></script>




  <script src="produtos_pagar.js"></script>
  <script src="lote_pagar.js"></script>
  <!-- ================== END PAGE LEVEL JS ================== -->

  <script>
    $(document).ready(function() {
     App.init();
     TableManageButtons.init();
     Notification.init();
});
</script>

</body>


</html>
