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


$idusuario                 = $_SESSION['id_usuario'];



function DadosParcela($idparcelas)
{
	include "conexao.php";
    $query_amigo = "SELECT * FROM parcelas where idparcelas = $idparcelas";
    $executa_query = mysqli_query ($db,$query_amigo);
   	$buscar_amigo = mysqli_fetch_assoc($executa_query);
   	
    return $buscar_amigo;
}


if(isset($_POST["desc"])){
	
	// echo "<pre>";
	// print_r($_POST);
	// echo "</pre>";
	// die();
	
	$idvenda 	= $_POST["idvenda"];
	$tipo 		= $_POST["tipo"];

	$demo1 		= $_POST["demo1"];
	$demo2 	    = $_POST["demo2"];
	$demo3 	 	= $_POST["demo3"];
	$instru1 	= $_POST["instru1"];
	$instru2 	= $_POST["instru2"];
	$instru3 	= $_POST["instru3"];
	$instru4 	= $_POST["instru4"];

	$antecipar  = json_decode($_POST["antecipar"]);
	
	// var_dump($antecipar);
	// die();

	include "conexao.php";
	 foreach ($antecipar as $key ) {
	


	$inserir = "UPDATE parcelas set 
		demonstrativo1= '$demo1',
		demonstrativo2= '$demo2',
		demonstrativo3= '$demo3',
		instrucao1= '$instru1',
		instrucao2= '$instru2',
		instrucao3= '$instru3',
		instrucao4= '$instru4'
		WHERE idparcelas = $key";

	//echo $inserir; die();
	$executa = mysqli_query($db, $inserir);


	}

?>

<script type="text/javascript">window.location="parcelas.php?idvenda=<?php echo $idvenda ?>&tipo=<?php echo $tipo ?>&desc=ok";</script>

 <?php } ?>


<!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 BASE JS ================== -->
	<script src="https://immobilebusiness.com.br/admin/assets/plugins/pace/pace.min.js"></script>
	<!-- ================== END BASE JS ================== -->

</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">
	

	<?php include "topo.php" ?>



		<!-- begin #content -->
		<div id="content" class="content">
			
			<!-- end breadcrumb -->
			<!-- begin page-header -->
			<h1 class="page-header">Alterar Descrição das parcelas</h1>
			<!-- end page-header -->
			
			<!-- begin row -->
			<div class="row">

		
   <div class="col-md-12">
			        <!-- begin panel -->
                    <div class="panel panel-inverse" data-sortable-id="table-basic-4">
                        <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">Parcelas</h4>
                        </div>
                        <div class="panel-body">
                <?php 
	              $idvenda = $_POST["idvenda"];
	              $tipo = $_POST["tipo"];
				  $teste = $_POST["antecipar"];

				?>
                       
                            <table class="table table-striped">
                    <?php foreach ($teste as $id) { 
                    	$Dados = DadosParcela($id);
                    ?>
                                <tr>
          <td><?php echo $Dados["idparcelas"]; ?></td>
          <td><?php echo $Dados["numero_sequencia"]; ?></td>
          <td><?php echo $Dados["valor_parcelas"]; ?></td>
          <td><?php echo $Dados["data_vencimento_parcela"]; ?></td>
        </tr>
        			<?php } ?>


                            </table>

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





























			    <!-- begin col-6 -->
			    <div class="col-md-12">
			        <!-- begin panel -->
                    <div class="panel panel-inverse" data-sortable-id="table-basic-4">
                        <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">Alterar Descrição da parcela</h4>
                        </div>
                        <div class="panel-body">
                        <form action="alterar_descricao.php" method="POST" name="nome">
                <?php 
              $idvenda = $_POST["idvenda"];
              $tipo = $_POST["tipo"];
              ?>
                        <input type="hidden" name="desc" value="1">
                        <input type="hidden" name="idvenda" value="<?php echo $idvenda; ?>">
                        <input type="hidden" name="tipo" value="<?php echo $tipo; ?>">
                        <input type="hidden" name="antecipar" value='<?php echo json_encode($teste); ?>'>
                            <table class="table table-striped">
                                <tr>
          <td><strong>Demonstrativo 1</strong></td>
          <td><input type="text" class="form-control" name="demo1" max="40" value="<?php echo $Dados["demonstrativo1"] ?>" /></td>
        </tr>


        <tr>
          <td><strong>Demonstrativo 2</strong></td>
          <td><input type="text" class="form-control" name="demo2" max="40" value="<?php echo $Dados["demonstrativo2"] ?>" /></td>
        </tr>

        <tr>
          <td><strong>Demonstrativo 3</strong></td>
          <td><input type="text" class="form-control" name="demo3" max="40" value="<?php echo $Dados["demonstrativo3"] ?>" /></td>
        </tr>

        <tr>
          <td><strong>Instrução 1</strong></td>
          <td><input type="text" class="form-control" name="instru1" max="40" value="<?php echo $Dados["instrucao1"] ?>" /></td>
        </tr>

        <tr>
          <td><strong>Instrução 2</strong></td>
          <td><input type="text" class="form-control" name="instru2" max="40" value="<?php echo $Dados["instrucao2"] ?>" /></td>
        </tr>

        <tr>
          <td><strong>Instrução 3</strong></td>
          <td><input type="text" class="form-control" name="instru3" max="40" value="<?php echo $Dados["instrucao3"] ?>" /></td>
        </tr>

        <tr>
          <td><strong>Instrução 4</strong></td>
          <td><input type="text" class="form-control" name="instru4" max="40" value="<?php echo $Dados["instrucao4"] ?>" /></td>
        </tr>
                            </table>

                            <p><input type="submit" class="btn btn-success btn-lg" role="button" value="Confirmar Descrição" /></p>
                            </form>
                        </div>
                    </div>
                    <!-- end panel -->
			      
			    </div>
			    <!-- end col-6 -->
			</div>
		
			
		</div>
		<!-- 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/js/apps.min.js"></script>
	<!-- ================== END PAGE LEVEL JS ================== -->
	
	<script>
		$(document).ready(function() {
			App.init();
		});
	</script>

</body>

</html>
