#import <UIKit/UIKit.h>
#import <EventKit/EventKit.h>
#import <EventKitUI/EventKitUI.h>
@interface DueDate : UITableViewController <UINavigationBarDelegate,UITableViewDelegate,UITableViewDataSource,EKEventEditViewDelegate,UINavigationControllerDelegate,UIActionSheetDelegate>{
EKEventViewController *detailViewController;
EKEventStore *eventStore;
EKCalendar *defaultCalendar;
NSMutableArray *eventsList;
}
@property (nonatomic,retain) EKEventViewController *detailViewController;
@property (nonatomic,retain) EKEventStore *eventStore;
@property (nonatomic,retain) EKCalendar *defaultCalendar;
@property (nonatomic,retain) NSMutableArray *eventsList;
-(NSArray *)fetchEventsForToday;
- (IBAction) addEvent:(id)sender;
@end
#import "DueDate.h"
@implementation DueDate
@synthesize detailViewController,eventStore,defaultCalendar,eventsList;
- (void)dealloc {
[eventStore release];
[eventsList release];
[defaultCalendar release];
[detailViewController release];
[super dealloc];
}
-(void)viewDidLoad{
self.title = @"Remind Me";
self.eventStore = [[EKEventStore alloc] init];
self.eventsList = [[NSMutableArray alloc] initWithArray:0];
self.defaultCalendar = [self.eventStore defaultCalendarForNewEvents];
UIBarButtonItem *addButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addEvent:)];
self.navigationItem.rightBarButtonItem = addButtonItem;
[addButtonItem release];
self.navigationController.delegate = self;
[self.eventsList addObjectsFromArray:[self fetchEventsForToday]];
[self.tableView reloadData];
}
-(void)viewDidUnload{
self.eventsList = nil;
}
-(void)viewWillAppear:(BOOL)animated{
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:NO];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
-(NSArray *)fetchEventsForToday{
NSDate *startDate = [NSDate date];
NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:86400];
NSArray *calendarArray = [NSArray arrayWithObject:defaultCalendar];
NSPredicate *predicate = [self.eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:calendarArray];
NSArray *events = [self.eventStore eventsMatchingPredicate:predicate];
return events;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [eventsList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCellAccessoryType editableCellAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];
}
cell.accessoryType = editableCellAccessoryType;
cell.textLabel.text = [[self.eventsList objectAtIndex:indexPath.row] title];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
self.detailViewController = [[EKEventViewController alloc] initWithNibName:nil bundle:nil];
detailViewController.event = [self.eventsList objectAtIndex:indexPath.row];
detailViewController.allowsEditing = YES;
[self.navigationController pushViewController:detailViewController animated:YES];
}
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
if (viewController == self && self.detailViewController.event.title == NULL) {
[self.eventsList removeObject:self.detailViewController.event];
[self.tableView reloadData];
}
}
- (void)eventEditViewController:(EKEventEditViewController *)controller didCompleteWithAction:(EKEventEditViewAction)action{
NSError *error = nil;
EKEvent *thisEvent = controller.event;
switch (action) {
case EKEventEditViewActionCanceled:
break;
case EKEventEditViewActionSaved:
if (self.defaultCalendar == thisEvent.calendar) {
[self.eventsList addObject:thisEvent];
}
[controller.eventStore saveEvent:controller.event span:EKSpanThisEvent error:&error];
[self.tableView reloadData];
break;
case EKEventEditViewActionDeleted:
if (self.defaultCalendar == thisEvent.calendar) {
[self.eventsList removeObject:thisEvent];
}
[controller.eventStore removeEvent:thisEvent span:EKSpanThisEvent error:&error];
[self.tableView reloadData];
break;
default:
break;
}
[controller dismissModalViewControllerAnimated:YES];
}
- (EKCalendar *)eventEditViewControllerDefaultCalendarForNewEvents:(EKEventEditViewController *)controller{
EKCalendar *calendarForEdit = self.defaultCalendar;
return calendarForEdit;
}
- (void) addEvent:(id)sender{
EKEventEditViewController *addController = [[EKEventEditViewController alloc] initWithNibName:nil bundle:nil];
addController.eventStore = self.eventStore;
// [self presentModalViewController:addController animated:YES];
[self presentModalViewController:addController animated:YES];
addController.editViewDelegate = self;
[addController release];
}
@end
#import <UIKit/UIKit.h>
@interface HomePageWebViewController : UIViewController <UIWebViewDelegate>{
IBOutlet UIWebView *webView;
IBOutlet UIActivityIndicatorView *loadingIndicator;
NSURL *contenturl;
}
-(void)setNavigationTitle:(NSString *)title;
-(void)setURL:(NSURL *)url;
@end
#import "HomePageWebViewController.h"
@implementation HomePageWebViewController
-(void)setURL:(NSURL *)url{
contenturl = url;
}
-(void)setNavigationTitle:(NSString *)title{
self.title = title;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark WEBVIEW DELEGATE
- (void)webViewDidStartLoad:(UIWebView *)webView{
[loadingIndicator startAnimating];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
[loadingIndicator stopAnimating];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
[loadingIndicator stopAnimating];
}
#pragma mark - View lifecycle
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
}
*/
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[loadingIndicator startAnimating];
[webView loadRequest:[NSURLRequest requestWithURL:contenturl]];
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
if([webView isLoading]){
[webView stopLoading];
}
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
#import <UIKit/UIKit.h>
#import <MessageUI/MFMailComposeViewController.h>
@interface MainMenuViewController : UIViewController <UITableViewDelegate,UITableViewDataSource,UIPickerViewDelegate,UIPickerViewDataSource,MFMailComposeViewControllerDelegate> {
NSMutableArray *aryProfessions;
NSMutableArray *aryMainMenuItems;
// NSMutableArray *barItems;
IBOutlet UIPickerView *pkrProfession;
IBOutlet UIToolbar *toolBar;
IBOutlet UIBarButtonItem *btnDone;
IBOutlet UIBarButtonItem *btnCancel;
MFMailComposeViewController *controller;
NSInteger _selIndex;
}
@property (nonatomic, assign) NSInteger selIndex;
- (IBAction)selectAnItem:(id)sender;
- (IBAction)itemNotSelected:(id)sender;
@end
#import "MainMenuViewController.h"
#import "HomePageWebViewController.h"
#import "DueDate.h"
@implementation MainMenuViewController
@synthesize selIndex = _selIndex;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewWillAppear:(BOOL)animated
{
self.title = @"ChiroCredit Main Menu";
[pkrProfession setHidden:YES];
[toolBar setHidden:YES];
[btnDone setEnabled:NO];
aryMainMenuItems = [[NSMutableArray alloc] initWithObjects:@"ChiroCredit Home Page",@"Countinuing Education Courses",@"Continuing Education FAQ's",@"Contact US",@"Remind me when Credits are Due",nil];
aryProfessions = [[[NSMutableArray alloc] initWithObjects:@"Please Select Anyone Course",
[NSDictionary dictionaryWithObjectsAndKeys:@"Aromatherapy",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=27",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Athletic Trainer",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=14",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Boundary Training",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=25",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Chiropractic Assistant",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=3",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Chiropractic Doctor",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=1",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Chiropractic Student",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=2",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Hand Therapist",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=4",@"url",nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Holistic Health Counselor",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=28",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Legal Secretary/Word Processor",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=34",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Massage Therapy",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=22",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Medical Doctor",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=32",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Naturopath",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=24",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Nursing",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=26",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Occupational Therapist",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=19",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"OT Assistant",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=21",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Other Florida Professionals",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=35",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"Physical Therapist",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=18",@"url", nil],
[NSDictionary dictionaryWithObjectsAndKeys:@"PT Assistant",@"title",@"http://www.chirocredit.com/courses/index.php?action=Show+Topics&pid=20",@"url", nil],
nil] retain];
NSLog(@"array count is:- %i",[aryProfessions count]);
// [pkrProfession reloadComponent:0];
[self.view reloadInputViews];
[super viewWillAppear:YES];
// Do any additional setup after loading the view from its nib.
}
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [aryMainMenuItems count];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.font=[UIFont systemFontOfSize:16.0f];
cell.textLabel.font=[UIFont boldSystemFontOfSize:16.0f];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text = [aryMainMenuItems objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
HomePageWebViewController *objHomePage = [[HomePageWebViewController alloc] initWithNibName:@"HomePageWebViewController" bundle:nil];
[objHomePage setNavigationTitle:@"ChiroCredit"];
[objHomePage setURL:[NSURL URLWithString:@"http://www.chirocredit.com/"]];
[self.navigationController pushViewController:objHomePage animated:YES];
}
else if(indexPath.row == 1){
[toolBar setHidden:NO];
// barItems = [[NSMutableArray alloc] init];
//
// UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 72, 0)];
// [lbl setTextAlignment:UITextAlignmentCenter];
// NSString *strLabel = @"Please Select any one course";
// lbl.text=strLabel;
// lbl.textColor=[UIColor whiteColor];
//
// UIBarButtonItem *lblBtn = [[UIBarButtonItem alloc] initWithCustomView:lbl];
// [lbl release];
//
// [barItems addObject:btnCancel];
// [barItems addObject:lblBtn];
// [barItems addObject:btnDone];
// [toolBar setItems:barItems animated:YES];
// [toolBar addSubview:lbl];
[pkrProfession setHidden:NO];
}
else if(indexPath.row == 2){
HomePageWebViewController *objHomePage = [[HomePageWebViewController alloc] initWithNibName:@"HomePageWebViewController" bundle:nil];
[objHomePage setNavigationTitle:@"Continuing Education FAQ's"];
[objHomePage setURL:[NSURL URLWithString:@"http://www.chirocredit.com/pages/faqs.php"]];
[self.navigationController pushViewController:objHomePage animated:YES];
}
else if(indexPath.row == 3){
NSArray *array1 = [[NSArray alloc]initWithObjects:@"powers@chirocredit.com",nil];
controller = [[MFMailComposeViewController alloc]init];
controller.mailComposeDelegate = self;
[controller setSubject:@"Contact Online CE"];
[controller setToRecipients:array1];
NSString *emailBody = @" ";
[controller setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:controller animated:YES];
[controller release];
}
else{
DueDate *objDueDate = [[DueDate alloc] initWithNibName:@"DueDate" bundle:nil];
[self.navigationController pushViewController:objDueDate animated:YES];
}
}
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
if (result == MFMailComposeResultSent) {
NSLog(@"Mail Sent...!");
UIAlertView *mailSend=[[UIAlertView alloc] initWithTitle:@"Email Sender" message:@"Mail has been sent.." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[mailSend show];
[mailSend release];
}
if (MFMailComposeResultCancelled) {
[self.navigationController popViewControllerAnimated:YES];
}
[self dismissModalViewControllerAnimated:YES];
}
//PICKER VIEW DELEGATES....
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
return [aryProfessions count];
}
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (row==0){
return [NSString stringWithFormat:@"Please Select Anyone Course"];
}
else{
return [[aryProfessions objectAtIndex:row]valueForKey:@"title"];
}
return nil;
}
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
if (row == 0) {
[btnDone setEnabled:NO];
}
else{
[btnDone setEnabled:YES];
}
self.selIndex = row;
if (self.selIndex == 0) {
[btnDone setEnabled:NO];
}
else{
[btnDone setEnabled:YES];
}
}
- (IBAction)selectAnItem:(id)sender {
if (self.selIndex != 0) {
NSDictionary *dicRow = [aryProfessions objectAtIndex:self.selIndex];
HomePageWebViewController *objProfession = [[HomePageWebViewController alloc] initWithNibName:@"HomePageWebViewController" bundle:nil];
[objProfession setNavigationTitle:[dicRow objectForKey:@"title"]];
[objProfession setURL:[NSURL URLWithString:[dicRow objectForKey:@"url"]]];
[self.navigationController pushViewController:objProfession animated:YES];
[dicRow release];
}
}
- (IBAction)itemNotSelected:(id)sender{
[toolBar setHidden:YES];
[pkrProfession setHidden:YES];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end