Example #1
0
 public static function delete($fname)
 {
     self::findBy("name='{$fname}'");
     if (get_called_class() == 'Flat') {
         $flat = new Flat();
         $flat->getFull($this->object_id);
         $photo_flat_path = $flat->getPhotoPath();
         unlink($photo_flat_path . $fname);
         unlink($photo_flat_path . $fname . '_prev');
     }
     parent::delete("name='{$fname}'");
 }
Example #2
0
 /**
  * @param string $area
  * @param string $themePath
  * @param string $locale
  * @param string $module
  * @param string $expectedId
  * @param string $savedValue
  *
  * @dataProvider cacheDataProvider
  */
 public function testSaveToCache($area, $themePath, $locale, $module, $expectedId, $savedValue)
 {
     if (isset($params['theme'])) {
         $this->theme->expects($this->any())->method('getThemePath')->will($this->returnValue($params['theme']));
         $params['theme'] = $this->theme;
     } else {
         $this->theme->expects($this->never())->method('getThemePath');
     }
     $this->cache->expects($this->once())->method('save')->with($savedValue, $expectedId)->will($this->returnValue(true));
     $actual = $this->object->saveToCache($savedValue, 'file', 'file.ext', $area, $themePath, $locale, $module);
     $this->assertTrue($actual);
 }
Example #3
0
    /**
     * set data
     */
    public function setData()
    {
        $requestHelper = $this->controller->getRequestHelper();
        $class = $requestHelper->getParam('class');
        $viewMode = $requestHelper->getParam('mode');

        if (!in_array($viewMode, array(DisplayClass::EDIT, DisplayClass::VIEW))) {
            $viewMode = DisplayClass::VIEW;
        }

        $obj = Factory::loadObject($class, $requestHelper->getParam('LK'));
        if (is_null($obj)) {
            $obj = Factory::createObject($class);
        }
        $this->obj = $obj;

        $user = Flat::user();
        $dataPermission = DataPermission::createObject($obj);
        if (!User::isLoggedIn() || !$user->isEntitled($obj->getPermissionForViewMode($viewMode)) || !$dataPermission->isUserOccupant($user->getLogicalKey())) {
            $viewMode = DisplayClass::VIEW;
        }

        $formModel = new base_form_Model($obj, $viewMode);
        $formModel->setAjaxForm('base_ajax_save_Controller');
        $formModel->setMethod(base_form_Model::METHOD_POST);
        $formModel->addAction("&class=$class");
        $formModel->addAction("&caller=" . $this->controller->getCallerSection());
        $formModel->setId('inputData');
        $this->data = new base_form_View($formModel);
    }
Example #4
0
 /**
  * get the displayMode for the actual field in scope
  *
  * @param $displayMode string
  * @return string
  */
 public function getDisplayMode($displayMode)
 {
     if (is_null(Flat::user())) {
         return DisplayClass::HIDE;
     }
     return $displayMode;
 }
Example #5
0
    /**
     * get the displayMode for the actual field in scope
     *
     * @param $displayMode string
     * @return string
     */
    public function getDisplayMode($displayMode)
    {
        $user = Flat::user();
        if (!$user->isEntitled('Administrator')) {
            return DisplayClass::VIEW;
        } else {
            return $displayMode;
        }

    }
