示例#1
0
 public function putVerify($groupId)
 {
     $this->beforeFilter('admin');
     $newGroup = (object) Input::all();
     if (!Group::isValidStatus($newGroup->status)) {
         throw new \Exception("Invalid value for verify request");
     }
     $group = Group::where('id', '=', $groupId)->first();
     if (!$group) {
         throw new \Exception("Invalid Group");
     }
     $group->status = $newGroup->status;
     DB::transaction(function () use($group) {
         $group->save();
         switch ($group->status) {
             case Group::STATUS_ACTIVE:
                 $group->createRbacRules();
                 break;
             case Group::STATUS_PENDING:
                 $group->destroyRbacRules();
                 break;
         }
     });
     return Response::json($group);
 }
示例#2
0
 public function portfolioItem($groupLink, $id)
 {
     $group = Group::where('link', '=', $groupLink)->firstOrFail();
     $portfolios = PortfolioRepository::byGroup($groupLink);
     $view = Agent::isTablet() || Request::has('t') ? 'tablet.portfolio_item' : (Agent::isMobile() || Request::has('m') ? 'mobile.portfolio_item' : 'index.portfolio_item');
     return view($view, array('group' => $group, 'portfolios' => $portfolios, 'id' => $id, 'title' => $group->title . ' | TWIGA'));
 }
 public function run()
 {
     $adminEmail = Config::get('madison.seeder.admin_email');
     $adminPassword = Config::get('madison.seeder.admin_password');
     // Login as admin to create docs
     $credentials = array('email' => $adminEmail, 'password' => $adminPassword);
     Auth::attempt($credentials);
     $admin = Auth::user();
     $group = Group::where('id', '=', 1)->first();
     // Create first doc
     $docSeedPath = app_path() . '/database/seeds/example.md';
     if (file_exists($docSeedPath)) {
         $content = file_get_contents($docSeedPath);
     } else {
         $content = "New Document Content";
     }
     $docOptions = array('title' => 'Example Document', 'content' => $content, 'sponsor' => $group->id, 'publish_state' => 'published', 'sponsorType' => Doc::SPONSOR_TYPE_GROUP);
     $document = Doc::createEmptyDocument($docOptions);
     //Set first doc as featured doc
     $featuredSetting = new Setting();
     $featuredSetting->meta_key = 'featured-doc';
     $featuredSetting->meta_value = $document->id;
     $featuredSetting->save();
     // Create second doc
     $docSeedPath = app_path() . '/database/seeds/example2.md';
     if (file_exists($docSeedPath)) {
         $content = file_get_contents($docSeedPath);
     } else {
         $content = "New Document Content";
     }
     $docOptions = array('title' => 'Second Example Document', 'sponsor' => $group->id, 'publish_state' => 'published', 'sponsorType' => Doc::SPONSOR_TYPE_GROUP);
     $document = Doc::createEmptyDocument($docOptions);
 }
 public function run()
 {
     $person = DB::table('people')->where('first_name', 'James')->where('last_name', 'Sample')->first();
     $company = Company::where('name', 'Sample Company')->first();
     $group_type = GroupType::where('name', 'employee')->first();
     $group = Group::where('name', 'e80-helpdesk')->first();
     if (isset($person)) {
         CompanyPerson::create(['person_id' => $person->id, 'company_id' => $company->id, 'group_type_id' => $group_type->id, 'group_id' => $group->id]);
     }
 }
示例#5
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($society)
 {
     if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) {
         $data['society'] = $society;
         $data['groups'] = Group::where('society_id', '=', $society)->orderBy('subcategory')->orderBy('groupname')->get();
         return View::make('groups.index', $data);
     } else {
         return View::make("shared.unauthorised");
     }
 }
示例#6
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @returnpResponse
  */
 public function edit($society, $hid, $id)
 {
     if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) {
         $pastoral = Pastoral::find($id);
         $pgid = Helpers::societySetting('group_pastors', $society);
         $addressee = Household::find($pastoral->household_id)->addressee;
         $pastorgroup = Group::where('id', '=', $pgid)->with('individual')->get();
         $pastors = array();
         foreach ($pastorgroup[0]->individual as $user) {
             $pastors[$user->id] = $user->surname . ", " . $user->firstname;
         }
         return View::make('pastorals.edit')->with('pastoral', $pastoral)->with('addressee', $addressee)->with('pastors', $pastors)->with('society', $society);
     } else {
         return view('shared.unauthorised');
     }
 }
