//
//  DocumentsViewController.m
//  Apex Mobile
//
//  Created by Ray on 14-5-5.
//  Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
//

#import "DocumentsViewController.h"

@interface DocumentsViewController ()

@end

@implementation DocumentsViewController


-(void)initpanel
{
    self.toolsinfo = [[NSMutableArray alloc] init];
    
    NSMutableDictionary* map = [[NSMutableDictionary alloc] init];
    
    [map setValue:@"Search documents" forKey:@"title"];
    [map setValue:@"rect_search_documents" forKey:@"img"];
    [self.toolsinfo addObject:map.copy];
    
    [map setValue:@"View document" forKey:@"title"];
    [map setValue:@"rect_view_download_documents" forKey:@"img"];
    [self.toolsinfo addObject:map.copy];
    
    
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initpanel];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return self.toolsinfo.count;
    
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    DebugLog(@"cellForRowAtIndexPath");
    
    NSString *CellIdentifier = @"documents";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    NSString* title = [self.toolsinfo[indexPath.row] valueForKey:@"title"];
    
    //    UIImageView* iv= [[UIImageView alloc] initWithImage:];
    cell.textLabel.text = title;
    cell.imageView.image = [UIImage imageNamed:[self.toolsinfo[indexPath.row] valueForKey:@"img"]];
    
    return cell;
    
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    //    SearchViewController *searchViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"NewsView"];
    //    searchViewController.function_name = @"Download Document";
    //    [self.navigationController pushViewController:searchViewController animated:YES];
    //    return;
    
    NSString* title = [self.toolsinfo[indexPath.row] valueForKey:@"title"];
    if([title isEqualToString:@"Search documents"])
    {
        SearchViewController *searchViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"SearchViewController"];
        searchViewController.function_name = @"Download Document";
        [self.navigationController pushViewController:searchViewController animated:YES];
    }
    else if([title isEqualToString:@"View document"])
    {
        LocalDocumentsViewController *viewcontroller=[self.storyboard instantiateViewControllerWithIdentifier:@"LocalDocumentsViewController"];
//        viewcontroller.module_name = @"Announcements";
        [self.navigationController pushViewController:viewcontroller animated:YES];
    }

}

@end