Example #6
0
 public static function getAdminFlatList($where, $per_page = 10, $current_page = 1, $action)
 {
     $start_pos = ($current_page - 1) * $per_page;
     $limit = " LIMIT {$start_pos},{$per_page}";
     $amount = Flat::getAmountInList($where);
     $order = " ORDER BY id DESC";
     $db_res = Flat::getAdminListLink($where . $order . $limit);
     //$flat->getFullBy($where.$order.$limit);
     $paginator = self::paginator("flat.php?action={$action}", $amount, $per_page, $current_page);
     $html = "\n\t\t<div><a href='flat.html?action=activateAll'>Активировать все</a></div>\n\t\t<div>{$paginator}</div>\n\t\t<table class='base_text'>\n\t\t<thead>\n\t\t<tr>\n\t\t <th>Комнат</th>\n\t\t <th>Цена</th>\n\t\t <th>Тип дома</th>\n\t\t <th>Адрес</th>\n\t\t <th>Юзер</th>\n\t\t <th></th>\n\t\t <th></th>\n\t\t <th></th>\n\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t";
     $status = $action == 'newSales' ? REALTY_STATUS_SALE : REALTY_STATUS_RENT;
     while ($row = $db_res->fetchRow()) {
         $type = Tenement::$TYPE[$row['ttype']];
         $price = number_format($row['price'], 0);
         $city = $row['city_id'] == 0 ? '' : $row['city'] . ',';
         $addr = $row['tenement_status'] == REALTY_STATUS_NEW ? "(NEW!) {$city} {$row['street']}, {$row['tnum']}" : "{$city} {$row['street']}, {$row['tnum']}";
         $user = '';
         if ($row['user_name'] != '') {
             $user = $row['user_name'];
         }
         if ($row['company_name'] != '') {
             $user .= ' - ' . $row['company_name'];
         }
         $html .= "<tr>\n\t\t\t<td>{$row['rooms']}</td>\n\t\t\t<td>{$price}</td>\n\t\t\t<td>{$type}</td>\t\t\t\n\t\t\t<td><a href='/tenement.html?action=edit&id={$row['tenement_id']}' target='_blank'>{$addr}</a></td>\n\t\t\t<td>{$user}</td>\n\t\t\t<td><a href='/flat.html?action=edit&id={$row['id']}' target='_blank'>Редактировать</a></td>\n\t\t\t<td><a href='/flat.html?action=view&id={$row['id']}' target='_blank'>Смотреть</a></td>\n\t\t\t<td><a href='javascript:delFlat({$row['id']});'>Удалить</a></td>\n\t\t\t<td><a href='/flat.html?action=approve&id={$row['id']}&status={$status}' target='_blank'>Активировать</a></td>\n\t\t\t</tr>";
     }
     $html .= "</tbody></table>\n\t\t<script>\t\t\n\t\tdelFlat = function(id) {\n\t\t\tif (confirm('Вы уверены удалить эту квартиру?')) {\n\t\t\t\tlocation.href = '/flat.html?action=delete&id='+id;\n\t\t\t}\n\t\t\treturn 0;\t\t\t\n\t\t}\t\t\t\t\n\t\t</script>";
     return $html;
 }
Example #7
0
 /**
  * set the last editor and the actual timestamp
  */
 private function _setLastEditorAndEditTime()
 {
     $user = Flat::user();
     $this['editor'] = $user->getLogicalKey();
     $this['editTime'] = new base_date_model_DateTime();
 }
Example #8
0
 public static function delete($id)
 {
     global $db;
     $db->query("SELECT id FROM flat WHERE tenement_id={$id}");
     $rows = $db->fetchAll();
     foreach ($rows as $row) {
         Flat::delete($row['id']);
     }
     $db->query("DELETE FROM tenement WHERE id={$id}");
     Photo::deletePhotos(TENEMENT, $id);
 }
Example #9
0
    private function _isEntitledForEntry($entry)
    {
        if ($entry['permission'] == Permission::getPermissionLKByName(Permission::EVERYBODY)) {
            return true;
        }

        $user = Flat::user();
        if (!$user instanceof User) {
            return false;
        }
        return $user->isEntitled($entry['permission']);

    }
Example #10
0
<?
$admin = "no";
include_once("../include/common.php");
$s->template_dir = $config["admin_template_dir"];
$s->compile_dir = $config["admin_compile_dir"];

if (isset($_POST["Enter"]) and ($_POST["Enter"] == "Enter")) {
	if ( ($_POST["Login"] == $config["admin_login"]) and ($_POST["Password"] == $config["admin_password"]) ){				
		$_SESSION['admin'] = 'a';
		
		Flat::restoreLostObjects(REALTY_STATUS_NEW,REALTY_STATUS_APPLY);
		Flat::restoreLostObjects(REALTY_STATUS_RENT_NEW,REALTY_STATUS_RENT_APPLY);
		House::restoreLostObjects(REALTY_STATUS_NEW,REALTY_STATUS_APPLY);
		Land::restoreLostObjects(REALTY_STATUS_NEW,REALTY_STATUS_APPLY);
		
		header("Location: index.php");
	}
}

$s->display('login.tpl'); 

