Пример #1
0
 /**
  * @param $activity
  * @return array
  */
 public function getXmlData(Activity $activity)
 {
     $activityData = [];
     $documentLinks = $activity->documentLinks()->get();
     foreach ($documentLinks as $documentLink) {
         $documentLink = $documentLink->document_link;
         $activityData[] = ['@attributes' => ['url' => $documentLink['url'], 'format' => $documentLink['format']], 'title' => ['narrative' => $this->buildNarrative($documentLink['title'][0]['narrative'])], 'category' => ['@attributes' => ['code' => isset($documentLink['category'][0]['code']) ? $documentLink['category'][0]['code'] : '']], 'language' => ['@attributes' => ['code' => isset($documentLink['language'][0]['language']) ? $documentLink['language'][0]['language'] : '']]];
     }
     return $activityData;
 }
Пример #2
0
 /**
  * @param $activity
  * @return array
  */
 public function getXmlData(Activity $activity)
 {
     $activityData = [];
     $documentLinks = $activity->documentLinks()->get();
     foreach ($documentLinks as $documentLink) {
         $documentLink = $documentLink->document_link;
         $activityData[] = ['@attributes' => ['url' => $documentLink['url'], 'format' => $documentLink['format']], 'title' => ['narrative' => $this->buildNarrative(getVal($documentLink, ['title', 0, 'narrative'], []))], 'category' => ['@attributes' => ['code' => getVal($documentLink, ['category', 0, 'code'])]], 'language' => ['@attributes' => ['code' => getVal($documentLink, ['language', 0, 'language'])]], 'document-date' => ['@attributes' => ['iso-date' => getVal($documentLink, ['document_date', 0, 'date'])]]];
     }
     return $activityData;
 }
Пример #3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('auth/login');
         }
     } elseif (session('role_id') == 3) {
         $route = $request->route();
         $routeName = $route->getName();
         if ($routeName == 'activity.show') {
             $activityId = $route->getParameter('activity');
             $orgId = Activity::select('organization_id')->find($activityId)->organization_id;
         } elseif ($routeName == 'organization.show') {
             $orgId = $route->getParameter('organization');
         } else {
             $orgId = session('org_id');
         }
         if ($orgId && $this->auth->user()->isSuperAdmin()) {
             $userId = User::select('id')->where('org_id', $orgId)->where('role_id', 1)->first()->id;
             app(OrganizationController::class)->masqueradeOrganization($orgId, $userId);
         } elseif (!$orgId && !isSuperAdminRoute()) {
             return redirect(config('app.super_admin_dashboard'));
         }
     } elseif (isSuperAdminRoute()) {
         $response = ['type' => 'warning', 'code' => ['message', ['message' => "You don't have correct privilege"]]];
         return redirect(config('app.admin_dashboard'))->withResponse($response);
     }
     return $next($request);
 }
 /**
  * Get the file being published for the Activity with a specific activityId.
  * @param $activityId
  * @return ActivityPublished|null
  */
 public function fileBeingPublished($activityId)
 {
     $activity = $this->activity->findOrFail($activityId);
     $settings = $activity->organization->settings;
     $publisherId = getVal($settings->registry_info, [0, 'publisher_id']);
     return $this->getFile($publisherId, $settings->publishing_type, $activityId, $activity->organization_id);
 }
Пример #5
0
 /**
  * get the identifiers of all activity
  * @param $orgId
  * @return array
  */
 public function getIdentifiers($orgId)
 {
     $activities = $this->activity->where('organization_id', $orgId)->get();
     $identifiers = [];
     foreach ($activities as $activityRow) {
         $identifiers[$activityRow->identifier['activity_identifier']] = $activityRow->id;
     }
     return $identifiers;
 }
Пример #6
0
 /**
  * @return mixed
  */
 public function buildActivityXml()
 {
     $activities = Activity::all();
     $xmlData = [];
     foreach ($activities as $activity) {
         $xmlData[] = $this->fetchActivityData($activity);
     }
     return $xmlData;
 }
 /**
  * @param                     $id
  * @param OrganizationManager $organizationManager
  * @return \Illuminate\View\View
  */
 public function index($id, OrganizationManager $organizationManager)
 {
     $activity = Activity::find($id);
     if (Gate::denies('ownership', $activity)) {
         return redirect()->back()->withResponse($this->getNoPrivilegesMessage());
     }
     if ($activity) {
         $reportingOrganization = $organizationManager->getOrganization(Session::get('org_id'))->reporting_org;
         return view('Activity.ReportingOrganization.edit', compact('reportingOrganization', 'id'));
     }
     return redirect()->route('activity.index')->withResponse(['messages' => ['Activity with id' . $id . ' not found.'], 'type' => 'danger']);
 }
 /**
  * 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;
 }
 /**
  * update Activity Default
  * @param array    $activityDefaults
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDefaults, Activity $activity)
 {
     $activity->default_field_values = $activityDefaults;
     return $activity->save();
 }
 /**
  * get identifier except activityId of an organization
  * @param $activityId
  * @return mixed
  */
 public function getActivityIdentifiersForOrganizationExcept($activityId)
 {
     return $this->activity->where(function ($query) use($activityId) {
         $query->where('id', '<>', $activityId)->where('organization_id', '=', session('org_id'));
     })->get(['identifier']);
 }
 /**
  * @param $activityId
  * @return model
  */
 public function getOtherIdentifierData($activityId)
 {
     return Activity::findorFail($activityId)->other_identifier;
 }
