Пример #1
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $modelC = new Campaigns('search');
     $modelC->unsetAttributes();
     // clear any default values
     if (isset($_GET[get_class($modelC)])) {
         $modelC->attributes = $_GET[get_class($modelC)];
     }
     $this->userData = Users::model()->findByPk($id);
     $list = null;
     switch ($this->userData->role) {
         case Users::ROLE_USER:
             $only_active = false;
             if (isset($_GET[get_class($modelC)])) {
                 $modelC->attributes = $_GET[get_class($modelC)];
                 if (isset($_GET[get_class($modelC)]['is_active']) && $_GET[get_class($modelC)]['is_active'] == 1) {
                     $only_active = true;
                 }
             }
             $list = $modelC->searchForUser($this->userData->id, $only_active);
             break;
         case Users::ROLE_PLATFORM:
             $model = new Platforms('search');
             $model->user_id = $this->userData->id;
             $list = $model->search();
             break;
         case Users::ROLE_WEBMASTER:
             Offers::disableDefaultScope();
             $status = Yii::app()->request->getParam('status', -1);
             $list = OffersUsers::model()->findByUserId($this->userData->id, true, $status === '' ? -1 : $status);
             break;
     }
     $this->render('view', array('model' => $this->loadModel($id), 'modelC' => $modelC, 'list' => $list));
 }
Пример #2
0
 public function init()
 {
     $site = Sites::model()->getCurrentSite();
     //echo $site->theme;
     Yii::app()->theme = $site->theme;
     $this->site_id = $site->id;
     Yii::import('application.extensions.sesmail.*');
     require_once 'vendors/aws-sdk/sdk.class.php';
     $this->ses = new YiiSesMail();
     if (stristr($_SERVER['REQUEST_URI'], 'admin')) {
         //if(!Yii::app()->user->isSuperUser) {
         //	$this->redirect("/");
         //	exit;
         //}
         $session = new CHttpSession();
         $session->open();
         $site_id = $session['site_id'];
         // override the site_id (since switched)
         if ($site_id) {
             $this->site_id = $site_id;
         }
         $this->sites = CHtml::listData(Sites::model()->findAll(), 'id', 'name');
         $this->admin = 1;
         $this->layout = '//layouts/admin';
     } else {
         $this->isEditor = Yii::app()->user->checkAccess('admin');
         $this->niches = Offers::model()->getNiches($this->site_id);
         //$this->site_id = $site->getCurrentSite();
         //Yii::import('application.extensions.sesmail.*');
         //require_once('protected/extensions/sesmail/YiiSesMail.php');
         //require_once('vendors/aws-sdk/sdk.class.php');
         $session = new CHttpSession();
         $session->open();
         $seenOffer = $session['seenBackout'];
         if ($seenOffer) {
             $this->hideBackout = true;
         }
         Yii::import('application.modules.user.models.*');
         $this->registration_model = new RegistrationForm();
         $this->login_model = new UserLogin();
     }
     parent::init();
 }
Пример #3
0
 public function sendOffer()
 {
     $slug = 'offerte-aanvragen';
     $page = Page::where('slug', 'LIKE', $slug)->first();
     $rules = array('name' => 'required|min:3', 'street' => 'required|min:3', 'zipcode' => 'required|min:3', 'city' => 'required|min:3', 'email' => 'required|min:3', 'phone' => 'required|min:3', 'boat_length' => 'required|min:1', 'boat_width' => 'required|min:1', 'storage' => 'required|min:3', 'total' => 'required|min:1');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::route('front.offer')->withErrors($validator)->With(Input::all());
     } else {
         $offer = new Offers();
         $offer->name = Input::get('name');
         $offer->street = Input::get('street');
         $offer->zipcode = Input::get('zipcode');
         $offer->city = Input::get('city');
         $offer->phone = Input::get('phone');
         $offer->email = Input::get('email');
         $offer->boat = Input::get('boat');
         $offer->storage = Input::get('storage');
         $offer->boat_length = Input::get('boat_length');
         $offer->boat_width = Input::get('boat_width');
         $offer->home_service = Input::get('home_service');
         $offer->home_service_km = Input::get('home_service_km');
         $offer->battery_service = Input::get('battery_service');
         $offer->outside_motor = Input::get('outside_motor');
         $offer->winter_ready = Input::get('winter_ready');
         $offer->repair_silo = Input::get('repair_silo');
         $offer->storage_period = Input::get('storage_period');
         $offer->storage_start = Input::get('storage_start');
         $offer->remarks = Input::get('remarks');
         $offer->total = Input::get('total');
         //            dd($offer);
         if ($offer->save()) {
             return View::make('front.pages.offer')->with(['page' => $page, 'message' => 'Offerte is aangevraagt, bedankt voor uw interesse wij nemen zo snel mogelijk contact met u op.']);
         }
     }
 }
 /**
  * Return array of offers in building.
  * @return Offer[]
  */
 public function GetOffers()
 {
     if ($this->_Offers == null) {
         $this->_Offers = Offers::GetOffersInvestmentBuilding($this->GetId(), $this->GetIdLng());
     }
     return $this->_Offers;
 }
