Preorder: Status can now be changed manually

This commit is contained in:
Frank Schubert
2023-11-07 13:00:29 +01:00
parent bd3489f6e4
commit 79fe0aa00e
18 changed files with 367 additions and 69 deletions

View File

@@ -125,7 +125,7 @@ class VoiceplanController extends mfBaseController {
$data['name'] = $r->name;
$data['description'] = $r->description;
if($r->increment) {
/*if($r->increment) {
$increments = explode("/",$r->increment);
if(count($increments) != 2) {
$this->layout()->setFlash("Ungültige Taktung", "error");
@@ -134,7 +134,7 @@ class VoiceplanController extends mfBaseController {
$data["increment_first"] = $increments[0];
$data["increment"] = $increments[1];
}
}*/
if(!$data['name']) {
$this->layout()->setFlash("Bitte Name eingeben", "error");
@@ -153,39 +153,69 @@ class VoiceplanController extends mfBaseController {
return $this->editAction();
}
if(is_array($_FILES) && array_key_exists("voiceplanfile", $_FILES) && !$_FILES['voiceplanfile']['error']) {
// import zones
if(is_array($_FILES) && array_key_exists("voiceplanzonefile", $_FILES) && !$_FILES['voiceplanzonefile']['error']) {
// look for uploaded import file
try {
// returns File object or throws Exception on error
$file = mfUpload::handleFormUpload("voiceplanfile");
$file = mfUpload::handleFormUpload("voiceplanzonefile");
} catch (Exception $ex) {
$this->layout()->setFlash("Fehler beim Dateiupload: ".$ex->getMessage(), "error");
$this->layout()->setFlash("Fehler beim Upload des Zonenfiles: ".$ex->getMessage(), "error");
return $this->editAction();
}
$vpf = VoiceplanFileModel::create([
'voiceplan_id' => $id,
'file_id' => $file->id,
'name' => "voiceplan-import-".date("Y-m-d_H-i-s").".csv",
'name' => "voiceplan-zone-import-".date("Y-m-d_H-i-s").".csv",
]);
$voiceplanfile_id = $vpf->save();
if(!$voiceplanfile_id) {
$voiceplanzonefile_id = $vpf->save();
if(!$voiceplanzonefile_id) {
$this->layout()->setFlash("Fehler beim Speichern der hochgeladenen Datei", "error");
return $this->editAction();
}
// if file was uploaded successfully, delete old destinations
// if file was uploaded successfully, delete old destinations and zones
foreach(VoiceplandestinationModel::search(['voiceplan_id' => $id]) as $destination) {
$destination->delete();
}
foreach(VoiceplanzoneModel::search(['voiceplan_id' => $id]) as $zone) {
$zone->delete();
}
if(!$voiceplan->importDestinationsFromCsv($file)) {
$this->layout()->setFlash("Fehler beim Importieren!", "error");
if(!$voiceplan->importZonesFromCsv($file)) {
$this->layout()->setFlash("Fehler beim Importieren der Zonen!", "error");
return $this->editAction();
}
// import destinations
if(is_array($_FILES) && array_key_exists("voiceplandestinationfile", $_FILES) && !$_FILES['voiceplandestinationfile']['error']) {
// look for uploaded import file
try {
// returns File object or throws Exception on error
$file = mfUpload::handleFormUpload("voiceplandestinationfile");
} catch (Exception $ex) {
$this->layout()->setFlash("Fehler beim Upload des Destinationfiles: ".$ex->getMessage(), "error");
return $this->editAction();
}
$vpf = VoiceplanFileModel::create([
'voiceplan_id' => $id,
'file_id' => $file->id,
'name' => "voiceplan-dest-import-".date("Y-m-d_H-i-s").".csv",
]);
$voiceplandestinationfile_id = $vpf->save();
if(!$voiceplandestinationfile_id) {
$this->layout()->setFlash("Fehler beim Speichern der hochgeladenen Datei", "error");
return $this->editAction();
}
if(!$voiceplan->importDestinationsFromCsv($file)) {
$this->layout()->setFlash("Fehler beim Importieren!", "error");
return $this->editAction();
}
}
}
$this->layout()->setFlash("Sprachtarifpaket erfolgreich gespeichert!", "success");