Fonts, Travel Program

This commit is contained in:
Kevin Adametz 2023-01-25 12:47:23 +01:00
parent 93d1bea8e3
commit 561c5875a7
173 changed files with 12359 additions and 1070 deletions

View file

@ -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);

View file

@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\SyS\Tools;
use App\Http\Controllers\Controller;
use App\Models\Booking;
use App\Models\IQContentSite;
use App\Models\IQContentSiteField;
use App\Models\IQContentTree;
use App\Models\IQContentTreeNode;
use App\Models\TravelCountry;
use App\Models\TravelGuide;
use App\Models\TravelNationality;
use App\Models\TravelBooking;
use Illuminate\Support\Str;
use IqContent\LaravelFilemanager\Controllers\FileController;
use IqContent\LaravelFilemanager\Controllers\FolderController;
use IqContent\LaravelFilemanager\Models\IQContentFile;
use Request;
use Validator;
class SysController extends Controller
{
private $tree = [];
/**
* ContentSiteController constructor.
*/
public function __construct()
{
$this->middleware(['sysadmin', '2fa']);
}
public function filterHTML(){
}
//content_links
public function calcu()
{
/*$query = Booking::with('booking_draft_items')->select('booking.*')->where('new_drafts', true);
$query->whereHas('booking_draft_items', function ($q) {
$q->where('comfort', true);
});
$bookings = $query->get();
foreach ($bookings as $booking){
$booking->comfort = true;
$booking->save();
}
*/
$bookings = Booking::orderBy('id', 'DESC')->offset(0)->limit(1000)->get();
// dd("nothing");
$val = [];
$text = "";
$data = [
'text' => $text,
'bookings' => $bookings,
];
return view('sys.tools.links', $data);
}
/*
clean code
$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);
*/
public function calcuStore()
{
return redirect()->back();
}
}

View file

@ -0,0 +1,65 @@
<?php
namespace App\Http\Controllers\SyS;
use App\Http\Controllers\Controller;
use App\Services\SyS\Import;
use App\Services\SyS\ReCalcu;
use App\Services\SyS\ReImport;
class SysController extends Controller
{
public function __construct()
{
$this->middleware(['sysadmin', '2fa']);
}
public function index()
{
return view('sys.index');
}
public function tool($serve)
{
switch ($serve) {
case 'reimport':
return ReImport::show();
break;
case 'calcu':
dd('check App\Services\SyS\ReCalcu');
break;
case 'tree':
dd('check App\Services\SyS\Import');
break;
case 'clean_tree_code':
dd('check App\Services\SyS\Import');
break;
case 'media_insert':
dd('check App\Services\SyS\Import');
break;
case 'import':
dd('check App\Services\SyS\Import');
break;
}
abort(403, 'not found tool');
}
public function store($serve)
{
switch ($serve) {
case 'reimport':
return ReImport::store();
break;
}
abort(403, 'not found tool');
}
}

View file

