diff --git a/laravel_app/app/Imports/ExcelFileImport.php b/laravel_app/app/Imports/ExcelFileImport.php
new file mode 100644
index 0000000..eefeb70
--- /dev/null
+++ b/laravel_app/app/Imports/ExcelFileImport.php
@@ -0,0 +1,26 @@
+min = now();
+ }
+
+ /**
+ * @param Collection $collection
+ */
+ public function collection(Collection $collection)
+ {
+ return collect([1,2,3]);
+ foreach ($collection as $row){
+
+ }
+ }
+}
diff --git a/laravel_app/app/Imports/HarvestDataImport.php b/laravel_app/app/Imports/HarvestDataImport.php
new file mode 100644
index 0000000..c482810
--- /dev/null
+++ b/laravel_app/app/Imports/HarvestDataImport.php
@@ -0,0 +1,16 @@
+formData['harvest_file'] = $this->harvestDataFiles[0] ?? null;
$this->formData['download_path'] = $this->formData['download_path'] ?? $this->formData['name'];
}
+
+
}
diff --git a/laravel_app/app/Livewire/Projects/Tabs/Settings.php b/laravel_app/app/Livewire/Projects/Tabs/Settings.php
index 1b70e9a..ba0a941 100644
--- a/laravel_app/app/Livewire/Projects/Tabs/Settings.php
+++ b/laravel_app/app/Livewire/Projects/Tabs/Settings.php
@@ -8,11 +8,13 @@
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
+use Laravel\Jetstream\InteractsWithBanner;
use Livewire\Component;
use Livewire\WithFileUploads;
class Settings extends Component
{
+ use InteractsWithBanner;
use WithFileUploads;
public $formData = [];
@@ -63,6 +65,7 @@ public function saveProject()
//dd(route('project.show',[$this->formData['name'],$this->formData['id'],'settings']));
return redirect()->route('project.show',[$this->formData['name'],$this->formData['id'],'settings']);
//$this->dispatch('saved');
+
}
public function saveMailSettings()
@@ -82,6 +85,7 @@ public function saveSettings()
$this->shouldReload();
Project::saveWithFormData($this->formData);
if($this->isDirty) redirect()->route('project.show',[$this->formData['name'],$this->formData['id'],'settings']);
+ $this->dispatch('download_notify',title:'Download',message:'hallo');
$this->dispatch('saved');
}
@@ -195,6 +199,7 @@ private function validateForm()
}],
'harvest_file' => ['sometimes', new HarvestFile],
])->validate();
+
}
private function validateEmailSettingsForm()
diff --git a/laravel_app/app/Models/Project.php b/laravel_app/app/Models/Project.php
index 8e3eb53..3af9cdd 100644
--- a/laravel_app/app/Models/Project.php
+++ b/laravel_app/app/Models/Project.php
@@ -13,7 +13,8 @@
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
-use function Livewire\off;
+use Maatwebsite\Excel\Facades\Excel;
+use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDate;
class Project extends Model
{
@@ -331,4 +332,21 @@ public function getMosaicsFor(Carbon $endDate, int $offset= 7): array
->filter()
->toArray();
}
+
+ public function missingDownloadsInHarvestFile()
+ {
+ if(!$this->harvest_json_path){
+ return;
+ }
+ $dates = $this->downloads->map(fn($d)=>$d->date)->sort();
+ }
+ private function getMinimumDateFromHarvestExcelFile()
+ {
+ $value = Storage::disk('local')->path($this->harvest_json_path);
+ $data = Excel::toCollection(new \App\Imports\ExcelFileImport(),$value);
+ $season_start_index = $data->first()->first()->search('season_start');
+ return collect($data->first()->slice(1))->reduce(function($carry,$value,$key) use ($season_start_index){
+ return min($carry,Carbon::instance(SharedDate::excelToDateTimeObject($value[$season_start_index])));
+ },now());
+ }
}
diff --git a/laravel_app/app/Models/ProjectDownload.php b/laravel_app/app/Models/ProjectDownload.php
index ea3af3d..fe773bc 100644
--- a/laravel_app/app/Models/ProjectDownload.php
+++ b/laravel_app/app/Models/ProjectDownload.php
@@ -4,6 +4,7 @@
use App\Events\ProjectDownloadStatus;
use App\Traits\HasStatus;
+use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@@ -24,6 +25,11 @@ public function project(): \Illuminate\Database\Eloquent\Relations\BelongsTo
return $this->belongsTo(Project::class);
}
+ public function getDateAttribute():Carbon
+ {
+ return Carbon::parse(explode('.',$this->name)[0]);
+ }
+
protected static function booted(): void
{
parent::booted();
diff --git a/laravel_app/app/Rules/HarvestFile.php b/laravel_app/app/Rules/HarvestFile.php
index 14e26e7..1f98a77 100644
--- a/laravel_app/app/Rules/HarvestFile.php
+++ b/laravel_app/app/Rules/HarvestFile.php
@@ -21,7 +21,6 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
if(!in_array($value['extension'], ['xlsx', 'xls', 'csv', 'ods'])) {
$fail($value['extension'].' is not a valid file (.xlsx, .xls, .csv, .ods).');
}
-
try{
$excelHeaderArray = (new HeadingRowImport)->toArray($value['path']);
$header = $excelHeaderArray[0][0];
diff --git a/laravel_app/database/migrations/2024_06_25_092126_add_min_harvest_date_column_to_projects.php b/laravel_app/database/migrations/2024_06_25_092126_add_min_harvest_date_column_to_projects.php
new file mode 100644
index 0000000..964692f
--- /dev/null
+++ b/laravel_app/database/migrations/2024_06_25_092126_add_min_harvest_date_column_to_projects.php
@@ -0,0 +1,28 @@
+date('min_harvest_date')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('projects', function (Blueprint $table) {
+ $table->dropColumn('min_harvest_date');
+ });
+ }
+};
diff --git a/laravel_app/resources/views/layouts/app.blade.php b/laravel_app/resources/views/layouts/app.blade.php
index 2f65886..9cdbf0f 100644
--- a/laravel_app/resources/views/layouts/app.blade.php
+++ b/laravel_app/resources/views/layouts/app.blade.php
@@ -37,6 +37,7 @@