From b8c287592398d116045e22780ab4b0bbf354bf4d Mon Sep 17 00:00:00 2001 From: Aries De Los Santos Date: Wed, 20 Jun 2018 08:18:47 +0800 Subject: [PATCH] Added page for listing vending items --- config/access.php | 1 + config/application.php | 1 + modules/vending/items.php | 92 ++++++++++++++++++++ themes/default/vending/items.php | 141 +++++++++++++++++++++++++++++++ 4 files changed, 235 insertions(+) create mode 100644 modules/vending/items.php create mode 100644 themes/default/vending/items.php diff --git a/config/access.php b/config/access.php index 4392f242..7f581afe 100644 --- a/config/access.php +++ b/config/access.php @@ -200,6 +200,7 @@ 'vending' => array( 'index' => AccountLevel::ANYONE, 'viewshop' => AccountLevel::ANYONE, + 'items' => AccountLevel::ANYONE, ), 'webcommands' => array( 'index' => AccountLevel::ADMIN, diff --git a/config/application.php b/config/application.php index 5972607d..89f82a10 100644 --- a/config/application.php +++ b/config/application.php @@ -395,6 +395,7 @@ 'vending' => array( 'index' => 'Vendors', + 'items' => 'List Items', ), ), diff --git a/modules/vending/items.php b/modules/vending/items.php new file mode 100644 index 00000000..1548f2f2 --- /dev/null +++ b/modules/vending/items.php @@ -0,0 +1,92 @@ +isRenewal) { + $fromTables = array("{$server->charMapDatabase}.item_db_re", "{$server->charMapDatabase}.item_db2_re"); + } else { + $fromTables = array("{$server->charMapDatabase}.item_db", "{$server->charMapDatabase}.item_db2"); + } + $itemDB = "{$server->charMapDatabase}.items"; + $tempTable = new Flux_TemporaryTable($server->connection, $itemDB, $fromTables); + + $bind = array(); + $sqlpartial = "WHERE 1=1 "; + $itemName = $params->get('name'); + + if ($itemName) { + $sqlpartial .= "AND (i.name_japanese LIKE ? OR i.name_japanese = ?) "; + $bind[] = "%$itemName%"; + $bind[] = $itemName; + } + + $sql = "SELECT COUNT(vending_id) AS total FROM vending_items AS vi " + . "LEFT JOIN cart_inventory AS ci on ci.id = vi.cartinventory_id " + . "LEFT JOIN items i ON i.id = ci.nameid "; + $sth = $server->connection->getStatement("$sql $sqlpartial"); + $sth->execute($bind); + $paginator = $this->getPaginator($sth->fetch()->total); + + $sortable = array('title' => 'asc', 'merchant', 'item_name'); + $paginator->setSortableColumns($sortable); + + $cols = "i.name_japanese AS item_name, i.slots, i.type" + . ", vi.cartinventory_id, vi.amount, vi.price" + . ", v.title, v.map, v.x, v.y, v.id AS shop_id, char.name AS merchant" + . ", ci.nameid AS item_id, ci.refine, ci.card0, ci.card1, ci.card2, ci.card3"; + $sql = "SELECT $cols FROM vending_items AS vi " + . "LEFT JOIN cart_inventory AS ci on vi.cartinventory_id = ci.id " + . "LEFT JOIN vendings AS v ON v.id = vi.vending_id " + . "LEFT JOIN `char` ON `char`.char_id = v.char_id " + . "LEFT JOIN items AS i ON i.id = ci.nameid "; + $sql = $paginator->getSQL("$sql $sqlpartial"); + $sth = $server->connection->getStatement($sql); + $sth->execute($bind); + $items = $sth->fetchAll(); + + $cards = array(); + $itemAttributes = Flux::config('Attributes')->toArray(); + if ($items) { + $cardIDs = array(); + + foreach ($items as $item) { + $item->cardsOver = -$item->slots; + + for ($n = 0; $n <= 3; $n++) { + $idx = "card$n"; + if ($item->$idx) { + if (!in_array($item->$idx, $cardIDs)) { + $cardIDs[] = $item->$idx; + } + $item->cardsOver++; + } + } + + if ($item->card0 == 254 || $item->card0 == 255 || $item->card0 == -256 || $item->cardsOver < 0) { + $item->cardsOver = 0; + } + } + + if ($cardIDs) { + $ids = implode(',', array_fill(0, count($cardIDs), '?')); + $sql = "SELECT id, name_japanese FROM {$server->charMapDatabase}.items WHERE id IN ($ids)"; + $sth = $server->connection->getStatement($sql); + + $sth->execute($cardIDs); + $temp = $sth->fetchAll(); + if ($temp) { + foreach ($temp as $card) { + $cards[$card->id] = $card->name_japanese; + } + } + } + } +} catch (Exception $e) { + $items = array(); +} diff --git a/themes/default/vending/items.php b/themes/default/vending/items.php new file mode 100644 index 00000000..f893cd1b --- /dev/null +++ b/themes/default/vending/items.php @@ -0,0 +1,141 @@ + +

+

Search...

+
+ moduleActionFormInputs($params->get('module'), $params->get('action')); ?> +

+ + + ... + + +

+
+ + infoText() ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
sortableColumn('title', 'Shop'); ?>sortableColumn('merchant', 'Merchant'); ?>PositionsortableColumn('item_name', 'Item Name'); ?>Card0Card1Card2Card3PriceAmount
+ $item->shop_id)); ?>">title; ?> + merchant; ?> + map, $item->x, $item->y); ?> + + iconImage($item->item_id)): ?> + + + refine > 0): ?> + +refine ?> + + + card0 == 255 && intval($item->card1 / 1280) > 0): ?> + card1/1280); ?> + + Very + + Strong + + + card0 == 254 || $item->card0 == 255): ?> + char_name): ?> + char_name . "'s") ?> + + 's + + + + card0 == 255 && array_key_exists($item->card1 % 1280, $itemAttributes)): ?> + card1 % 1280]) ?> + + actionAllowed('item', 'view')): ?> + $item->item_id)); ?>">item_name; ?> + + item_name ?> + + char_name): ?> + Of char_name ?> + + slots): ?> + slots . ']') ?> + + + card0 && ($item->type == 4 || $item->type == 5) && $item->card0 != 254 && $item->card0 != 255 && $item->card0 != -256): ?> + card0])): ?> + linkToItem($item->card0, $cards[$item->card0]) ?> + + linkToItem($item->card0, $item->card0) ?> + + + None + + + card1 && ($item->type == 4 || $item->type == 5) && $item->card0 != 255 && $item->card0 != -256): ?> + card1])): ?> + linkToItem($item->card1, $cards[$item->card1]) ?> + + linkToItem($item->card1, $item->card1) ?> + + + None + + + card2 && ($item->type == 4 || $item->type == 5) && $item->card0 != 254 && $item->card0 != 255 && $item->card0 != -256): ?> + card2])): ?> + linkToItem($item->card2, $cards[$item->card2]) ?> + + linkToItem($item->card2, $item->card2) ?> + + + None + + + card3 && ($item->type == 4 || $item->type == 5) && $item->card0 != 254 && $item->card0 != 255 && $item->card0 != -256): ?> + card3])): ?> + linkToItem($item->card3, $cards[$item->card3]) ?> + + linkToItem($item->card3, $item->card3) ?> + + + None + + + price, 0, ',', ' '); ?> z + + amount ?> +
+ getHTML() ?> + +

No Items found. Go back.

+ \ No newline at end of file