summaryrefslogtreecommitdiff
path: root/interact.go
diff options
context:
space:
mode:
Diffstat (limited to 'interact.go')
-rw-r--r--interact.go67
1 files changed, 59 insertions, 8 deletions
diff --git a/interact.go b/interact.go
index ba4fa67..4aae3ac 100644
--- a/interact.go
+++ b/interact.go
@@ -72,6 +72,43 @@ func interact(fulldb bool) {
c.Println(promptcol("______________________"))
},
})
+
+ paycmd := &ishell.Cmd{
+ Name: "payment",
+ Help: "<Date>/now - Enter a Payment",// at a specific Time 'YYYY-MM-DD' Or 'now'",
+ LongHelp: ` Usage: new payment <Date>/now
+ Enter a new Payment at <Date>.
+ Use Format "YYYY-MM-DD" for date.
+ 'now' will start the Task at current local date.`,
+ Func: func(c *ishell.Context) {
+ arg := "none"
+ if len(c.Args) > 0 {
+ arg = strings.Join(c.Args, " ")
+ if isDate(arg){
+ AddPayment(arg)
+ }else{
+ c.Println(boldRed("new payment <Date> - Please enter a valid Date of Format 'YYYY-MM-DD'"))
+ }
+ } else {
+ c.Println(boldRed("new payment <Date> - Please enter a Date"))
+ }
+ stdOut()
+ c.Println(promptcol("______________________"))
+ },
+ }
+ paycmd.AddCmd(&ishell.Cmd{
+ Name: "now",
+ Help: "Enter a new Payment dated today",
+ LongHelp: ` Usage: new payment now
+ Enter a new Payment with current local date`,
+ Func: func(c *ishell.Context) {
+ AddPayment("jetzt")
+ stdOut()
+ c.Println(promptcol("______________________"))
+ },
+ })
+
+ newcmd.AddCmd(paycmd)
shell.AddCmd(newcmd)
}
@@ -120,7 +157,7 @@ func interact(fulldb bool) {
-
+ /* OLD CHECKBILL
shell.AddCmd(&ishell.Cmd{
Name: "checkbill",
Help: "<id> check a Bill with the following id as paid",
@@ -144,6 +181,7 @@ func interact(fulldb bool) {
c.Println(promptcol("______________________"))
},
})
+ */
// Delete Commands: Bill / Task
{
@@ -360,7 +398,7 @@ func interact(fulldb bool) {
c.Println(boldRed(arg, "is not a valid id!"))
}
} else {
- tids := GetBillIds()
+ tids := GetBillIds(false)
selids, lids := GetBillList(tids)
choice := c.MultiChoice(lids, "Select a Bill to Edit")
//c.Println(tids)
@@ -462,10 +500,10 @@ func interact(fulldb bool) {
LongHelp: ` Usage: print bills
Show all Projects with a small summary, sorted by Customer.`,
Func: func(c *ishell.Context) {
- tids := GetBillIds()
+ tids := GetBillIds(false)
ids, str := GetBillList(tids)
choices := c.Checklist(str,
- "Which Tasks should be charged in the new bill ?",
+ "Which Bills should be Printed again ?",
nil)
out := func() (c []int) {
for _, v := range choices {
@@ -495,7 +533,6 @@ func interact(fulldb bool) {
}else{
c.Println(boldRed("Charging Aborted"))
}
-
c.Println(promptcol("______________________"))
},
@@ -588,7 +625,7 @@ func interact(fulldb bool) {
c.Println(boldRed(arg, "is not a valid integer!"))
}
} else {
- tids := GetBillIds()
+ tids := GetBillIds(false)
selids, lids := GetBillList(tids)
choice := c.MultiChoice(lids, "Select a Bill to Edit")
//c.Println(tids)
@@ -977,12 +1014,12 @@ func interact(fulldb bool) {
//c.ShowPrompt(true)
}
}
- halfbill := bill{0, "None", dur, proj.Id, proj.Name, time.Time{}, time.Time{}, allitems}
+ halfbill := bill{0, "None", dur, proj.Id, proj.Name, time.Time{}, time.Time{}, allitems, 0}
ShowBill(halfbill,false)
if isInterSure("Is this bill Correct?") {
billid, billident := newBill(billprojid)
//c.Println(green("Bill Completed"))
- fullbill := bill{billid, billident, dur, proj.Id, proj.Name, time.Time{}, time.Time{}, allitems}
+ fullbill := bill{billid, billident, dur, proj.Id, proj.Name, time.Time{}, time.Time{}, allitems, 0}
saveBill(fullbill)
checkTasks(selids, billid)
c.ProgressBar().Indeterminate(true)
@@ -1177,3 +1214,17 @@ func Multichoice(question string,list []string) (int) {
shell.Process(str)
shell.Println(about)*/
}
+
+// Invoke a Checklist Question with a leading Question
+// line and return an int slice of the selected rows of the list
+func Checklist(question string, list []string) ([]int) {
+ shell := ishell.New()
+ marker := li+li+">"
+ shell.SetMultiChoicePrompt(marker,nli)
+ shell.SetChecklistOptions("[ ] ", "[X] ")
+ qu1 := line(marker,false)
+ qu2 := frame(question,true)
+ quest := qu1 + strings.TrimLeft(qu2,"\n")
+ choices := shell.Checklist(list,quest,nil)
+ return choices
+}