@ -1,742 +0,0 @@
<?php
namespace App\Http\Controllers\SyS\Tools;
use App\Http\Controllers\Controller;
use App\Models\Booking;
use App\Models\IQContentSite;
use App\Models\IQContentSiteField;
use App\Models\IQContentTree;
use App\Models\IQContentTreeNode;
use App\Models\TravelCountry;
use App\Models\TravelGuide;
use App\Models\TravelNationality;
use App\Models\TravelBooking;
use Illuminate\Support\Str;
use IqContent\LaravelFilemanager\Controllers\FileController;
use IqContent\LaravelFilemanager\Controllers\FolderController;
use IqContent\LaravelFilemanager\Models\IQContentFile;
use Request;
use Validator;
class ContentLinkController extends Controller
{
private $tree = [];
/**
* ContentSiteController constructor.
*/
public function __construct()
{
$this->middleware(['sysadmin', '2fa']);
}
public function filterHTML(){
}
//content_links
public function index()
{
/*$query = Booking::with('booking_draft_items')->select('booking.*')->where('new_drafts', true);
$query->whereHas('booking_draft_items', function ($q) {
$q->where('comfort', true);
});
$bookings = $query->get();
foreach ($bookings as $booking){
$booking->comfort = true;
$booking->save();
}
*/
$bookings = Booking::orderBy('id', 'DESC')->offset(0)->limit(1000)->get();
// dd("nothing");
$val = [];
$text = "";
$data = [
'text' => $text,
'bookings' => $bookings,
];
return view('sys.tools.links', $data);
}
/*
clean code
$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);
*/
public function store()
{
return redirect()->back();
}
//tree
public function tree()
{
$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($site->travel_guide && $site->identifier === null){
$identifier = $site->travel_guide->scope === 1 ? 'long' : 'short';
//$site->identifier = $site->travel_guide->scope === 1 ? 'long' : 'short';
$text .= "-- ".$site->id." -- ".$identifier."\n";
}
}
}
}
$data = [
'text' => $text,
'values' => $val,
];
return view('sys.tools.trees', $data);
}
public function treeStore()
{
$trees = IQContentTree::all();
foreach ($trees as $tree){
foreach ($tree->iq_content_tree_nodes as $tree_node){
foreach ($tree_node->iq_content_sites as $site){
if($site->travel_guide){
$site->identifier = $site->travel_guide->scope === 1 ? 'long' : 'short';
$site->save();
}
}
}
}
return redirect()->back();
}
//clean_tree_code
public function cleanTreeCode(){
$val = [];
$text = "";
$travelGuide = TravelGuide::find(166);
$text = $travelGuide->full_text;
$data = [
'new_text' => \App\Services\Util::cleanHTML($text),
'full_text' => $travelGuide->full_text,
'values' => $val,
];
return view('sys.tools.clean', $data);
}
public function cleanTreeCodeStore(){
$this->cleanTextTravelGuide();
return redirect()->back();
}
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");
}
//media_insert
public function mediaInsert(){
$val = [];
$text = "";
$data = [
'text' => $text,
'values' => $val,
];
return view('sys.tools.insert', $data);
}
public function mediaInsertStore(){
$val = [];
$data = Request::all();
$text = $data['text'];
if($data['action'] === 'insert'){
$lines = explode(PHP_EOL, $text);
$FolderC = new FolderController();
$FileC = new FileController();
foreach ($lines as $line){
$sep = explode(';', $line);
if(isset($sep[0]) && isset($sep[1]) && isset($sep[2])){
//youtube //main dir
$working_dir = "/shares/youtube/".$sep[0];
$folder_name = $sep[1];
$folder = $FolderC->makeFolder($working_dir, $folder_name);
$working_dir = $working_dir."/".$folder_name;
$file = $FileC->makeYoutube($working_dir, $sep[2]);
$val[] = $file.' - '.$sep[2]." | ".$working_dir;
}
}
}
if($data['action'] === 'youtube_ids'){
$TravelGuides = TravelGuide::all();
foreach ($TravelGuides as $travelGuide){
$this->findYoutubeLinks($val, $travelGuide);
/* <iframe allowfullscreen="" frameborder="0" height="500" src="https://www.youtube-nocookie.com/embed/9zs9RKOFCIs?rel=0" width="100%"></iframe> */
}
}
if($data['action'] === 'replace_youtube_links') {
$TravelGuides = TravelGuide::all();
foreach ($TravelGuides as $travelGuide){
$this->replaceYoutubeLinks($val, $travelGuide);
/* <iframe allowfullscreen="" frameborder="0" height="500" src="https://www.youtube-nocookie.com/embed/9zs9RKOFCIs?rel=0" width="100%"></iframe> */
}
}
if($data['action'] === 'replace_youtube_div') {
$this->replaceYoutubeDiv($val, TravelGuide::find(335));
$TravelGuides = TravelGuide::all();
foreach ($TravelGuides as $travelGuide){
$this->replaceYoutubeDiv($val, $travelGuide);
/* <iframe allowfullscreen="" frameborder="0" height="500" src="https://www.youtube-nocookie.com/embed/9zs9RKOFCIs?rel=0" width="100%"></iframe> */
}
}
$data = [
'text' => $text,
'values' => $val,
];
return view('sys.tools.insert', $data);
}
//import
public function import()
{
$text = "";
$val = [];
$data = [
'text' => $text,
'values' => $val,
];
return view('sys.tools.import', $data);
}
public function importStore()
{
$data = Request::all();
$lines = explode(PHP_EOL, $data['text']);
if($data['action'] === 'import_TN'){
foreach ($lines as $line){
$ex = explode(';', $line);
$t_n = TravelNationality::whereName(trim($ex[1]))->first();
if($t_n){
$t_n->nat = $ex[0];
$t_n->save();
}else{
TravelNationality::create([
'name' => trim($ex[1]),
'nat' => $ex[0],
'active' => false,
]
);
}
}
}
if($data['action'] === 'import_CT') {
foreach ($lines as $line){
$ex = explode(';', $line);
$t_c = TravelCountry::whereName(trim($ex[1]))->first();
if($t_c){
dump($t_c->name);
$t_c->destco = $ex[0];
$t_c->save();
$tc = \App\Models\Sym\TravelCountry::find($t_c->crm_id);
$tc->destco = $ex[0];
$tc->save();
}
}
dd("");
}
return redirect()->back();
}
private function replaceYoutubeDiv(&$val, $travelGuide)
{
$ret = [];
$dom = new \DOMDocument('1.0', 'utf-8');
@$dom->loadHTML(mb_convert_encoding($travelGuide->full_text, 'HTML-ENTITIES', 'UTF-8'));
$links = $dom->getElementsByTagName('iframe');
foreach ($links as $link) {
if($link->parentNode->parentNode->nodeName === 'div'){
if($link->parentNode->parentNode->getAttribute('itemprop') === 'video'){
if($link->parentNode->parentNode->getAttribute('class') === 'mediaA'){
if($link->parentNode->parentNode->parentNode->getAttribute('itemprop') === 'video'){
$need = $link->parentNode->parentNode;
$replace = $link->parentNode->parentNode->parentNode;
$replace->parentNode->insertBefore($dom->importNode($need, true), $replace->nextSibling);
$replace->parentNode->removeChild($replace);
$html = $dom->saveHTML();
$travelGuide->full_text = $html;
$travelGuide->save();
$val[] = 'replace - '.$travelGuide->id;
}else{
// dump("notfound itemprop over class mediaA".$travelGuide->id);
$val[] = 'notfound - itemprop over class mediaA - '.$travelGuide->id;
//in
foreach ($link->parentNode->parentNode->childNodes as $node){
if($node->nodeName === 'h2'){
if($node->firstChild->nodeName === '#text'){
$span = $dom->createElement('span', htmlspecialchars($node->nodeValue));
$span->setAttribute('itemprop', 'name');
$h2 = $dom->createElement('h2');
$h2->appendChild($span);
$node->parentNode->replaceChild($h2, $node);
$html = $dom->saveHTML();
$travelGuide->full_text = $html;
$travelGuide->save();
$val[] = 'replace h2 - '.$travelGuide->id;
}
}
}
//<span itemprop="name">
}
//dump("found M div ".$travelGuide->id);
}else{
// dump("notfound class mediaA".$travelGuide->id);
$val[] = 'notfound - class mediaA - '.$travelGuide->id;
}
}else{
// dump("notfound div ".$travelGuide->id);
$val[] = 'notfound - video - '.$travelGuide->id;
}
// dump($travelGuide->id);
}else{
//dump("notfound".$travelGuide->id);
$val[] = 'notfound - div - '.$travelGuide->id;
}
}
return $ret;
}
private function replaceYoutubeLinks(&$val, $travelGuide)
{
$ret = [];
$dom = new \DOMDocument('1.0', 'utf-8');
@$dom->loadHTML(mb_convert_encoding($travelGuide->full_text, 'HTML-ENTITIES', 'UTF-8'));
$links = $dom->getElementsByTagName('iframe');
foreach ($links as $link) {
$src = $link->getAttribute('src');
//
$replace = false;
$reLink = false;
if($link->parentNode->nodeName === 'div'){
if($link->parentNode->getAttribute('class') === 'video-container'){
if($link->parentNode->parentNode->getAttribute('class') === 'mediaA' && $link->parentNode->parentNode->getAttribute('itemprop') !== 'video'){
$replace = $link->parentNode->parentNode;
$reLink = $link->parentNode;
}else{
$val[] = 'found - manual - '.$travelGuide->id;
}
}else{
$val[] = 'first div - manual - '.$travelGuide->id;
}
}elseif ($link->parentNode->nodeName === 'p'){
if($link->parentNode->parentNode->nodeName === 'div'){
if($link->parentNode->parentNode->getAttribute('itemprop') === 'video'){
//replace div
$replace = $link->parentNode->parentNode;
$reLink = $link->parentNode;
}else{
//replace p
$replace = $link->parentNode;
$reLink = $link;
}
}else{
$replace = $link->parentNode;
$reLink = $link;
}
}else{
$val[] = 'else div - manual - '.$travelGuide->id;
}
if($replace){
$id = preg_replace('/http.*?embed\//i', '', $src);
$videoID = preg_replace('#[&\?].+$#', '', $id);
$identifier = Str::slug(pre_slug($videoID), '-');
$IQContentFile = IQContentFile::whereIdentifier($identifier)->first();
if($IQContentFile) {
$video = new \DOMDocument('1.0', 'utf-8');
$makeText = '<?xml encoding="utf-8" ?><div class="mediaA" itemprop="video" itemscope itemtype="http://schema.org/VideoObject">';
$makeText .= '<h2><span itemprop="name">' . $IQContentFile->content['title'] . '</span></h2>';
$makeText .= '<meta itemprop="duration" content="' . $IQContentFile->content['duration'] . '" />';
$makeText .= '<meta itemprop="uploadDate" content="' . $IQContentFile->content['uploadDate'] . '"/>';
$makeText .= '<meta itemprop="thumbnailURL" content="' . $IQContentFile->content['thumbnailURL'] . '" />';
$makeText .= '<meta itemprop="embedURL" content="https://youtube.googleapis.com/v/' . $IQContentFile->content['id'] . '" />';
$makeText .= '<div class="video-container"><iframe src="https://www.youtube.com/embed/' . $IQContentFile->content['id'] . '?rel=0&amp;controls=0&amp;showinfo=0" data-identifier="' . $IQContentFile->identifier . '" data-slug="' . $IQContentFile->slug . '" frameborder="0" allowfullscreen></iframe></div>';
$makeText .= '<div class="mediaInfo"><p class="infotext" itemprop="description">'.$IQContentFile->content['description'].'</p></div></div>';
$makeText = str_replace('&', '&amp;', $makeText);
$video->loadHTML($makeText);
$replace->insertBefore($dom->importNode($video->documentElement, true), $reLink->nextSibling);
$replace->removeChild($reLink);
$html = $dom->saveHTML();
$travelGuide->full_text = $html;
$travelGuide->save();
$val[] = 'replace - '.$travelGuide->id;
}
}
}
return $ret;
}
private function findYoutubeLinks(&$val, $travelGuide)
{
$ret = [];
$dom = new \DOMDocument('1.0', 'utf-8');
@$dom->loadHTML(mb_convert_encoding($travelGuide->full_text, 'HTML-ENTITIES', 'UTF-8'));
$links = $dom->getElementsByTagName('iframe');
foreach ($links as $link) {
$src = $link->getAttribute('src');
$id = preg_replace('/http.*?embed\//i', '', $src);
$videoID = preg_replace('#[&\?].+$#', '', $id);
$identifier = Str::slug(pre_slug($videoID), '-');
$count = IQContentFile::whereIdentifier($identifier)->count();
if($count === 0){
$ret[$videoID] = $count;
$val[] = "weitere;Travel-Guide;".$videoID.";";
}
}
return $ret;
}
//private?
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 readNodeAndSaveToTree(){
$input = Request::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;
}
}
public function rindex()
{
$data = [
'text' => "",
'values' => [],
];
return view('iq.content.tools.redirects', $data);
}
public function rstore()
{
$iqContentTree = IQContentTree::find(2);
$this->makeTree($iqContentTree);
$input = Request::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;
}
}

