diff options
| author | Nikolaus Gotsche <n@softwarefools.com> | 2019-04-21 00:39:21 +0200 |
|---|---|---|
| committer | Nikolaus Gotsche <n@softwarefools.com> | 2019-04-21 00:39:21 +0200 |
| commit | 4a387707386c666b0210259ff8c18d6e9d6a5532 (patch) | |
| tree | b50c8a7bda51e71325b152ac5bca9f5718d0cf7f | |
| parent | 29539d25c1bc60db1f0745b969c8a9692eee27a7 (diff) | |
Show any Project0.3.10
| -rw-r--r-- | interact.go | 30 | ||||
| -rw-r--r-- | sqlite.go | 43 |
2 files changed, 61 insertions, 12 deletions
diff --git a/interact.go b/interact.go index d25c644..ba4fa67 100644 --- a/interact.go +++ b/interact.go @@ -506,7 +506,7 @@ func interact(fulldb bool) { { showcmd := &ishell.Cmd{ Name: "show", - Help: "all / customers / bills", + Help: "all / customers / bills / invoice / project", LongHelp: ` Usage: show <command>`, // Show all Projects with a small summary sorted by Customer.`, } @@ -603,6 +603,34 @@ func interact(fulldb bool) { c.Println(promptcol("______________________")) }, }) + showcmd.AddCmd(&ishell.Cmd{ + Name: "project", + Help: "<id> - Show details of the project with given id.", + LongHelp: ` Usage: show invoice <id> + Show detailed information of Project with given id. If no <id> is specified a selection screen is shown.`, + Func: func(c *ishell.Context) { + arg := "none" + if len(c.Args) > 0 { + arg = strings.Join(c.Args, " ") + argi, err := strconv.Atoi(arg) + if err == nil { + ShowProjectStatus(argi) + //allProjects() + //stdOut() + } else { + c.Println(boldRed(arg, "is not a valid id!")) + } + } else { + pids := GetProjectIds() + selids, lids := getProjectList(pids) + choice := c.MultiChoice(lids, "Select a Project to Show") + if choice > -1 { + ShowProjectStatus(selids[choice]) + } + } + c.Println(promptcol("______________________")) + }, + }) shell.AddCmd(showcmd) } /* @@ -1326,6 +1326,17 @@ func getOpenTask() { //opentask.checkout = checkout != 0 } +// Show status of a Project of given id +func ShowProjectStatus(id int) { + pr,cu := GetProject(id) + showProject(pr,cu) + + ShowProjectSum(id) + ShowClosedTasks(0,id) + + //showCurrentTask() +} + func showStatus(full bool) { /* boldGreen := color.New(color.FgGreen, color.Bold).SprintFunc() fmt.Println(frame(boldGreen("Status"),true)) @@ -1336,8 +1347,8 @@ func showStatus(full bool) { showOpenProject(true) if full { - ShowProjectSum() - getClosedTasks(0) + ShowProjectSum(currproject.Id) + ShowClosedTasks(0,currproject.Id) } showCurrentTask() @@ -1358,9 +1369,9 @@ func showStatus(full bool) { */ } -// Get all Tasks of the current Project and display them with simmilar name -func ShowProjectSum() { - _,st := GetTaskSums(currproject.Id) +// Get all Tasks of the given Project id and display them with simmilar name +func ShowProjectSum(id int) { + _,st := GetTaskSums(id) fmt.Println(sub("Tasks")) fmt.Println(StrLines(st,nli)) fmt.Println(sub("")) @@ -1387,6 +1398,15 @@ func showCurrentTask() { } } +// Show a project +func showProject(prj Project,cus Customer) { + boldGreen := color.New(color.FgGreen, color.Bold).SprintFunc() + fmt.Println(frame(boldGreen("Project "+prj.Name),true)) + fmt.Println(nli,prj.Id, ":", prj.Name, "- Started:", prj.First.Local().Format("Mon _2 Jan 2006")) + fmt.Println(nli," Last Changes", prj.Last.Local().Format("2006 Mon Jan _2 15:04")) + fmt.Println(nli," For:", cus.Company,"-",cus.Name," Hourly Rate:",cus.Satz,"[€/h]") +} + func showOpenProject(alone bool) { boldGreen := color.New(color.FgGreen, color.Bold).SprintFunc() //fmt.Println("___Last Project_____________") @@ -1466,14 +1486,15 @@ func newProject() { getLastProject() } -func getClosedTasks(num int) { - rows, err := db.Query("SELECT * FROM timetable WHERE stop != '1791-09-30 19:07' ORDER BY datetime(start)", currproject.Id) +// Show all Closed Tasks sorted by Billed and unbilled Tasks, Num Caps the number of Bills Shown (Not Used) +func ShowClosedTasks(num,prid int) { + rows, err := db.Query("SELECT * FROM timetable WHERE stop != '1791-09-30 19:07' ORDER BY datetime(start)", prid) checkErr(err) if num > 0 { - rows, err = db.Query("SELECT * FROM timetable WHERE project = $1 AND checkout > 0 AND stop != '1791-09-30 19:07' ORDER BY datetime(start) DESC LIMIT $2", currproject.Id, num) + rows, err = db.Query("SELECT * FROM timetable WHERE project = $1 AND checkout > 0 AND stop != '1791-09-30 19:07' ORDER BY datetime(start) DESC LIMIT $2", prid, num) checkErr(err) } else { - rows, err = db.Query("SELECT * FROM timetable WHERE project = $1 AND checkout > 0 AND stop != '1791-09-30 19:07' ORDER BY datetime(start)", currproject.Id) + rows, err = db.Query("SELECT * FROM timetable WHERE project = $1 AND checkout > 0 AND stop != '1791-09-30 19:07' ORDER BY datetime(start)", prid) checkErr(err) } var id, proj, check int @@ -1508,10 +1529,10 @@ func getClosedTasks(num int) { rows.Close() if num > 0 { - rows, err = db.Query("SELECT * FROM timetable WHERE project = $1 AND checkout = 0 AND stop != '1791-09-30 19:07'ORDER BY datetime(start) DESC LIMIT $2", currproject.Id, num) + rows, err = db.Query("SELECT * FROM timetable WHERE project = $1 AND checkout = 0 AND stop != '1791-09-30 19:07'ORDER BY datetime(start) DESC LIMIT $2", prid, num) checkErr(err) } else { - rows, err = db.Query("SELECT * FROM timetable WHERE project = $1 AND checkout = 0 AND stop != '1791-09-30 19:07'ORDER BY datetime(start)", currproject.Id) + rows, err = db.Query("SELECT * FROM timetable WHERE project = $1 AND checkout = 0 AND stop != '1791-09-30 19:07'ORDER BY datetime(start)", prid) checkErr(err) } sum2 := 0.0 |
