diff --git a/system/pages/houses.php b/system/pages/houses.php index db1a6992..de4bc943 100644 --- a/system/pages/houses.php +++ b/system/pages/houses.php @@ -14,17 +14,17 @@ $title = 'Houses'; $errors = array(); if(!$db->hasColumn('houses', 'name')) { - $errors[] = 'Houses list is not available on this server.'; + $errors[] = 'Houses list is not available on this server.'; - $twig->display('houses.html.twig', array( - 'errors' => $errors - )); + $twig->display('houses.html.twig', array( + 'errors' => $errors + )); return; } $rentType = trim(strtolower($config['lua']['houseRentPeriod'])); if($rentType != 'yearly' && $rentType != 'monthly' && $rentType != 'weekly' && $rentType != 'daily') - $rentType = 'never'; + $rentType = 'never'; $state = ''; $order = ''; @@ -32,116 +32,116 @@ $type = ''; if(isset($_GET['page']) && $_GET['page'] == 'view' && isset($_REQUEST['house'])) { - $beds = array("", "one", "two", "three", "fourth", "fifth"); - $houseName = $_REQUEST['house']; - $houseId = (Validator::number($_REQUEST['house']) ? $_REQUEST['house'] : -1); - $selectHouse = $db->query('SELECT * FROM ' . $db->tableName('houses') . ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($houseName) . ' OR `id` = ' . $db->quote($houseId)); + $beds = array("", "one", "two", "three", "fourth", "fifth"); + $houseName = $_REQUEST['house']; + $houseId = (Validator::number($_REQUEST['house']) ? $_REQUEST['house'] : -1); + $selectHouse = $db->query('SELECT * FROM ' . $db->tableName('houses') . ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($houseName) . ' OR `id` = ' . $db->quote($houseId)); - $house = array(); - if($selectHouse->rowCount() > 0) - { - $house = $selectHouse->fetch(); - $houseId = $house['id']; + $house = array(); + if($selectHouse->rowCount() > 0) + { + $house = $selectHouse->fetch(); + $houseId = $house['id']; - $title = $house['name'] . ' - ' . $title; + $title = $house['name'] . ' - ' . $title; - $imgPath = 'images/houses/' . $houseId . '.gif'; - if(!file_exists($imgPath)) { - $imgPath = 'images/houses/default.jpg'; - } + $imgPath = 'images/houses/' . $houseId . '.gif'; + if(!file_exists($imgPath)) { + $imgPath = 'images/houses/default.jpg'; + } - $bedsMessage = null; - $houseBeds = $house['beds']; - if($houseBeds > 0) - $bedsMessage = 'House have ' . (isset($beds[$houseBeds]) ? $beds[$houseBeds] : $houseBeds) . ' bed' . ($houseBeds > 1 ? 's' : ''); - else - $bedsMessage = 'This house dont have any beds'; + $bedsMessage = null; + $houseBeds = $house['beds']; + if($houseBeds > 0) + $bedsMessage = 'House have ' . (isset($beds[$houseBeds]) ? $beds[$houseBeds] : $houseBeds) . ' bed' . ($houseBeds > 1 ? 's' : ''); + else + $bedsMessage = 'This house dont have any beds'; - $houseOwner = $house['owner']; - if($houseOwner > 0) - { - $guild = NULL; - $owner = null; - if(isset($house['guild']) && $house['guild'] == 1) - { - $guild = new OTS_Guild(); - $guild->load($houseOwner); - $owner = getGuildLink($guild->getName()); - } - else - $owner = getCreatureName($houseOwner); + $houseOwner = $house['owner']; + if($houseOwner > 0) + { + $guild = NULL; + $owner = null; + if(isset($house['guild']) && $house['guild'] == 1) + { + $guild = new OTS_Guild(); + $guild->load($houseOwner); + $owner = getGuildLink($guild->getName()); + } + else + $owner = getCreatureName($houseOwner); - if($rentType != 'never' && $house['paid'] > 0) - { - $who = ''; - if($guild) - $who = $guild->getName(); - else - { - $player = new OTS_Player(); - $player->load($houseOwner); - if($player->isLoaded()) - { - $sexs = array('She', 'He'); - $who = $sexs[$player->getSex()]; - } - } - $owner .= ' ' . $who . ' has paid the rent until ' . date("M d Y, H:i:s", $house['paid']) . ' CEST.'; - } - } - } - else - $errors[] = 'House with name ' . $houseName . ' does not exists.'; + if($rentType != 'never' && $house['paid'] > 0) + { + $who = ''; + if($guild) + $who = $guild->getName(); + else + { + $player = new OTS_Player(); + $player->load($houseOwner); + if($player->isLoaded()) + { + $sexs = array('She', 'He'); + $who = $sexs[$player->getSex()]; + } + } + $owner .= ' ' . $who . ' has paid the rent until ' . date("M d Y, H:i:s", $house['paid']) . ' CEST.'; + } + } + } + else + $errors[] = 'House with name ' . $houseName . ' does not exists.'; - $twig->display('houses.view.html.twig', array( - 'errors' => $errors, - 'imgPath' => isset($imgPath) ? $imgPath : null, - 'houseName' => isset($house['name']) ? $house['name'] : null, - 'bedsMessage' => isset($bedsMessage) ? $bedsMessage : null, - 'houseSize' => isset($house['size']) ? $house['size'] : null, - 'houseRent' => isset($house['rent']) ? $house['rent'] : null, - 'owner' => isset($owner) ? $owner : null, - 'rentType' => isset($rentType) ? $rentType : null - )); + $twig->display('houses.view.html.twig', array( + 'errors' => $errors, + 'imgPath' => isset($imgPath) ? $imgPath : null, + 'houseName' => isset($house['name']) ? $house['name'] : null, + 'bedsMessage' => isset($bedsMessage) ? $bedsMessage : null, + 'houseSize' => isset($house['size']) ? $house['size'] : null, + 'houseRent' => isset($house['rent']) ? $house['rent'] : null, + 'owner' => isset($owner) ? $owner : null, + 'rentType' => isset($rentType) ? $rentType : null + )); - if (count($errors) > 0) { - return; - } + if (count($errors) > 0) { + return; + } } $cleanOldHouse = null; if(isset($config['lua']['houseCleanOld'])) { - $cleanOldHouse = (int)(eval('return ' . $config['lua']['houseCleanOld'] . ';') / (24 * 60 * 60)); + $cleanOldHouse = (int)(eval('return ' . $config['lua']['houseCleanOld'] . ';') / (24 * 60 * 60)); } $housesSearch = false; if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order']) && (isset($_POST['type']) || !$db->hasColumn('houses', 'guild'))) { - $townName = $config['towns'][$_POST['town']]; - $order = $_POST['order']; - $orderby = '`name`'; - if(!empty($order)) - { - if($order == 'size') - $orderby = '`size`'; - else if($order == 'rent') - $orderby = '`rent`'; - } + $townName = $config['towns'][$_POST['town']]; + $order = $_POST['order']; + $orderby = '`name`'; + if(!empty($order)) + { + if($order == 'size') + $orderby = '`size`'; + else if($order == 'rent') + $orderby = '`rent`'; + } - $town = 'town'; - if($db->hasColumn('houses', 'town_id')) - $town = 'town_id'; - else if($db->hasColumn('houses', 'townid')) - $town = 'townid'; + $town = 'town'; + if($db->hasColumn('houses', 'town_id')) + $town = 'town_id'; + else if($db->hasColumn('houses', 'townid')) + $town = 'townid'; - $whereby = '`' . $town . '` = ' .(int)$_POST['town']; - $state = $_POST['state']; - if(!empty($state)) - $whereby .= ' AND `owner` ' . ($state == 'free' ? '' : '!'). '= 0'; + $whereby = '`' . $town . '` = ' .(int)$_POST['town']; + $state = $_POST['state']; + if(!empty($state)) + $whereby .= ' AND `owner` ' . ($state == 'free' ? '' : '!'). '= 0'; - $type = isset($_POST['type']) ? $_POST['type'] : NULL; - if($type == 'guildhalls' && !$db->hasColumn('houses', 'guild')) - $type = 'all'; + $type = isset($_POST['type']) ? $_POST['type'] : NULL; + if($type == 'guildhalls' && !$db->hasColumn('houses', 'guild')) + $type = 'all'; if (!empty($type) && $type != 'all') { @@ -158,49 +158,49 @@ if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order']) && } } - $houses_info = $db->query('SELECT * FROM `houses` WHERE ' . $whereby. ' ORDER BY ' . $orderby); + $houses_info = $db->query('SELECT * FROM `houses` WHERE ' . $whereby. ' ORDER BY ' . $orderby); - $players_info = $db->query("SELECT `houses`.`id` AS `houseid` , `players`.`name` AS `ownername` FROM `houses` , `players` , `accounts` WHERE `players`.`id` = `houses`.`owner` AND `accounts`.`id` = `players`.`account_id`"); - $players = array(); - foreach($players_info->fetchAll() as $player) - $players[$player['houseid']] = array('name' => $player['ownername']); + $players_info = $db->query("SELECT `houses`.`id` AS `houseid` , `players`.`name` AS `ownername` FROM `houses` , `players` , `accounts` WHERE `players`.`id` = `houses`.`owner` AND `accounts`.`id` = `players`.`account_id`"); + $players = array(); + foreach($players_info->fetchAll() as $player) + $players[$player['houseid']] = array('name' => $player['ownername']); - $houses = array(); - foreach($houses_info->fetchAll() as $house) - { - $owner = isset($players[$house['id']]) ? $players[$house['id']] : array(); + $houses = array(); + foreach($houses_info->fetchAll() as $house) + { + $owner = isset($players[$house['id']]) ? $players[$house['id']] : array(); - $houseRent = null; - if($db->hasColumn('houses', 'guild') && $house['guild'] == 1 && $house['owner'] != 0) - { - $guild = new OTS_Guild(); - $guild->load($house['owner']); - $houseRent = 'Rented by ' . getGuildLink($guild->getName()); - } - else - { - if(!empty($owner['name'])) - $houseRent = 'Rented by ' . getPlayerLink($owner['name']); - else - $houseRent = 'Free'; - } + $houseRent = null; + if($db->hasColumn('houses', 'guild') && $house['guild'] == 1 && $house['owner'] != 0) + { + $guild = new OTS_Guild(); + $guild->load($house['owner']); + $houseRent = 'Rented by ' . getGuildLink($guild->getName()); + } + else + { + if(!empty($owner['name'])) + $houseRent = 'Rented by ' . getPlayerLink($owner['name']); + else + $houseRent = 'Free'; + } - $houses[] = array('owner' => $owner, 'name' => $house['name'], 'size' => $house['size'], 'rent' => $house['rent'], 'rentedBy' => $houseRent); - } + $houses[] = array('owner' => $owner, 'name' => $house['name'], 'size' => $house['size'], 'rent' => $house['rent'], 'rentedBy' => $houseRent); + } - $housesSearch = true; + $housesSearch = true; } $guild = $db->hasColumn('houses', 'guild') ? ' or guildhall' : ''; $twig->display('houses.html.twig', array( - 'state' => $state, - 'order' => $order, - 'type' => $type, - 'houseType' => $type == 'guildhalls' ? 'Guildhalls' : 'Houses and Flats', - 'townName' => isset($townName) ? $townName : null, - 'townId' => isset($_POST['town']) ? $_POST['town'] : null, - 'guild' => $guild, - 'cleanOldHouse' => isset($cleanOld) ? $cleanOld : null, - 'housesSearch' => $housesSearch, - 'houses' => isset($houses) ? $houses : null -)); \ No newline at end of file + 'state' => $state, + 'order' => $order, + 'type' => $type, + 'houseType' => $type == 'guildhalls' ? 'Guildhalls' : 'Houses and Flats', + 'townName' => isset($townName) ? $townName : null, + 'townId' => isset($_POST['town']) ? $_POST['town'] : null, + 'guild' => $guild, + 'cleanOldHouse' => isset($cleanOld) ? $cleanOld : null, + 'housesSearch' => $housesSearch, + 'houses' => isset($houses) ? $houses : null +)); diff --git a/system/templates/houses.html.twig b/system/templates/houses.html.twig index 4e75942c..20e8926d 100644 --- a/system/templates/houses.html.twig +++ b/system/templates/houses.html.twig @@ -1,171 +1,171 @@
- {% if errors is not empty %} - {% for error in errors %} -