?>
Example #11
0
function map($s) {
	
	$s->assign("lat",LAT_YOLA);
	$s->assign("lon",LON_YOLA);
	$s->assign("YANDEX_KEY",YANDEX_KEY);
	
	$ids = '';	
	$rooms = '';
	$prices = '';
	$prices_m = '';
	$areas = '';
	$addresses = '';
	$storeys = '';
	$dates = '';
	$types = '';
	$lons = '';
	$lats = '';
	$photos = '';
	$icons = '';
	if (!isset($_REQUEST['act']) || $_REQUEST['act']=='sales') {
		$status=REALTY_STATUS_SALE;
	}
	else {
		$status=REALTY_STATUS_RENT;
	}
	$res = _filter($status);
	
	$scale = (!isset($_GET['f_regions'])) ? 13 : 9;
	
	$add_sql = "f.updated_on>'".getNextDate(date('Y-m-d'),-30)."' AND t.status=".REALTY_STATUS_ACTIVE.' AND '.$res['sql'];
	$db_res = Flat::getFullListLink($add_sql);
	while ($row = $db_res->fetchRow()) {
		$ids .= $row['id'].',';
		$rooms .= $row['rooms'].',';
		$prices .= "'".number_format($row['price'],0)."',";
		$prices_m .= "'".number_format($row['price_m'],0)."',";
		$areas .= "'".$row['total_area']."',";
		$addr = "{$row['street']}, {$row['tnum']}";
		$addresses .= "'".$addr."',";
		
		$date = explode(' ',$row['updated_on']);
		$ds = explode('-',$date[0]);
		$date = $ds[2].'.'.$ds[1].'.'.$ds[0];		
		$dates .= "'".$date."',";
		$storeys .= "'".$row['storey']."/".$row['storeys']."',";
		$types .= "'".Tenement::$TYPE[$row['ttype']]."',";		
		$lons .= "'".$row['lon']."',";
		$lats .= "'".$row['lat']."',";
		$photo = ($row['photo_tenement']!='') ? $row['tenement_id']."/".$row['photo_tenement']."_prev" : '';
		$photos .= "'".$photo."',";
		if ($row['price_m']<30000) {
			$color = 'a';				
		}
		else if ($row['price_m']<40000) {
			$color = 'b';				
		}
		else {
			$color = 'c';	
		}
		$ri = ($row['rooms']<4) ? $row['rooms'] : 3;
		$icons .= "'".$ri."k".$color."',";
	}
	
	$s->assign("ids",$ids);
	$s->assign("rooms",$rooms);
	$s->assign("prices",$prices);
	$s->assign("prices_m",$prices_m);
	$s->assign("areas",$areas);
	$s->assign("addresses",$addresses);
	$s->assign("storeys",$storeys);
	$s->assign("dates",$dates);
	$s->assign("types",$types);
	$s->assign("lons",$lons);
	$s->assign("lats",$lats);
	$s->assign("scale",$scale);	
	$s->assign("photos",$photos);
	$s->assign("icons",$icons);
		
	$block_html = Html::getBlock('Квартиры на продажу на карте Йошкар-Олы',Html::pageFlatMap());
	$s->assign("block_html",$block_html);
	$s->display("flat_map.tpl");
}
Example #12
0
base_ui_Site::startMainContent($od);

print $od->toString();
$od->flush();

$requestHelper = new RequestHelper();

$class = $requestHelper->getParam('class');

if (is_null($class)) {
    throw new base_exception_Site(TMS(base_exception_Site::PARAM_MISSING, array('param' => 'class')));
}

$object = Factory::createObject($class);

$user = Flat::user();

if (!User::isLoggedIn() || !$user->isEntitled($object->getPermissionForViewMode(DisplayClass::VIEW))) {
    $od->addContent('Sie verfügen nicht über die benötigten Rechte, um diese Datenkategorie zu betrachten. Bitte wenden Sie sich an den Support');
    base_ui_Site::endMainContent($od);
    base_ui_Site::displayBottom($od);

    print $od->toString();
    exit();
}

