Viewing file: pedido_edit_view.php (19.54 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<style>
/* overwriting default behaviour of Modal Popup in Bootstrap */ body{ overflow: auto !important; } .modal{ overflow: hidden; }
/* created new class for targetting purpose - named ".modal2", ".modal1" */ .modal2.in{ position: absolute; bottom: 0; right:0; width:700px; left: 600px; top: auto; bottom: 0; overflow: auto; } </style>
<div class="content-wrapper" style="min-height: 946px;"> <div style="margin-left:20px;"> <section class="content-header"> <b>VENDEDOR:</b> <input type="text" name="vendedor" value="<?php echo($datosPedido[0]->vendedor); ?>" style="height: 30px;"id="vendedor" readonly/> </section>
<!-- Main content --> <section class="content"> <form method="post" name="gestionPedido" class="form-inline">
<input type="hidden" name="numeroPedido" id="numeroPedido" value="<?php echo ($nroPedido)?>" > </input>
<div class="tab-content">
<div class="panel panel-default"> <div class="panel-heading" role="tab" id="headingOne"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne"> <h2>DATOS CLIENTE</h2> </a> </h4> </div> <div id="collapseOne" class="panel-collapse collapse out" role="tabpanel" aria-labelledby="headingOne"> <div class="panel-body"> <div class="col-md-12" align="right"> <div class="estiloForm" > <input class="form-control input-sm" type="hidden" name="id_cliente" id="id_cliente" value="<?php echo ($datosCliente->id)?>" readonly> <b>Nombre:</b> <input class="form-control input-sm" style="height: 40px;" type="text" name="nombre" id="nombre" value="<?php echo ($datosCliente->nombre)?>" readonly> <b>Razon Social:</b> <input class="form-control input-sm" style="height: 40px;" type="text" name="razon_social" id="razon_social" value="<?php echo ($datosCliente->razon_social)?>" readonly> <b>Mail:</b> <input class="form-control input-sm" style="height: 40px;" type="text" name="mail" id="mail" value="<?php echo ($datosCliente->mail)?>" readonly> <b>Direccion:</b> <input class="form-control input-sm " style="height: 40px;" type="text" name="DireccionCliente" id="DireccionCliente" value="<?php echo ($datosCliente->direccion)?>" readonly> <b>Provincia:</b> <input class="form-control input-sm" style="height: 40px;" type="text" name="provincia" id="provincia" value="<?php echo ($datosCliente->provincia)?>"readonly> <br> <br> <b>Localidad:</b> <input class="form-control input-sm" style="height: 40px;" type="text" name="localidad" id="localidad" value="<?php echo ($datosCliente->localidad)?>" readonly> <b>Telefono:</b> <input class="form-control input-sm" style="height: 30px;" type="text" name="telefonoCliente" id="telefonoCliente" value="<?php echo ($datosCliente->telefono)?>" readonly> <b>Cuit:</b> <input class="form-control input-sm" style="height: 40px;" type="text" name="CuitCliente" id="CuitCliente" value="<?php echo ($datosCliente->cuit)?>"readonly> <b>Expreso:</b> <input class="form-control input-sm" style="height: 40px;" type="text" name="expreso" id="expreso" value="<?php echo ($datosCliente->expreso)?>" readonly> </div> </div> </div> </div> </div>
<!-- <button type="button" class="btn btn-success btn-large" data-toggle="modal" data-target="#listaProd" >Agregar Producto</button> --> <div> <div id="buscador2"> <h2>AGREGAR PRODUCTOS</h2> <form method="post" action="<?php echo base_url()?>pedido/paginacionProductos/"> <strong>Producto: </strong> <input type="text" name="buscandoProductos" style="height: 30px;"id="buscandoProductos" /> <input type="button" class="btn btn-primary btn-md" value="BUSCAR" onclick="busquedaProductos()"/> </form> </div> <br> <div id="div_noticias"> </div> </div> <h2>PRODUCTOS AGREGADOS AL CARRITO</h2> <div id="tablaPrincipal3" width="60%"> <?php $array=array(); $subtotal1=0; $total=0; $iva=0; $totalNeto=0; $cantidadItems=0; $descuento=0; if($datosPedido[0]->descuento != null){ $descuento=$datosPedido[0]->descuento; } $this->table->set_heading('Chequeo','Producto', 'Descripcion', 'Cantidad','Precio','Accion'); //crea la primera fila de la tabla con el encabezado $tmp = array ( 'table_open' => '<table class="table table-bordered table-striped" border="0" cellpadding="2" cellspacing="1" id="detalleTabla" width="60%">' ); $this->table->set_template($tmp); if($nroPedido !=NULL){ $detallesPedido=$this->consultas_model->getDetallesPedidoById($nroPedido); if($detallesPedido !=null){ foreach($detallesPedido as $file): $cantidadProdTabla=$cantidadProdTabla+1; $this->table->add_row('<input type="checkbox" name="seleccionar">',$file->nombre,$file->descripcion,$file->cantidad,$file->precio,'<input class="btn btn-danger" type="button" name="eliminar" id="eliminar" value="Eliminar" onclick="elinminarRegistro('. $file->id.','.$file->cantidad.')">'); //agregamos la celda a la tabla por cada iteracion $cantidadItems +=$file->cantidad; $valorParcialSinDesc=round($file->cantidad*$file->precio,2); $subtotal1 += $valorParcialSinDesc; $valorParcial=($valorParcialSinDesc - ($valorParcialSinDesc*$descuento/100)); $totalNeto +=round($valorParcial,2); endforeach; $iva =round($totalNeto*0.21,2); $total=round($totalNeto+$iva,2); } echo $this->table->generate(); } ?> </div> <div class="col-md-12 form-inline" align="right"> <b style="font-family: Arial; font-size: 16pt;height: 40px;">PRODUCTOS AGREGADOS (CANT. TOTALES):</b> <input style="font-family: Arial; font-size: 16pt;height: 40px;" type="text" name="cantidadRegistros" id="cantidadRegistros" value="<?php echo ($cantidadItems);?>" readonly> <label><b style="font-family: Arial; font-size: 16pt;height: 40px;"> Sub: $</b></label><input type="text" style="font-family: Arial; font-size: 20pt;height: 40px;"name="subtotal" id="subtotal" value="<?php echo ($subtotal1);?>"readonly> <br> <br> <label><b style="font-family: Arial; font-size: 16pt;height: 40px;"> Sub C/DESCUENTO: $</b></label><input type="text" style="font-family: Arial; font-size: 20pt;height: 40px;" name="totalAlternativo" id="totalAlternativo" value="<?php echo ($totalNeto);?>"readonly> <label><b style="font-family: Arial; font-size: 16pt;height: 40px;">IVA: $</b></label><input type="text" style="font-family: Arial; font-size: 20pt;height: 40px;"name="iva" id="iva" value="<?php echo ($iva);?>" readonly> <br><br> <label><b style="font-family: Arial; font-size: 16pt;height: 40px;">TOTAL: $</b></label> <input type="text" style="font-family: Arial; font-size: 20pt;height: 40px;" name="totalfinal" id="totalfinal" value="<?php echo ($total);?>"readonly> </div>
<input type="hidden" name="vieneDentro" id="vieneDentro" value=""> </input>
<div class="col-md-12" align="center"> <input class="btn btn-info btn-lg" type="button" value="VOLVER" onclick="volver();"> <input class="btn btn-success btn-lg" type="button" name="guardar" id="guardar" value="GUARDAR" onclick="guardarPedido();"> </div> </div>
</form>
</section><!-- /.content --> </div><!-- /.content-wrapper --> <script type="text/javascript"> $(this).ready( function() { $("#buscando").autocomplete({ minLength: 1, source:'<?php echo site_url("pedido/autocompletar");?>', }); $("#buscandoProductos").autocomplete({ minLength: 1, source:'<?php echo site_url("pedido/autocompletarProductos");?>', select: function(event, ui) { buscando=ui.item.value; $.ajax({ type: 'POST', url: '<?= base_url("pedido/paginacionProductos")?>', data: {buscando:buscando}, success: function(data){ $("#div_noticias").html(data); } }); } }); }); $().ready(function(){ $.ajax({ type: 'POST', url: '<?= base_url("pedido/paginacionProductos")?>', success: function(data){ $("#div_noticias").html(data); } }); });
function busquedaProductos(){ buscando=document.getElementById("buscandoProductos").value; $.ajax({ type: 'POST', url: '<?= base_url("pedido/paginacionProductos")?>', data: {buscando:buscando}, success: function(data){ $("#div_noticias").html(data); } }); }
function volver(){ location.href='<?php echo base_url()?>pedido/preparacion'; }
function registrarPago(){ nroPedido=document.getElementById("numeroPedido").value; total=document.getElementById('totalfinal').value; tipo=document.getElementById("comboTipoPago").value; dato=document.getElementById("datoOperacion").value; recibo=document.getElementById("recibo").value; valor=document.getElementById("valor").value; if(tipo != null){ if( valor !=null){ $.ajax({ type: 'POST', url: '<?= base_url("pedido/registrarPagoWeb")?>', data: {nroPedido:nroPedido,tipo:tipo,dato:dato,valor:valor,total:total,recibo:recibo}, success: function(data){ alert("PAGO REGISTRADO"); } }); } else{ alert("Monto mayor a cero, por favor"); }
} else{ alert("Debe Ingresar tipo de Pago"); }
} function aplicarDescuento(descuento){ if(descuento.length !=0){ descuento1=descuento.split('%'); valor=document.getElementById("totalAlternativo").value; nroPedido=document.getElementById("numeroPedido").value; subTotal=document.getElementById('subtotal').value; descuentoFinal=parseInt(descuento1); descuentoF=descuentoFinal*valor*0.01; valorFinal=(valor-descuentoF); $('#totalAlternativo').val(valorFinal.toFixed(2)); valorIva=parseFloat(valorFinal.toFixed(2)*1.21-valorFinal.toFixed(2)); $('#iva').val(valorIva.toFixed(2)); total=valorIva+valorFinal; $('#totalfinal').val(total.toFixed(2)); $('#comboDescuentos').val(descuento); vendedor=document.getElementById("comboVendedor").value; $.ajax({ type: 'POST', url: '<?= base_url("pedido/registrarDescuento")?>', data: {descuentoFinal:descuentoFinal,nroPedido:nroPedido,total:total,vendedor:vendedor,subTotal:subTotal}, success: function(data){ } }); } } function registraComentario() { comentario=document.getElementById('observacion').value; nroPedido=document.getElementById('numeroPedido').value; $.ajax({ type: 'POST', url: '<?php echo site_url("pedido/registrarComentario");?>', data: {comentario:comentario,nroPedido:nroPedido}, success:function(data){ alert("Comentario Registrado"); } }); } function agregarCliente(){ cliente=document.getElementById("buscando").value; pedido=document.getElementById("numeroPedido").value; $.ajax({ type: 'POST', url: '<?= base_url("pedido/getCliente")?>', data: {cliente:cliente,pedido:pedido}, success: function(data){ calculo=data.split(';'); $('#razon_social').val(calculo[2]); $('#DireccionCliente').val(calculo[3]); $('#telefonoCliente').val(calculo[5]); $('#id_cliente').val(calculo[0]); $('#CuitCliente').val(calculo[7]); $('#mail').val(calculo[8]); $('#expreso').val(calculo[12]); } }); }
function ingresarCarrito(producto,i,precio){
subTotal=document.getElementById('subtotal').value; total=document.getElementById('totalfinal').value; cliente=document.getElementById("id_cliente").value; vendedor=document.getElementById("comboVendedor").value; desc=document.getElementById("comboDescuentos").value; descto=desc.split('%'); descuento=descto[0]; cant="cantidadProd_"+i; nombre="ingresado_"+i; document.getElementById(nombre).checked = true; // document.getElementById('busquedaProductos').getElementsByTagName('input')[i].checked=true;
cantidad=document.getElementById(cant).value; pedido=document.getElementById("numeroPedido").value; suma=(cantidad*precio); cantidadProductos=document.getElementById("cantidadRegistros").value; cantProd=parseInt(cantidadProductos,10); cantidadSumafinal=parseInt(cantidad,10); //descuento aplicado en teoria desde php descuentoBase=document.getElementById("descuentoBase").value; if (cantidad>0){ document.getElementById("cantidadRegistros").value=(cantProd+cantidadSumafinal); $.ajax({ type: 'POST', url: '<?php echo site_url("pedido/registrarDetalle");?>', data: {pedido:pedido,producto:producto, cantidad:cantidad,precio:precio,cliente:cliente,vendedor:vendedor,total:total,subTotal:subTotal,descuento:descuento}, success:function(data){ respuesta=data.split(';'); valorSinDesc=parseFloat(cantidad*precio); valorParcial=(parseFloat(cantidad*precio)-parseFloat(cantidad*precio*descuentoBase/100)); $('#totalAlternativo').val(parseFloat(parseFloat(document.getElementById("totalAlternativo").value)+parseFloat(valorParcial.toFixed(2))).toFixed(2)); $('#subtotal').val(parseFloat(parseFloat(document.getElementById("subtotal").value)+parseFloat(valorSinDesc.toFixed(2))).toFixed(2)); $('#iva').val(parseFloat(parseFloat(document.getElementById("iva").value)+parseFloat(valorParcial.toFixed(2)*0.21)).toFixed(2)); $('#totalfinal').val((parseFloat(document.getElementById("totalfinal").value)+parseFloat(valorParcial.toFixed(2)*0.21)+parseFloat(valorParcial.toFixed(2))).toFixed(2)); $("#detalleTabla").append("<tr><td><input type='checkbox' name='seleccionar'></td>"+"<td>" + respuesta[0] + "</td><td>" + respuesta[1] + "</td><td>" + cantidad + "</td><td>" + precio+ "</td><td><input class='btn btn-danger' type='button' name='eliminar' id='eliminar' value='Eliminar' onclick='elinminarRegistro("+respuesta[2]+","+respuesta[3]+")'></td></tr>"); } }); } else{ alert("Debe ingresar un valor mayor a 0 para poder ingresar al carrito"); } }
function elinminarRegistro(id,cantidad) {
numeroPedido=document.getElementById("numeroPedido").value; subTotal=document.getElementById('subtotal').value; total=document.getElementById('totalfinal').value; cliente=document.getElementById("id_cliente").value; vendedor=document.getElementById("comboVendedor").value; desc=document.getElementById("comboDescuentos").value; descto=desc.split('%'); descuento=descto[0]; cantidadProductos=document.getElementById("cantidadRegistros").value; cantProd=parseInt(cantidadProductos,10); cantidadSumafinal=parseInt(cantidad,10); cantProd=parseInt(cantidadProductos,10); cantidadSumafinal=parseInt(cantidad,10);
descuentoBase=document.getElementById("descuentoBase").value; //tengo que averiguar el registro que estoy borrando de la tabla y de la base de datos document.getElementById("cantidadRegistros").value=(cantProd-cantidadSumafinal); $.ajax({ type: 'POST', url: '<?php echo site_url("pedido/eliminar");?>', data: {id:id,numeroPedido:numeroPedido,cliente:cliente,vendedor:vendedor,total:total,descuento:descuento,subTotal:subTotal}, success:function(data){ respuesta=data.split(';'); valorSinDto=parseFloat(respuesta[0]*respuesta[1]); valorParcial=(parseFloat(respuesta[0]*respuesta[1])-parseFloat(respuesta[0]*respuesta[1]*descuentoBase/100)); $('#subtotal').val(parseFloat(parseFloat(document.getElementById("subtotal").value)-parseFloat(valorSinDto.toFixed(2))).toFixed(2)); $('#totalAlternativo').val((parseFloat(parseFloat(document.getElementById("totalAlternativo").value))-parseFloat(valorParcial))); $('#iva').val((parseFloat(parseFloat(document.getElementById("iva").value))-parseFloat(valorParcial*0.21))); $('#totalfinal').val((parseFloat(document.getElementById("totalfinal").value)-parseFloat(valorParcial*0.21)-parseFloat(valorParcial)));
} }); // sacar el redirect window.location.reload(); }
function guardarPedido(){ var r=confirm("Desea guardar el Pedido Creado?"); if (r == true) { numeroPedido=document.getElementById("numeroPedido").value; total=document.getElementById('totalfinal').value; subtotal=document.getElementById('subtotal').value; cliente=document.getElementById("id_cliente").value; vendedor=document.getElementById("comboVendedor").value; if(total != '0'){ if(cliente != ''){ if(numeroPedido != ""){ location.href='<?php echo base_url()?>pedido/guardarPedido?nroPedido='+numeroPedido+'&total='+total+'&vendedor='+vendedor+'&subTotal='+subtotal; } } else{ alert('Ingrese un Cliente'); } } else{ alert('Ingrese Productos al pedido'); } } }
document.onkeydown = function(){ if (window.event && (window.event.keyCode == 8)) { valor = document.activeElement.value; if (valor==undefined) { return false; } //Evita Back en página. else { if (document.activeElement.getAttribute('type')=='sel ect-one') { return false; } //Evita Back en select. if (document.activeElement.getAttribute('type')=='but ton') { return false; } //Evita Back en button. if (document.activeElement.getAttribute('type')=='rad io') { return false; } //Evita Back en radio. if (document.activeElement.getAttribute('type')=='che ckbox') { return false; } //Evita Back en checkbox. if (document.activeElement.getAttribute('type')=='fil e') { return false; } //Evita Back en file. if (document.activeElement.getAttribute('type')=='res et') { return false; } //Evita Back en reset. if (document.activeElement.getAttribute('type')=='sub mit') { return false; } //Evita Back en submit. else //Text, textarea o password { if (document.activeElement.value.length==0) { return false; } //No realiza el backspace(largo igual a 0). else { document.activeElement.value.keyCode = 8; } //Realiza el backspace. } } } if(window.event && window.event.keyCode == 505){ window.event.keyCode = 505; } } </script>
|