{{ error }}

- {% endfor %} - {% else %} - -
-
- - - - -
House Search
- - - - -
-
+ {% if errors is not empty %} + {% for error in errors %} +

{{ error }}

+ {% endfor %} + {% else %} +
+
+
+ + + + +
House Search
+ + + + +
+
- - + + + {% endfor %} + {% endif %} + +
-
- Here you can see the list of all available houses, flats{{ guildString }}. - Click on any view button to get more information about a house or adjust - the search criteria and start a new search. -

- {% if cleanOldHouse is not empty or rentType != 'never' %} - Every morning during global server save there is automatic house cleaning. Server delete house owners who have not logged in last {{ cleanOldHouse }} days{% if rentType != 'never' %} or have not paid {{ rentType }} house rent. Remember to leave money for a rent in {% if config.lua.bankSystem is not empty %}your house bank or {% else %}depo in same city where you have house!{% endif %}{% else %}.{% endif %} -

- {% endif %} +
+
+ Here you can see the list of all available houses, flats{{ guildString }}. + Click on any view button to get more information about a house or adjust + the search criteria and start a new search. +

+ {% if cleanOldHouse is not empty or rentType != 'never' %} + Every morning during global server save there is automatic house cleaning. Server delete house owners who have not logged in last {{ cleanOldHouse }} days{% if rentType != 'never' %} or have not paid {{ rentType }} house rent. Remember to leave money for a rent in {% if config.lua.bankSystem is not empty %}your house bank or {% else %}depo in same city where you have house!{% endif %}{% else %}.{% endif %} +

