-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkPlacesViewController.swift
More file actions
78 lines (61 loc) · 3.11 KB
/
Copy pathWorkPlacesViewController.swift
File metadata and controls
78 lines (61 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// WorkPlaceViewController.swift
// ShiftMaster
//
// Created by Yair Levi on 8/2/14.
// Copyright (c) 2014 BarLeviSoft. All rights reserved.
//
import UIKit
class WorkPlacesViewController : UITableViewController, UITableViewDelegate, UITableViewDataSource, UserProviderDelegate
{
let identifire = "WorkPlaceCell"
var provider:UserProvider = UserProvider(user: PFUser.currentUser())
@IBOutlet weak var tableViewOutlet: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
provider.delegate = self
provider.GetWorkPlaces()
// var SA:[SalaryAditional] = [SalaryAditional(description: "Nesiot", amount: 25, type: SalaryAditional.AdditionalType.Dayly)]
// var SP:[SalaryPrecent] = [SalaryPrecent(description: "Income Taxes", over: 5000, precent: -20, type: SalaryPrecent.PrecentType.MonthlyOverAmount)]
// var SH:[SalaryHourly] = [SalaryHourly(description: "Hourly", over: 0, amount: 78)]
// var calc = Calculator.CreateCalculator(SA, precents: SP, hourlies: SH, name: "Basic Israel", type: Calculator.CalculatorType.Regular)
//
// var wp = WorkPalce.CreatePersonalWorkPlace(PFGeoPoint(latitude: 0.1, longitude: 0.1), name: "Microsoft", startEndMonth: 14, baseCalculator: Calculator(value: calc), fourSquareId: "12345")
//
// //UserProvider.UpdateCalculator(Calculator(value: calc))
// //UserProvider.UpdateWorkPlace(WorkPalce(personalWorkPlace: wp))
//
// var shift = Shift.CreateShift(NSDate.date(), dateEnd: NSDate.date().dateByAddingTimeInterval(60.0*60.0*3.0), workPlace: WorkPalce(personalWorkPlace: wp), privateCalculator: nil)
//
// UserProvider.UpdateShift(Shift(shift: shift))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
return countElements(provider.WorkPlaces) + 1
}
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell:WorkPlaceCell? = tableView.dequeueReusableCellWithIdentifier(identifire) as? WorkPlaceCell
if (cell == nil)
{
let nib:Array = NSBundle.mainBundle().loadNibNamed(identifire, owner: self, options: nil)
cell = nib[0] as? WorkPlaceCell
}
if indexPath.row != countElements(provider.WorkPlaces){
cell!.WorkPlaceName?.text = provider.WorkPlaces[indexPath.row].Name
}else{
cell!.WorkPlaceName?.text = "Add Work Place"
}
return cell;
}
override func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!){
if indexPath.row == countElements(provider.WorkPlaces){
// This is the "Add New Work Place" Row
}
}
func ProviderUpdated(provider: UserProvider, type: UserProvider.TypeOfUpdate) {
tableViewOutlet.reloadData()
}
}