<?php
/**
* object_ordering.php :: Esta página exibe um modelo de ordenação de registros, onde um campo númerico
* determina a ordem de exibição.
*
* PHP version 4
*
* phpWAFr version 1.1.2
* copyright (c) 2007 Associação SoftwareLivre.org
*
* phpWAFr is an open source PHP library designed to accelerate
* the development of transactional database Web applications.
*
* phpWAFr is released under the terms of the LGPL license 2.1
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html LGPL License 2.1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* @package phpWAFr
* @version 1.1.2
* @author Marcelo Rezende <hide@address.com>
* @copyright copyright (c) 2007 Associação SoftwareLivre.org
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html LGPL License 2.1
*/
require_once("../inc/common.php");
/*
verificação do nível do usuário, altere conforme sua necessidade, quanto maior
o valor, maior a restrição
*/
verifyUser(1);
/*
recupera chave, se existir
*/
$id = getParam("id");
/*
conexão com o banco de dados, altere somente se a conexão for diferente do default
*/
$conn = new db();
$conn->open();
/*
lista destino, configure conforme sua necessidade
*/
$sql = "SELECT sistema.sistema_id as id, nome_sistema as val " .
"FROM sistema_usuario, sistema " .
"WHERE sistema_usuario.sistema_id=sistema.sistema_id " .
"AND sistema_usuario.usuario_id=$id " .
"ORDER BY sistema_usuario.ordem_exibicao"; // coloque aqui o campo alvo da ordenação
$rs = new query($conn, $sql);
?>
<html>
<head>
<title>object-ordering</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="<?=CSS_CONTENT?>">
<script src="../inc/js/js_ordena.js"></script>
<script language="JavaScript">
/*
função que monta a lista com a nova sequencia, altere somente o nome da página
*/
function save() {
var list = document.frm.list;
var theList = "0";
for (i = 0; i <= list.options.length-1; i++) {
theList += "," + list.options[i].value;
}
parent.content.document.frm.f_ids.value = theList;
parent.content.document.frm.target = "control";
parent.content.document.frm.action = "../content/object_order.php";
parent.content.document.frm.submit();
}
</script>
</head>
<body class="contentBODY">
<?php
pageTitle("Objeto","Ordenação");
// botões de ações,
// configure conforme sua necessidade
$button = new Button;
$button->addItem(" Salvar ", "javascript:save()", "content");
$button->addItem(" Fechar ", "../content/object_list.php", "content");
echo $button->writeHTML();
// controle de abas,
// true, se for a aba da página atual,
// false, se for qualquer outra aba,
// configure conforme o exemplo abaixo
$tabs = new Tabs();
$tabs->addItem("Geral", false, "../content/object_edit.php?id=$id");
$tabs->addItem("Associação", false, "../content/object_association.php?id=$id");
$tabs->addItem("Ordenação", true);
$tabs->addItem("Detalhe", false, "../content/object_read.php?id=$id");
$tabs->addItem("Lista 1:N", false, "../content/object_list_1n.php?id=$id", 3);
echo $tabs->writeHTML();
?>
<form name="frm" method="post">
<!-- variável de control -->
<input type="hidden" name="executed" value="s">
<!-- chave primária -->
<input type="hidden" name="f_id" value="<?=$id?>">
<!-- lista de ids -->
<input type="hidden" name="f_ids" value="">
<!-- layout do formulário -->
<?php
// monta lista de registros para serem ordenados (NÃO DEVE SER ALTERADO)
$orderingList = "<select id=\"list\" name=\"list\" size=\"15\" class=\"DataFONT\" style=\"width:100%\">";
while($rs->getrow()){
$orderingList .= "<option value='" . $rs->field("id") . "'>".$rs->field("val") . "</option>";
}
$orderingList .= "</select>";
$table = new Table("", "100%", 1);
// cabeçalho
$table->addColumnHeader("<input type=\"button\" name=\"cima\" value=\"Mover para CIMA\" onClick=\"move(document.frm.list.selectedIndex,-1)\">",false,"100%","R");
$table->addRow();
// caixas de seleção
$table->addData($orderingList, "C");
$table->addRow();
// rodapé
$table->addColumnHeader("<input type=\"button\" name=\"baixo\" value=\"Mover para BAIXO\" onClick=\"move(document.frm.list.selectedIndex,+1)\">",false,"100%","R");
$table->addRow();
echo $table->writeHTML();
?>
</form>
</body>
</html>
<?php
$conn->close();
?>