/*
 * JSMin
 * Javascript Compressor
 * http://www.crockford.com/
 * http://www.smallsharptools.com/Projects/Packer/
*/

// V:\1.1.007\js\form\QE\Calcolatrici\Ext.ux.Namirial.form.CalcE24.js

Ext.ns('Ext.ux');Ext.ns('Ext.ux.Namirial');Ext.ns('Ext.ux.Namirial.form');Ext.ux.Namirial.form.CalcE24=Ext.extend(Ext.Window,{constructor:function(c){c=c||{};this.targetField=c.targetField;this.perc;this.CFISC=dichiarazione.getCurrentCfisc();this.tipo;this.VAL=[[0.31,0.35,0.43,0.22],[0.30,0.34,0.42,0.22]];this.QUOTA=[[1.29,1.46,1.78,0.94],[1.27,1.43,1.75,0.92]];try{this.tb_Annulla=new Ext.Toolbar.Button({text:'Annulla',icon:IMG_CANCEL,disabled:false,iconCls:'x-btn-text-icon',scope:this,tooltip:{title:'Annulla',text:'Annulla'},handler:this.annulla});this.tb_Salva=new Ext.Toolbar.Button({text:'Ok',icon:IMG_OK,disabled:false,scope:this,iconCls:'x-btn-text-icon',tooltip:{title:'Ok',text:'Ok'},handler:this.salva});var headerStyle="font-weight: bold; border-bottom: 1px solid "+BORDER_COLOR+";height: 35px;";var labelFasciaConfig={width:155,style:headerStyle,text:'Fascia retributiva'};var labelVersamentoConfig={style:headerStyle,text:'Totale versamento'};var labelOreConfig={width:82,style:headerStyle,text:'Ore'};var labelContributiLavConfig={style:headerStyle,text:'Contributi lavoratore'};var labelContributiDatConfig={style:headerStyle,text:'Contributi datore di lavoro'};this.labelFascia1=new Ext.form.Label(labelFasciaConfig);this.labelVersamento1=new Ext.form.Label(labelVersamentoConfig);this.labelOre1=new Ext.form.Label(labelOreConfig);this.labelContributiLav1=new Ext.form.Label(labelContributiLavConfig);this.labelContributiDat1=new Ext.form.Label(labelContributiDatConfig);this.labelFascia2=new Ext.form.Label(labelFasciaConfig);this.labelVersamento2=new Ext.form.Label(labelVersamentoConfig);this.labelOre2=new Ext.form.Label(labelOreConfig);this.labelContributiLav2=new Ext.form.Label(labelContributiLavConfig);this.labelContributiDat2=new Ext.form.Label(labelContributiDatConfig);this.label=[[],[]];this.label[0][0]=new Ext.form.Label({text:'1 - Fino a '+UNI_EURO+' 6,95'});this.label[0][1]=new Ext.form.Label({width:155,text:'2 - Oltre '+UNI_EURO+' 6,95 e fino '+UNI_EURO+' 8,48'});this.label[0][2]=new Ext.form.Label({text:'3 - Oltre '+UNI_EURO+' 8,48'});this.label[0][3]=new Ext.form.Label({width:155,text:'4 - Sup. alle 24 ore settimanali'});this.label[1][0]=new Ext.form.Label({text:'1 - Fino a '+UNI_EURO+' 6,83'});this.label[1][1]=new Ext.form.Label({width:155,text:'2 - Oltre '+UNI_EURO+' 6,83 e fino '+UNI_EURO+' 8,34'});this.label[1][2]=new Ext.form.Label({text:'3 - Oltre '+UNI_EURO+' 8,34'});this.label[1][3]=new Ext.form.Label({width:155,text:'4 - Sup. alle 24 ore settimanali'});this.versamento=[[],[]];this.ore_c=[[],[]];this.ore=[[],[]];this.contributi_lav=[[],[]];this.contributi_dat=[[],[]];this.versamento[0][0]=new Ext.ux.Namirial.form.NumberField({name:'VERS_0_0',decimalPrecision:2,width:100,maxValue:99999999999});this.versamento[0][1]=new Ext.ux.Namirial.form.NumberField({name:'VERS_0_1',decimalPrecision:2,width:100,maxValue:99999999999});this.versamento[0][2]=new Ext.ux.Namirial.form.NumberField({name:'VERS_0_2',decimalPrecision:2,width:100,maxValue:99999999999});this.versamento[0][3]=new Ext.ux.Namirial.form.NumberField({name:'VERS_0_3',decimalPrecision:2,width:100,maxValue:99999999999});this.ore_c[0][0]=new Ext.ux.Namirial.form.NumberField({name:'ORE_C_0_0',allowDecimals:false,disabled:true,width:40,maxValue:9999});this.ore_c[0][1]=new Ext.ux.Namirial.form.NumberField({name:'ORE_C_0_1',allowDecimals:false,disabled:true,width:40,maxValue:9999});this.ore_c[0][2]=new Ext.ux.Namirial.form.NumberField({name:'ORE_C_0_2',allowDecimals:false,disabled:true,width:40,maxValue:9999});this.ore_c[0][3]=new Ext.ux.Namirial.form.NumberField({name:'ORE_C_0_3',allowDecimals:false,disabled:true,width:40,maxValue:9999});this.ore[0][0]=new Ext.ux.Namirial.form.NumberField({name:'ORE_0_0',allowDecimals:false,maxValue:9999,width:40,autoCreate:MAX_LENGHT(3)});this.ore[0][1]=new Ext.ux.Namirial.form.NumberField({name:'ORE_0_1',allowDecimals:false,maxValue:9999,width:40,autoCreate:MAX_LENGHT(3)});this.ore[0][2]=new Ext.ux.Namirial.form.NumberField({name:'ORE_0_2',allowDecimals:false,maxValue:9999,width:40,autoCreate:MAX_LENGHT(3)});this.ore[0][3]=new Ext.ux.Namirial.form.NumberField({name:'ORE_0_3',allowDecimals:false,maxValue:999,width:40,autoCreate:MAX_LENGHT(3),validateOnBlur:false,validationEvent:'change',validator:this.controllaOre});this.contributi_lav[0][0]=new Ext.ux.Namirial.form.NumberField({name:'CONTRLAV_0_0',decimalPrecision:2,disabled:true,width:100,maxValue:99999999999});this.contributi_lav[0][1]=new Ext.ux.Namirial.form.NumberField({name:'CONTRLAV_0_1',decimalPrecision:2,disabled:true,width:100,maxValue:99999999999});this.contributi_lav[0][2]=new Ext.ux.Namirial.form.NumberField({name:'CONTRLAV_0_2',decimalPrecision:2,disabled:true,width:100,maxValue:99999999999});this.contributi_lav[0][3]=new Ext.ux.Namirial.form.NumberField({name:'CONTRLAV_0_3',decimalPrecision:2,disabled:true,width:100,maxValue:99999999999});this.contributi_dat[0][0]=new Ext.ux.Namirial.form.NumberField({name:'CONTRDAT_0_0',decimalPrecision:2,width:100,maxValue:99999999999});this.contributi_dat[0][1]=new Ext.ux.Namirial.form.NumberField({name:'CONTRDAT_0_1',decimalPrecision:2,width:100,maxValue:99999999999});this.contributi_dat[0][2]=new Ext.ux.Namirial.form.NumberField({name:'CONTRDAT_0_2',decimalPrecision:2,width:100,maxValue:99999999999});this.contributi_dat[0][3]=new Ext.ux.Namirial.form.NumberField({name:'CONTRDAT_0_3',decimalPrecision:2,width:100,maxValue:99999999999});this.versamento[1][0]=new Ext.ux.Namirial.form.NumberField({name:'VERS_1_0',decimalPrecision:2,width:100,maxValue:99999999999});this.versamento[1][1]=new Ext.ux.Namirial.form.NumberField({name:'VERS_1_1',decimalPrecision:2,width:100,maxValue:99999999999});this.versamento[1][2]=new Ext.ux.Namirial.form.NumberField({name:'VERS_1_2',decimalPrecision:2,width:100,maxValue:99999999999});this.versamento[1][3]=new Ext.ux.Namirial.form.NumberField({name:'VERS_1_3',decimalPrecision:2,width:100,maxValue:99999999999});this.ore_c[1][0]=new Ext.ux.Namirial.form.NumberField({name:'ORE_C_1_0',allowDecimals:false,disabled:true,width:40,maxValue:9999});this.ore_c[1][1]=new Ext.ux.Namirial.form.NumberField({name:'ORE_C_1_1',allowDecimals:false,disabled:true,width:40,maxValue:9999});this.ore_c[1][2]=new Ext.ux.Namirial.form.NumberField({name:'ORE_C_1_2',allowDecimals:false,disabled:true,width:40,maxValue:9999});this.ore_c[1][3]=new Ext.ux.Namirial.form.NumberField({name:'ORE_C_1_3',allowDecimals:false,disabled:true,width:40,maxValue:9999});this.ore[1][0]=new Ext.ux.Namirial.form.NumberField({name:'ORE_1_0',allowDecimals:false,maxValue:9999,width:40,autoCreate:MAX_LENGHT(3)});this.ore[1][1]=new Ext.ux.Namirial.form.NumberField({name:'ORE_1_1',allowDecimals:false,maxValue:9999,width:40,autoCreate:MAX_LENGHT(3)});this.ore[1][2]=new Ext.ux.Namirial.form.NumberField({name:'ORE_1_2',allowDecimals:false,maxValue:9999,width:40,autoCreate:MAX_LENGHT(3)});this.ore[1][3]=new Ext.ux.Namirial.form.NumberField({name:'ORE_1_3',allowDecimals:false,maxValue:999,width:40,autoCreate:MAX_LENGHT(3),validateOnBlur:false,validationEvent:'change',validator:this.controllaOre});this.contributi_lav[1][0]=new Ext.ux.Namirial.form.NumberField({name:'CONTRLAV_1_0',decimalPrecision:2,disabled:true,width:100,maxValue:99999999999});this.contributi_lav[1][1]=new Ext.ux.Namirial.form.NumberField({name:'CONTRLAV_1_1',decimalPrecision:2,disabled:true,width:100,maxValue:99999999999});this.contributi_lav[1][2]=new Ext.ux.Namirial.form.NumberField({name:'CONTRLAV_1_2',decimalPrecision:2,disabled:true,width:100,maxValue:99999999999});this.contributi_lav[1][3]=new Ext.ux.Namirial.form.NumberField({name:'CONTRLAV_1_3',decimalPrecision:2,disabled:true,width:100,maxValue:99999999999});this.contributi_dat[1][0]=new Ext.ux.Namirial.form.NumberField({name:'CONTRDAT_1_0',decimalPrecision:2,width:100,maxValue:99999999999});this.contributi_dat[1][1]=new Ext.ux.Namirial.form.NumberField({name:'CONTRDAT_1_1',decimalPrecision:2,width:100,maxValue:99999999999});this.contributi_dat[1][2]=new Ext.ux.Namirial.form.NumberField({name:'CONTRDAT_1_2',decimalPrecision:2,width:100,maxValue:99999999999});this.contributi_dat[1][3]=new Ext.ux.Namirial.form.NumberField({name:'CONTRDAT_1_3',decimalPrecision:2,width:100,maxValue:99999999999});for(var i=0;i<2;i++){for(var j=0;j<4;j++){this.versamento[i][j].on('change',this.calcoli,this);this.ore[i][j].on('change',this.calcoli,this);this.contributi_dat[i][j].on('change',this.calcoli,this)}}
this.totale_deducibile=new Ext.ux.Namirial.form.NumberField({name:'TOTALE',readOnly:true,fieldLabel:"Totale contributi deducibili",decimalPrecision:2,width:100,maxValue:99999999999});this.panel1=new Ext.form.FormPanel({title:"Contributi versati nel "+ANNO_DICHIARAZIONE+" relativi a periodi lavorativi del "+ANNO_DICHIARAZIONE+" (1"+UNI_o+" 2"+UNI_o+" 3"+UNI_o+" trimestre "+ANNO_DICHIARAZIONE+")",layout:"table",layoutConfig:{columns:6,extraCls:'x-form-item'},defaults:{border:false,bodyStyle:SFONDO_TRASPARENTE+"text-align: center;"},items:[{items:this.labelFascia1},{items:this.labelVersamento1},{colspan:2,items:this.labelOre1},{items:this.labelContributiLav1},{items:this.labelContributiDat1},{items:this.label[0][0],bodyStyle:SFONDO_TRASPARENTE},{items:this.versamento[0][0]},{items:this.ore_c[0][0]},{items:this.ore[0][0]},{items:this.contributi_lav[0][0]},{items:this.contributi_dat[0][0]},{items:this.label[0][1],bodyStyle:SFONDO_TRASPARENTE},{items:this.versamento[0][1]},{items:this.ore_c[0][1]},{items:this.ore[0][1]},{items:this.contributi_lav[0][1]},{items:this.contributi_dat[0][1]},{items:this.label[0][2],bodyStyle:SFONDO_TRASPARENTE},{items:this.versamento[0][2]},{items:this.ore_c[0][2]},{items:this.ore[0][2]},{items:this.contributi_lav[0][2]},{items:this.contributi_dat[0][2]},{items:this.label[0][3],bodyStyle:SFONDO_TRASPARENTE},{items:this.versamento[0][3]},{items:this.ore_c[0][3]},{items:this.ore[0][3]},{items:this.contributi_lav[0][3]},{items:this.contributi_dat[0][3]}]})
this.panel2=new Ext.form.FormPanel({title:"Contributi versati nel "+ANNO_DICHIARAZIONE+" relativi a periodi lavorativi del "+(ANNO_DICHIARAZIONE-1)+" (4"+UNI_o+" trimestre "+(ANNO_DICHIARAZIONE-1)+")",layout:"table",layoutConfig:{columns:6,extraCls:'x-form-item'},defaults:{border:false,bodyStyle:SFONDO_TRASPARENTE+"text-align: center;"},items:[{items:this.labelFascia2},{items:this.labelVersamento2},{colspan:2,items:this.labelOre2},{items:this.labelContributiLav2},{items:this.labelContributiDat2},{items:this.label[1][0],bodyStyle:SFONDO_TRASPARENTE},{items:this.versamento[1][0]},{items:this.ore_c[1][0]},{items:this.ore[1][0]},{items:this.contributi_lav[1][0]},{items:this.contributi_dat[1][0]},{items:this.label[1][1],bodyStyle:SFONDO_TRASPARENTE},{items:this.versamento[1][1]},{items:this.ore_c[1][1]},{items:this.ore[1][1]},{items:this.contributi_lav[1][1]},{items:this.contributi_dat[1][1]},{items:this.label[1][2],bodyStyle:SFONDO_TRASPARENTE},{items:this.versamento[1][2]},{items:this.ore_c[1][2]},{items:this.ore[1][2]},{items:this.contributi_lav[1][2]},{items:this.contributi_dat[1][2]},{items:this.label[1][3],bodyStyle:SFONDO_TRASPARENTE},{items:this.versamento[1][3]},{items:this.ore_c[1][3]},{items:this.ore[1][3]},{items:this.contributi_lav[1][3]},{items:this.contributi_dat[1][3]}]})
Ext.ux.Namirial.form.CalcE24.superclass.constructor.call(this,{id:WINDOW_CALCE24,resizable:false,constrain:true,title:'Contributi per addetti ai servizi domestici familiari',width:600,height:470,defaults:{border:false,bodyStyle:'padding:10px;'+SFONDO_FORM},items:[this.panel1,this.panel2],bbar:['->',{xtype:'label',style:'font-weight: bold;padding:5px;',text:this.totale_deducibile.fieldLabel+':'},this.totale_deducibile,createToolbarSpacer(30)],buttonAlign:'right',buttons:[this.tb_Salva,this.tb_Annulla]});}
catch(e){getToastMsg(MSG_TEXT,'data entry Rideterminazione interessi passivi');log.error("Ext.ux.Namirial.form.CalcE7#1 -> ",e);}},showWin:function(){if(Ext.isEmpty(Ext.WindowMgr.get(WINDOW_CALCE24))){this.show();}},calcoli:function(field){var fieldName=field.getName();var campo=fieldName.split('_');if(campo[0]!='ORE'){this.ore[campo[1]][campo[2]].setValue(0);}
var i=campo[1];var j=campo[2];var calc_vers=this.versamento[i][j].getValue();var calc_ore_c=(calc_vers/this.QUOTA[i][j]).toFixed(0);this.ore_c[i][j].setValue(calc_ore_c);if(this.ore[i][j].getValue()==0){this.ore[i][j].setValue(calc_ore_c)}
var calc_ore=this.ore[i][j].getValue();var calc_contrib_lav=calc_ore*this.VAL[i][j]
this.contributi_lav[i][j].setValue(calc_contrib_lav);var datore=calc_vers-calc_contrib_lav;if(datore<0)datore=0;this.contributi_dat[i][j].setValue(datore);var totale=0;for(var k=0;k<2;k++){for(var l=0;l<4;l++){totale+=this.contributi_dat[k][l].getValue();}}
this.totale_deducibile.setValue(totale);},annulla:function(){this.close();},salva:function(){if(this.panel1.getForm().isValid()&&this.panel2.getForm().isValid()){var oldval=this.targetField.getValue();var newal=this.totale_deducibile.getValue();this.targetField.setValue(newal);this.targetField.fireEvent('change',this.targetField,newal,oldval);this.close();}else{Toast('Attenzione','Errore nei campi')}},controllaOre:function(val){if(val!=0&&val<24){return"Le ore non possono essere inferiori a 24";}else{return true;}}});

