//
//  TaskListViewController.m
//  Macalline
//
//  Created by JianjiYuan on 14-12-1.
//  Copyright (c) 2014年 JianjiYuan. All rights reserved.
//

#import "SATaskListViewController.h"
#import "TaskDetailViewController.h"
#import "TaskHistoryViewController.h"
#import "BRNetworkMgr.h"
#import "RDVTabBarController.h"
#import <UIImageView+WebCache.h>
#import <SDImageCache.h>
#import "SATaskPointDetailViewController.h"
#import "SATaskPartView.h"
#import "SATaskNewDetailViewController.h"

@interface SATaskListCell : BaseTableViewCell
{
    
}
@property (nonatomic, strong) UIImageView *imageVContent;
@property (nonatomic, strong) UILabel *lblTitle;
@property (nonatomic, strong) UILabel *lblDueTime;
@property (nonatomic, strong) UILabel *lblSupportTime;
@property (nonatomic, strong) UILabel *lblSupportEnd;
@property (nonatomic, strong) UILabel *lblProcess;
@property (nonatomic, strong) UILabel *lblStatus;
@property (nonatomic, strong) UIView *viewLine;
@property (nonatomic, strong) UIView *viewProcess;
@property (nonatomic, strong) UIView *viewProcessBG;
@property (nonatomic, strong) UIImageView *imageVUser;
@end

@interface SATaskListViewController () < BRNetworkMgrDelegate ,UIGestureRecognizerDelegate>
{
    UILabel* lblNum;
    UILabel* lblStartTime;
    UILabel* lblEndTime ;
    UILabel* lblTitleName;
}
@property(nonatomic,strong)UITableView* tableView;
@property(nonatomic,strong) SATaskPartView* view1;

@property(nonatomic,strong) NSDate* endDate;
@property(nonatomic,strong) NSDate* startDate;

@end

@implementation SATaskListViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.title = @"小促销-任务一览";
        
        //        self.heightOfButtons = 50.0f;
        //        self.numberOfItems = 2;
        //        self.arrItemTitles = [NSMutableArray arrayWithArray:@[@"未完成(0)", @"已完成(0)"]];
        //        self.arrItemBgNorImages = @[[UIImage imageNamed:@"TabBar/tasktab_undone_off.png"],[UIImage imageNamed:@"TabBar/tasktab_done_off.png"]];
        //        self.arrItemBgPreImages = @[[UIImage imageNamed:@"TabBar/tasktab_undone_on.png"],[UIImage imageNamed:@"TabBar/tasktab_done_on.png"]];
        //        self.titleInsets = UIEdgeInsetsMake(22, 0, 0, 0);
        //        self.arrItemTitleNorColors = @[[UIColor whiteColor], [UIColor whiteColor]];
        //        self.arrItemTitlePreColors = @[[UIColor colorWithRed:0.2118 green:0.7098 blue:0.9490 alpha:1], [UIColor colorWithRed:0.2118 green:0.7098 blue:0.9490 alpha:1]];
        //        self.titleFontNor = [UIFont systemFontOfSize:12];
        //        self.TitleFontPre = [UIFont boldSystemFontOfSize:12];
        
    }
    return self;
}