Пример #5
0
 /**
  * Verifies offers
  * @return int[]
  */
 public static function VerifyOffers()
 {
     $list = array();
     $xml = new XMLReader();
     $domdoc = new DOMDocument();
     $xml->open(WebServiceVirgo::TMP_XML_OFELIST_FILE);
     Errors::LogSynchroStep('Offers - VerifyOffers() - step 1');
     $xml->read();
     while ($xml->name) {
         if ($xml->name == 'Oferta') {
             $node = simplexml_import_dom($domdoc->importNode($xml->expand(), true));
             $list[] = (int) $node["ID"];
         }
         $xml->read();
     }
     Errors::LogSynchroStep('Offers - VerifyOffers() - step 2');
     $db = DataBase::GetDbInstance();
     $query = "SELECT DISTINCT(id) FROM #S#offers o";
     $result = $db->ExecuteQuery($query);
     $ofrs = new Offers();
     //delete wrong offers
     $localOffs = array();
     $flippedList = array_flip($list);
     while ($row = $db->FetchArray($result)) {
         if (!isset($flippedList[$row[0]])) {
             $ofrs->DeleteOffer($row[0]);
         } else {
             $localOffs[] = $row[0];
         }
     }
     //detect missing offers
     $braki = array();
     $flippedLocalOffs = array_flip($localOffs);
     foreach ($list as $id) {
         if (!isset($flippedLocalOffs[$id])) {
             $braki[] = $id;
         }
     }
     Errors::LogSynchroStep('Offers - VerifyOffers() - step 3');
     return $braki;
 }
Пример #6
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Offers::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #7
0
 /**
  * Starts synchronization process of the database.
  * @param bool $skipTimeStamp Disables time stamp validation.
  * @return string
  */
 public function SynchronizeDB($skipTimeStamp = false)
 {
     if (WebServiceVirgo::WS()) {
         try {
             Errors::LogSynchroStep('VirgoApi - SynchronizeDB() - SYNCHRONIZATION START...');
             $date = $this->LoadParam(VirgoAPI::PARAM_SYNCHRONIZATION_TIME, time());
             if (time() - $date > Config::$DataSynchronizationInterval || $skipTimeStamp) {
                 $this->SaveParam(VirgoAPI::PARAM_SYNCHRONIZATION_TIME, time());
                 $cwd = getcwd();
                 chdir(VIRGO_API_DIR);
                 WebServiceVirgo::WS()->LoginEx();
                 //wyslanie odslon ofert
                 WebServiceVirgo::WS()->NoteOffersViews(Offers::GetOffersViews());
                 $log = "";
                 $count = WebServiceVirgo::WS()->GetOffers($log);
                 Errors::LogSynchroStep('VirgoApi - SynchronizeDB() - step 1');
                 $count2 = WebServiceVirgo::WS()->GetInvestments();
                 Errors::LogSynchroStep('VirgoApi - SynchronizeDB() - step 2');
                 //pobranie listy aktualnych ofert
                 //weryfikacja ofert czy istnieja jesli nie to usuwa z bazy
                 $xmlOffersLoaded = $this->GetOffersList(true);
                 if ($xmlOffersLoaded !== true) {
                     return 'VirgoAPI:SynchronizeDB: XML Error - VirgoAPI::GetOffersList(true)';
                 }
                 Errors::LogSynchroStep('VirgoApi - SynchronizeDB() - step 3');
                 $missingIds = $xmlOffersLoaded ? Offers::VerifyOffers() : array();
                 Errors::LogSynchroStep('VirgoApi - SynchronizeDB() - step 4');
                 if (count($missingIds) > 0) {
                     if (!file_exists("logs")) {
                         mkdir("logs");
                     }
                     $d = date("Y_m_d_H_i_s");
                     $logFileHandle = fopen("logs/" . $d . "_log.txt", "w");
                     fwrite($logFileHandle, $log);
                     fclose($logFileHandle);
                     copy("tmp.xml", "logs/" . $d . "_tmp.xml");
                     WebServiceVirgo::WS()->SetMissingOffers($missingIds);
                 }
                 Errors::LogSynchroStep('VirgoApi - SynchronizeDB() - step 5');
                 if (Config::$UsePropertiesDiskCache) {
                     $this->ClearPropertiesCache();
                 }
                 WebServiceVirgo::WS()->Logout();
                 chdir($cwd);
                 return "Ofs: {$count}, Invs: {$count2}";
             } else {
                 return "-";
             }
         } catch (Exception $ex) {
             Errors::LogError("VirgoAPI:SynchronizeDB", $ex->getMessage());
             return "ERROR";
         }
         Errors::LogSynchroStep('VirgoApi - SynchronizeDB() - SYNCHRONIZATION DONE!');
     } else {
         return 'Error: WebService not available';
     }
 }
Пример #8
0
 public function delofferAction()
 {
     $this->view->disable();
     $user_id = $this->session->get('user_id');
     if ($this->request->isAjax()) {
         $offer = Offers::findFirst($this->request->getPost('offer_id'));
         foreach ($offer->dannoffers as $dann) {
             $dann->delete();
         }
         foreach ($offer->comments as $comment) {
             $comment->delete();
         }
         foreach ($offer->favorites as $fav) {
             foreach (OffersHasFavorites::find(array('favorites_id  = "' . $fav->id . '"')) as $favs) {
                 $favs->delete();
             }
             $fav->delete();
         }
         $offer->delete();
         $el = new Elements();
         if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/public/upload/users/user-' . $user_id . '/offers/offer-' . $this->request->getPost('offer_id'))) {
             $el->delete($_SERVER['DOCUMENT_ROOT'] . '/public/upload/users/user-' . $user_id . '/offers/offer-' . $this->request->getPost('offer_id'));
         }
     }
 }
