Reservation calendar 4

This commit is contained in:
vinchent 2024-07-28 13:59:54 +02:00
parent 7894a05daf
commit 14828fb901
3 changed files with 26 additions and 4 deletions

View File

@ -686,7 +686,9 @@ func (m *Repository) AdminReservationsCalendar(w http.ResponseWriter, r *http.Re
} }
} else { } else {
// it's a block // it's a block
blockMap[y.StartDate.Format("2006-01-2")] = y.ReservationID for d := y.StartDate; !d.After(y.EndDate); d = d.AddDate(0, 0, 1) {
blockMap[d.Format("2006-01-2")] = y.ID
}
} }
} }
data[fmt.Sprintf("reservation_map_%d", x.ID)] = reservationMap data[fmt.Sprintf("reservation_map_%d", x.ID)] = reservationMap

View File

@ -27,7 +27,9 @@ Reservations Calendar
<div class="clearfix"></div> <div class="clearfix"></div>
{{range $rooms}} {{range $rooms}}
{{$roomId := .ID}} {{$roomID := .ID}}
{{$blocks := index $.Data (printf "block_map_%d" .ID)}}
{{$reservations := index $.Data (printf "reservation_map_%d" .ID)}}
<h4 class="mt-4">{{.RoomName}}</h4> <h4 class="mt-4">{{.RoomName}}</h4>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered table-sm"> <table class="table table-bordered table-sm">
@ -41,7 +43,21 @@ Reservations Calendar
<tr class="table-light"> <tr class="table-light">
{{range $index := iterate $dim}} {{range $index := iterate $dim}}
<td class="text-center"> <td class="text-center">
<input type="checkbox" name="checked" value=""> {{if gt (index $reservations (printf "%s-%s-%d" $curYear $curMonth (add $index 1))) 0}}
<a href="/admin/reservations/cal/{{index $reservations (printf "%s-%s-%d" $curYear $curMonth (add $index 1))}}">
<span class="text-danger">R</span>
</a>
{{else}}
<input
{{if gt (index $blocks (printf "%s-%s-%d" $curYear $curMonth (add $index 1))) 0}}
checked
name="remove_block_{{$roomID}}_{{printf "%s-%s-%d" $curYear $curMonth (add $index 1)}}"
value="{{index $blocks (printf "%s-%s-%d" $curYear $curMonth (add $index 1))}}"
{{else}}
name="add_block_{{$roomID}}_{{printf "%s-%s-%d" $curYear $curMonth (add $index 1)}}"
{{end}}
type="checkbox">
{{end}}
</td> </td>
{{end}} {{end}}
</tr> </tr>

View File

@ -50,7 +50,11 @@ Reservation
<div class="float-start"> <div class="float-start">
<input type="submit" class="btn btn-primary" value="Save"> <input type="submit" class="btn btn-primary" value="Save">
{{if eq $src "cal"}}
<a href="#" onclick="window.history.go(-1)" class="btn btn-warning">Cancel</a>
{{else}}
<a href="/admin/reservations-{{$src}}" class="btn btn-warning">Cancel</a> <a href="/admin/reservations-{{$src}}" class="btn btn-warning">Cancel</a>
{{end}}
<a href="#" class="btn btn-info" onclick="processRes({{$res.ID}})">Mark as Processed</a> <a href="#" class="btn btn-info" onclick="processRes({{$res.ID}})">Mark as Processed</a>
</div> </div>