public function ajaxVerificarePretPachetPas2(Request $request)
 {
     $packID = unserialize(base64_decode($request->PackID));
     $entryID = unserialize(base64_decode($request->EntryID));
     $camere = unserialize(base64_decode($request->Camere));
     $extraserv = $request->Extraservicii;
     $pachet = Pachete::where('PackID', $packID)->first();
     $intrare = PacheteIntrari::where('EntryID', $entryID)->first();
     $AidaRasp = [];
     dump($packID);
     dump($camere);
     foreach ($camere as $camera) {
         $Rooms = [];
         $ExtraServ = [];
         $ExtraServCam = [];
         $GuestCnt = [];
         array_push($Rooms, ['ID' => $camera['RoomID'], 'Rate' => ['0']]);
         array_push($GuestCnt, ['AgeQualifyingCode' => 'a', 'Count' => $camera['Adults']]);
         if ($camera['Childs'] != 0) {
             foreach ($camera['Ages'] as $ChildAge) {
                 array_push($GuestCnt, ['AgeQualifyingCode' => 'c', 'Count' => '1', 'Age' => $ChildAge]);
             }
         }
         if ($extraserv) {
             foreach ($extraserv as $ExtraServiciu) {
                 if (strpos($ExtraServiciu, $camera['RoomID']) !== false) {
                     $extraServID = explode('|', $ExtraServiciu);
                     $getExtra = Soap::PackExtraServices('Transilvania', $packID, $pachet->Type, $entryID, $extraServID[1]);
                     $serviceEntry = $getExtra->Package->PackEntry->ExtraServices->ExtraService[0]->ServiceEntries->ServiceEntry->ID;
                     array_push($ExtraServ, ['Service' => ['ID' => $extraServID[1]], 'ServiceEntries' => ['ServiceEntry' => ['ID' => $serviceEntry]], 'GuestsCount' => ['GuestCount' => $GuestCnt]]);
                     array_push($ExtraServCam, $extraServID[1]);
                 }
             }
         }
         // verific disponibilitatea in AIDA pentru fiecare camera in parte apoi arunc intr-un array raspunsul
         $packavail = Soap::PackAvail('Transilvania', $packID, $pachet->Type, $entryID, $Rooms, $ExtraServ);
         $array = (array) $packavail->Package->PackEntry->Configuration + ['ExtraServices' => $ExtraServCam];
         // dump($test);
         array_push($AidaRasp, $array);
     }
     // dump($AidaRasp);
     $datasejur = FormatRomanianDate($intrare->DateStart) . ' - ' . FormatRomanianDate($intrare->DateEnd) . ' (' . $intrare->Duration . ' nopti)';
     return (string) view('frontend.ajax.raspuns-pachete-packavail')->with('pachet', $pachet)->with('intrare', $intrare)->with('response', 'response')->with('datasejur', $datasejur)->with('camere', $AidaRasp);
 }