示例#7
0
 /**
  * Scope a query to only include users that belong to a specific group
  *
  * @param $query
  * @param $group
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeFromGroup($query, $group)
 {
     if (is_string($group)) {
         $group = Models\Group::where('name', '=', $group)->first();
     }
     return $query->whereHas('groups', function ($q) use($group) {
         $q->where('name', $group->name);
     });
 }
示例#8
0
 public function dashboard($society)
 {
     $data['total_indivs'] = Individual::socindiv($society)->count();
     $data['total_households'] = Household::where('society_id', '=', $society)->count();
     $data['missing_gps'] = Household::where('society_id', '=', $society)->where('latitude', '=', null)->count();
     $data['missing_hc'] = Household::where('society_id', '=', $society)->where('householdcell', '=', '')->count();
     $data['missing_pa'] = Household::where('society_id', '=', $society)->where('addr1', '=', '')->count();
     $data['members'] = Individual::socindiv($society)->members()->count();
     $data['children'] = Individual::socindiv($society)->children()->count();
     $totaged = Individual::socindiv($society)->members()->get();
     $totnum = 0;
     $totyr = 0;
     foreach ($totaged as $thisa) {
         if ($thisa->age) {
             $totyr = $totyr + $thisa->age;
             $totnum++;
         }
     }
     $data['missing_bd'] = Individual::socindiv($society)->members()->where('birthdate', '<', '1901-01-01')->count();
     if ($totnum) {
         $data['avg_age'] = round($totyr / $totnum, 1);
     }
     $data['fellowship'] = Individual::socindiv($society)->members()->whereHas('group', function ($query) {
         $query->where('grouptype', '=', 'fellowship');
     })->count();
     $data['service'] = Individual::socindiv($society)->members()->whereHas('group', function ($query) {
         $query->where('grouptype', '=', 'service');
     })->count();
     $data['worship'] = Individual::socindiv($society)->members()->whereHas('group', function ($query) {
         $query->where('grouptype', '=', 'worship');
     })->count();
     $data['learning'] = Individual::socindiv($society)->members()->whereHas('group', function ($query) {
         $query->where('grouptype', '=', 'learning');
     })->count();
     $data['groups'] = Group::where('society_id', '=', $society)->where('statistics', '=', 'yes')->orderBy('groupname')->get();
     $data['society'] = $society;
     //$data['analyticsData'] = LaravelAnalytics::getVisitorsAndPageViews(7);
     return view('statistics.dashboard', $data);
 }
示例#9
0
 public function installSave()
 {
     try {
         //Getting our input from the Input library
         $input = Input::all();
         //Rules
         $rules = array('password' => 'required', 'email' => 'required');
         // Validate Rules Input Fields
         $validation = Validator::make($input, $rules);
         if ($validation->fails()) {
             return Redirect::to('install')->with_errors($validation);
         }
         if (Schema::hasTable('users') == false) {
             Schema::create('users', function ($table) {
                 $table->increments('id');
                 $table->string('email');
                 $table->string('password');
                 $table->text('permissions')->nullable();
                 $table->boolean('activated')->default(0);
                 $table->string('activation_code')->nullable();
                 $table->timestamp('activated_at')->nullable();
                 $table->timestamp('last_login')->nullable();
                 $table->string('persist_code')->nullable();
                 $table->string('reset_password_code')->nullable();
                 $table->string('first_name')->nullable();
                 $table->string('last_name')->nullable();
                 $table->text('remember_token')->nullable();
                 $table->timestamps();
                 // We'll need to ensure that MySQL uses the InnoDB engine to
                 // support the indexes, other engines aren't affected.
                 // $table->engine = 'InnoDB';
                 $table->unique('email');
                 $table->index('activation_code');
                 $table->index('reset_password_code');
             });
         }
         if (Schema::hasTable('groups') == false) {
             Schema::create('groups', function ($table) {
                 $table->increments('id');
                 $table->string('name');
                 $table->text('permissions')->nullable();
                 $table->timestamps();
                 // We'll need to ensure that MySQL uses the InnoDB engine to
                 // support the indexes, other engines aren't affected.
                 // $table->engine = 'InnoDB';
                 $table->unique('name');
             });
         }
         if (Schema::hasTable('users_groups') == false) {
             Schema::create('users_groups', function ($table) {
                 $table->integer('user_id')->unsigned();
                 $table->integer('group_id')->unsigned();
                 // We'll need to ensure that MySQL uses the InnoDB engine to
                 // support the indexes, other engines aren't affected.
                 // $table->engine = 'InnoDB';
                 $table->primary(array('user_id', 'group_id'));
             });
         }
         /* Userpermissions */
         if (Schema::hasTable('userspermissions') == false) {
             Schema::create('userspermissions', function ($table) {
                 $table->increments('id');
                 $table->text('clients')->nullable();
                 $table->text('jobs')->nullable();
             });
         }
         if (Schema::hasTable('groupspermissions') == false) {
             /* Groupspermissions */
             Schema::create('groupspermissions', function ($table) {
                 $table->increments('id');
                 $table->text('clients')->nullable();
                 $table->text('jobs')->nullable();
             });
         }
         if (Schema::hasTable('throttle') == false) {
             Schema::create('throttle', function ($table) {
                 $table->increments('id');
                 $table->integer('user_id')->unsigned();
                 $table->string('ip_address')->nullable();
                 $table->integer('attempts')->default(0);
                 $table->boolean('suspended')->default(0);
                 $table->boolean('banned')->default(0);
                 $table->timestamp('last_attempt_at')->nullable();
                 $table->timestamp('suspended_at')->nullable();
                 $table->timestamp('banned_at')->nullable();
                 // We'll need to ensure that MySQL uses the InnoDB engine to
                 // support the indexes, other engines aren't affected.
                 //$table->engine = 'InnoDB';
             });
         }
         // Create rules table
         /* Schema::create(Config::get('sentry::sentry.table.rules'), function ($table) {
                $table->on(Config::get('sentry::sentry.db_instance'));
                $table->increments('id')->unsigned();
                $table->string('rule')->unique();
                $table->string('description')->nullable();
                $table->create();
            });*/
         /* Settings Table */
         if (!Schema::hasTable('settings')) {
             Schema::create('settings', function ($table) {
                 $table->integer('id')->nullable();
                 $table->boolean('ldapon');
                 $table->string('ldapserver')->nullable();
                 $table->string('ldapdomain')->nullable();
                 $table->string('ldapuser')->nullable();
                 $table->string('ldappassword')->nullable();
                 $table->string('ldapport')->nullable();
                 $table->string('servername')->nullable();
                 $table->string('adminemail')->nullable();
                 $table->string('logo')->nullable();
                 $table->string('confdir')->nullable();
             });
         }
         if (!Schema::hasTable('filessearch')) {
             Schema::create('filessearch', function ($table) {
                 $table->increments('id');
                 $table->integer('jobid')->nullable();
                 $table->string('path')->nullable();
                 $table->string('filename')->nullable();
             });
         }
         /// Configuration Bacula Tables /////
         if (!Schema::hasTable('cfgconsole')) {
             /* cfgFileSetExclude */
             Schema::create('cfgconsole', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('Password')->nullable();
                 $table->string('JobACL')->nullable();
                 $table->string('ClientACL')->nullable();
                 $table->string('StorageACL')->nullable();
                 $table->string('ScheduleACL')->nullable();
                 $table->string('PoolACL')->nullable();
                 $table->string('FileSetACL')->nullable();
                 $table->string('CatalogACL')->nullable();
                 $table->string('CommandACL')->nullable();
                 $table->string('WhereACL')->nullable();
             });
         }
         if (!Schema::hasTable('cfgmessages')) {
             /* cfgFileSetExclude */
             Schema::create('cfgmessages', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('MailCommand')->nullable();
                 $table->string('OperatorCommand')->nullable();
                 $table->string('destination')->nullable();
                 $table->string('append')->nullable();
                 $table->string('operator')->nullable();
                 $table->string('console')->nullable();
                 $table->string('mail')->nullable();
                 $table->string('mailonerror')->nullable();
                 $table->string('catalog')->nullable();
             });
         }
         if (!Schema::hasTable('cfgfilesetexclude')) {
             /* cfgFileSetExclude */
             Schema::create('cfgfilesetexclude', function ($table) {
                 $table->increments('id');
                 $table->integer('idfileset')->nullable();
                 $table->string('file')->nullable();
             });
         }
         /* cfgFileSetInclude  */
         if (!Schema::hasTable('cfgfilesetinclude')) {
             Schema::create('cfgfilesetinclude', function ($table) {
                 $table->increments('id');
                 $table->integer('idfileset')->nullable();
                 $table->string('file')->nullable();
             });
         }
         /* cfgFileSetIncludeOptions   */
         if (!Schema::hasTable('cfgfilesetincludeoptions')) {
             Schema::create('cfgfilesetincludeoptions', function ($table) {
                 $table->increments('id');
                 $table->integer('idfileset')->nullable();
                 $table->string('option')->nullable();
                 $table->string('value')->nullable();
             });
         }
         /* cfgFileSetIncludeOptions   */
         if (!Schema::hasTable('cfgfilesetexcludeoptions')) {
             Schema::create('cfgfilesetexcludeoptions', function ($table) {
                 $table->increments('id');
                 $table->integer('idfileset')->nullable();
                 $table->string('option')->nullable();
                 $table->string('value')->nullable();
             });
         }
         /* cfgcatalog */
         if (!Schema::hasTable('cfgcatalog')) {
             Schema::create('cfgcatalog', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('DBPassword')->nullable();
                 $table->string('DBName')->nullable();
                 $table->string('DBUser')->nullable();
                 $table->string('DBSocket')->nullable();
                 $table->string('DBAddress')->nullable();
                 $table->string('DBPort')->nullable();
             });
         }
         /* cfgclient */
         if (!Schema::hasTable('cfgclient')) {
             Schema::create('cfgclient', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('Address')->nullable();
                 $table->string('FDPort')->nullable();
                 $table->string('Catalog')->nullable();
                 $table->string('Password')->nullable();
                 $table->string('FileRetention')->nullable();
                 $table->string('JobRetention')->nullable();
                 $table->string('AutoPrune')->nullable();
                 $table->string('MaximumConcurrentJobs')->nullable();
                 $table->string('Priority')->nullable();
                 $table->string('HeartbeatInterval')->nullable();
             });
         }
         /* cfgdirector */
         if (!Schema::hasTable('cfgdirector')) {
             Schema::create('cfgdirector', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('Description')->nullable();
                 $table->string('Password')->nullable();
                 $table->string('Messages')->nullable();
                 $table->string('PidDirectory')->nullable();
                 $table->string('ScriptsDirectory')->nullable();
                 $table->string('QueryFile')->nullable();
                 $table->string('HeartbeatInterval')->nullable();
                 $table->string('MaximumConcurrentJobs')->nullable();
                 $table->string('FDConnectTimeout')->nullable();
                 $table->string('SDConnectTimeout')->nullable();
                 $table->string('DirPort')->nullable();
                 $table->string('DirAddress')->nullable();
                 $table->string('DirSourceAddress')->nullable();
                 $table->string('StatisticsRetention')->nullable();
                 $table->string('MaximumConsoleConnections')->nullable();
                 $table->string('VerId')->nullable();
                 $table->string('WorkingDirectory')->nullable();
             });
         }
         /* cfgfileset */
         if (!Schema::hasTable('cfgfileset')) {
             Schema::create('cfgfileset', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('IgnoreFileSetChanges')->nullable();
                 $table->string('EnableVSS')->nullable();
             });
         }
         /* cfgfilesetexcludeoptions */
         if (!Schema::hasTable('cfgfilesetexcludeoptions')) {
             Schema::create('cfgfilesetexcludeoptions', function ($table) {
                 $table->increments('id');
                 $table->integer('idfileset')->nullable();
                 $table->string('option')->nullable();
                 $table->string('value')->nullable();
             });
         }
         /* cfgjob */
         if (!Schema::hasTable('cfgjob')) {
             Schema::create('cfgjob', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('Enabled')->nullable();
                 $table->string('Type')->nullable();
                 $table->string('Level')->nullable();
                 $table->string('Accurate')->nullable();
                 $table->string('VerifyJob')->nullable();
                 $table->string('JobDefs')->nullable();
                 $table->string('Bootstrap')->nullable();
                 $table->string('WriteBootstrap')->nullable();
                 $table->string('Client')->nullable();
                 $table->string('FileSet')->nullable();
                 $table->string('Base')->nullable();
                 $table->string('Messages')->nullable();
                 $table->string('Pool')->nullable();
                 $table->string('FullBackupPool')->nullable();
                 $table->string('MaximumBandwidth')->nullable();
                 $table->string('IncrementalBackupPool')->nullable();
                 $table->string('Storage')->nullable();
                 $table->string('DifferentialBackupPool')->nullable();
                 $table->string('Schedule')->nullable();
                 $table->string('MaxRunTime')->nullable();
                 $table->string('DifferentialMaxWaitTime')->nullable();
                 $table->string('MaxRunSchedTime')->nullable();
                 $table->string('MaxWaitTime')->nullable();
                 $table->string('MaxStartDelay')->nullable();
                 $table->string('PruneJobs')->nullable();
                 $table->string('PreferMountedVolumes')->nullable();
                 $table->string('IncrementalMaxRunTime')->nullable();
                 $table->string('PruneVolumes')->nullable();
                 $table->string('SpoolData')->nullable();
                 $table->string('RunBeforeJob')->nullable();
                 $table->string('RunAfterJob')->nullable();
                 $table->string('RunAfterFailedJob')->nullable();
                 $table->string('ClientRunBeforeJob')->nullable();
                 $table->string('ClientRunAfterJob')->nullable();
                 $table->string('RerunFailedLevels')->nullable();
                 $table->string('MaxFullInterval')->nullable();
                 $table->string('SpoolSize')->nullable();
                 $table->string('Where')->nullable();
                 $table->string('AddPrefix')->nullable();
                 $table->string('RegexWhere')->nullable();
                 $table->string('StripPrefix')->nullable();
                 $table->string('MaximumConcurrentJobs')->nullable();
                 $table->string('RescheduleInterval')->nullable();
                 $table->string('PrefixLinks')->nullable();
                 $table->string('RescheduleOnError')->nullable();
                 $table->string('Replace')->nullable();
                 $table->string('AllowMixedPriority')->nullable();
                 $table->string('Priority')->nullable();
                 $table->string('AllowHigherDuplicates')->nullable();
                 $table->string('CancelLowerLevelDuplicates')->nullable();
                 $table->string('CancelQueuedDuplicates')->nullable();
                 $table->string('RescheduleTimes')->nullable();
                 $table->string('AllowDuplicateJobs')->nullable();
                 $table->string('CancelRunningDuplicates')->nullable();
                 $table->string('SpoolAttributes')->nullable();
                 $table->string('WritePartAfterJob')->nullable();
                 $table->string('Run')->nullable();
                 $table->string('PruneFiles')->nullable();
             });
         }
         /* cfgpool */
         if (!Schema::hasTable('cfgpool')) {
             Schema::create('cfgpool', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('MaximumVolumes')->nullable();
                 $table->string('PoolType')->nullable();
                 $table->string('Storage')->nullable();
                 $table->string('UseVolumeOnce')->nullable();
                 $table->string('MaximumVolumeJobs')->nullable();
                 $table->string('MaximumVolumeFiles')->nullable();
                 $table->string('MaximumVolumeBytes')->nullable();
                 $table->string('VolumeUseDuration')->nullable();
                 $table->string('CatalogFiles')->nullable();
                 $table->string('AutoPrune')->nullable();
                 $table->string('VolumeRetention')->nullable();
                 $table->string('ActionOnPurge')->nullable();
                 $table->string('ScratchPool')->nullable();
                 $table->string('RecyclePool')->nullable();
                 $table->string('RecycleOldestVolume')->nullable();
                 $table->string('RecycleCurrentVolume')->nullable();
                 $table->string('Recycle')->nullable();
                 $table->string('PurgeOldestVolume')->nullable();
                 $table->string('FileRetention')->nullable();
                 $table->string('JobRetention')->nullable();
                 $table->string('CleaningPrefix')->nullable();
                 $table->string('LabelFormat')->nullable();
             });
         }
         /* cfgschedule */
         if (!Schema::hasTable('cfgschedule')) {
             Schema::create('cfgschedule', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('Run')->nullable();
             });
         }
         /* cfgscheduleRun */
         if (!Schema::hasTable('cfgschedulerun')) {
             Schema::create('cfgschedulerun', function ($table) {
                 $table->increments('id');
                 $table->string('idschedule')->nullable();
                 $table->string('Run')->nullable();
             });
         }
         /* cfgstorage */
         if (!Schema::hasTable('cfgstorage')) {
             Schema::create('cfgstorage', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('Run')->nullable();
                 $table->string('SDPort')->nullable();
                 $table->string('Password')->nullable();
                 $table->string('Device')->nullable();
                 $table->string('MediaType')->nullable();
                 $table->string('Autochanger')->nullable();
                 $table->string('MaximumConcurrentJobs')->nullable();
                 $table->string('AllowCompression')->nullable();
                 $table->string('HeartbeatInterval')->nullable();
                 $table->string('Address')->nullable();
             });
         }
         /* daystats */
         if (!Schema::hasTable('daystats')) {
             Schema::create('daystats', function ($table) {
                 $table->increments('id');
                 $table->timestamp('data')->nullable();
                 $table->string('server')->nullable();
                 $table->bigInteger('bytes')->nullable();
                 $table->bigInteger('files')->nullable();
                 $table->integer('clients')->nullable();
                 $table->bigInteger('databasesize')->nullable();
             });
         }
         /* hoursstats */
         if (!Schema::hasTable('hoursstats')) {
             Schema::create('hoursstats', function ($table) {
                 $table->increments('id');
                 $table->timestamp('data')->nullable();
                 $table->string('server')->nullable();
                 $table->timestamp('starttime')->nullable();
                 $table->timestamp('endtime')->nullable();
                 $table->bigInteger('bytes')->nullable();
                 $table->bigInteger('hoursdiff')->nullable();
                 $table->double('hourbytes')->nullable();
                 $table->string('timediff')->nullable();
             });
         }
         //Group::where('name', '=', 'Admins')->count();
         //var_dump ($count);
         /* If Not Found Create Admin Group */
         if (!Group::where('name', '=', 'Admins')->count()) {
             $group = Sentry::createGroup(array('name' => 'Admins', 'permissions' => array('admin' => 1, 'users' => 1)));
         } else {
             $group = Sentry::findGroupByName('Admins');
         }
         // Create User
         if (!User::where('email', '=', Input::get('email'))->count()) {
             $user = Sentry::createUser(array('email' => Input::get('email'), 'password' => Input::get('password'), 'activated' => '1'));
             $user->addGroup($group);
         }
         /* Emails Tables */
         if (Schema::hasTable('emails') == false) {
             Schema::create('emails', function ($table) {
                 $table->increments('id');
                 $table->text('emails');
                 $table->text('clients')->nullable();
                 $table->text('jobs')->nullable();
                 $table->text('when')->nullable();
             });
         }
         echo json_encode(array('location' => 'install/installSucess'));
     } catch (Sentry\SentryException $e) {
         // $errors = new Laravel\Messages();
         Session::flash('status_error', $e->getMessage());
         return Redirect::to('install')->with_errors($validation);
     }
 }