- (void)viewDidLoad
{
    NSString *titles=[[NSString alloc]init];
    if ([_btnType isEqualToString:kDaoshicode]) {
        titles=@"导视";
    }
    if ([_btnType isEqualToString:kMeichengcode]) {
        titles=@"美陈";
    }
    if ([_btnType isEqualToString:kXiuxiqucode]) {
        titles=@"公共区域";
    }
    if ([_btnType isEqualToString:kGuanggaoweicode]) {
        titles=@"广告位";
    }
    if ([_btnType isEqualToString:kBeijingyinyuecode]) {
       titles=@"背景音乐";
    }
    if ([_btnType isEqualToString:kYingyunwuliaocode]) {
        titles=@"综合物料";
    }
    if ([_btnType isEqualToString:kDacuxiaocode]) {
        self.title = @"大促销-任务一览";
        titles=@"大促销";
    }
    if ([_btnType isEqualToString:kXiaocuxiaocode]) {
        self.title = @"小促销-任务一览";
        titles=@"小促销";
    }
    self.title=[[NSString alloc] initWithFormat:@"任务一览-%@",titles];
    
    [super viewDidLoad];
    UIView* headView = [[UIView alloc] init];
    headView.hidden = YES;
    [self.view addSubview:headView];
    [headView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0) excludingEdge:ALEdgeBottom];
    [headView autoSetDimension:ALDimensionHeight toSize:45];
    UIView* btnView = [[UIView alloc] init];
    btnView.clipsToBounds = YES;
    btnView.backgroundColor = [UIColor clearColor];;
    [headView addSubview:btnView];
    [btnView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    
    CGFloat w = self.view.bounds.size.width/2;
    UIButton* btnTitleName = [[UIButton alloc] initWithFrame:CGRectMake(-1, -1, w+1, 46)];
    btnTitleName.tag = 99;
    [btnTitleName addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    btnTitleName.layer.borderWidth = 1;
    btnTitleName.layer.borderColor = [UIColor colorWithRed:0.9333 green:0.9333 blue:0.9333 alpha:1].CGColor;
    [btnView addSubview:btnTitleName];
    
    lblTitleName = [[UILabel alloc] init];
    lblTitleName.textColor = [UIColor darkGrayColor];
    lblTitleName.textAlignment = NSTextAlignmentCenter;
    //lblTitleName.text = @"大促销";
    lblTitleName.text=titles;
    lblTitleName.font = [UIFont boldSystemFontOfSize:15];
    [btnTitleName addSubview:lblTitleName];
    [lblTitleName autoAlignAxis:ALAxisHorizontal toSameAxisOfView:btnTitleName];
    [lblTitleName autoAlignAxis:ALAxisVertical toSameAxisOfView:btnTitleName withOffset:-5];
    
    UIImageView* titleNameimage = [[UIImageView alloc] init];
    titleNameimage.image = [UIImage imageNamed:@"Task_Point/image_point_arrow.png"];
    [btnTitleName addSubview:titleNameimage];
    [titleNameimage autoSetDimensionsToSize:CGSizeMake(8, 12)];
    [titleNameimage autoAlignAxis:ALAxisHorizontal toSameAxisOfView:btnTitleName];
    [titleNameimage autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:13];
    
    UIButton* btnTime = [[UIButton alloc] initWithFrame:CGRectMake(w-1, -1, w+2, 46)];
    btnTime.tag = 100;
    [btnTime addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    btnTime.layer.borderWidth = 1;
    btnTime.layer.borderColor = [UIColor colorWithRed:0.9333 green:0.9333 blue:0.9333 alpha:1].CGColor;
    [btnView addSubview:btnTime];
    
    NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
    [inputFormatter setDateFormat:@"yyyy-MM-dd"];

    NSDateFormatter *inputFormatter1 = [[NSDateFormatter alloc] init];
    [inputFormatter1 setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    
    NSDate* eDate = [inputFormatter1 dateFromString:[DataMgr getInstance].serverTime];
    
    NSTimeInterval timeInterval = 24*60*60;
    int num = [_dayCount intValue];
    _startDate = [NSDate dateWithTimeInterval:timeInterval*-num sinceDate:eDate];
    _endDate = [NSDate dateWithTimeInterval:timeInterval*30 sinceDate:eDate];
    
    lblStartTime = [[UILabel alloc] init];
    lblStartTime.textColor = [UIColor darkGrayColor];
    lblStartTime.textAlignment = NSTextAlignmentCenter;
    lblStartTime.text = [NSString stringWithFormat:@"%@ 开始",[inputFormatter stringFromDate:_startDate]];
    lblStartTime.font = [UIFont boldSystemFontOfSize:11];
    [btnTime addSubview:lblStartTime];
    [lblStartTime autoAlignAxis:ALAxisHorizontal toSameAxisOfView:btnTime withOffset:-8];
    [lblStartTime autoAlignAxis:ALAxisVertical toSameAxisOfView:btnTime withOffset:-10];
    
    lblEndTime = [[UILabel alloc] init];
    lblEndTime.textColor = [UIColor darkGrayColor];
    lblEndTime.textAlignment = NSTextAlignmentCenter;
    lblEndTime.text = [NSString stringWithFormat:@"%@ 结束",[inputFormatter stringFromDate:_endDate]];
    lblEndTime.font = [UIFont boldSystemFontOfSize:11];
    [btnTime addSubview:lblEndTime];
    [lblEndTime autoAlignAxis:ALAxisHorizontal toSameAxisOfView:btnTime withOffset:8];
    [lblEndTime autoAlignAxis:ALAxisVertical toSameAxisOfView:btnTime withOffset:-10];
    
    UIImageView* timeArrimage = [[UIImageView alloc] init];
    timeArrimage.image = [UIImage imageNamed:@"Task_Point/image_point_arrow.png"];
    [btnTime addSubview:timeArrimage];
    [timeArrimage autoSetDimensionsToSize:CGSizeMake(8, 12)];
    [timeArrimage autoAlignAxis:ALAxisHorizontal toSameAxisOfView:btnTitleName];
    [timeArrimage autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:13];
    
    _tableView = [[UITableView alloc] init];
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    [_tableView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
//    [_tableView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:headView];
    self.lastIndexOfItem = 01;
    [self.dictTableDatas removeAllObjects];
    
    UIButton *btnHome = [UIButton buttonWithType:UIButtonTypeCustom];
    btnHome.tag = 99;
    [btnHome setBackgroundImage:[UIImage imageNamed:@"Task/icon_filter1.png"] forState:UIControlStateNormal];
    [btnHome setFrame:CGRectMake(0, 0, 23, 23)];
    [btnHome addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.navigationController navbarRightItemCustomized:@[btnHome] onwer:self.navigationItem];
    
}
-(void)btnClick:(UIButton*)sender
{
    if (sender.tag == 99) {
        [self addTaskPartView];
    }
    if (sender.tag == 100) {
        [self addSelectDateView];
    }
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.rdv_tabBarController.navigationController.navigationBarHidden = YES;
    
    
    if ([[UIApplication getObjectType:Number key:kShouldRequestDataWhenBack] boolValue]) {
        [self.dictTableDatas removeAllObjects];
        [self reRequestTableViewDatas];
    }
    
}

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

#pragma ---------------------   请求活动列表数据   -----------------------
- (void)reRequestTableViewDatas
{
    NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
    [inputFormatter setDateFormat:@"yyyy-MM-dd"];
    
    NSDateFormatter *inputFormatter1 = [[NSDateFormatter alloc] init];
    [inputFormatter1 setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate* eDate = [inputFormatter1 dateFromString:[DataMgr getInstance].serverTime];

    NSString* endDateStr = [inputFormatter stringFromDate:_endDate];
    NSTimeInterval timeInterval = 24*60*60;
    int num = [_dayCount intValue];
    _startDate = [NSDate dateWithTimeInterval:timeInterval*-num sinceDate:eDate];
    _endDate = [NSDate dateWithTimeInterval:timeInterval*30 sinceDate:eDate];
    
    NSString* startDateStr = [inputFormatter stringFromDate:_startDate];
    [UIApplication showLoadingView:@"正在加载数据..."];
    NSString *interface = @"queryActivityListEX";
    //  状态有未完成，已完成，过期 对应01，02，03
    NSDictionary *dicParam = @{@"typeCode":_btnType,@"startDate":startDateStr,@"endDate":endDateStr};
    AFHTTPRequestOperation *operation = [self.networkMgr operationWithURL:kBaseEXURL(interface)
                                                                interface:interface
                                                                   params:dicParam
                                                                 dataType:BRNetMgrDataTypeJSON
                                                                   method:BRNetMgrMethodPost];
    [operation setUserInfo:@{@"interface":interface,
                             @"lastIndexOfItem":kDataForTableKey(self.lastIndexOfItem)}];
    [self.networkMgr startOperation:operation];
}

- (void)reRequestTableViewDatasByStartTime:(NSString*)startDateStr andEndTime:(NSString*)endDateStr
{
    NSString *interface = @"queryActivityListEX";
    //  状态有未完成，已完成，过期 对应01，02，03]
    [UIApplication showLoadingView:@"正在加载数据..."];
    NSDictionary *dicParam = @{@"typeCode":_btnType,@"startDate":startDateStr,@"endDate":endDateStr};
    AFHTTPRequestOperation *operation = [self.networkMgr operationWithURL:kBaseEXURL(interface)
                                                                interface:interface
                                                                   params:dicParam
                                                                 dataType:BRNetMgrDataTypeJSON
                                                                   method:BRNetMgrMethodPost];
    [operation setUserInfo:@{@"interface":interface,
                             @"lastIndexOfItem":kDataForTableKey(self.lastIndexOfItem)}];
    [self.networkMgr startOperation:operation];
}

#pragma mark =============  BRNetworkMgr Delegate  =============
- (void)httpOperationSuccess:(AFHTTPRequestOperation *)operation
                      result:(NSDictionary *)result
{
    if ([operation.userInfo[@"interface"] isEqualToString:@"queryActivityListEX"]) {
        NSString *keyForTable = operation.userInfo[@"lastIndexOfItem"];
        lblNum.text = [NSString stringWithFormat:@"%@",result[@"unReviewNum"]];
        [self.dictTableDatas setObject:[result[@"acivityList"] validDataOfClass:[NSArray class]]
                                forKey:keyForTable];
        
        [_tableView reloadData];
    }
    
}

- (void)httpOperationFailed:(AFHTTPRequestOperation *)operation
                      error:(NSError *)error
{
    
}

#pragma mark =============  UITableView DataSource  =============

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cellIdentifier = @"TaskListCell";
    SATaskListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[SATaskListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    
    NSArray *arrContents = self.dictTableDatas[@"indexOfItem_1"];
    cell.lblTitle.text = arrContents[indexPath.row][@"name"];
    cell.lblDueTime.text = [NSString stringWithFormat:@"%@ 活动结束", arrContents[indexPath.row][@"endDate"]];
    cell.lblSupportTime.text = [NSString stringWithFormat:@"%@",arrContents[indexPath.row][@"reportEndDate"]];
    cell.lblSupportEnd.text = @"上报截止";
    
    NSString* num = arrContents[indexPath.row][@"progress"];
    CGFloat f = [num floatValue]/100;
    
    [cell.viewProcessBG setFrame:CGRectMake(0, 0, 100*f, 6)];
    
    cell.lblProcess.text = [NSString stringWithFormat:@"%@个商场 | %@%@",arrContents[indexPath.row][@"shopNum"], arrContents[indexPath.row][@"progress"],@"%"];
    cell.lblStatus.text = [NSString stringWithFormat:@"%@个任务待审核",arrContents[indexPath.row][@"unReviewNum"]];
    [cell.imageVContent sd_setImageWithURL:[NSURL URLWithString:arrContents[indexPath.row][@"pictureURL"]]
                          placeholderImage:[UIImage imageNamed:@"pic_jiazaizhogn.png"]
                                 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL){
                                     if (!image) {
                                         [cell.imageVContent setImage:[UIImage imageNamed:@"pic_jiazaishibai.png"]];
                                     }
                                 }];
    if ([[DataMgr getInstance].roleId isEqualToString:@"2"]) {
        cell.imageVUser.image = [UIImage imageNamed:@"icon_jiancha.png"];
    }else {
        cell.imageVUser.image = [UIImage imageNamed:@"icon_hecha.png"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 90;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSArray *arrContents = self.dictTableDatas[@"indexOfItem_1"];
    return arrContents.count;
}


#pragma mark =============  UITableView Delegate  =============

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    self.selectedIndexPath = indexPath;
    
    NSArray *arrContents = self.dictTableDatas[@"indexOfItem_1"];
    SATaskNewDetailViewController* vc = [[SATaskNewDetailViewController alloc] init];
    vc.activityId = arrContents[indexPath.row][@"id"];
    vc.btnType = self.btnType;
    [self.navigationController pushViewController:vc animated:YES];
    
}

- (void)configureCell:(UITableViewCell *)cell forIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row%2 == 0) {
        cell.contentView.backgroundColor = RGBColor(239, 238, 239, 1);
    }else{
        cell.contentView.backgroundColor = [UIColor whiteColor];
    }
    
}
#pragma ---------------------   底部弹出框   -----------------------
-(void)addTaskPartView
{
    _view1 = [[SATaskPartView alloc] initWithFrame:self.navigationController.view.bounds];
    __weak typeof(SATaskListViewController) *weakSelf = self;
    _view1.BtnClickBlock = ^(NSString* tag) {
        [weakSelf listBtnClick:tag];
    };

    UITapGestureRecognizer* tapGesture1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(Actiondo:)];
    tapGesture1.delegate = self;
    [_view1 addGestureRecognizer:tapGesture1];
    [self.navigationController.view addSubview:_view1];
}

-(void)addSelectDateView
{
    _view1 = [[SATaskPartView alloc] initWithFrame:self.navigationController.view.bounds andTitle:@"date" andStartTime:_startDate andEndTime:_endDate];
    __weak typeof(SATaskListViewController) *weakSelf = self;
    _view1.SelectTimeClick = ^(NSString* startTime,NSString* endTime) {
        [weakSelf listBtnClick:startTime andEndTime:endTime];
    };

    UITapGestureRecognizer* tapGesture1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(Actiondo:)];
    tapGesture1.delegate = self;
    [_view1 addGestureRecognizer:tapGesture1];
    [self.navigationController.view addSubview:_view1];
}
-(void)Actiondo:(UITapGestureRecognizer*)sender
{
    CGPoint point = [sender locationInView:self.view];
    
    NSLog(@"handleSingleTap!pointx:%f,y:%f",point.x,point.y);
    
    [_view1 removeFromSuperview];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    if (touch.view != _view1) {
        return NO;
        
    }
    return YES;
}

-(void)listBtnClick:(NSString*)Name
{
    NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
    [inputFormatter setDateFormat:@"yyyy-MM-dd"];
    
    NSString* str = @"";
    if ([Name isEqualToString:@"daoshi"]) {
        str=@"导视";
        _btnType = kDaoshicode;
    }
    if ([Name isEqualToString:@"meichen"]) {
        str=@"美陈";
        _btnType = kMeichengcode;
    }
    if ([Name isEqualToString:@"xiuxiqu"]) {

        str=@"公共区域";
        _btnType = kXiuxiqucode;
    }
    if ([Name isEqualToString:@"guanggaowei"]) {
        str=@"广告位";
        _btnType = kGuanggaoweicode;
    }
    if ([Name isEqualToString:@"beijingyinyue"]) {
        str=@"背景音乐";
        _btnType = kBeijingyinyuecode;
    }
    if ([Name isEqualToString:@"yingyunwuliao"]) {
        str=@"综合物料";
        _btnType = kYingyunwuliaocode;
    }
    if ([Name isEqualToString:@"dacuxiao"]) {
        str=@"大促销";
        _btnType = kDacuxiaocode;
    }
    if ([Name isEqualToString:@"xiaocuxiao"]) {
        str=@"小促销";
        _btnType = kXiaocuxiaocode;
    }
    self.title=[[NSString alloc] initWithFormat:@"%@-任务一览",str];
    lblTitleName.text = str;
    [self reRequestTableViewDatasByStartTime:[inputFormatter stringFromDate:_startDate] andEndTime:[inputFormatter stringFromDate:_endDate]];
    [_view1 removeFromSuperview];
}
-(void)listBtnClick:(NSString*)startTiem andEndTime:(NSString*)endTime
{
    NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
    [inputFormatter setDateFormat:@"yyyy-MM-dd"];
    _startDate = [inputFormatter dateFromString:startTiem];
    _endDate = [inputFormatter dateFromString:endTime];
    lblStartTime.text = [NSString stringWithFormat:@"%@ 开始",[inputFormatter stringFromDate:_startDate]];
    lblEndTime.text = [NSString stringWithFormat:@"%@ 结束",[inputFormatter stringFromDate:_endDate]];
    [self reRequestTableViewDatasByStartTime:startTiem andEndTime:endTime];
    [_view1 removeFromSuperview];
}
@end
#pragma ---------------------   自定义Cell   -----------------------
@implementation SATaskListCell

- (void)dealloc
{
    self.imageVContent = nil;
    self.lblTitle = nil;
    self.lblDueTime = nil;
    self.lblSupportTime = nil;
    self.lblProcess = nil;
    self.lblStatus = nil;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self.imageVContent autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(10, 10, 10, 0) excludingEdge:ALEdgeRight];
        [self.imageVContent autoSetDimension:ALDimensionWidth toSize:80];
        
        [self.lblTitle autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.imageVContent withOffset:10];
        [self.lblTitle autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.imageVContent];
        [self.lblTitle autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:10];
        
        [self.lblDueTime autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.lblTitle];
        [self.lblDueTime autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblTitle withOffset:2];
        
        [self.lblSupportTime autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.lblTitle];
        [self.lblSupportTime autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblDueTime withOffset:2];
        
        [self.lblSupportEnd autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.lblSupportTime withOffset:2];
        [self.lblSupportEnd autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.lblSupportTime];
        
        [self.lblProcess autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.lblTitle];
        [self.lblProcess autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblSupportTime withOffset:2];
        
        
        [self.viewProcess autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.lblTitle];
        [self.viewProcess autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.lblProcess withOffset:2];
        [self.viewProcess autoSetDimensionsToSize:CGSizeMake(100, 6)];
        
        
        [self.lblStatus autoPinEdgeToSuperviewEdge:ALEdgeRight];
        [self.lblStatus autoPinEdgeToSuperviewEdge:ALEdgeBottom];
        [self.lblStatus autoSetDimensionsToSize:CGSizeMake(105, 18)];
        
        
        [self.viewLine autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(0, 0, 0, 0) excludingEdge:ALEdgeTop];
        [self.viewLine autoSetDimension:ALDimensionHeight toSize:1];
        
    }
    return self;
}

