Esempio n. 1
0
 public function mailing_list($year = "_")
 {
     if ($year == "_" || $year == Year::current_year()->year) {
         $year_alias = "";
     } else {
         $year_alias = '.' . Year::where('year', '=', $year)->select('alias')->first()->alias;
     }
     return $this->alias . $year_alias . '@cserevue.org.au';
 }
Esempio n. 2
0
 public function get_user_status($user_id)
 {
     $user = DB::table('team_user')->where('team_id', '=', $this->id)->where('user_id', '=', $user_id)->where('year_id', '=', Year::current_year()->id)->first();
     $status = '';
     if ($user != NULL) {
         $status .= $user->status;
     }
     return $status;
 }
Esempio n. 3
0
 public function get_manage($id)
 {
     $executive = Executive::find($id);
     $year = Year::current_year();
     $users = array();
     foreach ($year->users as $a) {
         $users[] = $a->profile->full_name;
     }
     return View::make('executives.manage')->with('executive', $executive)->with('users', $users)->with('year', $year);
 }
 public function post_edit()
 {
     $input = Input::get();
     $camp = CampSetting::where('year_id', '=', Year::current_year()->id);
     $camp_reg = DB::table('camp_registrations')->where('camp_setting_id', '=', $camp->first()->id)->where('user_id', '=', Auth::user()->id);
     $rules = array('id' => 'required', 'car_places' => 'integer');
     $validation = Validator::make($input, $rules);
     if ($validation->passes()) {
         $camp_reg->update(Input::except('_token'));
         return Redirect::to('rms/camp/registrations/edit')->with('success', 'Successfully Edited registration for Camp');
     } else {
         return Redirect::to('rms/camp/registrations/edit')->withErrors($validation)->withInput();
     }
 }
Esempio n. 5
0
 public function get_admin($current = 'current')
 {
     if ($current == 'current') {
         $year = Year::current_year();
     } else {
         $year = Year::find($current);
     }
     if ($year) {
         $orders = MerchOrder::where('year_id', '=', $year->id)->get();
         $items = MerchItem::current_merch();
         $sizes = array('8' => '8', '10' => '10', '12' => '12', '14' => '14', 'XS' => 'XS', 'S' => 'S', 'M' => 'M', 'L' => 'L', 'XL' => 'XL', 'XXL' => 'XXL');
         return View::make('merch.orders.admin')->with('orders', $orders)->with('items', $items)->with('sizes', $sizes)->with('year', $year);
     } else {
         return "Invalid ID";
     }
 }
Esempio n. 6
0
 public function get_search($format = '.html')
 {
     $input = Input::get();
     $years = Year::lists('year', 'id');
     if (array_key_exists('q', $input) && $input['q'] != '') {
         $q = $input['q'];
         $year_id = $input['y'];
         $year = Year::find($year_id)->year;
         if (strlen($q) > 8) {
             $phone_query = $q;
         } else {
             $phone_query = 'NOTAPHONENUMBER';
         }
         if (preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9+-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,})\$/i", $q)) {
             $email_query = $q;
         } else {
             $email_query = 'NOTANEMAILADDRESS';
         }
         $results = User::join('profiles', 'users.id', '=', 'profiles.user_id')->join('user_year', 'users.id', '=', 'user_year.user_id')->where('year_id', '=', $year_id)->where(function ($query) use($q, $email_query, $phone_query) {
             $query->orWhere('full_name', 'LIKE', '%' . $q . '%');
             $query->orWhere('display_name', 'LIKE', '%' . $q . '%');
             $query->orWhere('email', 'LIKE', '%' . $email_query . '%');
             $query->orWhere('phone', 'LIKE', '%' . $phone_query . '%');
         })->get();
     } else {
         $q = '';
         $year = Year::current_year()->year;
         $results = array();
     }
     switch ($format) {
         case '.csv':
             return View::make('users.search_csv')->with('results', $results);
         default:
             return View::make('users.search')->with('query', $q)->with('year', $year)->with('years', $years)->with('results', $results);
     }
 }
