bazz
06-25-2008, 09:32 PM
Hi,
I think this just needs me to know of another bit of perl vocabulary. I don't know what I need to use, to make this last bit do as I need.
The below script outputs almost all perfectly. (see picture). (left shows data as returned by the query - un-processed b=booking_id, i=in o=out).
When I sort @check_in and @check_out to enable correct colouring it all displays fine even when one set of dates straddles two months. (see pic below again - 1st not yellow means it started in June). However, it's different with my @booking_id. I need it to remain relative to the booking. Oh, that's not clear :( coz your going to say use a hash and I don't see how it wil solve this.
the booking_id will always be higgeldy-piggeldy (jumbled/unsortable) even if the dates are ordered because they will have been made randonly ie with no correlation between when they were booked and when the booking was for.
The yello and orange 'dates' hyperlink to another script and I need to use the booking_id in the link. I don't seem to be able to keep them matching.
How can I / what do I need to do, to keep the booking_id relative to the dates.
while ( $room = $sth->fetchrow_hashref)
{
$room_number = $room->{room_number};
$room_name = $room->{room_name};
my $check_in_date = $room->{'GROUP_CONCAT( RB.check_in_date )'};
my $check_out_date = $room->{'GROUP_CONCAT( RB.check_out_date )'};
$room_status = $room->{room_status};
my $bookings_ids = $room->{'GROUP_CONCAT( RB.booking_id )'};
#print Dumper \$room;
my @check_in = (split /,/, $check_in_date);
my @check_out = (split /,/, $check_out_date);
my @booking_id = (split /,/, $bookings_ids);
my @check_in = sort(@check_in);
my @check_out = sort(@check_out);
# my @booking_id = sort(@booking_id); #oops, the sort won't work here, as is
I don't understand how a change to the query would fix it so I have posted in this perl forum.
More especially than ever, I would appreciate your help guys.
and here's the next part of perl script.
print qq(
<tr>
<td class='rooms_label'>$room_number $room_name b=$bookings_ids i=$check_in_date o=$check_out_date</td>
);
foreach my $day_number (1..$days)
{
if (length($day_number) < 2 )
{
$day_number = (join ( "" , ( '0', $day_number)));
}
if (length($month) < 2 )
{
$month = (join ( "" , ( '0', $month)));
}
my $full_iso_date = (join("-",($year, $month, $day_number)));
# compute state 'vacant' or 'busy'
if ($full_iso_date eq $check_out[0])
{
shift(@check_in);
shift(@check_out);
shift(@booking_id);
}
my $room_condition = get_day_status($check_in[0],
$check_out[0],
$full_iso_date);
I hope I have explained this legibly.
bazz
PS
July is the first thumb and june is the second. June gets it all in order and July gets knocked out because its first booking begins in the preceding month of June.
I think this just needs me to know of another bit of perl vocabulary. I don't know what I need to use, to make this last bit do as I need.
The below script outputs almost all perfectly. (see picture). (left shows data as returned by the query - un-processed b=booking_id, i=in o=out).
When I sort @check_in and @check_out to enable correct colouring it all displays fine even when one set of dates straddles two months. (see pic below again - 1st not yellow means it started in June). However, it's different with my @booking_id. I need it to remain relative to the booking. Oh, that's not clear :( coz your going to say use a hash and I don't see how it wil solve this.
the booking_id will always be higgeldy-piggeldy (jumbled/unsortable) even if the dates are ordered because they will have been made randonly ie with no correlation between when they were booked and when the booking was for.
The yello and orange 'dates' hyperlink to another script and I need to use the booking_id in the link. I don't seem to be able to keep them matching.
How can I / what do I need to do, to keep the booking_id relative to the dates.
while ( $room = $sth->fetchrow_hashref)
{
$room_number = $room->{room_number};
$room_name = $room->{room_name};
my $check_in_date = $room->{'GROUP_CONCAT( RB.check_in_date )'};
my $check_out_date = $room->{'GROUP_CONCAT( RB.check_out_date )'};
$room_status = $room->{room_status};
my $bookings_ids = $room->{'GROUP_CONCAT( RB.booking_id )'};
#print Dumper \$room;
my @check_in = (split /,/, $check_in_date);
my @check_out = (split /,/, $check_out_date);
my @booking_id = (split /,/, $bookings_ids);
my @check_in = sort(@check_in);
my @check_out = sort(@check_out);
# my @booking_id = sort(@booking_id); #oops, the sort won't work here, as is
I don't understand how a change to the query would fix it so I have posted in this perl forum.
More especially than ever, I would appreciate your help guys.
and here's the next part of perl script.
print qq(
<tr>
<td class='rooms_label'>$room_number $room_name b=$bookings_ids i=$check_in_date o=$check_out_date</td>
);
foreach my $day_number (1..$days)
{
if (length($day_number) < 2 )
{
$day_number = (join ( "" , ( '0', $day_number)));
}
if (length($month) < 2 )
{
$month = (join ( "" , ( '0', $month)));
}
my $full_iso_date = (join("-",($year, $month, $day_number)));
# compute state 'vacant' or 'busy'
if ($full_iso_date eq $check_out[0])
{
shift(@check_in);
shift(@check_out);
shift(@booking_id);
}
my $room_condition = get_day_status($check_in[0],
$check_out[0],
$full_iso_date);
I hope I have explained this legibly.
bazz
PS
July is the first thumb and june is the second. June gets it all in order and July gets knocked out because its first booking begins in the preceding month of June.