示例#1
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->step = sfConfig::get('app_max_cards_on_cardlist');
     $this->getUser()->syncParameters($this, 'card', 'index', array('offset', 'limit', 'numberPattern', 'sort_column', 'sort_direction'), $request);
     if (is_null($this->sort_column)) {
         $this->sort_column = 'card_number';
         $this->sort_direction = 'up';
     }
     $this->searchForm = new CardSearchForm();
     $c = CardPeer::getSortByNumberAscCriteria();
     SortCriteria::addSortCriteria($c, $this->sort_column, CardPeer::getSortAliases(), $this->sort_direction);
     if (is_null($this->offset)) {
         $this->offset = 0;
     }
     if (is_null($this->limit) || $this->limit <= 0) {
         $this->limit = $this->step;
     }
     if (!empty($this->numberPattern)) {
         $tmpc = CardPeer::getSearchNumberPatternCriteria($this->numberPattern);
         $this->searchCount = CardPeer::getCardsCount($tmpc);
         $c = CardPeer::getSearchNumberPatternCriteria($this->numberPattern, $c);
     }
     $this->card_list = CardPeer::doSelectCards($this->offset, $this->limit, $c);
     $this->count = CardPeer::getCardsCount();
     if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) {
         $this->forward404();
     }
 }
示例#2
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->step = sfConfig::get('app_max_features_on_featurelist');
     $this->getUser()->syncParameters($this, 'energyaction', 'index', array('offset', 'limit', 'sort_column', 'sort_direction'), $request);
     if (is_null($this->sort_column)) {
         $this->sort_column = 'name';
         $this->sort_direction = 'up';
     }
     if (is_null($this->offset)) {
         $this->offset = 0;
     }
     if (is_null($this->limit) || $this->limit <= 0) {
         $this->limit = $this->step;
     }
     $c = new Criteria();
     SortCriteria::addSortCriteria($c, $this->sort_column, EnergyactionPeer::getSortAliases(), $this->sort_direction);
     $c->setOffset($this->offset);
     if ($this->limit >= 0) {
         $c->setLimit($this->limit);
     }
     $this->energyaction_list = EnergyactionPeer::doSelect($c);
     $this->count = EnergyactionPeer::doCount(new Criteria());
     if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) {
         $this->forward404();
     }
 }
示例#3
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->user = $this->getUser()->getTemposUser();
     $this->forward404Unless($this->user, 'Only users can access this page.');
     $this->step = sfConfig::get('app_max_messages_on_messagelist');
     $this->getUser()->syncParameters($this, 'message', 'index', array('offset', 'limit', 'sort_column', 'sort_direction'), $request);
     if (is_null($this->sort_column)) {
         $this->sort_column = 'created_at';
         $this->sort_direction = 'down';
     }
     if (is_null($this->offset)) {
         $this->offset = 0;
     }
     if (is_null($this->limit) || $this->limit <= 0) {
         $this->limit = $this->step;
     }
     $c = MessagePeer::getUserCriteria($this->user->getId());
     $cb = clone $c;
     SortCriteria::addSortCriteria($c, $this->sort_column, MessagePeer::getSortAliases(), $this->sort_direction);
     $c->setOffset($this->offset);
     if ($this->limit >= 0) {
         $c->setLimit($this->limit);
     }
     $this->message_list = MessagePeer::doSelect($c);
     $this->count = MessagePeer::doCount($cb);
     $this->unread_count = MessagePeer::doCountUserUnreadMessages($this->user->getId());
     if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) {
         $this->forward404('Invalid offset/count values.');
     }
 }
示例#4
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->forward404Unless($this->room = RoomPeer::retrieveByPk($request->getParameter('roomId')), sprintf('Object room does not exist (%s).', $request->getParameter('roomId')));
     $this->step = sfConfig::get('app_max_closeperiods_on_closeperiodlist');
     $this->getUser()->syncParameters($this, 'closeperiod', 'index', array('offset', 'limit', 'sort_column', 'sort_direction'), $request);
     if (is_null($this->sort_column)) {
         $this->sort_column = 'start';
         $this->sort_direction = 'up';
     }
     if (is_null($this->offset)) {
         $this->offset = 0;
     }
     if (is_null($this->limit) || $this->limit <= 0) {
         $this->limit = $this->step;
     }
     $c = new Criteria();
     SortCriteria::addSortCriteria($c, $this->sort_column, CloseperiodPeer::getSortAliases(), $this->sort_direction);
     $c->setOffset($this->offset);
     if ($this->limit >= 0) {
         $c->setLimit($this->limit);
     }
     $this->closeperiod_list = CloseperiodPeer::doSelectFromRoom($this->room->getId(), $c);
     $this->count = CloseperiodPeer::doCount(CloseperiodPeer::getFromRoomCriteria($this->room->getId()));
     if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) {
         $this->forward404();
     }
 }
