function are_dotarea($dotare, $idApartament) { $ret = 0; $sql = "\n\t\tSELECT D.Descriere,D.idImobiliare\n\t\tFROM Apartament AS A, DotareApartament AS DA, Dotare AS D\n\t\tWHERE D.Descriere = '{$dotare}'\n\t\tAND DA.idDotare = D.id\n\t\tAND DA.idApartament = A.id\n\t\tAND A.id ={$idApartament}"; $dotareList = Dotare::find_by_sql($sql); if (!empty($dotareList)) { $ret = 1; } return $ret; }
function sync_Dotari() { global $conexiune2; $sql = "SELECT * FROM Dotare"; $tmparr = Dotare::find_by_sql($sql); $sql = "DELETE FROM fes_Dotare"; $result = execute_querry($sql, $conexiune2); $sql = "ALTER TABLE fes_Dotare AUTO_INCREMENT = 1"; $result = execute_querry($sql, $conexiune2); $record = array(); $sql = "INSERT INTO fes_Dotare (id,Descriere,idCategorieDotari) VALUES "; foreach ($tmparr as $tmp) { $record["id"] = $tmp->id; $record["Descriere"] = $tmp->Descriere; $record["idCategorieDotari"] = $tmp->idCategorieDotari; $sql .= "('" . join("', '", array_values($record)) . "'),"; } $sql = substr($sql, 0, strlen($sql) - 1); $result = execute_querry($sql, $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; }
$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)) . "'),"; } $sql_catdot = substr($sql_catdot, 0, strlen($sql_catdot) - 1); $result = execute_querry($sql_catdot, $conexiune2); // refresh Dotari $sql = "SELECT * FROM Dotare"; $tmparr = Dotare::find_by_sql($sql); $sql = "DELETE FROM Dotare"; $result = execute_querry($sql, $conexiune2); $sql = "ALTER TABLE Dotare AUTO_INCREMENT = 1"; $result = execute_querry($sql, $conexiune2); $record = array(); $sql = "INSERT INTO Dotare (id,Descriere,idCategorieDotari,Implicit) VALUES "; foreach ($tmparr as $tmp) { $record["id"] = $tmp->id; $record["Descriere"] = $tmp->Descriere; $record["idCategorieDotari"] = $tmp->idCategorieDotari; $record["Implicit"] = $tmp->Implicit; $sql .= "('" . join("', '", array_values($record)) . "'),"; } $sql = substr($sql, 0, strlen($sql) - 1); $result = execute_querry($sql, $conexiune2);
$rows = 0; echo "</div></div>"; echo "<div style=\"display: inline-block; width:325px; float: left\"><div>"; } ?> <fieldset id="FS<?php echo $categorie->id . "_" . $categorie->Proprietati; ?> "> <legend><?php echo $categorie->Descriere; ?> </legend> <?php $sql = "SELECT * FROM Dotare WHERE idCategorieDotari={$categorie->id} ORDER BY Descriere"; $dotareList = Dotare::find_by_sql($sql); if (!empty($dotareList)) { ?> <label class="label"><?php echo $categorie->Descriere; ?> </label><select name="CbDt<?php echo $categorie->id; ?> " class="standard"> <option value="" selected="selected">alegeti...</option> <?php foreach ($dotareList as $dotare) { $rows++; if ($rows > 22) { $rows = 2;
public function are_dotarea($dotare) { $sql = "\n\t\t\tSELECT D.Descriere,D.idImobiliare\n\t\t\tFROM Apartament AS A, DotareApartament AS DA, Dotare AS D\n\t\t\tWHERE D.Descriere = '{$dotare}'\n\t\t\tAND DA.idDotare = D.id\n\t\t\tAND DA.idApartament = A.id\n\t\t\tAND A.id ={$this->id}"; $dotareList = Dotare::find_by_sql($sql); if (!empty($dotareList)) { return true; } return false; }
<?php require_once ".././include/initialize.php"; if (!$session->is_logged_in()) { redirect_to("login.php"); } $message = ""; if (isset($_GET['idCateg'])) { $idCategorieDotari = $_GET['idCateg']; } if (isset($_POST['submit'])) { $dotare = new Dotare(); $Descriere = $_POST['Descriere']; $idCategorieDotari = $_POST['idCategorieDotari']; $sql = "SELECT * FROM Dotare WHERE Descriere='{$Descriere}' AND idCategorieDotari='{$idCategorieDotari}'"; $dotareList = Dotare::find_by_sql($sql); if (!empty($dotareList)) { $message = "Dotare deja exista in baza de date"; } else { $dotare->Descriere = $Descriere; $dotare->idCategorieDotari = $idCategorieDotari; $dotare->save(); $message = "Adaugat"; redirect_to("categoriedotare_list.php"); } } include_layout_template('admin_header.php'); ?> <script type="text/javascript"> <!--
function CategoriiDot($tip) { if ($tip != "nc") { $tip = "Proprietati LIKE '%{$tip}%'"; } else { $tip = "Proprietati='' OR Proprietati IS NULL"; } ?> <div id="butoane" class="butoanestanga"> <input type="button" value="Adauga categorie" onclick="addCategoriedotare()"></input> </div> <?php $sql = "SELECT * FROM CategorieDotari WHERE {$tip} ORDER BY Prioritate"; echo $sql; $categoriedotariList = Categoriedotari::find_by_sql($sql); if (!empty($categoriedotariList)) { foreach ($categoriedotariList as $categoriedotari) { ?> <div class="view"> <h3><?php echo $categoriedotari->Prioritate . " - " . $categoriedotari->Descriere . ($categoriedotari->Privat == 1 ? " - Privat - " : "") . ($categoriedotari->TipControl == 1 ? " - checkbox - " : " - lista - "); ?> | <a class="header" href="categoriedotare_update.php?id=<?php echo $categoriedotari->id; ?> ">modifica</a></h3> <?php $sql = "SELECT * FROM Dotare WHERE idCategorieDotari={$categoriedotari->id}"; $dotareList = Dotare::find_by_sql($sql); if (!empty($dotareList)) { $i = 0; ?> <table width="650px"> <tr> <td class="header" width="40%">Denumire</td> <td class="header" width="10%">Implicit</td> <td class="header" width="20%">ID Imobiliare</td> <td class="header" width="30%">Operatii</td> </tr> <?php foreach ($dotareList as $dotare) { $i++; $class = $i % 2 ? "impar" : "par"; ?> <tr id="<?php echo $dotare->id; ?> " class="<?php echo $class; ?> " ondblclick='dotareEdit("<?php echo $dotare->id; ?> ")' onmouseover='onOver("<?php echo $dotare->id; ?> ",1,<?php echo $i; ?> )' onmouseout='onOver("<?php echo $dotare->id; ?> ",0,<?php echo $i; ?> )'> <td><?php echo $dotare->Descriere; ?> </td> <td><input type="checkbox" disabled="disabled" <?php if ($dotare->Implicit == 1) { echo "checked=\"checked\""; } ?> /></td> <td><?php echo $dotare->idImobiliare; ?> </td> <td> <a href="dotare_update.php?id=<?php echo $dotare->id; ?> ">modifica</a> | <a href="dotare_delete.php?id=<?php echo $dotare->id; ?> ">sterge</a> | <a href="dotare_new.php?idCateg=<?php echo $categoriedotari->id; ?> ">adauga</a></td> </tr> <?php } ?> </table> <?php } else { ?> <input type="button" value="Adauga Dotare" onclick="addDotare(<?php echo $categoriedotari->id; ?> )"></input> <input type="button" value="Sterge Categorie" onclick="delCategoriedotare(<?php echo $categoriedotari->id; ?> )"></input> <?php } ?> </div> <?php } } }
$xt = 1; } if (strpos($dotare->Proprietati, "xs") !== false) { $xs = 1; } } if (isset($_POST['submit'])) { $dotare = new Dotare(); $postlist = array_keys($_POST); foreach ($postlist as $variable) { if ($variable != "submit") { ${$variable} = $_POST[$variable]; } } //$Descriere=$_POST['Descriere']; $dotare = Dotare::find_by_id($_SESSION['curentIdDotare']); unset($_SESSION['curentIdDotare']); $dotare->Descriere = $Descriere; $dotare->idCategorieDotari = $idCategorieDotari; $dotare->idImobiliare = $idImobiliare; $dotare->Implicit = isset($Implicit) ? $Implicit : 0; $dotare->Proprietati = ""; if (isset($_POST['xa'])) { $xa = 1; $dotare->Proprietati = $dotare->Proprietati . "xa"; } if (isset($_POST['xb'])) { $xb = 1; $dotare->Proprietati = $dotare->Proprietati . "xb"; } if (isset($_POST['xc'])) {
require_once ".././include/initialize.php"; if (!$session->is_logged_in()) { redirect_to("login.php"); } include_layout_template('admin_header.php'); ?> <script type="text/javascript"> <!-- function back(){ document.location = ("categoriedotare_list.php"); } //--> </script> <?php $dotare = Dotare::find_by_id($_GET['id']); $dotare->delete(); ?> <h3>Dotare <?php echo $dotare->Descriere; ?> a fost stearsa.</h3> <div id="butoane" class="butoane"> <input type="button" name="submit" value="Inapoi" onclick="back()" /> </div> <?php include_layout_template('admin_footer.php');