{{define "title"}}{{if .LocationID}}Ort bearbeiten{{else}}Ort anlegen{{end}}{{end}} {{define "main"}} {{$form := .Form}} {{$canSave := canGarden .Garden "locations:create"}}{{if .LocationID}}{{$canSave = canGardenResource .Garden .CurrentUser .LocationCreatedBy "locations:update:own" "locations:update:other"}}{{end}}
{{if .LocationID}}{{end}}

{{if .LocationID}}Ort bearbeiten{{else}}Ort anlegen{{end}}

{{template "location_fields" .}}
{{if $canSave}}{{end}} Abbrechen {{if and .LocationID (canGardenResource .Garden .CurrentUser .LocationCreatedBy "locations:delete:own" "locations:delete:other")}}
{{end}}
{{if .LocationID}}

Pflanzen an diesem Ort

{{template "view_toggle" "location-plants"}}
{{range .LocationPlants}} {{$canEditPlant := canGardenResource $.Garden $.CurrentUser .Plant.CreatedBy "plants:update:own" "plants:update:other"}}

{{if $canEditPlant}}{{.Plant.Name}}{{else}}{{.Plant.Name}}{{end}}

Anzahl: {{.Assignment.Quantity}}{{with .Assignment.PlantedAt}} · gepflanzt am {{humanDate .}}{{end}}

{{with .Assignment.Notes}}

{{.}}

{{end}}
{{else}}

Diesem Ort sind noch keine Pflanzen zugeordnet.

{{end}}

Historie der letzten 3 Jahre

{{range .LocationHistory}}

{{.Year}}

{{range .Plants}} {{$canEditPlant := canGardenResource $.Garden $.CurrentUser .Plant.CreatedBy "plants:update:own" "plants:update:other"}}

{{if $canEditPlant}}{{.Plant.Name}}{{else}}{{.Plant.Name}}{{end}}

{{plantStatusName .Plant.Status}}{{with .Assignment.RemovedAt}} · entfernt am {{humanDate .}}{{end}}

{{with .Assignment.Notes}}

{{.}}

{{end}}
{{else}}

Keine Pflanzen in diesem Jahr.

{{end}}
{{end}}
{{end}}
{{end}}