Example #1
0
 public function buildMemberships()
 {
     $items = \Own\Bus\Membership\Data::loadAll();
     $memberships = \Own\Bus\PlayerMembership\Data::loadAllByPlayerId($this->getModel()->getId());
     $selectedValues = [];
     foreach ($memberships as $membership) {
         $selectedValues[] = $membership->getMembershipId();
     }
     return Util\Form::buildCheckboxList('membership' . $this->unique, $items, 'id', 'title', $selectedValues);
 }
Example #2
0
 public function status(\Own\Bus\Player\Model $player)
 {
     $signedUser = $this->app->user();
     if (isset($_POST['sign-out'])) {
         \Rebond\Core\UserSecurity\Service::signOut($signedUser);
     }
     $tpl = new Util\Template(Util\Template::MODULE, ['app', 'User']);
     if (Util\Auth::isAuth($signedUser)) {
         $tpl->set('user', $signedUser);
         $tpl->set('player', $player);
         $today = new Util\DateTime();
         $options = [];
         $options['join'][] = 'bus_player_membership player_membership ON player_membership.membership_id = membership.id';
         $options['where'][] = ['player_membership.player_id = ?', $signedUser->getId()];
         $options['where'][] = ['membership.end_date >= ?', $today->format('date')];
         $memberships = \Own\Bus\Membership\Data::loadAll($options);
         $tpl->set('memberships', $memberships);
     }
     return $tpl->render('status');
 }
Example #3
0
File: Own.php Project: vincium/resa
 public function membership()
 {
     Util\Auth::isAdminAuthorized($this->signedUser, 'member', true, '/');
     $this->setTpl();
     $membershipId = Util\Converter::toInt('id');
     if (!isset($membershipId)) {
         Util\Session::adminError('item.not.found', [Util\Lang::lang('membership'), $membershipId], '/own/memberships');
     }
     $membership = \Own\Bus\Membership\Data::loadById($membershipId, true);
     $membershipForm = new \Own\Bus\Membership\Form($membership);
     // action
     $save = Util\Converter::toString('save', 'post');
     $courtIds = Util\Converter::toArray('court', 'post');
     if (isset($save)) {
         if ($membershipForm->setFromPost()->validate()->isValid()) {
             \Own\Bus\MembershipCourt\Data::deleteByMembershipId($membership->getId());
             $newCourts = [];
             if (isset($courtIds)) {
                 foreach ($courtIds as $courtId) {
                     $membershipCourt = new \Own\Bus\MembershipCourt\Model();
                     $membershipCourt->setMembershipId($membership->getId());
                     $membershipCourt->setCourtId($courtId);
                     $newCourts[] = $membershipCourt;
                 }
             }
             \Own\Bus\MembershipCourt\Data::saveAll($newCourts);
             $membership->save();
             Util\Session::adminSuccess('saved', '/own/memberships');
         } else {
             Util\Session::set('adminError', $membershipForm->getValidation()->getMessage());
         }
     }
     $tplEditor = new Util\Template(Util\Template::SITE, ['admin']);
     $tplEditor->set('item', $membershipForm);
     return $this->response('tpl-default', ['title' => Util\Lang::lang('own'), 'jsLauncher' => 'own'], 'layout-1-col', ['column1' => $tplEditor->render('membership-editor')]);
 }