示例#5
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->is_admin = $this->getUser()->hasCredential('admin', false);
     $this->form = new UserSearchForm();
     $formName = $this->form->getName();
     $this->step = sfConfig::get('app_max_users_on_userlist');
     $this->getUser()->syncParameters($this, 'user', 'index', array('offset', 'limit', $formName, 'sort_column', 'sort_direction'), $request);
     if (is_null($this->sort_column)) {
         $this->sort_column = 'name';
         $this->sort_direction = 'up';
     }
     if (is_null($this->offset)) {
         $this->offset = 0;
     }
     if (is_null($this->limit) || $this->limit <= 0) {
         $this->limit = $this->step;
     }
     $c = new Criteria();
     SortCriteria::addSortCriteria($c, $this->sort_column, UserPeer::getSortAliases(), $this->sort_direction);
     if (!is_null($this->{$formName})) {
         $this->filtered = true;
         $this->form->bind($this->{$formName}, $request->getFiles($formName));
         if ($this->form->isValid()) {
             $this->user_list = UserPeer::searchUsers($this->form->getValue('login'), $this->form->getValue('family_name'), $this->form->getValue('surname'), $this->form->getValue('usergroupsAsLeader'), $this->form->getValue('usergroupsAsMember'), $this->form->getValue('activities'), $this->form->getValue('is_active'), $this->form->getValue('card_number'), strtotime($this->form->getValue('begin_date')), strtotime($this->form->getValue('end_date')), $this->form->getValue('email_address'), $this->form->getValue('address'), $this->form->getValue('phone_number'), $c);
             $this->count = count($this->user_list);
             $this->user_list = array_slice($this->user_list, $this->offset, $this->limit);
         } else {
             $this->setTemplate('search');
         }
     } else {
         $c->setOffset($this->offset);
         if ($this->limit >= 0) {
             $c->setLimit($this->limit);
         }
         $this->filtered = false;
         $this->user_list = UserPeer::doSelectMembers($c);
         $this->count = UserPeer::doCountMembers(new Criteria());
     }
     if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) {
         $this->forward404('Invalid offset/count values.');
     }
 }
示例#6
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new RoomSearchForm();
     $formName = $this->form->getName();
     $this->step = sfConfig::get('app_max_rooms_on_roomlist');
     $this->getUser()->syncParameters($this, 'room', 'index', array('offset', 'limit', $this->form->getName(), 'sort_column', 'sort_direction'), $request);
     if (is_null($this->sort_column)) {
         $this->sort_column = 'name';
         $this->sort_direction = 'up';
     }
     if (is_null($this->offset)) {
         $this->offset = 0;
     }
     if (is_null($this->limit) || $this->limit <= 0) {
         $this->limit = $this->step;
     }
     $c = new Criteria();
     SortCriteria::addSortCriteria($c, $this->sort_column, RoomPeer::getSortAliases(), $this->sort_direction);
     if (!is_null($this->{$formName})) {
         $this->filtered = true;
         $this->form->bind($this->{$formName}, $request->getFiles($formName));
         if ($this->form->isValid()) {
             $this->room_list = RoomPeer::searchRooms($this->form->getValue('Activity_id'), $this->form->getValue('is_active'), $this->form->getValue('namePattern'), $this->form->getValue('capacity'), $this->form->getValue('addressPattern'), $this->form->getValue('descriptionPattern'), $this->form->getFeaturesFieldsValues(), $c);
             $this->count = count($this->room_list);
             $this->room_list = array_slice($this->room_list, $this->offset, $this->limit);
         } else {
             $this->setTemplate('search');
         }
     } else {
         $c->setOffset($this->offset);
         if ($this->limit >= 0) {
             $c->setLimit($this->limit);
         }
         $this->filtered = false;
         $this->room_list = RoomPeer::doSelect($c);
         $this->count = RoomPeer::doCount(new Criteria());
     }
     if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) {
         $this->forward404('Invalid offset/count values.');
     }
 }
