function alteDotari($idApartament, $tip) { $ret = ""; $sql = "SELECT * FROM CategorieDotari WHERE TipProprietate='{$tip}' AND Privat<>1"; $CatDotList = CategorieDotari::find_by_sql($sql); if (!empty($CatDotList)) { foreach ($CatDotList as $CatDot) { $sql = "SELECT * FROM Dotare WHERE idCategorieDotari='{$CatDot->id}'"; $DotList = Dotare::find_by_sql($sql); if (!empty($DotList)) { foreach ($DotList as $Dot) { if (are_dotarea($Dot->Descriere, $idApartament)) { $ret .= ", " . $Dot->Descriere; } } } } } }
function sync_CategorieDotari() { global $conexiune2; $sql = "SELECT * FROM CategorieDotari"; $categorii = CategorieDotari::find_by_sql($sql); $sql = "DELETE FROM fes_CategorieDotari"; $result = execute_querry($sql, $conexiune2); $sql = "ALTER TABLE fes_CategorieDotari AUTO_INCREMENT = 1"; $result = execute_querry($sql, $conexiune2); $CategorieDotari = array(); $sql_catdot = "INSERT INTO fes_CategorieDotari (id,Descriere,Prioritate) VALUES "; foreach ($categorii as $tmp) { $CategorieDotari["id"] = $tmp->id; $CategorieDotari["Descriere"] = $tmp->Descriere; $CategorieDotari["Prioritate"] = $tmp->Prioritate; $sql_catdot .= "('" . join("', '", array_values($CategorieDotari)) . "'),"; } $sql_catdot = substr($sql_catdot, 0, strlen($sql_catdot) - 1); $result = execute_querry($sql_catdot, $conexiune2); }
function scrieDotari($categorie, $idApartament) { $ret = ""; $sql = "SELECT * FROM CategorieDotari WHERE TipProprietate=1 AND Descriere='{$categorie}'"; $CatDotList = CategorieDotari::find_by_sql($sql); if (!empty($CatDotList)) { $CatDot = array_shift($CatDotList); $sql = "SELECT * FROM Dotare WHERE idCategorieDotari='{$CatDot->id}'"; $DotList = Dotare::find_by_sql($sql); if (!empty($DotList)) { foreach ($DotList as $Dot) { $sql = "SELECT * FROM DotareApartament WHERE idDotare='{$Dot->id}' AND idApartament='{$idApartament}'"; $DotApList = Dotareapartament::find_by_sql($sql); if (!empty($DotApList)) { $ret .= ", " . $Dot->Descriere; } } } } return $ret; }
$result = execute_querry($sql, $conexiune2); $sql = "ALTER TABLE Subzona AUTO_INCREMENT = 1"; $result = execute_querry($sql, $conexiune2); $subzona = array(); $sql_subzone = "INSERT INTO Subzona (id,Denumire,idCartier) VALUES "; foreach ($cartiere as $tmp) { $subzona["id"] = $tmp->id; $subzona["Denumire"] = $tmp->Denumire; $subzona["idCartier"] = $tmp->idZona; $sql_subzone .= "('" . join("', '", array_values($subzona)) . "'),"; } $sql_subzone = substr($sql_subzone, 0, strlen($sql_subzone) - 1); $result = execute_querry($sql_subzone, $conexiune2); // refresh CategorieDotari $sql = "SELECT * FROM CategorieDotari"; $categorii = CategorieDotari::find_by_sql($sql); $sql = "DELETE FROM CategorieDotari"; $result = execute_querry($sql, $conexiune2); $sql = "ALTER TABLE CategorieDotari AUTO_INCREMENT = 1"; $result = execute_querry($sql, $conexiune2); $CategorieDotari = array(); $sql_catdot = "INSERT INTO CategorieDotari (id,Descriere,TipProprietate,TipControl,Prioritate,Privat) VALUES "; foreach ($categorii as $tmp) { $CategorieDotari["id"] = $tmp->id; $CategorieDotari["Descriere"] = $tmp->Descriere; $CategorieDotari["TipProprietate"] = $tmp->TipProprietate; $CategorieDotari["TipControl"] = $tmp->TipControl; $CategorieDotari["Prioritate"] = $tmp->Prioritate; $CategorieDotari["Privat"] = $tmp->Privat; $sql_catdot .= "('" . join("', '", array_values($CategorieDotari)) . "'),"; }
return 0; } $oferta = Oferta::find_by_id($idOferta); $apartament = Apartament::find_by_id($oferta->idApartament); $client = Client::find_by_id($apartament->idClient); $agent = User::find_by_id($client->idUtilizator); $strada = Strada::find_by_id($apartament->idStrada); $subzona = Subzona::find_by_id($apartament->idSubzona); $cartier = Cartier::find_by_id($subzona->idCartier); $oras = Zona::find_by_id($cartier->idZona); $sursa = Sursa::find_by_id($apartament->idSursa); $agentIntroducere = User::find_by_id($oferta->idAgentIntroducere); $agentInchiriere = User::find_by_id($oferta->idAgentInchiriere); $agentVanzare = User::find_by_id($oferta->IdAgentVanzare); $sql = "SELECT * FROM CategorieDotari WHERE TipProprietate=1 ORDER BY Prioritate"; $CatDotList = CategorieDotari::find_by_sql($sql); if (!empty($CatDotList)) { foreach ($CatDotList as $CatDot) { $sql = "SELECT * FROM Dotare WHERE idCategorieDotari='{$CatDot->id}'"; $DotList = Dotare::find_by_sql($sql); if (!empty($DotList)) { foreach ($DotList as $Dot) { $sql = "SELECT * FROM DotareApartament WHERE idDotare='{$Dot->id}' AND idApartament='{$apartament->id}'"; $DotApList = Dotareapartament::find_by_sql($sql); if (!empty($DotApList)) { foreach ($DotApList as $DotAp) { if (!isset($dotString[$CatDot->id])) { $dotCat[$CatDot->id] = $CatDot->Descriere; $dotString[$CatDot->id] = $Dot->Descriere; } else { $dotString[$CatDot->id] .= ", " . $Dot->Descriere;