extends ./admin-layout.jade
include ./includes/mixins.jade


block jumbo-desc
    p New User Registration


block admin-content
    div
        - var ferrs = ( form_errors.length ) ? form_errors[0] : {};
        if ferrs.password
            +alert_error_array( ferrs.password )
        if ferrs.confirmation
            +alert_error_array( ferrs.confirmation )

    form( action="/admin/users/create" enctype="multipart/form-data" method="post" )
        +input_text( "username", "Username ", "", true, user1 )
        +input_text( "email", "Email", "", true, email1 )
        +input_text( "fname", "First Name", "", true, fname1 )
        +input_text( "lname", "Last Name", "", true,  lname1 )
        +input_text( "password", "Password", "", true,  "", "password" )
        +input_text( "confirm", "Repeat Password", "", true,  "", "password" )

        if ( roles )
            .form-group
                label.control-label( for="role") Role
                select.form-control( name="role" )
                    each role in roles
                      if (role != 'ROOT' || tier === 'ROOT')
                        - var formattedRole = _.startCase( role.toLowerCase() );
                        option( value=role, selected ) #{formattedRole}
          
        if ( agencies )
          if (tier === 'ROOT')
            .form-group
                label.control-label( for="agency" ) Agency
                select.form-control( name="agency" )
                    each agency in agencies
                        if ( agency.id === user.agency )
                            option( value=agency.id selected ) #{agency.name}
                        else
                            option( value=agency.id ) #{agency.name}
          else 
            option #{user.agency.name}

        +input_text( "badge", "Badge No.", "", true,  badge1 )
        +input_text( "sectunit", "Section / Unit", "", true,  unit1 )
        +input_text( "ranktitle", "Rank / Title", "", true,  rank1 )

        .form-group
            button.btn.btn-primary( type="submit" value="save" ) Submit
