{
    "type": "Ext.app.Controller",
    "reference": {
        "name": "items",
        "type": "array"
    },
    "codeClass": null,
    "userConfig": {
        "designer|userClassName": "Authorization"
    },
    "designerId": "82c6892f-f697-40d7-ad16-39fc72bb18e4",
    "cn": [
        {
            "type": "fixedfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "onLaunch",
                "implHandler": [
                    "/*this.authorizations = {\r",
                    "\t'01': false,\r",
                    "\t'02': false,\r",
                    "\t'03': false\r",
                    "};\r",
                    "\r",
                    "var actvt_checks = ['03', '02', '01'];\r",
                    "Ext.Array.each(actvt_checks, function(actvt) {\r",
                    "\tthis.checkAuthorization(actvt);\r",
                    "}, this);*/\r",
                    "\r",
                    "\r",
                    "/** ACTIVATE MAIN PANEL UNTILL THIS SHOULD BE IMPLEMENTED **/\r",
                    "this.getMainPanel().enable();\r",
                    ""
                ]
            },
            "designerId": "3ea528c7-103f-4ce9-a31f-808f85ba8f92"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "value"
                ],
                "fn": "checkAuthorization",
                "implHandler": [
                    "/* Check SAP authorizations */\r",
                    "var authorization = {\r",
                    "    object: 'ZAPM_SOD',\r",
                    "    obj_values: [\r",
                    "        {\r",
                    "            name: 'ACTVT',\r",
                    "            value: value\r",
                    "        }\r",
                    "    ]\r",
                    "};\r",
                    "\r",
                    "Ext.Ajax.request({\r",
                    "    url: '../../../../../auth_check',\r",
                    "    method: 'POST',\r",
                    "    jsonData: Ext.encode(authorization),\r",
                    "    success: function(response, object){\r",
                    "        var text = response.responseText;\r",
                    "        var result = Ext.JSON.decode(text);\r",
                    "        if (Ext.String.trim(result) == '0') {\r",
                    "            this.authorizations[value] = true;\r",
                    "        }\r",
                    "\t\tthis.reactToAuthorization(value);\r",
                    "    },\r",
                    "    failure: function(response, object){\r",
                    "        var text = response.responseText;\r",
                    "        Ext.Error.raise({\r",
                    "            msg: 'Could not perform authorization check',\r",
                    "            option: text,   // whatever was passed into the method\r",
                    "            'object': object // other arbitrary info\r",
                    "        });\r",
                    "    },\r",
                    "    scope: this\r",
                    "});"
                ]
            },
            "designerId": "8c63947b-2e65-4705-ac3b-94c2389b6975"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "actvt_value"
                ],
                "fn": "reactToAuthorization",
                "implHandler": [
                    "switch(actvt_value) {\r",
                    "\tcase '01':\r",
                    "\t\tif(this.authorizations['01']) {\r",
                    "\r",
                    "\t\t}\r",
                    "\tbreak;\r",
                    "\tcase '02':\r",
                    "\t\tif(this.authorizations['02']) {\r",
                    "\r",
                    "\t\t}\r",
                    "\tbreak;\r",
                    "\tcase '03':\r",
                    "\t\tif(this.authorizations['03'])\r",
                    "\t\t\tthis.getMainPanel().enable();\r",
                    "\t\telse\r",
                    "\t\t\tExt.MessageBox.alert(\r",
                    "\t\t\t\tCCS.Translator.getText('Authorization Error'),\r",
                    "\t\t\t\tCCS.Translator.getText('It seems you are not allowed to see this page.'),\r",
                    "\t\t\t\tfunction() {\r",
                    "\t\t\t\t\t//actions to complete when user clicks ok.\r",
                    "\t\t\t\t\twindow.history.back();\r",
                    "\t\t\t\t}\r",
                    "\t\t\t);\r",
                    "\tbreak;\r",
                    "\r",
                    "}"
                ]
            },
            "designerId": "894ae6ad-439e-4ea1-bff2-5f8f5c0d9bda"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "mainPanel",
                "selector": "#mainPanel"
            },
            "designerId": "40d208aa-b338-4e2c-bdee-08c133b36601"
        }
    ]
}