/**
  * @param $input
  * @param $organization
  * @param $settings
  * @return bool
  */
 public function updateSettings($input, $organization, $settings)
 {
     $organization->reporting_org = $input['reporting_organization_info'];
     $organization->save();
     $settings->publishing_type = $input['publishing_type'][0]['publishing'];
     $settings->registry_info = $input['registry_info'];
     $settings->default_field_values = $input['default_field_values'];
     $settings->default_field_groups = isset($input['default_field_groups']) ? $input['default_field_groups'] : [];
     $settings->organization_id = $organization->id;
     $settings->save();
     $this->organizationData->firstOrCreate(['organization_id' => $organization->id]);
 }
 /**
  * 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;
 }
 /**
  * write brief description
  * @param $organization_id
  * @return model
  */
 public function getOrganizationTotalBudgetData($organization_id)
 {
     return $this->org->where('organization_id', $organization_id)->first()->total_budget;
 }
 /**
  * write brief description
  * @param $organization_id
  * @return model
  */
 public function getRecipientCountryBudgetData($organization_id)
 {
     return $this->org->where('organization_id', $organization_id)->first()->recipient_country_budget;
 }
 /**
  * write brief description
  * @param $organization_id
  * @return model
  */
 public function getDocumentLinkData($organization_id)
 {
     return $this->org->where('organization_id', $organization_id)->first()->document_link;
 }
Example #6
0
 /**
  * @param OrganizationData $organizationData
  */
 protected function upgradeOrganizationData(OrganizationData $organizationData)
 {
     $totalBudgets = (array) $organizationData->total_budget;
     $recipientOrgBudgets = (array) $organizationData->recipient_organization_budget;
     $documentLinks = (array) $organizationData->document_link;
     foreach ($totalBudgets as $totalBudgetIndex => $totalBudget) {
         $totalBudgets[$totalBudgetIndex]['status'] = "1";
     }
     foreach ($recipientOrgBudgets as $recipientOrgBudgetIndex => $recipientOrgBudget) {
         $recipientOrgBudgets[$recipientOrgBudgetIndex]['status'] = "1";
     }
     foreach ($documentLinks as $documentLinkIndex => $documentLink) {
         $documentLinks[$documentLinkIndex]['document_date'][0]['date'] = "";
     }
     !$totalBudgets ?: ($organizationData->total_budget = $totalBudgets);
     !$recipientOrgBudgets ?: ($organizationData->recipient_organization_budget = $recipientOrgBudgets);
     !$documentLinks ?: ($organizationData->document_link = $documentLinks);
     $organizationData->save();
 }
 /**
  * write brief description
  * @param $organization_id
  * @return model
  */
 public function getOrganizationNameData($organization_id)
 {
     return $this->orgData->where('organization_id', $organization_id)->first()->name;
 }
 /**
  * change the organization data status to draft.
  * @param OrganizationData $organization
  * @return bool
  */
 public function resetOrganizationWorkflow(OrganizationData $organization)
 {
     $organization->status = 0;
     return $organization->save();
 }
 /**
  *  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;
 }
 /**
  * get total expenditure organization data
  * @param $orgId
  * @return model
  */
 public function getOrganizationTotalExpenditureData($orgId)
 {
     return $this->org->where('organization_id', $orgId)->first()->total_expenditure;
 }