示例#10
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     if (Helpers::perm('admin', $id)) {
         $data['page_title'] = "Edit society";
         $data['page_description'] = Helpers::getSetting('circuit_name') . " Circuit";
         $data['society'] = Society::with('service')->find($id);
         $data['latitude'] = $data['society']->latitude;
         $data['longitude'] = $data['society']->longitude;
         $data['indivs'] = Individual::socindiv($data['society']->id)->get();
         $data['groups'] = Group::where('society_id', '=', $data['society']->id)->orderBy('groupname')->get();
         $data['rosters'] = Roster::where('society_id', '=', $data['society']->id)->orderBy('rostername')->get();
         $data['provideropts'] = array('none' => '', 'bulksms' => 'Bulk SMS', 'smsfactory' => 'SMS Factory');
         return View::make('societies.edit', $data);
     } else {
         return view('shared.unauthorised');
     }
 }
示例#11
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $society = $view->getData()['soc'];
     $data['services'] = Society::with('service')->where('society', '=', $society)->first();
     foreach ($data['services']->service as $service) {
         if ($service['language'] == "English" and $service['description'] == "") {
             $service->description = "Our " . $service->servicetime . " service is led in English by a minister or local preacher and a team of musicians. Everyone is welcome!";
         } elseif ($service['language'] == "isiZulu" and $service['description'] == "") {
             $service->description = "Our " . $service->servicetime . " service is led in isiZulu by a minister or local preacher and uses the liturgy and music of the Methodist Hymn Book. Everyone is welcome!";
         }
         $data['allservices'][] = $service;
     }
     if (!count($data['services'])) {
         return View::make('errors.404');
     }
     if (isset($view->getData()['pagetitle'])) {
         $data['pagetitle'] = $view->getData()['pagetitle'];
     } else {
         $data['pagetitle'] = $society;
     }
     $socid = Society::where('society', '=', $society)->select('id')->first()->id;
     if (Helpers::is_online() and $data['services']->society_calendar != "") {
         $privatecal = new GoogleCalendar();
         $data['cals'] = $privatecal->getTen($data['services']->society_calendar, 8);
     }
     $data['sermon'] = Sermon::with(['series' => function ($query) use($socid) {
         $query->where('society_id', '=', $socid);
     }])->orderBy('servicedate', 'DESC')->first();
     if (!$data['sermon'] or !$data['sermon']->series) {
         $data['sermon'] = "None";
     } else {
         if ($data['sermon']->preachable_type == 'App\\Models\\Minister') {
             $data['preacher'] = Minister::find($data['sermon']->preachable_id);
         } elseif ($data['sermon']->preachable_type == 'App\\Models\\Guest') {
             $data['preacher'] = Guest::find($data['sermon']->preachable_id);
         } else {
             $data['preacher'] = Preacher::find($data['sermon']->preachable_id);
         }
     }
     $data['welcome_page'] = "together a transforming discipleship movement";
     $data['welcome_page_pic'] = "/public/images/715.jpg";
     if ($data['services']->roster) {
         $data['roster'] = $data['services']->roster;
     }
     $data['society'] = Society::where('society', '=', $society)->first();
     if ($data['society']->roster) {
         $data['roster'] = $data['society']->roster;
     }
     $webpage = Webpage::where('society_id', '=', $data['society']->id)->get();
     foreach ($webpage as $pg) {
         $data[$pg->fieldname] = $pg->fieldvalue;
         $data[$pg->fieldname . '_pic'] = $pg->pageimage;
     }
     $data['route'] = Route::getCurrentRoute()->getPath();
     if ($data['route'] != "{society}" and $data['route'] != "/") {
         $linkadd = Helpers::makeUrl(strtolower($society), '');
     } else {
         $linkadd = "";
     }
     $menu['link'] = $linkadd . "#sundays";
     $menu['label'] = "Sundays";
     $menu['longlabel'] = "Sunday services";
     $data['menu'][] = $menu;
     $data['youth'] = Mission::where('society_id', '=', $data['society']->id)->where('category', '=', 'youth')->orderBy('created_at')->take(5)->get();
     if (count($data['youth'])) {
         $menu['link'] = $linkadd . "#youth";
         $menu['label'] = "Youth";
         $menu['longlabel'] = "Children and Youth";
         $data['menu'][] = $menu;
     }
     $data['groups'] = Group::where('society_id', '=', $data['society']->id)->where('publish', '=', 1)->get();
     if (count($data['groups'])) {
         foreach ($data['groups'] as $obj) {
             $dum[0] = $obj->groupname;
             $dum[1] = $obj->latitude;
             $dum[2] = $obj->longitude;
             $dum[3] = Helpers::makeUrl(strtolower($data['services']->society), 'groups/' . $obj->slug);
             $fin[] = $dum;
         }
         $data['fin'] = json_encode($fin);
         $menu['link'] = "#groups";
         $menu['label'] = "Groups";
         $menu['longlabel'] = "Small groups";
         $data['menu'][] = $menu;
     } else {
         $data['fin'] = "";
     }
     $data['missions'] = Mission::where('society_id', '=', $data['society']->id)->where('category', '=', 'project')->take(5)->get();
     if (count($data['missions'])) {
         $menu['link'] = $linkadd . "#projects";
         $menu['label'] = "Projects";
         $menu['longlabel'] = "Mission projects";
         $data['menu'][] = $menu;
     }
     $blogs = Blog::with('individual')->orderBy('created_at', 'desc')->take(10)->get();
     if (count($blogs)) {
         $first = true;
         foreach ($blogs as $blog) {
             $societies = explode(',', $blog->societies);
             if (in_array($data['society']->id, $societies)) {
                 if ($first) {
                     $data['firstblog'] = $blog;
                     $first = false;
                 } else {
                     $data['blogs'][] = $blog;
                 }
             }
         }
         if (isset($data['firstblog'])) {
             $menu['link'] = $linkadd . "#blog";
             $menu['label'] = "Blog";
             $menu['longlabel'] = "Latest blogs";
             $data['menu'][] = $menu;
         }
     }
     $menu['link'] = $linkadd . "#contact";
     $menu['label'] = "Contact";
     $menu['longlabel'] = "Contact us";
     $data['menu'][] = $menu;
     $data['counter'] = 1;
     $view->with('data', $data);
 }
示例#12
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($society, $hid, $id)
 {
     if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) {
         $data['society'] = $society;
         $data['individual'] = Individual::with('group', 'skill')->find($id);
         if (!$data['individual']->photo) {
             $data['individual']->photo = "/public/images/profile.png";
         }
         if (count($data['individual']->currentgroups) != 0) {
             foreach ($data['individual']->currentgroups as $group) {
                 $groupmembers[] = $group->id;
             }
             $data['groupmembers'] = $groupmembers;
         }
         $data['groups'] = Group::where('society_id', '=', $society)->orderBy('groupname')->get();
         if (count($data['individual']->skill) != 0) {
             foreach ($data['individual']->skill as $skill) {
                 $skillmembers[] = $skill->id;
             }
             $data['skillmembers'] = $skillmembers;
         }
         $data['household_id'] = $data['individual']->household_id;
         $data['skills'] = Skill::orderBy('skill')->get();
         $data['pgadmin'] = Society::find($society)->pgadmin;
         return View::make('individuals.edit', $data);
     } else {
         //
     }
 }
示例#13
0
 public function getEdit($groupId = null)
 {
     if (!Auth::check()) {
         return Redirect::to('user/login')->with('error', 'Please log in to edit a group');
     }
     if (is_null($groupId)) {
         $group = new Group();
     } else {
         $group = Group::where('id', '=', $groupId)->first();
         if (!$group) {
             return Redirect::back()->with('error', "Group Not Found");
         }
         if (!$group->isGroupOwner(Auth::user()->id)) {
             return Redirect::back()->with('error', 'You cannot edit the group you are not the owner');
         }
     }
     return View::make('groups.edit.index', compact('group'));
 }
