From fbc6a18b0e313ab7d6d2aba571085222491d1e54 Mon Sep 17 00:00:00 2001 From: aespin Date: Tue, 8 Oct 2024 13:22:23 +0200 Subject: [PATCH] wip --- helper/helper.go | 4 ++-- storage/storage.go | 8 ++++---- templates/base.html | 5 +++-- templates/bundle.html | 25 +++++++++++++++++++------ types/barcode.go | 5 +++++ types/bundle.go | 14 ++++++++++++++ 6 files changed, 47 insertions(+), 14 deletions(-) diff --git a/helper/helper.go b/helper/helper.go index 6536142..21a6429 100644 --- a/helper/helper.go +++ b/helper/helper.go @@ -13,12 +13,12 @@ func Dates(dr string) (start, finish time.Time, err error) { inicio = strings.TrimSpace(inicio) final = strings.TrimSpace(final) // parse start date - start, err = time.Parse("02/01/2006 15:04", inicio) + start, err = time.ParseInLocation("02/01/2006 15:04", inicio, time.Local) if err != nil { return time.Time{}, time.Time{}, err } // parse finish date - finish, err = time.Parse("02/01/2006 15:04", final) + finish, err = time.ParseInLocation("02/01/2006 15:04", final, time.Local) if err != nil { return time.Time{}, time.Time{}, err } diff --git a/storage/storage.go b/storage/storage.go index e4b4707..c885371 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -23,7 +23,7 @@ type Storager interface { Barcode(ctx context.Context, reading string) (barcode *types.Barcode, err error) ListBarcode(ctx context.Context, lb types.LoadingBed, inicio, final time.Time) (barcodes []types.Barcode, err error) Bundle(ctx context.Context, ua string) (bundle *types.BundleData, err error) - ListBundle(ctx context.Context, lb types.LoadingBed, inicio, final time.Time) (bundles []types.BundleData, err error) + ListBundle(ctx context.Context, lb types.LoadingBed, inicio, final time.Time, confirmed bool) (bundles []types.BundleData, err error) } type storage struct { @@ -32,13 +32,13 @@ type storage struct { } // ListBundle implements Storager. -func (s *storage) ListBundle(ctx context.Context, lb types.LoadingBed, inicio time.Time, final time.Time) (bundles []types.BundleData, err error) { +func (s *storage) ListBundle(ctx context.Context, lb types.LoadingBed, inicio time.Time, final time.Time, confirmed bool) (bundles []types.BundleData, err error) { if lb == types.ALL { - if err := s.db.Where("created_at >= ? and created_at < ?", inicio, final).Find(&bundles).WithContext(ctx).Error; err != nil { + if err := s.db.Where("created_at >= ? and created_at < ? and confirmed = ?", inicio, final, confirmed).Find(&bundles).WithContext(ctx).Error; err != nil { return nil, err } } else { - if err := s.db.Where("loading_bed = ? and created_at >= ? and created_at < ?", lb, inicio, final).Find(&bundles).WithContext(ctx).Error; err != nil { + if err := s.db.Where("substr(nromatricula,1,3)=? and created_at >= ? and created_at < ? and confirmed = ?", types.MapQueryBed[lb], inicio, final, confirmed).Find(&bundles).WithContext(ctx).Error; err != nil { return nil, err } } diff --git a/templates/base.html b/templates/base.html index 9e0e1d9..b8fc488 100644 --- a/templates/base.html +++ b/templates/base.html @@ -18,12 +18,13 @@ + {{ template "body" . }} diff --git a/templates/bundle.html b/templates/bundle.html index 7d55dc3..d020259 100644 --- a/templates/bundle.html +++ b/templates/bundle.html @@ -79,6 +79,19 @@ +
+
+ +
+

+ +

+
+
+