summaryrefslogtreecommitdiff
path: root/sqlite.go
diff options
context:
space:
mode:
Diffstat (limited to 'sqlite.go')
-rw-r--r--sqlite.go53
1 files changed, 31 insertions, 22 deletions
diff --git a/sqlite.go b/sqlite.go
index 6ab652e..c090c0a 100644
--- a/sqlite.go
+++ b/sqlite.go
@@ -143,7 +143,7 @@ func newTaskTime(proj int, tim string) {
}
stmt, err := db.Prepare("INSERT INTO timetable(project, start, task, checkout) values(?, datetime(?,'utc'), ?, ?)")
fmt.Println(timstr)
- task := getInput("Specify Task: ")
+ task := getInterInput("Specify Task: ")
checkErr(err)
if (proj == 0) {
_, err = stmt.Exec(currproject.id,timstr,task,0)
@@ -167,7 +167,7 @@ func newTask(proj int) {
boldRed := color.New(color.FgRed, color.Bold).SprintFunc()
fmt.Println(boldGreen("Starting new Task"))
if (opentask.id == 0) {
- task := getInput("Specify Task: ")
+ task := getInterInput("Specify Task: ")
stmt, err := db.Prepare("INSERT INTO timetable(project, task, checkout) values(?, ?, ?)")
checkErr(err)
if (proj == 0) {
@@ -191,7 +191,7 @@ func newBill(proj int) (int,string) {
fmt.Println(boldGreen("Creating New Bill"))
//Show 5 recent bills
showLastBills(5)
- invno := getInput("Invoice Number: ")
+ invno := getInterInput("Invoice Number: ")
stmt, err := db.Prepare("INSERT INTO bills (identity, project, date) values(?, ?, datetime('now'))")
checkErr(err)
answ, err := stmt.Exec(invno,proj)
@@ -521,6 +521,8 @@ func getSelectedTasks(in []int) (outtask []task) {
}
return
}
+
+//Return sum of Hours and Dateranges
func analyzeTasks(in []task) (count int, hours float64, duration string) {
var lstart,hstop time.Time
for i,t := range in {
@@ -684,14 +686,21 @@ func showLastProject() {
}
func addCustomer() {
+ boldRed := color.New(color.FgRed, color.Bold).SprintFunc()
boldGreen := color.New(color.FgGreen, color.Bold).SprintFunc()
fmt.Println(boldGreen("Adding new Customer"))
- com := getInput("Enter Customer Company: ")
- nam := getInput("Enter Customer Name: ")
- add := getInput("Enter Address (separate lines by ; [Street;Zip;City;Country]): ")
- satstr := getInput("Hourly Rate: ")
- sat,err := strconv.ParseFloat(satstr,64)
- checkErr(err)
+ com := getInterInput("Enter Customer Company: ")
+ nam := getInterInput("Enter Customer Name: ")
+ add := getInterInput("Enter Address (separate lines by ; [Street;Zip;City;Country]): ")
+ sat := 0.0
+ for {
+ satstr := getInterInput("Hourly Rate: ")
+ sat,err = strconv.ParseFloat(satstr,64)
+ //checkErr(err)
+ if err != nil {
+ fmt.Println(satstr,boldRed("can not be Parsed as a Float."), "Try a shape of X.X")
+ }else{break}
+ }
stmt, err := db.Prepare("INSERT INTO customers(company, name, address, satz) values(?, ?, ?, ?)")
checkErr(err)
@@ -705,11 +714,11 @@ func newProject() {
boldGreen := color.New(color.FgGreen, color.Bold).SprintFunc()
fmt.Println(boldGreen("Creating new Project"))
if (opentask.id == 0) {
- nam := getInput("Enter Project Name: ")
+ nam := getInterInput("Enter Project Name: ")
icust := 0
allCustomers()
for{
- cust := getInput("Enter Customer id (0 for none): ")
+ cust := getInterInput("Enter Customer id: ")
icust,err = strconv.Atoi(cust)
if (err == nil && (isCustomer(icust) || icust == 0)) {
break
@@ -1035,23 +1044,23 @@ func editCustomer(id int) {
//fmt.Println(boldGreen("Edit Customer",id))
fmt.Println("Old Company Name:",comp)
- in := getInput("Enter New:")
+ in := getInterInput("Enter New:")
if in!=""{
comp=in
}
fmt.Println("Old Name:",name)
- in = getInput("Enter New:")
+ in = getInterInput("Enter New:")
if in!=""{
name=in
}
fmt.Println("Old Adress:",addr)
- in = getInput("Enter New:")
+ in = getInterInput("Enter New:")
if in!=""{
addr=in
}
fmt.Println("Old Hourly Rate:",satz)
for{
- satzstr := getInput("Enter New:")
+ satzstr := getInterInput("Enter New:")
if satzstr!=""{
satz,err = strconv.ParseFloat(satzstr,64)
if err != nil {
@@ -1087,7 +1096,7 @@ func editTask(id int) {
rows.Close() //good habit to close
fmt.Println("Old Name:",task)
- in := getInput("Enter New:")
+ in := getInterInput("Enter New:")
if in!=""{
task=in
}
@@ -1095,7 +1104,7 @@ func editTask(id int) {
stopstr=stop.Local().Format("2006-01-02 15:04")
for{
fmt.Println("Old Start:",startstr)
- newstart := getInput("Enter New:")
+ newstart := getInterInput("Enter New:")
if newstart!=""{
if isDate(newstart) {
startstr=newstart
@@ -1108,7 +1117,7 @@ func editTask(id int) {
}
fmt.Println("Old End:",stopstr)
for{
- newend := getInput("Enter New:")
+ newend := getInterInput("Enter New:")
if newend!=""{
if isDate(newend) {
stopstr=newend
@@ -1121,7 +1130,7 @@ func editTask(id int) {
}
fmt.Println("Old Project:",prj)
for{
- newprj := getInput("Enter New:")
+ newprj := getInterInput("Enter New:")
if newprj!=""{
prj,err = strconv.Atoi(newprj)
if err != nil {
@@ -1155,14 +1164,14 @@ func editProject(id int) {
err = rows.Scan(&name, &first, &fin, &cust)
checkErr(err)
fmt.Println("Old Name:",name)
- in := getInput("Enter New:")
+ in := getInterInput("Enter New:")
if in!=""{
name=in
}
nfirst=first.Local().Format("2006-01-02 15:04")
fmt.Println("Old Begin:",nfirst)
for{
- newfirst := getInput("Enter New:")
+ newfirst := getInterInput("Enter New:")
if newfirst!=""{
if isDate(newfirst) {
nfirst=newfirst
@@ -1175,7 +1184,7 @@ func editProject(id int) {
}
fmt.Println("Old Customer:",cust)
for{
- custs := getInput("Enter Customer id (0 for none): ")
+ custs := getInterInput("Enter Customer id (0 for none): ")
icust,err := strconv.Atoi(custs)
if (err == nil && (isCustomer(icust) || icust == 0)) {
cust = icust