Esempio n. 7
0
 public static function current_bundles()
 {
     return WellbeingBundle::where('year_id', '=', Year::current_year()->id);
 }
Esempio n. 8
0
 public static function current_nights()
 {
     return WellbeingNight::where('year_id', '=', Year::current_year()->id);
 }
Esempio n. 9
0
    $team_id = Request::segment(4);
    $team = Team::find($team_id);
    if (!Auth::User()->admin && !Auth::User()->is_currently_part_of_exec() && $team->privacy == 1 && !Auth::User()->is_part_of_team(Year::current_year()->id, $team_id)) {
        return Redirect::to('rms/account')->with('warning', 'You are not permitted access. Please login as an admin');
    }
});
Route::filter('manage_team', function () {
    $team_id = Request::segment(4);
    if (!Auth::User()->can_manage_team($team_id)) {
        return Redirect::to('rms/account')->with('warning', 'You are not permitted access. Please login as an admin');
    }
});
Route::filter('signed_up_for_camp', function () {
    if (Auth::user()->has_signed_up_for_camp()) {
        return Redirect::to('rms/camp/registrations/edit');
    }
});
Route::filter('orgs', function () {
    $on_orgs = false;
    $teams = DB::table('teams')->where('privacy', '=', '0')->lists('id');
    foreach ($teams as $team) {
        $count = DB::table('team_user')->where('team_id', '=', $team)->where('year_id', '=', Year::current_year()->id)->where('status', '=', 'head')->where('user_id', '=', Auth::User()->id)->get();
        if (count($count) != 0) {
            $on_orgs = true;
            break;
        }
    }
    if (!Auth::User()->admin && !Auth::User()->is_currently_part_of_exec() && !$on_orgs) {
        return Redirect::to('rms/account')->with('warning', 'You are not permitted access. Please login as an admin');
    }
});
Esempio n. 10
0
 public function get_delete()
 {
     $id = Auth::User()->wellbeing_orders_year(Year::current_year()->id)->first()->id;
     $order = WellbeingOrder::find($id);
     $order->nights()->detach();
     $order->bundles()->detach();
     $order->delete();
     return Redirect::to('rms/wellbeing/orders/')->with('success', 'Successfully Cancelled Order');
 }
Esempio n. 11
0
 public function getSponsors()
 {
     $year = Year::current_year();
     $sponsors = $year->sponsors()->orderBy('sponsor_year.sponsor_level', 'desc')->get();
     return View::make('home.sponsors')->with('year', $year)->with('sponsors', $sponsors);
 }
Esempio n. 12
0
 public function can_manage_team($team_id)
 {
     if ($this->admin || $this->is_currently_part_of_exec()) {
         return true;
     } else {
         $team = Team::find($team_id);
         $result = $team->users()->where('users.id', '=', $this->id)->where('status', '=', 'head')->where('year_id', '=', Year::current_year()->id)->get();
         return count($result) != 0;
     }
 }
Esempio n. 13
0
 public static function current_orders()
 {
     return WellbeingOrder::where('year_id', '=', Year::current_year()->id);
 }
Esempio n. 14
0
 public function post_renew()
 {
     $user = Auth::user();
     $year = Year::current_year();
     if ($user->needs_to_renew) {
         $user->years()->attach($year->id);
         return Redirect::to('rms/account')->with('success', 'You succesfully renewed');
     } else {
         return Redirect::to('rms/account')->with('warning', 'You didn\'t need to renew');
     }
 }
Esempio n. 15
0
 public function get_member_leave_ajax($team_id)
 {
     $user = Auth::User();
     $user->teams()->where('team_id', '=', $team_id)->where('year_id', '=', Year::current_year()->id)->first()->pivot->delete();
     return View::make('teams.index.ajax')->with('data', 'Leave Successful')->with('state', 'success');
 }