Example #1
0
 function afterSave(&$bean)
 {
     if (isset($bean->realty_id) && $bean->realty_id != '') {
         $realty = new Realty();
         $realty->retrieve($bean->realty_id);
         if (isset($realty->last_contact)) {
             $realty->last_contact = date('Y-m-d');
             $realty->save();
         }
     }
     if (isset($bean->parent_id) && $bean->parent_id != '') {
         $client = loadBean($bean->parent_type);
         $client->retrieve($bean->parent_id);
         if (isset($client->last_contact)) {
             $client->last_contact = date('Y-m-d');
             $client->save();
         }
     }
 }
Example #2
0
 public static function getFlatList2($where, $order, $direction, $per_page = 10, $current_page = 1, $action = 'sales', $user_id = NULL)
 {
     $start_pos = ($current_page - 1) * $per_page;
     $limit = " LIMIT {$start_pos},{$per_page}";
     //$amount = Flat::getAmountInList($where);
     $sort = $order == '' ? "f.updated_on" : $order;
     $where_param = $where . " GROUP BY f.id ORDER BY " . $sort . " " . $direction . $limit;
     $params = '';
     if (isset($_GET['rooms'])) {
         $params .= '&rooms=' . intval($_GET['rooms']);
     }
     if (isset($_REQUEST['f_rooms'])) {
         $params .= '&rooms=' . intval($_REQUEST['f_rooms']) . '&f_rooms=' . intval($_REQUEST['f_rooms']);
     }
     $price_min = 0;
     $price_max = 0;
     if (isset($_REQUEST['f_price'])) {
         $f_price = intval($_REQUEST['f_price']);
         $params .= '&f_price=' . $f_price;
         switch ($f_price) {
             case 1:
                 $price_max = 1000000;
                 break;
             case 2:
                 $price_min = 1000000;
                 $price_max = 1500000;
                 break;
             case 3:
                 $price_min = 1500000;
                 $price_max = 2000000;
                 break;
             case 4:
                 $price_min = 2000000;
                 $price_max = 3000000;
                 break;
             case 5:
                 $price_min = 3000000;
                 break;
         }
     } else {
         if (isset($_REQUEST['price_min']) && $_REQUEST['price_min'] > 0) {
             $price_min = intval($_REQUEST['price_min']);
         } else {
             $price_min = 0;
         }
         if (isset($_REQUEST['price_max']) && $_REQUEST['price_max'] > 0) {
             $price_max = intval($_REQUEST['price_max']);
         } else {
             $price_max = 0;
         }
         if ($price_min > 0) {
             $params .= '&price_min=' . $price_min;
         }
         if ($price_max > 0) {
             $params .= '&price_max=' . $price_max;
         }
     }
     if (isset($_REQUEST['f_date'])) {
         $params .= '&f_date=' . clearTextData($_REQUEST['f_date']);
     }
     if (isset($_REQUEST['f_price_sq'])) {
         $params .= '&f_price_sq=' . intval($_REQUEST['f_price_sq']);
     }
     if (isset($_REQUEST['f_tenement'])) {
         $params .= '&f_tenement=' . intval($_REQUEST['f_tenement']);
     }
     if (isset($_REQUEST['f_kitchen'])) {
         $params .= '&f_kitchen=' . intval($_REQUEST['f_kitchen']);
     }
     if (isset($_REQUEST['f_total_area'])) {
         $params .= '&f_total_area=' . intval($_REQUEST['f_total_area']);
     }
     if (isset($_REQUEST['f_total_area'])) {
         $params .= '&f_total_area=' . intval($_REQUEST['f_total_area']);
     }
     if (isset($_REQUEST['f_balcon'])) {
         $params .= '&f_balcon=' . intval($_REQUEST['f_balcon']);
     }
     if (isset($_REQUEST['f_no_corner'])) {
         $params .= '&f_no_corner=' . intval($_REQUEST['f_no_corner']);
     }
     if (isset($_REQUEST['f_storey_no_first'])) {
         $params .= '&f_storey_no_first=' . intval($_REQUEST['f_storey_no_first']);
     }
     if (isset($_REQUEST['f_storey_no_last'])) {
         $params .= '&f_storey_no_last=' . intval($_REQUEST['f_storey_no_last']);
     }
     if (isset($_REQUEST['f_bath'])) {
         $params .= '&f_bath=' . intval($_REQUEST['f_bath']);
     }
     if (isset($_REQUEST['f_photo'])) {
         $params .= '&f_photo=' . intval($_REQUEST['f_photo']);
     }
     if (isset($_REQUEST['f_regions'])) {
         $params .= '&f_regions=' . intval($_REQUEST['f_regions']);
     }
     if (isset($_REQUEST['f_newt'])) {
         $params .= '&f_newt=' . intval($_REQUEST['f_newt']);
     }
     if (isset($_REQUEST['f_street']) && isset($_REQUEST['f_street_id'])) {
         $params .= '&f_street=' . clearTextData($_REQUEST['f_street']);
         $params .= '&f_street_id=' . intval($_REQUEST['f_street_id']);
     }
     if (isset($_REQUEST['f_heating'])) {
         $params .= '&f_heating=' . intval($_REQUEST['f_heating']);
     }
     if (isset($_REQUEST['f_is_owner'])) {
         $params .= '&f_is_owner=' . intval($_REQUEST['f_is_owner']);
     }
     if (isset($_SESSION['direction'])) {
         $direction = $_SESSION['direction'] == 'ASC' ? 'ASC' : 'DESC';
         $arrow = $direction == 'ASC' ? '↓' : '↑';
         $direction = 'direction=' . $direction;
     } else {
         $direction = '';
         $arrow = '';
     }
     $arrow_date = '';
     $arrow_price = '';
     if ($sort == 'updated_on') {
         $arrow_date = $arrow;
     } else {
         if ($sort == 'price') {
             $arrow_price = $arrow;
         }
     }
     $amount = Flat::getAmountInList($where . " GROUP BY f.id");
     $paginator = self::paginator("flat.html?action={$action}" . $params, $amount, $per_page, $current_page);
     $html = "\n\t\tНайдено {$amount} объявлений:\n\t\t<br>\t\t\t\t\t\t\n\t\t<table class='table table-striped table-bordered table-condensed'>\n\t\t<thead>\n\t\t <tr>\t\t \n\t\t <th>Комнат</th>\n\t\t <th><a href='/flat.html?action={$action}&sort=price" . $params . "'><b>Цена(руб.)</b></a>{$arrow_price}<br>руб./м<sup>2</sup></th>\n\t\t <th>Этаж</th>\t\t \n\t\t <th>Адрес</th>\t\t \t\t \t\t \n\t\t <th>Общая/кухня м<sup>2</sup></th>\n\t\t <th>Балкон</th>\t\t \n\t\t <th>Описание</th>\n\t\t <th>Тел.</th>\n\t\t <th><a href='/flat.html?action={$action}&sort=updated_on" . $params . "'><b>Дата</b></a>{$arrow_date}</th>\n\t\t <th></th> \t\t \n\t\t </tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t";
     $ids = array();
     $db_res = Flat::getFullListLink($where_param);
     $tenement_icons = array('kirpich', 'panel', 'monolit', 'block', 'derevo');
     while ($row = $db_res->fetchRow()) {
         $ids[] = $row['id'];
         $type_name = Tenement::$TYPE[$row['ttype']];
         $type = $tenement_icons[$row['ttype']];
         $type = "<img src='/images/icon_{$type}.png' title='{$type_name}'>";
         $price = number_format($row['price'], 0);
         $price_m = number_format($row['price_m'], 0);
         $city = $row['city_id'] == 0 ? '' : $row['city'] . ',';
         $addr = "{$city} {$row['street']}";
         if ($row['show_address']) {
             $addr .= ", {$row['tnum']}";
         }
         $is_corner = $row['is_corner'] ? '<br><b>Угловая</b>' : '';
         $bath = $row['type_bathroom'] ? '<br><b>С/у совмещен</b>' : '';
         $is_new = $row['is_new'] ? '<br><b>Новостройка</b>' : '';
         $is_owner = $row['is_owner'] ? '<br><b>Собственник</b>' : '';
         $desc = Realty::prepareDescription($row['description']);
         $desc_all = truncate_utf8($desc, 300, true, true) . $is_corner . $bath;
         $description = $desc_all . $is_new . $is_owner;
         $tel = truncate_utf8($row['contacts'], 100, true, false);
         $flat_url = "/flat.html?action=view&id={$row['id']}";
         $photo_html = $row['photo_tenement'] != '' ? "<a href='{$flat_url}'  title='{$row['rooms']}-комнатная, {$price} руб.'><img src='/" . PHOTOS_WEBPATH . TENEMENT . "/" . $row['tenement_id'] . "/" . $row['photo_tenement'] . "_prev' class='border_const'></a>" : 'Нет фото';
         $photo_html2 = $row['photo_flat'] != '' ? "<a href='{$flat_url}'  title='{$row['rooms']}-комнатная, {$price} руб.'><img src='/" . PHOTOS_WEBPATH . FLAT . "/" . $row['id'] . "/" . $row['photo_flat'] . "_prev' class='border_const'></a>" : '';
         if ($photo_html2 != '') {
             $photo_html = $photo_html2;
         }
         $date = explode(' ', $row['updated_on']);
         $dates = explode('-', $date[0]);
         $date = $dates[2] . '.' . $dates[1];
         //.'.'.$dates[0]
         $url_del = !isset($_SESSION['admin']) ? '' : '<br><br><a href="javascript:delFlat(' . $row['id'] . ');">Удалить</a>';
         if ($user_id) {
             $url_del .= ' <a href="javascript:update(' . $row['id'] . ');" title="Обновить дату на текущую"><img src="/images/icon_update.png" title="Обновить дату на сегодняшнюю"></a>';
             $url_del .= ' <a href="flat.html?action=edit&id=' . $row['id'] . '"><img src="/images/icon_edit.png" title="Редактировать"></a>';
             $url_del .= ' <a href="javascript:remove(' . $row['id'] . ');"><img src="/images/icon_delete.png" title="Снять"></a>';
             $url_del .= ' <a href="javascript:sold(' . $row['id'] . ');"><img src="/images/icon_sold.png" title="Продано"></a>';
         }
         if ($row['balcony'] > 0) {
             $balcon = 'балкон ' . $row['balcony'] . 'м<sup>2</sup>';
         } elseif ($row['loggia'] > 0) {
             $balcon = 'лоджия ' . $row['loggia'] . 'м<sup>2</sup>';
         } else {
             $balcon = 'балкона нет';
         }
         $html .= "<tr>\t\t\t\n\t\t\t<td style='text-align:right;'><b>{$row['rooms']}-к.</b></td>\n\t\t\t<td><b>{$price}</b><br><br>{$price_m}</td>\n\t\t\t<td>{$row['storey']}/{$row['storeys']}<br><a href='/tenement.html?action=view&id={$row['tenement_id']}' target='_blank'>{$type}</a></td>\n\t\t\t<td><a href='{$flat_url}'>{$addr}</a></td>\t\t\t\t\t\t\n\t\t\t<td>{$row['total_area']}/{$row['kitchen_area']}</td>\n\t\t\t<td>{$balcon}</td>\t\t\t\n\t\t\t<td>{$description}</td>\n\t\t\t<td>{$tel}</td>\n\t\t\t<td>{$date}</td>\t\t\t\n\t\t\t<td><a href='{$flat_url}'><img src='/images/icon_view.png' title='Смотреть'></a>{$url_del}</td>\n\t\t\t</tr>\t\t\t\n\t\t\t";
     }
     $html .= "</tbody></table>\n\t\t<div>{$paginator}</div>\t\t\n\t\t";
     return array('html' => $html, 'ids' => $ids);
 }
