Hello everyone.
And then, the PointsControllers looks if there is someone that already booked for that day. And this is what is driving me crazy, because I'm not able to doing it to work. What I tried is this:
If anyone can PLEASE give some light to this... Please....
-- I'm struggling with a problem since a week ago, and this is driving me crazy.
I'm doing a website for doing surveys in the forest. This is the schema:
1 place have several points, and for each point, an user can book a day for doing a survey. If that point has booked already a survey for that date, an error will be shown.
I have the following tables: places, points, users and booked_surveys.
The table booked_surveys has the following fields: id, survey_date, point_id and user_id
Models: Place, Point, User, BookedSurvey
Controllers: PlacesController, PointController, UserController, BookedSurveysController
Views: add, edit, index and view for each one.
When the user is viewing a point, there's a date selector in the view for booking:
<h2>Book a date:</h2> <?php echo $this->Form->create('BoostCake', array( 'inputDefaults' => array( 'div' => 'form-group', 'label' => array( 'class' => 'col col-md-1 control-label' ), 'wrapInput' => 'col col-md-9', 'class' => 'form-control' ), 'class' => 'form-horizontal' )); ?> <?php echo $this->Form->create('Point');
echo $this->Form->input('BookedSurvey.survey_date', array( 'type'=>'date', 'label' => '', 'dateFormat' => 'YMD', 'minYear' => date('Y'), 'minMonth' => date('M'), 'minDay' => date('D'), 'div' => 'col col-md-9', 'style' => 'margin: 15px 5px 5px 0px' ));
echo $this->Form->hidden('User.id', array( 'value' => $user_id) );
?>
<div class="form-group"> <?php echo $this->Form->submit('Book survey', array( 'div' => 'col col-md-9', 'class' => 'btn btn-success btn-lg', 'style' => 'margin: 10px 5px 5px 10px' )); ?> </div>And then, the PointsControllers looks if there is someone that already booked for that day. And this is what is driving me crazy, because I'm not able to doing it to work. What I tried is this:
if ($this->request->is('post')) { // Begin of comprobation $booked_condition = $this->Point->BookedSurvey->find('first', array('conditions'=>array( 'DATE(BookedSurvey.survey_date)'=>'date()'))); if ($booked_condition){ echo "Already booked"; } If anyone can PLEASE give some light to this... Please....
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment