/**
  * set activity identifier
  */
 public function setIdentifier()
 {
     $reportingOrg = $this->organizationModel->find($this->orgId)->reporting_org;
     $reportingOrgIdentifier = $reportingOrg[0]['reporting_organization_identifier'];
     $activityIdentifier = $this->activity['activity_identifier'];
     $this->activityData['identifier'] = ["activity_identifier" => $activityIdentifier, 'iati_identifier_text' => sprintf('%s-%s', $reportingOrgIdentifier, $activityIdentifier)];
 }
 /**
  * return all organization data
  */
 public function get()
 {
     $id = request()->segment(2);
     $orgData = OrgData::where('organization_id', $id)->first()->toArray();
     $orgData['reporting_org'] = Organization::find($id)->reporting_org;
     return $orgData;
 }
 /**
  * Update published status for the changed files.
  * @param $changes
  * @param $organizationId
  */
 public function updateStatus($changes, $organizationId)
 {
     $this->organizationModel = $this->organization->findOrFail($organizationId);
     foreach ($changes['changes'] as $filename => $change) {
         $row = $this->activityPublished->query()->where('filename', '=', $filename)->where('organization_id', '=', $organizationId)->first();
         $row->published_to_register = 1;
         $row->save();
     }
 }
 public function run()
 {
     DB::table('users_organizations')->truncate();
     $groups = [['data' => ['organization_id' => '1', 'user_id' => '1'], 'organization' => ['name' => 'Gradinita cu Program Prelungit Draga Mea']], ['data' => ['organization_id' => '2', 'user_id' => '2'], 'organization' => ['name' => 'Gradinita cu Program Prelungit Dumbrava Minunata']], ['data' => ['organization_id' => '3', 'user_id' => '3'], 'organization' => ['name' => 'Gradinita cu Program Prelungit Nr. 1']], ['data' => ['organization_id' => '4', 'user_id' => '1'], 'organization' => ['name' => 'Gradinita cu Program Prelungit Nr. 5']], ['data' => ['organization_id' => '5', 'user_id' => '4'], 'organization' => ['name' => 'Gradinita cu Program Prelungit Nr.6']], ['data' => ['organization_id' => '6', 'user_id' => '5'], 'organization' => ['name' => 'Gradinita cu Program Prelungit Nr.7']], ['data' => ['organization_id' => '7', 'user_id' => '6'], 'organization' => ['name' => 'Gradinita cu Program Prelungit Nr. 9']], ['data' => ['organization_id' => '8', 'user_id' => '7'], 'organization' => ['name' => 'Gradinita cu Program Prelungit  Nr. 10']], ['data' => ['organization_id' => '9', 'user_id' => '1'], 'organization' => ['name' => 'Gradinita cu Program Prelungit Nr. 11']], ['data' => ['organization_id' => '10', 'user_id' => '8'], 'organization' => ['name' => 'Gradinita cu Program Prelungit Nr. 13']], ['data' => ['organization_id' => '11', 'user_id' => '8'], 'organization' => ['name' => 'Gradinita cu Program Prelungit Voinicelul']], ['data' => ['organization_id' => '12', 'user_id' => '6'], 'organization' => ['name' => 'Gradinita cu Program Prelungit Nr. 33']], ['data' => ['organization_id' => '13', 'user_id' => '4'], 'organization' => ['name' => 'Gradinita cu Program Prelungit 14 Mai']], ['data' => ['organization_id' => '14', 'user_id' => '9'], 'organization' => ['name' => 'Scoala Gimnaziala Grigore Moisil']], ['data' => ['organization_id' => '15', 'user_id' => '10'], 'organization' => ['name' => 'Scoala Gimnaziala C-tin Brancoveanu']], ['data' => ['organization_id' => '16', 'user_id' => '11'], 'organization' => ['name' => 'Scoala Gimnaziala Balcescu Petofi']], ['data' => ['organization_id' => '17', 'user_id' => '12'], 'organization' => ['name' => 'Scoala Gimnaziala Mircea Eliade']], ['data' => ['organization_id' => '18', 'user_id' => '13'], 'organization' => ['name' => 'Scoala Gimnaziala Octavian Goga']], ['data' => ['organization_id' => '19', 'user_id' => '14'], 'organization' => ['name' => 'Scoala Gimnaziala Nr.10']], ['data' => ['organization_id' => '20', 'user_id' => '11'], 'organization' => ['name' => 'Scoala Gimnaziala Ion Creanga']], ['data' => ['organization_id' => '21', 'user_id' => '15'], 'organization' => ['name' => 'Scoala Gimnaziala Avram Iancu']], ['data' => ['organization_id' => '22', 'user_id' => '16'], 'organization' => ['name' => 'Scoala Gimnaziala Lucian Blaga']], ['data' => ['organization_id' => '23', 'user_id' => '17'], 'organization' => ['name' => 'Scoala Gimnaziala Vasile Lucaciu']], ['data' => ['organization_id' => '24', 'user_id' => '18'], 'organization' => ['name' => 'Colegiul National Mihai Eminescu']], ['data' => ['organization_id' => '25', 'user_id' => '19'], 'organization' => ['name' => 'Colegiul National Ioan Slavici']], ['data' => ['organization_id' => '26', 'user_id' => '20'], 'organization' => ['name' => 'Colegiul National D-na Stanca']], ['data' => ['organization_id' => '27', 'user_id' => '21'], 'organization' => ['name' => 'Colegiul National Kolcsey Ferenc']], ['data' => ['organization_id' => '28', 'user_id' => '22'], 'organization' => ['name' => 'Liceul Teologic Ortodox Nicolae Steinhardt']], ['data' => ['organization_id' => '29', 'user_id' => '23'], 'organization' => ['name' => 'Liceul de Arte Aurel Popp']], ['data' => ['organization_id' => '30', 'user_id' => '24'], 'organization' => ['name' => 'Liceul Teoretic German Johann Ettinger']], ['data' => ['organization_id' => '31', 'user_id' => '25'], 'organization' => ['name' => 'Liceul cu Program Sportiv']], ['data' => ['organization_id' => '32', 'user_id' => '21'], 'organization' => ['name' => 'Liceul Reformat']], ['data' => ['organization_id' => '33', 'user_id' => '26'], 'organization' => ['name' => 'Colegiul Tehnic de Transporturi Si Telecomunicatii Ion I. C. Bratianu']], ['data' => ['organization_id' => '34', 'user_id' => '27'], 'organization' => ['name' => 'Colegiul Economic Gheorghe DragoS']], ['data' => ['organization_id' => '35', 'user_id' => '28'], 'organization' => ['name' => 'Liceul Tehnologic C-tin Brancusi']], ['data' => ['organization_id' => '36', 'user_id' => '29'], 'organization' => ['name' => 'Liceul Tehnologic Industrie Alimentara George Emil Palade']], ['data' => ['organization_id' => '37', 'user_id' => '30'], 'organization' => ['name' => 'Colegiul Tehnic Traian Vuia']], ['data' => ['organization_id' => '38', 'user_id' => '31'], 'organization' => ['name' => 'Colegiul Tehnic Elisa Zamfirescu']], ['data' => ['organization_id' => '39', 'user_id' => '32'], 'organization' => ['name' => 'Liceul Teologic Romano Catolic Ham Janos']], ['data' => ['organization_id' => '40', 'user_id' => '33'], 'organization' => ['name' => 'Centrul Judetean de excelenta']], ['data' => ['organization_id' => '41', 'user_id' => '34'], 'organization' => ['name' => 'Scoala Postliceala']]];
     foreach ($groups as $grop) {
         $organization = Organization::create($grop['organization']);
         $data = $grop['data'];
         DB::table('users_organizations')->insert($data);
     }
 }
 public function checkUserIdentifier(Request $request)
 {
     $userIdentifier = $request->get('userIdentifier');
     if ($this->organization->where('user_identifier', $userIdentifier)->count() == 0) {
         $response = ['status' => 'success', 'message' => 'The organization user identifier is available.'];
     } else {
         $response = ['status' => 'danger', 'message' => 'The organization user identifier has already been taken.'];
     }
     return $response;
 }
 /**
  * return activity data with results and transactions
  * @param int $id
  */
 private function getActivityData($id)
 {
     $activityData = Activity::find($id);
     if ($activityData) {
         $activityData = $activityData->toArray();
         $reportingOrg = Organization::find($activityData['organization_id'])->reporting_org;
         $results = ActivityResult::where('activity_id', $id)->get()->toArray();
         $transactions = Transaction::where('activity_id', $id)->get()->toArray();
         $documentLinks = ActivityDocumentLink::where('activity_id', $id)->get()->toArray();
         $activityData['results'] = $results;
         $activityData['transactions'] = $transactions;
         $activityData['document_link'] = $documentLinks;
         $activityData['reporting_organization'] = $reportingOrg;
     }
     return $activityData;
 }
Esempio n. 7
0
 /**
  * add or update organization by superadmin
  * @param null  $orgId
  * @param array $orgDetails
  * @return mixed|void
  */
 public function saveOrganization(array $orgDetails, $orgId = null)
 {
     try {
         $this->database->beginTransaction();
         $orgData = $this->makeOrganizationData($orgDetails);
         $organization = $this->organization->firstOrNew(['id' => $orgId]);
         $organization->fill($orgData)->save();
         $adminData = $this->makeAdminData($orgDetails, $organization->id);
         $user = $this->user->firstOrNew(['org_id' => $organization->id]);
         $user->fill($adminData)->save();
         $settingsData = $this->makeSettingsData($orgDetails, $organization->id);
         $settings = $this->settings->firstOrNew(['organization_id' => $organization->id]);
         $settings->fill($settingsData)->save();
         $this->database->commit();
         $this->logger->info($orgId ? 'Organization information Updated' : 'Organization added');
         $this->dbLogger->activity($orgId ? "activity.organization_updated" : "activity.organization_added", ['user_id' => $user->id, 'organization_id' => $orgId]);
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['settings' => $orgDetails]);
     }
 }
 /**
  * Update Settings with segmentation changes.
  * @param SettingsRequestManager $requestManager
  * @return mixed
  * @internal param TempRequest|Request $request
  */
 public function updateSettings(SettingsRequestManager $requestManager)
 {
     $organizationId = session('org_id');
     $settings = $requestManager->requestHandler->all();
     $organization = $this->organization->findOrFail($organizationId);
     if (!$organization->publishedFiles->isEmpty()) {
         if ($this->settingsService->hasSegmentationChanged($organizationId, $settings)) {
             $changes = $this->settingsService->getChangeLog($organizationId, $settings);
             if (empty($changes['previous']) && empty($changes['changes'])) {
                 return redirect()->route('settings.index')->withResponse(['type' => 'warning', 'messages' => ['You do not have any files for the segmentation change to take effect on.']]);
             }
             return view('settings.change-log', compact('organizationId', 'changes', 'settings'));
         }
     }
     if (!$this->settingsManager->updateSettings($settings, $this->organization, $this->settings)) {
         $response = ['type' => 'danger', 'code' => ['update_failed', ['name' => 'Settings']]];
     } else {
         $response = ['type' => 'success', 'code' => ['updated', ['name' => 'Settings']]];
     }
     return redirect()->to(config('app.admin_dashboard'))->withResponse($response);
 }
 /**
  * update organization profile
  * @param $input
  * @return mixed
  */
 protected function updateOrganizationProfile($input)
 {
     $organization = $this->organization->findOrFail($this->orgId);
     $file = Input::file('organization_logo');
     if ($file) {
         $fileUrl = url('files/logos/' . $this->orgId . '.' . $file->getClientOriginalExtension());
         $fileName = $this->orgId . '.' . $file->getClientOriginalExtension();
         $image = Image::make(File::get($file))->resize(150, 150)->encode();
         Storage::put('logos/' . $fileName, $image);
         $organization->logo_url = $fileUrl;
         $organization->logo = $fileName;
     }
     $organization->name = $input['organization_name'];
     $organization->address = $input['organization_address'];
     $organization->country = $input['country'];
     $organization->organization_url = $input['organization_url'];
     $organization->telephone = $input['organization_telephone'];
     $organization->twitter = $input['organization_twitter'];
     $organization->disqus_comments = array_key_exists('disqus_comments', $input) ? $input['disqus_comments'] : null;
     return $organization->save();
 }
 /**
  * @param $input
  * @param $organization
  */
 public function update(array $input, Organization $organization)
 {
     $organization->reporting_org = $input['reporting_org'];
     $organization->save();
 }
