diff --git a/assets/css/main.min.css b/assets/css/main.min.css new file mode 100644 index 0000000..5d98755 --- /dev/null +++ b/assets/css/main.min.css @@ -0,0 +1 @@ +.table-wrapper .table{margin-bottom:0}.table-wrapper:not(:last-child){margin-bottom:1.5rem}@media screen and (max-width: 1023px){.table-wrapper{overflow-x:auto}}.b-table{transition:opacity 86ms ease-out}@media screen and (min-width: 769px),print{.b-table .table-mobile-sort{display:none}}.b-table .icon{transition:transform 150ms ease-out,opacity 86ms ease-out}.b-table .icon.is-desc{transform:rotate(180deg)}.b-table .icon.is-expanded{transform:rotate(90deg)}.b-table .table{width:100%;border:1px solid rgba(0,0,0,0);border-radius:4px;border-collapse:separate}.b-table .table th{font-weight:600}.b-table .table th .th-wrap{display:flex;align-items:center}.b-table .table th .th-wrap .icon{margin-left:.5rem;margin-right:0;font-size:1rem}.b-table .table th .th-wrap.is-numeric{flex-direction:row-reverse;text-align:right}.b-table .table th .th-wrap.is-numeric .icon{margin-left:0;margin-right:.5rem}.b-table .table th .th-wrap.is-centered{justify-content:center;text-align:center}.b-table .table th.is-current-sort{border-color:#7a7a7a;font-weight:700}.b-table .table th.is-sortable:hover{border-color:#7a7a7a}.b-table .table th.is-sortable,.b-table .table th.is-sortable .th-wrap{cursor:pointer}.b-table .table th .multi-sort-cancel-icon{margin-left:10px}.b-table .table th.is-sticky{position:-webkit-sticky;position:sticky;left:0;z-index:3 !important;background:#fff}.b-table .table tr.is-selected .checkbox input:checked+.check{background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1 1'%3E%3Cpath style='fill:hsl(171deg, 100%25, 41%25)' d='M 0.04038059,0.6267767 0.14644661,0.52071068 0.42928932,0.80355339 0.3232233,0.90961941 z M 0.21715729,0.80355339 0.85355339,0.16715729 0.95961941,0.2732233 0.3232233,0.90961941 z'%3E%3C/path%3E%3C/svg%3E") no-repeat center center}.b-table .table tr.is-selected .checkbox input+.check{border-color:#fff}.b-table .table tr.is-empty:hover{background-color:rgba(0,0,0,0)}.b-table .table .is-chevron-cell,.b-table .table .is-checkbox-cell{width:40px}.b-table .table .is-chevron-cell{vertical-align:middle}.b-table .table .is-checkbox-cell .checkbox{vertical-align:middle}.b-table .table .is-checkbox-cell .checkbox.b-checkbox{margin-right:0}.b-table .table .is-checkbox-cell .checkbox .check{transition:none}.b-table .table tr.detail{box-shadow:inset 0 1px 3px #dbdbdb;background:#fafafa}.b-table .table tr.detail .detail-container{padding:1rem}.b-table .table:focus{border-color:#485fc7;box-shadow:0 0 0 .125em rgba(72,95,199,.25)}.b-table .table.is-bordered th.is-current-sort,.b-table .table.is-bordered th.is-sortable:hover{border-color:#dbdbdb;background:#f5f5f5}.b-table .table td.is-sticky{position:-webkit-sticky;position:sticky;left:0;z-index:1;background:#fff}.b-table .table td.is-image-cell .image{margin:0 auto;width:1.5rem;height:1.5rem}.b-table .table td.is-progress-cell{min-width:5rem;vertical-align:middle}.b-table .table-wrapper.has-sticky-header{height:300px;overflow-y:auto}@media screen and (max-width: 768px){.b-table .table-wrapper.has-sticky-header.has-mobile-cards{height:initial !important;overflow-y:initial !important}}.b-table .table-wrapper.has-sticky-header tr:first-child th{position:-webkit-sticky;position:sticky;top:0;z-index:2;background:#fff}@media screen and (max-width: 768px){.b-table .table-wrapper.has-mobile-cards thead{display:none}.b-table .table-wrapper.has-mobile-cards tfoot th{border:0;display:inherit}.b-table .table-wrapper.has-mobile-cards tr{box-shadow:0 2px 3px rgba(10,10,10,.1),0 0 0 1px rgba(10,10,10,.1);max-width:100%;position:relative;display:block}.b-table .table-wrapper.has-mobile-cards tr td{border:0;display:inherit}.b-table .table-wrapper.has-mobile-cards tr td:last-child{border-bottom:0}.b-table .table-wrapper.has-mobile-cards tr:not(:last-child){margin-bottom:1rem}.b-table .table-wrapper.has-mobile-cards tr:not([class*=is-]){background:inherit}.b-table .table-wrapper.has-mobile-cards tr:not([class*=is-]):hover{background-color:inherit}.b-table .table-wrapper.has-mobile-cards tr.detail{margin-top:-1rem}.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td{display:flex;width:auto;justify-content:space-between;text-align:right;border-bottom:1px solid #f5f5f5}.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td:before{content:attr(data-label);font-weight:600;padding-right:.5rem;text-align:left}.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td.is-image-cell .image{width:6rem;height:6rem;margin:0 auto .5rem}.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td.is-progress-cell span,.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td.is-progress-cell progress{display:flex;width:45%;align-items:center;align-self:center}.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td.is-checkbox-cell,.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td.is-image-cell{border-bottom:0 !important}.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td.is-checkbox-cell:before,.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td.is-actions-cell:before{display:none}.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td.is-label-hidden:before,.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td.is-image-cell:before{display:none}.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td.is-label-hidden span{display:block;width:100%}.b-table .table-wrapper.has-mobile-cards tr:not(.detail):not(.is-empty):not(.table-footer) td.is-label-hidden.is-progress-col progress{width:100%}}.b-table .table-wrapper.is-card-list thead{display:none}.b-table .table-wrapper.is-card-list tfoot th{border:0;display:inherit}.b-table .table-wrapper.is-card-list tr{box-shadow:0 2px 3px rgba(10,10,10,.1),0 0 0 1px rgba(10,10,10,.1);max-width:100%;position:relative;display:block}.b-table .table-wrapper.is-card-list tr td{border:0;display:inherit}.b-table .table-wrapper.is-card-list tr td:last-child{border-bottom:0}.b-table .table-wrapper.is-card-list tr:not(:last-child){margin-bottom:1rem}.b-table .table-wrapper.is-card-list tr:not([class*=is-]){background:inherit}.b-table .table-wrapper.is-card-list tr:not([class*=is-]):hover{background-color:inherit}.b-table .table-wrapper.is-card-list tr.detail{margin-top:-1rem}.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td{display:flex;width:auto;justify-content:space-between;text-align:right;border-bottom:1px solid #f5f5f5}.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td:before{content:attr(data-label);font-weight:600;padding-right:.5rem;text-align:left}.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td.is-image-cell .image{width:6rem;height:6rem;margin:0 auto .5rem}.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td.is-progress-cell span,.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td.is-progress-cell progress{display:flex;width:45%;align-items:center;align-self:center}.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td.is-checkbox-cell,.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td.is-image-cell{border-bottom:0 !important}.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td.is-checkbox-cell:before,.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td.is-actions-cell:before{display:none}.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td.is-label-hidden:before,.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td.is-image-cell:before{display:none}.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td.is-label-hidden span{display:block;width:100%}.b-table .table-wrapper.is-card-list tr:not(.detail):not(.is-empty):not(.table-footer) td.is-label-hidden.is-progress-col progress{width:100%}.b-table.is-loading{position:relative;pointer-events:none;opacity:.5}.b-table.is-loading:after{animation:spinAround 500ms infinite linear;border:2px solid #dbdbdb;border-radius:9999px;border-right-color:rgba(0,0,0,0);border-top-color:rgba(0,0,0,0);content:"";display:block;height:1em;position:relative;width:1em;position:absolute;top:4em;left:calc(50% - 2.5em);width:5em;height:5em;border-width:.25em}.b-table.has-pagination .table-wrapper{margin-bottom:0}.b-table.has-pagination .table-wrapper+.notification{border-top-left-radius:0;border-top-right-radius:0} \ No newline at end of file diff --git a/handlers/bundle.go b/handlers/bundle.go index 8cd5ed0..0e35c40 100644 --- a/handlers/bundle.go +++ b/handlers/bundle.go @@ -12,6 +12,7 @@ import ( ) func BundleHandler(storage storage.Storager) httprouter.Handle { + return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { if r.Method == http.MethodGet { diff --git a/handlers/index.go b/handlers/index.go index b19e1da..451f9de 100644 --- a/handlers/index.go +++ b/handlers/index.go @@ -13,9 +13,10 @@ import ( func IndexHandler(storage storage.Storager) httprouter.Handle { type PageView struct { - Stats *types.Stats - Bundles []types.BundleData - Barcodes []types.Barcode + Stats *types.Stats + BundlesATA12 []types.BundleData + BundlesATA345 []types.BundleData + Barcodes []types.Barcode } return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { // get current shift dates @@ -25,16 +26,22 @@ func IndexHandler(storage storage.Storager) httprouter.Handle { return } // - bundles, err := storage.ShiftListBundle(r.Context(), dates[0], dates[1]) + bundles12, err := storage.ShiftListBundle(r.Context(), dates[0], dates[1], types.ATA12) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + bundles345, err := storage.ShiftListBundle(r.Context(), dates[0], dates[1], types.ATA345) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } // create view view := &PageView{ - Stats: &types.Stats{}, - Bundles: bundles, - Barcodes: []types.Barcode{}, + Stats: &types.Stats{}, + BundlesATA12: bundles12, + BundlesATA345: bundles345, + Barcodes: []types.Barcode{}, } t, _ := template.ParseFiles("templates/base.html", "templates/index.html") diff --git a/storage/storage.go b/storage/storage.go index bb19048..1e946bb 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -11,6 +11,10 @@ import ( "gorm.io/gorm" ) +const ( + limit int = 10 +) + type DBConfig struct { Username string Password string @@ -24,7 +28,7 @@ type Storager interface { 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, confirmed bool) (bundles []types.BundleData, err error) - ShiftListBundle(ctx context.Context, inicio, final time.Time) (bundles []types.BundleData, err error) + ShiftListBundle(ctx context.Context, inicio, final time.Time, lb types.LoadingBed) (bundles []types.BundleData, err error) } type storage struct { @@ -33,8 +37,8 @@ type storage struct { } // ShiftListBundle implements Storager. -func (s *storage) ShiftListBundle(ctx context.Context, inicio, final time.Time) (bundles []types.BundleData, err error) { - if err := s.db.Where("created_at >= ? and created_at < ?", inicio, final).Find(&bundles).WithContext(ctx).Error; err != nil { +func (s *storage) ShiftListBundle(ctx context.Context, inicio, final time.Time, lb types.LoadingBed) (bundles []types.BundleData, err error) { + if err := s.db.Where("substr(nromatricula,1,3)=? and created_at >= ? and created_at < ?", types.MapQueryBed[lb], inicio, final).Order("created_at desc").Limit(limit).Find(&bundles).WithContext(ctx).Error; err != nil { return nil, err } return diff --git a/templates/barcodes.html b/templates/barcodes.html index 636d20d..22a06fe 100644 --- a/templates/barcodes.html +++ b/templates/barcodes.html @@ -3,10 +3,12 @@ {{define "body"}}
+
+

Etiquetas