//@ sourceURL=tabPagosBeneficiario.js
jQuery(function($){
	initRupI18nPromise.then(function() {

		initFilter();
		
		prepareData();	
	});
	
	const initFilter = () =>{
		$("#anyoPago74_pagosBeneficiario_filter_table").rup_combo({	
			source: $.rup.CTX_PATH + 'combo/anyos',
			sourceParam: {label: "descripcion", value:"value"},
			loadFromSelect:false,
			width: 'auto',
	        ordered: true,
			blank: '',
			customClasses: ['select-material'],
			rowStriping: true
		});
		
		$("#mesPago74_pagosBeneficiario_filter_table").rup_combo({
			parent: ["anyoPago74_pagosBeneficiario_filter_table"],			
			source: $.rup.CTX_PATH + 'combo/meses',
			sourceParam: {label: "descripcion", value:"value"},
			rowStriping: true,
			width: 'auto',
			ordered: false,
			orderedByValue: false,
			blank: '',
			customClasses: ['select-material']
		});
		
		$("#idPrestador74_pagosBeneficiario_filter_table").rup_combo({	
			source: $.rup.CTX_PATH + 'combo/prestadores',
			sourceParam: {label: "descripcion"+$.rup_utils.capitalizedLang(), value:"value"},
			loadFromSelect:false,
			width: 'auto',
	        ordered: true,
			blank: '',
			customClasses: ['select-material'],
			rowStriping: true
		});
	}
	
	function prepareData(){
		let tableColModels = [	
				{ 	name: "idPagoBeneficiario75",
					index: "idPagoBeneficiario75",
					editable: true, 
					hidden: true,
					width:"40"
				},	
				{ 	name: "pagos.anyoPago74",
					index: "pagos.anyoPago74",
					editable: true, 
					hidden: false,
					orderable: true,
					width:"50"
				},
				{ 	name: "pagos.mesPago74",
					index: "pagos.mesPago74",
					editable: true, 
					hidden: false,
					width:"50"
				},
				{ 	name: "pagos.prestadorServicio.razonSocial73",
					index: "pagos.prestadorServicio.razonSocial73",
					editable: true, 
					hidden: false,
					width:"50"
				},
				{ 	name: "numDias75",
					index: "numDias75",
					editable: true, 
					hidden: false,
					width:"50"
				},
				{ 	name: "tarifa75",
					index: "tarifa75",
					editable: true, 
					hidden: true,
					width:"50"
				},
				{ 	name: "tarifaStr",
					index: "tarifaStr",
					editable: true, 
					hidden: false,
					width:"50"
				},
				{ 	name: "importe",
					index: "importe",
					editable: true, 
					hidden: true,
					orderable:false,
					width:"50"
				},
				{ 	name: "importeStr",
					index: "importeStr",
					editable: true, 
					hidden: false,
					orderable:false,
					width:"50"
				},
				{ 	name: "solicitantes.idSolicitante01",
					index: "solicitantes.idSolicitante01",
					editable: true, 
					hidden: true
					
				},
				{ 	name: "maestroNivSoporte.idNivelSoporte58",
					index: "maestroNivSoporte.idNivelSoporte58",
					editable: true, 
					hidden: true
				},			
				{ 	name: "pagos.idPago74",
					index: "pagos.idPago74",
					editable: true, 
					hidden: true
				},
				
				{ 	name: "fAlta75",
					index: "fAlta75",
					editable: true, 
					hidden: true
				},
				{ 	name: "usuAlta75",
					index: "usuAlta75",
					editable: true, 
					hidden: true
				},
				{ 	name: "fModif75",
					index: "fModif75",
					editable: true, 
					hidden: true
				}
				,{ 	name: "usuModif75",
					index: "usuModif75",
					editable: true, 
					hidden: true
				}
				];
		let columnDefs = [ 
			{
				"targets": 2,
				"render": function(data, type, row, settings){	
					if      ( data == eneroId )     {return eneroDesc;
					}else if( data == febreroId )	{return febreroDesc;
					}else if( data == marzoId )		{return marzoDesc;
					}else if( data == abrilId )		{return abrilDesc;
					}else if( data == mayoId )		{return mayoDesc;
					}else if( data == junioId )		{return junioDesc;
					}else if( data == julioId )		{return julioDesc;
					}else if( data == agostoId )	{return agostoDesc;
					}else if( data == septiembreId ){return septiembreDesc;
					}else if( data == octubreId )	{return octubreDesc;
					}else if( data == noviembreId )	{return noviembreDesc;
					}else if( data == diciembreId )	{return diciembreDesc;
					}
					return  '';
				}
			},
			{
				"targets":[4,6,8],
				"className":"text-right",
			}

		];
		const misbotones = [
			]
		
	
		$("#pagosbeneficiario").rup_table({
			colReorder: {
			 fixedColumnsLeft: 1
			}
			,colModel: tableColModels
			,columnDefs : columnDefs
			,primaryKey: "idPagoBeneficiario75"
			,filter:{
	  	  		id:"pagosbeneficiario_filter_form",
	  	  		filterToolbar:"pagosbeneficiario_filter_toolbar",
	  	  		collapsableLayerId:"rup-table-filter-fieldset",
	  	  		showHidden: true
	     	}
			,noEdit : true
	   		,select: {
	       		activate: true,
	       		multiSelect:false,
	       		deleteDoubleClick:true
	   		}
			,seeker: {
				activate: true
			}
			,buttons: {
				activate: true,
				contextMenu: false,
				blackListButtons: ['addButton', 'editButton', 'cloneButton', 'copyButton','deleteButton','pdfButton', 'odsButton', 'csvButton'],
				myButtons:misbotones
			},
			columnOrderArrows: {
			    showOnlyActive: false,
			    display: 'inline'
			}
			,order: [ [1, "desc"],[2,"desc"]]
		});
		
		
	

		
		



		
	}
	
	
});