+ {% endif %} - {% if houses is not empty or housesSearch %} - - - - - + {% if houses is not empty or housesSearch %} +
Available {{ houseType }}{% if townName is not empty %} in {{ townName }}{% endif %} on {{ config.lua.serverName }}
+ + + + - - {% if houses is not empty %} - - - + + {% if houses is not empty %} + + + - - - {% elseif housesSearch %} - - {% endif %} - + + + {% elseif housesSearch %} + + {% endif %} + - {% if houses is not empty %} - {% set i = 0 %} - {% for house in houses %} - {% set i = i + 1 %} - - + {% if houses is not empty %} + {% set i = 0 %} + {% for house in houses %} + {% set i = i + 1 %} + + - + - + - + - - - {% endfor %} - {% endif %} - -
Available {{ houseType }}{% if townName is not empty %} in {{ townName }}{% endif %} on {{ config.lua.serverName }}
NameSizeRent
NameSizeRentStatus No {{ houseType }} with specified criterias.
Status No {{ houseType }} with specified criterias.
- {{ house.name }} -
+ {{ house.name }} + - {{ house.size }} - + {{ house.size }} + - {{ house.rent }} golds - + {{ house.rent }} golds + - {{ house.rentedBy|raw }} - + {{ house.rentedBy|raw }} + -
- - {{ include('buttons.view.html.twig') }} -
-
-
- {% endif %} +
+
+ + {{ include('buttons.view.html.twig') }} +
+
+
+ {% endif %} -
- - - - - + +
House Search
+ + + + - - - - - + + + + + - - + + + +
+ {% endfor %} + - + +
+ - - + +
+ + - - - - -
House Search
TownStatusOrder
TownStatusOrder
- {% set checked = false %} - {% for id, name in config.towns if id > 0 %} - {% if ((townId is empty and name is not empty) or id == townId) and not checked %} - {% set variable = "checked" %} - {% set checked = true %} - {% else %} - {% set variable = "" %} - {% endif %} +
+ {% set checked = false %} + {% for id, name in config.towns if id > 0 %} + {% if ((townId is empty and name is not empty) or id == townId) and not checked %} + {% set variable = "checked" %} + {% set checked = true %} + {% else %} + {% set variable = "" %} + {% endif %} - - -
- {% endfor %} -
- -
+
+ +
- -
+ +
- -
-
- -
+
+ +
- -
+ +
- -
-
- -
- -
- -
-
-
+ + + +
+ +
+ +
+ + + + +
- - - - - - -
- {{ include('buttons.submit.html.twig') }} -
-
-
- - - - {% endif %} - \ No newline at end of file + + + + + + +
+ {{ include('buttons.submit.html.twig') }} +
+ + + + + + {% endif %} + diff --git a/system/templates/houses.view.html.twig b/system/templates/houses.view.html.twig index 31fc5c23..64baad76 100644 --- a/system/templates/houses.view.html.twig +++ b/system/templates/houses.view.html.twig @@ -1,51 +1,51 @@
- {% if errors is not empty %} - {% for error in errors %} -

{{ error }}

- {% endfor %} - {% else %} - -
-
- - - - -
{{ houseName }}
- - - - -
-
+ {% if errors is not empty %} + {% for error in errors %} +

{{ error }}

+ {% endfor %} + {% else %} +
+
+
+ + + + +
{{ houseName }}
+ + + + +
+
- - + +
-
- - - - + - -
- {{ bedsMessage }} and has a size of {{ houseSize }} square meters. +
+
+ + + + - -
+ {{ bedsMessage }} and has a size of {{ houseSize }} square meters. - {% if rentType != 'never' %} - The {{ rentType }} is {{ houseRent }} gold and will be debited to the bank account on {{ config.lua.serverName }}. - {% endif %} -
+ {% if rentType != 'never' %} + The {{ rentType }} is {{ houseRent }} gold and will be debited to the bank account on {{ config.lua.serverName }}. + {% endif %} +
- {% if owner is not empty %} - The house has been rented by {{ owner|raw }}. - {% else %} - No one has bought this house yet. - {% endif %} -
-
-
- {% endif %} + {% if owner is not empty %} + The house has been rented by {{ owner|raw }}. + {% else %} + No one has bought this house yet. + {% endif %} +
+
+ + + + {% endif %} -

\ No newline at end of file +