Esempio n. 11
0
 /**
  * @param  CreateUserRequest $request
  * @return mixed
  */
 public function create(CreateUserRequest $request)
 {
     $organizations_user = Organization::get();
     // dd($organization_user);
     return view('backend.access.create')->withRoles($this->roles->getAllRoles('sort', 'asc', true))->withPermissions($this->permissions->getAllPermissions())->with(compact('organizations_user'));
 }
 /**
  * Find an Organization with a specific organizationId.
  * @param $organizationId
  * @return mixed
  */
 public function find($organizationId)
 {
     return $this->organization->findOrFail($organizationId);
 }
 /** Returns query builder of organizations having activity or organization file published.
  * @return mixed
  */
 public function initializeOrganizationQueryBuilder()
 {
     return Organization::leftJoin('activity_published', 'organizations.id', '=', 'activity_published.organization_id')->leftJoin('organization_published', 'organizations.id', '=', 'organization_published.organization_id')->where('activity_published.published_to_register', 1)->orWhere('organization_published.published_to_register', 1)->select('organizations.id', 'organizations.name', 'organizations.logo_url')->groupBy('organizations.id')->orderBy('organizations.name');
 }
Esempio n. 14
0
 public function destroy($id)
 {
     Organization::findOrFail($id)->delete();
     return redirect()->back()->withFlashSuccess('The organization was successfully deleted.');
 }
 /**
  *  Details of the organization to be exported to the csv
  * @return array
  */
 public function getAllOrganizationInfo()
 {
     $organizations = Organization::all();
     $organizationDetails = [];
     $organizations->each(function ($organization) use(&$organizationDetails) {
         $organizationId = $organization->id;
         $organizationDetails[$organizationId]['name'] = $organization->name;
         $organizationDetails[$organizationId]['admin_email'] = $this->getEmailOfOrganizationAdmin($organizationId);
         $activities = $this->getActivitiesData($organizationId);
         $organizationDetails[$organizationId]['noOfActivities'] = $activities ? $activities[0]->noofactivities : ' ';
         $organizationDetails[$organizationId]['activityLastUpdatedAt'] = $activities ? $activities[0]->updated_at : ' ';
         $organizationDetails[$organizationId]['noOfActivitiesPublished'] = $this->getNoOfActivitiesPublished($organizationId)[0]->noofpublishedactivities;
         $organizationDetails[$organizationId]['organizationDataPublished'] = $this->statusOfOrganizationDataPublished($organizationId)[0]->organizationdatapublished;
         $organizationUpdatedAt = OrganizationData::where('organization_id', $organizationId)->select('updated_at')->first();
         $organizationDetails[$organizationId]['organizationLastUpdatedAt'] = $organizationUpdatedAt ? $organizationUpdatedAt->updated_at : ' ';
     });
     return $organizationDetails;
 }
Esempio n. 16
0
 public function getUsersOfOrganization($orgId)
 {
     return $this->organization->findOrfail($orgId)->users;
 }
 /**
  * check in DB if new reporting org is already present
  * @param $reportOrg
  * @return mixed
  */
 public function getReportingOrganizations($reportOrg)
 {
     $result = Organization::where('id', '<>', session('org_id'))->whereRaw("reporting_org #>> '{0, reporting_organization_identifier}' = '" . $reportOrg['reporting_organization_identifier'] . "'");
     return $result->first();
 }
 /**
  * get groups by user Id
  * @param $userId
  * @return mixed
  */
 public function getGroupsByUserId($userId)
 {
     $userGroup = $this->userGroup->whereUserId($userId)->first();
     return $this->organization->whereIn('id', $userGroup->assigned_organizations)->with(['settings'])->orderBy('name', 'asc')->get();
 }