Viewing file: pedido_new_view3.php (44.64 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:1000px; left: 400px; top: auto; bottom: 0; overflow: auto; }
.modal3.in { position: absolute; bottom: 0; right: 0; width: auto; left: 400px; top: auto; bottom: 0; overflow: auto; }
#content { margin: 0 auto;
width: auto; height: auto;
}
#izquierda{ width:500px; height:100px; float: left; }
#derecha{ width:400px; height:100px; float: right; }
.cuadrado{ witdth:auto; height:auto; background-color: #999999; border: solid 1px #000000; color: white; } /* created new class for targetting purpose - named ".modal2", ".modal1" */ .modal2.in{ position: absolute; bottom: 0; right:0; width:800px; left: 600px; top: auto; bottom: 0; overflow: auto; }
</style>
<div class="content-wrapper" style="min-height: 946px;"> <div style="margin-left:20px;">
<!-- 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="col-md-12"> <div class="span4"> <form method="post" action="<?php echo base_url()?>pedido/paginacionClientes/"> <div> <div id="buscador"> <input style="font-family: Arial; font-size: 16pt;height: 40px;" placeholder="RAZON SOCIAL..." style="height: 20px;" type="text" name="buscando" class="med" id="buscando" /> <input type="button" class="btn btn-success btn-md" value="SELECCIONAR" onclick="agregarCliente()"/> </div> </div> </form> </div> <div class="span4"> <strong style="font-family: Arial; font-size: 12pt;height: 40px;">Vendedor: </strong> <select style="font-family: Arial; font-size: 16pt;height: 40px;" name="comboVendedor" id="comboVendedor" > <option><?php echo($datosPedido[0]->vendedor); ?></option> <?php $respuestaCombo=$this->consultas_model->getVendedores(); foreach($respuestaCombo as $file):?> <option><?= $file->nombre ?></option> <?php endforeach;?> </select> </div> <div class="span4"> <strong style="font-family: Arial; font-size: 12pt;height: 40px;">PAGO: </strong> <select style="font-family: Arial; font-size: 16pt;height: 40px;" name="comboMedioPago" id="comboMedioPago" > <option><?php echo($medioPago[0]->medio); ?></option> <?php $respuestaCombo2=$this->consultas_model->getMedioPago(); foreach($respuestaCombo2 as $file):?> <option><?= $file->medio ?></option> <?php endforeach;?> </select> </div> </div> <br><br><br><br> <div role="tabpanel" class="tab-pane active estiloForm" id="home"> <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;width: 200px;" 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;width: 200px; " 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>TEL </b> <input class="form-control input-sm" style="height: 40px;width: 170px;" type="text" name="telefonoCliente" id="telefonoCliente" value="<?php echo ($datosCliente->telefono)?>" readonly> <b>CUIT</b> <input class="form-control input-sm" style="height: 40px;font-size:20px;" 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> <b>IVA </b> <input class="form-control input-sm" style="height: 40px;color:rgb(255,0,0);font-size:20px;" type="text" name="expreso" id="expreso" value="<?php echo (strtoupper($datosCliente->iva))?>" readonly> </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> <br> <br>
<div class="panel panel-default"> <div class="panel-body"> <b>ESCRIBIR COMENTARIO: </b> <textarea class="form-control input-sm" style="margin: 0px; width: 1145px; height: 40px;" type="text" name="observacion" id="observacion" ><?php echo ($datosPedido[0]->observacion);?></textarea> <br> <br> <div class="col-md-12" align="right"> <input class="btn btn-default" type="button" name="observ" id="observ" value="REGISTRAR COMENTARIO" onclick="registraComentario();"> </div> </div> </div> <input type="hidden" name="cotizador" id="cotizador" value="<?php echo ($datosPedido[0]->cotizador);?>"> <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*$ivaMultiplicador,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> <br>
</div> <div class="col-md-12"> <div class="content" > <div id="izquierda" align="left"> <div class="cuadrado" > <h2>REGISTRACION DE PAGOS</h2> <br><br> <button type="button" class="btn btn-success btn-lg" data-toggle="modal" data-target="#modalRecibos">+ RECIBOS DISPONIBLES</button> <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">+ NUEVO RECIBO</button> </div> </div> <div id="derecha" align="right"> <label><b style="font-family: Arial; font-size: 16pt;height: 40px;">Descuento:</b></label> <select name="comboDescuentos" id="comboDescuentos" style="font-family: Arial; font-size: 16pt;height: 40px;" class="form-control"> <option><?php if($datosPedido[0]->descuento !=null) echo($datosPedido[0]->descuento ."%"); ?></option> <option></option> <?php $respuestaCombo=$this->consultas_model->getDescuentos(); foreach($respuestaCombo as $file):?> <option><?= $file ?>%</option> <?php endforeach;?> </select> <br> <br> <input class="btn btn-primary btn-lg" type="button" name="descuentoBoton" id="descuentoBoton" value="Aplicar Descuento" onclick="aplicarDescuento(document.getElementById('comboDescuentos').value);"> <br> <br> <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" pattern="[0-9]+([,\.][0-9]+)?" style="font-family: Arial; font-size: 20pt;height: 40px;" name="totalfinal" id="totalfinal" value="<?php echo ($total);?>"readonly> </div> </div> </div> <br><br> <input type="hidden" name="multiplicadorIva" id="multiplicadorIva" value="<?php echo ($ivaMultiplicador);?>"> <input type="hidden" name="bdIva" id="bdIva" value="<?php echo ($datosPedido[0]->iva);?>"> <input type="hidden" name="cotizador" id="cotizador" value="<?php echo ($datosPedido[0]->cotizador);?>"> <input type="hidden" name="cantidadRegistros" id="cantidadRegistros" value="<?php echo ($cantidadProdTabla);?>"> <input type="hidden" name="descuentoBase" id="descuentoBase" value="<?php echo ($datosPedido[0]->descuento);?>"> <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>
<!-- Modal --> <div ng-app="menuRecibos" style="margin-left:20px;"> <!-- MODAL RECIBOS REGISTRADOS --> <div class="modal fade modal3" id="modalRecibos" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="myModalLabel">RECIBOS REGISTRADOS AL PEDIDO </h4> </div> <div class="modal-body"> <form ng-submit="confirm()" name="pedidos" id="pedidos" action="<?php echo base_url();?>recibo/verRecibos/" method="POST" ng-controller="MyCtrl"> <input type="text" autofocus ng-model="search" ng-change="filter()" style="width: 600px;height :40px;" placeholder="BUSCAR" class="form-control" /> <button type="button" class="btn btn-primary btn-lg" title="ACTUALIZAR RECIBOS" ng-click="refresh()" aria-label="Left Align"> <span class="glyphicon glyphicon-refresh"></span> </button> <div class="row"> <div class="col-md-12" ng-show="filteredItems > 0"> <table class="table table-striped table-bordered"> <thead> <th>RECIBO <a ng-click="sort_by('id_recibo');"><i class="glyphicon glyphicon-sort"></i></a></th> <th>PEDIDO ASOCIADO <a ng-click="sort_by('numero_pedido');"><i class="glyphicon glyphicon-sort"></i></a></th> <th>FECHA <a ng-click="sort_by('fecha');"><i class="glyphicon glyphicon-sort"></i></a></th> <th>VENDEDOR <a ng-click="sort_by('COTIZADOR');"><i class="glyphicon glyphicon-sort"></i></a></th> <th>CLIENTE (RAZON SOCIAL) <a ng-click="sort_by('razon_social');"><i class="glyphicon glyphicon-sort"></i></a></th> <th>PAGADOR <a ng-click="sort_by('pagador');"><i class="glyphicon glyphicon-sort"></i></a></th> <th>TOTAL <a ng-click="sort_by('total');"><i class="glyphicon glyphicon-sort"></i></a></th> <th>ACCION </th> </thead> <tbody> <tr ng-repeat="data in filtered = (list | filter:search) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit"> <td ><b>{{data.id_recibo}}</b></td> <td ><b>{{data.numero_pedido}}</b></td> <td><b>{{data.fecha}}</b></td> <td><b>{{data.vendedor}}</b></td> <td><b>{{data.razon_social}}</b></td> <td><b>{{data.pagador}}</b></td> <td><b>{{data.total}}</b></td> <td> <div class="input-group"> <button type="submit" class="btn btn-warning btn-md" title="IMPRIMIR EN PDF" ng-click='ponerDatos(data.id_recibo,data.id_cliente,3)' aria-label="Left Align"> <span class="glyphicon glyphicon-print"></span> </button> </div> </td> </tr> </tbody> </table> </div> </div> <div class="col-md-10" ng-show="filteredItems == 0"> <div class="col-md-10"> <h4>NO HAY RECIBOS DISPONIBLES</h4> </div> </div> <div class="col-md-10" ng-show="filteredItems > 0"> <div class="col-md-4"> <h5>Obtenidos {{ filtered.length }} De {{ totalItems}} RECIBOS </h5> </div> <div class="col-md-8" pagination="" page="currentPage" max-size="10" on-select-page="setPage(page)" boundary-links="true" total-items="filteredItems" items-per-page="entryLimit" class="pagination-small" previous-text="«" next-text="»"></div> </div> <input type="hidden" name="accion" id="accion" ng-init="tipoOp = '0'" ng-model="model.accion" value="{{accion}}"> </input> <input type="hidden" name="numClienteRecibo" id="numeroCliente" ng-init="tipoOp = '0'" ng-model="model.numClienteRecibo" value="{{numClienteRecibo}}"> </input> <input type="hidden" name="numeroRecibo" id="numeroRecibo" ng-init="tipoOp = '0'" ng-model="model.numeroRecibo" value="{{numeroRecibo}}"> </input> </form> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">CERRAR</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal --> </div> <!-- Modal GENERACION DE RECIBOS --> <div class="modal fade modal2" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div style="margin-left:20px;" ng-controller="MyCtrl2" >
<!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">CREACION DE RECIBO</h4> </div> <div class="modal-body">
<div class="inline"> <!-- <label><b style="font-family: Arial; font-size: 14pt;height: 30px;">PAGADO: $</b></label> <input type="text" style="font-family: Arial; font-size: 14pt;height: 40px;width :160px;" name="pagadoPopup" id="pagadoPopup" value="<php if($valorPago !=null){ echo ($valorPago);}else{echo"0";}?>"readonly> --> <!-- <label><b style="font-family: Arial; font-size: 14pt;height: 30px;">SALDO: $</b></label> <input type="text" style="font-family: Arial; font-size: 14pt;height: 40px;width :160px;" name="saldoPopup" id="saldoPopup" value="<php echo ($total-$valorPago);?>"readonly> --> <label><b style="font-family: Arial; font-size: 18pt;height: 30px;">SUBTOTAL: $</b></label> <input type="text" style="font-family: Arial; font-size:20pt;height: 40px;width :160px;" name="subForm" id="subForm" ng-model="subForm" value="subForm" readonly> <label><b style="font-family: Arial; font-size: 18pt;height: 30px;">TOTAL: $</b></label> <input type="text" style="font-family: Arial; font-size:20pt;height: 40px;width :160px;" name="totalForm" id="totalForm" ng-model="totalForm" value="totalForm" readonly> </div> <br> <div class="form-inline">
<label><b>PAGADOR:</b></label> <input type="text" style="font-family: Arial; font-size: 12pt;height: 40px;width: 250px;" placeholder="PAGADOR" id="pagador" name="pagador" ng-model="pagador" value="" />
<label><b>OBSERVACION:</b></label> <input type="text" style="font-family: Arial; font-size: 12pt;height: 40px;width: 250px;" placeholder="OBSERVACION" id="observacion" name="observacion" ng-model="observacion" value="" /> <br> <br> <label><b>TIPO PAGO:</b></label> <select style="font-family: Arial; font-size: 12pt;width: 160px;"name="comboTipoPago" id="comboTipoPago" ng-model="combo" class="form-control"> <option></option> <?php $respuestaCombo=$this->consultas_model->getTiposPagos(); foreach($respuestaCombo as $file):?> <option><?= $file ?></option> <?php endforeach;?> </select> <label><b>IMPORTE:</b></label> <input type="number" style="font-family: Arial; font-size: 12pt;height: 40px;width: 160px;" placeholder="MONTO" id="valor" ng-model="valor" name="valor" value="" /> </div> <br><br> <label><b>NRO CHEQUE:</b></label> <input type="text" style="font-family: Arial; font-size: 12pt;height: 40px;width: 150px;" placeholder="NUMERO CHEQUE" id="numeroCheque" ng-model="numeroCheque" name="numeroCheque" value="" /> <label><b>BANCO:</b></label> <input type="text" style="font-family: Arial; font-size: 12pt;height: 40px;width: 150px;" placeholder="BANCO" id="banco" name="banco" ng-model="banco" value="" />
<label><b>FECHA COBRO:</b></label> <input style="font-family: Arial; font-size: 12pt;height: 40px;width: 200px;" name="datapicker1" id="datepicker1" ng-model="datepicker1" placeholder="FECHA COBRO" value=""> <button class="btn btn-primary btn-lg" title="STAND BY PEDIDO" ng-click="putData(combo,valor,numeroCheque,banco,datepicker1)" aria-label="Left Align"> <span class="glyphicon glyphicon-plus"></span> </button> <br><br> <div class="row"> <div class="col-md-10" ng-show="filteredItems >= 0"> <table class="table table-striped table-bordered"> <thead> <th>TIPO PAGO <a ng-click="sort_by('tipoPago');"><i class="glyphicon glyphicon-sort"></i></a></th> <th>MONTO <a ng-click="sort_by('monto');"><i class="glyphicon glyphicon-sort"></i></a></th> <th>NUMERO CHEQUE <a ng-click="sort_by('numeroCheque');"><i class="glyphicon glyphicon-sort"></i></a></th> <th>BANCO <a ng-click="sort_by('banco');"><i class="glyphicon glyphicon-sort"></i></a></th> <th>FECHA COBRO <a ng-click="sort_by('fechaCobro');"><i class="glyphicon glyphicon-sort"></i></a></th>
<th>ACCION </th> </thead> <tbody> <tr ng-repeat="data2 in listItems"> <td ><b>{{data2.tipoPago}}</b></td> <td><b>{{data2.valor}}</b></td> <td><b>{{data2.nro_cheque}}</b></td> <td><b>{{data2.banco}}</b></td> <td><b>{{data2.fechaCobro}}</b></td> <td> <div class="input-group"> <button type="submit" class="btn btn-danger btn-md" title="ELIMINAR ITEM" ng-click="sacarItems(data2)" aria-label="Left Align"> <span class="glyphicon glyphicon-trash"></span> </button>
</div> </td> </tr> </tbody> </table> </div> </div>
</div> <div class="modal-footer"> <div class="inline"> <form ng-submit="confirm()" name="pedidos2" id="pedidos2" action="<?php echo base_url();?>recibo/procesarRecibo/" method="POST" > <button type="button" class="btn btn-default btn-lg " data-dismiss="modal">CERRAR</button> <input type="hidden" name="nropedido" id="nropedido" ng-model="nroPedido" value="{{nroPedido}}"> </input> <input type="hidden" name="arrayDatos" id="arrayDatos" ng-model="arrayDatos" value="{{listItems}}"> </input> <input type="hidden" name="observacion2" id="observacion2" ng-model="observacion2" value="{{observacion}}"> </input> <input type="hidden" name="pagador2" id="pagador2" ng-model="pagador2" value="{{pagador}}"> </input> <input type="hidden" name="id_cliente" id="id_cliente" ng-model="id_cliente" value="{{id_cliente}}"> </input> <input type="submit" class="btn btn-success btn-lg" id="registrar2" value="GENERAR RECIBO" ng-click="pasarDatos();" /> </form> </div> </div> </div> </div> </div> </div> </div>
</section><!-- /.content --> </div><!-- /.content-wrapper --> <script type="text/javascript">
$( "#datepicker1" ).datepicker({ dateFormat: "yy-m-dd", // Primer dia de la semana El lunes firstDay: 1, // Dias Largo en castellano // Cuando seleccionamos la fecha esta se pone en el campo Input onSelect: function(dateText) {
} }); var app = angular.module('menuRecibos', ['ui.bootstrap']);
app.filter('startFrom', function() { return function(input, start) { if(input) { start = +start; //parse to int return input.slice(start); } return []; } }); app.controller('MyCtrl', function ($scope, $http, $location) { $scope.accion=''; $scope.numClienteRecibo=''; $scope.numeroRecibo=''; $nroPedido=document.getElementById("numeroPedido").value; $scope.list=[];
$http({ url: "<?php echo site_url("pedido/getPedidosPuntualesAajax");?>", method: "GET", params: {id_pedido: $nroPedido} }).success(function(data){ $scope.list = data; $scope.currentPage = 1; //current page $scope.entryLimit = 10; //max no of items to display in a page $scope.filteredItems = $scope.list.length; //Initially for no filter $scope.totalItems = $scope.list.length; }); $scope.setPage = function(pageNo) { $scope.currentPage = pageNo; }; $scope.refresh = function() {
$http({ url: "<?php echo site_url("pedido/getPedidosPuntualesAajax");?>", method: "GET", params: {id_pedido: $nroPedido} }).success(function(data){ $scope.list = data; $scope.currentPage = 1; //current page $scope.entryLimit = 10; //max no of items to display in a page $scope.filteredItems = $scope.list.length; //Initially for no filter $scope.totalItems = $scope.list.length; }); }; $scope.sort_by = function(predicate) { $scope.predicate = predicate; $scope.reverse = !$scope.reverse; };
$scope.ponerDatos= function (id,numeroCliente,accion){ $scope.accion=accion; $scope.numClienteRecibo=numeroCliente; $scope.numeroRecibo=id; };
$scope.confirm = function() { if (confirm('Estas seguro de esta accion?')){ event.returnValue=true; } else{ event.returnValue=false; } }; });
app.controller('MyCtrl2', function ($scope, $http, $location) { $scope.accion=''; $scope.observacion=''; $scope.pagador=''; $scope.numeroRecibo=''; $scope.id_cliente=document.getElementById("id_cliente").value; $scope.nroPedido=document.getElementById("numeroPedido").value; $scope.totalForm=document.getElementById("totalfinal").value;
$scope.subForm=document.getElementById("totalAlternativo").value; $scope.listItems=[]; $scope.currentPage = 1; //current page $scope.entryLimit = 10; //max no of items to display in a page $scope.filteredItems = ""; //Initially for no filter $scope.totalItems =0; $scope.setPage = function(pageNo) { $scope.currentPage = pageNo; }; $scope.sort_by = function(predicate) { $scope.predicate = predicate; $scope.reverse = !$scope.reverse; };
$scope.sacarItems= function(item){
var index = $scope.listItems.indexOf(item); $scope.listItems.splice(index, 1); }; $scope.putData= function (a,b,c,d,e){ error="0"; var datetime = $("#datepicker1").val(); if(b){}else{b="";} if(c){}else{c="";} if(d){}else{d="";} if(datetime){}else{datetime="";}
//validacion items //valido si es efectivo if(a ==="EFECTIVO"){ if(b != ""){ } else{ error="1"; alert("debe completar el monto"); } } //valido si es cheque if(a==="CHEQUE"){ if(b != ""){ if(c != ""){ if(d!= ""){ if(datetime!= ""){ }else{ error="1"; alert("debe completar FECHA COBRO"); } }else{ error="1"; alert("debe completar el BANCO"); } }else{ error="1"; alert("debe completar el numero de cheque"); } } else{ error="1"; alert("debe completar el monto"); } } if(a==="OTROS"){ error="1"; alert("no se inputa este tipo de pago"); }
if(error === "0"){ $scope.listItems.push({ 'tipoPago':a, 'valor':b, 'nro_cheque':c, 'banco':d, 'fechaCobro':datetime }); //vacio los campos $scope.numeroCheque=""; $scope.combo=""; $scope.valor=""; $scope.banco=""; $("#datepicker1").val("");
} };
$scope.confirm = function() {
if ($scope.listItems.length > 0){ event.returnValue=true; } else{ alert("COMPLETE LOS DATOS"); event.returnValue=false; } }; }); $(document).ready(function() { $("#busquedaRecibo .deleteLink").on("click",function() { var tr = $(this).closest('tr'); tr.css("background-color","#FF3700"); tr.fadeOut(400, function(){ tr.remove(); }); return false; }); }); $(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); eventoEnter(); } }); } }); }); $().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/facturar'; }
//funcion q se posiciona en el input de cantidades function eventoEnter(){
document.getElementById("cantidadProd_1").focus(); }
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){ if(data != "Faltan Datos"){ respuesta=data.split(';');
$('#pagadoPopup').val(parseFloat(parseFloat(document.getElementById("pagadoPopup").value)+parseFloat(valor))); $('#saldoPopup').val(parseFloat(parseFloat(document.getElementById("saldoPopup").value)-parseFloat(valor))); $("#busquedaRecibo").prepend("<tr><td>" + tipo + "</td><td>" + respuesta[0] + "</td><td>" + dato + "</td><td>" + valor+ "</td><td>" + recibo+ "</td><td><input class='deleteLink btn btn-danger' type='button' name='eliminar' id='eliminar' value='Eliminar' onclick='elinminarRegistroPago("+respuesta[1]+"," + valor+");'></td></tr>"); alert("PAGO REGISTRADO"); } else{ alert("Datos incompletos"); } } }); } 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('%'); subTotal=document.getElementById('subtotal').value;
valor=subTotal; descuentoFinal=parseFloat(descuento1); descuentoF=descuentoFinal*valor*0.01; valorFinal=(valor-descuentoF);
//correccion iva para registrar las posibilidades del iva. multiplicadorIva=document.getElementById('multiplicadorIva').value;
$('#totalAlternativo').val(valorFinal.toFixed(2));
valorIva=parseFloat((parseFloat(valorFinal).toFixed(2)*multiplicadorIva)).toFixed(2); $('#iva').val(valorIva);
total=(parseFloat(valorIva) + parseFloat(valorFinal));
$('#totalfinal').val(total.toFixed(2)); $('#comboDescuentos').val(descuento); vendedor=document.getElementById("comboVendedor").value; nroPedido=document.getElementById("numeroPedido").value; $.ajax({ type: 'POST', url: '<?= base_url("pedido/registrarDescuentoDepo")?>', 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(';'); $('#nombre').val(calculo[2]); $('#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; multiplicadorIva=document.getElementById('multiplicadorIva').value; if (cantidad>0){ $.ajax({ type: 'POST', url: '<?php echo site_url("pedido/registrarDetalleDepo");?>', data: {pedido:pedido,producto:producto, cantidad:cantidad,precio:precio,cliente:cliente,vendedor:vendedor,total:total,subTotal:subTotal,descuento:descuento,multiplicadorIva:multiplicadorIva}, success:function(data){ //chequeo si esta repetido, en caso de estarlo pido confirmacion. if(data !='repetido'){ 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)); multiplicadorIva=document.getElementById('multiplicadorIva').value; $('#iva').val(parseFloat(parseFloat(document.getElementById("iva").value)+parseFloat(valorParcial.toFixed(2)*multiplicadorIva)).toFixed(2)); $('#totalfinal').val((parseFloat(document.getElementById("totalfinal").value)+parseFloat(valorParcial.toFixed(2)*multiplicadorIva)+parseFloat(valorParcial.toFixed(2))).toFixed(2)); $("#detalleTabla").prepend("<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>"); document.getElementById("cantidadRegistros").value=(cantProd+cantidadSumafinal); }else{ var r=confirm("ARTICULO REPETIDO DESEA AGREGARLO IGUAL?"); if (r == true) { $.ajax({ type: 'POST', url: '<?php echo site_url("pedido/registrarDetalleDepoConfirmado");?>', 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)); multiplicadorIva=document.getElementById('multiplicadorIva').value; $('#iva').val(parseFloat(parseFloat(document.getElementById("iva").value)+parseFloat(valorParcial.toFixed(2)*multiplicadorIva)).toFixed(2)); $('#totalfinal').val((parseFloat(document.getElementById("totalfinal").value)+parseFloat(valorParcial.toFixed(2)*multiplicadorIva)+parseFloat(valorParcial.toFixed(2))).toFixed(2)); $("#detalleTabla").prepend("<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>"); document.getElementById("cantidadRegistros").value=(cantProd+cantidadSumafinal); } }); }
} } }); } else{ alert("Debe ingresar un valor mayor a 0 para poder ingresar al carrito"); } }
function elinminarRegistroPago(id,valor){ $.ajax({ type: 'POST', url: '<?php echo site_url("pedido/eliminarRegistroPago");?>', data: {id:id}, success:function(data){ $('#pagadoPopup').val(parseFloat(parseFloat(document.getElementById("pagadoPopup").value)-parseFloat(valor))); $('#saldoPopup').val(parseFloat(parseFloat(document.getElementById("saldoPopup").value)+parseFloat(valor))); alert("REGISTRO BORRADO");
}, error: function () { alert("ERROR AL BORRAR"); } }); } 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); multiplicadorIva=document.getElementById('multiplicadorIva').value; 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/eliminarDepo");?>', data: {id:id,numeroPedido:numeroPedido,cliente:cliente,vendedor:vendedor,total:total,descuento:descuento,subTotal:subTotal,multiplicadorIva:multiplicadorIva}, 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))); //agrego correcion iva multiplicadorIva=document.getElementById('multiplicadorIva').value; $('#iva').val((parseFloat(parseFloat(document.getElementById("iva").value))-parseFloat(valorParcial*multiplicadorIva))); $('#totalfinal').val((parseFloat(document.getElementById("totalfinal").value)-parseFloat(valorParcial*multiplicadorIva)-parseFloat(valorParcial))); window.location.reload(); } }); // 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; medioPago=document.getElementById("comboMedioPago").value; cotizador=document.getElementById("cotizador").value; if(total != '0'){ if(cliente != ''){ if(numeroPedido != ""){ location.href='<?php echo base_url()?>pedido/guardarPedidoFactu?nroPedido='+numeroPedido+'&total='+total+'&vendedor='+vendedor+'&subTotal='+subtotal+'&medioPago='+medioPago+'&cotizador='+cotizador; } } else{ alert('Ingrese un Cliente'); } } else{ alert('Ingrese Productos al pedido'); } } }
document.onkeydown = function(){
//evento enter if (window.event && (window.event.keyCode == 13)) { return false; } 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>
|