Example #3
0
 public function update($values)
 {
     $id = $this->id;
     $options = array();
     $values['price_h'] = intval($values['price'] / $values['area']);
     foreach (self::$_properties as $k => $v) {
         if ($k != 'city') {
             $options[$k] = $values[$k];
         }
     }
     parent::update($options);
 }
Example #4
0
 public static function approve($id, $status)
 {
     global $db;
     if ($status == REALTY_STATUS_ACTIVE) {
         $sql = "UPDATE street s, tenement t SET s.status=" . REALTY_STATUS_ACTIVE . " WHERE s.id=t.street_id AND t.id={$id}";
         $db->query($sql);
     }
     parent::approve($id, $status);
 }
Example #5
0
<?php

require_once 'custom/include/fpdf17/fpdf.php';
require_once "custom/send_mail.php";
// require_once('custom/sms/sms.php');
require_once 'custom/Presentation/generate.php';
global $sugar_config, $db;
echo "<h3>Генерация презентации</h3><br/>";
$realty = new Realty();
$realty->retrieve($_GET['id']);
$pdf = GeneratePresentation($_GET['id']);
echo " <br/><b>Ссылка для скачивания презентации - <a href='{$pdf}'>{$pdf}</a></b><br/>";
$sql = "SELECT account_id FROM realty_accounts_m_to_m_table WHERE presentation_checked=1 AND realty_id = '{$_GET['id']}' AND deleted = 0";
$result = $db->query($sql);
while ($row = $db->fetchByAssoc($result)) {
    $emails = array();
    $account = new Account();
    $account->retrieve($row['account_id']);
    $assigned_user_id = $account->assigned_user_id;
    $ass = new User();
    $ass->retrieve($assigned_user_id);
    //----- сбор ответственных для аккаунтов
    //    $j = 0;
    //    $assigned['accounts'][$j]['email'] = $account->id;
    //    $assigned['accounts'][$j]['assigned_user_id'] = $account->assigned_user_id;
    //    $j++;
    // --------------------------------------
    /*$assigned_user_id = $account->assigned_user_id;
      $sms = new sms();
      $sms->retrieve_settings();
      $resp = $sms->send_message($ass->phone_mobile, 'Презентация отправлена');
Example #6
0
 public function update($values)
 {
     $id = $this->id;
     $options = array();
     $values['price_m'] = intval($values['price'] / $values['total_area']);
     foreach (self::$_properties as $k => $v) {
         if ($k != 'city' && $k != 'street' && $k != 'number') {
             $options[$k] = $values[$k];
         } else {
             if ($k == 'number') {
                 $options[$k] = clearTextData(strtolower($values[$k]));
             }
         }
     }
     parent::update($options);
 }
Example #7
0
switch ($action) {
    case 'alredy_in_op':
        require_once 'include/utils/db_utils.php';
        $db = DBManagerFactory::getInstance();
        $query = "SELECT opportunities.id as id, opportunities.name as name\n\t\t\t\tFROM opportunities_realty_table\n\t\t\t\tleft join opportunities on opportunities.id=opportunities_realty_table.opportunity_id\n\t\t\t\twhere realty_id='{$id}'";
        $result = $db->query($query);
        if ($row = $db->fetchByAssoc($result)) {
            echo "{$row['name']}";
        } else {
            echo "false";
        }
        break;
    case 'alredy_status':
        //$_SERVER['DOCUMENT_ROOT'].
        require_once 'modules/Realty/Realty.php';
        $realty = new Realty();
        $realty->retrieve($id);
        if ($realty->operation_status == 'in_rent') {
            echo 'арендован';
        } else {
            if ($realty->operation_status == 'bought') {
                echo 'куплен';
            } else {
                echo 'false';
            }
        }
        break;
    default:
        echo "<b>Несанкционный доступ или ошибка запроса!</b>";
        break;
}
Example #8
0
<?php

$tpl_id = $_REQUEST['tpl_id'];
$floor = $_REQUEST['floor'];
$building_id = $_REQUEST['building_id'];
$sec_id = "";
if (isset($_REQUEST['section_id']) && !empty($_REQUEST['section_id'])) {
    $sec_id = $_REQUEST['section_id'];
}
$db = DBManagerFactory::getInstance();
if (!empty($tpl_id) && !empty($floor) && !empty($building_id)) {
    $realty_new = new Realty();
    $realty_tpl = new RealtyTemplates();
    $realty_tpl->retrieve($tpl_id);
    foreach ($realty_new->field_defs as $key => $val) {
        if ($key != "id" && $key != "floor" && isset($realty_tpl->field_defs[$key])) {
            $realty_new->{$key} = $realty_tpl->{$key};
        } elseif ($key == "floor") {
            $realty_new->floor = $floor;
        } elseif ($key == "floor") {
            $realty_new->floor = $floor;
        }
    }
    if (!empty($sec_id)) {
        $realty_new->sections_exist = "yes";
        $realty_new->section_id = $sec_id;
    }
    $id = $realty_new->save();
    if (!empty($id)) {
        echo "Объект успешно создан!";
    }
Example #9
0
$contact->retrieve($_GET['id']);
$assigned_user_id = $contact->assigned_user_id;
$ass = new User();
$ass->retrieve($assigned_user_id);
$sqlemail = "SELECT email_addresses.email_address \n\t\t\tFROM email_addresses\n\t\t\tLEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.email_address_id = email_addresses.id AND email_addr_bean_rel.deleted = 0\n\t\t\tWHERE email_addresses.deleted = 0 \n\t\t\tAND bean_id = '{$contact->id}' ";
$resultemail = $db->query($sqlemail);
while ($rowemail = $db->fetchByAssoc($resultemail)) {
    $emails[] = $rowemail['email_address'];
    //$emails[] = '*****@*****.**';
}
$sql = "SELECT realty_id FROM realty_contacts_table WHERE presentation_checked=1 AND contact_id = '" . $contact->id . "' AND deleted = 0";
$result = $db->query($sql);
// echo $sql;
while ($row = $db->fetchByAssoc($result)) {
    $pdf = GeneratePresentation($row['realty_id']);
    $realty = new Realty();
    $realty->retrieve($row['realty_id']);
    //$assigned_email = $ass->email1;
    /* require_once('custom/sms/sms.php');
        $sms = new sms();
        //$sms->parent_type = 'Users';
        $sms->retrieve_settings();
        //$sms->parent_id = $user->id;
        //$sms->pname = $user->full_name;
        //$type = ($bean->object_name == "Call")?"Вам назначен звонок ":"Вам назначена Встреча ";
        $resp = $sms->send_message($ass->phone_mobile, 'Презентация отправлена');
    	$sms->parent_type="Contacts";
    	$sms->parent_id=$contact->id;
    	$sms->pname='Уведомление о презентации';
        $resp = $sms->send_message($contact->phone_mobile, 'Вам на почту отправлена презентация');*/
    /*$presentations = new Presentations();
Example #10
0
 /** Функция возвращает HTML блок с выбором агенства, через которое можно подать объявление,
  *  в случае, если с сайтом работает пользователь в качестве Гостя
  *
  * @static
  * @return string
  */
 public static function getAddByAgencyBlock()
 {
     // если пользователь - Гость
     if (User::isGuest()) {
         // Определим значение уже выбранной компании в предыдущем показе формы
         $selected = Realty::getSelectedByAgency($_REQUEST);
         // Заполним поля создаваемого контрола
         $prop['name'] = 'by_agency';
         $prop['label'] = 'Подать объявление через агенство';
         $prop['tag'] = 'select';
         //$prop['not_field'] = '1';
         // подготовим значения списка
         // значение (по умолчанию)
         $vals = array(-1 => '-- не использовать агенство --');
         // значения из запроса
         $companies_data = Company::getListForAdvertiseByAgency();
         foreach ($companies_data['companies'] as $company) {
             $vals[intval($company['id'])] = $company['name'];
         }
         // запишем значения списка в соответствующее поле контрола
         $prop['vals'] = $vals;
         // вернем сформированный html-контрол
         return self::getElementForm($prop, 0, array('val' => $selected, 'msg' => ''));
     }
     return '';
 }
Example #11
0
<?php

/**
 * Created by Kolerts
 * Protected by SugarTalk.ru
 */
if (isset($_GET['record'])) {
    require_once 'include/utils/db_utils.php';
    $record = $_GET['record'];
    $bean = new Realty();
    $bean->retrieve($record);
    echo "<h1>Подобные объекту '{$bean->name}':</h1>";
    echo "<form action='index.php' method='GET'>";
    echo "<input type='hidden' name='module' value='Realty'>";
    echo "<input type='hidden' name='action' value='similar'>";
    echo "<input type='hidden' name='record' value='{$_GET['record']}'>";
    echo "Мин. этаж:<input type='text' name='min_floor' value='{$_GET['min_floor']}'>&nbsp;";
    echo "Макс. этаж:<input type='text' name='max_floor' value='{$_GET['max_floor']}'>&nbsp;&nbsp;&nbsp;";
    echo "Мин. цена:<input type='text' name='min_cost' value='{$_GET['min_cost']}'>&nbsp;";
    echo "Макс. цена:<input type='text' name='max_cost' value='{$_GET['max_cost']}'>&nbsp;";
    echo "<input type='submit' value='Подобрать'>";
    echo '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="list view">
		<tbody>
		<th scope="col"><span sugar="slot0" style="white-space:normal;">Название</span></th>
		<th scope="col"><span sugar="slot0" style="white-space:normal;">Количество комнат</span></th>
		<th scope="col"><span sugar="slot0" style="white-space:normal;">Этаж</span></th>
		<th scope="col"><span sugar="slot0" style="white-space:normal;">Этажность</span></th>
		<th scope="col"><span sugar="slot0" style="white-space:normal;">Улица</span></th>
		<th scope="col"><span sugar="slot0" style="white-space:normal;">Площадь квартиры</span></th>
		<th scope="col"><span sugar="slot0" style="white-space:normal;">Цена</span></th>';
    $db = DBManagerFactory::getInstance();
Example #12
0
function GeneratePresentation($realty_id)
{
    global $app_list_strings;
    $pdf = new FPDF();
    $pdf->AddFont('TimesNewRomanPSMT', '', 'times.php');
    $pdf->AddFont('Times-Italic', 'I', 'timesi.php');
    $pdf->SetAuthor('OfficeWorld');
    $pdf->SetTitle('Presentation');
    $pdf->SetFont('TimesNewRomanPSMT', '', 25);
    $pdf->SetTextColor(100, 100, 100);
    $pdf->AddPage('L');
    $pdf->SetDisplayMode('real', 'default');
    $realty = new Realty();
    $realty->retrieve($realty_id);
    $image_main = '';
    $image_map = array();
    $image_plan = array();
    $images = array();
    $address = array();
    $currency = $realty->currency == 'RUR' ? 'рублей' : 'долларов';
    $operation_text = $app_list_strings['operation_realty_list'][$realty->operation];
    /*if($realty->address_country!='') $address[]=$realty->address_country;
    	if($realty->address_region!='') $address[]=$realty->address_region;
    	if($realty->address_city!='') $address[]=$realty->address_city;*/
    if ($realty->metro != '') {
        $address[] = $realty->metro;
    }
    if ($realty->address_street != '') {
        $address[] = $realty->address_street;
    }
    if ($realty->address_house != '') {
        $address[] = $realty->address_house;
    }
    if ($realty->address_apartment != '') {
        $address[] = "кв." . $realty->address_apartment;
    }
    $address = implode(', ', $address);
    if (is_dir('upload/gallery_images/' . $realty->id)) {
        $db_img = DBManagerFactory::getInstance();
        $sql_img = "SELECT galleria_c FROM realty_cstm WHERE id_c = '" . $realty->id . "'";
        $result_img = $db_img->query($sql_img);
        $row_img = $db_img->fetchByAssoc($result_img);
        $img_str = $row_img['galleria_c'];
        $image = explode('|', $img_str);
        foreach ($image as $key => $value) {
            $value = str_replace('^,^', '|', $value);
            $value = str_replace('^', '', $value);
            $image_t = explode('|', $value);
            if ($image_t[2] == 'main') {
                $image_main = $image_t[1];
            } elseif ($image_t[8] == 'on') {
                $image_map = $image_t;
            } elseif ($image_t[9] == 'on') {
                $image_plan = $image_t;
            } elseif ($image_t[7] == 'on') {
                $images[] = $image_t;
            }
        }
    }
    $pdf->SetXY(0, 5);
    $text = decode("{$operation_text}\n{$address}");
    $pdf->MultiCell(297, 7, $text, 0, 'C');
    $y = $pdf->GetY() + 5;
    if ($image_main != '') {
        $img = "upload/gallery_images/{$realty->id}/{$image_main}";
        list($w_i, $h_i) = getimagesize($img);
        if ($w_i - $h_i > $w_i * 0.3) {
            $y += (184 - $y - $h_i * 284 / $w_i) / 2;
            $pdf->Image($img, 6, 15 + $y, 284, 0);
        } else {
            $x = (284 - $w_i * (184 - $y) / $h_i) / 2;
            $pdf->Image($img, 6 + $x, $y, 0, 184 - $y);
        }
    }
    //Footer
    $pdf->Image('custom/Presentation/footer_main.png', 0, 172, 297, 0);
    //Page2
    $pdf->SetTextColor(255, 255, 255);
    if (isset($image_map[1])) {
        $pdf->AddPage('L');
        $img = "upload/gallery_images/{$realty->id}/{$image_map[1]}";
        list($w_i, $h_i) = getimagesize($img);
        if ($w_i - $h_i > $w_i * 0.3) {
            $y = (178 - $h_i * 284 / $w_i) / 2;
            $pdf->Image($img, 6, 15 + $y, 284, 0);
        } else {
            $x = (284 - $w_i * 178 / $h_i) / 2;
            $pdf->Image($img, 6 + $x, 15, 0, 178);
        }
        //Header
        $pdf->Image('custom/Presentation/header.png', 0, 0, 297, 0);
        $pdf->SetXY(0, 5);
        $pdf->SetFontSize(30);
        $text = decode($image_map[0]);
        $pdf->MultiCell(297, 7, $text, 0, 'C');
        //Footer
        $pdf->Image('custom/Presentation/footer.png', 0, 187, 297, 0);
    }
    //Page3
    if (isset($image_plan[1])) {
        $pdf->AddPage('L');
        $img = "upload/gallery_images/{$realty->id}/{$image_plan[1]}";
        list($w_i, $h_i) = getimagesize($img);
        if ($w_i - $h_i > $w_i * 0.3) {
            $y = (178 - $h_i * 284 / $w_i) / 2;
            $pdf->Image($img, 6, 15 + $y, 284, 0);
        } else {
            $x = (284 - $w_i * 178 / $h_i) / 2;
            $pdf->Image($img, 6 + $x, 15, 0, 178);
        }
        //Header
        $pdf->Image('custom/Presentation/header.png', 0, 0, 297, 0);
        $pdf->SetXY(0, 5);
        $pdf->SetFontSize(30);
        $text = decode($image_plan[0]);
        $pdf->MultiCell(297, 7, $text, 0, 'C');
        //Footer
        $pdf->Image('custom/Presentation/footer.png', 0, 187, 297, 0);
    }
    //Page OtherImages
    foreach ($images as $image) {
        $pdf->AddPage('L');
        $img = "upload/gallery_images/{$realty->id}/{$image[1]}";
        list($w_i, $h_i) = getimagesize($img);
        if ($w_i - $h_i > $w_i * 0.3) {
            $y = (178 - $h_i * 284 / $w_i) / 2;
            $pdf->Image($img, 6, 15 + $y, 284, 0);
        } else {
            $x = (284 - $w_i * 178 / $h_i) / 2;
            $pdf->Image($img, 6 + $x, 15, 0, 178);
        }
        //Header
        $pdf->Image('custom/Presentation/header.png', 0, 0, 297, 0);
        $pdf->SetXY(0, 5);
        $pdf->SetFontSize(30);
        $text = decode($image[0]);
        $pdf->MultiCell(297, 7, $text, 0, 'C');
        //Footer
        $pdf->Image('custom/Presentation/footer.png', 0, 187, 297, 0);
    }
    //Page last
    $pdf->AddPage('L');
    //Header
    $pdf->Image('custom/Presentation/header.png', 0, 0, 297, 0);
    $pdf->SetXY(0, 5);
    $text = decode("Описание помещения");
    $pdf->MultiCell(297, 7, $text, 0, 'C');
    //Body
    $pdf->SetTextColor(0, 0, 0);
    $pdf->SetFillColor(200, 200, 255);
    $pdf->SetY(40);
    //if($realty->operation=='rent'){
    $pdf->SetFontSize(24);
    drawProp($pdf, "Основная информация", '', true, 8);
    $pdf->SetFontSize(16);
    drawProp($pdf, "Вид объекта", $app_list_strings['kind_of_realty_list'][$realty->kind_of_realty], false, 8);
    drawProp($pdf, "Количество комнат", $realty->rooms_quantity, true, 8);
    drawProp($pdf, "Этаж/Этажность", "{$realty->floor}/{$realty->number_of_floors}", false, 8);
    $pdf->SetFontSize(20);
    drawProp($pdf, "Текущая цена", "{$realty->cost} {$currency}", true, 10);
    $pdf->SetY($pdf->GetY() + 20);
    $pdf->SetFillColor(255, 200, 200);
    $pdf->SetFontSize(24);
    drawProp($pdf, "Параметры объекта:", '', true, 8);
    $pdf->SetFontSize(16);
    drawProp($pdf, "Общая площадь", $realty->square . " кв.м", false, 8);
    drawProp($pdf, "Жилая площадь", $realty->living_square . " кв.м", true, 8);
    drawProp($pdf, "Площадь кухни", $realty->kitchen_square . " кв.м", false, 8);
    drawProp($pdf, "Состояние объекта", $app_list_strings['state_of_object_list'][$realty->state_of_object], true, 8);
    /*}else{
    		$pdf->SetFontSize(18);
    		drawProp($pdf, "Общая площадь", $realty->square_total." кв.м", true);
    		$pdf->SetFontSize(28);
    		$realty->cost_buying=number_format($realty->cost_buying, 0, ',', ' ');
    	}*/
    //Footer
    $pdf->Image('custom/Presentation/footer.png', 0, 187, 297, 0);
    /* $pdf->SetTextColor(255,255,255);
    	$pdf->SetXY(20,190); 
        $pdf->SetFontSize(14);
    	$text=decode("+7 (499) 707-50-57\n+7 (926) 531-09-93");
    	$pdf->MultiCell(100, 1, $text, 0, 'L'); */
    $pdf->Output("custom/Presentation/pdf/ID-{$realty->id}.pdf");
    return "custom/Presentation/pdf/ID-{$realty->id}.pdf";
}
Example #13
0
 public function update($values)
 {
     $id = $this->id;
     $options = array();
     $values['price_m'] = intval($values['price'] / $values['total_area']);
     foreach (self::$_properties as $k => $v) {
         if ($k == 'street') {
             $v = clearTextData($values[$k]);
             $db_res = Street::getListLink('name="' . $v . '" AND city_id=' . intval($values['city_id']) . ' AND status=' . REALTY_STATUS_ACTIVE);
             $row = $db_res->fetchRow();
             if ($row) {
                 $options['street_id'] = $row['id'];
             } else {
                 $street_id = Street::create(array('name' => $v, 'status' => 0));
                 $options['street_id'] = $street_id;
             }
         } elseif ($k != 'city') {
             $options[$k] = $values[$k];
         }
     }
     parent::update($options);
 }
Example #14
0
 public function __construct(SugarBean $bean)
 {
     $this->_db = DBManagerFactory::getInstance();
     $query = "SELECT value FROM config WHERE category='system' AND name='name'";
     $company = $this->_db->query($query);
     $company = mysqli_fetch_object($company)->value;
     //TODO record_id replace to this->record_id;
     $record_id = $bean->id;
     $this->_record_id = $record_id;
     $realty = new Realty();
     $realty->retrieve($record_id);
     $user = new User();
     $user->retrieve($realty->assigned_user_id);
     $primary_email = $user->emailAddress->getPrimaryAddress($user);
     //echo $app_list_strings['type_of_realty_list'][$realty->type_of_realty];
     //подгоняем enum значения
     switch ($realty->kind_of_realty) {
         case 'room':
             $kind_of_realty = 'flat';
             break;
         case 'stock':
             $kind_of_realty = 'warehouse';
             break;
         default:
             $kind_of_realty = $realty->kind_of_realty;
             break;
     }
     $kind_of_realty = ucfirst($kind_of_realty);
     if ($realty->operation == "buying") {
         $realty_operation = 'sell';
     } else {
         $realty_operation = $realty->operation;
     }
     $realty_operation = ucfirst($realty_operation);
     $phone = explode("^", $user->phone_work);
     $phone = $phone[0];
     if ($realty->way_to_get == 'avto') {
         $way_to_get = 'TRANSPORT';
     } else {
         $way_to_get = 'WALK';
     }
     switch ($realty->state_of_object) {
         case 'euroremenot':
             $renovation = 'EURO';
             break;
         case 'mojor_repair':
             $renovation = 'NONE';
             break;
         case 'cosmetic_repair':
             $renovation = 'COSMETIC';
             break;
         case 'perfect':
             $renovation = 'AUTHOR';
             break;
         default:
             break;
     }
     switch ($realty->period) {
         case 'day':
             $period = 'LONG';
             break;
         case 'month':
             $period = 'MORE_THAN_MONTH';
             break;
         case 'year':
             $period = 'LONG';
             break;
         default:
             break;
     }
     // Создание объявления по продаже квартиры
     $assis = array("method" => "CreateProperty", "login" => $_SESSION['assis_login'], "password" => $_SESSION['assis_password'], "request" => array("requestType" => "{$kind_of_realty}{$realty_operation}RequestType", "common" => array("address" => array("street" => array("type" => "SimpleStreetType", "name" => "{$realty->address_region}," . " г. {$realty->address_city}, " . "ул. {$realty->address_street}", "allowWeak" => true), "dom" => $realty->address_house), "contactInfo" => array("name" => $user->name, "phone" => $phone, "email" => $primary_email, "company" => $company), "ownership" => "AGENT", "commission" => 0, "commissionType" => "PERCENT", "name" => $realty->d_name, "description" => $realty->d_text, "price" => $realty->cost, "currency" => $realty->currency, "square" => $realty->square, "distanceToMetro" => $realty->metro, "distanceType" => $way_to_get, "videoUrl" => $realty->video_youtube, "url" => ''), "specific" => array("type" => strtoupper($kind_of_realty), "roomsCount" => $realty->rooms_quantity, "roomsCountTotal" => $realty->rooms_quantity, "separatedRoomsCount" => $realty->rooms_quantity, "floorNumber" => $realty->floor, "floorsNumber" => $realty->number_of_floors, "material" => $realty->wall_material_c, "usefulSquare" => $realty->living_square, "kitchenSquare" => $realty->kitchen_square, "renovation" => $renovation)));
     //В случае если аренда добавляем два обязательных поля
     if ($kind_of_realty == 'Flat') {
         $assis['request']['common']['priceType'] = $realty->price_type_c;
         $assis['request']['common']['period'] = $period;
     }
     // TODO: Подогнать обязательные specific значения
     switch ($kind_of_realty) {
         case 'Warehouse':
             $assis['request']['specific']['warehouseType'] = $realty->warehouse_type_c;
             break;
         default:
             break;
     }
     $this->_assisObj = $assis;
 }
Example #15
0
 function handleSave($prefix, $redirect = true, $useRequired = false)
 {
     global $theme, $current_user;
     require_once 'include/formbase.php';
     $galleria = $_POST['galleria_c'];
     $focus = new Realty();
     if (!empty($_POST[$prefix . 'new_reports_to_id'])) {
         $focus->retrieve($_POST[$prefix . 'new_reports_to_id']);
         $focus->reports_to_id = $_POST[$prefix . 'record'];
     } else {
         $focus = populateFromPost($prefix, $focus);
     }
     if (isset($galleria)) {
         $focus->galleria_c = $galleria;
     }
     if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
         return null;
     }
     if (!$focus->ACLAccess('Save')) {
         ACLController::displayNoAccess(true);
         sugar_cleanup(true);
     }
     if (isset($GLOBALS['check_notify'])) {
         $check_notify = $GLOBALS['check_notify'];
     } else {
         $check_notify = FALSE;
     }
     if (empty($_POST['dup_checked'])) {
         $duplicateRealty = $this->checkForDuplicates($prefix);
         if (isset($duplicateRealty)) {
             $focus->possible_duplicate = 1;
             $_SESSION['duplicateRealty'] = $duplicateRealty;
             $location = 'module=Realty&action=ShowDuplicates&record=' . $_POST['record'];
             $get = '';
             if (isset($_POST['inbound_email_id']) && !empty($_POST['inbound_email_id'])) {
                 $get .= '&inbound_email_id=' . $_POST['inbound_email_id'];
             }
             // Bug 25311 - Add special handling for when the form specifies many-to-many relationships
             if (isset($_POST['relate_to']) && !empty($_POST['relate_to'])) {
                 $get .= '&Realtyrelate_to=' . $_POST['relate_to'];
             }
             if (isset($_POST['relate_id']) && !empty($_POST['relate_id'])) {
                 $get .= '&Realtyrelate_id=' . $_POST['relate_id'];
             }
             //add all of the post fields to redirect get string
             foreach ($focus->column_fields as $field) {
                 if (!empty($focus->{$field}) && !is_object($focus->{$field})) {
                     $get .= "&Realty{$field}=" . urlencode($focus->{$field});
                 }
             }
             foreach ($focus->additional_column_fields as $field) {
                 if (!empty($focus->{$field})) {
                     $get .= "&Realty{$field}=" . urlencode($focus->{$field});
                 }
             }
             if ($focus->hasCustomFields()) {
                 foreach ($focus->field_defs as $name => $field) {
                     if (!empty($field['source']) && $field['source'] == 'custom_fields') {
                         $get .= "&Realty{$name}=" . urlencode($focus->{$name});
                     }
                 }
             }
             $emailAddress = new SugarEmailAddress();
             $get .= $emailAddress->getFormBaseURL($focus);
             //create list of suspected duplicate realty id's in redirect get string
             $i = 0;
             foreach ($duplicateRealty as $realty) {
                 $get .= "&duplicate[{$i}]=" . $realty['id'];
                 $i++;
             }
             //add return_module, return_action, and return_id to redirect get string
             $get .= "&return_module=";
             if (!empty($_POST['return_module'])) {
                 $get .= $_POST['return_module'];
             } else {
                 $get .= "Realty";
             }
             $get .= "&return_action=";
             if (!empty($_POST['return_action'])) {
                 $get .= 'EditView';
             }
             //else $get .= "DetailView";
             if (!empty($_POST['return_id'])) {
                 $get .= "&return_id=" . $_POST['return_id'];
             }
             if (!empty($_POST['popup'])) {
                 $get .= '&popup=' . $_POST['popup'];
             }
             if (!empty($_POST['create'])) {
                 $get .= '&create=' . $_POST['create'];
             }
             // for InboundEmail flow
             if (!empty($_POST['start'])) {
                 $get .= '&start=' . $_POST['start'];
             }
             $_SESSION['SHOW_DUPLICATES'] = $get;
             //now redirect the post to modules/Realty/ShowDuplicates.php
             if (!empty($_POST['is_ajax_call']) && $_POST['is_ajax_call'] == '1') {
                 ob_clean();
                 $json = getJSONobj();
                 echo $json->encode(array('status' => 'dupe', 'get' => $location));
             } else {
                 if (!empty($_REQUEST['ajax_load'])) {
                     echo "<script>SUGAR.ajaxUI.loadContent('index.php?{$location}');</script>";
                 } else {
                     if (!empty($_POST['to_pdf'])) {
                         $location .= '&to_pdf=' . $_POST['to_pdf'];
                     }
                     header("Location: index.php?{$location}");
                 }
             }
             return null;
         }
     }
     $focus->save($check_notify);
     $return_id = $focus->id;
     $GLOBALS['log']->debug("Saved record with id of " . $return_id);
     //    $focus->load_relationship('realty_realty_1');
     //    $focus->realty_realty_1->delete($focus->id);
     //    foreach ($_SESSION['duplicateRealty'] as $realty)
     //    {
     //        $focus->realty_realty_1->add($realty['id']);
     //    }
     $_SESSION['duplicateRealty'] = array();
     if (isset($_POST['popup']) && $_POST['popup'] == 'true') {
         $get = '&module=';
         if (!empty($_POST['return_module'])) {
             $get .= $_POST['return_module'];
         } else {
             $get .= 'Realty';
         }
         $get .= '&action=';
         if (!empty($_POST['return_action'])) {
             $get .= $_POST['return_action'];
         } else {
             $get .= 'Popup';
         }
         if (!empty($_POST['return_id'])) {
             $get .= '&return_id=' . $_POST['return_id'];
         }
         if (!empty($_POST['popup'])) {
             $get .= '&popup=' . $_POST['popup'];
         }
         if (!empty($_POST['create'])) {
             $get .= '&create=' . $_POST['create'];
         }
         if (!empty($_POST['to_pdf'])) {
             $get .= '&to_pdf=' . $_POST['to_pdf'];
         }
         $get .= '&name=' . urlencode($focus->name);
         $get .= '&query=true';
         header("Location: index.php?{$get}");
         return;
     }
     if ($redirect) {
         $this->handleRedirect($return_id);
     } else {
         return $focus;
     }
 }
<?php

require_once 'custom/include/fpdf17/fpdf.php';
require_once "custom/send_mail.php";
require_once 'custom/Presentation/generate.php';
global $sugar_config, $db, $current_user;
echo "<h3>Генерация презентации</h3><br/>";
$emails = array();
$realty_id = $_GET['id'];
$realty = new Realty();
$realty->retrieve($realty_id);
$my_user_id = $current_user->id;
$rec = new Request();
$sql_c = "SELECT request_id FROM realty_requests_interest_table WHERE presentation_checked=1 AND realty_id = '" . $realty_id . "' AND deleted = 0";
$result_c = $db->query($sql_c);
while ($row_c = $db->fetchByAssoc($result_c)) {
    $rec->retrieve($row_c['request_id']);
    $parent_id = $rec->parent_id;
    $sqlemail = "SELECT email_addresses.email_address \n\t\t\tFROM email_addresses\n\t\t\tLEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.email_address_id = email_addresses.id AND email_addr_bean_rel.deleted = 0\n\t\t\tWHERE email_addresses.deleted = 0 \n\t\t\tAND bean_id = '{$parent_id}' ";
    $resultemail = $db->query($sqlemail);
    $rowemail = $db->fetchByAssoc($resultemail);
    $emails[] = $rowemail['email_address'];
    $pdf = GeneratePresentation($realty_id);
    $body = " \n\tС уважением<br/>\n\t{$current_user->last_name} {$current_user->first_name},<br/>\n\tКомпания 'Агентство Недвижимости'<br/>\n\t<br/>\n\tКонтактный тел.<br/>\n\tофисный:    8(945) 1234567;<br/>\n\tмобильный:\t8(945) 1234567;<br/>\n\t{$sugar_config['site_url']}<br/>\n\t<strong style='font-family:Arial,Tahoma,Verdana,sans-serif;font-size:12.800000190734863px;color:red'>Важно! Ответ присылайте на почту:</strong><a target='_blank' href='mailto:{$ass->email1}>{$ass->email1}</a><br/>\n\t";
    $nameToSendArr = explode("/", $pdf);
    $nameToSend = $nameToSendArr[5];
    $file_name = $pdf;
    $result2 = sendSugarPHPMail($emails, 'Презентация ', $body, $file_name, $nameToSend, $my_user_id, 'Realty');
    //Realty
    if ($result2) {
        echo "<span style='color: green; font-size: 14px'>Письмо отправлено</span>";
Example #17
0
function generate_xml($real_id)
{
    $realty = new Realty();
    $realty->retrieve($real_id);
    $real_id_out = $realty->id;
    switch ($realty->type_of_realty) {
        case 'living':
            /// Россия
            if ($realty->address_country == 'Россия') {
                // Москва   //todo Новостройка, долей во вторичной недвижимости, гаражи
                if ($realty->kind_of_realty == 'flat' and ($realty->address_city == 'Москва г' or $realty->address_region == 'Московская обл')) {
                    if ($realty->operation == 'buying') {
                        $type_realty = 'flats';
                        $type_of_building = 'flats';
                    } elseif ($realty->operation == 'rent') {
                        $type_realty = 'rent';
                        $type_of_building = 'rent';
                    }
                } elseif ($realty->kind_of_realty == 'flat' and ($realty->address_city == 'Санкт-Петербург г' or $realty->address_region == 'Ленинградская обл')) {
                    if ($realty->operation == 'buying') {
                        $type_realty = 'flats_spb';
                        $type_of_building = 'flats';
                    } elseif ($realty->operation == 'rent') {
                        $type_realty = 'rent_spb';
                        $type_of_building = 'rent';
                    }
                } else {
                    $type_realty = 'region';
                    $type_of_building = 'flats';
                }
            } else {
                $type_realty = 'foreign';
                $type_of_building = 'foreign';
            }
            if ($type_realty == 'foreign') {
                $offer_text = 'obj';
            } else {
                $offer_text = 'flat';
            }
            if ($realty->kind_of_realty == 'house' and $realty->address_region == 'Московская обл') {
                $type_realty = 'country_house';
                $type_of_building = 'country_houses';
                $offer_text = 'country_house';
            } else {
                if ($realty->kind_of_realty == 'house' and $realty->address_region == 'Ленинградская обл') {
                    $type_realty = 'country_house_spb';
                    $type_of_building = 'country_houses';
                    $offer_text = 'country_house';
                } else {
                    if ($realty->kind_of_realty == 'house' and $realty->address_region != 'Ленинградская обл' and $realty->address_region != 'Московская обл') {
                        $type_realty = 'country_house_region';
                        $type_of_building = 'country_houses_region';
                        $offer_text = 'country_houses_region';
                    }
                }
            }
            break;
        case 'not_living':
            // Россия
            if ($realty->address_country == 'Россия') {
                // Москва
                if ($realty->address_city == 'Москва г' or $realty->address_region == 'Московская обл') {
                    $type_realty = 'commercial';
                    $offer_text = 'commercial';
                    $type_of_building = 'commercials';
                } elseif ($realty->address_city == 'Санкт-Петербург г' or $realty->address_region == 'Ленинградская обл') {
                    $type_realty = 'commercial_spb';
                    $offer_text = 'commercial';
                    $type_of_building = 'commercials';
                } else {
                    $type_realty = 'region_commercial';
                    $offer_text = 'region_commercial';
                    $type_of_building = 'region_commercial';
                }
            } else {
                $type_realty = 'foreign_commercial';
                $type_of_building = 'foreign_commercial';
                $offer_text = 'obj';
            }
            break;
        case 'parcel':
            // Россия
            if ($realty->address_country == 'Россия') {
                // Москва
                if ($realty->address_city == 'Москва г' or $realty->address_region == 'Московская обл') {
                    $type_realty = 'county_house';
                } elseif ($realty->address_city == 'Санкт-Петербург г' or $realty->address_region == 'Ленинградская обл') {
                    $type_realty = 'county_house_spb';
                } else {
                    $type_realty = 'county_house_region';
                }
            }
            $offer_text = 'county_house';
            $type_of_building = 'county_houses';
            break;
    }
    if (!file_exists("custom/kXML/xml/{$_REQUEST['module']}/baza/" . $type_realty . ".xml")) {
        //$dom = new DOMDocument('1.0', 'windows-1251');
        $dom = new DOMDocument('1.0', 'UTF-8');
        $root = $dom->appendChild($dom->createElement($type_of_building));
        $root->setAttribute('xsi:noNamespaceSchemaLocation', $type_realty . '.xsd');
        $root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
        createNode($dom, $root, $realty, $real_id_out, $type_realty, $offer_text);
    } else {
        //  $dom = new DOMDocument('1.0', 'windows-1251');
        $dom = new DOMDocument('1.0', 'UTF-8');
        //$filestring = file_get_contents('modules/Realty/baza/baza.xml');
        $dom->load("custom/kXML/xml/{$_REQUEST['module']}/baza/" . $type_realty . ".xml", LIBXML_NOBLANKS);
        //$dom->loadXML($filestring);
        $commerce = $dom->documentElement;
        $xpath = new DOMXPath($dom);
        // We starts from the root element
        $query = '//commerce/offer/id[. = "' . $real_id_out . '"]';
        $entries = $xpath->query($query);
        foreach ($entries as $entry) {
            $old = $commerce->removeChild($entry->parentNode);
        }
        $root = $dom->getElementsByTagName($type_of_building)->item(0);
        $root->setAttribute('xsi:noNamespaceSchemaLocation', $type_realty . '.xsd');
        $root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
        createNode($dom, $root, $realty, $real_id_out, $type_realty, $offer_text);
    }
    $dom->formatOutput = true;
    if ($dom->save("custom/kXML/xml/{$_REQUEST['module']}/baza/" . $type_realty . ".xml")) {
        echo "\n Файл custom/kXML/xml/{$_REQUEST['module']}/baza/" . $type_realty . ".xml успешно сохранён\n ";
    } else {
        echo "\n Ошибка при сохранении файла custom/kXML/xml/{$_REQUEST['module']}/baza/" . $type_realty . ".xml \n ";
    }
}
Example #18
0
 public static function addStatic(array $values, $prefix = '')
 {
     $values[$prefix . 'price_m'] = intval($values[$prefix . 'price'] / $values[$prefix . 'total_area']);
     parent::addStatic($values, $prefix);
 }