KOKINIO - MANAGER
Edit File: reciclable.js
var Reciclable = { getReciclable:function(e){ var token = $('#csrf-token').val(); var reciclable = $('#reciclable-input').val(); var clasificacion = $('#clasificacion-input').val(); if(reciclable == '' | reciclable == null) $('#reciclable-input').css('border','1px solid red'); else if(clasificacion == '' | clasificacion == null){ $('#clasificacion-select').css('border','1px solid red'); }else{ var data = new FormData(); if($(e).data('id')!=''){ var id = $(e).data('id'); data.append('id' , id); } data.append('_token' , token); data.append('reciclable' , reciclable); data.append('clasificacion', clasificacion); Reciclable.sendReciclable(data); } }, sendReciclable:function(data){ $.ajax({ url:main_path+'/catalogo/saveReciclable', data:data, cache:false, contentType: false, processData: false, type: 'POST', dataType: "json", success: function( response ){ if(response.status == true ){ $.bootstrapGrowl('Reciclable Guardado!', { type: "success", delay: 6500, allow_dismiss: true }); if(data.get('id')!=''){ $('#modalReciclable').modal('hide'); window.location.assign(main_path+'/catalogo/reciclableAll'); } Reciclable.resetFields(); }else{ $.bootstrapGrowl( 'Mensaje:'+response.message , { type: "danger", delay: 7500, allow_dismiss: true }); } }, fail: function( response ) { $.bootstrapGrowl( 'Mensaje:'+response.message , { type: "danger", delay: 7500, allow_dismiss: true }); } }); }, resetFields:function(){ $('#reciclable-input').val(''); $('#clasificacion-input').val(''); }, tableFilter:function(e){ console.log('clickcc'); var $panel = $(e).parents('.filterable'), $filters = $panel.find('.filters input'), $tbody = $panel.find('.table tbody'); if ($filters.prop('disabled') == true) { $filters.prop('disabled', false); $filters.first().focus(); } else { $filters.val('').prop('disabled', true); $tbody.find('.no-result').remove(); $tbody.find('tr').show(); } }, edit:function(e){ $.ajax({ url:main_path+'/catalogo/getReciclable', data:{id:$(e).data('id')}, cache:false, type: 'GET', dataType: "json", success: function( response ){ if(response.status == true){ $('#reciclable-input').val(response.data.reciclable); $('#clasificacion-input').val(response.data.clasificacion); $('#send-button').attr('data-id',$(e).data('id')); $('#modalReciclable').modal('show'); } }, fail: function( response ) { alert('Error no encontrado') window.location.assign(main_path+'/catalogo/reciclableAll'); } }); }, new_cost:function(e){ $('#cost-modal').modal('show'); }, getPayReciclable:function(e){ var id = $(e).data('id'); var token = $('#csrf-token').val(); var reciclable = $('#reciclable-select').val(); var cliente = $('#cliente-select').val(); var year = $('#year-select').val(); var month = $('#month-select').val(); var pay_customer = $('#pay-customer').val(); var pay_driver = $('#pay-driver').val(); if(reciclable == '' | reciclable == null){ console.log(reciclable); $('#reciclable-select').css('border','1px solid red'); }else if(cliente == '' | cliente == null){ $('#cliente-select').css('border','1px solid red'); }else if(year == '' | year == null){ $('#year-select').css('border','1px solid red'); }else if(month == '' | month == null){ $('#month-select').css('border','1px solid red'); }else if(pay_customer == 0 | pay_customer == null){ $('#pay-customer').css('border','1px solid red'); }else if(pay_driver == 0 | pay_driver == null){ $('#pay-driver').css('border','1px solid red'); }else{ var data = { 'id' : id, '_token' : token, 'reciclable' : reciclable, 'cliente' : cliente, 'year' : year, 'month' : month, 'pay_customer' : pay_customer, 'pay_driver' : pay_driver }; Reciclable.sendPayReciclable(data); } }, sendPayReciclable:function (data){ $.ajax({ url:main_path+'/catalogo/savePayReciclable', data:data, type: 'POST', dataType: "json", success: function( response ){ if(response.status == true ){ $.bootstrapGrowl('Costo de Reciclable Guardado!', { type: "success", delay: 6500, allow_dismiss: true }); $('#cost-modal').modal('hide'); window.location.assign(main_path+'/catalogo/costo_reciclable'); //Reciclable.resetFields(); }else{ $.bootstrapGrowl( 'Mensaje:'+response.message , { type: "danger", delay: 7500, allow_dismiss: true }); } }, fail: function( response ) { $.bootstrapGrowl( 'Mensaje:'+response.message , { type: "danger", delay: 7500, allow_dismiss: true }); } }); }, editCost:function(e){ $.ajax({ url:main_path+'/catalogo/getCostReciclable', data:{id:$(e).data('id')}, cache:false, type: 'GET', dataType: "json", success: function( response ){ if(response.status == true){ $('#reciclable-select').val(response.data.reciclable_id).trigger("chosen:updated");; $('#cliente-select').val(response.data.cliente_id).trigger("chosen:updated");; $('#month-select').val(response.data.mes); $('#ano-select').val(response.data.ano); $('#pay-customer').val(response.data.pago_cliente); $('#pay-driver').val(response.data.pago_chofer); $('#send-button').attr('data-id',$(e).data('id')); $('#cost-modal').modal('show'); } }, fail: function( response ) { alert('Error no encontrado') window.location.assign(main_path+'/catalogo/costo_reciclable'); } }); }, deleteCost:function(e){ $.get(main_path+'/catalogo/deleteCost',{id:$(e).data('id')},function(resp){ $.bootstrapGrowl(resp.message, { type: resp.type, delay: 6500, allow_dismiss: true }); window.location.assign(main_path+'/catalogo/costo_reciclable'); }); }, getReciclablesCosto(date1 = null,date2 = null){ $.ajax({ url:main_path+'/catalogo/tableReciclable', data:{date1:date1,date2:date2}, cache:false, type: 'GET', success: function( response ){ $('#table-reciclable').html(response); }, fail: function( response ) { console.log("err"+response); } }); }, modifyCostoReciclable:function(e){ var type = $(e).data('type'); var reciclable_id = $(e).data('reciclable_id'); var user_id = $(e).data('user_id'); var fecha = $(e).data('fecha'); var cliente = $(e).data('cliente'); var costo = $(e).val(); var _token = $("#csrf-token").val(); var data = { type, reciclable_id, user_id, costo, fecha, cliente, _token }; console.log(data); $.ajax({ url:main_path+'/catalogo/editReciclableCosto', data:data, cache:false, type: 'POST', dataType: "json", success: function( resp ){ $.bootstrapGrowl(resp.message, { type: resp.type, delay: 6500, allow_dismiss: true }); }, fail: function( resp ) { console.log("err"+resp); } }); } }