Commit 95869a524d99fc59fae2dec174bccac956f4b8ba

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'develop'

Master(efernandez)

See merge request !30
src/js/controller.js
... ... @@ -519,11 +519,17 @@ angular.module('focaCrearFactura').controller('facturaController', [
519 519  
520 520 crearFuncionesProductos(producto);
521 521 });
  522 +
  523 + $scope.botoneraProductos.push({
  524 + label: 'Ultimos despachos',
  525 + image: 'ultimos-despachos.png',
  526 + imageDefault: 'productoDefault.png'
  527 + });
522 528 });
523 529 }
524 530  
525 531 $scope.seleccionarBusquedaProductos = function () {
526   -
  532 +
527 533 if (angular.equals({}, $scope.factura.vendedor)) {
528 534  
529 535 focaModalService.alert('Seleccione Vendedor');
... ... @@ -593,6 +599,89 @@ angular.module('focaCrearFactura').controller('facturaController', [
593 599 .catch(function (e) { console.error(e); });
594 600 };
595 601  
  602 + $scope.seleccionarUltimosDespachos = function () {
  603 +
  604 + if (angular.equals($scope.factura.cliente, {})) {
  605 + focaModalService.alert('Seleccione cliente');
  606 + return;
  607 + }
  608 +
  609 + var modalInstance = $uibModal.open(
  610 + {
  611 + templateUrl: 'modal-ultimos-despachos.html',
  612 + controller: 'ultimosDespachosController',
  613 + resolve: {
  614 + parametros: function () {
  615 + return {
  616 + planilla: $scope.factura.vendedor.NplVen,
  617 + };
  618 + }
  619 + },
  620 + size: 'md'
  621 + }
  622 + );
  623 +
  624 + modalInstance.result.then(function (despacho) {
  625 +
  626 + var articulo = {
  627 + TIP: $scope.factura.cliente.tipoFactura,
  628 + TCO: 'FT',
  629 + SUC: parseInt($scope.puntoVenta),
  630 + ORD: $scope.articulosFiltro().length + 1,
  631 + SEC: despacho.SEC,
  632 + ART: despacho.PRO,
  633 + RUB: producto.CodRub,
  634 + DES: producto.DetArt,
  635 + CAN: despacho.LTS,
  636 + PUN: producto.PreVen,
  637 + IVA: producto.IMPIVA,
  638 + NET: producto.IvaCO != 0 ? producto.PreNet : 0,
  639 + NEX: producto.IvaCO == 0 ? producto.PreNet : 0,
  640 + IMI: producto.ImpInt,
  641 + IMI2: producto.ImpInt2,
  642 + IMI3: producto.ImpInt3,
  643 + PUT: producto.PreVen,
  644 + SUR: despacho.SUR,
  645 + PLA: despacho.PLA,
  646 + LUG: despacho.LUG,
  647 + LEG: $scope.factura.vendedor.CodVen,
  648 + TUR: $scope.factura.vendedor.TurVen,
  649 + ORDEN_PRECOMPRA: '',
  650 + ESC: producto.tipoFactura === 'L' ? 1 : 0,
  651 + CMF: 0,
  652 + PTA: 0,
  653 + IVS: 0,
  654 + TIVA: 21, // TODO traer POR de la tabla ACODIVA where ID = IvaCO
  655 + CON: 0,
  656 + SINO: '',
  657 + ORD_TRA: 0,
  658 + IMP_DESP: 0,
  659 + PCD: 0,
  660 + RTO: '',
  661 + };
  662 +
  663 + crearFacturaService.setearDespachoOcupado({
  664 + surtidor: despacho.SUR,
  665 + producto: despacho.PRO,
  666 + carga: despacho.CAR
  667 + })
  668 + .then(function () {
  669 + $scope.factura.articulosFactura.push(articulo);
  670 + $scope.factura.despachos.push(despacho);
  671 + })
  672 + .catch(function (err) {
  673 +
  674 + console.error(err);
  675 + focaModalService.alert('El despacho esta en uso');
  676 + });
  677 +
  678 + })
  679 + .catch(function (err) {
  680 + console.error(err);
  681 + });
  682 +
  683 + };
  684 +
596 685 function crearFuncionesProductos(producto) {
597 686  
598 687 $scope[nombreFuncion(producto.DetArt)] = function () {
src/js/controllerUltimosDespachos.js
... ... @@ -0,0 +1,52 @@
  1 +angular.module('focaCrearFactura')
  2 + .controller('ultimosDespachosController', [
  3 + '$filter',
  4 + '$scope',
  5 + '$uibModalInstance',
  6 + 'crearFacturaService',
  7 + 'parametros',
  8 + function ($filter, $scope, $uibModalInstance, crearFacturaService, parametros) {
  9 +
  10 + $scope.colorTexto = { color: 'black' };
  11 +
  12 + config();
  13 +
  14 + function config() {
  15 +
  16 + crearFacturaService.getUltimosDespachos(parametros.planilla).then(function (res) {
  17 + $scope.productos = res.data;
  18 + });
  19 + }
  20 +
  21 + $scope.aceptar = function (despacho) {
  22 + $uibModalInstance.close(despacho);
  23 + };
  24 +
  25 + $scope.cancel = function () {
  26 + $uibModalInstance.dismiss('cancel');
  27 + };
  28 +
  29 + //TODO: Cambiar switch case con los casos de nombres de productos axion
  30 + function setColorNombreProducto() {
  31 +
  32 + // Diesel #FF852E | Euro+Diesel #6C389A | Premium #00A857 | Super #175AA5
  33 + switch ($scope.nombreProducto) {
  34 + case 'NAFTA SUPER XXI':
  35 + $scope.colorTexto = { color: '#FF852E' };
  36 + break;
  37 + case 'GO-INFINIA DIESEL':
  38 + $scope.colorTexto = { color: '#6C389A' };
  39 + break;
  40 + case 'ULTRADIESEL XXI - RED':
  41 + $scope.colorTexto = { color: '#00A857' };
  42 + break;
  43 + case 'NAFTA INFINIA':
  44 + $scope.colorTexto = { color: '#175AA5' };
  45 + break;
  46 + default:
  47 + $scope.colorTexto = { color: 'black' };
  48 + break;
  49 + }
  50 + }
  51 + }
  52 + ]);
... ... @@ -15,6 +15,9 @@ angular.module('focaCrearFactura')
15 15 getProductosByPlanilla: function (numeroPlanilla) {
16 16 return $http.get(route + '/turnos/productos/' + numeroPlanilla);
17 17 },
  18 + getUltimosDespachos: function (numeroPlanilla) {
  19 + return $http.get(route + '/turnos/productos/' + numeroPlanilla + '/true');
  20 + },
18 21 setearDespachoOcupado: function (parametros) {
19 22 return $http.post(route + '/turnos/despacho-en-uso', parametros);
20 23 },
src/views/modal-ultimos-despachos.html
... ... @@ -0,0 +1,76 @@
  1 +<div class="modal-header py-1">
  2 + <div class="row w-100">
  3 + <div class="col-lg-6">
  4 + <h5 class="modal-title my-1"><b>Despachos Disponibles</b></h5>
  5 + </div>
  6 + </div>
  7 +</div>
  8 +<div class="modal-body" id="modal-body">
  9 + <div ng-repeat="(key, producto) in productos">
  10 + <div class="row my-2">
  11 + <div class="col">
  12 + <label>
  13 + <img class="w-50" ng-src="./img/surtidor.png" alt="">
  14 + {{manguera.csu}}
  15 + </label>
  16 + <button
  17 + type="button"
  18 + class="btn p-1 text-secondary float-right border"
  19 + ng-click="manguera.show = !manguera.show">
  20 + <i ng-show="manguera.show" class="fa fa-minus px-1"></i>
  21 + <i ng-show="!manguera.show" class="fa fa-plus px-1"></i>
  22 + </button>
  23 + <table class="table table-sm table-striped" ng-show="manguera.show">
  24 + <tbody>
  25 + <tr ng-repeat="(key, despacho) in manguera.despachos">
  26 + <td class="py-2 py-sm-1" ng-bind="despacho.FEC | date:'dd/MM/yyyy hh:MM:ss'"></td>
  27 + <td class="py-2 py-sm-1" ng-bind="despacho.LTS"></td>
  28 + <td class="py-2 py-sm-1" ng-bind="despacho.IMP | currency: '$'"></td>
  29 + <td class="py-2 py-sm-1">
  30 + <button
  31 + type="button"
  32 + class="btn btn-default btn-xs p-1 float-right"
  33 + title="Seleccionar"
  34 + ng-click="aceptar(despacho)"
  35 + ><i class="fa fa-circle-thin" aria-hidden="true"></i>
  36 + </button>
  37 + </td>
  38 + </tr>
  39 + </tbody>
  40 + </table>
  41 + </div>
  42 + </div>
  43 + </div>
  44 +
  45 +</div>
  46 +<div class="modal-footer py-2">
  47 + <nav ng-show="currentPageProveedores.length > 0 && primerBusqueda" class="mr-auto">
  48 + <ul class="pagination pagination-sm mb-0">
  49 + <li class="page-item" ng-class="{'disabled': currentPage == 1}">
  50 + <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage - 1)">
  51 + <span aria-hidden="true">&laquo;</span>
  52 + <span class="sr-only">Anterior</span>
  53 + </a>
  54 + </li>
  55 + <li
  56 + class="page-item"
  57 + ng-repeat="pagina in paginas"
  58 + ng-class="{'active': pagina == currentPage}"
  59 + >
  60 + <a
  61 + class="page-link"
  62 + href="javascript:void();"
  63 + ng-click="selectPage(pagina)"
  64 + ng-bind="pagina"
  65 + ></a>
  66 + </li>
  67 + <li class="page-item" ng-class="{'disabled': currentPage == lastPage}">
  68 + <a class="page-link" href="javascript:void();" ng-click="selectPage(currentPage + 1)">
  69 + <span aria-hidden="true">&raquo;</span>
  70 + <span class="sr-only">Siguiente</span>
  71 + </a>
  72 + </li>
  73 + </ul>
  74 + </nav>
  75 + <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button>
  76 +</div>