package Epoll::Controller::Ajax; use strict; use warnings; use base 'Catalyst::Controller'; =head1 NAME Epoll::Controller::Ajax - Catalyst Controller =head1 DESCRIPTION Catalyst Controller. =head1 METHODS =cut =head2 index =cut sub index :Path :Args(0) { my ( $self, $c ) = @_; $c->response->body('Matched Epoll::Controller::Ajax in Ajax.'); } sub datecheck :Path { my ( $self, $c ) = @_; my $poll = $c->model('Vote'); if ($c->req->param('dstart') && $c->req->param('dend')) { my $start = $c->req->param('dstart') . ' ' . ($c->req->param('hstart') || ''); my $end = $c->req->param('dend') . ' ' . ($c->req->param('hend') || ''); if ($poll->check_date_max($start)) { if ($poll->check_date_max($end, $start)) { $c->response->body(''); } else { $c->response->body( $c->localize('The vote finish before starting')); } } else { $c->response->body( $c->localize('The start of the vote must be in the future')); } } else { $c->response->body( $c->localize('You must define a start and a end date')); } } sub end : Private { my ($self, $c) = @_; if ($c->res->body) { return } else { $c->forward(qw/Epoll::View::Ajax/) } } =head1 AUTHOR Olivier Thauvin =head1 LICENSE This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself. =cut 1;