

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Create Entry</title>
        <nav:resources override="true"/>
        <resource:dateChooser />
    </head>
    <body>
        <div class="nav">
            <h1>Create Entry</h1>
        </div>
        <div class="body">
            <g:render template="/shared/messages" />
            <g:hasErrors bean="${entryInstance}">
            <div class="errors">
                <g:renderErrors bean="${entryInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form action="save" method="post" >
                <g:hiddenField name="task.id" value="${entryInstance.task.id}" />
                <g:hiddenField name="entryType.id" value="${entryInstance.entryType.id}" />
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="task">Task:</label>
                                </td>
                                <td valign="top" class="name">
                                    <g:link controller="taskDetailed" action="show" id="${entryInstance.task.id}" >
                                        ${entryInstance?.task.encodeAsHTML()}
                                    </g:link>
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="comment">${entryInstance?.entryType.encodeAsHTML()}:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:entryInstance,field:'comment','errors')}">
                                    <textarea rows="5" cols="40" name="comment">${fieldValue(bean:entryInstance, field:'comment')}</textarea>
                                    <g:if test="${entryInstance?.entryType?.id == 1}">
                                        <g:helpBalloon code="entry.comment.fault" />
                                    </g:if>
                                    <g:elseif test="${entryInstance?.entryType?.id == 2}">
                                        <g:helpBalloon code="entry.comment.cause" />
                                    </g:elseif>
                                    <g:elseif test="${entryInstance?.entryType?.id == 3}">
                                        <g:helpBalloon code="entry.comment.work.done" />
                                    </g:elseif>
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="dateDone">Date Done:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:entryInstance,field:'dateDone','errors')}">
                                    <richui:dateChooser name="dateDone" format="dd-MM-yyyy" value="${entryInstance.dateDone}" />
                                    <g:helpBalloon code="entry.date.done" />
                                </td>
                            </tr>

                            <g:if test="${entryInstance?.entryType?.id == 1}">
                                <tr class="prop">
                                    <td valign="top" class="name">
                                        <label for="productionReference">Production:</label>
                                    </td>
                                    <td valign="top" class="value ${hasErrors(bean:entryInstance,field:'productionReference','errors')}">
                                        <g:select optionKey="id"
                                                            from="${ProductionReference.findAllByIsActive(true)}"
                                                            name="productionReference.id"
                                                            value="${entryInstance.productionReference?.id}"
                                                            noSelection="['null':'--None--']">
                                        </g:select>
                                        <g:helpBalloon code="entry.productionReference.fault" />
                                    </td>
                                </tr>
                            </g:if>

                            <g:if test="${entryInstance?.entryType?.id != 2}">
                                <tr class="prop">
                                    <td valign="top" class="name">
                                        <label for="durationHour">Duration:</label>
                                    </td>

                                    <td valign="top" class="value">
                                        <input class="time ${hasErrors(bean:entryInstance,field:'durationHour','errors')}" 
                                            type="text" id="durationHour" name="durationHour" 
                                            value="${fieldValue(bean:entryInstance,field:'durationHour')}" />
                                        :
                                        <input class="time ${hasErrors(bean:entryInstance,field:'durationMinute','errors')}" 
                                            type="text" id="durationMinute" name="durationMinute" 
                                            value="${fieldValue(bean:entryInstance,field:'durationMinute')}" />
                                        <g:helpBalloon code="entry.duration" />
                                    </td>
                                </tr>
                            </g:if>
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><input class="save" type="submit" value="Create" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
