01 2020
This commit is contained in:
parent
bed91c4f4a
commit
c8948338bb
122 changed files with 7911 additions and 1639 deletions
191
app/Http/Controllers/API/BookingController.php
Executable file
191
app/Http/Controllers/API/BookingController.php
Executable file
|
|
@ -0,0 +1,191 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Arrangement;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingServiceItem;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Lead;
|
||||
use App\Models\Participant;
|
||||
use App\Models\TravelBooking;
|
||||
use App\Repositories\DraftRepository;
|
||||
|
||||
|
||||
class BookingController extends Controller
|
||||
{
|
||||
private $successStatus = 200;
|
||||
private $successKey = 'f6077389c9ce710e554763a5de02c8ec';
|
||||
|
||||
protected $draftRepo;
|
||||
|
||||
public function __construct(DraftRepository $draftRepo)
|
||||
{
|
||||
$this->draftRepo = $draftRepo;
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
|
||||
$request = \Request::all();
|
||||
if($request['key'] !== $this->successKey){
|
||||
return response()->json(['error' => "key"], 401);
|
||||
}
|
||||
$travel_booking = TravelBooking::find($request['travel_booking_id']);
|
||||
|
||||
// $travel_booking = TravelBooking::find(2458);
|
||||
if(!$travel_booking){
|
||||
return response()->json(['error' => 'no-booking-found'], $this->successStatus);
|
||||
}
|
||||
|
||||
// ---- createCustomer
|
||||
$data = [
|
||||
'salutation_id' => $travel_booking->salutation_id,
|
||||
'name' => $travel_booking->last_name,
|
||||
'firstname' => $travel_booking->first_name,
|
||||
'street' => $travel_booking->street,
|
||||
'zip' => $travel_booking->zipcode,
|
||||
'city' => $travel_booking->city,
|
||||
'country_id' => $travel_booking->country_id,
|
||||
'phone' => $travel_booking->phone,
|
||||
'phonemobile' => $travel_booking->mobile,
|
||||
'email' => $travel_booking->email
|
||||
];
|
||||
$customer = Customer::create($data);
|
||||
|
||||
// ---- createLead
|
||||
$data = [
|
||||
'customer_id' => $customer->id,
|
||||
'request_date' => $travel_booking->created,
|
||||
'travelperiod_start' => $travel_booking->selected_start_date,
|
||||
'travelperiod_end' => $travel_booking->selected_end_date,
|
||||
'remarks' => $travel_booking->comments,
|
||||
'sf_guard_user_id' => 15,
|
||||
'is_closed' => true,
|
||||
'initialcontacttype_id' => 14,
|
||||
'status_id' => 7,
|
||||
'website_id' => 1,
|
||||
];
|
||||
$lead = Lead::create($data);
|
||||
$lead->updateNextDueDate();
|
||||
|
||||
|
||||
$data = [
|
||||
'booking_date' => $travel_booking->created->format('Y-m-d'),
|
||||
'customer_id' => $customer->id,
|
||||
'lead_id' => $lead->id,
|
||||
'new_drafts' => $travel_booking->drafts === null ? 0 : 1,
|
||||
'sf_guard_user_id' => 15,
|
||||
'branch_id' => 4,
|
||||
'travel_country_id' => isset($travel_booking->selected_travel['travel_country_id'][0]) ? $travel_booking->selected_travel['travel_country_id'][0] : null,
|
||||
'travel_category_id' => isset($travel_booking->selected_travel['travel_category_id']) ? $travel_booking->selected_travel['travel_category_id'] : null,
|
||||
'pax' => $travel_booking->selected_adults,
|
||||
'title' => isset($travel_booking->selected_travel['travel_title']) ? $travel_booking->selected_travel['travel_title'] : "",
|
||||
'start_date' => $travel_booking->selected_start_date->format('Y-m-d'),
|
||||
'end_date' => $travel_booking->selected_end_date->format('Y-m-d'),
|
||||
'website_id' => 1,
|
||||
'travel_number' => isset($travel_booking->selected_travel['travel_number']) ? $travel_booking->selected_travel['travel_number'] : null,
|
||||
'participant_name' => isset($travel_booking->participants[0]['last_name']) ? $travel_booking->participants[0]['last_name'] : null,
|
||||
'participant_firstname' => isset($travel_booking->participants[0]['first_name']) ? $travel_booking->participants[0]['first_name'] : null,
|
||||
'participant_birthdate' => isset($travel_booking->participants[0]['birthday']) ? date( "Y-m-d", strtotime($travel_booking->participants[0]['birthday'])) : null,
|
||||
'participant_salutation_id' => isset($travel_booking->participants[0]['gender']) ? $travel_booking->participants[0]['gender'] : null,
|
||||
'travel_company_id' => isset($travel_booking->service_items[0]['travel_company_id']) ? $travel_booking->service_items[0]['travel_company_id'] : null,
|
||||
'price' => $travel_booking->price,
|
||||
'price_total' => $travel_booking->price_total,
|
||||
'deposit_total' => $travel_booking->deposit_total,
|
||||
'final_payment' => $travel_booking->final_payment,
|
||||
'final_payment_date' => $travel_booking->final_payment_date->format('Y-m-d'),
|
||||
'travelagenda_id' => isset($travel_booking->selected_travel['travelagenda_id']) ? $travel_booking->selected_travel['travelagenda_id'] : null,
|
||||
];
|
||||
|
||||
//createBooking
|
||||
$booking = Booking::create($data);
|
||||
|
||||
//createTraveler
|
||||
if($travel_booking->participants){
|
||||
foreach ($travel_booking->participants as $key => $participant){
|
||||
if($key > 0){
|
||||
Participant::create([
|
||||
'booking_id' => $booking->id,
|
||||
'participant_name' => $participant['last_name'],
|
||||
'participant_firstname' => $participant['first_name'],
|
||||
'participant_birthdate' => date( "Y-m-d", strtotime($participant['birthday'])),
|
||||
'participant_salutation_id' => $participant['gender'],
|
||||
'participant_child' => $participant['child'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//createServiceItem //service_items
|
||||
if($travel_booking->service_items){
|
||||
foreach ($travel_booking->service_items as $key => $service_item){
|
||||
BookingServiceItem::create([
|
||||
'booking_id' => $booking->id,
|
||||
'travel_company_id' => $service_item['travel_company_id'],
|
||||
'service_price' => $service_item['service_price'],
|
||||
'service_price_refund' => 0,
|
||||
'commission' => $service_item['commission'],
|
||||
'travel_date' => $service_item['travel_date'],
|
||||
'name' => $service_item['name'],
|
||||
'is_commission_locked' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//createServiceItem //insurances
|
||||
if($travel_booking->insurances){
|
||||
foreach ($travel_booking->insurances as $key => $service_item){
|
||||
BookingServiceItem::create([
|
||||
'booking_id' => $booking->id,
|
||||
'travel_company_id' => $service_item['travel_company_id'],
|
||||
'service_price' => $service_item['price'],
|
||||
'service_price_refund' => 0,
|
||||
'commission' => $service_item['commission'],
|
||||
'travel_date' => $service_item['travel_date'],
|
||||
'name' => $service_item['name'],
|
||||
'is_commission_locked' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//createArrangement
|
||||
if($travel_booking->arrangements) {
|
||||
foreach ($travel_booking->arrangements as $key => $arrangement){
|
||||
Arrangement::create([
|
||||
'state' => isset($arrangement['state']) ? $arrangement['state'] : null,
|
||||
'begin' => isset($arrangement['end']) ? $arrangement['end'] : null,
|
||||
'end' => isset($arrangement['end']) ? $arrangement['end'] : null,
|
||||
'type_s' => isset($arrangement['type_s']) ? $arrangement['type_s'] : null,
|
||||
'data_s' => isset($arrangement['data_s']) ? $arrangement['data_s'] : null,
|
||||
'view_position' => isset($arrangement['view_position']) ? $arrangement['view_position'] : null,
|
||||
'booking_id' => $booking->id,
|
||||
'type_id' => $arrangement['type_id'],
|
||||
'in_pdf' => isset($arrangement['in_pdf']) ? $arrangement['in_pdf'] : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//createDrafts
|
||||
|
||||
if($travel_booking->drafts) {
|
||||
$this->draftRepo->create_drafts_from_booking($booking->id, $travel_booking->drafts);
|
||||
}
|
||||
|
||||
$travel_booking->crm_booking_id = $booking->id;
|
||||
$travel_booking->save();
|
||||
$ret= [
|
||||
'url_v1' => make_old_url('/index.php/booking/'.$booking->id.'/edit'),
|
||||
'url_v3' => route('booking_detail', $booking->id),
|
||||
'lead_id' => $lead->id
|
||||
];
|
||||
return response()->json(['success' => "import", "ret" => $ret], $this->successStatus);
|
||||
//return response()->json(['error' => 'no-node'], $this->successStatus);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -10,7 +10,8 @@ use App\Models\TravelGuide;
|
|||
|
||||
class CMSContentController extends Controller
|
||||
{
|
||||
public $successStatus = 200;
|
||||
private $successStatus = 200;
|
||||
private $successKey = 'f6077389c9ce710e554763a5de02c8ec';
|
||||
|
||||
|
||||
public function search()
|
||||
|
|
@ -22,7 +23,7 @@ class CMSContentController extends Controller
|
|||
return response()->json(['error' => "request no found"], $this->successStatus);
|
||||
}
|
||||
|
||||
if($request['key'] !== 'f6077389c9ce710e554763a5de02c8ec'){
|
||||
if($request['key'] !== $this->successKey){
|
||||
return response()->json(['error' => "key"], 401);
|
||||
}
|
||||
|
||||
|
|
@ -35,11 +36,13 @@ class CMSContentController extends Controller
|
|||
$tree = IQContentTree::whereIdentifier($tree_identifier)->first();
|
||||
$travel_guide = null;
|
||||
$url = "";
|
||||
$ret['title'] = "";
|
||||
$ret['description'] = "";
|
||||
if($tree){
|
||||
$lvl = 0;
|
||||
|
||||
$ret['tree'] = $tree->toArray();
|
||||
$ret['navi'] = $this->makeNaviTree($tree, $urlArray, "", 0, false);
|
||||
|
||||
$url = "/".$tree->identifier;
|
||||
$ret['bread_crumb'][$lvl] = [
|
||||
'title' => $tree->name,
|
||||
|
|
@ -51,14 +54,15 @@ class CMSContentController extends Controller
|
|||
$tree_node = IQContentTreeNode::whereTreeId($tree->id)->whereIdentifier($tree_node_identifier)->whereLvl($lvl)->whereActive(true)->first();
|
||||
|
||||
if($tree_node){
|
||||
$lvl ++;
|
||||
$ret['title'] = $tree_node->title;
|
||||
$ret['description'] = $tree_node->description;;
|
||||
$url = $url."/".$tree_node->identifier;
|
||||
$ret['bread_crumb'][$lvl] = [
|
||||
'title' => $tree_node->name,
|
||||
'url' => $url,
|
||||
];
|
||||
|
||||
$ret['nodes'][$lvl] = $tree_node->toArray();
|
||||
$lvl ++;
|
||||
}else{
|
||||
return response()->json(['error' => 'no-node'], $this->successStatus);
|
||||
}
|
||||
|
|
@ -69,12 +73,18 @@ class CMSContentController extends Controller
|
|||
if($tree_node->iq_content_sites->count()){
|
||||
foreach ($tree_node->iq_content_sites as $iq_content_site){
|
||||
if(isset($iq_content_site->travel_guide) && $iq_content_site->travel_guide && $iq_content_site->travel_guide->active){
|
||||
$ret['sites'][] = $iq_content_site->travel_guide->toArray();
|
||||
$key = ($iq_content_site->travel_guide->scope -1) *-1;
|
||||
$ret['sites'][$key] = $iq_content_site->travel_guide->toArray();
|
||||
/*if(!$travel_guide){
|
||||
//$travel_guide = $iq_content_site->travel_guide;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
if(isset($ret['sites'])){
|
||||
ksort($ret['sites']);
|
||||
$ret['sites'] = array_values($ret['sites']);
|
||||
}
|
||||
|
||||
}
|
||||
//children
|
||||
if($tree_node->iq_content_tree_node_childs->count()){
|
||||
|
|
|
|||
|
|
@ -33,35 +33,42 @@ class CMSContentInfoController extends Controller
|
|||
$locals = CMSInfoAvailable::whereType('local')->whereSpecial(false)->get();
|
||||
foreach ($locals as $value){
|
||||
$date = CMSInfoAvailable::getWeekWithDate($value->wday);
|
||||
$ret['local'][$date['date']] = [
|
||||
$ret['local'][strtotime($date['date'])] = [
|
||||
'day'=>$days[$value->wday],
|
||||
'active' => $value->active,
|
||||
'from' => $value->from,
|
||||
'to' => $value->to,
|
||||
'date' => $date['date'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
$phones = CMSInfoAvailable::whereType('phone')->whereSpecial(false)->get();
|
||||
foreach ($phones as $value){
|
||||
$date = CMSInfoAvailable::getWeekWithDate($value->wday);
|
||||
$ret['phone'][$date['date']] = [
|
||||
$ret['phone'][strtotime($date['date'])] = [
|
||||
'day'=>$days[$value->wday],
|
||||
'active' => $value->active,
|
||||
'from' => $value->from,
|
||||
'to' => $value->to,
|
||||
'date' => $date['date'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
$specials = CMSInfoAvailable::whereSpecial(true)->get();
|
||||
foreach ($specials as $special){
|
||||
$ret[$special->type][$special->date] = [
|
||||
$ret[$special->type][strtotime($special->date)] = [
|
||||
'day'=>$days[$special->wday],
|
||||
'active' => $special->active,
|
||||
'from' => $special->from,
|
||||
'to' => $special->to,
|
||||
'date' => $special->date,
|
||||
|
||||
];
|
||||
}
|
||||
// ksort($ret);
|
||||
ksort($ret['local']);
|
||||
ksort($ret['phone']);
|
||||
|
||||
$ret['info']['office_important_note_active'] = CMSInfo::getContentBySlug('office-important-note-active');
|
||||
$ret['info']['office_important_note'] = CMSInfo::getContentBySlug('office-important-note');
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ class DraftController extends Controller
|
|||
{
|
||||
public $successStatus = 200;
|
||||
public $data = "";
|
||||
public $room_str = "";
|
||||
public $room_name = "";
|
||||
public $className = "";
|
||||
public $option = "";
|
||||
|
||||
|
|
@ -23,12 +21,12 @@ class DraftController extends Controller
|
|||
{
|
||||
|
||||
|
||||
if ($action == "get_draft_list") {
|
||||
if ($action === "get_draft_list") {
|
||||
$drafts = Draft::where('active', true)->get()->sortByDesc("id");
|
||||
return response()->json(['success' => $drafts], $this->successStatus);
|
||||
}
|
||||
|
||||
if ($action == "get_draft_list_for_table") {
|
||||
if ($action === "get_draft_list_for_table") {
|
||||
$ret = [];
|
||||
if (request('program_id') && request('program_id') > 0) {
|
||||
$travel_program = TravelProgram::find(request('program_id'));
|
||||
|
|
@ -50,20 +48,19 @@ class DraftController extends Controller
|
|||
|
||||
}
|
||||
|
||||
if ($action == "create_drafts_from_fewo") {
|
||||
if ($action === "create_drafts_from_fewo") {
|
||||
$data = \Input::all();
|
||||
$start_date = Carbon::parse($data['startDateStr']);
|
||||
$end_date = Carbon::parse($data['endDateStr']);
|
||||
$pos = 0;
|
||||
if(isset($data['priceResult']) && is_array($data['priceResult'])){
|
||||
if (isset($data['priceResult']) && is_array($data['priceResult'])) {
|
||||
|
||||
if(isset($data['priceResult']['season']) && is_array($data['priceResult']['season'])){
|
||||
foreach ($data['priceResult']['season'] as $season => $values){
|
||||
|
||||
$service = '* Saison: '.$season."\n".
|
||||
'* Mindestbelegung: '.$values['minimumStay'].' '.($values['minimumStay'] < 2 ? 'Nacht' : 'Nächte')."\n".
|
||||
'* Preis: '.number_format($values['price'], 2, ',', '.').' € / '. $values['numberDays'].' '.($values['numberDays'] < 2 ? 'Nacht' : 'Nächte').' x '.number_format($values['perNight'], 2, ',', '.')." € \n";
|
||||
if (isset($data['priceResult']['season']) && is_array($data['priceResult']['season'])) {
|
||||
foreach ($data['priceResult']['season'] as $season => $values) {
|
||||
|
||||
$service = '* Saison: ' . $season . "\n" .
|
||||
'* Mindestbelegung: ' . $values['minimumStay'] . ' ' . ($values['minimumStay'] < 2 ? 'Nacht' : 'Nächte') . "\n" .
|
||||
'* Preis: ' . number_format($values['price'], 2, ',', '.') . ' € / ' . $values['numberDays'] . ' ' . ($values['numberDays'] < 2 ? 'Nacht' : 'Nächte') . ' x ' . number_format($values['perNight'], 2, ',', '.') . " € \n";
|
||||
|
||||
|
||||
$from_date = Carbon::parse($values['fromDay']);
|
||||
|
|
@ -75,7 +72,7 @@ class DraftController extends Controller
|
|||
'fewo_lodging_id' => $data['fewo_lodging_id'],
|
||||
'draft_type_id' => 38,
|
||||
'request_date' => $data['request_date'],
|
||||
'days_duration' => $values['numberDays'],
|
||||
'days_duration' => $values['numberDays'],
|
||||
'start_date' => $from_date->format("Y-m-d"),
|
||||
'end_date' => $to_date->format("Y-m-d"),
|
||||
'service' => $service,
|
||||
|
|
@ -87,14 +84,14 @@ class DraftController extends Controller
|
|||
|
||||
}
|
||||
}
|
||||
if(isset($data['priceResult']['flatPrice'])){
|
||||
$service = '* Service-Gebühr: '.number_format($data['priceResult']['deposit'], 2, ',', '.');
|
||||
if (isset($data['priceResult']['flatPrice'])) {
|
||||
$service = '* Service-Gebühr: ' . number_format($data['priceResult']['deposit'], 2, ',', '.');
|
||||
BookingDraftItem::create([
|
||||
'booking_id' => $data['booking_id'],
|
||||
'fewo_lodging_id' => $data['fewo_lodging_id'],
|
||||
'draft_type_id' => 39,
|
||||
'request_date' => $data['request_date'],
|
||||
'days_duration' => $data['priceResult']['days'],
|
||||
'days_duration' => $data['priceResult']['days'],
|
||||
'start_date' => $start_date->format("Y-m-d"),
|
||||
'end_date' => $end_date->format("Y-m-d"),
|
||||
'service' => $service,
|
||||
|
|
@ -106,14 +103,14 @@ class DraftController extends Controller
|
|||
|
||||
|
||||
}
|
||||
if(isset($data['priceResult']['deposit'])){
|
||||
$service = '* Kaution: '.number_format($data['priceResult']['deposit'], 2, ',', '.');
|
||||
if (isset($data['priceResult']['deposit'])) {
|
||||
$service = '* Kaution: ' . number_format($data['priceResult']['deposit'], 2, ',', '.');
|
||||
BookingDraftItem::create([
|
||||
'booking_id' => $data['booking_id'],
|
||||
'fewo_lodging_id' => $data['fewo_lodging_id'],
|
||||
'draft_type_id' => 40,
|
||||
'request_date' => $data['request_date'],
|
||||
'days_duration' => $data['priceResult']['days'],
|
||||
'days_duration' => $data['priceResult']['days'],
|
||||
'start_date' => $start_date->format("Y-m-d"),
|
||||
'end_date' => $end_date->format("Y-m-d"),
|
||||
'service' => $service,
|
||||
|
|
@ -124,532 +121,12 @@ class DraftController extends Controller
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return response()->json(['success' => $data['booking_id']], $this->successStatus);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($action == "create_drafts_from_booking") {
|
||||
$data = \Input::all();
|
||||
$this->data = $data;
|
||||
|
||||
$weekday = date('w', strtotime($data['startDateStr']));
|
||||
$travel_program = TravelProgram::find($data['travel_program_id']);
|
||||
$draft = $this->getDraftByTravelProgramData($travel_program, $data, $weekday);
|
||||
|
||||
$start_date = Carbon::parse($data['startDateStr']);
|
||||
$end_date = Carbon::parse($data['endDateStr']);
|
||||
|
||||
|
||||
if($draft){
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//prepare rooms
|
||||
//request('rooms'); // //["rooms"]=> array(1) { [0]=> object(stdClass)#7284 (5) { ["name"]=> string(12) "Einzelzimmer" ["price_adult"]=> float(1682.16) ["adult"]=> int(1) ["children"]=> int(0) ["price_children"]=> int(0) }
|
||||
$price_info_rooms = [];
|
||||
$room_names = [];
|
||||
$room_adult = 0;
|
||||
$room_children = 0;
|
||||
$room_price_adult = 0;
|
||||
$room_price_children = 0;
|
||||
|
||||
$data['rooms'] = array_reverse($data['rooms']);
|
||||
|
||||
foreach ($data['rooms'] as $room){
|
||||
|
||||
$room_adult += $room['adult'];
|
||||
$room_children += $room['children'];
|
||||
$room_price_adult += ($room['price_adult_full'] * $room['adult']);
|
||||
$room_price_children += ($room['price_children_full'] * $room['children']);
|
||||
|
||||
if(isset($room_names[$room['name']])){
|
||||
$room_names[$room['name']] = $room_names[$room['name']]+1;
|
||||
}else{
|
||||
$room_names[$room['name']] = 1;
|
||||
}
|
||||
|
||||
$service = trans('_vorlagen.grundpreis_reise');
|
||||
$this->room_name = $room['name'];
|
||||
$service = $this->replaceService($service);
|
||||
|
||||
$price_info_rooms[] = [
|
||||
'booking_id' => $data['booking_id'],
|
||||
'travel_program_id' => $data['travel_program_id'],
|
||||
'fewo_lodging_id' => null,
|
||||
'travel_class_id' => null,
|
||||
'draft_item_id' => null,
|
||||
'draft_type_id' => 30,
|
||||
'request_date' => $data['request_date'],
|
||||
'days_start' => null,
|
||||
'days_duration' => null,
|
||||
'start_date' => $data['startDateStr'],
|
||||
'end_date' => $data['endDateStr'],
|
||||
'service' => $service,
|
||||
'price_adult' => $room['price_adult_full'],
|
||||
'adult' => $room['adult'],
|
||||
'price_children' => $room['price_children_full'],
|
||||
'children' => $room['children'],
|
||||
'pos' => 0,
|
||||
'in_pdf' => true,
|
||||
'comfort' => $data['comfort']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$this->room_str = "";
|
||||
foreach ($room_names as $name=>$count){
|
||||
$this->room_str .= $count.' x '.$name.', ';
|
||||
}
|
||||
$this->room_str = rtrim($this->room_str, ', ');
|
||||
|
||||
|
||||
//before & after days
|
||||
|
||||
$price_info_rooms_before = [];
|
||||
$price_info_rooms_after = [];
|
||||
|
||||
if(isset($data['booking_before']) && is_array($data['booking_before'])){
|
||||
foreach ($data['booking_before'] as $booking_before){
|
||||
$start_date_before = clone $start_date;
|
||||
if(isset($booking_before['days']) && $booking_before['days'] > 0){
|
||||
$start_date_before->modify('-'.$booking_before['days'].' day');
|
||||
}
|
||||
|
||||
$price_info_rooms_before[] = [
|
||||
'booking_id' => $data['booking_id'],
|
||||
'travel_program_id' => $data['travel_program_id'],
|
||||
'fewo_lodging_id' => null,
|
||||
'travel_class_id' => null,
|
||||
'draft_item_id' => null,
|
||||
'draft_type_id' => 36,
|
||||
'request_date' => $data['request_date'],
|
||||
'days_start' => null,
|
||||
'days_duration' => $booking_before['days'],
|
||||
'start_date' => $start_date_before->format("Y-m-d"),
|
||||
'end_date' => $data['startDateStr'],
|
||||
'service' => $booking_before['name'],
|
||||
'price_adult' => $booking_before['price'],
|
||||
'adult' => $booking_before['adults'],
|
||||
'price_children' => $booking_before['price_children'],
|
||||
'children' => $booking_before['children'],
|
||||
'pos' => 0,
|
||||
'in_pdf' => true,
|
||||
'comfort' => $data['comfort']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data['booking_after']) && is_array($data['booking_after'])){
|
||||
foreach ($data['booking_after'] as $booking_after){
|
||||
$end_date_after = clone $end_date;
|
||||
if(isset($booking_after['days']) && $booking_after['days'] > 0){
|
||||
$end_date_after->modify('+'.$booking_after['days'].' day');
|
||||
}
|
||||
|
||||
$price_info_rooms_after[] = [
|
||||
'booking_id' => $data['booking_id'],
|
||||
'travel_program_id' => $data['travel_program_id'],
|
||||
'fewo_lodging_id' => null,
|
||||
'travel_class_id' => null,
|
||||
'draft_item_id' => null,
|
||||
'draft_type_id' => 37,
|
||||
'request_date' => $data['request_date'],
|
||||
'days_start' => null,
|
||||
'days_duration' => $booking_after['days'],
|
||||
'start_date' => $data['endDateStr'],
|
||||
'end_date' => $end_date_after->format("Y-m-d"),
|
||||
'service' => $booking_after['name'],
|
||||
'price_adult' => $booking_after['price'],
|
||||
'adult' => $booking_after['adults'],
|
||||
'price_children' => $booking_after['price_children'],
|
||||
'children' => $booking_after['children'],
|
||||
'pos' => 0,
|
||||
'in_pdf' => true,
|
||||
'comfort' => $data['comfort']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//prepare extra_charge
|
||||
$price_info_extra_charge = [];
|
||||
if($data['departure_extra_charge'] > 0){
|
||||
|
||||
$service = trans('_vorlagen.aufpreis_flug');
|
||||
$service = $this->replaceService($service);
|
||||
|
||||
$price_info_extra_charge[] = [
|
||||
'booking_id' => $data['booking_id'],
|
||||
'travel_program_id' => $data['travel_program_id'],
|
||||
'fewo_lodging_id' => null,
|
||||
'travel_class_id' => null,
|
||||
'draft_item_id' => null,
|
||||
'draft_type_id' => 33,
|
||||
'request_date' => $data['request_date'],
|
||||
'days_start' => null,
|
||||
'days_duration' => null,
|
||||
'start_date' => null,
|
||||
'end_date' => null,
|
||||
'service' => $service,
|
||||
'price_adult' => $data['departure_extra_charge'] ,
|
||||
'adult' => $data['traveler'] ,
|
||||
'price_children' => 0,
|
||||
'children' => 0,
|
||||
'pos' => 0,
|
||||
'in_pdf' => true,
|
||||
'comfort' => $data['comfort']
|
||||
];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//prepare $class_options
|
||||
$price_info_class_options = [];
|
||||
foreach ($data['class_options'] as $class_option){
|
||||
|
||||
$service = trans('_vorlagen.aufpreis_kategorie');
|
||||
$this->className = $class_option['name'];
|
||||
$service = $this->replaceService($service);
|
||||
|
||||
$price_info_class_options[] = [
|
||||
'booking_id' => $data['booking_id'],
|
||||
'travel_program_id' => $data['travel_program_id'],
|
||||
'fewo_lodging_id' => null,
|
||||
'travel_class_id' => null,
|
||||
'draft_item_id' => null,
|
||||
'draft_type_id' => 32,
|
||||
'request_date' => $data['request_date'],
|
||||
'days_start' => null,
|
||||
'days_duration' => null,
|
||||
'start_date' => null,
|
||||
'end_date' => null,
|
||||
'service' => $service,
|
||||
'price_adult' => $class_option['price'],
|
||||
'adult' => $class_option['count'],
|
||||
'price_children' => 0,
|
||||
'children' => 0,
|
||||
'pos' => 0,
|
||||
'in_pdf' => true,
|
||||
'comfort' => $data['comfort']
|
||||
];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//prepare $travel_options
|
||||
$price_info_travel_options = [];
|
||||
foreach ($data['travel_options'] as $travel_option){
|
||||
|
||||
$service = trans('_vorlagen.aufpreis_option');
|
||||
$this->option = $travel_option['name'];
|
||||
$service = $this->replaceService($service);
|
||||
|
||||
/*
|
||||
* if($travel_option['children'] < 1){
|
||||
$travel_option['price_children'] = 0;
|
||||
}
|
||||
*/
|
||||
$price_info_travel_options[] = [
|
||||
'booking_id' => $data['booking_id'],
|
||||
'travel_program_id' => $data['travel_program_id'],
|
||||
'fewo_lodging_id' => null,
|
||||
'travel_class_id' => null,
|
||||
'draft_item_id' => null,
|
||||
'draft_type_id' => 41,
|
||||
'request_date' => $data['request_date'],
|
||||
'days_start' => null,
|
||||
'days_duration' => null,
|
||||
'start_date' => null,
|
||||
'end_date' => null,
|
||||
'service' => $service,
|
||||
'price_adult' => $travel_option['price_adult'],
|
||||
'adult' => $travel_option['adult'],
|
||||
'price_children' => $travel_option['price_children'],
|
||||
'children' => $travel_option['children'],
|
||||
'pos' => 0,
|
||||
'in_pdf' => true,
|
||||
'comfort' => $data['comfort']
|
||||
];
|
||||
}
|
||||
|
||||
$price_info_travel_discounts = [];
|
||||
|
||||
foreach ($data['discount'] as $travel_discount){
|
||||
|
||||
$service = trans('_vorlagen.aufpreis_option');
|
||||
$this->option = "";
|
||||
$service = $this->replaceService($service);
|
||||
|
||||
if($travel_discount['price'] > 0){
|
||||
$travel_discount['price'] = $travel_discount['price']*-1;
|
||||
}
|
||||
$price_info_travel_options[] = [
|
||||
'booking_id' => $data['booking_id'],
|
||||
'travel_program_id' => $data['travel_program_id'],
|
||||
'fewo_lodging_id' => null,
|
||||
'travel_class_id' => null,
|
||||
'draft_item_id' => null,
|
||||
'draft_type_id' => 42,
|
||||
'request_date' => $data['request_date'],
|
||||
'days_start' => null,
|
||||
'days_duration' => null,
|
||||
'start_date' => null,
|
||||
'end_date' => null,
|
||||
'service' => $service,
|
||||
'price_adult' => $travel_discount['price'],
|
||||
'adult' => $travel_discount['count'],
|
||||
'price_children' => 0,
|
||||
'children' => 0,
|
||||
'pos' => 0,
|
||||
'in_pdf' => true,
|
||||
'comfort' => $data['comfort']
|
||||
];
|
||||
}
|
||||
|
||||
$info_texts = [];
|
||||
$last_post = 0;
|
||||
foreach ($draft->draft_items as $draft_item){
|
||||
|
||||
$service = $draft_item->service;
|
||||
$price_adult = 0;
|
||||
$adult = 0;
|
||||
$price_children = 0;
|
||||
$children = 0;
|
||||
|
||||
switch ($draft_item->draft_type->id){
|
||||
case 24: //rundreise
|
||||
$price_adult = $room_price_adult;
|
||||
$adult = $room_adult;
|
||||
$price_children = $room_price_children;
|
||||
$children = $room_children;
|
||||
break;
|
||||
case 4: //flug
|
||||
// "Hinflug: Rückflug: Flugzeiten ?"
|
||||
break;
|
||||
}
|
||||
|
||||
$start_date_temp = null;
|
||||
if($draft_item->days_start > 0){
|
||||
$start_date_temp = clone $start_date;
|
||||
$start_date_temp->addDay($draft_item->days_start-1);
|
||||
}
|
||||
|
||||
$end_date_temp = null;
|
||||
if($draft_item->days_duration > 0){
|
||||
$end_date_temp = clone $start_date;
|
||||
$end_date_temp->addDay($draft_item->days_duration-1);
|
||||
}
|
||||
|
||||
$service = $this->replaceService($service);
|
||||
|
||||
if($draft_item->draft_type->id == 27){
|
||||
//text -at last
|
||||
$info_texts[] = [
|
||||
'booking_id' => $data['booking_id'],
|
||||
'travel_program_id' => $data['travel_program_id'],
|
||||
'fewo_lodging_id' => null,
|
||||
'travel_class_id' => null,
|
||||
'draft_item_id' => $draft_item->id,
|
||||
'draft_type_id' => $draft_item->draft_type->id,
|
||||
'request_date' => $data['request_date'],
|
||||
'days_start' => $draft_item->days_start,
|
||||
'days_duration' => $draft_item->days_duration,
|
||||
'start_date' => $start_date_temp ? $start_date_temp->format("Y-m-d") : null,
|
||||
'end_date' => $end_date_temp ? $end_date_temp->format("Y-m-d") : null,
|
||||
'service' => $service,
|
||||
'price_adult' => $price_adult,
|
||||
'adult' => $adult,
|
||||
'price_children' => $price_children,
|
||||
'children' => $children,
|
||||
'pos' => $draft_item->pos,
|
||||
'in_pdf' => $draft_item->in_pdf,
|
||||
'comfort' => $data['comfort']
|
||||
];
|
||||
|
||||
|
||||
}else{
|
||||
//create new from draft items
|
||||
BookingDraftItem::create([
|
||||
'booking_id' => $data['booking_id'],
|
||||
'travel_program_id' => $data['travel_program_id'],
|
||||
'fewo_lodging_id' => null,
|
||||
'travel_class_id' => null,
|
||||
'draft_item_id' => $draft_item->id,
|
||||
'draft_type_id' => $draft_item->draft_type->id,
|
||||
'request_date' => $data['request_date'],
|
||||
'days_start' => $draft_item->days_start,
|
||||
'days_duration' => $draft_item->days_duration,
|
||||
'start_date' => $start_date_temp ? $start_date_temp->format("Y-m-d") : null,
|
||||
'end_date' => $end_date_temp ? $end_date_temp->format("Y-m-d") : null,
|
||||
'service' => $service,
|
||||
'price_adult' => $price_adult,
|
||||
'adult' => $adult,
|
||||
'price_children' => $price_children,
|
||||
'children' => $children,
|
||||
'pos' => $draft_item->pos,
|
||||
'in_pdf' => $draft_item->in_pdf,
|
||||
'comfort' => $data['comfort']
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$last_post = $draft_item->pos;
|
||||
|
||||
}
|
||||
|
||||
//set room prices
|
||||
if(count($price_info_rooms)){
|
||||
foreach ($price_info_rooms as $price_info_room){
|
||||
$last_post ++;
|
||||
$price_info_room['pos'] = $last_post;
|
||||
BookingDraftItem::create($price_info_room);
|
||||
}
|
||||
}
|
||||
|
||||
//set room prices before
|
||||
if(count($price_info_rooms_before)){
|
||||
foreach ($price_info_rooms_before as $price_info_room){
|
||||
$last_post ++;
|
||||
$price_info_room['pos'] = $last_post;
|
||||
BookingDraftItem::create($price_info_room);
|
||||
}
|
||||
}
|
||||
|
||||
//set room prices after
|
||||
if(count($price_info_rooms_after)){
|
||||
foreach ($price_info_rooms_after as $price_info_room){
|
||||
$last_post ++;
|
||||
$price_info_room['pos'] = $last_post;
|
||||
BookingDraftItem::create($price_info_room);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//set extra charge price
|
||||
if(count($price_info_extra_charge)){
|
||||
foreach ($price_info_extra_charge as $price_info_extra){
|
||||
$last_post ++;
|
||||
$price_info_extra['pos'] = $last_post;
|
||||
BookingDraftItem::create($price_info_extra);
|
||||
}
|
||||
}
|
||||
//set class options prices
|
||||
if(count($price_info_class_options)){
|
||||
foreach ($price_info_class_options as $price_info_class_option){
|
||||
$last_post ++;
|
||||
$price_info_class_option['pos'] = $last_post;
|
||||
BookingDraftItem::create($price_info_class_option);
|
||||
}
|
||||
}
|
||||
|
||||
//set travel options prices
|
||||
if(count($price_info_travel_options)){
|
||||
foreach ($price_info_travel_options as $price_info_travel_option){
|
||||
$last_post ++;
|
||||
$price_info_travel_option['pos'] = $last_post;
|
||||
BookingDraftItem::create($price_info_travel_option);
|
||||
}
|
||||
}
|
||||
|
||||
//set travel discount prices
|
||||
if(count($price_info_travel_discounts)){
|
||||
foreach ($price_info_travel_discounts as $price_info_travel_discount){
|
||||
$last_post ++;
|
||||
$price_info_travel_option['pos'] = $last_post;
|
||||
BookingDraftItem::create($price_info_travel_option);
|
||||
}
|
||||
}
|
||||
|
||||
//set travel options prices
|
||||
if(count($info_texts)){
|
||||
foreach ($info_texts as $info_text){
|
||||
$last_post ++;
|
||||
$info_text['pos'] = $last_post;
|
||||
BookingDraftItem::create($info_text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$ret = [];
|
||||
/*
|
||||
$travel_program_id = request('travel_program_id');
|
||||
$comfort = request('comfort');
|
||||
$booking_id = request('booking_id');
|
||||
$startDateStr = request('startDateStr');
|
||||
$endDateStr = request('endDateStr');
|
||||
$departure = request('departure');
|
||||
$departure_extra_charge = request('departure_extra_charge');
|
||||
$traveler = request('traveler');
|
||||
$title = request('title');
|
||||
$number = request('number');
|
||||
$rooms = request('rooms'); // //["rooms"]=> array(1) { [0]=> object(stdClass)#7284 (5) { ["name"]=> string(12) "Einzelzimmer" ["price_adult"]=> float(1682.16) ["adults"]=> int(1) ["children"]=> int(0) ["price_children"]=> int(0) }
|
||||
$class_options = request('class_options'); //["travel_options"]=> array(2) { [0]=> array(5) { ["name"]=> string(20) "Aufpreis Halbpension" ["price_adult"]=> float(75) ["adult"]=> int(5) ["children"]=> int(0) ["price_children"]=> int(0) }
|
||||
$travel_options = request('travel_options'); //["class_options"]=> array(1) { [0]=> array(3) { ["name"]=> string(39) "zugebuchte Leistung: Komfort (4 Sterne)" ["price"]=> float(152) ["count"]=> int(1)
|
||||
*/
|
||||
|
||||
return response()->json(['success' => $draft->id], $this->successStatus);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected function replaceService($service){
|
||||
|
||||
$service = str_replace('#Name#', $this->data['title'], $service);
|
||||
$service = str_replace('#Nummer#', $this->data['number'], $service);
|
||||
$service = str_replace('#Zimmer#', $this->room_str, $service);
|
||||
$service = str_replace('#Raumname#', $this->room_name, $service);
|
||||
$service = str_replace('#Kategorie#', $this->className, $service);
|
||||
$service = str_replace('#Option#', $this->option, $service);
|
||||
$service = str_replace('#Flughafen#', $this->data['departure'], $service);
|
||||
|
||||
return $service;
|
||||
|
||||
}
|
||||
|
||||
protected function getDraftByTravelProgramData($travel_program, $data, $weekday){
|
||||
if ($travel_program && count($travel_program->travel_program_drafts)) {
|
||||
|
||||
foreach ($travel_program->travel_program_drafts as $travel_program_draft) {
|
||||
//this need an realation to travel class by booking and price
|
||||
if(in_array($weekday, $travel_program_draft->weekdays)){
|
||||
if($data['comfort'] == false && strpos(strtolower($travel_program_draft->travel_class->name), 'standard') !== false){
|
||||
return $travel_program_draft->draft;
|
||||
}
|
||||
if($data['comfort'] == true && strpos(strtolower($travel_program_draft->travel_class->name), 'komfort') !== false){
|
||||
return $travel_program_draft->draft;
|
||||
}
|
||||
}
|
||||
}
|
||||
//found non get first
|
||||
foreach ($travel_program->travel_program_drafts as $travel_program_draft) {
|
||||
return $travel_program_draft->draft;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/*
|
||||
array(14) {
|
||||
["travel_program_id"]=> int(197) ["comfort"]=> bool(true) ["booking_id"]=> string(4) "8435" ["request_date"]=> string(10) "2018-10-29" ["startDateStr"]=> string(10) "2018-11-03" ["endDateStr"]=> string(10) "2018-11-10" ["departure"]=> string(7) "Hamburg" ["departure_extra_charge"]=> float(55) ["traveler"]=> int(3) ["title"]=> string(35) "Höhepunkte Jordaniens ab Nov. 2018" ["number"]=> string(16) "JOR-HOE1920018B1" ["rooms"]=> array(2) {
|
||||
[0]=> array(5) {
|
||||
["name"]=> string(12) "Doppelzimmer" ["price_adult"]=> float(1473.85) ["adults"]=> int(2) ["children"]=> int(0) ["price_children"]=> int(0) } [1]=> array(5) {
|
||||
["name"]=> string(12) "Einzelzimmer" ["price_adult"]=> float(1682.16) ["adults"]=> int(1) ["children"]=> int(0) ["price_children"]=> int(0) } } ["class_options"]=> array(2) {
|
||||
[0]=> array(3) {
|
||||
["name"]=> string(39) "zugebuchte Leistung: Komfort (4 Sterne)" ["price"]=> float(122) ["count"]=> int(2) } [1]=> array(3) {
|
||||
["name"]=> string(39) "zugebuchte Leistung: Komfort (4 Sterne)" ["price"]=> float(171) ["count"]=> int(1) } } ["travel_options"]=> array(1) {
|
||||
[0]=> array(5) {
|
||||
["name"]=> string(20) "Aufpreis Halbpension" ["price_adult"]=> float(75) ["adults"]=> int(3) ["children"]=> int(0) ["price_children"]=> int(0) } } }
|
||||
*/
|
||||
}
|
||||
216
app/Http/Controllers/Admin/ReportController.php
Executable file
216
app/Http/Controllers/Admin/ReportController.php
Executable file
|
|
@ -0,0 +1,216 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Exports\ReportCollectionExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\ServiceProvider;
|
||||
use App\Models\ServiceProviderEntry;
|
||||
use App\Models\TravelAgenda;
|
||||
use App\Services\Util;
|
||||
use Carbon\Carbon;
|
||||
use HTMLHelper;
|
||||
use Illuminate\Validation\Rules\In;
|
||||
use Input;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Request;
|
||||
use Response;
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('superadmin');
|
||||
}
|
||||
|
||||
|
||||
public function bookings()
|
||||
{
|
||||
$data = [
|
||||
'text' => "Umsetzung folgt",
|
||||
];
|
||||
return view('_empty', $data);
|
||||
}
|
||||
|
||||
public function providers()
|
||||
{
|
||||
$data = [
|
||||
'serviceProviders' => ServiceProvider::all(),
|
||||
];
|
||||
return view('admin.report.index', $data);
|
||||
}
|
||||
|
||||
public function providersExport(){
|
||||
|
||||
$query = ServiceProviderEntry::with('booking', 'service_provider', 'booking.customer');
|
||||
if(Input::get('filter_is_cleared') != ""){
|
||||
$query->where('is_cleared', '=', Input::get('filter_is_cleared'));
|
||||
}
|
||||
if(Input::get('filter_service_provider_id') != ""){
|
||||
$query->where('service_provider_id', '=', Input::get('filter_service_provider_id'));
|
||||
}
|
||||
if(Input::get('filter_travel_date_from') != ""){
|
||||
$query->whereHas('booking', function ($q) {
|
||||
$travel_date_from = Carbon::parse(Input::get('filter_travel_date_from'))->format("Y-m-d");
|
||||
$q->where("start_date", '>=', $travel_date_from);
|
||||
});
|
||||
}
|
||||
if(Input::get('filter_travel_date_to') != ""){
|
||||
$query->whereHas('booking', function ($q) {
|
||||
$travel_date_to = Carbon::parse(Input::get('filter_travel_date_to'))->format("Y-m-d");
|
||||
$q->where("start_date", '<=', $travel_date_to);
|
||||
});
|
||||
}
|
||||
|
||||
$query->whereHas('booking', function ($q) {
|
||||
$q->orderBy("lead_id", 'ASC');
|
||||
});
|
||||
|
||||
$filename = "file-".date('Y-m-d-H-i-s');
|
||||
$exports = $query->get();
|
||||
$columns = [];
|
||||
if(Input::get('export') === "export"){
|
||||
$filename = "Export_".date('Y-m-d-H-i-s');
|
||||
|
||||
$headers = array(
|
||||
'Zähler',
|
||||
'MyJack Nr.',
|
||||
'CRM Nr',
|
||||
'Kunde',
|
||||
'Reisedatum',
|
||||
'Gesamtreisepreis',
|
||||
'Reiseland',
|
||||
'Reiseprogramm',
|
||||
'Reiseteilnehmer',
|
||||
'Leistungsträger',
|
||||
'Rechnungsnummer',
|
||||
'Zahlung',
|
||||
'Zahlungsdatum',
|
||||
'Erlös',
|
||||
'Konto',
|
||||
);
|
||||
$isset = [];
|
||||
foreach($exports as $export) {
|
||||
$new = in_array($export->booking->lead_id, $isset) ? false : true;
|
||||
$columns[] = array(
|
||||
'Zähler' => $new ? $export->getCounter() : "",
|
||||
'MyJack Nr.' => $new ? $export->booking->merlin_order_number : "",
|
||||
'CRM Nr' => $new ? $export->booking->lead_id : "",
|
||||
'Kunde' => $new ? $export->booking->customer->name : "",
|
||||
'Reisedatum' => $new ? $export->booking->getStartDateFormat() : "",
|
||||
'Gesamtreisepreis' => $new ? $export->booking->price : "",
|
||||
'Reiseland' => $new ? $export->booking->travel_country->name : "",
|
||||
'Reiseprogramm' => $new ? $export->booking->travel_agenda->name : "",
|
||||
'Reiseteilnehmer' => $new ? $export->booking->pax : "",
|
||||
'Leistungsträger' => $export->service_provider->name,
|
||||
'Rechnungsnummer' => $export->invoice_number,
|
||||
'Zahlung' => $export->getAmountFinalEur(),
|
||||
'Zahlungsdatum' => $export->getPaymentDateFormat(),
|
||||
'Erlös' => $new ? $export->booking->proceeds() : "",
|
||||
'Konto' => $export->booking->getKontoNumber()
|
||||
);
|
||||
$isset[] = $export->booking->lead_id;
|
||||
}
|
||||
}
|
||||
if(Input::get('export') === "export_lt"){
|
||||
$filename = "Export_LT_".date('Y-m-d-H-i-s');
|
||||
|
||||
$headers = array(
|
||||
'Zähler',
|
||||
'MyJack Nr.',
|
||||
'CRM Nr',
|
||||
'Kunde',
|
||||
'Reisedatum',
|
||||
'Reiseland',
|
||||
'Reiseprogramm',
|
||||
'Reiseteilnehmer',
|
||||
'Leistungsträger',
|
||||
'Rechnungsnummer',
|
||||
'Zahlung',
|
||||
'ZahlungVorgang',
|
||||
);
|
||||
$isset = [];
|
||||
foreach($exports as $export) {
|
||||
$new = in_array($export->booking->lead_id, $isset) ? false : true;
|
||||
$columns[] = array(
|
||||
'Zähler' => $new ? $export->getCounter() : "",
|
||||
'MyJack Nr.' => $new ? $export->booking->merlin_order_number : "",
|
||||
'CRM Nr' => $new ? $export->booking->lead_id : "",
|
||||
'Kunde' => $new ? $export->booking->customer->name : "",
|
||||
'Reisedatum' => $new ? $export->booking->getStartDateFormat() : "",
|
||||
'Reiseland' => $new ? $export->booking->travel_country->name : "",
|
||||
'Reiseprogramm' => $new ? $export->booking->travel_agenda->name : "",
|
||||
'Reiseteilnehmer' => $new ? $export->booking->pax : "",
|
||||
'Leistungsträger' => $export->service_provider->name,
|
||||
'Rechnungsnummer' => $export->invoice_number,
|
||||
'Zahlung' => $export->getAmountFinalEur(),
|
||||
'ZahlungVorgang' => $export->booking->getServiceProviderPaymentsTotal(),
|
||||
);
|
||||
$isset[] = $export->booking->lead_id;
|
||||
}
|
||||
}
|
||||
return Excel::download(new ReportCollectionExport($columns, $headers), $filename.'.xls');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function providersDatatable()
|
||||
{
|
||||
|
||||
$query = ServiceProviderEntry::with('booking', 'service_provider', 'booking.customer');
|
||||
|
||||
if(Input::get('filter_is_cleared') != ""){
|
||||
$query->where('is_cleared', '=', Input::get('filter_is_cleared'));
|
||||
}
|
||||
if(Input::get('filter_service_provider_id') != ""){
|
||||
$query->where('service_provider_id', '=', Input::get('filter_service_provider_id'));
|
||||
}
|
||||
if(Input::get('filter_travel_date_from') != ""){
|
||||
$query->whereHas('booking', function ($q) {
|
||||
$travel_date_from = Carbon::parse(Input::get('filter_travel_date_from'))->format("Y-m-d");
|
||||
$q->where("start_date", '>=', $travel_date_from);
|
||||
});
|
||||
}
|
||||
if(Input::get('filter_travel_date_to') != ""){
|
||||
$query->whereHas('booking', function ($q) {
|
||||
$travel_date_to = Carbon::parse(Input::get('filter_travel_date_to'))->format("Y-m-d");
|
||||
$q->where("start_date", '<=', $travel_date_to);
|
||||
});
|
||||
}
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('booking.customer.fullName', function (ServiceProviderEntry $serviceProviderEntry) {
|
||||
return $serviceProviderEntry->booking->customer->fullName();
|
||||
})
|
||||
->addColumn('booking.proceeds', function (ServiceProviderEntry $serviceProviderEntry) {
|
||||
return $serviceProviderEntry->booking->proceeds();
|
||||
})
|
||||
->addColumn('booking.start_date', function (ServiceProviderEntry $serviceProviderEntry) {
|
||||
return $serviceProviderEntry->booking->getStartDateFormat();
|
||||
})
|
||||
->addColumn('is_cleared', function (ServiceProviderEntry $serviceProviderEntry) {
|
||||
return $serviceProviderEntry->is_cleared ? ' <span data-order="1" class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span data-order="0" class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->filterColumn('booking.customer.fullName', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereHas('booking', function ($q) use ($keyword) {
|
||||
$q->whereHas('customer', function ($q) use ($keyword) {
|
||||
$q->where("name", 'LIKE', '%' . $keyword . '%')
|
||||
->orWhere('firstname', 'LIKE', '%' . $keyword . '%');
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
->orderColumn('booking.start_date', 'booking.start_date $1')
|
||||
->orderColumn('is_cleared', 'is_cleared $1')
|
||||
->rawColumns(['is_cleared'])
|
||||
->make(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ class AdminUserController extends Controller
|
|||
{
|
||||
$data = Input::all();
|
||||
|
||||
if($data['user_id'] == "new"){
|
||||
if($data['user_id'] === "new"){
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
|
|
@ -81,7 +81,7 @@ class AdminUserController extends Controller
|
|||
return back()->withInput(Input::all())->withErrors($validator);
|
||||
}
|
||||
|
||||
if($data['user_id'] == "new"){
|
||||
if($data['user_id'] === "new"){
|
||||
$user = User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
|
|
@ -165,19 +165,19 @@ class AdminUserController extends Controller
|
|||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (User $user) {
|
||||
return '<a href="' . route('admin_user_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
return '<a href="' . route('admin_user_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('admin', function (User $user) {
|
||||
return '<a href="#" data-url="'.route('admin_user_load_modal', $user->id).'" data-data="'.$user->id.'" class="update_modal_data_show">'.HTMLHelper::getRoleLabel($user->admin, '<i class="fa fa-edit"></i> Rechte + ','').'</a>';
|
||||
})
|
||||
->addColumn('confirmed', function (User $user) {
|
||||
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('active', function (User $user) {
|
||||
return $user->active ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
return $user->active ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('action_delete', function (User $user) {
|
||||
return '<a href="' . route('admin_user_delete', [$user->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="far fa-trash"></span></a>';
|
||||
return '<a href="' . route('admin_user_delete', [$user->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>';
|
||||
})
|
||||
->orderColumn('confirmed', 'confirmed $1')
|
||||
->orderColumn('active', 'active $1')
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ class DataTableController extends Controller
|
|||
return $user->account ? $user->account->last_name : '';
|
||||
})
|
||||
->addColumn('action', function (User $user) {
|
||||
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('confirmed', function (User $user) {
|
||||
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('active', function (User $user) {
|
||||
return $user->active ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
return $user->active ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->orderColumn('confirmed', 'confirmed $1')
|
||||
->orderColumn('active', 'active $1')
|
||||
|
|
@ -52,205 +52,31 @@ class DataTableController extends Controller
|
|||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (Booking $booking) {
|
||||
return '<a href="' . route('booking_detail', [$booking->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
return '<a href="' . route('booking_detail', [$booking->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('id', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->id.'" href="' . route('booking_detail', [$booking->id]) . '" data-id="'.$booking->id.'">'.$booking->id.'</a>';
|
||||
})
|
||||
->addColumn('booking_date', function (Booking $booking) {
|
||||
return Carbon::parse($booking->booking_date)->format(\Util::formatDateDB());
|
||||
})
|
||||
->addColumn('start_date', function (Booking $booking) {
|
||||
return Carbon::parse($booking->start_date)->format(\Util::formatDateDB());
|
||||
})
|
||||
->addColumn('end_date', function (Booking $booking) {
|
||||
return Carbon::parse($booking->end_date)->format(\Util::formatDateDB());
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->filterColumn('id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'id'])
|
||||
|
||||
->make(true);
|
||||
}
|
||||
|
||||
public function getRequests()
|
||||
{
|
||||
|
||||
$query = Booking::where('lead_id', '!=', NULL);
|
||||
|
||||
if(Input::get('full_firstname_search') != ""){
|
||||
$query->where('participant_firstname', 'LIKE', '%'.Input::get('full_firstname_search').'%');
|
||||
}
|
||||
|
||||
if(Input::get('full_lastname_search') != ""){
|
||||
$query->where('participant_name', 'LIKE', '%'.Input::get('full_lastname_search').'%');
|
||||
}
|
||||
|
||||
// $query->where('end_date', '<=', $now);
|
||||
|
||||
if(Input::get('travel_option_search')){
|
||||
$now = Carbon::now();
|
||||
|
||||
|
||||
switch (Input::get('travel_option_search')){
|
||||
case 'before_2':
|
||||
$query->whereBetween('start_date', [Carbon::now()->modify('-2 month'), $now]);
|
||||
|
||||
break;
|
||||
case 'brefore_1':
|
||||
$query->whereBetween('start_date', [Carbon::now()->modify('-1 month'), $now]);
|
||||
|
||||
break;
|
||||
case 'on_site':
|
||||
$query->where('start_date', '<=', $now);
|
||||
$query->where('end_date', '>=', $now);
|
||||
break;
|
||||
case 'after_1':
|
||||
$query->whereBetween('start_date', [$now, Carbon::now()->modify('+1 month')]);
|
||||
|
||||
break;
|
||||
case 'after_2':
|
||||
$query->whereBetween('start_date', [$now, Carbon::now()->modify('+2 month')]);
|
||||
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
$start = null;
|
||||
$end = null;
|
||||
if(Input::get('arrival_start_date') != ""){
|
||||
$arrStart = explode(".", Input::get('arrival_start_date'));
|
||||
if(count($arrStart) == 3){
|
||||
$start = Carbon::create($arrStart[2], $arrStart[1], $arrStart[0], 0, 0, 0);
|
||||
}
|
||||
}
|
||||
if(Input::get('arrival_end_date') != ""){
|
||||
$arrEnd = explode(".", Input::get('arrival_end_date'));
|
||||
if(count($arrEnd) == 3){
|
||||
$end = Carbon::create($arrEnd[2], $arrEnd[1], $arrEnd[0], 23, 59, 59);
|
||||
}
|
||||
}
|
||||
if($start && $end){
|
||||
$query->whereBetween('start_date', [$start, $end]);
|
||||
}
|
||||
if($start && !$end){
|
||||
$query->where('start_date', '>=', $start);
|
||||
}
|
||||
if(!$start && $end){
|
||||
$query->where('start_date', '<=', $end);
|
||||
}
|
||||
|
||||
$start = null;
|
||||
$end = null;
|
||||
if(Input::get('departure_start_date') != ""){
|
||||
$arrStart = explode(".", Input::get('departure_start_date'));
|
||||
if(count($arrStart) == 3){
|
||||
$start = Carbon::create($arrStart[2], $arrStart[1], $arrStart[0], 0, 0, 0);
|
||||
}
|
||||
}
|
||||
if(Input::get('departure_end_date') != ""){
|
||||
$arrEnd = explode(".", Input::get('departure_end_date'));
|
||||
if(count($arrEnd) == 3){
|
||||
$end = Carbon::create($arrEnd[2], $arrEnd[1], $arrEnd[0], 23, 59, 59);
|
||||
}
|
||||
}
|
||||
if($start && $end){
|
||||
$query->whereBetween('end_date', [$start, $end]);
|
||||
}
|
||||
if($start && !$end){
|
||||
$query->where('end_date', '>=', $start);
|
||||
}
|
||||
if(!$start && $end){
|
||||
$query->where('end_date', '<=', $end);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(Input::get('sort_travel_country_id') != ""){
|
||||
$query->where('travel_country_id', '=', Input::get('sort_travel_country_id'));
|
||||
}
|
||||
if(Input::get('sort_travelagenda_id') != ""){
|
||||
$query->where('travelagenda_id', '=', Input::get('sort_travelagenda_id'));
|
||||
}
|
||||
|
||||
if(Input::get('sort_sf_guard_user_id') != ""){
|
||||
$query->where('sf_guard_user_id', '=', Input::get('sort_sf_guard_user_id'));
|
||||
}
|
||||
|
||||
if(Input::get('sort_travel_documents') != ""){
|
||||
$query->where('travel_documents', '=', Input::get('sort_travel_documents'));
|
||||
}
|
||||
|
||||
|
||||
if(Input::get('full_lead_id_search') != ""){
|
||||
$query->where('lead_id', 'LIKE', '%'.Input::get('full_lead_id_search'). '%');
|
||||
}
|
||||
if(Input::get('full_booking_id_search') != ""){
|
||||
$query->where('id', 'LIKE', '%'.Input::get('full_booking_id_search').'%');
|
||||
}
|
||||
|
||||
//confirmation_code_remider is delete 2
|
||||
//
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (Booking $booking) {
|
||||
return ''; //'<a href="' . route('booking_detail', [$booking->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('lead_id', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->lead_id.'" href="'.make_old_url('leads/'.$booking->lead_id.'/edit').'" data-id="'.$booking->lead_id.'">'.$booking->lead_id.'</a>';
|
||||
})
|
||||
->addColumn('participant_firstname', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->participant_firstname.'" href="'.make_old_url('customer/'.$booking->customer_id.'/edit').'" data-id="'.$booking->customer_id.'">'.$booking->participant_firstname.'</a>';
|
||||
})
|
||||
->addColumn('participant_name', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->participant_name.'" href="'.make_old_url('customer/'.$booking->customer_id.'/edit').'" data-id="'.$booking->customer_id.'">'.$booking->participant_name.'</a>';
|
||||
})
|
||||
->addColumn('id', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->id.'" href="'.make_old_url('booking/'.$booking->id.'/edit').'" data-id="'.$booking->id.'">'.$booking->id.'</a>';
|
||||
})
|
||||
->addColumn('travel_country_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->travel_country_id ? $booking->travel_country_id : 0).'">'.($booking->travel_country_id ? $booking->travel_country->name : "-").'</span>';
|
||||
})
|
||||
->addColumn('travelagenda_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->travelagenda_id ? $booking->travelagenda_id : 0).'">'.($booking->travelagenda_id ? $booking->travel_agenda->name : "-").'</span>';
|
||||
})
|
||||
->addColumn('start_date', function (Booking $booking) {
|
||||
return $booking->getStartDateFormat();
|
||||
})
|
||||
->addColumn('end_date', function (Booking $booking) {
|
||||
return $booking->getEndDateFormat();
|
||||
})
|
||||
->addColumn('travel_documents', function (Booking $booking) {
|
||||
return $booking->travel_documents ? ' <span data-order="1" class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span data-order="0" class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('sf_guard_user_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->sf_guard_user_id ? $booking->sf_guard_user_id : 0).'">'.($booking->sf_guard_user_id? $booking->sf_guard_user->first_name." ".$booking->sf_guard_user->last_name : "-").'</span>';
|
||||
})
|
||||
->addColumn('lead.status_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->lead->status_id ? $booking->lead->status_id : 0).'">'.($booking->lead->status_id ? $booking->lead->status->name : "-").'</span>';
|
||||
})
|
||||
/* ->filterColumn('travel_country_id', function($query, $keyword) {
|
||||
|
||||
if($keyword != "") {
|
||||
$query->whereRaw("travel_country_id = ?", $keyword);
|
||||
}
|
||||
|
||||
})
|
||||
->filterColumn('travelagenda_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("travelagenda_id = ?", $keyword);
|
||||
|
||||
}
|
||||
})
|
||||
*/
|
||||
->orderColumn('lead_id', 'lead_id $1')
|
||||
->orderColumn('participant_firstname', 'participant_firstname $1')
|
||||
->orderColumn('participant_name', 'participant_name $1')
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('travel_country_id', 'travel_country_id $1')
|
||||
->orderColumn('travelagenda_id', 'travelagenda_id $1')
|
||||
->orderColumn('sf_guard_user_id', 'sf_guard_user_id $1')
|
||||
->orderColumn('start_date', 'start_date $1')
|
||||
->orderColumn('end_date', 'end_date $1')
|
||||
->orderColumn('travel_documents', 'travel_documents $1')
|
||||
->rawColumns(['action_edit', 'lead_id', 'participant_firstname', 'participant_name', 'travel_country_id', 'travelagenda_id', 'sf_guard_user_id', 'lead.status_id', 'id', 'travel_documents'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Sym\TravelCountry;
|
||||
use App\Models\TravelAgenda;
|
||||
use Carbon\Carbon;
|
||||
use Input;
|
||||
use DataTables;
|
||||
|
||||
class RequestController extends Controller
|
||||
{
|
||||
|
|
@ -16,8 +20,13 @@ class RequestController extends Controller
|
|||
|
||||
public function index($step = false)
|
||||
{
|
||||
|
||||
|
||||
$d = Booking::join('travel_country', 'travel_country_id', '=', 'travel_country.id')->get()->pluck('name', 'travel_country_id')->unique()->toArray();
|
||||
|
||||
$data = [
|
||||
'step' => $step
|
||||
'step' => $step,
|
||||
'travel_countries' => $d,
|
||||
];
|
||||
return view('request.index', $data);
|
||||
}
|
||||
|
|
@ -36,6 +45,209 @@ class RequestController extends Controller
|
|||
}
|
||||
die();
|
||||
*/
|
||||
private function getSearchRequests(){
|
||||
|
||||
$query = Booking::where('lead_id', '!=', NULL);
|
||||
|
||||
if(Input::get('full_firstname_search') != ""){
|
||||
$query->where('participant_firstname', 'LIKE', '%'.Input::get('full_firstname_search').'%');
|
||||
}
|
||||
|
||||
if(Input::get('full_lastname_search') != ""){
|
||||
$query->where('participant_name', 'LIKE', '%'.Input::get('full_lastname_search').'%');
|
||||
}
|
||||
|
||||
|
||||
if(Input::get('travel_option_country_id') != ""){
|
||||
$country_ids = TravelCountry::where('contact_lands', 'LIKE', '%"'.Input::get('travel_option_country_id').'"%')->get()->pluck('id');
|
||||
$country_ids[] = Input::get('travel_option_country_id');
|
||||
$query->whereIn('travel_country_id', $country_ids);
|
||||
|
||||
}
|
||||
if(Input::get('travel_option_agenda_id') != ""){
|
||||
$query->where('travelagenda_id', '=', Input::get('travel_option_agenda_id'));
|
||||
|
||||
}
|
||||
|
||||
// $query->where('end_date', '<=', $now);
|
||||
|
||||
if(Input::get('travel_option_search')){
|
||||
$now = Carbon::now();
|
||||
|
||||
switch (Input::get('travel_option_search')){
|
||||
case 'before_2':
|
||||
$query->whereBetween('start_date', [Carbon::now()->modify('-2 month'), $now]);
|
||||
|
||||
break;
|
||||
case 'brefore_1':
|
||||
$query->whereBetween('start_date', [Carbon::now()->modify('-1 month'), $now]);
|
||||
|
||||
break;
|
||||
case 'on_site':
|
||||
$query->where('start_date', '<=', $now);
|
||||
$query->where('end_date', '>=', $now);
|
||||
break;
|
||||
case 'after_1':
|
||||
$query->whereBetween('start_date', [$now, Carbon::now()->modify('+1 month')]);
|
||||
|
||||
break;
|
||||
case 'after_2':
|
||||
$query->whereBetween('start_date', [$now, Carbon::now()->modify('+2 month')]);
|
||||
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
$start = null;
|
||||
$end = null;
|
||||
if(Input::get('arrival_start_date') != ""){
|
||||
$arrStart = explode(".", Input::get('arrival_start_date'));
|
||||
if(count($arrStart) == 3){
|
||||
$start = Carbon::create($arrStart[2], $arrStart[1], $arrStart[0], 0, 0, 0);
|
||||
}
|
||||
}
|
||||
if(Input::get('arrival_end_date') != ""){
|
||||
$arrEnd = explode(".", Input::get('arrival_end_date'));
|
||||
if(count($arrEnd) == 3){
|
||||
$end = Carbon::create($arrEnd[2], $arrEnd[1], $arrEnd[0], 23, 59, 59);
|
||||
}
|
||||
}
|
||||
if($start && $end){
|
||||
$query->whereBetween('start_date', [$start, $end]);
|
||||
}
|
||||
if($start && !$end){
|
||||
$query->where('start_date', '>=', $start);
|
||||
}
|
||||
if(!$start && $end){
|
||||
$query->where('start_date', '<=', $end);
|
||||
}
|
||||
|
||||
$start = null;
|
||||
$end = null;
|
||||
if(Input::get('departure_start_date') != ""){
|
||||
$arrStart = explode(".", Input::get('departure_start_date'));
|
||||
if(count($arrStart) == 3){
|
||||
$start = Carbon::create($arrStart[2], $arrStart[1], $arrStart[0], 0, 0, 0);
|
||||
}
|
||||
}
|
||||
if(Input::get('departure_end_date') != ""){
|
||||
$arrEnd = explode(".", Input::get('departure_end_date'));
|
||||
if(count($arrEnd) == 3){
|
||||
$end = Carbon::create($arrEnd[2], $arrEnd[1], $arrEnd[0], 23, 59, 59);
|
||||
}
|
||||
}
|
||||
if($start && $end){
|
||||
$query->whereBetween('end_date', [$start, $end]);
|
||||
}
|
||||
if($start && !$end){
|
||||
$query->where('end_date', '>=', $start);
|
||||
}
|
||||
if(!$start && $end){
|
||||
$query->where('end_date', '<=', $end);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(Input::get('sort_travel_country_id') != ""){
|
||||
$query->where('travel_country_id', '=', Input::get('sort_travel_country_id'));
|
||||
}
|
||||
if(Input::get('sort_travelagenda_id') != ""){
|
||||
$query->where('travelagenda_id', '=', Input::get('sort_travelagenda_id'));
|
||||
}
|
||||
|
||||
if(Input::get('sort_sf_guard_user_id') != ""){
|
||||
$query->where('sf_guard_user_id', '=', Input::get('sort_sf_guard_user_id'));
|
||||
}
|
||||
|
||||
if(Input::get('sort_travel_documents') != ""){
|
||||
$query->where('travel_documents', '=', Input::get('sort_travel_documents'));
|
||||
}
|
||||
|
||||
|
||||
if(Input::get('full_lead_id_search') != ""){
|
||||
$query->where('lead_id', 'LIKE', '%'.Input::get('full_lead_id_search'). '%');
|
||||
}
|
||||
if(Input::get('full_booking_id_search') != ""){
|
||||
$query->where('id', 'LIKE', '%'.Input::get('full_booking_id_search').'%');
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
public function getAjaxRequests(){
|
||||
|
||||
$query = $this->getSearchRequests();
|
||||
$ret = $query->get()->pluck('travelagenda_id', 'id')->unique()->toArray();
|
||||
return TravelAgenda::whereIn('id', $ret)->get()->pluck('name', 'id');
|
||||
}
|
||||
|
||||
public function getRequests()
|
||||
{
|
||||
|
||||
$query = $this->getSearchRequests();
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (Booking $booking) {
|
||||
return ''; //'<a href="' . route('booking_detail', [$booking->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('lead_id', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->lead_id.'" href="'.make_old_url('leads/'.$booking->lead_id.'/edit').'" data-id="'.$booking->lead_id.'">'.$booking->lead_id.'</a>';
|
||||
})
|
||||
->addColumn('participant_firstname', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->participant_firstname.'" href="'.make_old_url('customer/'.$booking->customer_id.'/edit').'" data-id="'.$booking->customer_id.'">'.$booking->participant_firstname.'</a>';
|
||||
})
|
||||
->addColumn('participant_name', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->participant_name.'" href="'.make_old_url('customer/'.$booking->customer_id.'/edit').'" data-id="'.$booking->customer_id.'">'.$booking->participant_name.'</a>';
|
||||
})
|
||||
->addColumn('id', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->id.'" href="'.make_old_url('booking/'.$booking->id.'/edit').'" data-id="'.$booking->id.'">'.$booking->id.'</a>';
|
||||
})
|
||||
->addColumn('travel_country_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->travel_country_id ? $booking->travel_country_id : 0).'">'.($booking->travel_country_id ? $booking->travel_country->name : "-").'</span>';
|
||||
})
|
||||
->addColumn('travelagenda_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->travelagenda_id ? $booking->travelagenda_id : 0).'">'.($booking->travelagenda_id ? $booking->travel_agenda->name : "-").'</span>';
|
||||
})
|
||||
->addColumn('start_date', function (Booking $booking) {
|
||||
return $booking->getStartDateFormat();
|
||||
})
|
||||
->addColumn('end_date', function (Booking $booking) {
|
||||
return $booking->getEndDateFormat();
|
||||
})
|
||||
->addColumn('travel_documents', function (Booking $booking) {
|
||||
return $booking->travel_documents ? ' <span data-order="1" class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span data-order="0" class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('sf_guard_user_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->sf_guard_user_id ? $booking->sf_guard_user_id : 0).'">'.($booking->sf_guard_user_id? $booking->sf_guard_user->first_name." ".$booking->sf_guard_user->last_name : "-").'</span>';
|
||||
})
|
||||
->addColumn('lead.status_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->lead->status_id ? $booking->lead->status_id : 0).'">'.($booking->lead->status_id ? $booking->lead->status->name : "-").'</span>';
|
||||
})
|
||||
/* ->filterColumn('travel_country_id', function($query, $keyword) {
|
||||
|
||||
if($keyword != "") {
|
||||
$query->whereRaw("travel_country_id = ?", $keyword);
|
||||
}
|
||||
|
||||
})
|
||||
->filterColumn('travelagenda_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("travelagenda_id = ?", $keyword);
|
||||
|
||||
}
|
||||
})
|
||||
*/
|
||||
->orderColumn('lead_id', 'lead_id $1')
|
||||
->orderColumn('participant_firstname', 'participant_firstname $1')
|
||||
->orderColumn('participant_name', 'participant_name $1')
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('travel_country_id', 'travel_country_id $1')
|
||||
->orderColumn('travelagenda_id', 'travelagenda_id $1')
|
||||
->orderColumn('sf_guard_user_id', 'sf_guard_user_id $1')
|
||||
->orderColumn('start_date', 'start_date $1')
|
||||
->orderColumn('end_date', 'end_date $1')
|
||||
->orderColumn('travel_documents', 'travel_documents $1')
|
||||
->rawColumns(['action_edit', 'lead_id', 'participant_firstname', 'participant_name', 'travel_country_id', 'travelagenda_id', 'sf_guard_user_id', 'lead.status_id', 'id', 'travel_documents'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
418
app/Http/Controllers/SyS/Tools/ContentLinkController.php
Executable file
418
app/Http/Controllers/SyS/Tools/ContentLinkController.php
Executable file
|
|
@ -0,0 +1,418 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SyS\Tools;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\IQContentSite;
|
||||
use App\Models\IQContentSiteField;
|
||||
use App\Models\IQContentTree;
|
||||
use App\Models\IQContentTreeNode;
|
||||
use App\Models\TravelGuide;
|
||||
use Input;
|
||||
use Validator;
|
||||
|
||||
class ContentLinkController extends Controller
|
||||
{
|
||||
|
||||
private $tree = [];
|
||||
/**
|
||||
* ContentSiteController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// $this->middleware('auth');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$val = [];
|
||||
$text = "";
|
||||
$travelGuides = TravelGuide::all();
|
||||
foreach ($travelGuides as $travelGuide){
|
||||
if(strpos($travelGuide->full_text, "<h1><br></h1>") !== false){
|
||||
$val[$travelGuide->id] = "<h1><br></h1>";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($travelGuides as $travelGuide){
|
||||
if(strpos($travelGuide->full_text, "<h1") !== false){
|
||||
$val[$travelGuide->id] = "<h1";
|
||||
}
|
||||
}
|
||||
|
||||
$travelGuide = TravelGuide::find(203);
|
||||
$text = $travelGuide->full_text;
|
||||
|
||||
// $new_text = preg_replace('/<h1[^>]*>([\s\S]*?)<\/h1[^>]*>/', '', $TravelGuide->full_text);
|
||||
|
||||
|
||||
$data = [
|
||||
'text' => $text,
|
||||
'values' => $val,
|
||||
];
|
||||
return view('sys.tools.links', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function store()
|
||||
{
|
||||
$travelGuides = TravelGuide::all();
|
||||
foreach ($travelGuides as $travelGuide){
|
||||
if(strpos($travelGuide->full_text, "<h1><br></h1>") !== false) {
|
||||
$travelGuide->full_text = str_replace("<h1><br></h1>", "", $travelGuide->full_text);
|
||||
$travelGuide->save();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($travelGuides as $travelGuide){
|
||||
if(strpos($travelGuide->full_text, "<h1") !== false){
|
||||
$travelGuide->full_text = str_replace("<h1", "<h2", $travelGuide->full_text);
|
||||
$travelGuide->full_text = str_replace("h1>", "h2>", $travelGuide->full_text);
|
||||
$travelGuide->save();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
|
||||
//$this->readNodeAndSaveToTree();
|
||||
//$this->cleanTextTravelGuide();
|
||||
//$this->h1ToTitleTravelGuide();
|
||||
}
|
||||
|
||||
|
||||
public function treeTitle()
|
||||
{
|
||||
$text = "";
|
||||
$val = [];
|
||||
$trees = IQContentTree::all();
|
||||
foreach ($trees as $tree){
|
||||
foreach ($tree->iq_content_tree_nodes as $tree_node){
|
||||
|
||||
$text .= $tree_node->id." -- ".$tree_node->title."\n";
|
||||
foreach ($tree_node->iq_content_sites as $site){
|
||||
if(isset($site->travel_guide->meta_title)){
|
||||
if(isset($val[$tree_node->id])){
|
||||
if(strlen($site->travel_guide->meta_title) > strlen($val[$tree_node->id])){
|
||||
$val[$tree_node->id] = $site->travel_guide->meta_title;
|
||||
}
|
||||
}else{
|
||||
$val[$tree_node->id] = $site->travel_guide->meta_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'text' => $text,
|
||||
'values' => $val,
|
||||
];
|
||||
return view('sys.tools.trees', $data);
|
||||
}
|
||||
|
||||
public function treeTitleStore()
|
||||
{
|
||||
|
||||
$trees = IQContentTree::all();
|
||||
$val = [];
|
||||
foreach ($trees as $tree){
|
||||
foreach ($tree->iq_content_tree_nodes as $tree_node){
|
||||
foreach ($tree_node->iq_content_sites as $site){
|
||||
if(isset($site->travel_guide->meta_title)){
|
||||
if(isset($val[$tree_node->id])){
|
||||
if(strlen($site->travel_guide->meta_title) > strlen($val[$tree_node->id])){
|
||||
$val[$tree_node->id] = $site->travel_guide->meta_title;
|
||||
}
|
||||
}else{
|
||||
$val[$tree_node->id] = $site->travel_guide->meta_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($val[$tree_node->id])){
|
||||
$tree_node->title = $val[$tree_node->id];
|
||||
$tree_node->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function h1ToTitleTravelGuide()
|
||||
{
|
||||
$TravelGuides = TravelGuide::all();
|
||||
foreach ($TravelGuides as $travelGuide){
|
||||
if(strpos($travelGuide->full_text,'<html><body><h1>' )){
|
||||
$dom = new \DOMDocument('1.0', 'utf-8');
|
||||
@$dom->loadHTML(mb_convert_encoding($travelGuide->full_text, 'HTML-ENTITIES', 'UTF-8'));
|
||||
$elements = $dom->getElementsByTagName('h1');
|
||||
|
||||
foreach ($elements as $element) {
|
||||
if($element->nodeValue != ""){
|
||||
var_dump($travelGuide->id);
|
||||
var_dump($element->nodeValue);
|
||||
echo "<br>";
|
||||
var_dump($travelGuide->name);
|
||||
echo "<br>";
|
||||
echo "--";
|
||||
echo "<br>";
|
||||
|
||||
$new_text = preg_replace('/<h1[^>]*>([\s\S]*?)<\/h1[^>]*>/', '', $travelGuide->full_text);
|
||||
|
||||
$travelGuide->name = $element->nodeValue;
|
||||
$travelGuide->full_text = $new_text;
|
||||
$travelGuide->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
die("done");
|
||||
}
|
||||
|
||||
|
||||
public function cleanTextTravelGuide()
|
||||
{
|
||||
$TravelGuides = TravelGuide::all();
|
||||
foreach ($TravelGuides as $travelGuide){
|
||||
$new_text = \App\Services\Util::cleanHTML($travelGuide->full_text);
|
||||
if(strcmp($travelGuide->full_text, $new_text) != 0){
|
||||
$travelGuide->full_text = $new_text;
|
||||
$travelGuide->save();
|
||||
var_dump($travelGuide->id);
|
||||
echo "<br>";
|
||||
}
|
||||
}
|
||||
die("done");
|
||||
}
|
||||
|
||||
|
||||
public function readNodeAndSaveToTree(){
|
||||
$input = Input::all();
|
||||
$ret = [];
|
||||
if(isset($input['text'])){
|
||||
$out = $this->ul_to_array($input['text']);
|
||||
$this->array_to_nodes($out);
|
||||
}
|
||||
die("done");
|
||||
$data = [
|
||||
'text' => $input['text'],
|
||||
'values' => $ret,
|
||||
];
|
||||
return view('iq.tools.links', $data);
|
||||
}
|
||||
|
||||
public function array_to_nodes($array, $lvl = 1, $parent_id = 1, $pos=100){
|
||||
|
||||
|
||||
if(is_array($array)){
|
||||
foreach ($array as $node){
|
||||
if(isset($node['slug'])){
|
||||
|
||||
$slug = substr($node['slug'], 0, 80);
|
||||
// $slug = substr($node['slug'], 0, strrpos($slug, " "));
|
||||
|
||||
$name = substr($node['name'], 0, 255);
|
||||
// $name = substr($node['name'], 0, strrpos($name, " "));
|
||||
|
||||
|
||||
$data = [
|
||||
'tree_id' => 1,
|
||||
'parent_id' => $parent_id,
|
||||
'lvl' => $lvl,
|
||||
'name' => $name,
|
||||
'identifier' => $slug,
|
||||
'active' => false,
|
||||
'pos' => $pos++,
|
||||
];
|
||||
$tree_node = IQContentTreeNode::create($data);
|
||||
|
||||
|
||||
$travel_guides = TravelGuide::whereSlug($node['slug'])->get();
|
||||
foreach ($travel_guides as $travel_guide){
|
||||
if(IQContentSite::whereTreeNodeId($tree_node->id)->whereTravelGuideId($travel_guide->id)->count() == 0) {
|
||||
IQContentSite::create(['tree_node_id' => $tree_node->id, 'travel_guide_id' => $travel_guide->id]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(isset($node['children']) && is_array($node['children'])){
|
||||
$this->array_to_nodes($node['children'], $lvl + 1, $tree_node->id, $pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function ul_to_array($ol){
|
||||
if(is_string($ol)){
|
||||
if(!$ol = simplexml_load_string($ol)) {
|
||||
trigger_error("Syntax error in UL/LI structure");
|
||||
return FALSE;
|
||||
}
|
||||
return $this->ul_to_array($ol);
|
||||
} else if(is_object($ol)){
|
||||
$output = array();
|
||||
foreach($ol->li as $li){
|
||||
|
||||
$tmp = false;
|
||||
if(isset($li->ol)){
|
||||
$tmp = $this->ul_to_array($li->ol);
|
||||
}
|
||||
|
||||
if($li->count()){
|
||||
|
||||
$str = (string) $li;
|
||||
|
||||
$a = new \SimpleXMLElement($li->children()->asXML());
|
||||
$str = (string) $a[0]." ".$str;
|
||||
$str = str_replace("\n", "", $str);
|
||||
$str = str_replace("\r", "", $str);
|
||||
$str = str_replace("\t", "", $str);
|
||||
$str = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $str);
|
||||
|
||||
if(trim($str) !== "" && $str !== null){
|
||||
$slug = (string) $a['href'];
|
||||
$link = explode("/", $slug);
|
||||
|
||||
$link1 = array_pop($link);
|
||||
$link1 = str_replace('.htm', '',$link1);
|
||||
$output[] = ['slug'=> $link1, 'name'=>$str, 'children'=>$tmp];
|
||||
}
|
||||
}else{
|
||||
$str = (string) $li;
|
||||
$str = str_replace("\n", "", $str);
|
||||
$str = str_replace("\r", "", $str);
|
||||
$str = str_replace("\t", "", $str);
|
||||
if(trim($str) !== "" && $str !== null){
|
||||
|
||||
$output[] = ['slug'=>'', 'name'=>$str, 'children'=>$tmp];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return $output;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function rindex()
|
||||
{
|
||||
$data = [
|
||||
'text' => "",
|
||||
'values' => [],
|
||||
];
|
||||
return view('iq.content.tools.redirects', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function rstore()
|
||||
{
|
||||
|
||||
$iqContentTree = IQContentTree::find(2);
|
||||
$this->makeTree($iqContentTree);
|
||||
$input = Input::all();
|
||||
$ret = [];
|
||||
|
||||
if(isset($input['text'])){
|
||||
|
||||
|
||||
$dom = new \DOMDocument('1.0', 'utf-8');
|
||||
@$dom->loadHTML(mb_convert_encoding($input['text'], 'HTML-ENTITIES', 'UTF-8'));
|
||||
|
||||
|
||||
|
||||
|
||||
$tags = ['ol'];
|
||||
foreach ($tags as $tag){
|
||||
$domElements = [];
|
||||
$elements = $dom->getElementsByTagName($tag)->item(0);
|
||||
|
||||
foreach($elements as $node){
|
||||
foreach($node->childNodes as $child) {
|
||||
$ret[] = array($child->nodeName => $child->nodeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* $tags = ['a']; foreach ($tags as $tag){
|
||||
$domElements = [];
|
||||
$elements = $dom->getElementsByTagName($tag);
|
||||
foreach ($elements as $element) {
|
||||
$domElements[] = $element;
|
||||
|
||||
}
|
||||
foreach ($domElements as $domElement) {
|
||||
$r = "-----";
|
||||
$href = $domElement->getAttribute('href');
|
||||
$link = explode("/", $href);
|
||||
|
||||
$link1 = array_pop($link);
|
||||
$link1 = str_replace('.html', '',$link1);
|
||||
$link1 = str_replace('-', '',$link1);
|
||||
if(isset($this->tree[$link1])){
|
||||
$r = $this->tree[$link1];
|
||||
}else{
|
||||
$link1 = array_pop($link);
|
||||
$link1 = str_replace('.html', '',$link1);
|
||||
$link1 = str_replace('-', '',$link1);
|
||||
if(isset($this->tree[$link1])){
|
||||
$r = $this->tree[$link1];
|
||||
}
|
||||
}
|
||||
|
||||
$ret[] = "Redirect 301 /".$href." ".$r;
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
$data = [
|
||||
'text' => $input['text'],
|
||||
'values' => $ret,
|
||||
];
|
||||
|
||||
return view('iq.content.tools.redirects', $data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function makeTree(IQContentTree $iq_content_tree, $lvl = 0, $parent_id = false, $url = "")
|
||||
{
|
||||
|
||||
if ($parent_id) {
|
||||
//where('active', true)
|
||||
$tree_nodes = IQContentTreeNode::where('tree_id', $iq_content_tree->id)->where('lvl', $lvl)->where('active', true)->where('parent_id', $parent_id)->orderBy('pos', 'ASC')->get();
|
||||
} else {
|
||||
|
||||
$url = "/" . $iq_content_tree->identifier . "/";
|
||||
$tree_nodes = IQContentTreeNode::where('tree_id', $iq_content_tree->id)->where('lvl', $lvl)->where('active', true)->orderBy('pos', 'ASC')->get();
|
||||
}
|
||||
|
||||
foreach ($tree_nodes as $node) {
|
||||
$children = IQContentTreeNode::where('tree_id', $iq_content_tree->id)->where('lvl', $lvl + 1)->where('active', true)->where('parent_id', $node->id)->count();
|
||||
$this->tree[str_replace('-', '', $node->identifier)] = url($url . $node->identifier);
|
||||
|
||||
if ($children) {
|
||||
$this->makeTree($iq_content_tree, $lvl + 1, $node->id, $url . $node->identifier . "/");
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ class TravelUserBookingFewoController extends Controller
|
|||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (TravelUserBookingFewo $travel_user_booking_fewo) {
|
||||
return '<a data-order="'.$travel_user_booking_fewo->id.'" href="' . route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
return '<a data-order="'.$travel_user_booking_fewo->id.'" href="' . route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('fewo_lodging', function (TravelUserBookingFewo $travel_user_booking_fewo) {
|
||||
//return '<a href="' . route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->fewo_lodging_id]) . '">'.$travel_user_booking_fewo->fewo_lodging->name.'</a>';
|
||||
|
|
@ -217,7 +217,7 @@ class TravelUserBookingFewoController extends Controller
|
|||
return $travel_user_booking_fewo->getStatuesName();
|
||||
})
|
||||
->addColumn('action_delete', function (TravelUserBookingFewo $travel_user_booking_fewo) {
|
||||
return '<a href="' . route('travel_user_booking_fewo_delete', [$travel_user_booking_fewo->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="far fa-trash"></span></a>';
|
||||
return '<a href="' . route('travel_user_booking_fewo_delete', [$travel_user_booking_fewo->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>';
|
||||
})
|
||||
->rawColumns(['action_edit', 'fewo_lodging', 'travel_user', 'is_calendar', 'is_mail', 'action_delete'])
|
||||
->make(true);
|
||||
|
|
|
|||
|
|
@ -96,11 +96,11 @@ class TravelUserController extends Controller
|
|||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (TravelUser $user) {
|
||||
return '<a data-order="'.$user->id.'" href="' . route('travel_user_detail', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
return '<a data-order="'.$user->id.'" href="' . route('travel_user_detail', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
|
||||
->addColumn('action_delete', function (TravelUser $user) {
|
||||
return '<a href="' . route('travel_user_delete', [$user->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="far fa-trash"></span></a>';
|
||||
return '<a href="' . route('travel_user_delete', [$user->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>';
|
||||
})
|
||||
->rawColumns(['action_edit', 'action_delete'])
|
||||
->make(true);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use Carbon\Carbon;
|
|||
use Illuminate\Database\Connection;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailActivateUser;
|
||||
use App\Mail\ReportExport;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class UserUpdateEmailController extends Controller
|
||||
|
|
@ -146,7 +146,7 @@ class UserUpdateEmailController extends Controller
|
|||
public function sendActivationMail($user, array $data)
|
||||
{
|
||||
$token = $this->createActivation($user, $data);
|
||||
Mail::to($data['email'])->send(new MailActivateUser($token, $user));
|
||||
Mail::to($data['email'])->send(new ReportExport($token, $user));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ class Kernel extends HttpKernel
|
|||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'admin' => \App\Http\Middleware\Admin::class,
|
||||
'superadmin' => \App\Http\Middleware\SuperAdmin::class,
|
||||
'sysadmin' => \App\Http\Middleware\SysAdmin::class,
|
||||
'auth.permission' => \App\Http\Middleware\AuthPermission::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
|
|
|
|||
26
app/Http/Middleware/SysAdmin.php
Executable file
26
app/Http/Middleware/SysAdmin.php
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Auth;
|
||||
|
||||
class SysAdmin
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ( Auth::check() && Auth::user()->isSySAdmin() )
|
||||
{
|
||||
return $next($request);
|
||||
}
|
||||
return redirect('/home');
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue