var parseNumberFromCurrency=function(a){if(a!=null){try{if(!a){return null}if(isNaN(a)){return null}return parseFloat(a)}catch(b){return 0}}return 0};var dt_formatCurrency=function(b,a,d,f){b.style.textAlign="right";try{if(f!=null){if(f!=""&&!isNaN(f)){f=""+f;if(f.indexOf(",")>0){f=f.replace(".","");f=f.replace(",",".")}b.innerHTML=(f*1).toFixed(2).replace(".",",")+"&nbsp;&euro;&nbsp;"}else{b.innerHTML=""}}}catch(c){alert(c)}};function arkiaTable(b,a){this.tableHeight=370;this.selectedRow=null;this.current_record=null;this.DataTable=null;this.tableContainer=b;this.fields=a;this.scrolling=true;this.maxRecords=0;this.numRows=0;this.dataURL=null;this.kolomZichtbaarheidsURL="/do/getKolomVisibilities.html?tablename=";this.kolomPositieURL="/do/getKolomPositions.html?tablename=";this.MSG_EMPTY=typeof str_MSG_EMPTY=="undefined"?"Geen data gevonden":str_MSG_EMPTY;this.MSG_LOADING=typeof str_MSG_LOADING=="undefined"?"Data wordt geladen":str_MSG_LOADING;this.MSG_ERROR=typeof str_MSG_ERROR=="undefined"?"Er is een fout opgetreden":str_MSG_ERROR;this.MSG_GOTOPAGE=typeof str_GaNaarPagina=="undefined"?"Ga naar pagina":str_GaNaarPagina;this.EERSTE_PAGINA=typeof str_eerstePagina=="undefined"?"Eerste pagina":str_eerstePagina;this.VOLGENDE_PAGINA=typeof str_volgendePagina=="undefined"?"Volgende pagina":str_volgendePagina;this.VORIGE_PAGINA=typeof str_vorigePagina=="undefined"?"Vorige pagina":str_vorigePagina;this.LAATSTE_PAGINA=typeof str_laatstePagina=="undefined"?"Laatste pagina":str_laatstePagina;var c=this}arkiaTable.prototype.deleteRow=function(b){try{if(b!=undefined){record=this.getRecord(b)}else{record=this.current_record}this.DataTable.deleteRow(this.current_record)}catch(a){alert(a)}};arkiaTable.prototype.reload=function(){sortState=this.DataTable.getState().sortedBy;var b=sortState?sortState.key:"id";var a=sortState?sortState.dir:"yui-dt-desc";this.DataTable.sortColumn(this.DataTable.getColumn(b),a)};arkiaTable.prototype.getRecord=function(a){if(this.id==a&&this.current_record){return this.current_record}recordset=this.DataTable.getRecordSet();for(i=0;i<recordset.getLength();i++){record=recordset.getRecord(i);if(record){if(record.getData("id")==a){return record}}}return null};arkiaTable.prototype._refresh=function(id){try{var _this=this;YAHOO.util.Connect.asyncRequest("POST",this.dataURL+"&id="+id,{success:function(o){if(o.responseText!==undefined){try{eval("data = "+o.responseText);var rowdata={};if(!data[0]){_this.reload();return}for(teller=0;teller<_this.fields.length;teller++){rowdata[_this.fields[teller].fieldname]=data[0][teller]}recordset=_this.DataTable.getRecordSet();found=false;for(i=0;i<recordset.getLength();i++){record=recordset.getRecord(i);if(record){if(record.getData("id")==id){_this.current_record=record;found=true;break}}}if(!found){}else{try{_this.DataTable.updateRow(_this.current_record,rowdata)}catch(e){alert(e)}}}catch(e){alert(" t "+e)}}}})}catch(e){alert(e)}};arkiaTable.prototype.refresh=function(a){if(a!==undefined){this.id=a}this._refresh(this.id)};arkiaTable.prototype.start=function(){var a=this;if(this.dataURL==null){if(!$(this.tableContainer)){YAHOO.util.Event.onAvailable(this.tableContainer,function(){a.initDatatable.call(a)})}else{this.initDatatable(this)}}else{this.initDatatable(this)}};arkiaTable.prototype.resizeEverything=function(){invoer=$("edit"+this.tableContainer);tabel=$("datatable_"+this.tableContainer+"_container");filter=$("filter_"+this.tableContainer+"_form");fh=0;if(filter){Rfilter=dom.getRegion(filter);fh=Rfilter.height}var a=dom.getRegion(invoer);var b=dom.getRegion(tabel);totalh=dom.getViewportHeight();if(totalh-a.bottom-fh-50>100){tabel.style.height=(totalh-a.bottom-fh-50)+"px";if(this.DataTable){try{elements=dom.getElementsByClassName("yui-dt-hd","div",tabel);if(elements.length>0){dttable=dom.getFirstChild(elements[0]);dtRegion=dom.getRegion(dttable)}}catch(c){alert(c)}this.DataTable.set("width",(dtRegion.width+20)+"px");this.DataTable.set("height",(totalh-a.bottom-fh-80)+"px")}}};arkiaTable.prototype.kolomZichtbaarheid=function(){try{_this=this;if(this.kolommenDialog==undefined){var c=function(){this.hide()};var b=function(){this.hide();YAHOO.util.Connect.setForm("kollomform");YAHOO.util.Connect.asyncRequest("POST","/do/saveKolomVisibility.html",{success:function(e){if(e.responseText!=undefined){if(e.responseText!=""){alert(e.responseText)}}}});try{checkboxes=dom.getElementsByClassName("colselvis");for(i=0;i<checkboxes.length;i++){if(checkboxes[i].checked){_this.DataTable.showColumn(checkboxes[i].getAttribute("fieldname"))}else{_this.DataTable.hideColumn(checkboxes[i].getAttribute("fieldname"))}}}catch(d){alert(d)}};inner='<div style="height:280px;overflow:auto;padding:10px;border:1px solid silver"><form id="kollomform"><input type="hidden" value="'+this.tableContainer+'" name="tablename"/> <table class="" style="margin-left:auto;margin-right:auto">';for(teller=2;teller<this.fields.length;teller++){inner+='<tr"><td>'+this.fields[teller].fieldcaption+"</td>";inner+='<td style="text-align:center;padding-left:15px" ><input type="checkbox"  class="colselvis"  fieldname="'+this.fields[teller].fieldname+'" name="col['+(teller-2)+']"';if(this.fields[teller].hidden!="true"){inner+=' checked="checked"'}inner+='/><input type="hidden" name="field['+(teller-2)+']" value="'+this.fields[teller].fieldname+'"/></td></tr>'}inner+="</table></form></div>";this.kolommenDialog=new YAHOO.widget.SimpleDialog("",{width:"250px",height:"400px",effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25},fixedcenter:true,modal:true,draggable:true,constraintoviewport:true,buttons:[{text:"Sluiten",handler:c,isDefault:false},{text:"Opslaan",handler:b,isDefault:true}]});this.kolommenDialog.setHeader("Kolommen");this.kolommenDialog.setBody('<div style="text-align:left">'+inner+"</div>");this.kolommenDialog.render(document.body)}this.kolommenDialog.show()}catch(a){alert(a)}};arkiaTable.prototype.initDataSource=function(){if(this.dataURL!=null){this.dataURL+="&results="+this.numRows+"&";this.datasource=new YAHOO.util.XHRDataSource(this.dataURL);this.datasource.responseType=YAHOO.util.DataSource.TYPE_JSARRAY;if(this.numRows!=0&&this.maxRecords==0){var a=this;YAHOO.util.Connect.asyncRequest("POST",this.dataURL+"&numrecords=true",{success:function(h){if(h.responseText!==undefined){try{if(isNaN(h.responseText)){alert(h.responseText);a.maxRecords=10}else{a.maxRecords=h.responseText;var g=$("numrecords");if(g){g.innerHTML="Aantal records : "+a.maxRecords}var d=a.DataTable.getColumnSet().keys;for(var c=0;c<d.length;c++){if(d[c].rowCounter=="true"){a.DataTable.getColumnSet().getColumn(c).label=a.maxRecords;a.DataTable.getColumnSet().getColumn(c)._elThLabel.innerHTML=a.maxRecords;break}}}}catch(f){arkia.log(f,"error")}}},failure:function(c){window.alert("Fout bij het ophalen van aantal regels")}});return true}return true}else{this.numRows=0;this.columVisibility=[];this.columPositions=[];datatable=this.DataTable;if(datatable.nodeName!="TABLE"){alert("this.DataTable is geen tabel")}this.datasource=new YAHOO.util.DataSource(datatable);this.datasource.responseType=YAHOO.util.DataSource.TYPE_HTMLTABLE;var b=this.DataTable.tFoot;this.renderCallBack=function(){this.getTableEl().tFoot=b}}return true};arkiaTable.prototype.initColumnVisibilities=function(){try{var me=this;if(this.kolomZichtbaarheidsURL==""){this.columVisibility={};return true}if(this.columVisibility==undefined){YAHOO.util.Connect.asyncRequest("POST",this.kolomZichtbaarheidsURL+this.tableContainer,{success:function(o){if(o.responseText!==undefined){exec=" temp = "+o.responseText;eval(exec);me.columVisibility=temp;me.initDatatable.call(me)}},failure:function(o){}});return false}return true}catch(e){alert(e)}};arkiaTable.prototype.initColumnPositions=function(){try{var me=this;if(this.kolomZichtbaarheidsURL==""){me.columPositions={};return true}if(this.columPositions==undefined){YAHOO.util.Connect.asyncRequest("POST",this.kolomPositieURL+this.tableContainer,{success:function(o){if(o.responseText!==undefined){exec=" temp = "+o.responseText;eval(exec);me.columPositions=temp;me.initDatatable.call(me)}},failure:function(o){}});return false}return true}catch(e){alert(e)}};arkiaTable.prototype.initConfigFields=function(){var b=[];var c=0;for(teller=0;teller<this.fields.length;teller++){try{var a={};a.key=this.fields[teller].fieldname;b[c+teller]=a}catch(d){alert(d)}}this.datasource.responseSchema={fields:b};this.myColumnDefs=[];sortedkey="";direction="";for(teller=0;teller<this.fields.length;teller++){var a={};a.key=this.fields[teller].fieldname;a.label=this.fields[teller].fieldcaption;if(this.fields[teller].sortable!="false"){a.sortable=true}else{a.sortable=false}a.resizeable="true";if(this.fields[teller].sorted=="true"){sortedkey=this.fields[teller].fieldname}try{if(this.columVisibility[this.fields[teller].fieldname]=="f"){this.fields[teller].hidden="true"}}catch(d){alert(d)}if(this.fields[teller].hidden=="true"){a.hidden=true}if(this.fields[teller].sorted=="true"){sortedkey=a.key}if(this.fields[teller].className){a.className=this.fields[teller].className}if(this.fields[teller].rowCounter){a.rowCounter=this.fields[teller].rowCounter}if(this.fields[teller].direction){direction=this.fields[teller].direction}if(this.fields[teller].align){a.align=this.fields[teller].align}if(this.fields[teller].type){a.type=this.fields[teller].type;if(a.type=="currency"){a.formatter=dt_formatCurrency;this.fields[teller].parser=parseNumberFromCurrency;a.parser=parseNumberFromCurrency}if(a.type=="uitvoering"){a.formatter=this.fields[teller].uitvoerder}}if(this.fields[teller].width){a.width=this.fields[teller].width}try{if(this.columPositions!=undefined&&this.columPositions[this.fields[teller].fieldname]!=undefined){pos=(this.columPositions[this.fields[teller].fieldname])*1;this.myColumnDefs[c+pos]=a}else{this.myColumnDefs[c+teller]=a}}catch(d){alert("2")}}if(sortedkey==""){sortedkey="id"}this.sortedkey=sortedkey;if(direction==""){direction="asc"}};arkiaTable.prototype.initTableFields=function(){try{var g=$(this.tableContainer);if(g==null){return}var o=g.children[0];var p=o.tHead.children[0];this.myColumnDefs=[];fielddata=[];var b=o.getAttribute("sortedkey");if(b!=null){this.sortedkey=b}if(this.sortedkey!=undefined){b=this.sortedkey}direction="asc";for(var m=0;m<p.cells.length;m++){var f={};var n={};var q=p.cells[m].getAttribute("key");var d=p.cells[m].innerHTML.trim();if(typeof q=="undefined"||q==null){q=d}f.key=q.trim();if(f.key==""){f.key="col"+m}n.key=f.key;f.label=d;var k=p.cells[m].getAttribute("field");if(k!=null){f.fieldname=k}else{f.fieldname=f.label}if(p.cells[m].getAttribute("coltype")=="currency"){f.formatter=dt_formatCurrency;f.parser=parseNumberFromCurrency;n.parser=parseNumberFromCurrency}if(p.cells[m].getAttribute("coltype")=="date"){f.formatter="date"}if(p.cells[m].getAttribute("hidden")=="true"){f.hidden="true"}var a=p.cells[m].getAttribute("colwidth");if(a!=null){f.width=a*1}var j=p.cells[m].getAttribute("classname");if(j!=null){f.className=j}var h=p.cells[m].getAttribute("sortable");if(h=="true"||h==null){f.sortable=true}else{f.sortable=false}f.resizeable=false;if(b==""&&f.key!=""){b=f.key}this.myColumnDefs[m]=f;fielddata[m]=n}this.datasource.responseSchema={fields:fielddata}}catch(l){arkia.log(l)}};arkiaTable.prototype.initFields=function(){if(this.fields){this.initConfigFields()}else{this.initTableFields()}};arkiaTable.prototype.onRenderEvent=function(){if(this.columnlinkAdded==undefined){this.columnlinkAdded=true;div=document.createElement("span");div.style.paddingRight="15px";div.style.paddingLeft="15px";link=document.createElement("a");link.innerHTML="Kolommen";link.href="#";link.title="Kolommen tonen /  verbergen";link.style.fontSize="8px";link.onclick=function(){this.kolomZichtbaarheid()};div.appendChild(link);parent=$(this.tableContainer).firstChild;parent.appendChild(div)}if($("yui-dt0-th-commands")){window.setTimeout(function(){$("yui-dt0-th-commands").onmousdown=function(){return false}},500);$("yui-dt0-th-commands").style.cursor="default"}};arkiaTable.prototype.onColumnReorderEvent=function(){var a=this.DataTable.getColumnSet().keys;qs="";for(var c=0,b=a.length;c<b;c++){var e=a[c];try{qs+="col["+e.getKey()+"]="+c+"&"}catch(d){alert(d)}}qs+="table="+this.tableContainer;passDataThrough("/do/saveKolomPos.html?"+qs)};arkiaTable.prototype.onRowClickEvent=function(d){try{var f=YAHOO.util.Event.getTarget(d);var c=this.DataTable.getRecord(f);try{if(c){this.id=c.getData("id");this.current_record=c}}catch(a){alert(a)}this.DataTable.onEventSelectRow(d)}catch(b){alert(b)}};arkiaTable.prototype.initDatatable=function(){try{var a=$(this.tableContainer);if(a==null){return}if(!this.initDataSource()){return}if(!this.initColumnVisibilities()){return}if(!this.initColumnPositions()){return}this.initFields();alert("TEST");try{a.className=""}catch(f){alert(f)}if(this.numRows!=0){this.paginator=new YAHOO.widget.Paginator({rowsPerPage:this.numRows,firstPageLinkLabel:"<img src='/icons/nav/first.png' alt=\"<< eerste \"/>",lastPageLinkLabel:"<img src='/icons/nav/last.png' alt=\" laatste >> \"/>",previousPageLinkLabel:"<img src='/icons/nav/prev.png' alt=\" < vorige \"/>",nextPageLinkLabel:"<img src='/icons/nav/next.png' alt=\" volgende > \"/>",firstPageLinkTitle:this.EERSTE_PAGINA,nextPageLinkTitle:this.VOLGENDE_PAGINA,previousPageLinkTitle:this.VORIGE_PAGINA,lastPageLinkTitle:this.LAATSTE_PAGINA,pageLabelBuilder:function(e){return e},pageTitleBuilder:function(e){return"Pagina "+e},template:'<table class="pg-nav"><tr><td>'+this.MSG_GOTOPAGE+"</td><td> {JumpToPageDropdown} </td><td> {FirstPageLink} </td><td> {PreviousPageLink} </td><td> {PageLinks} </td><td>{NextPageLink} </td><td> {LastPageLink} </td></tr></table>"});this.DataTable=new YAHOO.widget.DataTable(this.tableContainer,this.myColumnDefs,this.datasource,{sortedBy:{key:this.sortedkey,dir:direction},MSG_EMPTY:this.MSG_EMPTY,MSG_LOADING:this.MSG_LOADING,MSG_ERROR:this.MSG_ERROR,paginator:this.paginator,dynamicData:true,draggableColumns:true})}else{if(this.dataURL!=null){try{if(!this.scrolling){this.DataTable=new YAHOO.widget.DataTable(this.tableContainer,this.myColumnDefs,this.datasource,{sortedBy:{key:this.sortedkey,dir:"asc"},MSG_EMPTY:this.MSG_EMPTY,MSG_LOADING:this.MSG_LOADING,MSG_ERROR:this.MSG_ERROR,dynamicData:true})}else{this.DataTable=new YAHOO.widget.ScrollingDataTable(this.tableContainer,this.myColumnDefs,this.datasource,{sortedBy:{key:this.sortedkey,dir:"asc"},MSG_EMPTY:this.MSG_EMPTY,MSG_LOADING:this.MSG_LOADING,MSG_ERROR:this.MSG_ERROR,height:this.tableHeight+"px",width:this.tableWidth+"px",dynamicData:true})}}catch(d){alert("TEST 4 "+d)}}else{try{if(!this.scrolling){this.DataTable=new YAHOO.widget.DataTable(this.tableContainer,this.myColumnDefs,this.datasource,{sortedBy:{key:this.sortedkey,dir:"asc",MSG_EMPTY:this.MSG_EMPTY,MSG_LOADING:this.MSG_LOADING,MSG_ERROR:this.MSG_ERROR}})}else{this.DataTable=new YAHOO.widget.ScrollingDataTable(this.tableContainer,this.myColumnDefs,this.datasource,{sortedBy:{key:this.sortedkey,dir:"asc"},height:this.tableHeight+"px",width:this.tableWidth+"px",MSG_EMPTY:this.MSG_EMPTY,MSG_LOADING:this.MSG_LOADING,MSG_ERROR:this.MSG_ERROR})}}catch(d){alert("TEST 3 "+d)}}}this.DataTable.subscribe("rowMouseoverEvent",this.DataTable.onEventHighlightRow);this.DataTable.subscribe("rowMouseoutEvent",this.DataTable.onEventUnhighlightRow);this.DataTable.subscribe("postRenderEvent",function(){window.setTimeout(function(){try{setSelectors(a)}catch(g){alert(g)}},100)});this.DataTable.subscribe("renderEvent",this.onRenderEvent);if(this.renderCallBack){this.DataTable.subscribe("renderEvent",this.renderCallBack)}this.DataTable.subscribe("columnReorderEvent",this.onColumnReorderEvent,this,true);var c=this;this.DataTable.subscribe("rowClickEvent",function(g){c.onRowClickEvent.call(c,g)});this.DataTable.handleDataReturnPayload=function(g,e,h){if(c.maxRecords==0){h.totalRecords=0}else{h.totalRecords=c.maxRecords}setSelectors(a);return h};this.resizeEverything();if(this.tableContainer){if(typeof this.tableContainer=="string"){var b=$(this.tableContainer);if(b!=null){b.style.display="block"}}if(typeof this.tableContainer=="object"){this.tableContainer.style.display="block"}}}catch(f){alert(f)}};