#pragma mark =============  LazyLoad Properties  =============

- (UIImageView *)imageVContent
{
    if (!_imageVContent) {
        self.imageVContent = [UIImageView newAutoLayoutView];
        self.imageVContent.layer.cornerRadius = 5;
        self.imageVContent.contentMode = UIViewContentModeScaleAspectFill;
        self.imageVContent.clipsToBounds = YES;
        [self.contentView addSubview:_imageVContent];
    }
    return _imageVContent;
}

- (UIImageView *)imageVUser
{
    if (!_imageVUser) {
        self.imageVUser = [UIImageView newAutoLayoutView];
        //[self.contentView addSubview:_imageVUser];
    }
    return _imageVUser;
}
- (UIView *)viewProcess
{
    if (!_viewProcess) {
        self.viewProcess = [UIView newAutoLayoutView];
        _viewProcess.backgroundColor = [UIColor clearColor];
        _viewProcess.layer.borderWidth =1.5;
        _viewProcess.layer.borderColor = RGBColor(16, 133, 201, 1).CGColor;
        _viewProcess.layer.cornerRadius = 3;
        [self.contentView addSubview:_viewProcess];
    }
    return _viewProcess;
}

- (UIView *)viewProcessBG
{
    if (!_viewProcessBG) {
        self.viewProcessBG = [UIView newAutoLayoutView];
        _viewProcessBG.backgroundColor = RGBColor(16, 133, 201, 1);
        _viewProcessBG.layer.cornerRadius = 3;
        [self.viewProcess addSubview:_viewProcessBG];
    }
    return _viewProcessBG;
}
- (UIView *)viewLine
{
    if (!_viewLine) {
        self.viewLine = [UIView newAutoLayoutView];
        _viewLine.backgroundColor = [UIColor colorWithRed:0.9143 green:0.9143 blue:0.9143 alpha:1];
        [self.contentView addSubview:_viewLine];
    }
    return _viewLine;
}

