Index: trunk/prototype/config/schedulableToAttachment.ini
===================================================================
--- trunk/prototype/config/schedulableToAttachment.ini	(revision 5715)
+++ trunk/prototype/config/schedulableToAttachment.ini	(revision 6369)
@@ -5,4 +5,10 @@
 schedulable = schedulable.attachments
 
+[before.delete]
+decodeSchedulablettachment = modules/calendar/interceptors/DBMapping.php
+
+[after.delete]
+deleteAttachmentDependences = modules/calendar/interceptors/DBMapping.php
+
 [PostgreSQL.mapping]
 id = id
Index: trunk/prototype/config/attachment.ini
===================================================================
--- trunk/prototype/config/attachment.ini	(revision 5715)
+++ trunk/prototype/config/attachment.ini	(revision 6369)
@@ -4,7 +4,4 @@
 [before.create]
 encodeCreateAttachment = modules/calendar/interceptors/DBMapping.php
-
-[after.delete]
-deleteAttachmentDependences = modules/calendar/interceptors/DBMapping.php
 
 [PostgreSQL.mapping]
Index: trunk/prototype/modules/calendar/interceptors/DBMapping.php
===================================================================
--- trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 6345)
+++ trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 6369)
@@ -813,8 +813,13 @@
     }
 
+    public function decodeSchedulablettachment(&$uri, &$params, &$criteria, $original) {
+	if (isset($original['URI']['id'])){
+            $schedulableAttachment = Controller::read(array('concept' => 'schedulableToAttachment'), false, array('filter' => array( '=', 'attachment' , $original['URI']['id'] )));
+            $uri['id'] = $schedulableAttachment[0]['id'];
+        }
+    }
+
     public function deleteAttachmentDependences(&$uri, &$params, &$criteria, $original) {
-
-	if (isset($original['URI']['id']))
-	    Controller::delete(array('concept' => 'schedulableToAttachment', null, array('filter' => array('=', 'attachment', $original['URI']['id']))));
+        Controller::delete(array('concept' => 'attachment', 'id' => $original['URI']['id']));
     }
 
Index: trunk/prototype/modules/calendar/css/layout.css
===================================================================
--- trunk/prototype/modules/calendar/css/layout.css	(revision 6319)
+++ trunk/prototype/modules/calendar/css/layout.css	(revision 6369)
@@ -705,5 +705,9 @@
 
 .button.add.button-add-attachment{margin: -9px 0 0 8px;}
-.button.upload{margin-bottom: 4px;}
+.button.btn-danger.delete{margin: 0 0 0 0;}
+
+.button.upload{top: 4px;}
+.button.upload.edit{top: -2px;}
+
 div.fileupload-buttonbar{padding: 0.2em 0.5em }
 .archive-error{color: #F00;}
@@ -711,4 +715,5 @@
 .progress.in-progress{width: 100px; height: 12px;}
 
+span.status-upload{margin: -4px 0px 0px 0px;}
 
 .lbl-archive-nome, .lbl-archive-size{font-weight: bold !important;}
@@ -1162,4 +1167,6 @@
 .ui-tabs .ui-tabs-panel { padding: 0; margin-top: 10px;}
 
+.ui-tabs #calendar_addevent_details5.ui-tabs-panel{margin-top: -3px; min-height: 323px;}
+
 .ui-tabs .ui-tabs-nav li .ui-icon-close {
     float: right;
Index: trunk/prototype/modules/calendar/js/helpers.js
===================================================================
--- trunk/prototype/modules/calendar/js/helpers.js	(revision 6359)
+++ trunk/prototype/modules/calendar/js/helpers.js	(revision 6369)
@@ -1331,16 +1331,21 @@
     text: 'Excluir'
 }).click(function () {
-    $('.row.fileupload-buttonbar .attachments-list p').remove();
-				
-    var ids = [];
-    $.each($('.attachment-list input'), function (i, input) {
-	ids.push(input.value);
-    });
-    if(ids.length > 0){
-	DataLayer.remove('attachment', {
-	    filter: ['IN', 'id', ids]
-	    });
-	$('.attachment-list input').remove();
-    }
+    $.Zebra_Dialog('Tem certeza que deseja excluir todos anexos?', {
+	'type':     'question',
+	'overlay_opacity': '0.5',
+	'buttons':  ['Sim', 'Não'],
+	'onClose':  function(clicked) {
+	    if(clicked == 'Sim'){
+		
+                var ids = [];
+                $.each($('.attachment-list input'), function (i, input) {
+                     DataLayer.remove('schedulableToAttachment', {
+                        filter: ['=', 'id', ''+input.value]
+                        });
+                });
+                $('.attachment-list input').remove();
+                $('.row.fileupload-buttonbar .attachments-list p').remove();
+            }
+        }});
 }).end()
 .filter('.close').button({
@@ -1350,5 +1355,5 @@
     text: false
 }).click(function () {
-    DataLayer.remove('attachment', $(this).parents('p').find('input[name="fileId[]"]').val());
+    DataLayer.remove('schedulableToAttachment', $(this).parents('p').find('input[name="fileId[]"]').val());
     $(this).parents('p').remove();
 }).end()
Index: trunk/prototype/modules/calendar/templates/event_add.ejs
===================================================================
--- trunk/prototype/modules/calendar/templates/event_add.ejs	(revision 6331)
+++ trunk/prototype/modules/calendar/templates/event_add.ejs	(revision 6369)
@@ -161,4 +161,9 @@
 	
 	<fieldset class="attachment-list hidden">
+             <%if(data.event && data.event.attachments){
+                for (var i=0; i< data.event.attachments.length; i++) {%>
+                    <input type="hidden" name="fileId[]" value="<%=data.event.attachments[i].id%>"/>
+                <%}
+            }%>
 	</fieldset>
     </form>
@@ -166,5 +171,5 @@
 <div class="overflow_add_calender">
 	<fieldset id="calendar_addevent_details5" class="tab-level2">
-		<form id="fileupload" action="attachment:detail" method="POST">
+        <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">
@@ -183,5 +188,5 @@
 				<%}%>
             </div>
-			<div id="fileupload-progress"></div>
+            <div id="fileupload-progress"></div>
             <div class="files-list">
                <ul class="attachments-list">
@@ -197,5 +202,5 @@
 							<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>
+								<span class="button close tiny upload edit delete-upload" title="Deletar">Deletar</span>
 							<%}%>
 							<input type="hidden" name="fileId[]" value="<%=data.event.attachments[i].id%>"/>