示例#2
0
function getPachetPlecari($packID)
{
    $intrari = PacheteIntrari::where('PackID', $packID)->distinct('DateStart')->get(['EntryID', 'DateStart', 'DateEnd', 'Duration']);
    $intrariOut = [];
    foreach ($intrari as $intrare) {
        // $dataStart = Carbon::parse($intrare->DateStart)->formatLocalized('%a, %d %b %Y');
        // $dataEnd   = Carbon::parse($intrare->DateEnd)->formatLocalized('%a, %d %b %Y');
        $intrariOut[$intrare->EntryID] = FormatRomanianDate($intrare->DateStart) . ' - ' . FormatRomanianDate($intrare->DateEnd) . ' (' . $intrare->Duration . ' nopti)';
    }
    return $intrariOut;
}
 public function XmlFiles($operator)
 {
     $files = File::files("CatalogFiles/{$operator}");
     Pachete::truncate();
     PacheteCamere::truncate();
     PacheteOcupare::truncate();
     PacheteServicii::truncate();
     PacheteIntrari::truncate();
     PacheteOcupare::truncate();
     foreach ($files as $file) {
         $xml = new SimpleXMLElement($file, null, TRUE);
         $pachete = $xml->Packages;
         //----parcurg pachetele din $pachete---//
         foreach ($pachete as $pachet) {
             // dd($pachet);
             //---parcurg nodurile pachetului-----//
             foreach ($pachet as $xml_pachet) {
                 $atribute_pachet = $xml_pachet->attributes();
                 //---definim array_pachet---//
                 $array_pachet = ['PackID' => $atribute_pachet->ID, 'ProjectID' => $xml_pachet->Project->attributes()->ID, 'ProjectName' => $xml_pachet->Project->attributes()->Name, 'HomeCateg' => '', 'Type' => $atribute_pachet->Type, 'Name' => $atribute_pachet->Name, 'Currency' => $atribute_pachet->Currency, 'Code' => $atribute_pachet->Code, 'Description' => $xml_pachet->Description, 'Operator' => $operator];
                 Pachete::create($array_pachet);
                 //-------------de testat cu extradetalii suplimentare
                 $extradescrieri = $xml_pachet->ExtraDescription->Description;
                 if ($extradescrieri) {
                     foreach ($extradescrieri as $xml_extradescrieri) {
                         $atribute_extradescrieri = $xml_extradescrieri->attributes();
                         $array_extradescrieri = ['PackID' => $atribute_pachet->ID, 'Title' => $atribute_extradescrieri->Title, 'Description' => $xml_extradescrieri, 'Operator' => $operator];
                     }
                 }
                 $intrari_pachet = $xml_pachet->PackEntries->PackEntry;
                 //----Parcurg nodul de intrari pachete-----//
                 foreach ($intrari_pachet as $xml_intrari_pachet) {
                     $atribute_intrare_pachet = $xml_intrari_pachet->attributes();
                     //-----definim array_intrari_pachet----//
                     $array_intrare_pachet = ['PackID' => $atribute_pachet->ID, 'EntryID' => $atribute_intrare_pachet->ID, 'DateEnd' => $atribute_intrare_pachet->DateEnd, 'DateStart' => $atribute_intrare_pachet->DateStart, 'Duration' => $xml_intrari_pachet->Duration, 'TimeUnit' => $xml_intrari_pachet->Duration->attributes()->TimeUnit, 'Operator' => $operator];
                     PacheteIntrari::create($array_intrare_pachet);
                     //-----definesc nodurile copil din intrari pachete-----//
                     $extrservicii = $xml_intrari_pachet->ExtraServices->ExtraService;
                     //-----parcurg extraserviciile----//
                     if (!is_null(@$extrservicii)) {
                         foreach ($extrservicii as $xml_extraservicii) {
                             $atribute_extraservicii = $xml_extraservicii->attributes();
                             //-- definim array_extraservicii--//
                             $array_extraservicii = ['EntryID' => $atribute_intrare_pachet->ID, 'ServID' => $atribute_extraservicii->ID, 'Name' => $atribute_extraservicii->Name, 'Type' => $atribute_extraservicii->Type, 'Mandatory' => $atribute_extraservicii->Mandatory, 'PriceSetID' => @$xml_extraservicii->PriceSet->attributes()->ID, 'Operator' => $operator];
                             PacheteServicii::create($array_extraservicii);
                         }
                     }
                     //----------parcurg packconfigurarion--------//
                     $configurari_pachete = $xml_intrari_pachet->PackConfigurations;
                     foreach ($configurari_pachete as $configurare_pachet) {
                         //---------parcurg configurarile-----------//
                         foreach ($configurare_pachet as $xml_configurare_pachet) {
                             //------definesc nodurile copil din configurari
                             $ocupare_camere = $xml_configurare_pachet->Occupancy->GuestCount;
                             $date_camere_unitate = $xml_configurare_pachet->Accommodation;
                             //----parcurg nodul unitate----//
                             $array_adults = [];
                             $array_childs = [];
                             $array_infants = [];
                             $nrAdults = 0;
                             $nrChilds = 0;
                             $nrInfants = 0;
                             foreach ($date_camere_unitate as $xml_unitate_camere) {
                                 $atribute_unitate = $xml_unitate_camere->attributes();
                                 //----definesc array_unitate_camere-----//
                                 $array_unitate_camere = ['PackID' => $atribute_pachet->ID, 'EntryID' => $atribute_intrare_pachet->ID, 'UnitID' => $atribute_unitate->UnitID, 'RoomID' => $atribute_unitate->RoomID, 'Name' => $atribute_unitate->Name, 'Stars' => $atribute_unitate->Stars, 'RoomName' => $atribute_unitate->RoomName, 'RoomType' => $xml_unitate_camere->RoomType, 'RoomFeature' => $xml_unitate_camere->RoomFeature, 'CityID' => $xml_unitate_camere->City->attributes()->ID, 'CityName' => $xml_unitate_camere->City->attributes()->Name, 'Price' => $xml_configurare_pachet->Price->attributes()->Ammount, 'Currency' => $xml_configurare_pachet->Price->attributes()->CurrencyCode, 'Operator' => $operator];
                                 $pachete_camera = PacheteCamere::create($array_unitate_camere);
                                 Pachete::where('PackID', $atribute_pachet->ID)->update(['CityID' => $xml_unitate_camere->City->attributes()->ID]);
                                 Pachete::where('PackID', $atribute_pachet->ID)->update(['UnitID' => $atribute_unitate->UnitID]);
                             }
                             //------parcurg nodurile ocupare camere------//
                             foreach ($ocupare_camere as $xml_ocupare_camere) {
                                 $atribute_ocupare_camere = $xml_ocupare_camere->attributes();
                                 //----definim array_ocupare camere-----//
                                 $array_ocupare_camere = ['IDCamera' => $pachete_camera->id, 'Count' => $atribute_ocupare_camere->Count, 'AgeQualifyingCode' => $atribute_ocupare_camere->AgeQualifyingCode, 'MinAge' => $atribute_ocupare_camere->MinAge, 'MaxAge' => $atribute_ocupare_camere->MaxAge, 'RoomID' => $atribute_unitate->RoomID, 'UnitID' => $atribute_unitate->UnitID, 'PackID' => $atribute_pachet->ID, 'EntryID' => $atribute_intrare_pachet->ID, 'Operator' => $operator];
                                 PacheteOcupare::create($array_ocupare_camere);
                                 //--------creez coloanele de max adulti si max copii din pachete camare------------//
                                 if ((string) $atribute_ocupare_camere->AgeQualifyingCode == 'a') {
                                     $nrAdults += $atribute_ocupare_camere->Count;
                                     // array_push($array_adults, (string) $atribute_ocupare_camere->AgeQualifyingCode . '|' . (string) $atribute_ocupare_camere->Count);
                                 } else {
                                     if ((string) $atribute_ocupare_camere->AgeQualifyingCode == 'c' && (string) $atribute_ocupare_camere->MinAge >= 2) {
                                         $nrChilds += $atribute_ocupare_camere->Count;
                                         // array_push($array_childs, (string) $atribute_ocupare_camere->AgeQualifyingCode . '|' . (string) $atribute_ocupare_camere->Count);
                                     } else {
                                         if ((string) $atribute_ocupare_camere->AgeQualifyingCode == 'c' && (string) $atribute_ocupare_camere->MinAge < 2) {
                                             $nrInfants += $atribute_ocupare_camere->Count;
                                             // array_push($array_infants, (string) $atribute_ocupare_camere->AgeQualifyingCode . '|' . (string) $atribute_ocupare_camere->Count);
                                         }
                                     }
                                 }
                                 //array_push($array_age, (string) $atribute_ocupare_camere->AgeQualifyingCode . "|" . $atribute_ocupare_camere->Count);
                             }
                             // $pachete_camera->update(['Adults' => serialize($array_adults), 'Childs' => serialize($array_childs), 'Infants' => serialize($array_infants)]);
                             $pachete_camera->update(['Adults' => $nrAdults, 'Childs' => $nrChilds, 'Infants' => $nrInfants]);
                             // dd($pachete_camera);
                         }
                     }
                 }
             }
         }
         // Files::delete($file);
     }
 }