示例#7
0
 public function executeIndex(sfWebRequest $request)
 {
     $i18n = sfContext::getInstance()->getI18N();
     // Disable CSRF protection
     $this->form = new ReportingForm(array(), array(), false);
     $formName = $this->form->getName();
     $this->step = sfConfig::get('app_max_reservations_on_reporting');
     $this->getUser()->syncParameters($this, 'reporting', 'index', array('offset', 'limit', $formName, 'sort_column', 'sort_direction'), $request);
     if (is_null($this->sort_column)) {
         $this->sort_column = 'date';
         $this->sort_direction = 'up';
     }
     if (is_null($this->offset)) {
         $this->offset = 0;
     }
     if (is_null($this->limit) || $this->limit <= 0) {
         $this->limit = $this->step;
     }
     $c = new Criteria();
     SortCriteria::addSortCriteria($c, $this->sort_column, ReservationPeer::getSortAliases(), $this->sort_direction);
     $this->filtered = false;
     if (!is_null($this->{$formName})) {
         $this->filtered = true;
         $this->form->bind($this->{$formName}, $request->getFiles($formName));
         if ($this->form->isValid()) {
             $this->reservation_list = ReservationPeer::report($this->form->getValue('users'), $this->form->getValue('usergroups'), $this->form->getValue('activities'), $this->form->getValue('zones'), $this->form->getValue('rooms'), strtotime($this->form->getValue('begin_date')), strtotime($this->form->getValue('end_date')), $c);
             $this->count = count($this->reservation_list);
             $this->entire_reservation_list = $this->reservation_list;
             $this->reservation_list = array_slice($this->reservation_list, $this->offset, $this->limit);
         } else {
             $this->count = 0;
             $this->reservation_list = array();
         }
     } else {
         $this->count = 0;
         $this->reservation_list = array();
     }
     if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) {
         $this->forward404('Invalid offset/count values.');
     }
     if (!is_null($export = $request->getParameter('export'))) {
         $this->forward404Unless(in_array($export, array('csv', 'pdf')), sprintf('Unhandled value "%s" for export', $export));
         sfConfig::set('sf_web_debug', false);
         $activity_name = ConfigurationHelper::getParameter('Rename', 'activity_label');
         if (empty($activity_name)) {
             $activity_name = $i18n->__('Activity');
         }
         $free_field_1_name = ConfigurationHelper::getParameter('Rename', 'reservation_custom_field_1');
         $free_field_2_name = ConfigurationHelper::getParameter('Rename', 'reservation_custom_field_2');
         $free_field_3_name = ConfigurationHelper::getParameter('Rename', 'reservation_custom_field_3');
         $this->all_rows = array();
         $fields = $this->form->getValue('fields');
         foreach ($this->entire_reservation_list as $reservation) {
             //If there's is a temporary group, we modify the name to display "Perso. (first user, ...)"
             $resa_group_name = null;
             $ug = $reservation->getUsergroup();
             if (!is_null($ug)) {
                 $resa_group_name = $ug->getName();
             }
             $this->all_rows[] = array();
             end($this->all_rows);
             // Check which field we need to display.
             foreach ($fields as $field_id) {
                 // See lib\form\ReportingForm.class.php for indexes
                 switch ($field_id) {
                     case 0:
                         $this->all_rows[key($this->all_rows)][] = array($i18n->__('Date'), $reservation->getDate());
                         break;
                     case 1:
                         $this->all_rows[key($this->all_rows)][] = array($i18n->__('User'), $reservation->getUser()->getFullName());
                         break;
                     case 2:
                         $this->all_rows[key($this->all_rows)][] = array($activity_name, $reservation->getActivity()->getName());
                         break;
                     case 3:
                         $this->all_rows[key($this->all_rows)][] = array($i18n->__('Duration'), number_format($reservation->getDuration()));
                         break;
                     case 4:
                         $this->all_rows[key($this->all_rows)][] = array($i18n->__('Room'), $reservation->getRoomprofile()->getRoom()->getName());
                         break;
                     case 5:
                         $this->all_rows[key($this->all_rows)][] = array($i18n->__('Reason'), !is_null($reservation->getReservationreason()) ? $reservation->getReservationreason()->getName() : null);
                         break;
                     case 6:
                         $this->all_rows[key($this->all_rows)][] = array($i18n->__('Comment'), $reservation->getComment());
                         break;
                     case 7:
                         $this->all_rows[key($this->all_rows)][] = array($i18n->__('Group'), $resa_group_name);
                         break;
                     case 8:
                         $this->all_rows[key($this->all_rows)][] = array($i18n->__('Members count'), number_format($reservation->getMembersCount()));
                         break;
                     case 9:
                         $this->all_rows[key($this->all_rows)][] = array($i18n->__('Guests count'), number_format($reservation->getGuestsCount()));
                         break;
                     case 10:
                         $this->all_rows[key($this->all_rows)][] = array($i18n->__('Status'), number_format($reservation->getStatus()));
                         break;
                     case 11:
                         $this->all_rows[key($this->all_rows)][] = array($i18n->__('Price'), number_format($reservation->getPrice()));
                         break;
                     case 12:
                         $valuedFeaturesArray = $reservation->getRoomprofile()->getRoom()->getValuedFeaturesArray();
                         $concat = '';
                         foreach ($valuedFeaturesArray as $featureName => $values) {
                             $concat .= $featureName . '=' . $values . ' | ';
                         }
                         $concat = rtrim($concat, ' | ');
                         $this->all_rows[key($this->all_rows)][] = array($i18n->__('Features'), $concat);
                         break;
                     case 90:
                         $this->all_rows[key($this->all_rows)][] = array($free_field_1_name, $reservation->getCustom1());
                         break;
                     case 91:
                         $this->all_rows[key($this->all_rows)][] = array($free_field_2_name, $reservation->getCustom2());
                         break;
                     case 92:
                         $this->all_rows[key($this->all_rows)][] = array($free_field_3_name, $reservation->getCustom3());
                         break;
                 }
             }
         }
         if ($export == 'csv') {
             $this->setLayout(false);
             $this->getResponse()->clearHttpHeaders();
             $this->getResponse()->setHttpHeader('Pragma: public', true);
             $this->getResponse()->setHttpHeader('Content-disposition', sprintf('attachment; filename="%s"', 'reporting-' . date('Y-m-d') . '.csv'));
             $this->getResponse()->setContentType('text/csv; charset=utf-8');
             $this->getResponse()->sendHttpHeaders();
             $this->setTemplate('exportCSV');
         } else {
             if ($export == 'pdf') {
                 $config = sfTCPDFPluginConfigHandler::loadConfig();
                 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
                 // set document information
                 $pdf->SetCreator(PDF_CREATOR);
                 $pdf->SetAuthor('ISLOG Tempos');
                 $pdf->SetTitle('Tempos report export');
                 $pdf->SetSubject('Tempos export');
                 $pdf->SetKeywords('Tempos, report, ISLOG');
                 $pdf->SetHeaderData(sfConfig::get('app_has_logo'), PDF_HEADER_LOGO_WIDTH, $i18n->__('Report'), sprintf($i18n->__('Usage report from %s to %s'), $this->form->getValue('begin_date'), $this->form->getValue('end_date')));
                 $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
                 $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
                 $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
                 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
                 $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
                 $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
                 $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
                 $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
                 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
                 $pdf->setFontSubsetting(true);
                 $pdf->SetFont('dejavusans', '', 10, '', true);
                 $pdf->AddPage();
                 $this->writeHtmlTable($pdf, $this->all_rows);
                 $pdf->Output('reporting-' . date('Y-m-d') . '.pdf', 'I');
                 exit;
             }
         }
     }
 }
