This commit is contained in:
Albert Espín 2024-10-07 19:54:53 +02:00
parent 72f0c0d273
commit 99a4cc7b7a
4 changed files with 141 additions and 55 deletions

105
TODO
View File

@ -1,49 +1,56 @@
Defining template:
{{ define “template_name” }} {{ end }}
Using template:
{{ template “template_name” . }}
Block:
{{ block “content” . }} {{ end }}
Is equivalent to => {{ template “content” . }} {{ define “content” }} {{ end }}
If:
{{ if var }} //… {{ else if var }} //… {{ else }} //… {{ end }}
Assignment:
{{ $first_name := “arash” }} {{ $first_name = .Name }}
With:
{{ with . Firstname }} // . refers to Firstname {{ end }}
{{ with $ firstname := .Firstname }} // . and $firstname both refer to Firstname {{ end }}
Range:
{{ range .Users }} {{ .Firstname }} {{ end }}
{{ range $user := .Users }} {{ .Firstname }} {{ $user.Firstname }} {{ else }} No users found {{ end }}
{{ range $index, $user := .Users }} {{ end }}
Functions:
{{ if and cond1 cond2 … }}
{{ if or cond1 cond2 … }}
{{ if not cond }}
{{ len var }}
tmpl, _ := template.New(“template_name”).Parse(“...”)
tmpl.Name() => name of current template
tmpl.Execute(...) => execute current template
tmpl.ExecuteTemplate(...) => execute template by name
tmpl = tmpl.Lookup(“template_name”) => change current template
tmpl.Templates() => Get defined templates
Grupo6 string `json:"grupo6"`
Po int `json:"po" gorm:"index"`
Co int `json:"co"`
Colada string `json:"colada"`
Calidad string `json:"calidad"`
Matnr string `json:"matnr"`
Dibujo int `json:"dibujo"`
Operador string `json:"operador"`
Serie int `json:"serie"`
Nromatricula string `gorm:"primaryKey" json:"nromatricula"`
NroBulto string `json:"nro_bulto"`
EtiquetaDoble string `json:"etiqueta_doble"`
Fecha int `json:"fecha"`
Turno string `json:"turno"`
Observacion1 string `json:"observacion1"`
Observacion2 string `json:"observacion2"`
Observacion3 string `json:"observacion3"`
PaqueteLongitud float64 `json:"paquete_longitud"`
PaqueteAncho int `json:"paquete_ancho"`
PaqueteAlto float64 `json:"paquete_alto"`
PaquetePeso int `json:"paquete_peso"`
PaqueteNroSecciones int `json:"paquete_nro_secciones"`
PaqueteNroMantos int `json:"paquete_nro_mantos"`
PaqueteNroSeccManto int `json:"paquete_nro_secc_manto"`
SeccionTipo string `gorm:"index" json:"seccion_tipo"`
SeccionLongitud int `json:"seccion_longitud"`
SeccionAncho float64 `json:"seccion_ancho"`
SeccionAlto float64 `json:"seccion_alto"`
Idioma string `json:"idioma"`
Destino int `json:"destino"`
Hora int `json:"hora"`
Horario int `json:"horario"`
Inst string `json:"inst"`
Tren int `json:"tren"`
Normed string `json:"normed"`
Norpro string `json:"norpro"`
Nortol string `json:"nortol"`
Spras string `json:"spras"`
Statu int `json:"statu"`
Crlf string `json:"crlf"`
Maquina int `json:"maquina"`
Padre string `json:"padre"`
Paqpadre string `json:"paqpadre"`
RelevantTime string `json:"relevant_time"`
Desvio float64 `json:"desvio"`
Pesoteorico float64 `json:"pesoteorico"`
PesoteoricoReal float64 `json:"pesoteorico_real"`
DesvioTeoricoReal float64 `json:"desvio_teorico_real"`
FechaImpresion string `json:"fecha_impresion"`
PesoNivel1 float64 `json:"peso_nivel1"`
L3Sended bool `json:"l3_sended,omitempty"`
Confirmed bool `json:"confirmed,omitempty"`
SAP bool `json:"sap,omitempty"`
CreatedAt time.Time `gorm:"->;<-:create" json:"createdat,omitempty"`
UpdatedAt time.Time `json:"updatedat,omitempty"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedat,omitempty"`

View File

@ -4,17 +4,42 @@ import (
"net/http"
"text/template"
"git.espin.casa/albert/cml04-falcon-ui/helper"
"git.espin.casa/albert/cml04-falcon-ui/storage"
"git.espin.casa/albert/cml04-falcon-ui/types"
"github.com/julienschmidt/httprouter"
)
func BundleHandler(storage storage.Storager) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
t, _ := template.ParseFiles("templates/base.html", "templates/bundle.html")
err := t.Execute(w, nil)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
if r.Method == http.MethodGet {
t, _ := template.ParseFiles("templates/base.html", "templates/bundle.html")
err := t.Execute(w, nil)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
if r.Method == http.MethodPost {
// barcodes holder
Bundles := []types.BundleData{}
// parse form data from formulary
if err := r.ParseForm(); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
// barcode
codigo := r.FormValue("codigo")
// date range
fechas := r.FormValue("fechas")
// get range dates
inicio, final, err := helper.Dates(fechas)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
}
}

View File

@ -18,4 +18,5 @@ func CreateRoutes(r *httprouter.Router, storage storage.Storager) {
r.GET("/labels", handlers.LabelsHandler())
r.GET("/standards", handlers.StandardsHandler(storage))
r.GET("/bundle", handlers.BundleHandler(storage))
r.POST("/bundle", handlers.BundleHandler(storage))
}

View File

@ -41,14 +41,67 @@
<nav class="panel is-link">
<p class="panel-heading"><i class="fas fa-box" aria-hidden="true"></i> Busqueda Paquetes</p>
<div class="panel-block">
</div>
</nav>
</div>
{{ if .}}
<div class="column">
<nav class="panel is-link">
<p class="panel-heading"><i class="fas fa-box" aria-hidden="true"></i> Busqueda Paquetes</p>
<p class="panel-heading"><i class="fas fa-box" aria-hidden="true"></i> Listado Paquetes</p>
<div class="panel-block">
<table class="table">
<thead>
<tr>
<th><abbr title="Unidad de almacén">UA</abbr></th>
<th>PO</th>
<th>CO</th>
<th>Colada</th>
<th>Calidad</th>
<th>Código SAP</th>
<th>Producto</th>
<th>Peso</th>
<th>Desvío</th>
<th>Confirmado</th>
<th>Nivel 3</th>
<th>SAP</th>
</tr>
</thead>
<tfoot>
<tr>
<th><abbr title="Unidad de almacén">UA</abbr></th>
<th>PO</th>
<th>CO</th>
<th>Colada</th>
<th>Calidad</th>
<th>Código SAP</th>
<th>Producto</th>
<th>Peso</th>
<th>Desvío</th>
<th>Confirmado</th>
<th>Nivel 3</th>
<th>SAP</th>
</tr>
</tfoot>
<tbody>
{{ range . }}
<tr>
<td><a href="">{{ .Nromatricula }}</a></td>
<td><a href="">{{ .Po }}</a></td>
<td><a href="">{{ .Co }}</a></td>
<td>{{ .Colada }}</td>
<td>{{ .Calidad }}</td>
<td>{{ .Matnr }}</td>
<td>{{ .SeccionTipo }}</td>
<td>{{ .PaquetePeso }}</td>
<td>{{ .Desvio }}</td>
<td>{{ .L3Sended }}</td>
<td>{{ .Confirmed }}</td>
<td>{{ .SAP }}</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
</nav>
</div>