Пример #12
0
 /**
  * @param $activityId
  * @return array
  */
 public function getDefaultFlowTypeData($activityId)
 {
     return $this->activity->findOrFail($activityId)->default_flow_type;
 }
Пример #13
0
 /**
  * creates new transaction
  * @param $transactionDetails
  * @param $activity
  */
 public function create(array $transactionDetails, Activity $activity)
 {
     $transactionDetails = $this->checkSectorVocabulary($transactionDetails);
     $transaction = $this->transaction->newInstance(['transaction' => $transactionDetails['transaction'][0]]);
     $activity->transactions()->save($transaction);
 }
Пример #14
0
 /**
  * duplicate activity
  * @param Activity $activityData
  * @return bool
  */
 public function duplicateActivityAction(Activity $activityData)
 {
     try {
         $this->database->beginTransaction();
         $activityData->save();
         $this->database->commit();
         $this->logger->info('Activity has been Duplicated.', ['for ' => $activityData->id]);
         $this->logger->activity("activity.activity_duplicated", ['activity_id' => $activityData->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['ActivityIdentifier' => $activityData]);
     }
     return false;
 }
Пример #15
0
 /**
  * @param $activityId
  * @return model
  */
 public function getLegacyData($activityId)
 {
     return $this->activity->findOrFail($activityId)->legacy_data;
 }
 /**
  * @param $activityId
  * @return array
  */
 public function getCountryBudgetItemData($activityId)
 {
     return $this->activity->findOrFail($activityId)->country_budget_items;
 }
Пример #17
0
 /**
  * @param $activityId
  * @return array
  */
 public function getDefaultAidTypeData($activityId)
 {
     return $this->activity->findOrFail($activityId)->default_aid_type;
 }
 /**
  * @param Activity $activity
  * @param          $element
  * @return bool
  */
 public function deleteElement(Activity $activity, $element)
 {
     $activity->{$element} = null;
     return $activity->save();
 }
Пример #19
0
 /**
  * @param $activityId
  * @return model
  */
 public function getLocation($activityId)
 {
     return $this->activity->findOrFail($activityId)->location;
 }
 /**
  * @param $activityId
  * @return model
  */
 public function getRecipientCountryData($activityId)
 {
     return $this->activity->findOrFail($activityId)->recipient_country;
 }
Пример #21
0
 /**
  * @param $activityId
  * @return model
  */
 public function getDescriptionData($activityId)
 {
     return $this->activity->findorFail($activityId)->description;
 }
 /**
  * @param $activityId
  * @return array
  */
 public function getCollaborationTypeData($activityId)
 {
     return $this->activity->findOrFail($activityId)->collaboration_type;
 }
Пример #23
0
 /**
  * @param $activityId
  * @return model
  */
 public function getBudgetData($activityId)
 {
     return $this->activity->findorFail($activityId)->budget;
 }
Пример #24
0
 /**
  * @param $activityId
  * @return model
  */
 public function getActivityDateData($activityId)
 {
     return $this->activity->findorFail($activityId)->activity_date;
 }
Пример #25
0
 /**
  * @param $activityId
  * @return array
  */
 public function getRecipientRegionData($activityId)
 {
     return $this->activity->findOrFail($activityId)->recipient_region;
 }
Пример #26
0
 /**
  * @param $activityId
  * @return model
  */
 public function getActivityScopeData($activityId)
 {
     return $this->activity->findorFail($activityId)->activity_scope;
 }
 /**
  * @param $activityId
  * @return array
  */
 public function getParticipatingOrganizationData($activityId)
 {
     return $this->activity->findOrFail($activityId)->participating_organization;
 }
Пример #28
0
 /**
  * @param $organization_id
  * @return mixed
  */
 protected function getActivities($organization_id)
 {
     return $this->activity->where('organization_id', $organization_id)->get();
 }
Пример #29
0
 /**
  * @param $activityId
  * @return model
  */
 public function getContactInfoData($activityId)
 {
     return $this->activity->findorFail($activityId)->contact_info;
 }
Пример #30
0
 /**
  * update title and description
  * @param array    $activityDetails
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDetails, Activity $activity)
 {
     $activity->title = $activityDetails['title'];
     $activity->description = $activityDetails['description'];
     return $activity->save();
 }