Skip to content

Commit

Permalink
feat: tabel declaratii pe pagina adauga declaratii
Browse files Browse the repository at this point in the history
  • Loading branch information
ClimenteA committed Sep 11, 2022
1 parent 6b3af9e commit ae22580
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 9 deletions.
68 changes: 67 additions & 1 deletion assets/templates/declaratii.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,36 @@
.none {
display: none;
}

#tabel-incasari {
margin-bottom: 1rem;
margin-top: 4rem;
padding: 1rem;
max-height: 600px;
overflow: auto;
}

.download {
display: flex;
gap: 2rem;
float: right;
}

tr td {
width: 1%;
white-space: nowrap;
}

.bg-whitesmoke {
background: whitesmoke;
}
</style>


<main class="container">

<hgroup class="container">
<h1>Adauga declaratii/documente</h1>
<h1>Adauga declaratii</h1>
<h2>
Adauga declaratiile depuse la ANAF si dovezile de plata impozite.
</h2>
Expand Down Expand Up @@ -90,6 +113,49 @@ <h5 style="color: var(--secondary);">Adauga declaratii/documente</h5>

</form>


<article id="tabel-declaratii">
<h4 style="color: var(--secondary);">Tabel Declaratii</h4>
<table id="date-declaratii">

<thead>
<tr class="bg-whitesmoke">
<th scope="col">
Data
</th>
<th scope="col">
Tip Document
</th>
<th scope="col">
Descarca Fisier
</th>
<th scope="col">
Sterge Fisier
</th>
</tr>
</thead>

<tbody>
{{range .Declaratii}}
<tr>
<td>
{{.Data}}
</td>
<td>
{{.TipDocument}}
</td>
<td>
<a href="/download-fisier?path={{.CaleDocument}}">Descarca</a>
</td>
<td>
<a style="color:var(--del-color);" href="/sterge-fisier?path={{.CaleDocument}}">Sterge</a>
</td>
</tr>
{{end}}
</tbody>
</table>
</article>

</main>


Expand Down
13 changes: 6 additions & 7 deletions registre/adunadeclaratii.go → declaratii/adunadeclaratii.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package registre
package declaratii

import (
"encoding/json"
Expand All @@ -12,7 +12,6 @@ import (
"time"

"github.com/ClimenteA/pfasimplu-go/auth"
"github.com/ClimenteA/pfasimplu-go/declaratii"
)

func getDeclaratiiJsonPaths(user auth.Account) ([]string, error) {
Expand All @@ -39,9 +38,9 @@ func getDeclaratiiJsonPaths(user auth.Account) ([]string, error) {

}

func getDocMetadata(path string) declaratii.Declaratie {
func getDocMetadata(path string) Declaratie {

var data declaratii.Declaratie
var data Declaratie

jsonFile, err := os.Open(path)
if err != nil {
Expand All @@ -55,9 +54,9 @@ func getDocMetadata(path string) declaratii.Declaratie {
return data
}

func getDocsDataSlice(docMetadataJson []string, anul string) []declaratii.Declaratie {
func getDocsDataSlice(docMetadataJson []string, anul string) []Declaratie {

declaratii := []declaratii.Declaratie{}
declaratii := []Declaratie{}
now := time.Now()

for _, path := range docMetadataJson {
Expand Down Expand Up @@ -101,7 +100,7 @@ func getDocsDataSlice(docMetadataJson []string, anul string) []declaratii.Declar

}

func AdunaDeclaratii(user auth.Account, anul string) []declaratii.Declaratie {
func AdunaDeclaratii(user auth.Account, anul string) []Declaratie {

docMetadataJson, err := getDeclaratiiJsonPaths(user)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions declaratii/declaratii.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
"strconv"
"time"

"github.com/ClimenteA/pfasimplu-go/auth"
"github.com/ClimenteA/pfasimplu-go/utils"
Expand Down Expand Up @@ -89,8 +90,12 @@ func handleDeclaratii(app fiber.App, store session.Store) {

user := getCurrentUser(fmt.Sprint(currentUserPath))
yearsRegisterd := utils.GetAniInregistrati(user)
filterYear := strconv.Itoa(time.Now().Year())

declaratii := AdunaDeclaratii(user, filterYear)

return c.Render("declaratii", fiber.Map{
"Declaratii": declaratii,
"AniInregistrati": yearsRegisterd,
}, "base")
})
Expand Down
3 changes: 2 additions & 1 deletion registre/registre.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/ClimenteA/pfasimplu-go/auth"
outputs "github.com/ClimenteA/pfasimplu-go/cheltuieli"
"github.com/ClimenteA/pfasimplu-go/declaratii"
inputs "github.com/ClimenteA/pfasimplu-go/incasari"
"github.com/ClimenteA/pfasimplu-go/staticdata"
"github.com/ClimenteA/pfasimplu-go/tabelcsv"
Expand Down Expand Up @@ -144,7 +145,7 @@ func handleRegistre(app fiber.App, store session.Store) {
user := getCurrentUser(fmt.Sprint(currentUserPath))
aniInregistrati := utils.GetAniInregistrati(user)

declaratii := AdunaDeclaratii(user, filterYear)
declaratii := declaratii.AdunaDeclaratii(user, filterYear)
incasari := inputs.AdunaIncasari(user, filterYear)
cheltuieli := outputs.AdunaCheltuieli(user, filterYear)

Expand Down

0 comments on commit ae22580

Please sign in to comment.