diff --git a/app/Models/V2/Projects/ProjectReport.php b/app/Models/V2/Projects/ProjectReport.php index aa44ec36..2ed0c631 100644 --- a/app/Models/V2/Projects/ProjectReport.php +++ b/app/Models/V2/Projects/ProjectReport.php @@ -160,7 +160,16 @@ class ProjectReport extends Model implements MediaModel, AuditableContract, Repo 'beneficiaries_scstobc_farmers', 'beneficiaries_scstobc', 'total_unique_restoration_partners', - + 'business_milestones', + 'ft_other', + 'pt_other', + 'volunteer_other', + 'beneficiaries_other', + 'beneficiaries_training_women', + 'beneficiaries_training_men', + 'beneficiaries_training_other', + 'beneficiaries_training_youth', + 'beneficiaries_training_non_youth', // virtual (see HasWorkdays trait) 'other_workdays_description', // virtual (see HasRestorationPartners trait) diff --git a/app/Models/V2/Sites/SiteReport.php b/app/Models/V2/Sites/SiteReport.php index 439fdfab..bfa5eb83 100644 --- a/app/Models/V2/Sites/SiteReport.php +++ b/app/Models/V2/Sites/SiteReport.php @@ -100,7 +100,10 @@ class SiteReport extends Model implements MediaModel, AuditableContract, ReportM 'water_structures', 'site_community_partners_description', 'site_community_partners_income_increase_description', - + 'pct_survival_to_date', + 'survival_calculation', + 'survival_description', + 'maintenance_activities', // virtual (see HasWorkdays trait) 'other_workdays_description', ]; @@ -239,6 +242,11 @@ public function nonTreeSpecies() return $this->morphMany(TreeSpecies::class, 'speciesable')->where('collection', 'non-tree'); } + public function replantingTreeSpecies() + { + return $this->morphMany(TreeSpecies::class, 'speciesable')->where('collection', 'replanting'); + } + public function seedings(): MorphMany { return $this->morphMany(Seeding::class, 'seedable'); diff --git a/config/wri/linked-fields.php b/config/wri/linked-fields.php index afbe3169..d9db8ddd 100644 --- a/config/wri/linked-fields.php +++ b/config/wri/linked-fields.php @@ -459,6 +459,17 @@ 'pro-rep-indirect-beneficiaries-description' => ['property' => 'indirect_beneficiaries_description', 'label' => 'Indirect Beneficiaries Description', 'input_type' => 'long-text'], 'pro-rep-other-restoration-partners-description' => ['property' => 'other_restoration_partners_description', 'label' => 'Other Restoration Partners Description', 'input_type' => 'long-text'], 'pro-rep-total-unique-restoration-partners' => ['property' => 'total_unique_restoration_partners', 'label' => 'Total Unique Restoration Partners', 'input_type' => 'number'], + // New fields TM-1542 + 'pro-rep-business-milestones' => ['property' => 'business_milestones', 'label' => 'Business Milestones', 'input_type' => 'long-text'], + 'pro-rep-ft-other' => ['property' => 'ft_other', 'label' => 'Full Time Other Gender', 'input_type' => 'number'], + 'pro-rep-pt-other' => ['property' => 'pt_other', 'label' => 'Part Time Other Gender', 'input_type' => 'number'], + 'pro-rep-volunteer_other' => ['property' => 'volunteer_other', 'label' => 'Volunteer Other Gender', 'input_type' => 'number'], + 'pro-rep-beneficiaries-other' => ['property' => 'beneficiaries_other', 'label' => 'Other Gender Beneficiary', 'input_type' => 'number'], + 'pro-rep-beneficiaries-training-women' => ['property' => 'beneficiaries_training_women', 'label' => 'Women Trained', 'input_type' => 'number'], + 'pro-rep-beneficiaries-training-men' => ['property' => 'beneficiaries_training_men', 'label' => 'Men Trained', 'input_type' => 'number'], + 'pro-rep-beneficiaries-training-other' => ['property' => 'beneficiaries_training_other', 'label' => 'Other Gender Trained', 'input_type' => 'number'], + 'pro-rep-beneficiaries-training-youth' => ['property' => 'beneficiaries_training_youth', 'label' => 'Youth Trained', 'input_type' => 'number'], + 'pro-rep-beneficiaries-training-non-youth' => ['property' => 'beneficiaries_training_non_youth', 'label' => 'Non Youth Trained', 'input_type' => 'number'], ], 'relations' => [ 'pro-rep-rel-tree-species' => [ @@ -784,6 +795,11 @@ 'site-rep-other-workdays-description' => ['property' => 'other_workdays_description', 'label' => 'Other Activities Description', 'input_type' => 'long-text'], 'site-rep-num-trees-regenerating' => ['property' => 'num_trees_regenerating', 'label' => 'Estimate Number of Trees Restored via ANR', 'input_type' => 'number'], 'site-rep-regeneration-description' => ['property' => 'regeneration_description', 'label' => 'Description of ANR Activities', 'input_type' => 'long-text'], + // New fields TM-1542 + 'site-rep-pct-survival-to-date' => ['property' => 'pct_survival_to_date', 'label' => 'Survival Rate', 'input_type' => 'number'], + 'site-rep-survival-calculation' => ['property' => 'survival_calculation', 'label' => 'Description of Survival Rate Calculation', 'input_type' => 'long-text'], + 'site-rep-survival-description' => ['property' => 'survival_description', 'label' => 'Explanation of Survival Rate', 'input_type' => 'long-text'], + 'site-rep-maintenance-activities' => ['property' => 'maintenance_activities', 'label' => 'Maintenance Activities', 'input_type' => 'long-text'], ], 'file-collections' => [ 'site-rep-col-media' => ['property' => 'media', 'label' => 'Media', 'input_type' => 'file', 'multichoice' => true], @@ -796,6 +812,13 @@ 'site-rep-col-site-submission' => ['property' => 'site_submission', 'label' => 'Site submission', 'input_type' => 'file', 'multichoice' => true], ], 'relations' => [ + 'site-rep-rel-replanting-tree-species' => [ + 'property' => 'replantingTreeSpecies', + 'label' => 'Replanting Species + Count', + 'resource' => 'App\Http\Resources\V2\TreeSpecies\TreeSpeciesResource', + 'input_type' => 'treeSpecies', + 'collection' => 'replanting', + ], 'site-rep-rel-tree-species' => [ 'property' => 'treeSpecies', 'label' => 'Tree Species', diff --git a/database/migrations/2024_12_06_182649_add_report_fields_for_project_and_site_report.php b/database/migrations/2024_12_06_182649_add_report_fields_for_project_and_site_report.php new file mode 100644 index 00000000..26499a5e --- /dev/null +++ b/database/migrations/2024_12_06_182649_add_report_fields_for_project_and_site_report.php @@ -0,0 +1,61 @@ +longText('business_milestones')->nullable(); + $table->unsignedInteger('ft_other')->nullable(); + $table->unsignedInteger('pt_other')->nullable(); + $table->unsignedInteger('volunteer_other')->nullable(); + $table->unsignedInteger('beneficiaries_other')->nullable(); + $table->unsignedInteger('beneficiaries_training_women')->nullable(); + $table->unsignedInteger('beneficiaries_training_men')->nullable(); + $table->unsignedInteger('beneficiaries_training_other')->nullable(); + $table->unsignedInteger('beneficiaries_training_youth')->nullable(); + $table->unsignedInteger('beneficiaries_training_non_youth')->nullable(); + }); + + Schema::table('v2_site_reports', function (Blueprint $table) { + $table->unsignedInteger('pct_survival_to_date')->nullable(); + $table->longText('survival_calculation')->nullable(); + $table->longText('survival_description')->nullable(); + $table->longText('maintenance_activities')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + Schema::table('v2_project_reports', function (Blueprint $table) { + $table->dropColumn('business_milestones'); + $table->dropColumn('ft_other'); + $table->dropColumn('pt_other'); + $table->dropColumn('volunteer_other'); + $table->dropColumn('beneficiaries_other'); + $table->dropColumn('beneficiaries_training_women'); + $table->dropColumn('beneficiaries_training_men'); + $table->dropColumn('beneficiaries_training_other'); + $table->dropColumn('beneficiaries_training_youth'); + $table->dropColumn('beneficiaries_training_non_youth'); + }); + + Schema::table('v2_site_reports', function (Blueprint $table) { + $table->dropColumn('pct_survival_to_date'); + $table->dropColumn('survival_calculation'); + $table->dropColumn('survival_description'); + $table->dropColumn('maintenance_activities'); + }); + } +};