示例#1
0
    ?>
	<a href="estoque.html" class="button btn-square estoque">Estoque</a>
<?php 
}
if (Session::hasPermission('usuario', Session::VISUALIZAR)) {
    ?>
	<a class="button btn-square usuarios" href="<?php 
    echo Helper::link('usuario');
    ?>
">Usuários</a>
<?php 
}
if (Session::hasPermission('suporte', Session::VISUALIZAR)) {
    ?>
	<a class="button btn-square suporte" href="<?php 
    echo Helper::link('suporte');
    ?>
">Suporte</a>
<?php 
}
if (Session::hasPermission('relatorio', Session::VISUALIZAR)) {
    ?>
	<a class="button btn-square relatorios">Relatório</a>
<?php 
}
?>
<a class="button btn-square red perfil" href="<?php 
echo Helper::link('perfil');
?>
">Meu Perfil</a>
</div>
 public function salvar()
 {
     if (!Session::hasPermission('usuario', Session::EXCLUIR)) {
         Router::redirect('home');
     }
     $cols = array();
     $values = array();
     $ident = Request::get('ident');
     $ident = $ident == "0" ? false : $ident;
     $j = array();
     // resposta
     global $db;
     $exists = $db->query("select * from user where email='" . Request::post('email') . "'", true);
     if (!$ident && count($exists) > 0) {
         $j['status'] = 'danger';
         $j['message'] = 'O usuário já existe';
         echo json_encode($j);
         return;
     }
     foreach ($_POST as $key => $value) {
         if ($key == 'active') {
             $value = 1;
         }
         if (preg_match("/\\=/", $value)) {
             $refs = explode("&", $value);
             $rcol = array();
             $rval = array();
             foreach ($refs as $ref) {
                 $r = explode("=", $ref);
                 array_push($rcol, $r[0]);
                 array_push($rval, $r[1]);
             }
             $query = "delete from user_module where user_id=" . $rval[0] . " and module_id=" . $rval[1] . ";";
             $db->query($query, true);
             $query = "insert into user_module (" . implode(",", $rcol) . ") values ('" . implode("','", $rval) . "');";
             $db->query($query);
             continue;
         }
         array_push($cols, $key);
         array_push($values, $value);
     }
     if (!Request::post('active')) {
         array_push($cols, 'active');
         array_push($values, 0);
     }
     if (!$ident) {
         // neurosoft
         array_push($cols, "password");
         array_push($values, Session::password("neurosoft"));
         // neurosoft
         array_push($cols, "token");
         array_push($values, Session::token(Request::post('email') . "neurosoft"));
     }
     if ($ident) {
         $query = "update user set ";
         $sets = array();
         for ($i = 0; $i < count($cols); $i++) {
             array_push($sets, $cols[$i] . "='" . $values[$i] . "'");
         }
         $query .= implode(",", $sets) . " where id=" . $ident;
     } else {
         $query = "insert into user (" . implode(",", $cols) . ") values ('" . implode("','", $values) . "');";
     }
     $result = $db->query($query);
     if ($result) {
         $j['status'] = 'success';
         $j['message'] = 'Usuário salvo com êxito.';
         $returningId = $ident ? "" : "editar/" . $result;
         $j['redirect'] = "/" . APP_DIR . "usuario/" . $returningId;
     } else {
         $j['status'] = 'danger';
         $j['message'] = 'O sistema não pode salvar o usuário. Contate o administrador.';
     }
     echo json_encode($j);
 }
示例#3
0
        }
        ?>
                    </select><br/>
                
            <?php 
        $counter++;
    }
    ?>
    </div>
    <?php 
}
FormHelper::startGroup();
if (!$id && Session::hasPermission('usuario', Session::INSERIR) || Session::hasPermission('usuario', Session::EDITAR)) {
    FormHelper::submitAjax("Salvar", "salvar/" . $u['id'], array('class' => 'button button-md'));
}
if ($id && Session::hasPermission('usuario', Session::EXCLUIR)) {
    FormHelper::button("excluir", "Excluir", array('style' => 'margin-left:10px', 'onclick' => 'App.Usuario.Excluir("' . $u["name"] . '",' . $u['id'] . ")"));
}
FormHelper::button('cancelar', "Cancelar", array('style' => 'margin-left:10px', 'onclick' => "location.href=\"/" . APP_DIR . "usuario\""));
FormHelper::endGroup();
FormHelper::end();
?>
    <script type="text/javascript">
        App.Usuario.Excluir = function(nome, id) {
            if (App.Modal.Show("Excluir usuário", 'Deseja realmente excluir o usuário <strong>' + nome + '</strong>?', "Excluir", function() {
                location.href = '<?php 
echo "/" . APP_DIR . "service/usuario/excluir/";
?>
' + id;
            }));
        }