

var menu_data = [
    {id: 'app_home', icon: 'dashboard', value: 'Inicio'},
    {id: 'app_partners', icon: 'address-book-o', value: 'Clientes y Proveedores'},
    {id: 'app_products', icon: 'server', value: 'Productos y Servicios'},
    {id: 'app_bancos', icon: 'university', value: 'Bancos'},
    {id: 'app_invoices', icon: 'file-code-o', value: 'Facturas'},
]


var sidebar = {
    view: 'sidebar',
    id: 'main_sidebar',
    data: menu_data,
    ready: function(){
        this.select('app_home');
        this.open(this.getParentId('app_home'));
    },
    on:{
        onAfterSelect: function(id){
            $$('multi').setValue(id)
        }
    },
}


var multi_main = {
    id: 'multi',
    animate: true,
    cells:[
        {
            id: 'app_home',
            view: 'template',
            template: 'HOME'
        },
        app_partners,
        app_products,
        app_bancos,
        app_school,
        app_nomina,
        app_tickets,
        app_invoices,
    ],
}


var menu_user = {
    view: 'menu',
    id: 'menu_user',
    width: 150,
    autowidth: true,
    data: [
        {id: '0', value: 'User...', submenu:[{id:1, value:'Cerrar Sesión'}]},
    ],
    type: {
        subsign: true,
    },
}


var link_blog = "<a class='link_default' target='_blank' href='https://empresalibre.net/blog'>Blog</a>";
var link_forum = "<a class='link_default' target='_blank' href='https://git.cuates.net/elmau/empresa-libre/issues'>Foro</a>";
var link_doc = "<a class='link_default' target='_blank' href='https://empresalibre.net/docs'>Doc</a>";


var ui_main = {
    rows: [
        {view: 'toolbar', padding: 3, elements: [
            {view: 'button', type: 'icon', icon: 'bars',
                width: 37, align: 'left', css: 'app_button', click: function(){
                    $$('main_sidebar').toggle()
                }
            },
            {view: 'label', id: 'lbl_title_main', label: '<b>Empresa Libre</b>'},
            {},
            {view: 'label', id: 'lbl_blog', label: link_blog, align: 'right', width: 30},
            {view: 'label', id: 'lbl_forum', label: link_forum, align: 'right', width: 30},
            {view: 'label', id: 'lbl_doc', label: link_doc, align: 'right', width: 25},
            menu_user,
            {view: 'button', id: 'cmd_update_timbres', type: 'icon', width: 45,
                css: 'app_button', icon: 'bell-o',  badge: 0},
            {view: 'button', type: 'icon', width: 30, css: 'app_button',
                icon: 'cogs',  id: 'cmd_ir_al_admin', hidden: true,
                click: 'cmd_ir_al_admin_click'}
        ]
        },
        {
            cols:[
                sidebar,
                multi_main,
            ]
        }
    ]
};