View file

@ -9,103 +9,6 @@ namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class TravelBooking
*
* @property int $id
* @property int $salutation_id
* @property string $first_name
* @property string $last_name
* @property string $street
* @property string $zipcode
* @property string $city
* @property int $country_id
* @property string $fax
* @property string $phone
* @property string $mobile
* @property string $comments
* @property string $email
* @property Carbon $created
* @property Carbon $selected_start_date
* @property Carbon $selected_end_date
* @property string $program_name
* @property string $selected_travel
* @property string $selected_departure
* @property int $program_id
* @property int $period_id
* @property string $class
* @property int $selected_adults
* @property int $selected_childs
* @property int $participants_total
* @property string $participants
* @property string $drafts
* @property string $service_items
* @property string $arrangements
* @property string $rooms
* @property float $price
* @property float $price_total
* @property float $deposit_total
* @property float $final_payment
* @property Carbon $final_payment_date
* @property string $insurance_name
* @property string $insurances
* @property int $travel_cancellation
* @property string $options
* @property string $class_options
* @property string $extra_category
* @property bool $accept_legal_rights
* @property string $ip
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereAcceptLegalRights($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereArrangements($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereClass($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereClassOptions($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereComments($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereCreated($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereDepositTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereDrafts($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereExtraCategory($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereFax($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereFinalPayment($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereFinalPaymentDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereFirstName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereInsuranceName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereInsurances($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereIp($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereLastName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereMobile($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereOptions($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereParticipants($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereParticipantsTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking wherePeriodId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking wherePhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking wherePrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking wherePriceTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereProgramId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereProgramName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereRooms($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereSalutationId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereSelectedAdults($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereSelectedChilds($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereSelectedDeparture($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereSelectedEndDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereSelectedStartDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereSelectedTravel($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereServiceItems($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereStreet($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereTravelCancellation($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereZipcode($value)
* @mixin \Eloquent
* @property int|null $crm_booking_id
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelBooking whereCrmBookingId($value)
*/
class TravelBooking extends Model
{
protected $connection = 'mysql_stern';

View file

@ -53,4 +53,5 @@ class TravelClass extends Model
{
return $this->hasMany('App\Models\TravelProgramDraft', 'travel_class_id', 'id');
}
}

View file

@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class TravelProgram
*
*
* @property int $id
* @property float|null $profit_margin
* @property int|null $category_id
@ -58,7 +58,6 @@ use Illuminate\Database\Eloquent\Model;
* @property int|null $discount_is_percent_value
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*
* @property TravelArrivalPoint|null $travel_arrival_point
* @property TravelOrganizer|null $travel_organizer
* @property TravelInsurance|null $travel_insurance
@ -73,8 +72,62 @@ use Illuminate\Database\Eloquent\Model;
* @property Collection|TravelProgramImage[] $travel_program_images
* @property TravelProgramOption $travel_program_option
* @property TravelProgramRelated $travel_program_related
*
* @package App\Models
* @property int|null $travel_company
* @property-read Collection|\App\Models\TravelClass[] $classes
* @property-read int|null $classes_count
* @property-read int|null $travel_classes_count
* @property-read int|null $travel_program_drafts_count
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram query()
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereAdvices($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereCategoryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereClassDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereDefaultFlightPrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereDepositPercent($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereDiscount($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereDiscountIsPercentValue($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereExcluded($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereGeneralnote($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereHtmlDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereInSlider($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereIncluded($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereInsurance1($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereInsurance2($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereInsurance3($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereInsurance4($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereIsSeasonal($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereMapHtml($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereMapImage($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereMapImageExt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereMaxAgeForChildren($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereNettoPricesInEuro($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereNotes($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereOrganizer($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram wherePosition($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereProfitMargin($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereProgramCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereProgramDuration($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereProgramType($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereShowMap($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereSliderInfo($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereSubtitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTextRight($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTravelAgenda($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTravelArrivalPointId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTravelCategory($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTravelCompany($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereTravelCountry($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereUrl($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereWeekdays($value)
* @method static \Illuminate\Database\Eloquent\Builder|TravelProgram whereYouth($value)
* @mixin \Eloquent
*/
class TravelProgram extends Model
{
@ -134,6 +187,7 @@ class TravelProgram extends Model
'url',
'max_age_for_children',
'html_description',
'payment_conditions',
'insurance_1',
'insurance_2',
'insurance_3',
@ -191,9 +245,9 @@ class TravelProgram extends Model
return $this->belongsTo(TravelInsurance::class, 'insurance_3');
}
public function travel_category()
public function travel_program_category()
{
return $this->belongsTo(TravelCategory::class, 'category_id');
return $this->belongsTo(TravelProgramCategory::class, 'category_id');
}
public function travel_general_note()

View file

@ -0,0 +1,29 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
class TravelProgramCategory extends Model
{
protected $connection = 'mysql_stern';
protected $table = 'travel_category';
public $timestamps = false;
protected $fillable = [
'name',
];
public function travel_programs()
{
return $this->hasMany(TravelProgram::class, 'category_id');
}
}

View file

@ -58,4 +58,10 @@ class TravelProgramDraft extends Model
{
return $this->belongsTo(Draft::class, 'draft_id', 'id');
}
public function getWeekdaysOrAll()
{
return ($this->weekdays !== NULL && $this->weekdays[0] !== null) ? $this->weekdays : [0 => "0", 1 => "1", 2 => "2", 3 => "3", 4 => "4", 5 => "5", 6 => "6"];
}
}

View file

@ -0,0 +1,29 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
class TravelProgramCategory extends Model
{
protected $connection = 'mysql_stern';
protected $table = 'travel_category';
public $timestamps = false;
protected $fillable = [
'name',
];
public function travel_programs()
{
return $this->hasMany(TravelProgram::class, 'category_id');
}
}

View file

@ -493,7 +493,10 @@ class DraftRepository extends BaseRepository {
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(in_array($weekday, $travel_program_draft->getWeekdaysOrAll())){
if(!$travel_program_draft->travel_class){
return $travel_program_draft->draft;
}
if($data['comfort'] == false && strpos(strtolower($travel_program_draft->travel_class->name), 'standard') !== false){
return $travel_program_draft->draft;
}

View file

@ -75,6 +75,7 @@ class TravelProgramRepository extends BaseRepository {
'max_age_for_children' => $data['max_age_for_children'] ? $data['max_age_for_children'] : null,
'url' => $data['url'] ? $data['url'] : null,
'generalnote' => $data['generalnote'] ? $data['generalnote'] : null,
'payment_conditions' => $data['payment_conditions'] ? $data['payment_conditions'] : null,
];
$this->model->fill($fill);
$this->model->save();
@ -153,7 +154,7 @@ class TravelProgramRepository extends BaseRepository {
}
public function updateDraft($data)
{
{
if(isset($data['weekdays']) && count($data['weekdays']) > 1 && in_array(NULL, $data['weekdays'])){
$data['weekdays'] = array_filter($data['weekdays'], 'is_numeric');
sort($data['weekdays']);
@ -163,13 +164,13 @@ class TravelProgramRepository extends BaseRepository {
'travel_program_id' => $data['travel_program_id'],
'travel_class_id' => $data['travel_class_id'],
'draft_id' => $data['draft_id'],
'weekdays' => isset($data['weekdays']) ? $data['weekdays'] : null,
'weekdays' => isset($data['weekdays']) ? $data['weekdays'] : NULL,
]);
}else{
$travel_program_draft = TravelProgramDraft::findOrFail($data['id']);
$travel_program_draft->draft_id = $data['draft_id'];
$travel_program_draft->travel_class_id = $data['travel_class_id'];
$travel_program_draft->weekdays = isset($data['weekdays']) ? $data['weekdays'] : null;
$travel_program_draft->weekdays = isset($data['weekdays']) ? $data['weekdays'] : NULL;
$travel_program_draft->save();
}
return $travel_program_draft;

View file

@ -0,0 +1,171 @@
<?php
namespace App\Services;
use App\Models\Lead;
use App\Models\Booking;
use App\Models\Customer;
use App\Models\Arrangement;
use App\Models\Participant;
use App\Models\TravelBooking;
use App\Models\BookingServiceItem;
use App\Repositories\DraftRepository;
class BookingImport
{
public static function importFrom(TravelBooking $travel_booking){
// ---- 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();
$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 $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) {
$draftRepo = new DraftRepository($booking);
$draftRepo->create_drafts_from_booking($booking->id, $travel_booking->drafts);
}
$travel_booking->crm_booking_id = $booking->id;
$travel_booking->save();
return $booking;
}
}

View file

@ -52,6 +52,16 @@ class HTMLHelper
6 => 'Samstag',
];
private static $shortDays = [
0 => 'So',
1 => 'Mo',
2 => 'Di',
3 => 'Mi',
4 => 'Do',
5 => 'Fr',
6 => 'Sa',
];
public static $de_days = [
1 => 'Montag',
2 => 'Dienstag',
@ -89,6 +99,10 @@ class HTMLHelper
return self::$days[$i];
}
public static function getShortDay($i){
return self::$shortDays[$i];
}
public static function getDeDays(){
return self::$de_days;
}
@ -409,13 +423,18 @@ class HTMLHelper
return $ret;
}
public static function getWeekdaysString($weekdays = []){
public static function getWeekdaysString($weekdays = [], $short = false){
$ret = "";
if(is_array($weekdays) && count($weekdays)){
foreach($weekdays as $weekday){
if($weekday !== NULL){
$ret .= self::getDay($weekday).', ';
if($short){
$ret .= self::getShortDay($weekday).', ';
}else{
$ret .= self::getDay($weekday).', ';
}
}
}
if($ret != ""){

652
app/Services/SyS/Import.php Normal file
View file

@ -0,0 +1,652 @@
<?php
namespace App\Services\SyS;
use Carbon;
use Request;
use App\Models\IQContentTree;
use App\Models\IQContentTreeNode;
class Import
{
//tree
public function tree()
{
$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($site->travel_guide && $site->identifier === null){
$identifier = $site->travel_guide->scope === 1 ? 'long' : 'short';
//$site->identifier = $site->travel_guide->scope === 1 ? 'long' : 'short';
$text .= "-- ".$site->id." -- ".$identifier."\n";
}
}
}
}
$data = [
'text' => $text,
'values' => $val,
];
return view('sys.tools.trees', $data);
}
public function treeStore()
{
$trees = IQContentTree::all();
foreach ($trees as $tree){
foreach ($tree->iq_content_tree_nodes as $tree_node){
foreach ($tree_node->iq_content_sites as $site){
if($site->travel_guide){
$site->identifier = $site->travel_guide->scope === 1 ? 'long' : 'short';
$site->save();
}
}
}
}
return redirect()->back();
}
//clean_tree_code
public function cleanTreeCode(){
$val = [];
$text = "";
$travelGuide = TravelGuide::find(166);
$text = $travelGuide->full_text;
$data = [
'new_text' => \App\Services\Util::cleanHTML($text),
'full_text' => $travelGuide->full_text,
'values' => $val,
];
return view('sys.tools.clean', $data);
}
public function cleanTreeCodeStore(){
$this->cleanTextTravelGuide();
return redirect()->back();
}
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");
}
//media_insert
public function mediaInsert(){
$val = [];
$text = "";
$data = [
'text' => $text,
'values' => $val,
];
return view('sys.tools.insert', $data);
}
public function mediaInsertStore(){
$val = [];
$data = Request::all();
$text = $data['text'];
if($data['action'] === 'insert'){
$lines = explode(PHP_EOL, $text);
$FolderC = new FolderController();
$FileC = new FileController();
foreach ($lines as $line){
$sep = explode(';', $line);
if(isset($sep[0]) && isset($sep[1]) && isset($sep[2])){
//youtube //main dir
$working_dir = "/shares/youtube/".$sep[0];
$folder_name = $sep[1];
$folder = $FolderC->makeFolder($working_dir, $folder_name);
$working_dir = $working_dir."/".$folder_name;
$file = $FileC->makeYoutube($working_dir, $sep[2]);
$val[] = $file.' - '.$sep[2]." | ".$working_dir;
}
}
}
if($data['action'] === 'youtube_ids'){
$TravelGuides = TravelGuide::all();
foreach ($TravelGuides as $travelGuide){
$this->findYoutubeLinks($val, $travelGuide);
/* <iframe allowfullscreen="" frameborder="0" height="500" src="https://www.youtube-nocookie.com/embed/9zs9RKOFCIs?rel=0" width="100%"></iframe> */
}
}
if($data['action'] === 'replace_youtube_links') {
$TravelGuides = TravelGuide::all();
foreach ($TravelGuides as $travelGuide){
$this->replaceYoutubeLinks($val, $travelGuide);
/* <iframe allowfullscreen="" frameborder="0" height="500" src="https://www.youtube-nocookie.com/embed/9zs9RKOFCIs?rel=0" width="100%"></iframe> */
}
}
if($data['action'] === 'replace_youtube_div') {
$this->replaceYoutubeDiv($val, TravelGuide::find(335));
$TravelGuides = TravelGuide::all();
foreach ($TravelGuides as $travelGuide){
$this->replaceYoutubeDiv($val, $travelGuide);
/* <iframe allowfullscreen="" frameborder="0" height="500" src="https://www.youtube-nocookie.com/embed/9zs9RKOFCIs?rel=0" width="100%"></iframe> */
}
}
$data = [
'text' => $text,
'values' => $val,
];
return view('sys.tools.insert', $data);
}
//import
public function import()
{
$text = "";
$val = [];
$data = [
'text' => $text,
'values' => $val,
];
return view('sys.tools.import', $data);
}
public function importStore()
{
$data = Request::all();
$lines = explode(PHP_EOL, $data['text']);
if($data['action'] === 'import_TN'){
foreach ($lines as $line){
$ex = explode(';', $line);
$t_n = TravelNationality::whereName(trim($ex[1]))->first();
if($t_n){
$t_n->nat = $ex[0];
$t_n->save();
}else{
TravelNationality::create([
'name' => trim($ex[1]),
'nat' => $ex[0],
'active' => false,
]
);
}
}
}
if($data['action'] === 'import_CT') {
foreach ($lines as $line){
$ex = explode(';', $line);
$t_c = TravelCountry::whereName(trim($ex[1]))->first();
if($t_c){
dump($t_c->name);
$t_c->destco = $ex[0];
$t_c->save();
$tc = \App\Models\Sym\TravelCountry::find($t_c->crm_id);
$tc->destco = $ex[0];
$tc->save();
}
}
dd("");
}
return redirect()->back();
}
private function replaceYoutubeDiv(&$val, $travelGuide)
{
$ret = [];
$dom = new \DOMDocument('1.0', 'utf-8');
@$dom->loadHTML(mb_convert_encoding($travelGuide->full_text, 'HTML-ENTITIES', 'UTF-8'));
$links = $dom->getElementsByTagName('iframe');
foreach ($links as $link) {
if($link->parentNode->parentNode->nodeName === 'div'){
if($link->parentNode->parentNode->getAttribute('itemprop') === 'video'){
if($link->parentNode->parentNode->getAttribute('class') === 'mediaA'){
if($link->parentNode->parentNode->parentNode->getAttribute('itemprop') === 'video'){
$need = $link->parentNode->parentNode;
$replace = $link->parentNode->parentNode->parentNode;
$replace->parentNode->insertBefore($dom->importNode($need, true), $replace->nextSibling);
$replace->parentNode->removeChild($replace);
$html = $dom->saveHTML();
$travelGuide->full_text = $html;
$travelGuide->save();
$val[] = 'replace - '.$travelGuide->id;
}else{
// dump("notfound itemprop over class mediaA".$travelGuide->id);
$val[] = 'notfound - itemprop over class mediaA - '.$travelGuide->id;
//in
foreach ($link->parentNode->parentNode->childNodes as $node){
if($node->nodeName === 'h2'){
if($node->firstChild->nodeName === '#text'){
$span = $dom->createElement('span', htmlspecialchars($node->nodeValue));
$span->setAttribute('itemprop', 'name');
$h2 = $dom->createElement('h2');
$h2->appendChild($span);
$node->parentNode->replaceChild($h2, $node);
$html = $dom->saveHTML();
$travelGuide->full_text = $html;
$travelGuide->save();
$val[] = 'replace h2 - '.$travelGuide->id;
}
}
}
//<span itemprop="name">
}
//dump("found M div ".$travelGuide->id);
}else{
// dump("notfound class mediaA".$travelGuide->id);
$val[] = 'notfound - class mediaA - '.$travelGuide->id;
}
}else{
// dump("notfound div ".$travelGuide->id);
$val[] = 'notfound - video - '.$travelGuide->id;
}
// dump($travelGuide->id);
}else{
//dump("notfound".$travelGuide->id);
$val[] = 'notfound - div - '.$travelGuide->id;
}
}
return $ret;
}
private function replaceYoutubeLinks(&$val, $travelGuide)
{
$ret = [];
$dom = new \DOMDocument('1.0', 'utf-8');
@$dom->loadHTML(mb_convert_encoding($travelGuide->full_text, 'HTML-ENTITIES', 'UTF-8'));
$links = $dom->getElementsByTagName('iframe');
foreach ($links as $link) {
$src = $link->getAttribute('src');
//
$replace = false;
$reLink = false;
if($link->parentNode->nodeName === 'div'){
if($link->parentNode->getAttribute('class') === 'video-container'){
if($link->parentNode->parentNode->getAttribute('class') === 'mediaA' && $link->parentNode->parentNode->getAttribute('itemprop') !== 'video'){
$replace = $link->parentNode->parentNode;
$reLink = $link->parentNode;
}else{
$val[] = 'found - manual - '.$travelGuide->id;
}
}else{
$val[] = 'first div - manual - '.$travelGuide->id;
}
}elseif ($link->parentNode->nodeName === 'p'){
if($link->parentNode->parentNode->nodeName === 'div'){
if($link->parentNode->parentNode->getAttribute('itemprop') === 'video'){
//replace div
$replace = $link->parentNode->parentNode;
$reLink = $link->parentNode;
}else{
//replace p
$replace = $link->parentNode;
$reLink = $link;
}
}else{
$replace = $link->parentNode;
$reLink = $link;
}
}else{
$val[] = 'else div - manual - '.$travelGuide->id;
}
if($replace){
$id = preg_replace('/http.*?embed\//i', '', $src);
$videoID = preg_replace('#[&\?].+$#', '', $id);
$identifier = Str::slug(pre_slug($videoID), '-');
$IQContentFile = IQContentFile::whereIdentifier($identifier)->first();
if($IQContentFile) {
$video = new \DOMDocument('1.0', 'utf-8');
$makeText = '<?xml encoding="utf-8" ?><div class="mediaA" itemprop="video" itemscope itemtype="http://schema.org/VideoObject">';
$makeText .= '<h2><span itemprop="name">' . $IQContentFile->content['title'] . '</span></h2>';
$makeText .= '<meta itemprop="duration" content="' . $IQContentFile->content['duration'] . '" />';
$makeText .= '<meta itemprop="uploadDate" content="' . $IQContentFile->content['uploadDate'] . '"/>';
$makeText .= '<meta itemprop="thumbnailURL" content="' . $IQContentFile->content['thumbnailURL'] . '" />';
$makeText .= '<meta itemprop="embedURL" content="https://youtube.googleapis.com/v/' . $IQContentFile->content['id'] . '" />';
$makeText .= '<div class="video-container"><iframe src="https://www.youtube.com/embed/' . $IQContentFile->content['id'] . '?rel=0&amp;controls=0&amp;showinfo=0" data-identifier="' . $IQContentFile->identifier . '" data-slug="' . $IQContentFile->slug . '" frameborder="0" allowfullscreen></iframe></div>';
$makeText .= '<div class="mediaInfo"><p class="infotext" itemprop="description">'.$IQContentFile->content['description'].'</p></div></div>';
$makeText = str_replace('&', '&amp;', $makeText);
$video->loadHTML($makeText);
$replace->insertBefore($dom->importNode($video->documentElement, true), $reLink->nextSibling);
$replace->removeChild($reLink);
$html = $dom->saveHTML();
$travelGuide->full_text = $html;
$travelGuide->save();
$val[] = 'replace - '.$travelGuide->id;
}
}
}
return $ret;
}
private function findYoutubeLinks(&$val, $travelGuide)
{
$ret = [];
$dom = new \DOMDocument('1.0', 'utf-8');
@$dom->loadHTML(mb_convert_encoding($travelGuide->full_text, 'HTML-ENTITIES', 'UTF-8'));
$links = $dom->getElementsByTagName('iframe');
foreach ($links as $link) {
$src = $link->getAttribute('src');
$id = preg_replace('/http.*?embed\//i', '', $src);
$videoID = preg_replace('#[&\?].+$#', '', $id);
$identifier = Str::slug(pre_slug($videoID), '-');
$count = IQContentFile::whereIdentifier($identifier)->count();
if($count === 0){
$ret[$videoID] = $count;
$val[] = "weitere;Travel-Guide;".$videoID.";";
}
}
return $ret;
}
//private?
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 readNodeAndSaveToTree(){
$input = Request::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;
}
}
public function rindex()
{
$data = [
'text' => "",
'values' => [],
];
return view('iq.content.tools.redirects', $data);
}
public function rstore()
{
$iqContentTree = IQContentTree::find(2);
$this->makeTree($iqContentTree);
$input = Request::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;
}
}

View file

@ -0,0 +1,71 @@
<?php
namespace App\Services\SyS;
use Carbon;
use Request;
use App\Models\Booking;
use App\Models\IQContentTree;
use App\Models\IQContentTreeNode;
class ReCalcu
{
//content_links
public function calcu()
{
/*$query = Booking::with('booking_draft_items')->select('booking.*')->where('new_drafts', true);
$query->whereHas('booking_draft_items', function ($q) {
$q->where('comfort', true);
});
$bookings = $query->get();
foreach ($bookings as $booking){
$booking->comfort = true;
$booking->save();
}
*/
$bookings = Booking::orderBy('id', 'DESC')->offset(0)->limit(1000)->get();
// dd("nothing");
$val = [];
$text = "";
$data = [
'text' => $text,
'bookings' => $bookings,
];
return view('sys.tools.links', $data);
}
/*
clean code
$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);
*/
public function calcuStore()
{
return redirect()->back();
}
}

View file

@ -0,0 +1,41 @@
<?php
namespace App\Services\SyS;
use Carbon;
use Request;
use App\Models\Booking;
use App\Models\TravelBooking;
use App\Services\BookingImport;
class ReImport
{
//content_links
public static function show()
{
$TravelBooking = TravelBooking::orderBy('id', 'DESC')->limit(200)->get();
$data = [
'values' => $TravelBooking,
'text' => '',
];
return view('sys.tools.reimport', $data);
}
public static function store()
{
$data = Request::all();
$ret = "";
if(strpos($data['action'], 'checkOne_') !== false){
$id = (int) str_replace('checkOne_', '', $data['action']);
$travel_booking = TravelBooking::findOrFail($id);
$booking = BookingImport::importFrom($travel_booking);
dd($booking);
}
\Session()->flash('alert-success', $ret);
return back();
}
}