Ext.BLANK_IMAGE_URL="Content/images/default/s.gif";Ext.namespace("Aol");Ext.override(Ext.form.DisplayField,{getValue:function(){return this.value},setValue:function(a){this.value=a;this.setRawValue(this.formatValue(a));return this},formatValue:function(a){if(this.dateFormat&&Ext.isDate(a))return a.dateFormat(this.dateFormat);if(this.numberFormat&&typeof a=="number")return Ext.util.Format.number(a,this.numberFormat);return a}});
Aol.Grid=function(a){Aol.Grid.superclass.constructor.call(this,Ext.apply({title:affissioniLocale.affissioniGridTitle,autoHeight:true,cm:new Aol.AffissioneColumnModel,disableSelection:true,stripeRows:true,viewConfig:{forceFit:true,enableRowBody:true,getRowClass:function(c,b,d){d.body="<p><b>Oggetto:</b> "+c.data.Oggetto+"</p>";return"x-grid3-row-expanded"}},autoload:true},a))};Ext.extend(Aol.Grid,Ext.grid.GridPanel,{});
Aol.GridSearch=function(a){Aol.Grid.superclass.constructor.call(this,Ext.apply({title:affissioniLocale.ricerca,collapsible:true,items:[{xtype:"form",border:false,bodyStyle:"padding:5px",labelAlign:"right",autoHeight:true,labelWidth:120,defaults:{width:300},buttons:[{text:affissioniLocale.trova,handler:this.trovaAffissioni,scope:this},{text:affissioniLocale.annulla,handler:this.annulla,scope:this}],items:[{xtype:"combo",fieldLabel:affissioniLocale.provenienza,hiddenName:"ProvenienzaSearch",mode:"local",
triggerAction:"all",editable:false,store:new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:"Affissioni.aspx/UfficiRichiedenti",method:"POST"}),totalProperty:"totalRecords",root:"uffici",remoteSort:false,autoLoad:true,id:"AFF_URCH",fields:["AFF_URCH","UFF_D_URCH"]}),valueField:"AFF_URCH",displayField:"UFF_D_URCH"},{xtype:"combo",fieldLabel:affissioniLocale.tipoAtto,hiddenName:"TipoAttoSearch",mode:"local",triggerAction:"all",editable:false,store:new Ext.data.JsonStore({totalProperty:"totalRecords",
root:"tipi",remoteSort:false,autoLoad:true,id:"AFF_CAT",fields:["AFF_CAT","ATT_DES"],proxy:new Ext.data.HttpProxy({url:"Affissioni.aspx/TipiAtto",method:"POST"})}),valueField:"AFF_CAT",displayField:"ATT_DES"},{xtype:"textfield",fieldLabel:affissioniLocale.oggetto,name:"OggettoSearch"}]}]},a))};Ext.extend(Aol.GridSearch,Ext.Panel,{trovaAffissioni:function(){this.store.reload()},annulla:function(){this.getComponent(0).form.reset();this.store.reload()}});
Aol.AffissioneStore=function(a){Aol.AffissioneStore.superclass.constructor.call(this,Ext.apply({paramNames:{start:"Skip",limit:"Take",sort:"Sort",dir:"SortDir"},gridSearch:null,totalProperty:"totalRecords",root:"affissioni",remoteSort:true,autoLoad:false,idProperty:"Id",method:"POST",listeners:{beforeload:{scope:this,fn:this.prepareParams}}},a))};
Ext.extend(Aol.AffissioneStore,Ext.data.JsonStore,{prepareParams:function(){var a=this.gridSearch.getComponent(0).form.getValues();this.setBaseParam("UffCod",a.ProvenienzaSearch);this.setBaseParam("AttCod",a.TipoAttoSearch);this.setBaseParam("Oggetto",a.OggettoSearch)}});
Aol.AffissioneColumnModel=function(){var a=[{id:"affissione",header:affissioniLocale.provenienza,width:60,dataIndex:"UFF_D_URCH",sortable:true},{header:affissioniLocale.tipoAtto,width:60,dataIndex:"ATT_DES",sortable:true},{header:affissioniLocale.dataRichiesta,width:20,dataIndex:"AFF_DRC",sortable:true,renderer:renderDate},{header:affissioniLocale.pubblicatoIl,width:20,dataIndex:"AFF_DIA",sortable:true,renderer:renderDate},{header:affissioniLocale.scadenza,width:20,dataIndex:"AFF_DSA",sortable:true,
renderer:renderDate}];m=new Aol.AffissioniMan;m.gridCustomColumnModel(a);Aol.AffissioneColumnModel.superclass.constructor.call(this,a)};Ext.extend(Aol.AffissioneColumnModel,Ext.grid.ColumnModel,{});Aol.AffissioneBar=function(a){Aol.AffissioneBar.superclass.constructor.call(this,Ext.apply({pageSize:10,displayInfo:true,remoteSort:true,displayMsg:affissioniLocale.formatAffissioniGridPaging,emptyMsg:affissioniLocale.affissioniGridEmpty,paramNames:{start:"Skip",limit:"Take"}},a))};
Ext.extend(Aol.AffissioneBar,Ext.PagingToolbar,{});function renderDate(a){if(a&&!Ext.isEmpty(a))return a.format!==undefined?a.format("d/m/Y"):a}
Aol.AffissioneForm=function(a){a=Ext.apply({title:affissioniLocale.affissione,width:600,height:"auto",modal:true,resizable:false,layout:"fit",closeAction:"hide",formDocument:null,buttons:[{text:affissioniLocale.visualizza,handler:this.viewDocument,scope:this},{text:affissioniLocale.download,handler:this.downloadDocument,scope:this},{text:affissioniLocale.chiudi,handler:this.closeRecord,scope:this}],items:[{autoHeight:true,xtype:"form",border:false,bodyStyle:"padding:5px",labelAlign:"right",labelWidth:120,
items:[{layout:"column",border:false,defaults:{border:false},items:[{layout:"form",items:[{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:affissioniLocale.numeroProtocollo,name:"AFF_NPG"}],columnWidth:0.5},{layout:"form",items:[{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:affissioniLocale.del,name:"AFF_DPG",dateFormat:"d/m/Y"}],columnWidth:0.5}]},{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:affissioniLocale.ricevimentoRichiesta,name:"AFF_DRC",dateFormat:"d/m/Y"},
{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:affissioniLocale.richiedente,name:"UFF_D_URCH"},{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:affissioniLocale.emittente,name:"UFF_D_UEMI"},{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:affissioniLocale.tipoAtto,name:"ATT_DES"},{layout:"column",border:false,defaults:{border:false},items:[{layout:"form",items:[{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:affissioniLocale.numeroAtto,name:"AFF_NUM"}],
columnWidth:0.5},{layout:"form",items:[{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:affissioniLocale.del,name:"AFF_DTA",dateFormat:"d/m/Y"}],columnWidth:0.5}]},{layout:"column",border:false,defaults:{border:false},items:[{layout:"form",items:[{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:affissioniLocale.inizioAffissione,name:"AFF_DIA",dateFormat:"d/m/Y"}],columnWidth:0.5},{layout:"form",items:[{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:affissioniLocale.durata,
name:"AFF_DUR"}],columnWidth:0.5}]},{layout:"column",border:false,defaults:{border:false},items:[{layout:"form",items:[{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:affissioniLocale.giorniProroga,name:"AFF_DPR"}],columnWidth:0.5},{layout:"form",items:[{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:affissioniLocale.scadenza,name:"AFF_DSA",dateFormat:"d/m/Y"}],columnWidth:0.5}]},{xtype:"displayfield",style:"padding:3px 3px 3px 0",fieldLabel:"Oggetto",name:affissioniLocale.oggetto},
{xtype:"combo",id:"cmbAllegati",fieldLabel:affissioniLocale.allegati,mode:"local",triggerAction:"all",editable:false,width:382,lazyInit:false,store:new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:"Allegato.aspx/Index",method:"POST"}),totalProperty:"totalRecords",root:"affissioni",remoteSort:false,autoLoad:false,id:"Id",fields:["Id","Descrizione","ResponseFile"]}),valueField:"Id",displayField:"Descrizione"}]}]},a);m=new Aol.AffissioniMan;m.formCustomFields(a);Aol.AffissioneForm.superclass.constructor.call(this,
a)};
Ext.extend(Aol.AffissioneForm,Ext.Window,{viewDocument:function(){var a=this.getComponent(0).get("cmbAllegati");if(a){var c=a.getValue();if(!Ext.isEmpty(c)){var b=String.format("Allegato.aspx/ViewDocument?allegatoId={0}&affissioneId={1}",c,this.currentRec.data.Id),d=this.getMediaType(a,c);if(d=="PDFFRAME"){a={mediaType:d,url:b,unsupportedText:this.getUnsupportedText(a,c,b),autoSize:true};(new Ext.ux.MediaWindow({id:"PDFViewerWin",bodyStyle:"position:relative; padding:0px;",width:750,height:550,maximizable:true,
mediaCfg:a,title:affissioniLocale.affissione})).show()}else{try{Ext.destroy(Ext.get("downloadIframe"))}catch(g){}Ext.DomHelper.append(document.body,{tag:"iframe",id:"downloadIframe",frameBorder:0,width:0,height:0,css:"display:none;visibility:hidden;height:0px;",src:b})}}}},downloadDocument:function(){var a=this.getComponent(0).get("cmbAllegati");if(a){a=a.getValue();if(!Ext.isEmpty(a)){a=String.format("Allegato.aspx/DownloadDocument?allegatoId={0}&affissioneId={1}",a,this.currentRec.data.Id);try{Ext.destroy(Ext.get("downloadIframe"))}catch(c){}Ext.DomHelper.append(document.body,
{tag:"iframe",id:"downloadIframe",frameBorder:0,width:0,height:0,css:"display:none;visibility:hidden;height:0px;",src:a})}}},closeRecord:function(){this.hide()},getMediaType:function(a,c){var b=a.findRecord("Id",c);if(b)switch(b.data.ResponseFile){case "application/pdf":return"PDFFRAME";case "image/gif":return"GIF";case "image/tiff":return"TIFF";case "image/jpeg":return"JPEG";case "image/jp2":return"JP2";case "image/png":return"PNG";case "text/plain":return"TXT";case "application/rtf":return"RTF";
case "application/msword":return"WORD";case "application/vnd.ms-excel":return"EXCEL";case "application/vnd.ms-powerpoint":return"POWERPOINT";default:return"PDFFRAME"}else return""},getUnsupportedText:function(a,c,b){return a.findRecord("Id",c)?String.format(affissioniLocale.formatAllegatoError,b):affissioniLocale.allegatoError}});
Ext.onReady(function(){var a=new Aol.GridSearch({});a.render("gridSearch");var c=new Aol.AffissioneStore({fields:["Id","UFF_D_URCH","UFF_D_UEMI","ATT_DES","AFF_NPG",{name:"AFF_DPG",type:"date",dateFormat:"M$"},{name:"AFF_DRC",type:"date",dateFormat:"M$"},"Oggetto",{name:"AFF_DIA",type:"date",dateFormat:"M$"},"AFF_DUR","AFF_DPR",{name:"AFF_DSA",type:"date",dateFormat:"M$"},"AFF_NUM","AFF_PDF",{name:"AFF_DTA",type:"date",dateFormat:"M$"},{name:"HasPdf",type:"boolean"}],url:"Affissioni.aspx",gridSearch:a});
a.store=c;c.setDefaultSort("Id","asc");a=new Aol.AffissioneBar({store:c});a=new Aol.Grid({store:c,bbar:a});var b=new Aol.AffissioneForm({});a.on({rowclick:function(d,g){var f=d.store.getAt(g);b.buttons[0].setDisabled(true);b.buttons[1].setDisabled(true);b.show();b.center();b.currentRec=f;b.getComponent(0).getForm().loadRecord(f);var e=b.getComponent(0).get("cmbAllegati");if(e){var h=e.getStore();e.setValue("");h.on("load",function(j,i){if(i.length>0){e.setValue(i[0].data.Id);b.buttons[0].setDisabled(false);
b.buttons[1].setDisabled(false)}else e.setValue("")},this,{single:true});h.load({params:{affissioneId:f.data.Id}})}},scope:this});a.render("gridContainer");c.load({params:{Skip:0,Take:10}})});
