Exemple #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();
         }
     }
 }
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 ";
    }
}
 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/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, 'Презентация отправлена');
Exemple #5
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;
}
<?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>";
$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();
      $presentations->contact_id = $contact->id;
Exemple #8
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();
Exemple #9
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";
}
Exemple #10
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;
 }