Index: /sandbox/2.4.2-expresso1/expressoCalendar/setup/tables_current.inc.php
===================================================================
--- /sandbox/2.4.2-expresso1/expressoCalendar/setup/tables_current.inc.php	(revision 6876)
+++ /sandbox/2.4.2-expresso1/expressoCalendar/setup/tables_current.inc.php	(revision 6945)
@@ -101,4 +101,17 @@
             'uc' => array()
                 ),
+
+       'calendar_task_to_activity_object' => array(
+            'fd' => array(
+                'id' => array( 'type' => 'auto', 'nullable' => False),
+                'calendar_object_activity_id' => array(  'type' => 'int', 'precision' => '8', 'nullable' => False),
+                'calendar_object_task_id' => array(  'type' => 'int', 'precision' => '8', 'nullable' => False),
+                'owner' => array(  'type' => 'int', 'precision' => '8', 'nullable' => False),
+            ),
+            'pk' => array('id'),
+            'fk' => array(),
+            'ix' => array(),
+            'uc' => array()
+        ),
             
             
Index: /sandbox/2.4.2-expresso1/expressoCalendar/setup/tables_update.inc.php
===================================================================
--- /sandbox/2.4.2-expresso1/expressoCalendar/setup/tables_update.inc.php	(revision 6876)
+++ /sandbox/2.4.2-expresso1/expressoCalendar/setup/tables_update.inc.php	(revision 6945)
@@ -135,4 +135,6 @@
         $oProc->query("INSERT INTO calendar_object_type(id, name) VALUES ('2', 'TODO');");
 
+        $oProc->query("CREATE TABLE calendar_task_to_activity_object(id serial not null, calendar_object_activity_id integer not null, calendar_object_task_id integer not null, owner integer not null);");
+
         $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.008';
         return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
Index: /sandbox/2.4.2-expresso1/expressoCalendar/setup/setup.inc.php
===================================================================
--- /sandbox/2.4.2-expresso1/expressoCalendar/setup/setup.inc.php	(revision 6797)
+++ /sandbox/2.4.2-expresso1/expressoCalendar/setup/setup.inc.php	(revision 6945)
@@ -33,5 +33,6 @@
 	$setup_info['expressoCalendar']['tables'][]		=  'calendar_permission';
 	$setup_info['expressoCalendar']['tables'][]		=  'module_preference';
-	$setup_info['expressoCalendar']['tables'][]		=  'calendar_repeat_ranges';
+    $setup_info['expressoCalendar']['tables'][]     =  'calendar_repeat_ranges';
+	$setup_info['expressoCalendar']['tables'][]		=  'calendar_task_to_activity_object';
 
 	$setup_info['expressoCalendar']['enable']		= 1;
Index: /sandbox/2.4.2-expresso1/prototype/config/schedulable.ini
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/config/schedulable.ini	(revision 6876)
+++ /sandbox/2.4.2-expresso1/prototype/config/schedulable.ini	(revision 6945)
@@ -5,4 +5,5 @@
 participants = participant.schedulable
 attachments = schedulableToAttachment.schedulable
+taskToActivity = taskToActivity.activity
 	
 [model.hasOne]
@@ -14,7 +15,9 @@
 [after.create]
 createCalendarToSchedulable = modules/calendar/interceptors/DBMapping.php
+;createTasksToActivity = modules/calendar/interceptors/DBMapping.php
 
 [before.find]
 findSchedulable = modules/calendar/interceptors/DBMapping.php
+findTask = modules/calendar/interceptors/DBMapping.php
 
 [after.find]
@@ -25,5 +28,4 @@
 encodeUpdateSchedulable = modules/calendar/interceptors/DBMapping.php
 updateEvent = modules/calendar/interceptors/Notifications.php
-
 
 [after.update]
Index: /sandbox/2.4.2-expresso1/prototype/config/taskToActivity.ini
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/config/taskToActivity.ini	(revision 6945)
+++ /sandbox/2.4.2-expresso1/prototype/config/taskToActivity.ini	(revision 6945)
@@ -0,0 +1,17 @@
+service = PostgreSQL
+PostgreSQL.concept = calendar_task_to_activity_object
+
+[model.depends]
+activity = schedulable.taskToActivity
+
+;[before.create]
+;decodeCreateTaskToActivity = modules/calendar/interceptors/DBMapping.php
+
+[after.find]
+deepnessFindTask = modules/calendar/interceptors/DBMapping.php
+
+[PostgreSQL.mapping]
+id = id
+activity = calendar_object_activity_id
+task = calendar_object_task_id
+owner = owner
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/interceptors/DBMapping.php
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/interceptors/DBMapping.php	(revision 6891)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/interceptors/DBMapping.php	(revision 6945)
@@ -150,5 +150,6 @@
 		.'calendar FROM calendar_to_calendar_object , calendar_object '
 		.'WHERE ( calendar_to_calendar_object.calendar_id IN (\'' . implode('\',\'', $criteria['filter'][2][2]) . '\')) '
-		.'AND calendar_to_calendar_object.calendar_object_id = calendar_object.id ';	
+		.'AND calendar_to_calendar_object.calendar_object_id = calendar_object.id '
+        .'AND calendar_object.id NOT IN(select calendar_object_task_id from calendar_task_to_activity_object where owner = \'' . Config::me('uidNumber') . '\') ';	
 	    
 	    if(isset($criteria['searchEvent']) && $criteria['searchEvent']){
@@ -180,4 +181,47 @@
 		$params = array_merge($params, $occ);		
 	    }