示例#14
0
 private function _covenant($society, $blank = "false")
 {
     $pdf = new Fpdf();
     $soc = Society::find($society);
     if (!$blank) {
         $households = Household::with('individual')->where('society_id', '=', $society)->orderBy('sortsurname')->get();
         if ($soc->logo == "") {
             $logopath = base_path() . '/public/images/defaultlogo.jpg';
         } else {
             $logopath = base_path() . '/public/images/defaultlogo.jpg';
         }
     } else {
         $individual = (object) ['firstname' => 'Name:', 'surname' => '', 'memberstatus' => 'member', 'title' => '', 'birthdate' => '', 'cellphone' => '', 'email' => '', 'giving' => '', 'group' => array()];
         $individuals[] = $individual;
         $individuals[] = $individual;
         $individuals[] = $individual;
         $household = (object) ['addressee' => 'Household:', 'addr1' => '', 'addr2' => '', 'addr3' => '', 'post1' => '', 'post2' => '', 'post3' => '', 'homephone' => '', 'householdcell' => '', 'individual' => $individuals];
         $households[] = $household;
     }
     $churchname = $soc->society . " Methodist Church";
     foreach ($households as $household) {
         $pg = 1;
         $pdf->AddPage('P');
         $pdf->SetAutoPageBreak(0, 0);
         $pdf->SetFont('Arial', 'B', 12);
         $pdf->text(10, 10, utf8_decode($household->addressee));
         $pdf->SetFont('Arial', '', 11);
         $pdf->rect(48, 12, 152, 7);
         $pdf->text(10, 17, "Physical Address");
         if ($household->addr1) {
             $addr = $household->addr1;
             if ($household->addr2) {
                 $addr = $addr . ", " . $household->addr2;
                 if ($household->addr3) {
                     $addr = $addr . ", " . $household->addr3;
                 }
             }
             $pdf->text(50, 17, $addr);
         }
         $pdf->rect(48, 21, 152, 7);
         $pdf->text(10, 26, "Postal Address");
         if ($household->addr1) {
             $paddr = $household->post1;
             if ($household->post2) {
                 $paddr = $paddr . ", " . $household->post2;
                 if ($household->post3) {
                     $paddr = $paddr . ", " . $household->post3;
                 }
             }
             $pdf->text(50, 26, $paddr);
         }
         $pdf->text(10, 35, "Home phone");
         $pdf->rect(48, 30, 152, 7);
         $pdf->text(10, 44, "Church SMSes go to");
         $pdf->rect(48, 40, 152, 7);
         $pdf->text(50, 35, substr($household->homephone, 0, 3) . " " . substr($household->homephone, 3, 4) . " " . substr($household->homephone, 7, 3));
         if ($household->householdcell != 0 and Individual::where('id', '=', $household->householdcell)->exists()) {
             $pdf->text(50, 45, Individual::find($household->householdcell)->firstname);
         }
         $yy = 54;
         foreach ($household->individual as $indiv) {
             if ($indiv->memberstatus == "child") {
                 $threshold = 270;
             } else {
                 $threshold = 210;
             }
             if ($yy > $threshold) {
                 $pg++;
                 $pdf->AddPage('P');
                 $pdf->SetFont('Arial', 'B', 11);
                 $pdf->text(10, 10, utf8_decode($household->addressee) . " - page " . $pg);
                 $yy = 18;
                 $pdf->SetFont('Arial', '', 11);
             }
             $starty = $yy;
             $pdf->SetFont('Arial', 'B', 11);
             $pdf->text(10, $yy, $indiv->title . " " . utf8_decode($indiv->firstname) . " " . utf8_decode($indiv->surname));
             $pdf->SetFont('Arial', '', 11);
             $pdf->text(100, $yy, "Date of birth");
             $pdf->rect(123, $yy - 5, 8, 7);
             $pdf->rect(132, $yy - 5, 25, 7);
             $pdf->rect(158, $yy - 5, 20, 7);
             if ($indiv->birthdate != "0000-00-00" and $indiv->birthdate != "") {
                 $pdf->text(125, $yy, date("d", strtotime($indiv->birthdate)));
                 $pdf->text(134, $yy, date("F", strtotime($indiv->birthdate)));
                 if (substr($indiv->birthdate, 0, 4) != "1900" and substr($indiv->birthdate, 0, 4) != "") {
                     $pdf->text(163, $yy, date("Y", strtotime($indiv->birthdate)));
                 } else {
                     $pdf->SetFont('Arial', '', 7);
                     $pdf->setxy(178, $yy - 5.2);
                     $pdf->multicell(23, 2, "Please include year of birth - this is helpful for worship planning");
                 }
             } else {
                 $pdf->SetFont('Arial', '', 7);
                 $pdf->setxy(178, $yy - 5.2);
                 $pdf->multicell(23, 2, "Please include year of birth - this is helpful for worship planning");
             }
             $pdf->SetFont('Arial', '', 11);
             $yy = $yy + 9;
             $pdf->text(10, $yy, "Cellphone");
             $pdf->rect(48, $yy - 5, 50, 7);
             $pdf->text(50, $yy, substr($indiv->cellphone, 0, 3) . " " . substr($indiv->cellphone, 3, 4) . " " . substr($indiv->cellphone, 7, 3));
             $pdf->text(100, $yy, "Email");
             $pdf->rect(111, $yy - 5, 89, 7);
             $pdf->text(113, $yy, $indiv->email);
             $yy = $yy + 9;
             $pdf->text(10, $yy, "I would like to be considered as a: ");
             $pdf->rect(72, $yy - 4, 6, 6);
             $pdf->text(80, $yy, "member");
             $pdf->rect(102, $yy - 4, 6, 6);
             $pdf->text(110, $yy, "non-member");
             $pdf->rect(138, $yy - 4, 6, 6);
             $pdf->text(146, $yy, "child");
             if ($indiv->memberstatus == "child") {
                 $pdf->text(140, $yy, "X");
             }
             $pdf->rect(162, $yy - 4, 6, 6);
             $pdf->text(170, $yy, "youth");
             if ($indiv->memberstatus == "youth") {
                 $pdf->text(164, $yy, "X");
             }
             $yy = $yy + 3;
             if (strtolower($indiv->memberstatus) != "child") {
                 $adultgroups = array();
                 $pdf->rect(10, $yy, 38, 45);
                 $pdf->image(base_path() . '/public/images/serve.png', 32, $yy + 30, 14, 14);
                 $pdf->rect(48, $yy, 38, 45);
                 $pdf->image(base_path() . '/public/images/worship.png', 70, $yy + 30, 14, 14);
                 $pdf->rect(86, $yy, 38, 45);
                 $pdf->image(base_path() . '/public/images/learn.png', 108, $yy + 30, 14, 14);
                 $pdf->rect(124, $yy, 38, 45);
                 $pdf->image(base_path() . '/public/images/give.png', 147, $yy + 30, 14, 14);
                 $pdf->rect(162, $yy, 38, 45);
                 $pdf->image(base_path() . '/public/images/connect.png', 184, $yy + 30, 14, 14);
                 $adultgroups['service'] = "";
                 $adultgroups['course'] = "";
                 $adultgroups['fellowship'] = "";
                 $adultgroups['worship'] = "";
                 $pdf->SetFont('Arial', '', 8);
                 // Giving
                 $pdf->setxy(124, $yy);
                 if ($indiv->giving == 0) {
                     $pdf->multicell(38, 4, "I do not have a planned giving number.");
                     $pdf->rect(125, $yy + 9, 5, 5);
                     $pdf->text(132, $yy + 12, "Please send me info");
                     $pdf->rect(125, $yy + 15, 5, 5);
                     $pdf->text(132, $yy + 18, "Please sign me up");
                 } else {
                     $pdf->multicell(38, 4, "I am a planned giver and have a PG number.");
                     $pdf->rect(125, $yy + 9, 5, 5);
                     $pdf->text(132, $yy + 12, "But I can't remember it!");
                     $pdf->rect(125, $yy + 15, 5, 5);
                     $pdf->setxy(131, $yy + 16);
                     $pdf->multicell(30, 4, "I have not been receiving a quarterly acknowledgement of my planned giving offerings");
                 }
                 foreach ($indiv->group as $group) {
                     if ($group->grouptype != "admin") {
                         $adultgroups[$group->grouptype] = $adultgroups[$group->grouptype] . $group->groupname . ", ";
                     }
                 }
                 //Service
                 $pdf->setxy(10, $yy);
                 $pdf->SetFont('Arial', 'B', 8);
                 if ($adultgroups['service']) {
                     $pdf->multicell(38, 3, "Current: " . substr($adultgroups['service'], 0, strlen($adultgroups['service']) - 2));
                 }
                 $pdf->SetFont('Arial', '', 8);
                 $pdf->setxy(10, $pdf->gety());
                 $pdf->multicell(38, 3, "I'm interested in getting involved in: ");
                 // Worship
                 $pdf->setxy(48, $yy);
                 $services = Service::where('society_id', '=', $soc->id)->get();
                 if (count($services) > 1) {
                     $pdf->multicell(38, 4, "The service I usually attend is:");
                     $yadd = 0;
                     foreach ($services as $service) {
                         $pdf->rect(60, $yy + 9 + $yadd, 5, 5);
                         $pdf->text(67, $yy + 12 + $yadd, $service->servicetime);
                         $yadd = $yadd + 7;
                     }
                 } else {
                     $pdf->text(58, $yy + 6, $services[0]->servicetime . " service");
                 }
                 // Courses
                 $pdf->setxy(86, $yy);
                 $courses = Group::where('society_id', '=', $soc->id)->where('groupname', 'like', date('Y') . "%")->where('grouptype', '=', 'course')->get();
                 if (count($courses)) {
                     $pdf->multicell(38, 4, "I am interested in doing a course this year:");
                     $yadd = 0;
                     foreach ($courses as $course) {
                         $pdf->rect(87, $yy + 9 + $yadd, 5, 5);
                         $pdf->text(93, $yy + 12 + $yadd, substr($course->groupname, 4));
                         $yadd = $yadd + 7;
                     }
                 } else {
                     $pdf->multicell(38, 4, "I would love to do a course this year. I am interested in:");
                 }
                 //Groups
                 $pdf->setxy(162, $yy);
                 if ($adultgroups['fellowship']) {
                     $pdf->SetFont('Arial', 'B', 8);
                     $pdf->multicell(38, 4, "Current group: " . substr($adultgroups['fellowship'], 0, -2));
                     $pdf->SetFont('Arial', '', 8);
                 } else {
                     $groups = Group::where('society_id', '=', $soc->id)->where('groupname', 'like', date('Y') . "%")->where('grouptype', '=', 'fellowship')->get();
                     if (count($groups)) {
                         $pdf->multicell(38, 4, "I would like to join a small group:");
                         $yadd = 0;
                         foreach ($groups as $group) {
                             $pdf->rect(163, $yy + 9 + $yadd, 5, 5);
                             $pdf->text(169, $yy + 12 + $yadd, substr($group->groupname, 4));
                             $yadd = $yadd + 7;
                         }
                     } else {
                         $pdf->multicell(38, 4, "I would like to join a small group - please send more info.");
                     }
                 }
                 $yy = $yy + 3;
                 $yy = $yy + 48;
                 $pdf->rect(9, $starty - 6, 192, $yy - $starty + 1);
             } else {
                 $allgroups = "";
                 foreach ($indiv->group as $group) {
                     $allgroups = $allgroups . $group->groupname . ", ";
                 }
                 $pdf->SetFont('Arial', '', 8);
                 $pdf->text(10, $yy + 2, substr($allgroups, 0, -2));
                 $yy = $yy + 6;
                 $pdf->rect(9, $starty - 6, 192, $yy - $starty + 3);
                 $yy = $yy + 2;
             }
             $yy = $yy + 2;
         }
     }
     $pdf->Output();
     exit;
 }
