Another adjunct to the problem...

I have got the filter working, but still would like to see:
Is there a way to do the above using the addCriteria/addAscendingOrderByColumn 
and other Propel capabilities? It would be nicer than using the SQL code below 
just in case the structure of the database changed!

Adrian          
----

----- from BookingPeer.php -----

class BookingPeer extends BaseBookingPeer
{

        function getBookedUnbooked($date)
        {
                
                $con = Propel::getConnection();

                $sql = "
                  SELECT booking.* FROM booking
                                WHERE '".$date."' BETWEEN start_date AND 
end_date
                        UNION 
                        SELECT 0 as id, 0 as client_id, id AS room_id, 
'0000-00-00' as start_date, '0000-00-00' as end_date, 0 as adults, 0 as 
children, '0000-00-00 00:00:00' as created_at FROM room 
                                WHERE room.id NOT IN ( 
                                        SELECT room_id FROM booking 
                                                WHERE '".$date."' BETWEEN 
start_date AND end_date
                                        )
                        ORDER BY room_id
                        ";  
                $stmt = $con->createStatement();
                $rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_NUM);  

                
                // $this->bookings = 
BookingPeer::populateObjects(BookingPeer::doSelectRS($rs, $con));
                return BookingPeer::populateObjects($rs);               
                
        }


}

----- from actions.class.php -----

        public function executeShowbooked()
  {
                if (!$this->getRequestParameter('checkDate') )
                {
                        $this->checkDate = date('Y-m-d');
                }
                else
                {
                        $this->checkDate = 
$this->getRequestParameter('checkDate');
                }
                $this->checkDate = $this->getRequestParameter('checkDate');
    $this->bookings = BookingPeer::getBookedUnbooked( $this->checkDate);
  }
 

----- from showbookedSuccess.php -----
<?php echo form_tag('booking/showbooked') ?>
<p>Check this date:<?php echo input_date_tag('checkDate',$checkDate, array (
          'rich' => true,
          'withtime' => false,
        )) ?>
        <?php echo submit_tag('Check...'); ?></p>

----- the rest of the form / results display is not shown -----

Still will want to take this a step further and show rooms and dates booked in 
a "grid" or "matrix" as shown below:

          Room
Date      101  102  103  201  202  203
20080612    Y    N    Y    N    Y    N
20080613    Y    N    N    N    Y    Y
20080614    N    Y    Y    N    Y    Y
20080615    N    N    Y    N    Y    N


Adrian
---
Adrian Gould
Lecturer in IT / Network Engineering / Multimedia
Business Finance & Computing [Midland Campus]
Swan TAFE
PO BOX 1336, Midland WA 6936

Phone: (08) 9267 7777
eMail: [EMAIL PROTECTED]






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to