/** * @param $id * @return \Illuminate\View\View */ function index($id) { $activityData = $this->activityManager->getActivityData($id); if (Gate::denies('ownership', $activityData)) { return redirect()->back()->withResponse($this->getNoPrivilegesMessage()); } $iatiIdentifier = $this->iatiIdentifierManager->getIatiIdentifierData($id); $organization = $this->organizationManager->getOrganization($this->organization_id); $reportingOrganization = $organization->reporting_org; $form = $this->identifier->editForm($iatiIdentifier, $id); return view('Activity.iatiIdentifier.iatiIdentifier', compact('form', 'reportingOrganization', 'id')); }
/** * Download organization xml * @param $orgId * @return \Illuminate\Http\Response */ public function downloadOrganizationXml($orgId) { $orgElem = $this->organizationManager->getOrganizationElement(); $xmlService = $orgElem->getOrgXmlService(); $xml = $xmlService->generateTemporaryOrganizationXml($this->organizationManager->getOrganization($orgId), $this->organizationManager->getOrganizationData($orgId), $this->settingsManager->getSettings($orgId), $orgElem); return response()->make($xml, 200, ['Content-type' => 'text/xml', 'Content-Disposition' => sprintf('attachment; filename=orgXmlFile.xml')]); }
public function index($id) { $organization = $this->organizationManager->getOrganization($this->organization_id); if (!isset($organization->reporting_org[0])) { $response = ['type' => 'warning', 'code' => ['settings', ['name' => 'activity']]]; return redirect('/settings')->withResponse($response); } $this->authorize('edit_activity'); $activityData = $this->activityManager->getActivityData($id); $iatiIdentifier = $activityData->identifier; $data['activity_status'] = $activityData->activity_status; $data['start_date'] = $activityData->activity_date[0]['date']; $data['end_date'] = $activityData->activity_date[1]['date']; $data['date_type'] = $activityData->activity_date[0]['type']; $form = $this->stepThreeForm->editForm($data, $id); return view('wizard.activity.stepThree.create', compact('form', 'iatiIdentifier', 'id')); }
/** * @param $orgId * @param RecipientRegionBudgetRequest $recipientRegionBudgetRequest * @param Request $request * @return mixed */ public function update($orgId, RecipientRegionBudgetRequest $recipientRegionBudgetRequest, Request $request) { $organization = $this->organizationManager->getOrganization($orgId); $organizationData = $this->recipientRegionBudgetManager->getOrganizationData($orgId); if (Gate::denies('belongsToOrganization', $organization)) { return redirect()->back()->withResponse($this->getNoPrivilegesMessage()); } $this->authorizeByRequestType($organizationData, 'recipient_region_budget'); $input = $request->all(); if ($this->recipientRegionBudgetManager->update($input, $organizationData)) { $this->organizationManager->resetStatus($orgId); $response = ['type' => 'success', 'code' => ['updated', ['name' => 'Organization Recipient Region Budget']]]; return redirect()->to(sprintf('/organization/%s', $orgId))->withResponse($response); } $response = ['type' => 'danger', 'code' => ['update_failed', ['name' => 'Organization Recipient Region Budget']]]; return redirect()->back()->withInput()->withResponse($response); }
/** * step two from view * @param $id * @return \Illuminate\View\View */ public function index($id) { $organization = $this->organizationManager->getOrganization($this->organization_id); if (!isset($organization->reporting_org[0])) { $response = ['type' => 'warning', 'code' => ['settings', ['name' => 'activity']]]; return redirect('/settings')->withResponse($response); } $this->authorize('edit_activity'); $activityData = $this->activityManager->getActivityData($id); $iatiIdentifier = $activityData->identifier; $data['title'] = $activityData->title[0]['narrative']; $data['general'] = $activityData->description[0]['narrative'][0]['narrative']; $data['objective'] = $activityData->description[1]['narrative'][0]['narrative']; $data['target'] = $activityData->description[2]['narrative'][0]['narrative']; $form = $this->stepTwoForm->editForm($data, $id); return view('wizard.activity.stepTwo.create', compact('form', 'iatiIdentifier', 'id')); }
/** * Download of activity xml files * @param $activityId * @return \Illuminate\Http\Response */ public function downloadActivityXml($activityId) { $activityData = $this->activityManager->getActivityData($activityId); $activityElement = $this->activityManager->getActivityElement(); $xmlService = $activityElement->getActivityXmlService(); $xml = $xmlService->generateTemporaryActivityXml($this->activityManager->getActivityData($activityId), $this->activityManager->getTransactionData($activityId), $this->activityManager->getResultData($activityId), $this->settingsManager->getSettings($activityData['organization_id']), $activityElement, $this->organizationManager->getOrganizationElement(), $this->organizationManager->getOrganization($activityData->organization_id)); return response()->make($xml, 200, ['Content-type' => 'text/xml', 'Content-Disposition' => sprintf('attachment; filename=activityXmlFile.xml')]); }
/** * Save only those Activities passing Validation. * @param $validCsvFilePath * @param array $defaultFieldValues * @return bool|null */ protected function saveValidatedActivities($validCsvFilePath, array $defaultFieldValues) { if ($this->uploadActivityManager->save($validCsvFilePath, $this->organizationManager->getOrganization($this->organizationId), $defaultFieldValues)) { File::delete($validCsvFilePath); return true; } return null; }
/** * display activity list to be imported with validation messages * @param ImportActivityRequest $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function listActivities(ImportActivityRequest $request) { $organization = $this->organizationManager->getOrganization($this->organizationId); $this->authorize('add_activity', $organization); if (!isset($organization->reporting_org[0])) { $response = ['type' => 'warning', 'code' => ['settings', ['name' => 'activity']]]; return redirect('/settings')->withResponse($response); } $file = request()->file('activity'); $activities = $this->importActivityManager->getActivities($file); if ($activities === false) { return redirect()->route('import-activity.index')->withResponse(['type' => 'warning', 'code' => ['message', ['message' => 'Uploaded csv file doesn\'t match with any template listed below.']]]); } elseif (!$activities) { return redirect()->route('import-activity.index')->withResponse(['type' => 'warning', 'code' => ['message', ['message' => 'Couldn\'t find activities to be imported.']]]); } $duplicateIdentifiers = array_pop($activities); return view('Activity.list-activities', compact('activities', 'duplicateIdentifiers')); }
/** * * @param $orgId * @param Request $request * @param TotalExpenditureRequestManager $expenditureRequestManager * @return mixed */ public function update($orgId, Request $request, TotalExpenditureRequestManager $expenditureRequestManager) { $organization = $this->organizationManager->getOrganization($orgId); $organizationData = $this->totalExpenditureManager->getOrganizationData($orgId); if (Gate::denies('belongsToOrganization', $organization)) { return redirect()->back()->withResponse($this->getNoPrivilegesMessage()); } $organizationData = $this->totalExpenditureManager->getOrganizationData($orgId); $this->authorizeByRequestType($organizationData, 'total_expenditure'); $totalExpenditure = $request->all(); if ($this->totalExpenditureManager->update($totalExpenditure, $organizationData)) { $this->organizationManager->resetStatus($orgId); $response = ['type' => 'success', 'code' => ['updated', ['name' => 'Organization Total Expenditure']]]; return redirect()->to(sprintf('/organization/%s', $orgId))->withResponse($response); } $response = ['type' => 'danger', 'code' => ['update_failed', ['name' => 'Organization Total Expenditure']]]; return redirect()->back()->withInput()->withResponse($response); }
/** * it validates organization schema according to version standard * @param $id * @param null $version * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function validateOrganization($id, $version = null) { $organization = $this->organizationManager->getOrganization($id); $settings = $this->settingsManager->getSettings($id); $organizationData = $this->organizationManager->getOrganizationData($id); $orgElem = $this->organizationManager->getOrganizationElement(); if ($version == null) { $version = config('app.default_version_name'); } return $this->validateCompletedOrganization($organization, $settings, $organizationData, $orgElem, $version); }
/** * @param SettingsManager $settingsManager * @param OrganizationManager $organizationManager * @param ActivityManager $activityManager * @param OtherIdentifierManager $otherIdentifierManager * @param SettingsService $settingsService * @param LoggerInterface $loggerInterface */ function __construct(SettingsManager $settingsManager, OrganizationManager $organizationManager, ActivityManager $activityManager, OtherIdentifierManager $otherIdentifierManager, SettingsService $settingsService, LoggerInterface $loggerInterface) { $this->middleware('auth'); $this->settingsManager = $settingsManager; $org_id = Session::get('org_id'); $this->settings = $settingsManager->getSettings($org_id); $this->organization = $organizationManager->getOrganization($org_id); $this->activityManager = $activityManager; $this->otherIdentifierManager = $otherIdentifierManager; $this->settingsService = $settingsService; $this->loggerInterface = $loggerInterface; }
/** * @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']); }
/** * generate activity xml * @param Activity $activity */ public function generateXml(Activity $activity) { $activity_id = $activity->id; $org_id = $activity->organization_id; $settings = $this->getSettings($org_id); $transactionData = $this->activityManager->getTransactionData($activity_id); $resultData = $this->activityManager->getResultData($activity_id); $organization = $this->organizationManager->getOrganization($org_id); $orgElem = $this->organizationManager->getOrganizationElement(); $activityElement = $this->activityManager->getActivityElement(); $xmlService = $activityElement->getActivityXmlService(); $xmlService->generateActivityXml($activity, $transactionData, $resultData, $settings, $activityElement, $orgElem, $organization); }
/** * import selected activities * @param array $activities * @return bool */ public function importActivities(array $activities) { $database = app(DatabaseManager::class); try { $database->beginTransaction(); $organization = $this->orgManager->getOrganization(session('org_id')); $this->template ?: $this->setTemplate(json_decode($activities[0], true)); $this->importedActivities = $this->template->save($activities); $database->commit(); $this->logger->activity("activity.activity_uploaded", ['organization' => $organization->name, 'organization_id' => $organization->id]); return true; } catch (Exception $exception) { $database->rollback(); $this->logger->error($exception, ['activities' => $activities]); } return false; }
/** * @return \Illuminate\View\View */ public function create() { $organization = $this->organizationManager->getOrganization($this->org_id); $organizationIdentifier = $organization->user_identifier; return view('admin.registerUser', compact('organizationIdentifier')); }