@extends('BaseSistemaWeb') @section('CSS') {{ HTML::style('bootstrap-select/css/bootstrap-select.min.css') }} {{ HTML::style('bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css') }} @stop @section('Contenido')

Gestión de ventas en línea

Creación de campaña de descuentos

{{ Form::open(array('route' => 'SysWebVentasCampanhasAgregar', 'method' => 'post', 'class' => 'form-horizontal row-border', 'id' => 'frmAgregar', 'files' => true, 'target' => 'upload_iframe')) }}
{{ Form::text('nombre', '', array('class' => 'form-control', 'placeholder' => '')) }}
{{ Form::text('fecha_inicio', '', array('class' => 'form-control', 'placeholder' => '', 'readonly')) }}
{{ Form::text('fecha_fin', '', array('class' => 'form-control', 'placeholder' => '', 'readonly')) }}
{{ Form::button('Guardar', array('class' => 'btn btn-primary', 'id' => 'btnAgregar', 'type' => 'submit')) }} {{ HTML::linkRoute('SysWebVentasCampanhas', 'Cancelar', array(), array('class' => 'btn btn-default')) }}
{{ Form::close() }}
@stop @section('JS') {{ HTML::script('bootstrap-select/js/bootstrap-select.min.js') }} {{ HTML::script('bootstrap-select/js/i18n/defaults-es_CL.min.js') }} {{ HTML::script('ajax-bootstrap-select/js/ajax-bootstrap-select.min.js') }} {{ HTML::script('ajax-bootstrap-select/js/locale/ajax-bootstrap-select.es-ES.min.js') }} {{ HTML::script('bootstrap-datetimepicker/js/moment-with-locales.js') }} {{ HTML::script('bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js') }} {{ HTML::script('Alphanum/jquery.alphanum.min.js') }} @stop @section('JSOr') $('[name="tipo"]').on("changed.bs.select", function(e, clickedIndex, isSelected, previousValue){ var select = $(this); var valor = select.selectpicker("val"); if( valor == "US" ){ $(".dvInfoDescuento").hide("slow"); $(".dvNCompras").hide("slow"); $(".dvCodCupon").hide("slow"); $(".dvProdUpSell").show("slow"); } else if( valor == "DPT" ){ $(".dvInfoDescuento").show("slow"); $(".dvNCompras").show("slow"); $(".dvCodCupon").hide("slow"); $(".dvProdUpSell").hide("slow"); } else{ $(".dvInfoDescuento").show("slow"); $(".dvNCompras").show("slow"); $(".dvCodCupon").show("slow"); $(".dvProdUpSell").hide("slow"); } }); $(".date").datetimepicker({ locale: "es", format: "D/MM/YYYY hh:mm a", ignoreReadonly: true }); $("#fecha_inicio").on("dp.change", function(e){ $("#fecha_fin").data("DateTimePicker").minDate( e.date ); }); $('[name="descuento"]').numeric(); $('[name="numero_de_compras"]').numeric("integer"); $('[name="codigo_cupon_fijo"]').alphanum({ allowSpace: false, allowNewline: false }); $.post( "{{ URL::route('SysWebVentasCampanhasListadoDePyV') }}", {accion: "P"}, function(data){ if(data.success){ if( data.productos.length > 0 ){ $('[name="productos_servicios_id"]').html(""); $.each(data.productos, function(i, producto){ $('[name="productos_servicios_id"]').append(''); }); $('[name="productos_servicios_id"]').selectpicker("refresh"); $('[name="productos_servicios_id"]').on("changed.bs.select", function(e, clickedIndex, isSelected, previousValue){ var select = $(this); var valor = select.selectpicker("val"); var sinV = parseInt( $('[name="productos_servicios_id"]').find('option[value="'+valor+'"]').attr("data-sinV") ); $.post( "{{ URL::route('SysWebVentasCampanhasListadoDePyV') }}", {accion: "V", idPS: valor}, function(data){ if(data.success){ $.each(data.variaciones, function(i, variacion){ $('[name="variacion_upsell_id"]').html(""); if( sinV == 0 ){ $(".dvVariacionUS").show("slow"); var atributos = JSON.parse( variacion.atributos ); var nAtributos = atributos.length; var strAtributos = ""; $.each(atributos, function(i, atributo){ strAtributos = strAtributos+atributo.nombre+": "+atributo.valor; if(i < (nAtributos - 1)){ strAtributos = strAtributos+", "; } }); $('[name="variacion_upsell_id"]').append(''); } else{ $(".dvVariacionUS").hide("slow"); $('[name="variacion_upsell_id"]').append(''); } $('[name="variacion_upsell_id"]').selectpicker("refresh"); }); } }, "json" ); }); } } else{ if(data.mensaje != ''){ new PNotify({ title: "Error", text: data.mensaje, type: "error" }); } $.each(data.errMensajes, function(key, value){ if(value != ''){ $("#err"+key).html(value); } else{ $("#err"+key).html(""); } }); } }, "json" ); $("#frmAgregar").submit(function(e){ $.isLoading({ text: "Cargando..." }); NProgress.start(); $("#btnAgregar").html(' Cargando').prop("disabled", true); e.preventDefault(); var frmAgregar = new FormData(document.getElementById("frmAgregar")); $.ajax({ type: "POST", url: "{{ URL::route('SysWebVentasCampanhasAgregar', array()) }}", data: frmAgregar, cache: false, contentType: false, processData: false, dataType: "json", success: function(data){ $.isLoading("hide"); NProgress.done(); $("#btnAgregar").html("Guardar").prop("disabled", false); if(data.success){ new PNotify({ title: "Realizado", text: data.mensaje, type: "success" }); setTimeout( function(){ window.location.href = "{{ URL::route('SysWebVentasCampanhas') }}"; }, 3000 ); } else{ if(data.mensaje != ''){ new PNotify({ title: "Error", text: data.mensaje, type: "error" }); } $.each(data.errMensajes, function(key, value){ if(value != ''){ $("#err"+key).html(value); } else{ $("#err"+key).html(""); } }); } }, error: function(jqXHR, textStatus, errorThrown){ new PNotify({ title: "Error", text: textStatus + " " + errorThrown, type: "error" }); } }); }); @stop