Index: trunk/prototype/modules/calendar/templates/event_add.ejs
===================================================================
--- trunk/prototype/modules/calendar/templates/event_add.ejs	(revision 5511)
+++ trunk/prototype/modules/calendar/templates/event_add.ejs	(revision 5514)
@@ -1,9 +1,9 @@
-<!--<div title="Criar Evento" class="new-event-win active"> -->
-    <form method="POST" action="<%=((data.event.isOrganizer == 0) && (data.event.id)) ? "schedulable:preview" : "schedulable:detail"%>" class="form-addevent content">
+<div title="Criar Evento" class="div-addevent content">
+    <form method="POST" action="<%=(data.event.acl.organization || data.event.acl.write) ?  "schedulable:detail" : "schedulable:preview"%>" class="form-addevent content">
 
 	<fieldset id="calendar_addevent_details1">
 		<legend class="hidden">Detalhes do evento</legend>
 		<p class="input-group">
-			<input type="text" class="h1" name="summary" <%= (data.event.isOrganizer == 0) ? 'disabled="disabled"' : '' %> value="<%= (data.event.summary) ? data.event.summary : '' %>"/>
+			<input type="text" class="h1" name="summary" <%=(data.event.acl.organization || data.event.acl.write) ? '' : 'disabled="disabled"' %> value="<%= (data.event.summary) ? data.event.summary : '' %>"/>
 			<% if( data.event.id ){ %>
 				<input type="hidden" class="id-event" name="idEvent" value="<%= data.event.id %>"/>
@@ -11,11 +11,11 @@
 		</p>
 		<p class="input-group date-info">
-			<input type="text" class="date start-date" value="<%= (data.event.startDate) ? data.event.startDate : '' %>" <%= (data.event.isOrganizer == 0) ? 'disabled="disabled"' : '' %> name="startDate" />
-			<input type="text" class="time start-time<%= (data.event.allDay) ? ' hidden' : '' %>" value="<%= (data.event.startHour) ? data.event.startHour : '' %>" <%= (data.event.isOrganizer == 0) ? 'disabled="disabled"' : '' %> name="startHour" /> 
+			<input type="text" class="date start-date" value="<%= (data.event.startDate) ? data.event.startDate : '' %>" <%=(data.event.acl.organization || data.event.acl.write) ? '' : 'disabled="disabled"' %> name="startDate" />
+			<input type="text" class="time start-time<%= (data.event.allDay) ? ' hidden' : '' %>" value="<%= (data.event.startHour) ? data.event.startHour : '' %>" <%= (data.event.acl.organization || data.event.acl.write) ? '' : 'disabled="disabled"' %> name="startHour" /> 
 			<span>até</span>
-			<input type="text" class="date end-date" value="<%= (data.event.endDate) ? data.event.endDate : '' %>" <%= (data.event.isOrganizer == 0) ? 'disabled="disabled"' : '' %> name="endDate" />
-			<input type="text" class="time end-time<%= (data.event.allDay) ? ' hidden' : '' %>" value="<%= (data.event.endHour) ? data.event.endHour : '' %>" <%= (data.event.isOrganizer == 0) ? 'disabled="disabled"' : '' %> name="endHour" />
-
-			<a href="#" class="calendar_addevent_details_lnk_timezone">Fuso horário</a>
+			<input type="text" class="date end-date" value="<%= (data.event.endDate) ? data.event.endDate : '' %>" <%= (data.event.acl.organization || data.event.acl.write) ? '' : 'disabled="disabled"' %> name="endDate" />
+			<input type="text" class="time end-time<%= (data.event.allDay) ? ' hidden' : '' %>" value="<%= (data.event.endHour) ? data.event.endHour : '' %>" <%=(data.event.acl.organization || data.event.acl.write) ? '' : 'disabled="disabled"' %> name="endHour" />
+
+			<a href="#" class="calendar_addevent_details_lnk_timezone <%=((!data.event.acl.organization || !data.event.acl.write) && (data.event.id)) ? "hidden" : '' %>">Fuso horário</a>
 <!--			<input type="text" name="timezone" style="display: none;" />-->
 			<select name="timezone" class="hidden calendar-addevent-details-txt-timezone">
@@ -25,6 +25,9 @@
 				<% } %>
 			</select>
-		</p>
-		
+			
+			<a class="button suggestion-hours small <%=(data.event.acl.organization || data.event.acl.write) ? "hidden" : '' %>" href="#">Sugerir horário</a>
+			
+		</p>
+				
 		<div class="ui-widget messages-validation hidden">
 			<div style="padding: 0.2em 0.7em;" class="ui-state-error ui-corner-all"> 
@@ -37,5 +40,5 @@
 		
 		<p class="input-group event-type">
-			<input type="checkbox" name="allDay" value="true" <%= (data.event.isOrganizer == 0) ? 'disabled="disabled"' : '' %> <%= (data.event.allDay) ? 'checked="checked"' : '' %>/>
+			<input type="checkbox" name="allDay" value="true" <%= (data.event.acl.organization || data.event.acl.write) ? '' : 'disabled="disabled"' %> <%= (data.event.allDay) ? 'checked="checked"' : '' %>/>
 			<label for="allDay">Dia inteiro</label>
 <!--
@@ -48,5 +51,5 @@
 <!--		<li><a href="#calendar_addevent_details3">Repetir</a></li>-->
 		<li><a href="#calendar_addevent_details4">Lembretes</a></li>
