Fewo Mails / Booking Country Services
This commit is contained in:
parent
b9c26d06d0
commit
48a6eb2282
154 changed files with 7761 additions and 1643 deletions
143
app/Http/Controllers/Settings/EmailsController.php
Executable file
143
app/Http/Controllers/Settings/EmailsController.php
Executable file
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\EmailTemplate;
|
||||
use App\Models\EmailTemplateDir;
|
||||
use App\Services\Booking;
|
||||
use App\Services\BookingFewo;
|
||||
use App\Services\Util;
|
||||
use Request;
|
||||
|
||||
class EmailsController extends Controller
|
||||
{
|
||||
|
||||
protected $identifier_booking_file;
|
||||
protected $identifier_fewo_file;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->identifier_booking_file = 'booking-email-file';
|
||||
$this->identifier_fewo_file = 'fewo-email-file';
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
|
||||
public function index($step = false)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'email_template' => EmailTemplate::all(),
|
||||
'email_template_dirs' => EmailTemplateDir::all(),
|
||||
'booking_email_files' => CMSContent::where('identifier', '=', $this->identifier_booking_file)->get()->sortByDesc('pos'),
|
||||
'customer_mail_dirs' => Booking::getCustomerMailDirs(),
|
||||
'identifier_booking_file' => $this->identifier_booking_file,
|
||||
'identifier_fewo_file' => $this->identifier_fewo_file,
|
||||
'fewo_email_files' => CMSContent::where('identifier', '=', $this->identifier_fewo_file)->get()->sortByDesc('pos'),
|
||||
'customer_fewo_mail_dirs' => BookingFewo::getCustomerMailDirs(),
|
||||
'step' => $step
|
||||
|
||||
];
|
||||
return view('settings.emails.index', $data);
|
||||
}
|
||||
|
||||
public function load(){
|
||||
$data = Request::all();
|
||||
$ret = "";
|
||||
if(Request::ajax()) {
|
||||
if($data['action'] === "modal-email-template") {
|
||||
if($data['id'] === 'new'){
|
||||
$value = new EmailTemplate();
|
||||
$value->id = 0;
|
||||
$value->active = 1;
|
||||
}else{
|
||||
$value = EmailTemplate::find($data['id']);
|
||||
|
||||
}
|
||||
$directories = EmailTemplateDir::where('active', '=', true)->get();
|
||||
$ret = view("settings.emails.modal", compact('value', 'directories'))->render();
|
||||
}
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret]);
|
||||
}
|
||||
|
||||
public function update(){
|
||||
|
||||
$data = Request::all();
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
$data['step'] = isset($data['step']) ? $data['step'] : false;
|
||||
|
||||
if($data['action'] === 'email_template'){
|
||||
if($data['id'] === "new" || $data['id'] == 0){
|
||||
$model = EmailTemplate::create($data);
|
||||
}else{
|
||||
$model = EmailTemplate::find($data['id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
if($data['action'] === 'email_template_dir') {
|
||||
if($data['id'] === "new"){
|
||||
EmailTemplateDir::create($data);
|
||||
}else{
|
||||
$model = EmailTemplateDir::find($data['id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
|
||||
if($data['action'] === 'customer_mail_dirs') {
|
||||
$data['object'] = [
|
||||
'icon' => $data['icon'],
|
||||
'model' => $data['model'],
|
||||
'emails' => isset($data['emails']) ? Util::_explodeLines($data['emails']) : null,
|
||||
];
|
||||
|
||||
$pos = $data['pos'];
|
||||
if($pos > 9){
|
||||
\Session()->flash('alert-error', 'max 9 Ordner für E-Mail Ablage');
|
||||
return redirect(route('admin_settings_emails', [$data['step']]));
|
||||
}
|
||||
if($data['id'] === "new"){
|
||||
//check ist pos
|
||||
if(CMSContent::where('identifier', '=', $data['identifier'])->where('pos', '=', $pos)->count()){
|
||||
\Session()->flash('alert-error', 'Die ID '.$pos.' existiert schon');
|
||||
return redirect(route('admin_settings_emails', [$data['step']]));
|
||||
}
|
||||
CMSContent::create($data);
|
||||
//store in cms old Datebase
|
||||
\App\Models\Sym\CmsContent::create($data);
|
||||
}else{
|
||||
$model = CMSContent::find($data['id']);
|
||||
if($model->pos != $pos && CMSContent::where('identifier', '=', $data['identifier'])->where('pos', '=', $pos)->count()){
|
||||
\Session()->flash('alert-error', 'Die ID '.$pos.' existiert schon');
|
||||
return redirect(route('admin_settings_emails', [$data['step']]));
|
||||
}
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
|
||||
$m = \App\Models\Sym\CmsContent::find($data['id']);
|
||||
$m->fill($data);
|
||||
$m->save();
|
||||
}
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_settings_emails', [$data['step']]));
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
|
||||
$model = EmailTemplate::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue