Emily Berk wrote:
>
>
> Thanks for your response!
>
> I hear what you are saying about the 31 or so hits on the database per
> month.
>
> But if I do it with the single database hit, then I am doing a compare
> in PHP for each date I write and the code gets ugly (IMO). Since it's a
> very, very small database, it feels to me as if code cleanliness would
> trump the evil of so many database hits.
>
> -- Emily
>
Don't make the mistake of thinking too small now. It's a pain to expand
once it's in use. The PHP code is not that big of a deal. The code for
my PHP calendar is 90% code to generate the calendar, 5% to connect to
the database and another 5% to sort out the dates. Just a few loops.
I can not post the entire calendar but here is the code that takes care
of sorting.
//Check for Scheduled Appointment for $day
$ArrayLength = count($row);
for( $y=1 ; $y <= $ArrayLength ; $y++ ) {
$OnsiteScheduledDateOrg = $row[$y]['FormatedDate'];
$OnsiteScheduledDate = $row[$y]['OnsiteScheduled'];
$OnsiteScheduledDate = substr("$OnsiteScheduledDate", 0, 10); //Only
Compare the Date, not tge time
$ThisTicketStatusID = $row[$y]['Status_id']; //Get the status ID,
this
controls the color
//Add 0 if less then 9 to make 09
if( $month_num < 10 ) {
$month_numt = "0".$month_num; }
else { $month_numt = $month_num; }
if( $day < 10 ) {
$dayt = "0".$day; }
else{ $dayt = $day; }
$CalendayTestDay = "$year-$month_numt-$dayt";
//echo("<br>$OnsiteScheduledDate - $CalendayTestDay");
if( $OnsiteScheduledDate == $CalendayTestDay) {
//Create Link to Appointment
$Ticket_ID = $row[$y]['ID'];
$User_name = $row[$y]['User_name'];
if( $ThisTicketStatusID == 1 ) {
echo('<span style="color: black; background-color:
rgb('.$SchedulerColor1DB.');"><a target="_blank"
href="../../workorder.php?Ticket_ID='.$Ticket_ID.'&Step=EditAddTicket&SSID='.$SSID.'">'.$OnsiteScheduledDateOrg.' - '.$User_name.'</span></a><br>');
}
elseif( $ThisTicketStatusID == 12 OR $ThisTicketStatusID == 8 ) {
echo('<span style="color: black; background-color:
rgb('.$SchedulerColor0DB.');"><a target="_blank"
href="../../workorder.php?Ticket_ID='.$Ticket_ID.'&Step=EditAddTicket&SSID='.$SSID.'">'.$OnsiteScheduledDateOrg.' - '.$User_name.'</span></a><br>');
}
else{ //Catch Other Status ID's with a Date.
echo('<a target="_blank"
href="../../workorder.php?Ticket_ID='.$Ticket_ID.'&Step=EditAddTicket&SSID='.$SSID.'">'.$OnsiteScheduledDateOrg.' - '.$User_name.'</a><br>');
}
}
}