$urlColumns = $requestHelper->getParam('cols');
if (!is_null($urlColumns)) {
    if ($urlColumns == 'all') {
        $fi = new Fieldinfo($class);
        $columnNames = $fi->getAllFieldNames();
Example #13
0
function getFlatListByTenement($param)
{
    global $config;
    $id = intval($param['id']);
    if (isset($_GET['limit']) && intval($_GET['limit']) == 3) {
        $limit = 3;
    } else {
        $limit = 30;
    }
    $db_res = Flat::getFullListLink("tenement_id={$id} AND (f.status=" . REALTY_STATUS_SALE . " OR f.status=" . REALTY_STATUS_RENT . " OR f.status=" . REALTY_STATUS_SOLD . ") GROUP BY f.id ORDER BY f.updated_on DESC LIMIT {$limit}");
    if (isset($_SESSION['user_id']) && in_array($_SESSION['user_id'], $config['user_workers'])) {
        $is_editor = true;
        $h = '<th></th>';
    } else {
        $is_editor = false;
        $h = '';
    }
    $html = '
	История продаж в этом доме:<br><br>
	<table class="table table-striped table-bordered table-condensed"><thead>
	<tr>
	<th>Дата</th><th>Комнат</th><th>Цена (руб.)</th><th>Цена за кв.м.(руб.)</th><th>Этаж</th><th>Общ. пл.м<sup>2</sup></th><th>Сделка</th>' . $h . '
	</tr></thead>';
    while ($row = $db_res->fetchRow()) {
        $html .= '<tr>';
        $date = explode(' ', $row['updated_on']);
        $dates = explode('-', $date[0]);
        $date = $dates[2] . '.' . $dates[1] . '.' . $dates[0];
        //$type = ($row['status']==REALTY_STATUS_SALE) ? 'продажа' : 'аренда';
        switch ($row['status']) {
            case REALTY_STATUS_SALE:
                $type = 'продажа';
                break;
            case REALTY_STATUS_RENT:
                $type = 'аренда';
                break;
            case REALTY_STATUS_SOLD:
                $type = 'продано';
                break;
        }
        $t = $is_editor ? '<td><a href="/flat.html?action=updateDate&id=' . $row['id'] . '" title="Обновить дату"><img src="/images/icon_update.png"></a></td>' : '';
        $price = number_format($row['price'], 0);
        $price_m = number_format($row['price_m'], 0);
        $html .= "<td><a href='/flat.html?action=view&id={$row['id']}' title='смотреть'>{$date}</a></td><td>{$row['rooms']}</td><td>{$price}</td><td>{$price_m}</td><td>{$row['storey']}</td><td>{$row['total_area']}</td><td>{$type}</td>{$t}";
        $html .= '</tr>';
    }
    $html .= '</table>';
    if (isset($date)) {
        echo $html;
    } else {
        echo '';
    }
}
Example #14
0
<?php
/**
 * Created by PhpStorm.
 * User: Alex
 * Date: 12.01.2015
 * Time: 11:54
 */

require_once (dirname(dirname(__DIR__)) . '/config.php');

$od = new OutputDevice();

if (!Flat::user()->isEntitled('Administrator')) {
    base_ui_Site::displayHead($od);
    base_ui_Site::displayTop($od);
    base_ui_Site::displayNavigation($od);
    base_ui_Site::startMainContent($od);
    $od->addContent('Sie sind nicht berechtigt diesen Bereich zu benutzen.');
    base_ui_Site::endMainContent($od);
    base_ui_Site::displayBottom($od);

} else {
    base_ui_ACP::displayHead($od);
    base_ui_ACP::displayTop($od);
    base_ui_ACP::displayNavigation($od);
    base_ui_ACP::startMainContent($od);

    $rh = new RequestHelper();
    $controllerClass = $rh->getParam('controller');

    /** @var Controller $controller */
Example #15
0
base_ui_Site::displayHead($od);
base_ui_Site::displayTop($od);
base_ui_Site::displayNavigation($od);
base_ui_Site::startMainContent($od);

$od->addContent(Html::startTag('h3'));
$od->addContent('Benutzer LogIn');
$od->addContent(Html::endTag('h3'));

print $od->toString();
$od->flush();


if (User::isLoggedIn()) {
    $od->addContent('Zum Ausloggen bitte ' . Html::url(HTML_ROOT . '/' . Flat::language() . '/logout.php', 'hier') . "klicken\n");
} else {
    $od->addContent("<form method='post' action='ajax.php?controller=base_ajax_login_Controller&redirect=index.php' class='ajaxForm' >\n");
    $table = new base_html_model_Table();
    
    $labelCell = new base_html_model_table_Cell();
    $labelCell->setContent('Benutzername');
    $valueCell = new base_html_model_table_Cell();
    $obj = Factory::createObject('user');
    $inputUserName = base_form_element_Factory::createElement($obj->getFieldinfo('userid'));
    $inputUserName->setName('userid');
    $inputUserName->setDisplayMode(DisplayClass::EDIT);
    $valueCell->setContent($inputUserName->display());
    $rowUserId = new base_html_model_table_Row();
    $rowUserId->addCell($labelCell);
    $rowUserId->addCell($valueCell);
Example #16
0
File: User.php Project: kafruhs/fws
    public static function logout()
    {
        if (!self::isLoggedIn()) {
            return self::LOGOUT_SUCCESS;
        }

        $table = DB::table('user');
        $where = DB::where($table->getColumn('LK'), DB::intTerm(Flat::user()->getLogicalKey()));
        $updateData = array(
            'ip' => DB::stringTerm(''),
            'sessionid' => DB::stringTerm(''),
        );
        try {
            self::_updateUserLoginData($table, $where, $updateData);
            session_destroy();
            return self::LOGOUT_SUCCESS;
        } catch (Exception $e) {
            return self::LOGOUT_FAILURE;
        }
    }
Example #17
0
function edit($s) {
	if (!isset($_SESSION['admin']) && !isset($_SESSION['user_id'])) {
		header("Location: /index.html");
		exit();
	}
	$id = intval($_GET['id']);
	$tenement = new Tenement();
	$tenement->getFull($id);
	if ($tenement->status!=REALTY_STATUS_NEW && !isset($_SESSION['admin'])) {
		header("Location: /index.html");
		exit();
	}
	if (empty($_POST) && $tenement->id>0) {			
		$block_html = Html::pageTenementEdit($tenement);		
		$s->assign("block_html",$block_html);
		$s->assign("YANDEX_KEY",YANDEX_KEY);
		$s->assign("LAT_CENTER_REGION",LAT_CENTER_REGION);
		$s->assign("LON_CENTER_REGION",LON_CENTER_REGION);
		$s->assign("city_id",$tenement->city_id);
		$s->assign("city",$tenement->city);
		$s->assign("street_id",$tenement->street_id);
		$s->assign("street",$tenement->street);
		if (isset($_SESSION['admin']))
			$s->assign("is_admin",$_SESSION['admin']);
		$s->display("tenement_edit.tpl");
	}
	//Смена адреса на существующий дом
	elseif (isset($_POST['id']) && $_POST['id']>0 && (isset($_SESSION['admin']) 
	 || (isset($_SESSION['user_id']) && $tenement->user_id==$_SESSION['user_id']))) {						
		$tenement_id = intval($_POST['id']);		
		$tenement->find($tenement_id);
		if (!$tenement->id) {
			echo "Дом не найден";
			exit();
		}
		//дом есть, переводим все кв в него, старый удаляем
		Flat::changeTenement($id,$tenement_id);
		if ($id != $tenement_id) {
			//Tenement::delete($id);
			//echo "delete $id";
		}
		header("Location: /tenement.html?action=view&id=".$tenement_id);
		exit();		
	}
	elseif($id>0 && !empty($_POST) && (isset($_SESSION['admin']) 
	 || (isset($_SESSION['user_id']) && $tenement->user_id==$_SESSION['user_id']))) {
		if ($_REQUEST['city_id']>1) {
			Tenement::$_properties['street']['required']=null;
			Tenement::$_properties['street_id']['required']=null;	
			Tenement::$_properties['number']['required']=null;
		}				
		$errors = $tenement->checkForm($_REQUEST);			
		if (!isset($errors['is_error']) && $tenement->id > 0) {								
			$tenement->update($_POST);			
			$photo_path = $tenement->getPhotoPath();
			if (!is_dir($photo_path)) {			
				mkdir($photo_path,0777);
				chmod($photo_path,0777);						
			}
			//добавляем новые фото
			if (isset($_POST['photo_tenement']) && is_array($_POST['photo_tenement'])) {
				foreach ($_POST['photo_tenement'] as $fname) {
					$fname = clearTextData($fname);
					if ($fname!='') $tenement->addPhoto($fname,$_POST);
				}
			}
			//редактируем существующие фото
			if (isset($_POST['photo_'.TENEMENT.'_exist']) && is_array($_POST['photo_'.TENEMENT.'_exist'])) {
				foreach ($_POST['photo_'.TENEMENT.'_exist'] as $fname) {
					$fname = clearTextData($fname);
					if ($fname!='') $tenement->editPhoto($fname,$_POST);
				}
			}			
			header("Location: /tenement.html?action=view&id=".$tenement->id);
			exit();
		}
		else {
			print_r($errors);
		}
	}
	else {		
		//$block_html = Html::pageTenementEdit($tenement);
		$s->assign("YANDEX_KEY",YANDEX_KEY);
		if (isset($_SESSION['admin']))
			$s->assign("is_admin",$_SESSION['admin']);
		$s->assign("block_html",'Дом не найден');
		$s->display("tenement_edit.tpl");
	}	
}
Example #18
0
function import($s) {
	if (!isset($_SESSION['user_id'])) {
		header("Location: index.html");
		exit();
	}
	$amount=-1;
	$num_updated_all = 0;		
	if (isset($_FILES["userfile"])) {
		if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
			$filename = $_FILES['userfile']['tmp_name'];			
			$rows =  file($filename);
			unset($rows[0]);
			$amount=0;			
			foreach ($rows as $row) {				
				$row = iconv("windows-1251", "utf-8", $row);
				$el = explode('|',$row);

				$date = $el[33];//дата объявления
				//if ($date<date('d.m.Y'))
				
				$type_deal = $el[0];//1 - продажа, 2 - аренда
				$status = ($el[0]==1) ? REALTY_STATUS_IMPORT_SALE : REALTY_STATUS_IMPORT_RENT;
				$is_city = $el[1];//1-город 2-республика
				if ($is_city != 1) continue;
				$rooms = $el[2];//11-комната 22-дом 27-участок 28-уч. под застройку 41-гараж
				if ($rooms>11) continue; 
				$phone = $el[6];
				$an_name = $el[7];
				$phone2 = $el[8];
				$name2 = $el[9];
				$street = $el[10];
				//echo "\n$street _\n";
				if(!preg_match("/[0-9]+[а-яА-Я]*$/", $street)) {
					//нет номера дома 
    				//continue; 
				}
				//echo "\n$street\n";
				preg_match("/[0-9]+[а-яА-Я]*$/", $street,$nums_tenement);
				
				$num = mb_strtolower($nums_tenement[0],'UTF-8');//strtolower($nums_tenement[0]);				 
				$street_name = str_replace($num,'',$street);
				$street_name = trim(str_replace('  ',' ',$street_name));
				$street_clear2 = str_replace('ул','',$street_name);
				$street_clear2 = str_replace('.','',$street_clear2);								
				$street_arr = explode(' ',$street_clear2);
				//находим самую длинную строку в названии улицы
				$i = 0;
				$max_len = '';
				$last_len = 0;
				if(count($street_arr)) {
					foreach ($street_arr as $c) {
						if (strlen($c)>$last_len) {
							$max_len = $c;
							$last_len = strlen($c); 
						}
						$i++;	
					}					
				}
				if ($max_len=='') continue;
				//echo "\nmax_len=$max_len";
				$row = Street::findBy("name LIKE '%$max_len%'");
				if (!$row) {					
					$street_id = Street::createStatic(array('name'=>$street_name,'city_id'=>0, 'status'=>0));
				}
				else {
					$street_id = $row['id'];
					$street_name = $row['name'];
				}					
				$storey = $el[12];
				$stores = $el[13];
				$tenement_type = $el[15];
				if ($tenement_type=='КИРП') $type_id=0;
				elseif ($tenement_type=='ПАН') $type_id=1;
				elseif ($tenement_type=='БЛОК') $type_id=3;
				elseif ($tenement_type=='ДЕР') $type_id=4;				
				else $type_id=2;
								
				$total_area = str_replace(',','.',$el[16]);
				//if ($total_area=='') continue;
				$living_area  = str_replace(',','.',$el[17]);
				$kitchen_area  = str_replace(',','.',$el[18]);
				if (!$kitchen_area) $kitchen_area=9;
				$description  = $el[26];
				$price  = str_replace(',','.',$el[27]);
				//if (!($price>0)) continue; 
				$price_k  = $el[28];//1-тыс. 2-млн. 5-руб/м 6-у.е./м
				
				if ($price_k==1) $price *= 1000;
				elseif ($price_k==2) $price *= 1000000;
				elseif ($price_k==5) $price *= $total_area;
				
				$haggle = $el[29];//торг/чистая продажа
				$date_end = $el[31];//срок сдачи дома				

				$row = Tenement::findBy("street_id='$street_id' AND number='$num'");
				if ($row) {
					$tenement_id=$row['id'];
				}
				else {
					$num = clearTextData($num);
					$options = array(
					'city_id'=>0,
					'street_id'=>$street_id,
					'number'=>$num,
					'type_id'=>clearTextData($type_id),
					'storeys'=>clearTextData($stores),
					'hot_water'=>1,
					'type_energy'=>0,
					'type_heating'=>0,					
					'user_id'=>$_SESSION['user_id'],
					'status'=>REALTY_STATUS_NEW
					);
					
					$address = urlencode('Йошкар-Ола, '.$street_name.', д.'.$num);
					$geo_url = 'http://psearch-maps.yandex.ru/1.x/?text='.$address.'&key='.YANDEX_KEY.'&format=json';					
					$json = file_get_contents($geo_url);
					$d = json_decode($json);
					if (isset($d->{'response'}->{'GeoObjectCollection'}->{'featureMember'}[0]->{'GeoObject'}->{'Point'}->{'pos'})) {
						$coords = explode(' ',$d->{'response'}->{'GeoObjectCollection'}->{'featureMember'}[0]->{'GeoObject'}->{'Point'}->{'pos'});					
						$options['lon'] = $coords[0];
						$options['lat'] = $coords[1];				
					}						
					$tenement_id = Tenement::addStatic($options);
				}
				if (!$tenement_id) continue;
				$num_updated = Flat::updateByCondition("tenement_id='$tenement_id' AND rooms='$rooms' AND storey='$storey' AND price='$price' AND user_id='{$_SESSION['user_id']}'",array('updated_on'=>date('Y-m-d H:i:s')));
				$num_updated_all += $num_updated;
				if ($num_updated>0) continue;				
				$contacts = ($phone2!='') ? $phone2.' '.$name2 : $phone.' '.$an_name;
				$options = array(
					'tenement_id'=>$tenement_id,
					'price'=>clearTextData($price),
					'rooms'=>clearTextData($rooms),
					'storey'=>clearTextData($storey),
					'total_area'=>clearTextData($total_area),
					'kitchen_area'=>clearTextData($kitchen_area),
					'living_area'=>clearTextData($living_area),
					'description'=>clearTextData($description,1000),
					'contacts'=>clearTextData($contacts),
					'user_id'=>$_SESSION['user_id'],
					'status'=>$status							
				);
				Flat::addStatic($options);
				$amount++;
			}
			$dest = IMPORT_PATH.$_SESSION['user_id'].'_'.date('d').'_'.date('m').'_'.date('H').'_'.date('i').'_'.date('s').'.txt';
			move_uploaded_file($filename,$dest);
		}
	}
	$s->assign("amount",$amount);
	$s->assign("num_updated_all",$num_updated_all);	
	$s->display("import.tpl");
}
Example #19
0
function activateAll() {
	Flat::setStatusMass("status=".REALTY_STATUS_APPLY,REALTY_STATUS_SALE);
	header("Location: ".$_SERVER['HTTP_REFERER']);
	exit();
}
Example #20
0
File: Link.php Project: kafruhs/fws
    /**
     * get the url
     *
     * @return string
     * @throws base_ui_model_Exception
     */
    public function getLinkString()
    {
        $pageName = $this->getPageName();
        $controllerName = $this->getControllerName();
        if ($pageName == 'frontend' && empty($controllerName)) {
            throw new base_ui_model_Exception(TMS(base_ui_model_Exception::LINK_CONTROLLERNAME_NEEDED));
        }

        $link  = HTML_ROOT;
        $lang  = Flat::language();
        $link .= "/$lang/$pageName.php";
        $params = $this->getGetParams();

        if (!empty($controllerName)) {
            $params['controller'] = $controllerName;
        }

        if (!empty($params)) {
            $link .= '?';
            $parts = [];
            foreach (array_reverse($params) as $paramName => $paramValue) {
                $parts[] = "$paramName=$paramValue";
            }
            $link .= implode('&', $parts);
        }
        return $link;
    }