Changeset 4049


Ignore:
Timestamp:
04/15/11 16:53:03 (13 years ago)
Author:
brunocosta
Message:

Ticket #1745 - Nova visão semanal e mensal da agenda.

Location:
branches/2.2.0.1/calendar
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.0.1/calendar/inc/class.uicalendar.inc.php

    r4030 r4049  
    495495                function month() 
    496496                { 
    497                         echo $this->printer_friendly($this->get_month(),lang('Monthview')); 
     497                        if($_GET['month']||$_POST['month']){ 
     498                            $params['month'] = $_GET['month']?(int)$_GET['month']:(int)$_POST['month']; 
     499                            $params['year'] = $_GET['year']?(int)$_GET['year']:(int)$_POST['year']; 
     500                            $params['day'] = 1; 
     501 
     502                        }else{ 
     503                            $params['day'] = $_post['date']?(int)substr($_POST['date'] , 6, 2):(int)substr($_GET['date'] , 6, 2); 
     504                            $params['month'] = $_post['date']?(int)substr($_POST['date'] , 4, 2):(int)substr($_GET['date'] , 4, 2); 
     505                            $params['year'] = $_post['date']?(int)substr($_POST['date'] , 0, 4):(int)substr($_GET['date'] , 0, 4); 
     506 
     507                        } 
     508 
     509                        echo $this->printer_friendly($this->print_month_new($params),lang('Weekview')); 
    498510                        $GLOBALS['phpgw']->common->phpgw_footer(); 
    499511                } 
     
    689701                function week() 
    690702                { 
    691                         echo $this->printer_friendly($this->get_week(),lang('Weekview')); 
     703 
     704                        if($_GET['month']||$_POST['month']){ 
     705                            $params['month'] = $_GET['month']?(int)$_GET['month']:(int)$_POST['month']; 
     706                            $params['year'] = $_GET['year']?(int)$_GET['year']:(int)$_POST['year']; 
     707                            $params['day'] = 1; 
     708 
     709                        }else{ 
     710                            $params['day'] = $_post['date']?(int)substr($_POST['date'] , 6, 2):(int)substr($_GET['date'] , 6, 2); 
     711                            $params['month'] = $_post['date']?(int)substr($_POST['date'] , 4, 2):(int)substr($_GET['date'] , 4, 2); 
     712                            $params['year'] = $_post['date']?(int)substr($_POST['date'] , 0, 4):(int)substr($_GET['date'] , 0, 4); 
     713 
     714                        } 
     715 
     716                        echo $this->printer_friendly($this->print_week_new($params),lang('Weekview')); 
    692717                        $GLOBALS['phpgw']->common->phpgw_footer(); 
    693718                } 
     
    33953420                        ); 
    33963421                        $this->output_template_array($p,'b_row2','form_button',$var); 
    3397                         if ( $menuaction == 'calendar.uicalendar.week' || ($menuaction == 'calendar.uicalendar.month' && $account_prefs['calendar']['type_month_print'] == '1')) 
    3398                           { 
    3399                             $aux = explode('.',$menuaction); 
    3400                             $typeview = $aux[2]; 
    3401                             if($typeview == 'week') 
    3402                                 $params['period'] = 2; 
    3403                             else 
    3404                                 $params['period'] = 3; 
    3405                                          
    3406                             if(isset($_GET['date'])) 
    3407                                 $date = $_GET['date']; 
    3408                             else 
    3409                                 $date = $_POST['date']; 
    3410                             if($date) 
    3411                             { 
    3412                                 $params['year'] = substr($date, 0,4); 
    3413                                 $params['month'] = substr($date, 4,2); 
    3414                                 $params['day'] = substr($date, 6,2); 
    3415                             } 
    3416                             else 
    3417                             { 
    3418                                 $params['year'] = $_GET['year']?$_GET['year']:$_POST['year']; 
    3419                                 $params['month'] = $_GET['month']?$_GET['month']:$_POST['month']; 
    3420                                 if(!$params['month']) 
    3421                                 { 
    3422                                     $params['month'] = $this->bo->month; 
    3423                                 } 
    3424                                 $params['day'] = $this->bo->day; 
    3425                             } 
    3426  
    3427                             $result_events_json = $this->print_events_to_show_json($params); 
    3428                             $var = Array( 
    3429                                     'typeview'                  => $typeview, 
    3430                                     'typeview_aux'              => $typeview, 
    3431                                     'date'                      => $result_events_json['date_events_json'], 
    3432                                     'hora_final'                => $result_events_json['hora_final'], 
    3433                                     'hora_inicial'              => $result_events_json['hora_inicial'], 
    3434                                     'events_json'               => json_encode($result_events_json['events_to_show_json'])?json_encode($result_events_json['events_to_show_json']):'null' 
    3435                                     ); 
    3436                             $this->output_template_array($p,'place_component','new_component',$var); 
    3437                           } 
    3438                        else 
    3439                           { 
     3422//                        if ( $menuaction == 'calendar.uicalendar.week' || ($menuaction == 'calendar.uicalendar.month' && $account_prefs['calendar']['type_month_print'] == '1')) 
     3423//                          { 
     3424//                            $aux = explode('.',$menuaction); 
     3425//                            $typeview = $aux[2]; 
     3426//                            if($typeview == 'week') 
     3427//                                $params['period'] = 2; 
     3428//                            else 
     3429//                                $params['period'] = 3; 
     3430// 
     3431//                            if(isset($_GET['date'])) 
     3432//                                $date = $_GET['date']; 
     3433//                            else 
     3434//                                $date = $_POST['date']; 
     3435//                            if($date) 
     3436//                            { 
     3437//                                $params['year'] = substr($date, 0,4); 
     3438//                                $params['month'] = substr($date, 4,2); 
     3439//                                $params['day'] = substr($date, 6,2); 
     3440//                            } 
     3441//                            else 
     3442//                            { 
     3443//                                $params['year'] = $_GET['year']?$_GET['year']:$_POST['year']; 
     3444//                                $params['month'] = $_GET['month']?$_GET['month']:$_POST['month']; 
     3445//                                if(!$params['month']) 
     3446//                                { 
     3447//                                    $params['month'] = $this->bo->month; 
     3448//                                } 
     3449//                                $params['day'] = $this->bo->day; 
     3450//                            } 
     3451// 
     3452//                            $result_events_json = $this->print_events_to_show_json($params); 
     3453//                            $var = Array( 
     3454//                                    'typeview'                  => $typeview, 
     3455//                                    'typeview_aux'              => $typeview, 
     3456//                                    'date'                    => $result_events_json['date_events_json'], 
     3457//                                    'hora_final'              => $result_events_json['hora_final'], 
     3458//                                    'hora_inicial'            => $result_events_json['hora_inicial'], 
     3459//                                    'events_json'             => json_encode($result_events_json['events_to_show_json'])?json_encode($result_events_json['events_to_show_json']):'null' 
     3460//                                    ); 
     3461//                            $this->output_template_array($p,'place_component','new_component',$var); 
     3462//                          } 
     3463//                       else 
     3464//                          { 
    34403465                            $p->set_var('place_component',''); 
    3441                           } 
     3466//                          } 
    34423467                        $p->parse('table_row','blank_row',True); 
    34433468                        $p->pparse('out','footer_table'); 
     
    50745099                } 
    50755100 
     5101                      function print_week_new($params){ 
     5102 
     5103                        $p = CreateObject('phpgwapi.Template',$this->template_dir); 
     5104                        $p->set_unknowns('keep'); 
     5105 
     5106                        $tpl = 'new_week.tpl'; 
     5107 
     5108                        if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && 
     5109                                $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') 
     5110                        { 
     5111                                $tpl = 'day_list.tpl'; 
     5112                        } 
     5113 
     5114                           $minical_prev = $this->mini_calendar( 
     5115                                        Array( 
     5116                                                'day'   => 1, 
     5117                                                'month' => $this->bo->month -1, 
     5118                                                'year'  => $this->bo->year, 
     5119                                                'link'  => 'week', 
     5120                                                'outside_month' => False 
     5121                                        ) 
     5122                                ); 
     5123 
     5124                        $minical_next1 = $this->mini_calendar( 
     5125                                        Array( 
     5126                                                'day'   => 1, 
     5127                                                'month' => $this->bo->month + 1, 
     5128                                                'year'  => $this->bo->year, 
     5129                                                'link'  => 'week', 
     5130                                                'outside_month' => False 
     5131                                        ) 
     5132                                ); 
     5133 
     5134                        $minical_next = $this->mini_calendar( 
     5135                                        Array( 
     5136                                                'day'   => 1, 
     5137                                                'month' => $this->bo->month, 
     5138                                                'year'  => $this->bo->year, 
     5139                                                'link'  => 'week', 
     5140                                                'outside_month' => False 
     5141                                        ) 
     5142                                ); 
     5143                        $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); 
     5144 
     5145                        $templates = Array( 
     5146                                'new_week'   => $tpl, 
     5147                        ); 
     5148 
     5149                        $p->set_file($templates); 
     5150                        $p->set_block('new_week','day','day'); 
     5151                        $params['period'] = 2; 
     5152                        $result_events_json = $this->print_events_to_show_json($params); 
     5153                        $p->set_var('date',$result_events_json['date_events_json']); 
     5154                        $p->set_var('hora_final',$result_events_json['hora_final']); 
     5155                        $p->set_var('hora_inicial',$result_events_json['hora_inicial']); 
     5156                          $p->set_var('minical',$minical_prev.'<br>'.$minical_next.'<br>'.$minical_next1); 
     5157                        $p->set_var('title',lang(strftime("%B",$m)).' '.$this->bo->year); 
     5158                        $p->set_var('user',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)); 
     5159                        $p->set_var('events_json',json_encode($result_events_json['events_to_show_json'])?json_encode($result_events_json['events_to_show_json']):'null'); 
     5160                        return $p->fp('out','day'); 
     5161                } 
     5162 
     5163                function print_month_new($params){ 
     5164 
     5165                        $p = CreateObject('phpgwapi.Template',$this->template_dir); 
     5166                        $p->set_unknowns('keep'); 
     5167 
     5168                        $tpl = 'new_month.tpl'; 
     5169 
     5170                        if((int)($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'])==2 && 
     5171                                $GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') 
     5172                        { 
     5173                                $tpl = 'day_list.tpl'; 
     5174                        } 
     5175 
     5176 
     5177 
     5178                        $templates = Array( 
     5179                                'new_month'   => $tpl, 
     5180                        ); 
     5181 
     5182                        $minical_prev = $this->mini_calendar( 
     5183                                        Array( 
     5184                                                'day'   => 1, 
     5185                                                'month' => $this->bo->month -1, 
     5186                                                'year'  => $this->bo->year, 
     5187                                                'link'  => 'week', 
     5188                                                'outside_month' => False 
     5189                                        ) 
     5190                                ); 
     5191 
     5192                        $minical_next1 = $this->mini_calendar( 
     5193                                        Array( 
     5194                                                'day'   => 1, 
     5195                                                'month' => $this->bo->month + 2, 
     5196                                                'year'  => $this->bo->year, 
     5197                                                'link'  => 'week', 
     5198                                                'outside_month' => False 
     5199                                        ) 
     5200                                ); 
     5201 
     5202                        $minical_next = $this->mini_calendar( 
     5203                                        Array( 
     5204                                                'day'   => 1, 
     5205                                                'month' => $this->bo->month + 1, 
     5206                                                'year'  => $this->bo->year, 
     5207                                                'link'  => 'week', 
     5208                                                'outside_month' => False 
     5209                                        ) 
     5210                                ); 
     5211                        $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); 
     5212                        $p->set_file($templates); 
     5213                        $p->set_block('new_month','day','day'); 
     5214                        $params['period'] = 3; 
     5215                        $result_events_json = $this->print_events_to_show_json($params); 
     5216                        $p->set_var('date',$result_events_json['date_events_json']); 
     5217                        $p->set_var('hora_final',$result_events_json['hora_final']); 
     5218                        $p->set_var('hora_inicial',$result_events_json['hora_inicial']); 
     5219                        $p->set_var('minical',$minical_prev.'<br>'.$minical_next.'<br>'.$minical_next1); 
     5220                        $p->set_var('title',lang(strftime("%B",$m)).' '.$this->bo->year); 
     5221                        $p->set_var('user',$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner)); 
     5222                        $p->set_var('events_json',json_encode($result_events_json['events_to_show_json'])?json_encode($result_events_json['events_to_show_json']):'null'); 
     5223                        return $p->fp('out','day'); 
     5224                } 
    50765225 
    50775226                //função vai devolver os eventos do mês atual para exibição no novo componente da Agenda 
     
    51885337                                else 
    51895338                                { 
    5190                                     $text = $event['title']; 
     5339                                    $text = $event['title']." - ".$event['description']; 
    51915340                                } 
    51925341 
     
    54105559                        { 
    54115560                                $var = Array( 
    5412                                         'action_url_button'     => $this->page('set_action','&cal_id='.$cal_id.'&action='.$param), 
     5561                                        'action_url_button'     => $this->page('set_action','&cal_id='.$cal_id.'&action='.$param.'&user_id='.$this->bo->owner), 
    54135562                                        'action_text_button'    => '  '.$text.'  ', 
    54145563                                        'action_confirm_button' => '', 
  • branches/2.2.0.1/calendar/js/dhtmlx/server/pdfGenerator.php

    r4001 r4049  
    1010        public $offsetLeft = 10; 
    1111        public $offsetRight = 10; 
    12          
     12 
    1313        // header height of day container in month mode 
    1414        public $monthDayHeaderHeight = 6; 
     
    2323        // width of left scale in day and week mode 
    2424        public $dayLeftWidth = 16; 
    25          
     25 
    2626        // font size settings 
    2727        public $monthHeaderFontSize = 9; 
     
    7979                        case 'week': 
    8080                                $date = date("Ymd") . "_" . date("H:i"); 
    81                                 $this->orientation = 'L'; 
     81                                $this->orientation = 'P'; 
    8282                                $this->wrapper = new pdfWrapper($this->offsetTop, $this->offsetRight, $this->offsetBottom, $this->offsetLeft, $this->orientation); 
    83                                 $this->printDayWeek(); 
     83                                $this->printWeek(); 
    8484                                break; 
    8585                        case 'year': 
     
    102102//              print_r($this); 
    103103//              echo "</pre>"; 
    104                  
     104 
    105105                $this->wrapper->pdfOut($date); 
    106106        } 
    107107 
    108         // parses options profile, orientation, header and footer from xml  
     108        // parses options profile, orientation, header and footer from xml 
    109109        private function renderData($data) { 
    110110                if (isset($data->attributes()->profile)) { 
     
    177177                                $this->todayTextColor = '000000'; 
    178178                                $this->scaleColorOne = 'FFFFFF'; 
    179                                 $this->scaleColorTwo = 'FFFFFF';         
     179                                $this->scaleColorTwo = 'FFFFFF'; 
    180180                                $this->yearDayColor = 'FFFFFF'; 
    181181                                $this->yearDayColorInactive = 'FFFFFF'; 
     
    192192 
    193193                switch ($this->mode) { 
     194                        case 'week': 
     195                            foreach ($scales->x->column as $text) { 
     196                                        $this->topScales[] = (string) $text; 
     197                                } 
     198                                foreach ($scales->row as $text) { 
     199                                        $week = explode("|", $text); 
     200                                        $this->dayHeader[] = $week; 
     201                                } 
     202                                break; 
    194203                        case 'month': 
    195204                                foreach ($scales->x->column as $text) { 
     
    201210                                } 
    202211                                break; 
    203                                  
     212 
    204213                        case 'year': 
    205214                                foreach ($scales->month as $month) { 
     
    209218                                                $monthArr['columns'][] = (string) $col; 
    210219                                        } 
    211                                          
     220 
    212221                                        foreach ($month->row as $row) { 
    213222                                                $row = explode("|", $row); 
     
    217226                                } 
    218227                                break; 
    219                          
     228 
    220229                        case 'agenda': 
    221230                                $this->agendaHeader[0] = (string) $scales->column[0]; 
     
    224233 
    225234                        case 'day': 
    226                         case 'week': 
    227235                                foreach ($scales->x->column as $col) { 
    228236                                        $this->columnHeader[] = (string) $col; 
     
    255263                                } 
    256264                                break; 
     265                        case 'week': 
     266                                foreach ($xml->event as $ev) { 
     267                                        $event['week'] = (int) $ev->attributes()->week; 
     268                                        $event['day'] = (int) $ev->attributes()->day; 
     269                                        $event['x'] = (int) $ev->attributes()->x; 
     270                                        $event['y'] = (int) $ev->attributes()->y; 
     271                                        $event['width'] = (int) $ev->attributes()->width; 
     272                                        $event['height'] = (int) $ev->attributes()->height; 
     273                                        $event['type'] = (string) $ev->attributes()->type; 
     274                                        $event['text'] = (string) $ev->body; 
     275                                        $event['color'] = (string) $ev->body->attributes()->color; 
     276                                        $this->events[] = $event; 
     277                                } 
     278                                break; 
    257279                        case 'year': 
    258280                                foreach ($xml->event as $ev) { 
     
    271293                                break; 
    272294                        case 'day': 
    273                         case 'week': 
    274295                                foreach ($xml->event as $ev) { 
    275296                                        $event['head'] = (string) $ev->header; 
     
    311332        } 
    312333 
     334        private function printWeek() { 
     335                $this->wrapper->drawWeekHeader($this->orientation, $this->topScales, $this->monthHeaderHeight, $this->bgColor, $this->lineColor, $this->monthHeaderFontSize); 
     336                $this->wrapper->drawToday($this->today, $this->todayFontSize); 
     337                $this->wrapper->drawWeekGrid($this->dayHeader, $this->monthDayHeaderHeight, $this->dayHeaderColor, $this->dayBodyColor, $this->dayHeaderColorInactive, $this->dayBodyColorInactive, $this->monthDayHeaderFontSize); 
     338                $this->wrapper->drawWeekEvents($this->events, $this->eventColor, $this->eventBorderColor, $this->monthEventFontSize, $this->profile); 
     339        } 
     340 
    313341} 
    314342 
  • branches/2.2.0.1/calendar/js/dhtmlx/server/pdfWrapper.php

    r4001 r4049  
    8686                // circle for drawing day containers 
    8787                for ($i = 0; $i < count($dayHeader); $i++) { 
    88                         // draws day headers for every cell of row 
    89                         for ($j = 0; $j < count($dayHeader[$i]); $j++) { 
    90                                 $ln = ($j == 6) ? 1 : 0; 
    91                                 $color = ($activeDays[$i][$j] == true) ? $this->dayHeaderColor : $this->dayHeaderColorInactive; 
    92                                 $this->cb->SetFillColor($color['R'], $color['G'], $color['B']); 
    93                                 $this->cb->Cell($this->dayWidth, $this->dayHeaderHeight, $dayHeader[$i][$j], 1, $ln, 'R', 1); 
    94                                 $this->dayEventsHeight[$i][$j] = 0; 
    95                         } 
    96                         // draws day body for every cell of row 
    97                         for ($j = 0; $j < 7; $j++) { 
    98                                 $ln = ($j == 6) ? 1 : 0; 
    99                                 $color = ($activeDays[$i][$j] == true) ? $this->dayBodyColor : $this->dayBodyColorInactive; 
    100                                 $this->cb->SetFillColor($color['R'], $color['G'], $color['B']); 
    101                                 $this->cb->Cell($this->dayWidth, $this->dayBodyHeight, '', 1, $ln, 'R', 1); 
    102                         } 
     88                    // draws day headers for every cell of row 
     89                    for ($j = 0; $j < count($dayHeader[$i]); $j++) { 
     90                            $ln = ($j == 6) ? 1 : 0; 
     91                            $color = ($activeDays[$i][$j] == true) ? $this->dayHeaderColor : $this->dayHeaderColorInactive; 
     92                            $this->cb->SetFillColor($color['R'], $color['G'], $color['B']); 
     93                            $this->cb->Cell($this->dayWidth, $this->dayHeaderHeight, $dayHeader[$i][$j], 1, $ln, 'R', 1); 
     94                            $this->dayEventsHeight[$i][$j] = 0; 
     95                    } 
     96                    // draws day body for every cell of row 
     97                    for ($j = 0; $j < 7; $j++) { 
     98                            $ln = ($j == 6) ? 1 : 0; 
     99                            $color = ($activeDays[$i][$j] == true) ? $this->dayBodyColor : $this->dayBodyColorInactive; 
     100                            $this->cb->SetFillColor($color['R'], $color['G'], $color['B']); 
     101                            $this->cb->Cell($this->dayWidth, $this->dayBodyHeight, '', 1, $ln, 'R', 0); 
     102                    } 
    103103                } 
    104104        } 
     
    113113                $this->cb->setFontSize($monthEventFontSize); 
    114114 
    115                 $this->cb->SetFillColor($this->eventColor['R'], $this->eventColor['G'], $this->eventColor['B']);                 
     115                $this->cb->SetFillColor($this->eventColor['R'], $this->eventColor['G'], $this->eventColor['B']); 
    116116                // initial value for footnote number 
    117117                $footNum = 0; 
     
    204204                $x = $this->offsetLeft; 
    205205                $y = $this->offsetTop; 
    206                  
     206 
    207207                // variables for checking if events have the same date 
    208208                $week = -1; 
     
    233233                                                } 
    234234                                        } 
    235                                          
     235 
    236236                                        $this->cb->MultiCell($this->colWidth, 5, $textTop, 0, 'C', 0, 0, $x, $y); 
    237237                                        $y += $this->cb->getLastH(); 
     
    276276                $activeDays = Array(); 
    277277                $prevDay = (int) $dayHeader[0][0]; 
    278                  
     278 
    279279                for ($i = 0; $i < count($dayHeader); $i++) { 
    280280                        for ($j = 0; $j < count($dayHeader[$i]); $j++) { 
     
    290290                return $activeDays; 
    291291        } 
    292          
    293          
     292 
     293 
    294294        // 
    295295        public function drawYear($orientation, $yearValues, $events, $headerHeight, $bgColor, $lineColor, $dayColor, $dayColorInactive, $eventColor, $yearHeaderFontSize, $yearFontSize) { 
     
    387387                $this->cb->setFontSize($fontSize); 
    388388 
    389                 // sets column  
     389                // sets column 
    390390                $timeColWidth = 50; 
    391391                $dscColWidth = $this->cb->getPageWidth() - $this->offsetLeft - $this->offsetRight - $timeColWidth; 
     
    450450                $this->cb->setX($this->offsetLeft + $leftWidth); 
    451451                $this->cb->setY($this->offsetTop, false); 
    452                  
     452 
    453453                // draws scales on top 
    454454                $this->cb->setFontSize($dayHeaderFontSize); 
     
    496496                $this->eventColor = $this->convertColor($eventColor); 
    497497                $this->eventBorderColor = $this->convertColor($eventBorderColor); 
    498                  
     498 
    499499                $eventHeaderHeight = 4; 
    500                  
     500 
    501501                $this->lineStyle = Array('width' => 0.1, 'cap' => 'round', 'join' => 'round', 'dash' => '0', 'color' => $this->eventBorderColor); 
    502502                $this->cb->setLineStyle($this->lineStyle); 
    503                  
     503 
    504504 
    505505                // circle for every event 
     
    520520                        $width = $event['width']*$this->colWidth/100 - $this->colWidth/60; 
    521521                        $height = $event['height']*$this->colHeight/100; 
    522                          
     522 
    523523                        // draws event container 
    524524                        $this->cb->RoundedRect($x, $y, $width, $height, 1, '1111', 'DF', array(), $this->eventColor); 
     
    540540 
    541541 
     542 
     543 
     544        /*************************************************************************/ 
     545        // draws scheduler header in month mode 
     546        public function drawWeekHeader($orientation, $topScale, $topScaleHeight, $bgColor, $lineColor, $monthHeaderFontSize) { 
     547                $this->cb->AddPage($orientation); 
     548                $this->bgColor = $this->convertColor($bgColor); 
     549                $this->lineColor = $this->convertColor($lineColor); 
     550                $this->topScaleHeight = $topScaleHeight; 
     551                $this->topScale = $topScale; 
     552 
     553                $this->lineStyle = Array('width' => 0.1, 'cap' => 'round', 'join' => 'round', 'dash' => '2', 'color' => $this->lineColor); 
     554                $this->cb->SetLineStyle($this->lineStyle); 
     555                $this->cb->SetFillColor($this->bgColor['R'], $this->bgColor['G'], $this->bgColor['B']); 
     556                $this->cb->SetFontSize($monthHeaderFontSize); 
     557 
     558                // calculates day width 
     559                $this->dayWidth = ($this->cb->getPageWidth() - $this->offsetLeft - $this->offsetRight)/2; 
     560                // circle: for every column of header draw cell 
     561//              for ($i = 0; $i < count($topScale); $i++) { 
     562//                      $this->cb->Cell($this->dayWidth, $topScaleHeight, $topScale[$i], 1, 0, 'C', 1); 
     563//              } 
     564        } 
     565 
     566 
     567        // draws scheduler grid on month mode 
     568        public function drawWeekGrid($dayHeader, $dayHeaderHeight, $dayHeaderColor, $dayBodyColor, $dayHeaderColorInactive, $dayBodyColorInactive, $monthDayHeaderFontSize) { 
     569 
     570                // sets starting coordinates 
     571                $this->cb->setX($this->offsetLeft); 
     572                $this->cb->setY($this->offsetTop + $this->topScaleHeight, false); 
     573 
     574                $this->dayHeaderColor = $this->convertColor($dayHeaderColor); 
     575                $this->dayBodyColor = $this->convertColor($dayBodyColor); 
     576                $this->dayHeaderColorInactive = $this->convertColor($dayHeaderColorInactive); 
     577                $this->dayBodyColorInactive = $this->convertColor($dayBodyColorInactive); 
     578 
     579                // calculates height of day container header, body and whole height of day container 
     580                $this->dayHeaderHeight = $dayHeaderHeight; 
     581                $this->dayHeader = $dayHeader; 
     582                $this->dayBodyHeight = ($this->cb->getPageHeight() - $this->offsetTop - $this->offsetBottom - $this->topScaleHeight - $this->dayHeaderHeight*count($dayHeader))/count($dayHeader); 
     583                $this->dayHeight = $this->dayHeaderHeight + $this->dayBodyHeight; 
     584 
     585                // sets font size 
     586                $this->cb->SetFontSize($monthDayHeaderFontSize); 
     587                // creates array of values where result['week']['day'] is true if day container in current month and false otherwise 
     588                //$activeDays = $this->setActiveDays($dayHeader); 
     589 
     590                // circle for drawing day containers 
     591                for ($i = 0; $i < count($dayHeader); $i++) { 
     592                    // draws day headers for every cell of row 
     593                    for ($j = 0; $j < 2; $j++) { 
     594                            if($i == 3 && $j == 1){ 
     595                                $ln = ($j == 1) ? 1 : 0; 
     596                                $color =  $this->dayHeaderColor ; 
     597                                $this->cb->SetFillColor($color['R'], $color['G'], $color['B']); 
     598                                $this->cb->Cell($this->dayWidth, $this->dayHeaderHeight, '', 1, $ln, 'R', 1); 
     599                                $this->dayEventsHeight[$i][$j] = 0; 
     600                            }else{ 
     601                                $ln = ($j == 1) ? 1 : 0; 
     602                                $color =  $this->dayHeaderColor ; 
     603                                $this->cb->SetFillColor($color['R'], $color['G'], $color['B']); 
     604                                $this->cb->Cell($this->dayWidth, $this->dayHeaderHeight, $dayHeader[$i][$j], 1, $ln, 'R', 1); 
     605                                $this->dayEventsHeight[$i][$j] = 0; 
     606 
     607                            } 
     608 
     609 
     610                    } 
     611                    // draws day body for every cell of row 
     612                    for ($j = 0; $j < 2; $j++) { 
     613                            $ln = ($j == 1) ? 1 : 0; 
     614                            $color = $this->dayBodyColor ; 
     615                            $this->cb->SetFillColor($color['R'], $color['G'], $color['B']); 
     616                            $this->cb->Cell($this->dayWidth, $this->dayBodyHeight, '', 1, $ln, 'R', 0); 
     617 
     618                    } 
     619 
     620                } 
     621        } 
     622 
     623 
     624 
     625        // draws events in month mode 
     626        public function drawWeekEvents($events, $eventColor, $eventBorderColor, $monthEventFontSize, $mode, $offset = 1, $offsetLine = 6) { 
     627                $this->eventColor = $this->convertColor($eventColor); 
     628                $this->eventBorderColor = $this->convertColor($eventBorderColor); 
     629                $this->events = $events; 
     630 
     631                $this->cb->setFontSize($monthEventFontSize); 
     632 
     633                $this->cb->SetFillColor($this->eventColor['R'], $this->eventColor['G'], $this->eventColor['B']); 
     634                // initial value for footnote number 
     635                $footNum = 0; 
     636                // initial values for checking if in some day footenote has already drawed 
     637                $day = -1; 
     638                $week = -1; 
     639 
     640                // circle for drawing every event 
     641                foreach ($this->events as $i => $event) { 
     642                        //$event = $this->events[$i]; 
     643 
     644                       if($event['week'] == 3 && $event['day'] > 0) 
     645                               continue; 
     646//                        $event['week'] = $event['week'] -1; 
     647                        // calculation x-, y- positions, width and height of event 
     648                        $x = $this->offsetLeft + $event['day']*$this->dayWidth; 
     649                        $y = $this->offsetTop + $this->topScaleHeight + $event['week']*$this->dayHeight + $this->dayHeaderHeight + $this->dayEventsHeight[$event['week']][$event['day']]; 
     650                        if ($event['type'] == 'event_line') { 
     651                                $width = $event['width']*$this->dayWidth/100; 
     652                                $x += 1.5; 
     653                        } else { 
     654                                $width = $this->dayWidth - 1; 
     655                        } 
     656                        $height = 4; 
     657 
     658                        $this->cb->setX($x); 
     659                        $this->cb->setY($y, false); 
     660 
     661                        // checks if event can be drawed in day container 
     662//                      if ($y + $height > ($this->offsetTop + $this->topScaleHeight + ($event['week'] + 1)*$this->dayHeight)) { 
     663//                              // checks if footenote hasn't already drawed for current day and week values 
     664//                              if (!(($week == $event['week'])&&($day == $event['day']))) { 
     665//                                      $footNum++; 
     666//                                      $x1Line = $this->offsetLeft + $this->dayWidth*($event['day'] + 1); 
     667//                                      $x2Line = $x1Line - $offsetLine; 
     668//                                      $y1Line = $this->offsetTop + $this->topScaleHeight + $this->dayHeight*($event['week'] + 1) - $offsetLine; 
     669//                                      $y2Line = $this->offsetTop + $this->topScaleHeight + $this->dayHeight*($event['week'] + 1); 
     670//                                      $this->lineStyle = Array('width' => 0.1, 'cap' => 'round', 'join' => 'round', 'dash' => '2', 'color' => $this->lineColor); 
     671//                                      $this->cb->SetLineStyle($this->lineStyle); 
     672//                                      $this->cb->Line($x1Line, $y1Line, $x2Line, $y2Line); 
     673//                                      $textWidth = $this->cb->getStringWidth($footNum); 
     674//                                      $xText = $x1Line - $textWidth - 0.5; 
     675//                                      $yText = $y2Line - 0.6; 
     676// 
     677//                                      $day = $event['day']; 
     678//                                      $week = $event['week']; 
     679//                                      $this->cb->Text($xText, $yText, $footNum); 
     680//                              } 
     681//                              // sets variable which means that this event will print in footenotes 
     682//                              $this->events[$i]['foot'] = true; 
     683//                      } else { 
     684                                // draws event in current day 
     685                                $this->lineStyle = Array('width' => 0.3, 'cap' => 'round', 'join' => 'round', 'dash' => '0', 'color' => $this->eventBorderColor); 
     686                                $this->cb->SetLineStyle($this->lineStyle); 
     687                                $text = $this->textWrap($event['text'], $width, $monthEventFontSize); 
     688 
     689                                // sets event color 
     690                                $color = $this->processEventColor($event['color']); 
     691                                if (($color == 'transparent')||($mode !== 'color')) { 
     692                                        $this->cb->SetFillColor($this->eventColor['R'], $this->eventColor['G'], $this->eventColor['B']); 
     693                                } else { 
     694                                        $color = $this->convertColor($color); 
     695                                        $this->cb->SetFillColor($color['R'], $color['G'], $color['B']); 
     696                                } 
     697 
     698                                if ($event['type'] == 'event_clear') { 
     699                                        $this->cb->Cell($width, $height, $text, 0, 0, 'L', 0); 
     700                                } else { 
     701                                        $this->cb->Cell($width, $height, $text, 1, 0, 'L', 1); 
     702                                } 
     703                                for ($j = $event['day']; ($j < $event['day'] + ceil($width/$this->dayWidth))&&($j < 7); $j++) { 
     704                                        if ($event['week'] < count($this->dayHeader)) { 
     705                                                $this->dayEventsHeight[$event['week']][$j] += $height + $offset; 
     706                                        } 
     707                                } 
     708                                $this->events[$i]['foot'] = false; 
     709                //      } 
     710                //} 
     711                // draws footenotes 
     712//              if ($footNum > 0) { 
     713//                      $this->drawMonthFootenotes(); 
     714                } 
     715        } 
     716 
     717        /*********************************************/ 
     718 
     719 
     720 
     721 
     722 
    542723        // draws today value 
    543724        public function drawToday($today, $todayFontSize) { 
     
    584765                return $final; 
    585766        } 
    586          
    587          
     767 
     768 
    588769        // convert event color ot RGB-format 
    589770        private function processEventColor($color) { 
     
    596777                } 
    597778                $result = preg_match_all("/rgb\s?\((\d{1,3})\s?,\s?(\d{1,3})\s?,\s?(\d{1,3})\)/", $color, $rgb); 
    598                  
     779 
    599780                if ($result) { 
    600781                        $color = ''; 
     
    612793        } 
    613794 
     795 
     796 
     797 
     798 
     799 
     800 
     801 
    614802} 
    615803 
  • branches/2.2.0.1/calendar/js/dhtmlx/sources/ext/ext_pdf.js

    r4001 r4049  
    1 scheduler.toPDF=function(url,mode,header,footer){  
     1scheduler.toPDF=function(url,mode,header,footer){ 
    22        var dx = 0; 
    33        var dy = 0; 
     
    77                mode = "color"; 
    88        } 
    9                  
     9 
    1010        mode = mode||"color"; 
    11          
     11 
    1212        function x_norm(x) { 
    1313            x = parseFloat(x); 
     
    2727                return xml; 
    2828        } 
    29         function de_day(node,n){  
     29        function de_day(node,n){ 
    3030                var x = parseInt(node.style.left); 
    31                  
     31 
    3232                for (var dx=0; dx < scheduler._cols.length; dx++){ 
    3333                        x-=scheduler._cols[dx]; 
     
    3636                return n; 
    3737        } 
    38         function de_week(node,n){  
     38        function de_week(node,n){ 
    3939                var y = parseInt(node.style.top); 
    4040                for (var dy=0; dy < scheduler._colsS.heights.length; dy++) 
     
    5050            /*  var dd = r[i].cells[j]; 
    5151                var css = dd.className; 
    52                  
     52 
    5353                if (css!=" " && css!="dhx_now ") 
    5454                        days.push(""); 
     
    7070            xml+=">"; 
    7171            xml += "<scale mode='" + scheduler._mode + "' today='" + scheduler._els.dhx_cal_date[0].innerHTML + "'>"; 
    72              
     72 
    7373            if (scheduler._mode == "agenda"){ 
    7474                var xh = scheduler._els.dhx_cal_header[0].childNodes[0].childNodes; 
    75                  
     75 
    7676                xml+="<column>"+xh[0].innerHTML+"</column><column>"+xh[1].innerHTML+"</column>" 
    7777            } else if (scheduler._mode == "year"){ 
     
    8888                        xml+=xml_month_scale(xh); 
    8989                    xml += "</x>"; 
    90                  
     90 
    9191                    var yh = scheduler._els.dhx_cal_data[0]; 
    9292                    if (yh.firstChild.tagName == "TABLE") { 
     
    9797                            yh = yh.previousSibling; 
    9898                        yh = yh.childNodes; 
    99                  
     99 
    100100                        xml += "<y>"; 
    101101                        for (var i = 0; i < yh.length; i++) 
     
    105105                    } 
    106106                } 
    107                  
     107 
    108108            xml += "</scale>"; 
    109109            return xml; 
     
    112112                return (window.getComputedStyle?(window.getComputedStyle(node, null)[style]):(node.currentStyle?node.currentStyle[style]:null))||""; 
    113113        } 
    114         function xml_body() {  
     114        function xml_body() { 
    115115            var xml = ""; 
    116116            var evs = scheduler._rendered; 
    117              
     117 
    118118            if (scheduler._mode == "agenda"){ 
    119119                for (var i=0; i < evs.length; i++) 
     
    123123                for (var i=0; i < evs.length; i++) { 
    124124                        var d = evs[i].start_date; 
    125                                 if (d.valueOf()<scheduler._min_date.valueOf())  
     125                                if (d.valueOf()<scheduler._min_date.valueOf()) 
    126126                                d = scheduler._min_date; 
    127127                                while (d<evs[i].end_date){ 
    128                                         var m = d.getMonth()+12*(d.getFullYear()-scheduler._min_date.getFullYear())-scheduler.week_starts._month;  
     128                                        var m = d.getMonth()+12*(d.getFullYear()-scheduler._min_date.getFullYear())-scheduler.week_starts._month; 
    129129                                        var day  = scheduler.week_starts[m]+d.getDate()-1; 
    130130 
     
    132132                                scheduler._mark_year_date(d); 
    133133                                d = scheduler.date.add(d,1,"day"); 
    134                                 if (d.valueOf()>=scheduler._max_date.valueOf())  
     134                                if (d.valueOf()>=scheduler._max_date.valueOf()) 
    135135                                        break; 
    136136                        } 
    137                         }    
     137                        } 
    138138            } else { 
    139139                    for (var i = 0; i < evs.length; i++) { 
     
    146146                        var day = dets._sday; 
    147147                        var week = dets._sweek; 
    148                         if (scheduler._mode != "month") { 
     148                        if (scheduler._mode != "month" && scheduler._mode != "week") { 
    149149                           if (parseInt(evs[i].style.left) <= 26) { 
    150150                              zx = 2; 
    151151                              zdx += x_norm(evs[i].style.left)-1; 
    152                            }                    
     152                           } 
    153153                            if (evs[i].parentNode == scheduler._els.dhx_cal_data[0]) continue; 
    154154                            zx += x_norm(evs[i].parentNode.style.left); 
     
    157157                            zdy = parseInt(evs[i].offsetHeight); 
    158158                            zy = parseInt(evs[i].style.top) - 22; 
    159                              
    160                             day = de_day(evs[i],day); 
    161                             week = de_week(evs[i],week); 
     159                            if(scheduler._mode == "month" ){ 
     160                                day = de_day(evs[i],day); 
     161                                week = de_week(evs[i],week); 
     162                            } 
    162163                        } 
    163                          
     164 
    164165                        xml += "\n<event week='"+week+"' day='"+day+"' type='" + e_type + "' x='" + zx + "' y='" + zy + "' width='" + zdx + "' height='" + zdy + "'>"; 
    165                          
    166                          
     166 
     167 
    167168                        if (e_type == "event") { 
    168169                            xml += "<header><![CDATA[" + evs[i].childNodes[1].innerHTML + "]]></header>"; 
     
    184185            return xml; 
    185186        } 
    186          
     187 
    187188        var uid = (new Date()).valueOf(); 
    188189        var d=document.createElement("div"); 
     
    193194        document.getElementById(uid).firstChild.value = xml_top(mode).replace("\u2013", "-") + xml_body() + xml_end(); 
    194195        document.getElementById(uid).submit(); 
    195         d.parentNode.removeChild(d);grid = null;         
    196 }    
     196        d.parentNode.removeChild(d);grid = null; 
     197} 
Note: See TracChangeset for help on using the changeset viewer.