$(document).ready(function(){
	// $("#seguimiento_modal").on("click",function(){
    	$.ajax({
            type: "GET",
            dataType: "json",
            url: base_url+"/seguimiento/expediente/seguimiento/"+rowidex,
            success:function(data){
            	console.log(data);

            	var htmls = "";
            	$.each(data.tramite, function(i,val){
					var clase = val.Estado;
					switch(val.estado) {
						case 0:
						  	clase = '<span class="badge badge-default">'+val.Estado+'</span>';
						  	break;
						case 1:
							clase = '<span class="badge badge-info">'+val.Estado+'</span>';
						  	break;
						case 2:
							clase = '<span class="badge badge-success">'+val.Estado+'</span>';
						  	break;
						case 3:
							clase = '<span class="badge badge-danger">'+val.Estado+'</span>';
						  	break;
						case 4:
							clase = '<span class="badge badge-primary">'+val.Estado+'</span>';
						  	break;
						case 5:
							clase = '<span class="badge badge-secondary">'+val.Estado+'</span>';
						  	break;
						case 6:
							clase = '<span class="badge badge-warning">'+val.Estado+'</span>';
						  	break;
						default:
						  	// code block
					}
            		htmls += "<tr>"+
		                  "<td>"+(i+1)+"</td>"+
		                  "<td>"+val.Oficina+"</td>"+
		                  "<td>"+clase+"</td>"+
		                  "<td>"+val.Observacion+"</td>"+
		                  "<td>"+val.Destino+"</td>"+
		                "</tr>";
            	});
            	$("#seguimiento").html(htmls);
            },
            error:function(result){

            }
        });
    	// $('#modal-datatable-seguimiento').modal('show');
    // });

    $(".subir").on("click",function(e){
        var id = $(this).attr("id");
        // console.log("#formulary"+id)
        var validator = $("#formulary"+id).validate();
        //  console.log(validator);
        var validar = validator.form();
    	if(validar == true){
            var data = new FormData($("#formulary"+id)[0]);
            $('.content').loader('show');
            $.ajax({
		        type: "POST",
		        dataType: "json",
		        url: base_url+"/seguimiento/expediente/"+id,
		        cache: false,
			    contentType: false,
			    processData: false,
		        data:data,
		        success:function(data){
		          // console.log(data);
		            $('.content').loader('hide');
		          	if(data.status == true){
                        $.confirm({
                            title: 'Satisfactorio',
                            content: data['message'],
                            type: 'green',
                            theme: 'modern',
                            // closeIcon: true,
                            icon: 'fas fa-check',
                            buttons: {
                              confirm: {
                                  text:"Aceptar",
                                  btnClass: 'btn-green',
                                  action: function(){
                                    location.reload();
                                  }
                              }
                            }
                        });
			        }else{
			            $.confirm({
							title: 'Aviso!',
							content: data['message'],
							type: 'orange',
							theme: 'modern',
							closeIcon: true,
							icon: 'fas fa-exclamation-triangle',
							buttons: {
							  confirm: {
							      text:"Intentar de nuevo",
							      btnClass: 'btn-green',
							      action: function(){
							      }
							  },
							  cancel:{
							      text:"Salir",
							      action:function(){
							         
							      }
							  }
			                }
			            });
			        }
	                // table.draw();
	                // $('#modal-datatable').modal('hide');
		        },
		        error:function(result){

		        }
		    });
        }
        e.preventDefault();
    })
});