Пример #9
0
 /**
  * Populate the array of site links
  * @param array[] &$list The array which holds the array of link information: loc, frequency, priority
  */
 public function populateSitemap(&$list)
 {
     $offers = Offers::model()->published()->currentSite()->findAll();
     $niches = Niches::model()->published()->currentSite()->findAll();
     // Add primary items here
     $list[] = array('loc' => $this->createAbsoluteUrl('/'), 'frequency' => 'weekly', 'priority' => '1');
     $list[] = array('loc' => $this->createAbsoluteUrl('/registration'), 'frequency' => 'yearly', 'priority' => '0.5');
     $list[] = array('loc' => $this->createAbsoluteUrl('/login'), 'frequency' => 'monthly', 'priority' => '0.5');
     $list[] = array('loc' => $this->createAbsoluteUrl('/past'), 'frequency' => 'monthly', 'priority' => '0.5');
     $list[] = array('loc' => $this->createAbsoluteUrl('/privacy.html'), 'frequency' => 'yearly', 'priority' => '0.5');
     $list[] = array('loc' => $this->createAbsoluteUrl('/offers/index'), 'frequency' => 'weekly', 'priority' => '1');
     foreach ($niches as $row) {
         $list[] = array('loc' => $this->createAbsoluteUrl('/niches/view', array('slug' => $row->name)), 'frequency' => 'weekly', 'priority' => '1');
     }
     foreach ($offers as $row) {
         $list[] = array('loc' => $this->createAbsoluteUrl('/offers/view', array('slug' => $row->slug)), 'frequency' => 'weekly', 'priority' => '1');
     }
 }
Пример #10
0
 /**
  * Return offer as object.
  * @return Offer
  */
 public function GetOfferObj()
 {
     if ($this->_OfferObj == null) {
         $this->_OfferObj = Offers::GetOffer($this->GetOfferId(), $this->GetOfferLng());
     }
     return $this->_OfferObj;
 }
