Subversion Repositories bacoAlunos

Rev

Rev 1306 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@ page import="jomm.dao.utils.HibernateUtils" %>
<%@ page import="pt.estgp.estgweb.domain.dao.impl.DigitalDeliveryCategoryDaoImpl" %>
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %>
<%@ page import="pt.estgp.estgweb.domain.DigitalDeliveryCategory" %>
<%@ page import="java.util.List" %>
<%@ page import="pt.estgp.estgweb.domain.DigitalDeliveryCategoryImpl" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>

<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
<%--
  Created by IntelliJ IDEA.
  User: jorgemachado
  Date: 04/02/14
  Time: 16:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


<script language="JavaScript">
    function openChildCategory(categoryId,absoluteCategoryId)
    {
        if($("[id*=category" + absoluteCategoryId + "_]").length > 0)
        {
            $("[id*=category" + absoluteCategoryId + "_]").remove();
        }
        else
        {
            $.post("/baco/user/digitalDelivery/loadChilds.jsp?parentId="+categoryId, function() {
            })
                    .done(
                    function(data) {
                        // data = iconv("UTF-8","ISO-8859-1",data);

                        $("#category"+absoluteCategoryId).after(data);

                    }
            );
        }

    }

    function closeChildCategory(absoluteCategoryId)
    {
       $("[id*=category" + absoluteCategoryId + "_]").remove();

    }


</script>

<%

    HibernateUtils.getCurrentSession().beginTransaction();

    List<DigitalDeliveryCategory> childs = DaoFactory.getDigitalDeliveryCategoryDaoImpl().loadChilds(null);
    request.setAttribute("childs",childs);
%>
<table>
    <tr>
        <th>Categoria</th>
        <th>Descrição</th>
        <th>Mover Entregas Para Outra Categoria</th>
        <th>Operações</th>
    </tr>
    <logic:iterate id="child" name="childs" type="pt.estgp.estgweb.domain.DigitalDeliveryCategory">
        <tr id="category${child.absoluteId}">
            <td>
                <div>
                    <img src="<%=request.getContextPath()%>/imgs/folder.gif"/> <a href="javascript:openChildCategory('${child.id}','${child.absoluteId}')"> ${child.name}</a>
                </div>
            </td>
            <td>${child.description}</td>
            <td>
                <select name="categoryParentId">
                    <option value="">--</option>
                    <%
                        List<DigitalDeliveryCategory> categories = DaoFactory.getDigitalDeliveryCategoryDaoImpl().loadAllOrderedParent(null);
                        for(DigitalDeliveryCategory cat : categories)
                        {
                    %>
                    <option value="<%=cat.getId()%>"><%=((DigitalDeliveryCategoryImpl)cat).getAbsoluteName()%></option>
                    <%
                        }
                    %>
                </select>
            </td>
            <td>
                Editar
            </td>
        </tr>
    </logic:iterate>
</table>

<%

    HibernateUtils.getCurrentSession().getTransaction().commit();

%>