Viewing file: ot_new_view.php (5.54 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<div> <h1 ><?= $titulo ?></h1> <form a method="post" name="gestionOT" class="form-horizontal"> <strong>Numero Referencia Orden de Compra: </strong><input type="text" name="nroOrden" id="nroOrden" value="<?php echo ($ordenReferencia);?>"> <br><br> <div id="tablaPrincipalOC" align="center"> <?php $array=array(); $this->table->set_heading('Cantidad disponible', 'Productos disponible', 'Descripcion','Cantidad a Agregar','Agregar a OR'); //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="detalleTablaOT" width="100%">'); $this->table->set_template($tmp); $i=1; //modifica el espaciado //aplico los cambios de modificacion anterior $detallesOC=$this->consultas_model->getDetallesByIdOC($nroOrdenCompra,$cliente); if($detallesOC !=null){ foreach($detallesOC as $file): $this->table->add_row($file->cant_disponible,$file->nombre,$file->descripcion,'<input type="text" name="cantidadProd_'.$i.'" id="cantidadProd_'.$i.'">','<input class="btn btn-success" type="button" name="selection" id="selection" value="Seleccionar" onclick="ingresarOT('.$file->id.','.$i.','.$file->cantidad.')">'); //agregamos la celda a la tabla por cada iteracion $i++; endforeach;
} echo $this->table->generate();
?> </div> <h1 >Nueva Orden de Referencia</h1> <div id="tablaPrincipalOT" align="center"> <?php $array=array(); $detallesOCNuevo=null; $this->table->set_heading('Cantidad ', 'Producto', 'Descripcion','Eliminar Producto'); //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="detalleTablaOTNueva" width="100%">' ); $this->table->set_template($tmp); $detallesOCNuevo=$this->consultas_model->getDetallesByIdOT($nroOt,$cliente); if($detallesOCNuevo !=null){
foreach($detallesOCNuevo as $file): $this->table->add_row($file->cantidad,$file->nombre,$file->descripcion,'<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 endforeach;
} echo $this->table->generate();
?> </div> <div class="col-md-12" align="center"> <input class="btn btn-large" type="button" value="Volver" onclick="volver();"> <input class="btn btn-primary btn-large" type="button" name="crearOt" id="crearOt" value="Crear OT" onclick="enviarOT();"> </div> <input type="hidden" name="ordenTrabajo" id="ordenTrabajo" value="<?php echo ($nroOt);?>"> <input type="hidden" name="cliente" id="cliente" value="<?php echo ($cliente);?>"> <input type="hidden" name="nroOrden" id="nroOrden" value="<?php echo ($nroOrdenCompra);?>"> </form> <br>
</div>
<script type="text/javascript">
function elinminarRegistro(id,cantidad) { ordenTrabajo=document.getElementById("ordenTrabajo").value; cliente=document.getElementById("cliente").value; nroOrden=document.getElementById("nroOrden").value; //tengo que averiguar el registro que estoy borrando de la tabla y de la base de datos $.ajax({ type: 'POST', url: '<?php echo site_url("ordenReferencia/eliminar");?>', data: {ordenTrabajo:ordenTrabajo, cliente:cliente,id:id,cantidad:cantidad,nroOrden:nroOrden}, success:function(data){ } }); window.location.reload(); }
function ingresarOT(id,i,cantDisp){ ordenTrabajo=document.getElementById("ordenTrabajo").value; cliente=document.getElementById("cliente").value; nroOrden=document.getElementById("nroOrden").value; cant="cantidadProd_"+i; cantidad=document.getElementById(cant).value; idProductos=id; if(cantidad>null){ if(cantidad < cantDisp ){ cantActualizar=(cantDisp-cantidad); $.ajax({ type: 'POST', url: '<?php echo site_url("ordenReferencia/registrarDetalles");?>', data: {cantidad:cantidad,idProductos:idProductos,ordenTrabajo:ordenTrabajo,cliente:cliente,nroOrden:nroOrden,cantActualizar:cantActualizar}, success:function(data){ respuesta=data.split(';'); $("#detalleTablaOTNueva").append("<tr><td>" + cantidad + "</td><td>" + respuesta[0] + "</td><td>" + respuesta[1] + "</td><td><input class='btn btn-danger' type='button' name='eliminar' id='eliminar' value='Eliminar' onclick='elinminarRegistro(idProductos)'></td></tr>"); } }); window.location.reload(); } else{ alert("No puede superar la cantidad disponible"); $('#'+cant).val(''); } } else{ alert("Debe Ingresar un valor mayor a cero"); }
}
function volver(){
location.href='<?php echo base_url()?>ordenReferencia/index'; }
function enviarOT(){ var r=confirm("Desea crear la ORDEN DE TRABAJO?"); if (r == true) { numeroOT=document.getElementById("ordenTrabajo").value; if(numeroOT != ""){ location.href='<?php echo base_url()?>ordenReferencia/crearOt?ordenTrabajo='+numeroOT+'&cliente='+document.getElementById("cliente").value+'&nroOrden='+document.getElementById("nroOrden").value; }
} }
document.onkeydown = function(){ if(window.event && window.event.keyCode == 8){ return false; } if(window.event && window.event.keyCode == 505){ window.event.keyCode = 505; } }
</script>
|