<?php 
        if ($week) {
        
         $currentweek = $week;
        } else {
            $currentweek = (int)date('W');
        }
      $weeks = array();
      if ($year == date('Y')) {
      
        foreach (range(1,date('W')) as $week ) {
            $weekForDate = $week <=9 ? "0".$week :$week;
            
            $startDate = date('d.M',strtotime(($year).'-W'.$weekForDate.'-1'));
            $date = PhonalisaDate::newServerDate($startDate, 'd.M');

            $startDate = app()->dateFormatter->format('dd.MMM',$date);

            $endDate = date('d.M',strtotime(($year).'-W'.$weekForDate.'-7'));
            $date = PhonalisaDate::newServerDate($endDate, 'd.M');
            $endDate = app()->dateFormatter->format('dd.MMM',$date);

            $weeks[] = array(
            'label'=>$week.'. '.__('STATISTIC_WEEK_PICKER_LABEL_SUFFIX').' ('.$startDate.'-'.$endDate.')',
            'value'=>$week
            );
        }
        
      } else {

        foreach (range(1,52) as $week ) {
            $weekForDate = $week <=9 ? "0".$week :$week;
            $startDate = date('d.M',strtotime(($year).'-W'.$weekForDate.'-1'));
            $date = PhonalisaDate::newServerDate($startDate, 'd.M');
            $startDate = app()->dateFormatter->format('dd.MMM',$date);
            $endDate = date('d.M',strtotime(($year).'-W'.$weekForDate.'-7'));
            $date = PhonalisaDate::newServerDate($endDate, 'd.M');
            $endDate = app()->dateFormatter->format('dd.MMM',$date);            
            $weeks[] = array(
            'label'=>$week.'. '.__('STATISTIC_WEEK_PICKER_LABEL_SUFFIX').' ('.$startDate.'-'.$endDate.')',
            'value'=>$week
            );
	  }
      
      } 

      $data = CHtml::listData($weeks,'value','label');
      echo CHtml::dropDownList('weekDropdown',$currentweek,$data,array(
	  'class'=>'btn dropdown-toggle span3 weekSelector',
	  'style'=>'width: 200px;'
      ));
?>