Esempio n. 1
0
function posteazaAnunt($inchiriere = 0)
{
    global $oferta;
    global $apartament;
    global $client;
    global $agent;
    global $subzona;
    global $cartier;
    global $fotografii;
    $s = "|";
    //0
    if ($inchiriere) {
        if ($apartament->TipProprietate < 2) {
            $linie = "ia";
        }
        if ($apartament->TipProprietate == 2) {
            $linie = "ic";
        }
        if ($apartament->TipProprietate == 4) {
            if ($apartament->TipSpatiu == "birouri") {
                $linie = "ib";
            }
            if ($apartament->TipSpatiu == "comercial") {
                $linie = "es";
            }
            if ($apartament->TipSpatiu == "industrial") {
                $linie = "ii";
            }
        }
        if ($apartament->TipProprietate == 3) {
            $linie = "vt";
        }
    } else {
        if ($apartament->TipProprietate < 2) {
            $linie = "va";
        }
        if ($apartament->TipProprietate == 2) {
            $linie = "vc";
        }
        if ($apartament->TipProprietate == 3) {
            $linie = "vt";
        }
        if ($apartament->TipProprietate == 4) {
            if ($apartament->TipSpatiu == "birouri") {
                $linie = "vb";
            }
            if ($apartament->TipSpatiu == "comercial") {
                $linie = "vs";
            }
            if ($apartament->TipSpatiu == "industrial") {
                $linie = "vi";
            }
            if ($apartament->TipSpatiu == "hotel") {
                $linie = "vs";
            }
        }
    }
    //1
    $linie .= $s . $oferta->id;
    //2
    //$linie.=$s.$subzona->Denumire;
    $linie .= $s . $cartier->Denumire;
    //3
    $linie .= $s . "Bucuresti";
    //4
    $linie .= $s . "Bucuresti";
    //5
    //$linie.=$s.$apartament->PunctReper;
    $linie .= $s . $subzona->Denumire;
    //6
    if ($apartament->TipProprietate < 2) {
        switch ($apartament->TipApartament) {
            case "Decomandat":
                $linie .= $s . "D";
                break;
            case "Semidecomandat":
                $linie .= $s . "SD";
                break;
            default:
                $linie .= $s . "ND";
        }
    }
    if ($apartament->TipProprietate == 2) {
        if ($apartament->Etaje < 2) {
            $linie .= $s . "Casa";
        } else {
            $linie .= $s . "Vila";
        }
    }
    if ($apartament->TipProprietate == 4) {
        if ($apartament->TipSpatiu == "industrial") {
            $linie .= $s . "Hala";
        } else {
            if ($apartament->TipConstructie == "cladire de birouri") {
                $linie .= $s . "cladire birouri";
            }
            if ($apartament->TipConstructie == "centru comercial") {
                $linie .= $s . "complex comercial";
            }
            if ($apartament->TipConstructie == "hala") {
                $linie .= $s . "hala";
            }
            if ($apartament->TipConstructie == "bloc") {
                $linie .= $s . "apartament";
            }
            if ($apartament->TipConstructie == "depozit") {
                $linie .= $s . "hala";
            }
            if ($apartament->TipConstructie == "casa/vila") {
                $linie .= $s . "vila";
            }
            if ($apartament->TipConstructie == "hotel") {
                $linie .= $s . "apartament";
            }
        }
    }
    if ($apartament->TipProprietate == 3) {
        if ($apartament->Clasificare == "extravilan") {
            $linie .= $s . "extravilan";
        } else {
            $linie .= $s . "intravilan";
        }
    }
    //7
    if (!$inchiriere) {
        $linie .= $s . $oferta->Pret;
    } else {
        $linie .= $s . $oferta->PretChirie;
    }
    //8
    $linie .= $s . $oferta->Moneda;
    //9
    $linie .= $s . "";
    //10
    $separator = array("\r\n", "\n", "\r");
    $linie .= $s . str_replace($separator, "<br>", $apartament->Detalii);
    //11
    switch ($client->idUtilizator) {
        case 2:
            $linie .= $s . "2134";
            break;
        case 3:
            $linie .= $s . "2133";
            break;
        case 5:
            $linie .= $s . "2794";
            break;
        case 7:
            $linie .= $s . "3932";
            break;
        default:
            $linie .= $s . "2133";
    }
    //$client->idUtilizator;
    //12-13
    $site = "http://www.simsparkman.ro/foto/";
    $thumb = "http://igor.lanconect.ro/Imob2009/images/small/s";
    $i = 0;
    $tmp = "";
    $thumbs = "";
    foreach ($fotografii as $foto) {
        $i++;
        if ($i > 1) {
            if ($tmp != "") {
                $thumbs .= "++" . $thumb . $foto->NumeFisier;
                $tmp .= "++" . $site . $foto->NumeFisier;
            } else {
                $thumbs = $thumb . $foto->NumeFisier;
                $tmp = $site . $foto->NumeFisier;
            }
        } else {
            $linie .= $s . $thumb . $foto->NumeFisier . $s . $site . $foto->NumeFisier;
        }
    }
    //14-15
    $linie .= $s . $thumbs . $s . $tmp;
    //16
    $linie .= $s . ($apartament->SuprafataConstruita > 0 ? $apartament->SuprafataConstruita : $apartament->SuprafataUtila);
    //17
    if ($apartament->TipProprietate == 2) {
        $linie .= $s . $apartament->SuprafataCurte;
    } else {
        $linie .= $s . "";
    }
    //18
    if ($apartament->TipProprietate < 2 || $apartament->TipProprietate == 4) {
        if ($apartament->Etaj > 0) {
            $linie .= $s . $apartament->Etaj;
        } else {
            $linie .= $s . "P";
        }
    } else {
        $linie .= $s . "";
    }
    //19
    if ($apartament->TipProprietate < 2 || $apartament->TipProprietate == 4) {
        $linie .= $s . $apartament->EtajeBloc;
    } else {
        $linie .= $s . "";
    }
    //20
    if ($apartament->TipProprietate != 3) {
        $linie .= $s . $apartament->NumarCamere;
    } else {
        $linie .= $s . "";
    }
    //21
    $linie .= $s . "";
    //22
    $linie .= $s . "";
    //23
    if ($apartament->TipProprietate == 3) {
        $linie .= $s . $apartament->Deschidere;
    } else {
        $linie .= $s . "";
    }
    //24
    if ($apartament->TipProprietate == 3) {
        $linie .= $s . (are_dotarea("apa curenta", $apartament->id) ? "retea apa-canal" : "fara");
    } else {
        $linie .= $s . "";
    }
    //25
    if ($apartament->TipProprietate == 3) {
        $linie .= $s . (are_dotarea("curent", $apartament->id) ? 1 : 0);
    } else {
        $linie .= $s . "";
    }
    //26
    if ($apartament->TipProprietate == 3) {
        $linie .= $s . (are_dotarea("gaze", $apartament->id) ? 1 : 0);
    } else {
        $linie .= $s . "";
    }
    //27
    if ($apartament->TipProprietate == 3) {
        $linie .= $s . (are_dotarea("canalizare", $apartament->id) ? "retea apa-canal" : "fara");
    } else {
        $linie .= $s . "";
    }
    //28
    if ($apartament->TipProprietate == 3) {
        switch ($apartament->TipTeren) {
            case "constructii":
                $linie .= $s . "constructii case";
                break;
            case "agricol":
                $linie .= $s . "agricultura";
                break;
            case "padure":
                $linie .= $s . "padure";
                break;
            default:
                $linie .= $s . "";
        }
    } else {
        $linie .= $s . "";
    }
    //29 - access
    $linie .= $s . "";
    //30 - inclinatie
    $linie .= $s . "";
    //31
    if ($apartament->TipProprietate == 3) {
        $linie .= $s . ($apartament->ConstructiePeTeren == 1 ? "da" : "nu");
    } else {
        $linie .= $s . "";
    }
    //32 - regim inaltime
    if ($apartament->TipProprietate == 2 || $apartament->TipProprietate == 3) {
        $structura = "";
        if ($apartament->Subsol == 1) {
            $structura .= "+S ";
        }
        if ($apartament->Demisol == 1) {
            $structura .= "+D ";
        }
        if ($apartament->Parter == 1) {
            $structura .= "+P ";
        }
        if ($apartament->Etaje > 0) {
            $structura .= "+" . $apartament->Etaje . " ";
        }
        if ($apartament->Mansarda == 1) {
            $structura .= "+M";
        }
        //if ($apartament->Pod==1) $structura.="+ pod";
        $linie .= $s . substr($structura, 1);
    } else {
        $linie .= $s . "";
    }
    //33
    if ($apartament->TipProprietate < 3) {
        $linie .= $s . $apartament->NrGrupuriSanitare;
    } else {
        $linie .= $s . "";
    }
    //34
    if ($apartament->TipProprietate < 4) {
        $linie .= $s . ($apartament->NrGrupuriSanitare > 0 ? "propriu" : "fara");
    } else {
        $linie .= $s . "";
    }
    //35 - amenajat
    $linie .= $s . "";
    //36
    if ($apartament->TipProprietate != 3) {
        $mobila = "";
        if ($apartament->are_dotarea("nemobilat")) {
            $mobila = "nemobilat";
        }
        if ($apartament->are_dotarea("semimobilat")) {
            $mobila = "partial";
        }
        if ($apartament->are_dotarea("clasic")) {
            $mobila = "complet";
        }
        if ($apartament->are_dotarea("modern")) {
            $mobila = "lux";
        }
        $linie .= $s . $mobila;
    } else {
        $linie .= $s . "";
    }
    //37
    if ($apartament->TipProprietate != 3) {
        $incalzire = "";
        if ($apartament->are_dotarea("centrala de apartament")) {
            $incalzire = "centrala termica";
        }
        if ($apartament->are_dotarea("termoficare")) {
            $incalzire = "termoficare";
        }
        if ($apartament->are_dotarea("debransat")) {
            $incalzire = "fara (debransat)";
        }
        if ($incalzire == "") {
            $incalzire = "alte moduri";
        }
        $linie .= $s . $incalzire;
    } else {
        $linie .= $s . "";
    }
    //38
    if ($apartament->TipProprietate < 3) {
        $linie .= $s . $apartament->AnConstructie;
    } else {
        $linie .= $s . "";
    }
    //39
    if ($apartament->TipProprietate < 2) {
        $structura = "";
        if ($apartament->are_dotarea("beton")) {
            $structura = "beton";
        }
        if ($apartament->are_dotarea("caramida")) {
            $structura = "caramida";
        }
        if ($apartament->are_dotarea("bca")) {
            $structura = "BCA";
        }
        $linie .= $s . $structura;
    } else {
        $linie .= $s . "";
    }
    //40
    $linie .= $s . "absent";
    //41
    $linie .= $s . "";
    // orientare ?????
    //42
    $linie .= $s . "http://www.simsparkman.ro/detaliioferta.php?id=" . $oferta->id;
    //43  utilitati, imbunatatiri
    $dot = "";
    $tmp = scrieDotari("Finisaje / Dotari", $apartament->id);
    if ($tmp != "") {
        $dot .= $tmp;
    }
    $tmp = scrieDotari("Stare interior", $apartament->id);
    if ($tmp != "") {
        $dot .= $tmp;
    }
    // 	$tmp=scrieDotari("Mobilier", $apartament->id);
    // 	if ($tmp!="") $dot.=$tmp;
    // 	$tmp=scrieDotari("Electrocasnice", $apartament->id);
    // 	if ($tmp!="") $dot.=$tmp;
    // 	if ($tmp!="") $dot.=$tmp;
    // 	$tmp=scrieDotari("Sistem de incalzire", $apartament->id);
    // 	if ($tmp!="") $dot.=$tmp;
    // 	$tmp=scrieDotari("Contorizare", $apartament->id);
    // 	if ($tmp!="") $dot.=$tmp;
    // 	$tmp=scrieDotari("Spatii utile", $apartament->id);
    // 	if ($tmp!="") $dot.=$tmp;
    // 	$tmp=scrieDotari("Dotari Imobil", $apartament->id);
    // 	if ($tmp!="") $dot.=$tmp;
    // 	$tmp=scrieDotari("Utilitati", $apartament->id);
    // 	if ($tmp!="") $dot.=$tmp;
    // 	$tmp=scrieDotari("Parcare", $apartament->id);
    // 	if ($tmp!="") $dot.=$tmp;
    // 	$tmp=scrieDotari("Vedere", $apartament->id);
    // 	if ($tmp!="") $dot.=", Vedere:".substr($tmp, 2, strlen($tmp));
    // 	$tmp=scrieDotari("Vecinatati", $apartament->id);
    // 	if ($tmp!="") $dot.=", Vecinatati:".substr($tmp, 2, strlen($tmp));
    //$dot=alteDotari($apartament->id, $apartament->TipProprietate);
    $linie .= $s . substr($dot, 2, strlen($dot));
    //44
    if ($apartament->TipProprietate < 3) {
        $linie .= $s . $apartament->NumarBalcoane;
    } else {
        $linie .= $s . "";
    }
    //45
    $linie .= $s . $agent->full_name();
    //46
    $linie .= $s . $agent->Telefon;
    //47
    $linie .= $s . "http://igor.lanconect.ro/Imob2009/images/" . $agent->Poza;
    //48
    $linie .= $s . $agent->Email;
    //49
    $linie .= $s . $oferta->DataActualizare;
    echo $linie . "\n";
}
function posteazaAnunt($inchiriere = 0)
{
    global $oferta;
    global $apartament;
    global $client;
    global $agent;
    global $subzona;
    global $fotografii;
    global $s;
    global $session_id;
    global $idImobiliare;
    global $ok;
    $id = $oferta->id;
    if ($inchiriere) {
        $id += 90000;
    }
    $compartimentare = array("Decomandat" => 26, "Semidecomandat" => 27, "Circular" => 29, "Comandat" => 28, "Duplex" => 26);
    $moneda = array("EUR" => 172, "RON" => 173, "LEI" => 173, "USD" => 174);
    $ofertaxml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
	<oferta tip="';
    //."apartament"
    switch ($apartament->TipProprietate) {
        case 0:
            $ofertaxml .= "apartament";
            break;
        case 1:
            $ofertaxml .= "apartament";
            break;
        case 2:
            $ofertaxml .= "casavila";
            break;
        case 3:
            $ofertaxml .= "teren";
            break;
        case 4:
            $ofertaxml .= "spatiu";
            break;
    }
    $ofertaxml .= '" versiune="3">
	<id2>' . $id . '</id2>' . ($inchiriere > 0 ? "<deinchiriat>1</deinchiriat>" : "<devanzare>1</devanzare>") . '
	<tara>1048</tara>
	<judet>10</judet>
	<localitate>13822</localitate>
	<zona>' . $subzona->idImobiliare . '</zona>
	<siteagentie>0</siteagentie>
	<portal>0</portal>';
    if ($apartament->TipProprietate < 2) {
        $ofertaxml .= '<tiplocuinta>' . ($apartament->NumarCamere > 1 ? "110" : "111") . '</tiplocuinta>';
    }
    if ($apartament->TipProprietate == 4) {
        switch ($apartament->TipSpatiu) {
            case "birouri":
                $ofertaxml .= '<tipspatiu>419</tipspatiu>';
                break;
            case "comercial":
                $ofertaxml .= '<tipspatiu>420</tipspatiu>';
                break;
            case "industrial":
                $ofertaxml .= '<tipspatiu>421</tipspatiu>';
                break;
            case "hotel":
                $ofertaxml .= '<tipspatiu>422</tipspatiu>';
                break;
            default:
                $ofertaxml .= '<tipspatiu>420</tipspatiu>';
        }
    }
    if ($apartament->TipProprietate < 3) {
        $ofertaxml .= '<nrcamere>' . $apartament->NumarCamere . '</nrcamere>';
    }
    if (strpos("013", $apartament->TipProprietate) !== false) {
        $ofertaxml .= '<etaj>' . ($apartament->Etaj + 45) . '</etaj>';
    }
    $ofertaxml .= '<longitudine>' . $apartament->Lng . '</longitudine>
	<latitudine>' . $apartament->Lat . '</latitudine>
	<altitudine>200</altitudine>';
    if ($apartament->SuprafataConstruita > 0) {
        $ofertaxml .= "<suprafataconstruita>{$apartament->SuprafataConstruita}</suprafataconstruita>";
    }
    if (!($inchiriere > 0)) {
        $ofertaxml .= "<pretvanzare>" . ($oferta->Pret + 0) . "</pretvanzare>";
        $ofertaxml .= "<monedavanzare>{$moneda[$oferta->Moneda]}</monedavanzare>";
    } else {
        $ofertaxml .= "<pretinchiriere>{$oferta->PretChirie}</pretinchiriere>";
        $ofertaxml .= "<monedainchiriere>{$moneda[$oferta->Moneda]}</monedainchiriere>";
    }
    if ($oferta->ComisionCumparatorZero == '1') {
        $ofertaxml .= "<comisionzero>1</comisionzero>";
    } else {
        $ofertaxml .= "<comisionzero>2</comisionzero>";
        $ofertaxml .= "<comisioncumparator><lang id=\"1048\">" . base64_encode($oferta->ComisionClient) . "</lang></comisioncumparator>";
    }
    if ($apartament->TipProprietate != 3) {
        // fara terenuri
        $ofertaxml .= "<suprafatautila>{$apartament->SuprafataUtila}</suprafatautila>";
        $ofertaxml .= "<anconstructie>{$apartament->AnConstructie}</anconstructie>";
        $ofertaxml .= "<nrgaraje>{$apartament->NumarGaraje}</nrgaraje>";
    }
    if ($apartament->TipProprietate < 3) {
        // apartamente si case
        $ofertaxml .= "<regimhotelier>0</regimhotelier>";
        $ofertaxml .= "<nrnivele>{$apartament->EtajeBloc}</nrnivele>";
        $ofertaxml .= "<nrbai>{$apartament->NrGrupuriSanitare}</nrbai>";
        $ofertaxml .= "<nrbalcoane>{$apartament->NumarBalcoane}</nrbalcoane>";
        $ofertaxml .= "<nrbucatarii>{$apartament->NumarBucatarii}</nrbucatarii>";
        $ofertaxml .= "<nrlocuriparcare>{$apartament->NumarParcari}</nrlocuriparcare>";
    }
    if ($apartament->TipProprietate < 4) {
        // fara spatii
        $tmp = "";
        if (are_dotarea("birouri", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, 468, 456, "", "");
        }
        if (are_dotarea("rezidential", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, 466, 454, 471, "");
        }
        if (are_dotarea("comercial", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, 467, 455, 473, "");
        }
        if (are_dotarea("agricol", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, "", "", 472, "");
        }
        if (are_dotarea("industrial", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, "", "", 474, "");
        }
        $ofertaxml .= "<destinatie>{$tmp}</destinatie>";
    }
    if ($apartament->TipProprietate < 2) {
        // doar apartamente
        $ofertaxml .= '<tipcompartimentare>' . $compartimentare[$apartament->TipApartament] . '</tipcompartimentare>';
        $ofertaxml .= "<tipimobil>" . (121 + $apartament->TipProprietate) . "</tipimobil>";
        $ofertaxml .= "<confort>" . ($apartament->Confort + 36) . "</confort>";
        $ofertaxml .= "<dotari>" . dotari("Mobilier,Electrocasnice,Contorizare,Spatii utile,Dotari Imobil", $apartament->id) . "</dotari>";
        $ofertaxml .= "<finisaje>" . dotari("Finisaje / Dotari", $apartament->id) . (are_dotarea("renovat", $apartament->id) ? "24 " : "") . (are_dotarea("stare buna", $apartament->id) ? "5 " : "") . (are_dotarea("curat", $apartament->id) ? "5 " : "") . (are_dotarea("necesita renovare", $apartament->id) ? "99 " : "") . "</finisaje>";
        $ofertaxml .= "<utilitati>" . dotari("Utilitati,Sistem de incalzire", $apartament->id) . (are_dotarea("aer conditionat", $apartament->id) ? "44 " : "") . "</utilitati>";
        $ofertaxml .= "<altedetaliizona>47,67,75</altedetaliizona>";
    }
    if ($apartament->TipProprietate == 2) {
        // doar case
        $ofertaxml .= "<frontstradal>{$apartament->Deschidere}</frontstradal>";
        $ofertaxml .= "<suprafatateren>{$apartament->SuprafataCurte}</suprafatateren>";
        $ofertaxml .= "<nrterase>{$apartament->NumarTerase}</nrterase>";
        $ofertaxml .= "<demisol>" . ($apartament->Demisol + 0) . "</demisol>";
        $ofertaxml .= "<subsol>" . ($apartament->Subsol + 0) . "</subsol>";
        $ofertaxml .= "<mansarda>" . ($apartament->Mansarda + 0) . "</mansarda>";
        $ofertaxml .= "<nrfronturi>" . $apartament->NumarDeschideri . "</nrfronturi>";
        $ofertaxml .= "<destinatie>" . dotari("Destinatie", $apartament->id) . "</destinatie>";
    }
    if ($apartament->TipProprietate == 3) {
        // doar terenuri
        $ofertaxml .= "<suprafatateren>{$apartament->SuprafataUtila}</suprafatateren>";
        $ofertaxml .= "<frontstradal>{$apartament->Deschidere}</frontstradal>";
        $ofertaxml .= "<umsuprafatateren>382</umsuprafatateren>";
        switch ($apartament->Clasificare) {
            case "intravilan":
                $ofertaxml .= "<clasificareteren>373</clasificareteren>";
                break;
            case "extravilan":
                $ofertaxml .= "<clasificareteren>374</clasificareteren>";
                break;
            default:
                $ofertaxml .= "<clasificareteren>373</clasificareteren>";
                break;
        }
        switch ($apartament->TipTeren) {
            case "constructii":
                $ofertaxml .= "<tipteren>375</tipteren>";
                break;
            case "agricol":
                $ofertaxml .= "<tipteren>376</tipteren>";
                break;
            case "padure":
                $ofertaxml .= "<tipteren>377</tipteren>";
                break;
            default:
                $ofertaxml .= "<tipteren>375</tipteren>";
                break;
        }
        $ofertaxml .= "<nrfronturistradale>{$apartament->NumarDeschideri}</nrfronturistradale>";
        $ofertaxml .= "<inclinatieteren>{$apartament->Inclinatie}</inclinatieteren>";
        $ofertaxml .= "<latimedrumacces>{$apartament->LatimeDrumAcces}</latimedrumacces>";
        $ofertaxml .= "<suprafataconstruita>{$apartament->SuprafataConstruita}</suprafataconstruita>";
        $ofertaxml .= "<constructiepeteren>" . ($apartament->ConstructiePeTeren + 0) . "</constructiepeteren>";
    }
    if ($apartament->TipProprietate == 4) {
        // doar spatii
        $ofertaxml .= "<nrincaperi>{$apartament->NumarCamere}</nrincaperi>";
        $ofertaxml .= "<nrgrupurisanitare>{$apartament->NrGrupuriSanitare}</nrgrupurisanitare>";
        $ofertaxml .= "<destinatierecomandata>" . base64_encode(dotari("Destinatie", $apartament->id)) . "</destinatierecomandata>";
        switch ($apartament->ClasaBirouri) {
            case "A":
                $ofertaxml .= '<clasabirouri>554</clasabirouri>';
                break;
            case "B":
                $ofertaxml .= '<clasabirouri>555</clasabirouri>';
                break;
            case "C":
                $ofertaxml .= '<clasabirouri>556</clasabirouri>';
                break;
            default:
                $ofertaxml .= '<clasabirouri></clasabirouri>';
        }
    }
    $ofertaxml .= "<agent>{$agent->id}</agent>";
    $tmp = "";
    if (are_dotarea("nou / finalizat", $apartament->id) || are_dotarea("stare buna", $apartament->id) || are_dotarea("necesita renovare", $apartament->id) || are_dotarea("reabilitat termic", $apartament->id)) {
        if ($apartament->TipProprietate < 2) {
            $tmp = "127";
        }
        if ($apartament->TipProprietate == 2) {
            $tmp = "362";
        }
        if ($apartament->TipProprietate == 4) {
            $tmp = "551";
        }
    }
    if (are_dotarea("nou / nefinalizat", $apartament->id)) {
        if ($apartament->TipProprietate < 2) {
            $tmp = "129";
        }
        if ($apartament->TipProprietate == 2) {
            $tmp = "364";
        }
        if ($apartament->TipProprietate == 4) {
            $tmp = "552";
        }
    }
    if ($tmp != "") {
        $ofertaxml .= "<stadiuconstructie>{$tmp}</stadiuconstructie>";
    }
    $tmp = "";
    if (are_dotarea("beton", $apartament->id)) {
        $tmp = corespondent($apartament->TipProprietate, 136, 368, "", 432);
    }
    if (are_dotarea("caramida", $apartament->id)) {
        $tmp = corespondent($apartament->TipProprietate, 137, 366, "", 430);
    }
    if (are_dotarea("bca", $apartament->id)) {
        $tmp = corespondent($apartament->TipProprietate, 138, 367, "", 431);
    }
    if (are_dotarea("lemn", $apartament->id)) {
        $tmp = corespondent($apartament->TipProprietate, 139, 369, "", 433);
    }
    if (are_dotarea("metal", $apartament->id)) {
        $tmp = corespondent($apartament->TipProprietate, 140, 370, "", 435);
    }
    if ($tmp != "") {
        $ofertaxml .= "<structurarezistenta>{$tmp}</structurarezistenta>";
    }
    $ofertaxml .= "<vecinatati><lang id=\"1048\">" . base64_encode(dotari("Vecinatati", $apartament->id)) . "</lang></vecinatati>";
    $ofertaxml .= "<descriere><lang id=\"1048\">" . base64_encode($apartament->Detalii) . "</lang></descriere>";
    $ofertaxml .= "<sector>{$apartament->Sector}</sector>";
    $ofertaxml .= "<alias>SP" . str_pad($oferta->id, 5, "0", STR_PAD_LEFT) . "</alias>";
    if ($oferta->Negociabil > 0) {
        $ofertaxml .= "<pretnegociabil>1</pretnegociabil>";
    }
    if ($oferta->Exclusivitate > 0) {
        $ofertaxml .= "<exclusivitate>1</exclusivitate>";
    }
    if ($oferta->OfertaWeb > 0) {
        $ofertaxml .= "<linkextern>http://www.simsparkman.ro/detaliioferta.php?id={$oferta->id}</linkextern>";
    }
    // inca nu au fost reanalizate
    // ?? nu mai e inm baza $ofertaxml.="<servicii>".dotari("Servicii???",$apartament->id)."</servicii>";
    //$ofertaxml.="<altedetaliizona>67,302,303</altedetaliizona>";
    $sql = "SELECT COUNT(*) FROM Foto WHERE idApartament={$apartament->id}";
    $nrimagini = Foto::count_by_sql($sql);
    if ($nrimagini > 0) {
        $ofertaxml .= "<imagini nrimagini=\"{$nrimagini}\">";
        $fotoList = Foto::find_by_sql("SELECT * FROM Foto WHERE idApartament={$apartament->id}");
        foreach ($fotoList as $foto) {
            $ofertaxml .= "<imagine dummy=\"False\" modificata=\"1228840157\" latime=\"800\" inaltime=\"600\" pozitie=\"{$foto->Ordin}\">";
            $ofertaxml .= "<descriere>" . base64_encode($foto->Detalii) . "</descriere>";
            $ofertaxml .= "<blob>";
            $ofertaxml .= base64_encode(file_get_contents(".." . DS . $foto->image_path()));
            $ofertaxml .= "</blob>";
            $ofertaxml .= "</imagine>";
        }
        $ofertaxml .= "</imagini>";
    }
    //echo $ofertaxml;
    if ($oferta->ExportImobiliare < 3 && $oferta->Stare == 'de actualitate') {
        if ($oferta->ExportImobiliare = 1) {
            $operatie = "MOD";
            $ofertaxml .= "<datamodificare>" . time() . "</datamodificare>";
        } else {
            $operatie = "ADD";
            $ofertaxml .= "<dataadaugare>" . time() . "</dataadaugare>";
        }
    } else {
        $operatie = "DEL";
    }
    $ofertaxml .= '</oferta>';
    echo $ofertaxml;
    // publica oferta
    $ok = 1;
    switch ($apartament->TipProprietate) {
        case 0:
            $oftip = 0;
            break;
        case 1:
            $oftip = 0;
            break;
        case 2:
            $oftip = 1;
            break;
        case 3:
            $oftip = 3;
            break;
        case 4:
            $oftip = 4;
            break;
    }
    try {
        $result = $s->__soapCall('publica_oferta', array('publica_oferta' => array('id_str' => $oftip . ':' . $id, 'sid' => $session_id, 'operatie' => $operatie, 'ofertaxml' => $ofertaxml)));
    } catch (Exception $e) {
        $ok = 0;
        die('Eroare Publicare oferta: ' . $e->getMessage());
    }
    if (isset($result->mesaj)) {
        $idImobiliare = array_pop(explode(" ", $result->mesaj));
    }
    echo '<pre>PUBLICARE OFERTA: ' . print_r($result, true) . '</pre>';
}
Esempio n. 3
0
function posteazaAnunt($inchiriere = 0)
{
    global $oferta;
    global $apartament;
    global $client;
    global $agent;
    global $subzona;
    global $strada;
    global $fotografii;
    global $request;
    $id = $oferta->id;
    $data["key"] = "2HVO01c20rHj0lB60jI50dwB";
    $data["tip_oferta"] = $inchiriere == 0 ? "vanzare" : "inchiriere";
    switch ($apartament->TipProprietate) {
        case 0:
            $data["categorie_imobil"] = $apartament->NumarCamere > 1 ? "apartament" : "garsoniera";
        case 1:
            $data["categorie_imobil"] = $apartament->NumarCamere > 1 ? "apartament" : "garsoniera";
        case 2:
            $data["categorie_imobil"] = "casa";
        case 3:
            $data["categorie_imobil"] = "teren";
        case 4:
            $data["categorie_imobil"] = "spatiu";
    }
    setAtribut($data, "zone_id", $subzona->idMC);
    setAtribut($data, "orase_id", 1);
    setAtribut($data, "strada_imobil", $subzona->Denumire);
    //setAtribut($data, "numar_strada", $apartament->Numar);
    setAtribut($data, "camere_imobil", $apartament->NumarCamere);
    setAtribut($data, "bai_imobil", $apartament->NrGrupuriSanitare, "N");
    setAtribut($data, "suprafata_imobil", $apartament->SuprafataConstruita > 0 ? $apartament->SuprafataConstruita : $apartament->SuprafataUtila, "N");
    setAtribut($data, "pret_imobil", $inchiriere ? $oferta->PretChirie : $oferta->Pret);
    setAtribut($data, "pret_tva", "cu_tva");
    setAtribut($data, "pret_negociabil", 1);
    setAtribut($data, "afiseaza_pmp", 1);
    if (are_dotarea("centrala de bloc", $apartament->id)) {
        setAtribut($data, "incalzire_imobil", "centrala_bloc");
    }
    if (are_dotarea("termoficare", $apartament->id)) {
        setAtribut($data, "incalzire_imobil", "centrala_zona");
    }
    if (are_dotarea("centrala de apartament", $apartament->id)) {
        setAtribut($data, "incalzire_imobil", "centrala_proprie");
    }
    if (are_dotarea("incalzire cu sobe", $apartament->id)) {
        setAtribut($data, "incalzire_imobil", "soba");
    }
    if (are_dotarea("garaj", $apartament->id)) {
        setAtribut($data, "parcare_imobil", "garaj");
    }
    if (are_dotarea("parcare subterana", $apartament->id) || are_dotarea("parcare inchiriata", $apartament->id) || are_dotarea("parcare proprie", $apartament->id)) {
        setAtribut($data, "parcare_imobil", "privata");
    }
    setAtribut($data, "etaj_imobil", $apartament->Etaj > 0 ? $apartament->Etaj : "P");
    setAtribut($data, "etajDin_imobil", "P+" . $apartament->EtajeBloc);
    setAtribut($data, "an_constructie_imobil", $apartament->AnConstructie, "N");
    // -----
    setAtribut($data, "terase_balcoane", $apartament->NumarBalcoane, "N");
    setAtribut($data, "compartimentare", $apartament->TipApartament != "Circular" ? strtolower($apartament->TipApartament) : "semidecomandat");
    if (are_dotarea("termopan", $apartament->id)) {
        $data["pvc_termopan_tamplarie"] = 1;
    }
    if (are_dotarea("gresie", $apartament->id)) {
        $data["imbunatatiri_gresie"] = 1;
    }
    if (are_dotarea("faianta", $apartament->id)) {
        $data["imbunatatiri_faianta"] = 1;
    }
    if (are_dotarea("parchet", $apartament->id)) {
        $data["imbunatatiri_parchet"] = 1;
    }
    // -----
    // 	$anunt="Confort ".$apartament->Confort.", ".strtolower($apartament->TipApartament);
    // 	$anunt.=scrieDotari("Mobilier", $apartament->id);
    // 	$anunt.=scrieDotari("Electrocasnice", $apartament->id);
    // 	$anunt.=scrieDotari("Finisaje / Dotari", $apartament->id);
    // 	$anunt.=scrieDotari("Contorizare", $apartament->id);
    // 	$anunt.=scrieDotari("Spatii utile", $apartament->id);
    // 	$anunt.=scrieDotari("Dotari Imobil", $apartament->id);
    // 	$anunt.=scrieDotari("Utilitati", $apartament->id);
    // 	$tmp=scrieDotari("Vedere", $apartament->id);
    // 	if ($tmp!="") $anunt.="; Vedere: ".substr($tmp, 2, strlen($tmp));
    // 	$tmp=scrieDotari("Vecinatati", $apartament->id);
    // 	if ($tmp!="") $anunt.="; Vecinatati: ".substr($tmp, 2, strlen($tmp));
    $anunt = $apartament->Detalii;
    $anunt .= " Cod oferta SP" . str_pad($id, 5, "0", STR_PAD_LEFT);
    setAtribut($data, "info_imobil", $anunt);
    setAtribut($data, "Ylat", $apartament->Lat);
    setAtribut($data, "Ylong", $apartament->Lng);
    // ------
    setAtribut($data, "telefon_proprietar", substr($client->TelefonMobil, -5));
    setAtribut($data, "email", $agent->Email);
    setAtribut($data, "id_intern", "SP" . ($inchiriere ? "1" : "0") . str_pad($id, 4, "0", STR_PAD_LEFT));
    $request->flush();
    $request->setVerb($oferta->ExportMC == 1 ? "post" : "put");
    $request->setPath("/imobile.json");
    $request->buildPostBody($data);
    //print_r($data);
    $request->execute();
    $response = $request->getResponseBody();
    //return false;
    //$request->setPath('/imobile.json');
    //$request->setVerb('post');
    //$request->buildPostBody($data);
    //$request->execute();
    //$response = $request->getResponseBody();
    //print_r($data);
    //echo "<br/>";
    //print_r($response);
    //return false;
    echo "Sincronizare " . $data["id_intern"] . ": ";
    if (!valid_code($response->code)) {
        echo "eroare sincronizare: ";
        print_r($response);
        echo "<br />";
        return false;
    } else {
        echo "succes<br/>";
    }
    $responseData = $response->data;
    $oferta->idMC = $responseData->id;
    foreach ($fotografii as $foto) {
        $request->flush();
        $request->setVerb("post");
        $request->setPath("/poze.json");
        $pozaData["key"] = "2HVO01c20rHj0lB60jI50dwB";
        $pozaData["id_intern"] = "SP" . ($inchiriere ? "1" : "0") . str_pad($id, 4, "0", STR_PAD_LEFT);
        $pozaData["url"] = "http://igor.lanconect.ro/Imob2009/images/{$foto->NumeFisier}";
        $request->buildPostBody($pozaData);
        //print_r($pozaData);
        $request->execute();
        $response = $request->getResponseBody();
        if (!valid_code($response->code)) {
            echo "<br />";
            echo "Eroare sincronizare poza: " . $data["id_intern"] . " - " . $foto->id . ": ";
            print_r($response);
            //return false;
        }
    }
    return true;
}
Esempio n. 4
0
 function __construct(Apartament $apartment, Oferta $oferta, Subzona $subzona, Cartier $cartier, Zona $oras)
 {
     $this->DATA_APARITIE = $apartment->DataIntrare;
     $this->ORAS = $oras->Denumire;
     switch ($apartment->TipApartament) {
         case "Decomandat":
             $this->A_IMPARTIRE = 1;
             break;
         case "Semidecomandat":
             $this->A_IMPARTIRE = 2;
             break;
         case "Comandat":
             $this->A_IMPARTIRE = 3;
             break;
         case "Circular":
             $this->A_IMPARTIRE = 3;
             break;
         default:
             $this->A_IMPARTIRE = 1;
             break;
     }
     $this->B_CLASA = $apartment->ClasaBirouri;
     $this->DATA_MODIFICARE = $oferta->DataActualizare;
     $this->GEO_LAT = $apartment->Lat;
     $this->GEO_LONG = $apartment->Lng;
     $this->DESCHIDERE = $apartment->Deschidere;
     $this->SUPR_CONSTR = $apartment->SuprafataConstruita;
     switch ($apartment->TipProprietate) {
         case 2:
             $this->SUPR_TEREN = $apartment->SuprafataCurte;
             break;
         case 3:
             $this->SUPR_TEREN = $apartment->SuprafataUtila;
             break;
     }
     $this->SUPR_UTILA = $apartment->SuprafataUtila;
     $this->T_I_PRET = $oferta->PretChirie;
     $this->T_POT = $apartment->POT;
     $this->T_RI = "";
     //??????
     $this->T_V_PRET = $oferta->Pret;
     $this->AGENTIA = "1173";
     $this->C_MANSARDA = $apartment->Mansarda;
     $this->C_PIVNITA = $apartment->Subsol;
     $this->ID_LOCAL = $oferta->id;
     $this->MOBILAT = "";
     if (are_dotarea("semimobilat", $apartment->id)) {
         $this->MOBILAT = 2;
     } else {
         if (are_dotarea("nemobilat", $apartment->id)) {
             $this->MOBILAT = 3;
         } else {
             if (are_dotarea("mobilat clasic", $apartment->id) || are_dotarea("mobilat modern", $apartment->id) || are_dotarea("bucatarie mobilata", $apartment->id)) {
                 $this->MOBILAT = 1;
             }
         }
     }
     $this->NR_GR_SANITARE = "";
     $this->NRDORMITOARE = $apartment->NumarCamere - 1;
     $this->STARE_IMOBIL = 2;
     if (are_dotarea("nou / finalizat", $apartment->id)) {
         $this->STARE_IMOBIL = 1;
     }
     if (are_dotarea("necesita renovare", $apartment->id)) {
         $this->STARE_IMOBIL = 3;
     }
     $this->T_D_APA = 1;
     $this->T_D_CANALIZARE = 1;
     $this->T_D_CURENT = 1;
     $this->T_D_GAZE = 1;
     $this->T_EXTRAVILAN = $apartment->Clasificare == "extravilan" ? 1 : 0;
     $this->T_INTRAVILAN = $apartment->Clasificare == "intravilan" ? 1 : 0;
     $finisaje = array("parchet" => "parchet", "mocheta" => "mocheta", "gresie" => "gresie", "huma" => "huma", "tapet" => "tapet", "faianta" => "faianta", "termopan" => "geamuri termopan");
     $this->FINISAJE = "";
     foreach ($finisaje as $key => $finisaj) {
         if (are_dotarea($key, $apartment->id)) {
             $this->FINISAJE .= $finisaj . ",";
         }
     }
     if ($this->FINISAJE != "") {
         $this->FINISAJE = substr($this->FINISAJE, 0, -1);
     }
     $dotari = array("aer conditionat" => "aer conditionat", "alarma" => "sistem de alarma", "interfon" => "interfon", "usa metalica" => "usa metalica", "lift" => "lift", "masina de spalat rufe" => "masina de spalat");
     $this->DOTARI = "";
     foreach ($dotari as $key => $dotare) {
         if (are_dotarea($key, $apartment->id)) {
             $this->DOTARI .= $dotare . ",";
         }
     }
     if ($this->DOTARI != "") {
         $this->DOTARI = substr($this->DOTARI, 0, -1);
     }
     //if ( $session->user_id==1) {
     //print_r($this);
     //}
     $this->DESTINATII_TEXT = $apartment->Destinatie;
     $this->DETALII = "";
     //?????
     $this->OBSERVATII = $apartment->Detalii;
     $this->REPER = $apartment->PunctReper;
     $this->VECINATATI = "";
     $vecinatatiArr = array("gradinita" => "gradinita", "lac" => "lac", "liceu" => "scoala", "magazine" => "magazine", "metrou" => "transport in comun", "parc" => "parc", "scoala" => "scoala");
     foreach ($vecinatatiArr as $key => $dotare) {
         if (are_dotarea($key, $apartment->id)) {
             $this->VECINATATI .= $dotare . ",";
         }
     }
     if ($this->VECINATATI != "") {
         $this->VECINATATI = substr($this->VECINATATI, 0, -1);
     }
     $this->NR_BALCOANE = $apartment->NumarBalcoane;
     $this->ETAJ = $apartment->Etaj;
     $this->NRCAM = $apartment->NumarCamere;
     $this->NRETAJE = $apartment->TipProprietate == 2 ? $apartment->Etaje : $apartment->EtajeBloc;
     $this->NR_BAI = $apartment->NrGrupuriSanitare;
     $this->T_I_TRANZ = $oferta->Inchiriere;
     $this->T_V_TRANZ = $oferta->Vanzare;
     //echo $apartment->TipProprietate." ".$apartment->TipSpatiu.PHP_EOL;
     switch ($apartment->TipProprietate) {
         case 0:
             $this->TIP_IMOBIL_REAL = 1;
             break;
         case 1:
             $this->TIP_IMOBIL_REAL = 1;
             break;
         case 2:
             $this->TIP_IMOBIL_REAL = 3;
             break;
         case 3:
             $this->TIP_IMOBIL_REAL = 7;
             break;
         case 4:
             if ($apartment->TipSpatiu == "birouri") {
                 $this->TIP_IMOBIL_REAL = 2;
             }
             if ($apartment->TipSpatiu == "comercial") {
                 $this->TIP_IMOBIL_REAL = 5;
             }
             if ($apartment->TipSpatiu == "industrial") {
                 $this->TIP_IMOBIL_REAL = 6;
             }
             if ($apartment->TipSpatiu == "hotel") {
                 $this->TIP_IMOBIL_REAL = 5;
             }
             break;
         default:
             $this->TIP_IMOBIL_REAL = 1;
     }
     $this->AGENT_ID = $oferta->IdAgentVanzare;
     $this->JUDET = 1;
     $this->T_I_MONEDA = $oferta->Moneda;
     $this->T_V_MONEDA = $oferta->Moneda;
     $this->AN_CONSTRUCTIE = $apartment->AnConstructie;
     $this->AMPLASAMENT = "";
     $this->ZONA = $subzona->idImopedia;
     $this->idApartament = $apartment->id;
 }
