Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa tarde...
o cenário é o seguinte tenho uma pagina index.php que envia informação para outro aquivo php, no qual envia as informação para uma
pagina detalle.php, onde na index.php exibi em uma div o conteúdo da detalle.php....
eu estou tentando passar um post de um form, das informações que se encontra na detalle.php ...
só que acabo não recebendo nada, apenas um conteúdo da index ..
ajuda ai ...
detalle.php ->
<?php
@session_start();
$cnpj = $_GET['cnpj'];
?> <form class="form-horizontal" action="teste.php?cnpj=<?php echo $cnpj ?>" method="POST" enctype="multipart/form-data" role="form">
<div class="table-responsive">
<?php
if(count($_SESSION['detalle'])>0){?>
<form class="form-horizontal" action="teste.php?cnpj=<?php echo $cnpj ?>" method="POST" enctype="multipart/form-data" role="form">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Produto</th>
<th>Qtd</th>
<th>Preço</th>
<!--<th>Desconto</th>-->
<th>IPI</th>
<th>SubTotal</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$total = 0;
$total_l = 0;
$seq = 0;
foreach($_SESSION['detalle'] as $k => $detalle){
$total += $detalle['PRECO'] * $detalle['cantidad'];
$total_l += $detalle['subtotal'];
?>
<tr>
<td><?php echo $seq += 1;?>
<input name="ID" id="ID" value="<?php echo $detalle['ID'];?>" hidden />
</td>
<td><?php echo utf8_encode($detalle['NOMEFANTASIA']);?></td>
<td><?php echo $detalle['cantidad'];?>
<input type="text" name="quan" id="quan" value="<?php echo $detalle['cantidad'] ?>" hidden />
</td>
<td><?php echo $detalle['PRECO'];?>
<input type="text" name="PRECO" id="PRECO" value="<?php echo $detalle['PRECO'] ?>" hidden />
</td>
<!--<td></td>-->
<td><?php $ALI = $detalle['PRECO'] * $detalle['ALIQUOTA']/100; echo $ALI?>
<input type="text" name="aliquota" id="aliquota" value="<?php echo $ALI ?>" hidden />
</td>
<td><?php echo $detalle['subtotal'];?>
<input name="total_" id="total_" value="<?php echo number_format($total_l, 2)?>" hidden />
</td>
<td><button type="button" class="btn btn-sm btn-danger eliminar-producto" id="<?php echo $detalle['ID'];?>">Eliminar</button></td>
</tr>
<?php }?>
<tr>
<td colspan="1" class="text-right"><b>
Total Bruto: R$<?php echo number_format($total, 2);?>
</b></td>
<td></td>
<input name="total_total" id="total_total" value="<?php echo number_format($total_l, 2)?>" hidden />
<td><b>
Total Líquido: R$<?php echo number_format($total_l, 2)?></b>
</td>
<td><b>
Total com Desconto:</b>
<input type="text" name="valor_unitario" id="valor_unitario" value="<?php echo number_format($total, 2)?>" hidden />
<input type="text" name="qnt" id="qnt" value="0" hidden />
<input type="text" name="total" id="total" readonly="readonly" size="5" class="text-center" />
</td>
<td>
</td>
</tr>
</tbody>
</table>
<?php }else{?>
<div class="panel-body"> Nenhum Produto Selecionado</div>
<?php }?>
</div>
<script type="text/javascript">
$(function(){
$(".btn-agregar-producto").off("click");
$(".btn-agregar-producto").on("click", function(e) {
var cantidad = $("#txt_cantidad").val();
var producto_id = $("#cbo_producto").val();
if(producto_id!=0){
if(cantidad!=''){
$.ajax({
url: 'Controller/ProductoController.php?page=1&cnpj=<?php echo $cnpj?>',
type: 'post',
data: {'producto_id':producto_id, 'cantidad':cantidad},
dataType: 'json',
success: function(data) {
if(data.success==true){
$("#txt_cantidad").val('');
alertify.success(data.msj);
$(".detalle-producto").load('detalle.php?cnpj=<?php echo $cnpj?>');
}else{
alertify.error(data.msj);
}
},
error: function(jqXHR, textStatus, error) {
alertify.error(error);
}
});
}else{
alertify.error('Coloque a Quantidade');
}
}else{
alertify.error('Um produto Selecionado');
}
});
$(".eliminar-producto").off("click");
$(".eliminar-producto").on("click", function(e) {
var id = $(this).attr("id");
var id = $(this).attr("id");
$.ajax({
url: 'Controller/ProductoController.php?page=2&cnpj=<?php echo $cnpj?>',
type: 'post',
data: {'id':id},
dataType: 'json'
}).done(function(data){
if(data.success==true){
alertify.success(data.msj);
$(".detalle-producto").load('detalle.php?cnpj=<?php echo $cnpj?>');
}else{
alertify.error(data.msj);
}
})
});
});
</script>
index.php ->
<?php
session_start();
$_SESSION['detalle'] = array();
require_once 'Config/conexion.php';
require_once 'Model/Producto.php';
require_once 'Model/prazo.php';
$objProducto = new Producto();
$resultado_producto = $objProducto->get();
$objProducto1 = new Producto1();
$resultado_producto1 = $objProducto1->get1();
$cnpj = $_GET['cnpj'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Carrito de Compras</title>
<!-- Bootstrap -->
<link href="libs/css/bootstrap.css" rel="stylesheet">
<script src="libs/js/jquery.js"></script>
<script src="libs/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(function(){
$(".btn-agregar-producto").off("click");
$(".btn-agregar-producto").on("click", function(e) {
var cantidad = $("#txt_cantidad").val();
var producto_id = $("#cbo_producto").val();
var desconto = $("#qnt").val();
if(producto_id!=0){
if(cantidad!=''){
$.ajax({
url: 'Controller/ProductoController.php?page=1&cnpj=<?php echo $cnpj?>',
type: 'post',
data: {'producto_id':producto_id, 'cantidad':cantidad},
dataType: 'json',
success: function(data) {
if(data.success==true){
$("#txt_cantidad").val('');
alertify.success(data.msj);
$(".detalle-producto").load('detalle.php?cnpj=<?php echo $cnpj?>');
}else{
alertify.error(data.msj);
}
},
error: function(jqXHR, textStatus, error) {
alertify.error(error);
}
});
}else{
alertify.error('Coloque a Quantidade');
}
}else{
alertify.error('Um produto Selecionado');
}
});
$(".eliminar-producto").off("click");
$(".eliminar-producto").on("click", function(e) {
var id = $(this).attr("id");
var id = $(this).attr("id");
$.ajax({
url: 'Controller/ProductoController.php?page=2',
type: 'post',
data: {'id':id},
dataType: 'json'
}).done(function(data){
if(data.success==true){
alertify.success(data.msj);
$(".detalle-producto").load('detalle.php');
}else{
alertify.error(data.msj);
}
})
});
});
</script>
<!-- Alertity -->
<link rel="stylesheet" href="libs/js/alertify/themes/alertify.core.css" />
<link rel="stylesheet" href="libs/js/alertify/themes/alertify.bootstrap.css" id="toggleCSS" />
<script src="libs/js/alertify/lib/alertify.min.js"></script>
</head>
<body>
<div class="container">
<div class="page-header">
<h3>Iniciar pedido</h3>
</div>
<div class="row">
<div class="col-md-12">
<form class="form-horizontal" action="teste.php?cnpj=<?php echo $cnpj ?>" method="POST" enctype="multipart/form-data" role="form">
<div class="col-md-4">
<div>Produtos:
<select name="cbo_producto" id="cbo_producto" class="col-md-2 form-control">
<option value="0">Selecione um produdo...</option>
<?php foreach($resultado_producto as $producto):?>
<option value="<?php echo $producto['ID']?>"><?php echo utf8_encode($producto['NOMEFANTASIA'])?></option>
<?php endforeach;?>
</select>
</div>
</div>
<div class="col-md-2">
<div>Quantidade:
<input id="txt_cantidad" name="txt_cantidad" type="number" class="form-control" placeholder="Quantos?" autocomplete="off" />
</div>
</div>
<div class="col-md-2">
<div style="margin-top: 19px;">
<button type="button" class="btn btn-success btn-agregar-producto">Inserir</button>
</div>
</div>
</div>
</div>
<br>
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">Produtos Selecionados</h3>
</div>
<div class="panel-body detalle-producto">
<div class="table-responsive">
<?php if(count($_SESSION['detalle'])>0){?>
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Produto</th>
<th>Qtd</th>
<th>Preço</th>
<!--<th>Desconto</th>-->
<th>IPI</th>
<th>SubTotal</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$total = 0;
$total_l = 0;
$seq = 0;
foreach($_SESSION['detalle'] as $k => $detalle){
$total += $detalle['PRECO'] * $detalle['cantidad'];
$total_l += $detalle['subtotal'];
?>
<tr>
<td><?php echo $seq += 1;?>
<input name="ID" id="ID" value="<?php echo $detalle['ID'];?>" />
</td>
<td><?php echo utf8_encode($detalle['NOMEFANTASIA']);?></td>
<td><?php echo $detalle['cantidad'];?>
<input type="text" name="quan" id="quan" value="<?php echo $detalle['cantidad'] ?>" />
</td>
<td><?php echo $detalle['PRECO'];?>
<input type="text" name="PRECO" id="PRECO" value="<?php echo $detalle['PRECO'] ?>" />
</td>
<!--<td></td>-->
<td><?php $ALI = $detalle['PRECO'] * $detalle['ALIQUOTA']/100; echo $ALI?>
<input type="text" name="aliquota" id="aliquota" value="<?php echo $ALI ?>" />
</td>
<td><?php echo $detalle['subtotal'];?>
<input name="total_" id="total_" value="<?php echo number_format($total_l, 2)?>" />
</td>
<td><button type="button" class="btn btn-sm btn-danger eliminar-producto" id="<?php echo $detalle['ID'];?>">Eliminar</button></td>
</tr>
<?php }?>
<tr>
<td colspan="1" class="text-right"><b>
Total Bruto: R$<?php echo number_format($total, 2);?>
</b></td>
<td></td>
<input name="total_total" id="total_total" value="<?php echo number_format($total_l, 2)?>" />
<td><b>
Total Líquido: R$<?php echo number_format($total_l, 2)?></b>
</td>
<td><b>
Total com Desconto:</b>
<input type="text" name="valor_unitario" id="valor_unitario" value="<?php echo number_format($total, 2)?>" />
<input type="text" name="qnt" id="qnt" value="0" hidden />
<input type="text" name="total" id="total" readonly="readonly" size="5" class="text-center" />
</td>
<td>
</td>
</tr>
</table>
<?php }else{?>
<div class="panel-body"> Nenhum Produto Selecionado</div>
<?php }?>
</div>
</div>
</div>
<div class="col-md-4">
<div>Prazos:
<select name="prazo" id="prazo" class="form-control">
<option value="0">Selecione um prazo...</option>
<?php foreach($resultado_producto1 as $producto1):?>
<option value="<?php echo $producto1['CODCPG']?>"><?php echo utf8_encode($producto1['NOME'])?></option>
<?php endforeach;?>
</select>
</div>
</div>
<div class="col-md-2">
<div>Desconto%:
<input type="text" name="qnt" id="qnt" value="0" class="form-control" maxlength="3" />
<input type="text" name="total" id="total" readonly="readonly" hidden />
</div>
</div>
<div class="col-md-3">
<div>Previsão De Faturamento:
<input type="date" name="prev_pagamento" id="prev_pagamento" class="form-control" />
</div>
</div>
<br/>
<div class="modal-footer" id="iten-footer">
<button type="submit" class="btn btn-success"><i class="fa fa-shopping-cart"></i> Fazer Pedido</button>
<input type="hidden" name="done" value="" />
<button type="button" class="btn btn-danger" data-dismiss="modal">Fechar</button>
</div>
</form>
</div>
<script type="text/javascript">
function id(el) {
return document.getElementById( el );
}
function total( total_total, qnt ) {
return parseFloat(total_total.replace(',', '.'), 10)/100 * parseFloat(qnt.replace(',', '.'), 10);
}
window.onload = function() {
id('qnt').addEventListener('keyup', function(){
var result = total( id('valor_unitario').value , this.value );
var t = parseFloat(result);
var t1 = document.getElementById("total_total").value;
var t2 = parseFloat(t1) - t;
id('total').value = String(t2.toFixed(2)).formatMoney();
});
}
String.prototype.formatMoney = function() {
var v = this;
if(v.indexOf('.') === -1) {
v = v.replace(/([\d]+)/, "$1,00");
}
v = v.replace(/([\d]+)\.([\d]{1})$/, "$1,$20");
v = v.replace(/([\d]+)\.([\d]{2})$/, "$1,$2");
v = v.replace(/([\d]+)([\d]{3}),([\d]{2})$/, "$1.$2,$3");
return v;
};
</script>
</body>
</html>
/applications/core/interface/imageproxy/imageproxy.php?img=http://i.imgur.com/qt23t7A.png&key=8a55e0e2b8ae1c8afc62405ed31d594c17132ffe9a1a2b6c24ee4dbfa34e10da" alt="qt23t7A.png" />
Carregando comentários...