summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.go32
-rw-r--r--interact.go42
-rw-r--r--sqlite.go16
3 files changed, 69 insertions, 21 deletions
diff --git a/config.go b/config.go
index 50ee7db..b77871b 100644
--- a/config.go
+++ b/config.go
@@ -87,22 +87,22 @@ func makeNewTOML(gibts bool) {
config = Config{file,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n}
}
//fmt.Println("Whats Your Namecount\n")
- database := getNewInput("DB File Path: ",config.Database)
- name := getNewInput("Whats your Name?: ",config.Name)
- street := getNewInput("Street: ",config.Street)
- zip := getNewInput("Zip Code: ",config.Zip)
- city := getNewInput("City: ",config.City)
- country := getNewInput("Country: ",config.City)
- telefon := getNewInput("Telefone number: ",config.Telefon)
- mobile := getNewInput("Mobile number: ",config.Mobile)
- mail := getNewInput("Email: ",config.Mail)
- url := getNewInput("URL: ",config.Url)
- taxid := getNewInput("Tax ID: ",config.Taxid)
- bankname := getNewInput("Bank Name: ",config.Bankname)
- bankacc := getNewInput("Bank Account: ",config.Bankacc)
- banklz := getNewInput("BLZ: ",config.Banklz)
- iban := getNewInput("IBAN: ",config.Iban)
- bic := getNewInput("BIC: ",config.Bic)
+ database := getNewInterInput("DB File Path: ",config.Database)
+ name := getNewInterInput("Whats your Name?: ",config.Name)
+ street := getNewInterInput("Street: ",config.Street)
+ zip := getNewInterInput("Zip Code: ",config.Zip)
+ city := getNewInterInput("City: ",config.City)
+ country := getNewInterInput("Country: ",config.City)
+ telefon := getNewInterInput("Telefone number: ",config.Telefon)
+ mobile := getNewInterInput("Mobile number: ",config.Mobile)
+ mail := getNewInterInput("Email: ",config.Mail)
+ url := getNewInterInput("URL: ",config.Url)
+ taxid := getNewInterInput("Tax ID: ",config.Taxid)
+ bankname := getNewInterInput("Bank Name: ",config.Bankname)
+ bankacc := getNewInterInput("Bank Account: ",config.Bankacc)
+ banklz := getNewInterInput("BLZ: ",config.Banklz)
+ iban := getNewInterInput("IBAN: ",config.Iban)
+ bic := getNewInterInput("BIC: ",config.Bic)
conf := Config{database,name,street,zip,city,country,telefon,mobile,mail,url,taxid,bankacc,banklz,bankname,iban,bic}
diff --git a/interact.go b/interact.go
index 906d221..67e7f15 100644
--- a/interact.go
+++ b/interact.go
@@ -283,8 +283,13 @@ func interact() {
c.Println(boldRed(arg,"is not a valid id!"))
}
}else{
- c.Println(boldRed("editcustomer <id> - Please enter an id"))
- allCustomers()
+ selids,lids := getCustomerList()
+ choice := c.MultiChoice(lids,"Select a Customer to Edit")
+ if choice > -1 {
+ editCustomer(selids[choice])
+ }
+ //c.Println(boldRed("editcustomer <id> - Please enter an id"))
+ //allCustomers()
}
c.Println(promptcol("______________________"))
},
@@ -355,6 +360,17 @@ func interact() {
})
shell.AddCmd(&ishell.Cmd{
+ Name: "allcustomers",
+ Help: "Show all Customers",
+ LongHelp: ` Usage: allcustomers
+ Show all Customers.`,
+ Func: func(c *ishell.Context) {
+ allCustomers()
+ c.Println(promptcol("______________________"))
+ },
+ })
+
+ shell.AddCmd(&ishell.Cmd{
Name: "showbills",
Help: "<n> - Show the last n bills",
LongHelp: ` Usage: showbills <n>
@@ -659,9 +675,7 @@ func isInterSure(question string) (bool) {
}
func getInterInput(question string) (out string) {
- shell := ishell.New()
- //shell.SetMultiChoicePrompt(" ->"," - ")
- //shell.SetChecklistOptions("[ ] ","[X] ")
+ shell := ishell.New()
shell.ShowPrompt(false)
defer shell.ShowPrompt(true)
@@ -671,6 +685,24 @@ func getInterInput(question string) (out string) {
return
}
+func getNewInterInput(question,old string) (string) {
+ shell := ishell.New()
+ shell.ShowPrompt(false)
+ defer shell.ShowPrompt(true)
+
+ if old != "" {
+ shell.Println("Current:",old)
+ }
+ shell.Print(question)
+ line := shell.ReadLine()
+
+ if line == "" {
+ return old
+ }else{
+ return line
+ }
+}
+
func multichoice(about string) {
shell := ishell.New()
diff --git a/sqlite.go b/sqlite.go
index 1907ddd..37de159 100644
--- a/sqlite.go
+++ b/sqlite.go
@@ -879,6 +879,22 @@ func setProject (nid int) {
}
}
+func getCustomerList() (outint []int, outstr []string) {
+ rows,err := db.Query("SELECT id, company, name FROM customers")
+ checkErr(err)
+ var id int
+ var comp string
+ var name string
+ for rows.Next() {
+ err = rows.Scan(&id, &comp, &name)
+ checkErr(err)
+ st := fmt.Sprintf("%s: %s",comp,name)
+ outint = append(outint,id)
+ outstr = append(outstr, st)
+ }
+ return
+}
+
func allCustomers() {
rows,err := db.Query("SELECT * FROM customers")
//rows,err := db.Query("SELECT (id, company, name, address, satz, lastbill) FROM customers")