radhar / date-formatter Goto Github PK
View Code? Open in Web Editor NEWformatting
formatting
.h class:
@interface MoviePlayerViewController : UIViewController {
IBOutlet UIImageView *cloud;
IBOutlet UIImageView *cloud1;
IBOutlet UIImageView *cloud2;
IBOutlet UIImageView *cloud3;
UIView *myFirstView;
CGPoint fram;
CGRect frame;
CGPoint location1;
int count;
}
@EnD
.m class:
@implementation MoviePlayerViewController
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
location1 = [touch locationInView:touch.view];
NSUInteger numTaps = [[touches anyObject] tapCount];
if (numTaps == 1 && count == 0) {//numTaps == 1 &&
count = 1;
fram.x = location1.x;
fram.y = location1.y;
}
if (CGRectContainsPoint([cloud frame], [touch locationInView:self.view])){
cloud.center = location1;
return;
}
if (CGRectContainsPoint([cloud1 frame], [touch locationInView:self.view])){
cloud1.center = location1;
return;
}
if (CGRectContainsPoint([cloud2 frame], [touch locationInView:self.view])){
cloud2.center = location1;
return;
}
if (CGRectContainsPoint([cloud3 frame], [touch locationInView:self.view])){
cloud3.center = location1;
return;
}
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesBegan:touches withEvent:event];
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
//UIImageView *img;
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (location.y >= 371) {
if (location.x >= 0 && location.x <= 45) {
if (location.y >= 371 && location.y <= 420) {
//if (CGRectContainsPoint([cloud frame],location)){
frame = CGRectMake(100, 150, 150, 125);
cloud.frame = frame;
//cloud.center.y = 150;
count = 0;
return;
//}
}
}
}else {
if (CGRectContainsPoint([cloud frame],location)){
cloud.center = fram;
count = 0;
return;
}
if (CGRectContainsPoint([cloud1 frame],location)){
cloud1.center = fram;
count = 0;
return;
}
if (CGRectContainsPoint([cloud2 frame],location)){
cloud2.center = fram;
count = 0;
return;
}
if (CGRectContainsPoint([cloud3 frame],location)){
cloud3.center = fram;
count = 0;
return;
}
}
count = 0;
}
}
NSString *dateStr = @"Tue, 25 May 2010 12:53:58 +0000";
// Convert string to date object
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"EE, d LLLL yyyy HH:mm:ss Z"];
NSDate *date = [dateFormat dateFromString:dateStr];
[dateFormat release];
KalTileView.h
//m for tile
//#import <EventKit/EventKit.h>
//#import <EventKitUI/EventKitUI.h>
enum {
KalTileTypeRegular = 0,
KalTileTypeAdjacent = 1 << 0,
KalTileTypeToday = 1 << 1,
};
typedef char KalTileType;
@Class KalDate;
@interface KalTileView : UIView
{
KalDate *date;
CGPoint origin;
struct {
unsigned int selected : 1;
unsigned int highlighted : 1;
unsigned int marked : 1;
unsigned int type : 2;
} flags;
//m for tile
//EKEventStore *eventStore;
// EKCalendar *defaultCalendar;
}
@Property (nonatomic, retain) KalDate *date;
@Property (nonatomic, getter=isHighlighted) BOOL highlighted;
@Property (nonatomic, getter=isSelected) BOOL selected;
@Property (nonatomic, getter=isMarked) BOOL marked;
@Property (nonatomic) KalTileType type;
//-(BOOL)fetchEventsForThisDate:(NSDate *)date1;
-(BOOL)doesThisDateHaveAppointment:(NSString *)date;
KalTileView.m
extern const CGSize kTileSize;
@implementation KalTileView
@synthesize date;
(id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame])) {
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];
self.clipsToBounds = NO;
origin = frame.origin;
[self resetState];
}
return self;
}
(void)drawRect:(CGRect)rect
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGFloat fontSize = 24.f;
UIFont *font = [UIFont boldSystemFontOfSize:fontSize];
UIColor *shadowColor = nil;
UIColor *textColor = nil;
UIImage *markerImage = nil;
CGContextSelectFont(ctx, [font.fontName cStringUsingEncoding:NSUTF8StringEncoding], fontSize, kCGEncodingMacRoman);
CGContextTranslateCTM(ctx, 0, kTileSize.height);
CGContextScaleCTM(ctx, 1, -1);
if ([self isToday] && self.selected) {
[[[UIImage imageNamed:@"Kal.bundle/kal_tile_today_selected.png"] stretchableImageWithLeftCapWidth:6 topCapHeight:0] drawInRect:CGRectMake(0, -1, kTileSize.width+1, kTileSize.height+1)];
textColor = [UIColor whiteColor];
shadowColor = [UIColor blackColor];
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker_today.png"];
} else if ([self isToday] && !self.selected) {
[[[UIImage imageNamed:@"Kal.bundle/kal_tile_today.png"] stretchableImageWithLeftCapWidth:6 topCapHeight:0] drawInRect:CGRectMake(0, -1, kTileSize.width+1, kTileSize.height+1)];
textColor = [UIColor whiteColor];
shadowColor = [UIColor blackColor];
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker_today.png"];
} else if (self.selected) {
[[[UIImage imageNamed:@"Kal.bundle/kal_tile_selected.png"] stretchableImageWithLeftCapWidth:1 topCapHeight:0] drawInRect:CGRectMake(0, -1, kTileSize.width+1, kTileSize.height+1)];
textColor = [UIColor whiteColor];
shadowColor = [UIColor blackColor];
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker_selected.png"];
} else if (self.belongsToAdjacentMonth) {
textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Kal.bundle/kal_tile_dim_text_fill.png"]];
shadowColor = nil;
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker_dim.png"];
} else {
textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Kal.bundle/kal_tile_text_fill.png"]];
shadowColor = [UIColor whiteColor];
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker.png"];
}
NSDateFormatter *dateFortmatter=[[NSDateFormatter alloc] init];
[dateFortmatter setDateFormat:@"yyyyMMdd"];
NSString *dateOfTile=[dateFortmatter stringFromDate:[date NSDate]];
[dateFortmatter release];
//if ([self fetchEventsForThisDate:[date NSDate]]) {
// NSLog(@"date has appointment");
// if (self.belongsToAdjacentMonth)
// {
// textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Kal.bundle/kal_tile_dim_text_fill.png"]];
// shadowColor = nil;
// markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker_dim.png"];
// }
// else
// {
// textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Kal.bundle/kal_tile_text_fill.png"]];
// shadowColor = [UIColor whiteColor];
// markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker.png"];
// }
// [markerImage drawInRect:CGRectMake(21.f, 5.f, 4.f, 5.f)];
//
//
// }
//
if ([self doesThisDateHaveAppointment:dateOfTile]) {
NSLog(@"date has appointment");
if (self.belongsToAdjacentMonth)
{
textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Kal.bundle/kal_tile_dim_text_fill.png"]];
shadowColor = nil;
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker_dim.png"];
}
else
{
textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Kal.bundle/kal_tile_text_fill.png"]];
shadowColor = [UIColor whiteColor];
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker.png"];
}
[markerImage drawInRect:CGRectMake(21.f, 5.f, 4.f, 5.f)];
}
else{
}
if (flags.marked)
[markerImage drawInRect:CGRectMake(21.f, 5.f, 4.f, 5.f)];
NSUInteger n = [self.date day];
NSString *dayText = [NSString stringWithFormat:@"%lu", (unsigned long)n];
const char *day = [dayText cStringUsingEncoding:NSUTF8StringEncoding];
CGSize textSize = [dayText sizeWithFont:font];
CGFloat textX, textY;
textX = roundf(0.5f * (kTileSize.width - textSize.width));
textY = 6.f + roundf(0.5f * (kTileSize.height - textSize.height));
if (shadowColor) {
[shadowColor setFill];
CGContextShowTextAtPoint(ctx, textX, textY, day, n >= 10 ? 2 : 1);
textY += 1.f;
}
[textColor setFill];
CGContextShowTextAtPoint(ctx, textX, textY, day, n >= 10 ? 2 : 1);
if (self.highlighted) {
[[UIColor colorWithWhite:0.25f alpha:0.3f] setFill];
CGContextFillRect(ctx, CGRectMake(0.f, 0.f, kTileSize.width, kTileSize.height));
}
}
(void)resetState
{
// realign to the grid
CGRect frame = self.frame;
frame.origin = origin;
frame.size = kTileSize;
self.frame = frame;
[date release];
date = nil;
flags.type = KalTileTypeRegular;
flags.highlighted = NO;
flags.selected = NO;
flags.marked = NO;
}
(void)setDate:(KalDate *)aDate
{
if (date == aDate)
return;
[date release];
date = [aDate retain];
[self setNeedsDisplay];
}
(BOOL)isSelected { return flags.selected; }
(void)setSelected:(BOOL)selected
{
if (flags.selected == selected)
return;
if (![self isToday]) {
CGRect rect = self.frame;
if (selected) {
rect.origin.x--;
rect.size.width++;
rect.size.height++;
} else {
rect.origin.x++;
rect.size.width--;
rect.size.height--;
}
self.frame = rect;
}
flags.selected = selected;
[self setNeedsDisplay];
}
(BOOL)isHighlighted { return flags.highlighted; }
(void)setHighlighted:(BOOL)highlighted
{
if (flags.highlighted == highlighted)
return;
flags.highlighted = highlighted;
[self setNeedsDisplay];
}
(BOOL)isMarked { return flags.marked; }
(void)setMarked:(BOOL)marked
{
if (flags.marked == marked)
return;
flags.marked = marked;
[self setNeedsDisplay];
}
(KalTileType)type { return flags.type; }
(void)setType:(KalTileType)tileType
{
if (flags.type == tileType)
return;
CGRect rect = self.frame;
if (tileType == KalTileTypeToday) {
rect.origin.x--;
rect.size.width++;
rect.size.height++;
} else if (flags.type == KalTileTypeToday) {
rect.origin.x++;
rect.size.width--;
rect.size.height--;
}
self.frame = rect;
flags.type = tileType;
[self setNeedsDisplay];
}
(BOOL)isToday { return flags.type == KalTileTypeToday; }
(BOOL)belongsToAdjacentMonth { return flags.type == KalTileTypeAdjacent; }
(void)dealloc
{
[date release];
[super dealloc];
}
//-(BOOL)fetchEventsForThisDate:(NSDate *)date1{
//
// //NSDateFormatter *dateFortmatter=[[NSDateFormatter alloc] init];
//// [dateFortmatter setDateFormat:@"yyyy-MM-dd"];
//// NSDate *date1=[dateFortmatter dateFromString:datee];
// //m for ML
// //[dateFortmatter release];
// //NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//// [dateFormatter setDateFormat:@"yyyy-MM-dd"];
//// //HH:mm:ss
//// //NSString *str = [NSString stringWithFormat:"%@ 00:00:00",date];
//// NSDate *dat =[dateFormatter dateFromString:date];
//
// //NSDate *datee = date1;
// eventStore = [[EKEventStore alloc] init];
//
// defaultCalendar = [eventStore defaultCalendarForNewEvents];
// BOOL isEventPresent = NO;
// NSTimeInterval secondsInHalfHours = 24 * 60 * 60;
// NSDate *endDate = [date1 dateByAddingTimeInterval:secondsInHalfHours];
//
// //NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:86400];
//
//
//
// // Create the predicate. Pass it the default calendar.
//
// NSArray *calendarArray = [NSArray arrayWithObject:defaultCalendar];
//
// NSPredicate *predicate = [eventStore predicateForEventsWithStartDate:date1 endDate:endDate
//
// calendars:calendarArray];
//
//
//
// // Fetch all events that match the predicate.
//
// NSArray *events = [eventStore eventsMatchingPredicate:predicate];
//
//if ([events count] != 0) {
// isEventPresent = YES;
//
//}
//
// return isEventPresent;
//
//
//
//}
-(BOOL)doesThisDateHaveAppointment:(NSString *)dateOfTile
{
if ([dateOfTile length]<1) {
return NO;
}
BOOL isAppointmentPresent=NO;
sqlite3 *database;
NSArray *arrDocPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// b create the actual destination path
NSString *strDestPath = [NSString stringWithFormat:@"%@/call_log.sqlite",[arrDocPath objectAtIndex:0]];
// Open the database from the users filessytem
if(sqlite3_open([strDestPath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
NSString *sqlString=[NSString stringWithFormat:@"SELECT appointment_id FROM appointment_log where date = %@",dateOfTile];
NSLog(@"getvalues--------------:%@",sqlString);
const char *sqlStatement = [sqlString UTF8String];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
int appointment_id=sqlite3_column_int(compiledStatement, 0);
isAppointmentPresent=YES;
}
}
else
{
NSAssert1(0, @"Error while getting data. '%s'", sqlite3_errmsg(database));
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
return isAppointmentPresent;
}
@EnD
calender.h
@interface calenderViewController : UIViewController<KalDelegate,KalDataSource>//,EKEventEditViewDelegate
{
IBOutlet UITableView *dayView;
IBOutlet UIScrollView *dayScrollView;
IBOutlet UILabel *dateLabel;
IBOutlet UITextView *dateTextView;
IBOutlet UITextView *noOfAppointmentLabel;
KalViewController *kal;
NSMutableArray *appointmentViewsArray;
NSMutableArray *appointmentViewsArray1;
NSMutableArray *items;
EKEventStore *eventStore;
EKCalendar *defaultCalendar;
NSString *startTime1;
NSString *startTime2;
int appcount;
}
-(void)setViewDates:(NSDate *)date;
-(NSMutableArray *)getAppointmentForDate:(NSString *)date;
-(void)addAppointmentsOnTable:(NSMutableArray *)appointmentArray;
-(NSArray *)fetchEventsForToday:(NSDate *)date;
-(void)addAppointmentsOnTableOfCalenderEvent:(NSArray *)appointmentArray1;
@EnD
calender.m
@implementation calenderViewController
//@synthesize detailViewController,eventStore,defaultCalendar,eventsList;
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
(void)viewDidLoad {
eventStore = [[EKEventStore alloc] init];
items = [[NSMutableArray alloc] init];
defaultCalendar = [eventStore defaultCalendarForNewEvents];
[super viewDidLoad];
for (int i=0; i<=23; i++) {
UILabel _lbl=[[UILabel alloc] initWithFrame:CGRectMake(0, i_100, 60, 30)];
lbl.textAlignment=UITextAlignmentRight;
lbl.font=[UIFont fontWithName:@"Helvetica" size:15.0];
if (i<12) {
lbl.text=[NSString stringWithFormat:@"%d AM",i];
}
else
{
lbl.text=[NSString stringWithFormat:@"%d PM",i-12];
}
if (i==12) {
lbl.text=[NSString stringWithFormat:@"12 PM"];
}
if (i==0) {
lbl.text=[NSString stringWithFormat:@"12:00 AM"];
lbl.frame=CGRectMake(-5, i*100, 70, 30);
}
UILabel *mins=[[UILabel alloc] initWithFrame:CGRectMake(0, (i*100)+50, 60, 30)];
mins.backgroundColor=[UIColor clearColor];
mins.textAlignment=UITextAlignmentRight;
mins.text=@"30";
[dayScrollView addSubview:lbl];
[dayScrollView addSubview:mins];
}
dayView.rowHeight=100.0;
[self setViewDates:[NSDate date]];
kal = [[KalViewController alloc] initWithSelectedDate:[NSDate date]];
kal.Kaldelegate=self;
kal.view.frame=CGRectMake(423, 20, 320, 320);
kal.view.clipsToBounds=YES;
[self.view addSubview:kal.view];
}
// -----------------------------------------
/*
// Override to allow orientations other than the default portrait orientation.
//- (void)dealloc {
// [super dealloc];
//}
-(IBAction)todayClicked:(id)sender
{
[kal showAndSelectDate:[NSDate date]];
[self setViewDates:[NSDate date]];
}
-(void)setViewDates:(NSDate *)date
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd"];
dateLabel.text=[NSString stringWithFormat:@"%@",[dateFormatter stringFromDate:date]];
[dateFormatter setDateFormat:@"EEEE"];
dateTextView.text=[NSString stringWithFormat:@"%@, %@ %@ %@",[dateFormatter stringFromDate:date],[self monthString:date],dateLabel.text,[self yearString:date]];
[dateFormatter release];
NSDateFormatter *databaseDate = [[NSDateFormatter alloc] init];
[databaseDate setDateFormat:@"yyyyMMdd"];
NSString *databaseDateString=[databaseDate stringFromDate:date];
//m for ML
[databaseDate release];
NSMutableArray *appointments_array=[self getAppointmentForDate:databaseDateString];
//[self.eventsList addObjectsFromArray:[self fetchEventsForToday]];
NSArray *calEvents = [self fetchEventsForToday:date];
NSLog(@"The no of events in iphone calender is:%d",[calEvents count]);
if ([calEvents count]==1) {
appcount= [calEvents count];
//noOfAppointmentLabel.text=[NSString stringWithFormat:@"You have %d appointment\nscheduled for this day",[appointments_array count]];
}
if ([appointments_array count]==1) {
int nifAPP = [appointments_array count] + appcount;
noOfAppointmentLabel.text=[NSString stringWithFormat:@"You have %d appointment\nscheduled for this day",nifAPP];
}
else
{
int nifAPP1 = [appointments_array count] + appcount;
noOfAppointmentLabel.text=[NSString stringWithFormat:@"You have %d appointments\nscheduled for this day",nifAPP1];
}
[self addAppointmentsOnTable:appointments_array];
[self addAppointmentsOnTableOfCalenderEvent:calEvents];
}
(NSString*) monthString:(NSDate *)date{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMMM"];
NSString *string=[dateFormatter stringFromDate:date];
//m for ML
[dateFormatter release];
return string;
}
(NSString*) yearString:(NSDate *)date{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy"];
NSString *string=[dateFormatter stringFromDate:date];
//m for ML
[dateFormatter release];
return string;
}
-(NSMutableArray *)getAppointmentForDate:(NSString *)date
{
//
NSMutableArray *appointment_array=[[NSMutableArray alloc] init];
sqlite3 *database;
NSArray *arrDocPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//Create the actual destination path
NSString *databasePath = [NSString stringWithFormat:@"%@/call_log.sqlite",[arrDocPath objectAtIndex:0]];
// Open the database from the users filessytem
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
NSString *sqlString=[NSString stringWithFormat:@"SELECT appointment_id,patient_id,physician_id,starttime,endtime,title FROM appointment_log WHERE date = %@",date];
NSLog(@"getvalues--------------:%@",sqlString);
const char *sqlStatement = [sqlString UTF8String];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
Appointment_table *appointment=[[Appointment_table alloc] init];
appointment.appointment_id=sqlite3_column_int(compiledStatement, 0);
appointment.patient_id=sqlite3_column_int(compiledStatement, 1);
appointment.physician_id=sqlite3_column_int(compiledStatement,2);
if (sqlite3_column_text(compiledStatement, 3) ==NULL)
appointment.startTime=0.0;
else
appointment.startTime = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)] floatValue];
if (sqlite3_column_text(compiledStatement, 4) ==NULL)
appointment.endTime=0.0;
else
appointment.endTime = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 4)] floatValue];
if (sqlite3_column_text(compiledStatement, 5) ==NULL)
appointment.title=@"";
else
appointment.title = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 5)];
[appointment_array addObject:appointment];
}
}
else
{
NSAssert1(0, @"Error while retriving data. '%s'", sqlite3_errmsg(database));
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
return appointment_array;
}
// Add appointment to table
-(void)addAppointmentsOnTable:(NSMutableArray *)appointmentArray
{
if (appointmentViewsArray) {
for (AppointmentOnCalendarView *v in appointmentViewsArray) {
[v release];
}
[appointmentViewsArray removeAllObjects];
appointmentViewsArray=[[NSMutableArray alloc] init];
}
else
{
appointmentViewsArray=[[NSMutableArray alloc] init];
}
Appointment_table *appointment=[[Appointment_table alloc] init];
for (int i=0; i<[appointmentArray count]; i++) {
appointment=[appointmentArray objectAtIndex:i];
AppointmentOnCalendarView *appointmentView=[[AppointmentOnCalendarView alloc] init];
appointmentView.delegate=self;
/* float heightOfView=(appointment.endTime-appointment.startTime);
int floor=(appointment.endTime-appointment.startTime);
heightOfView=heightOfView-floor;
heightOfView=(1/0.6)*heightOfView;
heightOfView=floor+heightOfView;
NSLog(@"height of view %d %f",floor,heightOfView);*/
float startTime=appointment.startTime;
int floor1=appointment.startTime;
startTime=startTime-floor1;
startTime=(1/0.6)*startTime;
startTime=floor1+startTime;
float endTime=appointment.endTime;
int floor2=appointment.endTime;
endTime=endTime-floor2;
endTime=(1/0.6)*endTime;
endTime=floor2+endTime;
float heightOfView=endTime-startTime;
// frame for appointment View.
appointmentView.view.frame=CGRectMake(5, ((startTime)_1.667_60)+1,dayView.frame.size.width-30 , heightOfView_1.66_60);
appointmentView.app_title.text=[appointment.title AES256DecryptWithKey:@"v014AVCOesang"];
if (appointment.physician_id==-1) {
appointmentView.physicianOrPatientLabel.text=@"Participant";
[appointmentView getPatientName:appointment.patient_id];
appointmentView.isphysician=NO;
appointmentView.view.backgroundColor=[UIColor colorWithRed:154.0/255.0 green:200.0/255.0 blue:193.0/255.0 alpha:0.6];
}
else
{
appointmentView.physicianOrPatientLabel.text=@"Physician";
[appointmentView getPhysicianName:appointment.physician_id];
appointmentView.isphysician=YES;
appointmentView.view.backgroundColor=[UIColor colorWithRed:154.0/255.0 green:150.0/255.0 blue:220.0/255.0 alpha:0.6];
}
appointmentView.appointmentid=appointment.appointment_id;
[dayView addSubview:appointmentView.view];
[appointmentViewsArray addObject:appointmentView];
}
}
//csynch
-(void)addAppointmentsOnTableOfCalenderEvent:(NSArray *)appointmentArray1{
NSLog(@"event to add in table %d",[appointmentArray1 count]);
if (appointmentViewsArray1) {
for (AppointmentOnCalendarView *v in appointmentViewsArray1) {
[v release];
}
[appointmentViewsArray1 removeAllObjects];
appointmentViewsArray1=[[NSMutableArray alloc] init];
}
else
{
appointmentViewsArray1=[[NSMutableArray alloc] init];
}
for (int i=0; i<[appointmentArray1 count]; i++) {
EKEvent *event =[appointmentArray1 objectAtIndex:i];
AppointmentOnCalendarView *appointmentView=[[AppointmentOnCalendarView alloc] init];
appointmentView.delegate=self;
/* float heightOfView=(appointment.endTime-appointment.startTime);
int floor=(appointment.endTime-appointment.startTime);
heightOfView=heightOfView-floor;
heightOfView=(1/0.6)*heightOfView;
heightOfView=floor+heightOfView;
NSLog(@"height of view %d %f",floor,heightOfView);*/
NSDateFormatter *databasetime = [[NSDateFormatter alloc] init];
[databasetime setDateFormat:@"HH.mm"];
NSString *time=[databasetime stringFromDate:event.startDate];
//mfor ML
[databasetime release];
//startTime1=[[time];
float startTime=[time floatValue];
int floor1=[time floatValue];
startTime=startTime-floor1;
startTime=(1/0.6)*startTime;
startTime=floor1+startTime;
NSDateFormatter *databasetime1 = [[NSDateFormatter alloc] init];
[databasetime1 setDateFormat:@"HH.mm"];
NSString *time1=[databasetime1 stringFromDate:event.endDate];
//mfor ML
[databasetime release];
float endTime=[time1 floatValue];
int floor2=[time1 floatValue];
endTime=endTime-floor2;
endTime=(1/0.6)*endTime;
endTime=floor2+endTime;
float heightOfView=endTime-startTime;
// frame for appointment View.
appointmentView.view.frame=CGRectMake(5, ((startTime)*1.667*60)+1,dayView.frame.size.width-30 , heightOfView*1.66*60);
appointmentView.app_title.text= event.title;
appointmentView.physicianOrPatientLabel.text= event.location;
//[appointmentView getPatientName:appointment.patient_id];
//appointmentView.isphysician=NO;
appointmentView.view.backgroundColor=[UIColor colorWithRed:100.0/255.0 green:100.0/255.0 blue:123.0/255.0 alpha:0.6];
//appointmentView.appointmentid= 0;
[dayView addSubview:appointmentView.view];
[appointmentViewsArray1 addObject:appointmentView];
}
}
-(void)viewTouched:(int)appointment_id patientName:(NSString *)patientName
{
EditAppointmentView *editAppointment=[[EditAppointmentView alloc] init];
NSLog(@"patient id %d",editAppointment.patient_id);
editAppointment.superObject=self;
editAppointment.appointment_id=appointment_id;
editAppointment.patient_Name=patientName;
[self.view addSubview:editAppointment.view];
}
-(void)viewTouched:(int)appointment_id physicianName:(NSString *)physicianName
{
EditPhysicianAppointmentView *editAppointment=[[EditPhysicianAppointmentView alloc] init];
NSLog(@"patient id %d",editAppointment.physician_id);
editAppointment.superObject=self;
editAppointment.appointment_id=appointment_id;
editAppointment.physician_Name =physicianName;
[self.view addSubview:editAppointment.view];
}
(NSArray *)fetchEventsForToday:(NSDate *)date {
// endDate is 1 day = 60*60*24 seconds = 86400 seconds from startDate
NSTimeInterval secondsInHalfHours = 24 * 60 * 60;
NSDate *endDate = [date dateByAddingTimeInterval:secondsInHalfHours];
//NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:86400];
// Create the predicate. Pass it the default calendar.
NSArray *calendarArray = [NSArray arrayWithObject:defaultCalendar];
NSPredicate *predicate = [eventStore predicateForEventsWithStartDate:date endDate:endDate
calendars:calendarArray];
// Fetch all events that match the predicate.
NSArray *events = [eventStore eventsMatchingPredicate:predicate];
NSLog(@"The no of events in iphone calender is:%d",[events count]);
return events;
}
error in startdate i.e is start date is nil.
KalTileView.h
//m for tile
enum {
KalTileTypeRegular = 0,
KalTileTypeAdjacent = 1 << 0,
KalTileTypeToday = 1 << 1,
};
typedef char KalTileType;
@Class KalDate;
@interface KalTileView : UIView
{
KalDate *date;
CGPoint origin;
struct {
unsigned int selected : 1;
unsigned int highlighted : 1;
unsigned int marked : 1;
unsigned int type : 2;
} flags;
//m for tile
EKEventStore *eventStore;
EKCalendar *defaultCalendar;
}
@Property (nonatomic, retain) KalDate *date;
@Property (nonatomic, getter=isHighlighted) BOOL highlighted;
@Property (nonatomic, getter=isSelected) BOOL selected;
@Property (nonatomic, getter=isMarked) BOOL marked;
@Property (nonatomic) KalTileType type;
-(BOOL)fetchEventsForThisDate:(NSDate *)date1;
-(BOOL)doesThisDateHaveAppointment:(NSString *)date;
.m file
extern const CGSize kTileSize;
@implementation KalTileView
@synthesize date;
(id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame])) {
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];
self.clipsToBounds = NO;
origin = frame.origin;
[self resetState];
}
return self;
}
(void)drawRect:(CGRect)rect
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGFloat fontSize = 24.f;
UIFont *font = [UIFont boldSystemFontOfSize:fontSize];
UIColor *shadowColor = nil;
UIColor *textColor = nil;
UIImage *markerImage = nil;
CGContextSelectFont(ctx, [font.fontName cStringUsingEncoding:NSUTF8StringEncoding], fontSize, kCGEncodingMacRoman);
CGContextTranslateCTM(ctx, 0, kTileSize.height);
CGContextScaleCTM(ctx, 1, -1);
if ([self isToday] && self.selected) {
[[[UIImage imageNamed:@"Kal.bundle/kal_tile_today_selected.png"] stretchableImageWithLeftCapWidth:6 topCapHeight:0] drawInRect:CGRectMake(0, -1, kTileSize.width+1, kTileSize.height+1)];
textColor = [UIColor whiteColor];
shadowColor = [UIColor blackColor];
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker_today.png"];
} else if ([self isToday] && !self.selected) {
[[[UIImage imageNamed:@"Kal.bundle/kal_tile_today.png"] stretchableImageWithLeftCapWidth:6 topCapHeight:0] drawInRect:CGRectMake(0, -1, kTileSize.width+1, kTileSize.height+1)];
textColor = [UIColor whiteColor];
shadowColor = [UIColor blackColor];
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker_today.png"];
} else if (self.selected) {
[[[UIImage imageNamed:@"Kal.bundle/kal_tile_selected.png"] stretchableImageWithLeftCapWidth:1 topCapHeight:0] drawInRect:CGRectMake(0, -1, kTileSize.width+1, kTileSize.height+1)];
textColor = [UIColor whiteColor];
shadowColor = [UIColor blackColor];
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker_selected.png"];
} else if (self.belongsToAdjacentMonth) {
textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Kal.bundle/kal_tile_dim_text_fill.png"]];
shadowColor = nil;
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker_dim.png"];
} else {
textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Kal.bundle/kal_tile_text_fill.png"]];
shadowColor = [UIColor whiteColor];
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker.png"];
}
NSDateFormatter *dateFortmatter=[[NSDateFormatter alloc] init];
[dateFortmatter setDateFormat:@"yyyyMMdd"];
NSString *dateOfTile=[dateFortmatter stringFromDate:[date NSDate]];
//m for ML
[dateFortmatter release];
if ([self fetchEventsForThisDate:[date NSDate]]) {
NSLog(@"date has appointment");
if (self.belongsToAdjacentMonth)
{
textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Kal.bundle/kal_tile_dim_text_fill.png"]];
shadowColor = nil;
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker_dim.png"];
}
else
{
textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Kal.bundle/kal_tile_text_fill.png"]];
shadowColor = [UIColor whiteColor];
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker.png"];
}
[markerImage drawInRect:CGRectMake(21.f, 5.f, 4.f, 5.f)];
}
if ([self doesThisDateHaveAppointment:dateOfTile]) {
NSLog(@"date has appointment");
if (self.belongsToAdjacentMonth)
{
textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Kal.bundle/kal_tile_dim_text_fill.png"]];
shadowColor = nil;
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker_dim.png"];
}
else
{
textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Kal.bundle/kal_tile_text_fill.png"]];
shadowColor = [UIColor whiteColor];
markerImage = [UIImage imageNamed:@"Kal.bundle/kal_marker.png"];
}
[markerImage drawInRect:CGRectMake(21.f, 5.f, 4.f, 5.f)];
}
else{
}
if (flags.marked)
[markerImage drawInRect:CGRectMake(21.f, 5.f, 4.f, 5.f)];
NSUInteger n = [self.date day];
NSString *dayText = [NSString stringWithFormat:@"%lu", (unsigned long)n];
const char *day = [dayText cStringUsingEncoding:NSUTF8StringEncoding];
CGSize textSize = [dayText sizeWithFont:font];
CGFloat textX, textY;
textX = roundf(0.5f * (kTileSize.width - textSize.width));
textY = 6.f + roundf(0.5f * (kTileSize.height - textSize.height));
if (shadowColor) {
[shadowColor setFill];
CGContextShowTextAtPoint(ctx, textX, textY, day, n >= 10 ? 2 : 1);
textY += 1.f;
}
[textColor setFill];
CGContextShowTextAtPoint(ctx, textX, textY, day, n >= 10 ? 2 : 1);
if (self.highlighted) {
[[UIColor colorWithWhite:0.25f alpha:0.3f] setFill];
CGContextFillRect(ctx, CGRectMake(0.f, 0.f, kTileSize.width, kTileSize.height));
}
}
(void)resetState
{
// realign to the grid
CGRect frame = self.frame;
frame.origin = origin;
frame.size = kTileSize;
self.frame = frame;
[date release];
date = nil;
flags.type = KalTileTypeRegular;
flags.highlighted = NO;
flags.selected = NO;
flags.marked = NO;
}
(void)setDate:(KalDate *)aDate
{
if (date == aDate)
return;
[date release];
date = [aDate retain];
[self setNeedsDisplay];
}
(BOOL)isSelected { return flags.selected; }
(void)setSelected:(BOOL)selected
{
if (flags.selected == selected)
return;
// workaround since I cannot draw outside of the frame in drawRect:
if (![self isToday]) {
CGRect rect = self.frame;
if (selected) {
rect.origin.x--;
rect.size.width++;
rect.size.height++;
} else {
rect.origin.x++;
rect.size.width--;
rect.size.height--;
}
self.frame = rect;
}
flags.selected = selected;
[self setNeedsDisplay];
}
(BOOL)isHighlighted { return flags.highlighted; }
(void)setHighlighted:(BOOL)highlighted
{
if (flags.highlighted == highlighted)
return;
flags.highlighted = highlighted;
[self setNeedsDisplay];
}
(BOOL)isMarked { return flags.marked; }
(void)setMarked:(BOOL)marked
{
if (flags.marked == marked)
return;
flags.marked = marked;
[self setNeedsDisplay];
}
(KalTileType)type { return flags.type; }
(void)setType:(KalTileType)tileType
{
if (flags.type == tileType)
return;
// workaround since I cannot draw outside of the frame in drawRect:
CGRect rect = self.frame;
if (tileType == KalTileTypeToday) {
rect.origin.x--;
rect.size.width++;
rect.size.height++;
} else if (flags.type == KalTileTypeToday) {
rect.origin.x++;
rect.size.width--;
rect.size.height--;
}
self.frame = rect;
flags.type = tileType;
[self setNeedsDisplay];
}
(BOOL)isToday { return flags.type == KalTileTypeToday; }
(BOOL)belongsToAdjacentMonth { return flags.type == KalTileTypeAdjacent; }
//m for ML
(void)dealloc
{
//[dateFortmatter release];
[date release];
[super dealloc];
}
-(BOOL)fetchEventsForThisDate:(NSDate *)date1{
//NSDateFormatter *dateFortmatter=[[NSDateFormatter alloc] init];
// [dateFortmatter setDateFormat:@"yyyy-MM-dd"];
// NSDate *date1=[dateFortmatter dateFromString:datee];
//m for ML
//[dateFortmatter release];
//NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// [dateFormatter setDateFormat:@"yyyy-MM-dd"];
// //HH:mm:ss
// //NSString *str = [NSString stringWithFormat:"%@ 00:00:00",date];
// NSDate *dat =[dateFormatter dateFromString:date];
//NSDate *datee = date1;
eventStore = [[EKEventStore alloc] init];
defaultCalendar = [eventStore defaultCalendarForNewEvents];
BOOL isEventPresent = NO;
NSTimeInterval secondsInHalfHours = 24 * 60 * 60;
NSDate *endDate = [date1 dateByAddingTimeInterval:secondsInHalfHours];
//NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:86400];
// Create the predicate. Pass it the default calendar.
NSArray *calendarArray = [NSArray arrayWithObject:defaultCalendar];
NSPredicate *predicate = [eventStore predicateForEventsWithStartDate:date1 endDate:endDate
calendars:calendarArray];
// Fetch all events that match the predicate.
NSArray *events = [eventStore eventsMatchingPredicate:predicate];
if ([events count] != 0) {
isEventPresent = YES;
}
return isEventPresent;
}
-(BOOL)doesThisDateHaveAppointment:(NSString *)dateOfTile
{
if ([dateOfTile length]<1) {
return NO;
}
BOOL isAppointmentPresent=NO;
sqlite3 *database;
NSArray *arrDocPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// b create the actual destination path
NSString *strDestPath = [NSString stringWithFormat:@"%@/call_log.sqlite",[arrDocPath objectAtIndex:0]];
// Open the database from the users filessytem
if(sqlite3_open([strDestPath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
NSString *sqlString=[NSString stringWithFormat:@"SELECT appointment_id FROM appointment_log where date = %@",dateOfTile];
NSLog(@"getvalues--------------:%@",sqlString);
const char *sqlStatement = [sqlString UTF8String];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
int appointment_id=sqlite3_column_int(compiledStatement, 0);
isAppointmentPresent=YES;
}
}
else
{
NSAssert1(0, @"Error while getting data. '%s'", sqlite3_errmsg(database));
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
return isAppointmentPresent;
}
@EnD
Kal.h
@interface calenderViewController : UIViewController<KalDelegate,KalDataSource>//,EKEventEditViewDelegate
{
IBOutlet UITableView *dayView;
IBOutlet UIScrollView *dayScrollView;
IBOutlet UILabel *dateLabel;
IBOutlet UITextView *dateTextView;
IBOutlet UITextView *noOfAppointmentLabel;
KalViewController *kal;
NSMutableArray *appointmentViewsArray;
NSMutableArray *appointmentViewsArray1;
NSMutableArray *items;
EKEventStore *eventStore;
EKCalendar *defaultCalendar;
NSString *startTime1;
NSString *startTime2;
int appcount;
}
-(void)setViewDates:(NSDate *)date;
-(NSMutableArray *)getAppointmentForDate:(NSString *)date;
-(void)addAppointmentsOnTable:(NSMutableArray *)appointmentArray;
-(NSArray *)fetchEventsForToday:(NSDate *)date;
-(void)addAppointmentsOnTableOfCalenderEvent:(NSArray *)appointmentArray1;
@EnD
Kal.m
@implementation calenderViewController
//@synthesize detailViewController,eventStore,defaultCalendar,eventsList;
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
(void)viewDidLoad {
eventStore = [[EKEventStore alloc] init];
items = [[NSMutableArray alloc] init];
defaultCalendar = [eventStore defaultCalendarForNewEvents];
[super viewDidLoad];
for (int i=0; i<=23; i++) {
UILabel _lbl=[[UILabel alloc] initWithFrame:CGRectMake(0, i_100, 60, 30)];
lbl.textAlignment=UITextAlignmentRight;
lbl.font=[UIFont fontWithName:@"Helvetica" size:15.0];
if (i<12) {
lbl.text=[NSString stringWithFormat:@"%d AM",i];
}
else
{
lbl.text=[NSString stringWithFormat:@"%d PM",i-12];
}
if (i==12) {
lbl.text=[NSString stringWithFormat:@"12 PM"];
}
if (i==0) {
lbl.text=[NSString stringWithFormat:@"12:00 AM"];
lbl.frame=CGRectMake(-5, i*100, 70, 30);
}
UILabel *mins=[[UILabel alloc] initWithFrame:CGRectMake(0, (i*100)+50, 60, 30)];
mins.backgroundColor=[UIColor clearColor];
mins.textAlignment=UITextAlignmentRight;
mins.text=@"30";
[dayScrollView addSubview:lbl];
[dayScrollView addSubview:mins];
}
dayView.rowHeight=100.0;
[self setViewDates:[NSDate date]];
kal = [[KalViewController alloc] initWithSelectedDate:[NSDate date]];
kal.Kaldelegate=self;
kal.view.frame=CGRectMake(423, 20, 320, 320);
kal.view.clipsToBounds=YES;
[self.view addSubview:kal.view];
}
// -----------------------------------------
/*
// Override to allow orientations other than the default portrait orientation.
//- (void)dealloc {
// [super dealloc];
//}
-(IBAction)todayClicked:(id)sender
{
[kal showAndSelectDate:[NSDate date]];
[self setViewDates:[NSDate date]];
}
-(void)setViewDates:(NSDate *)date
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd"];
dateLabel.text=[NSString stringWithFormat:@"%@",[dateFormatter stringFromDate:date]];
[dateFormatter setDateFormat:@"EEEE"];
dateTextView.text=[NSString stringWithFormat:@"%@, %@ %@ %@",[dateFormatter stringFromDate:date],[self monthString:date],dateLabel.text,[self yearString:date]];
[dateFormatter release];
NSDateFormatter *databaseDate = [[NSDateFormatter alloc] init];
[databaseDate setDateFormat:@"yyyyMMdd"];
NSString *databaseDateString=[databaseDate stringFromDate:date];
//m for ML
[databaseDate release];
NSMutableArray *appointments_array=[self getAppointmentForDate:databaseDateString];
//[self.eventsList addObjectsFromArray:[self fetchEventsForToday]];
NSArray *calEvents = [self fetchEventsForToday:date];
NSLog(@"The no of events in iphone calender is:%d",[calEvents count]);
if ([calEvents count]==1) {
appcount= [calEvents count];
//noOfAppointmentLabel.text=[NSString stringWithFormat:@"You have %d appointment\nscheduled for this day",[appointments_array count]];
}
if ([appointments_array count]==1) {
int nifAPP = [appointments_array count] + appcount;
noOfAppointmentLabel.text=[NSString stringWithFormat:@"You have %d appointment\nscheduled for this day",nifAPP];
}
else
{
int nifAPP1 = [appointments_array count] + appcount;
noOfAppointmentLabel.text=[NSString stringWithFormat:@"You have %d appointments\nscheduled for this day",nifAPP1];
}
[self addAppointmentsOnTable:appointments_array];
[self addAppointmentsOnTableOfCalenderEvent:calEvents];
}
(NSString*) monthString:(NSDate *)date{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMMM"];
NSString *string=[dateFormatter stringFromDate:date];
//m for ML
[dateFormatter release];
return string;
}
(NSString*) yearString:(NSDate *)date{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy"];
NSString *string=[dateFormatter stringFromDate:date];
//m for ML
[dateFormatter release];
return string;
}
-(NSMutableArray *)getAppointmentForDate:(NSString *)date
{
//
NSMutableArray *appointment_array=[[NSMutableArray alloc] init];
sqlite3 *database;
NSArray *arrDocPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//Create the actual destination path
NSString *databasePath = [NSString stringWithFormat:@"%@/call_log.sqlite",[arrDocPath objectAtIndex:0]];
// Open the database from the users filessytem
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
NSString *sqlString=[NSString stringWithFormat:@"SELECT appointment_id,patient_id,physician_id,starttime,endtime,title FROM appointment_log WHERE date = %@",date];
NSLog(@"getvalues--------------:%@",sqlString);
const char *sqlStatement = [sqlString UTF8String];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
Appointment_table *appointment=[[Appointment_table alloc] init];
appointment.appointment_id=sqlite3_column_int(compiledStatement, 0);
appointment.patient_id=sqlite3_column_int(compiledStatement, 1);
appointment.physician_id=sqlite3_column_int(compiledStatement,2);
if (sqlite3_column_text(compiledStatement, 3) ==NULL)
appointment.startTime=0.0;
else
appointment.startTime = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)] floatValue];
if (sqlite3_column_text(compiledStatement, 4) ==NULL)
appointment.endTime=0.0;
else
appointment.endTime = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 4)] floatValue];
if (sqlite3_column_text(compiledStatement, 5) ==NULL)
appointment.title=@"";
else
appointment.title = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 5)];
[appointment_array addObject:appointment];
}
}
else
{
NSAssert1(0, @"Error while retriving data. '%s'", sqlite3_errmsg(database));
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
return appointment_array;
}
// Add appointment to table
-(void)addAppointmentsOnTable:(NSMutableArray *)appointmentArray
{
if (appointmentViewsArray) {
for (AppointmentOnCalendarView *v in appointmentViewsArray) {
[v release];
}
[appointmentViewsArray removeAllObjects];
appointmentViewsArray=[[NSMutableArray alloc] init];
}
else
{
appointmentViewsArray=[[NSMutableArray alloc] init];
}
Appointment_table *appointment=[[Appointment_table alloc] init];
for (int i=0; i<[appointmentArray count]; i++) {
appointment=[appointmentArray objectAtIndex:i];
AppointmentOnCalendarView *appointmentView=[[AppointmentOnCalendarView alloc] init];
appointmentView.delegate=self;
/* float heightOfView=(appointment.endTime-appointment.startTime);
int floor=(appointment.endTime-appointment.startTime);
heightOfView=heightOfView-floor;
heightOfView=(1/0.6)*heightOfView;
heightOfView=floor+heightOfView;
NSLog(@"height of view %d %f",floor,heightOfView);*/
float startTime=appointment.startTime;
int floor1=appointment.startTime;
startTime=startTime-floor1;
startTime=(1/0.6)*startTime;
startTime=floor1+startTime;
float endTime=appointment.endTime;
int floor2=appointment.endTime;
endTime=endTime-floor2;
endTime=(1/0.6)*endTime;
endTime=floor2+endTime;
float heightOfView=endTime-startTime;
// frame for appointment View.
appointmentView.view.frame=CGRectMake(5, ((startTime)_1.667_60)+1,dayView.frame.size.width-30 , heightOfView_1.66_60);
appointmentView.app_title.text=[appointment.title AES256DecryptWithKey:@"v014AVCOesang"];
if (appointment.physician_id==-1) {
appointmentView.physicianOrPatientLabel.text=@"Participant";
[appointmentView getPatientName:appointment.patient_id];
appointmentView.isphysician=NO;
appointmentView.view.backgroundColor=[UIColor colorWithRed:154.0/255.0 green:200.0/255.0 blue:193.0/255.0 alpha:0.6];
}
else
{
appointmentView.physicianOrPatientLabel.text=@"Physician";
[appointmentView getPhysicianName:appointment.physician_id];
appointmentView.isphysician=YES;
appointmentView.view.backgroundColor=[UIColor colorWithRed:154.0/255.0 green:150.0/255.0 blue:220.0/255.0 alpha:0.6];
}
appointmentView.appointmentid=appointment.appointment_id;
[dayView addSubview:appointmentView.view];
[appointmentViewsArray addObject:appointmentView];
}
}
//csynch
-(void)addAppointmentsOnTableOfCalenderEvent:(NSArray *)appointmentArray1{
NSLog(@"event to add in table %d",[appointmentArray1 count]);
if (appointmentViewsArray1) {
for (AppointmentOnCalendarView *v in appointmentViewsArray1) {
[v release];
}
[appointmentViewsArray1 removeAllObjects];
appointmentViewsArray1=[[NSMutableArray alloc] init];
}
else
{
appointmentViewsArray1=[[NSMutableArray alloc] init];
}
for (int i=0; i<[appointmentArray1 count]; i++) {
EKEvent *event =[appointmentArray1 objectAtIndex:i];
AppointmentOnCalendarView *appointmentView=[[AppointmentOnCalendarView alloc] init];
appointmentView.delegate=self;
/* float heightOfView=(appointment.endTime-appointment.startTime);
int floor=(appointment.endTime-appointment.startTime);
heightOfView=heightOfView-floor;
heightOfView=(1/0.6)*heightOfView;
heightOfView=floor+heightOfView;
NSLog(@"height of view %d %f",floor,heightOfView);*/
NSDateFormatter *databasetime = [[NSDateFormatter alloc] init];
[databasetime setDateFormat:@"HH.mm"];
NSString *time=[databasetime stringFromDate:event.startDate];
//mfor ML
[databasetime release];
//startTime1=[[time];
float startTime=[time floatValue];
int floor1=[time floatValue];
startTime=startTime-floor1;
startTime=(1/0.6)*startTime;
startTime=floor1+startTime;
NSDateFormatter *databasetime1 = [[NSDateFormatter alloc] init];
[databasetime1 setDateFormat:@"HH.mm"];
NSString *time1=[databasetime1 stringFromDate:event.endDate];
//mfor ML
[databasetime release];
float endTime=[time1 floatValue];
int floor2=[time1 floatValue];
endTime=endTime-floor2;
endTime=(1/0.6)*endTime;
endTime=floor2+endTime;
float heightOfView=endTime-startTime;
// frame for appointment View.
appointmentView.view.frame=CGRectMake(5, ((startTime)*1.667*60)+1,dayView.frame.size.width-30 , heightOfView*1.66*60);
appointmentView.app_title.text= event.title;
appointmentView.physicianOrPatientLabel.text= event.location;
//[appointmentView getPatientName:appointment.patient_id];
//appointmentView.isphysician=NO;
appointmentView.view.backgroundColor=[UIColor colorWithRed:100.0/255.0 green:100.0/255.0 blue:123.0/255.0 alpha:0.6];
//appointmentView.appointmentid= 0;
[dayView addSubview:appointmentView.view];
[appointmentViewsArray1 addObject:appointmentView];
}
}
-(void)viewTouched:(int)appointment_id patientName:(NSString *)patientName
{
EditAppointmentView *editAppointment=[[EditAppointmentView alloc] init];
NSLog(@"patient id %d",editAppointment.patient_id);
editAppointment.superObject=self;
editAppointment.appointment_id=appointment_id;
editAppointment.patient_Name=patientName;
[self.view addSubview:editAppointment.view];
}
-(void)viewTouched:(int)appointment_id physicianName:(NSString *)physicianName
{
EditPhysicianAppointmentView *editAppointment=[[EditPhysicianAppointmentView alloc] init];
NSLog(@"patient id %d",editAppointment.physician_id);
editAppointment.superObject=self;
editAppointment.appointment_id=appointment_id;
editAppointment.physician_Name =physicianName;
[self.view addSubview:editAppointment.view];
}
(NSArray *)fetchEventsForToday:(NSDate *)date {
// endDate is 1 day = 60*60*24 seconds = 86400 seconds from startDate
NSTimeInterval secondsInHalfHours = 24 * 60 * 60;
NSDate *endDate = [date dateByAddingTimeInterval:secondsInHalfHours];
//NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:86400];
// Create the predicate. Pass it the default calendar.
NSArray *calendarArray = [NSArray arrayWithObject:defaultCalendar];
NSPredicate *predicate = [eventStore predicateForEventsWithStartDate:date endDate:endDate
calendars:calendarArray];
// Fetch all events that match the predicate.
NSArray *events = [eventStore eventsMatchingPredicate:predicate];
NSLog(@"The no of events in iphone calender is:%d",[events count]);
return events;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.