+	    $params = self::deepnessFindEvent($uri, $params, $criteria, $original);
+	    return false;
+	}
+    }
+
+    public function findTask(&$uri, &$params, &$criteria, $original) {
+
+        ob_start();
+        print_r('$uri' . "\n");
+        print_r($uri);
+        print_r('$params' . "\n");
+        print_r($params);
+        print_r('$criteria' . "\n");
+        print_r($criteria);
+        print_r('$original' . "\n");
+        print_r($original);
+        $output = ob_get_clean();
+        file_put_contents( "/tmp/acoutinho.log",  $output , FILE_APPEND);
+	if (isset($criteria['filterTasks']) && $criteria['filterTasks']) {
+
+	    $sql = ' SELECT calendar_object.id as id ,calendar_object.cal_uid as "uid", calendar_object.type_id as "type", '
+	    .'calendar_object.dtstart as "startTime", calendar_object.summary as "summary", '
+	    .'calendar_object.description as "description", calendar_object.dtend as "endTime" , '
+	    .'calendar_object.priority as "priority", calendar_object.due as "due", '
+	    .'calendar_object.percentage as "percentage", calendar_object.status as "status", '
+	    .'calendar_object.location as "location", calendar_object.allday as "allDay", '
+	    .'calendar_object.transp as "transparent", calendar_object.class_id as "class", '
+	    .'calendar_object.repeat as "repeat", calendar_object.range_start as "rangeStart", '
+	    .'calendar_object.range_end as "rangeEnd", calendar_object.last_update as "lastUpdate", '
+	    .'calendar_object.dtstamp as "dtstamp", calendar_object.sequence as "sequence", '
+	    .'calendar_object.tzid as "timezone" ,calendar_to_calendar_object.calendar_id as '
+	    .'calendar FROM calendar_to_calendar_object , calendar_object '
+	    .'WHERE ( calendar_to_calendar_object.calendar_id IN (\'' . implode('\',\'', $criteria['filter'][3][2]) . '\')) '
+	    .'AND calendar_to_calendar_object.calendar_object_id = calendar_object.id '
+        .'AND calendar_to_calendar_object.calendar_object_id NOT IN (select calendar_object_activity_id from calendar_task_to_activity_object where owner =  \'' . Config::me("uidNumber") . '\' ) '    
+        .'AND calendar_to_calendar_object.calendar_object_id NOT IN (select calendar_object_task_id from calendar_task_to_activity_object where owner =  \'' . Config::me("uidNumber") . '\' ) ';    
+
+        if(isset($criteria['filter'][4]))
+            $sql .= 'AND (((upper("summary") like upper(\'%'.$criteria['filter'][4][1][2].'%\') OR upper("description") like upper(\'%'.$criteria['filter'][4][1][2].'%\'))))';
+
+	    $sql .= 'AND (range_start >= \'' . $criteria['filter'][2][2] . '\' AND type_id <= \'' .  $criteria['filter'][1][2] . '\')';
+
+	    $params = Controller::service('PostgreSQL')->execResultSql($sql);
 	    $params = self::deepnessFindEvent($uri, $params, $criteria, $original);
 	    return false;
@@ -495,4 +539,28 @@
     }
 
+    //TODO: Remover apos suporte a ManytoMany na api 
+    public function createTasksToActivity(&$uri, &$result, &$criteria, $original) {
+
+        ob_start();
+        print_r('$uri' . "\n");
+        print_r($uri);
+        print_r('$params' . "\n");
+        print_r($params);
+        print_r('$criteria' . "\n");
+        print_r($criteria);
+        print_r('$original' . "\n");
+        print_r($original);
+        $output = ob_get_clean();
+        file_put_contents( "/tmp/acoutinho.log",  $output , FILE_APPEND);
+
+        if(isset($original['properties']['taskToActivity']) && $original['properties']['taskToActivity']){
+
+            foreach($original['properties']['taskToActivity'] as $relational)
+
+                Controller::create(array('concept' => 'taskToActivity'), array('task' => $relational['task'], 'owner' => $relational['owner'], 'activity' => $result['id']));
+
+        }
+    }
+
     public function createCreateSchedulableToAttachment(&$uri, &$params, &$criteria, $original) {
 	if (array_key_exists('attachments', $original['properties']))
@@ -541,4 +609,16 @@
 
     //TODO: Remover apos suporte a deepness na api 
+    public function deepnessFindTask(&$uri, &$result, &$criteria, $original) {
+        if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 
+           foreach($result as &$value)
+                $value['task'] = Controller::read(array('concept' => 'schedulable', 'id' => $value['task']));
+           
+        
+        return $result;
+    }
+
+
+
+    //TODO: Remover apos suporte a deepness na api 
     public function deepnessFindEvent(&$uri, &$result, &$criteria, $original) {
 	if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) {
@@ -572,4 +652,13 @@
 
 		$result[$i]['DayLigth'] = $DayLigth;
+
+        if(((int)$v['type']) == 2){
+
+            $taskToActivity = Controller::find(array('concept' => 'taskToActivity'), false, array('filter' => array('AND', array('=', 'activity', $v['id']), array('=','owner', Config::me('uidNumber'))) , 'deepness' => 2));
+
+            if($taskToActivity)
+                $result[$i]['taskToActivity'] = $taskToActivity;
+
+        }
 
 		if (isset($v['id'])) {
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/css/layout.css
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/css/layout.css	(revision 6881)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/css/layout.css	(revision 6945)
@@ -264,10 +264,13 @@
 #calendar_addactivity_details8 .block-attendee-list, #calendar_addactivity_details8 .block-activity-list { width:430px; margin-right: 5px; }
 
-.block-attendee-list, .block-activity-list, .block-add-activity { float:left;}
+.block-activity-list, .block-activity-group-select{width: 405px}
+.block-add-activity.search{width: 298px}
+
+.block-attendee-list, .block-activity-list, .block-add-activity, .block-activity-group-select { float:left;}
 .block-attendee-list { width:400px; margin-right: 5px; }
 .new-event-win .block-add-attendee { width:260px; margin-right: 5px; }
 .new-task-win .block-add-attendee { width:335px; margin-right: 5px; }
-.block-attendee-list dd, .block-add-attendee dd, .block-activity-list dd, .block-add-activity dd { border: 1px solid #BFBFBF; }
-.block-attendee-list dt, .block-add-attendee dt,.block-activity-list dt, .block-add-activity dt { background-color:#FFF; margin: 5px 0 -6px 5px; font-weight: bold; display: table;  position: relative; display: table;}
+.block-attendee-list dd, .block-add-attendee dd, .block-activity-list dd, .block-add-activity dd, .block-activity-group-select dd { border: 1px solid #BFBFBF; }
+.block-attendee-list dt, .block-add-attendee dt,.block-activity-list dt, .block-add-activity dt, .block-activity-group-select dt { background-color:#FFF; margin: 5px 0 -6px 5px; font-weight: bold; display: table;  position: relative; display: table;}
 .block-attendee-list dd.attendee-list { height: 196px; }
 .block-attendee-list dd.attendee-list ul, .block-activity-list dd.task-activity-list ul { max-height: 186px; overflow: auto; margin-top: 10px;}
@@ -276,5 +279,22 @@
 .block-attendee-list dd.attendee-list-brief, .block-activity-list dd.activity-list-brief { border:none !important; margin: 5px 0; color:#777; }
 #calendar_addactivity_details8 .block-attendee-list, #calendar_addactivity_details8 .block-activity-list { width:430px; margin-right: 5px; }
-.block-activity-list dd.task-activity-list { height: 292px; }
+
+/* Pesquisa de tarefas */
+.block-activity-group-select dd.task-activity-list { height: 181px; }
+.block-activity-group-select dd.group-select { height: 40px; }
+
+fieldset.block-add-activity ul.search-result-list li{ width: 9999px; }
+fieldset.block-add-activity ul.search-result-list{width: 290px;}
+
+fieldset.block-add-activity fieldset.add-activity-search{max-width: 320px; width: 282px}
+fieldset.block-add-activity fieldset.add-activity-search input{max-width: 260px; width: 245px;}
+
+.block-activity-group-select dd.group-select select{margin: 12px 8px;}
+.block-activity-group-select dd.task-activity-list{padding: 10px 5px}
+
+/** Pesquisa de tarefas **/
+
+select.group-addactivity-details-txt-timezone{width: 175px;}
+
 
 dl.block-add-attendee, dl.block-add-activity {
@@ -283,5 +303,11 @@
 }
 
-.new-event-win dl.block-add-attendee dd.add-attendee, dl.block-add-activity dd.add-activity {
+dl.block-add-activity dd.add-activity{
+    width: 295px;
+    min-height: 254px;
+    display: block;
+}
+
+.new-event-win dl.block-add-attendee dd.add-attendee{
 	width: 260px;
 	min-height: 260px;
@@ -294,4 +320,7 @@
 	display: block;
 }
+
+.new-activity-win dl.block-activity-group-select li.task{overflow: hidden; position: relative;}
+.new-activity-win dl.block-activity-group-select ul{overflow: hidden;}
 
 #calendar_addactivity_details8 dl.block-add-attendee dd.add-attendee ,#calendar_addactivity_details8 dl.block-add-activity dd.add-activity {
@@ -322,5 +351,5 @@
 */
 
-.attendee-options{ position: absolute; top: 0; left: 287px; background-color: white; z-index: 100; width: 90px; background-color: #FFF;	padding: 0 20px 0 3px; text-align: right;}
+.attendee-options, .activity-options{ position: absolute; top: 0; left: 287px; background-color: white; z-index: 100; width: 90px; background-color: #FFF;	padding: 0 20px 0 3px; text-align: right;}
 .attendees-list .not-attendee, .activitys-list .not-activity { height:16px; }
 
@@ -383,4 +412,7 @@
 	min-width: 99999px;
 }
+
+ ul.task-activity-list li label.name{display: table-cell;}
+
 dd.task-activity-list ul.task-activity-list li label[title=''] { display:none }
 /*
@@ -754,5 +786,5 @@
 
 .button.add.button-add-attachment{margin: -9px 0 0 8px;}
-.button.btn-danger.delete{margin: 0 0 0 0;}
+.button.btn-danger.delete{margin: 0 0 0 0; min-width: 143px;}
 
 .button.upload{top: 4px;}
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/css/style.css
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/css/style.css	(revision 6881)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/css/style.css	(revision 6945)
@@ -53,5 +53,5 @@
 
 .new-activity-win fieldset { border: none; margin: 0; padding: 0; }
-.new-activity-win fieldset.tab-level2 { padding: 0px 5px; min-height: 310px; max-height: 310px; overflow: auto;}
+.new-activity-win fieldset.tab-level2 { padding: 0px 5px; min-height: 250px; max-height: 310px; overflow: auto;}
 
 .new-activity-win .overflow_add_calender { overflow: auto; max-height: 320px; }
@@ -102,8 +102,14 @@
 .new-event-win div.div-addevent{ padding: 0; width: 700px; border: 0;}
 .new-task-win div.div-addtask { padding: 0; width: 774px; border: 0;}
-.new-event-win form.form-addevent, .new-task-win form.form-addtask { padding: 9px; }
-
-.new-activity-win div.div-addevent { padding: 0; width: 700px; border: 0;}
-.new-activity-win form.form-addevent { padding: 9px; }
+
+.new-event-win form.form-addevent, 
+.new-task-win form.form-addtask,
+.new-activity-win form.form-addactivity { padding: 9px; }
+
+.new-activity-win input.time{width: 45px;}
+.new-activity-win input.date{width: 80px;}
+
+.new-activity-win div.div-addactivity { padding: 0; width: 734px; border: 0;}
+.new-activity-win form.form-addactivity { padding: 9px; }
 
 .expresso-calendar-container input[type="text"] { height: 18px; }
@@ -590,20 +596,17 @@
 .div-addactivity #calendar_addactivity_details1 .subitem .done { width: 45px;}
 
-
-.div-addactivity  #calendar_addactivity_details6 .parent {width: 680px; min-height: 268px; float: left;}
-.div-addactivity  #calendar_addactivity_details6 .parent .child-top {width: 690px; height: 30px; background: #E8F4FD; border-left: 1px solid #CCC; border-right: 1px solid #CCC; border-bottom: 1px solid #CCC;}
-.div-addactivity  #calendar_addactivity_details6 .parent .child-bottom {width: 690px; height: 220px; overflow: auto;  float: left; border-left: 1px solid #CCC; border-right: 1px solid #CCC; border-bottom: 1px solid #CCC;}
-.div-addactivity  #calendar_addactivity_details6 .parent .child-bottom .child-bottom-each { height: 30px; }
-.div-addactivity  #calendar_addactivity_details6 .parent .child-bottom .child-bottom-each:hover { background: #FFF2F2; cursor: pointer;}
-
-
-.div-addactivity  #calendar_addactivity_details6 .parent .child-bottom .child-bottom-each .date-hour { width: 30%; float: left; height: 30px}
-.div-addactivity  #calendar_addactivity_details6 .parent .child-bottom .child-bottom-each .date-hour span { margin: 8px; float: left; }
-.div-addactivity  #calendar_addactivity_details6 .parent .child-bottom .child-bottom-each .organization{ width: 69%; float: left;  height: 30px; border-left: 1px solid #CCC; }
-.div-addactivity  #calendar_addactivity_details6 .parent .child-bottom .child-bottom-each .organization span{ margin: 8px; float: left; }
-
-
-.div-addactivity  #calendar_addactivity_details6 .parent .child-top .date-hour { width: 29%; float: left; background: #E8F4FD; height: 30px; }
-.div-addactivity  #calendar_addactivity_details6 .parent .child-top .date-hour span{ margin: 8px; float: left; font-weight: bold; color: #2E6E9E; }
-.div-addactivity  #calendar_addactivity_details6 .parent .child-top .organization { width: 70%; float: left; background: #E8F4FD; height: 30px; border-left: 1px solid #CCC; font-weight: bold; color: #2E6E9E; }
-.div-addactivity  #calendar_addactivity_details6 .parent .child-top .organization span{margin: 8px; float: left; }
+.div-addactivity  #group_addactivity_details6 .parent {width: 680px; min-height: 268px; float: left;}
+.div-addactivity  #group_addactivity_details6 .parent .child-top {width: 690px; height: 30px; background: #E8F4FD; border-left: 1px solid #CCC; border-right: 1px solid #CCC; border-bottom: 1px solid #CCC;}
+.div-addactivity  #group_addactivity_details6 .parent .child-bottom {width: 690px; height: 220px; overflow: auto;  float: left; border-left: 1px solid #CCC; border-right: 1px solid #CCC; border-bottom: 1px solid #CCC;}
+.div-addactivity  #group_addactivity_details6 .parent .child-bottom .child-bottom-each { height: 30px; }
+.div-addactivity  #group_addactivity_details6 .parent .child-bottom .child-bottom-each:hover { background: #FFF2F2; cursor: pointer;}
+
+.div-addactivity  #group_addactivity_details6 .parent .child-bottom .child-bottom-each .date-hour { width: 30%; float: left; height: 30px}
+.div-addactivity  #group_addactivity_details6 .parent .child-bottom .child-bottom-each .date-hour span { margin: 8px; float: left; }
+.div-addactivity  #group_addactivity_details6 .parent .child-bottom .child-bottom-each .organization{ width: 69%; float: left;  height: 30px; border-left: 1px solid #CCC; }
+.div-addactivity  #group_addactivity_details6 .parent .child-bottom .child-bottom-each .organization span{ margin: 8px; float: left; }
+
+.div-addactivity  #group_addactivity_details6 .parent .child-top .date-hour { width: 29%; float: left; background: #E8F4FD; height: 30px; }
+.div-addactivity  #group_addactivity_details6 .parent .child-top .date-hour span{ margin: 8px; float: left; font-weight: bold; color: #2E6E9E; }
+.div-addactivity  #group_addactivity_details6 .parent .child-top .organization { width: 70%; float: left; background: #E8F4FD; height: 30px; border-left: 1px solid #CCC; font-weight: bold; color: #2E6E9E; }
+.div-addactivity  #group_addactivity_details6 .parent .child-top .organization span{margin: 8px; float: left; }
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/calendar.codecs.js
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/calendar.codecs.js	(revision 6903)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/calendar.codecs.js	(revision 6945)
@@ -799,5 +799,214 @@
         };
     });
-
+    return (notArray ? res[0] : res);
+    }
+});
+
+DataLayer.codec( "schedulable", "taskSearch", {
+
+    decoder: function( evtObj ){
+
+    },
+
+    encoder: function( evtObj ){
+
+    var notArray = false;
+      
+    if( notArray = $.type(evtObj) !== "array" )
+        evtObj = [ evtObj ];
+
+    var res = $.map(evtObj, function( objEvent ){           
+            
+        if(!(typeof(objEvent) == 'object'))
+            return (null);
+
+        return {
+            id: objEvent.id,
+            description: !!objEvent.summary ? objEvent.summary : objEvent.description,
+            startDate: new Date( parseInt(objEvent.startTime) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ),
+            startHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.startTime)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat),
+            endDate: new Date( parseInt(objEvent.endTime) - (!!parseInt(objEvent.allDay) ? 86400000 : 0)  ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ),
+            endHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date(parseInt(objEvent.endTime)),  objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'endTime'), User.preferences.hourFormat),
+            dueDate: (!objEvent.due || objEvent.due == '' || objEvent.due == '0') ? '' : new Date( parseInt(objEvent.due) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ),
+            dueTime: (!objEvent.due || objEvent.due == '' || objEvent.due == '0') ? '' : dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.due)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat),
+            allDay: !!parseInt( objEvent.allDay ),
+            percentage: (objEvent.percentage) ? objEvent.percentage : '0'
+        }
+    });
+    return (notArray ? res[0] : res);
+    }
+});
+
+DataLayer.codec( "schedulable", "activity", {
+
+    decoder: function( evtObj ){
+    Encoder.EncodeType = "entity";
+    
+    if( notArray = $.type(evtObj) !== "array" )
+        evtObj = [ evtObj ];
+
+    var pref = User.preferences;
+
+    var res = $.map(evtObj, function( form ){
+    
+        var tzId =  form.timezone || Calendar.signatureOf[form.group].calendar.timezone || User.preferences.timezone,
+
+        formatString = pref.dateFormat + " " + pref.hourFormat;
+
+	var decodeParticipants = function(attend){
+	    return [DataLayer.merge(
+		{  
+		    user: User.me.id, 
+		    isOrganizer: 1,
+		    acl: 'row',
+		    alarms: $.map( form.alarmTime || [], function( alarmTime, i ){
+			if( alarmTime === "" )
+			    return( null );
+			return !!form.alarmId[i] ? {
+			    type: form.alarmType[i], 
+			    unit: form.alarmUnit[i], 
+			    time: form.alarmTime[i], 
+			    id: form.alarmId[i]
+			    }:
+
+			    {
+			    type: form.alarmType[i],
+			    unit: form.alarmUnit[i], 
+			    time: form.alarmTime[i]
+			    };
+		    })
+		}, attend != '0' ? {id: attend} : {})];
+	};
+
+        return DataLayer.merge({
+        "class": form["class"],
+        startTime: Date.parseExact(form.startDate + " "+$.trim(form.startHour) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'),
+        endTime:  Date.parseExact(form.endDate + " "+$.trim(form.endHour), formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'),  //+ (!!form.allDay ? 86400000 : 0) ,
+        due: (form.dueDate == '' )? 0 : Date.parseExact(form.dueDate + " "+$.trim(form.dueHour) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'),
+        allDay: ( !!form.allDay ? 1 : 0 ),      
+        status: form.taskStatus,      
+        id: form.idActivity,
+        type: !!form.type ?  form.type : 2,
+        percentage: form.percentage,
+        priority: form.priority,
+        category: form.category,
+        summary: form.summary,
+        description: form.description,
+        timezone: tzId,
+        attachments: $.map(form.attachment || [], function( attachment, i ){
+            return {
+            attachment: attachment
+            }
+        }),
+        participants: decodeParticipants(form.idAttendee),
+        taskToActivity:$.map( form.idtask || [], function( task, i ){
+
+            return DataLayer.merge({
+                task: task,
+                owner: User.me.id
+            }, form.idTaskToActivity[i] != '' ? {id: form.idTaskToActivity[i]} : {});
+
+        })
+        }, form.lastGroup ? (( form.lastGroup == form.group ) ? {} : {calendar: form.group, lastGroup: form.lastGroup}) : {calendar: form.group});
+    });
+
+    return notArray ? res[0] : res;
+    },
+
+    encoder: function( evtObj ){
+
+    var notArray = false;
+      
+    if( notArray = $.type(evtObj) !== "array" )
+        evtObj = [ evtObj ];
+    
+    var res = $.map(evtObj, function( objEvent ){           
+            
+        if(!(typeof(objEvent) == 'object'))
+            return (null);
+
+        var decodeTasks = function(obj){
+
+            var tasks = {}, task = {};
+
+            for(var i =0; i < obj.taskToActivity.length; i++){
+
+                taskToActivity = DataLayer.get('taskToActivity', obj.taskToActivity[i]); 
+                task = taskToActivity.task;
+
+                if($.type(task) != 'object')
+                    task = DataLayer.get('schedulable', task);
+
+                tasks[task.id] = {
+                    taskToActivity: taskToActivity.id,
+                    allDay: !!parseInt(task.allDay),
+                    dueDate: (!task.due || task.due == '' || task.due == '0') ? '' : new Date( parseInt(task.due) ).setTimezoneOffset( Timezone.timezone( task.timezone ) ).toString( User.preferences.dateFormat ),
+                    dueTime: (!task.due || task.due == '' || task.due == '0') ? '' : dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(task.due)), task.timezone, obj.calendar, obj.DayLigth, 'startTime'), User.preferences.hourFormat),
+                    startDate: new Date( parseInt(task.startTime) ).setTimezoneOffset( Timezone.timezone( task.timezone ) ).toString( User.preferences.dateFormat ),
+                    startHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(task.startTime)), task.timezone, task.calendar, obj.DayLigth, 'startTime'), User.preferences.hourFormat),
+                    endDate: new Date( parseInt(task.endTime) - (!!parseInt(task.allDay) ? 86400000 : 0)  ).setTimezoneOffset( Timezone.timezone( task.timezone ) ).toString( User.preferences.dateFormat ),
+                    endHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date(parseInt(task.endTime)),  task.timezone, obj.calendar, obj.DayLigth, 'endTime'), User.preferences.hourFormat),
+                }
+
+                tasks[task.id].description = tasks[task.id].startDate + ' - ' + (!!task.summary ? task.summary : task.description);
+
+            }
+
+            tasks.length = obj.taskToActivity.length;
+            return tasks;
+
+        };
+
+        return {
+        "class": objEvent["class"],
+        id: objEvent.id,
+        location: objEvent.location,
+        category: objEvent.category,
+        activityStatus: objEvent.status,
+        groups: Calendar.groups,
+        group: objEvent.group ? objEvent.group : objEvent.calendar,
+        summary: objEvent.summary,
+        type: !!objEvent.type ? objEvent.type : 2,
+        description: objEvent.description,
+        timezone: objEvent.timezone,
+        timezones: Timezone.timezones,
+        percentage: (objEvent.percentage) ? objEvent.percentage : '0',
+        priority: objEvent.priority,
+        startDate: new Date( parseInt(objEvent.startTime) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ),
+        startHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.startTime)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat),
+        endDate: new Date( parseInt(objEvent.endTime) - (!!parseInt(objEvent.allDay) ? 86400000 : 0)  ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ),
+        endHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date(parseInt(objEvent.endTime)),  objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'endTime'), User.preferences.hourFormat),
+        dueDate: (!objEvent.due || objEvent.due == '' || objEvent.due == '0') ? '' : new Date( parseInt(objEvent.due) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ),
+        dueTime: (!objEvent.due || objEvent.due == '' || objEvent.due == '0') ? '' : dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.due)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat),
+        allDay: !!parseInt( objEvent.allDay ),
+        historic: [],
+        tasks: objEvent.taskToActivity ? decodeTasks(objEvent) : {},
+        attachments: $.map(objEvent.attachments || [], function( attachment, i ){
+            var attach = DataLayer.get('schedulableToAttachment', attachment, false);
+            //TODO - Verificar na API retorno de id sobre os conceitos em que s?o utilizados tabelas de liga??o
+            if(!attach.name) return(null); 
+            
+            var ext = attach.name.split('.');
+            attach.name = attach.name.length < 10 ?  attach.name : ( ext.length == 1 ? attach.name.substr(0, 10) : (attach.name.substr(0, 6) + '.' +  ext[ext.length -1]));
+            attach.size = formatBytes(attach.size);
+            return attach;
+        }),
+        me : User.me,
+        attendee: $.map(objEvent.participants || [], function( participant, i ){                        
+
+            var attend = DataLayer.get('participant', (participant.id || participant));
+            attend.user = DataLayer.get('user', attend.user);
+
+            return {
+                id: attend.id,
+                alarms : $.map(attend.alarms || [], function( alarm ){
+                    var alarm = DataLayer.get('alarm', alarm);
+                    return (alarm == "" ? (null) : alarm);
+                })
+            };
+        }),
+
+        };
+    });
     return (notArray ? res[0] : res);
     }
@@ -1089,5 +1298,5 @@
     
     if(!(!!evtObj))
-        return undefined;
+        evtObj = [];
 
     var notArray = false;
@@ -1314,18 +1523,21 @@
 
 	    //occurrences = DataLayer.unique( occurrences ).sort();
-		  
-	    for( var i = 0; i < occurrences.length; i++ )
-		grouped[ evt.calendar ].push( DataLayer.merge(
-		{
-		    id: evt.URI || evt.id+ '-' + i,
-		    title: Encoder.htmlDecode(evt.summary),
-		    start: Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) ), calendar.timezone,  !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving),
-		    end:   Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) + duration - (!!parseInt(evt.allDay) ? 86400000 : 0)), calendar.timezone, !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving),
-		    allDay: parseInt( evt.allDay ),
-		    isRepeat: isRepeat,
-		    occurrence: i,
-		    type: evt.type,
-		    calendar: evt.calendar
-		    }, eventEditable(evt.id, isRepeat, i ) ) );
+		var typeEvent;  
+	    for( var i = 0; i < occurrences.length; i++ ){
+
+            typeEvent = (evt.type == 2 && evt.taskToActivity ? 3 : evt.type)
+    		grouped[ evt.calendar ].push( DataLayer.merge(
+    		{
+    		    id: evt.URI || evt.id+ '-' + i,
+    		    title: Encoder.htmlDecode(evt.summary),
+    		    start: Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) ), calendar.timezone,  !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving),
+    		    end:   Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) + duration - (!!parseInt(evt.allDay) ? 86400000 : 0)), calendar.timezone, !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving),
+    		    allDay: parseInt( evt.allDay ),
+    		    isRepeat: isRepeat,
+    		    occurrence: i,
+    		    type: typeEvent,
+    		    calendar: evt.calendar
+    		    }, (parseInt(typeEvent) == 1 ? eventEditable(evt.id, isRepeat, i ) : (parseInt(typeEvent) == 2 ? {editable: true, disableResizing: false, disableDragging: false} : {editable: false, disableResizing: true, disableDragging: true}) )) );
+        }
 	});
 
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/activity.helpers.js
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/activity.helpers.js	(revision 6881)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/activity.helpers.js	(revision 6945)
@@ -1,6 +1,5 @@
-function activityDetails( objEvent, decoded, path, isMail, repeat){
-
-
-    attendees = {};
+function activityDetails( objActivity, decoded, path, isMail, repeat){
+
+    tasks = {length: 0};
 	
     if(path == undefined)
@@ -8,277 +7,214 @@
 		
     if( !decoded )
-	objEvent = DataLayer.decode( "schedulable:calendar", objEvent );
+	objActivity = DataLayer.decode( "schedulable:group", objActivity );
 
     if(!isMail)
-	objEvent = DataLayer.encode( "schedulable:preview", objEvent );
-	
-    if(typeof(objEvent.id) == 'undefined'){
-		objEvent.alarms = Calendar.signatureOf[User.preferences.defaultCalendar || Calendar.calendarIds[0]].defaultAlarms || false;
-		objEvent.useAlarmDefault = 1;
-		//Código provisório ... Mockup
-		objEvent.alarms.taskActivity = {};
-    }
-	
+	objActivity = DataLayer.encode( "schedulable:activity", objActivity );
+    
+    var registerStatus = function(){
+        var blkAuto = UI.dialogs.addActivity.find('#group_addactivity_details1');
+
+        var startDate = false;
+        var endDate = new Date;
+        var dueDate = new Date;
+        var percentage = 0;
+
+        var allDay = true;
+
+        var formatString =  User.preferences.dateFormat + " " +  User.preferences.hourFormat;
+
+        if(tasks.length == 0){
+
+            startDate = new Date();
+            var configData = (startDate.toString('mm') < 30)  ? {minutes: (30 - parseInt(startDate.toString('mm')))} : {hours: 1, minutes: '-'+startDate.toString('mm')};
+            startDate.add(configData); 
+
+            endDate = new Date(dateCalendar.decodeRange(startDate, (!!User.preferences.defaultCalendar ? (   !!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration ?  (Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration) : (User.preferences.defaultDuration)) : (User.preferences.defaultDuration))));
+
+            blkAuto.find('input[name="startDate"]').val(startDate.toString(User.preferences.dateFormat ));
+            blkAuto.find('input[name="startHour"]').val(startDate.toString(User.preferences.hourFormat ));
+
+            blkAuto.find('input[name="endDate"]').val(endDate.toString(User.preferences.dateFormat ));
+            blkAuto.find('input[name="endHour"]').val(endDate.toString(User.preferences.hourFormat ));
+
+            blkAuto.find('input[name="dueDate"]').val('');
+            blkAuto.find('input[name="dueHour"]').val('');
+                        
+            blkAuto.find('input[name="percentage"]').val(percentage);
+
+            blkAuto.find('input[name="allDay"]').attr('checked', false);
+
+            return true;
+        }
+
+        for (var i in tasks){
+
+            if(i == 'length')
+                continue;
+
+            stTime = Date.parseExact( tasks[i].startDate + " "+$.trim( tasks[i].startHour) , formatString);
+            enTime = Date.parseExact( tasks[i].endDate + " "+$.trim( tasks[i].endHour), formatString );
+            
+            startDate = (startDate && startDate.compareTo(stTime) == -1) ? startDate : stTime;
+            endDate = endDate.compareTo(enTime) == -1 ? enTime : endDate;
+            
+            if(tasks[i].dueDate != ''){
+                pvTime = Date.parseExact( tasks[i].dueDate + " "+$.trim( tasks[i].dueTime), formatString );
+                dueDate = dueDate.compareTo(pvTime) == -1 ? pvTime : dueDate;
+            }
+
+            if(parseInt(tasks[i].percentage) > 0)
+                percentage += parseInt((100 / tasks.length)) * ( parseInt(tasks[i].percentage) / 100);
+        }
+
+        dueDate = dueDate.compareTo(endDate) == -1 ? endDate : dueDate;
+
+        blkAuto.find('input[name="startDate"]').val(startDate.toString(User.preferences.dateFormat ));
+        blkAuto.find('input[name="startHour"]').val(startDate.toString(User.preferences.hourFormat ));
+
+        blkAuto.find('input[name="endDate"]').val(endDate.toString(User.preferences.dateFormat ));
+        blkAuto.find('input[name="endHour"]').val(endDate.toString(User.preferences.hourFormat ));
+
+        blkAuto.find('input[name="dueDate"]').val(dueDate.toString(User.preferences.dateFormat ));
+        blkAuto.find('input[name="dueHour"]').val(dueDate.toString(User.preferences.hourFormat ));
+
+        blkAuto.find('input[name="percentage"]').val(percentage);
+
+        blkAuto.find('input[name="allDay"]').attr('checked', (!!(startDate.compareTo(endDate) == 0) || (startDate.toString('HH:mm') == endDate.toString('HH:mm')) ? true : false));
+    }
+
+
+    var callbackTask = function(){
+
+        blkAddTask.find("li .button").filter(".close.new").button({
+            icons: {
+            primary: "ui-icon-close"
+            },
+            text: false
+        }).click(function () {
+
+            delete tasks[$(this).parents('li').find('input[name="idtask[]"]').val()]
+            tasks.length +=  -1;
+
+            idTaskToActivity = $(this).parents('li').find('input[name="idTaskToActivity[]"]').val()
+
+            if(idTaskToActivity != '')
+                DataLayer.remove('taskToActivity', idTaskToActivity);
+            
+            $(this).parents('li').remove();
+                
+            if(blkAddTask.find(".task-activity-list li").length == 1)
+                blkAddTask.find("li.not-activity    ").removeClass('hidden');
+
+            registerStatus();
+        })
+        .addClass('tiny disable ui-button-disabled ui-state-disabled')
+        .removeClass('new').end()
+
+        .filter(".info.new").button({
+            icons: {
+                primary:  "ui-icon-notice"
+            },
+            text: false
+        }).click(function () {
+            var positionY = $(this).parents("li").offset().top;
+             
+            var name = $(this).parents('li').find("div").find(".name").text();
+            var email = $(this).parents('li').find("div").find(".mail").text()
+                        
+            if( $('.qtip.qtip-blue.qtip-active').val() !== ''){
+                $(this).qtip({
+                    show: {
+                        ready: true,
+                        solo: true,
+                        when: {
+                            event: 'click'
+                        }
+                    },
+                    hide: false,
+                    content: {
+                        text: $('<div></div>').html( DataLayer.render( path + 'templates/activity_information_task.ejs', {
+                            'name' : name
+                        } ) ),
+                        title: {
+                            text:'InformaÃ§Ãµes',
+                            button: '<a class="button close" href="#">close</a>'
+                        }
+                    },
+                style: {
+                    name: 'blue',
+                        tip: {
+                             },
+                        border: {
+                            width: 4,
+                            radius: 8
+                        },
+                        width: {
+                            min: 230,
+                            max:230
+                        }
+                },
+                position: {
+                    corner: {
+                        target: 'rightMiddle',
+                        tooltip: 'leftMiddle'
+                    },
+                    adjust: {
+                        x: 30,
+                        y: 0
+                    }
+                }
+            })
+            .qtip("api").onShow = function(arg0) {
+                $('.qtip-active .button.close').button({
+                    icons: {
+                        primary: "ui-icon-close"
+                    },
+                    text: false
+                })
+                .click(function(){
+                    blkAddAtendee.find('dd.task-activity-list').qtip('destroy');
+                });
+                                        
+                $('.qtip-active .button.cancel').button().click(function(){
+                    blkAddAtendee.find('dd.activity-list [type=checkbox]').attr('checked', false);
+                    blkAddAtendee.find('dd.activity-list').qtip('destroy');
+                });
+
+                $('.qtip .button').button();
+                                        
+            };
+         }             
+     })
+ .addClass('tiny disable ui-button-disabled ui-state-disabled')
+ .removeClass('new').end()    
+
+        UI.dialogs.addActivity.find('.task-activity-list li').hover(
+            function () {
+                $(this).addClass("hover-attendee");
+                $(this).find('.button').removeClass('disable ui-button-disabled ui-state-disabled').end()
+                .find('.activity-options').addClass('hover-attendee');
+            },
+            function () {
+                $(this).removeClass("hover-attendee");
+                $(this).find('.button').addClass('disable ui-button-disabled ui-state-disabled').end()
+                .find('.activity-options').removeClass('hover-attendee');
+            }
+        );        
+    }
+
+
     /**
-	 * canDiscardEventDialog deve ser true se não houver alterações no evento
+	 * canDiscardEventDialog deve ser true se nÃ£o houver alteraÃ§Ãµes no evento
 	 */
     canDiscardEventDialog = true;
     /**
-	 * zebraDiscardEventDialog é uma flag indicando que uma janela de confirmação (Zebra_Dialog)
-	 * já está aberta na tela, uma vez que não é possivel acessar o evento ESC utilizado para fechá-la
+	 * zebraDiscardEventDialog Ã© uma flag indicando que uma janela de confirmaÃ§Ã£o (Zebra_Dialog)
+	 * jÃ¡ estÃ¡ aberta na tela, uma vez que nÃ£o Ã© possivel acessar o evento ESC utilizado para fechÃ¡-la
 	 */
     zebraDiscardEventDialog = false;
 	
-    /**
-		ACLs do participant
-	*/
-    acl_names = {
-	'w': 'acl-white',
-	'i': 'acl-invite-guests',
-	'p': 'acl-participation-required'
-    };
-
-
-var callbackAttendee = function(){
-	//Cria qtip de permissões pelo click do checkbox
-	var checked = false;
-	blkAddAtendee.find("li.not-activity").addClass('hidden');
-	
-	blkAddAtendee.find("li .button").filter(".close.new").button({
-	    icons: {
-		primary: "ui-icon-close"
-	    },
-	    text: false
-	}).click(function () {
-	    DataLayer.remove('participant', $(this).parents('li').find('[type=checkbox]').val());
-	    if($(this).parent().find('.button.delegate').hasClass('activity-permissions-change-button')){
-		removeOthers();
-		blkAddAtendee.find('.request-update').addClass('hidden');
-		blkAddAtendee.find('.status option').toggleClass('hidden');
-				
-		blkAddAtendee.find('option[value=1]').attr('selected','selected').trigger('change');
-	    }
-			
-	    $(this).parents('li').remove();
-			
-	    if(blkAddAtendee.find(".activity-list li").length == 1)
-		blkAddAtendee.find("li.not-activity").removeClass('hidden');
-	})
-	.addClass('tiny disable ui-button-disabled ui-state-disabled')
-	.removeClass('new').end()
-	
-	.filter(".delegate.new").button({
-	    icons: {
-		primary: "ui-icon-transferthick-e-w"
-	    },
-	    text: false
-	}).click(function () {
-	    var me = $(this).parents('li');
-	    if($(this).hasClass('activity-permissions-change-button')){
-		$(this).removeClass('activity-permissions-change-button')   
-		    .find('.ui-icon-transferthick-e-w').removeClass('activity-permissions-change').end();               
-		
-		me.find('input[name="delegatedFrom[]"]').val('');
-		dependsDelegate(me, true);
-				
-		blkAddAtendee.find('.request-update').addClass('hidden');
-		blkAddAtendee.find('.status option').toggleClass('hidden');
-
-		blkAddAtendee.find('option[value=1]').attr('selected','selected').trigger('change');
-				
-	    }else{
-		removeOthers();
-			
-		$(this).addClass('activity-permissions-change-button')   
-		.find('.ui-icon-transferthick-e-w').addClass('activity-permissions-change').end();               
-		
-		me.find('input[name="delegatedFrom[]"]').val(blkAddAtendee.find('.me input[name="attendee[]"]').val());
-		
-		dependsDelegate(me, false);
-			
-		blkAddAtendee.find('.request-update').removeClass('hidden');
-		if(blkAddAtendee.find('.status option.hidden').length == 1)
-		    blkAddAtendee.find('.status option').toggleClass('hidden');
-			
-		blkAddAtendee.find('option[value=5]').attr('selected','selected').trigger('change');
-	    }
-	})
-	.addClass('tiny disable ui-button-disabled ui-state-disabled')
-	.removeClass('new').end()
-		
-	.filter(".edit.new").button({
-	    icons: {
-		primary: "ui-icon-notice"
-	    },
-	    text: false
-	}).click(function() {
-
-		console.log($(this).parents("li").position().top);
-
-		var positionY = $(this).parents("li").offset().top;
-
-	    if(!!!checked)
-		$(this).parents('li').find('[type=checkbox]').attr('checked', (!$(this).parent().find('[type=checkbox]').is(':checked'))).end();
-		
-		var name = $(this).parents('li').find("div").find(".name").text();
-		var email = $(this).parents('li').find("div").find(".mail").text()
-	    //var aclsParticipant =  $(this).parents('li')
-	    checked = false;
-			
-	    if( $('.qtip.qtip-blue.qtip-active').val() !== ''){
-		$(this).qtip({
-		    show: {
-		    ready: true, 
-	   		solo: true, 
-	    when: {
-		    event: 'click'
-		    }
-		},
-		hide: false,
-		content: {
-				text: $('<div></div>').html( DataLayer.render( path + 'templates/activity_information_task.ejs', {
-					'name' : name
-				} ) ), 
-				title: {
-					text:'Informações', 
-					button: '<a class="button close" href="#">close</a>'
-				}
-		},
-		style: {
-		name: 'blue', 
-		    tip: {
-				corner: 'leftMiddle'
-			}, 
-		    border: {
-				width: 4, 
-			    radius: 8
-			}, 
-		    width: {
-				min: 230, 
-			    max:230
-			}
-	    },
-	    position: {
-	    corner: {
-	    target: 'rightMiddle',
-	    tooltip: 'leftMiddle'
-	    },
-	    adjust: {
-		    x: 30, 
-		    y: 0
-	    }
-	    }
-	    })
-	.qtip("api").onShow = function(arg0) {
-	    $('.qtip-active .button.close').button({
-		icons: {
-		    primary: "ui-icon-close"
-		},
-		text: false
-	    })
-	    .click(function(){
-		blkAddAtendee.find('dd.task-activity-list').qtip('destroy');
-	    });
-					
-	    $('.qtip-active .button.save').button().click(function(){
-						
-		var acl = '';
-		$('.qtip-active').find('[type=checkbox]:checked').each(function(i, obj) {
-		    acl+= obj.value;
-		});
-
-		blkAddAtendee.find('dd.task-activity-list [type=checkbox]:checked').siblings('input[name="attendeeAcl[]"]').each(function(i, obj) { 
-		    obj.value = 'r'+acl;
-		}).parents('li').find('.button.edit').addClass('activity-permissions-change-button')   
-		.find('.ui-icon-key').addClass('activity-permissions-change');               
-						
-		blkAddAtendee.find('dd.task-activity-list [type=checkbox]').attr('checked', false);
-						
-		blkAddAtendee.find('dd.task-activity-list').qtip('destroy');
-					
-	    });
-	    $('.qtip-active .button.cancel').button().click(function(){
-		blkAddAtendee.find('dd.activity-list [type=checkbox]').attr('checked', false);
-		blkAddAtendee.find('dd.activity-list').qtip('destroy');
-	    });
-					
-	    if(aclsParticipant)
-		for(var i = 1; i < aclsParticipant.length; i++){
-		    $('.qtip-active').find('input[name="'+acl_names[aclsParticipant.charAt(i)]+'"]').attr('checked', true);
-		}
-							
-	    $('.qtip .button').button();
-					
-	};
-	}else{
-	    if(!$('.new-activity-win dd.task-activity-list').find('[type=checkbox]:checked').length){
-		blkAddAtendee.find('dd.attendee-list').qtip('destroy');
-	    }else{
-		$('.qtip-active .button.save .ui-button-text').html('Aplicar a todos')
-	    }
-			
-	};			
-    })
-.addClass('tiny disable ui-button-disabled ui-state-disabled')
-.removeClass('new').end()
-		
-.filter(".open-delegate.new").click(function(){
-    if($(this).hasClass('ui-icon-triangle-1-e')){
-	$(this).removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s');
-	$(this).parents('li').find('.list-delegates').removeClass('hidden');
-    }else{
-	$(this).removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e');
-	$(this).parents('li').find('.list-delegates').addClass('hidden');
-    }
-		
-}).removeClass('new');
-	
-	
-blkAddAtendee.find("li input[type=checkbox].new").click(function(){
-    if(!$('.new-activity-win dd.task-activity-list').find('[type=checkbox]:checked').length){
-	blkAddAtendee.find('dd.task-activity-list').qtip('destroy');
-    }else{
-	checked = true;
-	$(this).parents('li').find('.button.edit').click();
-    }
-}).removeClass('new');
-	
-UI.dialogs.addActivity.find('.task-activity-list li').hover(
-    function () {
-	$(this).addClass("hover-activity");
-	$(this).find('.button').removeClass('disable ui-button-disabled ui-state-disabled').end()
-	.find('.activity-options').addClass('hover-activity');
-    },
-    function () {
-	$(this).removeClass("hover-activity");
-	$(this).find('.button').addClass('disable ui-button-disabled ui-state-disabled').end()
-	.find('.activity-options').removeClass('hover-activity');;
-    }
-    );
-	
-}
-    var dependsDelegate = function(reference, inverse){
-	if(inverse){
-	    if(reference.find('input[name="attendee[]"]').val() == blkAddAtendee.find('li.organizer input[name="attendee_organizer"]').val())
-		blkAddAtendee.find('li.organizer input[name="attendee_organizer"]').val(blkAddAtendee.find('.me input[name="attendee[]"]').val());
-	}else{
-	    if(blkAddAtendee.find('.me input[name="attendee[]"]').val() == blkAddAtendee.find('li.organizer input[name="attendee_organizer"]').val())
-		blkAddAtendee.find('li.organizer input[name="attendee_organizer"]').val(reference.find('input[name="attendee[]"]').val());
-	}
-	
-    };
-    
-    var removeOthers = function(){
-	var other = blkAddAtendee.find('.delegate.attendee-permissions-change-button');
-	if(other.lenght){
-	    dependsDelegate(other.parents('li'), true);
-	}
-	blkAddAtendee.find('.delegate').removeClass('attendee-permissions-change-button');
-	blkAddAtendee.find('.ui-icon-transferthick-e-w').removeClass('attendee-permissions-change');
-	
-    };
-	
 	var html = DataLayer.render( path+'templates/activity_add.ejs', {
-	    event:objEvent
+	    activity:objActivity
 	});	
 			
@@ -286,79 +222,84 @@
 
 	    UI.dialogs.addActivity = jQuery('#sandbox').append('<div title="Criar Atividade" class="new-activity-win active"> <div>').find('.new-activity-win.active').html(html).dialog({
-		resizable: false, 
-		modal:true, 
-		autoOpen: false,
-		width:734, 
-		position: 'center', 
-		close: function(event, ui) {
-			/**
-			 * Remove tooltip possivelmente existente
-			 */
-			if ($('.qtip.qtip-blue.qtip-active').length)
-				$('.qtip.qtip-blue.qtip-active').qtip('destroy');						
-			attendees  = {};
-		},
-		beforeClose: function(event, ui) {
-		
-		    if (!canDiscardEventDialog && !zebraDiscardEventDialog) {
-			zebraDiscardEventDialog = true;
-			window.setTimeout(function() {
-			    $.Zebra_Dialog('Suas alterações na atividade não foram salvas. Deseja descartar as alterações?', {
-				'type':     'question',
-				'overlay_opacity': '0.5',
-				'buttons':  ['Descartar alterações', 'Continuar editando'],
-				'onClose':  function(clicked) {
-				    if(clicked == 'Descartar alterações') {
-					canDiscardEventDialog = true;
-					/**
-					*Remoção dos anexos do eventos caso seja cancelado a edição
-					*/
-					DataLayer.rollback();
-
-					var ids = false;
-					$.each($('.attachment-list input'), function (i, input) {
-					    DataLayer.put('attachment', {id: ''+input.value});
-					    DataLayer.remove('attachment', ''+input.value);
-						ids = true;
-					});
-					if(ids)
-						DataLayer.commit();
-				
-					
-	                                                                                
-					UI.dialogs.addActivity.dialog('close');
-				    }else{
-					zebraDiscardEventDialog = false;
-				    }
-										
-				    /**
-				    * Uma vez aberta uma janela de confirmação (Zebra_Dialog), ao fechá-la
-				    * com ESC, para que o evento ESC não seja propagado para fechamento da
-				    * janela de edição de eventos, deve ser setada uma flag indicando que
-				    * já existe uma janela de confirmação aberta.
-				    */
-				    if (!clicked) {
-					window.setTimeout(function() {
-					    zebraDiscardEventDialog = false;
-					}, 200);
-				    }
-				}
-			    });
-								
-			}, 300);
-
-		    }
-		    //DataLayer.rollback();
-		    return canDiscardEventDialog;
-		},
-		dragStart: function(event, ui) {
-			if ($('.qtip.qtip-blue.qtip-active').length)
-				$('.qtip.qtip-blue.qtip-active').qtip('destroy');
-		}
-	    });
+    		resizable: false, 
+    		modal:true, 
+    		autoOpen: false,
+    		width:734, 
+    		position: 'center', 
+    		close: function(event, ui) {
+    			/**
+    			 * Remove tooltip possivelmente existente
+    			 */
+    			if ($('.qtip.qtip-blue.qtip-active').length)
+    				$('.qtip.qtip-blue.qtip-active').qtip('destroy');						
+    			
+                attendees  = {};
+    		},
+    		beforeClose: function(event, ui) {
+    		
+    		    if (!canDiscardEventDialog && !zebraDiscardEventDialog) {
+        			zebraDiscardEventDialog = true;
+        			window.setTimeout(function() {
+        			    $.Zebra_Dialog('Suas alteraÃ§Ãµes na atividade nÃ£o foram salvas. Deseja descartar as alteraÃ§Ãµes?', {
+        				'type':     'question',
+        				'overlay_opacity': '0.5',
+        				'buttons':  ['Descartar alteraÃ§Ãµes', 'Continuar editando'],
+        				'onClose':  function(clicked) {
+        				    if(clicked == 'Descartar alteraÃ§Ãµes') {
+            					canDiscardEventDialog = true;
+            					/**
+            					*RemoÃ§Ã£o dos anexos do eventos caso seja cancelado a ediÃ§Ã£o
+            					*/
+            					DataLayer.rollback();
+
+            					var ids = false;
+            					$.each($('.attachment-list input'), function (i, input) {
+            					    DataLayer.put('attachment', {id: ''+input.value});
+            					    DataLayer.remove('attachment', ''+input.value);
+            						ids = true;
+            					});
+            					if(ids)
+            						DataLayer.commit();
+
+            					UI.dialogs.addActivity.dialog('close');
+        				    }else{
+        					   zebraDiscardEventDialog = false;
+        				    }
+        										
+        				    /**
+        				    * Uma vez aberta uma janela de confirmaÃ§Ã£o (Zebra_Dialog), ao fechÃ¡-la
+        				    * com ESC, para que o evento ESC nÃ£o seja propagado para fechamento da
+        				    * janela de ediÃ§Ã£o de eventos, deve ser setada uma flag indicando que
+        				    * jÃ¡ existe uma janela de confirmaÃ§Ã£o aberta.
+        				    */
+        				    if (!clicked) {
+            					window.setTimeout(function() {
+            					    zebraDiscardEventDialog = false;
+            					}, 200);
+        				    }
+        				}
+        		    });
+        								
+        		}, 300);
+    	    }
+    	    //DataLayer.rollback();
+    	    return canDiscardEventDialog;
+    	},
+    	dragStart: function(event, ui) {
+    		if ($('.qtip.qtip-blue.qtip-active').length)
+    			$('.qtip.qtip-blue.qtip-active').qtip('destroy');
+       }
+    });
 				
 	} else {
 	    UI.dialogs.addActivity.html(html);
 	}
+
+/* Checkbox allday */
+UI.dialogs.addActivity.find('input[name="allDay"]').click(function(){
+    $(this).attr("checked") ? 
+    UI.dialogs.addActivity.find('.start-time, .end-time').addClass('hidden') :
+    UI.dialogs.addActivity.find('.start-time, .end-time').removeClass('hidden'); 
+});
 		
 var tabs = UI.dialogs.addActivity.children('.content').tabs({
@@ -368,60 +309,64 @@
 	}	
 	});
-var calendar = DataLayer.get('calendar', objEvent.calendar);
+
+var group = DataLayer.get('calendar', objActivity.group);
 				
-if (calendar.timezone != objEvent.timezone){
-    UI.dialogs.addActivity.find('.calendar_addactivity_details_lnk_timezone').find('option[value="'+objEvent.timezone+'"]').attr('selected','selected').trigger('change');
-    UI.dialogs.addActivity.find('.calendar_addactivity_details_lnk_timezone').addClass('hidden');
-    $('.calendar-addevent-details-txt-timezone').removeClass('hidden');
+if (group.timezone != objActivity.timezone){
+    UI.dialogs.addActivity.find('.group_addactivity_details_lnk_timezone').find('option[value="'+objActivity.timezone+'"]').attr('selected','selected').trigger('change');
+    UI.dialogs.addActivity.find('.group_addactivity_details_lnk_timezone').addClass('hidden');
+    $('.group-addevent-details-txt-timezone').removeClass('hidden');
 			
 }
 
-UI.dialogs.addActivity.find('.calendar_addactivity_details_lnk_timezone').click(function(e){
+UI.dialogs.addActivity.find('.group_addactivity_details_lnk_timezone').click(function(e){
     $(this).addClass('hidden');
-    $('.calendar-addactivity-details-txt-timezone').removeClass('hidden');
+    $('.group-addactivity-details-txt-timezone').removeClass('hidden');
     e.preventDefault();
 });
 
-/*Seleciona a agenda padrão para visualização/edição de um evento*/
-if(objEvent.id)
-    UI.dialogs.addActivity.find('option[value="'+objEvent.calendar+'"]').attr('selected','selected').trigger('change');
-
-/* Checkbox allday */
-
-UI.dialogs.addActivity.find('input[name="allDay"]').click(function(){
-    $(this).attr("checked") ? 
-    UI.dialogs.addActivity.find('.start-time, .end-time').addClass('hidden') :
-    UI.dialogs.addActivity.find('.start-time, .end-time').removeClass('hidden'); 
-    updateMap(true);
-});
+UI.dialogs.addActivity.find('.button.remove').button({
+    text:false, 
+    icons:{
+	primary:'ui-icon-close'
+    }
+}).click(function(el){
+    var id;
+    if( id = $(this).parent().find('input[name="alarmId[]"]').val())
+	DataLayer.remove('alarm', id);
+    $(this).parent().remove().find('li').is(':empty');
+});
+
+UI.dialogs.addActivity.find('.button-add-alarms').click(function(){
+            DataLayer.render( 'templates/alarms_add_itemlist.ejs', {type: 0}, function( template ){                     
+            jQuery('.activity-alarms-list').append(template)
+            .find('li:last label:eq(0)').remove().end()
+            .find('.number').numeric().end()
+            .find('.button.remove').button({
+                text:false, 
+                icons:{
+                    primary:'ui-icon-close'
+                }
+            }).click(function(el) {
+                $(this).parent().remove();
+            });    
+            });
+        });
+
+/*Seleciona a agenda padrÃ£o para visualizaÃ§Ã£o/ediÃ§Ã£o de um evento*/
+if(objActivity.id)
+    UI.dialogs.addActivity.find('option[value="'+objActivity.group+'"]').attr('selected','selected').trigger('change');
 
 UI.dialogs.addActivity.find('.button').button();
-UI.dialogs.addActivity.find('.button.add').button({
-    icons: {
-	secondary: "ui-icon-plus"
-    }
+    UI.dialogs.addActivity.find('.button.add').button({
+        icons: {
+    	   secondary: "ui-icon-plus"
+        }
 });
 
 // ==== validation events ====
-UI.dialogs.addActivity.find(".input-group .h1").Watermark("Atividade sem título");
-if(User.preferences.hourFormat.length == 5) {
-    UI.dialogs.addActivity.find(".end-time, .start-time").mask("99:99", {
-	completed: function(){
-	    updateMap();
-	}
-    });
-} else {
-    $.mask.definitions['{']='[ap]';
-    $.mask.definitions['}']='[m]';
-    UI.dialogs.addActivity.find(".end-time, .start-time").mask("99:99 {}", {
-	completed:function(){
-	    $(this).val(date.Calendar.defaultToAmPm($(this).val()));
-	    $(this).timepicker("refresh");
-	    $(this).val($(this).val().replace(/[\.]/gi, ""));
-	    updateMap();
-	}
-    });
-}
+UI.dialogs.addActivity.find(".input-group .h1").Watermark("Atividade sem tÃ­tulo");
+
 UI.dialogs.addActivity.find(".number").numeric();
+
 User.preferences.dateFormat.indexOf('-') > 0 ? 
 UI.dialogs.addActivity.find(".date").mask("99-99-9999", {
@@ -430,4 +375,5 @@
     }
 }) : 
+
 UI.dialogs.addActivity.find(".date").mask("99/99/9999", {
     completed:function(){
@@ -436,15 +382,15 @@
 });
 
-UI.dialogs.addActivity.find(".menu-addActivity")
+UI.dialogs.addActivity.find(".menu-addactivity")
 .children(".delete").click(function(){
     $.Zebra_Dialog('Tem certeza que deseja excluir a atividade?', {
 	'type':     'question',
 	'overlay_opacity': '0.5',
-	'buttons':  ['Sim', 'Não'],
+	'buttons':  ['Sim', 'NÃ£o'],
 	'onClose':  function(clicked) {
 	    if(clicked == 'Sim'){
 		canDiscardEventDialog = true;
 		/* Remove por filtro */
-		DataLayer.removeFilter('schedulable', {filter: ['AND', ['=', 'id', objEvent.id], ['=', 'calendar', objEvent.calendar], ['=','user',(objEvent.me.user ? objEvent.me.user.id : objEvent.me.id)]]});
+		DataLayer.removeFilter('schedulable', {filter: ['AND', ['=', 'id', objActivity.id], ['=', 'group', objActivity.group], ['=','user',(objActivity.me.user ? objActivity.me.user.id : objActivity.me.id)]]});
 		Calendar.rerenderView(true);
 		/********************/
@@ -460,26 +406,16 @@
 	    
 .children(".save").click(function(){
-    /* Validação */
+    /* ValidaÃ§Ã£o 
     var msg = false;			
     if(msg = validDateEvent()){
-	$(".new-activity-win.active").find('.messages-validation').removeClass('hidden').find('.message label').html(msg); 
-	return false;
-    }
-			
+    	$(".new-activity-win.active").find('.messages-validation').removeClass('hidden').find('.message label').html(msg); 
+    	return false;
+    }
+    */
     canDiscardEventDialog = true;
 			
-    var exit = function(event){
-	if(event)
-	    DataLayer.remove('schedulable', event, false); 
-
-	UI.dialogs.addActivity.children().find('form.form-addevent').submit();
-	UI.dialogs.addActivity.dialog("close");    }
-                        
-    if(repeat){
-	DataLayer.remove('repeat', false);
-	DataLayer.put('repeat', repeat);
-	DataLayer.commit('repeat', false, exit(repeat.schedulable));
-    }else
-	exit();
+	UI.dialogs.addActivity.children().find('form.form-addactivity').submit();
+	UI.dialogs.addActivity.dialog("close");
+
 }).end()
 		
@@ -488,10 +424,6 @@
 });
 
-var task_activityHtml = DataLayer.render( path+'templates/task_activity_add.ejs', {
-	event:objEvent
-});
-
-
-var blkAddAtendee = UI.dialogs.addActivity.find('#calendar_addactivity_details8').append(task_activityHtml);
+var task_activityHtml = DataLayer.render( path+'templates/task_activity_add.ejs', {	activity: objActivity});
+var blkAddTask = UI.dialogs.addActivity.find('#group_addactivity_details8').append(task_activityHtml);
 
 var dates = UI.dialogs.addActivity.find('input.date').datepicker({
@@ -502,119 +434,113 @@
 });
 
-UI.dialogs.addActivity.find('input.time').timepicker({ 
-    closeText: 'Ok',
-    hourGrid: 4,
-    minuteGrid: 10,
-    ampm : ((User.preferences.hourFormat.length > 5) ? true: false),
-    timeFormat: "hh:mm tt",
-    onSelect: function (selectedDateTime){
-	if(!(User.preferences.hourFormat.length == 5))
-	    $(this).val(selectedDateTime.replace(/[\.]/gi, ""));								
-	updateMap();
-    },
-    onClose : function (selectedDateTime){
-	if(!(User.preferences.hourFormat.length == 5))
-	    $(this).val(selectedDateTime.replace(/[\.]/gi, ""));
-    }
-	
-
-});
-
-blkAddAtendee.find('.add-activity-search .ui-icon-search').click(function(event) {
-    blkAddAtendee.find('.add-activity-search input').keydown();
+blkAddTask.find('.add-activity-search .ui-icon-search').click(function(event) {
+    blkAddTask.find('.add-activity-search input').keydown();
 });
 			
 			
-blkAddAtendee.find('.add-activity-search input').keydown(function(event) {
+blkAddTask.find('.add-activity-search input').keydown(function(event) {
 
     if(event.keyCode == '13' || typeof(event.keyCode) == 'undefined') {	
     // Fazer get das tarefas	
-	var result = [ {'name': 'Tarefa 01'} , {'name': 'Tarefa 02'} , {'name' : 'Tarefa 03'} ];
-	//DataLayer.get('user', ["*", "name", $(this).val()], true);
-
-
+	var filter = 
+        {
+            filter: 
+                ['AND',
+                    ['=', 'type', '2'], 
+                    ['>=','startTime', $.now()], 
+                    ['in', 'calendar', 
+                        [$('div.new-activity-win.active select[name="groupFilter"]').val()]
+                    ]
+                ], criteria: {'filterTasks': true}
+        };
+    if($(this).val() != ''){
+        filter['filter'].push(['OR',
+                            ["i*", "summary", $(this).val()], 
+                            ["i*", "description", $(this).val()]
+                           ]);
+    }
+
+    var result = DataLayer.get('schedulable:taskSearch', filter, true)
 	/**
-        * TODO: trocar por template
-        */
-	blkAddAtendee.find('ul.search-result-list').empty().css('overflow', 'hidden');
+    * TODO: trocar por template
+    */
+	blkAddTask.find('ul.search-result-list').empty().css('overflow', 'hidden');
 	if (!result) {
-	    blkAddAtendee.find('ul.search-result-list').append('<li><label class="empty">Nenhum resultado encontrado.</label></li>');
-	}
-
-	for(i=0; i<result.length; i++)
-	    result[i].enabled = (blkAddAtendee.find('dd.task-helpers-list ul.task-helpers-list label.mail[title="' +  result[i].mail + '"]').length) ? false : true;
-											
-	blkAddAtendee.find('ul.search-result-list').append(DataLayer.render( path+'templates/task_search_itemlist.ejs', result));
-
-
-	blkAddAtendee.find('ul.search-result-list li').click(function(event, ui){
-	    if ($(event.target).is('input')) {
-		old_item = $(event.target).parents('li');
-		newAttendeeId = DataLayer.put('participant', {
-		    user: old_item.find('.id').html(), 
-		    isExternal: old_item.find('.isExternal').html()
-		});
-							
-		attendees[old_item.find('.id').html()] = old_item.find('.name').html();
-							
-		blkAddAtendee.find('dd.task-activity-list ul.task-activity-list')
-		.append(DataLayer.render(path+'templates/task_add_itemlist.ejs', [{
-		    id: newAttendeeId, 
-		    name: old_item.find('.name').html(), 
-		    mail: old_item.find('.mail').html(), 
-		    isExternal: old_item.find('.isExternal').html(), 
-		    acl: objEvent.acl,
-		    isDirty: !!!objEvent.id
-		 }]))
-		.scrollTo('max');
-		/**
-							* Delegação de participação de um participante com permissão apenas de leitura
-							*
-							*/
-			if(!objEvent.acl.organization && !objEvent.acl.write && !objEvent.acl.inviteGuests && objEvent.acl.read ){
-									
-			    blkAddAtendee.find('.block-add-attendee.search').addClass('hidden');
-			    blkAddAtendee.find('.block-add-attendee.search dt').html('Adicionar outros contatos');
-									
-			    blkAddAtendee.find('.status option').toggleClass('hidden');
-			    blkAddAtendee.find('option[value=5]').attr('selected','selected').trigger('change');
-			    blkAddAtendee.find('.request-update').removeClass('hidden');
-
-			    blkAddAtendee.find('dd.attendee-list ul.attendee-list li .button.close').parents('li').find('input[name="delegatedFrom[]"]').val(blkAddAtendee.find('.me input[name="attendee[]"]').val());
-									
-			    blkAddAtendee.find('.me .participant-delegate').addClass('disable ui-button-disabled ui-state-disabled');
-			    blkAddAtendee.find(".button.close").button({
-				icons: {
-				    primary: "ui-icon-close"
-				},
-				text: false
-			    }).click(function () {
-										
-				$(this).parents('li').find('input[name="delegatedFrom[]"]').val('');
-				blkAddAtendee.find('.request-update').addClass('hidden');
-				blkAddAtendee.find('.status option').toggleClass('hidden');
-				blkAddAtendee.find('option[value=1]').attr('selected','selected').trigger('change');			
-				blkAddAtendee.find('.me .participant-delegate').removeClass('disable ui-button-disabled ui-state-disabled attendee-permissions-change-button')
-				.find('.ui-icon-person').removeClass('attendee-permissions-change').end();               	
-										
-				DataLayer.remove('participant', $(this).parents('li').find('[type=checkbox]').val());
-				$(this).parents('li').remove();
-			    })
-			    .addClass('tiny');
-			}else{
-			    callbackAttendee();
-			    old_item.remove();
-			}
-	    }
-	});
-
-
+	    blkAddTask.find('ul.search-result-list').append('<li><label class="empty">Nenhum resultado encontrado.</label></li>');
+	}else{
+    	for(i=0; i<result.length; i++)
+    	    result[i].enabled = (blkAddTask.find('dd.task-activity-list ul.task-activity-list input[value="' +  result[i].id + '"]').length) ? false : true;
+    											
+    	blkAddTask.find('ul.search-result-list').append(DataLayer.render( path+'templates/task_search_itemlist.ejs', result));
+
+        /* TODO - Verificar id da aitividade*/
+    	blkAddTask.find('ul.search-result-list li').click(function(event, ui){
+    	    if ($(event.target).is('input')) {
+                old_item = $(event.target).parents('li');
+
+                tasks[old_item.find('[name="id"]').val()] = {
+                    startDate: old_item.find('[name="taskStartDate"]').val(),
+                    startHour: old_item.find('[name="taskStartHour"]').val(),
+                    endDate: old_item.find('[name="taskEndDate"]').val(),
+                    endHour: old_item.find('[name="taskEndHour"]').val(),
+                    dueDate: old_item.find('[name="taskDueDate"]').val(),
+                    dueTime: old_item.find('[name="taskDueTime"]').val(),
+                    allDay: old_item.find('[name="taskAllDay"]').val(),
+                    percentage: old_item.find('[name="taskPercentage"]').val(),
+                };
+
+                tasks.length += 1;
+
+    /*
+        		newTaskToActivity = DataLayer.put('taskToActivity', {
+        		    owner: User.me.id,
+                    task: old_item.find('.id').html(), 
+        		    activity: 'VER ISSO AQUI'
+        		});
+    */  							
+        		//attendees[old_item.find('.id').html()] = old_item.find('.name').html();
+        							
+        		blkAddTask.find('dd.task-activity-list ul.task-activity-list')
+        		.append(DataLayer.render(path+'templates/task_add_itemlist.ejs', [{
+                    idTask: old_item.find('[name="id"]').val(),
+        		    description: old_item.find('.description').html()
+        		 }]))
+        		.scrollTo('max');
+
+        	    callbackTask();
+                registerStatus();
+                blkAddTask.find('.not-activity').addClass('hidden');
+                old_item.remove();
+    	    }
+    	});
+
+    }
 	event.preventDefault();
     }
 });
 
-UI.dialogs.addActivity.find('.row.fileupload-buttonbar .button').filter('.delete').button({
+/*Carrega as tarefas jÃ¡ existentes em uma atividade*/
+if(objActivity.tasks.length){
+    tasks = objActivity.tasks;
+
+    for(var i in objActivity.tasks){
+        if(i != 'length')
+            blkAddTask.find('dd.task-activity-list ul.task-activity-list')
+                .append(DataLayer.render(path+'templates/task_add_itemlist.ejs', [{
+                    idTask: i,
+                    description: tasks[i].description,
+                    idTaskToActivity: tasks[i].taskToActivity
+                 }]))
+            .scrollTo('max');
+    }
+
+    callbackTask();
+    registerStatus();
+    blkAddTask.find('.not-activity').addClass('hidden');
+}
+
+UI.dialogs.addActivity.find('.row.fileupload-buttonbar-activity .button').filter('.delete').button({
     icons: {
-	primary: "ui-icon-close"
+	   primary: "ui-icon-close"
     },
     text: 'Excluir'
@@ -623,5 +549,5 @@
 	'type':     'question',
 	'overlay_opacity': '0.5',
-	'buttons':  ['Sim', 'Não'],
+	'buttons':  ['Sim', 'NÃ£o'],
 	'onClose':  function(clicked) {
 	    if(clicked == 'Sim'){
@@ -640,5 +566,5 @@
 .filter('.close').button({
     icons: {
-	primary: "ui-icon-close"
+	   primary: "ui-icon-close"
     },
     text: false
@@ -649,5 +575,5 @@
 .filter('.downlaod-archive').button({
     icons: {
-	primary: "ui-icon-arrowthickstop-1-s"
+	   primary: "ui-icon-arrowthickstop-1-s"
     },
     text: false
@@ -697,15 +623,15 @@
 	},
     done: function(e, data){
-	var currentUpload = $('.progress.after-upload:first').removeClass('after-upload').addClass('on-complete').hide();
-
-	if(!!data.result && data.result != "[]"){
-	    var newAttach = (attch = jQuery.parseJSON(data.result)) ? attch : jQuery.parseJSON(data.result[0].activeElement.childNodes[0].data);
-	    $('.attachment-list').append('<input tyepe="hidden" name="attachment[]" value="'+newAttach['attachment'][0][0].id+'"/>');
-	    currentUpload.removeClass('on-complete').parents('p')
-	    .append('<input type="hidden" name="fileId[]" value="'+newAttach['attachment'][0][0].id+'"/>')
-	    .find('.status-upload').addClass('ui-icon ui-icon-check');
-	}else
-	    currentUpload.removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel');
-    }
+    	var currentUpload = $('.progress.after-upload:first').removeClass('after-upload').addClass('on-complete').hide();
+
+    	if(!!data.result && data.result != "[]"){
+    	    var newAttach = (attch = jQuery.parseJSON(data.result)) ? attch : jQuery.parseJSON(data.result[0].activeElement.childNodes[0].data);
+    	    $('.attachment-list').append('<input tyepe="hidden" name="attachment[]" value="'+newAttach['attachment'][0][0].id+'"/>');
+    	    currentUpload.removeClass('on-complete').parents('p')
+    	    .append('<input type="hidden" name="fileId[]" value="'+newAttach['attachment'][0][0].id+'"/>')
+    	    .find('.status-upload').addClass('ui-icon ui-icon-check');
+    	}else
+    	    currentUpload.removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel');
+        }
 });
 $('.attachments-list .button').button();
@@ -779,37 +705,4 @@
     progressTimer = window.setInterval(intervalHandler, interval);
 });
-	
-if(objEvent.isShared){
-		
-    var acls = Calendar.signatureOf[objEvent.calendar].permission.acl;
-		
-    if(!acls.write){
-	UI.dialogs.addActivity.find(':input').attr('disabled', 'disabled');
-	UI.dialogs.addActivity.find('.button').hide();
-    }
-		
-    if(acls.remove)
-	UI.dialogs.addActivity.find('.button.remove').show();
-    
-    UI.dialogs.addActivity.find('.button.cancel').show();	
-}
-
-disponibily(objEvent, path, attendees);
-
-UI.dialogs.addActivity.find('.button-add-alarms').click(function(){
-    var li_attach = DataLayer.render(path+'templates/alarms_add_itemlist.ejs', {type: 1});
-
-    jQuery('.activity-alarms-list').append(li_attach).find('.button.remove').button({
-	text:false, 
-	icons:{
-	    primary:'ui-icon-close'
-	}
-    }).click(function(el) {
-		$(this).parent().remove().find('li').is(':empty')
-	});
-// valicacao de campos numericos
-$('.number').numeric();
-});
-
 
 UI.dialogs.addActivity.dialog('open');
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/helpers.js
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/helpers.js	(revision 6916)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/helpers.js	(revision 6945)
@@ -2522,5 +2522,5 @@
 		var data = {
 			type : type == "tasks" ? "task-list" : ( type == "events" ? "event-list" : "search"),
-			html : listEvents,					
+			html : listEvents
 		}
 		window_print.document.open();		
@@ -2713,5 +2713,5 @@
 				var data = {
 					type : $(this).parents('.details-event-list').hasClass("details-event") ? "event-detail" : "task-detail",
-					html : html,					
+					html : html
 				}
 				window_print.document.open();		
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/init.js
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/init.js	(revision 6934)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/init.js	(revision 6945)
@@ -440,39 +440,46 @@
 			evt.id = evt.id.split('-')[0];
             
-			if(evt.type == 1){
-
-                        if(evt.selectable){
-                            if(evt.isRepeat){
-                                $.Zebra_Dialog(evt.title + ' é um evento com repetição.', {
-                                        'type':     'question',
-                                        'overlay_opacity': '0.5',
-                                        'buttons':  ['Editar todas ocorrências', 'Editar essa ocorrência'],
-                                        'onClose':  function(clicked) {
-                                                if(clicked == 'Editar todas ocorrências') {
-                                                    eventDetails( DataLayer.get( "schedulable", evt.id), true);
-                                                }else{
-                                                    /*
-                                                    * TODO - repeat foi adicionado pois melhorias devem ser feitas no rollback do
-                                                    *DataLayer, repeat somente é usado quando se trata da criação de um evento
-                                                    *pela edição de uma ocorrência.
-                                                    */      
-                                                    var repeat = mount_exception(evt.id, evt.occurrence);
-                                                                                                  
-                                                    $('.calendar-copy-move input[name="typeEvent"]').val("3");
-                                                    
-                                                    eventDetails(copyAndMoveTo(false , evt.id , false, "3", evt), true, '', false, repeat);
-                                                }       
-                                        }
-                                });
-                            }else{
-				var schedulable = DataLayer.get( "schedulable", evt.id);
-				schedulable.group = evt.calendar;
-				eventDetails( schedulable, true);
-			    }
+            switch (parseInt(evt.type)){
+                case 1:
+                    if(evt.selectable){
+                        if(evt.isRepeat){
+                            $.Zebra_Dialog(evt.title + ' é um evento com repetição.', {
+                                'type':     'question',
+                                'overlay_opacity': '0.5',
+                                'buttons':  ['Editar todas ocorrências', 'Editar essa ocorrência'],
+                                'onClose':  function(clicked) {
+                                    if(clicked == 'Editar todas ocorrências') {
+                                        eventDetails( DataLayer.get( "schedulable", evt.id), true);
+                                    }else{
+                                        /*
+                                        * TODO - repeat foi adicionado pois melhorias devem ser feitas no rollback do
+                                        *DataLayer, repeat somente é usado quando se trata da criação de um evento
+                                        *pela edição de uma ocorrência.
+                                        */      
+                                        var repeat = mount_exception(evt.id, evt.occurrence);
+                                                                                          
+                                        $('.calendar-copy-move input[name="typeEvent"]').val("3");
+                                        
+                                        eventDetails(copyAndMoveTo(false , evt.id , false, "3", evt), true, '', false, repeat);
+                                    }       
+                                }
+                            });
+                        }else{
+                            var schedulable = DataLayer.get( "schedulable", evt.id);
+                            schedulable.group = evt.calendar;
+                            eventDetails( schedulable, true);
+                            }
                         }
-            }else{
-                var task = DataLayer.get( "schedulable", evt.id);
-                task.group = evt.calendar;
-                taskDetails( task, true);
+                        break;
+                    case 2:
+                        var task = DataLayer.get( "schedulable", evt.id);
+                        task.group = evt.calendar;
+                        taskDetails( task, true);
+                        break;
+                    case 3:
+                        var activity = DataLayer.get( "schedulable", evt.id);
+                        activity.group = evt.calendar;
+                        activityDetails( activity, true);
+                        break;
             }
 		},
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_search_itemlist.ejs
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_search_itemlist.ejs	(revision 6881)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_search_itemlist.ejs	(revision 6945)
@@ -1,11 +1,15 @@
 <% for (var i=0; i < data.length; i++) { %>
 <li class="ui-widget-content" title="<%=data[i]['name']%>" style="border: 0;">
-	<input type="checkbox" name="opcao" />
-	<input type="hidden" value="<%=data[i]['id']%>" />
-	<input class="id hidden" value="<%=data[i]['id']%>"/>
-    <input class="isExternal hidden" value="<%=data[i]['isExternal']%>"/>
-
-    <label class="name"><%=data[i]['name']%></label>
-	<label class="mail hidden"><%=data[i]['mail']%></label>
+	<input type="checkbox" name="option" <%= (data[i].enabled) ?  '' : 'disabled="disabled"' %> value="<%= data[i].id %>" />
+    <input type="hidden" name="id" value="<%=data[i]['id']%>" />
+    <input type="hidden" name="taskStartDate" value="<%=data[i]['startDate']%>" />
+    <input type="hidden" name="taskStartHour" value="<%=data[i]['startHour']%>" />
+    <input type="hidden" name="taskEndDate" value="<%=data[i]['endDate']%>" />
+    <input type="hidden" name="taskEndHour" value="<%=data[i]['endHour']%>" />
+    <input type="hidden" name="taskDueDate" value="<%=data[i]['dueDate']%>" />
+    <input type="hidden" name="taskDueTime" value="<%=data[i]['dueTime']%>" />
+    <input type="hidden" name="taskAllDay" value="<%=data[i]['allDay']%>" />
+    <input type="hidden" name="taskPercentage" value="<%=data[i]['percentage']%>" />
+    <label class="description"><%=data[i]['startDate']%> - <%=data[i]['description']%></label>
 </li>
 <% } %>
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/activity_add.ejs
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/activity_add.ejs	(revision 6881)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/activity_add.ejs	(revision 6945)
@@ -1,39 +1,36 @@
 <div title="Criar Tarefa" class="div-addactivity content">
-    <form method="POST" action="<%=(data.event.acl.organization || data.event.acl.write) ?  "schedulable:detail" : "schedulable:preview"%>" class="form-addevent content">
-
-	<fieldset id="calendar_addactivity_details1">
-		<legend class="hidden">Detalhes da tarefa</legend>
+    <form method="POST" action="schedulable:activity" class="form-addactivity content">
+
+	<fieldset id="group_addactivity_details1">
+		<legend class="hidden">Detalhes da atividade</legend>
 		<p class="input-group">
-			<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 %>"/>
+			<input type="text" class="h1" name="summary" value="<%= (data.activity.summary) ? data.activity.summary : '' %>"/>
+			<% if( data.activity.id ){ %>
+                <input type="hidden" class="id-activity" name="idActivity" value="<%= data.activity.id %>"/>
 			<% } %>
-                        <% if( data.event.id && data.event.calendar ){ %>
-				<input type="hidden" class="last-calendar" name="lastCalendar" value="<%= data.event.calendar %>"/>
+            <% if( data.activity.id && data.activity.group ){ %>
+				<input type="hidden" class="last-group" name="lastCalendar" value="<%= data.activity.group %>"/>
 			<% } %>
+            <input type="hidden" class="id-attendee" name="idAttendee" value="<%= data.activity.attendee[0] ? data.activity.attendee[0].id : '0'%>"/>
 		</p>
 		<p class="input-group date-info">
-			<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" /> 
+			<input type="text" class="date start-date" value="<%= (data.activity.startDate) ? data.activity.startDate : '' %>" name="startDate" />
+			<input type="text" class="time start-time<%= (data.activity.allDay) ? ' hidden' : '' %>" value="<%= (data.activity.startHour) ? data.activity.startHour : '' %>" name="startHour" /> 
 			<span>até</span>
-			<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" />
+			<input type="text" class="date end-date" value="<%= (data.activity.endDate) ? data.activity.endDate : '' %>" name="endDate" />
+			<input type="text" class="time end-time<%= (data.activity.allDay) ? ' hidden' : '' %>" value="<%= (data.activity.endHour) ? data.activity.endHour : '' %>" name="endHour" />
 
 				<span class="previsao-termino">Previsão término:</span>
-				<input type="text" class="date date-previsao">
-				<input type="text" class="time time-previsao">
-
-				<a href="#" class="calendar_addactivity_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-addactivity-details-txt-timezone">
+				<input type="text" class="date date-due" name="dueDate">
+				<input type="text" class="time time-due" name="dueHour">
+
+				<a href="#" class="group_addactivity_details_lnk_timezone">Fuso horário</a>
+			
+			<select name="timezone" class="hidden group-addactivity-details-txt-timezone">
 				<option value="">- None selected -</option>
-				<% for( var tzId in data.event.timezones ){ %>
-				  <option value="<%= tzId %>" <%= data.timezone === tzId ? 'selected="selected"' : '' %>><%= tzId + ' (' + data.event.timezones[ tzId ] + ')' %></option>
+				<% for( var tzId in data.activity.timezones ){ %>
+				  <option value="<%= tzId %>" <%= data.timezone === tzId ? 'selected="selected"' : '' %>><%= tzId + ' (' + data.activity.timezones[ tzId ] + ')' %></option>
 				<% } %>
 			</select>
-			
-			<a class="button suggestion-hours small <%=(data.event.acl.organization || data.event.acl.write || !data.event.isAttendee) ? "hidden" : '' %>" href="#">Sugerir horário</a>
 			
 		</p>
@@ -49,61 +46,49 @@
 		
 		<p class="input-group activity-type">
-			<input type="checkbox" name="allDay" value="true" <%= (data.event.acl.organization || data.event.acl.write) ? '' : 'disabled="disabled"' %> <%= (data.event.allDay) ? 'checked="checked"' : '' %>/>
+			<input type="checkbox" name="allDay" value="true" <%= (data.activity.allDay) ? 'checked="checked"' : '' %>/>
 			<label for="allDay">Dia inteiro</label>
 		</p>
 		<div class="subitem">
-				% Conclusão: <input type="number" class="done" value="1"> 
-				<span class="span_done"><input type="checkbox" class="button-repeat" /> Completo<span>
-				<select style="margin: 0 0 0 20px;">
-					<option>Desenvolvimento</option>
-				</select>
-				<span style="margin:0 0 0 20px;">Prioridade<span> 
-				<select>
-					<option>Alta</option>
-					<option selected="selected">Média</option>
-					<option>Baixa</option>
-				</select>
-		</div>
+                % Conclusão: <input type="number" name="percentage" class="done" value="<%= data.activity.percentage %>"> 
+                <span style="margin:0 0 0 5px;">Status:<span> 
+                <select name="activityStatus" style="margin: 0 0 0 5px;">
+                    <option <%= (data.activity.activityStatus == '1') ? 'selected="selected"' : '' %> value="1">Sem ações</option>
+                    <option <%= (data.activity.activityStatus == '2') ? 'selected="selected"' : '' %> value="2">Em Processo</option>
+                    <option <%= (data.activity.activityStatus == '3') ? 'selected="selected"' : '' %> value="3">Finalizada</option>
+                    <option <%= (data.activity.activityStatus == '4') ? 'selected="selected"' : '' %> value="4">Cancelada</option>
+                </select>
+                <span style="margin:0 0 0 5px;">Prioridade<span> 
+                <select name="priority">
+                    <option <%= (data.activity.priority == '1') ? 'selected="selected"' : '' %> value="1">Alta</option>
+                    <option <%= (data.activity.priority == '2') ? 'selected="selected"' : '' %> value="2">Normal</option>
+                    <option <%= (data.activity.priority == '3') ? 'selected="selected"' : '' %> value="3">Baixa</option>
+                </select>
+                <span class="span_done"><img src="../prototype/modules/calendar/img/empty-status.png"/> Completo<span>
+        </div>
 	</fieldset>
 	<ul style="width: 710px">
-		<li><a href="#calendar_addactivity_details2">Detalhes da tarefa</a></li>
-		<li><a href="#calendar_addactivity_details8">Tarefas</a></li>
-		<li><a href="#calendar_addactivity_details4">Lembretes</a></li>
-		<li><a href="#calendar_addactivity_details5">Anexos</a></li>
-		<li><a href="#calendar_addactivity_details6">Histórico</a></li>
+		<li><a href="#group_addactivity_details2">Detalhes da atividade</a></li>
+		<li><a href="#group_addactivity_details8">Tarefas</a></li>
+		<li><a href="#group_addactivity_details4">Lembretes</a></li>
+		<li><a href="#group_addactivity_details5">Anexos</a></li>
+		<li><a href="#group_addactivity_details6">Histórico</a></li>
 	</ul>
-	<fieldset id="calendar_addactivity_details2" class="tab-level2">
-		<legend class="hidden">Detalhes do evento</legend>
+	<fieldset id="group_addactivity_details2" class="tab-level2">
+		<legend class="hidden">Detalhes da atividade</legend>
 
 		<p class="input-group">
-			<label for="calendar_addactivity_details_txtarea_description" class="for-textarea" >Descrição</label>
-			<textarea name="description" <%= (data.event.acl.organization || data.event.acl.write) ? '' : 'disabled="disabled"' %> ><%=(data.event) ? data.event.description : '' %></textarea>
+			<label for="group_addactivity_details_txtarea_description" class="for-textarea" >Descrição</label>
+			<textarea name="description"><%=(data.activity) ? data.activity.description : '' %></textarea>
 		</p>
 
 		<p class="input-group">
-			<label for="calendar_addactivity_details_slt_cal">Grupo</label>
-				<select>
-					<% 
-					  for (var i=0; i< data.event.calendars.length; i++) {
-					    if(data.event.calendars[i].id != data.event.calendar && Calendar.signatureOf[data.event.calendars[i].id].isOwner != '1' && (!Calendar.signatureOf[data.event.calendars[i].id].permission.acl.write) )
-						continue;
-					%>
-					      <option value="<%= data.event.calendars[i].id %>" <%= data.event.calendars[i].id == data.event.calendar ? 'selected="selected"':'' %>>
-					      <%= data.event.calendars[i].name %>
-					      </option>
-					<% } %>
-				</select>
-			<!--<select name="calendar" >
-			<% 
-			  for (var i=0; i< data.event.calendars.length; i++) {
-			    if(data.event.calendars[i].id != data.event.calendar && Calendar.signatureOf[data.event.calendars[i].id].isOwner != '1' && !Calendar.signatureOf[data.event.calendars[i].id].permission.acl.write)
-				continue;
-			%>
-			      <option value="<%= data.event.calendars[i].id %>" <%= data.event.calendars[i].id == data.event.calendar ? 'selected="selected"':'' %>>
-			      <%= data.event.calendars[i].name %>
-			      </option>
-			<% } %>
+			<label for="group_addactivity_details_slt_cal">Grupo</label>
+			<select name="group">
+				<% for (var i=0; i< data.activity.groups.length; i++) {	%>
+                    <option value="<%= data.activity.groups[i].id %>" <%= data.activity.groups[i].id == data.activity.group ? 'selected="selected"':'' %>>
+				       <%= data.activity.groups[i].name %>
+			        </option>
+				<% } %>
 			</select>
-		-->
 		</p>
 		
@@ -114,7 +99,7 @@
 				<label class="input-group">Mostrar-me como</label>
 				<input type="radio" checked="checked"/>
-				<label for="calendar_addevent_details_rdo_status1">Dispon?vel</label>
+				<label for="group_addactivity_details_rdo_status1">Dispon?vel</label>
 				<input type="radio"/>
-				<label for="calendar_addevent_details_rdo_status2">Ocupado</label>
+				<label for="group_addactivity_details_rdo_status2">Ocupado</label>
 			</p>
 			-->
@@ -122,9 +107,9 @@
 				<label class="input-group">Privacidade</label>
 				<input type="radio" name="class" value="1" checked="checked"/>
-				<label for="calendar_addactivity_details_rdo_class1">Padrão</label>
+				<label for="group_addactivity_details_rdo_class1">Padrão</label>
 				<input type="radio" name="class" value="2" />
-				<label for="calendar_addactivity_details_rdo_class2">Público</label>
+				<label for="group_addactivity_details_rdo_class2">Público</label>
 				<input type="radio" name="class" value="3" />
-				<label for="calendar_addactivity_details_rdo_class3">Privado</label>
+				<label for="group_addactivity_details_rdo_class3">Privado</label>
 			</p>
 			
@@ -134,8 +119,8 @@
 	
 	<div class="overflow_add_calender">
-	<fieldset id="calendar_addactivity_details4" class="tab-level2">
+	<fieldset id="group_addactivity_details4" class="tab-level2">
 		<legend class="hidden">Lembretes</legend>
 		
-		<p class="default-alarm-event <%= (!data.event.id && data.event.alarms) ? '' : 'hidden'%>">
+		<p class="default-alarm-activity <%= (!data.activity.id && data.activity.alarms) ? '' : 'hidden'%>">
 			<input type="checkbox" name="defaultAlarm" value="true" checked="checked"/>
 			<label class="input-default-alarm" for="defautAlarm">Usar alarmes padrões</label>
@@ -143,26 +128,27 @@
 	
 		<ul class="activity-alarms-list">
-			<% if (data.event && data.event.alarms) {
-				for (var i=0; i< data.event.alarms.length; i++) {
+			<% if (data.activity && data.activity.attendee && !!data.activity.attendee.length && data.activity.attendee[0].alarms) {
+				var alarms = data.activity.attendee[0].alarms;
+				for (var i=0; i< alarms.length; i++) {
 			%>
 			<li class="input-group">
-				<label>Avisar-me por </label>
-				<select name="alarmType[]">
-                                    <option value="alert" <%= data.event.alarms[i].type=='alert' ? 'selected="selected"':'' %>>Alerta</option>
-                                    <option value="mail" <%= data.event.alarms[i].type=='mail' ? 'selected="selected"':'' %>>E-mail</option>
-                                    <!--<option value="sms" <%= data.event.alarms[i].type=='sms' ? 'selected="selected"':'' %>>SMS</option>-->
-				</select>
-				<input type="text" name="alarmTime[]" class="number input-small" value="<%= data.event.alarms[i].time %>"/>
-				<select name="alarmUnit[]">
-					<option value="m" <%= data.event.alarms[i].unit=='m' ? 'selected="selected"':'' %>>Minutos</option>
-					<option value="h" <%= data.event.alarms[i].unit=='h' ? 'selected="selected"':'' %>>Horas</option>
-					<option value="d" <%= data.event.alarms[i].unit=='d' ? 'selected="selected"':'' %>>Dias</option>
-				</select>
-				<input type="hidden" name="alarmId[]" value="<%=data.event.useAlarmDefault ? '' : data.event.alarms[i].id%>" />
-				<input type="hidden" name="isDefaultAlarm[]" value="<%=data.event.useAlarmDefault ? 1 : 0%>" />
-				<label> antes de cada evento.</label>
+			    <label>Avisar-me por </label>
+			    <select name="alarmType[]">
+				<option value="alert" <%= alarms[i].type=='alert' ? 'selected="selected"':'' %>>Alerta</option>
+				<option value="mail" <%= alarms[i].type=='mail' ? 'selected="selected"':'' %>>E-mail</option>
+				<!--<option value="sms" <%= alarms[i].type=='sms' ? 'selected="selected"':'' %>>SMS</option>-->
+			    </select>
+			    <input type="text" name="alarmTime[]" class="number input-small" value="<%= alarms[i].time %>"/>
+			    <select name="alarmUnit[]">
+				<option value="m" <%= alarms[i].unit=='m' ? 'selected="selected"':'' %>>Minutos</option>
+				<option value="h" <%= alarms[i].unit=='h' ? 'selected="selected"':'' %>>Horas</option>
+				<option value="d" <%= alarms[i].unit=='d' ? 'selected="selected"':'' %>>Dias</option>
+			    </select>
+				<input type="hidden" name="alarmId[]" value="<%=data.activity.useAlarmDefault ? '' : alarms[i].id%>" />
+				<input type="hidden" name="isDefaultAlarm[]" value="<%=data.activity.useAlarmDefault ? 1 : 0%>" />
+				<label> antes de cada activityo.</label>
 				<a class="button remove tiny"></a>
 			</li>
-			<%	}
+			<%}
 			   }
 			%>
@@ -173,5 +159,5 @@
 	</div>
 	
-	<fieldset id="calendar_addactivity_details6" class="tab-level2" title="Participantes">
+	<fieldset id="group_addactivity_details6" class="tab-level2" title="Participantes">
 		<div class="parent"  >
 			
@@ -193,12 +179,12 @@
 	</fieldset>	
 	
-	<fieldset id="calendar_addactivity_details8" class="tab-level2" title="Tarefas">
+	<fieldset id="group_addactivity_details8" class="tab-level2" title="Tarefas">
 		
 	</fieldset>
 
 	<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%>"/>
+             <%if(data.activity && data.activity.attachments){
+                for (var i=0; i< data.activity.attachments.length; i++) {%>
+                    <input type="hidden" name="fileId[]" value="<%=data.activity.attachments[i].id%>"/>
                 <%}
             }%>
@@ -207,5 +193,5 @@
     
 <div class="overflow_add_calender">
-	<fieldset id="calendar_addactivity_details5" class="tab-level2">
+	<fieldset id="group_addactivity_details5" class="tab-level2">
         <form id="fileupload" action="attachment:detail" method="POST">
         <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
@@ -213,33 +199,32 @@
             <div class="button-files-upload">
                 <!-- The fileinput-button span is used to style the file input field as button -->
-                <%if(data.event.acl.organization || data.event.acl.write){%>
-		    <span class="button btn-success fileinput-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>
-				<%}%>
+
+				<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++) {
+			   <%if(data.activity && data.activity.attachments){
+					for (var i=0; i< data.activity.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>
+							<span class="archive-nome"><%=data.activity.attachments[i].name%></span>
 							
 							<label class="lbl-archive-size">Tamanho:</label>
-							<span class="archive-size"><%=data.event.attachments[i].size%></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 edit delete-upload" title="Deletar">Deletar</span>
-							<%}%>
-							<input type="hidden" name="fileId[]" value="<%=data.event.attachments[i].id%>"/>
+							<span class="archive-size"><%=data.activity.attachments[i].size%></span>
+							<a href="../prototype/getArchive.php?attachment=<%=data.activity.attachments[i].id%>" class="button tiny upload downlaod-archive">Download</a>
+							
+							<span class="button close tiny upload edit delete-upload" title="Deletar">Deletar</span>
+						
+							<input type="hidden" name="fileId[]" value="<%=data.activity.attachments[i].id%>"/>
 						</p>
 					<%}
@@ -255,10 +240,10 @@
 	</fieldset>
 </div>
-	<form action="../prototype/modules/calendar/export.php" method="GET" class="form-export content">
-		<input type="hidden" class="id-activity" name="activity" value="<%= data.event.id %>"/>
+	<form action="../prototype/modules/group/export.php" method="GET" class="form-export content">
+		<input type="hidden" class="id-activity" name="activity" value="<%= data.activity.id %>"/>
 	</form>
 
     <div title="" class="menu-container footer-container menu-addactivity">
-	    <% if (data.event.id) { %>
+	    <% if (data.activity.id) { %>
 			<a title="Exportar" class="button export" href="#">Exportar</a>
 			<a title="Excluir" class="button delete" href="#">Excluir</a>
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/index.ejs
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/index.ejs	(revision 6881)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/index.ejs	(revision 6945)
@@ -158,5 +158,3 @@
 	</div>
 </body>
-
 </html>
-
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_add.ejs
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_add.ejs	(revision 6876)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_add.ejs	(revision 6945)
@@ -77,5 +77,5 @@
 		<li><a href="#calendar_addtask_details6">Participantes</a></li>
 		<li><a href="#calendar_addtask_details7">Disponibilidade</a></li>
-		<li><a href="#calendar_addtask_details8">Histórico de alterações</a></li>
+		<li><a href="#calendar_addtask_details8">Histórico</a></li>
 	</ul>
 	<fieldset id="calendar_addtask_details2" class="tab-level2">
@@ -163,5 +163,5 @@
 	</fieldset>
 	
-	<fieldset id="calendar_addtask_details8" class="tab-level2" title="Histórico de alterações">
+	<fieldset id="calendar_addtask_details8" class="tab-level2" title="Histórico">
 		<div class="parent"  >
 			
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_add_itemlist.ejs
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_add_itemlist.ejs	(revision 6881)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_add_itemlist.ejs	(revision 6945)
@@ -1,15 +1,12 @@
-<li class="attendee"> 
+<%console.log(data)%>
+<li class="task"> 
 	<div style="overflow:hidden; width:100%; display:table;">	
 		<div class="activity-options" style="float: right; margin: 0 10px 0 0;">
-			<a class="button edit activity-options-button-edit new ui-icon-notice">InformaÃ§Ãµes</a>
+			<a class="button info activity-options-button-edit new ui-icon-notice">InformaÃ§Ãµes</a>
 			<a class="button close new">Remover</a>
 		</div>	
-		<input class="new" type="checkbox" value="<%= data[0].id %>">
-		<input type="hidden" name="attendee[]" value="<%= data[0].id %>">
-		<input type="hidden" name="attendeeType[]" value="<%=data[0].isExternal%>">
-		<input type="hidden" name="attendeeAcl[]" value="r">
-		<input type="hidden" name="delegatedFrom[]" value="0">
-		<label title="<%= data[0].name ? data[0].name : '' %>" class="name"><%= data[0].name ? data[0].name : '' %></label>
-		<label title="<%= data[0].mail ? data[0].mail : '' %>" class="mail <%= data[0].name ? 'hidden' : ''%>"><%= data[0].mail ? data[0].mail : '' %></label>
-	</div>
+		<input class="new" type="checkbox" value="<%= data[0].idTask %>">
+        <input type="hidden" name="idtask[]" value="<%= data[0].idTask %>">
+		<input type="hidden" name="idTaskToActivity[]" value="<%= data[0].idTaskToActivity %>">
+		<label title="<%= data[0].description %>" class="name"><%= data[0].description %></label>
 </li>
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_activity_add.ejs
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_activity_add.ejs	(revision 6881)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/templates/task_activity_add.ejs	(revision 6945)
@@ -1,9 +1,20 @@
-	<dl class="block-activity-list activitys-list">
-		<dt class="activity-list">Tarefas</dt>
+    <dl class="block-activity-group-select activitys-list">
+        <dt class="activity-group-select">Grupo de evento</dt>
+        <dd class="group-select">
+            <ul class="activity-group-select">
+                <select name="groupFilter">
+                    <%for(var i = 0; i < Calendar.groups.length; i++){%>
+                        <option value="<%= Calendar.groups[i].id  %>"><%= Calendar.groups[i].name %></option>
+                    <%}%>
+                </select>
+            </ul>
+        </dd>
+    
+	<dt class="activity-list">Tarefas</dt>
 		<dd class="task-activity-list">
 			<ul class="task-activity-list">
 
-	<% if(data.event.me.id == data.event.organizer.id && !(data.event.attendee.length > 0) ) { %>
-			<li class="not-activity">Não há outros participantes.</li>
+	<% if(data.activity.tasks.length <= 0) { %>
+		<li class="not-activity">Não há outras tarefas.</li>
 	<% } %>
 		
@@ -13,5 +24,5 @@
 
 <dl class="block-add-activity search" style="">
-	<dt class="add-activity search">Adicionar tarefa</dt>
+	<dt class="add-activity search">Pesquisar tarefa</dt>
 	<dd class="add-activity">
 		<fieldset class="block-add-activity" title="Participantes">
