<?php require_once '/export/home/g2sn/enrlprc/html/kura/z-ap/ItemDto.php'; require_once '/export/home/g2sn/enrlprc/html/kura/z-ap/dao/ItemDao.php'; require_once '/export/home/g2sn/enrlprc/html/kura/z-ap/Util.php'; try { $dao = new ItemDao(); $item = new ItemDto(); $util = new Util(); $bcode = $_POST['code']; $item->setCode($bcode); $item->setName(""); $item->setPrice(0); $item->setQty(0); $item->setDetail(""); $items = array(); $items = $dao->getItem($item, 0, 0); } catch (Exception $e) { $error = $e->getMessage(); } header('Content-Type: text/html; charset=utf-8'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>変更情報入力</title> </head> <body> <?php if (isset($error)) {
require_once '/export/home/g2sn/enrlprc/html/kura/z-ap/dao/ItemDao.php'; require_once '/export/home/g2sn/enrlprc/html/kura/z-ap/Util.php'; try { $dao = new ItemDao(); $item = new ItemDto(); $util = new Util(); $code = $_POST['code']; $name = $_POST['name']; $price = $_POST['price']; $qty = $_POST['qty']; $detail = $_POST['detail']; $priCd = $_POST['priCd']; $qtyCd = $_POST['qtyCd']; $item->setCode($code); $item->setName($name); $item->setPrice($price); $item->setQty($qty); $item->setDetail($detail); $items = array(); $items = $dao->getItem($item, $priCd, $qtyCd); } catch (Exception $e) { $error = $e->getMessage(); } header('Content-Type: text/html; charset=utf-8'); ?> <!DOCTYPE html> <html> <head> <script type="text/javascript" src="../javascript/jquery/jquery-2.1.4.js"></script> <script type="text/javascript" src="zapp.js"></script>
/** * ItemDtoからテーブルitemをselect検索します。 * 在庫数qtyと値段priceは以上以下の選択ができます。 * * @param ItemDto $item * 検索するitemのオブジェクト * @param int $priCd * 値段コード、0=以上,1=以下 * @param int $qtyCd * 在庫数コード、0=以上,1=以下 */ public function getItem($item, $priCd, $qtyCd) { $code = $item->getCode(); if (empty($code)) { $code = '%'; } $name = $item->getName(); $price = $item->getPrice(); $detail = $item->getDetail(); $qty = $item->getQty(); $sql = 'select code, name, price, detail, qty from item where code like ? and name like ? '; switch ($priCd) { case 0: $sql .= 'and price >= ? '; break; case 1: $sql .= 'and price <= ? '; break; } switch ($qtyCd) { case 0: $sql .= 'and qty >= ? '; break; case 1: $sql .= 'and qty <= ? '; break; } if (!empty($detail)) { $sql .= 'and detail like ? '; } $stmt = $this->pdo->prepare($sql); $stmt->bindValue(1, $code, PDO::PARAM_INT); $stmt->bindValue(2, '%' . $this->esc_str($name) . '%', PDO::PARAM_STR); $stmt->bindValue(3, $price, PDO::PARAM_INT); $stmt->bindValue(4, $qty, PDO::PARAM_INT); $stmt->bindValue(5, '%' . $this->esc_str($detail) . '%', PDO::PARAM_STR); $stmt->execute(); $rItems = array(); foreach ($stmt as $row) { $rItem = new ItemDto(); $rItem->setCode($row['code']); $rItem->setName($row['name']); $rItem->setPrice($row['price']); $rItem->setDetail($row['detail']); $rItem->setQty($row['qty']); array_push($rItems, $rItem); } return $rItems; }