File Controller, Booking Organisation, import Draft, old arrangements

This commit is contained in:
Kevin Adametz 2025-09-04 10:35:45 +02:00
parent 4eb83def39
commit 8fd1f4d451
289 changed files with 36649 additions and 10877 deletions

View file

@ -38,11 +38,11 @@ class TravelCountryController extends Controller
public function detail($id, $step = false)
{
if($id === "new") {
if ($id == "new") {
$model = new TravelCountry();
$id = 'new';
$model->active_backend = 1;
}else{
} else {
$model = TravelCountry::findOrFail($id);
$id = $model->id;
}
@ -62,15 +62,15 @@ class TravelCountryController extends Controller
{
$data = Request::all();
if(isset($data['update-action'])){
if($data['update-action'] === 'save-travel-county-service'){
$data['active'] = true;//isset($data['active']) ? true : false;
if (isset($data['update-action'])) {
if ($data['update-action'] === 'save-travel-county-service') {
$data['active'] = true; //isset($data['active']) ? true : false;
$travel_country = TravelCountry::findOrFail($id);
$data['travel_country_id'] = $travel_country->id;
$data['crm_travel_country_id'] = $travel_country->crm_id;
if($data['travel_county_service_id'] === 'new'){
if ($data['travel_county_service_id'] === 'new') {
$model = TravelCountryService::create($data);
}else{
} else {
$model = TravelCountryService::find($data['travel_county_service_id']);
$model->fill($data);
$model->save();
@ -81,7 +81,7 @@ class TravelCountryController extends Controller
}
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
if(!isset($data['contact_lands'])){
if (!isset($data['contact_lands'])) {
$data['contact_lands'] = null;
}
$data['action'] = isset($data['action']) ? $data['action'] : false;
@ -90,9 +90,9 @@ class TravelCountryController extends Controller
$data['active_frontend'] = isset($data['active_frontend']) ? true : false;
$data['active_backend'] = isset($data['active_backend']) ? true : false;
*/
if($id === "new"){
if ($id === "new") {
$model = TravelCountry::create($data);
}else{
} else {
$model = TravelCountry::find($id);
$model->fill($data);
$model->save();
@ -106,11 +106,11 @@ class TravelCountryController extends Controller
}
//TODO for this time
$tc = \App\Models\Sym\TravelCountry::find($model->crm_id);
if(!$tc){
if (!$tc) {
$tc = \App\Models\Sym\TravelCountry::create($data);
$model->crm_id = $tc->id;
$model->save();
}else {
} else {
$tc->fill($data);
$tc->save();
}
@ -119,17 +119,18 @@ class TravelCountryController extends Controller
}
public function delete($id, $del="travel_country"){
public function delete($id, $del = "travel_country")
{
if($del === 'travel_country'){
if ($del === 'travel_country') {
$model = TravelCountry::findOrFail($id);
if($model->travel_nationality_requirements){
foreach($model->travel_nationality_requirements as $travel_nationality_requirement){
if ($model->travel_nationality_requirements) {
foreach ($model->travel_nationality_requirements as $travel_nationality_requirement) {
$travel_nationality_requirement->delete();
}
}
$tc = \App\Models\Sym\TravelCountry::find($model->crm_id);
if($tc){
if ($tc) {
$tc->delete();
}
$model->delete();
@ -137,7 +138,7 @@ class TravelCountryController extends Controller
return redirect()->back();
}
if($del === 'general_file'){
if ($del === 'general_file') {
$general_file = GeneralFile::findOrFail($id);
$travel_country = $general_file->travel_country;
$fileRepo = new GeneralFileRepository($general_file);
@ -146,23 +147,18 @@ class TravelCountryController extends Controller
$general_file->delete();
\Session()->flash('alert-success', 'Datei gelöscht');
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'data']));
}
if($del === 'country_service'){
if ($del === 'country_service') {
$travel_country_service = TravelCountryService::findOrFail($id);
$travel_country = $travel_country_service->travel_country;
//check as entry
if($travel_country_service->booking_country_services->count() > 0){
if ($travel_country_service->booking_country_services->count() > 0) {
\Session()->flash('alert-error', 'Die Leistung kann nicht gelöscht werden, diese hat Einträge bei den Buchungen');
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'services']));
}
$travel_country_service->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'services']));
}
}
}