<link rel="stylesheet" href="componentes/ventas/recursos/css/ventas.css">
<section class="invoice" id="cotizacion-{{ hash_vista }}">
    <form id="frm-cotizaciones-{{ hash_vista }}">
        {% include 'ventas/vistas/cotizaciones/cotizacion/cabecera.html.php' %}
        {% include 'ventas/vistas/cotizaciones/cotizacion/servicios.html.php' %}
        {% include 'ventas/vistas/cotizaciones/cotizacion/tabla.html.php' %}
        <div class="box box-solid box-primary">
            <div class="box-header" style="text-align:center;">
                <h2 class="box-title" style="font-weight: bold;">
                    Observaciones/Detalles:
                </h2>
            </div>
            <div class="box-body">
                <textarea class="form-control" rows="5" id="Observaciones" name="Observaciones" placeholder="Observaciones/Detalles">{{CotizacionEditar.cotizacionOBSERVACIONES}}</textarea>
            </div>
        </div>
        {% include 'ventas/vistas/cotizaciones/cotizacion/pie.html.php' %}
    </form>
</section>

<script type="text/javascript" src="componentes/ventas/recursos/js/ventas.js" ></script>                
<script type="text/javascript">

    $("#frm-cotizaciones-{{ hash_vista }}").submit(function (evt) {
        var datos = $(this).serialize();
        if( $("#frm-cotizaciones-{{ hash_vista }} .idItemServicios").length > 0 ){
             ejecutarOperacion("ventas","Cotizaciones","registrarCotizacion", $('#frm-cotizaciones-{{ hash_vista }}').serialize()+"&usuarioID="+{{session.usuarioID}},
             function (datos) {
                cargarVista("ventas","Cotizaciones","vistaPrevia","cotizacionID="+datos.Cotizacion.cotizacionID,"Vista Previa Cotización "+datos.Cotizacion.cotizacionID, "vistaPrevia");
                //removeTab("editarcotizacion");
                cerrarTabContenedor("cotizacion-{{ hash_vista }}");
            });
        }else{
            swal("Error!", 'NO PUEDES GENERAR UNA COTIZACIÓN SIN ITEMS', "error");
        }
        evt.preventDefault();
    });
    
</script>