-<!--		<li><a href="#calendar_addevent_details4" style="color:#BBB;">Anexos</a></li>-->
+		<li><a href="#calendar_addevent_details5">Anexos</a></li>
 		<li><a href="#calendar_addevent_details6">Participantes</a></li>
 	</ul>
@@ -55,10 +58,10 @@
 		<p class="input-group event-info">
 			<label for="calendar_addevent_details_txt_local">Onde</label>
-			<input type="text" name="location" <%= (data.event.isOrganizer == 0) ? 'disabled="disabled"' : '' %> value="<%= (data.event) ? data.event.location : '' %>"/>
+			<input type="text" name="location" <%=(data.event.acl.organization || data.event.acl.write) ? '' : 'disabled="disabled"' %> value="<%= (data.event) ? data.event.location : '' %>"/>
 		</p>
 
 		<p class="input-group">
 			<label for="calendar_addevent_details_txtarea_description" class="for-textarea" >Descrição</label>
-			<textarea name="description" <%= (data.event.isOrganizer == 0) ? 'disabled="disabled"' : '' %> ><%=(data.event) ? data.event.description : '' %></textarea>
+			<textarea name="description" <%= (data.event.acl.organization || data.event.acl.write) ? '' : 'disabled="disabled"' %> ><%=(data.event) ? data.event.description : '' %></textarea>
 		</p>
 
@@ -144,43 +147,57 @@
 	<fieldset id="calendar_addevent_details6" class="tab-level2" title="Participantes">
 	</fieldset>
+	
+	
+	<fieldset class="attachment-list hidden">
+	</fieldset>
     </form>
-    <form action="../../../../upload.php" method="POST">	
-<!--
+    
+
 	<fieldset id="calendar_addevent_details5" class="tab-level2">
-		<span class="input_label">Anexos</span>	
-		  <ul class="attachments-list">
-			<% if (data.event && data.event.attachments) {
-				for (var i=0; i< data.event.attachments.length; i++) {
-			%>
-				<li>
-					<a href="<%= data.event.attachments[i].src %>" >
-						<input type="checkbox" name="attachments['<%= data.event.attachments[i].name %>']" checked="checked" />
-						<label for="calendar_addevent_details_attach_<%=i%>"><%= data.event.attachments[i].name %></label>
-					</a>
-				</li>
-			<%	}
-			   }
-			%>
-
-		  </ul>
-		<span class="button add button-add-attachment">Adicionar anexo</span>
-	
-		<div id="fileupload">
-			<div title="form:upload.php">
-				<div class="fileupload-buttonbar">
-					<label class="fileinput-button">
-						<span>Add files...</span>
-						<input type="file" name="files[]" multiple>
-					</label>
-					<button type="submit" class="start">Start upload</button>
-					<button type="reset"  class="cancel">Cancel upload</button>
-					<button type="button" class="delete">Delete files</button>
-				</div>
-			</div>
-			<div class="fileupload-content">
-				<table class="files"></table>
-				<div class="fileupload-progressbar"></div>
-			</div>
-		</div>
+		<form id="fileupload" action="attachment:detail" method="POST">
+        <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
+        <div class="row fileupload-buttonbar">
+            <div class="button-files-upload">
+                <!-- The fileinput-button span is used to style the file input field as button -->
+                <span class="button btn-success fileinput-button">
+                    <span><i class="icon-plus icon-white"></i> Adicionar</span>
+                    <input type="file" name="files[]" multiple>
+                </span>
+				<%if(data.event.acl.organization || data.event.acl.write){%>
+					<button type="button" class="button btn-danger delete">
+						<i class="icon-trash icon-white"></i> Remover Todos
+					</button>
+				<%}%>
+            </div>
+			<div id="fileupload-progress"></div>
+            <div class="files-list">
+               <ul class="attachments-list">
+			   <%if(data.event && data.event.attachments){
+					for (var i=0; i< data.event.attachments.length; i++) {
+					%>
+						<p class="input-group arquive-info">
+							<label class="lbl-archive-nome">Nome:</label>
+							<span class="archive-nome"><%=data.event.attachments[i].name%></span>
+							
+							<label class="lbl-archive-size">Tamanho:</label>
+							<span class="archive-size"><%=data.event.attachments[i].size%> kb</span>
+							<a href="../prototype/getArchive.php?attachment=<%=data.event.attachments[i].id%>" class="button tiny upload downlaod-archive">Download</a>
+							<%if(data.event.acl.organization || data.event.acl.write){%>
+								<span class="button close tiny upload delete-upload" title="Deletar">Deletar</span>
+							<%}%>
+							<input type="hidden" name="fileId[]" value="<%=data.event.attachments[i].id%>"/>
+						</p>
+					<%}
+				}%>
+			   
+			   
+			   </ul>
+            </div>
+        </div>
+        <br>
+        
+    </form>
+
+	</fieldset>
 
 	</fieldset>
@@ -194,10 +211,11 @@
     <div class="menu-container footer-container menu-addevent">
 	    <% if (data.event.id) { %>
-		<a class="button export" href="#">Exportar</a>
-	    <a class="button delete" href="#">Excluir</a>
+			<a class="button export" href="#">Exportar</a>
+			<a class="button delete" href="#">Excluir</a>
 	    <% } %>
 		<a class="button cancel" href="#">Cancelar</a>
 	    <a class="button save" href="#">Salvar</a>
     </div>
-<!--</div>-->
+</div>
 <!--<script src="application.js"></script>-->
+<!--<script src="application.js"></script>-->