示例#15
0
文件: Doc.php 项目: st421/madison
 public static function getAllValidSponsors()
 {
     $userMeta = UserMeta::where('meta_key', '=', UserMeta::TYPE_INDEPENDENT_SPONSOR)->where('meta_value', '=', 1)->get();
     $groups = Group::where('status', '=', Group::STATUS_ACTIVE)->get();
     $results = new Collection();
     $userIds = array();
     foreach ($userMeta as $m) {
         $userIds[] = $m->user_id;
     }
     if (!empty($userIds)) {
         $users = User::whereIn('id', $userIds)->get();
         foreach ($users as $user) {
             $row = array('display_name' => "{$user->fname} {$user->lname}", 'sponsor_type' => 'individual', 'id' => $user->id);
             $results->add($row);
         }
     }
     foreach ($groups as $group) {
         $row = array('display_name' => $group->display_name, 'sponsor_type' => 'group', 'id' => $group->id);
         $results->add($row);
     }
     return $results;
 }
示例#16
0
 public function search()
 {
     $input = Input::all();
     $data['q'] = $input['q'];
     $perms = array_flatten(Permission::where('user_id', '=', Auth::user()->id)->select('society_id')->get()->toArray());
     $individuals = Individual::where('surname', 'like', '%' . $input['q'] . '%')->orWhere('firstname', 'like', '%' . $input['q'] . '%')->whereNull('deleted_at')->orderBy('surname')->get();
     foreach ($individuals as $indiv) {
         if ($indiv->household) {
             if (in_array($indiv->household->society_id, $perms)) {
                 $ids[] = $indiv->id;
             }
         }
     }
     $data['individuals'] = Individual::wherein('id', $ids)->get();
     $data['groups'] = Group::where('groupname', 'like', '%' . $input['q'] . '%')->whereIn('society_id', $perms)->whereNull('deleted_at')->get();
     $data['projects'] = Project::where('project', 'like', '%' . $input['q'] . '%')->whereNull('deleted_at')->get();
     return view('home', $data);
 }