示例#8
0
 public function executeOverallIndex(sfWebRequest $request)
 {
     $this->handleZoneParameters($request);
     $this->form = new RoomSearchForm($this->activity);
     $this->form->setIsActive(true);
     $formName = $this->form->getName();
     $this->getUser()->syncParameters($this, 'home', 'overallIndex', array($formName, 'displayPeriod'), $request);
     $this->getUser()->syncParameters($this, 'general', 'index', array('date'), $request);
     if (is_null($this->date)) {
         $this->date = time();
     } else {
         $this->date = strtotime($this->date);
     }
     if (is_null($this->displayPeriod)) {
         $this->displayPeriod = 'month';
     } else {
         $this->forward404Unless(in_array($this->displayPeriod, array('week', 'month')), sprintf('"%s" is not a valid value for displayPeriod', $this->displayPeriod));
     }
     $this->today = false;
     if ($this->displayPeriod == 'month') {
         if (date('m', $this->date) == date('m')) {
             $this->today = true;
         }
     } else {
         if (date('W', $this->date) == date('W')) {
             $this->today = true;
         }
     }
     $c = new Criteria();
     SortCriteria::addSortCriteria($c, $this->sort_column, RoomPeer::getSortAliases(), $this->sort_direction);
     $this->filtered = false;
     if (!is_null($this->{$formName})) {
         $this->form->bind($this->{$formName}, $request->getFiles($formName));
         if ($this->form->isValid()) {
             $this->filtered = true;
             $this->room_list = RoomPeer::searchRooms($this->activity->getId(), true, $this->form->getValue('namePattern'), $this->form->getValue('capacity'), $this->form->getValue('addressPattern'), $this->form->getValue('descriptionPattern'), $this->form->getFeaturesFieldsValues(), $c);
         }
     }
     if (!$this->filtered) {
         $this->room_list = RoomPeer::searchRooms($this->activity->getId(), true, null, null, null, null, null, $c);
         $this->count = 0;
     }
     $this->room_list = $this->person->filterAccessibleRooms($this->room_list);
     $this->count = count($this->room_list);
     $this->availability = RoomPeer::getAvailability($this->room_list, $this->activity->getId(), $this->person, $this->displayPeriod, $this->date);
     $this->checkFeatures();
 }
