
<td width="50%" style="border: solid 0px green;font-size: 8pt">
    <fieldset>
        <legend>Cadastrar Usuarios</legend>
        <table width="100%" valign="top" style="border: solid 0px red; " align="center">
            <?php
            
            if ($adduserstatus == "0" or $adduserstatus == "12") {
                
                print("<div class='alert alert-success'>User [" . $_POST["username"] . "] Cadastrado com sucesso</div>");
                
            }
            if ($adduserstatus == "1") {
                
                print("<div class='alert alert-danger'>Login, senha, e nome são obrigatórios.</div>");
                
            }
            if ($adduserstatus == "2") {
                
                print("<div class='alert alert-danger'>Login já Cadastrado.. Escolha outro..</div>");
                
            }
            if ($adduserstatus == "3") {
                
                print("<div class='alert alert-danger'>Nenhuma Operadora Selecionada...</div>");
                
            }
            if ($adduserstatus == "4") {
                
                print("<div class='alert alert-danger'>O login deve ter entre 3 e 20 digitos.</div>");
                
            }
            if ($adduserstatus == "5") {
                
                print("<div class='alert alert-danger'>A Senha deve ter entre 3 e 20 digitos.</div>");
                
            }
            if ($adduserstatus == "6") {
                
                print("<div class='alert alert-danger'>O Vencmento não pode ser menor do que a data de cadastro.</div>");
                
            }
            if ($adduserstatus == "7") {
                
                print("<div class='alert alert-danger'>O Campo DD deve ser preenchido.</div>");
                
            }
            if ($adduserstatus == "8") {
                
                print("<div class='alert alert-danger'>Voce excedeu o saldo de logins</div>");
                
            }
            if ($adduserstatus == "9") {
                
                print("<div class='alert alert-danger'>Saldo Pre-Pago esgotado, você precisa adquirir um plano.</div>");
                
            }
            if (isset($status) && $status != "") {
                
                print($status);
                
            }
            ?>
            <form id="adduser" name="adduser" action="adduser.php" method="post">
                <tr>
                    <td colspan="">
                        Login Teste:
                        <input type="checkbox" name="teste" class="" onchange="usTeste(this)"/>                     
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        Valor Cobrado<br/>
                        <div class="" style="width: 30%">
                            <input type="text" name="valor_cob" id="valor_cob" class="form-control numeros" value="<?php echo isset($_POST["valor_cob"]) ? $_POST["valor_cob"] : ""; ?>"/>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td width="50%" valign="top">
                        Login:<br>
                        <input type="text" name="username" size="20" tabindex="1" class="form-control" value="<?php echo isset($_POST["username"]) ? $_POST["username"] : ""; ?>"/>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        Senha:<br/>
                        <input type="text" name="password" size="20" tabindex="2" class="form-control" value="<?php echo isset($_POST["password"]) ? $_POST["password"] : ""; ?>"/>
                    </td>

                </tr>
                <tr>
                    <td>
                        Cadastrado em:<br/>
                        <input id="startdate" type="text" name="startdate" size="20" class="form-control" value="<?php echo date('d/m/Y') ?>" readonly="true"/>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        Vencimento:<br/>
                        <input id="expiredate" type="text" name="expiredate" size="20" class="form-control" value="<?php echo isset($_POST["expiredate"]) ? $_POST["expiredate"] : ""; ?>"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Nome:<br>
                        <input type="text" name="displayname" size="20" tabindex="3" class="form-control" value="<?php echo isset($_POST["displayname"]) ? $_POST["displayname"] : ""; ?>"/> 
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        E-mail :<br/>
                        <input type="text" name="email" size="20" tabindex="5" class="form-control" value="<?php echo isset($_POST["email"]) ? $_POST["email"] : ""; ?>">
                    </td>
                </tr>
                <tr>
                    <td>
                        <table>
                            <tr>                                
                                <td width="20%">DD:<br/>

                                    <input class="form-control numeros" maxlength="2" name="dd" value="<?php echo isset($_POST["dd"]) ? $_POST["dd"] : ""; ?>"/>

                                </td>
                                <td>
                                    Telefone:<br/>
                                    <input class="form-control numeros" maxlength="9" name="telefone" value="<?php echo isset($_POST["telefone"]) ? $_POST["telefone"] : ""; ?>"/>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <table>
                            <tr>                                
                                <td width="20%">DD:<br/>

                                    <input class="form-control numeros" maxlength="2" name="dd_cel" value="<?php echo isset($_POST["dd_cel"]) ? $_POST["dd_cel"] : ""; ?>"/>

                                </td>
                                <td>
                                    Celular:<br/>
                                    <input class="form-control numeros" maxlength="9" name="celular" value="<?php echo isset($_POST["celular"]) ? $_POST["celular"] : ""; ?>"/>
                                </td>
                            </tr>
                        </table>
                    </td>
                    
                </tr>
                <tr>
                    <td style="vertical-align: top">
                        Maximo de Conexões<br/>
                        <input type="text" name="maxconnections" id="maxconnections" size="1" tabindex="8" class="form-control" value="<?php echo isset($_POST["maxconnections"]) ? $_POST["maxconnections"] : ""; ?>"/>
                    </td>
                    <td>&nbsp;</td>
                    <td colspan="">Observações do Login:<br/>
                        <textarea class="form-control" name="obs_user" ><?php echo isset($_POST["obs_user"]) ? $_POST["obs_user"] : ""; ?></textarea>
                    </td>                  
                    
                </tr>
                <tr>
                    <td> <input type="checkbox" name="enviar_email" id="enviar_email" class="" <?php if (isset($_POST["enviar_email"])): ?> checked="true"<?php endif; ?>/> 
                        Enviar dados de cadastro<br/> por email.                                          
                    </td>
                    <td></td>
                    <td></td>
                </tr>

                <input name="usrgroup" type="hidden" id="usrgroup" tabindex="4"  value="<?php
                if ($_SESSION["adminid"] < 10) {
                    echo "#0" . $_SESSION["adminid"];
                } else {
                    echo "#" . $_SESSION["adminid"];
                }
                ?>" size="20" readonly="true">&nbsp;<?php
                       if ($hidehelp == "1") {
                           
                       }
                       ?>               

                <!--<input type="hidden" name="maxconnections" id="maxconnections" size="1" tabindex="8" class="form-control" value=""/>-->
                <input type="hidden" name="admin" value="false"/>
                <input type="hidden" name="enabled" value="true"/>
                <input type="hidden" name="debug" value="false"/>

        </table>
        <p>&nbsp;</p>
        <fieldset >
            <legend class="addedit">Perfis:&nbsp;</legend>
            <table width="100%" valign="top" cellpadding="0" cellspacing="0" border="0" id="fieldPerf"> 
                <?php
                //Opçoes Mult Profis
                $con = mysql_connect($dbhost, $dbuser, $dbpass) or sqlerror();
                mysql_select_db($dbname, $con);
                $SQL = "SELECT mult_perf FROM cmum_settings WHERE id = '1'";
                $rs = mysql_query($SQL);
                if (is_resource($rs)) {
                    $mp = mysql_fetch_assoc($rs);
                    $tipo_campo = "checkbox";
                    if ($mp['mult_perf'] == '0') {
                        $tipo_campo = "radio";
                    }
                } else {
                    exit('Erro ao buscar informaçoes multi perifs.');
                }
                //***** Bloco codigo profiles removido ***** //
                if ($adduserstatus > 0 && $adduserstatus < 10) {
                    $lr = "0";
                    $conn2 = @mysql_connect($dbhost, $dbuser, $dbpass) or sqlerror();
                    mysql_select_db($dbname, $conn2);
                    $SQL = "SELECT * FROM cmum_profiles";
                    if ($_SESSION['adminlevel'] != "0") {
                        $ids_pf = implode(',', $pf_pm);
                        $SQL .= " WHERE id IN ({$ids_pf}) AND bloqueado='0'";
                    }
                    $rs = mysql_query($SQL) or sqlerror();
                    $numprof = mysql_num_rows($rs);
                    while ($line2 = mysql_fetch_array($rs)) {
                        if ($_SESSION['adminlevel'] != "0") {
                            if (array_search($line2['id'], $pf_pm) !== false) {
                                if ($lr == "0") {
                                    $dbprof = unserialize($profiles);
                                    if ($dbprof <> "") {
                                        $checked = "";
                                        foreach ($dbprof as $printprof) {
                                            if ($printprof == $line2["id"]) {
                                                $checked = "checked=\"checked\"";
                                            }
                                        }
                                    } else {
                                        $checked = "";
                                    }
                                    //print("<tr width=\"100%\" valign=\"top\"><td width=\"50%\" valign=\"top\"><input type=\"checkbox\" name=\"profiles[]\" tabindex=\"15\" value=\"" . $line2["id"] . "\" " . $checked . "/>" . $line2["name"] . "</td>");
                                    print("<tr width=\"100%\" valign=\"top\"><td width=\"50%\" valign=\"top\"><input type=\"{$tipo_campo}\" name=\"profiles[]\" tabindex=\"15\" value=\"" . $line2["id"] . "\" " . $checked . "/>" . $line2["name"] . "</td>");
                                    $lr = "1";
                                } else {
                                    $dbprof = unserialize($profiles);
                                    if ($dbprof <> "") {
                                        $checked = "";
                                        foreach ($dbprof as $printprof) {
                                            if ($printprof == $line2["id"]) {
                                                $checked = "checked=\"checked\"";
                                            }
                                        }
                                    } else {
                                        $checked = "";
                                    }
                                    print("<td width=\"50%\" valign=\"top\"><input type=\"{$tipo_campo}\" name=\"profiles[]\" tabindex=\"15\" value=\"" . $line2["id"] . "\" " . $checked . "/>" . $line2["name"] . "</td></tr>");
                                    $lr = "0";
                                }
                            }
                        } else {
                            if ($lr == "0") {
                                $dbprof = unserialize($profiles);
                                if ($dbprof <> "") {
                                    $checked = "";
                                    foreach ($dbprof as $printprof) {
                                        if ($printprof == $line2["id"]) {
                                            $checked = "checked=\"checked\"";
                                        }
                                    }
                                } else {
                                    $checked = "";
                                }
                                //print("<tr width=\"100%\" valign=\"top\"><td width=\"50%\" valign=\"top\"><input type=\"checkbox\" name=\"profiles[]\" tabindex=\"15\" value=\"" . $line2["id"] . "\" " . $checked . "/>" . $line2["name"] . "</td>");
                                print("<tr width=\"100%\" valign=\"top\"><td width=\"50%\" valign=\"top\"><input type=\"{$tipo_campo}\" name=\"profiles[]\" tabindex=\"15\" value=\"" . $line2["id"] . "\" " . $checked . "/>" . $line2["name"] . "</td>");
                                $lr = "1";
                            } else {
                                $dbprof = unserialize($profiles);
                                if ($dbprof <> "") {
                                    $checked = "";
                                    foreach ($dbprof as $printprof) {
                                        if ($printprof == $line2["id"]) {
                                            $checked = "checked=\"checked\"";
                                        }
                                    }
                                } else {
                                    $checked = "";
                                }
                                print("<td width=\"50%\" valign=\"top\"><input type=\"{$tipo_campo}\" name=\"profiles[]\" tabindex=\"15\" value=\"" . $line2["id"] . "\" " . $checked . "/>" . $line2["name"] . "</td></tr>");
                                $lr = "0";
                            }
                        }
                    }
                    mysql_close($conn2);
                } else {
                    $lr = "0";
                    $conn2 = @mysql_connect($dbhost, $dbuser, $dbpass) or sqlerror();
                    mysql_select_db($dbname, $conn2);
                    $sql2 = mysql_query("SELECT * FROM cmum_profiles WHERE bloqueado='0'") or sqlerror();
                    $numprof = mysql_num_rows($sql2);
                    while ($line2 = mysql_fetch_array($sql2)) {
                        if ($_SESSION['adminlevel'] != "0") {
                            if (array_search($line2['id'], $pf_pm) !== false) {
                                if ($lr == "0") {
                                    print("<tr width=\"100%\" valign=\"top\"><td width=\"50%\" valign=\"top\"><input type=\"{$tipo_campo}\" name=\"profiles[]\" tabindex=\"15\" value=\"" . $line2["id"] . "\"/>" . $line2["name"] . "</td>");
                                    $lr = "1";
                                } else {
                                    print("<td width=\"50%\" valign=\"top\"><input type=\"{$tipo_campo}\" name=\"profiles[]\" tabindex=\"15\" value=\"" . $line2["id"] . "\"/>" . $line2["name"] . "</td></tr>");
                                    $lr = "0";
                                }
                            }
                        } else {
                            if ($lr == "0") {
                                print("<tr width=\"100%\" valign=\"top\"><td width=\"50%\" valign=\"top\"><input type=\"{$tipo_campo}\" name=\"profiles[]\" tabindex=\"15\" value=\"" . $line2["id"] . "\"/>" . $line2["name"] . "</td>");
                                $lr = "1";
                            } else {
                                print("<td width=\"50%\" valign=\"top\"><input type=\"{$tipo_campo}\" name=\"profiles[]\" tabindex=\"15\" value=\"" . $line2["id"] . "\"/>" . $line2["name"] . "</td></tr>");
                                $lr = "0";
                            }
                        }
                    }
                    mysql_close($conn2);
                }
                ?>
            </table>
            <?php if ($numprof == 0) : ?>
                <p>Não Existe Perfis Cadastrados <a href="profiles.php">Clique Aqui</a></p>
            <?php elseif ($mp['mult_perf'] != "0"): ?>
                <br/>
                <input type="checkbox" name="allprof" onClick="checkedAll(this)"/>Selecionar Todos
            <?php endif; ?>

        </fieldset><br>
        <button name="badduser" type="submit" value="add_permanecer" alt="Add Usuario" title="Add Usuário" style="" class="btn btn-success">
            <!--<img src="images/ok.png"  width="32px" alt="Add Usuario" title="Add Usuário"/>-->
            Salvar &<br/>Novo
        </button>
        <button name="badduser" type="submit" value="Add user" alt="Add Usuario" title="Add Usuário" style="" class="btn btn-success">
            <!--<img src="images/ok.png"  width="32px" alt="Add Usuario" title="Add Usuário"/>-->
            Salvar &<br/>Sair
        </button>
        <button name="badduser" type="submit" value="Clear fields" alt="Cancelar" title="Cancelar" style="" class="btn btn-danger">
            <!--<img src="images/cancel.png" width="32px" alt="Cancelar" title="Cancelar"/>-->
            Cancelar<br/>Cadastro
        </button>
        <!--<button name="badduser" type="submit" value="Sair" alt="Sair" title="Sair" style="" class="btn btn-default">
        <a href="<?php echo __FILE__ . '/../manusers.php' ?>">-->
            <!--<img src="images/exit.png" width="32px" alt="Sair" title="Sair" border="0"/>-->
        <!--</a>-->
        <!--</button>-->            

<!--<input type="submit" name="badduser" value="Add user" tabindex="18" id="submit" accesskey="s" title="(ALT+S)">

<input type="submit" name="badduser" value="Add user and stay" tabindex="19" id="submit" accesskey="a" title="(ALT+A)"><br>
<input type="submit" name="badduser" value="Random username" tabindex="20" id="submit" accesskey="u" title="(ALT+U)">
<input type="submit" name="badduser" value="Random password" tabindex="20" id="submit" accesskey="r" title="(ALT+R)">
<input type="submit" name="badduser" value="Random username & password" tabindex="20" id="submit" accesskey="b" title="(ALT+B)"><br>
<input type="submit" name="badduser" value="Load defaults" tabindex="21" id="submit" accesskey="l" title="(ALT+L)">
<input type="submit" name="badduser" value="Clear fields" tabindex="22" id="submit" accesskey="c" title="(ALT+C)" onClick="focus();adduser.username.focus()">-->
    </form>
</td>
<!--<td width="252" height="20" valign="top"><div id="cspinfo" style="width: 230px; border: solid 0px blue"></div></td>-->
</fieldset>
