Compare commits
4 Commits
f39b6205d1
...
490a9f1444
| Author | SHA1 | Date | |
|---|---|---|---|
|
490a9f1444
|
|||
|
fdb11bc57c
|
|||
|
f87a6352dd
|
|||
|
9e3a04cd78
|
@@ -235,10 +235,10 @@ func (rc *cartItemController) Update(c *gin.Context) {
|
||||
//}
|
||||
|
||||
func (rc *cartItemController) CartItemView(c *gin.Context) {
|
||||
//sessionId := GetSessionId(c)
|
||||
sessionId := GetSessionId(c)
|
||||
|
||||
//cartItems, err := repositories.CartItems.GetAllBySession(sessionId)
|
||||
cartItems, err := repositories.CartItems.GetAll()
|
||||
cartItems, err := repositories.CartItems.GetAllBySession(sessionId)
|
||||
//cartItems, err := repositories.CartItems.GetAll()
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "cart.html", gin.H{"data": gin.H{"error": err}})
|
||||
|
||||
@@ -3,6 +3,7 @@ package controllers
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"example.com/gin/test/models"
|
||||
"example.com/gin/test/repositories"
|
||||
@@ -11,7 +12,8 @@ import (
|
||||
|
||||
type PrintController interface {
|
||||
PrintVariantView(*gin.Context)
|
||||
PrintVariantHandler(*gin.Context)
|
||||
PrintCartView(*gin.Context)
|
||||
PrintHandler(*gin.Context)
|
||||
}
|
||||
|
||||
type printController struct{}
|
||||
@@ -25,12 +27,14 @@ func (rc *printController) PrintVariantView(c *gin.Context) {
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": err}})
|
||||
return
|
||||
}
|
||||
|
||||
shopItem, err := repositories.ShopItems.GetById(fmt.Sprintf("%v", variant.ShopItemID))
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": err}})
|
||||
return
|
||||
}
|
||||
|
||||
type ShopItemVariantPair struct {
|
||||
@@ -49,27 +53,86 @@ func (rc *printController) PrintVariantView(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "printvariant.html", data)
|
||||
}
|
||||
|
||||
func (rc *printController) PrintVariantHandler(c *gin.Context) {
|
||||
err := repositories.ShopItems.DeleteById(c.Param("id"))
|
||||
func (rc *printController) PrintCartView(c *gin.Context) {
|
||||
sessionId := GetSessionId(c)
|
||||
|
||||
cartItems, err := repositories.CartItems.GetAllBySession(sessionId)
|
||||
if err != nil {
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"error": err,
|
||||
"success": "",
|
||||
})
|
||||
|
||||
c.HTML(http.StatusOK, "deleteitem.html", data)
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": err}})
|
||||
return
|
||||
}
|
||||
|
||||
shopItems, _ := repositories.ShopItems.GetAll()
|
||||
fmt.Println(len(shopItems))
|
||||
type ShopItemVariantPair struct {
|
||||
ShopItem models.ShopItem
|
||||
ItemVariant models.ItemVariant
|
||||
}
|
||||
|
||||
var items []ShopItemVariantPair
|
||||
for _, cartItem := range cartItems {
|
||||
items = append(items, ShopItemVariantPair{ShopItem: cartItem.ShopItem, ItemVariant: cartItem.ItemVariant})
|
||||
}
|
||||
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"title": "shopItem Page",
|
||||
"shopItems": shopItems,
|
||||
"itemVariants": items,
|
||||
})
|
||||
|
||||
fmt.Println(data)
|
||||
|
||||
c.HTML(http.StatusOK, "index.html", data)
|
||||
c.HTML(http.StatusOK, "printvariant.html", data)
|
||||
}
|
||||
|
||||
func (rc *printController) PrintHandler(c *gin.Context) {
|
||||
variantIds := c.PostFormArray("variant-id[]")
|
||||
variantAmounts := c.PostFormArray("variant-amount[]")
|
||||
variantCoverPages := c.PostFormArray("variant-coverpage[]")
|
||||
|
||||
if len(variantIds) != len(variantAmounts) || len(variantIds) != len(variantCoverPages) {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": "Invalid arguments"}})
|
||||
return
|
||||
}
|
||||
|
||||
var printJobs []models.PrintJob
|
||||
for idx := range variantIds {
|
||||
variant, err := repositories.ShopItems.GetVariantById(variantIds[idx])
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": err}})
|
||||
return
|
||||
}
|
||||
|
||||
shopItem, err := repositories.ShopItems.GetById(fmt.Sprintf("%v", variant.ShopItemID))
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": err}})
|
||||
return
|
||||
}
|
||||
|
||||
coverPage := false
|
||||
if variantCoverPages[idx] == "1" {
|
||||
coverPage = true
|
||||
}
|
||||
|
||||
variantAmount, err := strconv.Atoi(variantAmounts[idx])
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": err}})
|
||||
return
|
||||
}
|
||||
|
||||
printJob, err := models.NewPrintJob(shopItem, variant, coverPage, uint(variantAmount))
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": err}})
|
||||
return
|
||||
}
|
||||
|
||||
printJobs = append(printJobs, printJob)
|
||||
}
|
||||
|
||||
executeJobs := func() {
|
||||
for _, printJob := range printJobs {
|
||||
printJob.Execute()
|
||||
}
|
||||
}
|
||||
|
||||
go executeJobs()
|
||||
|
||||
c.HTML(http.StatusOK, "index.html", nil)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ type ShopItemController interface {
|
||||
ShopItemView(*gin.Context)
|
||||
AddItemView(*gin.Context)
|
||||
AddItemHandler(*gin.Context)
|
||||
AddItemsView(*gin.Context)
|
||||
AddItemsHandler(*gin.Context)
|
||||
CreateTag(*gin.Context)
|
||||
GetAllTags(*gin.Context)
|
||||
EditItemView(*gin.Context)
|
||||
@@ -316,6 +318,94 @@ func (rc *shopItemController) AddItemHandler(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "additem.html", data)
|
||||
}
|
||||
|
||||
func (rc *shopItemController) AddItemsView(c *gin.Context) {
|
||||
data := CreateSessionData(c, gin.H{})
|
||||
|
||||
c.HTML(http.StatusOK, "batchupload.html", data)
|
||||
}
|
||||
|
||||
func (rc *shopItemController) AddItemsHandler(c *gin.Context) {
|
||||
errorHandler := func(err error) {
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"error": err,
|
||||
})
|
||||
c.HTML(http.StatusBadRequest, "batchupload.html", data)
|
||||
}
|
||||
|
||||
form, err := c.MultipartForm()
|
||||
|
||||
if err != nil {
|
||||
errorHandler(err)
|
||||
return
|
||||
}
|
||||
|
||||
files := form.File["pdf"]
|
||||
|
||||
var shopItems []models.ShopItem
|
||||
for _, file := range files {
|
||||
dstPdf := filepath.Join("static/uploads", file.Filename)
|
||||
|
||||
if err := c.SaveUploadedFile(file, dstPdf); err != nil {
|
||||
errorHandler(err)
|
||||
return
|
||||
}
|
||||
|
||||
dstImage := dstPdf + ".preview.png"
|
||||
cmd := exec.Command("pdftoppm", "-png", "-singlefile", dstPdf, dstPdf+".preview")
|
||||
_, err := cmd.Output()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error during pdftoppm: ", err.Error())
|
||||
}
|
||||
|
||||
category, err := models.ParseCategory("Zine")
|
||||
if err != nil {
|
||||
errorHandler(err)
|
||||
return
|
||||
}
|
||||
|
||||
variants := []models.ItemVariant{
|
||||
{
|
||||
Name: "B/W",
|
||||
Price: 1.0,
|
||||
},
|
||||
}
|
||||
|
||||
shopItem := models.ShopItem{
|
||||
Name: file.Filename,
|
||||
Abstract: file.Filename,
|
||||
Description: file.Filename,
|
||||
Category: category,
|
||||
IsPublic: true,
|
||||
BasePrice: rc.GetBasePrice(variants),
|
||||
Image: dstImage,
|
||||
Pdf: dstPdf,
|
||||
Variants: variants,
|
||||
}
|
||||
|
||||
_, err = repositories.ShopItems.Create(shopItem)
|
||||
if err != nil {
|
||||
errorHandler(err)
|
||||
return
|
||||
}
|
||||
|
||||
shopItems = append(shopItems, shopItem)
|
||||
}
|
||||
|
||||
msg := "The Following items were registered:\n"
|
||||
|
||||
for _, item := range shopItems {
|
||||
msg += fmt.Sprintf("%s\n", item.Name)
|
||||
}
|
||||
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"error": "",
|
||||
"success": msg,
|
||||
})
|
||||
|
||||
c.HTML(http.StatusOK, "batchupload.html", data)
|
||||
}
|
||||
|
||||
func (rc *shopItemController) EditItemView(c *gin.Context) {
|
||||
shopItem, err := repositories.ShopItems.GetById(c.Param("id"))
|
||||
tags, err := repositories.Tags.GetAll()
|
||||
|
||||
6
main.go
6
main.go
@@ -83,7 +83,9 @@ func main() {
|
||||
viewRoutes.GET("/shopitems/:id/delete", authValidator.RequireAuth, shopItemController.DeleteItemView)
|
||||
viewRoutes.POST("/shopitems/:id/delete", authValidator.RequireAuth, shopItemController.DeleteItemHandler)
|
||||
viewRoutes.GET("/variant/:id/print", authValidator.RequireAuth, printController.PrintVariantView)
|
||||
viewRoutes.POST("/variant/:id/print", authValidator.RequireAuth, printController.PrintVariantHandler)
|
||||
viewRoutes.GET("/cart/print", authValidator.RequireAuth, printController.PrintCartView)
|
||||
viewRoutes.POST("/print", authValidator.RequireAuth, printController.PrintHandler)
|
||||
|
||||
viewRoutes.GET("/tags", authValidator.RequireAuth, shopItemController.TagView)
|
||||
viewRoutes.POST("/tags/:id", authValidator.RequireAuth, shopItemController.TagHandler)
|
||||
viewRoutes.POST("/tags", authValidator.RequireAuth, shopItemController.AddTagHandler)
|
||||
@@ -102,9 +104,11 @@ func main() {
|
||||
viewRoutes.GET("/register", userController.RegisterView)
|
||||
viewRoutes.GET("/passwordreset", userController.ResetView)
|
||||
viewRoutes.GET("/additem", authValidator.RequireAuth, shopItemController.AddItemView)
|
||||
viewRoutes.GET("/batchupload", authValidator.RequireAuth, shopItemController.AddItemsView)
|
||||
viewRoutes.POST("/login", userController.LoginHandler)
|
||||
viewRoutes.POST("/register", userController.RegisterHandler)
|
||||
viewRoutes.POST("/additem", authValidator.RequireAuth, shopItemController.AddItemHandler)
|
||||
viewRoutes.POST("/batchupload", authValidator.RequireAuth, shopItemController.AddItemsHandler)
|
||||
viewRoutes.POST("/passwordreset", userController.ResetHandler)
|
||||
}
|
||||
|
||||
|
||||
57
models/printer.go
Normal file
57
models/printer.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type PrintOption string
|
||||
|
||||
const (
|
||||
CoverPage PrintOption = "-o FrontCoverPage=Printed -o FrontCoverTray=BypassTray -o InputSlot=Tray1"
|
||||
Colored PrintOption = "-o SelectColor=Color"
|
||||
Grayscale PrintOption = "-o SelectColor=Grayscale"
|
||||
)
|
||||
|
||||
type PrintJob struct {
|
||||
Pdf string
|
||||
Amount uint
|
||||
Options []PrintOption
|
||||
}
|
||||
|
||||
func NewPrintJob(shopItem ShopItem, variant ItemVariant, coverPage bool, amount uint) (PrintJob, error) {
|
||||
if shopItem.Pdf == "" {
|
||||
return PrintJob{}, fmt.Errorf("ShopItem has no PDF assigned")
|
||||
}
|
||||
|
||||
if amount > 100 {
|
||||
return PrintJob{}, fmt.Errorf("Amount to big. This is denied for security reasons")
|
||||
}
|
||||
|
||||
var result PrintJob
|
||||
result.Pdf = shopItem.Pdf
|
||||
result.Amount = amount
|
||||
|
||||
if variant.Name == "Colored" {
|
||||
result.Options = append(result.Options, Colored)
|
||||
}
|
||||
|
||||
if coverPage {
|
||||
result.Options = append(result.Options, CoverPage)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (p *PrintJob) Execute() error {
|
||||
baseCommand := "lp -p KONICA_MINOLTA_KONICA_MINOLTA_bizhub_C258/Booklet "
|
||||
baseCommand += fmt.Sprintf("-n %v ", p.Amount)
|
||||
|
||||
for _, option := range p.Options {
|
||||
baseCommand += fmt.Sprintf(" %v ", option)
|
||||
}
|
||||
|
||||
baseCommand += fmt.Sprintf(" -- %s", p.Pdf)
|
||||
|
||||
fmt.Println(baseCommand)
|
||||
return nil
|
||||
}
|
||||
53
views/batchupload.html
Normal file
53
views/batchupload.html
Normal file
@@ -0,0 +1,53 @@
|
||||
{{ template "header.html" . }}
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/circlea.png" alt="Your Company">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Batch Upload</h2>
|
||||
Select multiple files on the upload. For each a new Shop Item will be created with the Filename as Name, Abstract
|
||||
and Description.<br>
|
||||
Afterwards you should edit every item and set the proper Values for that, price and so on.
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<form class="space-y-6" action="/additems" method="POST" enctype="multipart/form-data">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-900">
|
||||
PDF
|
||||
</label>
|
||||
<div class="mt-1 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
|
||||
<div class="space-y-1 text-center">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-900" stroke="currentColor" fill="none" viewBox="0 0 48 48" aria-hidden="true">
|
||||
<path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<div class="flex text-sm text-gray-600">
|
||||
<label for="pdf-upload" class="relative cursor-pointer bg-white rounded-md font-medium text-indigo-600 hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500">
|
||||
<span class="">Upload a file</span>
|
||||
<input id="pdf-upload" name="pdf" type="file" multiple="multiple" accept="application/pdf" class="sr-only">
|
||||
</label>
|
||||
<p class="pl-1 text-gray-900">or drag and drop</p>
|
||||
</div>
|
||||
<p class="text-xs text-gray-900">
|
||||
PDF up to 50MB
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-10 text-center text-sm/6 text-red-500">
|
||||
{{ .data.error }}
|
||||
</p>
|
||||
<p class="mt-10 text-center text-sm/6 text-green-500">
|
||||
{{ .data.success }}
|
||||
</p>
|
||||
|
||||
|
||||
<div>
|
||||
<button type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm/6 font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Add Item</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ template "footer.html" . }}
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class="bg-gray-200 rounded m-4 p-4">
|
||||
<h3 class="text-lg">{{ .data.shopItem.Name }}</h3>
|
||||
<i class="text-xs">{{ .data.shopItem.Description }}</i>
|
||||
<p class="">Price: {{ .data.shopItem.Price }}</p>
|
||||
<p class="">Price: {{ .data.shopItem.BasePrice }}</p>
|
||||
{{ if .loggedIn }}
|
||||
|
||||
<p class="mt-10 text-center text-sm/6 text-red-500">
|
||||
|
||||
@@ -55,14 +55,28 @@
|
||||
-->
|
||||
|
||||
<div>
|
||||
<input type="hidden" name="category" value="Zine" required>
|
||||
<input type="hidden" id="variant-name1" name="variant-name[]" value="B/W" required>
|
||||
<div class="flex items-center justify-between">
|
||||
<label for="price" class="block text-sm/6 font-medium text-gray-900">Price</label>
|
||||
<label for="variant-value1" class="block text-sm/6 font-medium text-gray-900">Price B/W</label>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<input type="number" name="price" id="price" value="{{ .data.shopItem.Price }}" step="0.01" min="0.00" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
<input type="number" name="variant-value[]" id="variant-value1" step="0.01" min="0.00" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<input type="hidden" id="variant-name2" name="variant-name[]" value="Colored" required>
|
||||
<div class="flex items-center justify-between">
|
||||
<label for="variant-value2" class="block text-sm/6 font-medium text-gray-900">Price Colored</label>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<input type="number" name="variant-value[]" id="variant-value2" step="0.01" min="0.00" class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-900">
|
||||
Image
|
||||
@@ -73,9 +87,9 @@
|
||||
<path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<div class="flex text-sm text-gray-600">
|
||||
<label for="file-upload" class="relative cursor-pointer bg-white rounded-md font-medium text-indigo-600 hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500">
|
||||
<label for="image-upload" class="relative cursor-pointer bg-white rounded-md font-medium text-indigo-600 hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500">
|
||||
<span class="">Upload a file</span>
|
||||
<input id="file-upload" name="file-upload" type="file" class="sr-only">
|
||||
<input id="image-upload" name="image" type="file" accept="image/*" class="sr-only">
|
||||
</label>
|
||||
<p class="pl-1 text-gray-900">or drag and drop</p>
|
||||
</div>
|
||||
@@ -86,6 +100,29 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-900">
|
||||
PDF
|
||||
</label>
|
||||
<div class="mt-1 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
|
||||
<div class="space-y-1 text-center">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-900" stroke="currentColor" fill="none" viewBox="0 0 48 48" aria-hidden="true">
|
||||
<path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<div class="flex text-sm text-gray-600">
|
||||
<label for="pdf-upload" class="relative cursor-pointer bg-white rounded-md font-medium text-indigo-600 hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500">
|
||||
<span class="">Upload a file</span>
|
||||
<input id="pdf-upload" name="pdf" type="file" accept="application/pdf" class="sr-only">
|
||||
</label>
|
||||
<p class="pl-1 text-gray-900">or drag and drop</p>
|
||||
</div>
|
||||
<p class="text-xs text-gray-900">
|
||||
PDF up to 50MB
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-10 text-center text-sm/6 text-red-500">
|
||||
{{ .data.error }}
|
||||
</p>
|
||||
|
||||
@@ -28,7 +28,13 @@
|
||||
{{ if .loggedIn }}
|
||||
<div class="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0 px-4 sm:px-8">
|
||||
<a href="/additem" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Add Item</a>
|
||||
<a href="/batchupload" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300
|
||||
hover:bg-gray-700 hover:text-white">Batch Upload</a>
|
||||
<a href="/tags" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Tags</a>
|
||||
<a href="/cart/print" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700
|
||||
hover:text-white">Print</a>
|
||||
<a href="/cart" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700
|
||||
hover:text-white">Cart</a>
|
||||
<a href="/logout" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-red-300 hover:bg-gray-700 hover:text-white">Logout</a>
|
||||
</div>
|
||||
{{ else }}
|
||||
|
||||
@@ -4,10 +4,15 @@
|
||||
<div class="mx-auto max-w-3xl">
|
||||
<div class="mt-6 sm:mt-8">
|
||||
<div class="relative overflow-x-auto border-b border-gray-200 dark:border-gray-800">
|
||||
<h2 class="title font-manrope font-bold text-4xl leading-10 mb-8 text-center text-black">Zineshop Print
|
||||
Service
|
||||
</h2>
|
||||
<p class="font-normal text-base leading-7 text-gray-900 text-left mb-5 mt-6">
|
||||
Pressing Print will automatically print the given Zines for you.<br>
|
||||
Add Zines for printing simply by adding them to the Cart
|
||||
</p>
|
||||
|
||||
<p class="font-normal text-base leading-7 text-gray-500 text-left mb-5 mt-6">
|
||||
Welcome to the Zineshop Printservice.<br>
|
||||
Pressing Print will automatically print the given Zines for you.
|
||||
All you have to do is set an Amount for each Zine you want to print.<br><br>
|
||||
<bold>CoverPage</bold>: If selected, the Printer will take Paper from the BypassTray for the first page. For
|
||||
example you can put colored paper there to have a nice looking front page, and the rest will be normal paper.
|
||||
Makue sure you put paper in that tray when selecting this option.<br><br>
|
||||
@@ -17,52 +22,47 @@
|
||||
|
||||
</p>
|
||||
|
||||
<form action="#" method="POST">
|
||||
<table class="w-full text-left font-medium text-gray-900 dark:text-white ">
|
||||
<tbody class="divide-y divide-gray-200 dark:divide-gray-800">
|
||||
{{ range .data.itemVariants }}
|
||||
<tr>
|
||||
<form action="/print" method="POST">
|
||||
<table class="w-full text-left font-medium text-gray-900 dark:text-white">
|
||||
<tbody class="divide-y divide-gray-200 dark:divide-gray-800">
|
||||
{{ range .data.itemVariants }}
|
||||
<tr>
|
||||
<input type="hidden" name="variant-id[]" value="{{ .ItemVariant.ID }}" required>
|
||||
<td class="whitespace-nowrap py-4">
|
||||
<div class="flex items-center gap-4">
|
||||
<a href="/shopitems/{{ .ItemVariant.ShopItemID }}" class="flex items-center aspect-square w-8 h-10 shrink-0">
|
||||
<img class="h-auto w-full max-h-full dark:hidden" src="/{{ .ShopItem.Image }}" alt="imac image" />
|
||||
</a>
|
||||
<a href="/shopitems/{{ .ItemVariant.ShopItemID }}" class="hover:underline">{{ .ShopItem.Name }} - {{ .ItemVariant.Name }}</a>
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<a href="/shopitems/{{ .ItemVariant.ShopItemID }}" class="flex items-center aspect-square w-8 h-10 shrink-0">
|
||||
<img class="h-auto w-full max-h-full dark:hidden" src="/{{ .ShopItem.Image }}" alt="imac image" />
|
||||
</a>
|
||||
<a href="/shopitems/{{ .ItemVariant.ShopItemID }}" class="hover:underline">{{ .ShopItem.Name }} - {{ .ItemVariant.Name }}</a>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="whitespace-nowrap py-4">
|
||||
<select name="variant-coverpage[]" required class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
||||
<option selected value="0">Normal</option>
|
||||
<option value="1">CoverPage</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="whitespace-nowrap py-4">
|
||||
<label class="flex text-sm/6 items-center">
|
||||
<input type="checkbox" class="form-checkbox h-4 w-4 text-gray-900" value="CoverPage" name="CoverPage">
|
||||
<span class="ml-2 text-sm/6 text-gray-900">CoverPage</span>
|
||||
</label>
|
||||
</td>
|
||||
<td class="whitespace-nowrap py-4">
|
||||
Amount:
|
||||
Amount:
|
||||
</td>
|
||||
<td class="p-4 text-right text-base font-bold text-gray-900 dark:text-white">
|
||||
<div>
|
||||
<input type="hidden" id="variant-name1" name="variant-name[]" value="B/W" required>
|
||||
<div class="mt-2">
|
||||
<input type="number" name="variant-value[]" id="variant-value1" step="1" min="1" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
<div>
|
||||
<div class="mt-2">
|
||||
<input type="number" name="variant-amount[]" step="1" min="0" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</tr>
|
||||
{{ end }}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="max-lg:max-w-lg max-lg:mx-auto">
|
||||
<p class="font-normal text-base leading-7 text-gray-500 text-center mb-5 mt-6">If CoverPage
|
||||
selected, make sure you put paper in the BypassTray</p>
|
||||
<button type="submit"
|
||||
class="rounded-full py-4 px-6 bg-indigo-600 text-white font-semibold text-lg w-full text-center
|
||||
transition-all duration-500 hover:bg-indigo-700 ">Print</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
<div class="max-lg:max-w-lg max-lg:mx-auto">
|
||||
<p class="font-normal text-base leading-7 text-gray-500 text-center mb-5 mt-6">If CoverPage selected, make sure you put paper in the BypassTray</p>
|
||||
<button type="submit" class="rounded-full py-4 px-6 bg-indigo-600 text-white font-semibold text-lg w-full text-center transition-all duration-500 hover:bg-indigo-700">Print</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -77,25 +77,4 @@
|
||||
</div>
|
||||
|
||||
|
||||
<!--
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||
<div class="bg-gray-200 rounded m-4 p-4">
|
||||
<div class="relative flex rounded-lg justify-center items-center">
|
||||
<img src="/{{ .data.shopItem.Image }}" alt="shopping image"
|
||||
class="object-cover items-center justify-center rounded">
|
||||
</div>
|
||||
<h3 class="text-lg">{{ .data.shopItem.Name }}</h3>
|
||||
<i class="text-xs">{{ .data.shopItem.Abstract }}</i>
|
||||
<p class="text-xs">{{ .data.shopItem.Description }}</p>
|
||||
<p class="">Price: {{ .data.shopItem.Price }}</p>
|
||||
{{ if .loggedIn }}
|
||||
<div class="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0 px-4 sm:px-8">
|
||||
<a href="{{ .data.shopItem.ID }}/edit" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Edit</a>
|
||||
<a href="{{ .data.shopItem.ID }}/delete" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-red-300 hover:bg-gray-700 hover:text-white">Delete</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
-->
|
||||
{{ template "footer.html" . }}
|
||||
|
||||
Reference in New Issue
Block a user