/*
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
dojo._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","kfc.kwo.LookupsGrid"],["require","dojox.grid.DataGrid"],["require","dojo.data.ItemFileWriteStore"],["require","kfc._KFC"],["require","dojox.grid.cells.dijit"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["kfc.kwo.LookupsGrid"]){_4._hasResource["kfc.kwo.LookupsGrid"]=true;_4.provide("kfc.kwo.LookupsGrid");_4.require("dojox.grid.DataGrid");_4.require("dojo.data.ItemFileWriteStore");_4.require("kfc._KFC");_4.require("dojox.grid.cells.dijit");_4.declare("kfc.kwo.LookupsGrid",[kfc._KFC],{templateString:_4.cache("kfc.kwo","templates/LookupsGrid.html","
\n \n
\n Lookups\n \n
\n
\n
\n"),widgetsInTemplate:true,store:null,isDirty:false,saveFile:"server/save.php",loadFile:"server/load.php",seedFile:"server/getTypes.php",db_schema:"KFC",db_table_name:"KWO_LOOKUPS",_getGridStructure:function(){return [{name:" ",formatter:function(){return " ";},editable:false,width:"1em"},{name:"Name",field:"P_NAME",editable:true,width:"15em"},{name:"Description",field:"P_DESCRIPTION",editable:true,width:"auto"},{name:"Enabled",field:"P_ENABLED_FLAG",editable:true,width:"8em",type:_6.grid.cells.Select,options:["Y","N"]}];},_setGridStore:function(){this.grid.setStore(this.store);},_getDataStructure:function(){return {P_ID:null,P_NAME:"",P_DESCRIPTION:"",P_ENABLED_FLAG:"Y",P_DELETED_FLAG:"N"};},_createStore:function(){var s=(this.store_path.length)?new _4.data.ItemFileWriteStore({url:this.store_path}):new _4.data.ItemFileWriteStore({data:{identifier:"P_ID",items:[]}});this.setStore(s);},setStore:function(_7){this.store=_7;},refresh:function(){this.grid.selection.clear();this.load();},load:function(){var _8=this;_8.setStatus({MSG:"Fetching lookups...",TYPE:"INFO",ACTIVITY:true});this.grid.selection.clear();_4.xhrPost({sync:true,url:_8.loadFile,handleAs:"json",content:{P_REQ_NAME:"LOOKUPS",P_REQ_TYPE:"LOAD",P_SCHEMA:_8.db_schema,P_TABLE_NAME:_8.db_table_name},load:function(_9){_8.setStatus({MSG:"Done",TYPE:"INFO",ACTIVITY:false});var s=new _4.data.ItemFileWriteStore({data:_9});_8.setStore(s);},error:function(_a){_8.setStatus({MSG:"Failed to retrieve lookups...",TYPE:"ERROR",ACTIVITY:false});}});},addRow:function(){var _b=this._getDataStructure();_b.P_ID=new Date().getTime();this.store.newItem(_b);},deleteRow:function(){var _c=this.grid;var _d=_c.selection.getSelected();for(var i in _d){this.store.deleteItem(_d[i]);}},save:function(){this.setStatus({MSG:"Saving lookups...",TYPE:"INFO",ACTIVITY:true});var _e=this;var _f={"NEW":KfcStoreFunctions.getNewItems(this.store,true),"UPD":KfcStoreFunctions.getModifiedItems(this.store,true),"DEL":KfcStoreFunctions.getDeletedItems(this.store,true)};_4.xhrPost({sync:true,url:_e.saveFile,handleAs:"text",content:{P_REQ_NAME:"LOOKUPS",P_REQ_TYPE:"SAVE",P_SCHEMA:_e.db_schema,P_TABLE_NAME:_e.db_table_name,P_VALUES:_4.toJson(_f)},load:function(_10){_e.setStatus({MSG:"Done",DETAILS:"Successfully saved lookups.",TYPE:"INFO",ACTIVITY:false});},error:function(_11){_e.setStatus({MSG:"Save failed...",DETAILS:_11,TYPE:"ERROR",ACTIVITY:false});}});},setStatus:function(_12){},postCreate:function(){this.grid.attr("structure",this._getGridStructure());this.grid.startup();_4.connect(this,"setStore",this,"_setGridStore");}});}}};});