Пример #11
0
                    <span>Dates: </span>
                    <?php //echo $_REQUEST['check_in_date'] . ' - ' . $_REQUEST['check_out_date'];
					//echo "<br /> // ***";
                        echo $_SESSION['check_in_date'] . ' - ' . $_SESSION['check_out_date']; ?>
                </li>
                <li style = "display:none;">
                    <span>Guests: </span>
                    <?php echo $_SESSION['book_room_adults'] . ' Adults, ' . $_SESSION['book_room_children'] . ' Children';
                        echo $_SESSION['book_room_adults'] . ' Adults, ' . $_SESSION['book_room_children'] . ' Children'; ?>
                </li>
            </ul>
            <a href = "<?php echo HTTP_PATH . 'bookings/' . $hotels->hotelSeoUrl() . '.html'; ?>" class = "bookbutton">Edit Reservation</a>
        </div>
    </div><!-- booking-side-wrapper -->
    <?php
        $offers=new Offers();
        $offerArr=$offers->getOffersForHotel($hotels_id);
        if(count($offerArr)>0){
    ?>
    <div class = "booking-side-wrapper">
        <div class = "booking-side clearfix">
            <h4 class = "title-style4">Special Offers<span class = "title-block"></span></h4>
            <div class="bookings-offers">
                <?php
                    foreach($offerArr as $offer){ ?>
                        <div class="offers">
                            <h4>
                                <?php
                                    $room=new HotelRoomType();
                                    $room->setRoomTypeId($offer['room_type']);
                                    $room->extractor($room->getHotelRoomTypeFromId());
Пример #12
0
 public static function disableDefaultScope()
 {
     self::$_useDefaultScope = false;
 }
 public function detailAction()
 {
     $response = new ApiResponse();
     if ($this->request->isGet()) {
         $offers_id = $this->request->get('offers_id');
         $offer = Offers::findFirstById($offers_id);
         if ($offer == false) {
             $response->setResponseError('No offer found!');
             return $response;
         } else {
             $response->setResponse($offer, 1);
             return $response;
         }
     } else {
         $response->setResponseError('Wrong HTTP Method');
     }
     return $response;
 }
Пример #14
0
<legend>Past Deals</legend>
<p>No past deals yet.  Check back soon!</p>
<?php 
$this->beginClip('bottomoffers');
?>
        <ul class="thumbnails">    
            <?php 
$this->widget('bootstrap.widgets.TbListView', array('dataProvider' => Offers::model()->getSideOffers(null, $this->site_id, 3), 'summaryText' => false, 'emptyText' => false, 'itemView' => '//offers/_smallthumb'));
?>
        </ul>
        <div style="text-align:right;margin-right:5px;clear:both;margin-bottom:15px;">
            <a align="text-align:right;clear:both;" class="btn btn-large btn-success" href="<?php 
echo $this->createUrl('offers/');
?>
">See More <i class="icon-chevron-right icon-white"></i></a>
        </div>
<?php 
$this->endClip();
Пример #15
0
function loadHotelsWithOffers()
{
    $from_date = date('Y-m-d');
    $hotel_id = $_REQUEST['hotel_id'];
    $offers = new Offers();
    $offerArr = $offers->loadOffersForHotel($from_date, $hotel_id);
    $offerContent = "";
    $offerAvailable = false;
    if (count($offerArr) > 0) {
        $offerAvailable = true;
        $offerContent = "\n            <div>\n                <div class='group-set' style='width: 100%;'>\n                    <div class='front-offers'>";
        foreach ($offerArr as $offer) {
            $offerContent = $offerContent . "\n                                <div class='offers'>\n                                    <h4>";
            $room = new HotelRoomType();
            $room->setRoomTypeId($offer['room_type']);
            $room->extractor($room->getHotelRoomTypeFromId());
            $offerContent = $offerContent . "Room: " . $room->roomTypeName() . " | " . $offer['title'];
            $room = null;
            $offerContent = $offerContent . "</h4>\n                                    <div  class='desc clearfix'>" . $offer['des'] . "</div>\n                                    <div class='offer-image clearfix'>";
            if ($offer['image'] != '' && file_exists(DOC_ROOT . 'uploads/special_offers/' . $offer['image'])) {
                $offerContent = $offerContent . "<img style='max-width: 100%; max-height: 100%;' src='" . HTTP_PATH . "uploads/special_offers/" . $offer['image'] . "' />";
            }
            $offerContent = $offerContent . "</div>\n                                    <div class='clearfix detail'>\n                                        <ul class='offerFe'>\n                                            <li>Offer type : ";
            if ($offer['dis_type'] == 0) {
                $offerContent = $offerContent . "Fixed Price";
            } elseif ($offer['dis_type'] == 1) {
                $offerContent = $offerContent . "Percentage Discount";
            } elseif ($offer['dis_type'] == 2) {
                $offerContent = $offerContent . "Free Nights";
            } elseif ($offer['dis_type'] == 3) {
                $offerContent = $offerContent . "Custom";
            }
            $offerContent = $offerContent . "</li>\n                                            <li>";
            if ($offer['date_validity'] == 'on') {
                $offerContent = $offerContent . "Only for ";
            } else {
                $offerContent = $offerContent . "For ";
            }
            $offerContent = $offerContent . "bookings between " . $offer['from_date'] . " & " . $offer['to_date'] . "</li>\n                                            <li>Offer available for\n                                                <ul>\n                                                    <li>Beds:";
            $beds = Libs::get('bed_type');
            foreach (array_filter(explode(':', $offer['bed_type'])) as $bed) {
                $offerContent = $offerContent . $beds[$bed] . "/ ";
                if ($offerContent != "") {
                    $offerContent = $offerContent . $beds[$bed] . "/ ";
                } else {
                    $offerContent = $offerContent . $beds[$bed];
                }
            }
            $offerContent = $offerContent . "</li>\n                                                    <li>Meals:";
            $meals = Libs::get('meal_type');
            foreach (array_filter(explode(':', $offer['meal_type'])) as $meal) {
                $offerContent = $offerContent . $meals[$meal] . "/ ";
            }
            $offerContent = $offerContent . "</li>\n                                                </ul>\n                                            </li>\n                                        </ul>\n                                    </div>\n                                    <div class='clearfix'></div>\n                                </div>";
        }
        $offerContent = $offerContent . "</div>\n                    </div>\n                </div>";
    } else {
        $offerAvailable = false;
    }
    $offerArray = array("offerAvailable" => $offerAvailable, "offerContent" => $offerContent);
    echo json_encode($offerArray);
}
Пример #16
0
 /**
  * Returns unique list of used languages in offers or definied in service.
  * @return Language[]
  */
 public function GetAvailableLanguages()
 {
     if ($this->checkwebext()) {
         return Serwisy::GetAvailableLanguages();
     } else {
         return Offers::GetAvailableLanguages();
     }
 }
Пример #17
0
 public function edit($id)
 {
     $offers = Offers::find($id);
     return View::make('admin.pages.offer.edit')->with(['offers' => $offers]);
 }
Пример #18
0
 /**
  * Return offer as object.
  * @return Offer
  */
 public function GetOfferObj()
 {
     if ($this->_OfferObj == null) {
         $ofs = new Offers();
         $this->_OfferObj = $ofs->GetOffer($this->GetOfferId());
     }
     return $this->_OfferObj;
 }
Пример #19
0
 public function listByCode($code)
 {
     $offers = Offers::where('display_from', '<', 'CURDATE')->where('display_to', '>', 'CURDATE')->where('archive', '!=', '1')->where('trip_from', '=', $code)->get();
     return Response::json(array('success' => true, 'data' => $offers->toArray()));
 }
Пример #20
0
 /**
  * Get a list of offers to be added or remove. Write the offers to the database.
  * @param boolean $archive
  * @param string &$log
  * @param array &$count_arr
  * @return null|int|array
  * @throws Exception 
  */
 private function GetOffersPartial($archive, &$log, &$count_arr)
 {
     Errors::LogSynchroStep('WebServiceVirgo - GetOffersPartial() start...');
     if (!$this->WS()) {
         Errors::LogSynchroStep('WebServiceVirgo - NO WEBSERVICE');
         return null;
     }
     try {
         $log .= "archive=" . (int) $archive . "\n";
         $time_start = microtime_float();
         if ($this->_sid == "") {
             return;
         }
         $params = array('sid' => $this->_sid);
         if ($archive) {
             $result = $this->WS()->getSC()->__soapCall("GetOffersArchive", array($params));
             $buf = $result->GetOffersArchiveResult->OffersZip;
             $status = $result->GetOffersArchiveResult->Status;
             $msg = $result->GetOffersArchiveResult->Message;
         } else {
             $result = $this->WS()->getSC()->__soapCall("GetOffers", array($params));
             $buf = $result->GetOffersResult->OffersZip;
             $status = $result->GetOffersResult->Status;
             $msg = $result->GetOffersResult->Message;
         }
         $time_end = microtime_float();
         $time = $time_end - $time_start;
         if ($this->_DEBUG) {
             echo "SOAP Call execution time: {$time} seconds<br>";
         }
         if ($status != 0) {
             throw new Exception($msg);
         }
         $zip_file = $archive ? self::TMP_ZIP_ARCH_FILE : self::TMP_ZIP_FILE;
         $f = fopen($zip_file, "w");
         fwrite($f, $buf);
         fclose($f);
         $time_end2 = microtime_float();
         $time = $time_end2 - $time_end;
         if ($this->_DEBUG) {
             echo "Save ZIP execution time: {$time} seconds<br>";
         }
         //unzip XML file with offers
         $contents = "";
         $zip = new ZipArchive();
         if ($zip->open($zip_file)) {
             $fp = $zip->getStream('xml.xml');
             if (!$fp) {
                 exit("failed reading xml file (" . getcwd() . "), probably invalid permissions to folder\n");
             }
             $contents = '';
             while (!feof($fp)) {
                 $contents .= fread($fp, 1024);
             }
             fclose($fp);
             $zip->close();
             $xml_file = $archive ? self::TMP_XML_OFE_ARCH_FILE : self::TMP_XML_OFE_FILE;
             file_put_contents($xml_file, $contents);
             if (file_exists($zip_file)) {
                 unlink($zip_file);
             }
         }
         $time_end3 = microtime_float();
         $time = $time_end3 - $time_end2;
         if ($this->_DEBUG) {
             echo "Save XML execution time: {$time} seconds<br>";
         }
         $times = array("read_props" => 0, "save" => 0, "del_props" => 0, "rooms" => 0, "del_offers" => 0, "rooms_del" => 0, "photos" => 0);
         $prevOfferId = "0";
         $content = file_get_contents($xml_file);
         //$content = preg_replace("/<UwagiOpis>([^\<\>]*)\<\/UwagiOpis>/m", "<UwagiOpis><![CDATA[$1]]></UwagiOpis>", $content);
         //$content = preg_replace("/<UwagiNieruchomosc>([^\<\>]*)\<\/UwagiNieruchomosc>/m", "<UwagiNieruchomosc><![CDATA[$1]]></UwagiNieruchomosc>", $content);
         $fp = fopen($xml_file, 'w');
         fwrite($fp, $content);
         fclose($fp);
         //open and read XML file
         $xml2 = new XMLReader();
         $xml2->open($xml_file);
         $domdoc = new DOMDocument();
         $ids_do_usuniecia_dodania = array();
         $all_agents_ids = array();
         $all_dept_ids = array();
         $blokuj_agentow = true;
         $blokuj_oddzialy = true;
         $time_end4 = microtime_float();
         $time = $time_end4 - $time_end3;
         if ($this->_DEBUG) {
             echo "Load XML execution time: {$time} seconds<br>";
         }
         $xml2->read();
         while ($xml2->name) {
             //Departments
             if ($xml2->name == "Oddzial") {
                 if ($blokuj_oddzialy) {
                     $blokuj_oddzialy = false;
                 }
                 $node = simplexml_import_dom($domdoc->importNode($xml2->expand(), true));
                 if (count($node) > 0) {
                     $log .= "oddzial=" . $node["ID"] . " - " . $node->Nazwa . "\n";
                     $dep = new Department($node["ID"], $node->Nazwa, $node->Nazwa2, $node->Adres, $node->Miasto, $node->Kod, $node->Nip, $node->Wojewodztwo, $node->Www, $node->Telefon, $node->Email, $node->Fax, $node->Uwagi, $node->Naglowek, $node->Stopka, $node->PlikLogo, $node->ZdjecieWWW, $node->Subdomena, $node->Firma);
                     array_push($all_dept_ids, (int) $node["ID"]);
                     Departments::AddEditDepartment($dep);
                     echo DataBase::GetDbInstance()->LastError();
                 }
             }
             //Agents
             if ($xml2->name == "Agent") {
                 if ($blokuj_agentow) {
                     $blokuj_agentow = false;
                 }
                 $node = simplexml_import_dom($domdoc->importNode($xml2->expand(), true));
                 if (count($node) > 0) {
                     $log .= "agent=" . $node["ID"] . " - " . $node->Nazwa . "\n";
                     $kod_pracownika = 0;
                     if (is_numeric($node->KodPracownika)) {
                         $kod_pracownika = (int) $node->KodPracownika;
                     }
                     $agent = new Agent($node["ID"], $node->Nazwa, $node->Telefon, $node->Komorka, $node->Email, $node->Oddzial, $node->JabberLogin, $node->NrLicencji, $node->OdpowiedzialnyNazwa, $node->OdpowiedzialnyNrLicencji, $node->Komunikator, $node->PlikFoto, $kod_pracownika, $node->DzialFunkcja);
                     array_push($all_agents_ids, (int) $node["ID"]);
                     Agents::AddEditAgent($agent);
                     echo DataBase::GetDbInstance()->LastError();
                 }
             }
             //Offers
             if ($xml2->name == "Oferty") {
                 $node = simplexml_import_dom($domdoc->importNode($xml2->expand(), true));
                 if (count($node) > 0) {
                     foreach ($node->children() as $nodeOferta) {
                         $count_arr["suma"]++;
                         $log .= "oferta=" . $nodeOferta["ID"] . " - " . $nodeOferta["Symbol"] . "\n";
                         //read major properties
                         $rent = strtolower($nodeOferta["Wynajem"]) == "true" ? 1 : 0;
                         $orig = strtolower($nodeOferta["Pierwotny"]) == "true" ? 1 : 0;
                         $przedmiot = $nodeOferta["Przedmiot"];
                         if ($przedmiot == "Biurowiec") {
                             $przedmiot = "Obiekt";
                         }
                         $first_page = strtolower($nodeOferta->PierwszaStrona) == "true" ? 1 : 0;
                         $zamiana = $nodeOferta->Zamiana ? 1 : 0;
                         $loc_as_commune = strtolower($nodeOferta["LokalizacjaJakoGmina"]) == "true" ? 1 : 0;
                         $has_swfs = 0;
                         $has_movs = 0;
                         $has_maps = 0;
                         $has_projs = 0;
                         $has_pans = 0;
                         $has_photos = 0;
                         if (isset($nodeOferta->Zdjecia)) {
                             foreach ($nodeOferta->Zdjecia->children() as $zd) {
                                 switch ($zd->typ) {
                                     case "Zdjecie":
                                         $has_photos = 1;
                                         break;
                                     case "Rzut":
                                         $has_projs = 1;
                                         break;
                                     case "Mapa":
                                         $has_maps = 1;
                                         break;
                                     case "SWF":
                                         $has_swfs = 1;
                                         break;
                                     case "Filmy":
                                         $has_movs = 1;
                                         break;
                                     case "Panorama":
                                         $has_pans = 1;
                                         break;
                                 }
                             }
                         }
                         $attr_arr = array("Link" => null, "ZeroProwizji" => 0);
                         if (isset($nodeOferta->Atrybuty)) {
                             foreach ($nodeOferta->Atrybuty->children() as $at) {
                                 if ($at["opis"] == "Link") {
                                     $attr_arr["Link"] = (string) $at;
                                 }
                                 if ($at["opis"] == "ZeroProwizji") {
                                     $attr_arr["ZeroProwizji"] = (string) $at;
                                 }
                             }
                         }
                         $offer = new Offer($nodeOferta["Jezyk"], CheckNumeric($nodeOferta["ID"]), $nodeOferta["Status"], $przedmiot, $rent, $nodeOferta["Symbol"], $orig, $nodeOferta["Wojewodztwo"], $nodeOferta["Powiat"], $nodeOferta["Lokalizacja"], $nodeOferta["Dzielnica"], $nodeOferta["Rejon"], $nodeOferta["Ulica"], $nodeOferta["Pietro"], CheckNumeric($nodeOferta["Cena"]), CheckNumeric($nodeOferta["CenaM2"]), $nodeOferta["IloscPokoi"], CheckNumeric($nodeOferta["PowierzchniaCalkowita"]), CheckNumeric($nodeOferta["MapSzerokoscGeogr"]), CheckNumeric($nodeOferta["MapDlugoscGeogr"]), $nodeOferta["TechnologiaBudowlana"], $nodeOferta["MaterialKonstrukcyjny"], $nodeOferta["StanWybudowania"], $nodeOferta["RodzajBudynku"], $nodeOferta["Agent"], $nodeOferta["DataWprowadzenia"], $nodeOferta["DataWprowadzenia"], 0, empty_to_null($nodeOferta->Kraj), $nodeOferta->IloscPieter, $nodeOferta->RokBudowy, empty_to_null($nodeOferta->RodzajDomu), $first_page, empty_to_null($nodeOferta->RodzajObiektu), empty_to_null($nodeOferta->SposobPrzyjecia), $nodeOferta->IloscOdslonWWW, null, empty_to_null($nodeOferta->StatusWlasnosci), empty_to_null($nodeOferta->UmeblowanieLista), $nodeOferta->PowierzchniaDzialki, $zamiana, empty_to_null(html_entity_decode($nodeOferta->UwagiOpis)), empty_to_null(html_entity_decode($nodeOferta->UwagiNieruchomosc)), empty_to_null($attr_arr["Link"]), $attr_arr["ZeroProwizji"], $nodeOferta["DataWaznosci"], $has_swfs, $has_movs, $has_photos, $has_pans, $has_maps, $has_projs, $loc_as_commune);
                         $photosNode = null;
                         $roomsNode = null;
                         $modDate = null;
                         $attributesNode = null;
                         $ts = microtime_float();
                         //properties that are in offers directly
                         $pomin = OffersHelper::$props_arr;
                         //atributes that are in offers directly
                         $pomin_attr = array("Link", "ZeroProwizji");
                         //read other properties
                         foreach ($nodeOferta->children() as $propNode) {
                             $pname = $propNode->getName();
                             if ($pname == "StanPrawnyDom" || $pname == "StanPrawnyGruntu" || $pname == "StanPrawnyLokal" || $pname == "StanPrawnyLokalLista") {
                                 $offer->setStanPrawny($propNode);
                             }
                             if (in_array($pname, $pomin) === false) {
                                 if ($pname == "Zdjecia") {
                                     $photosNode = $propNode;
                                 } else {
                                     if ($pname == "DataAktualizacji") {
                                         $modDate = $propNode;
                                     } else {
                                         if ($pname == "Pomieszczenia") {
                                             $roomsNode = $propNode;
                                         } else {
                                             if ($pname == "Atrybuty") {
                                                 $attributesNode = $propNode;
                                                 $set = array();
                                                 foreach ($propNode->children() as $listNode) {
                                                     if (array_search($listNode['opis'], $pomin_attr) === false) {
                                                         $set[count($set)] = $listNode['opis'] . "#|#" . $listNode;
                                                     }
                                                 }
                                                 $offer->__set($pname, $set);
                                             } else {
                                                 if ($propNode['iset'] == true) {
                                                     $set = array();
                                                     foreach ($propNode->children() as $listNode) {
                                                         $set[count($set)] = $listNode;
                                                     }
                                                     $offer->__set($pname, $set);
                                                 } else {
                                                     $offer->__set($pname, $propNode);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         if ($nodeOferta['NrLokalu']) {
                             $offer->__set('NrLokalu', $nodeOferta['NrLokalu']);
                         }
                         $times["read_props"] += microtime_float() - $ts;
                         $ts = microtime_float();
                         //save offer object to database
                         if ($modDate != null) {
                             $offer->SetModificationDate($modDate);
                         }
                         $ret = Offers::AddEditOffer($offer);
                         if ($ret == "A") {
                             $count_arr["dodane"]++;
                         } else {
                             if ($ret == "E") {
                                 $count_arr["zmodyfikowane"]++;
                             }
                         }
                         echo DataBase::GetDbInstance()->LastError();
                         $times["save"] += microtime_float() - $ts;
                         $ts = microtime_float();
                         //delete unuse properties from offer
                         $addedProperties = array();
                         foreach ($nodeOferta->children() as $propNode) {
                             $pname = $propNode->getName();
                             if ($pname == "StanPrawnyDom" || $pname == "StanPrawnyGruntu" || $pname == "StanPrawnyLokal" || $pname == "StanPrawnyLokalLista") {
                                 $pname = "StanPrawny";
                             }
                             if (in_array($pname, $pomin) === false) {
                                 if ($pname != "Zdjecia" && $pname != "Pomieszczenia" && $pname != "Atrybuty" && $pname != "DataAktualizacji" || $propNode['iset'] == true) {
                                     $prop = Properties::GetPropertyName($pname);
                                     if ($prop != null) {
                                         $addedProperties[count($addedProperties)] = $prop->GetID();
                                     }
                                 }
                             }
                         }
                         if ($nodeOferta['NrLokalu']) {
                             $addedProperties[] = Properties::GetPropertyName('NrLokalu')->GetID();
                         }
                         if ($attributesNode != null) {
                             $addedProperties[] = Properties::GetPropertyName($attributesNode->getName())->GetID();
                         }
                         Offers::DeleteUnUseProperties($offer->GetId(), $offer->GetIdLng(), $addedProperties);
                         $times["del_props"] += microtime_float() - $ts;
                         $ts = microtime_float();
                         //photos
                         $addedPhotos = array();
                         if ($photosNode != null) {
                             foreach ($photosNode->children() as $photoNode) {
                                 $intro = strtolower($photoNode->intro) == "true" ? 1 : 0;
                                 $photo = new OfferPhoto($photoNode['ID'], $offer->GetId(), null, $photoNode->plik, $photoNode->opis, $photoNode->lp, $photoNode->typ, $intro, $photoNode['fotoID'], (string) $photoNode->LinkFilmYouTube, (string) $photoNode->LinkMiniaturkaYouTube);
                                 OfferPhotos::AddEditPhoto($photo);
                                 echo DataBase::GetDbInstance()->LastError();
                                 $addedPhotos[count($addedPhotos)] = $photo->GetId();
                             }
                         }
                         OfferPhotos::DeleteUnUsePhotos($offer->GetId(), $addedPhotos, 0);
                         $times["photos"] += microtime_float() - $ts;
                         $ts = microtime_float();
                         //rooms
                         if ($roomsNode != null) {
                             if ($prevOfferId != $offer->GetId() . "") {
                                 OfferRooms::DeleteRooms($offer->GetId(), null);
                             }
                             $times["rooms_del"] += microtime_float() - $ts;
                             foreach ($roomsNode->children() as $roomNode) {
                                 $room = new OfferRoom(0, $offer->GetId(), $offer->GetIdLng(), $roomNode['Rodzaj'], $roomNode->Lp, $roomNode->Powierzchnia, $roomNode->Poziom, $roomNode->Typ, CheckNumeric($roomNode->Wysokosc), $roomNode->RodzajKuchni, CheckNumeric($roomNode->Ilosc), $roomNode->Glazura, $roomNode->WidokZOkna, $roomNode->Opis, $roomNode->StanPodlogi, $roomNode->RodzajPomieszczenia);
                                 //sets of properties
                                 $_floors = array();
                                 if ($roomNode->Podlogi) {
                                     foreach ($roomNode->Podlogi->children() as $listNode) {
                                         $_floors[count($_floors)] = $listNode;
                                     }
                                 }
                                 $room->SetFloors($_floors);
                                 $_windowsExhibition = array();
                                 if ($roomNode->WystawaOkien) {
                                     foreach ($roomNode->WystawaOkien->children() as $listNode) {
                                         $_windowsExhibition[count($_windowsExhibition)] = $listNode;
                                     }
                                 }
                                 $room->SetWindowsExhibition($_windowsExhibition);
                                 $_walls = array();
                                 if ($roomNode->Sciany) {
                                     foreach ($roomNode->Sciany->children() as $listNode) {
                                         $_walls[count($_walls)] = $listNode;
                                     }
                                 }
                                 $room->SetWalls($_walls);
                                 $_equipment = array();
                                 if ($roomNode->Wyposazenie) {
                                     foreach ($roomNode->Wyposazenie->children() as $listNode) {
                                         $_equipment[count($_equipment)] = $listNode;
                                     }
                                 }
                                 $room->SetEquipment($_equipment);
                                 OfferRooms::AddRoom($room);
                                 echo DataBase::GetDbInstance()->LastError();
                             }
                         }
                         $times["rooms"] += microtime_float() - $ts;
                         $prevOfferId = $offer->GetId() . "";
                     }
                 }
             }
             //Deleted offers
             if ($xml2->name == "Usuniete") {
                 $node = simplexml_import_dom($domdoc->importNode($xml2->expand(), true));
                 foreach ($node->children() as $doUsuniecia) {
                     array_push($ids_do_usuniecia_dodania, (int) $doUsuniecia["ID"]);
                 }
             }
             $xml2->read();
         }
         //Delete redundant departments
         if (!$blokuj_oddzialy) {
             Departments::DeleteRedundantDepartments($all_dept_ids);
         }
         //Delete redundant agents
         if (!$blokuj_agentow) {
             Agents::DeleteRedundantAgents($all_agents_ids);
         }
         $ts = microtime_float();
         $time_end5 = microtime_float();
         $time = $time_end5 - $time_end4;
         $times["del_offers"] += microtime_float() - $ts;
         if ($this->_DEBUG) {
             echo "Saving data to db execution time: {$time} seconds<br>";
             var_dump($times);
         }
         $xml2->close();
         Errors::LogSynchroStep('WebServiceVirgo - GetOffersPartial() done');
         return $ids_do_usuniecia_dodania;
     } catch (Exception $ex) {
         Errors::LogError("WebServiceVirgo:GetOffers", $ex->getMessage() . "; " . $ex->getTraceAsString());
         return 0;
     }
 }
Пример #21
0
 /**
  * Returns array of offers investment.
  * @param int $investmentId
  * @param int $lngId
  * @return array
  */
 public static function GetOffers($investmentId, $lngId = 1045)
 {
     $db = DataBase::GetDbInstance();
     $params = array((int) $investmentId, (int) $lngId);
     $query = "SELECT o.id FROM #S#offers o INNER JOIN #S#investments_buildings b ON o.investments_buildings_id=b.id WHERE b.investments_id=? AND o.id_lng=? ORDER BY o.id";
     $result = $db->ExecuteQueryWithParams($query, $params);
     $offers = array();
     while ($row = $db->FetchArray($result)) {
         $offers[] = Offers::getOffer($row[0], $lngId);
     }
     return $offers;
 }
Пример #22
0
        $this->dbError();
        $this->qryDatabase();
    }
    public function qryDatabase()
    {
        $this->sql = "\n      SELECT o.offers_id, o.customers_id, o.offers_subtotal_price, o.offers_description, o.offers_date, \n             c.customers_id, c.firstname, c.lastname, c.company\n      FROM offers AS o, customers AS c\n      WHERE o.customers_id = c.customers_id\n    ";
        $this->query = mysqli_query($this->db, $this->sql);
    }
    public function createRows()
    {
        while ($this->rows = mysqli_fetch_assoc($this->query)) {
            echo "<tr>\n              <td>" . $this->rows['offers_id'] . "</td>\n              <td>" . $this->rows['firstname'] . " " . $this->rows['lastname'] . "</td>\n              <td>" . $this->rows['company'] . "</td>\n              <td>&euro;" . $this->rows['offers_subtotal_price'] . "</td>\n              <td>" . $this->rows['offers_description'] . "</td>\n              <td>" . $this->rows['offers_date'] . "</td>\n              <td><a href='offerte_bewerken?id=" . $this->rows['offers_id'] . "'>Bewerken</a></td>\n              <td><a href='incl/offers/templates/template_one.php?offer_id=" . $this->rows['offers_id'] . "&customer_id=" . $this->rows['customers_id'] . "' target='_blank'>Link</a></td>\n            </tr>\n      ";
        }
    }
}
$offers = new Offers();
?>

<div class="container">
  <table id="table-offertes" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
    <thead>
      <tr>
        <th>Offertenummer</th>
        <th>Klantnaam</th>
        <th>Bedrijf</th>
        <th>Bedrag</th>
        <th>Beschrijving</th>
        <th>Datum</th>
        <th>Bewerken</th>
        <th>Link</th>
      </tr>
Пример #23
0
 public function commentsAction()
 {
     $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
     if ($this->request->hasPost('comm') && $this->request->hasPost('offer') && $this->request->isAjax()) {
         $comments = new Comments();
         $comments->offers_id = $this->request->getPost('offer');
         $comments->reciever_id = $this->session->get('user_id');
         $comments->text = $this->request->getPost('comm');
         $comments->creation_date = date("Y-m-d-H-i-s");
         $comments->save();
         $offer = Offers::findFirst($this->request->getPost('offer'));
         foreach ($offer->comments as $comm) {
             $com[$comm->id] = array($comm->user->first_name, $comm->text, $comm->creation_date);
         }
         $this->view->setVars(array('comm' => $com));
     }
 }