Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //----------------------------------------------------------------------------------------------------
- // REGISTRO DE LA PROPIEDAD DE PR
- // POR: INVID LLC
- // PROPOSITO:
- // Maneja la vista madre para todas las vistas de Minuta.
- //----------------------------------------------------------------------------------------------------
- var MinutaView = BaseView.extend({
- reloadClass: MinutaView,
- events: {
- "click .btn-save-minuta": function () {
- if (app.views.mainView.currentMinuta.Minuta.EstatusId == 3 && !app.views.mainView.currentMinuta.Minuta.DocumentoLey216) {
- this.checkCartaCredito()
- } else {
- this.save()
- }
- },
- "click .btn-close": "close",
- "click .historial-asiento": "showHistorico",
- "click .manejo-notificaciones": "showManejoNotificaciones",
- "click .notificacion-caducar": "caducarDocumento",
- "click .notificacion-suspender": "suspenderNotificacion",
- "click .notificacion-suspender-recalificacion": "suspenderNotificacionRecalificar",
- "click .notificacion-suspender-noprocede": "suspenderNotificacionNoProcede",
- "click .btn-print": "printReceipt",
- "click .btn-new": "new",
- "click .btn-new-reuse-presentante": "newReuse",
- "click .btn-leave": "leave",
- "click .btn-retirar": "retirarConfirm",
- "click .btn-negar-retiro": "negarConfirm",
- "click .devolver-minuta": "beforeDevolver",
- "click .btn-devolver": "devolverDocumento",
- "click .btn-denegar": "denegarTemp",
- "click .despachar-minuta": "verificarEstatus"
- },
- bindings: {
- ".asiento-diario": "value:AsientoDiario",
- ".asiento-segmento": "value:AsientoSegmento",
- ".asiento-section": "value:AsientoSection",
- ".motivo-denegar": "value:MotivoDenegar",
- ".motivo-devolver": "value:MotivoDevolver",
- },
- initialize: function () {
- MinutaView.__super__.initialize.apply(this, arguments)
- },
- generateCartaCredito: false,
- init: function () {
- var template = Handlebars.compile($("#minuta").html())
- this.views = {}
- $(this.el)
- .html(template(this.model.toJSON()))
- .addClass("minuta-block active")
- this.workingEl = ".btn-save-minuta"
- this.applyBindings()
- this.delegateEvents()
- $(this.el).find(".asiento-diario").inputmask("mask", { "mask": "999[9]" })
- this.$el.find("#nav-container").onePageNav({
- currentClass: 'current',
- changeHash: false,
- scrollSpeed: 750,
- scrollThreshold: 0.5,
- topOffset: 0,
- $elToScroll: this.$el.find("section#content"),
- filter: '',
- easing: 'swing'
- });
- _.bindAll(this, "render", "beforeRetirar", "beforeNegar", "retirar", "negar",
- "beforeDevolver", "devolverDocumento", "checkCartaCredito");
- _.bindAll(this, "render", "beforeNegar");
- this.startingScrollspy(100);
- },
- moveMainPanel: function (ev) {
- var el = $(ev.currentTarget).find("a").attr("href")
- this.$el.find("section#content").animate({ "top": "100px" }, 300)
- },
- retirarConfirm: function () {
- this.confirm = new ConfirmView()
- this.confirm.hideOnCancel = false
- this.confirm.show("¿Desea retirar el documento?", this.beforeRetirar)
- },
- verificarEstatus: function () {
- var currEstatus = this.model.get("EstatusId")
- if (currEstatus == 7 || currEstatus == 8 || currEstatus == 2 || currEstatus == 3)
- {
- var url = "despacho.html?minutaId=" + this.model.get("Id") + "&aid=" + this.model.get("AsientoId") + "";
- window.open(url, '_blank');
- } else {
- msg = "Debe suspender el documento, para poder despacharlo"
- var aviso = new MessageView()
- aviso.setSize("modal-sm")
- aviso.show(msg, "Aviso", null)
- }
- },
- denegarTemp: function () {
- },
- negar: function () {
- var self = this
- if (this.isWorking)
- return
- this.workingEl = ".btn-denegar"
- this.startWorking()
- var model = new GlobalEmptyModel()
- model.set("AsientoId", this.model.get("AsientoId"))
- model.set("MotivoDenegar", this.model.get("MotivoDenegar"))
- model.customUrl = ("/api/retiroDocumento/denegar/asiento/" + this.model.get("AsientoId"))
- model.save({ Motivo: model.get("MotivoDenegar") }, {
- success: function (err, response) {
- self.stopWorking()
- $(".modal-backdrop").remove()
- if (response) {
- (new MessageView().show("Se ha denegado la solicitud de retiro.", null, function () {
- self.leaveToQueue()
- }))
- }
- },
- error: this.xhrError,
- beforeSend: this.beforeSend
- })
- },
- beforeDevolver: function () {
- var self = this
- this.confirm = new ConfirmView()
- this.confirm.hideOnCancel = false
- this.confirm.show("¿Desea devolver el documento al técnico?", function () {
- self.$el.find(".modal.fade.devolver-modal").modal({ backdrop: 'static', keyboard: false });
- })
- },
- beforeNegar: function () {
- var self = this
- var dardeo = new DarDeoView()
- dardeo.parent = self
- dardeo.show(this.negar)
- },
- negarConfirm: function () {
- var self = this
- this.confirm = new ConfirmView()
- this.confirm.hideOnCancel = false
- this.confirm.show("¿Desea denegar la solicitud de retiro?", function () {
- self.beforeNegar()
- })
- },
- beforeRetirar: function () {
- var self = this
- var dardeo = new DarDeoView()
- dardeo.parent = self
- dardeo.show(this.retirar)
- },
- devolverDocumento: function () {
- var self = this
- if (this.isWorking)
- return
- self.workingEl = ".btn-devolver"
- self.startWorking()
- var model = new GlobalEmptyModel()
- model.set("AsientoId", self.model.get("AsientoId"))
- model.set("MotivoDevolver", self.model.get("MotivoDevolver"))
- model.set("TecnicoEmail", self.model.get("CreadoEmail"))
- model.set("Asiento", self.model.get("Asiento"))
- var data = {
- AsientoId: model.get("AsientoId"),
- Motivo: model.get("MotivoDevolver"),
- TecnicoEmail: model.get("TecnicoEmail"),
- Asiento: model.get("Asiento")
- }
- model.customUrl = ("/api/minuta/asiento/" + data.AsientoId + "/devolver")
- model.save(data, {
- success: function (err, response) {
- if (response) {
- self.stopWorking()
- $(".modal-backdrop").remove()
- new MessageView().show("Se ha devuelto el documento exitosamente.", null, function () {
- setTimeout(function () {
- window.location.assign("#")
- }, 50)
- })
- }
- },
- error: self.xhrError,
- beforeSend: self.beforeSend
- })
- },
- retirar: function () {
- var self = this
- if (this.isWorking)
- return
- this.workingEl = ".ok"
- var model = new GlobalEmptyModel()
- this.model.set("Id", this.model.get("AsientoId"))
- model.customUrl = ("/api/retiroDocumento/asiento/" + this.model.get("AsientoId"))
- model.save({}, {
- success: function (err, response) {
- var confirm = new ConfirmView()
- confirm.show("El documento ha sido retirado")
- $(self.$el).find(".btn-retirar").addClass("hidden")
- $(self.$el).find(".btn-negar-retiro").addClass("hidden")
- self.leaveToQueue()
- },
- error: this.xhrError,
- beforeSend: this.beforeSend
- })
- },
- loadViewsByRoles: function () {
- var $container = $(this.el).find(".left-col .main-accordion"),
- $rightContainer = $(this.el).find(".right-col .right-accordion"),
- minuta = app.views.mainView.currentMinuta.Minuta
- if (!minuta.PuedoVer) {
- window.location.assign('#')
- return
- }
- this.views.documentTypeManagementView = new DocumentTypeManagementView()
- this.views.documentTypeManagementView.parent = this
- this.views.fincaListView = new FincaListView()
- this.views.titularListView = new TitularListView()
- this.views.transaccionListView = new TransaccionListView()
- // this.views.planoListView = new PlanoListView()
- // this.views.planoListView.parent = this
- this.views.documentosComplementariosListView = new DocumentosComplementariosListView()
- this.views.minutaArancelListView = new MinutaArancelListView({
- attributes: { hideDefaultArancel: (!minuta.DocumentoLey216) ? false : true }, forMinuta: true,
- for216: minuta.DocumentoLey216
- })
- this.views.carritoManagementView = new CarritoManagementView()
- this.views.carritoManagementView.parent = this
- this.views.notificacionesView = new NotificacionManagementView()
- $container.append(this.views.notificacionesView.render().el)
- $container.append(this.views.documentTypeManagementView.render().el)
- var obj = {
- minuta:minuta,
- presentante:this.minutaObj.Presentante,
- notarioEmail:this.minutaObj.NotarioEmail,
- otroNombreCompleto:this.minutaObj.OtroNombreApellido
- }
- if (!minuta.DocumentoLey216 && !minuta.DocumentoEnAtraso) {
- // var s = {minuta,}
- this.views.presentanteView = new PresentanteView(obj)
- // this.views.presentanteView.minuta = minuta
- $container.append(this.views.presentanteView.render().el)
- }
- $container.append(this.views.titularListView.render().el)
- $container.append(this.views.fincaListView.render().el)
- $container.append(this.views.transaccionListView.render().el)
- $container.append(this.views.minutaArancelListView.render().el)
- // if (!minuta.DocumentoLey216 && !minuta.DocumentoEnAtraso)
- // $container.append(this.views.planoListView.render().el)
- if (!minuta.DocumentoLey216)
- $container.append(this.views.documentosComplementariosListView.render().el)
- this.views.notificacionesListView = new NotificacionListView()
- $container.prepend(this.views.notificacionesListView.render().el)
- var estatusId = app.views.mainView.currentMinuta.Minuta.EstatusId
- switch (true) {
- case (estatusId == 1):
- if (!minuta.DocumentoEnAtraso && !minuta.DocumentoLey216) {
- this.views.minutaDocumentoView = new MinutaDocumentoView()
- $container.append(this.views.minutaDocumentoView.render().el)
- }
- break
- case (estatusId == 2):
- if (app.views.mainView.currentMinuta.CantidadDerechosVigentes > 0) {
- //this.$el.find(".derechos-vigentes-callout").removeClass("hidden")
- }
- break
- }
- $container.append(this.views.carritoManagementView.render().el)
- this.nameActionButton()
- if (!minuta.EsMio) {
- this.setReadOnly()
- this.views.notificacionesListView.removeReadOnly()
- }
- this.$el.find(".main-accordion").collapse()
- this.$el.fadeIn()
- if (minuta.DocumentoEnAtraso) {
- var presentacion = this.$el.find(".presentacion-row").text().trim()
- this.$el.find(".presentacion-row").text(presentacion + "*")
- }
- },
- showHistorico: function () {
- var asiento = this.model.get("AsientoId")
- window.open('historialAsiento.html?asiento=' + asiento, '_blank');
- },
- showManejoNotificaciones: function () {
- this.views.notificacionesView.applyBindings()
- this.views.notificacionesView.loadDestinatarios()
- this.views.notificacionesView.puedeEditarse = true
- this.$el.find(".minuta-notificacion-block:last").modal({ backdrop: 'static', keyboard: false })
- },
- nameActionButton: function () {
- var name = "Guardar"
- switch (app.views.mainView.currentMinuta.Minuta.EstatusId) {
- case 1:
- name = "Presentar"
- this.saveAction = "presentar"
- this.customUrl = "/api/minuta/" + this.getMinutaId() + "/" + this.saveAction
- break
- case 2:
- name = "Enviar al Registrador"
- this.saveAction = "calificar"
- this.customUrl = "/api/minuta/" + this.getMinutaId() +
- "/asiento/" + app.views.mainView.currentMinuta.Minuta.AsientoId +
- "/" + this.saveAction
- break
- case 3:
- name = "Inscribir"
- this.saveAction = "inscribir"
- this.customUrl = "/api/minuta/" + this.getMinutaId() +
- "/asiento/" + app.views.mainView.currentMinuta.Minuta.AsientoId +
- "/" + this.saveAction
- break
- case 7:
- name = "Enviar al Registrador"
- this.saveAction = "calificar"
- this.customUrl = "/api/minuta/" + this.getMinutaId() +
- "/asiento/" + app.views.mainView.currentMinuta.Minuta.AsientoId +
- "/" + this.saveAction
- break
- case 8:
- name = "Enviar al Registrador"
- this.saveAction = "calificar"
- this.customUrl = "/api/minuta/" + this.getMinutaId() +
- "/asiento/" + app.views.mainView.currentMinuta.Minuta.AsientoId +
- "/" + this.saveAction
- break
- case 12:
- name = "Extender Asiento"
- }
- var $el = $(this.el).find(".btn-save-minuta .text")
- $el.text(name)
- $el.attr({
- "title": name
- })
- $(this.el).find(".btn-save-minuta").attr({
- "title": name
- })
- },
- loadMinutaData: function (cb) {
- var minutaId = Utils.UrlManagement.querystring("minutaId"),
- asientoId = Utils.UrlManagement.querystring("aid"),
- self = this
- if (minutaId) {
- this.model = new MinutaModel()
- this.model.customUrl = "/api/minuta/" + minutaId
- // importante: si hay mas de un asiento para la minuta hay que especificar el asiento.
- if (parseInt(asientoId) > 0) {
- this.model.customUrl += "/asiento/" + asientoId
- }
- this.model.idAttribute = "MinutaId"
- this.model.fetch(
- {
- success: function (err, response) {
- //Load minuta
- self.BandejaFiltros = app.views.mainView.currentMinuta.BandejaFiltros
- var minuta = app.views.mainView.currentMinuta = response
- self.minutaObj = minuta
- var estatus = app.views.mainView.currentMinuta.Minuta.EstatusId
- self.model = new MinutaModel(minuta.Minuta)
- if (self.model.soloMinutaNotario()) {
- window.location.replace('#minutanot?minutaId=' + minutaId + "&aid=" + asientoId)
- return;
- }
- self.model.set("ArancelLst", minuta.ArancelLst)
- self.model.set("DocumentoComplementarioLst", minuta.DocumentoComplementarioLst)
- self.model.set("PersonaLst", minuta.PersonaLst)
- self.model.set("PropiedadLst", minuta.PropiedadLst)
- self.model.set("TransaccionLst", minuta.TransaccionLst)
- self.model.set("Presentante", minuta.Presentante)
- self.model.set("NotificacionLst", minuta.NotificacionLst)
- self.model.set("LeyEspecial", minuta.LeyEspecial)
- self.model.set("Secciones", minuta.Secciones)
- self.model.set("EstatusId", estatus)
- cb()
- },
- error: this.xhrError,
- beforeSend: this.beforeSend
- })
- } else {
- cb()
- }
- },
- getDespachadosMismaFinca:function(cb){ // Buscar otros documentos despachados con la misma finca
- var model = new GlobalEmptyModel(),
- fincas = "",
- msgHtml = "<h3>Hay documentos despachados con las siguientes fincas:</h3><ul>",
- self = this;
- _.each(this.model.get("PropiedadLst"), function(value){
- fincas += value.Id + "|"
- })
- model.customUrl = "/api/minuta/despachados/mismasFincas?fincas=" + fincas
- model.fetch({
- success:function(err, response){
- if(response.length > 0){
- var link = window.location.origin + "/client/#minuta?"
- _.each(self.model.get("PropiedadLst"), function(value){
- var documentosPorFinca = _.where(response, { "PropiedadId": value.Id });
- msgHtml += "<h4>Propiedad: " + documentosPorFinca[0].NumeroPropiedad
- + " Demarcación: " + documentosPorFinca[0].CodigoDemarcacion
- + "</h4>"
- _.each(documentosPorFinca, function(value){
- var hLink = link + "minutaId=" + value.MinutaId + "&aid=" + value.AsientoId
- msgHtml += "<li>" + value.Asiento
- + ": <a target='_blank', href='" + hLink + "'>Ver documento</a>"
- + "</li>"
- });
- msgHtml += "</ul>"
- var confirm = new ConfirmView()
- confirm.cancelcb = cb
- confirm.setSize("modal-lg")
- confirm.show(msgHtml, cb)
- });
- } else{
- cb()
- }
- },
- error:this.xhrError,
- beforeSend:this.beforeSend
- })
- },
- save: function () {
- if (this.isWorking) return
- var self = this, minuta = app.views.mainView.currentMinuta.Minuta
- var afterSave = function () {
- self.startWorking()
- var data = {},
- views = app.views.mainView.views.minutaView.views,
- msg = "",
- role = _.first(app.roles)
- if (role != 3) {
- switch (minuta.EstatusId) {
- case 1:
- if (minuta.DocumentoEnAtraso || minuta.DocumentoLey216) {
- data.Asiento = self.model.get("Asiento")
- self.customUrl = "/api/minuta/" + self.model.get("MinutaId") +
- "/presentar/asiento/" + data.Asiento +
- "/tipoDocumento/" + ((minuta.DocumentoEnAtraso) ? "atrasado" : "ley216")
- msg = "Documento pasado a despacho"
- }
- break
- case 2:
- if (minuta.DocumentoLey216) {
- self.customUrl = "/api/minuta/" + self.model.get("MinutaId") +
- "/asiento/" + self.model.get("AsientoId") +
- "/extender/tipoDocumento/ley216"
- }
- break
- case 3:
- self.customUrl = "/api/minuta/" + self.getMinutaId() +
- "/asiento/" + app.views.mainView.currentMinuta.Minuta.AsientoId +
- "/" + self.saveAction + "/generarCredito/" + self.generateCartaCredito
- case 12:
- if (minuta.DocumentoLey216) {
- self.customUrl = "/api/minuta/" + self.model.get("MinutaId") +
- "/asiento/" + self.model.get("AsientoId") +
- "/inscribir/tipoDocumento/ley216"
- }
- break
- }
- var model = new GlobalEmptyModel()
- model.customUrl = self.customUrl
- model.save({
- data: data
- }, {
- success: function (err, response) {
- self.stopWorking()
- if (response.Message) {
- var confirm = new ConfirmView()
- confirm.setSize("modal-lg")
- confirm.show(Utils.ErrorManagement.returnErrorHtml(response.Message), null, "Error")
- } else {
- if (msg) {
- (new MessageView().show(msg))
- }
- if ((minuta.DocumentoEnAtraso || minuta.DocumentoLey216) && minuta.EstatusId == 1) {
- self.render()
- } else {
- //Solo ensenar seccion de recibo si ha sido presentada la minuta
- if (minuta.EstatusId == 1) {
- //Show
- self.$el.find(".new-document").modal({ backdrop: 'static', keyboard: false })
- } else {
- self.getDespachadosMismaFinca(function(){
- self.leaveToQueue(self.BandejaFiltros)
- // var propiedadNum = _.first(self.model.get("PropiedadLst"));
- // self.leaveToQueue(propiedadNum.NumeroPropiedad)
- // if (minuta.EstatusId > 2)
- // self.leaveToQueue()
- // else if(minuta.EstatusId == 2){
- // var propiedadNum = _.first(self.model.get("PropiedadLst"));
- // if(role == 1 || role == 2)
- // self.leaveToQueue(propiedadNum.NumeroPropiedad)
- // else
- // self.leaveToQueue()
- // }
- // else
- // self.leave()
- })
- }
- }
- }
- },
- error: function (err, response) {
- if (self.saveAction == "presentar" && response.responseJSON == "SUBMISSIONTIMEERROR") {
- self.timeOutError("No se puede presentar fuera del horario establecido.")
- var confirm = new ConfirmView(),
- msg = "El horario para presentación personal es de 8:00 am a 12:00 pm y de 1:00 pm a 4:00 pm."
- confirm.setSize("modal-lg")
- confirm.show(msg, null, "Aviso")
- }
- },
- beforeSend: self.beforeSend
- })
- } else {
- // self.stopWorking()
- self.validarPaga(function(){
- var model = new GlobalEmptyModel()
- model.customUrl = "/api/cesta/aranceles/" + self.model.get("MinutaId") + "/exento/" + self.model.get("Exento")
- model.fetch(
- {
- success: function (err, response) {
- $(self.el).find(".carrito-management-block").modal({ backdrop: 'static', keyboard: false })
- self.views.carritoManagementView.prepCarrito();
- self.views.carritoManagementView.achHide();
- self.stopWorking()
- },
- error: self.xhrError,
- beforeSend: self.beforeSend
- })
- })
- }
- }
- var validarFincas = function(){
- var model = new GlobalEmptyModel()
- model.customUrl = "/api/propiedad/despacho/validarFincas/minutaId/"
- + minuta.Id
- + "/asientoId/"
- + minuta.AsientoId
- model.fetch({
- success:function(err,response){
- var role = _.first(app.roles),
- list = []
- if(role == 1){
- list = _.where(response, { "InscripcionMarcadoTecnico": false });
- } else if(role == 2){
- list = _.where(response, { "InscripcionMarcadoRegistrador": false });
- }
- if(list.length > 0){
- var aviso = new MessageView(),
- msg = 'Las siguientes fincas faltan por ser verificadas. Debe marcarlas como "Verificado" en cada finca en el Despacho:'
- msg += "<br><br><ul>"
- _.each(response, function(value){
- msg += "<li>Demarcación: " + value.CodigoDemarcacion + " Finca: " + value.NumeroPropiedad + "</li>"
- });
- msg += "</ul>"
- aviso.setSize("modal-lg")
- aviso.show(msg, "Aviso", null)
- } else{
- bioValidate()
- }
- },
- error:self.xhrError,
- beforeSend:self.beforeSend
- })
- }
- var bioValidate = function () {
- var role = _.first(app.roles)
- if (minuta.EstatusId == 3 || minuta.EstatusId == 12 && role == 2) {
- (new ConfirmView()).show("¿Desea firmar este documento?", function () {
- var dardeo = new DarDeoView()
- dardeo.parent = self
- dardeo.show(afterSave)
- })
- } else {
- afterSave()
- }
- }
- if(minuta.EstatusId > 1)
- // this.isValid(validarFincas)
- this.isValid(bioValidate)
- else
- this.isValid(bioValidate)
- },
- validarPaga:function(cb){
- var self = this,
- rol = app.roles[0]
- var model = new GlobalEmptyModel()
- model.customUrl = "/api/cesta/minuta/" + this.model.get("MinutaId") + "/pagada"
- model.fetch(
- {
- success: function (err, response) {
- if(!response)
- cb()
- else{
- self.stopWorking()
- self.saveNotario()
- }
- },
- error: self.xhrError,
- beforeSend: self.beforeSend
- })
- },
- saveNotario: function () {
- var self = this,
- data = {}
- msg = ""
- if(this.isWorking)
- return
- this.startWorking()
- this.customUrl = "/api/minuta/" + this.getMinutaId() + "/presentar"
- var model = new GlobalEmptyModel()
- model.customUrl = this.customUrl
- model.save({
- data: data
- }, {
- success: function (err, response) {
- self.stopWorking()
- if (response.Message) {
- var confirm = new ConfirmView()
- confirm.setSize("modal-lg")
- confirm.show(Utils.ErrorManagement.returnErrorHtml(response.Message), null, "Error")
- } else {
- if (msg) {
- (new MessageView().show(msg))
- }
- self.$el.find(".new-document").modal({ backdrop: 'static', keyboard: false })
- }
- },
- error: self.xhrError,
- beforeSend: self.beforeSend
- })
- },
- printReceipt: function () {
- if (this.isWorking) return
- var self = this
- this.workingEl = ".btn-print"
- this.startWorking()
- this.$el.find("iframe.receipt-frame").attr("src", app.GlobalApiPath + "/stream/reciboPresentacion/" + self.model.get("MinutaId") + "/" + app.token)
- setTimeout(function () {
- self.stopWorking()
- }, 5000)
- },
- newReuse: function () {
- //Esto se hace para que se llene la informacion del presentante con la data de la ultima presentacion
- app.currentPresentanteData = this.views.presentanteView.model.toJSON()
- this.new()
- },
- new: function () {
- if (this.isWorking) return
- var self = this, model = new StartingPointModel(),
- minuta = app.views.mainView.currentMinuta.Minuta
- this.workingEl = ".btn-new"
- this.startWorking()
- if (minuta.DocumentoLey216 || minuta.DocumentoEnAtraso) {
- var tipoDocument = (this.DocumentoEnAtraso) ? 1 : 2
- model.customUrl = "/api/minuta/tipoDocumento/" + tipoDocument
- } else {
- model.customUrl = "/api/minuta/false"
- }
- model.save({}, {
- success: function (err, response) {
- var returnObj = Utils.EncriptionManagement.convertStrToJson(response)
- $(".modal-backdrop").remove()
- self.$el.find(".new-document").modal("hide")
- self.$el.remove()
- self.stopWorking()
- window.location.assign('#minuta?minutaId=' + returnObj.MinutaId)
- },
- error: this.xhrError,
- beforeSend: this.beforeSend
- })
- },
- leave: function () {
- this.$el.find(".new-document").modal("hide")
- window.location.assign('#')
- },
- leaveToQueue: function (bandejaFiltros) {
- this.$el.find(".new-document").modal("hide")
- if(bandejaFiltros){
- var qStr = "?finca=" + bandejaFiltros.FiltroFinca
- + "&tipoDoc=" + bandejaFiltros.FiltroPresentacion
- + "&estado=" + bandejaFiltros.FiltroEstado
- + "&demarcacion=" + bandejaFiltros.FiltroDemarcacion
- window.location.assign('#documentQueue' + qStr)
- }
- else
- window.location.assign('#documentQueue')
- },
- isValid: function (cb) {
- var views = app.views.mainView.views.minutaView.views,
- errors = [],
- isValid = true,
- minuta = app.views.mainView.currentMinuta.Minuta,
- role = _.first(app.roles)
- var isExterno = role == 3 || role == 11 ? true : false
- //***Shared Validations
- //Tipo document exists
- //Tipo documento notarial exists
- if (!views.documentTypeManagementView.isValid())
- errors.push("Debe especificar información del documento")
- //At least one a favor de
- if (views.titularListView.hasEmptyItem())
- errors.push("Debe haber por lo menos un a favor de")
- //At least one finca
- if (views.fincaListView.hasEmptyItem())
- errors.push("Debe haber por lo menos una finca")
- //At least one transaction
- if (views.transaccionListView.hasEmptyItem())
- errors.push("Debe haber por lo menos una transaccion")
- if (!isExterno) {
- // tarea #1050 segun solicitado por bethzaida y jessica no se deben validar los aranceles ni en 216 ni en prekaribe. -- el dario.
- if (!this.model.get("Exento") && !minuta.DocumentoEnAtraso && !minuta.DocumentoLey216) {
- if (!views.minutaArancelListView.isValid())
- errors.push("No se entraron los aranceles necesarios")
- }
- }
- if (!minuta.DocumentoLey216 && !minuta.DocumentoEnAtraso) {
- if (!views.presentanteView.isValid()) {
- errors.push("No se entró la información de presentante")
- }
- }
- switch (true) {
- case (minuta.EstatusId == 1):
- if (!minuta.DocumentoEnAtraso && !minuta.DocumentoLey216) {
- if (!views.minutaDocumentoView.hasFile())
- errors.push("Debe especificar el documento a presentar")
- }
- if (minuta.DocumentoEnAtraso || minuta.DocumentoLey216) {
- //Asiendo es provisto por el usuario
- var asientoDiario = this.model.get("AsientoDiario")
- asientoSegmento = this.model.get("AsientoSegmento")
- asientoSection = this.model.get("AsientoSection")
- if ((asientoDiario == "" || !asientoDiario) ||
- (asientoSegmento == "" || !asientoSegmento) ||
- (asientoSection == "" || !asientoSection)) {
- errors.push("Debe llenar el numero de asiento")
- }
- }
- break
- }
- var confirm = new ConfirmView()
- if (errors.length > 0) {
- var errorHtml = "",
- isValid = false
- _.each(errors, function (item) {
- errorHtml = errorHtml + Utils.ErrorManagement.returnErrorHtml(item)
- })
- confirm.setSize("modal-lg")
- confirm.show(errorHtml, null, "Error")
- } else {
- var model = new GlobalEmptyModel(),
- self = this
- if (!this.model.get("Exento") && !isExterno) {
- model.customUrl = "/api/minuta/" + self.getMinutaId() +
- "/arancelObligatorio/" + ((minuta.DocumentoEnAtraso || minuta.DocumentoLey216) ? false : true) +
- "/validacion/"
- model.save({}, {
- success: function (err, response) {
- if (response == false) {
- confirm.setSize("modal-lg")
- confirm.show(
- Utils.ErrorManagement.returnErrorHtml("No se especificaron todos los aranceles"),
- null,
- "Error"
- )
- } else {
- if (typeof cb == "function") cb()
- }
- },
- error: this.xhrError,
- beforeSend: this.beforeSend
- })
- } else {
- if (typeof cb == "function") cb()
- }
- }
- },
- caducarDocumento: function () {
- var self = this
- var confirm = new ConfirmView()
- confirm.show("¿Seguro que desea caducar este documento?", function () {
- var model = new GlobalEmptyModel()
- model.id = self.model.get("AsientoId")
- model.attributes = self.model.attributes
- model.idAttibute = "AsientoId"
- model.customUrl = "/api/notificacion/caducar"
- model.save({},
- {
- success: function (err, response) {
- app.router.navigate("#main", { trigger: true })
- },
- error: self.xhrError,
- beforeSend: self.beforeSend
- })
- })
- },
- suspenderNotificacion: function () {
- var self = this
- var confirm = new ConfirmView()
- confirm.show("Suspender?", function () {
- var model = new GlobalEmptyModel()
- model.id = self.model.get("AsientoId")
- model.attributes = self.model.attributes
- model.idAttibute = "AsientoId"
- model.customUrl = "/api/notificacion/suspender/S/"
- model.save({},
- {
- success: function (err, response) {
- self.close()
- },
- error: self.xhrError,
- beforeSend: self.beforeSend
- })
- })
- },
- suspenderNotificacionRecalificar: function () {
- var self = this
- var confirm = new ConfirmView()
- confirm.show("Suspender?", function () {
- var model = new GlobalEmptyModel()
- model.id = self.model.get("AsientoId")
- model.attributes = self.model.attributes
- model.idAttibute = "AsientoId"
- model.customUrl = "/api/notificacion/suspender/R/"
- model.save({},
- {
- success: function (err, response) {
- self.close()
- },
- error: self.xhrError,
- beforeSend: self.beforeSend
- })
- })
- },
- suspenderNotificacionNoProcede: function () {
- var self = this
- var confirm = new ConfirmView()
- confirm.show("Al desistir de la notificación no podrá recuperla. ¿Desea continuar?", function () {
- var model = new GlobalEmptyModel()
- model.id = self.model.get("AsientoId")
- model.attributes = self.model.attributes
- model.idAttibute = "AsientoId"
- model.customUrl = "/api/notificacion/suspender/N/"
- model.save({},
- {
- success: function (err, response) {
- self.close()
- },
- error: self.xhrError,
- beforeSend: self.beforeSend
- })
- })
- },
- close: function () {
- var self = this;
- (new ConfirmView()).show("Salir?", function () {
- app.views.mainView.currentMinuta = {}
- self.$el.fadeOut(function () {
- self.$el.remove()
- window.location.assign('#')
- })
- })
- },
- checkCartaCredito: function () {
- var self = this,
- asientoId = Utils.UrlManagement.querystring("aid")
- var model = new GlobalEmptyModel()
- model.customUrl = "/api/cartacredito/verificarCantidad/" + asientoId
- model.fetch(
- {
- success: function (err, response) {
- if (response.hasSobrante) {
- var confirm = new ConfirmView()
- confirm.setSize("modal-lg")
- confirm.cancelcb = function () {
- self.save()
- }
- confirm.show("¿Este asiento tiene un sobrante, desea generar una carta de crédito por la cantidad de $" + response.Cantidad + "?", function () {
- self.generateCartaCredito = true
- self.save()
- })
- } else {
- self.save()
- }
- },
- error: this.xhrError,
- beforeSend: this.beforeSend
- })
- },
- render: function () {
- var self = this
- Utils.TemplateManagement.loadHtmlTemplate("#minuta", "minuta",
- function () {
- self.loadMinutaData(function () {
- self.init()
- self.loadViewsByRoles()
- self.$el.removeClass("hidden").fadeIn()
- })
- })
- return this
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement