Changeset 7861


Ignore:
Timestamp:
02/06/13 09:53:21 (7 years ago)
Author:
acoutinho
Message:

Ticket #3340 - Falha ao alterar o grupo de uma tarefa quando inserido em uma atividade

Location:
trunk/prototype/modules/calendar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/modules/calendar/interceptors/DBMapping.php

    r7795 r7861  
    594594            //necessário para atulizar a atividade de composta pela tarefa aqui sendo atualizada 
    595595            if(isset($criteria['historic']['startTime']) || isset($criteria['historic']['endTime'])){ 
     596                /* 
     597                 * Verify current task is built-in activity 
     598                 * */ 
    596599                $taskToActivity = Controller::find(array('concept' => 'taskToActivity'), false, array('filter' => array('AND', array('=', 'task', $uri['id']), array('=', 'owner', Config::me('uidNumber'))), 'deepness' => 2)); 
    597600                if(!empty($taskToActivity)){ 
     
    599602                    $isAllDay = 1; 
    600603 
     604                    /* 
     605                     * Get all task in activity 
     606                     * */ 
     607                    $taskToActivity = Controller::find(array('concept' => 'taskToActivity'), false, array('filter' => array('AND', array('=', 'activity', $taskToActivity[0]['activity']), array('=', 'owner', Config::me('uidNumber'))), 'deepness' => 2)); 
     608 
    601609                    if(!empty($activity)){ 
    602610                        $start = $params['startTime']; 
    603611                        $end = $params['endTime']; 
    604612                        foreach($taskToActivity as $t){ 
    605                          if($t['task']['id'] != $params['id']){ 
    606                             $start = $t['task']['startTime'] < $start ? $t['task']['startTime'] : $start; 
    607                             $end = $t['task']['endTime'] > $end ? $t['task']['endTime'] : $end; 
    608                             $isAllDay = (($isAllDay == 1) && ($t['task']['allDay'] == '1')) ? 1 : 0; 
    609                          } 
     613 
     614 
     615                            if($t['task']['id'] != $params['id']){ 
     616                                $start = $t['task']['startTime'] < $start ? $t['task']['startTime'] : $start; 
     617                                $end = $t['task']['endTime'] > $end ? $t['task']['endTime'] : $end; 
     618                                $isAllDay = (($isAllDay == 1) && ($t['task']['allDay'] == '1')) ? 1 : 0; 
     619                            } 
    610620                        } 
    611621 
     
    631641                } 
    632642            } 
    633  
     643            /* 
     644             * Clean historic not used 
     645             * */ 
    634646            unset($criteria['historic']['endTime']); 
    635647            unset($criteria['historic']['rangeEnd']); 
     
    841853    } 
    842854 
     855    public function getCalendarTask( $task ){ 
     856 
     857        $sql = 'select co.calendar_id as "calendar" from calendar_to_calendar_object as "co", calendar_signature as "cs" where cs.user_uidnumber = '. Config::me('uidNumber') 
     858            .' AND cs.is_owner = 1 AND cs.calendar_id = co.calendar_id AND co.calendar_object_id = '. $task; 
     859 
     860 
     861        $returns = Controller::service('PostgreSQL')->execResultSql($sql); 
     862 
     863        return $returns[0]['calendar']; 
     864    } 
     865 
    843866    //TODO: Remover apos suporte a deepness na api  
    844867    public function deepnessFindTask(&$uri, &$result, &$criteria, $original) { 
    845         if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0)  
    846            foreach($result as &$value) 
     868        if (isset($criteria['deepness']) && $criteria['deepness'] != 0){ 
     869 
     870            foreach($result as &$value){ 
     871 
    847872                $value['task'] = Controller::read(array('concept' => 'schedulable', 'id' => $value['task'])); 
    848             
    849          
    850         return $result; 
     873                $value['task']['calendar'] = self::getCalendarTask( $value['task']['id'] ); 
     874            } 
     875 
     876            return $result; 
     877        } 
    851878    } 
    852879 
    853880    //TODO: Remover apos suporte a deepness na api  
    854881    public function deepnessFindHistoric(&$uri, &$result, &$criteria, $original) { 
    855         if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) { 
     882        if (isset($criteria['deepness']) && $criteria['deepness'] != 0) { 
    856883            foreach($result as &$v){ 
    857884                $v['user'] = Controller::read(array('concept' => 'user', 'id' => $v['user'])); 
     
    883910                .'calendar_object.range_end as "rangeEnd", calendar_object.last_update as "lastUpdate", ' 
    884911                .'calendar_object.dtstamp as "dtstamp", calendar_object.sequence as "sequence", ' 
    885                 .'calendar_object.tzid as "timezone" ' 
    886                 .'FROM calendar_object ' 
    887                 .'WHERE ( calendar_object.id = '. $criteria['schedulable'] .')'; 
     912                .'calendar_object.tzid as "timezone", calendar_to_calendar_object.calendar_id as "calendar" ' 
     913                .'FROM calendar_object, calendar_to_calendar_object ' 
     914                .'WHERE ( calendar_object.id = '. $criteria['schedulable'] .' AND calendar_to_calendar_object.calendar_object_id = calendar_object.id)'; 
    888915 
    889916            $params = Controller::service('PostgreSQL')->execResultSql($sql); 
     917 
     918            foreach( $params as &$event ){ 
     919 
     920 
     921                if(isset( $event['repeat'] ) && isset( $event['repeat']['id'] ) ){ 
     922                    $occurrences = Controller::service('PostgreSQL')->execResultSql('SELECT DISTINCT occurrence FROM calendar_object as "c", calendar_repeat_occurrence as "o", calendar_repeat as "r" WHERE r.object_id = '. $event['id'] .' AND o.repeat_id = r.id ' ); 
     923 
     924                    if($occurrences){ 
     925                        $event['occurrences'] = array(); 
     926 
     927                        foreach($occurrences as $o) 
     928                            $event['occurrences'][] = $o['occurrence']; 
     929                    }else 
     930                        unset( $event['occurrences'] ); 
     931                } 
     932            } 
    890933 
    891934            $params = self::deepnessFindEvent($uri, $params, $criteria, $original); 
    892935            return false; 
    893936        } 
    894  
    895  
    896  
    897937    } 
    898938 
    899939    //TODO: Remover apos suporte a deepness na api  
    900940    public function deepnessFindEvent(&$uri, &$result, &$criteria, $original) { 
    901         if ((isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) ) { 
     941        if ((isset($criteria['deepness']) && $criteria['deepness'] != 0) ) { 
    902942 
    903943            $date = new DateTime('now', new DateTimeZone('UTC')); 
     
    9881028    public static function deepnessReadParticipant( &$uri , &$result , &$criteria , $original ){ 
    9891029         
    990        if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 
     1030       if(isset($criteria['deepness']) && $criteria['deepness'] != 0) 
    9911031       { 
    9921032            if(isset($result['id']) && isset($result['user'])) 
  • trunk/prototype/modules/calendar/js/activity.helpers.js

    r7680 r7861  
    259259                    ['=', 'type', '2'],  
    260260                    ['>=','startTime', $.now()],  
    261                     ['in', 'calendar',  
    262                         [$('div.new-activity-win.active select[name="groupFilter"]').val()] 
    263                     ] 
     261                    ['in', 'calendar', [$('div.new-activity-win.active select[name="groupFilter"]').val()]] 
    264262                ], criteria: {filterTasks: true, deepness: 2} 
    265263        }; 
     
    412410    updateActivity = false; 
    413411 
    414     var objActivity = DataLayer.get('schedulable:activity', UI.dialogs.addActivity.find('input[name="idActivity"]').val()); 
     412    var idTask = UI.dialogs.addActivity.find('input[name="idActivity"]').val(); 
     413 
     414    getSchedulable( idTask ); 
     415 
     416    var objActivity = DataLayer.get('schedulable:activity', idTask ); 
    415417    var blkAddTask = UI.dialogs.addActivity.find('#group_addactivity_details8'); 
    416418    var blkAuto = UI.dialogs.addActivity.find('#group_addactivity_details1'); 
     
    671673            text: false 
    672674        }).click(function () { 
    673             var task = DataLayer.get('schedulable:task', $(this).parents('li').find('input[name="idtask[]"]').val()); 
    674             taskDetails(task, true, '',true, null, true);            
     675 
     676            var idTask = $(this).parents('li').find('input[name="idtask[]"]').val() 
     677            getSchedulable(idTask); 
     678            var task = DataLayer.get('schedulable:task', idTask); 
     679            taskDetails(task, true, '',true, null, true); 
    675680        }) 
    676681        .addClass('tiny disable ui-button-disabled ui-state-disabled') 
  • trunk/prototype/modules/calendar/js/calendar.codecs.js

    r7790 r7861  
    201201 
    202202            Calendar.rerenderView(true); 
    203             if(updateActivity) 
     203            if(updateActivity){ 
     204 
     205                DataLayer.remove('taskToActivity', false); 
    204206                refreshTaskActivity(); 
     207            } 
     208 
    205209        }); 
    206210    } 
Note: See TracChangeset for help on using the changeset viewer.