Fonts, Travel Program
This commit is contained in:
parent
93d1bea8e3
commit
561c5875a7
173 changed files with 12359 additions and 1070 deletions
|
|
@ -3,15 +3,8 @@
|
|||
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;
|
||||
|
||||
use App\Services\BookingImport;
|
||||
|
||||
class BookingController extends Controller
|
||||
{
|
||||
|
|
@ -20,9 +13,9 @@ class BookingController extends Controller
|
|||
|
||||
protected $draftRepo;
|
||||
|
||||
public function __construct(DraftRepository $draftRepo)
|
||||
public function __construct()
|
||||
{
|
||||
$this->draftRepo = $draftRepo;
|
||||
|
||||
}
|
||||
|
||||
public function import()
|
||||
|
|
@ -40,158 +33,12 @@ class BookingController extends Controller
|
|||
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);
|
||||
$booking = BookingImport::importFrom($travel_booking);
|
||||
|
||||
// ---- 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();
|
||||
|
||||
$comfort = false;
|
||||
if(isset($travel_booking->drafts['comfort']) && $travel_booking->drafts['comfort']){
|
||||
$comfort = true;
|
||||
}
|
||||
$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,
|
||||
'pax' => $travel_booking->selected_adults,
|
||||
'title' => isset($travel_booking->selected_travel['travel_title']) ? $travel_booking->selected_travel['travel_title'] : "",
|
||||
'comfort' => $comfort,
|
||||
'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,
|
||||
'nationality_id' => isset($travel_booking->participants[0]['nationality']) ? $travel_booking->participants[0]['nationality'] : null,*/
|
||||
'participant_name' => null,
|
||||
'participant_firstname' => null,
|
||||
'participant_birthdate' => null,
|
||||
'participant_salutation_id' => null,
|
||||
'nationality_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'),
|
||||
'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,
|
||||
'travelagenda_id' => isset($travel_booking->selected_travel['travelagenda_id']) ? $travel_booking->selected_travel['travelagenda_id'] : null,
|
||||
'travel_company_id' => isset($travel_booking->selected_travel['travel_company_id']) ? $travel_booking->selected_travel['travel_company_id'] : 4,
|
||||
];
|
||||
|
||||
//createBooking
|
||||
$booking = Booking::create($data);
|
||||
|
||||
//createTraveler
|
||||
if($travel_booking->participants){
|
||||
foreach ($travel_booking->participants as $key => $participant){
|
||||
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'],
|
||||
'nationality_id' =>$participant['nationality'],
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//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
|
||||
'lead_id' => $booking->lead_id
|
||||
];
|
||||
return response()->json(['success' => "import", "ret" => $ret], $this->successStatus);
|
||||
//return response()->json(['error' => 'no-node'], $this->successStatus);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue