//@ sourceURL=protocolosSol.js
jQuery(function($){
	initRupI18nPromise.then(function() {
		prepareData();		
	});
	
	function prepareData(){
		
		$("#idTipoProtocolo26_filter_table").rup_combo({
			loadFromSelect:true,
			width: 'auto',
	        ordered: false,
			customClasses: ['select-material'],
			rowStriping: true,
			blank: '',
			selected:''
		});
		
		$.rup_date({
			//yearRange: 'c-100:c+0',
	        from: "fEntradaDesde_filter_table",
	        to: "fEntradaHasta_filter_table",
	        mask: 'dd/mm/yyyy',
			showButtonPanel : true,
			showOtherMonths : true,
			noWeekend : true
	     });
		
		$.rup_date({
			//yearRange: 'c-100:c+0',
	        from: "fSalidaDesde_filter_table",
	        to: "fSalidaHasta_filter_table",
	        mask: 'dd/mm/yyyy',
			showButtonPanel : true,
			showOtherMonths : true,
			noWeekend : true
	     });
		
		let tableColModels = [	
				
	
				{ 	name: "idTipoProtocolo26",
					index: "idTipoProtocolo26",
					editable: true, 
					hidden: false
				},
				{ 	name: "fEntrada26",
					index: "fEntrada26",
					editable: true, 
					hidden: false
				},
				{ 	name: "fSalida26",
					index: "fSalida26",
					editable: true, 
					hidden: false
				}
				];
		let columnDefs = [ 
			{ 
				"targets": 0,
				"render": function(data, type, row, settings){	
					
					if( data == 1 ){
						return  $.rup.i18n.app.protocolos.segEjCognitivo;
					}else if( data == 2){
						return  $.rup.i18n.app.protocolos.suicicio;
					}else if( data == 3){
						return  $.rup.i18n.app.protocolos.maltrato;
					}
					return  "";
				}
			}
		];
	
		$("#protocolos").rup_table({
			colReorder: {
			 fixedColumnsLeft: 1
			}
			,colModel: tableColModels
			,columnDefs : columnDefs
			,primaryKey: "idProtocolo26"
			,filter:{
	  	  		id:"protocolos_filter_form",
	  	  		filterToolbar:"protocolos_filter_toolbar",
	  	  		collapsableLayerId:"protocolos_filter_fieldset",
	  	  		showHidden: true
	     	}
			,noEdit : true
	   		,select: {
	       		activate: true
	   		}
			,buttons: {
				activate: true,
				contextMenu: false,
				blackListButtons: ['addButton', 'editButton', 'cloneButton', 'copyButton','deleteButton','pdfButton', 'odsButton', 'csvButton'],
			}
			,columnOrderArrows: {
			    showOnlyActive: false,
			    display: 'inline'
			}
			,order: [[0, "asc"],[1, "des"]]
		});
	}
});