summaryrefslogtreecommitdiff
path: root/sqlite.go
diff options
context:
space:
mode:
Diffstat (limited to 'sqlite.go')
-rw-r--r--sqlite.go88
1 files changed, 69 insertions, 19 deletions
diff --git a/sqlite.go b/sqlite.go
index 37de159..d3ff213 100644
--- a/sqlite.go
+++ b/sqlite.go
@@ -129,8 +129,8 @@ func newTaskTime(proj int, tim string) {
if (opentask.id == 0) {
timstr := "1791-09-30 19:07"
//zone, _ := time.Now().Zone()
- if isDate(tim) {
- timstr = getDate(tim)
+ if isDateTime(tim) {
+ timstr = getDateTime(tim)
//timst = timstr+" "+zone
}else if isTime(tim) {
currdate := time.Now().Local().Format("2006-01-02")
@@ -320,8 +320,8 @@ func closeTaskTime(tim string) {
//timt,err := time.Parse("2006-01-02 15:04",tim)
timst,timstr := "1791-09-30 19:07","1791-09-30 19:07"
zone, _ := time.Now().Zone()
- if isDate(tim) {
- timstr = getDate(tim)
+ if isDateTime(tim) {
+ timstr = getDateTime(tim)
timst = timstr+" "+zone
} else if isTime(tim) {
timstr = time.Now().Local().Format("2006-01-02")+" "+getTime(tim)
@@ -372,6 +372,37 @@ func closeTask() {
}
}
+func checkBill(bid int) {
+ boldGreen := color.New(color.FgGreen, color.Bold).SprintFunc()
+ boldRed := color.New(color.FgRed, color.Bold).SprintFunc()
+ fmt.Println(boldGreen("Checking Bill ",bid," as Paid:","BILLIDENTITY COMING SOON"))
+ if !isBill(bid) {
+ fmt.Println(bid,boldRed("is not a known bill ID"))
+ return
+ }
+ //timst,timstr := "1791-09-30 19:07","1791-09-30 19:07"
+ //zone, _ := time.Now().Zone()
+ timstr := "1791-09-30 19:07"
+
+ timin := getInterInput("Specify Date (YYYY-MM-DD): ")
+
+ if isDateTime(timin) {
+ timstr = getDateTime(timin)
+ }else if isDate(timin) {
+ //currdate := time.Now().Local().Format("2006-01-02")
+ timstr = getDate(timin)+" 12:00"
+ }else {
+ fmt.Println(timin,boldRed("is Not a Valid Datestring!"), "use: 'YYYY-MM-DD'")
+ return
+ }
+ //ti :=
+ fmt.Println(boldGreen(timstr))
+ stmt, err := db.Prepare("UPDATE bills SET paid = datetime(?,'utc') WHERE id = ?")
+ checkErr(err)
+ _, err = stmt.Exec(timstr,bid)
+ checkErr(err)
+}
+
func checkTasks(in []int,billid int) {
ins := strings.Trim(strings.Replace(fmt.Sprint(in)," "," , ",-1),"[]")
que := fmt.Sprintf("UPDATE timetable SET checkout = ? WHERE id IN (%s)",ins)
@@ -826,7 +857,7 @@ func getLastProject() {
nprname=prname
nfirst=first
nlast=last
- nfinish=finish
+ nfinish=finish
ncustom=custom
}
}
@@ -1059,31 +1090,40 @@ func editCustomer(id int) {
rows.Close() //good habit to close
//fmt.Println(boldGreen("Edit Customer",id))
- fmt.Println("Old Company Name:",comp)
+ /*fmt.Println("Old Company Name:",comp)
in := getInterInput("Enter New:")
if in!=""{
comp=in
- }
- fmt.Println("Old Name:",name)
+ }*/
+ comp = getNewInterInput("New Company Name: ",comp)
+ /*fmt.Println("Old Name:",name)
in = getInterInput("Enter New:")
if in!=""{
name=in
- }
- fmt.Println("Old Adress:",addr)
+ }*/
+ name = getNewInterInput("New Customer Name: ",name)
+ /*fmt.Println("Old Adress:",addr)
in = getInterInput("Enter New:")
if in!=""{
addr=in
- }
- fmt.Println("Old Hourly Rate:",satz)
+ }*/
+ addr = getNewInterInput("New Adress: ",addr)
+ //fmt.Println("Old Hourly Rate:",satz)
for{
- satzstr := getInterInput("Enter New:")
+ satzstr := getNewInterInput("New Hourly Rate: ",fmt.Sprintf("%.2f",satz))
+ satz,err = strconv.ParseFloat(satzstr,64)
+ if err != nil {
+ fmt.Println(satzstr,boldRed("can not be Parsed as a Float."), "Try a shape of X.X")
+ //os.Exit(0)
+ }else{break}
+ /*satzstr := getInterInput("Enter New:")
if satzstr!=""{
satz,err = strconv.ParseFloat(satzstr,64)
if err != nil {
fmt.Println(satzstr,boldRed("can not be Parsed as a Float."), "Try a shape of X.X")
//os.Exit(0)
}else{break}
- }else{break}
+ }else{break}*/
}
stmt, err := db.Prepare("UPDATE customers SET company = ?, name = ?, address = ?, satz = ? WHERE id = ?")
checkErr(err)
@@ -1122,7 +1162,7 @@ func editTask(id int) {
fmt.Println("Old Start:",startstr)
newstart := getInterInput("Enter New:")
if newstart!=""{
- if isDate(newstart) {
+ if isDateTime(newstart) {
startstr=newstart
break
}else{
@@ -1135,7 +1175,7 @@ func editTask(id int) {
for{
newend := getInterInput("Enter New:")
if newend!=""{
- if isDate(newend) {
+ if isDateTime(newend) {
stopstr=newend
break
}else{
@@ -1189,7 +1229,7 @@ func editProject(id int) {
for{
newfirst := getInterInput("Enter New:")
if newfirst!=""{
- if isDate(newfirst) {
+ if isDateTime(newfirst) {
nfirst=newfirst
break
}else{
@@ -1270,21 +1310,31 @@ func isCustomer(id int) bool {
}
}
-func getDate(in string) string {
+func getDateTime(in string) string {
r := regexp.MustCompile(`(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})`)
return r.FindString(in)
}
+func getDate(in string) string {
+ r := regexp.MustCompile(`(\d{4})-(\d{2})-(\d{2})`)
+ return r.FindString(in)
+}
+
func getTime(in string) string {
r := regexp.MustCompile(`(\d{2}):(\d{2})`)
return r.FindString(in)
}
-func isDate(in string) bool {
+func isDateTime(in string) bool {
match, _ := regexp.MatchString(`(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})`,in)
return match
}
+func isDate(in string) bool {
+ match, _ := regexp.MatchString(`(\d{4})-(\d{2})-(\d{2})`,in)
+ return match
+}
+
func isTime(in string) bool {
match, _ := regexp.MatchString(`(\d{2}):(\d{2})`,in)
return match