示例#9
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new ReservationDeleteForm(array(), array(), false);
     $formName = $this->form->getName();
     $this->formConfirm = new ReservationDeleteConfirmForm(array(), array(), false);
     $nameConfirm = $this->formConfirm->getName();
     $this->getUser()->syncParameters($this, 'reservationDelete', 'index', array('offset', 'limit', $formName, 'sort_column', 'sort_direction'), $request);
     $this->step = sfConfig::get('app_max_reservations_on_reporting');
     $search = $request->getPostParameter($nameConfirm);
     $deletion_choice = $search['deletion_choices'];
     $this->displayInfo = true;
     if ($request->getParameter('id') != null) {
         $this->forward404Unless($reservation = ReservationPeer::retrieveByPk($request->getParameter('id')), sprintf('Object reservation does not exist (%s).', $request->getParameter('id')));
         $this->reservationId = $request->getParameter('id');
         $this->formConfirm = new ReservationDeleteConfirmForm(array(), array(), false);
         $nameConfirm = $this->formConfirm->getName();
         $search = $request->getPostParameter($nameConfirm);
         $deletion_choice = $search['deletion_choices'];
     } else {
         $this->reservationId = null;
     }
     if (is_null($this->sort_column)) {
         $this->sort_column = 'date';
         $this->sort_direction = 'up';
     }
     if (is_null($this->offset)) {
         $this->offset = 0;
     }
     if (is_null($this->limit) || $this->limit <= 0) {
         $this->limit = $this->step;
     }
     $c = new Criteria();
     SortCriteria::addSortCriteria($c, $this->sort_column, ReservationPeer::getSortAliases(), $this->sort_direction);
     if ($request->getParameter('id') != null) {
         $this->forward404Unless($reservation = ReservationPeer::retrieveByPk($request->getParameter('id')), sprintf('Object reservation does not exist (%s).', $request->getParameter('id')));
         switch ($deletion_choice) {
             case 'this':
                 $room_id = $reservation->getRoomProfile()->getRoomId();
                 if (!$this->isAdmin() || !$reservation->isEditable()) {
                     if (!$this->getUser()->canDeleteReservation($reservation)) {
                         $this->getUser()->setFlash('deleteError', true);
                         $this->redirect('reservation/index?roomId=' . $room_id);
                     }
                 }
                 $this->deleteAReservation($reservation);
                 $this->redirect('reservation/index?roomId=' . $room_id);
                 break;
             case 'next':
                 $this->reservation_list = ReservationPeer::reportRepeatNext($reservation);
                 break;
             case 'previous':
                 $this->reservation_list = ReservationPeer::reportRepeatPrevious($reservation);
                 break;
             case 'all':
                 $this->reservation_list = ReservationPeer::reportRepeatAll($reservation);
                 break;
         }
     }
     $this->getUser()->syncParameters($this, 'reservationDelete', 'index', array('offset', 'limit', $formName, 'sort_column', 'sort_direction'), $request);
     $this->filtered = false;
     if (!is_null($this->{$formName}) && is_null($request->getParameter('id'))) {
         $this->filtered = true;
         $this->form->bind($this->{$formName}, $request->getFiles($formName));
         if ($this->form->isValid()) {
             $this->reservation_list = ReservationPeer::reportTime($this->form->getValue('activity'), $this->form->getValue('rooms'), strtotime($this->form->getValue('start_date')), strtotime($this->form->getValue('end_date')), strtotime($this->form->getValue('start_hour')), strtotime($this->form->getValue('end_hour')), $this->form->getValue('periodicity'), $this->form->getValue('number'), $c);
             //
             $this->getUser()->setAttribute('stop_on_error_tmp', $this->form->getValue('stop_on_error'));
             // -----------------------------------
             $this->count = count($this->reservation_list);
             $this->reservation_list = array_slice($this->reservation_list, $this->offset, $this->limit);
         } else {
             $this->count = 0;
             $this->reservation_list = array();
         }
     } else {
         if (!isset($this->reservation_list)) {
             $this->count = 0;
             $this->reservation_list = array();
         }
         $this->displayInfo = false;
     }
     //
     $this->getUser()->setAttribute('list_delete_tmp', $this->reservation_list);
     // -----------------------------------
     if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) {
         $this->forward404('Invalid offset/count values.');
     }
 }