示例#17
0
 /**
  * Create a new job instance.
  *
  */
 public function __construct()
 {
     $group = \App\Models\Group::where('name', '=', 'shift_staff')->first();
     $this->shiftStaff = \App\User::FromGroup($group)->get();
 }
示例#18
0
文件: User.php 项目: DCgov/dc-madison
 /**
  *	activeGroup.
  *
  *	Returns current active group for this user
  *		Grabs the active group id from Session
  *
  *	@param void
  *
  *	@return Group|| new Group
  *
  *	@todo Why would this return a new group?  Should probalby return some falsy value.
  */
 public function activeGroup()
 {
     $activeGroupId = Session::get('activeGroupId');
     if ($activeGroupId <= 0) {
         //return new Group();
         return;
     }
     return Group::where('id', '=', $activeGroupId)->first();
 }
 public function edit($id)
 {
     $company_person = CompanyPerson::find($id);
     if (Auth::user()->can('update-contact') || Auth::user()->active_contact->id == $id && Auth::user()->can('update-own-contact') || !$company_person->isE80() && Auth::user()->can('update-customer-contact')) {
         $data['title'] = "Edit Contact";
         $data['titles'] = Title::orderBy("name")->get();
         $data['departments'] = Department::orderBy("name")->get();
         $data['companies'] = Company::orderBy("name")->get();
         $data['contact'] = CompanyPerson::find($id);
         $data['divisions'] = Division::orderBy("name")->get();
         $data['groups'] = Group::where("group_type_id", "=", $company_person->group_type_id)->orderBy("name")->get();
         return view('company_person/edit', $data);
     } else {
         return redirect()->back()->withErrors(['Access denied to contacts edit page']);
     }
 }