<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Area.aspx.cs" Inherits="GigaTech.CMS.Web.Common.SystemAdmin.Building.Area" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
    <script language=javascript>
        Ext.onReady(function () {

            Ext.QuickTips.init();

            var gridStore = Ext.create('Ext.data.Store', {
                autoLoad: true,
                fields: ['idno', 'name', 'show'],
                proxy: {
                    type: 'ajax',
                    url: 'Handler.ashx?action=GetAreaData',
                    reader: {
                        type: 'json',
                        root: 'items'
                    }
                }
            });

            Ext.create('Ext.container.Viewport', {
                layout: 'fit',
                items: [
                                            Ext.create('Ext.grid.Panel', {
                                                viewConfig: {
                                                    markDirty: false
                                                },
                                               // margin: 10,
                                                height: 300,
                                                frame:true,
                                                title: '<%=GetGlobalResourceObject("CMSResource", "AreaMainten")%>',
                            tbar: ['->',
                                {
                                    xtype: 'tbtext',
                                    text: '<font color=red>※ <%=GetGlobalResourceObject("CMSResource", "ClickForEdit")%> ※</font>'
                                },
                                '->'
                            ],
                                                buttons: [
    {
        text: '<%=GetGlobalResourceObject("CMSResource", "SaveSetting")%>',
                    scale: 'medium',
                    icon:'/Common/DMZ/Images/24x24/floppy.png',
                    border: 1,
                    style: {
                        borderColor: 'gray',
                        borderStyle: 'solid'
                    },
                    handler: function () {

                        Ext.Ajax.request({
                            url: 'Handler.ashx?action=SaveAreaData',
                            params: {
                                area1: gridStore.getAt(0).get("name") + '@' + (gridStore.getAt(0).get("show") ? '1' : '0'),
                                area2: gridStore.getAt(1).get("name") + '@' + (gridStore.getAt(1).get("show") ? '1' : '0'),
                                area3: gridStore.getAt(2).get("name") + '@' + (gridStore.getAt(2).get("show") ? '1' : '0'),
                                area4: gridStore.getAt(3).get("name") + '@' + (gridStore.getAt(3).get("show") ? '1' : '0'),
                                area5: gridStore.getAt(4).get("name") + '@' + (gridStore.getAt(4).get("show") ? '1' : '0'),
                                area6: gridStore.getAt(5).get("name") + '@' + (gridStore.getAt(5).get("show") ? '1' : '0'),
                                area7: gridStore.getAt(6).get("name") + '@' + (gridStore.getAt(6).get("show") ? '1' : '0'),
                                area8: gridStore.getAt(7).get("name") + '@' + (gridStore.getAt(7).get("show") ? '1' : '0'),
                                area9: gridStore.getAt(8).get("name") + '@' + (gridStore.getAt(8).get("show") ? '1' : '0'),
                                area10: gridStore.getAt(9).get("name") + '@' + (gridStore.getAt(9).get("show") ? '1' : '0'),
                                area11: gridStore.getAt(10).get("name") + '@' + (gridStore.getAt(10).get("show") ? '1' : '0'),
                                area12: gridStore.getAt(11).get("name") + '@' + (gridStore.getAt(11).get("show") ? '1' : '0'),
                                area13: gridStore.getAt(12).get("name") + '@' + (gridStore.getAt(12).get("show") ? '1' : '0'),
                                area14: gridStore.getAt(13).get("name") + '@' + (gridStore.getAt(13).get("show") ? '1' : '0'),
                                area15: gridStore.getAt(14).get("name") + '@' + (gridStore.getAt(14).get("show") ? '1' : '0')
                            },
                            success: function (response) {
                                alert("<%=GetGlobalResourceObject("CMSResource", "SaveSuccess")%>");
                            },
                            failure: function (response) {
                                alert("<%=GetGlobalResourceObject("CMSResource", "SaveFail")%>");
                            }
                        });
                        
                    }
                }
                                                            ],
                                                store: gridStore,
                                                columns: [
                                                    { header: '<%=GetGlobalResourceObject("CMSResource", "SerialNumber")%>', dataIndex: 'idno', width: 40, align: 'center' },
                                {
                                    header: '<%=GetGlobalResourceObject("CMSResource", "Name")%>',
                                    dataIndex: 'name',
                                    flex: 1,
                                    editor: {
                                        xtype: 'textfield',
                                        maxLength: 10
                                    }
                                },
                                {
                                    xtype: 'checkcolumn',
                                    header: '<%=GetGlobalResourceObject("CMSResource", "Display")%>',
                                    dataIndex: 'show',
                                    width: 90
                                }
                            ],
                                                selType: 'cellmodel',
                                                plugins: [
                                                    Ext.create('Ext.grid.plugin.CellEditing', {
                                                        clicksToEdit: 1
                                                    })
                                                ]
                                            })
                ]
            });

        });
    </script>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>