- (UILabel *)lblTitle
{
    if (!_lblTitle) {
        self.lblTitle = [self getAutoLayoutLabel];
        _lblTitle.font = [UIFont boldSystemFontOfSize:13];
        _lblTitle.textColor = [UIColor darkGrayColor];
        [self.contentView addSubview:_lblTitle];
    }
    return _lblTitle;
}

- (UILabel *)lblStatus
{
    if (!_lblStatus) {
        self.lblStatus = [self getAutoLayoutLabel];
        _lblStatus.font = [UIFont boldSystemFontOfSize:12];
        _lblStatus.textColor = [UIColor whiteColor];
        _lblStatus.backgroundColor = [UIColor lightGrayColor];
        _lblStatus.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_lblStatus];
    }
    return _lblStatus;
}

- (UILabel *)lblDueTime
{
    if (!_lblDueTime) {
        self.lblDueTime = [self getAutoLayoutLabel];
        _lblDueTime.font = [UIFont systemFontOfSize:11];
        _lblDueTime.textColor = [UIColor darkGrayColor];
        [self.contentView addSubview:_lblDueTime];
    }
    return _lblDueTime;
}
- (UILabel *)lblSupportEnd
{
    if (!_lblSupportEnd) {
        self.lblSupportEnd = [self getAutoLayoutLabel];
        _lblSupportEnd.font = [UIFont systemFontOfSize:11];
        _lblSupportEnd.textColor = RGBColor(253, 173, 82, 1);
        [self.contentView addSubview:_lblSupportEnd];
    }
    return _lblSupportEnd;
}
- (UILabel *)lblSupportTime
{
    if (!_lblSupportTime) {
        self.lblSupportTime = [self getAutoLayoutLabel];
         _lblSupportTime.font = [UIFont systemFontOfSize:11];
        _lblSupportTime.textColor = [UIColor darkGrayColor];
        [self.contentView addSubview:_lblSupportTime];
    }
    return _lblSupportTime;
}

- (UILabel *)lblProcess
{
    if (!_lblProcess) {
        self.lblProcess = [self getAutoLayoutLabel];
        _lblProcess.font = [UIFont systemFontOfSize:11];
        _lblProcess.textColor = [UIColor darkGrayColor];
        [self.contentView addSubview:_lblProcess];
    }
    return _lblProcess;
}

- (UILabel *)getAutoLayoutLabel
{
    UILabel *lblTemp = [UILabel newAutoLayoutView];
    lblTemp.textAlignment = NSTextAlignmentLeft;
    lblTemp.backgroundColor = [UIColor clearColor];
    lblTemp.textColor = [UIColor blackColor];
    lblTemp.font = [UIFont systemFontOfSize:13];
    lblTemp.numberOfLines = 1;
    return lblTemp;
}


@end