Esempio n. 5
0
function posteazaAnunt($inchiriere = 0)
{
    global $oferta;
    global $apartament;
    global $client;
    global $agent;
    global $subzona;
    global $fotografii;
    global $s;
    global $session_id;
    global $idImobiliare;
    global $ok;
    $id = $oferta->id;
    if ($inchiriere) {
        $id += 90000;
    }
    $compartimentare = array("Decomandat" => 26, "Semidecomandat" => 27, "Circular" => 29, "Comandat" => 28, "Duplex" => 26);
    $moneda = array("EUR" => 172, "RON" => 173, "LEI" => 173, "USD" => 174);
    $ofertaxml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
	<oferta tip="apartament" versiune="2">
	<id2>' . $id . '</id2>' . ($inchiriere > 0 ? "<deinchiriat>1</deinchiriat>" : "<devanzare>1</devanzare>") . '
	<tara>1048</tara>
	<judet>10</judet>
	<localitate>13822</localitate>
	<zona>' . $subzona->idImobiliare . '</zona>
	<nrcamere>' . $apartament->NumarCamere . '</nrcamere>
	<tiplocuinta>' . ($apartament->NumarCamere > 1 ? "110" : "111") . '</tiplocuinta>
	<tipcompartimentare>' . $compartimentare[$apartament->TipApartament] . '</tipcompartimentare>
	<etaj>' . ($apartament->Etaj + 45) . '</etaj>
	<tipimobil>121</tipimobil>
	<longitudine>' . $apartament->Lng . '</longitudine>
	<latitudine>' . $apartament->Lat . '</latitudine>
	<altitudine>200</altitudine>';
    if ($apartament->SuprafataUtila > 0) {
        $ofertaxml .= "<suprafatautila>{$apartament->SuprafataUtila}</suprafatautila>";
    }
    if ($apartament->SuprafataConstruita > 0) {
        $ofertaxml .= "<suprafataconstruita>{$apartament->SuprafataConstruita}</suprafataconstruita>";
    }
    if ($oferta->Titlu != "") {
        $ofertaxml .= "<titlu><lang id=\"1048\">" . base64_encode($oferta->Titlu) . "</lang></titlu>";
    }
    if (!($inchiriere > 0)) {
        $ofertaxml .= "<pretvanzare>" . ($oferta->Pret + 0) . "</pretvanzare>";
        $ofertaxml .= "<monedavanzare>{$moneda[$oferta->Moneda]}</monedavanzare>";
    } else {
        $ofertaxml .= "<pretinchiriere>{$oferta->PretChirie}</pretinchiriere>";
        $ofertaxml .= "<monedainchiriere>{$moneda[$oferta->Moneda]}</monedainchiriere>";
    }
    $ofertaxml .= "<comisioncumparator><lang id=\"1048\">" . base64_encode($oferta->ComisionClient) . "</lang></comisioncumparator>";
    $ofertaxml .= "<confort>" . ($apartament->Confort + 36) . "</confort>\n\t<anconstructie>{$apartament->AnConstructie}</anconstructie>\n\t<nrnivele>{$apartament->EtajeBloc}</nrnivele>\n\t<nrbai>{$apartament->NrGrupuriSanitare}</nrbai>\n\t<nrbalcoane>{$apartament->NumarBalcoane}</nrbalcoane>\n\t<nrbucatarii>1</nrbucatarii>\n\t<nrgaraje>" . (are_dotarea("parcare subterana", $apartament->id) + are_dotarea("garaj", $apartament->id)) . "</nrgaraje>\n\t<nrlocuriparcare>" . (are_dotarea("parcare inchiriata", $apartament->id) + are_dotarea("parcare proprie", $apartament->id)) . "</nrlocuriparcare>\n\t<agent>{$agent->id}</agent>";
    $tmp = "";
    if (are_dotarea("nou / finalizat", $apartament->id)) {
        $tmp = "127";
    }
    if (are_dotarea("stare buna", $apartament->id)) {
        $tmp = "127";
    }
    if (are_dotarea("necesita renovare", $apartament->id)) {
        $tmp = "127";
    }
    if (are_dotarea("reabilitat termic", $apartament->id)) {
        $tmp = "127";
    }
    if (are_dotarea("nou / nefinalizat", $apartament->id)) {
        $tmp = "129";
    }
    if ($tmp != "") {
        $ofertaxml .= "<stadiuconstructie>{$tmp}</stadiuconstructie>";
    }
    $tmp = "";
    if (are_dotarea("beton", $apartament->id)) {
        $tmp = "136";
    }
    if (are_dotarea("caramida", $apartament->id)) {
        $tmp = "137";
    }
    if (are_dotarea("bca", $apartament->id)) {
        $tmp = "138";
    }
    if (are_dotarea("lemn", $apartament->id)) {
        $tmp = "139";
    }
    if (are_dotarea("metal", $apartament->id)) {
        $tmp = "140";
    }
    if ($tmp != "") {
        $ofertaxml .= "<structurarezistenta>{$tmp}</structurarezistenta>";
    }
    // destinatie
    $ofertaxml .= "<destinatie>" . dotari("Destinatie", $apartament->id) . "</destinatie>\n";
    $ofertaxml .= "<dotari>" . dotari("Mobilier,Electrocasnice,Contorizare,Spatii utile,Dotari Imobil", $apartament->id) . "</dotari>\n";
    $ofertaxml .= "<finisaje>" . dotari("Finisaje / Dotari", $apartament->id) . (are_dotarea("renovat", $apartament->id) ? "24 " : "") . (are_dotarea("stare buna", $apartament->id) ? "5 " : "") . (are_dotarea("curat", $apartament->id) ? "5 " : "") . (are_dotarea("necesita renovare", $apartament->id) ? "99 " : "") . "</finisaje>\n";
    $ofertaxml .= "<utilitati>" . dotari("Utilitati,Sistem de incalzire", $apartament->id) . (are_dotarea("aer conditionat", $apartament->id) ? "44 " : "") . "</utilitati>\n";
    $ofertaxml .= "<vecinatati><lang id=\"1048\">" . base64_encode(dotari("Vecinatati", $apartament->id)) . "</lang></vecinatati>\n";
    $ofertaxml .= "<servicii>" . dotari("Servicii???", $apartament->id) . "</servicii>\n";
    $ofertaxml .= "<descriere><lang id=\"1048\">" . base64_encode($apartament->Detalii) . "</lang></descriere>";
    $ofertaxml .= "<altedetaliizona>67,302,303</altedetaliizona>";
    $ofertaxml .= "<sector>{$apartament->Sector}</sector>";
    $ofertaxml .= "<alias>SP" . str_pad($oferta->id, 5, "0", STR_PAD_LEFT) . "</alias>";
    if ($oferta->Negociabil > 0) {
        $ofertaxml .= "<pretnegociabil>1</pretnegociabil>";
    }
    if ($oferta->Exclusivitate > 0) {
        $ofertaxml .= "<exclusivitate>1</exclusivitate>";
    }
    if ($oferta->OfertaWeb > 0) {
        $ofertaxml .= "<linkextern>http://www.simsparkman.ro/detaliioferta.php?id={$oferta->id}</linkextern>";
    }
    $sql = "SELECT COUNT(*) FROM Foto WHERE idApartament={$apartament->id}";
    $nrimagini = Foto::count_by_sql($sql);
    if ($nrimagini > 0) {
        $ofertaxml .= "<imagini nrimagini=\"{$nrimagini}\">";
        $fotoList = Foto::find_by_sql("SELECT * FROM Foto WHERE idApartament={$apartament->id}");
        foreach ($fotoList as $foto) {
            $ofertaxml .= "<imagine dummy=\"False\" modificata=\"1228840157\" latime=\"800\" inaltime=\"600\" pozitie=\"{$foto->Ordin}\">";
            $ofertaxml .= "<descriere>" . base64_encode($foto->Detalii) . "</descriere>";
            $ofertaxml .= "<blob>";
            $ofertaxml .= base64_encode(file_get_contents(".." . DS . $foto->image_path()));
            $ofertaxml .= "</blob>";
            $ofertaxml .= "</imagine>";
        }
        $ofertaxml .= "</imagini>\n";
    }
    //echo $ofertaxml;
    if ($oferta->ExportImobiliare < 3 && $oferta->Stare == 'de actualitate') {
        if ($oferta->ExportImobiliare = 1) {
            $operatie = "MOD";
            $ofertaxml .= "<datamodificare>" . time() . "</datamodificare>";
        } else {
            $operatie = "ADD";
            $ofertaxml .= "<dataadaugare>" . time() . "</dataadaugare>";
        }
    } else {
        $operatie = "DEL";
    }
    $ofertaxml .= '</oferta>';
    //echo $ofertaxml;
    // publica oferta
    $ok = 1;
    try {
        $result = $s->__soapCall('publica_oferta', array('publica_oferta' => array('id_str' => '0:' . $id, 'sid' => $session_id, 'operatie' => $operatie, 'ofertaxml' => $ofertaxml)));
    } catch (Exception $e) {
        $ok = 0;
        die('Eroare Publicare oferta: ' . $e->getMessage());
    }
    if (isset($result->mesaj)) {
        $idImobiliare = array_pop(explode(" ", $result->mesaj));
    }
    echo '<pre>PUBLICARE OFERTA: ' . print_r($result, true) . '</pre>';
}
function posteazaAnunt($inchiriere = 0)
{
    global $oferta;
    global $apartament;
    global $client;
    global $agent;
    global $subzona;
    global $fotografii;
    global $s;
    global $session_id;
    global $idImobiliare;
    global $ok;
    $id = $oferta->id;
    if ($inchiriere) {
        $id += 90000;
    }
    $compartimentare = array("Decomandat" => 26, "Semidecomandat" => 27, "Circular" => 29, "Comandat" => 28, "Duplex" => 26);
    $moneda = array("EUR" => 172, "RON" => 173, "LEI" => 173, "USD" => 174);
    $ofertaxml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
	<oferta tip="';
    //."apartament"
    switch ($apartament->TipProprietate) {
        case 0:
            $ofertaxml .= "apartament";
            break;
        case 1:
            $ofertaxml .= "apartament";
            break;
        case 2:
            $ofertaxml .= "casavila";
            break;
        case 3:
            $ofertaxml .= "teren";
            break;
        case 4:
            $ofertaxml .= "spatiu";
            break;
    }
    $ofertaxml .= '" versiune="3">
	<id2>' . $id . '</id2>' . ($inchiriere > 0 ? "<deinchiriat>1</deinchiriat>" : "<devanzare>1</devanzare>") . '
	<tara>1048</tara>
	<judet>10</judet>
	<localitate>13822</localitate>
	<zona>' . $subzona->idImobiliare . '</zona>
	<siteagentie>0</siteagentie>
	<portal>1</portal>';
    if ($apartament->TipProprietate < 2) {
        $ofertaxml .= '<tiplocuinta>' . ($apartament->NumarCamere > 1 ? "110" : "111") . '</tiplocuinta>';
    }
    if ($apartament->TipProprietate == 4) {
        switch ($apartament->TipSpatiu) {
            case "birouri":
                $ofertaxml .= '<tipspatiu>419</tipspatiu>';
                break;
            case "comercial":
                $ofertaxml .= '<tipspatiu>420</tipspatiu>';
                break;
            case "industrial":
                $ofertaxml .= '<tipspatiu>421</tipspatiu>';
                break;
            case "hotel":
                $ofertaxml .= '<tipspatiu>422</tipspatiu>';
                break;
            default:
                $ofertaxml .= '<tipspatiu>420</tipspatiu>';
        }
    }
    if ($apartament->TipProprietate < 3) {
        $ofertaxml .= '<nrcamere>' . $apartament->NumarCamere . '</nrcamere>';
    }
    if (strpos("013", $apartament->TipProprietate) !== false) {
        $ofertaxml .= '<etaj>' . ($apartament->Etaj + 45) . '</etaj>';
    }
    $ofertaxml .= '<longitudine>' . $apartament->Lng . '</longitudine>
	<latitudine>' . $apartament->Lat . '</latitudine>
	<altitudine>200</altitudine>';
    if ($apartament->SuprafataConstruita > 0) {
        $ofertaxml .= "<suprafataconstruita>{$apartament->SuprafataConstruita}</suprafataconstruita>";
    }
    if (!($inchiriere > 0)) {
        $ofertaxml .= "<pretvanzare>" . ($oferta->Pret + 0) . "</pretvanzare>";
        $ofertaxml .= "<monedavanzare>{$moneda[$oferta->Moneda]}</monedavanzare>";
    } else {
        $ofertaxml .= "<pretinchiriere>{$oferta->PretChirie}</pretinchiriere>";
        $ofertaxml .= "<monedainchiriere>{$moneda[$oferta->Moneda]}</monedainchiriere>";
    }
    if ($oferta->ComisionCumparatorZero == '1') {
        $ofertaxml .= "<comisionzero>1</comisionzero>";
    } else {
        $ofertaxml .= "<comisionzero>2</comisionzero>";
        $ofertaxml .= "<comisioncumparator><lang id=\"1048\">" . base64_encode($oferta->ComisionClient) . "</lang></comisioncumparator>";
    }
    // utilitati
    $tmp = "";
    $x = dotare_imobiliare("gaze", $apartament->id, $apartament->TipProprietate, "2", "123", "307", "357");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("curent", $apartament->id, $apartament->TipProprietate, "32", "98", "308", "352");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("apa curenta", $apartament->id, $apartament->TipProprietate, "90", "120", "305", "354");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("canalizare", $apartament->id, $apartament->TipProprietate, "91", "121", "306", "355");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("curent trifazic", $apartament->id, $apartament->TipProprietate, "", "111", "309", "353");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("termoficare", $apartament->id, $apartament->TipProprietate, "26", "170", "", "340");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("centrala bloc", $apartament->id, $apartament->TipProprietate, "27", "", "", "");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("centrala proprie", $apartament->id, $apartament->TipProprietate, "28", "171", "", "341");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("incalzire cu sobe", $apartament->id, $apartament->TipProprietate, "35", "172", "", "342");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("incalzire pardoseala", $apartament->id, $apartament->TipProprietate, "36", "174", "", "344");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("aer conditionat", $apartament->id, $apartament->TipProprietate, "44", "176", "", "346");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $tmp = substr($tmp, 0, -1);
    $ofertaxml .= "<utilitati>{$tmp}</utilitati>";
    //alte detalii zona
    $tmp = "";
    $x = dotare_imobiliare("asfaltate", $apartament->id, $apartament->TipProprietate, "67", "297", "321", "423");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("betonate", $apartament->id, $apartament->TipProprietate, "72", "299", "323", "425");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("neamenajate", $apartament->id, $apartament->TipProprietate, "74", "301", "325", "427");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("pietruite", $apartament->id, $apartament->TipProprietate, "71", "298", "322", "424");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $x = dotare_imobiliare("de pamant", $apartament->id, $apartament->TipProprietate, "73", "300", "324", "426");
    if ($x != "") {
        $tmp .= $x . " ";
    }
    $tmp = substr($tmp, 0, -1);
    $ofertaxml .= "<altedetaliizona>{$tmp}</altedetaliizona>";
    if ($apartament->TipProprietate != 3) {
        // fara terenuri
        $ofertaxml .= "<suprafatautila>{$apartament->SuprafataUtila}</suprafatautila>";
        $ofertaxml .= "<anconstructie>{$apartament->AnConstructie}</anconstructie>";
        $ofertaxml .= "<nrgaraje>{$apartament->NumarGaraje}</nrgaraje>";
        //dotari
        $tmp = "";
        $x = dotare_imobiliare("bucatarie mobilata", $apartament->id, $apartament->TipProprietate, "88", "233", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("mobilat clasic", $apartament->id, $apartament->TipProprietate, "81", "280", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("mobilat modern", $apartament->id, $apartament->TipProprietate, "82", "281", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("semimobilat", $apartament->id, $apartament->TipProprietate, "83", "282", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("nemobilat", $apartament->id, $apartament->TipProprietate, "481", "482", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("frigider", $apartament->id, $apartament->TipProprietate, "102", "270", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("cuptor cu microunde", $apartament->id, $apartament->TipProprietate, "103", "265", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("aragaz", $apartament->id, $apartament->TipProprietate, "104", "263", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("masina de spalat rufe", $apartament->id, $apartament->TipProprietate, "95", "273", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("masina de spalat vase", $apartament->id, $apartament->TipProprietate, "106", "274", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("televizor", $apartament->id, $apartament->TipProprietate, "112", "278", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("hota", $apartament->id, $apartament->TipProprietate, "105", "272", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("apometre", $apartament->id, $apartament->TipProprietate, "127", "238", "", "395");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("repartitoare", $apartament->id, $apartament->TipProprietate, "128", "239", "", "396");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("contor individual gaze", $apartament->id, $apartament->TipProprietate, "129", "240", "", "397");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("interfon", $apartament->id, $apartament->TipProprietate, "144", "255", "", "408");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("lift", $apartament->id, $apartament->TipProprietate, "145", "256", "", "409");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("uscatorie", $apartament->id, $apartament->TipProprietate, "148", "", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("boxa", $apartament->id, $apartament->TipProprietate, "153", "", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("debara", $apartament->id, $apartament->TipProprietate, "154", "", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("pivnita", $apartament->id, $apartament->TipProprietate, "", "225", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("spatiu depozitare", $apartament->id, $apartament->TipProprietate, "", "227", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("crama", $apartament->id, $apartament->TipProprietate, "", "226", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("anexe", $apartament->id, $apartament->TipProprietate, "", "230", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        if ($apartament->TipCurte != "") {
            $i = 0;
            if ($apartament->TipProprietate == 2) {
                $i = 110;
            }
            if ($apartament->TipCurte == "comuna") {
                $tmp .= 242 + $i . " ";
            } else {
                $tmp .= 241 + $i . " ";
            }
        }
        if ($apartament->TipProprietate < 2 && $apartament->NumarTerase > 0) {
            $tmp .= "151 ";
        }
        if ($apartament->TipProprietate < 2 && $apartament->NrGrupuriSanitare > 1) {
            $tmp .= "152 ";
        }
        if ($apartament->TipProprietate < 2 && $apartament->NrGrupuriSanitare > 1) {
            $tmp .= "229 ";
        }
        $tmp = substr($tmp, 0, -1);
        $ofertaxml .= "<dotari>{$tmp}</dotari>";
        // finisaje
        $tmp = "";
        $x = dotare_imobiliare("stare buna", $apartament->id, $apartament->TipProprietate, "5", "198", "", "381");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("curat", $apartament->id, $apartament->TipProprietate, "5", "198", "", "381");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("nou", $apartament->id, $apartament->TipProprietate, "24", "197", "", "380");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("renovat", $apartament->id, $apartament->TipProprietate, "24", "197", "", "380");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("necesita renovare", $apartament->id, $apartament->TipProprietate, "99", "199", "", "382");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("termopan", $apartament->id, $apartament->TipProprietate, "12", "201", "", "384");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("parchet", $apartament->id, $apartament->TipProprietate, "50", "459", "", "378");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("mocheta", $apartament->id, $apartament->TipProprietate, "57", "461", "", "377");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("gresie", $apartament->id, $apartament->TipProprietate, "55", "460", "", "374");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("faianta", $apartament->id, $apartament->TipProprietate, "62", "189", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("usa metalica", $apartament->id, $apartament->TipProprietate, "160", "214", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("tamplarie interioara", $apartament->id, $apartament->TipProprietate, "165", "219", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("vopsea lavabila", $apartament->id, $apartament->TipProprietate, "60", "190", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("huma", $apartament->id, $apartament->TipProprietate, "65", "194", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("tapet", $apartament->id, $apartament->TipProprietate, "64", "195", "", "");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $tmp = substr($tmp, 0, -1);
        $ofertaxml .= "<finisaje>{$tmp}</finisaje>";
        // structura de rezistenta
        $tmp = "";
        if (are_dotarea("beton", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, 136, 368, "", 432);
        }
        if (are_dotarea("caramida", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, 137, 366, "", 430);
        }
        if (are_dotarea("bca", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, 138, 367, "", 431);
        }
        if (are_dotarea("lemn", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, 139, 369, "", 433);
        }
        if (are_dotarea("metal", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, 140, 370, "", 435);
        }
        if ($tmp != "") {
            $ofertaxml .= "<structurarezistenta>{$tmp}</structurarezistenta>";
        }
        // stadiu constructie
        $tmp = "";
        if (are_dotarea("nou / finalizat", $apartament->id) || are_dotarea("stare buna", $apartament->id) || are_dotarea("necesita renovare", $apartament->id) || are_dotarea("reabilitat termic", $apartament->id)) {
            if ($apartament->TipProprietate < 2) {
                $tmp = "127";
            }
            if ($apartament->TipProprietate == 2) {
                $tmp = "362";
            }
            if ($apartament->TipProprietate == 4) {
                $tmp = "551";
            }
        }
        if (are_dotarea("nou / nefinalizat", $apartament->id)) {
            if ($apartament->TipProprietate < 2) {
                $tmp = "129";
            }
            if ($apartament->TipProprietate == 2) {
                $tmp = "364";
            }
            if ($apartament->TipProprietate == 4) {
                $tmp = "552";
            }
        }
        if ($tmp != "") {
            $ofertaxml .= "<stadiuconstructie>{$tmp}</stadiuconstructie>";
        }
    }
    if ($apartament->TipProprietate == 0) {
        // apartamente bloc
        $ofertaxml .= "<nrnivele>{$apartament->EtajeBloc}</nrnivele>";
    }
    if ($apartament->TipProprietate == 1 || $apartament->TipProprietate == 2) {
        //apartamente in vila si case
        $ofertaxml .= "<nrnivele>{$apartament->Etaje}</nrnivele>";
        $ofertaxml .= "<demisol>{$apartament->Demisol}</demisol>";
        $ofertaxml .= "<mansarda>{$apartament->Mansarda}</mansarda>";
        $ofertaxml .= "<subsol>{$apartament->Subsol}</subsol>";
    }
    if ($apartament->TipProprietate < 3) {
        // apartamente si case
        $ofertaxml .= "<regimhotelier>0</regimhotelier>";
        //$ofertaxml.="<nrnivele>{$apartament->EtajeBloc}</nrnivele>";
        $ofertaxml .= "<nrbai>{$apartament->NrGrupuriSanitare}</nrbai>";
        $ofertaxml .= "<nrbalcoane>{$apartament->NumarBalcoane}</nrbalcoane>";
        $ofertaxml .= "<nrbucatarii>{$apartament->NumarBucatarii}</nrbucatarii>";
        $ofertaxml .= "<nrlocuriparcare>{$apartament->NumarParcari}</nrlocuriparcare>";
    }
    if ($apartament->TipProprietate < 4) {
        // fara spatii
        $tmp = "";
        if (are_dotarea("birouri", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, 468, 456, "", "");
        }
        if (are_dotarea("rezidential", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, 466, 454, 471, "");
        }
        if (are_dotarea("comercial", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, 467, 455, 473, "");
        }
        if (are_dotarea("agricol", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, "", "", 474, "");
        }
        if (are_dotarea("industrial", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, "", "", 472, "");
        }
        $ofertaxml .= "<destinatie>{$tmp}</destinatie>";
    }
    if ($apartament->TipProprietate < 2) {
        // doar apartamente
        $ofertaxml .= '<tipcompartimentare>' . $compartimentare[$apartament->TipApartament] . '</tipcompartimentare>';
        $ofertaxml .= "<tipimobil>" . (121 + $apartament->TipProprietate) . "</tipimobil>";
        $ofertaxml .= "<confort>" . ($apartament->Confort + 36) . "</confort>";
        //$ofertaxml.="<dotari>".dotari("Mobilier,Electrocasnice,Contorizare,Spatii utile,Dotari Imobil",$apartament->id)."</dotari>";
        $ofertaxml .= "<finisaje>" . dotari("Finisaje / Dotari", $apartament->id) . (are_dotarea("renovat", $apartament->id) ? "24 " : "") . (are_dotarea("stare buna", $apartament->id) ? "5 " : "") . (are_dotarea("curat", $apartament->id) ? "5 " : "") . (are_dotarea("necesita renovare", $apartament->id) ? "99 " : "") . "</finisaje>";
        //$ofertaxml.="<utilitati>".dotari("Utilitati,Sistem de incalzire",$apartament->id).(are_dotarea("aer conditionat", $apartament->id) ? "44 " : "")."</utilitati>";
    }
    if ($apartament->TipProprietate == 2) {
        // doar case
        $ofertaxml .= "<frontstradal>{$apartament->Deschidere}</frontstradal>";
        $ofertaxml .= "<suprafatateren>{$apartament->SuprafataCurte}</suprafatateren>";
        $ofertaxml .= "<nrterase>{$apartament->NumarTerase}</nrterase>";
        //$ofertaxml.="<demisol>".($apartament->Demisol+0)."</demisol>";
        //$ofertaxml.="<subsol>".($apartament->Subsol+0)."</subsol>";
        //$ofertaxml.="<mansarda>".($apartament->Mansarda+0)."</mansarda>";
        $ofertaxml .= "<nrfronturi>" . $apartament->NumarDeschideri . "</nrfronturi>";
        $ofertaxml .= "<destinatie>" . dotari("Destinatie", $apartament->id) . "</destinatie>";
        $tmp = "";
        if (are_dotarea("tabla", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, "", 2, "", "");
        }
        if (are_dotarea("tigla", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, "", 3, "", "");
        }
        if (are_dotarea("sindrila", $apartament->id)) {
            $tmp = corespondent($apartament->TipProprietate, "", 4, "", "");
        }
        $ofertaxml .= "<invelitoareacoperis>{$tmp}</invelitoareacoperis>";
    }
    if ($apartament->TipProprietate == 3) {
        // doar terenuri
        $ofertaxml .= "<suprafatateren>{$apartament->SuprafataUtila}</suprafatateren>";
        $ofertaxml .= "<frontstradal>{$apartament->Deschidere}</frontstradal>";
        $ofertaxml .= "<umsuprafatateren>382</umsuprafatateren>";
        switch ($apartament->Clasificare) {
            case "intravilan":
                $ofertaxml .= "<clasificareteren>373</clasificareteren>";
                break;
            case "extravilan":
                $ofertaxml .= "<clasificareteren>374</clasificareteren>";
                break;
            default:
                $ofertaxml .= "<clasificareteren>373</clasificareteren>";
                break;
        }
        switch ($apartament->TipTeren) {
            case "constructii":
                $ofertaxml .= "<tipteren>375</tipteren>";
                break;
            case "agricol":
                $ofertaxml .= "<tipteren>376</tipteren>";
                break;
            case "padure":
                $ofertaxml .= "<tipteren>377</tipteren>";
                break;
            default:
                $ofertaxml .= "<tipteren>375</tipteren>";
                break;
        }
        $ofertaxml .= "<nrfronturistradale>{$apartament->NumarDeschideri}</nrfronturistradale>";
        $ofertaxml .= "<inclinatieteren>{$apartament->Inclinatie}</inclinatieteren>";
        $ofertaxml .= "<latimedrumacces>{$apartament->LatimeDrumAcces}</latimedrumacces>";
        $ofertaxml .= "<suprafataconstruita>{$apartament->SuprafataConstruita}</suprafataconstruita>";
        $ofertaxml .= "<constructiepeteren>" . ($apartament->ConstructiePeTeren + 0) . "</constructiepeteren>";
    }
    if ($apartament->TipProprietate == 4) {
        // doar spatii
        $ofertaxml .= "<nrincaperi>{$apartament->NumarCamere}</nrincaperi>";
        $ofertaxml .= "<nrgrupurisanitare>{$apartament->NrGrupuriSanitare}</nrgrupurisanitare>";
        $ofertaxml .= "<destinatierecomandata>" . base64_encode(dotari("Destinatie", $apartament->id)) . "</destinatierecomandata>";
        switch ($apartament->ClasaBirouri) {
            case "A":
                $ofertaxml .= '<clasabirouri>554</clasabirouri>';
                break;
            case "B":
                $ofertaxml .= '<clasabirouri>555</clasabirouri>';
                break;
            case "C":
                $ofertaxml .= '<clasabirouri>556</clasabirouri>';
                break;
            default:
                $ofertaxml .= '<clasabirouri></clasabirouri>';
        }
        $tmp = "";
        switch ($apartament->TipConstructie) {
            case "bloc":
                $tmp = 424;
                break;
            case "cladire de birouri":
                $tmp = 425;
                break;
            case "hala":
                $tmp = 426;
                break;
            case "depozit":
                $tmp = 427;
                break;
            case "casa/vila":
                $tmp = 428;
                break;
            case "hotel":
                $tmp = 429;
                break;
            case "centru comercial":
                $tmp = 562;
                break;
        }
        $ofertaxml .= "<tipimobil>{$tmp}</tipimobil>";
        $tmp = "";
        $x = dotare_imobiliare("lift marfa", $apartament->id, $apartament->TipProprietate, "", "", "", "435");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("marfa", $apartament->id, $apartament->TipProprietate, "", "", "", "451");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("CFR", $apartament->id, $apartament->TipProprietate, "", "", "", "448");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("TIR", $apartament->id, $apartament->TipProprietate, "", "", "", "449");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("Rampa TIR", $apartament->id, $apartament->TipProprietate, "", "", "", "450");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("pivnita", $apartament->id, $apartament->TipProprietate, "", "", "", "437");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("spatiu depozitare", $apartament->id, $apartament->TipProprietate, "", "", "", "439");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("crama", $apartament->id, $apartament->TipProprietate, "", "", "", "438");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $x = dotare_imobiliare("anexe", $apartament->id, $apartament->TipProprietate, "", "", "", "440");
        if ($x != "") {
            $tmp .= $x . " ";
        }
        $tmp = substr($tmp, 0, -1);
        $ofertaxml .= "<altecaracteristici>{$tmp}</altecaracteristici>";
    }
    $ofertaxml .= "<agent>{$agent->id}</agent>";
    $ofertaxml .= "<vecinatati><lang id=\"1048\">" . base64_encode(dotari("Vecinatati", $apartament->id)) . "</lang></vecinatati>";
    $ofertaxml .= "<descriere><lang id=\"1048\">" . base64_encode($apartament->Detalii . ", cod oferta SP" . $inchiriere . str_pad($oferta->id, 4, "0", STR_PAD_LEFT)) . "</lang></descriere>";
    $ofertaxml .= "<sector>{$apartament->Sector}</sector>";
    $ofertaxml .= "<alias>SP" . str_pad($oferta->id, 5, "0", STR_PAD_LEFT) . "</alias>";
    if ($oferta->Negociabil > 0) {
        $ofertaxml .= "<pretnegociabil>1</pretnegociabil>";
    }
    if ($oferta->Exclusivitate > 0) {
        $ofertaxml .= "<exclusivitate>1</exclusivitate>";
    }
    if ($oferta->OfertaWeb > 0) {
        $ofertaxml .= "<linkextern>http://www.simsparkman.ro/detaliioferta.php?id={$oferta->id}</linkextern>";
    }
    // inca nu au fost reanalizate
    // ?? nu mai e inm baza $ofertaxml.="<servicii>".dotari("Servicii???",$apartament->id)."</servicii>";
    //$ofertaxml.="<altedetaliizona>67,302,303</altedetaliizona>";
    $sql = "SELECT COUNT(*) FROM Foto WHERE idApartament={$apartament->id}";
    $nrimagini = Foto::count_by_sql($sql);
    if ($nrimagini > 0) {
        $ofertaxml .= "<imagini nrimagini=\"{$nrimagini}\">";
        $fotoList = Foto::find_by_sql("SELECT * FROM Foto WHERE idApartament={$apartament->id}");
        foreach ($fotoList as $foto) {
            $ofertaxml .= "<imagine dummy=\"False\" modificata=\"1228840157\" latime=\"800\" inaltime=\"600\" pozitie=\"{$foto->Ordin}\">";
            $ofertaxml .= "<descriere>" . base64_encode($foto->Detalii) . "</descriere>";
            $ofertaxml .= "<blob>";
            $ofertaxml .= base64_encode(file_get_contents(".." . DS . $foto->image_path()));
            $ofertaxml .= "</blob>";
            $ofertaxml .= "</imagine>";
        }
        $ofertaxml .= "</imagini>";
    }
    //echo $ofertaxml;
    if ($oferta->ExportImobiliare < 3 && $oferta->Stare == 'de actualitate') {
        if ($oferta->ExportImobiliare = 1) {
            $operatie = "MOD";
            $ofertaxml .= "<datamodificare>" . time() . "</datamodificare>";
        } else {
            $operatie = "ADD";
            $ofertaxml .= "<dataadaugare>" . time() . "</dataadaugare>";
        }
    } else {
        $operatie = "DEL";
    }
    $ofertaxml .= '</oferta>';
    //echo $ofertaxml;
    // publica oferta
    $ok = 1;
    switch ($apartament->TipProprietate) {
        case 0:
            $oftip = 0;
            break;
        case 1:
            $oftip = 0;
            break;
        case 2:
            $oftip = 1;
            break;
        case 3:
            $oftip = 3;
            break;
        case 4:
            $oftip = 4;
            break;
    }
    try {
        $result = $s->__soapCall('publica_oferta', array('publica_oferta' => array('id_str' => $oftip . ':' . $id, 'sid' => $session_id, 'operatie' => $operatie, 'ofertaxml' => $ofertaxml)));
    } catch (Exception $e) {
        $ok = 0;
        die('Eroare Publicare oferta: ' . $e->getMessage());
    }
    if (isset($result->mesaj)) {
        $idImobiliare = array_pop(explode(" ", $result->mesaj));
    }
    echo '<pre>PUBLICARE OFERTA: ' . print_r($result, true) . '</pre>';
    if ($result->cod == "0") {
        return true;
    }
    return false;
}
Esempio n. 7
0
function posteazaAnunt($inchiriere = 0)
{
    global $oferta;
    global $apartament;
    global $client;
    global $agent;
    global $subzona;
    global $strada;
    global $fotografii;
    global $request;
    $id = $oferta->id;
    $data["key"] = "2HVO01c20rHj0lB60jI50dwB";
    $data["tip_oferta"] = $inchiriere == 0 ? "vanzare" : "inchiriere";
    switch ($apartament->TipProprietate) {
        case 0:
            $data["categorie_imobil"] = $apartament->NumarCamere > 1 ? "apartament" : "garsoniera";
            break;
        case 1:
            $data["categorie_imobil"] = $apartament->NumarCamere > 1 ? "apartament" : "garsoniera";
            break;
        case 2:
            $data["categorie_imobil"] = "casa";
            break;
        case 3:
            $data["categorie_imobil"] = "teren";
            break;
        case 4:
            if ($apartament->TipSpatiu == "birouri") {
                $data["categorie_imobil"] = "spatiu_birouri";
                break;
            }
            if ($apartament->TipSpatiu == "hotel") {
                $data["categorie_imobil"] = "spatiu_birouri";
                break;
            }
            if ($apartament->TipSpatiu == "comercial") {
                $data["categorie_imobil"] = "spatiu_comercial";
                break;
            }
            if ($apartament->TipSpatiu == "industrial") {
                $data["categorie_imobil"] = "hala_industriala";
                break;
            }
    }
    setAtribut($data, "zone_id", $subzona->idMC);
    setAtribut($data, "orase_id", 1);
    setAtribut($data, "strada_imobil", $subzona->Denumire);
    //setAtribut($data, "numar_strada", $apartament->Numar);
    setAtribut($data, "camere_imobil", $apartament->NumarCamere);
    setAtribut($data, "bai_imobil", $apartament->NrGrupuriSanitare, "N");
    setAtribut($data, "suprafata_imobil", $apartament->SuprafataConstruita > 0 ? $apartament->SuprafataConstruita : $apartament->SuprafataUtila, "N");
    setAtribut($data, "pret_imobil", $inchiriere ? $oferta->PretChirie : $oferta->Pret);
    setAtribut($data, "pret_tva", "cu_tva");
    setAtribut($data, "pret_negociabil", 1);
    setAtribut($data, "afiseaza_pmp", 1);
    if (are_dotarea("centrala de bloc", $apartament->id)) {
        setAtribut($data, "incalzire_imobil", "centrala_bloc");
    }
    if (are_dotarea("termoficare", $apartament->id)) {
        setAtribut($data, "incalzire_imobil", "centrala_zona");
    }
    if (are_dotarea("centrala de apartament", $apartament->id)) {
        setAtribut($data, "incalzire_imobil", "centrala_proprie");
    }
    if (are_dotarea("incalzire cu sobe", $apartament->id)) {
        setAtribut($data, "incalzire_imobil", "soba");
    }
    if (are_dotarea("garaj", $apartament->id) || $apartament->NumarGaraje > 0) {
        setAtribut($data, "parcare_imobil", "garaj");
    }
    if ($apartament->NumarParcari > 0 || are_dotarea("parcare subterana", $apartament->id) || are_dotarea("parcare inchiriata", $apartament->id) || are_dotarea("parcare proprie", $apartament->id)) {
        setAtribut($data, "parcare_imobil", "privata");
    }
    switch ($apartament->Etaj) {
        case -3:
            setAtribut($data, "etaj_imobil", "D");
            break;
        case -2:
            setAtribut($data, "etaj_imobil", "D");
            break;
        case -1:
            setAtribut($data, "etaj_imobil", $apartament->Etaje);
            break;
        case 0:
            setAtribut($data, "etaj_imobil", "P");
            break;
        default:
            setAtribut($data, "etaj_imobil", $apartament->Etaj);
            break;
    }
    //setAtribut($data, "etaj_imobil", ($apartament->Etaj > 0 ? $apartament->Etaj : "P"));
    if ($apartament->TipProprietate == 1 || $apartament->TipProprietate == 2 || $apartament->TipProprietate == 4) {
        $str = "";
        if ($apartament->Subsol > 0) {
            $str .= "S+";
        }
        if ($apartament->Demisol > 0) {
            $str .= "D+";
        }
        if ($apartament->Parter > 0) {
            $str .= "P+";
        }
        if ($apartament->Etaje > 0) {
            $str .= $apartament->Etaje . "+";
        }
        if ($apartament->Mansarda > 0) {
            $str .= "M+";
        }
        if ($apartament->Pod > 0) {
            $str .= "Pod+";
        }
        $str = substr($str, 0, -1);
        setAtribut($data, "etajDin_imobil", $str);
    } else {
        if ($apartament->TipProprietate == 0) {
            setAtribut($data, "etajDin_imobil", $apartament->EtajeBloc);
        }
    }
    setAtribut($data, "an_constructie_imobil", $apartament->AnConstructie, "N");
    if ($apartament->AnRenovare > 0) {
        setAtribut($data, "an_renovare_imobil", $apartament->AnRenovare, "N");
    }
    // ---
    if ($apartament->Mansarda > 0) {
        setAtribut($data, "mansarda", 1);
    }
    // -----
    setAtribut($data, "terase_balcoane", $apartament->NumarBalcoane, "N");
    setAtribut($data, "compartimentare", $apartament->TipApartament != "Circular" ? strtolower($apartament->TipApartament) : "semidecomandat");
    if (are_dotarea("termopan", $apartament->id)) {
        $data["pvc_termopan_tamplarie"] = 1;
    }
    if (are_dotarea("gresie", $apartament->id)) {
        $data["imbunatatiri_gresie"] = 1;
    }
    if (are_dotarea("faianta", $apartament->id)) {
        $data["imbunatatiri_faianta"] = 1;
    }
    if (are_dotarea("parchet", $apartament->id)) {
        $data["imbunatatiri_parchet"] = 1;
    }
    if (are_dotarea("canalizare", $apartament->id)) {
        $data["canalizare"] = "canal";
    }
    if (are_dotarea("beton", $apartament->id)) {
        $data["beton_constructie_imobil"] = 1;
    }
    if (are_dotarea("caramida", $apartament->id)) {
        $data["caramida_constructie_imobil"] = 1;
    }
    if (are_dotarea("metal", $apartament->id)) {
        $data["alta_varianta_constructie_imobil"] = "metal";
    }
    if (are_dotarea("centrala proprie", $apartament->id)) {
        $data["centrala_gaz"] = 1;
    }
    if (are_dotarea("gaze", $apartament->id)) {
        $data["conectare_gaze"] = 1;
    }
    // -----
    // 	$anunt="Confort ".$apartament->Confort.", ".strtolower($apartament->TipApartament);
    // 	$anunt.=scrieDotari("Mobilier", $apartament->id);
    // 	$anunt.=scrieDotari("Electrocasnice", $apartament->id);
    // 	$anunt.=scrieDotari("Finisaje / Dotari", $apartament->id);
    // 	$anunt.=scrieDotari("Contorizare", $apartament->id);
    // 	$anunt.=scrieDotari("Spatii utile", $apartament->id);
    // 	$anunt.=scrieDotari("Dotari Imobil", $apartament->id);
    // 	$anunt.=scrieDotari("Utilitati", $apartament->id);
    // 	$tmp=scrieDotari("Vedere", $apartament->id);
    // 	if ($tmp!="") $anunt.="; Vedere: ".substr($tmp, 2, strlen($tmp));
    // 	$tmp=scrieDotari("Vecinatati", $apartament->id);
    // 	if ($tmp!="") $anunt.="; Vecinatati: ".substr($tmp, 2, strlen($tmp));
    $anunt = $apartament->Detalii;
    $anunt .= " Cod oferta SP" . str_pad($id, 5, "0", STR_PAD_LEFT);
    setAtribut($data, "info_imobil", $anunt);
    setAtribut($data, "Ylat", $apartament->Lat);
    setAtribut($data, "Ylong", $apartament->Lng);
    // ------
    if ($apartament->TipProprietate == 3) {
        $data["suprafata_teren"] = $apartament->SuprafataUtila;
        $data["teren_deschidere"] = $apartament->Deschidere;
    }
    if ($apartament->TipProprietate == 2) {
        $data["amprenta_sol"] = $apartament->AmprentaSol;
    }
    // ------
    setAtribut($data, "telefon_proprietar", substr($client->TelefonMobil, -5));
    setAtribut($data, "email", $agent->Email);
    setAtribut($data, "id_intern", "SP" . ($inchiriere ? "1" : "0") . str_pad($id, 4, "0", STR_PAD_LEFT));
    // -------
    if ($apartament->TipProprietate == 4) {
        if ($apartament->TipSpatiu == "birouri") {
            $data["clasa_birouri"] = $apartament->ClasaBirouri;
        }
        $data["grupuri_sanitare_imobil"] = $apartament->NrGrupuriSanitare;
    }
    // -------
    $request->flush();
    $request->setVerb($oferta->ExportMC == 1 ? "post" : "put");
    $request->setPath("/imobile.json");
    $request->buildPostBody($data);
    //print_r($data);
    $request->execute();
    $response = $request->getResponseBody();
    //return false;
    //$request->setPath('/imobile.json');
    //$request->setVerb('post');
    //$request->buildPostBody($data);
    //$request->execute();
    //$response = $request->getResponseBody();
    //print_r($data);
    //echo "<br/>";
    //print_r($response);
    //return false;
    echo "Sincronizare " . $data["id_intern"] . ": ";
    if (!valid_code($response->code)) {
        echo "eroare sincronizare: ";
        print_r($response);
        echo "<br />";
        return false;
    } else {
        echo "succes<br/>";
    }
    $responseData = $response->data;
    $oferta->idMC = $responseData->id;
    // stergere fotografii anterioare
    $request->flush();
    $request->setVerb("DELETE");
    $request->setPath("/poze.json");
    $pozaData["key"] = "2HVO01c20rHj0lB60jI50dwB";
    $pozaData["id_intern"] = "SP" . ($inchiriere ? "1" : "0") . str_pad($id, 4, "0", STR_PAD_LEFT);
    $request->buildPostBody($pozaData);
    $request->execute();
    $response = $request->getResponseBody();
    if (!valid_code($response->code)) {
        echo "<br />";
        echo "Eroare stergere poze: " . $data["id_intern"];
        print_r($response);
        //return false;
    }
    // postare fotografii
    foreach ($fotografii as $foto) {
        $request->flush();
        $request->setVerb("post");
        $request->setPath("/poze.json");
        $pozaData["key"] = "2HVO01c20rHj0lB60jI50dwB";
        $pozaData["id_intern"] = "SP" . ($inchiriere ? "1" : "0") . str_pad($id, 4, "0", STR_PAD_LEFT);
        $pozaData["url"] = "http://crm.simsparkman.ro/images/{$foto->NumeFisier}";
        $pozaData["ordine"] = $foto->Ordin;
        $request->buildPostBody($pozaData);
        //print_r($pozaData);
        $request->execute();
        $response = $request->getResponseBody();
        if (!valid_code($response->code)) {
            echo "<br />";
            echo "Eroare sincronizare poza: " . $data["id_intern"] . " - " . $foto->id . ": ";
            print_r($response);
            //return false;
        }
    }
    return true;
}