/*jslint         browser : true, continue : true,
  devel  : true, indent  : 2,    maxerr   : 50,
  newcap : true, nomen   : true, plusplus : true,
  regexp : true, sloppy  : true, vars     : false,
  white  : true
*/

/*global $, app */

app.subscription = (function () {
    'use strict';
    //---------------- BEGIN MODULE SCOPE VARIABLES --------------
    var

        stateMap = {},
        configModule,
        initModule;
    //----------------- END MODULE SCOPE VARIABLES ---------------

    //------------------- BEGIN UTILITY METHODS ------------------
    //-------------------- END UTILITY METHODS -------------------

    //------------------- BEGIN EVENT HANDLERS -------------------

    //-------------------- END EVENT HANDLERS --------------------

    //------------------- BEGIN PUBLIC METHODS -------------------
    //CONFIGMODULE
    //
    configModule = function (context) {
        stateMap.context = context.context;
        if (stateMap.context.params.id) {
            stateMap.id = stateMap.context.params.id;
        }
    };

    //INITMODULE
    //
    initModule = function ($container) {
        if (typeof $container === 'undefined') {
            $container = $('#app-shell-main-content');
        }
        $container.html(Handlebars.templates['app.subscription']({}));

        //Context menu           
        app.nav.contextClear();
        ////app.nav.setContextTitle("Subscriptions");

        var $appList = $('#rf-list');
        $appList.empty();
        $appList.append('<ul class="list-group">');
        $appList.append("<li><a class=\"list-group-item\" href=\"#!/subnotify/\">" + app.utilB.genListColumn("Notify users with imminent expiring subscriptions") + "</a></li>");
        $appList.append("<li><a class=\"list-group-item\" href=\"#!/reportDataExpires/\">" + app.utilB.genListColumn("Show subscriptions by expiry") + "</a></li>");
        $appList.append("<li><a class=\"list-group-item\" href=\"#!/reportDataProdEmails/\">" + app.utilB.genListColumn("Build email address CSV by product code") + "</a></li>");
        $appList.append('</ul>');
        //not implemented yet
        // $appList.append("<li><a href=\"#!/subrenew/\">" + app.utilB.genListColumn("Renew") + "</a></li>");


    };

    //PUBLIC METHODS
    //
    return {
        configModule: configModule,
        initModule: initModule
    };
    //------------------- END PUBLIC METHODS ---------------------
}());