Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if ([tableView isEqual:[self HoursTableView]]){
- NSString *timeText = [arrayOfHours objectAtIndex:indexPath.row];
- NSString *apptHour = [timeText substringToIndex:2];
- NSString *apptMins = [timeText substringFromIndex:2];
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SCHEDULE_ROW"];
- NSDateFormatter *DateFormatter=[[NSDateFormatter alloc] init];
- [DateFormatter setDateFormat:[NSString stringWithFormat:@"%@-%@-%@-%@-%@",TODAY_year, TODAY_month, TODAY_day, apptHour, apptMins]];
- NSString *TODAY = [DateFormatter stringFromDate:[NSDate date]];
- int BEGIN_THIS_HOUR_EPOCH = [[self toEpoch:TODAY] intValue];
- int END_THIS_HOUR_EPOCH = BEGIN_THIS_HOUR_EPOCH + 3600;
- // Get items
- sqlite3_stmt *statementSCHEDULE;
- NSString *querySQL = [NSString stringWithFormat:@"SELECT APS.DATE_TIME_START, APS.DATE_TIME_END, APS.APPT_ID, APS.HOURS, CONTACT_NAME, CONTACT_LASTNAME, APS.ARTIST_ID FROM APPOINTMENTS APS LEFT JOIN CONTACTS ON CONTACTS.CONTACT_ID=APS.CONTACT_ID WHERE (DATE_TIME_START>='%i' AND DATE_TIME_START<='%i') ORDER BY APS.ARTIST_ID", BEGIN_THIS_HOUR_EPOCH, END_THIS_HOUR_EPOCH];
- //NSLog(@"Query: %@",querySQL);
- const char* query_sql = [querySQL UTF8String];
- UILabel *time = (UILabel *)[cell viewWithTag:655];
- UILabel *sched_time_a1 = (UILabel *)[cell viewWithTag:101];
- UILabel *sched_time_a2 = (UILabel *)[cell viewWithTag:102];
- UILabel *sched_time_a3 = (UILabel *)[cell viewWithTag:103];
- UILabel *sched_time_a4 = (UILabel *)[cell viewWithTag:104];
- UILabel *sched_time_a5 = (UILabel *)[cell viewWithTag:105];
- UILabel *sched_time_a6 = (UILabel *)[cell viewWithTag:106];
- UILabel *sched_time_a7 = (UILabel *)[cell viewWithTag:107];
- UILabel *sched_time_a8 = (UILabel *)[cell viewWithTag:108];
- //UIView *sched_a1 = (UIView *)[cell viewWithTag:111];
- UIView *sched_a2 = (UIView *)[cell viewWithTag:112];
- UIView *sched_a3 = (UIView *)[cell viewWithTag:113];
- UIView *sched_a4 = (UIView *)[cell viewWithTag:114];
- UIView *sched_a5 = (UIView *)[cell viewWithTag:115];
- UIView *sched_a6 = (UIView *)[cell viewWithTag:116];
- UIView *sched_a7 = (UIView *)[cell viewWithTag:117];
- UIView *sched_a8 = (UIView *)[cell viewWithTag:118];
- UILabel *sched_name_a1 = (UILabel *)[cell viewWithTag:121];
- UILabel *sched_name_a2 = (UILabel *)[cell viewWithTag:122];
- UILabel *sched_name_a3 = (UILabel *)[cell viewWithTag:123];
- UILabel *sched_name_a4 = (UILabel *)[cell viewWithTag:124];
- UILabel *sched_name_a5 = (UILabel *)[cell viewWithTag:125];
- UILabel *sched_name_a6 = (UILabel *)[cell viewWithTag:126];
- UILabel *sched_name_a7 = (UILabel *)[cell viewWithTag:127];
- UILabel *sched_name_a8 = (UILabel *)[cell viewWithTag:128];
- sched_name_a1.text = @"";
- sched_name_a2.text = @"";
- sched_name_a3.text = @"";
- sched_name_a4.text = @"";
- sched_name_a5.text = @"";
- sched_name_a6.text = @"";
- sched_name_a7.text = @"";
- sched_name_a8.text = @"";
- sched_time_a1.text = @"";
- sched_time_a2.text = @"";
- sched_time_a3.text = @"";
- sched_time_a4.text = @"";
- sched_time_a5.text = @"";
- sched_time_a6.text = @"";
- sched_time_a7.text = @"";
- sched_time_a8.text = @"";
- sched_a2.layer.backgroundColor = [UIColor clearColor].CGColor;
- sched_a3.layer.backgroundColor = [UIColor clearColor].CGColor;
- sched_a4.layer.backgroundColor = [UIColor clearColor].CGColor;
- sched_a5.layer.backgroundColor = [UIColor clearColor].CGColor;
- sched_a6.layer.backgroundColor = [UIColor clearColor].CGColor;
- sched_a7.layer.backgroundColor = [UIColor clearColor].CGColor;
- sched_a8.layer.backgroundColor = [UIColor clearColor].CGColor;
- sched_a2.layer.borderWidth = 0;
- sched_a3.layer.borderWidth = 0;
- sched_a4.layer.borderWidth = 0;
- sched_a5.layer.borderWidth = 0;
- sched_a6.layer.borderWidth = 0;
- sched_a7.layer.borderWidth = 0;
- sched_a8.layer.borderWidth = 0;
- if (sqlite3_open([dbPathString UTF8String], &inkStudiosDB)==SQLITE_OK) {
- if(sqlite3_prepare(inkStudiosDB, query_sql, -1, &statementSCHEDULE, NULL)==SQLITE_OK) {
- while (sqlite3_step(statementSCHEDULE)==SQLITE_ROW) {
- NSString *start = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statementSCHEDULE, 0)];
- NSString *end = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statementSCHEDULE, 1)];
- NSString *APPT_ID = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statementSCHEDULE, 2)];
- int Hours = sqlite3_column_int(statementSCHEDULE, 3);
- NSString *FIRST = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statementSCHEDULE, 4)];
- NSString *ID = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statementSCHEDULE, 6)];
- NSString *START = [self fromEpochToHuman:start withFormat:@"ha"];
- NSString *END = [self fromEpochToHuman:end withFormat:@"ha"];
- int heightCalc = Hours * 52;
- UIButton *sched_button_a1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
- if ([ID isEqualToString:artist_one]) {
- sched_name_a1.text = FIRST;
- sched_time_a1.text = [NSString stringWithFormat:@"%@ - %@", START, END];
- sched_button_a1.frame = CGRectMake(73, 0, 110, 52);
- CGRect frame_a1 = sched_button_a1.frame;
- // Resize height based on length of appointment
- frame_a1.size.height = heightCalc;
- sched_button_a1.frame = frame_a1;
- [sched_button_a1 setTitle:APPT_ID forState:UIControlStateNormal];
- sched_button_a1.layer.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:0.4f].CGColor;
- [sched_button_a1 addTarget:self action:@selector(showAppointment:) forControlEvents:UIControlEventTouchUpInside];
- [cell.contentView addSubview:sched_button_a1];
- [cell.contentView bringSubviewToFront:sched_button_a1];
- }else if([ID isEqualToString:artist_two]){
- CGRect frame = sched_a2.frame;
- frame.size.height = heightCalc;
- sched_a2.frame = frame;
- sched_a2.layer.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.4f].CGColor;
- sched_name_a2.text = FIRST;
- sched_time_a2.text = [NSString stringWithFormat:@"%@ - %@", START, END];
- sched_a2.layer.borderColor = [UIColor whiteColor].CGColor;
- sched_a2.layer.borderWidth = 1;
- [sched_a2.layer setCornerRadius:8.0f];
- [sched_a2.layer setMasksToBounds:YES];
- }else if([ID isEqualToString:artist_three]){
- CGRect frame = sched_a3.frame;
- frame.size.height = heightCalc;
- sched_a3.frame = frame;
- sched_a3.layer.backgroundColor = [[UIColor colorWithRed:204.0f/255.0f green:32.0f/255.0f blue:32.0f/255.0f alpha:1.0] colorWithAlphaComponent:0.4f].CGColor;
- sched_name_a3.text = FIRST;
- sched_time_a3.text = [NSString stringWithFormat:@"%@ - %@", START, END];
- sched_a3.layer.borderColor = [UIColor whiteColor].CGColor;
- sched_a3.layer.borderWidth = 1;
- [sched_a3.layer setCornerRadius:8.0f];
- [sched_a3.layer setMasksToBounds:YES];
- }else if([ID isEqualToString:artist_four]){
- CGRect frame = sched_a4.frame;
- frame.size.height = heightCalc;
- sched_a4.frame = frame;
- sched_a4.layer.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.4f].CGColor;
- sched_name_a4.text = FIRST;
- sched_time_a4.text = [NSString stringWithFormat:@"%@ - %@", START, END];
- sched_a4.layer.borderColor = [UIColor whiteColor].CGColor;
- sched_a4.layer.borderWidth = 1;
- [sched_a4.layer setCornerRadius:8.0f];
- [sched_a4.layer setMasksToBounds:YES];
- }else if([ID isEqualToString:artist_five]){
- CGRect frame = sched_a5.frame;
- frame.size.height = heightCalc;
- sched_a5.frame = frame;
- sched_a5.layer.backgroundColor = [[UIColor colorWithRed:204.0f/255.0f green:32.0f/255.0f blue:32.0f/255.0f alpha:1.0] colorWithAlphaComponent:0.4f].CGColor;
- sched_name_a5.text = FIRST;
- sched_time_a5.text = [NSString stringWithFormat:@"%@ - %@", START, END];
- sched_a5.layer.borderColor = [UIColor whiteColor].CGColor;
- sched_a5.layer.borderWidth = 1;
- [sched_a5.layer setCornerRadius:8.0f];
- [sched_a5.layer setMasksToBounds:YES];
- }else if([ID isEqualToString:artist_six]){
- CGRect frame = sched_a6.frame;
- frame.size.height = heightCalc;
- sched_a6.frame = frame;
- sched_a6.layer.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.4f].CGColor;
- sched_name_a6.text = FIRST;
- sched_time_a6.text = [NSString stringWithFormat:@"%@ - %@", START, END];
- sched_a6.layer.borderColor = [UIColor whiteColor].CGColor;
- sched_a6.layer.borderWidth = 1;
- [sched_a6.layer setCornerRadius:8.0f];
- [sched_a6.layer setMasksToBounds:YES];
- }else if([ID isEqualToString:artist_seven]){
- CGRect frame = sched_a7.frame;
- frame.size.height = heightCalc;
- sched_a7.frame = frame;
- sched_a7.layer.backgroundColor = [[UIColor colorWithRed:204.0f/255.0f green:32.0f/255.0f blue:32.0f/255.0f alpha:1.0] colorWithAlphaComponent:0.4f].CGColor;
- sched_name_a7.text = FIRST;
- sched_time_a7.text = [NSString stringWithFormat:@"%@ - %@", START, END];
- sched_a7.layer.borderColor = [UIColor whiteColor].CGColor;
- sched_a7.layer.borderWidth = 1;
- [sched_a7.layer setCornerRadius:8.0f];
- [sched_a7.layer setMasksToBounds:YES];
- }else if([ID isEqualToString:artist_eight]){
- CGRect frame = sched_a8.frame;
- frame.size.height = heightCalc;
- sched_a8.frame = frame;
- sched_a8.layer.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.4f].CGColor;
- sched_name_a8.text = FIRST;
- sched_time_a8.text = [NSString stringWithFormat:@"%@ - %@", START, END];
- sched_a8.layer.borderColor = [UIColor whiteColor].CGColor;
- sched_a8.layer.borderWidth = 1;
- [sched_a8.layer setCornerRadius:8.0f];
- [sched_a8.layer setMasksToBounds:YES];
- }
- }
- sqlite3_close(inkStudiosDB);
- }else{
- NSLog(@"Error fetching appointments (inner): %s", sqlite3_errmsg(inkStudiosDB));
- sqlite3_close(inkStudiosDB);
- }
- sqlite3_close(inkStudiosDB);
- }else{NSLog(@"Error fetching appointments (outter): %s", sqlite3_errmsg(inkStudiosDB));}
- time.text = timeText;
- [self HoursTableView].backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4f];
- cell.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.0f];
- return cell;
- }
- return nil;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement