Upload Files Booking, Mails, Attachments,

This commit is contained in:
Kevin Adametz 2020-04-17 15:51:22 +02:00
parent 5daea268f7
commit 68b9d1ff88
92 changed files with 2837 additions and 1778 deletions

View file

@ -7,6 +7,7 @@ use App\Models\CustomerFile;
use App\Models\CustomerMail;
use App\Repositories\CustomerMailRepository;
use App\Repositories\CustomerFileRepository;
use App\Services\Util;
use Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\URL;
@ -53,14 +54,19 @@ class CustomerMailController extends Controller
}
public function store($id)
public function store($id, $action=false)
{
$data = Request::all();
$customer_mail = CustomerMail::findOrFail($id);
if($action === 'move-mail'){
$data['travel_country_id'] = isset($data['travel_country_id']) && $data['travel_country_id'] ? $data['travel_country_id'] : null;
$customer_mail->dir = $data['dir'];
$customer_mail->travel_country_id = $data['travel_country_id'];
$customer_mail->save();
}
return back();
/* $data = Request::all();
\Session()->flash('alert-save', '1');
return redirect(route('lead_detail', [$lead->id]));*/
}
public function delete($id){
@ -201,11 +207,36 @@ class CustomerMailController extends Controller
$status = false;
if(Request::ajax()){
if($data['action'] === 'toggle_important'){
$customer_mail = CustomerMail::find($data['id']);
$customer_mail = CustomerMail::find($data['id']);
$customer_mail->important = ($customer_mail->important ? false : true);
$customer_mail->save();
$status = 'success';
}
if($data['action'] === 'add_attachment'){
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$contents = file_get_contents($data['target'], false, stream_context_create($arrContextOptions));
$mine = Util::getMimeFromHeader($http_response_header);
$extension = Util::getExtensionFromMime($mine);
$fileRepo = new CustomerFileRepository(new CustomerFile());
$fileRepo->_set('disk', 'customer');
$fileRepo->_set('dir', '/attachment/'.date('Y/m').'/');
$fileRepo->_set('customer_id', NULL);
$fileRepo->_set('customer_mail_id', NULL);
$fileRepo->_set('identifier', 'tmp');
$fileRepo->_set('originalName', $data['name']);
$fileRepo->_set('mine', $mine);
$fileRepo->_set('extension', $extension);
return $fileRepo->storeFile($contents);
}
}
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
}