//@ sourceURL=intervenciones.js

jQuery(function($){
	initRupI18nPromise.then(function() {
		prepareData();		
	});
	
	function prepareData(){
		
		
		$("#maestroIntervenciones_idTipoIntervencion45_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: "fIntervencionDesde_filter_table",
	        to: "fIntervencionHasta_filter_table",
	        mask: 'dd/mm/yyyy',
			showButtonPanel : true,
			showOtherMonths : true,
			noWeekend : true
	     });
		$("#baja25_filter_table").change(function(){
			if($("#baja25_filter_table").prop("checked")){
				$("#maestroIntervenciones_idTipoIntervencion45_filter_table").rup_combo("setRupValue",9);
			}
		});
		
		$("input[name='_pendiente25']").remove();
		$("input[name='_baja25']").remove();
	
		
		let tableColModels = [			
				
				{ 	name: "maestroIntervenciones.desc",
					index: "maestroIntervenciones.desc",
					editable: true, 
					hidden: false
				},
				
				{ 	name: "fIntervencion25",
					index: "fIntervencion25",
					editable: true, 
					hidden: false
				},
				{ 	name: "pendiente25",
					index: "pendiente25",
					editable: true, 
					hidden: false
				},
				{ 	name: "baja25",
					index: "baja25",
					editable: true, 
					hidden: false
				}
				];
		let columnDefs = [ 
			{ 
				"targets": 2,
				"render": function(data, type, row, settings){	
					
//					if( data == 1 ){
//						return '<i class="mdi mdi-check-box-outline"></i>';
//					}
//					return '<i class="mdi mdi-checkbox-blank-outline"></i>';
					if( data == 1 ){
						return $.rup.i18n.app.comun.si;
					}
					return $.rup.i18n.app.comun.no;


				}
			},
			{ 
				"targets": 3,
				"render": function(data, type, row, settings){	
					
					if( data == 1 ){
						return $.rup.i18n.app.comun.si;
					}else{
						return $.rup.i18n.app.comun.no;
					}
				}
			}
			
		];
	
		$("#intervenciones").rup_table({
			colReorder: {
			 fixedColumnsLeft: 1
			}
			,colModel: tableColModels
			,columnDefs : columnDefs
			,primaryKey: "idIntervencion25"
			,filter:{
	  	  		id:"intervenciones_filter_form",
	  	  		filterToolbar:"intervenciones_filter_toolbar",
	  	  		collapsableLayerId:"intervenciones_filter_fieldset",
	  	  		showHidden: true
	     	} 	
			,noEdit : true
	   		,select: {
	       		activate: true
	   		}
			,seeker: {
				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"]]
		});
	}
});