     
     @IBAction func onDoneDatePopup(sender: UIButton) {
         
-
         let formatter1 = DateFormatter.MM_dd_yyyy
         let fromDate = formatter1.dateFromString((fromButton.titleLabel!.text)!)
         let toDate = formatter1.dateFromString((toButton.titleLabel!.text)!)

        let (begin, end) = getMonth(0)
        fromDate = begin
        toDate = end.dateByAddingTimeInterval(oneDay)

        // TODO: set data for table view based on fromDate and toDate
        reloadDateRange()

                if beginWeek != nil && endWeek != nil {
                    navigationItem.title = getWeekText(beginWeek!, endWeek: endWeek!)
                }
                
                fromDate = beginWeek
                toDate = endWeek?.dateByAddingTimeInterval(oneDay)
                
                break
            case 1:
                viewMode = ViewMode.Monthly
                navigationItem.title = DateFormatter.MMMM.stringFromDate(NSDate())
                
                let (beginMonth, endMonth) = getMonth(monthIndex)
                fromDate = beginMonth
                toDate = endMonth.dateByAddingTimeInterval(oneDay)
                
                break
            case 2:
                viewMode = ViewMode.Yearly
                navigationItem.title = DateFormatter.yyyy.stringFromDate(NSDate())
                
                let (beginYear, endYear) = getYear(yearIndex)
                fromDate = beginYear
                toDate = endYear.dateByAddingTimeInterval(oneDay)
                
                break
            case 3:
                viewMode = ViewMode.Custom
